{"version":3,"file":"params.cjs","names":[],"sources":["../../src/utils/params.ts"],"sourcesContent":["import { AnthropicBeta } from \"@anthropic-ai/sdk/resources\";\n\nimport {\n  AnthropicInvocationParams,\n  AnthropicOutputConfig,\n  AnthropicThinkingConfigParam,\n} from \"../types.js\";\n\ntype InvocationCompatibilityFields = {\n  model?: string;\n  thinking: AnthropicThinkingConfigParam;\n  topK?: number;\n  topP?: number;\n  temperature?: number;\n};\n\nfunction isThinkingEnabled(thinking: AnthropicThinkingConfigParam): boolean {\n  return thinking.type === \"enabled\" || thinking.type === \"adaptive\";\n}\n\nexport function isOpus47Model(model?: string): boolean {\n  return model?.startsWith(\"claude-opus-4-7\") ?? false;\n}\n\nexport function getTaskBudgetBetas(\n  model?: string,\n  outputConfig?: AnthropicOutputConfig\n): AnthropicBeta[] {\n  const hasTaskBudget =\n    outputConfig &&\n    typeof outputConfig === \"object\" &&\n    \"task_budget\" in outputConfig &&\n    outputConfig.task_budget != null;\n\n  return isOpus47Model(model) && hasTaskBudget\n    ? ([\"task-budgets-2026-03-13\"] as AnthropicBeta[])\n    : [];\n}\n\nexport function validateInvocationParamCompatibility(\n  fields: InvocationCompatibilityFields\n): void {\n  const { model, thinking, topK, topP, temperature } = fields;\n  const opus47 = isOpus47Model(model);\n\n  if (opus47 && thinking.type === \"enabled\") {\n    throw new Error(\n      'thinking.type=\"enabled\" is not supported for claude-opus-4-7; use thinking.type=\"adaptive\" instead'\n    );\n  }\n  if (\n    opus47 &&\n    typeof thinking === \"object\" &&\n    thinking != null &&\n    \"budget_tokens\" in thinking\n  ) {\n    throw new Error(\n      \"thinking.budget_tokens is not supported for claude-opus-4-7; use outputConfig.effort instead\"\n    );\n  }\n  if (opus47) {\n    if (topK !== undefined) {\n      throw new Error(\n        \"topK is not supported for claude-opus-4-7; omit topK/topP/temperature or use model prompting instead\"\n      );\n    }\n    if (topP !== undefined && topP !== 1) {\n      throw new Error(\n        \"topP is not supported for claude-opus-4-7 when set to non-default values\"\n      );\n    }\n    if (temperature !== undefined && temperature !== 1) {\n      throw new Error(\n        \"temperature is not supported for claude-opus-4-7 when set to non-default values\"\n      );\n    }\n  }\n\n  if (isThinkingEnabled(thinking)) {\n    if (topK !== undefined) {\n      throw new Error(\"topK is not supported when thinking is enabled\");\n    }\n    if (topP !== undefined) {\n      throw new Error(\"topP is not supported when thinking is enabled\");\n    }\n    if (temperature !== undefined && temperature !== 1) {\n      throw new Error(\"temperature is not supported when thinking is enabled\");\n    }\n  }\n}\n\nexport function getSamplingParams(\n  fields: InvocationCompatibilityFields\n): Pick<AnthropicInvocationParams, \"temperature\" | \"top_k\" | \"top_p\"> {\n  const { model, thinking, topK, topP, temperature } = fields;\n  const output: Pick<\n    AnthropicInvocationParams,\n    \"temperature\" | \"top_k\" | \"top_p\"\n  > = {};\n\n  if (isThinkingEnabled(thinking) || isOpus47Model(model)) {\n    return output;\n  }\n\n  if (temperature !== undefined) {\n    output.temperature = temperature;\n  }\n  if (topK !== undefined) {\n    output.top_k = topK;\n  }\n  if (topP !== undefined) {\n    output.top_p = topP;\n  }\n\n  return output;\n}\n"],"mappings":";AAgBA,SAAS,kBAAkB,UAAiD;AAC1E,QAAO,SAAS,SAAS,aAAa,SAAS,SAAS;;AAG1D,SAAgB,cAAc,OAAyB;AACrD,QAAO,OAAO,WAAW,kBAAkB,IAAI;;AAGjD,SAAgB,mBACd,OACA,cACiB;CACjB,MAAM,gBACJ,gBACA,OAAO,iBAAiB,YACxB,iBAAiB,gBACjB,aAAa,eAAe;AAE9B,QAAO,cAAc,MAAM,IAAI,gBAC1B,CAAC,0BAA0B,GAC5B,EAAE;;AAGR,SAAgB,qCACd,QACM;CACN,MAAM,EAAE,OAAO,UAAU,MAAM,MAAM,gBAAgB;CACrD,MAAM,SAAS,cAAc,MAAM;AAEnC,KAAI,UAAU,SAAS,SAAS,UAC9B,OAAM,IAAI,MACR,yGACD;AAEH,KACE,UACA,OAAO,aAAa,YACpB,YAAY,QACZ,mBAAmB,SAEnB,OAAM,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