import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);

// src/adapters/claude/session/models.ts
var DEFAULT_MODEL = "opus";
var FALLBACK_MODEL = "claude-opus-4-8";
var DEFAULT_EFFORT = "high";
var GATEWAY_TO_SDK_MODEL = {
  "claude-opus-4-7": "opus",
  "claude-opus-4-8": "opus",
  "claude-sonnet-4-6": "sonnet"
};
function toSdkModelId(modelId) {
  return GATEWAY_TO_SDK_MODEL[modelId] ?? modelId;
}
var MODELS_WITH_1M_CONTEXT = /* @__PURE__ */ new Set([
  "claude-opus-4-7",
  "claude-opus-4-8",
  "claude-sonnet-4-6",
  "claude-sonnet-5",
  "claude-fable-5"
]);
function supports1MContext(modelId) {
  return MODELS_WITH_1M_CONTEXT.has(modelId);
}
var MODELS_WITH_EFFORT = /* @__PURE__ */ new Set([
  "claude-opus-4-7",
  "claude-opus-4-8",
  "claude-sonnet-4-6",
  "claude-sonnet-5",
  "claude-fable-5"
]);
var MODELS_WITH_XHIGH_EFFORT = /* @__PURE__ */ new Set([
  "claude-opus-4-7",
  "claude-opus-4-8",
  "claude-sonnet-5",
  "claude-fable-5"
]);
function supportsEffort(modelId) {
  return MODELS_WITH_EFFORT.has(modelId);
}
function resolveEffortForModel(modelId, effort) {
  if (effort) return effort;
  return supportsEffort(modelId) ? DEFAULT_EFFORT : void 0;
}
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);
}
var MODELS_WITH_FAST_MODE = /* @__PURE__ */ new Set(["claude-opus-4-7", "claude-opus-4-8"]);
function supportsFastMode(modelId) {
  return MODELS_WITH_FAST_MODE.has(modelId);
}
function fastModeStateEnabled(state) {
  return state !== void 0 && state !== "off";
}
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 };
}
var MODEL_FAMILY_VERSION_PATTERN = /\b(\d+)(?:[-.](\d+))?\b/;
function extractModelFamilyVersion(s) {
  if (!s) return null;
  const match = s.replace(/\[\d+m\]/gi, "").match(MODEL_FAMILY_VERSION_PATTERN);
  if (!match) return null;
  return match[2] ? `${match[1]}.${match[2]}` : match[1];
}
function modelVersionsCompatible(preference, candidate) {
  const preferred = extractModelFamilyVersion(preference);
  if (!preferred) return true;
  const candidateVersion = extractModelFamilyVersion(candidate.value) ?? extractModelFamilyVersion(candidate.name) ?? extractModelFamilyVersion(candidate.description);
  if (!candidateVersion) return true;
  return preferred === candidateVersion;
}
function scoreModelMatch(model, tokens, contextHint) {
  const haystack = `${model.value} ${model.name ?? ""}`.toLowerCase();
  let score = 0;
  let nonHintMatched = false;
  for (const token of tokens) {
    if (haystack.includes(token)) {
      if (token !== contextHint) nonHintMatched = true;
      score += token === contextHint ? 3 : 1;
    }
  }
  if (contextHint && !nonHintMatched) return 0;
  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) => {
    if (!modelVersionsCompatible(trimmed, o)) return false;
    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) {
    if (!modelVersionsCompatible(trimmed, model)) continue;
    const score = scoreModelMatch(model, tokens, contextHint);
    if (0 < score && (!bestMatch || bestScore < score)) {
      bestMatch = model;
      bestScore = score;
    }
  }
  return bestMatch?.value ?? null;
}
export {
  DEFAULT_EFFORT,
  DEFAULT_MODEL,
  FALLBACK_MODEL,
  fastModeStateEnabled,
  getEffortOptions,
  resolveEffortForModel,
  resolveModelPreference,
  supports1MContext,
  supportsEffort,
  supportsFastMode,
  supportsMcpInjection,
  supportsXhighEffort,
  toSdkModelId
};
//# sourceMappingURL=models.js.map