// src/adapters/claude/session/models.ts
var DEFAULT_MODEL = "opus";
var GATEWAY_TO_SDK_MODEL = {
  "claude-opus-4-5": "opus",
  "claude-opus-4-6": "opus",
  "claude-opus-4-7": "opus",
  "claude-sonnet-4-5": "sonnet",
  "claude-sonnet-4-6": "sonnet",
  "claude-haiku-4-5": "haiku"
};
function toSdkModelId(modelId) {
  return GATEWAY_TO_SDK_MODEL[modelId] ?? modelId;
}
var MODELS_WITH_1M_CONTEXT = /* @__PURE__ */ new Set([
  "claude-opus-4-6",
  "claude-opus-4-7",
  "claude-sonnet-4-6"
]);
function supports1MContext(modelId) {
  return MODELS_WITH_1M_CONTEXT.has(modelId);
}
var MODELS_WITH_EFFORT = /* @__PURE__ */ new Set([
  "claude-opus-4-5",
  "claude-opus-4-6",
  "claude-opus-4-7",
  "claude-sonnet-4-6"
]);
var MODELS_WITH_XHIGH_EFFORT = /* @__PURE__ */ new Set([
  "claude-opus-4-6",
  "claude-opus-4-7"
]);
function supportsEffort(modelId) {
  return MODELS_WITH_EFFORT.has(modelId);
}
function supportsXhighEffort(modelId) {
  return MODELS_WITH_XHIGH_EFFORT.has(modelId);
}
var MODELS_TO_EXCLUDE_MCP_TOOLS = /* @__PURE__ */ new Set(["claude-haiku-4-5"]);
function supportsMcpInjection(modelId) {
  return !MODELS_TO_EXCLUDE_MCP_TOOLS.has(modelId);
}
function getEffortOptions(modelId) {
  if (!supportsEffort(modelId)) return null;
  const options = [
    { value: "low", name: "Low" },
    { value: "medium", name: "Medium" },
    { value: "high", name: "High" }
  ];
  if (supportsXhighEffort(modelId)) {
    options.push(
      { value: "xhigh", name: "Extra High" },
      { value: "max", name: "Max" }
    );
  }
  return options;
}
var MODEL_CONTEXT_HINT_PATTERN = /\[(\d+m)\]$/i;
function tokenizeModelPreference(model) {
  const lower = model.trim().toLowerCase();
  const contextHint = lower.match(MODEL_CONTEXT_HINT_PATTERN)?.[1]?.toLowerCase();
  const normalized = lower.replace(MODEL_CONTEXT_HINT_PATTERN, " $1 ");
  const rawTokens = normalized.split(/[^a-z0-9]+/).filter(Boolean);
  const tokens = rawTokens.map((token) => {
    if (token === "opusplan") return "opus";
    if (token === "best" || token === "default") return "";
    return token;
  }).filter((token) => token && token !== "claude").filter((token) => /[a-z]/.test(token) || token.endsWith("m"));
  return { tokens, contextHint };
}
function scoreModelMatch(model, tokens, contextHint) {
  const haystack = `${model.value} ${model.name ?? ""}`.toLowerCase();
  let score = 0;
  for (const token of tokens) {
    if (haystack.includes(token)) {
      score += token === contextHint ? 3 : 1;
    }
  }
  return score;
}
function resolveModelPreference(preference, options) {
  const trimmed = preference.trim();
  if (!trimmed) return null;
  const lower = trimmed.toLowerCase();
  const directMatch = options.find(
    (o) => o.value === trimmed || o.value.toLowerCase() === lower || o.name && o.name.toLowerCase() === lower
  );
  if (directMatch) return directMatch.value;
  const includesMatch = options.find((o) => {
    const value = o.value.toLowerCase();
    const display = (o.name ?? "").toLowerCase();
    return value.includes(lower) || display.includes(lower) || lower.includes(value);
  });
  if (includesMatch) return includesMatch.value;
  const { tokens, contextHint } = tokenizeModelPreference(trimmed);
  if (tokens.length === 0) return null;
  let bestMatch = null;
  let bestScore = 0;
  for (const model of options) {
    const score = scoreModelMatch(model, tokens, contextHint);
    if (0 < score && (!bestMatch || bestScore < score)) {
      bestMatch = model;
      bestScore = score;
    }
  }
  return bestMatch?.value ?? null;
}
export {
  DEFAULT_MODEL,
  getEffortOptions,
  resolveModelPreference,
  supports1MContext,
  supportsEffort,
  supportsMcpInjection,
  supportsXhighEffort,
  toSdkModelId
};
//# sourceMappingURL=models.js.map