// src/harness/index.ts
import {
  harnessSupportsModel,
  modelProvider,
  preferredHarnessForModel,
  snapHarnessToModel as aiSnapHarnessToModel,
  snapModelToHarness as aiSnapModelToHarness
} from "@tangle-network/agent-interface";
var KNOWN_HARNESSES = [
  "opencode",
  "claude-code",
  "kimi-code",
  "codex",
  "amp",
  "factory-droids",
  "pi",
  "hermes",
  "forge",
  "openclaw",
  "acp",
  "cursor",
  "cli-base"
];
var DEFAULT_HARNESS = "opencode";
var HARNESS_SET = new Set(KNOWN_HARNESSES);
function isHarness(value) {
  return typeof value === "string" && HARNESS_SET.has(value);
}
function coerceHarness(value, fallback = DEFAULT_HARNESS) {
  return isHarness(value) ? value : fallback;
}
function resolveSessionHarness(input = {}) {
  const fallback = input.fallback ?? DEFAULT_HARNESS;
  if (isHarness(input.sessionHarness)) {
    const locked = input.sessionHarness;
    const swapAttempted = isHarness(input.requested) && input.requested !== locked;
    return { harness: locked, locked: true, swapAttempted };
  }
  const harness = coerceHarness(input.requested, coerceHarness(input.workspaceDefault, fallback));
  return { harness, locked: false, swapAttempted: false };
}
function isModelCompatibleWithHarness(harness, modelId) {
  return harnessSupportsModel(harness, modelId);
}
function snapModelToHarness(harness, modelId, canonicalIds) {
  return aiSnapModelToHarness(harness, modelId, canonicalIds);
}
function snapHarnessToModel(harness, modelId) {
  return aiSnapHarnessToModel(harness, modelId);
}
function assertHarnessModelCompatible(harness, modelId) {
  if (!isModelCompatibleWithHarness(harness, modelId)) {
    const provider = modelProvider(modelId);
    const native = preferredHarnessForModel(modelId);
    throw new Error(
      `Harness "${harness}" cannot run model "${modelId}" (provider "${provider}"). Use ${native ?? "a router-backed harness (opencode)"} or an allowed model.`
    );
  }
}

export {
  modelProvider,
  KNOWN_HARNESSES,
  DEFAULT_HARNESS,
  isHarness,
  coerceHarness,
  resolveSessionHarness,
  isModelCompatibleWithHarness,
  snapModelToHarness,
  snapHarnessToModel,
  assertHarnessModelCompatible
};
//# sourceMappingURL=chunk-E7QYOOON.js.map