@ai-sdk/anthropic 2.0.0-canary.2 → 2.0.0-canary.4

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.
@@ -147,7 +147,7 @@ function prepareTools({
147
147
  default: {
148
148
  const _exhaustiveCheck = type;
149
149
  throw new UnsupportedFunctionalityError({
150
- functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
150
+ functionality: `tool choice type: ${_exhaustiveCheck}`
151
151
  });
152
152
  }
153
153
  }
@@ -157,13 +157,12 @@ function prepareTools({
157
157
  import {
158
158
  UnsupportedFunctionalityError as UnsupportedFunctionalityError2
159
159
  } from "@ai-sdk/provider";
160
- import { convertUint8ArrayToBase64 } from "@ai-sdk/provider-utils";
161
160
  function convertToAnthropicMessagesPrompt({
162
161
  prompt,
163
162
  sendReasoning,
164
163
  warnings
165
164
  }) {
166
- var _a, _b, _c, _d;
165
+ var _a, _b, _c;
167
166
  const betas = /* @__PURE__ */ new Set();
168
167
  const blocks = groupIntoBlocks(prompt);
169
168
  let system = void 0;
@@ -211,42 +210,39 @@ function convertToAnthropicMessagesPrompt({
211
210
  });
212
211
  break;
213
212
  }
214
- case "image": {
215
- anthropicContent.push({
216
- type: "image",
217
- source: part.image instanceof URL ? {
218
- type: "url",
219
- url: part.image.toString()
220
- } : {
221
- type: "base64",
222
- media_type: (_b = part.mimeType) != null ? _b : "image/jpeg",
223
- data: convertUint8ArrayToBase64(part.image)
224
- },
225
- cache_control: cacheControl
226
- });
227
- break;
228
- }
229
213
  case "file": {
230
- if (part.data instanceof URL) {
231
- throw new UnsupportedFunctionalityError2({
232
- functionality: "Image URLs in user messages"
214
+ if (part.mediaType.startsWith("image/")) {
215
+ anthropicContent.push({
216
+ type: "image",
217
+ source: part.data instanceof URL ? {
218
+ type: "url",
219
+ url: part.data.toString()
220
+ } : {
221
+ type: "base64",
222
+ media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
223
+ data: part.data
224
+ },
225
+ cache_control: cacheControl
233
226
  });
234
- }
235
- if (part.mimeType !== "application/pdf") {
227
+ } else if (part.mediaType === "application/pdf") {
228
+ betas.add("pdfs-2024-09-25");
229
+ anthropicContent.push({
230
+ type: "document",
231
+ source: part.data instanceof URL ? {
232
+ type: "url",
233
+ url: part.data.toString()
234
+ } : {
235
+ type: "base64",
236
+ media_type: "application/pdf",
237
+ data: part.data
238
+ },
239
+ cache_control: cacheControl
240
+ });
241
+ } else {
236
242
  throw new UnsupportedFunctionalityError2({
237
- functionality: "Non-PDF files in user messages"
243
+ functionality: `media type: ${part.mediaType}`
238
244
  });
239
245
  }
240
- betas.add("pdfs-2024-09-25");
241
- anthropicContent.push({
242
- type: "document",
243
- source: {
244
- type: "base64",
245
- media_type: "application/pdf",
246
- data: part.data
247
- },
248
- cache_control: cacheControl
249
- });
250
246
  break;
251
247
  }
252
248
  }
@@ -257,7 +253,7 @@ function convertToAnthropicMessagesPrompt({
257
253
  for (let i2 = 0; i2 < content.length; i2++) {
258
254
  const part = content[i2];
259
255
  const isLastPart = i2 === content.length - 1;
260
- const cacheControl = (_c = getCacheControl(part.providerOptions)) != null ? _c : isLastPart ? getCacheControl(message.providerOptions) : void 0;
256
+ const cacheControl = (_b = getCacheControl(part.providerOptions)) != null ? _b : isLastPart ? getCacheControl(message.providerOptions) : void 0;
261
257
  const toolResultContent = part.content != null ? part.content.map((part2) => {
262
258
  var _a2;
263
259
  switch (part2.type) {
@@ -272,7 +268,7 @@ function convertToAnthropicMessagesPrompt({
272
268
  type: "image",
273
269
  source: {
274
270
  type: "base64",
275
- media_type: (_a2 = part2.mimeType) != null ? _a2 : "image/jpeg",
271
+ media_type: (_a2 = part2.mediaType) != null ? _a2 : "image/jpeg",
276
272
  data: part2.data
277
273
  },
278
274
  cache_control: void 0
@@ -307,7 +303,7 @@ function convertToAnthropicMessagesPrompt({
307
303
  for (let k = 0; k < content.length; k++) {
308
304
  const part = content[k];
309
305
  const isLastContentPart = k === content.length - 1;
310
- const cacheControl = (_d = getCacheControl(part.providerOptions)) != null ? _d : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
306
+ const cacheControl = (_c = getCacheControl(part.providerOptions)) != null ? _c : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
311
307
  switch (part.type) {
312
308
  case "text": {
313
309
  anthropicContent.push({
@@ -364,7 +360,7 @@ function convertToAnthropicMessagesPrompt({
364
360
  }
365
361
  default: {
366
362
  const _exhaustiveCheck = type;
367
- throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
363
+ throw new Error(`content type: ${_exhaustiveCheck}`);
368
364
  }
369
365
  }
370
366
  }
@@ -444,6 +440,9 @@ var AnthropicMessagesLanguageModel = class {
444
440
  this.settings = settings;
445
441
  this.config = config;
446
442
  }
443
+ supportsUrl(url) {
444
+ return url.protocol === "https:";
445
+ }
447
446
  get provider() {
448
447
  return this.config.provider;
449
448
  }
@@ -649,13 +648,11 @@ var AnthropicMessagesLanguageModel = class {
649
648
  completionTokens: response.usage.output_tokens
650
649
  },
651
650
  rawCall: { rawPrompt, rawSettings },
652
- rawResponse: {
653
- headers: responseHeaders,
654
- body: rawResponse
655
- },
656
651
  response: {
657
652
  id: (_a = response.id) != null ? _a : void 0,
658
- modelId: (_b = response.model) != null ? _b : void 0
653
+ modelId: (_b = response.model) != null ? _b : void 0,
654
+ headers: responseHeaders,
655
+ body: rawResponse
659
656
  },
660
657
  warnings,
661
658
  providerMetadata: {
@@ -839,7 +836,7 @@ var AnthropicMessagesLanguageModel = class {
839
836
  })
840
837
  ),
841
838
  rawCall: { rawPrompt, rawSettings },
842
- rawResponse: { headers: responseHeaders },
839
+ response: { headers: responseHeaders },
843
840
  warnings,
844
841
  request: { body: JSON.stringify(body) }
845
842
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/anthropic-messages-language-model.ts","../../src/anthropic-error.ts","../../src/anthropic-prepare-tools.ts","../../src/convert-to-anthropic-messages-prompt.ts","../../src/map-anthropic-stop-reason.ts","../../src/anthropic-tools.ts"],"sourcesContent":["import {\n LanguageModelV2,\n LanguageModelV2CallWarning,\n LanguageModelV2FinishReason,\n LanguageModelV2FunctionToolCall,\n LanguageModelV2ProviderMetadata,\n LanguageModelV2StreamPart,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n ParseResult,\n Resolvable,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\nimport { anthropicFailedResponseHandler } from './anthropic-error';\nimport {\n AnthropicMessagesModelId,\n AnthropicMessagesSettings,\n} from './anthropic-messages-settings';\nimport { prepareTools } from './anthropic-prepare-tools';\nimport { convertToAnthropicMessagesPrompt } from './convert-to-anthropic-messages-prompt';\nimport { mapAnthropicStopReason } from './map-anthropic-stop-reason';\n\ntype AnthropicMessagesConfig = {\n provider: string;\n baseURL: string;\n headers: Resolvable<Record<string, string | undefined>>;\n supportsImageUrls: boolean;\n fetch?: FetchFunction;\n buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;\n transformRequestBody?: (args: Record<string, any>) => Record<string, any>;\n};\n\nexport class AnthropicMessagesLanguageModel implements LanguageModelV2 {\n readonly specificationVersion = 'v2';\n readonly defaultObjectGenerationMode = 'tool';\n\n readonly modelId: AnthropicMessagesModelId;\n readonly settings: AnthropicMessagesSettings;\n\n private readonly config: AnthropicMessagesConfig;\n\n constructor(\n modelId: AnthropicMessagesModelId,\n settings: AnthropicMessagesSettings,\n config: AnthropicMessagesConfig,\n ) {\n this.modelId = modelId;\n this.settings = settings;\n this.config = config;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n get supportsImageUrls(): boolean {\n return this.config.supportsImageUrls;\n }\n\n private async getArgs({\n prompt,\n maxTokens = 4096, // 4096: max model output tokens TODO update default in v5\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n stopSequences,\n responseFormat,\n seed,\n tools,\n toolChoice,\n providerOptions,\n }: Parameters<LanguageModelV2['doGenerate']>[0]) {\n const warnings: LanguageModelV2CallWarning[] = [];\n\n if (frequencyPenalty != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'frequencyPenalty',\n });\n }\n\n if (presencePenalty != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'presencePenalty',\n });\n }\n\n if (seed != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'seed',\n });\n }\n\n if (responseFormat != null && responseFormat.type !== 'text') {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'responseFormat',\n details: 'JSON response format is not supported.',\n });\n }\n\n const { prompt: messagesPrompt, betas: messagesBetas } =\n convertToAnthropicMessagesPrompt({\n prompt,\n sendReasoning: this.settings.sendReasoning ?? true,\n warnings,\n });\n\n const anthropicOptions = parseProviderOptions({\n provider: 'anthropic',\n providerOptions,\n schema: anthropicProviderOptionsSchema,\n });\n\n const isThinking = anthropicOptions?.thinking?.type === 'enabled';\n const thinkingBudget = anthropicOptions?.thinking?.budgetTokens;\n\n const baseArgs = {\n // model id:\n model: this.modelId,\n\n // standardized settings:\n max_tokens: maxTokens,\n temperature,\n top_k: topK,\n top_p: topP,\n stop_sequences: stopSequences,\n\n // provider specific settings:\n ...(isThinking && {\n thinking: { type: 'enabled', budget_tokens: thinkingBudget },\n }),\n\n // prompt:\n system: messagesPrompt.system,\n messages: messagesPrompt.messages,\n };\n\n if (isThinking) {\n if (thinkingBudget == null) {\n throw new UnsupportedFunctionalityError({\n functionality: 'thinking requires a budget',\n });\n }\n\n if (baseArgs.temperature != null) {\n baseArgs.temperature = undefined;\n warnings.push({\n type: 'unsupported-setting',\n setting: 'temperature',\n details: 'temperature is not supported when thinking is enabled',\n });\n }\n\n if (topK != null) {\n baseArgs.top_k = undefined;\n warnings.push({\n type: 'unsupported-setting',\n setting: 'topK',\n details: 'topK is not supported when thinking is enabled',\n });\n }\n\n if (topP != null) {\n baseArgs.top_p = undefined;\n warnings.push({\n type: 'unsupported-setting',\n setting: 'topP',\n details: 'topP is not supported when thinking is enabled',\n });\n }\n\n // adjust max tokens to account for thinking:\n baseArgs.max_tokens = maxTokens + thinkingBudget;\n }\n\n const {\n tools: anthropicTools,\n toolChoice: anthropicToolChoice,\n toolWarnings,\n betas: toolsBetas,\n } = prepareTools({ tools, toolChoice });\n\n return {\n args: {\n ...baseArgs,\n tools: anthropicTools,\n tool_choice: anthropicToolChoice,\n },\n warnings: [...warnings, ...toolWarnings],\n betas: new Set([...messagesBetas, ...toolsBetas]),\n };\n }\n\n private async getHeaders({\n betas,\n headers,\n }: {\n betas: Set<string>;\n headers: Record<string, string | undefined> | undefined;\n }) {\n return combineHeaders(\n await resolve(this.config.headers),\n betas.size > 0 ? { 'anthropic-beta': Array.from(betas).join(',') } : {},\n headers,\n );\n }\n\n private buildRequestUrl(isStreaming: boolean): string {\n return (\n this.config.buildRequestUrl?.(this.config.baseURL, isStreaming) ??\n `${this.config.baseURL}/messages`\n );\n }\n\n private transformRequestBody(args: Record<string, any>): Record<string, any> {\n return this.config.transformRequestBody?.(args) ?? args;\n }\n\n async doGenerate(\n options: Parameters<LanguageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>> {\n const { args, warnings, betas } = await this.getArgs(options);\n\n const {\n responseHeaders,\n value: response,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: this.buildRequestUrl(false),\n headers: await this.getHeaders({ betas, headers: options.headers }),\n body: this.transformRequestBody(args),\n failedResponseHandler: anthropicFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n anthropicMessagesResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const { messages: rawPrompt, ...rawSettings } = args;\n\n // extract text\n let text = '';\n for (const content of response.content) {\n if (content.type === 'text') {\n text += content.text;\n }\n }\n\n // extract tool calls\n let toolCalls: LanguageModelV2FunctionToolCall[] | undefined = undefined;\n if (response.content.some(content => content.type === 'tool_use')) {\n toolCalls = [];\n for (const content of response.content) {\n if (content.type === 'tool_use') {\n toolCalls.push({\n toolCallType: 'function',\n toolCallId: content.id,\n toolName: content.name,\n args: JSON.stringify(content.input),\n });\n }\n }\n }\n\n const reasoning = response.content\n .filter(\n content =>\n content.type === 'redacted_thinking' || content.type === 'thinking',\n )\n .map(content =>\n content.type === 'thinking'\n ? {\n type: 'text' as const,\n text: content.thinking,\n signature: content.signature,\n }\n : {\n type: 'redacted' as const,\n data: content.data,\n },\n );\n\n return {\n text,\n reasoning: reasoning.length > 0 ? reasoning : undefined,\n toolCalls,\n finishReason: mapAnthropicStopReason(response.stop_reason),\n usage: {\n promptTokens: response.usage.input_tokens,\n completionTokens: response.usage.output_tokens,\n },\n rawCall: { rawPrompt, rawSettings },\n rawResponse: {\n headers: responseHeaders,\n body: rawResponse,\n },\n response: {\n id: response.id ?? undefined,\n modelId: response.model ?? undefined,\n },\n warnings,\n providerMetadata: {\n anthropic: {\n cacheCreationInputTokens:\n response.usage.cache_creation_input_tokens ?? null,\n cacheReadInputTokens: response.usage.cache_read_input_tokens ?? null,\n },\n },\n request: { body: JSON.stringify(args) },\n };\n }\n\n async doStream(\n options: Parameters<LanguageModelV2['doStream']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>> {\n const { args, warnings, betas } = await this.getArgs(options);\n const body = { ...args, stream: true };\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: this.buildRequestUrl(true),\n headers: await this.getHeaders({ betas, headers: options.headers }),\n body: this.transformRequestBody(body),\n failedResponseHandler: anthropicFailedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n anthropicMessagesChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const { messages: rawPrompt, ...rawSettings } = args;\n\n let finishReason: LanguageModelV2FinishReason = 'unknown';\n const usage: { promptTokens: number; completionTokens: number } = {\n promptTokens: Number.NaN,\n completionTokens: Number.NaN,\n };\n\n const toolCallContentBlocks: Record<\n number,\n {\n toolCallId: string;\n toolName: string;\n jsonText: string;\n }\n > = {};\n\n let providerMetadata: LanguageModelV2ProviderMetadata | undefined =\n undefined;\n\n let blockType:\n | 'text'\n | 'thinking'\n | 'tool_use'\n | 'redacted_thinking'\n | undefined = undefined;\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<z.infer<typeof anthropicMessagesChunkSchema>>,\n LanguageModelV2StreamPart\n >({\n transform(chunk, controller) {\n if (!chunk.success) {\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n\n const value = chunk.value;\n\n switch (value.type) {\n case 'ping': {\n return; // ignored\n }\n\n case 'content_block_start': {\n const contentBlockType = value.content_block.type;\n\n blockType = contentBlockType;\n\n switch (contentBlockType) {\n case 'text':\n case 'thinking': {\n return; // ignored\n }\n\n case 'redacted_thinking': {\n controller.enqueue({\n type: 'redacted-reasoning',\n data: value.content_block.data,\n });\n return;\n }\n\n case 'tool_use': {\n toolCallContentBlocks[value.index] = {\n toolCallId: value.content_block.id,\n toolName: value.content_block.name,\n jsonText: '',\n };\n return;\n }\n\n default: {\n const _exhaustiveCheck: never = contentBlockType;\n throw new Error(\n `Unsupported content block type: ${_exhaustiveCheck}`,\n );\n }\n }\n }\n\n case 'content_block_stop': {\n // when finishing a tool call block, send the full tool call:\n if (toolCallContentBlocks[value.index] != null) {\n const contentBlock = toolCallContentBlocks[value.index];\n\n controller.enqueue({\n type: 'tool-call',\n toolCallType: 'function',\n toolCallId: contentBlock.toolCallId,\n toolName: contentBlock.toolName,\n args: contentBlock.jsonText,\n });\n\n delete toolCallContentBlocks[value.index];\n }\n\n blockType = undefined; // reset block type\n\n return;\n }\n\n case 'content_block_delta': {\n const deltaType = value.delta.type;\n switch (deltaType) {\n case 'text_delta': {\n controller.enqueue({\n type: 'text-delta',\n textDelta: value.delta.text,\n });\n\n return;\n }\n\n case 'thinking_delta': {\n controller.enqueue({\n type: 'reasoning',\n textDelta: value.delta.thinking,\n });\n\n return;\n }\n\n case 'signature_delta': {\n // signature are only supported on thinking blocks:\n if (blockType === 'thinking') {\n controller.enqueue({\n type: 'reasoning-signature',\n signature: value.delta.signature,\n });\n }\n\n return;\n }\n\n case 'input_json_delta': {\n const contentBlock = toolCallContentBlocks[value.index];\n\n controller.enqueue({\n type: 'tool-call-delta',\n toolCallType: 'function',\n toolCallId: contentBlock.toolCallId,\n toolName: contentBlock.toolName,\n argsTextDelta: value.delta.partial_json,\n });\n\n contentBlock.jsonText += value.delta.partial_json;\n\n return;\n }\n\n default: {\n const _exhaustiveCheck: never = deltaType;\n throw new Error(\n `Unsupported delta type: ${_exhaustiveCheck}`,\n );\n }\n }\n }\n\n case 'message_start': {\n usage.promptTokens = value.message.usage.input_tokens;\n usage.completionTokens = value.message.usage.output_tokens;\n\n providerMetadata = {\n anthropic: {\n cacheCreationInputTokens:\n value.message.usage.cache_creation_input_tokens ?? null,\n cacheReadInputTokens:\n value.message.usage.cache_read_input_tokens ?? null,\n },\n };\n\n controller.enqueue({\n type: 'response-metadata',\n id: value.message.id ?? undefined,\n modelId: value.message.model ?? undefined,\n });\n\n return;\n }\n\n case 'message_delta': {\n usage.completionTokens = value.usage.output_tokens;\n finishReason = mapAnthropicStopReason(value.delta.stop_reason);\n return;\n }\n\n case 'message_stop': {\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage,\n providerMetadata,\n });\n return;\n }\n\n case 'error': {\n controller.enqueue({ type: 'error', error: value.error });\n return;\n }\n\n default: {\n const _exhaustiveCheck: never = value;\n throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`);\n }\n }\n },\n }),\n ),\n rawCall: { rawPrompt, rawSettings },\n rawResponse: { headers: responseHeaders },\n warnings,\n request: { body: JSON.stringify(body) },\n };\n }\n}\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst anthropicMessagesResponseSchema = z.object({\n type: z.literal('message'),\n id: z.string().nullish(),\n model: z.string().nullish(),\n content: z.array(\n z.discriminatedUnion('type', [\n z.object({\n type: z.literal('text'),\n text: z.string(),\n }),\n z.object({\n type: z.literal('thinking'),\n thinking: z.string(),\n signature: z.string(),\n }),\n z.object({\n type: z.literal('redacted_thinking'),\n data: z.string(),\n }),\n z.object({\n type: z.literal('tool_use'),\n id: z.string(),\n name: z.string(),\n input: z.unknown(),\n }),\n ]),\n ),\n stop_reason: z.string().nullish(),\n usage: z.object({\n input_tokens: z.number(),\n output_tokens: z.number(),\n cache_creation_input_tokens: z.number().nullish(),\n cache_read_input_tokens: z.number().nullish(),\n }),\n});\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst anthropicMessagesChunkSchema = z.discriminatedUnion('type', [\n z.object({\n type: z.literal('message_start'),\n message: z.object({\n id: z.string().nullish(),\n model: z.string().nullish(),\n usage: z.object({\n input_tokens: z.number(),\n output_tokens: z.number(),\n cache_creation_input_tokens: z.number().nullish(),\n cache_read_input_tokens: z.number().nullish(),\n }),\n }),\n }),\n z.object({\n type: z.literal('content_block_start'),\n index: z.number(),\n content_block: z.discriminatedUnion('type', [\n z.object({\n type: z.literal('text'),\n text: z.string(),\n }),\n z.object({\n type: z.literal('thinking'),\n thinking: z.string(),\n }),\n z.object({\n type: z.literal('tool_use'),\n id: z.string(),\n name: z.string(),\n }),\n z.object({\n type: z.literal('redacted_thinking'),\n data: z.string(),\n }),\n ]),\n }),\n z.object({\n type: z.literal('content_block_delta'),\n index: z.number(),\n delta: z.discriminatedUnion('type', [\n z.object({\n type: z.literal('input_json_delta'),\n partial_json: z.string(),\n }),\n z.object({\n type: z.literal('text_delta'),\n text: z.string(),\n }),\n z.object({\n type: z.literal('thinking_delta'),\n thinking: z.string(),\n }),\n z.object({\n type: z.literal('signature_delta'),\n signature: z.string(),\n }),\n ]),\n }),\n z.object({\n type: z.literal('content_block_stop'),\n index: z.number(),\n }),\n z.object({\n type: z.literal('error'),\n error: z.object({\n type: z.string(),\n message: z.string(),\n }),\n }),\n z.object({\n type: z.literal('message_delta'),\n delta: z.object({ stop_reason: z.string().nullish() }),\n usage: z.object({ output_tokens: z.number() }),\n }),\n z.object({\n type: z.literal('message_stop'),\n }),\n z.object({\n type: z.literal('ping'),\n }),\n]);\n\nconst anthropicProviderOptionsSchema = z.object({\n thinking: z\n .object({\n type: z.union([z.literal('enabled'), z.literal('disabled')]),\n budgetTokens: z.number().optional(),\n })\n .optional(),\n});\n\nexport type AnthropicProviderOptions = z.infer<\n typeof anthropicProviderOptionsSchema\n>;\n","import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nconst anthropicErrorDataSchema = z.object({\n type: z.literal('error'),\n error: z.object({\n type: z.string(),\n message: z.string(),\n }),\n});\n\nexport type AnthropicErrorData = z.infer<typeof anthropicErrorDataSchema>;\n\nexport const anthropicFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: anthropicErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n","import {\n LanguageModelV2CallOptions,\n LanguageModelV2CallWarning,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport { AnthropicTool, AnthropicToolChoice } from './anthropic-api-types';\n\nexport function prepareTools({\n tools,\n toolChoice,\n}: {\n tools: LanguageModelV2CallOptions['tools'];\n toolChoice?: LanguageModelV2CallOptions['toolChoice'];\n}): {\n tools: Array<AnthropicTool> | undefined;\n toolChoice: AnthropicToolChoice | undefined;\n toolWarnings: LanguageModelV2CallWarning[];\n betas: Set<string>;\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: LanguageModelV2CallWarning[] = [];\n const betas = new Set<string>();\n\n if (tools == null) {\n return { tools: undefined, toolChoice: undefined, toolWarnings, betas };\n }\n\n const anthropicTools: AnthropicTool[] = [];\n\n for (const tool of tools) {\n switch (tool.type) {\n case 'function':\n anthropicTools.push({\n name: tool.name,\n description: tool.description,\n input_schema: tool.parameters,\n });\n break;\n case 'provider-defined':\n switch (tool.id) {\n case 'anthropic.computer_20250124':\n betas.add('computer-use-2025-01-24');\n anthropicTools.push({\n name: tool.name,\n type: 'computer_20250124',\n display_width_px: tool.args.displayWidthPx as number,\n display_height_px: tool.args.displayHeightPx as number,\n display_number: tool.args.displayNumber as number,\n });\n break;\n case 'anthropic.computer_20241022':\n betas.add('computer-use-2024-10-22');\n anthropicTools.push({\n name: tool.name,\n type: 'computer_20241022',\n display_width_px: tool.args.displayWidthPx as number,\n display_height_px: tool.args.displayHeightPx as number,\n display_number: tool.args.displayNumber as number,\n });\n break;\n case 'anthropic.text_editor_20250124':\n betas.add('computer-use-2025-01-24');\n anthropicTools.push({\n name: tool.name,\n type: 'text_editor_20250124',\n });\n break;\n case 'anthropic.text_editor_20241022':\n betas.add('computer-use-2024-10-22');\n anthropicTools.push({\n name: tool.name,\n type: 'text_editor_20241022',\n });\n break;\n case 'anthropic.bash_20250124':\n betas.add('computer-use-2025-01-24');\n anthropicTools.push({\n name: tool.name,\n type: 'bash_20250124',\n });\n break;\n case 'anthropic.bash_20241022':\n betas.add('computer-use-2024-10-22');\n anthropicTools.push({\n name: tool.name,\n type: 'bash_20241022',\n });\n break;\n default:\n toolWarnings.push({ type: 'unsupported-tool', tool });\n break;\n }\n break;\n default:\n toolWarnings.push({ type: 'unsupported-tool', tool });\n break;\n }\n }\n\n if (toolChoice == null) {\n return {\n tools: anthropicTools,\n toolChoice: undefined,\n toolWarnings,\n betas,\n };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n return {\n tools: anthropicTools,\n toolChoice: { type: 'auto' },\n toolWarnings,\n betas,\n };\n case 'required':\n return {\n tools: anthropicTools,\n toolChoice: { type: 'any' },\n toolWarnings,\n betas,\n };\n case 'none':\n // Anthropic does not support 'none' tool choice, so we remove the tools:\n return { tools: undefined, toolChoice: undefined, toolWarnings, betas };\n case 'tool':\n return {\n tools: anthropicTools,\n toolChoice: { type: 'tool', name: toolChoice.toolName },\n toolWarnings,\n betas,\n };\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","import {\n LanguageModelV2CallWarning,\n LanguageModelV2Message,\n LanguageModelV2Prompt,\n LanguageModelV2ProviderMetadata,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport { convertUint8ArrayToBase64 } from '@ai-sdk/provider-utils';\nimport {\n AnthropicAssistantMessage,\n AnthropicCacheControl,\n AnthropicMessagesPrompt,\n AnthropicUserMessage,\n} from './anthropic-api-types';\n\nexport function convertToAnthropicMessagesPrompt({\n prompt,\n sendReasoning,\n warnings,\n}: {\n prompt: LanguageModelV2Prompt;\n sendReasoning: boolean;\n warnings: LanguageModelV2CallWarning[];\n}): {\n prompt: AnthropicMessagesPrompt;\n betas: Set<string>;\n} {\n const betas = new Set<string>();\n const blocks = groupIntoBlocks(prompt);\n\n let system: AnthropicMessagesPrompt['system'] = undefined;\n const messages: AnthropicMessagesPrompt['messages'] = [];\n\n function getCacheControl(\n providerMetadata: LanguageModelV2ProviderMetadata | undefined,\n ): AnthropicCacheControl | undefined {\n const anthropic = providerMetadata?.anthropic;\n\n // allow both cacheControl and cache_control:\n const cacheControlValue =\n anthropic?.cacheControl ?? anthropic?.cache_control;\n\n // Pass through value assuming it is of the correct type.\n // The Anthropic API will validate the value.\n return cacheControlValue as AnthropicCacheControl | undefined;\n }\n\n for (let i = 0; i < blocks.length; i++) {\n const block = blocks[i];\n const isLastBlock = i === blocks.length - 1;\n const type = block.type;\n\n switch (type) {\n case 'system': {\n if (system != null) {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'Multiple system messages that are separated by user/assistant messages',\n });\n }\n\n system = block.messages.map(({ content, providerOptions }) => ({\n type: 'text',\n text: content,\n cache_control: getCacheControl(providerOptions),\n }));\n\n break;\n }\n\n case 'user': {\n // combines all user and tool messages in this block into a single message:\n const anthropicContent: AnthropicUserMessage['content'] = [];\n\n for (const message of block.messages) {\n const { role, content } = message;\n switch (role) {\n case 'user': {\n for (let j = 0; j < content.length; j++) {\n const part = content[j];\n\n // cache control: first add cache control from part.\n // for the last part of a message,\n // check also if the message has cache control.\n const isLastPart = j === content.length - 1;\n\n const cacheControl =\n getCacheControl(part.providerOptions) ??\n (isLastPart\n ? getCacheControl(message.providerOptions)\n : undefined);\n\n switch (part.type) {\n case 'text': {\n anthropicContent.push({\n type: 'text',\n text: part.text,\n cache_control: cacheControl,\n });\n break;\n }\n\n case 'image': {\n anthropicContent.push({\n type: 'image',\n source:\n part.image instanceof URL\n ? {\n type: 'url',\n url: part.image.toString(),\n }\n : {\n type: 'base64',\n media_type: part.mimeType ?? 'image/jpeg',\n data: convertUint8ArrayToBase64(part.image),\n },\n cache_control: cacheControl,\n });\n\n break;\n }\n\n case 'file': {\n if (part.data instanceof URL) {\n // The AI SDK automatically downloads files for user file parts with URLs\n throw new UnsupportedFunctionalityError({\n functionality: 'Image URLs in user messages',\n });\n }\n\n if (part.mimeType !== 'application/pdf') {\n throw new UnsupportedFunctionalityError({\n functionality: 'Non-PDF files in user messages',\n });\n }\n\n betas.add('pdfs-2024-09-25');\n\n anthropicContent.push({\n type: 'document',\n source: {\n type: 'base64',\n media_type: 'application/pdf',\n data: part.data,\n },\n cache_control: cacheControl,\n });\n\n break;\n }\n }\n }\n\n break;\n }\n case 'tool': {\n for (let i = 0; i < content.length; i++) {\n const part = content[i];\n\n // cache control: first add cache control from part.\n // for the last part of a message,\n // check also if the message has cache control.\n const isLastPart = i === content.length - 1;\n\n const cacheControl =\n getCacheControl(part.providerOptions) ??\n (isLastPart\n ? getCacheControl(message.providerOptions)\n : undefined);\n\n const toolResultContent =\n part.content != null\n ? part.content.map(part => {\n switch (part.type) {\n case 'text':\n return {\n type: 'text' as const,\n text: part.text,\n cache_control: undefined,\n };\n case 'image':\n return {\n type: 'image' as const,\n source: {\n type: 'base64' as const,\n media_type: part.mimeType ?? 'image/jpeg',\n data: part.data,\n },\n cache_control: undefined,\n };\n }\n })\n : JSON.stringify(part.result);\n\n anthropicContent.push({\n type: 'tool_result',\n tool_use_id: part.toolCallId,\n content: toolResultContent,\n is_error: part.isError,\n cache_control: cacheControl,\n });\n }\n\n break;\n }\n default: {\n const _exhaustiveCheck: never = role;\n throw new Error(`Unsupported role: ${_exhaustiveCheck}`);\n }\n }\n }\n\n messages.push({ role: 'user', content: anthropicContent });\n\n break;\n }\n\n case 'assistant': {\n // combines multiple assistant messages in this block into a single message:\n const anthropicContent: AnthropicAssistantMessage['content'] = [];\n\n for (let j = 0; j < block.messages.length; j++) {\n const message = block.messages[j];\n const isLastMessage = j === block.messages.length - 1;\n const { content } = message;\n\n for (let k = 0; k < content.length; k++) {\n const part = content[k];\n const isLastContentPart = k === content.length - 1;\n\n // cache control: first add cache control from part.\n // for the last part of a message,\n // check also if the message has cache control.\n const cacheControl =\n getCacheControl(part.providerOptions) ??\n (isLastContentPart\n ? getCacheControl(message.providerOptions)\n : undefined);\n\n switch (part.type) {\n case 'text': {\n anthropicContent.push({\n type: 'text',\n text:\n // trim the last text part if it's the last message in the block\n // because Anthropic does not allow trailing whitespace\n // in pre-filled assistant responses\n isLastBlock && isLastMessage && isLastContentPart\n ? part.text.trim()\n : part.text,\n\n cache_control: cacheControl,\n });\n break;\n }\n\n case 'reasoning': {\n if (sendReasoning) {\n anthropicContent.push({\n type: 'thinking',\n thinking: part.text,\n signature: part.signature!,\n cache_control: cacheControl,\n });\n } else {\n warnings.push({\n type: 'other',\n message:\n 'sending reasoning content is disabled for this model',\n });\n }\n break;\n }\n\n case 'redacted-reasoning': {\n anthropicContent.push({\n type: 'redacted_thinking',\n data: part.data,\n cache_control: cacheControl,\n });\n break;\n }\n\n case 'tool-call': {\n anthropicContent.push({\n type: 'tool_use',\n id: part.toolCallId,\n name: part.toolName,\n input: part.args,\n cache_control: cacheControl,\n });\n break;\n }\n }\n }\n }\n\n messages.push({ role: 'assistant', content: anthropicContent });\n\n break;\n }\n\n default: {\n const _exhaustiveCheck: never = type;\n throw new Error(`Unsupported type: ${_exhaustiveCheck}`);\n }\n }\n }\n\n return {\n prompt: { system, messages },\n betas,\n };\n}\n\ntype SystemBlock = {\n type: 'system';\n messages: Array<LanguageModelV2Message & { role: 'system' }>;\n};\ntype AssistantBlock = {\n type: 'assistant';\n messages: Array<LanguageModelV2Message & { role: 'assistant' }>;\n};\ntype UserBlock = {\n type: 'user';\n messages: Array<LanguageModelV2Message & { role: 'user' | 'tool' }>;\n};\n\nfunction groupIntoBlocks(\n prompt: LanguageModelV2Prompt,\n): Array<SystemBlock | AssistantBlock | UserBlock> {\n const blocks: Array<SystemBlock | AssistantBlock | UserBlock> = [];\n let currentBlock: SystemBlock | AssistantBlock | UserBlock | undefined =\n undefined;\n\n for (const message of prompt) {\n const { role } = message;\n switch (role) {\n case 'system': {\n if (currentBlock?.type !== 'system') {\n currentBlock = { type: 'system', messages: [] };\n blocks.push(currentBlock);\n }\n\n currentBlock.messages.push(message);\n break;\n }\n case 'assistant': {\n if (currentBlock?.type !== 'assistant') {\n currentBlock = { type: 'assistant', messages: [] };\n blocks.push(currentBlock);\n }\n\n currentBlock.messages.push(message);\n break;\n }\n case 'user': {\n if (currentBlock?.type !== 'user') {\n currentBlock = { type: 'user', messages: [] };\n blocks.push(currentBlock);\n }\n\n currentBlock.messages.push(message);\n break;\n }\n case 'tool': {\n if (currentBlock?.type !== 'user') {\n currentBlock = { type: 'user', messages: [] };\n blocks.push(currentBlock);\n }\n\n currentBlock.messages.push(message);\n break;\n }\n default: {\n const _exhaustiveCheck: never = role;\n throw new Error(`Unsupported role: ${_exhaustiveCheck}`);\n }\n }\n }\n\n return blocks;\n}\n","import { LanguageModelV2FinishReason } from '@ai-sdk/provider';\n\nexport function mapAnthropicStopReason(\n finishReason: string | null | undefined,\n): LanguageModelV2FinishReason {\n switch (finishReason) {\n case 'end_turn':\n case 'stop_sequence':\n return 'stop';\n case 'tool_use':\n return 'tool-calls';\n case 'max_tokens':\n return 'length';\n default:\n return 'unknown';\n }\n}\n","import { z } from 'zod';\n\n// Copied from ai package\ntype ExecuteFunction<PARAMETERS, RESULT> =\n | undefined\n | ((\n args: PARAMETERS,\n options: { abortSignal?: AbortSignal },\n ) => Promise<RESULT>);\n\n// Copied from ai package\nexport type ToolResultContent = Array<\n | {\n type: 'text';\n text: string;\n }\n | {\n type: 'image';\n data: string; // base64 encoded png image, e.g. screenshot\n mimeType?: string; // e.g. 'image/png';\n }\n>;\n\nconst Bash20241022Parameters = z.object({\n command: z.string(),\n restart: z.boolean().optional(),\n});\n\n/**\n * Creates a tool for running a bash command. Must have name \"bash\".\n *\n * Image results are supported.\n *\n * @param execute - The function to execute the tool. Optional.\n */\nfunction bashTool_20241022<RESULT>(\n options: {\n execute?: ExecuteFunction<\n {\n /**\n * The bash command to run. Required unless the tool is being restarted.\n */\n command: string;\n\n /**\n * Specifying true will restart this tool. Otherwise, leave this unspecified.\n */\n restart?: boolean;\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n } = {},\n): {\n type: 'provider-defined';\n id: 'anthropic.bash_20241022';\n args: {};\n parameters: typeof Bash20241022Parameters;\n execute: ExecuteFunction<z.infer<typeof Bash20241022Parameters>, RESULT>;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.bash_20241022',\n args: {},\n parameters: Bash20241022Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nconst Bash20250124Parameters = z.object({\n command: z.string(),\n restart: z.boolean().optional(),\n});\n\n/**\n * Creates a tool for running a bash command. Must have name \"bash\".\n *\n * Image results are supported.\n *\n * @param execute - The function to execute the tool. Optional.\n */\nfunction bashTool_20250124<RESULT>(\n options: {\n execute?: ExecuteFunction<\n {\n /**\n * The bash command to run. Required unless the tool is being restarted.\n */\n command: string;\n\n /**\n * Specifying true will restart this tool. Otherwise, leave this unspecified.\n */\n restart?: boolean;\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n } = {},\n): {\n type: 'provider-defined';\n id: 'anthropic.bash_20250124';\n args: {};\n parameters: typeof Bash20250124Parameters;\n execute: ExecuteFunction<z.infer<typeof Bash20250124Parameters>, RESULT>;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.bash_20250124',\n args: {},\n parameters: Bash20250124Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nconst TextEditor20241022Parameters = z.object({\n command: z.enum(['view', 'create', 'str_replace', 'insert', 'undo_edit']),\n path: z.string(),\n file_text: z.string().optional(),\n insert_line: z.number().int().optional(),\n new_str: z.string().optional(),\n old_str: z.string().optional(),\n view_range: z.array(z.number().int()).optional(),\n});\n\n/**\n * Creates a tool for editing text. Must have name \"str_replace_editor\".\n *\n * Image results are supported.\n *\n * @param execute - The function to execute the tool. Optional.\n */\nfunction textEditorTool_20241022<RESULT>(\n options: {\n execute?: ExecuteFunction<\n {\n /**\n * The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.\n */\n command: 'view' | 'create' | 'str_replace' | 'insert' | 'undo_edit';\n\n /**\n * Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`.\n */\n path: string;\n\n /**\n * Required parameter of `create` command, with the content of the file to be created.\n */\n file_text?: string;\n\n /**\n * Required parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`.\n */\n insert_line?: number;\n\n /**\n * Optional parameter of `str_replace` command containing the new string (if not given, no string will be added). Required parameter of `insert` command containing the string to insert.\n */\n new_str?: string;\n\n /**\n * Required parameter of `str_replace` command containing the string in `path` to replace.\n */\n old_str?: string;\n\n /**\n * Optional parameter of `view` command when `path` points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file.\n */\n view_range?: number[];\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n } = {},\n): {\n type: 'provider-defined';\n id: 'anthropic.text_editor_20241022';\n args: {};\n parameters: typeof TextEditor20241022Parameters;\n execute: ExecuteFunction<\n z.infer<typeof TextEditor20241022Parameters>,\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.text_editor_20241022',\n args: {},\n parameters: TextEditor20241022Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nconst TextEditor20250124Parameters = z.object({\n command: z.enum(['view', 'create', 'str_replace', 'insert', 'undo_edit']),\n path: z.string(),\n file_text: z.string().optional(),\n insert_line: z.number().int().optional(),\n new_str: z.string().optional(),\n old_str: z.string().optional(),\n view_range: z.array(z.number().int()).optional(),\n});\n\n/**\n * Creates a tool for editing text. Must have name \"str_replace_editor\".\n *\n * Image results are supported.\n *\n * @param execute - The function to execute the tool. Optional.\n */\nfunction textEditorTool_20250124<RESULT>(\n options: {\n execute?: ExecuteFunction<\n {\n /**\n * The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.\n */\n command: 'view' | 'create' | 'str_replace' | 'insert' | 'undo_edit';\n\n /**\n * Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`.\n */\n path: string;\n\n /**\n * Required parameter of `create` command, with the content of the file to be created.\n */\n file_text?: string;\n\n /**\n * Required parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`.\n */\n insert_line?: number;\n\n /**\n * Optional parameter of `str_replace` command containing the new string (if not given, no string will be added). Required parameter of `insert` command containing the string to insert.\n */\n new_str?: string;\n\n /**\n * Required parameter of `str_replace` command containing the string in `path` to replace.\n */\n old_str?: string;\n\n /**\n * Optional parameter of `view` command when `path` points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file.\n */\n view_range?: number[];\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n } = {},\n): {\n type: 'provider-defined';\n id: 'anthropic.text_editor_20250124';\n args: {};\n parameters: typeof TextEditor20250124Parameters;\n execute: ExecuteFunction<\n z.infer<typeof TextEditor20250124Parameters>,\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.text_editor_20250124',\n args: {},\n parameters: TextEditor20250124Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nconst Computer20241022Parameters = z.object({\n action: z.enum([\n 'key',\n 'type',\n 'mouse_move',\n 'left_click',\n 'left_click_drag',\n 'right_click',\n 'middle_click',\n 'double_click',\n 'screenshot',\n 'cursor_position',\n ]),\n coordinate: z.array(z.number().int()).optional(),\n text: z.string().optional(),\n});\n\n/**\n * Creates a tool for executing actions on a computer. Must have name \"computer\".\n *\n * Image results are supported.\n *\n * @param displayWidthPx - The width of the display being controlled by the model in pixels.\n * @param displayHeightPx - The height of the display being controlled by the model in pixels.\n * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.\n * @param execute - The function to execute the tool. Optional.\n */\nfunction computerTool_20241022<RESULT>(options: {\n displayWidthPx: number;\n displayHeightPx: number;\n displayNumber?: number;\n execute?: ExecuteFunction<\n {\n /**\n * The action to perform. The available actions are:\n * - `key`: Press a key or key-combination on the keyboard.\n * - This supports xdotool's `key` syntax.\n * - Examples: \"a\", \"Return\", \"alt+Tab\", \"ctrl+s\", \"Up\", \"KP_0\" (for the numpad 0 key).\n * - `type`: Type a string of text on the keyboard.\n * - `cursor_position`: Get the current (x, y) pixel coordinate of the cursor on the screen.\n * - `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.\n * - `left_click`: Click the left mouse button.\n * - `left_click_drag`: Click and drag the cursor to a specified (x, y) pixel coordinate on the screen.\n * - `right_click`: Click the right mouse button.\n * - `middle_click`: Click the middle mouse button.\n * - `double_click`: Double-click the left mouse button.\n * - `screenshot`: Take a screenshot of the screen.\n */\n action:\n | 'key'\n | 'type'\n | 'mouse_move'\n | 'left_click'\n | 'left_click_drag'\n | 'right_click'\n | 'middle_click'\n | 'double_click'\n | 'screenshot'\n | 'cursor_position';\n\n /**\n * (x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=mouse_move` and `action=left_click_drag`.\n */\n coordinate?: number[];\n\n /**\n * Required only by `action=type` and `action=key`.\n */\n text?: string;\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n}): {\n type: 'provider-defined';\n id: 'anthropic.computer_20241022';\n args: {};\n parameters: typeof Computer20241022Parameters;\n execute: ExecuteFunction<z.infer<typeof Computer20241022Parameters>, RESULT>;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.computer_20241022',\n args: {\n displayWidthPx: options.displayWidthPx,\n displayHeightPx: options.displayHeightPx,\n displayNumber: options.displayNumber,\n },\n parameters: Computer20241022Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nconst Computer20250124Parameters = z.object({\n action: z.enum([\n 'key',\n 'hold_key',\n 'type',\n 'cursor_position',\n 'mouse_move',\n 'left_mouse_down',\n 'left_mouse_up',\n 'left_click',\n 'left_click_drag',\n 'right_click',\n 'middle_click',\n 'double_click',\n 'triple_click',\n 'scroll',\n 'wait',\n 'screenshot',\n ]),\n coordinate: z.tuple([z.number().int(), z.number().int()]).optional(),\n duration: z.number().optional(),\n scroll_amount: z.number().optional(),\n scroll_direction: z.enum(['up', 'down', 'left', 'right']).optional(),\n start_coordinate: z.tuple([z.number().int(), z.number().int()]).optional(),\n text: z.string().optional(),\n});\n\n/**\n * Creates a tool for executing actions on a computer. Must have name \"computer\".\n *\n * Image results are supported.\n *\n * @param displayWidthPx - The width of the display being controlled by the model in pixels.\n * @param displayHeightPx - The height of the display being controlled by the model in pixels.\n * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.\n * @param execute - The function to execute the tool. Optional.\n */\nfunction computerTool_20250124<RESULT>(options: {\n displayWidthPx: number;\n displayHeightPx: number;\n displayNumber?: number;\n execute?: ExecuteFunction<\n {\n /**\n * - `key`: Press a key or key-combination on the keyboard.\n * - This supports xdotool's `key` syntax.\n * - Examples: \"a\", \"Return\", \"alt+Tab\", \"ctrl+s\", \"Up\", \"KP_0\" (for the numpad 0 key).\n * - `hold_key`: Hold down a key or multiple keys for a specified duration (in seconds). Supports the same syntax as `key`.\n * - `type`: Type a string of text on the keyboard.\n * - `cursor_position`: Get the current (x, y) pixel coordinate of the cursor on the screen.\n * - `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.\n * - `left_mouse_down`: Press the left mouse button.\n * - `left_mouse_up`: Release the left mouse button.\n * - `left_click`: Click the left mouse button at the specified (x, y) pixel coordinate on the screen. You can also include a key combination to hold down while clicking using the `text` parameter.\n * - `left_click_drag`: Click and drag the cursor from `start_coordinate` to a specified (x, y) pixel coordinate on the screen.\n * - `right_click`: Click the right mouse button at the specified (x, y) pixel coordinate on the screen.\n * - `middle_click`: Click the middle mouse button at the specified (x, y) pixel coordinate on the screen.\n * - `double_click`: Double-click the left mouse button at the specified (x, y) pixel coordinate on the screen.\n * - `triple_click`: Triple-click the left mouse button at the specified (x, y) pixel coordinate on the screen.\n * - `scroll`: Scroll the screen in a specified direction by a specified amount of clicks of the scroll wheel, at the specified (x, y) pixel coordinate. DO NOT use PageUp/PageDown to scroll.\n * - `wait`: Wait for a specified duration (in seconds).\n * - `screenshot`: Take a screenshot of the screen.\n */\n action:\n | 'key'\n | 'hold_key'\n | 'type'\n | 'cursor_position'\n | 'mouse_move'\n | 'left_mouse_down'\n | 'left_mouse_up'\n | 'left_click'\n | 'left_click_drag'\n | 'right_click'\n | 'middle_click'\n | 'double_click'\n | 'triple_click'\n | 'scroll'\n | 'wait'\n | 'screenshot';\n\n /**\n * (x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=mouse_move` and `action=left_click_drag`.\n */\n coordinate?: [number, number];\n\n /**\n * The duration to hold the key down for. Required only by `action=hold_key` and `action=wait`.\n */\n duration?: number;\n\n /**\n * The number of 'clicks' to scroll. Required only by `action=scroll`.\n */\n scroll_amount?: number;\n\n /**\n * The direction to scroll the screen. Required only by `action=scroll`.\n */\n scroll_direction?: 'up' | 'down' | 'left' | 'right';\n\n /**\n * (x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to start the drag from. Required only by `action=left_click_drag`.\n */\n start_coordinate?: [number, number];\n\n /**\n * Required only by `action=type`, `action=key`, and `action=hold_key`. Can also be used by click or scroll actions to hold down keys while clicking or scrolling.\n */\n text?: string;\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n}): {\n type: 'provider-defined';\n id: 'anthropic.computer_20250124';\n args: {};\n parameters: typeof Computer20250124Parameters;\n execute: ExecuteFunction<z.infer<typeof Computer20250124Parameters>, RESULT>;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.computer_20250124',\n args: {\n displayWidthPx: options.displayWidthPx,\n displayHeightPx: options.displayHeightPx,\n displayNumber: options.displayNumber,\n },\n parameters: Computer20250124Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nexport const anthropicTools = {\n bash_20241022: bashTool_20241022,\n bash_20250124: bashTool_20250124,\n textEditor_20241022: textEditorTool_20241022,\n textEditor_20250124: textEditorTool_20250124,\n computer_20241022: computerTool_20241022,\n computer_20250124: computerTool_20250124,\n};\n"],"mappings":";AAAA;AAAA,EAOE,iCAAAA;A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A,EACnE,UAAUA,GAAE,OAAO,EAAE,SAAS;AAAA,EAC9B,eAAeA,GAAE,OAAO,EAAE,SAAS;AAAA,EACnC,kBAAkBA,GAAE,KAAK,CAAC,MAAM,QAAQ,QAAQ,OAAO,CAAC,EAAE,SAAS;AAAA,EACnE,kBAAkBA,GAAE,MAAM,CAACA,GAAE,OAAO,EAAE,IAAI,GAAGA,GAAE,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS;AAAA,EACzE,MAAMA,GAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;AAYD,SAAS,sBAA8B,SAoFrC;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,IAAI;AAAA,IACJ,MAAM;AAAA,MACJ,gBAAgB,QAAQ;AAAA,MACxB,iBAAiB,QAAQ;AAAA,MACzB,eAAe,QAAQ;AAAA,IACzB;AAAA,IACA,YAAY;AAAA,IACZ,SAAS,QAAQ;AAAA,IACjB,kCAAkC,QAAQ;AAAA,EAC5C;AACF;AAEO,IAAM,iBAAiB;AAAA,EAC5B,eAAe;AAAA,EACf,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,mBAAmB;AACrB;","names":["UnsupportedFunctionalityError","z","anthropicTools","UnsupportedFunctionalityError","_a","i","part","UnsupportedFunctionalityError","anthropicTools","z","z"]}
1
+ {"version":3,"sources":["../../src/anthropic-messages-language-model.ts","../../src/anthropic-error.ts","../../src/anthropic-prepare-tools.ts","../../src/convert-to-anthropic-messages-prompt.ts","../../src/map-anthropic-stop-reason.ts","../../src/anthropic-tools.ts"],"sourcesContent":["import {\n LanguageModelV2,\n LanguageModelV2CallWarning,\n LanguageModelV2FinishReason,\n LanguageModelV2FunctionToolCall,\n LanguageModelV2ProviderMetadata,\n LanguageModelV2StreamPart,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n ParseResult,\n Resolvable,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\nimport { anthropicFailedResponseHandler } from './anthropic-error';\nimport {\n AnthropicMessagesModelId,\n AnthropicMessagesSettings,\n} from './anthropic-messages-settings';\nimport { prepareTools } from './anthropic-prepare-tools';\nimport { convertToAnthropicMessagesPrompt } from './convert-to-anthropic-messages-prompt';\nimport { mapAnthropicStopReason } from './map-anthropic-stop-reason';\n\ntype AnthropicMessagesConfig = {\n provider: string;\n baseURL: string;\n headers: Resolvable<Record<string, string | undefined>>;\n supportsImageUrls: boolean;\n fetch?: FetchFunction;\n buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;\n transformRequestBody?: (args: Record<string, any>) => Record<string, any>;\n};\n\nexport class AnthropicMessagesLanguageModel implements LanguageModelV2 {\n readonly specificationVersion = 'v2';\n readonly defaultObjectGenerationMode = 'tool';\n\n readonly modelId: AnthropicMessagesModelId;\n readonly settings: AnthropicMessagesSettings;\n\n private readonly config: AnthropicMessagesConfig;\n\n constructor(\n modelId: AnthropicMessagesModelId,\n settings: AnthropicMessagesSettings,\n config: AnthropicMessagesConfig,\n ) {\n this.modelId = modelId;\n this.settings = settings;\n this.config = config;\n }\n\n supportsUrl(url: URL): boolean {\n return url.protocol === 'https:';\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n get supportsImageUrls(): boolean {\n return this.config.supportsImageUrls;\n }\n\n private async getArgs({\n prompt,\n maxTokens = 4096, // 4096: max model output tokens TODO update default in v5\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n stopSequences,\n responseFormat,\n seed,\n tools,\n toolChoice,\n providerOptions,\n }: Parameters<LanguageModelV2['doGenerate']>[0]) {\n const warnings: LanguageModelV2CallWarning[] = [];\n\n if (frequencyPenalty != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'frequencyPenalty',\n });\n }\n\n if (presencePenalty != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'presencePenalty',\n });\n }\n\n if (seed != null) {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'seed',\n });\n }\n\n if (responseFormat != null && responseFormat.type !== 'text') {\n warnings.push({\n type: 'unsupported-setting',\n setting: 'responseFormat',\n details: 'JSON response format is not supported.',\n });\n }\n\n const { prompt: messagesPrompt, betas: messagesBetas } =\n convertToAnthropicMessagesPrompt({\n prompt,\n sendReasoning: this.settings.sendReasoning ?? true,\n warnings,\n });\n\n const anthropicOptions = parseProviderOptions({\n provider: 'anthropic',\n providerOptions,\n schema: anthropicProviderOptionsSchema,\n });\n\n const isThinking = anthropicOptions?.thinking?.type === 'enabled';\n const thinkingBudget = anthropicOptions?.thinking?.budgetTokens;\n\n const baseArgs = {\n // model id:\n model: this.modelId,\n\n // standardized settings:\n max_tokens: maxTokens,\n temperature,\n top_k: topK,\n top_p: topP,\n stop_sequences: stopSequences,\n\n // provider specific settings:\n ...(isThinking && {\n thinking: { type: 'enabled', budget_tokens: thinkingBudget },\n }),\n\n // prompt:\n system: messagesPrompt.system,\n messages: messagesPrompt.messages,\n };\n\n if (isThinking) {\n if (thinkingBudget == null) {\n throw new UnsupportedFunctionalityError({\n functionality: 'thinking requires a budget',\n });\n }\n\n if (baseArgs.temperature != null) {\n baseArgs.temperature = undefined;\n warnings.push({\n type: 'unsupported-setting',\n setting: 'temperature',\n details: 'temperature is not supported when thinking is enabled',\n });\n }\n\n if (topK != null) {\n baseArgs.top_k = undefined;\n warnings.push({\n type: 'unsupported-setting',\n setting: 'topK',\n details: 'topK is not supported when thinking is enabled',\n });\n }\n\n if (topP != null) {\n baseArgs.top_p = undefined;\n warnings.push({\n type: 'unsupported-setting',\n setting: 'topP',\n details: 'topP is not supported when thinking is enabled',\n });\n }\n\n // adjust max tokens to account for thinking:\n baseArgs.max_tokens = maxTokens + thinkingBudget;\n }\n\n const {\n tools: anthropicTools,\n toolChoice: anthropicToolChoice,\n toolWarnings,\n betas: toolsBetas,\n } = prepareTools({ tools, toolChoice });\n\n return {\n args: {\n ...baseArgs,\n tools: anthropicTools,\n tool_choice: anthropicToolChoice,\n },\n warnings: [...warnings, ...toolWarnings],\n betas: new Set([...messagesBetas, ...toolsBetas]),\n };\n }\n\n private async getHeaders({\n betas,\n headers,\n }: {\n betas: Set<string>;\n headers: Record<string, string | undefined> | undefined;\n }) {\n return combineHeaders(\n await resolve(this.config.headers),\n betas.size > 0 ? { 'anthropic-beta': Array.from(betas).join(',') } : {},\n headers,\n );\n }\n\n private buildRequestUrl(isStreaming: boolean): string {\n return (\n this.config.buildRequestUrl?.(this.config.baseURL, isStreaming) ??\n `${this.config.baseURL}/messages`\n );\n }\n\n private transformRequestBody(args: Record<string, any>): Record<string, any> {\n return this.config.transformRequestBody?.(args) ?? args;\n }\n\n async doGenerate(\n options: Parameters<LanguageModelV2['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>> {\n const { args, warnings, betas } = await this.getArgs(options);\n\n const {\n responseHeaders,\n value: response,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: this.buildRequestUrl(false),\n headers: await this.getHeaders({ betas, headers: options.headers }),\n body: this.transformRequestBody(args),\n failedResponseHandler: anthropicFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n anthropicMessagesResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const { messages: rawPrompt, ...rawSettings } = args;\n\n // extract text\n let text = '';\n for (const content of response.content) {\n if (content.type === 'text') {\n text += content.text;\n }\n }\n\n // extract tool calls\n let toolCalls: LanguageModelV2FunctionToolCall[] | undefined = undefined;\n if (response.content.some(content => content.type === 'tool_use')) {\n toolCalls = [];\n for (const content of response.content) {\n if (content.type === 'tool_use') {\n toolCalls.push({\n toolCallType: 'function',\n toolCallId: content.id,\n toolName: content.name,\n args: JSON.stringify(content.input),\n });\n }\n }\n }\n\n const reasoning = response.content\n .filter(\n content =>\n content.type === 'redacted_thinking' || content.type === 'thinking',\n )\n .map(content =>\n content.type === 'thinking'\n ? {\n type: 'text' as const,\n text: content.thinking,\n signature: content.signature,\n }\n : {\n type: 'redacted' as const,\n data: content.data,\n },\n );\n\n return {\n text,\n reasoning: reasoning.length > 0 ? reasoning : undefined,\n toolCalls,\n finishReason: mapAnthropicStopReason(response.stop_reason),\n usage: {\n promptTokens: response.usage.input_tokens,\n completionTokens: response.usage.output_tokens,\n },\n rawCall: { rawPrompt, rawSettings },\n response: {\n id: response.id ?? undefined,\n modelId: response.model ?? undefined,\n headers: responseHeaders,\n body: rawResponse,\n },\n warnings,\n providerMetadata: {\n anthropic: {\n cacheCreationInputTokens:\n response.usage.cache_creation_input_tokens ?? null,\n cacheReadInputTokens: response.usage.cache_read_input_tokens ?? null,\n },\n },\n request: { body: JSON.stringify(args) },\n };\n }\n\n async doStream(\n options: Parameters<LanguageModelV2['doStream']>[0],\n ): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>> {\n const { args, warnings, betas } = await this.getArgs(options);\n const body = { ...args, stream: true };\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: this.buildRequestUrl(true),\n headers: await this.getHeaders({ betas, headers: options.headers }),\n body: this.transformRequestBody(body),\n failedResponseHandler: anthropicFailedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n anthropicMessagesChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const { messages: rawPrompt, ...rawSettings } = args;\n\n let finishReason: LanguageModelV2FinishReason = 'unknown';\n const usage: { promptTokens: number; completionTokens: number } = {\n promptTokens: Number.NaN,\n completionTokens: Number.NaN,\n };\n\n const toolCallContentBlocks: Record<\n number,\n {\n toolCallId: string;\n toolName: string;\n jsonText: string;\n }\n > = {};\n\n let providerMetadata: LanguageModelV2ProviderMetadata | undefined =\n undefined;\n\n let blockType:\n | 'text'\n | 'thinking'\n | 'tool_use'\n | 'redacted_thinking'\n | undefined = undefined;\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<z.infer<typeof anthropicMessagesChunkSchema>>,\n LanguageModelV2StreamPart\n >({\n transform(chunk, controller) {\n if (!chunk.success) {\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n\n const value = chunk.value;\n\n switch (value.type) {\n case 'ping': {\n return; // ignored\n }\n\n case 'content_block_start': {\n const contentBlockType = value.content_block.type;\n\n blockType = contentBlockType;\n\n switch (contentBlockType) {\n case 'text':\n case 'thinking': {\n return; // ignored\n }\n\n case 'redacted_thinking': {\n controller.enqueue({\n type: 'redacted-reasoning',\n data: value.content_block.data,\n });\n return;\n }\n\n case 'tool_use': {\n toolCallContentBlocks[value.index] = {\n toolCallId: value.content_block.id,\n toolName: value.content_block.name,\n jsonText: '',\n };\n return;\n }\n\n default: {\n const _exhaustiveCheck: never = contentBlockType;\n throw new Error(\n `Unsupported content block type: ${_exhaustiveCheck}`,\n );\n }\n }\n }\n\n case 'content_block_stop': {\n // when finishing a tool call block, send the full tool call:\n if (toolCallContentBlocks[value.index] != null) {\n const contentBlock = toolCallContentBlocks[value.index];\n\n controller.enqueue({\n type: 'tool-call',\n toolCallType: 'function',\n toolCallId: contentBlock.toolCallId,\n toolName: contentBlock.toolName,\n args: contentBlock.jsonText,\n });\n\n delete toolCallContentBlocks[value.index];\n }\n\n blockType = undefined; // reset block type\n\n return;\n }\n\n case 'content_block_delta': {\n const deltaType = value.delta.type;\n switch (deltaType) {\n case 'text_delta': {\n controller.enqueue({\n type: 'text-delta',\n textDelta: value.delta.text,\n });\n\n return;\n }\n\n case 'thinking_delta': {\n controller.enqueue({\n type: 'reasoning',\n textDelta: value.delta.thinking,\n });\n\n return;\n }\n\n case 'signature_delta': {\n // signature are only supported on thinking blocks:\n if (blockType === 'thinking') {\n controller.enqueue({\n type: 'reasoning-signature',\n signature: value.delta.signature,\n });\n }\n\n return;\n }\n\n case 'input_json_delta': {\n const contentBlock = toolCallContentBlocks[value.index];\n\n controller.enqueue({\n type: 'tool-call-delta',\n toolCallType: 'function',\n toolCallId: contentBlock.toolCallId,\n toolName: contentBlock.toolName,\n argsTextDelta: value.delta.partial_json,\n });\n\n contentBlock.jsonText += value.delta.partial_json;\n\n return;\n }\n\n default: {\n const _exhaustiveCheck: never = deltaType;\n throw new Error(\n `Unsupported delta type: ${_exhaustiveCheck}`,\n );\n }\n }\n }\n\n case 'message_start': {\n usage.promptTokens = value.message.usage.input_tokens;\n usage.completionTokens = value.message.usage.output_tokens;\n\n providerMetadata = {\n anthropic: {\n cacheCreationInputTokens:\n value.message.usage.cache_creation_input_tokens ?? null,\n cacheReadInputTokens:\n value.message.usage.cache_read_input_tokens ?? null,\n },\n };\n\n controller.enqueue({\n type: 'response-metadata',\n id: value.message.id ?? undefined,\n modelId: value.message.model ?? undefined,\n });\n\n return;\n }\n\n case 'message_delta': {\n usage.completionTokens = value.usage.output_tokens;\n finishReason = mapAnthropicStopReason(value.delta.stop_reason);\n return;\n }\n\n case 'message_stop': {\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage,\n providerMetadata,\n });\n return;\n }\n\n case 'error': {\n controller.enqueue({ type: 'error', error: value.error });\n return;\n }\n\n default: {\n const _exhaustiveCheck: never = value;\n throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`);\n }\n }\n },\n }),\n ),\n rawCall: { rawPrompt, rawSettings },\n response: { headers: responseHeaders },\n warnings,\n request: { body: JSON.stringify(body) },\n };\n }\n}\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst anthropicMessagesResponseSchema = z.object({\n type: z.literal('message'),\n id: z.string().nullish(),\n model: z.string().nullish(),\n content: z.array(\n z.discriminatedUnion('type', [\n z.object({\n type: z.literal('text'),\n text: z.string(),\n }),\n z.object({\n type: z.literal('thinking'),\n thinking: z.string(),\n signature: z.string(),\n }),\n z.object({\n type: z.literal('redacted_thinking'),\n data: z.string(),\n }),\n z.object({\n type: z.literal('tool_use'),\n id: z.string(),\n name: z.string(),\n input: z.unknown(),\n }),\n ]),\n ),\n stop_reason: z.string().nullish(),\n usage: z.object({\n input_tokens: z.number(),\n output_tokens: z.number(),\n cache_creation_input_tokens: z.number().nullish(),\n cache_read_input_tokens: z.number().nullish(),\n }),\n});\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst anthropicMessagesChunkSchema = z.discriminatedUnion('type', [\n z.object({\n type: z.literal('message_start'),\n message: z.object({\n id: z.string().nullish(),\n model: z.string().nullish(),\n usage: z.object({\n input_tokens: z.number(),\n output_tokens: z.number(),\n cache_creation_input_tokens: z.number().nullish(),\n cache_read_input_tokens: z.number().nullish(),\n }),\n }),\n }),\n z.object({\n type: z.literal('content_block_start'),\n index: z.number(),\n content_block: z.discriminatedUnion('type', [\n z.object({\n type: z.literal('text'),\n text: z.string(),\n }),\n z.object({\n type: z.literal('thinking'),\n thinking: z.string(),\n }),\n z.object({\n type: z.literal('tool_use'),\n id: z.string(),\n name: z.string(),\n }),\n z.object({\n type: z.literal('redacted_thinking'),\n data: z.string(),\n }),\n ]),\n }),\n z.object({\n type: z.literal('content_block_delta'),\n index: z.number(),\n delta: z.discriminatedUnion('type', [\n z.object({\n type: z.literal('input_json_delta'),\n partial_json: z.string(),\n }),\n z.object({\n type: z.literal('text_delta'),\n text: z.string(),\n }),\n z.object({\n type: z.literal('thinking_delta'),\n thinking: z.string(),\n }),\n z.object({\n type: z.literal('signature_delta'),\n signature: z.string(),\n }),\n ]),\n }),\n z.object({\n type: z.literal('content_block_stop'),\n index: z.number(),\n }),\n z.object({\n type: z.literal('error'),\n error: z.object({\n type: z.string(),\n message: z.string(),\n }),\n }),\n z.object({\n type: z.literal('message_delta'),\n delta: z.object({ stop_reason: z.string().nullish() }),\n usage: z.object({ output_tokens: z.number() }),\n }),\n z.object({\n type: z.literal('message_stop'),\n }),\n z.object({\n type: z.literal('ping'),\n }),\n]);\n\nconst anthropicProviderOptionsSchema = z.object({\n thinking: z\n .object({\n type: z.union([z.literal('enabled'), z.literal('disabled')]),\n budgetTokens: z.number().optional(),\n })\n .optional(),\n});\n\nexport type AnthropicProviderOptions = z.infer<\n typeof anthropicProviderOptionsSchema\n>;\n","import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\nimport { z } from 'zod';\n\nconst anthropicErrorDataSchema = z.object({\n type: z.literal('error'),\n error: z.object({\n type: z.string(),\n message: z.string(),\n }),\n});\n\nexport type AnthropicErrorData = z.infer<typeof anthropicErrorDataSchema>;\n\nexport const anthropicFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: anthropicErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n","import {\n LanguageModelV2CallOptions,\n LanguageModelV2CallWarning,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport { AnthropicTool, AnthropicToolChoice } from './anthropic-api-types';\n\nexport function prepareTools({\n tools,\n toolChoice,\n}: {\n tools: LanguageModelV2CallOptions['tools'];\n toolChoice?: LanguageModelV2CallOptions['toolChoice'];\n}): {\n tools: Array<AnthropicTool> | undefined;\n toolChoice: AnthropicToolChoice | undefined;\n toolWarnings: LanguageModelV2CallWarning[];\n betas: Set<string>;\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: LanguageModelV2CallWarning[] = [];\n const betas = new Set<string>();\n\n if (tools == null) {\n return { tools: undefined, toolChoice: undefined, toolWarnings, betas };\n }\n\n const anthropicTools: AnthropicTool[] = [];\n\n for (const tool of tools) {\n switch (tool.type) {\n case 'function':\n anthropicTools.push({\n name: tool.name,\n description: tool.description,\n input_schema: tool.parameters,\n });\n break;\n case 'provider-defined':\n switch (tool.id) {\n case 'anthropic.computer_20250124':\n betas.add('computer-use-2025-01-24');\n anthropicTools.push({\n name: tool.name,\n type: 'computer_20250124',\n display_width_px: tool.args.displayWidthPx as number,\n display_height_px: tool.args.displayHeightPx as number,\n display_number: tool.args.displayNumber as number,\n });\n break;\n case 'anthropic.computer_20241022':\n betas.add('computer-use-2024-10-22');\n anthropicTools.push({\n name: tool.name,\n type: 'computer_20241022',\n display_width_px: tool.args.displayWidthPx as number,\n display_height_px: tool.args.displayHeightPx as number,\n display_number: tool.args.displayNumber as number,\n });\n break;\n case 'anthropic.text_editor_20250124':\n betas.add('computer-use-2025-01-24');\n anthropicTools.push({\n name: tool.name,\n type: 'text_editor_20250124',\n });\n break;\n case 'anthropic.text_editor_20241022':\n betas.add('computer-use-2024-10-22');\n anthropicTools.push({\n name: tool.name,\n type: 'text_editor_20241022',\n });\n break;\n case 'anthropic.bash_20250124':\n betas.add('computer-use-2025-01-24');\n anthropicTools.push({\n name: tool.name,\n type: 'bash_20250124',\n });\n break;\n case 'anthropic.bash_20241022':\n betas.add('computer-use-2024-10-22');\n anthropicTools.push({\n name: tool.name,\n type: 'bash_20241022',\n });\n break;\n default:\n toolWarnings.push({ type: 'unsupported-tool', tool });\n break;\n }\n break;\n default:\n toolWarnings.push({ type: 'unsupported-tool', tool });\n break;\n }\n }\n\n if (toolChoice == null) {\n return {\n tools: anthropicTools,\n toolChoice: undefined,\n toolWarnings,\n betas,\n };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n return {\n tools: anthropicTools,\n toolChoice: { type: 'auto' },\n toolWarnings,\n betas,\n };\n case 'required':\n return {\n tools: anthropicTools,\n toolChoice: { type: 'any' },\n toolWarnings,\n betas,\n };\n case 'none':\n // Anthropic does not support 'none' tool choice, so we remove the tools:\n return { tools: undefined, toolChoice: undefined, toolWarnings, betas };\n case 'tool':\n return {\n tools: anthropicTools,\n toolChoice: { type: 'tool', name: toolChoice.toolName },\n toolWarnings,\n betas,\n };\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","import {\n LanguageModelV2CallWarning,\n LanguageModelV2Message,\n LanguageModelV2Prompt,\n LanguageModelV2ProviderMetadata,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\nimport {\n AnthropicAssistantMessage,\n AnthropicCacheControl,\n AnthropicMessagesPrompt,\n AnthropicUserMessage,\n} from './anthropic-api-types';\n\nexport function convertToAnthropicMessagesPrompt({\n prompt,\n sendReasoning,\n warnings,\n}: {\n prompt: LanguageModelV2Prompt;\n sendReasoning: boolean;\n warnings: LanguageModelV2CallWarning[];\n}): {\n prompt: AnthropicMessagesPrompt;\n betas: Set<string>;\n} {\n const betas = new Set<string>();\n const blocks = groupIntoBlocks(prompt);\n\n let system: AnthropicMessagesPrompt['system'] = undefined;\n const messages: AnthropicMessagesPrompt['messages'] = [];\n\n function getCacheControl(\n providerMetadata: LanguageModelV2ProviderMetadata | undefined,\n ): AnthropicCacheControl | undefined {\n const anthropic = providerMetadata?.anthropic;\n\n // allow both cacheControl and cache_control:\n const cacheControlValue =\n anthropic?.cacheControl ?? anthropic?.cache_control;\n\n // Pass through value assuming it is of the correct type.\n // The Anthropic API will validate the value.\n return cacheControlValue as AnthropicCacheControl | undefined;\n }\n\n for (let i = 0; i < blocks.length; i++) {\n const block = blocks[i];\n const isLastBlock = i === blocks.length - 1;\n const type = block.type;\n\n switch (type) {\n case 'system': {\n if (system != null) {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'Multiple system messages that are separated by user/assistant messages',\n });\n }\n\n system = block.messages.map(({ content, providerOptions }) => ({\n type: 'text',\n text: content,\n cache_control: getCacheControl(providerOptions),\n }));\n\n break;\n }\n\n case 'user': {\n // combines all user and tool messages in this block into a single message:\n const anthropicContent: AnthropicUserMessage['content'] = [];\n\n for (const message of block.messages) {\n const { role, content } = message;\n switch (role) {\n case 'user': {\n for (let j = 0; j < content.length; j++) {\n const part = content[j];\n\n // cache control: first add cache control from part.\n // for the last part of a message,\n // check also if the message has cache control.\n const isLastPart = j === content.length - 1;\n\n const cacheControl =\n getCacheControl(part.providerOptions) ??\n (isLastPart\n ? getCacheControl(message.providerOptions)\n : undefined);\n\n switch (part.type) {\n case 'text': {\n anthropicContent.push({\n type: 'text',\n text: part.text,\n cache_control: cacheControl,\n });\n break;\n }\n\n case 'file': {\n if (part.mediaType.startsWith('image/')) {\n anthropicContent.push({\n type: 'image',\n source:\n part.data instanceof URL\n ? {\n type: 'url',\n url: part.data.toString(),\n }\n : {\n type: 'base64',\n media_type:\n part.mediaType === 'image/*'\n ? 'image/jpeg'\n : part.mediaType,\n data: part.data,\n },\n cache_control: cacheControl,\n });\n } else if (part.mediaType === 'application/pdf') {\n betas.add('pdfs-2024-09-25');\n\n anthropicContent.push({\n type: 'document',\n source:\n part.data instanceof URL\n ? {\n type: 'url',\n url: part.data.toString(),\n }\n : {\n type: 'base64',\n media_type: 'application/pdf',\n data: part.data,\n },\n cache_control: cacheControl,\n });\n } else {\n throw new UnsupportedFunctionalityError({\n functionality: `media type: ${part.mediaType}`,\n });\n }\n\n break;\n }\n }\n }\n\n break;\n }\n case 'tool': {\n for (let i = 0; i < content.length; i++) {\n const part = content[i];\n\n // cache control: first add cache control from part.\n // for the last part of a message,\n // check also if the message has cache control.\n const isLastPart = i === content.length - 1;\n\n const cacheControl =\n getCacheControl(part.providerOptions) ??\n (isLastPart\n ? getCacheControl(message.providerOptions)\n : undefined);\n\n const toolResultContent =\n part.content != null\n ? part.content.map(part => {\n switch (part.type) {\n case 'text':\n return {\n type: 'text' as const,\n text: part.text,\n cache_control: undefined,\n };\n case 'image':\n return {\n type: 'image' as const,\n source: {\n type: 'base64' as const,\n media_type: part.mediaType ?? 'image/jpeg',\n data: part.data,\n },\n cache_control: undefined,\n };\n }\n })\n : JSON.stringify(part.result);\n\n anthropicContent.push({\n type: 'tool_result',\n tool_use_id: part.toolCallId,\n content: toolResultContent,\n is_error: part.isError,\n cache_control: cacheControl,\n });\n }\n\n break;\n }\n default: {\n const _exhaustiveCheck: never = role;\n throw new Error(`Unsupported role: ${_exhaustiveCheck}`);\n }\n }\n }\n\n messages.push({ role: 'user', content: anthropicContent });\n\n break;\n }\n\n case 'assistant': {\n // combines multiple assistant messages in this block into a single message:\n const anthropicContent: AnthropicAssistantMessage['content'] = [];\n\n for (let j = 0; j < block.messages.length; j++) {\n const message = block.messages[j];\n const isLastMessage = j === block.messages.length - 1;\n const { content } = message;\n\n for (let k = 0; k < content.length; k++) {\n const part = content[k];\n const isLastContentPart = k === content.length - 1;\n\n // cache control: first add cache control from part.\n // for the last part of a message,\n // check also if the message has cache control.\n const cacheControl =\n getCacheControl(part.providerOptions) ??\n (isLastContentPart\n ? getCacheControl(message.providerOptions)\n : undefined);\n\n switch (part.type) {\n case 'text': {\n anthropicContent.push({\n type: 'text',\n text:\n // trim the last text part if it's the last message in the block\n // because Anthropic does not allow trailing whitespace\n // in pre-filled assistant responses\n isLastBlock && isLastMessage && isLastContentPart\n ? part.text.trim()\n : part.text,\n\n cache_control: cacheControl,\n });\n break;\n }\n\n case 'reasoning': {\n if (sendReasoning) {\n anthropicContent.push({\n type: 'thinking',\n thinking: part.text,\n signature: part.signature!,\n cache_control: cacheControl,\n });\n } else {\n warnings.push({\n type: 'other',\n message:\n 'sending reasoning content is disabled for this model',\n });\n }\n break;\n }\n\n case 'redacted-reasoning': {\n anthropicContent.push({\n type: 'redacted_thinking',\n data: part.data,\n cache_control: cacheControl,\n });\n break;\n }\n\n case 'tool-call': {\n anthropicContent.push({\n type: 'tool_use',\n id: part.toolCallId,\n name: part.toolName,\n input: part.args,\n cache_control: cacheControl,\n });\n break;\n }\n }\n }\n }\n\n messages.push({ role: 'assistant', content: anthropicContent });\n\n break;\n }\n\n default: {\n const _exhaustiveCheck: never = type;\n throw new Error(`content type: ${_exhaustiveCheck}`);\n }\n }\n }\n\n return {\n prompt: { system, messages },\n betas,\n };\n}\n\ntype SystemBlock = {\n type: 'system';\n messages: Array<LanguageModelV2Message & { role: 'system' }>;\n};\ntype AssistantBlock = {\n type: 'assistant';\n messages: Array<LanguageModelV2Message & { role: 'assistant' }>;\n};\ntype UserBlock = {\n type: 'user';\n messages: Array<LanguageModelV2Message & { role: 'user' | 'tool' }>;\n};\n\nfunction groupIntoBlocks(\n prompt: LanguageModelV2Prompt,\n): Array<SystemBlock | AssistantBlock | UserBlock> {\n const blocks: Array<SystemBlock | AssistantBlock | UserBlock> = [];\n let currentBlock: SystemBlock | AssistantBlock | UserBlock | undefined =\n undefined;\n\n for (const message of prompt) {\n const { role } = message;\n switch (role) {\n case 'system': {\n if (currentBlock?.type !== 'system') {\n currentBlock = { type: 'system', messages: [] };\n blocks.push(currentBlock);\n }\n\n currentBlock.messages.push(message);\n break;\n }\n case 'assistant': {\n if (currentBlock?.type !== 'assistant') {\n currentBlock = { type: 'assistant', messages: [] };\n blocks.push(currentBlock);\n }\n\n currentBlock.messages.push(message);\n break;\n }\n case 'user': {\n if (currentBlock?.type !== 'user') {\n currentBlock = { type: 'user', messages: [] };\n blocks.push(currentBlock);\n }\n\n currentBlock.messages.push(message);\n break;\n }\n case 'tool': {\n if (currentBlock?.type !== 'user') {\n currentBlock = { type: 'user', messages: [] };\n blocks.push(currentBlock);\n }\n\n currentBlock.messages.push(message);\n break;\n }\n default: {\n const _exhaustiveCheck: never = role;\n throw new Error(`Unsupported role: ${_exhaustiveCheck}`);\n }\n }\n }\n\n return blocks;\n}\n","import { LanguageModelV2FinishReason } from '@ai-sdk/provider';\n\nexport function mapAnthropicStopReason(\n finishReason: string | null | undefined,\n): LanguageModelV2FinishReason {\n switch (finishReason) {\n case 'end_turn':\n case 'stop_sequence':\n return 'stop';\n case 'tool_use':\n return 'tool-calls';\n case 'max_tokens':\n return 'length';\n default:\n return 'unknown';\n }\n}\n","import { z } from 'zod';\n\n// Copied from ai package\ntype ExecuteFunction<PARAMETERS, RESULT> =\n | undefined\n | ((\n args: PARAMETERS,\n options: { abortSignal?: AbortSignal },\n ) => Promise<RESULT>);\n\n// Copied from ai package\nexport type ToolResultContent = Array<\n | {\n type: 'text';\n text: string;\n }\n | {\n type: 'image';\n data: string; // base64 encoded png image, e.g. screenshot\n mediaType?: string; // e.g. 'image/png';\n }\n>;\n\nconst Bash20241022Parameters = z.object({\n command: z.string(),\n restart: z.boolean().optional(),\n});\n\n/**\n * Creates a tool for running a bash command. Must have name \"bash\".\n *\n * Image results are supported.\n *\n * @param execute - The function to execute the tool. Optional.\n */\nfunction bashTool_20241022<RESULT>(\n options: {\n execute?: ExecuteFunction<\n {\n /**\n * The bash command to run. Required unless the tool is being restarted.\n */\n command: string;\n\n /**\n * Specifying true will restart this tool. Otherwise, leave this unspecified.\n */\n restart?: boolean;\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n } = {},\n): {\n type: 'provider-defined';\n id: 'anthropic.bash_20241022';\n args: {};\n parameters: typeof Bash20241022Parameters;\n execute: ExecuteFunction<z.infer<typeof Bash20241022Parameters>, RESULT>;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.bash_20241022',\n args: {},\n parameters: Bash20241022Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nconst Bash20250124Parameters = z.object({\n command: z.string(),\n restart: z.boolean().optional(),\n});\n\n/**\n * Creates a tool for running a bash command. Must have name \"bash\".\n *\n * Image results are supported.\n *\n * @param execute - The function to execute the tool. Optional.\n */\nfunction bashTool_20250124<RESULT>(\n options: {\n execute?: ExecuteFunction<\n {\n /**\n * The bash command to run. Required unless the tool is being restarted.\n */\n command: string;\n\n /**\n * Specifying true will restart this tool. Otherwise, leave this unspecified.\n */\n restart?: boolean;\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n } = {},\n): {\n type: 'provider-defined';\n id: 'anthropic.bash_20250124';\n args: {};\n parameters: typeof Bash20250124Parameters;\n execute: ExecuteFunction<z.infer<typeof Bash20250124Parameters>, RESULT>;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.bash_20250124',\n args: {},\n parameters: Bash20250124Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nconst TextEditor20241022Parameters = z.object({\n command: z.enum(['view', 'create', 'str_replace', 'insert', 'undo_edit']),\n path: z.string(),\n file_text: z.string().optional(),\n insert_line: z.number().int().optional(),\n new_str: z.string().optional(),\n old_str: z.string().optional(),\n view_range: z.array(z.number().int()).optional(),\n});\n\n/**\n * Creates a tool for editing text. Must have name \"str_replace_editor\".\n *\n * Image results are supported.\n *\n * @param execute - The function to execute the tool. Optional.\n */\nfunction textEditorTool_20241022<RESULT>(\n options: {\n execute?: ExecuteFunction<\n {\n /**\n * The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.\n */\n command: 'view' | 'create' | 'str_replace' | 'insert' | 'undo_edit';\n\n /**\n * Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`.\n */\n path: string;\n\n /**\n * Required parameter of `create` command, with the content of the file to be created.\n */\n file_text?: string;\n\n /**\n * Required parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`.\n */\n insert_line?: number;\n\n /**\n * Optional parameter of `str_replace` command containing the new string (if not given, no string will be added). Required parameter of `insert` command containing the string to insert.\n */\n new_str?: string;\n\n /**\n * Required parameter of `str_replace` command containing the string in `path` to replace.\n */\n old_str?: string;\n\n /**\n * Optional parameter of `view` command when `path` points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file.\n */\n view_range?: number[];\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n } = {},\n): {\n type: 'provider-defined';\n id: 'anthropic.text_editor_20241022';\n args: {};\n parameters: typeof TextEditor20241022Parameters;\n execute: ExecuteFunction<\n z.infer<typeof TextEditor20241022Parameters>,\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.text_editor_20241022',\n args: {},\n parameters: TextEditor20241022Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nconst TextEditor20250124Parameters = z.object({\n command: z.enum(['view', 'create', 'str_replace', 'insert', 'undo_edit']),\n path: z.string(),\n file_text: z.string().optional(),\n insert_line: z.number().int().optional(),\n new_str: z.string().optional(),\n old_str: z.string().optional(),\n view_range: z.array(z.number().int()).optional(),\n});\n\n/**\n * Creates a tool for editing text. Must have name \"str_replace_editor\".\n *\n * Image results are supported.\n *\n * @param execute - The function to execute the tool. Optional.\n */\nfunction textEditorTool_20250124<RESULT>(\n options: {\n execute?: ExecuteFunction<\n {\n /**\n * The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`, `undo_edit`.\n */\n command: 'view' | 'create' | 'str_replace' | 'insert' | 'undo_edit';\n\n /**\n * Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`.\n */\n path: string;\n\n /**\n * Required parameter of `create` command, with the content of the file to be created.\n */\n file_text?: string;\n\n /**\n * Required parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`.\n */\n insert_line?: number;\n\n /**\n * Optional parameter of `str_replace` command containing the new string (if not given, no string will be added). Required parameter of `insert` command containing the string to insert.\n */\n new_str?: string;\n\n /**\n * Required parameter of `str_replace` command containing the string in `path` to replace.\n */\n old_str?: string;\n\n /**\n * Optional parameter of `view` command when `path` points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file.\n */\n view_range?: number[];\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n } = {},\n): {\n type: 'provider-defined';\n id: 'anthropic.text_editor_20250124';\n args: {};\n parameters: typeof TextEditor20250124Parameters;\n execute: ExecuteFunction<\n z.infer<typeof TextEditor20250124Parameters>,\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.text_editor_20250124',\n args: {},\n parameters: TextEditor20250124Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nconst Computer20241022Parameters = z.object({\n action: z.enum([\n 'key',\n 'type',\n 'mouse_move',\n 'left_click',\n 'left_click_drag',\n 'right_click',\n 'middle_click',\n 'double_click',\n 'screenshot',\n 'cursor_position',\n ]),\n coordinate: z.array(z.number().int()).optional(),\n text: z.string().optional(),\n});\n\n/**\n * Creates a tool for executing actions on a computer. Must have name \"computer\".\n *\n * Image results are supported.\n *\n * @param displayWidthPx - The width of the display being controlled by the model in pixels.\n * @param displayHeightPx - The height of the display being controlled by the model in pixels.\n * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.\n * @param execute - The function to execute the tool. Optional.\n */\nfunction computerTool_20241022<RESULT>(options: {\n displayWidthPx: number;\n displayHeightPx: number;\n displayNumber?: number;\n execute?: ExecuteFunction<\n {\n /**\n * The action to perform. The available actions are:\n * - `key`: Press a key or key-combination on the keyboard.\n * - This supports xdotool's `key` syntax.\n * - Examples: \"a\", \"Return\", \"alt+Tab\", \"ctrl+s\", \"Up\", \"KP_0\" (for the numpad 0 key).\n * - `type`: Type a string of text on the keyboard.\n * - `cursor_position`: Get the current (x, y) pixel coordinate of the cursor on the screen.\n * - `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.\n * - `left_click`: Click the left mouse button.\n * - `left_click_drag`: Click and drag the cursor to a specified (x, y) pixel coordinate on the screen.\n * - `right_click`: Click the right mouse button.\n * - `middle_click`: Click the middle mouse button.\n * - `double_click`: Double-click the left mouse button.\n * - `screenshot`: Take a screenshot of the screen.\n */\n action:\n | 'key'\n | 'type'\n | 'mouse_move'\n | 'left_click'\n | 'left_click_drag'\n | 'right_click'\n | 'middle_click'\n | 'double_click'\n | 'screenshot'\n | 'cursor_position';\n\n /**\n * (x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=mouse_move` and `action=left_click_drag`.\n */\n coordinate?: number[];\n\n /**\n * Required only by `action=type` and `action=key`.\n */\n text?: string;\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n}): {\n type: 'provider-defined';\n id: 'anthropic.computer_20241022';\n args: {};\n parameters: typeof Computer20241022Parameters;\n execute: ExecuteFunction<z.infer<typeof Computer20241022Parameters>, RESULT>;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.computer_20241022',\n args: {\n displayWidthPx: options.displayWidthPx,\n displayHeightPx: options.displayHeightPx,\n displayNumber: options.displayNumber,\n },\n parameters: Computer20241022Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nconst Computer20250124Parameters = z.object({\n action: z.enum([\n 'key',\n 'hold_key',\n 'type',\n 'cursor_position',\n 'mouse_move',\n 'left_mouse_down',\n 'left_mouse_up',\n 'left_click',\n 'left_click_drag',\n 'right_click',\n 'middle_click',\n 'double_click',\n 'triple_click',\n 'scroll',\n 'wait',\n 'screenshot',\n ]),\n coordinate: z.tuple([z.number().int(), z.number().int()]).optional(),\n duration: z.number().optional(),\n scroll_amount: z.number().optional(),\n scroll_direction: z.enum(['up', 'down', 'left', 'right']).optional(),\n start_coordinate: z.tuple([z.number().int(), z.number().int()]).optional(),\n text: z.string().optional(),\n});\n\n/**\n * Creates a tool for executing actions on a computer. Must have name \"computer\".\n *\n * Image results are supported.\n *\n * @param displayWidthPx - The width of the display being controlled by the model in pixels.\n * @param displayHeightPx - The height of the display being controlled by the model in pixels.\n * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.\n * @param execute - The function to execute the tool. Optional.\n */\nfunction computerTool_20250124<RESULT>(options: {\n displayWidthPx: number;\n displayHeightPx: number;\n displayNumber?: number;\n execute?: ExecuteFunction<\n {\n /**\n * - `key`: Press a key or key-combination on the keyboard.\n * - This supports xdotool's `key` syntax.\n * - Examples: \"a\", \"Return\", \"alt+Tab\", \"ctrl+s\", \"Up\", \"KP_0\" (for the numpad 0 key).\n * - `hold_key`: Hold down a key or multiple keys for a specified duration (in seconds). Supports the same syntax as `key`.\n * - `type`: Type a string of text on the keyboard.\n * - `cursor_position`: Get the current (x, y) pixel coordinate of the cursor on the screen.\n * - `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.\n * - `left_mouse_down`: Press the left mouse button.\n * - `left_mouse_up`: Release the left mouse button.\n * - `left_click`: Click the left mouse button at the specified (x, y) pixel coordinate on the screen. You can also include a key combination to hold down while clicking using the `text` parameter.\n * - `left_click_drag`: Click and drag the cursor from `start_coordinate` to a specified (x, y) pixel coordinate on the screen.\n * - `right_click`: Click the right mouse button at the specified (x, y) pixel coordinate on the screen.\n * - `middle_click`: Click the middle mouse button at the specified (x, y) pixel coordinate on the screen.\n * - `double_click`: Double-click the left mouse button at the specified (x, y) pixel coordinate on the screen.\n * - `triple_click`: Triple-click the left mouse button at the specified (x, y) pixel coordinate on the screen.\n * - `scroll`: Scroll the screen in a specified direction by a specified amount of clicks of the scroll wheel, at the specified (x, y) pixel coordinate. DO NOT use PageUp/PageDown to scroll.\n * - `wait`: Wait for a specified duration (in seconds).\n * - `screenshot`: Take a screenshot of the screen.\n */\n action:\n | 'key'\n | 'hold_key'\n | 'type'\n | 'cursor_position'\n | 'mouse_move'\n | 'left_mouse_down'\n | 'left_mouse_up'\n | 'left_click'\n | 'left_click_drag'\n | 'right_click'\n | 'middle_click'\n | 'double_click'\n | 'triple_click'\n | 'scroll'\n | 'wait'\n | 'screenshot';\n\n /**\n * (x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=mouse_move` and `action=left_click_drag`.\n */\n coordinate?: [number, number];\n\n /**\n * The duration to hold the key down for. Required only by `action=hold_key` and `action=wait`.\n */\n duration?: number;\n\n /**\n * The number of 'clicks' to scroll. Required only by `action=scroll`.\n */\n scroll_amount?: number;\n\n /**\n * The direction to scroll the screen. Required only by `action=scroll`.\n */\n scroll_direction?: 'up' | 'down' | 'left' | 'right';\n\n /**\n * (x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to start the drag from. Required only by `action=left_click_drag`.\n */\n start_coordinate?: [number, number];\n\n /**\n * Required only by `action=type`, `action=key`, and `action=hold_key`. Can also be used by click or scroll actions to hold down keys while clicking or scrolling.\n */\n text?: string;\n },\n RESULT\n >;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n}): {\n type: 'provider-defined';\n id: 'anthropic.computer_20250124';\n args: {};\n parameters: typeof Computer20250124Parameters;\n execute: ExecuteFunction<z.infer<typeof Computer20250124Parameters>, RESULT>;\n experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;\n} {\n return {\n type: 'provider-defined',\n id: 'anthropic.computer_20250124',\n args: {\n displayWidthPx: options.displayWidthPx,\n displayHeightPx: options.displayHeightPx,\n displayNumber: options.displayNumber,\n },\n parameters: Computer20250124Parameters,\n execute: options.execute,\n experimental_toToolResultContent: options.experimental_toToolResultContent,\n };\n}\n\nexport const anthropicTools = {\n bash_20241022: bashTool_20241022,\n bash_20250124: bashTool_20250124,\n textEditor_20241022: textEditorTool_20241022,\n textEditor_20250124: textEditorTool_20250124,\n computer_20241022: computerTool_20241022,\n computer_20250124: computerTool_20250124,\n};\n"],"mappings":";AAAA;AAAA,EAOE,iCAAAA;AAAA,OACK;AACP;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,KAAAC,UAAS;;;ACpBlB,SAAS,sCAAsC;AAC/C,SAAS,SAAS;AAElB,IAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,MAAM,EAAE,QAAQ,OAAO;AAAA,EACvB,OAAO,EAAE,OAAO;AAAA,IACd,MAAM,EAAE,OAAO;AAAA,IACf,SAAS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E,SAAS;AAAA,EACzE,MAAMA,GAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;AAYD,SAAS,sBAA8B,SAoFrC;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,IAAI;AAAA,IACJ,MAAM;AAAA,MACJ,gBAAgB,QAAQ;AAAA,MACxB,iBAAiB,QAAQ;AAAA,MACzB,eAAe,QAAQ;AAAA,IACzB;AAAA,IACA,YAAY;AAAA,IACZ,SAAS,QAAQ;AAAA,IACjB,kCAAkC,QAAQ;AAAA,EAC5C;AACF;AAEO,IAAM,iBAAiB;AAAA,EAC5B,eAAe;AAAA,EACf,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,mBAAmB;AACrB;","names":["UnsupportedFunctionalityError","z","anthropicTools","UnsupportedFunctionalityError","_a","i","part","UnsupportedFunctionalityError","anthropicTools","z","z"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "2.0.0-canary.2",
3
+ "version": "2.0.0-canary.4",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -26,8 +26,8 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@ai-sdk/provider": "2.0.0-canary.1",
30
- "@ai-sdk/provider-utils": "3.0.0-canary.2"
29
+ "@ai-sdk/provider": "2.0.0-canary.3",
30
+ "@ai-sdk/provider-utils": "3.0.0-canary.4"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "20.17.24",