eve 0.76.3 → 0.78.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/src/channel/adapter.d.ts +13 -4
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/send-input.d.ts +6 -2
- package/dist/src/channel/send-input.js +1 -1
- package/dist/src/channel/session.js +1 -1
- package/dist/src/chunks/{use-eve-agent-BtKWTEpm.js → use-eve-agent-B8brxCk-.js} +46 -28
- package/dist/src/chunks/{use-eve-agent-jI6EsYAu.js → use-eve-agent-BSYe_Re7.js} +46 -28
- package/dist/src/cli/commands/vercel-non-interactive.d.ts +5 -3
- package/dist/src/cli/commands/vercel-non-interactive.js +1 -1
- package/dist/src/client/eve-agent-store.d.ts +2 -2
- package/dist/src/client/message-response.d.ts +2 -0
- package/dist/src/client/message-response.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +9 -9
- package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +6 -1
- package/dist/src/compiled/@ai-sdk/anthropic/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/google/index.d.ts +16 -3
- package/dist/src/compiled/@ai-sdk/google/index.js +6 -6
- package/dist/src/compiled/@ai-sdk/mcp/index.d.ts +681 -348
- package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/openai/index.d.ts +56 -42
- package/dist/src/compiled/@ai-sdk/openai/index.js +5 -3
- package/dist/src/compiled/@ai-sdk/otel/index.js +3 -3
- package/dist/src/compiled/@ai-sdk/provider/index.d.ts +49 -15
- package/dist/src/compiled/@ai-sdk/provider/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/provider-utils/index.d.ts +4 -1
- package/dist/src/compiled/_chunks/workflow/{dist-DXLdlucM.js → dist-C8k3N3BQ.js} +2 -4
- package/dist/src/compiled/_chunks/workflow/dist-DsNhwdzf.js +1 -0
- package/dist/src/compiled/_chunks/workflow/experimental-decision-DlvnsBD-.js +3 -0
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/context/dynamic-model-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +16 -0
- package/dist/src/context/keys.js +1 -1
- package/dist/src/evals/judge.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/types.d.ts +14 -1
- package/dist/src/execution/agent-sessions/steps.d.ts +2 -0
- package/dist/src/execution/agent-sessions/steps.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.js +1 -1
- package/dist/src/execution/catalog/connection-entry.js +1 -1
- package/dist/src/execution/catalog/search.js +1 -1
- package/dist/src/execution/catalog/step-catalog.d.ts +12 -3
- package/dist/src/execution/catalog/step-catalog.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +1 -2
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/publish-session-events.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-container.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/sandbox/read-file.d.ts +5 -5
- package/dist/src/execution/sandbox/read-file.js +2 -2
- package/dist/src/execution/sandbox/session.d.ts +6 -0
- package/dist/src/execution/sandbox/session.js +2 -2
- package/dist/src/execution/session/active-turn.d.ts +9 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/checkpoint-migrations.js +1 -1
- package/dist/src/execution/session/end-sandbox-step.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +1 -1
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/next-input.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn.d.ts +11 -4
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-inbox/inbox.d.ts +3 -0
- package/dist/src/execution/session-inbox/inbox.js +1 -1
- package/dist/src/execution/session-workflow-tool-run.d.ts +14 -12
- package/dist/src/execution/session-workflow-tool-run.js +1 -1
- package/dist/src/execution/tasks/start.d.ts +14 -1
- package/dist/src/execution/tasks/start.js +1 -1
- package/dist/src/execution/tasks/steps.d.ts +7 -4
- package/dist/src/execution/tasks/steps.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/workflow/apply-run-messages-step.d.ts +20 -0
- package/dist/src/execution/tools/workflow/apply-run-messages-step.js +1 -0
- package/dist/src/execution/tools/workflow/ask.d.ts +0 -1
- package/dist/src/execution/tools/workflow/ask.js +1 -1
- package/dist/src/execution/tools/workflow/interrupt.d.ts +5 -2
- package/dist/src/execution/tools/workflow/interrupt.js +1 -1
- package/dist/src/execution/tools/workflow/messages.d.ts +14 -0
- package/dist/src/execution/tools/workflow/messages.js +1 -1
- package/dist/src/execution/tools/workflow/owner.d.ts +18 -6
- package/dist/src/execution/tools/workflow/owner.js +1 -1
- package/dist/src/execution/tools/workflow/start.d.ts +10 -0
- package/dist/src/execution/tools/workflow/start.js +1 -1
- package/dist/src/execution/tools/workflow/step.js +1 -1
- package/dist/src/execution/tools/workflow/workflow-owner-blocking.d.ts +12 -0
- package/dist/src/execution/tools/workflow/workflow-owner-blocking.js +1 -1
- package/dist/src/execution/tools/workflow/workflow.js +1 -1
- package/dist/src/execution/web-fetch/request.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +18 -3
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/attachment-staging.d.ts +13 -12
- package/dist/src/harness/attachment-staging.js +1 -1
- package/dist/src/harness/compaction/step.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/hitl/approvals.d.ts +4 -7
- package/dist/src/harness/hitl/approvals.js +1 -1
- package/dist/src/harness/hitl/approved-calls.d.ts +11 -0
- package/dist/src/harness/hitl/approved-calls.js +1 -1
- package/dist/src/harness/hitl/candidates.d.ts +0 -4
- package/dist/src/harness/hitl/candidates.js +1 -1
- package/dist/src/harness/hitl/delivery.d.ts +0 -1
- package/dist/src/harness/hitl/delivery.js +1 -1
- package/dist/src/harness/hitl/index.d.ts +2 -2
- package/dist/src/harness/hitl/index.js +1 -1
- package/dist/src/harness/hitl/intake.d.ts +2 -2
- package/dist/src/harness/hitl/intake.js +1 -1
- package/dist/src/harness/model-call/call.js +1 -1
- package/dist/src/harness/model-call/errors.d.ts +10 -0
- package/dist/src/harness/model-call/errors.js +1 -1
- package/dist/src/harness/model-call/run.js +1 -1
- package/dist/src/harness/session-machine/state.d.ts +0 -2
- package/dist/src/harness/session-machine/transitions.js +1 -1
- package/dist/src/harness/session-machine/view.d.ts +0 -3
- package/dist/src/harness/session-machine/view.js +1 -1
- package/dist/src/harness/step/after-model.js +1 -1
- package/dist/src/harness/token-estimate.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/attachments/data.d.ts +29 -10
- package/dist/src/internal/attachments/data.js +1 -1
- package/dist/src/internal/attachments/errors.d.ts +2 -2
- package/dist/src/internal/attachments/media-metadata.d.ts +15 -0
- package/dist/src/internal/attachments/media-metadata.js +1 -1
- package/dist/src/internal/attachments/public-link.d.ts +5 -0
- package/dist/src/internal/attachments/public-link.js +1 -0
- package/dist/src/internal/attachments/sandbox-refs.d.ts +7 -6
- package/dist/src/internal/attachments/sandbox-refs.js +1 -1
- package/dist/src/internal/attachments/url-refs.js +1 -1
- package/dist/src/protocol/message.d.ts +7 -0
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/public/channels/attachment-error.d.ts +14 -0
- package/dist/src/public/channels/attachment-error.js +1 -0
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +1 -1
- package/dist/src/public/channels/discord/defaults.js +1 -1
- package/dist/src/public/channels/github/defaults.js +1 -1
- package/dist/src/public/channels/index.d.ts +2 -0
- package/dist/src/public/channels/index.js +1 -1
- package/dist/src/public/channels/linear/defaults.js +1 -1
- package/dist/src/public/channels/slack/api.d.ts +10 -0
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/approval-cards.js +1 -1
- package/dist/src/public/channels/slack/attachments.d.ts +29 -19
- package/dist/src/public/channels/slack/attachments.js +1 -1
- package/dist/src/public/channels/slack/defaults.js +1 -1
- package/dist/src/public/channels/slack/inbound.d.ts +6 -0
- package/dist/src/public/channels/slack/inbound.js +1 -1
- package/dist/src/public/channels/slack/interaction-cards.d.ts +6 -0
- package/dist/src/public/channels/slack/interaction-cards.js +1 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/defaults.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/defaults.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/channels/twilio/defaults.js +1 -1
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/runtime/channels/registry.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/update/web-options.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +2 -1
- package/dist/src/shared/channel-definition.d.ts +16 -4
- package/dist/src/svelte/index.d.ts +0 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/read-file.d.ts +3 -2
- package/dist/src/tools/provided/read-file.js +2 -2
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/vue/index.d.ts +0 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +12 -4
- package/docs/channels/chat-sdk.mdx +1 -1
- package/docs/channels/custom.mdx +30 -3
- package/docs/channels/eve.mdx +34 -0
- package/docs/channels/slack.mdx +5 -1
- package/docs/concepts/built-in-tools.md +10 -10
- package/docs/concepts/sessions-runs-and-streaming.md +2 -2
- package/docs/evals/overview.mdx +1 -1
- package/docs/guides/client/streaming.mdx +1 -1
- package/docs/guides/dynamic-capabilities.md +6 -2
- package/docs/memory/custom-provider.md +3 -1
- package/docs/sandbox/index.mdx +10 -4
- package/docs/tools/human-in-the-loop.md +1 -1
- package/docs/tools/overview.mdx +1 -1
- package/package.json +11 -11
- package/dist/src/compiled/_chunks/workflow/experimental-decision-BrfWf6-n.js +0 -3
- package/dist/src/context/caller-scope.d.ts +0 -7
- package/dist/src/context/caller-scope.js +0 -1
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +0 -13
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +0 -1
- package/dist/src/harness/hitl/approved-call-callers.d.ts +0 -14
- package/dist/src/harness/hitl/approved-call-callers.js +0 -1
- package/dist/src/internal/attachments/refs.d.ts +0 -55
- package/dist/src/internal/attachments/refs.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{APICallError as e,InvalidArgumentError as t,InvalidResponseDataError as n,NoSuchModelError as r,UnsupportedFunctionalityError as i}from"../provider/index.js";import{$ as a,Ct as o,E as s,F as c,H as l,J as u,L as d,P as f,S as p,St as m,T as h,U as g,V as _,X as v,Y as y,Z as b,_ as x,_t as S,a as C,bt as w,c as T,ct as E,d as D,et as O,ft as k,g as ee,it as A,l as j,lt as te,mt as M,nt as N,pt as P,q as F,rt as ne,s as I,st as L,v as re,vt as R,w as z,wt as B,y as V,z as ie}from"../../_chunks/workflow/dist-DXLdlucM.js";import{n as H,r as ae,t as oe}from"../../_chunks/workflow/experimental-decision-BrfWf6-n.js";import{z as U}from"#compiled/zod/index.js";const W=F(()=>B(U.object({type:U.literal(`error`),error:U.object({type:U.string(),message:U.string()})}))),G=x({errorSchema:W,errorToMessage:e=>e.error.message}),se=F(()=>B(U.object({id:U.string(),type:U.literal(`file`),filename:U.string(),mime_type:U.string(),size_bytes:U.number(),created_at:U.string(),downloadable:U.boolean().nullish()})));var K=class{get provider(){return this.config.provider}constructor(e){this.config=e,this.specificationVersion=`v4`}async uploadFile({data:e,mediaType:t,filename:n,abortSignal:r,headers:i}){let a=j(e),o=new Blob([a],{type:t}),s=new FormData;n==null?s.append(`file`,o):s.append(`file`,o,n);let{value:c}=await ne({url:`${this.config.baseURL}/files`,headers:C(this.config.headers(),{"anthropic-beta":`files-api-2025-04-14`},i),formData:s,failedResponseHandler:G,successfulResponseHandler:V(se),abortSignal:r,fetch:this.config.fetch});return{warnings:[],providerReference:{anthropic:c.id},mediaType:c.mime_type??t,filename:c.filename??n,providerMetadata:{anthropic:{filename:c.filename,mimeType:c.mime_type,sizeBytes:c.size_bytes,createdAt:c.created_at,...c.downloadable==null?{}:{downloadable:c.downloadable}}}}}};const ce=U.object({type:U.literal(`fallback`),from:U.object({model:U.string()}),to:U.object({model:U.string()})}),q=U.object({type:U.string(),category:U.string().nullish(),explanation:U.string().nullish(),recommended_model:U.string().nullish()}),J=U.object({type:U.string(),status:U.object({type:U.string(),tool_uses:U.record(U.string(),U.object({type:U.string(),outcome:U.string().nullish(),explanation:U.string().nullish()})).nullish()})}),Y=U.union([U.object({type:U.literal(`code_execution_20250825`),tool_id:U.string()}),U.object({type:U.literal(`code_execution_20260120`),tool_id:U.string()}),U.object({type:U.literal(`direct`)})]),X=U.discriminatedUnion(`type`,[U.object({type:U.literal(`web_search_result_location`),cited_text:U.string(),url:U.string(),title:U.string().nullable(),encrypted_index:U.string()}),U.object({type:U.literal(`page_location`),cited_text:U.string(),document_index:U.number(),document_title:U.string().nullable(),start_page_number:U.number(),end_page_number:U.number(),file_id:U.string().nullish()}),U.object({type:U.literal(`char_location`),cited_text:U.string(),document_index:U.number(),document_title:U.string().nullable(),start_char_index:U.number(),end_char_index:U.number(),file_id:U.string().nullish()}),U.object({type:U.literal(`content_block_location`),cited_text:U.string(),document_index:U.number(),document_title:U.string().nullable(),start_block_index:U.number(),end_block_index:U.number(),file_id:U.string().nullable()}),U.object({type:U.literal(`search_result_location`),cited_text:U.string(),search_result_index:U.number(),source:U.string(),title:U.string().nullable(),start_block_index:U.number(),end_block_index:U.number()})]),le=U.union([U.string(),U.array(U.union([U.string(),U.object({type:U.literal(`text`),text:U.string(),citations:U.array(U.json()).nullable().optional()})]))]),ue=U.object({type:U.string(),path:U.string(),reason:U.string()}),Z=F(()=>B(U.object({type:U.literal(`message`),id:U.string().nullish(),model:U.string().nullish(),content:U.array(U.discriminatedUnion(`type`,[U.object({type:U.literal(`text`),text:U.string(),citations:U.array(X).nullable().optional()}),U.object({type:U.literal(`thinking`),thinking:U.string(),signature:U.string()}),U.object({type:U.literal(`redacted_thinking`),data:U.string()}),U.object({type:U.literal(`compaction`),content:U.string().nullish(),signature:U.string().nullish()}),U.object({type:U.literal(`tool_use`),id:U.string(),name:U.string(),input:U.unknown(),caller:Y.optional(),toolset_name:U.string().nullish()}),U.object({type:U.literal(`server_tool_use`),id:U.string(),name:U.string(),input:U.record(U.string(),U.unknown()).nullish(),caller:Y.optional()}),U.object({type:U.literal(`mcp_tool_use`),id:U.string(),name:U.string(),input:U.unknown(),server_name:U.string()}),U.object({type:U.literal(`mcp_tool_result`),tool_use_id:U.string(),is_error:U.boolean(),content:le}),U.object({type:U.literal(`web_fetch_tool_result`),tool_use_id:U.string(),caller:Y.optional(),content:U.union([U.object({type:U.literal(`web_fetch_result`),url:U.string(),retrieved_at:U.string().nullable(),content:U.object({type:U.literal(`document`),title:U.string().nullable(),citations:U.object({enabled:U.boolean()}).optional(),source:U.union([U.object({type:U.literal(`base64`),media_type:U.literal(`application/pdf`),data:U.string()}),U.object({type:U.literal(`text`),media_type:U.literal(`text/plain`),data:U.string()})])})}),U.object({type:U.literal(`web_fetch_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`web_search_tool_result`),tool_use_id:U.string(),caller:Y.optional(),content:U.union([U.array(U.object({type:U.literal(`web_search_result`),url:U.string(),title:U.string().nullable(),encrypted_content:U.string(),page_age:U.string().nullish()})),U.object({type:U.literal(`web_search_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`code_execution_tool_result`),tool_use_id:U.string(),content:U.union([U.object({type:U.literal(`code_execution_result`),stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`encrypted_code_execution_result`),encrypted_stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`code_execution_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`bash_code_execution_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`bash_code_execution_result`),content:U.array(U.object({type:U.literal(`bash_code_execution_output`),file_id:U.string()})),stdout:U.string(),stderr:U.string(),return_code:U.number()}),U.object({type:U.literal(`bash_code_execution_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`text_editor_code_execution_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`text_editor_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_view_result`),content:U.string(),file_type:U.string(),num_lines:U.number().nullable(),start_line:U.number().nullable(),total_lines:U.number().nullable()}),U.object({type:U.literal(`text_editor_code_execution_create_result`),is_file_update:U.boolean()}),U.object({type:U.literal(`text_editor_code_execution_str_replace_result`),lines:U.array(U.string()).nullable(),new_lines:U.number().nullable(),new_start:U.number().nullable(),old_lines:U.number().nullable(),old_start:U.number().nullable()})])}),U.object({type:U.literal(`tool_search_tool_result`),tool_use_id:U.string(),content:U.union([U.object({type:U.literal(`tool_search_tool_search_result`),tool_references:U.array(U.object({type:U.literal(`tool_reference`),tool_name:U.string()}))}),U.object({type:U.literal(`tool_search_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`container_upload`),file_id:U.string()}),U.object({type:U.literal(`advisor_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`advisor_result`),text:U.string(),stop_reason:U.string().nullish()}),U.object({type:U.literal(`advisor_redacted_result`),encrypted_content:U.string(),stop_reason:U.string().nullish()}),U.object({type:U.literal(`advisor_tool_result_error`),error_code:U.string()})])}),ce])),stop_reason:U.string().nullish(),stop_sequence:U.string().nullish(),stop_details:q.nullish(),input_transformations:U.array(ue).nullish(),safeguard_results:U.array(J).nullish(),usage:U.looseObject({input_tokens:U.number(),output_tokens:U.number(),output_tokens_details:U.object({thinking_tokens:U.number().nullish()}).nullish(),cache_creation_input_tokens:U.number().nullish(),cache_read_input_tokens:U.number().nullish(),iterations:U.array(U.object({type:U.union([U.literal(`compaction`),U.literal(`message`),U.literal(`advisor_message`),U.literal(`fallback_message`)]),model:U.string().nullish(),input_tokens:U.number(),output_tokens:U.number(),cache_creation_input_tokens:U.number().nullish(),cache_read_input_tokens:U.number().nullish()})).nullish()}),container:U.object({expires_at:U.string(),id:U.string(),skills:U.array(U.object({type:U.union([U.literal(`anthropic`),U.literal(`custom`)]),skill_id:U.string(),version:U.string()})).nullish()}).nullish(),context_management:U.object({applied_edits:U.array(U.union([U.object({type:U.literal(`clear_tool_uses_20250919`),cleared_tool_uses:U.number(),cleared_input_tokens:U.number()}),U.object({type:U.literal(`clear_thinking_20251015`),cleared_thinking_turns:U.number(),cleared_input_tokens:U.number()}),U.object({type:U.literal(`compact_20260112`)})]))}).nullish()}))),de=F(()=>B(U.discriminatedUnion(`type`,[U.object({type:U.literal(`message_start`),message:U.object({id:U.string().nullish(),model:U.string().nullish(),role:U.string().nullish(),usage:U.looseObject({input_tokens:U.number(),cache_creation_input_tokens:U.number().nullish(),cache_read_input_tokens:U.number().nullish()}),content:U.array(U.discriminatedUnion(`type`,[U.object({type:U.literal(`tool_use`),id:U.string(),name:U.string(),input:U.unknown(),caller:Y.optional(),toolset_name:U.string().nullish()})])).nullish(),stop_reason:U.string().nullish(),input_transformations:U.array(ue).nullish(),container:U.object({expires_at:U.string(),id:U.string()}).nullish()})}),U.object({type:U.literal(`content_block_start`),index:U.number(),content_block:U.discriminatedUnion(`type`,[U.object({type:U.literal(`text`),text:U.string()}),U.object({type:U.literal(`thinking`),thinking:U.string()}),U.object({type:U.literal(`tool_use`),id:U.string(),name:U.string(),input:U.record(U.string(),U.unknown()).optional(),caller:Y.optional(),toolset_name:U.string().nullish()}),U.object({type:U.literal(`redacted_thinking`),data:U.string()}),U.object({type:U.literal(`compaction`),content:U.string().nullish(),signature:U.string().nullish()}),U.object({type:U.literal(`server_tool_use`),id:U.string(),name:U.string(),input:U.record(U.string(),U.unknown()).nullish(),caller:Y.optional()}),U.object({type:U.literal(`mcp_tool_use`),id:U.string(),name:U.string(),input:U.unknown(),server_name:U.string()}),U.object({type:U.literal(`mcp_tool_result`),tool_use_id:U.string(),is_error:U.boolean(),content:le}),U.object({type:U.literal(`web_fetch_tool_result`),tool_use_id:U.string(),caller:Y.optional(),content:U.union([U.object({type:U.literal(`web_fetch_result`),url:U.string(),retrieved_at:U.string().nullable(),content:U.object({type:U.literal(`document`),title:U.string().nullable(),citations:U.object({enabled:U.boolean()}).optional(),source:U.union([U.object({type:U.literal(`base64`),media_type:U.literal(`application/pdf`),data:U.string()}),U.object({type:U.literal(`text`),media_type:U.literal(`text/plain`),data:U.string()})])})}),U.object({type:U.literal(`web_fetch_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`web_search_tool_result`),tool_use_id:U.string(),caller:Y.optional(),content:U.union([U.array(U.object({type:U.literal(`web_search_result`),url:U.string(),title:U.string().nullable(),encrypted_content:U.string(),page_age:U.string().nullish()})),U.object({type:U.literal(`web_search_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`code_execution_tool_result`),tool_use_id:U.string(),content:U.union([U.object({type:U.literal(`code_execution_result`),stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`encrypted_code_execution_result`),encrypted_stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`code_execution_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`bash_code_execution_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`bash_code_execution_result`),content:U.array(U.object({type:U.literal(`bash_code_execution_output`),file_id:U.string()})),stdout:U.string(),stderr:U.string(),return_code:U.number()}),U.object({type:U.literal(`bash_code_execution_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`text_editor_code_execution_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`text_editor_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_view_result`),content:U.string(),file_type:U.string(),num_lines:U.number().nullable(),start_line:U.number().nullable(),total_lines:U.number().nullable()}),U.object({type:U.literal(`text_editor_code_execution_create_result`),is_file_update:U.boolean()}),U.object({type:U.literal(`text_editor_code_execution_str_replace_result`),lines:U.array(U.string()).nullable(),new_lines:U.number().nullable(),new_start:U.number().nullable(),old_lines:U.number().nullable(),old_start:U.number().nullable()})])}),U.object({type:U.literal(`tool_search_tool_result`),tool_use_id:U.string(),content:U.union([U.object({type:U.literal(`tool_search_tool_search_result`),tool_references:U.array(U.object({type:U.literal(`tool_reference`),tool_name:U.string()}))}),U.object({type:U.literal(`tool_search_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`advisor_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`advisor_result`),text:U.string(),stop_reason:U.string().nullish()}),U.object({type:U.literal(`advisor_redacted_result`),encrypted_content:U.string(),stop_reason:U.string().nullish()}),U.object({type:U.literal(`advisor_tool_result_error`),error_code:U.string()})])}),ce])}),U.object({type:U.literal(`content_block_delta`),index:U.number(),delta:U.discriminatedUnion(`type`,[U.object({type:U.literal(`input_json_delta`),partial_json:U.string()}),U.object({type:U.literal(`text_delta`),text:U.string()}),U.object({type:U.literal(`thinking_delta`),thinking:U.string()}),U.object({type:U.literal(`signature_delta`),signature:U.string()}),U.object({type:U.literal(`compaction_delta`),content:U.string().nullish()}),U.object({type:U.literal(`citations_delta`),citation:X})])}),U.object({type:U.literal(`content_block_stop`),index:U.number()}),U.object({type:U.literal(`error`),error:U.object({type:U.string(),message:U.string(),code:U.union([U.string(),U.number()]).nullish(),statusCode:U.number().nullish(),isRetryable:U.boolean().nullish(),data:U.unknown().nullish()})}),U.object({type:U.literal(`message_delta`),delta:U.object({stop_reason:U.string().nullish(),stop_sequence:U.string().nullish(),stop_details:q.nullish(),safeguard_results:U.array(J).nullish(),container:U.object({expires_at:U.string(),id:U.string(),skills:U.array(U.object({type:U.union([U.literal(`anthropic`),U.literal(`custom`)]),skill_id:U.string(),version:U.string()})).nullish()}).nullish()}),usage:U.looseObject({input_tokens:U.number().nullish(),output_tokens:U.number(),output_tokens_details:U.object({thinking_tokens:U.number().nullish()}).nullish(),cache_creation_input_tokens:U.number().nullish(),cache_read_input_tokens:U.number().nullish(),iterations:U.array(U.object({type:U.union([U.literal(`compaction`),U.literal(`message`),U.literal(`advisor_message`),U.literal(`fallback_message`)]),model:U.string().nullish(),input_tokens:U.number(),output_tokens:U.number(),cache_creation_input_tokens:U.number().nullish(),cache_read_input_tokens:U.number().nullish()})).nullish()}),input_transformations:U.array(ue).nullish(),context_management:U.object({applied_edits:U.array(U.union([U.object({type:U.literal(`clear_tool_uses_20250919`),cleared_tool_uses:U.number(),cleared_input_tokens:U.number()}),U.object({type:U.literal(`clear_thinking_20251015`),cleared_thinking_turns:U.number(),cleared_input_tokens:U.number()}),U.object({type:U.literal(`compact_20260112`)})]))}).nullish()}),U.object({type:U.literal(`message_stop`)}),U.object({type:U.literal(`ping`)})]))),fe=F(()=>B(U.object({signature:U.string().optional(),redactedData:U.string().optional()}))),pe=U.object({containerUpload:U.boolean().optional(),citations:U.object({enabled:U.boolean()}).optional(),title:U.string().optional(),context:U.string().optional()}),me=U.object({clearAt:U.literal(`next_user_message`).optional(),effort:U.enum([`low`,`medium`,`high`,`xhigh`,`max`]).optional(),toolChanges:U.array(U.discriminatedUnion(`type`,[U.object({type:U.literal(`tool_addition`),toolName:U.string()}),U.object({type:U.literal(`tool_removal`),toolName:U.string()})])).optional()}),he=U.object({sendReasoning:U.boolean().optional(),structuredOutputMode:U.enum([`outputFormat`,`jsonTool`,`auto`]).optional(),thinking:U.union([U.discriminatedUnion(`type`,[U.object({type:U.literal(`adaptive`),display:U.enum([`omitted`,`summarized`,`updates`]).optional(),blockBinding:U.object({prefixMismatchBehavior:U.enum([`error`,`drop_block`])}).optional()}),U.object({type:U.literal(`enabled`),budgetTokens:U.number().optional()}),U.object({type:U.literal(`disabled`)}),U.object({type:U.literal(`between_tools`)})]),U.object({type:U.never().optional(),blockBinding:U.object({prefixMismatchBehavior:U.enum([`error`,`drop_block`])})})]).optional(),disableParallelToolUse:U.boolean().optional(),cacheControl:U.object({type:U.literal(`ephemeral`),ttl:U.union([U.literal(`5m`),U.literal(`1h`)]).optional()}).optional(),metadata:U.object({userId:U.string().optional()}).optional(),mcpServers:U.array(U.object({type:U.literal(`url`),name:U.string(),url:U.string(),authorizationToken:U.string().nullish(),toolConfiguration:U.object({enabled:U.boolean().nullish(),allowedTools:U.array(U.string()).nullish()}).nullish()})).optional(),container:U.object({id:U.string().optional(),skills:U.array(U.discriminatedUnion(`type`,[U.object({type:U.literal(`anthropic`),skillId:U.string(),version:U.string().optional()}),U.object({type:U.literal(`custom`),providerReference:U.record(U.string(),U.string()),version:U.string().optional()})])).optional()}).optional(),toolStreaming:U.boolean().optional(),effort:U.enum([`low`,`medium`,`high`,`xhigh`,`max`]).optional(),taskBudget:U.object({type:U.literal(`tokens`),total:U.number().int().min(2e4),remaining:U.number().int().min(0).optional()}).optional(),speed:U.enum([`fast`,`standard`]).optional(),serviceTier:U.enum([`auto`,`standard_only`]).optional(),inferenceGeo:U.enum([`us`,`global`]).optional(),fallbacks:U.union([U.literal(`default`),U.array(U.object({model:U.string(),max_tokens:U.number().int().optional(),thinking:U.record(U.string(),U.unknown()).optional(),output_config:U.record(U.string(),U.unknown()).optional(),speed:U.enum([`fast`,`standard`]).optional()}))]).optional(),anthropicBeta:U.array(U.string()).optional(),safeguards:U.array(U.object({type:U.literal(`dangerous_tool_use`),classifierContext:U.record(U.string(),U.unknown()).optional()})).optional(),compaction:U.object({type:U.literal(`summarize`),instructions:U.string().optional()}).optional(),contextManagement:U.object({edits:U.array(U.discriminatedUnion(`type`,[U.object({type:U.literal(`clear_tool_uses_20250919`),trigger:U.discriminatedUnion(`type`,[U.object({type:U.literal(`input_tokens`),value:U.number()}),U.object({type:U.literal(`tool_uses`),value:U.number()})]).optional(),keep:U.object({type:U.literal(`tool_uses`),value:U.number()}).optional(),clearAtLeast:U.object({type:U.literal(`input_tokens`),value:U.number()}).optional(),clearToolInputs:U.boolean().optional(),excludeTools:U.array(U.string()).optional()}),U.object({type:U.literal(`clear_thinking_20251015`),keep:U.union([U.literal(`all`),U.object({type:U.literal(`thinking_turns`),value:U.number()})]).optional()}),U.object({type:U.literal(`compact_20260112`),trigger:U.object({type:U.literal(`input_tokens`),value:U.number()}).optional(),pauseAfterCompaction:U.boolean().optional(),instructions:U.string().optional()})]))}).optional()});function ge(e){let t=e?.anthropic;return t?.cacheControl??t?.cache_control}var _e=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(e,t){let n=ge(e);if(n){if(!t.canCache){this.warnings.push({type:`unsupported`,feature:`cache_control on non-cacheable context`,details:`cache_control cannot be set on ${t.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>4){this.warnings.push({type:`unsupported`,feature:`cacheControl breakpoint limit`,details:`Maximum 4 cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return n}}getWarnings(){return this.warnings}};const ve=F(()=>B(U.object({model:U.string(),maxUses:U.number().optional(),maxTokens:U.number().int().min(1024).optional(),caching:U.object({type:U.literal(`ephemeral`),ttl:U.union([U.literal(`5m`),U.literal(`1h`)])}).optional()}))),ye=F(()=>B(U.discriminatedUnion(`type`,[U.object({type:U.literal(`advisor_result`),text:U.string(),stopReason:U.string().optional()}),U.object({type:U.literal(`advisor_redacted_result`),encryptedContent:U.string(),stopReason:U.string().optional()}),U.object({type:U.literal(`advisor_tool_result_error`),errorCode:U.string()})]))),be=F(()=>B(U.object({}).strict())),xe=z({id:`anthropic.advisor_20260301`,inputSchema:be,outputSchema:ye,supportsDeferredResults:!0}),Se=e=>xe(e),Ce=[`screenshot`,`zoom`,`left_click`,`right_click`,`middle_click`,`double_click`,`triple_click`,`left_click_drag`,`mouse_move`,`left_mouse_down`,`left_mouse_up`,`cursor_position`,`scroll`,`type`,`key`,`hold_key`,`wait`],we=F(()=>B(U.object({action:U.enum(Ce),coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),duration:U.number().optional(),region:U.tuple([U.number().int(),U.number().int(),U.number().int(),U.number().int()]).optional(),repeat:U.number().int().optional(),scroll_amount:U.number().optional(),scroll_direction:U.enum([`up`,`down`,`left`,`right`]).optional(),start_coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),text:U.string().optional()}))),Te=F(()=>B(U.object({configs:U.partialRecord(U.enum(Ce),U.object({enabled:U.boolean().optional(),deferLoading:U.boolean().optional()})).optional()}))),Ee=p({id:`anthropic.computer_toolset_20260801`,inputSchema:we}),De=F(()=>B(U.object({maxCharacters:U.number().optional()}))),Oe=F(()=>B(U.object({command:U.enum([`view`,`create`,`str_replace`,`insert`]),path:U.string(),file_text:U.string().optional(),insert_line:U.number().int().optional(),new_str:U.string().optional(),insert_text:U.string().optional(),old_str:U.string().optional(),view_range:U.array(U.number().int()).optional()}))),ke=p({id:`anthropic.text_editor_20250728`,inputSchema:Oe}),Ae=(e={})=>ke(e),je=F(()=>B(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),userLocation:U.object({type:U.literal(`approximate`),city:U.string().optional(),region:U.string().optional(),country:U.string().optional(),timezone:U.string().optional()}).optional(),responseInclusion:U.enum([`full`,`excluded`]).optional()}))),Me=F(()=>B(U.array(U.object({url:U.string(),title:U.string().nullable(),pageAge:U.string().nullable(),encryptedContent:U.string(),type:U.literal(`web_search_result`)})))),Ne=F(()=>B(U.object({query:U.string()}))),Pe=z({id:`anthropic.web_search_20260318`,inputSchema:Ne,outputSchema:Me,supportsDeferredResults:!0}),Fe=(e={})=>Pe(e),Ie=F(()=>B(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),userLocation:U.object({type:U.literal(`approximate`),city:U.string().optional(),region:U.string().optional(),country:U.string().optional(),timezone:U.string().optional()}).optional()}))),Le=F(()=>B(U.array(U.object({url:U.string(),title:U.string().nullable(),pageAge:U.string().nullable(),encryptedContent:U.string(),type:U.literal(`web_search_result`)})))),Re=F(()=>B(U.object({query:U.string()}))),ze=z({id:`anthropic.web_search_20260209`,inputSchema:Re,outputSchema:Le,supportsDeferredResults:!0}),Be=(e={})=>ze(e),Ve=F(()=>B(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),userLocation:U.object({type:U.literal(`approximate`),city:U.string().optional(),region:U.string().optional(),country:U.string().optional(),timezone:U.string().optional()}).optional()}))),He=F(()=>B(U.array(U.object({url:U.string(),title:U.string().nullable(),pageAge:U.string().nullable(),encryptedContent:U.string(),type:U.literal(`web_search_result`)})))),Ue=F(()=>B(U.object({query:U.string()}))),We=z({id:`anthropic.web_search_20250305`,inputSchema:Ue,outputSchema:He,supportsDeferredResults:!0}),Ge=(e={})=>We(e),Ke=F(()=>B(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),citations:U.object({enabled:U.boolean()}).optional(),maxContentTokens:U.number().optional(),useCache:U.boolean().optional(),responseInclusion:U.enum([`full`,`excluded`]).optional()}))),qe=F(()=>B(U.object({type:U.literal(`web_fetch_result`),url:U.string(),content:U.object({type:U.literal(`document`),title:U.string().nullable(),citations:U.object({enabled:U.boolean()}).optional(),source:U.union([U.object({type:U.literal(`base64`),mediaType:U.literal(`application/pdf`),data:U.string()}),U.object({type:U.literal(`text`),mediaType:U.literal(`text/plain`),data:U.string()})])}),retrievedAt:U.string().nullable()}))),Je=F(()=>B(U.object({url:U.string()}))),Ye=z({id:`anthropic.web_fetch_20260318`,inputSchema:Je,outputSchema:qe,supportsDeferredResults:!0}),Xe=(e={})=>Ye(e),Ze=F(()=>B(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),citations:U.object({enabled:U.boolean()}).optional(),maxContentTokens:U.number().optional()}))),Qe=F(()=>B(U.object({type:U.literal(`web_fetch_result`),url:U.string(),content:U.object({type:U.literal(`document`),title:U.string().nullable(),citations:U.object({enabled:U.boolean()}).optional(),source:U.union([U.object({type:U.literal(`base64`),mediaType:U.literal(`application/pdf`),data:U.string()}),U.object({type:U.literal(`text`),mediaType:U.literal(`text/plain`),data:U.string()})])}),retrievedAt:U.string().nullable()}))),$e=F(()=>B(U.object({url:U.string()}))),et=z({id:`anthropic.web_fetch_20260209`,inputSchema:$e,outputSchema:Qe,supportsDeferredResults:!0}),tt=(e={})=>et(e),nt=F(()=>B(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),citations:U.object({enabled:U.boolean()}).optional(),maxContentTokens:U.number().optional()}))),rt=F(()=>B(U.object({type:U.literal(`web_fetch_result`),url:U.string(),content:U.object({type:U.literal(`document`),title:U.string().nullable(),citations:U.object({enabled:U.boolean()}).optional(),source:U.union([U.object({type:U.literal(`base64`),mediaType:U.literal(`application/pdf`),data:U.string()}),U.object({type:U.literal(`text`),mediaType:U.literal(`text/plain`),data:U.string()})])}),retrievedAt:U.string().nullable()}))),it=F(()=>B(U.object({url:U.string()}))),at=z({id:`anthropic.web_fetch_20250910`,inputSchema:it,outputSchema:rt,supportsDeferredResults:!0}),ot=(e={})=>at(e);async function st({tools:e,toolChoice:t,disableParallelToolUse:n,cacheControlValidator:r,supportsStructuredOutput:a,supportsStrictTools:o,defaultEagerInputStreaming:s=!1,rejectsForcedToolUse:c=!1}){e=e?.length?e:void 0;let l=[],u=new Set,d=r||new _e;if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:l,betas:u};let f=[];for(let t of e)switch(t.type){case`function`:{let e=d.getCacheControl(t.providerOptions,{type:`tool definition`,canCache:!0}),n=t.providerOptions?.anthropic,r=n?.eagerInputStreaming??s,i=n?.deferLoading,c=n?.allowedCallers;!o&&t.strict!=null&&l.push({type:`unsupported`,feature:`strict`,details:`Tool '${t.name}' has strict: ${t.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`}),f.push({name:t.name,description:t.description,input_schema:t.inputSchema,cache_control:e,...r?{eager_input_streaming:!0}:{},...o===!0&&t.strict!=null?{strict:t.strict}:{},...i==null?{}:{defer_loading:i},...c==null?{}:{allowed_callers:c},...t.inputExamples==null?{}:{input_examples:t.inputExamples.map(e=>e.input)}}),a===!0&&u.add(`structured-outputs-2025-11-13`),(t.inputExamples!=null||c!=null)&&u.add(`advanced-tool-use-2025-11-20`);break}case`provider`:switch(t.id){case`anthropic.code_execution_20250522`:u.add(`code-execution-2025-05-22`),f.push({type:`code_execution_20250522`,name:`code_execution`,cache_control:void 0});break;case`anthropic.code_execution_20250825`:u.add(`code-execution-2025-08-25`),f.push({type:`code_execution_20250825`,name:`code_execution`});break;case`anthropic.code_execution_20260120`:f.push({type:`code_execution_20260120`,name:`code_execution`});break;case`anthropic.computer_20250124`:u.add(`computer-use-2025-01-24`),f.push({name:`computer`,type:`computer_20250124`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case`anthropic.computer_20251124`:u.add(`computer-use-2025-11-24`),f.push({name:`computer`,type:`computer_20251124`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,enable_zoom:t.args.enableZoom,cache_control:void 0});break;case`anthropic.computer_toolset_20260801`:{let e=await w({value:t.args,schema:Te}),n=e.configs==null?void 0:Object.fromEntries(Object.entries(e.configs).map(([e,t])=>[e,{...t?.enabled!=null&&{enabled:t.enabled},...t?.deferLoading!=null&&{defer_loading:t.deferLoading}}]));f.push({type:`computer_toolset_20260801`,...n!=null&&{configs:n},cache_control:void 0});break}case`anthropic.computer_20241022`:u.add(`computer-use-2024-10-22`),f.push({name:`computer`,type:`computer_20241022`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case`anthropic.text_editor_20250124`:u.add(`computer-use-2025-01-24`),f.push({name:`str_replace_editor`,type:`text_editor_20250124`,cache_control:void 0});break;case`anthropic.text_editor_20241022`:u.add(`computer-use-2024-10-22`),f.push({name:`str_replace_editor`,type:`text_editor_20241022`,cache_control:void 0});break;case`anthropic.text_editor_20250429`:u.add(`computer-use-2025-01-24`),f.push({name:`str_replace_based_edit_tool`,type:`text_editor_20250429`,cache_control:void 0});break;case`anthropic.text_editor_20250728`:{let e=await w({value:t.args,schema:De});f.push({name:`str_replace_based_edit_tool`,type:`text_editor_20250728`,max_characters:e.maxCharacters,cache_control:void 0});break}case`anthropic.bash_20250124`:u.add(`computer-use-2025-01-24`),f.push({name:`bash`,type:`bash_20250124`,cache_control:void 0});break;case`anthropic.bash_20241022`:u.add(`computer-use-2024-10-22`),f.push({name:`bash`,type:`bash_20241022`,cache_control:void 0});break;case`anthropic.memory_20250818`:u.add(`context-management-2025-06-27`),f.push({name:`memory`,type:`memory_20250818`});break;case`anthropic.web_fetch_20250910`:{u.add(`web-fetch-2025-09-10`);let e=await w({value:t.args,schema:nt});f.push({type:`web_fetch_20250910`,name:`web_fetch`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case`anthropic.web_fetch_20260209`:{u.add(`code-execution-web-tools-2026-02-09`);let e=await w({value:t.args,schema:Ze});f.push({type:`web_fetch_20260209`,name:`web_fetch`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case`anthropic.web_fetch_20260318`:{let e=await w({value:t.args,schema:Ke});f.push({type:`web_fetch_20260318`,name:`web_fetch`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,use_cache:e.useCache,response_inclusion:e.responseInclusion,cache_control:void 0});break}case`anthropic.web_search_20250305`:{let e=await w({value:t.args,schema:Ve});f.push({type:`web_search_20250305`,name:`web_search`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case`anthropic.web_search_20260209`:{u.add(`code-execution-web-tools-2026-02-09`);let e=await w({value:t.args,schema:Ie});f.push({type:`web_search_20260209`,name:`web_search`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case`anthropic.web_search_20260318`:{let e=await w({value:t.args,schema:je});f.push({type:`web_search_20260318`,name:`web_search`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,response_inclusion:e.responseInclusion,cache_control:void 0});break}case`anthropic.tool_search_regex_20251119`:f.push({type:`tool_search_tool_regex_20251119`,name:`tool_search_tool_regex`});break;case`anthropic.tool_search_bm25_20251119`:f.push({type:`tool_search_tool_bm25_20251119`,name:`tool_search_tool_bm25`});break;case`anthropic.advisor_20260301`:{u.add(`advisor-tool-2026-03-01`);let e=await w({value:t.args,schema:ve});f.push({type:`advisor_20260301`,name:`advisor`,model:e.model,...e.maxUses!==void 0&&{max_uses:e.maxUses},...e.maxTokens!==void 0&&{max_tokens:e.maxTokens},...e.caching!==void 0&&{caching:e.caching}});break}default:l.push({type:`unsupported`,feature:`provider-defined tool ${t.id}`})}break;default:l.push({type:`unsupported`,feature:`tool ${t}`})}if(t==null)return{tools:f,toolChoice:n?{type:`auto`,disable_parallel_tool_use:n}:void 0,toolWarnings:l,betas:u};let p=t.type;switch(p){case`auto`:return{tools:f,toolChoice:{type:`auto`,disable_parallel_tool_use:n},toolWarnings:l,betas:u};case`required`:return c?(l.push({type:`unsupported`,feature:`toolChoice`,details:`toolChoice 'required' is not supported by this model because it rejects forced tool use. Using 'auto' instead. Instruct the model to use a tool in the prompt and verify that a tool call was made.`}),{tools:f,toolChoice:{type:`auto`,disable_parallel_tool_use:n},toolWarnings:l,betas:u}):{tools:f,toolChoice:{type:`any`,disable_parallel_tool_use:n},toolWarnings:l,betas:u};case`none`:return{tools:void 0,toolChoice:void 0,toolWarnings:l,betas:u};case`tool`:return c?(l.push({type:`unsupported`,feature:`toolChoice`,details:`toolChoice 'tool' is not supported by this model because it rejects forced tool use. Only the '${t.toolName}' tool is sent with 'auto' tool choice. Instruct the model to use the tool in the prompt and verify that a tool call was made.`}),{tools:f.filter(e=>`name`in e&&e.name===t.toolName),toolChoice:{type:`auto`,disable_parallel_tool_use:n},toolWarnings:l,betas:u}):{tools:f,toolChoice:{type:`tool`,name:t.toolName,disable_parallel_tool_use:n},toolWarnings:l,betas:u};default:throw new i({functionality:`tool choice type: ${p}`})}}function ct({usage:e,rawUsage:t}){let n=e.cache_creation_input_tokens??0,r=e.cache_read_input_tokens??0,i=e.output_tokens_details?.thinking_tokens??void 0,a,o,s=e.iterations?.some(e=>e.type===`fallback_message`);if(e.iterations&&e.iterations.length>0&&!s){let t=e.iterations.filter(e=>e.type===`compaction`||e.type===`message`);if(t.length>0){let e=t.reduce((e,t)=>({input:e.input+t.input_tokens,output:e.output+t.output_tokens}),{input:0,output:0});a=e.input,o=e.output}else a=e.input_tokens,o=e.output_tokens}else a=e.input_tokens,o=e.output_tokens;return{inputTokens:{total:a+n+r,noCache:a,cacheRead:r,cacheWrite:n},outputTokens:{total:o,text:i==null?void 0:o-i,reasoning:i},raw:t??e}}const lt=F(()=>B(U.object({type:U.literal(`code_execution_result`),stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}))),ut=F(()=>B(U.object({code:U.string()}))),dt=z({id:`anthropic.code_execution_20250522`,inputSchema:ut,outputSchema:lt}),ft=(e={})=>dt(e),pt=F(()=>B(U.discriminatedUnion(`type`,[U.object({type:U.literal(`code_execution_result`),stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`bash_code_execution_result`),content:U.array(U.object({type:U.literal(`bash_code_execution_output`),file_id:U.string()})),stdout:U.string(),stderr:U.string(),return_code:U.number()}),U.object({type:U.literal(`bash_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_view_result`),content:U.string(),file_type:U.string(),num_lines:U.number().nullable(),start_line:U.number().nullable(),total_lines:U.number().nullable()}),U.object({type:U.literal(`text_editor_code_execution_create_result`),is_file_update:U.boolean()}),U.object({type:U.literal(`text_editor_code_execution_str_replace_result`),lines:U.array(U.string()).nullable(),new_lines:U.number().nullable(),new_start:U.number().nullable(),old_lines:U.number().nullable(),old_start:U.number().nullable()})]))),mt=F(()=>B(U.discriminatedUnion(`type`,[U.object({type:U.literal(`programmatic-tool-call`),code:U.string()}),U.object({type:U.literal(`bash_code_execution`),command:U.string()}),U.discriminatedUnion(`command`,[U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`view`),path:U.string()}),U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`create`),path:U.string(),file_text:U.string().nullish()}),U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`str_replace`),path:U.string(),old_str:U.string(),new_str:U.string()})])]))),ht=z({id:`anthropic.code_execution_20250825`,inputSchema:mt,outputSchema:pt,supportsDeferredResults:!0}),gt=(e={})=>S(ht(e),{type:`provider`,prepareProviderOptions:e=>{let t=e?.anthropic;return{...e,anthropic:{...t,allowedCallers:[...new Set([...t?.allowedCallers??[],`code_execution_20250825`])]}}}}),_t=F(()=>B(U.discriminatedUnion(`type`,[U.object({type:U.literal(`code_execution_result`),stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`encrypted_code_execution_result`),encrypted_stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`bash_code_execution_result`),content:U.array(U.object({type:U.literal(`bash_code_execution_output`),file_id:U.string()})),stdout:U.string(),stderr:U.string(),return_code:U.number()}),U.object({type:U.literal(`bash_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_view_result`),content:U.string(),file_type:U.string(),num_lines:U.number().nullable(),start_line:U.number().nullable(),total_lines:U.number().nullable()}),U.object({type:U.literal(`text_editor_code_execution_create_result`),is_file_update:U.boolean()}),U.object({type:U.literal(`text_editor_code_execution_str_replace_result`),lines:U.array(U.string()).nullable(),new_lines:U.number().nullable(),new_start:U.number().nullable(),old_lines:U.number().nullable(),old_start:U.number().nullable()})]))),vt=F(()=>B(U.discriminatedUnion(`type`,[U.object({type:U.literal(`programmatic-tool-call`),code:U.string()}),U.object({type:U.literal(`bash_code_execution`),command:U.string()}),U.discriminatedUnion(`command`,[U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`view`),path:U.string()}),U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`create`),path:U.string(),file_text:U.string().nullish()}),U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`str_replace`),path:U.string(),old_str:U.string(),new_str:U.string()})])]))),yt=z({id:`anthropic.code_execution_20260120`,inputSchema:vt,outputSchema:_t,supportsDeferredResults:!0}),bt=(e={})=>S(yt(e),{type:`provider`,prepareProviderOptions:e=>{let t=e?.anthropic;return{...e,anthropic:{...t,allowedCallers:[...new Set([...t?.allowedCallers??[],`code_execution_20260120`])]}}}}),xt=F(()=>B(U.array(U.object({type:U.literal(`tool_reference`),toolName:U.string()})))),St=F(()=>B(U.object({pattern:U.string(),limit:U.number().optional()}))),Ct=z({id:`anthropic.tool_search_regex_20251119`,inputSchema:St,outputSchema:xt,supportsDeferredResults:!0}),wt=(e={})=>Ct(e);function Tt(e){return typeof e==`string`?new TextDecoder().decode(T(e)):new TextDecoder().decode(e)}function Et(e){try{if(typeof e==`string`)return P(e);if(typeof e==`object`&&e)return e}catch{let t=e?.errorCode;return{errorCode:typeof t==`string`?t:`unavailable`}}return{}}async function Dt({prompt:e,sendReasoning:t,warnings:n,cacheControlValidator:r,toolNameMapping:a,toolsetNames:o={}}){let s=new Set,c=Ot(e),l=r||new _e,u,f=[],p=-1;async function m(e){return(await N({provider:`anthropic`,providerOptions:e,schema:pe}))?.citations?.enabled??!1}async function h(e){return(await N({provider:`anthropic`,providerOptions:e,schema:pe}))?.containerUpload??!1}async function g(e){let t=await N({provider:`anthropic`,providerOptions:e,schema:pe});return{title:t?.title,context:t?.context}}for(let e=0;e<c.length;e++){let r=c[e],v=e===c.length-1,y=r.type;switch(y){case`system`:{let t=[];for(let{content:e,providerOptions:n}of r.messages){let r=await N({provider:`anthropic`,providerOptions:n,schema:me}),i=r?.toolChanges??[],o=[];(e!==``||i.length===0&&r?.clearAt==null&&r?.effort==null)&&o.push({type:`text`,text:e,cache_control:l.getCacheControl(n,{type:`system message`,canCache:!0})});for(let e of i)o.push({type:e.type,tool:{type:`tool_reference`,name:a.toProviderToolName(e.toolName)}});t.push({content:o,clearAt:r?.clearAt,effort:r?.effort,toolChangeCount:i.length})}let i=t.reduce((e,t)=>e+t.toolChangeCount,0),o=t.some(e=>e.clearAt!=null||e.effort!=null);if(e===0||u==null&&i===0&&!o){i>0&&n.push({type:`other`,message:`tool changes on the initial system message are not supported by Anthropic. Configure the initial tool set via the tools option instead. The tool changes have been ignored.`});for(let e of t)e.content.length===0&&e.clearAt==null&&e.effort!=null?(f.push({role:`system`,content:[],output_config:{effort:e.effort}}),s.add(`mid-conversation-output-config-2026-07-01`)):(e.clearAt!=null||e.effort!=null)&&n.push({type:`other`,message:`clearAt and effort on this initial system message are not supported by Anthropic. Use a separate effort-only system message with empty content to set effort. These options have been ignored.`});u=t.flatMap(e=>e.content.filter(e=>e.type===`text`))}else{s.add(`mid-conversation-system-2026-04-07`);for(let e of t)f.push({role:`system`,content:e.content,...e.clearAt!=null&&{clear_at:e.clearAt},...e.effort!=null&&{output_config:{effort:e.effort}}}),e.toolChangeCount>0&&s.add(`mid-conversation-tool-changes-2026-07-01`),e.clearAt!=null&&s.add(`mid-conversation-system-clear-at-2026-08-21`),e.effort!=null&&s.add(`mid-conversation-output-config-2026-07-01`)}break}case`user`:{let e=[];for(let t of r.messages){let{role:r,content:a}=t;switch(r){case`user`:a.length>0&&(p=f.length);for(let n=0;n<a.length;n++){let r=a[n],o=n===a.length-1,c=l.getCacheControl(r.providerOptions,{type:`user message part`,canCache:!0})??(o?l.getCacheControl(t.providerOptions,{type:`user message`,canCache:!0}):void 0);switch(r.type){case`text`:e.push({type:`text`,text:r.text,cache_control:c});break;case`file`:switch(r.data.type){case`reference`:{let t=te({reference:r.data.reference,provider:`anthropic`});s.add(`files-api-2025-04-14`),await h(r.providerOptions)?e.push({type:`container_upload`,file_id:t}):d(r.mediaType)===`image`?e.push({type:`image`,source:{type:`file`,file_id:t},cache_control:c}):e.push({type:`document`,source:{type:`file`,file_id:t},cache_control:c});break}case`text`:{let t=await m(r.providerOptions),n=await g(r.providerOptions);e.push({type:`document`,source:{type:`text`,media_type:`text/plain`,data:r.data.text},title:n.title??r.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:c});break}case`url`:case`data`:{let t=d(r.mediaType);if(t===`image`)e.push({type:`image`,source:r.data.type===`url`?{type:`url`,url:r.data.url.toString()}:{type:`base64`,media_type:E({part:r}),data:D(r.data.data)},cache_control:c});else if(t===`application`&&(r.data.type===`url`?r.mediaType===`application/pdf`:E({part:r})===`application/pdf`)){s.add(`pdfs-2024-09-25`);let t=await m(r.providerOptions),n=await g(r.providerOptions);e.push({type:`document`,source:r.data.type===`url`?{type:`url`,url:r.data.url.toString()}:{type:`base64`,media_type:`application/pdf`,data:D(r.data.data)},title:n.title??r.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:c})}else if(r.mediaType===`text/plain`){let t=await m(r.providerOptions),n=await g(r.providerOptions);e.push({type:`document`,source:r.data.type===`url`?{type:`url`,url:r.data.url.toString()}:{type:`text`,media_type:`text/plain`,data:Tt(r.data.data)},title:n.title??r.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:c})}else throw new i({functionality:`media type: ${r.mediaType}`});break}}}}break;case`tool`:for(let r=0;r<a.length;r++){let i=a[r];if(i.type===`tool-approval-response`)continue;let c=i.output,u=`providerOptions`in c?c.providerOptions:c.type===`content`?c.value.find(e=>e.providerOptions!=null)?.providerOptions:void 0,f=r===a.length-1,p=l.getCacheControl(i.providerOptions,{type:`tool result part`,canCache:!0})??l.getCacheControl(u,{type:`tool result output`,canCache:!0})??(f?l.getCacheControl(t.providerOptions,{type:`tool result message`,canCache:!0}):void 0),m;switch(c.type){case`content`:m=c.value.map(e=>{switch(e.type){case`text`:return{type:`text`,text:e.text};case`file`:{let t=d(e.mediaType);if(e.data.type===`url`)return t===`image`?{type:`image`,source:{type:`url`,url:e.data.url.toString()}}:{type:`document`,source:{type:`url`,url:e.data.url.toString()}};if(e.data.type===`data`){if(t===`image`)return{type:`image`,source:{type:`base64`,media_type:E({part:e}),data:D(e.data.data)}};if(E({part:e})===`application/pdf`)return s.add(`pdfs-2024-09-25`),{type:`document`,source:{type:`base64`,media_type:`application/pdf`,data:D(e.data.data)}};n.push({type:`other`,message:`unsupported tool content part type: ${e.type} with media type: ${e.mediaType}`});return}n.push({type:`other`,message:`unsupported tool content part type: ${e.type} with data type: ${e.data.type}`});return}case`custom`:{let t=e.providerOptions?.anthropic;if(t?.type===`tool-reference`)return{type:`tool_reference`,tool_name:t.toolName};n.push({type:`other`,message:`unsupported custom tool content part`});return}default:n.push({type:`other`,message:`unsupported tool content part type: ${e.type}`});return}}).filter(_);break;case`text`:case`error-text`:m=c.value;break;case`execution-denied`:m=c.reason??`Tool call execution denied.`;break;default:m=JSON.stringify(c.value)}let h=At({toolName:i.toolName,providerOptions:i.providerOptions,toolsetNames:o});e.push({type:`tool_result`,tool_use_id:i.toolCallId,...h!=null&&{toolset_name:h},content:m,is_error:c.type===`error-text`||c.type===`error-json`||void 0,cache_control:p})}break;default:throw Error(`Unsupported role: ${r}`)}}f.push({role:`user`,content:e});break}case`assistant`:{let e=[],i=new Set;for(let c=0;c<r.messages.length;c++){let u=r.messages[c],d=c===r.messages.length-1,{content:f}=u;for(let r=0;r<f.length;r++){let c=f[r],p=r===f.length-1,m=l.getCacheControl(c.providerOptions,{type:`assistant message part`,canCache:!0})??(p?l.getCacheControl(u.providerOptions,{type:`assistant message`,canCache:!0}):void 0);switch(c.type){case`text`:{let t=c.providerOptions?.anthropic;if(t?.type===`compaction`){if(c.text===``)break;typeof t.signature==`string`&&s.add(`compact-2026-09-04`),e.push({type:`compaction`,content:c.text,...typeof t.signature==`string`&&{signature:t.signature},cache_control:m})}else e.push({type:`text`,text:v&&d&&p?c.text.trim():c.text,...t?.citations!=null&&{citations:t.citations},cache_control:m});break}case`reasoning`:if(t){let t=await N({provider:`anthropic`,providerOptions:c.providerOptions,schema:fe});t==null?n.push({type:`other`,message:`unsupported reasoning metadata`}):t.signature==null?t.redactedData==null?n.push({type:`other`,message:`unsupported reasoning metadata`}):(l.getCacheControl(c.providerOptions,{type:`redacted thinking block`,canCache:!1}),e.push({type:`redacted_thinking`,data:t.redactedData})):(l.getCacheControl(c.providerOptions,{type:`thinking block`,canCache:!1}),e.push({type:`thinking`,thinking:c.text,signature:t.signature}))}else n.push({type:`other`,message:`sending reasoning content is disabled for this model`});break;case`custom`:{if(c.kind!==`anthropic.fallback`)break;let t=await k({value:c.providerOptions?.anthropic,schema:ce});if(!t.success){n.push({type:`other`,message:`anthropic fallback metadata must include from.model and to.model`});break}s.add(`server-side-fallback-2026-06-01`),e.push({type:`fallback`,from:t.value.from,to:t.value.to});break}case`tool-call`:{let t=jt(c.providerOptions);if(c.providerExecuted){let r=a.toProviderToolName(c.toolName);if(c.providerOptions?.anthropic?.type===`mcp-tool-use`){i.add(c.toolCallId);let t=c.providerOptions?.anthropic?.serverName;if(t==null||typeof t!=`string`){n.push({type:`other`,message:`mcp tool use server name is required and must be a string`});break}e.push({type:`mcp_tool_use`,id:c.toolCallId,name:c.toolName,input:c.input,server_name:t,cache_control:m})}else if(r===`code_execution`&&c.input!=null&&typeof c.input==`object`&&`type`in c.input&&typeof c.input.type==`string`&&(c.input.type===`bash_code_execution`||c.input.type===`text_editor_code_execution`)){let{type:n,...r}=c.input;e.push({type:`server_tool_use`,id:c.toolCallId,name:n,input:r,...t&&{caller:t},cache_control:m})}else if(r===`code_execution`&&c.input!=null&&typeof c.input==`object`&&`type`in c.input&&c.input.type===`programmatic-tool-call`){let{type:n,...r}=c.input;e.push({type:`server_tool_use`,id:c.toolCallId,name:`code_execution`,input:r,...t&&{caller:t},cache_control:m})}else r===`code_execution`||r===`web_fetch`||r===`web_search`||r===`tool_search_tool_regex`||r===`tool_search_tool_bm25`?e.push({type:`server_tool_use`,id:c.toolCallId,name:r,input:c.input,...t&&{caller:t},cache_control:m}):r===`advisor`?e.push({type:`server_tool_use`,id:c.toolCallId,name:`advisor`,input:{},...t&&{caller:t},cache_control:m}):n.push({type:`other`,message:`provider executed tool call for tool ${c.toolName} is not supported`});break}let r=At({toolName:c.toolName,providerOptions:c.providerOptions,toolsetNames:o});if(r!=null){let i=Mt(c.input),{action:a}=i,o=typeof a==`string`;o||n.push({type:`other`,message:`toolset tool call for tool ${c.toolName} is missing the action`}),e.push({type:`tool_use`,id:c.toolCallId,name:o?a:r,toolset_name:r,input:i,...t&&{caller:t},cache_control:m});break}e.push({type:`tool_use`,id:c.toolCallId,name:c.toolName,input:Mt(c.input),...t&&{caller:t},cache_control:m});break}case`tool-result`:{let t=a.toProviderToolName(c.toolName),r=jt(c.providerOptions);if(i.has(c.toolCallId)){let t=c.output;if(t.type!==`json`&&t.type!==`error-json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}e.push({type:`mcp_tool_result`,tool_use_id:c.toolCallId,is_error:t.type===`error-json`,content:t.value,cache_control:m})}else if(t===`code_execution`){let t=c.output;if(t.type===`error-text`||t.type===`error-json`){let n={};try{typeof t.value==`string`?n=P(t.value):typeof t.value==`object`&&t.value!==null&&(n=t.value)}catch{}n.type===`code_execution_tool_result_error`?e.push({type:`code_execution_tool_result`,tool_use_id:c.toolCallId,content:{type:`code_execution_tool_result_error`,error_code:n.errorCode??`unknown`},cache_control:m}):e.push({type:`bash_code_execution_tool_result`,tool_use_id:c.toolCallId,cache_control:m,content:{type:`bash_code_execution_tool_result_error`,error_code:n.errorCode??`unknown`}});break}if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}if(t.value==null||typeof t.value!=`object`||!(`type`in t.value)||typeof t.value.type!=`string`){n.push({type:`other`,message:`provider executed tool result output value is not a valid code execution result for tool ${c.toolName}`});break}if(t.value.type===`code_execution_result`){let n=await w({value:t.value,schema:lt});e.push({type:`code_execution_tool_result`,tool_use_id:c.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:m})}else if(t.value.type===`encrypted_code_execution_result`){let n=await w({value:t.value,schema:_t});n.type===`encrypted_code_execution_result`&&e.push({type:`code_execution_tool_result`,tool_use_id:c.toolCallId,content:{type:n.type,encrypted_stdout:n.encrypted_stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:m})}else{let n=await w({value:t.value,schema:pt});n.type===`code_execution_result`?e.push({type:`code_execution_tool_result`,tool_use_id:c.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:m}):n.type===`bash_code_execution_result`||n.type===`bash_code_execution_tool_result_error`?e.push({type:`bash_code_execution_tool_result`,tool_use_id:c.toolCallId,cache_control:m,content:n.type===`bash_code_execution_result`?{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content}:n}):e.push({type:`text_editor_code_execution_tool_result`,tool_use_id:c.toolCallId,cache_control:m,content:n})}break}if(t===`web_fetch`){let t=c.output;if(t.type===`error-json`){e.push({type:`web_fetch_tool_result`,tool_use_id:c.toolCallId,content:{type:`web_fetch_tool_result_error`,error_code:Et(t.value).errorCode??`unavailable`},...r&&{caller:r},cache_control:m});break}if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}let i=await w({value:t.value,schema:rt});e.push({type:`web_fetch_tool_result`,tool_use_id:c.toolCallId,content:{type:`web_fetch_result`,url:i.url,retrieved_at:i.retrievedAt,content:{type:`document`,title:i.content.title,citations:i.content.citations,source:{type:i.content.source.type,media_type:i.content.source.mediaType,data:i.content.source.data}}},...r&&{caller:r},cache_control:m});break}if(t===`web_search`){let t=c.output;if(t.type===`error-json`){e.push({type:`web_search_tool_result`,tool_use_id:c.toolCallId,content:{type:`web_search_tool_result_error`,error_code:Et(t.value).errorCode??`unavailable`},...r&&{caller:r},cache_control:m});break}if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}let i=await w({value:t.value,schema:He});e.push({type:`web_search_tool_result`,tool_use_id:c.toolCallId,content:i.map(e=>({url:e.url,title:e.title,page_age:e.pageAge,encrypted_content:e.encryptedContent,type:e.type})),...r&&{caller:r},cache_control:m});break}if(t===`tool_search_tool_regex`||t===`tool_search_tool_bm25`){let t=c.output;if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}let r=(await w({value:t.value,schema:xt})).map(e=>({type:`tool_reference`,tool_name:e.toolName}));e.push({type:`tool_search_tool_result`,tool_use_id:c.toolCallId,content:{type:`tool_search_tool_search_result`,tool_references:r},cache_control:m});break}if(t===`advisor`){let t=c.output;if(t.type!==`json`&&t.type!==`error-json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}let r=await w({value:t.value,schema:ye});r.type===`advisor_result`?e.push({type:`advisor_tool_result`,tool_use_id:c.toolCallId,content:{type:`advisor_result`,text:r.text,...r.stopReason!==void 0&&{stop_reason:r.stopReason}},cache_control:m}):r.type===`advisor_redacted_result`?e.push({type:`advisor_tool_result`,tool_use_id:c.toolCallId,content:{type:`advisor_redacted_result`,encrypted_content:r.encryptedContent,...r.stopReason!==void 0&&{stop_reason:r.stopReason}},cache_control:m}):e.push({type:`advisor_tool_result`,tool_use_id:c.toolCallId,content:{type:`advisor_tool_result_error`,error_code:r.errorCode},cache_control:m});break}n.push({type:`other`,message:`provider executed tool result for tool ${c.toolName} is not supported`});break}}}}e.length>0&&f.push({role:`assistant`,content:kt(e)});break}default:throw Error(`content type: ${y}`)}}let v=new Set;for(let e of f)if(e.role===`assistant`)for(let t of e.content)t.type===`server_tool_use`&&t.name===`code_execution`&&v.add(t.id);let y=new Set;for(let e=0;e<p;e++){let t=f[e];if(t.role===`assistant`)for(let e of t.content){if(!(`caller`in e))continue;let t=e.caller;if(t==null||t.type===`direct`||v.has(t.tool_id))continue;let r=`id`in e?e.id:e.tool_use_id;delete e.caller,y.has(r)||(y.add(r),n.push({type:`other`,message:`Omitted caller metadata for tool ${r} because source code execution tool ${t.tool_id} is missing from the conversation history.`}))}}return{prompt:{system:u,messages:f},betas:s}}function Ot(e){let t=[],n;for(let r of e){let{role:e}=r;switch(e){case`system`:n?.type!==`system`&&(n={type:`system`,messages:[]},t.push(n)),n.messages.push(r);break;case`assistant`:n?.type!==`assistant`&&(n={type:`assistant`,messages:[]},t.push(n)),n.messages.push(r);break;case`user`:n?.type!==`user`&&(n={type:`user`,messages:[]},t.push(n)),n.messages.push(r);break;case`tool`:n?.type!==`user`&&(n={type:`user`,messages:[]},t.push(n)),n.messages.push(r);break;default:throw Error(`Unsupported role: ${e}`)}}return t}function kt(e){let t=[],n=[];function r(){t.push(...n.filter(e=>e.type!==`tool_use`),...n.filter(e=>e.type===`tool_use`)),n=[]}for(let i of e)i.type===`thinking`||i.type===`redacted_thinking`||i.type===`fallback`?(r(),t.push(i)):n.push(i);return r(),t}function At({toolName:e,providerOptions:t,toolsetNames:n}){let r=n[e];if(r!=null)return r;let i=t?.anthropic?.toolsetName;return typeof i==`string`?i:void 0}function jt(e){let t=e?.anthropic?.caller;return(t?.type===`code_execution_20250825`||t?.type===`code_execution_20260120`)&&t.toolId?{type:t.type,tool_id:t.toolId}:t?.type===`direct`?{type:`direct`}:void 0}function Mt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{rawInvalidInput:e}}function Nt({finishReason:e,isJsonResponseFromTool:t}){switch(e){case`pause_turn`:case`end_turn`:case`stop_sequence`:return`stop`;case`refusal`:return`content-filter`;case`tool_use`:return t?`stop`:`tool-calls`;case`max_tokens`:case`model_context_window_exceeded`:return`length`;case`compaction`:return`other`;default:return`other`}}const Pt=new Set([`date-time`,`time`,`date`,`duration`,`email`,`hostname`,`uri`,`ipv4`,`ipv6`,`uuid`]),Ft=[`minimum`,`maximum`,`exclusiveMinimum`,`exclusiveMaximum`,`multipleOf`,`minLength`,`maxLength`,`pattern`,`minItems`,`maxItems`,`uniqueItems`,`minProperties`,`maxProperties`,`not`];function It(e){return Lt(e)}function Q(e){return typeof e==`boolean`||!g(e)?e:Lt(e)}function Lt(e){let t={},n=e;if(e.$ref!=null)return{$ref:e.$ref};if(e.$schema!=null&&(t.$schema=e.$schema),e.$id!=null&&(t.$id=e.$id),e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description),e.default!==void 0&&(t.default=e.default),e.const!==void 0&&(t.const=e.const),e.enum!=null&&(t.enum=e.enum),e.type!=null&&(t.type=e.type),e.anyOf==null?e.oneOf!=null&&(t.anyOf=e.oneOf.map(Q)):t.anyOf=e.anyOf.map(Q),e.allOf!=null&&(t.allOf=e.allOf.map(Q)),e.definitions!=null&&(t.definitions=Object.fromEntries(Object.entries(e.definitions).map(([e,t])=>[e,Q(t)]))),n.$defs!=null){let e=t;e.$defs=Object.fromEntries(Object.entries(n.$defs).map(([e,t])=>[e,Q(t)]))}(e.type===`object`||e.properties!=null)&&(e.properties!=null&&(t.properties=Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,Q(t)]))),t.additionalProperties=!1,e.required!=null&&(t.required=e.required)),e.items!=null&&(t.items=Array.isArray(e.items)?e.items.map(Q):Q(e.items)),typeof e.format==`string`&&Pt.has(e.format)&&(t.format=e.format);let r=Rt(e);return r!=null&&(t.description=t.description==null?r:`${t.description}\n${r}`),t}function Rt(e){let t=Ft.flatMap(t=>{let n=e[t];return n==null||n===!1?[]:`${zt(t)}: ${Bt(n)}`});return typeof e.format==`string`&&!Pt.has(e.format)&&t.push(`format: ${e.format}`),t.length===0?void 0:`${t.join(`; `)}.`}function zt(e){return e.replace(/[A-Z]/g,e=>` ${e.toLowerCase()}`)}function Bt(e){return typeof e==`string`?e:JSON.stringify(e)}function Vt(e){let t=Ht(e.type);return h({message:e.message,type:e.type,code:e.code??void 0,statusCode:e.statusCode??t.statusCode,isRetryable:e.isRetryable??t.isRetryable,data:`data`in e?e.data:e})}function Ht(e){switch(e){case`api_error`:return{statusCode:500,isRetryable:!0};case`overloaded_error`:return{statusCode:529,isRetryable:!0};case`rate_limit_error`:return{statusCode:429,isRetryable:!0};case`request_too_large`:return{statusCode:413,isRetryable:!1};case`authentication_error`:return{statusCode:401,isRetryable:!1};case`permission_error`:return{statusCode:403,isRetryable:!1};case`not_found_error`:return{statusCode:404,isRetryable:!1};case`billing_error`:case`invalid_request_error`:return{statusCode:400,isRetryable:!1};default:return{}}}function Ut(e,t,n){if(e.type===`web_search_result_location`)return{type:`source`,sourceType:`url`,id:n(),url:e.url,title:e.title??void 0,providerMetadata:{anthropic:{citedText:e.cited_text,encryptedIndex:e.encrypted_index}}};if(e.type!==`page_location`&&e.type!==`char_location`)return;let r=t[e.document_index];if(r)return{type:`source`,sourceType:`document`,id:n(),mediaType:r.mediaType,title:e.document_title??r.title,filename:r.filename,providerMetadata:{anthropic:e.type===`page_location`?{citedText:e.cited_text,startPageNumber:e.start_page_number,endPageNumber:e.end_page_number}:{citedText:e.cited_text,startCharIndex:e.start_char_index,endCharIndex:e.end_char_index}}}}function Wt(e){return e==null?void 0:{type:e.type,toolId:`tool_id`in e?e.tool_id:void 0}}function $(e){let t=Wt(e);return t==null?{}:{providerMetadata:{anthropic:{caller:t}}}}function Gt(e){let t={};for(let n of e??[])n.type===`provider`&&n.id===`anthropic.computer_toolset_20260801`&&(t[n.name]=`computer`);return t}function Kt({memberName:e,input:t}){return{action:e,...typeof t==`object`&&t&&!Array.isArray(t)?t:{}}}function qt(e){let t=e.indexOf(`.`);return t===-1?e:e.substring(0,t)}var Jt=class r{static[ae](e){return M({modelId:e.modelId,config:e.config})}static[H](e){return new r(e.modelId,e.config)}constructor(e,t){this.specificationVersion=`v4`,this.modelId=e,this.config=t,this.generateId=t.generateId??f}supportsUrl(e){return e.protocol===`https:`}get provider(){return this.config.provider}get supportedUrls(){return this.config.supportedUrls?.()??{}}static async prepareRequest({modelId:e,config:n,options:{userSuppliedBetas:r,prompt:i,maxOutputTokens:a,temperature:o,topP:c,topK:l,frequencyPenalty:u,presencePenalty:d,stopSequences:f,responseFormat:p,seed:m,tools:h,toolChoice:g,reasoning:_,providerOptions:v,stream:y}}){let b=[];u!=null&&b.push({type:`unsupported`,feature:`frequencyPenalty`}),d!=null&&b.push({type:`unsupported`,feature:`presencePenalty`}),m!=null&&b.push({type:`unsupported`,feature:`seed`}),o!=null&&o>1?(b.push({type:`unsupported`,feature:`temperature`,details:`${o} exceeds anthropic maximum of 1.0. clamped to 1.0`}),o=1):o!=null&&o<0&&(b.push({type:`unsupported`,feature:`temperature`,details:`${o} is below anthropic minimum of 0. clamped to 0`}),o=0),p?.type===`json`&&(p.schema??b.push({type:`unsupported`,feature:`responseFormat`,details:`JSON response format requires a schema. The response format is ignored.`}));let x=qt(n.provider),S=await N({provider:`anthropic`,providerOptions:v,schema:he}),C=x===`anthropic`?null:await N({provider:x,providerOptions:v,schema:he}),w=C!=null,T=Object.assign({},S??{},C??{}),{maxOutputTokens:E,supportsStructuredOutput:D,supportsAdaptiveThinking:O,rejectsSamplingParameters:k,supportsXhighEffort:ee,rejectsThinkingDisabledAboveHighEffort:A,rejectsThinkingDisabled:j,rejectsForcedToolUse:M,supportsBetweenToolsThinking:P,isKnownModel:F}=Yt(e);!F&&a==null&&b.push({type:`compatibility`,feature:`maxOutputTokens`,details:`The model "${e}" is unknown. The max output tokens have been limited to ${E}. Set maxOutputTokens explicitly to override this limit.`}),k&&(o!=null&&(b.push({type:`unsupported`,feature:`temperature`,details:`temperature is not supported by ${e} and will be ignored`}),o=void 0),l!=null&&(b.push({type:`unsupported`,feature:`topK`,details:`topK is not supported by ${e} and will be ignored`}),l=void 0),c!=null&&(b.push({type:`unsupported`,feature:`topP`,details:`topP is not supported by ${e} and will be ignored`}),c=void 0));let ne=F||e.includes(`claude-`),I=(n.supportsNativeStructuredOutput??!0)&&D,L=(n.supportsStrictTools??!0)&&D,re=T?.structuredOutputMode??`auto`,R=re===`outputFormat`||re===`auto`&&I;!R&&M&&I&&p?.type===`json`&&p.schema!=null&&(b.push({type:`unsupported`,feature:`providerOptions.anthropic.structuredOutputMode`,details:`structuredOutputMode 'jsonTool' is not supported by ${e} because it rejects forced tool use. Using 'outputFormat' instead.`}),R=!0);let z=p?.type===`json`&&p.schema!=null&&!R?{type:`function`,name:`json`,description:`Respond with a JSON object.`,inputSchema:p.schema}:void 0;z!=null&&T?.disableParallelToolUse===!1&&b.push({type:`unsupported`,feature:`providerOptions.anthropic.disableParallelToolUse`,details:"`disableParallelToolUse: false` is ignored when using the JSON response tool. Parallel tool use is disabled to ensure a single coherent JSON tool call."});let B=T?.contextManagement,V=T?.compaction;if(B!=null&&V!=null)throw new t({argument:`providerOptions`,message:"Anthropic provider options `compaction` and `contextManagement` cannot be used together."});let H=new _e,ae=s({tools:h,providerToolNames:{"anthropic.code_execution_20250522":`code_execution`,"anthropic.code_execution_20250825":`code_execution`,"anthropic.code_execution_20260120":`code_execution`,"anthropic.computer_20241022":`computer`,"anthropic.computer_20250124":`computer`,"anthropic.computer_20251124":`computer`,"anthropic.computer_toolset_20260801":`computer`,"anthropic.text_editor_20241022":`str_replace_editor`,"anthropic.text_editor_20250124":`str_replace_editor`,"anthropic.text_editor_20250429":`str_replace_based_edit_tool`,"anthropic.text_editor_20250728":`str_replace_based_edit_tool`,"anthropic.bash_20241022":`bash`,"anthropic.bash_20250124":`bash`,"anthropic.memory_20250818":`memory`,"anthropic.web_search_20250305":`web_search`,"anthropic.web_search_20260209":`web_search`,"anthropic.web_search_20260318":`web_search`,"anthropic.web_fetch_20250910":`web_fetch`,"anthropic.web_fetch_20260209":`web_fetch`,"anthropic.web_fetch_20260318":`web_fetch`,"anthropic.tool_search_regex_20251119":`tool_search_tool_regex`,"anthropic.tool_search_bm25_20251119":`tool_search_tool_bm25`,"anthropic.advisor_20260301":`advisor`}}),oe=Gt(h),{prompt:U,betas:W}=await Dt({prompt:i,sendReasoning:T?.sendReasoning??!0,warnings:b,cacheControlValidator:H,toolNameMapping:ae,toolsetNames:oe});if(ie(_)&&T?.effort==null){let t=Zt({reasoning:_,modelId:e,supportsAdaptiveThinking:O,supportsXhighEffort:ee,rejectsThinkingDisabled:j,supportsBetweenToolsThinking:P,maxOutputTokensForModel:E,warnings:b});t!=null&&(T.thinking??=t.thinking,t.effort!=null&&T.thinking?.type!==`disabled`&&(T.effort=t.effort))}if(j&&T?.thinking!=null){let t=T.thinking;t.type===`disabled`&&P?(b.push({type:`unsupported`,feature:`providerOptions.anthropic.thinking`,details:`thinking cannot be disabled for ${e}. Using 'between_tools' thinking, the lowest thinking setting, instead.`}),T.thinking={type:`between_tools`}):t.type===`disabled`?(b.push({type:`unsupported`,feature:`providerOptions.anthropic.thinking`,details:`thinking cannot be disabled for ${e}; it always uses adaptive thinking. The thinking setting has been removed. Lower 'effort' to reduce thinking.`}),T.thinking=void 0):t.type===`enabled`&&(b.push({type:`unsupported`,feature:`providerOptions.anthropic.thinking`,details:`budget-based thinking is not supported by ${e}; it always uses adaptive thinking. Using adaptive thinking instead. Use 'effort' to control how much the model thinks.`}),T.thinking={type:`adaptive`})}A&&T?.thinking?.type===`disabled`&&(T.effort===`xhigh`||T.effort===`max`)&&(b.push({type:`unsupported`,feature:`providerOptions.anthropic.effort`,details:`effort '${T.effort}' is not supported by ${e} when thinking is disabled. The effort has been lowered to 'high'.`}),T.effort=`high`),T?.thinking?.type===`between_tools`&&(T.effort===`xhigh`||T.effort===`max`)&&(b.push({type:`unsupported`,feature:`providerOptions.anthropic.effort`,details:`effort '${T.effort}' is not supported with 'between_tools' thinking. The effort has been lowered to 'high'.`}),T.effort=`high`);let G=T?.thinking?.type,se=G===`enabled`||G===`adaptive`||G===`between_tools`,K=T?.thinking!=null&&`blockBinding`in T.thinking?T.thinking.blockBinding:void 0,ce=se||G===`disabled`||K!=null,q=G===`enabled`?T?.thinking?.budgetTokens:void 0,J=G===`adaptive`?T?.thinking?.display:void 0,Y=a??E,X={model:e,max_tokens:Y,temperature:o,top_k:l,top_p:c,stop_sequences:f,...ce&&{thinking:{...G!=null&&{type:G},...q!=null&&{budget_tokens:q},...J!=null&&{display:J},...K!=null&&{block_binding:{prefix_mismatch_behavior:K.prefixMismatchBehavior}}}},...(T?.effort||T?.taskBudget||R&&p?.type===`json`&&p.schema!=null)&&{output_config:{...T?.effort&&{effort:T.effort},...T?.taskBudget&&{task_budget:{type:T.taskBudget.type,total:T.taskBudget.total,...T.taskBudget.remaining!=null&&{remaining:T.taskBudget.remaining}}},...R&&p?.type===`json`&&p.schema!=null&&{format:{type:`json_schema`,schema:It(p.schema)}}}},...T?.speed&&{speed:T.speed},...T?.serviceTier&&{service_tier:T.serviceTier},...T?.inferenceGeo&&{inference_geo:T.inferenceGeo},...T?.fallbacks!=null&&(T.fallbacks==="default"||T.fallbacks.length>0)&&{fallbacks:T.fallbacks},...T?.cacheControl&&{cache_control:T.cacheControl},...T?.metadata?.userId!=null&&{metadata:{user_id:T.metadata.userId}},...T?.mcpServers&&T.mcpServers.length>0&&{mcp_servers:T.mcpServers.map(e=>({type:e.type,name:e.name,url:e.url,authorization_token:e.authorizationToken,tool_configuration:e.toolConfiguration?{allowed_tools:e.toolConfiguration.allowedTools,enabled:e.toolConfiguration.enabled}:void 0}))},...T?.container&&{container:T.container.skills&&T.container.skills.length>0?{id:T.container.id,skills:T.container.skills.map(e=>({type:e.type,skill_id:e.type===`custom`?te({reference:e.providerReference,provider:`anthropic`}):e.skillId,version:e.version}))}:T.container.id},system:U.system,messages:U.messages,...T?.safeguards&&T.safeguards.length>0&&{safeguards:T.safeguards.map(e=>({type:e.type,...e.classifierContext!==void 0&&{classifier_context:e.classifierContext}}))},...V&&{compaction:{type:V.type,...V.instructions!==void 0&&{instructions:V.instructions}}},...B&&{context_management:{edits:B.edits.map(e=>{let t=e.type;switch(t){case`clear_tool_uses_20250919`:return{type:e.type,...e.trigger!==void 0&&{trigger:e.trigger},...e.keep!==void 0&&{keep:e.keep},...e.clearAtLeast!==void 0&&{clear_at_least:e.clearAtLeast},...e.clearToolInputs!==void 0&&{clear_tool_inputs:e.clearToolInputs},...e.excludeTools!==void 0&&{exclude_tools:e.excludeTools}};case`clear_thinking_20251015`:return{type:e.type,...e.keep!==void 0&&{keep:e.keep}};case`compact_20260112`:return{type:e.type,...e.trigger!==void 0&&{trigger:e.trigger},...e.pauseAfterCompaction!==void 0&&{pause_after_compaction:e.pauseAfterCompaction},...e.instructions!==void 0&&{instructions:e.instructions}};default:b.push({type:`other`,message:`Unknown context management strategy: ${t}`});return}}).filter(e=>e!==void 0)}}};se?(G===`enabled`&&q==null&&(b.push({type:`compatibility`,feature:`extended thinking`,details:`thinking budget is required when thinking is enabled. using default budget of 1024 tokens.`}),X.thinking={type:`enabled`,budget_tokens:1024},q=1024),X.temperature!=null&&(X.temperature=void 0,b.push({type:`unsupported`,feature:`temperature`,details:`temperature is not supported when thinking is enabled`})),l!=null&&(X.top_k=void 0,b.push({type:`unsupported`,feature:`topK`,details:`topK is not supported when thinking is enabled`})),c!=null&&(X.top_p=void 0,b.push({type:`unsupported`,feature:`topP`,details:`topP is not supported when thinking is enabled`})),X.max_tokens=Y+(q??0)):ne&&c!=null&&o!=null&&(b.push({type:`unsupported`,feature:`topP`,details:`topP is not supported when temperature is set. topP is ignored.`}),X.top_p=void 0),F&&X.max_tokens>E&&(a!=null&&b.push({type:`unsupported`,feature:`maxOutputTokens`,details:`${X.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${e} ${E} max output tokens. The max output tokens have been limited to ${E}.`}),X.max_tokens=E),T?.mcpServers&&T.mcpServers.length>0&&W.add(`mcp-client-2025-04-04`),T?.safeguards&&T.safeguards.length>0&&W.add(`dangerous-tool-use-2026-09-03`),V&&W.add(`compact-2026-09-04`),B&&(W.add(`context-management-2025-06-27`),B.edits.some(e=>e.type===`compact_20260112`)&&W.add(`compact-2026-01-12`)),T?.container&&T.container.skills&&T.container.skills.length>0&&(W.add(`code-execution-2025-08-25`),W.add(`skills-2025-10-02`),W.add(`files-api-2025-04-14`),h?.some(e=>e.type===`provider`&&(e.id===`anthropic.code_execution_20250825`||e.id===`anthropic.code_execution_20260120`))||b.push({type:`other`,message:`code execution tool is required when using skills`})),T?.taskBudget&&W.add(`task-budgets-2026-03-13`),T?.speed===`fast`&&W.add(`fast-mode-2026-02-01`),J===`updates`&&W.add(`thinking-display-updates-2026-08-18`),K!=null&&W.add(`thinking-binding-controls-2026-08-01`),T?.fallbacks==="default"?W.add(`server-side-fallback-2026-07-01`):T?.fallbacks&&T.fallbacks.length>0&&W.add(`server-side-fallback-2026-06-01`);let le=y&&(T?.toolStreaming??!0),{tools:ue,toolChoice:Z,toolWarnings:de,betas:fe}=await st(z==null?{tools:h??[],toolChoice:g,disableParallelToolUse:T?.disableParallelToolUse,cacheControlValidator:H,supportsStructuredOutput:I,supportsStrictTools:L,defaultEagerInputStreaming:le,rejectsForcedToolUse:M}:{tools:[...h??[],z],toolChoice:{type:`required`},disableParallelToolUse:!0,cacheControlValidator:H,supportsStructuredOutput:!1,supportsStrictTools:L,defaultEagerInputStreaming:le,rejectsForcedToolUse:M}),pe=H.getWarnings();return{args:{...X,tools:ue,tool_choice:Z,stream:y===!0||void 0},warnings:[...b,...de,...pe],betas:new Set([...W,...fe,...r,...T?.anthropicBeta??[]]),usesJsonResponseTool:z!=null,toolNameMapping:ae,providerOptionsName:x,usedCustomProviderKey:w}}getArgs(e){return r.prepareRequest({modelId:this.modelId,config:this.config,options:e})}async getHeaders({betas:e,headers:t}){return C(this.config.headers?await L(this.config.headers):void 0,t,e.size>0?{"anthropic-beta":Array.from(e).join(`,`)}:{})}async getBetasFromHeaders(e){let t=(this.config.headers?await L(this.config.headers):void 0)?.[`anthropic-beta`]??``,n=e?.[`anthropic-beta`]??``;return new Set([...t.toLowerCase().split(`,`),...n.toLowerCase().split(`,`)].map(e=>e.trim()).filter(e=>e!==``))}buildRequestUrl(e){return this.config.buildRequestUrl?.(this.config.baseURL,e)??`${this.config.baseURL}/messages`}transformRequestBody(e,t){return this.config.transformRequestBody?.(e,t)??e}extractCitationDocuments(e){return e.filter(e=>e.role===`user`).flatMap(e=>e.content).filter(e=>e.type!==`file`||e.mediaType!==`application/pdf`&&e.mediaType!==`text/plain`?!1:e.providerOptions?.anthropic?.citations?.enabled??!1).map(e=>{let t=e;return{title:t.filename??`Untitled Document`,filename:t.filename,mediaType:t.mediaType}})}async doGenerate(e){let{args:t,warnings:n,betas:r,usesJsonResponseTool:i,toolNameMapping:a,providerOptionsName:o,usedCustomProviderKey:s}=await this.getArgs({...e,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders(e.headers)}),c=[...this.extractCitationDocuments(e.prompt)],l=Xt(t.tools),{responseHeaders:u,value:d,rawValue:f}=await A({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:r,headers:e.headers}),body:this.transformRequestBody(t,r),failedResponseHandler:G,successfulResponseHandler:V(Z),abortSignal:e.abortSignal,fetch:this.config.fetch}),p=[],m={},h={},g=!1;for(let e of d.content)switch(e.type){case`text`:if(!i){let t=e.citations?.filter(e=>e.type===`web_search_result_location`);if(p.push({type:`text`,text:e.text,...t!=null&&t.length>0&&{providerMetadata:{anthropic:{citations:t}}}}),e.citations)for(let t of e.citations){let e=Ut(t,c,this.generateId);e&&p.push(e)}}break;case`thinking`:p.push({type:`reasoning`,text:e.thinking,providerMetadata:{anthropic:{signature:e.signature}}});break;case`redacted_thinking`:p.push({type:`reasoning`,text:``,providerMetadata:{anthropic:{redactedData:e.data}}});break;case`container_upload`:p.push({type:`custom`,kind:`anthropic.container_upload`,providerMetadata:{anthropic:{fileId:e.file_id}}});break;case`compaction`:if(!e.content)break;p.push({type:`text`,text:e.content,providerMetadata:{anthropic:{type:`compaction`,...e.signature!=null&&{signature:e.signature}}}});break;case`tool_use`:i&&e.name===`json`?(g=!0,p.push({type:`text`,text:JSON.stringify(e.input)})):e.toolset_name==null?p.push({type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),...$(e.caller)}):p.push({type:`tool-call`,toolCallId:e.id,toolName:a.toCustomToolName(e.toolset_name),input:JSON.stringify(Kt({memberName:e.name,input:e.input})),providerMetadata:{anthropic:{toolsetName:e.toolset_name,...$(e.caller).providerMetadata?.anthropic}}});break;case`server_tool_use`:if(e.name===`text_editor_code_execution`||e.name===`bash_code_execution`)p.push({type:`tool-call`,toolCallId:e.id,toolName:a.toCustomToolName(`code_execution`),input:JSON.stringify({type:e.name,...e.input}),providerExecuted:!0,...l?{dynamic:!0}:{},...$(e.caller)});else if(e.name===`web_search`||e.name===`code_execution`||e.name===`web_fetch`){let t=e.name===`code_execution`&&e.input!=null&&typeof e.input==`object`&&`code`in e.input&&!(`type`in e.input)?{type:`programmatic-tool-call`,...e.input}:e.input;p.push({type:`tool-call`,toolCallId:e.id,toolName:a.toCustomToolName(e.name),input:JSON.stringify(t),providerExecuted:!0,...l&&e.name===`code_execution`?{dynamic:!0}:{},...$(e.caller)})}else e.name===`tool_search_tool_regex`||e.name===`tool_search_tool_bm25`?(h[e.id]=e.name,p.push({type:`tool-call`,toolCallId:e.id,toolName:a.toCustomToolName(e.name),input:JSON.stringify(e.input),providerExecuted:!0,...$(e.caller)})):e.name===`advisor`&&p.push({type:`tool-call`,toolCallId:e.id,toolName:a.toCustomToolName(`advisor`),input:JSON.stringify(e.input),providerExecuted:!0,...$(e.caller)});break;case`mcp_tool_use`:m[e.id]={type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:`mcp-tool-use`,serverName:e.server_name}}},p.push(m[e.id]);break;case`mcp_tool_result`:p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:m[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:m[e.tool_use_id].providerMetadata});break;case`web_fetch_tool_result`:e.content.type===`web_fetch_result`?(c.push({title:e.content.content.title??e.content.url,mediaType:e.content.content.source.media_type}),p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`web_fetch`),result:{type:`web_fetch_result`,url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}},...$(e.caller)})):e.content.type===`web_fetch_tool_result_error`&&p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`web_fetch`),isError:!0,result:{type:`web_fetch_tool_result_error`,errorCode:e.content.error_code},...$(e.caller)});break;case`web_search_tool_result`:if(Array.isArray(e.content)){p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`web_search`),result:e.content.map(e=>({url:e.url,...e.title==null?{}:{title:e.title},pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type})),...$(e.caller)});for(let t of e.content)p.push({type:`source`,sourceType:`url`,id:this.generateId(),url:t.url,...t.title==null?{}:{title:t.title},providerMetadata:{anthropic:{pageAge:t.page_age??null}}})}else p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`web_search`),isError:!0,result:{type:`web_search_tool_result_error`,errorCode:e.content.error_code},...$(e.caller)});break;case`code_execution_tool_result`:e.content.type===`code_execution_result`?p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`code_execution`),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`encrypted_code_execution_result`?p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`code_execution`),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`code_execution_tool_result_error`&&p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`code_execution`),isError:!0,result:{type:`code_execution_tool_result_error`,errorCode:e.content.error_code}});break;case`bash_code_execution_tool_result`:case`text_editor_code_execution_tool_result`:p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`code_execution`),result:e.content});break;case`tool_search_tool_result`:{let t=h[e.tool_use_id];if(t==null){let e=a.toCustomToolName(`tool_search_tool_bm25`);a.toCustomToolName(`tool_search_tool_regex`),t=e===`tool_search_tool_bm25`?`tool_search_tool_regex`:`tool_search_tool_bm25`}e.content.type===`tool_search_tool_search_result`?p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(t),isError:!0,result:{type:`tool_search_tool_result_error`,errorCode:e.content.error_code}});break}case`advisor_tool_result`:{let t=a.toCustomToolName(`advisor`);e.content.type===`advisor_result`?p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_result`,text:e.content.text,...e.content.stop_reason!=null&&{stopReason:e.content.stop_reason}}}):e.content.type===`advisor_redacted_result`?p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_redacted_result`,encryptedContent:e.content.encrypted_content,...e.content.stop_reason!=null&&{stopReason:e.content.stop_reason}}}):p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,isError:!0,result:{type:`advisor_tool_result_error`,errorCode:e.content.error_code}});break}case`fallback`:p.push({type:`custom`,kind:`anthropic.fallback`,providerMetadata:{anthropic:{type:`fallback`,from:e.from,to:e.to}}})}return{content:p,finishReason:{unified:Nt({finishReason:d.stop_reason,isJsonResponseFromTool:g}),raw:d.stop_reason??void 0},usage:ct({usage:d.usage}),request:{body:t},response:{id:d.id??void 0,modelId:d.model??void 0,headers:u,body:f},warnings:n,providerMetadata:(()=>{let e=$t(d.stop_details),t={usage:d.usage,stopSequence:d.stop_sequence??null,...e==null?{}:{stopDetails:e},...d.input_transformations==null?{}:{inputTransformations:d.input_transformations},...d.safeguard_results==null?{}:{safeguardResults:d.safeguard_results},iterations:d.usage.iterations?d.usage.iterations.map(e=>({type:e.type,...e.model==null?{}:{model:e.model},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:d.container?{expiresAt:d.container.expires_at,id:d.container.id,skills:d.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null}:null,contextManagement:Qt(d.context_management)??null},n={anthropic:t};return s&&o!==`anthropic`&&(n[o]=t),n})()}}async doStream(t){"use step";let{args:r,warnings:i,betas:a,usesJsonResponseTool:o,toolNameMapping:s,providerOptionsName:c,usedCustomProviderKey:u}=await this.getArgs({...t,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders(t.headers)}),d=[...this.extractCitationDocuments(t.prompt)],f=Xt(r.tools),p=this.buildRequestUrl(!0),{responseHeaders:m,value:h}=await A({url:p,headers:await this.getHeaders({betas:a,headers:t.headers}),body:this.transformRequestBody(r,a),failedResponseHandler:G,successfulResponseHandler:ee(de),abortSignal:t.abortSignal,fetch:this.config.fetch}),g={unified:`other`,raw:void 0},_={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},v={},y={},b={},x=null,S,C=null,w,T,E,D=null,O=!1,k=!1,j,te=!1,M,N=this.generateId,[F,ne]=h.pipeThrough(new TransformStream({start(e){e.enqueue({type:`stream-start`,warnings:i})},transform(e,r){if(te)return;if(t.includeRawChunks&&r.enqueue({type:`raw`,rawValue:e.rawValue}),!e.success){r.enqueue({type:`error`,error:e.error});return}let i=e.value;switch(i.type){case`ping`:return;case`content_block_start`:{let e=i.content_block,t=e.type;if(t===`fallback`){r.enqueue({type:`custom`,kind:`anthropic.fallback`,providerMetadata:{anthropic:{type:`fallback`,from:e.from,to:e.to}}});return}switch(M=t,t){case`text`:if(o)return;v[i.index]={type:`text`,citations:[]},r.enqueue({type:`text-start`,id:String(i.index)});return;case`thinking`:v[i.index]={type:`reasoning`},r.enqueue({type:`reasoning-start`,id:String(i.index)});return;case`redacted_thinking`:v[i.index]={type:`reasoning`},r.enqueue({type:`reasoning-start`,id:String(i.index),providerMetadata:{anthropic:{redactedData:e.data}}});return;case`compaction`:v[i.index]={type:`text`,citations:[]},r.enqueue({type:`text-start`,id:String(i.index),providerMetadata:{anthropic:{type:`compaction`,...e.signature!=null&&{signature:e.signature}}}}),e.signature!=null&&e.content!=null&&e.content!==``&&r.enqueue({type:`text-delta`,id:String(i.index),delta:e.content});return;case`tool_use`:if(o&&e.name===`json`)O=!0,v[i.index]={type:`text`,citations:[]},r.enqueue({type:`text-start`,id:String(i.index)});else if(e.toolset_name!=null){let t=Wt(e.caller),n=s.toCustomToolName(e.toolset_name),a=e.input&&Object.keys(e.input).length>0;v[i.index]={type:`tool-call`,toolCallId:e.id,toolName:n,input:a?JSON.stringify(e.input):``,firstDelta:!0,toolset:{name:e.toolset_name,memberName:e.name},...t&&{caller:t}},r.enqueue({type:`tool-input-start`,id:e.id,toolName:n})}else{let t=Wt(e.caller),n=e.input&&Object.keys(e.input).length>0?JSON.stringify(e.input):``;v[i.index]={type:`tool-call`,toolCallId:e.id,toolName:e.name,input:n,firstDelta:n.length===0,...t&&{caller:t}},r.enqueue({type:`tool-input-start`,id:e.id,toolName:e.name})}return;case`server_tool_use`:{let t=Wt(e.caller);if([`web_fetch`,`web_search`,`code_execution`,`text_editor_code_execution`,`bash_code_execution`].includes(e.name)){let n=e.name===`text_editor_code_execution`||e.name===`bash_code_execution`?`code_execution`:e.name,a=e.name===`text_editor_code_execution`||e.name===`bash_code_execution`?e.name:e.name===`code_execution`?`programmatic-tool-call`:void 0,o=s.toCustomToolName(n),c=e.input!=null&&typeof e.input==`object`&&Object.keys(e.input).length>0?JSON.stringify(e.input):``;v[i.index]={type:`tool-call`,toolCallId:e.id,toolName:o,input:c,providerExecuted:!0,...f&&n===`code_execution`?{dynamic:!0}:{},firstDelta:c.length===0,providerToolName:n,providerToolInputType:a,...t&&{caller:t}},r.enqueue({type:`tool-input-start`,id:e.id,toolName:o,providerExecuted:!0,...f&&n===`code_execution`?{dynamic:!0}:{}})}else if(e.name===`tool_search_tool_regex`||e.name===`tool_search_tool_bm25`){b[e.id]=e.name;let n=s.toCustomToolName(e.name);v[i.index]={type:`tool-call`,toolCallId:e.id,toolName:n,input:``,providerExecuted:!0,firstDelta:!0,providerToolName:e.name,...t&&{caller:t}},r.enqueue({type:`tool-input-start`,id:e.id,toolName:n,providerExecuted:!0})}else if(e.name===`advisor`){let n=s.toCustomToolName(`advisor`);v[i.index]={type:`tool-call`,toolCallId:e.id,toolName:n,input:`{}`,providerExecuted:!0,firstDelta:!0,providerToolName:e.name,...t&&{caller:t}},r.enqueue({type:`tool-input-start`,id:e.id,toolName:n,providerExecuted:!0})}return}case`web_fetch_tool_result`:e.content.type===`web_fetch_result`?(d.push({title:e.content.content.title??e.content.url,mediaType:e.content.content.source.media_type}),r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`web_fetch`),result:{type:`web_fetch_result`,url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}},...$(e.caller)})):e.content.type===`web_fetch_tool_result_error`&&r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`web_fetch`),isError:!0,result:{type:`web_fetch_tool_result_error`,errorCode:e.content.error_code},...$(e.caller)});return;case`web_search_tool_result`:if(Array.isArray(e.content)){r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`web_search`),result:e.content.map(e=>({url:e.url,...e.title==null?{}:{title:e.title},pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type})),...$(e.caller)});for(let t of e.content)r.enqueue({type:`source`,sourceType:`url`,id:N(),url:t.url,...t.title==null?{}:{title:t.title},providerMetadata:{anthropic:{pageAge:t.page_age??null}}})}else r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`web_search`),isError:!0,result:{type:`web_search_tool_result_error`,errorCode:e.content.error_code},...$(e.caller)});return;case`code_execution_tool_result`:e.content.type===`code_execution_result`?r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`code_execution`),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`encrypted_code_execution_result`?r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`code_execution`),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`code_execution_tool_result_error`&&r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`code_execution`),isError:!0,result:{type:`code_execution_tool_result_error`,errorCode:e.content.error_code}});return;case`bash_code_execution_tool_result`:case`text_editor_code_execution_tool_result`:r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`code_execution`),result:e.content});return;case`tool_search_tool_result`:{let t=b[e.tool_use_id];if(t==null){let e=s.toCustomToolName(`tool_search_tool_bm25`);s.toCustomToolName(`tool_search_tool_regex`),t=e===`tool_search_tool_bm25`?`tool_search_tool_regex`:`tool_search_tool_bm25`}e.content.type===`tool_search_tool_search_result`?r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(t),isError:!0,result:{type:`tool_search_tool_result_error`,errorCode:e.content.error_code}});return}case`advisor_tool_result`:{let t=s.toCustomToolName(`advisor`);e.content.type===`advisor_result`?r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_result`,text:e.content.text,...e.content.stop_reason!=null&&{stopReason:e.content.stop_reason}}}):e.content.type===`advisor_redacted_result`?r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_redacted_result`,encryptedContent:e.content.encrypted_content,...e.content.stop_reason!=null&&{stopReason:e.content.stop_reason}}}):r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,isError:!0,result:{type:`advisor_tool_result_error`,errorCode:e.content.error_code}});return}case`mcp_tool_use`:y[e.id]={type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:`mcp-tool-use`,serverName:e.server_name}}},r.enqueue(y[e.id]);return;case`mcp_tool_result`:r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:y[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:y[e.tool_use_id].providerMetadata});return;default:throw Error(`Unsupported content block type: ${t}`)}}case`content_block_stop`:if(v[i.index]!=null){let e=v[i.index];switch(e.type){case`text`:r.enqueue({type:`text-end`,id:String(i.index),...e.citations.length>0&&{providerMetadata:{anthropic:{citations:e.citations}}}});break;case`reasoning`:r.enqueue({type:`reasoning-end`,id:String(i.index)});break;case`tool-call`:if(!(o&&e.toolName===`json`)){if(e.toolset!=null){let t={};try{t=e.input===``?{}:P(e.input)}catch{t=void 0}e.input=t===void 0?e.input:JSON.stringify(Kt({memberName:e.toolset.memberName,input:t})),r.enqueue({type:`tool-input-delta`,id:e.toolCallId,delta:e.input})}r.enqueue({type:`tool-input-end`,id:e.toolCallId});let t=e.input===``?`{}`:e.input;if(e.providerToolName===`code_execution`)try{let e=P(t);typeof e==`object`&&e&&`code`in e&&!(`type`in e)&&(t=JSON.stringify({type:`programmatic-tool-call`,...e}))}catch{}r.enqueue({type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:t,providerExecuted:e.providerExecuted,...f&&e.providerToolName===`code_execution`?{dynamic:!0}:{},...(e.caller||e.toolset)&&{providerMetadata:{anthropic:{...e.toolset&&{toolsetName:e.toolset.name},...e.caller&&{caller:e.caller}}}}})}}delete v[i.index]}M=void 0;return;case`content_block_delta`:{let e=i.delta.type;switch(e){case`text_delta`:if(o)return;r.enqueue({type:`text-delta`,id:String(i.index),delta:i.delta.text});return;case`thinking_delta`:r.enqueue({type:`reasoning-delta`,id:String(i.index),delta:i.delta.thinking});return;case`signature_delta`:M===`thinking`&&r.enqueue({type:`reasoning-delta`,id:String(i.index),delta:``,providerMetadata:{anthropic:{signature:i.delta.signature}}});return;case`compaction_delta`:i.delta.content!=null&&r.enqueue({type:`text-delta`,id:String(i.index),delta:i.delta.content});return;case`input_json_delta`:{let e=v[i.index],t=i.delta.partial_json;if(t.length===0)return;if(O){if(e?.type!==`text`)return;r.enqueue({type:`text-delta`,id:String(i.index),delta:t})}else{if(e?.type!==`tool-call`)return;if(e.toolset!=null){e.input+=t;return}e.firstDelta&&e.providerToolInputType!=null&&(t=`{"type": "${e.providerToolInputType}",${t.substring(1)}`),r.enqueue({type:`tool-input-delta`,id:e.toolCallId,delta:t}),e.input+=t,e.firstDelta=!1}return}case`citations_delta`:{let e=i.delta.citation,t=v[i.index];t?.type===`text`&&e.type===`web_search_result_location`&&t.citations.push(e);let n=Ut(e,d,N);n&&r.enqueue(n);return}default:throw Error(`Unsupported delta type: ${e}`)}}case`message_start`:if(k){if(j===i.message.id)return;te=!0,r.enqueue({type:`error`,error:new n({data:i,message:`Received message_start for message ${JSON.stringify(i.message.id)} while message ${JSON.stringify(j)} is still open.`})});return}if(k=!0,j=i.message.id,_.input_tokens=i.message.usage.input_tokens,_.cache_read_input_tokens=i.message.usage.cache_read_input_tokens??0,_.cache_creation_input_tokens=i.message.usage.cache_creation_input_tokens??0,S={...i.message.usage},i.message.input_transformations!=null&&(T=i.message.input_transformations),i.message.container!=null&&(D={expiresAt:i.message.container.expires_at,id:i.message.container.id,skills:null}),i.message.stop_reason!=null&&(g={unified:Nt({finishReason:i.message.stop_reason,isJsonResponseFromTool:O}),raw:i.message.stop_reason}),r.enqueue({type:`response-metadata`,id:i.message.id??void 0,modelId:i.message.model??void 0}),r.enqueue({type:`custom`,kind:`anthropic.message_start`,providerMetadata:{anthropic:{id:i.message.id??null,model:i.message.model??null,usage:S}}}),i.message.content!=null)for(let e=0;e<i.message.content.length;e++){let t=i.message.content[e];if(t.type===`tool_use`){let e=Wt(t.caller);r.enqueue({type:`tool-input-start`,id:t.id,toolName:t.name});let n=JSON.stringify(t.input??{});r.enqueue({type:`tool-input-delta`,id:t.id,delta:n}),r.enqueue({type:`tool-input-end`,id:t.id}),r.enqueue({type:`tool-call`,toolCallId:t.id,toolName:t.name,input:n,...e&&{providerMetadata:{anthropic:{caller:e}}}})}}return;case`message_delta`:i.usage.input_tokens!=null&&_.input_tokens!==i.usage.input_tokens&&(_.input_tokens=i.usage.input_tokens),_.output_tokens=i.usage.output_tokens,i.usage.output_tokens_details!=null&&(_.output_tokens_details=i.usage.output_tokens_details),i.usage.cache_read_input_tokens!=null&&(_.cache_read_input_tokens=i.usage.cache_read_input_tokens),i.usage.cache_creation_input_tokens!=null&&(_.cache_creation_input_tokens=i.usage.cache_creation_input_tokens),i.usage.iterations!=null&&(_.iterations=i.usage.iterations),g={unified:Nt({finishReason:i.delta.stop_reason,isJsonResponseFromTool:O}),raw:i.delta.stop_reason??void 0},C=i.delta.stop_sequence??null,w=$t(i.delta.stop_details),D=i.delta.container==null?null:{expiresAt:i.delta.container.expires_at,id:i.delta.container.id,skills:i.delta.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null},i.context_management&&(x=Qt(i.context_management)),i.input_transformations!=null&&(T=i.input_transformations),i.delta.safeguard_results!=null&&(E=i.delta.safeguard_results),S={...S,...i.usage};return;case`message_stop`:{k=!1,j=void 0;let e={usage:S??null,stopSequence:C,...w==null?{}:{stopDetails:w},...T==null?{}:{inputTransformations:T},...E==null?{}:{safeguardResults:E},iterations:_.iterations?_.iterations.map(e=>({type:e.type,...e.model==null?{}:{model:e.model},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:D,contextManagement:x},t={anthropic:e};u&&c!==`anthropic`&&(t[c]=e),r.enqueue({type:`finish`,finishReason:g,usage:ct({usage:_,rawUsage:S}),providerMetadata:t});return}case`error`:r.enqueue({type:`error`,error:Vt(i.error)});return;default:throw Error(`Unsupported chunk type: ${i}`)}}})).tee(),I=F.getReader();try{await I.read();let t=await I.read();if(t.value?.type===`raw`&&(t=await I.read()),t.value?.type===`error`){let n=t.value.error;throw l(n)?new e({message:n.message,url:p,requestBodyValues:r,statusCode:n.statusCode??500,responseHeaders:m,responseBody:JSON.stringify(n.data),isRetryable:n.isRetryable??!1}):Error(`Expected a normalized Anthropic stream error`)}}finally{I.cancel().catch(()=>{}),I.releaseLock()}return{stream:ne,request:{body:r},response:{headers:m}}}};function Yt(e){return e.includes(`claude-sonnet-5-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!0,rejectsForcedToolUse:!0,supportsBetweenToolsThinking:!0,isKnownModel:!0}:e.includes(`claude-opus-5-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!0,rejectsForcedToolUse:!0,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-opus-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-fable-5-1`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!0,rejectsForcedToolUse:!0,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-fable-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!0,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-opus-4-8`)||e.includes(`claude-opus-4-7`)||e.includes(`claude-sonnet-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-sonnet-4-6`)||e.includes(`claude-opus-4-6`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-sonnet-4-5`)||e.includes(`claude-opus-4-5`)||e.includes(`claude-haiku-4-5`)?{maxOutputTokens:64e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-opus-4-1`)?{maxOutputTokens:32e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:/claude-sonnet-4(?:-|@)/.test(e)?{maxOutputTokens:64e3,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:/claude-opus-4(?:-|@)/.test(e)?{maxOutputTokens:32e3,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-3-haiku`)?{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(e)?{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!1}:e.includes(`claude-`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!1}:{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!1}}function Xt(e){if(!e)return!1;let t=!1,n=!1;for(let r of e){if(`type`in r&&(r.type===`web_fetch_20260209`||r.type===`web_fetch_20260318`||r.type===`web_search_20260209`||r.type===`web_search_20260318`)){t=!0;continue}if(`type`in r&&(r.type===`code_execution_20250522`||r.type===`code_execution_20250825`||r.type===`code_execution_20260120`)){n=!0;break}}return t&&!n}function Zt({reasoning:e,modelId:t,supportsAdaptiveThinking:n,supportsXhighEffort:r,rejectsThinkingDisabled:i,supportsBetweenToolsThinking:a,maxOutputTokensForModel:o,warnings:s}){if(!ie(e))return;if(e===`none`)return a?{thinking:{type:`between_tools`}}:i?(s.push({type:`compatibility`,feature:`reasoning`,details:`reasoning 'none' is not supported by ${t}; it always uses adaptive thinking. Using effort 'low' to minimize thinking instead.`}),{effort:`low`}):{thinking:{type:`disabled`}};if(n)return{thinking:{type:`adaptive`,display:`summarized`},effort:b({reasoning:e,effortMap:{minimal:`low`,low:`low`,medium:`medium`,high:`high`,xhigh:r?`xhigh`:`max`},warnings:s})};let c=v({reasoning:e,maxOutputTokens:o,maxReasoningBudget:o,warnings:s});if(c!=null)return{thinking:{type:`enabled`,budgetTokens:c}}}function Qt(e){return e?{appliedEdits:e.applied_edits.map(e=>{switch(e.type){case`clear_tool_uses_20250919`:return{type:e.type,clearedToolUses:e.cleared_tool_uses,clearedInputTokens:e.cleared_input_tokens};case`clear_thinking_20251015`:return{type:e.type,clearedThinkingTurns:e.cleared_thinking_turns,clearedInputTokens:e.cleared_input_tokens};case`compact_20260112`:return{type:e.type}}}).filter(e=>e!==void 0)}:null}function $t(e){if(e!=null)return{type:e.type,...e.category==null?{}:{category:e.category},...e.explanation==null?{}:{explanation:e.explanation},...e.recommended_model==null?{}:{recommendedModel:e.recommended_model}}}const en=/^[A-Za-z0-9_-]{1,64}$/,tn=he.pick({anthropicBeta:!0}),nn=()=>U.object({id:U.string(),type:U.literal(`message_batch`),processing_status:U.string(),request_counts:U.object({processing:U.number(),succeeded:U.number(),errored:U.number(),canceled:U.number(),expired:U.number()}),created_at:U.string(),expires_at:U.string(),archived_at:U.string().nullish(),cancel_initiated_at:U.string().nullish(),ended_at:U.string().nullish(),results_url:U.string().nullish()}),rn=F(()=>B(nn())),an=F(()=>B(U.object({data:U.array(nn()),has_more:U.boolean(),last_id:U.string().nullish()}))),on=new Set([`advisor_tool_result`,`bash_code_execution_tool_result`,`code_execution_tool_result`,`compaction`,`container_upload`,`fallback`,`mcp_tool_result`,`mcp_tool_use`,`redacted_thinking`,`server_tool_use`,`text`,`text_editor_code_execution_tool_result`,`thinking`,`tool_search_tool_result`,`tool_use`,`web_fetch_tool_result`,`web_search_tool_result`]),sn=F(()=>B(U.discriminatedUnion(`type`,[U.object({type:U.literal(`succeeded`),message:U.unknown()}),U.object({type:U.literal(`errored`),error:U.object({type:U.literal(`error`),error:U.object({type:U.string(),message:U.string()}),request_id:U.string().nullish()})}),U.object({type:U.literal(`canceled`)}),U.object({type:U.literal(`expired`)})]))),cn=F(()=>B(U.object({custom_id:U.string(),result:U.unknown()})));function ln(e){for(let t of e){let e=t.type;if(e!==`text`)throw new i({functionality:`batch request type: ${e}`,message:`The Anthropic Message Batches API does not support batch requests with type "${e}".`})}}var un=class{constructor(e){this.options=e,this.specificationVersion=`v4`,this.provider=e.provider,this.supportedUrls=e.supportedUrls,this.generateId=e.config.generateId??f}async doStartBatch({requests:e,providerOptions:t,headers:n,abortSignal:r,webhookUrl:a}){ln(e),fn(e);let o=new Set(await dn({provider:this.options.config.provider,providerOptions:t})),s=new Set(o),c=[],l=a==null?[]:[{warning:{type:`unsupported`,feature:`webhookUrl`,details:`The Anthropic Message Batches API does not support completion webhooks.`}}];for(let t of e){if((await dn({provider:this.options.config.provider,providerOptions:t.options.providerOptions})).length>0)throw new i({functionality:`per-request providerOptions.anthropic.anthropicBeta`,message:`Anthropic Message Batches do not support per-request betas (request "${t.id}"). Set providerOptions.anthropic.anthropicBeta on startBatch instead.`});let e=await Jt.prepareRequest({modelId:t.modelId,config:this.options.config,options:{...t.options,stream:!1,userSuppliedBetas:new Set(o)}});if(e.usesJsonResponseTool)throw new i({functionality:`batch responseFormat JSON-tool fallback`,message:`Anthropic Message Batches cannot decode the JSON-tool structured-output fallback (request "${t.id}") because batch results are retrieved independently of the start call. Use a model that supports native output_format structured outputs.`});let n=t.options.tools?.find(t=>t.type===`provider`&&e.toolNameMapping.toProviderToolName(t.name)!==t.name);if(n!=null)throw new i({functionality:`aliased provider tool names in batches`,message:`Anthropic Message Batches cannot restore the custom provider-tool name "${n.name}" when results are retrieved independently of the start call (request "${t.id}"). Use the provider's canonical tool name.`});let r=this.options.config.transformRequestBody?.(e.args,e.betas)??e.args;pn({body:r,requestId:t.id}),c.push({custom_id:t.id,params:r});for(let t of e.betas)s.add(t);for(let n of e.warnings)l.push({requestId:t.id,warning:n})}let{value:u}=await A({url:this.getBatchUrl(``),headers:await this.getStartBatchHeaders({betas:s,headers:n}),body:{requests:c},failedResponseHandler:G,successfulResponseHandler:V(rn),abortSignal:r,fetch:this.options.config.fetch});return{batchId:u.id,...mn(u),warnings:l}}async doGetBatchStatus(e){return mn(await this.retrieveBatch(e))}async doCancelBatch(e){return await A({url:this.getBatchUrl(`/${encodeURIComponent(e.batchId)}/cancel`),headers:await this.getBatchHeaders(e.headers),body:{},failedResponseHandler:G,successfulResponseHandler:V(rn),abortSignal:e.abortSignal,fetch:this.options.config.fetch}),{}}async doListBatches(e){let t=new URL(this.getBatchUrl(``));e.limit!=null&&t.searchParams.set(`limit`,String(e.limit)),e.cursor!=null&&t.searchParams.set(`after_id`,e.cursor);let{value:n}=await c({url:t.toString(),validateUrl:!1,headers:await this.getBatchHeaders(e.headers),failedResponseHandler:G,successfulResponseHandler:V(an),abortSignal:e.abortSignal,fetch:this.options.config.fetch});return{batches:n.data.map(e=>({batchId:e.id,...mn(e)})),...n.has_more&&n.last_id!=null?{nextCursor:n.last_id}:{}}}async doGetBatchResults(e){let r=await this.retrieveBatch(e);if(mn(r).status===`pending`)throw new t({argument:`batchId`,message:`Anthropic batch "${e.batchId}" is not complete.`});if(r.archived_at!=null)throw new t({argument:`batchId`,message:`Anthropic batch "${e.batchId}" results are no longer available.`});if(r.results_url==null)throw new n({data:r,message:`Anthropic batch "${e.batchId}" completed without batch output.`});let{value:i}=await c({url:r.results_url,validateUrl:!0,credentialedOrigin:this.options.config.baseURL,trustedOrigin:this.options.config.baseURL,headers:await this.getBatchHeaders(e.headers),failedResponseHandler:G,successfulResponseHandler:re(cn),abortSignal:e.abortSignal,fetch:this.options.config.fetch});return I(this.iterateBatchResults(i))}async retrieveBatch(e){let{value:t}=await c({url:this.getBatchUrl(`/${encodeURIComponent(e.batchId)}`),validateUrl:!1,headers:await this.getBatchHeaders(e.headers),failedResponseHandler:G,successfulResponseHandler:V(rn),abortSignal:e.abortSignal,fetch:this.options.config.fetch});return t}async*iterateBatchResults(e){for await(let t of e)yield await _n(t,this.generateId)}getBatchUrl(e){return`${this.options.config.baseURL}/messages/batches${e}`}async getStartBatchHeaders({betas:e,headers:t}){return C(O(await this.getBatchHeaders(t)),{"anthropic-beta":e.size>0?Array.from(e).join(`,`):void 0})}async getBatchHeaders(e){return C(this.options.config.headers?await L(this.options.config.headers):void 0,e)}};async function dn({provider:e,providerOptions:t}){let n=e.split(`.`)[0],r=await N({provider:`anthropic`,providerOptions:t,schema:tn}),i=n===`anthropic`?void 0:await N({provider:n,providerOptions:t,schema:tn});return Object.assign({},r??{},i??{}).anthropicBeta??[]}function fn(e){let n=new Set;for(let r of e){if(!en.test(r.id))throw new t({argument:`requests`,message:`Anthropic batch request ID "${r.id}" must match ^[A-Za-z0-9_-]{1,64}\$.`});if(n.has(r.id))throw new t({argument:`requests`,message:`Anthropic batch request IDs must be unique; duplicate ID "${r.id}".`});n.add(r.id)}}function pn({body:e,requestId:t}){if(e.speed!=null)throw new i({functionality:`providerOptions.anthropic.speed`,message:`Anthropic Message Batches do not support speed (request "${t}").`});if(Array.isArray(e.fallbacks)&&e.fallbacks.some(e=>typeof e==`object`&&!!e&&`speed`in e&&e.speed!=null))throw new i({functionality:`providerOptions.anthropic.fallbacks[].speed`,message:`Anthropic Message Batches do not support fallback speed (request "${t}").`})}function mn(e){let t=gn(e.request_counts);return{status:hn(e.processing_status),rawStatus:e.processing_status,...t==null?{}:{requestCounts:t},createdAt:e.created_at,expiresAt:e.expires_at,providerMetadata:{anthropic:{archivedAt:e.archived_at??null,cancelInitiatedAt:e.cancel_initiated_at??null,endedAt:e.ended_at??null,requestCounts:e.request_counts,resultsUrl:e.results_url??null}}}}function hn(e){switch(e){case`ended`:return`completed`;default:return`pending`}}function gn(e){return a({total:e.processing+e.succeeded+e.errored+e.canceled+e.expired,pending:e.processing,completed:e.succeeded,failed:e.errored+e.canceled+e.expired})}async function _n(e,t){let n=await k({value:e.result,schema:sn});if(!n.success)return vn(e.custom_id);let r=n.value;switch(r.type){case`canceled`:return{type:`text`,id:e.custom_id,status:`cancelled`};case`expired`:return{type:`text`,id:e.custom_id,status:`expired`};case`errored`:{let t=r.error.request_id;return{type:`text`,id:e.custom_id,status:`failed`,error:{message:r.error.error.message,type:r.error.error.type},...t==null?{}:{providerMetadata:{anthropic:{requestId:t}}}}}case`succeeded`:{let n=await yn(r.message);return n==null?vn(e.custom_id):{type:`text`,id:e.custom_id,status:`succeeded`,result:bn(n,t)}}}}function vn(e){return{type:`text`,id:e,status:`failed`,error:{message:`Anthropic returned an invalid Message batch result.`,code:`invalid_response`}}}async function yn(e){let t=await k({value:e,schema:Z});if(t.success)return t.value;if(!g(e)||!Array.isArray(e.content))return;let n=[];for(let t of e.content){let r=await k({value:{...e,content:[t]},schema:Z});if(r.success){let[e]=r.value.content;e!=null&&n.push(e)}else if(!g(t)||typeof t.type!=`string`||on.has(t.type))return}let r=await k({value:{...e,content:n},schema:Z});return r.success?r.value:void 0}function bn(e,t){let n=[],r={},i={};for(let a of e.content)switch(a.type){case`text`:let e=a.citations;n.push({type:`text`,text:a.text,...e!=null&&e.length>0&&{providerMetadata:{anthropic:{citations:e}}}});for(let e of a.citations??[]){let r=Ut(e,[],t);r!=null&&n.push(r)}break;case`thinking`:n.push({type:`reasoning`,text:a.thinking,providerMetadata:{anthropic:{signature:a.signature}}});break;case`redacted_thinking`:n.push({type:`reasoning`,text:``,providerMetadata:{anthropic:{redactedData:a.data}}});break;case`container_upload`:n.push({type:`custom`,kind:`anthropic.container_upload`,providerMetadata:{anthropic:{fileId:a.file_id}}});break;case`compaction`:if(!a.content)break;n.push({type:`text`,text:a.content,providerMetadata:{anthropic:{type:`compaction`,...a.signature!=null&&{signature:a.signature}}}});break;case`tool_use`:n.push({type:`tool-call`,toolCallId:a.id,toolName:a.name,input:JSON.stringify(a.input),...xn(a.caller)});break;case`server_tool_use`:{let e=a.name===`bash_code_execution`||a.name===`text_editor_code_execution`,t=e||a.name===`code_execution`,r=e?`code_execution`:a.name;(a.name===`tool_search_tool_bm25`||a.name===`tool_search_tool_regex`)&&(i[a.id]=a.name),n.push({type:`tool-call`,toolCallId:a.id,toolName:r,input:JSON.stringify(e?{type:a.name,...a.input}:a.name===`code_execution`&&a.input!=null&&`code`in a.input&&!(`type`in a.input)?{type:`programmatic-tool-call`,...a.input}:a.input),providerExecuted:!0,...t?{dynamic:!0}:{},...xn(a.caller)});break}case`mcp_tool_use`:{let e={type:`tool-call`,toolCallId:a.id,toolName:a.name,input:JSON.stringify(a.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{serverName:a.server_name,type:`mcp-tool-use`}}};r[a.id]=e,n.push(e);break}case`mcp_tool_result`:{let e=r[a.tool_use_id];n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:e?.toolName??`mcp`,isError:a.is_error,result:a.content,dynamic:!0,...e?.providerMetadata!=null&&{providerMetadata:e.providerMetadata}});break}case`web_fetch_tool_result`:n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`web_fetch`,...a.content.type===`web_fetch_tool_result_error`?{isError:!0,result:{errorCode:a.content.error_code,type:a.content.type}}:{result:{content:{citations:a.content.content.citations,source:{data:a.content.content.source.data,mediaType:a.content.content.source.media_type,type:a.content.content.source.type},title:a.content.content.title,type:a.content.content.type},retrievedAt:a.content.retrieved_at,type:a.content.type,url:a.content.url}},...xn(a.caller)});break;case`web_search_tool_result`:if(n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`web_search`,...Array.isArray(a.content)?{result:a.content.map(e=>({encryptedContent:e.encrypted_content,pageAge:e.page_age??null,...e.title==null?{}:{title:e.title},type:e.type,url:e.url}))}:{isError:!0,result:{errorCode:a.content.error_code,type:a.content.type}},...xn(a.caller)}),Array.isArray(a.content))for(let e of a.content)n.push({type:`source`,sourceType:`url`,id:t(),url:e.url,...e.title==null?{}:{title:e.title},providerMetadata:{anthropic:{pageAge:e.page_age??null}}});break;case`code_execution_tool_result`:n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`code_execution`,...a.content.type===`code_execution_tool_result_error`?{isError:!0,result:{errorCode:a.content.error_code,type:a.content.type}}:{result:a.content}});break;case`bash_code_execution_tool_result`:case`text_editor_code_execution_tool_result`:n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`code_execution`,result:a.content});break;case`tool_search_tool_result`:{let e=i[a.tool_use_id]??`tool_search_tool_regex`;n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:e,...a.content.type===`tool_search_tool_result_error`?{isError:!0,result:{errorCode:a.content.error_code,type:a.content.type}}:{result:a.content.tool_references.map(e=>({toolName:e.tool_name,type:e.type}))}});break}case`advisor_tool_result`:a.content.type===`advisor_result`?n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`advisor`,result:{type:a.content.type,text:a.content.text,...a.content.stop_reason==null?{}:{stopReason:a.content.stop_reason}}}):a.content.type===`advisor_redacted_result`?n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`advisor`,result:{type:a.content.type,encryptedContent:a.content.encrypted_content,...a.content.stop_reason==null?{}:{stopReason:a.content.stop_reason}}}):n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`advisor`,isError:!0,result:{errorCode:a.content.error_code,type:a.content.type}});break;case`fallback`:n.push({type:`custom`,kind:`anthropic.fallback`,providerMetadata:{anthropic:{type:`fallback`,from:a.from,to:a.to}}})}return{content:n,finishReason:{unified:Nt({finishReason:e.stop_reason}),raw:e.stop_reason??void 0},usage:ct({usage:e.usage}),response:{id:e.id??void 0,modelId:e.model??void 0},warnings:[],providerMetadata:{anthropic:Sn(e)}}}function xn(e){return e==null?{}:{providerMetadata:{anthropic:{caller:{type:e.type,toolId:e.tool_id}}}}}function Sn(e){let t=wn(e.stop_details);return{usage:e.usage,stopSequence:e.stop_sequence??null,...t==null?{}:{stopDetails:t},...e.input_transformations==null?{}:{inputTransformations:e.input_transformations},...e.safeguard_results==null?{}:{safeguardResults:e.safeguard_results},iterations:e.usage.iterations?e.usage.iterations.map(e=>({type:e.type,...e.model==null?{}:{model:e.model},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:e.container?{expiresAt:e.container.expires_at,id:e.container.id,skills:e.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null}:null,contextManagement:Cn(e.context_management)}}function Cn(e){return e?{appliedEdits:e.applied_edits.map(e=>{switch(e.type){case`clear_tool_uses_20250919`:return{type:e.type,clearedToolUses:e.cleared_tool_uses,clearedInputTokens:e.cleared_input_tokens};case`clear_thinking_20251015`:return{type:e.type,clearedThinkingTurns:e.cleared_thinking_turns,clearedInputTokens:e.cleared_input_tokens};case`compact_20260112`:return{type:e.type}}})}:null}function wn(e){if(e!=null)return{type:e.type,...e.category==null?{}:{category:e.category},...e.explanation==null?{}:{explanation:e.explanation},...e.recommended_model==null?{}:{recommendedModel:e.recommended_model}}}const Tn=F(()=>B(U.object({command:U.string(),restart:U.boolean().optional()}))),En=p({id:`anthropic.bash_20241022`,inputSchema:Tn});function Dn(e={}){let{execute:t,...n}=e;return En(t===void 0?{...n,execute:async({command:e},{abortSignal:t,experimental_sandbox:n})=>{if(!n)throw Error(`Sandbox session is not available`);return await n.run({command:e,abortSignal:t})}}:{...n,...t===null?{}:{execute:t}})}const On=F(()=>B(U.object({command:U.string(),restart:U.boolean().optional()}))),kn=p({id:`anthropic.bash_20250124`,inputSchema:On});function An(e={}){let{execute:t,...n}=e;return kn(t===void 0?{...n,execute:async({command:e},{abortSignal:t,experimental_sandbox:n})=>{if(!n)throw Error(`Sandbox session is not available`);return await n.run({command:e,abortSignal:t})}}:{...n,...t===null?{}:{execute:t}})}const jn=F(()=>B(U.object({action:U.enum([`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`screenshot`,`cursor_position`]),coordinate:U.array(U.number().int()).optional(),text:U.string().optional()}))),Mn=p({id:`anthropic.computer_20241022`,inputSchema:jn}),Nn=F(()=>B(U.object({action:U.enum([`key`,`hold_key`,`type`,`cursor_position`,`mouse_move`,`left_mouse_down`,`left_mouse_up`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`wait`,`screenshot`]),coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),duration:U.number().optional(),scroll_amount:U.number().optional(),scroll_direction:U.enum([`up`,`down`,`left`,`right`]).optional(),start_coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),text:U.string().optional()}))),Pn=p({id:`anthropic.computer_20250124`,inputSchema:Nn}),Fn=F(()=>B(U.object({action:U.enum([`key`,`hold_key`,`type`,`cursor_position`,`mouse_move`,`left_mouse_down`,`left_mouse_up`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`wait`,`screenshot`,`zoom`]),coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),duration:U.number().optional(),region:U.tuple([U.number().int(),U.number().int(),U.number().int(),U.number().int()]).optional(),scroll_amount:U.number().optional(),scroll_direction:U.enum([`up`,`down`,`left`,`right`]).optional(),start_coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),text:U.string().optional()}))),In=p({id:`anthropic.computer_20251124`,inputSchema:Fn}),Ln=F(()=>B(U.discriminatedUnion(`command`,[U.object({command:U.literal(`view`),path:U.string(),view_range:U.tuple([U.number(),U.number()]).optional()}),U.object({command:U.literal(`create`),path:U.string(),file_text:U.string()}),U.object({command:U.literal(`str_replace`),path:U.string(),old_str:U.string(),new_str:U.string()}),U.object({command:U.literal(`insert`),path:U.string(),insert_line:U.number(),insert_text:U.string()}),U.object({command:U.literal(`delete`),path:U.string()}),U.object({command:U.literal(`rename`),old_path:U.string(),new_path:U.string()})]))),Rn=p({id:`anthropic.memory_20250818`,inputSchema:Ln}),zn=F(()=>B(U.object({command:U.enum([`view`,`create`,`str_replace`,`insert`,`undo_edit`]),path:U.string(),file_text:U.string().optional(),insert_line:U.number().int().optional(),new_str:U.string().optional(),insert_text:U.string().optional(),old_str:U.string().optional(),view_range:U.array(U.number().int()).optional()}))),Bn=p({id:`anthropic.text_editor_20241022`,inputSchema:zn}),Vn=F(()=>B(U.object({command:U.enum([`view`,`create`,`str_replace`,`insert`,`undo_edit`]),path:U.string(),file_text:U.string().optional(),insert_line:U.number().int().optional(),new_str:U.string().optional(),insert_text:U.string().optional(),old_str:U.string().optional(),view_range:U.array(U.number().int()).optional()}))),Hn=p({id:`anthropic.text_editor_20250124`,inputSchema:Vn}),Un=F(()=>B(U.object({command:U.enum([`view`,`create`,`str_replace`,`insert`]),path:U.string(),file_text:U.string().optional(),insert_line:U.number().int().optional(),new_str:U.string().optional(),insert_text:U.string().optional(),old_str:U.string().optional(),view_range:U.array(U.number().int()).optional()}))),Wn=p({id:`anthropic.text_editor_20250429`,inputSchema:Un}),Gn=F(()=>B(U.array(U.object({type:U.literal(`tool_reference`),toolName:U.string()})))),Kn=F(()=>B(U.object({query:U.string(),limit:U.number().optional()}))),qn=z({id:`anthropic.tool_search_bm25_20251119`,inputSchema:Kn,outputSchema:Gn,supportsDeferredResults:!0}),Jn={advisor_20260301:Se,bash_20241022:Dn,bash_20250124:An,codeExecution_20250522:ft,codeExecution_20250825:gt,codeExecution_20260120:bt,computer_20241022:Mn,computer_20250124:Pn,computer_20251124:In,computerToolset_20260801:Ee,memory_20250818:Rn,textEditor_20241022:Bn,textEditor_20250124:Hn,textEditor_20250429:Wn,textEditor_20250728:Ae,webFetch_20250910:ot,webFetch_20260209:tt,webFetch_20260318:Xe,webSearch_20250305:Ge,webSearch_20260209:Be,webSearch_20260318:Fe,toolSearchRegex_20251119:wt,toolSearchBm25_20251119:(e={})=>qn(e)},Yn=F(()=>B(U.object({id:U.string(),display_title:U.string().nullish(),name:U.string().nullish(),description:U.string().nullish(),latest_version:U.string().nullish(),source:U.string(),created_at:U.string(),updated_at:U.string()})));F(()=>B(U.object({data:U.array(U.object({version:U.string()}))})));const Xn=F(()=>B(U.object({type:U.string(),skill_id:U.string(),name:U.string().nullish(),description:U.string().nullish()})));function Zn(e){let t=encodeURIComponent(e);return t===`.`?`%252E`:t===`..`?`%252E%252E`:t}var Qn=class{get provider(){return this.config.provider}constructor(e){this.config=e,this.specificationVersion=`v4`}async getHeaders(){return C(await L(this.config.headers),{"anthropic-beta":`skills-2025-10-02`})}async fetchVersionMetadata({skillId:e,version:t,headers:n}){let{value:r}=await c({url:`${this.config.baseURL}/skills/${Zn(e)}/versions/${Zn(t)}`,validateUrl:!1,headers:n,failedResponseHandler:G,successfulResponseHandler:V(Xn),fetch:this.config.fetch});return{...r.name==null?{}:{name:r.name},...r.description==null?{}:{description:r.description}}}async uploadSkill(e){let t=[],n=new FormData;e.displayTitle!=null&&n.append(`display_title`,e.displayTitle);for(let t of e.files){let e=j(t.data);n.append(`files[]`,new Blob([e]),t.path)}let r=await this.getHeaders(),{value:i}=await ne({url:`${this.config.baseURL}/skills`,headers:r,formData:n,failedResponseHandler:G,successfulResponseHandler:V(Yn),fetch:this.config.fetch}),a=i.latest_version==null?{}:await this.fetchVersionMetadata({skillId:i.id,version:i.latest_version,headers:r}),o=a.name??i.name,s=a.description??i.description;return{providerReference:{anthropic:i.id},...i.display_title==null?{}:{displayTitle:i.display_title},...o==null?{}:{name:o},...s==null?{}:{description:s},...i.latest_version==null?{}:{latestVersion:i.latest_version},providerMetadata:{anthropic:{...i.source==null?{}:{source:i.source},...i.created_at==null?{}:{createdAt:i.created_at},...i.updated_at==null?{}:{updatedAt:i.updated_at}}},warnings:t}}};const $n=`4.0.72`,er=`https://api.anthropic.com`,tr=`${er}/v1`;function nr(e){let t=o(R(e));return t===er?tr:t}function rr(e={}){let n=nr(y({settingValue:e.baseURL,environmentVariableName:`ANTHROPIC_BASE_URL`}))??tr,i=e.name??`anthropic.messages`,a={"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]};if(e.apiKey&&e.authToken)throw new t({argument:`apiKey/authToken`,message:`Both apiKey and authToken were provided. Please use only one authentication method.`});let o=()=>{let t=e.authToken?{Authorization:`Bearer ${e.authToken}`}:{"x-api-key":u({apiKey:e.apiKey,environmentVariableName:`ANTHROPIC_API_KEY`,description:`Anthropic`})};return m({"anthropic-version":`2023-06-01`,...t,...e.headers},`ai-sdk-anthropic/${$n}`)},s={provider:i,baseURL:n,headers:o,fetch:e.fetch,generateId:e.generateId??f,supportedUrls:()=>a},c=e=>new Jt(e,s),l=()=>new un({provider:`${i.replace(/\.messages$/,``)}.batch`,config:s,supportedUrls:a}),d=()=>new Qn({provider:`${i.replace(`.messages`,``)}.skills`,baseURL:n,headers:o,fetch:e.fetch}),p=function(e){if(new.target)throw Error(`The Anthropic model function cannot be called with the new keyword.`);return c(e)};return p.specificationVersion=`v4`,p.languageModel=c,p.chat=c,p.messages=c,p.decisionModel=e=>new oe({model:c(e),provider:`${i.replace(/\.messages$/,``)}.decision`}),p.evaluationModel=p.decisionModel,p.experimental_batch=l,p.embeddingModel=e=>{throw new r({modelId:e,modelType:`embeddingModel`})},p.textEmbeddingModel=p.embeddingModel,p.imageModel=e=>{throw new r({modelId:e,modelType:`imageModel`})},p.files=()=>new K({provider:i,baseURL:n,headers:o,fetch:e.fetch}),p.skills=d,p.tools=Jn,p}const ir=rr();function ar({steps:e}){for(let t=e.length-1;t>=0;t--){let n=(e[t].providerMetadata?.anthropic)?.container?.id;if(n)return{providerOptions:{anthropic:{container:{id:n}}}}}}export{$n as VERSION,ir as anthropic,rr as createAnthropic,ar as forwardAnthropicContainerIdFromLastStep};
|
|
1
|
+
import{APICallError as e,InvalidArgumentError as t,InvalidResponseDataError as n,NoSuchModelError as r,UnsupportedFunctionalityError as i}from"../provider/index.js";import{$ as a,Ct as o,E as s,F as c,H as l,J as u,L as d,P as f,S as p,St as m,T as h,U as g,V as _,X as v,Y as y,Z as b,_ as x,_t as S,a as C,bt as w,c as T,ct as E,d as D,et as O,ft as k,g as ee,it as A,l as j,lt as te,mt as ne,nt as M,pt as N,q as P,rt as F,s as I,st as L,v as re,vt as ie,w as R,wt as z,y as B,z as ae}from"../../_chunks/workflow/dist-C8k3N3BQ.js";import{n as V,t as H}from"../../_chunks/workflow/dist-DsNhwdzf.js";import{t as oe}from"../../_chunks/workflow/experimental-decision-DlvnsBD-.js";import{z as U}from"#compiled/zod/index.js";const se=P(()=>z(U.object({type:U.literal(`error`),error:U.object({type:U.string(),message:U.string()})}))),W=x({errorSchema:se,errorToMessage:e=>e.error.message}),G=P(()=>z(U.object({id:U.string(),type:U.literal(`file`),filename:U.string(),mime_type:U.string(),size_bytes:U.number(),created_at:U.string(),downloadable:U.boolean().nullish()})));var ce=class{get provider(){return this.config.provider}constructor(e){this.config=e,this.specificationVersion=`v4`}async uploadFile({data:e,mediaType:t,filename:n,abortSignal:r,headers:i}){let a=j(e),o=new Blob([a],{type:t}),s=new FormData;n==null?s.append(`file`,o):s.append(`file`,o,n);let{value:c}=await F({url:`${this.config.baseURL}/files`,headers:C(this.config.headers(),{"anthropic-beta":`files-api-2025-04-14`},i),formData:s,failedResponseHandler:W,successfulResponseHandler:B(G),abortSignal:r,fetch:this.config.fetch});return{warnings:[],providerReference:{anthropic:c.id},mediaType:c.mime_type??t,filename:c.filename??n,providerMetadata:{anthropic:{filename:c.filename,mimeType:c.mime_type,sizeBytes:c.size_bytes,createdAt:c.created_at,...c.downloadable==null?{}:{downloadable:c.downloadable}}}}}};const K=U.object({type:U.literal(`fallback`),from:U.object({model:U.string()}),to:U.object({model:U.string()})}),le=U.object({type:U.string(),category:U.string().nullish(),explanation:U.string().nullish(),recommended_model:U.string().nullish()}),q=U.object({type:U.string(),status:U.object({type:U.string(),tool_uses:U.record(U.string(),U.object({type:U.string(),outcome:U.string().nullish(),explanation:U.string().nullish()})).nullish()})}),J=U.union([U.object({type:U.literal(`code_execution_20250825`),tool_id:U.string()}),U.object({type:U.literal(`code_execution_20260120`),tool_id:U.string()}),U.object({type:U.literal(`direct`)})]),ue=U.discriminatedUnion(`type`,[U.object({type:U.literal(`web_search_result_location`),cited_text:U.string(),url:U.string(),title:U.string().nullable(),encrypted_index:U.string()}),U.object({type:U.literal(`page_location`),cited_text:U.string(),document_index:U.number(),document_title:U.string().nullable(),start_page_number:U.number(),end_page_number:U.number(),file_id:U.string().nullish()}),U.object({type:U.literal(`char_location`),cited_text:U.string(),document_index:U.number(),document_title:U.string().nullable(),start_char_index:U.number(),end_char_index:U.number(),file_id:U.string().nullish()}),U.object({type:U.literal(`content_block_location`),cited_text:U.string(),document_index:U.number(),document_title:U.string().nullable(),start_block_index:U.number(),end_block_index:U.number(),file_id:U.string().nullable()}),U.object({type:U.literal(`search_result_location`),cited_text:U.string(),search_result_index:U.number(),source:U.string(),title:U.string().nullable(),start_block_index:U.number(),end_block_index:U.number()})]),Y=U.union([U.string(),U.array(U.union([U.string(),U.object({type:U.literal(`text`),text:U.string(),citations:U.array(U.json()).nullable().optional()})]))]),X=U.object({type:U.string(),path:U.string(),reason:U.string()}),Z=P(()=>z(U.object({type:U.literal(`message`),id:U.string().nullish(),model:U.string().nullish(),content:U.array(U.discriminatedUnion(`type`,[U.object({type:U.literal(`text`),text:U.string(),citations:U.array(ue).nullable().optional()}),U.object({type:U.literal(`thinking`),thinking:U.string(),signature:U.string()}),U.object({type:U.literal(`redacted_thinking`),data:U.string()}),U.object({type:U.literal(`compaction`),content:U.string().nullish(),signature:U.string().nullish()}),U.object({type:U.literal(`tool_use`),id:U.string(),name:U.string(),input:U.unknown(),caller:J.optional(),toolset_name:U.string().nullish()}),U.object({type:U.literal(`server_tool_use`),id:U.string(),name:U.string(),input:U.record(U.string(),U.unknown()).nullish(),caller:J.optional()}),U.object({type:U.literal(`mcp_tool_use`),id:U.string(),name:U.string(),input:U.unknown(),server_name:U.string()}),U.object({type:U.literal(`mcp_tool_result`),tool_use_id:U.string(),is_error:U.boolean(),content:Y}),U.object({type:U.literal(`web_fetch_tool_result`),tool_use_id:U.string(),caller:J.optional(),content:U.union([U.object({type:U.literal(`web_fetch_result`),url:U.string(),retrieved_at:U.string().nullable(),content:U.object({type:U.literal(`document`),title:U.string().nullable(),citations:U.object({enabled:U.boolean()}).optional(),source:U.union([U.object({type:U.literal(`base64`),media_type:U.literal(`application/pdf`),data:U.string()}),U.object({type:U.literal(`text`),media_type:U.literal(`text/plain`),data:U.string()})])})}),U.object({type:U.literal(`web_fetch_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`web_search_tool_result`),tool_use_id:U.string(),caller:J.optional(),content:U.union([U.array(U.object({type:U.literal(`web_search_result`),url:U.string(),title:U.string().nullable(),encrypted_content:U.string(),page_age:U.string().nullish()})),U.object({type:U.literal(`web_search_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`code_execution_tool_result`),tool_use_id:U.string(),content:U.union([U.object({type:U.literal(`code_execution_result`),stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`encrypted_code_execution_result`),encrypted_stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`code_execution_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`bash_code_execution_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`bash_code_execution_result`),content:U.array(U.object({type:U.literal(`bash_code_execution_output`),file_id:U.string()})),stdout:U.string(),stderr:U.string(),return_code:U.number()}),U.object({type:U.literal(`bash_code_execution_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`text_editor_code_execution_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`text_editor_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_view_result`),content:U.string(),file_type:U.string(),num_lines:U.number().nullable(),start_line:U.number().nullable(),total_lines:U.number().nullable()}),U.object({type:U.literal(`text_editor_code_execution_create_result`),is_file_update:U.boolean()}),U.object({type:U.literal(`text_editor_code_execution_str_replace_result`),lines:U.array(U.string()).nullable(),new_lines:U.number().nullable(),new_start:U.number().nullable(),old_lines:U.number().nullable(),old_start:U.number().nullable()})])}),U.object({type:U.literal(`tool_search_tool_result`),tool_use_id:U.string(),content:U.union([U.object({type:U.literal(`tool_search_tool_search_result`),tool_references:U.array(U.object({type:U.literal(`tool_reference`),tool_name:U.string()}))}),U.object({type:U.literal(`tool_search_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`container_upload`),file_id:U.string()}),U.object({type:U.literal(`advisor_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`advisor_result`),text:U.string(),stop_reason:U.string().nullish()}),U.object({type:U.literal(`advisor_redacted_result`),encrypted_content:U.string(),stop_reason:U.string().nullish()}),U.object({type:U.literal(`advisor_tool_result_error`),error_code:U.string()})])}),K])),stop_reason:U.string().nullish(),stop_sequence:U.string().nullish(),stop_details:le.nullish(),input_transformations:U.array(X).nullish(),safeguard_results:U.array(q).nullish(),usage:U.looseObject({input_tokens:U.number(),output_tokens:U.number(),output_tokens_details:U.object({thinking_tokens:U.number().nullish()}).nullish(),cache_creation_input_tokens:U.number().nullish(),cache_read_input_tokens:U.number().nullish(),iterations:U.array(U.object({type:U.union([U.literal(`compaction`),U.literal(`message`),U.literal(`advisor_message`),U.literal(`fallback_message`)]),model:U.string().nullish(),input_tokens:U.number(),output_tokens:U.number(),cache_creation_input_tokens:U.number().nullish(),cache_read_input_tokens:U.number().nullish()})).nullish()}),container:U.object({expires_at:U.string(),id:U.string(),skills:U.array(U.object({type:U.union([U.literal(`anthropic`),U.literal(`custom`)]),skill_id:U.string(),version:U.string()})).nullish()}).nullish(),context_management:U.object({applied_edits:U.array(U.union([U.object({type:U.literal(`clear_tool_uses_20250919`),cleared_tool_uses:U.number(),cleared_input_tokens:U.number()}),U.object({type:U.literal(`clear_thinking_20251015`),cleared_thinking_turns:U.number(),cleared_input_tokens:U.number()}),U.object({type:U.literal(`compact_20260112`)})]))}).nullish()}))),de=P(()=>z(U.discriminatedUnion(`type`,[U.object({type:U.literal(`message_start`),message:U.object({id:U.string().nullish(),model:U.string().nullish(),role:U.string().nullish(),usage:U.looseObject({input_tokens:U.number(),cache_creation_input_tokens:U.number().nullish(),cache_read_input_tokens:U.number().nullish()}),content:U.array(U.discriminatedUnion(`type`,[U.object({type:U.literal(`tool_use`),id:U.string(),name:U.string(),input:U.unknown(),caller:J.optional(),toolset_name:U.string().nullish()})])).nullish(),stop_reason:U.string().nullish(),input_transformations:U.array(X).nullish(),container:U.object({expires_at:U.string(),id:U.string()}).nullish()})}),U.object({type:U.literal(`content_block_start`),index:U.number(),content_block:U.discriminatedUnion(`type`,[U.object({type:U.literal(`text`),text:U.string()}),U.object({type:U.literal(`thinking`),thinking:U.string()}),U.object({type:U.literal(`tool_use`),id:U.string(),name:U.string(),input:U.record(U.string(),U.unknown()).optional(),caller:J.optional(),toolset_name:U.string().nullish()}),U.object({type:U.literal(`redacted_thinking`),data:U.string()}),U.object({type:U.literal(`compaction`),content:U.string().nullish(),signature:U.string().nullish()}),U.object({type:U.literal(`server_tool_use`),id:U.string(),name:U.string(),input:U.record(U.string(),U.unknown()).nullish(),caller:J.optional()}),U.object({type:U.literal(`mcp_tool_use`),id:U.string(),name:U.string(),input:U.unknown(),server_name:U.string()}),U.object({type:U.literal(`mcp_tool_result`),tool_use_id:U.string(),is_error:U.boolean(),content:Y}),U.object({type:U.literal(`web_fetch_tool_result`),tool_use_id:U.string(),caller:J.optional(),content:U.union([U.object({type:U.literal(`web_fetch_result`),url:U.string(),retrieved_at:U.string().nullable(),content:U.object({type:U.literal(`document`),title:U.string().nullable(),citations:U.object({enabled:U.boolean()}).optional(),source:U.union([U.object({type:U.literal(`base64`),media_type:U.literal(`application/pdf`),data:U.string()}),U.object({type:U.literal(`text`),media_type:U.literal(`text/plain`),data:U.string()})])})}),U.object({type:U.literal(`web_fetch_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`web_search_tool_result`),tool_use_id:U.string(),caller:J.optional(),content:U.union([U.array(U.object({type:U.literal(`web_search_result`),url:U.string(),title:U.string().nullable(),encrypted_content:U.string(),page_age:U.string().nullish()})),U.object({type:U.literal(`web_search_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`code_execution_tool_result`),tool_use_id:U.string(),content:U.union([U.object({type:U.literal(`code_execution_result`),stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`encrypted_code_execution_result`),encrypted_stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`code_execution_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`bash_code_execution_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`bash_code_execution_result`),content:U.array(U.object({type:U.literal(`bash_code_execution_output`),file_id:U.string()})),stdout:U.string(),stderr:U.string(),return_code:U.number()}),U.object({type:U.literal(`bash_code_execution_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`text_editor_code_execution_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`text_editor_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_view_result`),content:U.string(),file_type:U.string(),num_lines:U.number().nullable(),start_line:U.number().nullable(),total_lines:U.number().nullable()}),U.object({type:U.literal(`text_editor_code_execution_create_result`),is_file_update:U.boolean()}),U.object({type:U.literal(`text_editor_code_execution_str_replace_result`),lines:U.array(U.string()).nullable(),new_lines:U.number().nullable(),new_start:U.number().nullable(),old_lines:U.number().nullable(),old_start:U.number().nullable()})])}),U.object({type:U.literal(`tool_search_tool_result`),tool_use_id:U.string(),content:U.union([U.object({type:U.literal(`tool_search_tool_search_result`),tool_references:U.array(U.object({type:U.literal(`tool_reference`),tool_name:U.string()}))}),U.object({type:U.literal(`tool_search_tool_result_error`),error_code:U.string()})])}),U.object({type:U.literal(`advisor_tool_result`),tool_use_id:U.string(),content:U.discriminatedUnion(`type`,[U.object({type:U.literal(`advisor_result`),text:U.string(),stop_reason:U.string().nullish()}),U.object({type:U.literal(`advisor_redacted_result`),encrypted_content:U.string(),stop_reason:U.string().nullish()}),U.object({type:U.literal(`advisor_tool_result_error`),error_code:U.string()})])}),K])}),U.object({type:U.literal(`content_block_delta`),index:U.number(),delta:U.discriminatedUnion(`type`,[U.object({type:U.literal(`input_json_delta`),partial_json:U.string()}),U.object({type:U.literal(`text_delta`),text:U.string()}),U.object({type:U.literal(`thinking_delta`),thinking:U.string()}),U.object({type:U.literal(`signature_delta`),signature:U.string()}),U.object({type:U.literal(`compaction_delta`),content:U.string().nullish()}),U.object({type:U.literal(`citations_delta`),citation:ue})])}),U.object({type:U.literal(`content_block_stop`),index:U.number()}),U.object({type:U.literal(`error`),error:U.object({type:U.string(),message:U.string(),code:U.union([U.string(),U.number()]).nullish(),statusCode:U.number().nullish(),isRetryable:U.boolean().nullish(),data:U.unknown().nullish()})}),U.object({type:U.literal(`message_delta`),delta:U.object({stop_reason:U.string().nullish(),stop_sequence:U.string().nullish(),stop_details:le.nullish(),safeguard_results:U.array(q).nullish(),container:U.object({expires_at:U.string(),id:U.string(),skills:U.array(U.object({type:U.union([U.literal(`anthropic`),U.literal(`custom`)]),skill_id:U.string(),version:U.string()})).nullish()}).nullish()}),usage:U.looseObject({input_tokens:U.number().nullish(),output_tokens:U.number(),output_tokens_details:U.object({thinking_tokens:U.number().nullish()}).nullish(),cache_creation_input_tokens:U.number().nullish(),cache_read_input_tokens:U.number().nullish(),iterations:U.array(U.object({type:U.union([U.literal(`compaction`),U.literal(`message`),U.literal(`advisor_message`),U.literal(`fallback_message`)]),model:U.string().nullish(),input_tokens:U.number(),output_tokens:U.number(),cache_creation_input_tokens:U.number().nullish(),cache_read_input_tokens:U.number().nullish()})).nullish()}),input_transformations:U.array(X).nullish(),context_management:U.object({applied_edits:U.array(U.union([U.object({type:U.literal(`clear_tool_uses_20250919`),cleared_tool_uses:U.number(),cleared_input_tokens:U.number()}),U.object({type:U.literal(`clear_thinking_20251015`),cleared_thinking_turns:U.number(),cleared_input_tokens:U.number()}),U.object({type:U.literal(`compact_20260112`)})]))}).nullish()}),U.object({type:U.literal(`message_stop`)}),U.object({type:U.literal(`ping`)})]))),fe=P(()=>z(U.object({signature:U.string().optional(),redactedData:U.string().optional()}))),pe=U.object({containerUpload:U.boolean().optional(),citations:U.object({enabled:U.boolean()}).optional(),title:U.string().optional(),context:U.string().optional()}),me=U.object({clearAt:U.literal(`next_user_message`).optional(),effort:U.enum([`low`,`medium`,`high`,`xhigh`,`max`]).optional(),toolChanges:U.array(U.discriminatedUnion(`type`,[U.object({type:U.literal(`tool_addition`),toolName:U.string()}),U.object({type:U.literal(`tool_removal`),toolName:U.string()})])).optional()}),he=U.object({sendReasoning:U.boolean().optional(),structuredOutputMode:U.enum([`outputFormat`,`jsonTool`,`auto`]).optional(),thinking:U.union([U.discriminatedUnion(`type`,[U.object({type:U.literal(`adaptive`),display:U.enum([`omitted`,`summarized`,`updates`]).optional(),blockBinding:U.object({prefixMismatchBehavior:U.enum([`error`,`drop_block`])}).optional()}),U.object({type:U.literal(`enabled`),budgetTokens:U.number().optional()}),U.object({type:U.literal(`disabled`)}),U.object({type:U.literal(`between_tools`)})]),U.object({type:U.never().optional(),blockBinding:U.object({prefixMismatchBehavior:U.enum([`error`,`drop_block`])})})]).optional(),disableParallelToolUse:U.boolean().optional(),cacheControl:U.object({type:U.literal(`ephemeral`),ttl:U.union([U.literal(`5m`),U.literal(`1h`)]).optional()}).optional(),metadata:U.object({userId:U.string().optional()}).optional(),mcpServers:U.array(U.object({type:U.literal(`url`),name:U.string(),url:U.string(),authorizationToken:U.string().nullish(),toolConfiguration:U.object({enabled:U.boolean().nullish(),allowedTools:U.array(U.string()).nullish()}).nullish()})).optional(),container:U.object({id:U.string().optional(),skills:U.array(U.discriminatedUnion(`type`,[U.object({type:U.literal(`anthropic`),skillId:U.string(),version:U.string().optional()}),U.object({type:U.literal(`custom`),providerReference:U.record(U.string(),U.string()),version:U.string().optional()})])).optional()}).optional(),toolStreaming:U.boolean().optional(),effort:U.enum([`low`,`medium`,`high`,`xhigh`,`max`]).optional(),taskBudget:U.object({type:U.literal(`tokens`),total:U.number().int().min(2e4),remaining:U.number().int().min(0).optional()}).optional(),speed:U.enum([`fast`,`standard`]).optional(),serviceTier:U.enum([`auto`,`standard_only`]).optional(),inferenceGeo:U.enum([`us`,`global`]).optional(),fallbacks:U.union([U.literal(`default`),U.array(U.object({model:U.string(),max_tokens:U.number().int().optional(),thinking:U.record(U.string(),U.unknown()).optional(),output_config:U.record(U.string(),U.unknown()).optional(),speed:U.enum([`fast`,`standard`]).optional()}))]).optional(),anthropicBeta:U.array(U.string()).optional(),safeguards:U.array(U.object({type:U.literal(`dangerous_tool_use`),classifierContext:U.record(U.string(),U.unknown()).optional()})).optional(),compaction:U.object({type:U.literal(`summarize`),instructions:U.string().optional()}).optional(),contextManagement:U.object({edits:U.array(U.discriminatedUnion(`type`,[U.object({type:U.literal(`clear_tool_uses_20250919`),trigger:U.discriminatedUnion(`type`,[U.object({type:U.literal(`input_tokens`),value:U.number()}),U.object({type:U.literal(`tool_uses`),value:U.number()})]).optional(),keep:U.object({type:U.literal(`tool_uses`),value:U.number()}).optional(),clearAtLeast:U.object({type:U.literal(`input_tokens`),value:U.number()}).optional(),clearToolInputs:U.boolean().optional(),excludeTools:U.array(U.string()).optional()}),U.object({type:U.literal(`clear_thinking_20251015`),keep:U.union([U.literal(`all`),U.object({type:U.literal(`thinking_turns`),value:U.number()})]).optional()}),U.object({type:U.literal(`compact_20260112`),trigger:U.object({type:U.literal(`input_tokens`),value:U.number()}).optional(),pauseAfterCompaction:U.boolean().optional(),instructions:U.string().optional()})]))}).optional()});function ge(e){let t=e?.anthropic;return t?.cacheControl??t?.cache_control}var _e=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(e,t){let n=ge(e);if(n){if(!t.canCache){this.warnings.push({type:`unsupported`,feature:`cache_control on non-cacheable context`,details:`cache_control cannot be set on ${t.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>4){this.warnings.push({type:`unsupported`,feature:`cacheControl breakpoint limit`,details:`Maximum 4 cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return n}}getWarnings(){return this.warnings}};const ve=P(()=>z(U.object({model:U.string(),maxUses:U.number().optional(),maxTokens:U.number().int().min(1024).optional(),caching:U.object({type:U.literal(`ephemeral`),ttl:U.union([U.literal(`5m`),U.literal(`1h`)])}).optional()}))),ye=P(()=>z(U.discriminatedUnion(`type`,[U.object({type:U.literal(`advisor_result`),text:U.string(),stopReason:U.string().optional()}),U.object({type:U.literal(`advisor_redacted_result`),encryptedContent:U.string(),stopReason:U.string().optional()}),U.object({type:U.literal(`advisor_tool_result_error`),errorCode:U.string()})]))),be=P(()=>z(U.object({}).strict())),xe=R({id:`anthropic.advisor_20260301`,inputSchema:be,outputSchema:ye,supportsDeferredResults:!0}),Se=e=>xe(e),Ce=[`screenshot`,`zoom`,`left_click`,`right_click`,`middle_click`,`double_click`,`triple_click`,`left_click_drag`,`mouse_move`,`left_mouse_down`,`left_mouse_up`,`cursor_position`,`scroll`,`type`,`key`,`hold_key`,`wait`],we=P(()=>z(U.object({action:U.enum(Ce),coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),duration:U.number().optional(),region:U.tuple([U.number().int(),U.number().int(),U.number().int(),U.number().int()]).optional(),repeat:U.number().int().optional(),scroll_amount:U.number().optional(),scroll_direction:U.enum([`up`,`down`,`left`,`right`]).optional(),start_coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),text:U.string().optional()}))),Te=P(()=>z(U.object({configs:U.partialRecord(U.enum(Ce),U.object({enabled:U.boolean().optional(),deferLoading:U.boolean().optional()})).optional()}))),Ee=p({id:`anthropic.computer_toolset_20260801`,inputSchema:we}),De=P(()=>z(U.object({maxCharacters:U.number().optional()}))),Oe=P(()=>z(U.object({command:U.enum([`view`,`create`,`str_replace`,`insert`]),path:U.string(),file_text:U.string().optional(),insert_line:U.number().int().optional(),new_str:U.string().optional(),insert_text:U.string().optional(),old_str:U.string().optional(),view_range:U.array(U.number().int()).optional()}))),ke=p({id:`anthropic.text_editor_20250728`,inputSchema:Oe}),Ae=(e={})=>ke(e),je=P(()=>z(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),userLocation:U.object({type:U.literal(`approximate`),city:U.string().optional(),region:U.string().optional(),country:U.string().optional(),timezone:U.string().optional()}).optional(),responseInclusion:U.enum([`full`,`excluded`]).optional()}))),Me=P(()=>z(U.array(U.object({url:U.string(),title:U.string().nullable(),pageAge:U.string().nullable(),encryptedContent:U.string(),type:U.literal(`web_search_result`)})))),Ne=P(()=>z(U.object({query:U.string()}))),Pe=R({id:`anthropic.web_search_20260318`,inputSchema:Ne,outputSchema:Me,supportsDeferredResults:!0}),Fe=(e={})=>Pe(e),Ie=P(()=>z(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),userLocation:U.object({type:U.literal(`approximate`),city:U.string().optional(),region:U.string().optional(),country:U.string().optional(),timezone:U.string().optional()}).optional()}))),Le=P(()=>z(U.array(U.object({url:U.string(),title:U.string().nullable(),pageAge:U.string().nullable(),encryptedContent:U.string(),type:U.literal(`web_search_result`)})))),Re=P(()=>z(U.object({query:U.string()}))),ze=R({id:`anthropic.web_search_20260209`,inputSchema:Re,outputSchema:Le,supportsDeferredResults:!0}),Be=(e={})=>ze(e),Ve=P(()=>z(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),userLocation:U.object({type:U.literal(`approximate`),city:U.string().optional(),region:U.string().optional(),country:U.string().optional(),timezone:U.string().optional()}).optional()}))),He=P(()=>z(U.array(U.object({url:U.string(),title:U.string().nullable(),pageAge:U.string().nullable(),encryptedContent:U.string(),type:U.literal(`web_search_result`)})))),Ue=P(()=>z(U.object({query:U.string()}))),We=R({id:`anthropic.web_search_20250305`,inputSchema:Ue,outputSchema:He,supportsDeferredResults:!0}),Ge=(e={})=>We(e),Ke=P(()=>z(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),citations:U.object({enabled:U.boolean()}).optional(),maxContentTokens:U.number().optional(),useCache:U.boolean().optional(),responseInclusion:U.enum([`full`,`excluded`]).optional()}))),qe=P(()=>z(U.object({type:U.literal(`web_fetch_result`),url:U.string(),content:U.object({type:U.literal(`document`),title:U.string().nullable(),citations:U.object({enabled:U.boolean()}).optional(),source:U.union([U.object({type:U.literal(`base64`),mediaType:U.literal(`application/pdf`),data:U.string()}),U.object({type:U.literal(`text`),mediaType:U.literal(`text/plain`),data:U.string()})])}),retrievedAt:U.string().nullable()}))),Je=P(()=>z(U.object({url:U.string()}))),Ye=R({id:`anthropic.web_fetch_20260318`,inputSchema:Je,outputSchema:qe,supportsDeferredResults:!0}),Xe=(e={})=>Ye(e),Ze=P(()=>z(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),citations:U.object({enabled:U.boolean()}).optional(),maxContentTokens:U.number().optional()}))),Qe=P(()=>z(U.object({type:U.literal(`web_fetch_result`),url:U.string(),content:U.object({type:U.literal(`document`),title:U.string().nullable(),citations:U.object({enabled:U.boolean()}).optional(),source:U.union([U.object({type:U.literal(`base64`),mediaType:U.literal(`application/pdf`),data:U.string()}),U.object({type:U.literal(`text`),mediaType:U.literal(`text/plain`),data:U.string()})])}),retrievedAt:U.string().nullable()}))),$e=P(()=>z(U.object({url:U.string()}))),et=R({id:`anthropic.web_fetch_20260209`,inputSchema:$e,outputSchema:Qe,supportsDeferredResults:!0}),tt=(e={})=>et(e),nt=P(()=>z(U.object({maxUses:U.number().optional(),allowedDomains:U.array(U.string()).optional(),blockedDomains:U.array(U.string()).optional(),citations:U.object({enabled:U.boolean()}).optional(),maxContentTokens:U.number().optional()}))),rt=P(()=>z(U.object({type:U.literal(`web_fetch_result`),url:U.string(),content:U.object({type:U.literal(`document`),title:U.string().nullable(),citations:U.object({enabled:U.boolean()}).optional(),source:U.union([U.object({type:U.literal(`base64`),mediaType:U.literal(`application/pdf`),data:U.string()}),U.object({type:U.literal(`text`),mediaType:U.literal(`text/plain`),data:U.string()})])}),retrievedAt:U.string().nullable()}))),it=P(()=>z(U.object({url:U.string()}))),at=R({id:`anthropic.web_fetch_20250910`,inputSchema:it,outputSchema:rt,supportsDeferredResults:!0}),ot=(e={})=>at(e);async function st({tools:e,toolChoice:t,disableParallelToolUse:n,cacheControlValidator:r,supportsStructuredOutput:a,supportsStrictTools:o,defaultEagerInputStreaming:s=!1,rejectsForcedToolUse:c=!1}){e=e?.length?e:void 0;let l=[],u=new Set,d=r||new _e;if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:l,betas:u};let f=[];for(let t of e)switch(t.type){case`function`:{let e=d.getCacheControl(t.providerOptions,{type:`tool definition`,canCache:!0}),n=t.providerOptions?.anthropic,r=n?.eagerInputStreaming??s,i=n?.deferLoading,c=n?.allowedCallers;!o&&t.strict===!0&&l.push({type:`unsupported`,feature:`strict`,details:`Tool '${t.name}' has strict: ${t.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`}),f.push({name:t.name,description:t.description,input_schema:t.inputSchema,cache_control:e,...r?{eager_input_streaming:!0}:{},...o===!0&&t.strict!=null?{strict:t.strict}:{},...i==null?{}:{defer_loading:i},...c==null?{}:{allowed_callers:c},...t.inputExamples==null?{}:{input_examples:t.inputExamples.map(e=>e.input)}}),a===!0&&u.add(`structured-outputs-2025-11-13`),(t.inputExamples!=null||c!=null)&&u.add(`advanced-tool-use-2025-11-20`);break}case`provider`:switch(t.id){case`anthropic.code_execution_20250522`:u.add(`code-execution-2025-05-22`),f.push({type:`code_execution_20250522`,name:`code_execution`,cache_control:void 0});break;case`anthropic.code_execution_20250825`:u.add(`code-execution-2025-08-25`),f.push({type:`code_execution_20250825`,name:`code_execution`});break;case`anthropic.code_execution_20260120`:f.push({type:`code_execution_20260120`,name:`code_execution`});break;case`anthropic.computer_20250124`:u.add(`computer-use-2025-01-24`),f.push({name:`computer`,type:`computer_20250124`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case`anthropic.computer_20251124`:u.add(`computer-use-2025-11-24`),f.push({name:`computer`,type:`computer_20251124`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,enable_zoom:t.args.enableZoom,cache_control:void 0});break;case`anthropic.computer_toolset_20260801`:{let e=await w({value:t.args,schema:Te}),n=e.configs==null?void 0:Object.fromEntries(Object.entries(e.configs).map(([e,t])=>[e,{...t?.enabled!=null&&{enabled:t.enabled},...t?.deferLoading!=null&&{defer_loading:t.deferLoading}}]));f.push({type:`computer_toolset_20260801`,...n!=null&&{configs:n},cache_control:void 0});break}case`anthropic.computer_20241022`:u.add(`computer-use-2024-10-22`),f.push({name:`computer`,type:`computer_20241022`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case`anthropic.text_editor_20250124`:u.add(`computer-use-2025-01-24`),f.push({name:`str_replace_editor`,type:`text_editor_20250124`,cache_control:void 0});break;case`anthropic.text_editor_20241022`:u.add(`computer-use-2024-10-22`),f.push({name:`str_replace_editor`,type:`text_editor_20241022`,cache_control:void 0});break;case`anthropic.text_editor_20250429`:u.add(`computer-use-2025-01-24`),f.push({name:`str_replace_based_edit_tool`,type:`text_editor_20250429`,cache_control:void 0});break;case`anthropic.text_editor_20250728`:{let e=await w({value:t.args,schema:De});f.push({name:`str_replace_based_edit_tool`,type:`text_editor_20250728`,max_characters:e.maxCharacters,cache_control:void 0});break}case`anthropic.bash_20250124`:u.add(`computer-use-2025-01-24`),f.push({name:`bash`,type:`bash_20250124`,cache_control:void 0});break;case`anthropic.bash_20241022`:u.add(`computer-use-2024-10-22`),f.push({name:`bash`,type:`bash_20241022`,cache_control:void 0});break;case`anthropic.memory_20250818`:u.add(`context-management-2025-06-27`),f.push({name:`memory`,type:`memory_20250818`});break;case`anthropic.web_fetch_20250910`:{u.add(`web-fetch-2025-09-10`);let e=await w({value:t.args,schema:nt});f.push({type:`web_fetch_20250910`,name:`web_fetch`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case`anthropic.web_fetch_20260209`:{u.add(`code-execution-web-tools-2026-02-09`);let e=await w({value:t.args,schema:Ze});f.push({type:`web_fetch_20260209`,name:`web_fetch`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case`anthropic.web_fetch_20260318`:{let e=await w({value:t.args,schema:Ke});f.push({type:`web_fetch_20260318`,name:`web_fetch`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,use_cache:e.useCache,response_inclusion:e.responseInclusion,cache_control:void 0});break}case`anthropic.web_search_20250305`:{let e=await w({value:t.args,schema:Ve});f.push({type:`web_search_20250305`,name:`web_search`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case`anthropic.web_search_20260209`:{u.add(`code-execution-web-tools-2026-02-09`);let e=await w({value:t.args,schema:Ie});f.push({type:`web_search_20260209`,name:`web_search`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case`anthropic.web_search_20260318`:{let e=await w({value:t.args,schema:je});f.push({type:`web_search_20260318`,name:`web_search`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,response_inclusion:e.responseInclusion,cache_control:void 0});break}case`anthropic.tool_search_regex_20251119`:f.push({type:`tool_search_tool_regex_20251119`,name:`tool_search_tool_regex`});break;case`anthropic.tool_search_bm25_20251119`:f.push({type:`tool_search_tool_bm25_20251119`,name:`tool_search_tool_bm25`});break;case`anthropic.advisor_20260301`:{u.add(`advisor-tool-2026-03-01`);let e=await w({value:t.args,schema:ve});f.push({type:`advisor_20260301`,name:`advisor`,model:e.model,...e.maxUses!==void 0&&{max_uses:e.maxUses},...e.maxTokens!==void 0&&{max_tokens:e.maxTokens},...e.caching!==void 0&&{caching:e.caching}});break}default:l.push({type:`unsupported`,feature:`provider-defined tool ${t.id}`})}break;default:l.push({type:`unsupported`,feature:`tool ${t}`})}if(t==null)return{tools:f,toolChoice:n?{type:`auto`,disable_parallel_tool_use:n}:void 0,toolWarnings:l,betas:u};let p=t.type;switch(p){case`auto`:return{tools:f,toolChoice:{type:`auto`,disable_parallel_tool_use:n},toolWarnings:l,betas:u};case`required`:return c?(l.push({type:`unsupported`,feature:`toolChoice`,details:`toolChoice 'required' is not supported by this model because it rejects forced tool use. Using 'auto' instead. Instruct the model to use a tool in the prompt and verify that a tool call was made.`}),{tools:f,toolChoice:{type:`auto`,disable_parallel_tool_use:n},toolWarnings:l,betas:u}):{tools:f,toolChoice:{type:`any`,disable_parallel_tool_use:n},toolWarnings:l,betas:u};case`none`:return{tools:void 0,toolChoice:void 0,toolWarnings:l,betas:u};case`tool`:return c?(l.push({type:`unsupported`,feature:`toolChoice`,details:`toolChoice 'tool' is not supported by this model because it rejects forced tool use. Only the '${t.toolName}' tool is sent with 'auto' tool choice. Instruct the model to use the tool in the prompt and verify that a tool call was made.`}),{tools:f.filter(e=>`name`in e&&e.name===t.toolName),toolChoice:{type:`auto`,disable_parallel_tool_use:n},toolWarnings:l,betas:u}):{tools:f,toolChoice:{type:`tool`,name:t.toolName,disable_parallel_tool_use:n},toolWarnings:l,betas:u};default:throw new i({functionality:`tool choice type: ${p}`})}}function ct({usage:e,rawUsage:t}){let n=e.cache_creation_input_tokens??0,r=e.cache_read_input_tokens??0,i=e.output_tokens_details?.thinking_tokens??void 0,a,o,s=e.iterations?.some(e=>e.type===`fallback_message`);if(e.iterations&&e.iterations.length>0&&!s){let t=e.iterations.filter(e=>e.type===`compaction`||e.type===`message`);if(t.length>0){let e=t.reduce((e,t)=>({input:e.input+t.input_tokens,output:e.output+t.output_tokens}),{input:0,output:0});a=e.input,o=e.output}else a=e.input_tokens,o=e.output_tokens}else a=e.input_tokens,o=e.output_tokens;return{inputTokens:{total:a+n+r,noCache:a,cacheRead:r,cacheWrite:n},outputTokens:{total:o,text:i==null?void 0:o-i,reasoning:i},raw:t??e}}const lt=P(()=>z(U.object({type:U.literal(`code_execution_result`),stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}))),ut=P(()=>z(U.object({code:U.string()}))),dt=R({id:`anthropic.code_execution_20250522`,inputSchema:ut,outputSchema:lt}),ft=(e={})=>dt(e),pt=P(()=>z(U.discriminatedUnion(`type`,[U.object({type:U.literal(`code_execution_result`),stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`bash_code_execution_result`),content:U.array(U.object({type:U.literal(`bash_code_execution_output`),file_id:U.string()})),stdout:U.string(),stderr:U.string(),return_code:U.number()}),U.object({type:U.literal(`bash_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_view_result`),content:U.string(),file_type:U.string(),num_lines:U.number().nullable(),start_line:U.number().nullable(),total_lines:U.number().nullable()}),U.object({type:U.literal(`text_editor_code_execution_create_result`),is_file_update:U.boolean()}),U.object({type:U.literal(`text_editor_code_execution_str_replace_result`),lines:U.array(U.string()).nullable(),new_lines:U.number().nullable(),new_start:U.number().nullable(),old_lines:U.number().nullable(),old_start:U.number().nullable()})]))),mt=P(()=>z(U.discriminatedUnion(`type`,[U.object({type:U.literal(`programmatic-tool-call`),code:U.string()}),U.object({type:U.literal(`bash_code_execution`),command:U.string()}),U.discriminatedUnion(`command`,[U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`view`),path:U.string()}),U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`create`),path:U.string(),file_text:U.string().nullish()}),U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`str_replace`),path:U.string(),old_str:U.string(),new_str:U.string()})])]))),ht=R({id:`anthropic.code_execution_20250825`,inputSchema:mt,outputSchema:pt,supportsDeferredResults:!0}),gt=(e={})=>S(ht(e),{type:`provider`,prepareProviderOptions:e=>{let t=e?.anthropic;return{...e,anthropic:{...t,allowedCallers:[...new Set([...t?.allowedCallers??[],`code_execution_20250825`])]}}}}),_t=P(()=>z(U.discriminatedUnion(`type`,[U.object({type:U.literal(`code_execution_result`),stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`encrypted_code_execution_result`),encrypted_stdout:U.string(),stderr:U.string(),return_code:U.number(),content:U.array(U.object({type:U.literal(`code_execution_output`),file_id:U.string()})).optional().default([])}),U.object({type:U.literal(`bash_code_execution_result`),content:U.array(U.object({type:U.literal(`bash_code_execution_output`),file_id:U.string()})),stdout:U.string(),stderr:U.string(),return_code:U.number()}),U.object({type:U.literal(`bash_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_tool_result_error`),error_code:U.string()}),U.object({type:U.literal(`text_editor_code_execution_view_result`),content:U.string(),file_type:U.string(),num_lines:U.number().nullable(),start_line:U.number().nullable(),total_lines:U.number().nullable()}),U.object({type:U.literal(`text_editor_code_execution_create_result`),is_file_update:U.boolean()}),U.object({type:U.literal(`text_editor_code_execution_str_replace_result`),lines:U.array(U.string()).nullable(),new_lines:U.number().nullable(),new_start:U.number().nullable(),old_lines:U.number().nullable(),old_start:U.number().nullable()})]))),vt=P(()=>z(U.discriminatedUnion(`type`,[U.object({type:U.literal(`programmatic-tool-call`),code:U.string()}),U.object({type:U.literal(`bash_code_execution`),command:U.string()}),U.discriminatedUnion(`command`,[U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`view`),path:U.string()}),U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`create`),path:U.string(),file_text:U.string().nullish()}),U.object({type:U.literal(`text_editor_code_execution`),command:U.literal(`str_replace`),path:U.string(),old_str:U.string(),new_str:U.string()})])]))),yt=R({id:`anthropic.code_execution_20260120`,inputSchema:vt,outputSchema:_t,supportsDeferredResults:!0}),bt=(e={})=>S(yt(e),{type:`provider`,prepareProviderOptions:e=>{let t=e?.anthropic;return{...e,anthropic:{...t,allowedCallers:[...new Set([...t?.allowedCallers??[],`code_execution_20260120`])]}}}}),xt=P(()=>z(U.array(U.object({type:U.literal(`tool_reference`),toolName:U.string()})))),St=P(()=>z(U.object({pattern:U.string(),limit:U.number().optional()}))),Ct=R({id:`anthropic.tool_search_regex_20251119`,inputSchema:St,outputSchema:xt,supportsDeferredResults:!0}),wt=(e={})=>Ct(e);function Tt(e){return typeof e==`string`?new TextDecoder().decode(T(e)):new TextDecoder().decode(e)}function Et(e){try{if(typeof e==`string`)return N(e);if(typeof e==`object`&&e)return e}catch{let t=e?.errorCode;return{errorCode:typeof t==`string`?t:`unavailable`}}return{}}async function Dt({prompt:e,sendReasoning:t,warnings:n,cacheControlValidator:r,toolNameMapping:a,toolsetNames:o={}}){let s=new Set,c=Ot(e),l=r||new _e,u,f=[],p=-1;async function m(e){return(await M({provider:`anthropic`,providerOptions:e,schema:pe}))?.citations?.enabled??!1}async function h(e){return(await M({provider:`anthropic`,providerOptions:e,schema:pe}))?.containerUpload??!1}async function g(e){let t=await M({provider:`anthropic`,providerOptions:e,schema:pe});return{title:t?.title,context:t?.context}}for(let e=0;e<c.length;e++){let r=c[e],v=e===c.length-1,y=r.type;switch(y){case`system`:{let t=[];for(let{content:e,providerOptions:n}of r.messages){let r=await M({provider:`anthropic`,providerOptions:n,schema:me}),i=r?.toolChanges??[],o=[];(e!==``||i.length===0&&r?.clearAt==null&&r?.effort==null)&&o.push({type:`text`,text:e,cache_control:l.getCacheControl(n,{type:`system message`,canCache:!0})});for(let e of i)o.push({type:e.type,tool:{type:`tool_reference`,name:a.toProviderToolName(e.toolName)}});t.push({content:o,clearAt:r?.clearAt,effort:r?.effort,toolChangeCount:i.length})}let i=t.reduce((e,t)=>e+t.toolChangeCount,0),o=t.some(e=>e.clearAt!=null||e.effort!=null);if(e===0||u==null&&i===0&&!o){i>0&&n.push({type:`other`,message:`tool changes on the initial system message are not supported by Anthropic. Configure the initial tool set via the tools option instead. The tool changes have been ignored.`});for(let e of t)e.content.length===0&&e.clearAt==null&&e.effort!=null?(f.push({role:`system`,content:[],output_config:{effort:e.effort}}),s.add(`mid-conversation-output-config-2026-07-01`)):(e.clearAt!=null||e.effort!=null)&&n.push({type:`other`,message:`clearAt and effort on this initial system message are not supported by Anthropic. Use a separate effort-only system message with empty content to set effort. These options have been ignored.`});u=t.flatMap(e=>e.content.filter(e=>e.type===`text`))}else{s.add(`mid-conversation-system-2026-04-07`);for(let e of t)f.push({role:`system`,content:e.content,...e.clearAt!=null&&{clear_at:e.clearAt},...e.effort!=null&&{output_config:{effort:e.effort}}}),e.toolChangeCount>0&&s.add(`mid-conversation-tool-changes-2026-07-01`),e.clearAt!=null&&s.add(`mid-conversation-system-clear-at-2026-08-21`),e.effort!=null&&s.add(`mid-conversation-output-config-2026-07-01`)}break}case`user`:{let e=[];for(let t of r.messages){let{role:r,content:a}=t;switch(r){case`user`:a.length>0&&(p=f.length);for(let n=0;n<a.length;n++){let r=a[n],o=n===a.length-1,c=l.getCacheControl(r.providerOptions,{type:`user message part`,canCache:!0})??(o?l.getCacheControl(t.providerOptions,{type:`user message`,canCache:!0}):void 0);switch(r.type){case`text`:e.push({type:`text`,text:r.text,cache_control:c});break;case`file`:switch(r.data.type){case`reference`:{let t=te({reference:r.data.reference,provider:`anthropic`});s.add(`files-api-2025-04-14`),await h(r.providerOptions)?e.push({type:`container_upload`,file_id:t}):d(r.mediaType)===`image`?e.push({type:`image`,source:{type:`file`,file_id:t},cache_control:c}):e.push({type:`document`,source:{type:`file`,file_id:t},cache_control:c});break}case`text`:{let t=await m(r.providerOptions),n=await g(r.providerOptions);e.push({type:`document`,source:{type:`text`,media_type:`text/plain`,data:r.data.text},title:n.title??r.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:c});break}case`url`:case`data`:{let t=d(r.mediaType);if(t===`image`)e.push({type:`image`,source:r.data.type===`url`?{type:`url`,url:r.data.url.toString()}:{type:`base64`,media_type:E({part:r}),data:D(r.data.data)},cache_control:c});else if(t===`application`&&(r.data.type===`url`?r.mediaType===`application/pdf`:E({part:r})===`application/pdf`)){s.add(`pdfs-2024-09-25`);let t=await m(r.providerOptions),n=await g(r.providerOptions);e.push({type:`document`,source:r.data.type===`url`?{type:`url`,url:r.data.url.toString()}:{type:`base64`,media_type:`application/pdf`,data:D(r.data.data)},title:n.title??r.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:c})}else if(r.mediaType===`text/plain`){let t=await m(r.providerOptions),n=await g(r.providerOptions);e.push({type:`document`,source:r.data.type===`url`?{type:`url`,url:r.data.url.toString()}:{type:`text`,media_type:`text/plain`,data:Tt(r.data.data)},title:n.title??r.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:c})}else throw new i({functionality:`media type: ${r.mediaType}`});break}}}}break;case`tool`:for(let r=0;r<a.length;r++){let i=a[r];if(i.type===`tool-approval-response`)continue;let c=i.output,u=`providerOptions`in c?c.providerOptions:c.type===`content`?c.value.find(e=>e.providerOptions!=null)?.providerOptions:void 0,f=r===a.length-1,p=l.getCacheControl(i.providerOptions,{type:`tool result part`,canCache:!0})??l.getCacheControl(u,{type:`tool result output`,canCache:!0})??(f?l.getCacheControl(t.providerOptions,{type:`tool result message`,canCache:!0}):void 0),m;switch(c.type){case`content`:m=c.value.map(e=>{switch(e.type){case`text`:return{type:`text`,text:e.text};case`file`:{let t=d(e.mediaType);if(e.data.type===`url`)return t===`image`?{type:`image`,source:{type:`url`,url:e.data.url.toString()}}:{type:`document`,source:{type:`url`,url:e.data.url.toString()}};if(e.data.type===`data`){if(t===`image`)return{type:`image`,source:{type:`base64`,media_type:E({part:e}),data:D(e.data.data)}};if(E({part:e})===`application/pdf`)return s.add(`pdfs-2024-09-25`),{type:`document`,source:{type:`base64`,media_type:`application/pdf`,data:D(e.data.data)}};n.push({type:`other`,message:`unsupported tool content part type: ${e.type} with media type: ${e.mediaType}`});return}n.push({type:`other`,message:`unsupported tool content part type: ${e.type} with data type: ${e.data.type}`});return}case`custom`:{let t=e.providerOptions?.anthropic;if(t?.type===`tool-reference`)return{type:`tool_reference`,tool_name:t.toolName};n.push({type:`other`,message:`unsupported custom tool content part`});return}default:n.push({type:`other`,message:`unsupported tool content part type: ${e.type}`});return}}).filter(_);break;case`text`:case`error-text`:m=c.value;break;case`execution-denied`:m=c.reason??`Tool call execution denied.`;break;default:m=JSON.stringify(c.value)}let h=At({toolName:i.toolName,providerOptions:i.providerOptions,toolsetNames:o});e.push({type:`tool_result`,tool_use_id:i.toolCallId,...h!=null&&{toolset_name:h},content:m,is_error:c.type===`error-text`||c.type===`error-json`||void 0,cache_control:p})}break;default:throw Error(`Unsupported role: ${r}`)}}f.push({role:`user`,content:e});break}case`assistant`:{let e=[],i=new Set;for(let c=0;c<r.messages.length;c++){let u=r.messages[c],d=c===r.messages.length-1,{content:f}=u;for(let r=0;r<f.length;r++){let c=f[r],p=r===f.length-1,m=l.getCacheControl(c.providerOptions,{type:`assistant message part`,canCache:!0})??(p?l.getCacheControl(u.providerOptions,{type:`assistant message`,canCache:!0}):void 0);switch(c.type){case`text`:{let t=c.providerOptions?.anthropic;if(t?.type===`compaction`){if(c.text===``)break;typeof t.signature==`string`&&s.add(`compact-2026-09-04`),e.push({type:`compaction`,content:c.text,...typeof t.signature==`string`&&{signature:t.signature},cache_control:m})}else e.push({type:`text`,text:v&&d&&p?c.text.trim():c.text,...t?.citations!=null&&{citations:t.citations},cache_control:m});break}case`reasoning`:if(t){let t=await M({provider:`anthropic`,providerOptions:c.providerOptions,schema:fe});t==null?n.push({type:`other`,message:`unsupported reasoning metadata`}):t.signature==null?t.redactedData==null?n.push({type:`other`,message:`unsupported reasoning metadata`}):(l.getCacheControl(c.providerOptions,{type:`redacted thinking block`,canCache:!1}),e.push({type:`redacted_thinking`,data:t.redactedData})):(l.getCacheControl(c.providerOptions,{type:`thinking block`,canCache:!1}),e.push({type:`thinking`,thinking:c.text,signature:t.signature}))}else n.push({type:`other`,message:`sending reasoning content is disabled for this model`});break;case`custom`:{if(c.kind!==`anthropic.fallback`)break;let t=await k({value:c.providerOptions?.anthropic,schema:K});if(!t.success){n.push({type:`other`,message:`anthropic fallback metadata must include from.model and to.model`});break}s.add(`server-side-fallback-2026-06-01`),e.push({type:`fallback`,from:t.value.from,to:t.value.to});break}case`tool-call`:{let t=jt(c.providerOptions);if(c.providerExecuted){let r=a.toProviderToolName(c.toolName);if(c.providerOptions?.anthropic?.type===`mcp-tool-use`){i.add(c.toolCallId);let t=c.providerOptions?.anthropic?.serverName;if(t==null||typeof t!=`string`){n.push({type:`other`,message:`mcp tool use server name is required and must be a string`});break}e.push({type:`mcp_tool_use`,id:c.toolCallId,name:c.toolName,input:c.input,server_name:t,cache_control:m})}else if(r===`code_execution`&&c.input!=null&&typeof c.input==`object`&&`type`in c.input&&typeof c.input.type==`string`&&(c.input.type===`bash_code_execution`||c.input.type===`text_editor_code_execution`)){let{type:n,...r}=c.input;e.push({type:`server_tool_use`,id:c.toolCallId,name:n,input:r,...t&&{caller:t},cache_control:m})}else if(r===`code_execution`&&c.input!=null&&typeof c.input==`object`&&`type`in c.input&&c.input.type===`programmatic-tool-call`){let{type:n,...r}=c.input;e.push({type:`server_tool_use`,id:c.toolCallId,name:`code_execution`,input:r,...t&&{caller:t},cache_control:m})}else r===`code_execution`||r===`web_fetch`||r===`web_search`||r===`tool_search_tool_regex`||r===`tool_search_tool_bm25`?e.push({type:`server_tool_use`,id:c.toolCallId,name:r,input:c.input,...t&&{caller:t},cache_control:m}):r===`advisor`?e.push({type:`server_tool_use`,id:c.toolCallId,name:`advisor`,input:{},...t&&{caller:t},cache_control:m}):n.push({type:`other`,message:`provider executed tool call for tool ${c.toolName} is not supported`});break}let r=At({toolName:c.toolName,providerOptions:c.providerOptions,toolsetNames:o});if(r!=null){let i=Mt(c.input),{action:a}=i,o=typeof a==`string`;o||n.push({type:`other`,message:`toolset tool call for tool ${c.toolName} is missing the action`}),e.push({type:`tool_use`,id:c.toolCallId,name:o?a:r,toolset_name:r,input:i,...t&&{caller:t},cache_control:m});break}e.push({type:`tool_use`,id:c.toolCallId,name:c.toolName,input:Mt(c.input),...t&&{caller:t},cache_control:m});break}case`tool-result`:{let t=a.toProviderToolName(c.toolName),r=jt(c.providerOptions);if(i.has(c.toolCallId)){let t=c.output;if(t.type!==`json`&&t.type!==`error-json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}e.push({type:`mcp_tool_result`,tool_use_id:c.toolCallId,is_error:t.type===`error-json`,content:t.value,cache_control:m})}else if(t===`code_execution`){let t=c.output;if(t.type===`error-text`||t.type===`error-json`){let n={};try{typeof t.value==`string`?n=N(t.value):typeof t.value==`object`&&t.value!==null&&(n=t.value)}catch{}n.type===`code_execution_tool_result_error`?e.push({type:`code_execution_tool_result`,tool_use_id:c.toolCallId,content:{type:`code_execution_tool_result_error`,error_code:n.errorCode??`unknown`},cache_control:m}):e.push({type:`bash_code_execution_tool_result`,tool_use_id:c.toolCallId,cache_control:m,content:{type:`bash_code_execution_tool_result_error`,error_code:n.errorCode??`unknown`}});break}if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}if(t.value==null||typeof t.value!=`object`||!(`type`in t.value)||typeof t.value.type!=`string`){n.push({type:`other`,message:`provider executed tool result output value is not a valid code execution result for tool ${c.toolName}`});break}if(t.value.type===`code_execution_result`){let n=await w({value:t.value,schema:lt});e.push({type:`code_execution_tool_result`,tool_use_id:c.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:m})}else if(t.value.type===`encrypted_code_execution_result`){let n=await w({value:t.value,schema:_t});n.type===`encrypted_code_execution_result`&&e.push({type:`code_execution_tool_result`,tool_use_id:c.toolCallId,content:{type:n.type,encrypted_stdout:n.encrypted_stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:m})}else{let n=await w({value:t.value,schema:pt});n.type===`code_execution_result`?e.push({type:`code_execution_tool_result`,tool_use_id:c.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content??[]},cache_control:m}):n.type===`bash_code_execution_result`||n.type===`bash_code_execution_tool_result_error`?e.push({type:`bash_code_execution_tool_result`,tool_use_id:c.toolCallId,cache_control:m,content:n.type===`bash_code_execution_result`?{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code,content:n.content}:n}):e.push({type:`text_editor_code_execution_tool_result`,tool_use_id:c.toolCallId,cache_control:m,content:n})}break}if(t===`web_fetch`){let t=c.output;if(t.type===`error-json`){e.push({type:`web_fetch_tool_result`,tool_use_id:c.toolCallId,content:{type:`web_fetch_tool_result_error`,error_code:Et(t.value).errorCode??`unavailable`},...r&&{caller:r},cache_control:m});break}if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}let i=await w({value:t.value,schema:rt});e.push({type:`web_fetch_tool_result`,tool_use_id:c.toolCallId,content:{type:`web_fetch_result`,url:i.url,retrieved_at:i.retrievedAt,content:{type:`document`,title:i.content.title,citations:i.content.citations,source:{type:i.content.source.type,media_type:i.content.source.mediaType,data:i.content.source.data}}},...r&&{caller:r},cache_control:m});break}if(t===`web_search`){let t=c.output;if(t.type===`error-json`){e.push({type:`web_search_tool_result`,tool_use_id:c.toolCallId,content:{type:`web_search_tool_result_error`,error_code:Et(t.value).errorCode??`unavailable`},...r&&{caller:r},cache_control:m});break}if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}let i=await w({value:t.value,schema:He});e.push({type:`web_search_tool_result`,tool_use_id:c.toolCallId,content:i.map(e=>({url:e.url,title:e.title,page_age:e.pageAge,encrypted_content:e.encryptedContent,type:e.type})),...r&&{caller:r},cache_control:m});break}if(t===`tool_search_tool_regex`||t===`tool_search_tool_bm25`){let t=c.output;if(t.type!==`json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}let r=(await w({value:t.value,schema:xt})).map(e=>({type:`tool_reference`,tool_name:e.toolName}));e.push({type:`tool_search_tool_result`,tool_use_id:c.toolCallId,content:{type:`tool_search_tool_search_result`,tool_references:r},cache_control:m});break}if(t===`advisor`){let t=c.output;if(t.type!==`json`&&t.type!==`error-json`){n.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${c.toolName} is not supported`});break}let r=await w({value:t.value,schema:ye});r.type===`advisor_result`?e.push({type:`advisor_tool_result`,tool_use_id:c.toolCallId,content:{type:`advisor_result`,text:r.text,...r.stopReason!==void 0&&{stop_reason:r.stopReason}},cache_control:m}):r.type===`advisor_redacted_result`?e.push({type:`advisor_tool_result`,tool_use_id:c.toolCallId,content:{type:`advisor_redacted_result`,encrypted_content:r.encryptedContent,...r.stopReason!==void 0&&{stop_reason:r.stopReason}},cache_control:m}):e.push({type:`advisor_tool_result`,tool_use_id:c.toolCallId,content:{type:`advisor_tool_result_error`,error_code:r.errorCode},cache_control:m});break}n.push({type:`other`,message:`provider executed tool result for tool ${c.toolName} is not supported`});break}}}}e.length>0&&f.push({role:`assistant`,content:kt(e)});break}default:throw Error(`content type: ${y}`)}}let v=new Set;for(let e of f)if(e.role===`assistant`)for(let t of e.content)t.type===`server_tool_use`&&t.name===`code_execution`&&v.add(t.id);let y=new Set;for(let e=0;e<p;e++){let t=f[e];if(t.role===`assistant`)for(let e of t.content){if(!(`caller`in e))continue;let t=e.caller;if(t==null||t.type===`direct`||v.has(t.tool_id))continue;let r=`id`in e?e.id:e.tool_use_id;delete e.caller,y.has(r)||(y.add(r),n.push({type:`other`,message:`Omitted caller metadata for tool ${r} because source code execution tool ${t.tool_id} is missing from the conversation history.`}))}}return{prompt:{system:u,messages:f},betas:s}}function Ot(e){let t=[],n;for(let r of e){let{role:e}=r;switch(e){case`system`:n?.type!==`system`&&(n={type:`system`,messages:[]},t.push(n)),n.messages.push(r);break;case`assistant`:n?.type!==`assistant`&&(n={type:`assistant`,messages:[]},t.push(n)),n.messages.push(r);break;case`user`:n?.type!==`user`&&(n={type:`user`,messages:[]},t.push(n)),n.messages.push(r);break;case`tool`:n?.type!==`user`&&(n={type:`user`,messages:[]},t.push(n)),n.messages.push(r);break;default:throw Error(`Unsupported role: ${e}`)}}return t}function kt(e){let t=[],n=[];function r(){t.push(...n.filter(e=>e.type!==`tool_use`),...n.filter(e=>e.type===`tool_use`)),n=[]}for(let i of e)i.type===`thinking`||i.type===`redacted_thinking`||i.type===`fallback`?(r(),t.push(i)):n.push(i);return r(),t}function At({toolName:e,providerOptions:t,toolsetNames:n}){let r=n[e];if(r!=null)return r;let i=t?.anthropic?.toolsetName;return typeof i==`string`?i:void 0}function jt(e){let t=e?.anthropic?.caller;return(t?.type===`code_execution_20250825`||t?.type===`code_execution_20260120`)&&t.toolId?{type:t.type,tool_id:t.toolId}:t?.type===`direct`?{type:`direct`}:void 0}function Mt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{rawInvalidInput:e}}function Nt({finishReason:e,isJsonResponseFromTool:t}){switch(e){case`pause_turn`:case`end_turn`:case`stop_sequence`:return`stop`;case`refusal`:return`content-filter`;case`tool_use`:return t?`stop`:`tool-calls`;case`max_tokens`:case`model_context_window_exceeded`:return`length`;case`compaction`:return`other`;default:return`other`}}const Pt=new Set([`date-time`,`time`,`date`,`duration`,`email`,`hostname`,`uri`,`ipv4`,`ipv6`,`uuid`]),Ft=[`minimum`,`maximum`,`exclusiveMinimum`,`exclusiveMaximum`,`multipleOf`,`minLength`,`maxLength`,`pattern`,`minItems`,`maxItems`,`uniqueItems`,`minProperties`,`maxProperties`,`not`];function It(e){return Lt(e)}function Q(e){return typeof e==`boolean`||!g(e)?e:Lt(e)}function Lt(e){let t={},n=e;if(e.$ref!=null)return{$ref:e.$ref};if(e.$schema!=null&&(t.$schema=e.$schema),e.$id!=null&&(t.$id=e.$id),e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description),e.default!==void 0&&(t.default=e.default),e.const!==void 0&&(t.const=e.const),e.enum!=null&&(t.enum=e.enum),e.type!=null&&(t.type=e.type),e.anyOf==null?e.oneOf!=null&&(t.anyOf=e.oneOf.map(Q)):t.anyOf=e.anyOf.map(Q),e.allOf!=null&&(t.allOf=e.allOf.map(Q)),e.definitions!=null&&(t.definitions=Object.fromEntries(Object.entries(e.definitions).map(([e,t])=>[e,Q(t)]))),n.$defs!=null){let e=t;e.$defs=Object.fromEntries(Object.entries(n.$defs).map(([e,t])=>[e,Q(t)]))}(e.type===`object`||e.properties!=null)&&(e.properties!=null&&(t.properties=Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,Q(t)]))),t.additionalProperties=!1,e.required!=null&&(t.required=e.required)),e.items!=null&&(t.items=Array.isArray(e.items)?e.items.map(Q):Q(e.items)),typeof e.format==`string`&&Pt.has(e.format)&&(t.format=e.format);let r=Rt(e);return r!=null&&(t.description=t.description==null?r:`${t.description}\n${r}`),t}function Rt(e){let t=Ft.flatMap(t=>{let n=e[t];return n==null||n===!1?[]:`${zt(t)}: ${Bt(n)}`});return typeof e.format==`string`&&!Pt.has(e.format)&&t.push(`format: ${e.format}`),t.length===0?void 0:`${t.join(`; `)}.`}function zt(e){return e.replace(/[A-Z]/g,e=>` ${e.toLowerCase()}`)}function Bt(e){return typeof e==`string`?e:JSON.stringify(e)}function Vt(e){let t=Ht(e.type);return h({message:e.message,type:e.type,code:e.code??void 0,statusCode:e.statusCode??t.statusCode,isRetryable:e.isRetryable??t.isRetryable,data:`data`in e?e.data:e})}function Ht(e){switch(e){case`api_error`:return{statusCode:500,isRetryable:!0};case`overloaded_error`:return{statusCode:529,isRetryable:!0};case`rate_limit_error`:return{statusCode:429,isRetryable:!0};case`request_too_large`:return{statusCode:413,isRetryable:!1};case`authentication_error`:return{statusCode:401,isRetryable:!1};case`permission_error`:return{statusCode:403,isRetryable:!1};case`not_found_error`:return{statusCode:404,isRetryable:!1};case`billing_error`:case`invalid_request_error`:return{statusCode:400,isRetryable:!1};default:return{}}}function Ut(e,t,n){if(e.type===`web_search_result_location`)return{type:`source`,sourceType:`url`,id:n(),url:e.url,title:e.title??void 0,providerMetadata:{anthropic:{citedText:e.cited_text,encryptedIndex:e.encrypted_index}}};if(e.type!==`page_location`&&e.type!==`char_location`)return;let r=t[e.document_index];if(r)return{type:`source`,sourceType:`document`,id:n(),mediaType:r.mediaType,title:e.document_title??r.title,filename:r.filename,providerMetadata:{anthropic:e.type===`page_location`?{citedText:e.cited_text,startPageNumber:e.start_page_number,endPageNumber:e.end_page_number}:{citedText:e.cited_text,startCharIndex:e.start_char_index,endCharIndex:e.end_char_index}}}}function Wt(e){return e==null?void 0:{type:e.type,toolId:`tool_id`in e?e.tool_id:void 0}}function $(e){let t=Wt(e);return t==null?{}:{providerMetadata:{anthropic:{caller:t}}}}function Gt(e){let t={};for(let n of e??[])n.type===`provider`&&n.id===`anthropic.computer_toolset_20260801`&&(t[n.name]=`computer`);return t}function Kt({memberName:e,input:t}){return{action:e,...typeof t==`object`&&t&&!Array.isArray(t)?t:{}}}function qt(e){let t=e.indexOf(`.`);return t===-1?e:e.substring(0,t)}var Jt=class r{static[V](e){return ne({modelId:e.modelId,config:e.config})}static[H](e){return new r(e.modelId,e.config)}constructor(e,t){this.specificationVersion=`v4`,this.modelId=e,this.config=t,this.generateId=t.generateId??f}supportsUrl(e){return e.protocol===`https:`}get provider(){return this.config.provider}get supportedUrls(){return this.config.supportedUrls?.()??{}}static async prepareRequest({modelId:e,config:n,options:{userSuppliedBetas:r,prompt:i,maxOutputTokens:a,temperature:o,topP:c,topK:l,frequencyPenalty:u,presencePenalty:d,stopSequences:f,responseFormat:p,seed:m,tools:h,toolChoice:g,reasoning:_,providerOptions:v,stream:y}}){let b=[];u!=null&&b.push({type:`unsupported`,feature:`frequencyPenalty`}),d!=null&&b.push({type:`unsupported`,feature:`presencePenalty`}),m!=null&&b.push({type:`unsupported`,feature:`seed`}),o!=null&&o>1?(b.push({type:`unsupported`,feature:`temperature`,details:`${o} exceeds anthropic maximum of 1.0. clamped to 1.0`}),o=1):o!=null&&o<0&&(b.push({type:`unsupported`,feature:`temperature`,details:`${o} is below anthropic minimum of 0. clamped to 0`}),o=0),p?.type===`json`&&(p.schema??b.push({type:`unsupported`,feature:`responseFormat`,details:`JSON response format requires a schema. The response format is ignored.`}));let x=qt(n.provider),S=await M({provider:`anthropic`,providerOptions:v,schema:he}),C=x===`anthropic`?null:await M({provider:x,providerOptions:v,schema:he}),w=C!=null,T=Object.assign({},S??{},C??{}),{maxOutputTokens:E,supportsStructuredOutput:D,supportsAdaptiveThinking:O,rejectsSamplingParameters:k,supportsXhighEffort:ee,rejectsThinkingDisabledAboveHighEffort:A,rejectsThinkingDisabled:j,rejectsBudgetThinking:ne,rejectsForcedToolUse:N,supportsBetweenToolsThinking:P,isKnownModel:F}=Yt(e);!F&&a==null&&b.push({type:`compatibility`,feature:`maxOutputTokens`,details:`The model "${e}" is unknown. The max output tokens have been limited to ${E}. Set maxOutputTokens explicitly to override this limit.`}),k&&(o!=null&&(b.push({type:`unsupported`,feature:`temperature`,details:`temperature is not supported by ${e} and will be ignored`}),o=void 0),l!=null&&(b.push({type:`unsupported`,feature:`topK`,details:`topK is not supported by ${e} and will be ignored`}),l=void 0),c!=null&&(b.push({type:`unsupported`,feature:`topP`,details:`topP is not supported by ${e} and will be ignored`}),c=void 0));let I=F||e.includes(`claude-`),L=(n.supportsNativeStructuredOutput??!0)&&D,re=(n.supportsStrictTools??!0)&&D,ie=T?.structuredOutputMode??`auto`,R=ie===`outputFormat`||ie===`auto`&&L;!R&&N&&L&&p?.type===`json`&&p.schema!=null&&(b.push({type:`unsupported`,feature:`providerOptions.anthropic.structuredOutputMode`,details:`structuredOutputMode 'jsonTool' is not supported by ${e} because it rejects forced tool use. Using 'outputFormat' instead.`}),R=!0);let z=p?.type===`json`&&p.schema!=null&&!R?{type:`function`,name:`json`,description:`Respond with a JSON object.`,inputSchema:p.schema}:void 0;z!=null&&T?.disableParallelToolUse===!1&&b.push({type:`unsupported`,feature:`providerOptions.anthropic.disableParallelToolUse`,details:"`disableParallelToolUse: false` is ignored when using the JSON response tool. Parallel tool use is disabled to ensure a single coherent JSON tool call."});let B=T?.contextManagement,V=T?.compaction;if(B!=null&&V!=null)throw new t({argument:`providerOptions`,message:"Anthropic provider options `compaction` and `contextManagement` cannot be used together."});let H=new _e,oe=s({tools:h,providerToolNames:{"anthropic.code_execution_20250522":`code_execution`,"anthropic.code_execution_20250825":`code_execution`,"anthropic.code_execution_20260120":`code_execution`,"anthropic.computer_20241022":`computer`,"anthropic.computer_20250124":`computer`,"anthropic.computer_20251124":`computer`,"anthropic.computer_toolset_20260801":`computer`,"anthropic.text_editor_20241022":`str_replace_editor`,"anthropic.text_editor_20250124":`str_replace_editor`,"anthropic.text_editor_20250429":`str_replace_based_edit_tool`,"anthropic.text_editor_20250728":`str_replace_based_edit_tool`,"anthropic.bash_20241022":`bash`,"anthropic.bash_20250124":`bash`,"anthropic.memory_20250818":`memory`,"anthropic.web_search_20250305":`web_search`,"anthropic.web_search_20260209":`web_search`,"anthropic.web_search_20260318":`web_search`,"anthropic.web_fetch_20250910":`web_fetch`,"anthropic.web_fetch_20260209":`web_fetch`,"anthropic.web_fetch_20260318":`web_fetch`,"anthropic.tool_search_regex_20251119":`tool_search_tool_regex`,"anthropic.tool_search_bm25_20251119":`tool_search_tool_bm25`,"anthropic.advisor_20260301":`advisor`}}),U=Gt(h),{prompt:se,betas:W}=await Dt({prompt:i,sendReasoning:T?.sendReasoning??!0,warnings:b,cacheControlValidator:H,toolNameMapping:oe,toolsetNames:U});if(ae(_)&&T?.effort==null){let t=Zt({reasoning:_,modelId:e,supportsAdaptiveThinking:O,supportsXhighEffort:ee,rejectsThinkingDisabled:j,supportsBetweenToolsThinking:P,maxOutputTokensForModel:E,warnings:b});t!=null&&(T.thinking??=t.thinking,t.effort!=null&&T.thinking?.type!==`disabled`&&(T.effort=t.effort))}if(j&&T?.thinking!=null){let t=T.thinking;t.type===`disabled`&&P?(b.push({type:`unsupported`,feature:`providerOptions.anthropic.thinking`,details:`thinking cannot be disabled for ${e}. Using 'between_tools' thinking, the lowest thinking setting, instead.`}),T.thinking={type:`between_tools`}):t.type===`disabled`&&(b.push({type:`unsupported`,feature:`providerOptions.anthropic.thinking`,details:`thinking cannot be disabled for ${e}; it always uses adaptive thinking. The thinking setting has been removed. Lower 'effort' to reduce thinking.`}),T.thinking=void 0)}ne&&T?.thinking?.type===`enabled`&&(b.push({type:`unsupported`,feature:`providerOptions.anthropic.thinking`,details:j?`budget-based thinking is not supported by ${e}; it always uses adaptive thinking. Using adaptive thinking instead. Use 'effort' to control how much the model thinks.`:`budget-based thinking is not supported by ${e}. Using adaptive thinking instead. Use 'effort' to control how much the model thinks.`}),T.thinking={type:`adaptive`}),A&&T?.thinking?.type===`disabled`&&(T.effort===`xhigh`||T.effort===`max`)&&(b.push({type:`unsupported`,feature:`providerOptions.anthropic.effort`,details:`effort '${T.effort}' is not supported by ${e} when thinking is disabled. The effort has been lowered to 'high'.`}),T.effort=`high`),T?.thinking?.type===`between_tools`&&(T.effort===`xhigh`||T.effort===`max`)&&(b.push({type:`unsupported`,feature:`providerOptions.anthropic.effort`,details:`effort '${T.effort}' is not supported with 'between_tools' thinking. The effort has been lowered to 'high'.`}),T.effort=`high`);let G=T?.thinking?.type,ce=G===`enabled`||G===`adaptive`||G===`between_tools`,K=T?.thinking!=null&&`blockBinding`in T.thinking?T.thinking.blockBinding:void 0,le=ce||G===`disabled`||K!=null,q=G===`enabled`?T?.thinking?.budgetTokens:void 0,J=G===`adaptive`?T?.thinking?.display:void 0,ue=a??E,Y={model:e,max_tokens:ue,temperature:o,top_k:l,top_p:c,stop_sequences:f,...le&&{thinking:{...G!=null&&{type:G},...q!=null&&{budget_tokens:q},...J!=null&&{display:J},...K!=null&&{block_binding:{prefix_mismatch_behavior:K.prefixMismatchBehavior}}}},...(T?.effort||T?.taskBudget||R&&p?.type===`json`&&p.schema!=null)&&{output_config:{...T?.effort&&{effort:T.effort},...T?.taskBudget&&{task_budget:{type:T.taskBudget.type,total:T.taskBudget.total,...T.taskBudget.remaining!=null&&{remaining:T.taskBudget.remaining}}},...R&&p?.type===`json`&&p.schema!=null&&{format:{type:`json_schema`,schema:It(p.schema)}}}},...T?.speed&&{speed:T.speed},...T?.serviceTier&&{service_tier:T.serviceTier},...T?.inferenceGeo&&{inference_geo:T.inferenceGeo},...T?.fallbacks!=null&&(T.fallbacks==="default"||T.fallbacks.length>0)&&{fallbacks:T.fallbacks},...T?.cacheControl&&{cache_control:T.cacheControl},...T?.metadata?.userId!=null&&{metadata:{user_id:T.metadata.userId}},...T?.mcpServers&&T.mcpServers.length>0&&{mcp_servers:T.mcpServers.map(e=>({type:e.type,name:e.name,url:e.url,authorization_token:e.authorizationToken,tool_configuration:e.toolConfiguration?{allowed_tools:e.toolConfiguration.allowedTools,enabled:e.toolConfiguration.enabled}:void 0}))},...T?.container&&{container:T.container.skills&&T.container.skills.length>0?{id:T.container.id,skills:T.container.skills.map(e=>({type:e.type,skill_id:e.type===`custom`?te({reference:e.providerReference,provider:`anthropic`}):e.skillId,version:e.version}))}:T.container.id},system:se.system,messages:se.messages,...T?.safeguards&&T.safeguards.length>0&&{safeguards:T.safeguards.map(e=>({type:e.type,...e.classifierContext!==void 0&&{classifier_context:e.classifierContext}}))},...V&&{compaction:{type:V.type,...V.instructions!==void 0&&{instructions:V.instructions}}},...B&&{context_management:{edits:B.edits.map(e=>{let t=e.type;switch(t){case`clear_tool_uses_20250919`:return{type:e.type,...e.trigger!==void 0&&{trigger:e.trigger},...e.keep!==void 0&&{keep:e.keep},...e.clearAtLeast!==void 0&&{clear_at_least:e.clearAtLeast},...e.clearToolInputs!==void 0&&{clear_tool_inputs:e.clearToolInputs},...e.excludeTools!==void 0&&{exclude_tools:e.excludeTools}};case`clear_thinking_20251015`:return{type:e.type,...e.keep!==void 0&&{keep:e.keep}};case`compact_20260112`:return{type:e.type,...e.trigger!==void 0&&{trigger:e.trigger},...e.pauseAfterCompaction!==void 0&&{pause_after_compaction:e.pauseAfterCompaction},...e.instructions!==void 0&&{instructions:e.instructions}};default:b.push({type:`other`,message:`Unknown context management strategy: ${t}`});return}}).filter(e=>e!==void 0)}}};ce?(G===`enabled`&&q==null&&(b.push({type:`compatibility`,feature:`extended thinking`,details:`thinking budget is required when thinking is enabled. using default budget of 1024 tokens.`}),Y.thinking={type:`enabled`,budget_tokens:1024},q=1024),Y.temperature!=null&&(Y.temperature=void 0,b.push({type:`unsupported`,feature:`temperature`,details:`temperature is not supported when thinking is enabled`})),l!=null&&(Y.top_k=void 0,b.push({type:`unsupported`,feature:`topK`,details:`topK is not supported when thinking is enabled`})),c!=null&&(Y.top_p=void 0,b.push({type:`unsupported`,feature:`topP`,details:`topP is not supported when thinking is enabled`})),Y.max_tokens=ue+(q??0)):I&&c!=null&&o!=null&&(b.push({type:`unsupported`,feature:`topP`,details:`topP is not supported when temperature is set. topP is ignored.`}),Y.top_p=void 0),F&&Y.max_tokens>E&&(a!=null&&b.push({type:`unsupported`,feature:`maxOutputTokens`,details:`${Y.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${e} ${E} max output tokens. The max output tokens have been limited to ${E}.`}),Y.max_tokens=E),T?.mcpServers&&T.mcpServers.length>0&&W.add(`mcp-client-2025-04-04`),T?.safeguards&&T.safeguards.length>0&&W.add(`dangerous-tool-use-2026-09-03`),V&&W.add(`compact-2026-09-04`),B&&(W.add(`context-management-2025-06-27`),B.edits.some(e=>e.type===`compact_20260112`)&&W.add(`compact-2026-01-12`)),T?.container&&T.container.skills&&T.container.skills.length>0&&(W.add(`code-execution-2025-08-25`),W.add(`skills-2025-10-02`),W.add(`files-api-2025-04-14`),h?.some(e=>e.type===`provider`&&(e.id===`anthropic.code_execution_20250825`||e.id===`anthropic.code_execution_20260120`))||b.push({type:`other`,message:`code execution tool is required when using skills`})),T?.taskBudget&&W.add(`task-budgets-2026-03-13`),T?.speed===`fast`&&W.add(`fast-mode-2026-02-01`),J===`updates`&&W.add(`thinking-display-updates-2026-08-18`),K!=null&&W.add(`thinking-binding-controls-2026-08-01`),T?.fallbacks==="default"?W.add(`server-side-fallback-2026-07-01`):T?.fallbacks&&T.fallbacks.length>0&&W.add(`server-side-fallback-2026-06-01`);let X=y&&(T?.toolStreaming??!0),{tools:Z,toolChoice:de,toolWarnings:fe,betas:pe}=await st(z==null?{tools:h??[],toolChoice:g,disableParallelToolUse:T?.disableParallelToolUse,cacheControlValidator:H,supportsStructuredOutput:L,supportsStrictTools:re,defaultEagerInputStreaming:X,rejectsForcedToolUse:N}:{tools:[...h??[],z],toolChoice:{type:`required`},disableParallelToolUse:!0,cacheControlValidator:H,supportsStructuredOutput:!1,supportsStrictTools:re,defaultEagerInputStreaming:X,rejectsForcedToolUse:N}),me=H.getWarnings();return{args:{...Y,tools:Z,tool_choice:de,stream:y===!0||void 0},warnings:[...b,...fe,...me],betas:new Set([...W,...pe,...r,...T?.anthropicBeta??[]]),usesJsonResponseTool:z!=null,toolNameMapping:oe,providerOptionsName:x,usedCustomProviderKey:w}}getArgs(e){return r.prepareRequest({modelId:this.modelId,config:this.config,options:e})}async getHeaders({betas:e,headers:t}){return C(this.config.headers?await L(this.config.headers):void 0,t,e.size>0?{"anthropic-beta":Array.from(e).join(`,`)}:{})}async getBetasFromHeaders(e){let t=(this.config.headers?await L(this.config.headers):void 0)?.[`anthropic-beta`]??``,n=e?.[`anthropic-beta`]??``;return new Set([...t.toLowerCase().split(`,`),...n.toLowerCase().split(`,`)].map(e=>e.trim()).filter(e=>e!==``))}buildRequestUrl(e){return this.config.buildRequestUrl?.(this.config.baseURL,e)??`${this.config.baseURL}/messages`}transformRequestBody(e,t){return this.config.transformRequestBody?.(e,t)??e}extractCitationDocuments(e){return e.filter(e=>e.role===`user`).flatMap(e=>e.content).filter(e=>e.type!==`file`||e.mediaType!==`application/pdf`&&e.mediaType!==`text/plain`?!1:e.providerOptions?.anthropic?.citations?.enabled??!1).map(e=>{let t=e;return{title:t.filename??`Untitled Document`,filename:t.filename,mediaType:t.mediaType}})}async doGenerate(e){let{args:t,warnings:n,betas:r,usesJsonResponseTool:i,toolNameMapping:a,providerOptionsName:o,usedCustomProviderKey:s}=await this.getArgs({...e,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders(e.headers)}),c=[...this.extractCitationDocuments(e.prompt)],l=Xt(t.tools),{responseHeaders:u,value:d,rawValue:f}=await A({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:r,headers:e.headers}),body:this.transformRequestBody(t,r),failedResponseHandler:W,successfulResponseHandler:B(Z),abortSignal:e.abortSignal,fetch:this.config.fetch}),p=[],m={},h={},g=!1;for(let e of d.content)switch(e.type){case`text`:if(!i){let t=e.citations?.filter(e=>e.type===`web_search_result_location`);if(p.push({type:`text`,text:e.text,...t!=null&&t.length>0&&{providerMetadata:{anthropic:{citations:t}}}}),e.citations)for(let t of e.citations){let e=Ut(t,c,this.generateId);e&&p.push(e)}}break;case`thinking`:p.push({type:`reasoning`,text:e.thinking,providerMetadata:{anthropic:{signature:e.signature}}});break;case`redacted_thinking`:p.push({type:`reasoning`,text:``,providerMetadata:{anthropic:{redactedData:e.data}}});break;case`container_upload`:p.push({type:`custom`,kind:`anthropic.container_upload`,providerMetadata:{anthropic:{fileId:e.file_id}}});break;case`compaction`:if(!e.content)break;p.push({type:`text`,text:e.content,providerMetadata:{anthropic:{type:`compaction`,...e.signature!=null&&{signature:e.signature}}}});break;case`tool_use`:i&&e.name===`json`?(g=!0,p.push({type:`text`,text:JSON.stringify(e.input)})):e.toolset_name==null?p.push({type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),...$(e.caller)}):p.push({type:`tool-call`,toolCallId:e.id,toolName:a.toCustomToolName(e.toolset_name),input:JSON.stringify(Kt({memberName:e.name,input:e.input})),providerMetadata:{anthropic:{toolsetName:e.toolset_name,...$(e.caller).providerMetadata?.anthropic}}});break;case`server_tool_use`:if(e.name===`text_editor_code_execution`||e.name===`bash_code_execution`)p.push({type:`tool-call`,toolCallId:e.id,toolName:a.toCustomToolName(`code_execution`),input:JSON.stringify({type:e.name,...e.input}),providerExecuted:!0,...l?{dynamic:!0}:{},...$(e.caller)});else if(e.name===`web_search`||e.name===`code_execution`||e.name===`web_fetch`){let t=e.name===`code_execution`&&e.input!=null&&typeof e.input==`object`&&`code`in e.input&&!(`type`in e.input)?{type:`programmatic-tool-call`,...e.input}:e.input;p.push({type:`tool-call`,toolCallId:e.id,toolName:a.toCustomToolName(e.name),input:JSON.stringify(t),providerExecuted:!0,...l&&e.name===`code_execution`?{dynamic:!0}:{},...$(e.caller)})}else e.name===`tool_search_tool_regex`||e.name===`tool_search_tool_bm25`?(h[e.id]=e.name,p.push({type:`tool-call`,toolCallId:e.id,toolName:a.toCustomToolName(e.name),input:JSON.stringify(e.input),providerExecuted:!0,...$(e.caller)})):e.name===`advisor`&&p.push({type:`tool-call`,toolCallId:e.id,toolName:a.toCustomToolName(`advisor`),input:JSON.stringify(e.input),providerExecuted:!0,...$(e.caller)});break;case`mcp_tool_use`:m[e.id]={type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:`mcp-tool-use`,serverName:e.server_name}}},p.push(m[e.id]);break;case`mcp_tool_result`:p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:m[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:m[e.tool_use_id].providerMetadata});break;case`web_fetch_tool_result`:e.content.type===`web_fetch_result`?(c.push({title:e.content.content.title??e.content.url,mediaType:e.content.content.source.media_type}),p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`web_fetch`),result:{type:`web_fetch_result`,url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}},...$(e.caller)})):e.content.type===`web_fetch_tool_result_error`&&p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`web_fetch`),isError:!0,result:{type:`web_fetch_tool_result_error`,errorCode:e.content.error_code},...$(e.caller)});break;case`web_search_tool_result`:if(Array.isArray(e.content)){p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`web_search`),result:e.content.map(e=>({url:e.url,...e.title==null?{}:{title:e.title},pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type})),...$(e.caller)});for(let t of e.content)p.push({type:`source`,sourceType:`url`,id:this.generateId(),url:t.url,...t.title==null?{}:{title:t.title},providerMetadata:{anthropic:{pageAge:t.page_age??null}}})}else p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`web_search`),isError:!0,result:{type:`web_search_tool_result_error`,errorCode:e.content.error_code},...$(e.caller)});break;case`code_execution_tool_result`:e.content.type===`code_execution_result`?p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`code_execution`),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`encrypted_code_execution_result`?p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`code_execution`),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`code_execution_tool_result_error`&&p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`code_execution`),isError:!0,result:{type:`code_execution_tool_result_error`,errorCode:e.content.error_code}});break;case`bash_code_execution_tool_result`:case`text_editor_code_execution_tool_result`:p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(`code_execution`),result:e.content});break;case`tool_search_tool_result`:{let t=h[e.tool_use_id];if(t==null){let e=a.toCustomToolName(`tool_search_tool_bm25`);a.toCustomToolName(`tool_search_tool_regex`),t=e===`tool_search_tool_bm25`?`tool_search_tool_regex`:`tool_search_tool_bm25`}e.content.type===`tool_search_tool_search_result`?p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:a.toCustomToolName(t),isError:!0,result:{type:`tool_search_tool_result_error`,errorCode:e.content.error_code}});break}case`advisor_tool_result`:{let t=a.toCustomToolName(`advisor`);e.content.type===`advisor_result`?p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_result`,text:e.content.text,...e.content.stop_reason!=null&&{stopReason:e.content.stop_reason}}}):e.content.type===`advisor_redacted_result`?p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_redacted_result`,encryptedContent:e.content.encrypted_content,...e.content.stop_reason!=null&&{stopReason:e.content.stop_reason}}}):p.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,isError:!0,result:{type:`advisor_tool_result_error`,errorCode:e.content.error_code}});break}case`fallback`:p.push({type:`custom`,kind:`anthropic.fallback`,providerMetadata:{anthropic:{type:`fallback`,from:e.from,to:e.to}}})}return{content:p,finishReason:{unified:Nt({finishReason:d.stop_reason,isJsonResponseFromTool:g}),raw:d.stop_reason??void 0},usage:ct({usage:d.usage}),request:{body:t},response:{id:d.id??void 0,modelId:d.model??void 0,headers:u,body:f},warnings:n,providerMetadata:(()=>{let e=$t(d.stop_details),t={usage:d.usage,stopSequence:d.stop_sequence??null,...e==null?{}:{stopDetails:e},...d.input_transformations==null?{}:{inputTransformations:d.input_transformations},...d.safeguard_results==null?{}:{safeguardResults:d.safeguard_results},iterations:d.usage.iterations?d.usage.iterations.map(e=>({type:e.type,...e.model==null?{}:{model:e.model},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:d.container?{expiresAt:d.container.expires_at,id:d.container.id,skills:d.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null}:null,contextManagement:Qt(d.context_management)??null},n={anthropic:t};return s&&o!==`anthropic`&&(n[o]=t),n})()}}async doStream(t){"use step";let{args:r,warnings:i,betas:a,usesJsonResponseTool:o,toolNameMapping:s,providerOptionsName:c,usedCustomProviderKey:u}=await this.getArgs({...t,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders(t.headers)}),d=[...this.extractCitationDocuments(t.prompt)],f=Xt(r.tools),p=this.buildRequestUrl(!0),{responseHeaders:m,value:h}=await A({url:p,headers:await this.getHeaders({betas:a,headers:t.headers}),body:this.transformRequestBody(r,a),failedResponseHandler:W,successfulResponseHandler:ee(de),abortSignal:t.abortSignal,fetch:this.config.fetch}),g={unified:`other`,raw:void 0},_={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},v={},y={},b={},x=null,S,C=null,w,T,E,D=null,O=!1,k=!1,j,te=!1,ne,M=this.generateId,[P,F]=h.pipeThrough(new TransformStream({start(e){e.enqueue({type:`stream-start`,warnings:i})},transform(e,r){if(te)return;if(t.includeRawChunks&&r.enqueue({type:`raw`,rawValue:e.rawValue}),!e.success){r.enqueue({type:`error`,error:e.error});return}let i=e.value;switch(i.type){case`ping`:return;case`content_block_start`:{let e=i.content_block,t=e.type;if(t===`fallback`){r.enqueue({type:`custom`,kind:`anthropic.fallback`,providerMetadata:{anthropic:{type:`fallback`,from:e.from,to:e.to}}});return}switch(ne=t,t){case`text`:if(o)return;v[i.index]={type:`text`,citations:[]},r.enqueue({type:`text-start`,id:String(i.index)});return;case`thinking`:v[i.index]={type:`reasoning`},r.enqueue({type:`reasoning-start`,id:String(i.index)});return;case`redacted_thinking`:v[i.index]={type:`reasoning`},r.enqueue({type:`reasoning-start`,id:String(i.index),providerMetadata:{anthropic:{redactedData:e.data}}});return;case`compaction`:v[i.index]={type:`text`,citations:[]},r.enqueue({type:`text-start`,id:String(i.index),providerMetadata:{anthropic:{type:`compaction`,...e.signature!=null&&{signature:e.signature}}}}),e.signature!=null&&e.content!=null&&e.content!==``&&r.enqueue({type:`text-delta`,id:String(i.index),delta:e.content});return;case`tool_use`:if(o&&e.name===`json`)O=!0,v[i.index]={type:`text`,citations:[]},r.enqueue({type:`text-start`,id:String(i.index)});else if(e.toolset_name!=null){let t=Wt(e.caller),n=s.toCustomToolName(e.toolset_name),a=e.input&&Object.keys(e.input).length>0;v[i.index]={type:`tool-call`,toolCallId:e.id,toolName:n,input:a?JSON.stringify(e.input):``,firstDelta:!0,toolset:{name:e.toolset_name,memberName:e.name},...t&&{caller:t}},r.enqueue({type:`tool-input-start`,id:e.id,toolName:n})}else{let t=Wt(e.caller),n=e.input&&Object.keys(e.input).length>0?JSON.stringify(e.input):``;v[i.index]={type:`tool-call`,toolCallId:e.id,toolName:e.name,input:n,firstDelta:n.length===0,...t&&{caller:t}},r.enqueue({type:`tool-input-start`,id:e.id,toolName:e.name})}return;case`server_tool_use`:{let t=Wt(e.caller);if([`web_fetch`,`web_search`,`code_execution`,`text_editor_code_execution`,`bash_code_execution`].includes(e.name)){let n=e.name===`text_editor_code_execution`||e.name===`bash_code_execution`?`code_execution`:e.name,a=e.name===`text_editor_code_execution`||e.name===`bash_code_execution`?e.name:e.name===`code_execution`?`programmatic-tool-call`:void 0,o=s.toCustomToolName(n),c=e.input!=null&&typeof e.input==`object`&&Object.keys(e.input).length>0?JSON.stringify(e.input):``;v[i.index]={type:`tool-call`,toolCallId:e.id,toolName:o,input:c,providerExecuted:!0,...f&&n===`code_execution`?{dynamic:!0}:{},firstDelta:c.length===0,providerToolName:n,providerToolInputType:a,...t&&{caller:t}},r.enqueue({type:`tool-input-start`,id:e.id,toolName:o,providerExecuted:!0,...f&&n===`code_execution`?{dynamic:!0}:{}})}else if(e.name===`tool_search_tool_regex`||e.name===`tool_search_tool_bm25`){b[e.id]=e.name;let n=s.toCustomToolName(e.name);v[i.index]={type:`tool-call`,toolCallId:e.id,toolName:n,input:``,providerExecuted:!0,firstDelta:!0,providerToolName:e.name,...t&&{caller:t}},r.enqueue({type:`tool-input-start`,id:e.id,toolName:n,providerExecuted:!0})}else if(e.name===`advisor`){let n=s.toCustomToolName(`advisor`);v[i.index]={type:`tool-call`,toolCallId:e.id,toolName:n,input:`{}`,providerExecuted:!0,firstDelta:!0,providerToolName:e.name,...t&&{caller:t}},r.enqueue({type:`tool-input-start`,id:e.id,toolName:n,providerExecuted:!0})}return}case`web_fetch_tool_result`:e.content.type===`web_fetch_result`?(d.push({title:e.content.content.title??e.content.url,mediaType:e.content.content.source.media_type}),r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`web_fetch`),result:{type:`web_fetch_result`,url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}},...$(e.caller)})):e.content.type===`web_fetch_tool_result_error`&&r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`web_fetch`),isError:!0,result:{type:`web_fetch_tool_result_error`,errorCode:e.content.error_code},...$(e.caller)});return;case`web_search_tool_result`:if(Array.isArray(e.content)){r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`web_search`),result:e.content.map(e=>({url:e.url,...e.title==null?{}:{title:e.title},pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type})),...$(e.caller)});for(let t of e.content)r.enqueue({type:`source`,sourceType:`url`,id:M(),url:t.url,...t.title==null?{}:{title:t.title},providerMetadata:{anthropic:{pageAge:t.page_age??null}}})}else r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`web_search`),isError:!0,result:{type:`web_search_tool_result_error`,errorCode:e.content.error_code},...$(e.caller)});return;case`code_execution_tool_result`:e.content.type===`code_execution_result`?r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`code_execution`),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`encrypted_code_execution_result`?r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`code_execution`),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:e.content.content??[]}}):e.content.type===`code_execution_tool_result_error`&&r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`code_execution`),isError:!0,result:{type:`code_execution_tool_result_error`,errorCode:e.content.error_code}});return;case`bash_code_execution_tool_result`:case`text_editor_code_execution_tool_result`:r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(`code_execution`),result:e.content});return;case`tool_search_tool_result`:{let t=b[e.tool_use_id];if(t==null){let e=s.toCustomToolName(`tool_search_tool_bm25`);s.toCustomToolName(`tool_search_tool_regex`),t=e===`tool_search_tool_bm25`?`tool_search_tool_regex`:`tool_search_tool_bm25`}e.content.type===`tool_search_tool_search_result`?r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:s.toCustomToolName(t),isError:!0,result:{type:`tool_search_tool_result_error`,errorCode:e.content.error_code}});return}case`advisor_tool_result`:{let t=s.toCustomToolName(`advisor`);e.content.type===`advisor_result`?r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_result`,text:e.content.text,...e.content.stop_reason!=null&&{stopReason:e.content.stop_reason}}}):e.content.type===`advisor_redacted_result`?r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,result:{type:`advisor_redacted_result`,encryptedContent:e.content.encrypted_content,...e.content.stop_reason!=null&&{stopReason:e.content.stop_reason}}}):r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:t,isError:!0,result:{type:`advisor_tool_result_error`,errorCode:e.content.error_code}});return}case`mcp_tool_use`:y[e.id]={type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:`mcp-tool-use`,serverName:e.server_name}}},r.enqueue(y[e.id]);return;case`mcp_tool_result`:r.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:y[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:y[e.tool_use_id].providerMetadata});return;default:throw Error(`Unsupported content block type: ${t}`)}}case`content_block_stop`:if(v[i.index]!=null){let e=v[i.index];switch(e.type){case`text`:r.enqueue({type:`text-end`,id:String(i.index),...e.citations.length>0&&{providerMetadata:{anthropic:{citations:e.citations}}}});break;case`reasoning`:r.enqueue({type:`reasoning-end`,id:String(i.index)});break;case`tool-call`:if(!(o&&e.toolName===`json`)){if(e.toolset!=null){let t={};try{t=e.input===``?{}:N(e.input)}catch{t=void 0}e.input=t===void 0?e.input:JSON.stringify(Kt({memberName:e.toolset.memberName,input:t})),r.enqueue({type:`tool-input-delta`,id:e.toolCallId,delta:e.input})}r.enqueue({type:`tool-input-end`,id:e.toolCallId});let t=e.input===``?`{}`:e.input;if(e.providerToolName===`code_execution`)try{let e=N(t);typeof e==`object`&&e&&`code`in e&&!(`type`in e)&&(t=JSON.stringify({type:`programmatic-tool-call`,...e}))}catch{}r.enqueue({type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:t,providerExecuted:e.providerExecuted,...f&&e.providerToolName===`code_execution`?{dynamic:!0}:{},...(e.caller||e.toolset)&&{providerMetadata:{anthropic:{...e.toolset&&{toolsetName:e.toolset.name},...e.caller&&{caller:e.caller}}}}})}}delete v[i.index]}ne=void 0;return;case`content_block_delta`:{let e=i.delta.type;switch(e){case`text_delta`:if(o)return;r.enqueue({type:`text-delta`,id:String(i.index),delta:i.delta.text});return;case`thinking_delta`:r.enqueue({type:`reasoning-delta`,id:String(i.index),delta:i.delta.thinking});return;case`signature_delta`:ne===`thinking`&&r.enqueue({type:`reasoning-delta`,id:String(i.index),delta:``,providerMetadata:{anthropic:{signature:i.delta.signature}}});return;case`compaction_delta`:i.delta.content!=null&&r.enqueue({type:`text-delta`,id:String(i.index),delta:i.delta.content});return;case`input_json_delta`:{let e=v[i.index],t=i.delta.partial_json;if(t.length===0)return;if(O){if(e?.type!==`text`)return;r.enqueue({type:`text-delta`,id:String(i.index),delta:t})}else{if(e?.type!==`tool-call`)return;if(e.toolset!=null){e.input+=t;return}e.firstDelta&&e.providerToolInputType!=null&&(t=`{"type": "${e.providerToolInputType}",${t.substring(1)}`),r.enqueue({type:`tool-input-delta`,id:e.toolCallId,delta:t}),e.input+=t,e.firstDelta=!1}return}case`citations_delta`:{let e=i.delta.citation,t=v[i.index];t?.type===`text`&&e.type===`web_search_result_location`&&t.citations.push(e);let n=Ut(e,d,M);n&&r.enqueue(n);return}default:throw Error(`Unsupported delta type: ${e}`)}}case`message_start`:if(k){if(j===i.message.id)return;te=!0,r.enqueue({type:`error`,error:new n({data:i,message:`Received message_start for message ${JSON.stringify(i.message.id)} while message ${JSON.stringify(j)} is still open.`})});return}if(k=!0,j=i.message.id,_.input_tokens=i.message.usage.input_tokens,_.cache_read_input_tokens=i.message.usage.cache_read_input_tokens??0,_.cache_creation_input_tokens=i.message.usage.cache_creation_input_tokens??0,S={...i.message.usage},i.message.input_transformations!=null&&(T=i.message.input_transformations),i.message.container!=null&&(D={expiresAt:i.message.container.expires_at,id:i.message.container.id,skills:null}),i.message.stop_reason!=null&&(g={unified:Nt({finishReason:i.message.stop_reason,isJsonResponseFromTool:O}),raw:i.message.stop_reason}),r.enqueue({type:`response-metadata`,id:i.message.id??void 0,modelId:i.message.model??void 0}),r.enqueue({type:`custom`,kind:`anthropic.message_start`,providerMetadata:{anthropic:{id:i.message.id??null,model:i.message.model??null,usage:S}}}),i.message.content!=null)for(let e=0;e<i.message.content.length;e++){let t=i.message.content[e];if(t.type===`tool_use`){let e=Wt(t.caller);r.enqueue({type:`tool-input-start`,id:t.id,toolName:t.name});let n=JSON.stringify(t.input??{});r.enqueue({type:`tool-input-delta`,id:t.id,delta:n}),r.enqueue({type:`tool-input-end`,id:t.id}),r.enqueue({type:`tool-call`,toolCallId:t.id,toolName:t.name,input:n,...e&&{providerMetadata:{anthropic:{caller:e}}}})}}return;case`message_delta`:i.usage.input_tokens!=null&&_.input_tokens!==i.usage.input_tokens&&(_.input_tokens=i.usage.input_tokens),_.output_tokens=i.usage.output_tokens,i.usage.output_tokens_details!=null&&(_.output_tokens_details=i.usage.output_tokens_details),i.usage.cache_read_input_tokens!=null&&(_.cache_read_input_tokens=i.usage.cache_read_input_tokens),i.usage.cache_creation_input_tokens!=null&&(_.cache_creation_input_tokens=i.usage.cache_creation_input_tokens),i.usage.iterations!=null&&(_.iterations=i.usage.iterations),g={unified:Nt({finishReason:i.delta.stop_reason,isJsonResponseFromTool:O}),raw:i.delta.stop_reason??void 0},C=i.delta.stop_sequence??null,w=$t(i.delta.stop_details),D=i.delta.container==null?null:{expiresAt:i.delta.container.expires_at,id:i.delta.container.id,skills:i.delta.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null},i.context_management&&(x=Qt(i.context_management)),i.input_transformations!=null&&(T=i.input_transformations),i.delta.safeguard_results!=null&&(E=i.delta.safeguard_results),S={...S,...i.usage};return;case`message_stop`:{k=!1,j=void 0;let e={usage:S??null,stopSequence:C,...w==null?{}:{stopDetails:w},...T==null?{}:{inputTransformations:T},...E==null?{}:{safeguardResults:E},iterations:_.iterations?_.iterations.map(e=>({type:e.type,...e.model==null?{}:{model:e.model},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:D,contextManagement:x},t={anthropic:e};u&&c!==`anthropic`&&(t[c]=e),r.enqueue({type:`finish`,finishReason:g,usage:ct({usage:_,rawUsage:S}),providerMetadata:t});return}case`error`:r.enqueue({type:`error`,error:Vt(i.error)});return;default:throw Error(`Unsupported chunk type: ${i}`)}}})).tee(),I=P.getReader();try{await I.read();let t=await I.read();if(t.value?.type===`raw`&&(t=await I.read()),t.value?.type===`error`){let n=t.value.error;throw l(n)?new e({message:n.message,url:p,requestBodyValues:r,statusCode:n.statusCode??500,responseHeaders:m,responseBody:JSON.stringify(n.data),isRetryable:n.isRetryable??!1}):Error(`Expected a normalized Anthropic stream error`)}}finally{I.cancel().catch(()=>{}),I.releaseLock()}return{stream:F,request:{body:r},response:{headers:m}}}};function Yt(e){return e.includes(`claude-sonnet-5-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!0,rejectsBudgetThinking:!0,rejectsForcedToolUse:!0,supportsBetweenToolsThinking:!0,isKnownModel:!0}:e.includes(`claude-opus-5-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!0,rejectsBudgetThinking:!0,rejectsForcedToolUse:!0,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-haiku-5-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!0,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-opus-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-fable-5-1`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!0,rejectsBudgetThinking:!0,rejectsForcedToolUse:!0,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-fable-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!0,rejectsBudgetThinking:!0,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-opus-4-8`)||e.includes(`claude-opus-4-7`)||e.includes(`claude-sonnet-5`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-sonnet-4-6`)||e.includes(`claude-opus-4-6`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-sonnet-4-5`)||e.includes(`claude-opus-4-5`)||e.includes(`claude-haiku-4-5`)?{maxOutputTokens:64e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-opus-4-1`)?{maxOutputTokens:32e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:/claude-sonnet-4(?:-|@)/.test(e)?{maxOutputTokens:64e3,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:/claude-opus-4(?:-|@)/.test(e)?{maxOutputTokens:32e3,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:e.includes(`claude-3-haiku`)?{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!0}:/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(e)?{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!1}:e.includes(`claude-`)?{maxOutputTokens:128e3,supportsStructuredOutput:!0,supportsAdaptiveThinking:!0,rejectsSamplingParameters:!0,supportsXhighEffort:!0,rejectsThinkingDisabledAboveHighEffort:!0,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!1}:{maxOutputTokens:4096,supportsStructuredOutput:!1,supportsAdaptiveThinking:!1,rejectsSamplingParameters:!1,supportsXhighEffort:!1,rejectsThinkingDisabledAboveHighEffort:!1,rejectsThinkingDisabled:!1,rejectsBudgetThinking:!1,rejectsForcedToolUse:!1,supportsBetweenToolsThinking:!1,isKnownModel:!1}}function Xt(e){if(!e)return!1;let t=!1,n=!1;for(let r of e){if(`type`in r&&(r.type===`web_fetch_20260209`||r.type===`web_fetch_20260318`||r.type===`web_search_20260209`||r.type===`web_search_20260318`)){t=!0;continue}if(`type`in r&&(r.type===`code_execution_20250522`||r.type===`code_execution_20250825`||r.type===`code_execution_20260120`)){n=!0;break}}return t&&!n}function Zt({reasoning:e,modelId:t,supportsAdaptiveThinking:n,supportsXhighEffort:r,rejectsThinkingDisabled:i,supportsBetweenToolsThinking:a,maxOutputTokensForModel:o,warnings:s}){if(!ae(e))return;if(e===`none`)return a?{thinking:{type:`between_tools`}}:i?(s.push({type:`compatibility`,feature:`reasoning`,details:`reasoning 'none' is not supported by ${t}; it always uses adaptive thinking. Using effort 'low' to minimize thinking instead.`}),{effort:`low`}):{thinking:{type:`disabled`}};if(n)return{thinking:{type:`adaptive`,display:`summarized`},effort:b({reasoning:e,effortMap:{minimal:`low`,low:`low`,medium:`medium`,high:`high`,xhigh:r?`xhigh`:`max`,max:`max`},warnings:s})};let c=v({reasoning:e,maxOutputTokens:o,maxReasoningBudget:o,warnings:s});if(c!=null)return{thinking:{type:`enabled`,budgetTokens:c}}}function Qt(e){return e?{appliedEdits:e.applied_edits.map(e=>{switch(e.type){case`clear_tool_uses_20250919`:return{type:e.type,clearedToolUses:e.cleared_tool_uses,clearedInputTokens:e.cleared_input_tokens};case`clear_thinking_20251015`:return{type:e.type,clearedThinkingTurns:e.cleared_thinking_turns,clearedInputTokens:e.cleared_input_tokens};case`compact_20260112`:return{type:e.type}}}).filter(e=>e!==void 0)}:null}function $t(e){if(e!=null)return{type:e.type,...e.category==null?{}:{category:e.category},...e.explanation==null?{}:{explanation:e.explanation},...e.recommended_model==null?{}:{recommendedModel:e.recommended_model}}}const en=/^[A-Za-z0-9_-]{1,64}$/,tn=he.pick({anthropicBeta:!0}),nn=()=>U.object({id:U.string(),type:U.literal(`message_batch`),processing_status:U.string(),request_counts:U.object({processing:U.number(),succeeded:U.number(),errored:U.number(),canceled:U.number(),expired:U.number()}),created_at:U.string(),expires_at:U.string(),archived_at:U.string().nullish(),cancel_initiated_at:U.string().nullish(),ended_at:U.string().nullish(),results_url:U.string().nullish()}),rn=P(()=>z(nn())),an=P(()=>z(U.object({data:U.array(nn()),has_more:U.boolean(),last_id:U.string().nullish()}))),on=new Set([`advisor_tool_result`,`bash_code_execution_tool_result`,`code_execution_tool_result`,`compaction`,`container_upload`,`fallback`,`mcp_tool_result`,`mcp_tool_use`,`redacted_thinking`,`server_tool_use`,`text`,`text_editor_code_execution_tool_result`,`thinking`,`tool_search_tool_result`,`tool_use`,`web_fetch_tool_result`,`web_search_tool_result`]),sn=P(()=>z(U.discriminatedUnion(`type`,[U.object({type:U.literal(`succeeded`),message:U.unknown()}),U.object({type:U.literal(`errored`),error:U.object({type:U.literal(`error`),error:U.object({type:U.string(),message:U.string()}),request_id:U.string().nullish()})}),U.object({type:U.literal(`canceled`)}),U.object({type:U.literal(`expired`)})]))),cn=P(()=>z(U.object({custom_id:U.string(),result:U.unknown()})));function ln(e){for(let t of e){let e=t.type;if(e!==`text`)throw new i({functionality:`batch request type: ${e}`,message:`The Anthropic Message Batches API does not support batch requests with type "${e}".`})}}var un=class{constructor(e){this.options=e,this.specificationVersion=`v4`,this.provider=e.provider,this.supportedUrls=e.supportedUrls,this.generateId=e.config.generateId??f}async doStartBatch({requests:e,providerOptions:t,headers:n,abortSignal:r,webhookUrl:a}){ln(e),fn(e);let o=new Set(await dn({provider:this.options.config.provider,providerOptions:t})),s=new Set(o),c=[],l=a==null?[]:[{warning:{type:`unsupported`,feature:`webhookUrl`,details:`The Anthropic Message Batches API does not support completion webhooks.`}}];for(let t of e){if((await dn({provider:this.options.config.provider,providerOptions:t.options.providerOptions})).length>0)throw new i({functionality:`per-request providerOptions.anthropic.anthropicBeta`,message:`Anthropic Message Batches do not support per-request betas (request "${t.id}"). Set providerOptions.anthropic.anthropicBeta on startBatch instead.`});let e=await Jt.prepareRequest({modelId:t.modelId,config:this.options.config,options:{...t.options,stream:!1,userSuppliedBetas:new Set(o)}});if(e.usesJsonResponseTool)throw new i({functionality:`batch responseFormat JSON-tool fallback`,message:`Anthropic Message Batches cannot decode the JSON-tool structured-output fallback (request "${t.id}") because batch results are retrieved independently of the start call. Use a model that supports native output_format structured outputs.`});let n=t.options.tools?.find(t=>t.type===`provider`&&e.toolNameMapping.toProviderToolName(t.name)!==t.name);if(n!=null)throw new i({functionality:`aliased provider tool names in batches`,message:`Anthropic Message Batches cannot restore the custom provider-tool name "${n.name}" when results are retrieved independently of the start call (request "${t.id}"). Use the provider's canonical tool name.`});let r=this.options.config.transformRequestBody?.(e.args,e.betas)??e.args;pn({body:r,requestId:t.id}),c.push({custom_id:t.id,params:r});for(let t of e.betas)s.add(t);for(let n of e.warnings)l.push({requestId:t.id,warning:n})}let{value:u}=await A({url:this.getBatchUrl(``),headers:await this.getStartBatchHeaders({betas:s,headers:n}),body:{requests:c},failedResponseHandler:W,successfulResponseHandler:B(rn),abortSignal:r,fetch:this.options.config.fetch});return{batchId:u.id,...mn(u),warnings:l}}async doGetBatchStatus(e){return mn(await this.retrieveBatch(e))}async doCancelBatch(e){return await A({url:this.getBatchUrl(`/${encodeURIComponent(e.batchId)}/cancel`),headers:await this.getBatchHeaders(e.headers),body:{},failedResponseHandler:W,successfulResponseHandler:B(rn),abortSignal:e.abortSignal,fetch:this.options.config.fetch}),{}}async doListBatches(e){let t=new URL(this.getBatchUrl(``));e.limit!=null&&t.searchParams.set(`limit`,String(e.limit)),e.cursor!=null&&t.searchParams.set(`after_id`,e.cursor);let{value:n}=await c({url:t.toString(),validateUrl:!1,headers:await this.getBatchHeaders(e.headers),failedResponseHandler:W,successfulResponseHandler:B(an),abortSignal:e.abortSignal,fetch:this.options.config.fetch});return{batches:n.data.map(e=>({batchId:e.id,...mn(e)})),...n.has_more&&n.last_id!=null?{nextCursor:n.last_id}:{}}}async doGetBatchResults(e){let r=await this.retrieveBatch(e);if(mn(r).status===`pending`)throw new t({argument:`batchId`,message:`Anthropic batch "${e.batchId}" is not complete.`});if(r.archived_at!=null)throw new t({argument:`batchId`,message:`Anthropic batch "${e.batchId}" results are no longer available.`});if(r.results_url==null)throw new n({data:r,message:`Anthropic batch "${e.batchId}" completed without batch output.`});let{value:i}=await c({url:r.results_url,validateUrl:!0,credentialedOrigin:this.options.config.baseURL,trustedOrigin:this.options.config.baseURL,headers:await this.getBatchHeaders(e.headers),failedResponseHandler:W,successfulResponseHandler:re(cn,{maxLineBytes:this.options.maxLineBytes}),abortSignal:e.abortSignal,fetch:this.options.config.fetch});return I(this.iterateBatchResults(i))}async retrieveBatch(e){let{value:t}=await c({url:this.getBatchUrl(`/${encodeURIComponent(e.batchId)}`),validateUrl:!1,headers:await this.getBatchHeaders(e.headers),failedResponseHandler:W,successfulResponseHandler:B(rn),abortSignal:e.abortSignal,fetch:this.options.config.fetch});return t}async*iterateBatchResults(e){for await(let t of e)yield await _n(t,this.generateId)}getBatchUrl(e){return`${this.options.config.baseURL}/messages/batches${e}`}async getStartBatchHeaders({betas:e,headers:t}){return C(O(await this.getBatchHeaders(t)),{"anthropic-beta":e.size>0?Array.from(e).join(`,`):void 0})}async getBatchHeaders(e){return C(this.options.config.headers?await L(this.options.config.headers):void 0,e)}};async function dn({provider:e,providerOptions:t}){let n=e.split(`.`)[0],r=await M({provider:`anthropic`,providerOptions:t,schema:tn}),i=n===`anthropic`?void 0:await M({provider:n,providerOptions:t,schema:tn});return Object.assign({},r??{},i??{}).anthropicBeta??[]}function fn(e){let n=new Set;for(let r of e){if(!en.test(r.id))throw new t({argument:`requests`,message:`Anthropic batch request ID "${r.id}" must match ^[A-Za-z0-9_-]{1,64}\$.`});if(n.has(r.id))throw new t({argument:`requests`,message:`Anthropic batch request IDs must be unique; duplicate ID "${r.id}".`});n.add(r.id)}}function pn({body:e,requestId:t}){if(e.speed!=null)throw new i({functionality:`providerOptions.anthropic.speed`,message:`Anthropic Message Batches do not support speed (request "${t}").`});if(Array.isArray(e.fallbacks)&&e.fallbacks.some(e=>typeof e==`object`&&!!e&&`speed`in e&&e.speed!=null))throw new i({functionality:`providerOptions.anthropic.fallbacks[].speed`,message:`Anthropic Message Batches do not support fallback speed (request "${t}").`})}function mn(e){let t=gn(e.request_counts);return{status:hn(e.processing_status),rawStatus:e.processing_status,...t==null?{}:{requestCounts:t},createdAt:e.created_at,expiresAt:e.expires_at,providerMetadata:{anthropic:{archivedAt:e.archived_at??null,cancelInitiatedAt:e.cancel_initiated_at??null,endedAt:e.ended_at??null,requestCounts:e.request_counts,resultsUrl:e.results_url??null}}}}function hn(e){switch(e){case`ended`:return`completed`;default:return`pending`}}function gn(e){return a({total:e.processing+e.succeeded+e.errored+e.canceled+e.expired,pending:e.processing,completed:e.succeeded,failed:e.errored+e.canceled+e.expired})}async function _n(e,t){let n=await k({value:e.result,schema:sn});if(!n.success)return vn(e.custom_id);let r=n.value;switch(r.type){case`canceled`:return{type:`text`,id:e.custom_id,status:`cancelled`};case`expired`:return{type:`text`,id:e.custom_id,status:`expired`};case`errored`:{let t=r.error.request_id;return{type:`text`,id:e.custom_id,status:`failed`,error:{message:r.error.error.message,type:r.error.error.type},...t==null?{}:{providerMetadata:{anthropic:{requestId:t}}}}}case`succeeded`:{let n=await yn(r.message);return n==null?vn(e.custom_id):{type:`text`,id:e.custom_id,status:`succeeded`,result:bn(n,t)}}}}function vn(e){return{type:`text`,id:e,status:`failed`,error:{message:`Anthropic returned an invalid Message batch result.`,code:`invalid_response`}}}async function yn(e){let t=await k({value:e,schema:Z});if(t.success)return t.value;if(!g(e)||!Array.isArray(e.content))return;let n=[];for(let t of e.content){let r=await k({value:{...e,content:[t]},schema:Z});if(r.success){let[e]=r.value.content;e!=null&&n.push(e)}else if(!g(t)||typeof t.type!=`string`||on.has(t.type))return}let r=await k({value:{...e,content:n},schema:Z});return r.success?r.value:void 0}function bn(e,t){let n=[],r={},i={};for(let a of e.content)switch(a.type){case`text`:let e=a.citations;n.push({type:`text`,text:a.text,...e!=null&&e.length>0&&{providerMetadata:{anthropic:{citations:e}}}});for(let e of a.citations??[]){let r=Ut(e,[],t);r!=null&&n.push(r)}break;case`thinking`:n.push({type:`reasoning`,text:a.thinking,providerMetadata:{anthropic:{signature:a.signature}}});break;case`redacted_thinking`:n.push({type:`reasoning`,text:``,providerMetadata:{anthropic:{redactedData:a.data}}});break;case`container_upload`:n.push({type:`custom`,kind:`anthropic.container_upload`,providerMetadata:{anthropic:{fileId:a.file_id}}});break;case`compaction`:if(!a.content)break;n.push({type:`text`,text:a.content,providerMetadata:{anthropic:{type:`compaction`,...a.signature!=null&&{signature:a.signature}}}});break;case`tool_use`:n.push({type:`tool-call`,toolCallId:a.id,toolName:a.name,input:JSON.stringify(a.input),...xn(a.caller)});break;case`server_tool_use`:{let e=a.name===`bash_code_execution`||a.name===`text_editor_code_execution`,t=e||a.name===`code_execution`,r=e?`code_execution`:a.name;(a.name===`tool_search_tool_bm25`||a.name===`tool_search_tool_regex`)&&(i[a.id]=a.name),n.push({type:`tool-call`,toolCallId:a.id,toolName:r,input:JSON.stringify(e?{type:a.name,...a.input}:a.name===`code_execution`&&a.input!=null&&`code`in a.input&&!(`type`in a.input)?{type:`programmatic-tool-call`,...a.input}:a.input),providerExecuted:!0,...t?{dynamic:!0}:{},...xn(a.caller)});break}case`mcp_tool_use`:{let e={type:`tool-call`,toolCallId:a.id,toolName:a.name,input:JSON.stringify(a.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{serverName:a.server_name,type:`mcp-tool-use`}}};r[a.id]=e,n.push(e);break}case`mcp_tool_result`:{let e=r[a.tool_use_id];n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:e?.toolName??`mcp`,isError:a.is_error,result:a.content,dynamic:!0,...e?.providerMetadata!=null&&{providerMetadata:e.providerMetadata}});break}case`web_fetch_tool_result`:n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`web_fetch`,...a.content.type===`web_fetch_tool_result_error`?{isError:!0,result:{errorCode:a.content.error_code,type:a.content.type}}:{result:{content:{citations:a.content.content.citations,source:{data:a.content.content.source.data,mediaType:a.content.content.source.media_type,type:a.content.content.source.type},title:a.content.content.title,type:a.content.content.type},retrievedAt:a.content.retrieved_at,type:a.content.type,url:a.content.url}},...xn(a.caller)});break;case`web_search_tool_result`:if(n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`web_search`,...Array.isArray(a.content)?{result:a.content.map(e=>({encryptedContent:e.encrypted_content,pageAge:e.page_age??null,...e.title==null?{}:{title:e.title},type:e.type,url:e.url}))}:{isError:!0,result:{errorCode:a.content.error_code,type:a.content.type}},...xn(a.caller)}),Array.isArray(a.content))for(let e of a.content)n.push({type:`source`,sourceType:`url`,id:t(),url:e.url,...e.title==null?{}:{title:e.title},providerMetadata:{anthropic:{pageAge:e.page_age??null}}});break;case`code_execution_tool_result`:n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`code_execution`,...a.content.type===`code_execution_tool_result_error`?{isError:!0,result:{errorCode:a.content.error_code,type:a.content.type}}:{result:a.content}});break;case`bash_code_execution_tool_result`:case`text_editor_code_execution_tool_result`:n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`code_execution`,result:a.content});break;case`tool_search_tool_result`:{let e=i[a.tool_use_id]??`tool_search_tool_regex`;n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:e,...a.content.type===`tool_search_tool_result_error`?{isError:!0,result:{errorCode:a.content.error_code,type:a.content.type}}:{result:a.content.tool_references.map(e=>({toolName:e.tool_name,type:e.type}))}});break}case`advisor_tool_result`:a.content.type===`advisor_result`?n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`advisor`,result:{type:a.content.type,text:a.content.text,...a.content.stop_reason==null?{}:{stopReason:a.content.stop_reason}}}):a.content.type===`advisor_redacted_result`?n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`advisor`,result:{type:a.content.type,encryptedContent:a.content.encrypted_content,...a.content.stop_reason==null?{}:{stopReason:a.content.stop_reason}}}):n.push({type:`tool-result`,toolCallId:a.tool_use_id,toolName:`advisor`,isError:!0,result:{errorCode:a.content.error_code,type:a.content.type}});break;case`fallback`:n.push({type:`custom`,kind:`anthropic.fallback`,providerMetadata:{anthropic:{type:`fallback`,from:a.from,to:a.to}}})}return{content:n,finishReason:{unified:Nt({finishReason:e.stop_reason}),raw:e.stop_reason??void 0},usage:ct({usage:e.usage}),response:{id:e.id??void 0,modelId:e.model??void 0},warnings:[],providerMetadata:{anthropic:Sn(e)}}}function xn(e){return e==null?{}:{providerMetadata:{anthropic:{caller:{type:e.type,toolId:e.tool_id}}}}}function Sn(e){let t=wn(e.stop_details);return{usage:e.usage,stopSequence:e.stop_sequence??null,...t==null?{}:{stopDetails:t},...e.input_transformations==null?{}:{inputTransformations:e.input_transformations},...e.safeguard_results==null?{}:{safeguardResults:e.safeguard_results},iterations:e.usage.iterations?e.usage.iterations.map(e=>({type:e.type,...e.model==null?{}:{model:e.model},inputTokens:e.input_tokens,outputTokens:e.output_tokens,...e.cache_creation_input_tokens?{cacheCreationInputTokens:e.cache_creation_input_tokens}:{},...e.cache_read_input_tokens?{cacheReadInputTokens:e.cache_read_input_tokens}:{}})):null,container:e.container?{expiresAt:e.container.expires_at,id:e.container.id,skills:e.container.skills?.map(e=>({type:e.type,skillId:e.skill_id,version:e.version}))??null}:null,contextManagement:Cn(e.context_management)}}function Cn(e){return e?{appliedEdits:e.applied_edits.map(e=>{switch(e.type){case`clear_tool_uses_20250919`:return{type:e.type,clearedToolUses:e.cleared_tool_uses,clearedInputTokens:e.cleared_input_tokens};case`clear_thinking_20251015`:return{type:e.type,clearedThinkingTurns:e.cleared_thinking_turns,clearedInputTokens:e.cleared_input_tokens};case`compact_20260112`:return{type:e.type}}})}:null}function wn(e){if(e!=null)return{type:e.type,...e.category==null?{}:{category:e.category},...e.explanation==null?{}:{explanation:e.explanation},...e.recommended_model==null?{}:{recommendedModel:e.recommended_model}}}const Tn=P(()=>z(U.object({command:U.string(),restart:U.boolean().optional()}))),En=p({id:`anthropic.bash_20241022`,inputSchema:Tn});function Dn(e={}){let{execute:t,...n}=e;return En(t===void 0?{...n,execute:async({command:e},{abortSignal:t,experimental_sandbox:n})=>{if(!n)throw Error(`Sandbox session is not available`);return await n.run({command:e,abortSignal:t})}}:{...n,...t===null?{}:{execute:t}})}const On=P(()=>z(U.object({command:U.string(),restart:U.boolean().optional()}))),kn=p({id:`anthropic.bash_20250124`,inputSchema:On});function An(e={}){let{execute:t,...n}=e;return kn(t===void 0?{...n,execute:async({command:e},{abortSignal:t,experimental_sandbox:n})=>{if(!n)throw Error(`Sandbox session is not available`);return await n.run({command:e,abortSignal:t})}}:{...n,...t===null?{}:{execute:t}})}const jn=P(()=>z(U.object({action:U.enum([`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`screenshot`,`cursor_position`]),coordinate:U.array(U.number().int()).optional(),text:U.string().optional()}))),Mn=p({id:`anthropic.computer_20241022`,inputSchema:jn}),Nn=P(()=>z(U.object({action:U.enum([`key`,`hold_key`,`type`,`cursor_position`,`mouse_move`,`left_mouse_down`,`left_mouse_up`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`wait`,`screenshot`]),coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),duration:U.number().optional(),scroll_amount:U.number().optional(),scroll_direction:U.enum([`up`,`down`,`left`,`right`]).optional(),start_coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),text:U.string().optional()}))),Pn=p({id:`anthropic.computer_20250124`,inputSchema:Nn}),Fn=P(()=>z(U.object({action:U.enum([`key`,`hold_key`,`type`,`cursor_position`,`mouse_move`,`left_mouse_down`,`left_mouse_up`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`wait`,`screenshot`,`zoom`]),coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),duration:U.number().optional(),region:U.tuple([U.number().int(),U.number().int(),U.number().int(),U.number().int()]).optional(),scroll_amount:U.number().optional(),scroll_direction:U.enum([`up`,`down`,`left`,`right`]).optional(),start_coordinate:U.tuple([U.number().int(),U.number().int()]).optional(),text:U.string().optional()}))),In=p({id:`anthropic.computer_20251124`,inputSchema:Fn}),Ln=P(()=>z(U.discriminatedUnion(`command`,[U.object({command:U.literal(`view`),path:U.string(),view_range:U.tuple([U.number(),U.number()]).optional()}),U.object({command:U.literal(`create`),path:U.string(),file_text:U.string()}),U.object({command:U.literal(`str_replace`),path:U.string(),old_str:U.string(),new_str:U.string()}),U.object({command:U.literal(`insert`),path:U.string(),insert_line:U.number(),insert_text:U.string()}),U.object({command:U.literal(`delete`),path:U.string()}),U.object({command:U.literal(`rename`),old_path:U.string(),new_path:U.string()})]))),Rn=p({id:`anthropic.memory_20250818`,inputSchema:Ln}),zn=P(()=>z(U.object({command:U.enum([`view`,`create`,`str_replace`,`insert`,`undo_edit`]),path:U.string(),file_text:U.string().optional(),insert_line:U.number().int().optional(),new_str:U.string().optional(),insert_text:U.string().optional(),old_str:U.string().optional(),view_range:U.array(U.number().int()).optional()}))),Bn=p({id:`anthropic.text_editor_20241022`,inputSchema:zn}),Vn=P(()=>z(U.object({command:U.enum([`view`,`create`,`str_replace`,`insert`,`undo_edit`]),path:U.string(),file_text:U.string().optional(),insert_line:U.number().int().optional(),new_str:U.string().optional(),insert_text:U.string().optional(),old_str:U.string().optional(),view_range:U.array(U.number().int()).optional()}))),Hn=p({id:`anthropic.text_editor_20250124`,inputSchema:Vn}),Un=P(()=>z(U.object({command:U.enum([`view`,`create`,`str_replace`,`insert`]),path:U.string(),file_text:U.string().optional(),insert_line:U.number().int().optional(),new_str:U.string().optional(),insert_text:U.string().optional(),old_str:U.string().optional(),view_range:U.array(U.number().int()).optional()}))),Wn=p({id:`anthropic.text_editor_20250429`,inputSchema:Un}),Gn=P(()=>z(U.array(U.object({type:U.literal(`tool_reference`),toolName:U.string()})))),Kn=P(()=>z(U.object({query:U.string(),limit:U.number().optional()}))),qn=R({id:`anthropic.tool_search_bm25_20251119`,inputSchema:Kn,outputSchema:Gn,supportsDeferredResults:!0}),Jn={advisor_20260301:Se,bash_20241022:Dn,bash_20250124:An,codeExecution_20250522:ft,codeExecution_20250825:gt,codeExecution_20260120:bt,computer_20241022:Mn,computer_20250124:Pn,computer_20251124:In,computerToolset_20260801:Ee,memory_20250818:Rn,textEditor_20241022:Bn,textEditor_20250124:Hn,textEditor_20250429:Wn,textEditor_20250728:Ae,webFetch_20250910:ot,webFetch_20260209:tt,webFetch_20260318:Xe,webSearch_20250305:Ge,webSearch_20260209:Be,webSearch_20260318:Fe,toolSearchRegex_20251119:wt,toolSearchBm25_20251119:(e={})=>qn(e)},Yn=P(()=>z(U.object({id:U.string(),display_title:U.string().nullish(),name:U.string().nullish(),description:U.string().nullish(),latest_version:U.string().nullish(),source:U.string(),created_at:U.string(),updated_at:U.string()})));P(()=>z(U.object({data:U.array(U.object({version:U.string()}))})));const Xn=P(()=>z(U.object({type:U.string(),skill_id:U.string(),name:U.string().nullish(),description:U.string().nullish()})));function Zn(e){let t=encodeURIComponent(e);return t===`.`?`%252E`:t===`..`?`%252E%252E`:t}var Qn=class{get provider(){return this.config.provider}constructor(e){this.config=e,this.specificationVersion=`v4`}async getHeaders(){return C(await L(this.config.headers),{"anthropic-beta":`skills-2025-10-02`})}async fetchVersionMetadata({skillId:e,version:t,headers:n}){let{value:r}=await c({url:`${this.config.baseURL}/skills/${Zn(e)}/versions/${Zn(t)}`,validateUrl:!1,headers:n,failedResponseHandler:W,successfulResponseHandler:B(Xn),fetch:this.config.fetch});return{...r.name==null?{}:{name:r.name},...r.description==null?{}:{description:r.description}}}async uploadSkill(e){let t=[],n=new FormData;e.displayTitle!=null&&n.append(`display_title`,e.displayTitle);for(let t of e.files){let e=j(t.data);n.append(`files[]`,new Blob([e]),t.path)}let r=await this.getHeaders(),{value:i}=await F({url:`${this.config.baseURL}/skills`,headers:r,formData:n,failedResponseHandler:W,successfulResponseHandler:B(Yn),fetch:this.config.fetch}),a=i.latest_version==null?{}:await this.fetchVersionMetadata({skillId:i.id,version:i.latest_version,headers:r}),o=a.name??i.name,s=a.description??i.description;return{providerReference:{anthropic:i.id},...i.display_title==null?{}:{displayTitle:i.display_title},...o==null?{}:{name:o},...s==null?{}:{description:s},...i.latest_version==null?{}:{latestVersion:i.latest_version},providerMetadata:{anthropic:{...i.source==null?{}:{source:i.source},...i.created_at==null?{}:{createdAt:i.created_at},...i.updated_at==null?{}:{updatedAt:i.updated_at}}},warnings:t}}};const $n=`4.0.78`,er=`https://api.anthropic.com`,tr=`${er}/v1`;function nr(e){let t=o(ie(e));return t===er?tr:t}function rr(e={}){let n=nr(y({settingValue:e.baseURL,environmentVariableName:`ANTHROPIC_BASE_URL`}))??tr,i=e.name??`anthropic.messages`,a={"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]};if(e.apiKey&&e.authToken)throw new t({argument:`apiKey/authToken`,message:`Both apiKey and authToken were provided. Please use only one authentication method.`});let o=()=>{let t=e.authToken?{Authorization:`Bearer ${e.authToken}`}:{"x-api-key":u({apiKey:e.apiKey,environmentVariableName:`ANTHROPIC_API_KEY`,description:`Anthropic`})};return m({"anthropic-version":`2023-06-01`,...t,...e.headers},`ai-sdk-anthropic/${$n}`)},s={provider:i,baseURL:n,headers:o,fetch:e.fetch,generateId:e.generateId??f,supportedUrls:()=>a},c=e=>new Jt(e,s),l=()=>new un({provider:`${i.replace(/\.messages$/,``)}.batch`,maxLineBytes:e.batchResultDownloads?.maxLineBytes,config:s,supportedUrls:a}),d=()=>new Qn({provider:`${i.replace(`.messages`,``)}.skills`,baseURL:n,headers:o,fetch:e.fetch}),p=function(e){if(new.target)throw Error(`The Anthropic model function cannot be called with the new keyword.`);return c(e)};return p.specificationVersion=`v4`,p.languageModel=c,p.chat=c,p.messages=c,p.decisionModel=e=>new oe({model:c(e),provider:`${i.replace(/\.messages$/,``)}.decision`}),p.evaluationModel=p.decisionModel,p.experimental_batch=l,p.embeddingModel=e=>{throw new r({modelId:e,modelType:`embeddingModel`})},p.textEmbeddingModel=p.embeddingModel,p.imageModel=e=>{throw new r({modelId:e,modelType:`imageModel`})},p.files=()=>new ce({provider:i,baseURL:n,headers:o,fetch:e.fetch}),p.skills=d,p.tools=Jn,p}const ir=rr();function ar({steps:e}){for(let t=e.length-1;t>=0;t--){let n=(e[t].providerMetadata?.anthropic)?.container?.id;if(n)return{providerOptions:{anthropic:{container:{id:n}}}}}}export{$n as VERSION,ir as anthropic,rr as createAnthropic,ar as forwardAnthropicContainerIdFromLastStep};
|