@ai-sdk/anthropic 4.0.0-beta.4 → 4.0.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +305 -4
- package/README.md +2 -0
- package/dist/index.d.ts +83 -58
- package/dist/index.js +2043 -1356
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +85 -58
- package/dist/internal/index.js +1804 -1342
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +116 -13
- package/package.json +14 -15
- package/src/{anthropic-messages-api.ts → anthropic-api.ts} +14 -6
- package/src/anthropic-error.ts +1 -1
- package/src/anthropic-files.ts +95 -0
- package/src/{anthropic-messages-language-model.ts → anthropic-language-model.ts} +263 -78
- package/src/anthropic-message-metadata.ts +1 -4
- package/src/{anthropic-messages-options.ts → anthropic-options.ts} +68 -11
- package/src/anthropic-prepare-tools.ts +14 -7
- package/src/anthropic-provider.ts +42 -13
- package/src/{convert-anthropic-messages-usage.ts → convert-anthropic-usage.ts} +4 -4
- package/src/{convert-to-anthropic-messages-prompt.ts → convert-to-anthropic-prompt.ts} +190 -149
- package/src/forward-anthropic-container-id-from-last-step.ts +2 -2
- package/src/get-cache-control.ts +5 -2
- package/src/index.ts +1 -1
- package/src/internal/index.ts +11 -2
- package/src/map-anthropic-stop-reason.ts +1 -1
- package/src/sanitize-json-schema.ts +203 -0
- package/src/skills/anthropic-skills-api.ts +44 -0
- package/src/skills/anthropic-skills.ts +132 -0
- package/src/tool/bash_20241022.ts +2 -2
- package/src/tool/bash_20250124.ts +2 -2
- package/src/tool/code-execution_20250522.ts +2 -2
- package/src/tool/code-execution_20250825.ts +2 -2
- package/src/tool/code-execution_20260120.ts +2 -2
- package/src/tool/computer_20241022.ts +2 -2
- package/src/tool/computer_20250124.ts +2 -2
- package/src/tool/computer_20251124.ts +2 -2
- package/src/tool/memory_20250818.ts +2 -2
- package/src/tool/text-editor_20241022.ts +2 -2
- package/src/tool/text-editor_20250124.ts +2 -2
- package/src/tool/text-editor_20250429.ts +2 -2
- package/src/tool/text-editor_20250728.ts +6 -3
- package/src/tool/tool-search-bm25_20251119.ts +2 -2
- package/src/tool/tool-search-regex_20251119.ts +2 -2
- package/src/tool/web-fetch-20250910.ts +2 -2
- package/src/tool/web-fetch-20260209.ts +2 -2
- package/src/tool/web-search_20250305.ts +2 -2
- package/src/tool/web-search_20260209.ts +2 -2
- package/dist/index.d.mts +0 -1090
- package/dist/index.mjs +0 -5244
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -969
- package/dist/internal/index.mjs +0 -5136
- package/dist/internal/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,375 +1,454 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
VERSION: () => VERSION,
|
|
24
|
-
anthropic: () => anthropic,
|
|
25
|
-
createAnthropic: () => createAnthropic,
|
|
26
|
-
forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
|
|
30
1
|
// src/anthropic-provider.ts
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
import {
|
|
3
|
+
InvalidArgumentError,
|
|
4
|
+
NoSuchModelError
|
|
5
|
+
} from "@ai-sdk/provider";
|
|
6
|
+
import {
|
|
7
|
+
generateId as generateId2,
|
|
8
|
+
loadApiKey,
|
|
9
|
+
loadOptionalSetting,
|
|
10
|
+
withoutTrailingSlash,
|
|
11
|
+
withUserAgentSuffix
|
|
12
|
+
} from "@ai-sdk/provider-utils";
|
|
36
13
|
|
|
37
|
-
// src/anthropic-
|
|
38
|
-
|
|
39
|
-
|
|
14
|
+
// src/anthropic-files.ts
|
|
15
|
+
import {
|
|
16
|
+
combineHeaders,
|
|
17
|
+
convertInlineFileDataToUint8Array,
|
|
18
|
+
createJsonResponseHandler,
|
|
19
|
+
lazySchema as lazySchema2,
|
|
20
|
+
postFormDataToApi,
|
|
21
|
+
zodSchema as zodSchema2
|
|
22
|
+
} from "@ai-sdk/provider-utils";
|
|
23
|
+
import { z as z2 } from "zod/v4";
|
|
40
24
|
|
|
41
25
|
// src/anthropic-error.ts
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
import {
|
|
27
|
+
createJsonErrorResponseHandler,
|
|
28
|
+
lazySchema,
|
|
29
|
+
zodSchema
|
|
30
|
+
} from "@ai-sdk/provider-utils";
|
|
31
|
+
import { z } from "zod/v4";
|
|
32
|
+
var anthropicErrorDataSchema = lazySchema(
|
|
33
|
+
() => zodSchema(
|
|
34
|
+
z.object({
|
|
35
|
+
type: z.literal("error"),
|
|
36
|
+
error: z.object({
|
|
37
|
+
type: z.string(),
|
|
38
|
+
message: z.string()
|
|
51
39
|
})
|
|
52
40
|
})
|
|
53
41
|
)
|
|
54
42
|
);
|
|
55
|
-
var anthropicFailedResponseHandler =
|
|
43
|
+
var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
|
|
56
44
|
errorSchema: anthropicErrorDataSchema,
|
|
57
45
|
errorToMessage: (data) => data.error.message
|
|
58
46
|
});
|
|
59
47
|
|
|
60
|
-
// src/anthropic-
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
48
|
+
// src/anthropic-files.ts
|
|
49
|
+
var anthropicUploadFileResponseSchema = lazySchema2(
|
|
50
|
+
() => zodSchema2(
|
|
51
|
+
z2.object({
|
|
52
|
+
id: z2.string(),
|
|
53
|
+
type: z2.literal("file"),
|
|
54
|
+
filename: z2.string(),
|
|
55
|
+
mime_type: z2.string(),
|
|
56
|
+
size_bytes: z2.number(),
|
|
57
|
+
created_at: z2.string(),
|
|
58
|
+
downloadable: z2.boolean().nullish()
|
|
59
|
+
})
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
var AnthropicFiles = class {
|
|
63
|
+
constructor(config) {
|
|
64
|
+
this.config = config;
|
|
65
|
+
this.specificationVersion = "v4";
|
|
66
|
+
}
|
|
67
|
+
get provider() {
|
|
68
|
+
return this.config.provider;
|
|
69
|
+
}
|
|
70
|
+
async uploadFile({
|
|
71
|
+
data,
|
|
72
|
+
mediaType,
|
|
73
|
+
filename
|
|
74
|
+
}) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const fileBytes = convertInlineFileDataToUint8Array(data);
|
|
77
|
+
const blob = new Blob([fileBytes], { type: mediaType });
|
|
78
|
+
const formData = new FormData();
|
|
79
|
+
if (filename != null) {
|
|
80
|
+
formData.append("file", blob, filename);
|
|
81
|
+
} else {
|
|
82
|
+
formData.append("file", blob);
|
|
83
|
+
}
|
|
84
|
+
const { value: response } = await postFormDataToApi({
|
|
85
|
+
url: `${this.config.baseURL}/files`,
|
|
86
|
+
headers: combineHeaders(this.config.headers(), {
|
|
87
|
+
"anthropic-beta": "files-api-2025-04-14"
|
|
88
|
+
}),
|
|
89
|
+
formData,
|
|
90
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
91
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
92
|
+
anthropicUploadFileResponseSchema
|
|
93
|
+
),
|
|
94
|
+
fetch: this.config.fetch
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
warnings: [],
|
|
98
|
+
providerReference: { anthropic: response.id },
|
|
99
|
+
mediaType: (_a = response.mime_type) != null ? _a : mediaType,
|
|
100
|
+
filename: (_b = response.filename) != null ? _b : filename,
|
|
101
|
+
providerMetadata: {
|
|
102
|
+
anthropic: {
|
|
103
|
+
filename: response.filename,
|
|
104
|
+
mimeType: response.mime_type,
|
|
105
|
+
sizeBytes: response.size_bytes,
|
|
106
|
+
createdAt: response.created_at,
|
|
107
|
+
...response.downloadable != null ? { downloadable: response.downloadable } : {}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// src/anthropic-language-model.ts
|
|
115
|
+
import {
|
|
116
|
+
APICallError
|
|
117
|
+
} from "@ai-sdk/provider";
|
|
118
|
+
import {
|
|
119
|
+
combineHeaders as combineHeaders2,
|
|
120
|
+
createEventSourceResponseHandler,
|
|
121
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
122
|
+
createToolNameMapping,
|
|
123
|
+
generateId,
|
|
124
|
+
isCustomReasoning,
|
|
125
|
+
mapReasoningToProviderBudget,
|
|
126
|
+
mapReasoningToProviderEffort,
|
|
127
|
+
parseProviderOptions as parseProviderOptions2,
|
|
128
|
+
postJsonToApi,
|
|
129
|
+
resolve,
|
|
130
|
+
resolveProviderReference as resolveProviderReference2,
|
|
131
|
+
serializeModelOptions,
|
|
132
|
+
WORKFLOW_SERIALIZE,
|
|
133
|
+
WORKFLOW_DESERIALIZE
|
|
134
|
+
} from "@ai-sdk/provider-utils";
|
|
135
|
+
|
|
136
|
+
// src/anthropic-api.ts
|
|
137
|
+
import {
|
|
138
|
+
lazySchema as lazySchema3,
|
|
139
|
+
zodSchema as zodSchema3
|
|
140
|
+
} from "@ai-sdk/provider-utils";
|
|
141
|
+
import { z as z3 } from "zod/v4";
|
|
142
|
+
var anthropicResponseSchema = lazySchema3(
|
|
143
|
+
() => zodSchema3(
|
|
144
|
+
z3.object({
|
|
145
|
+
type: z3.literal("message"),
|
|
146
|
+
id: z3.string().nullish(),
|
|
147
|
+
model: z3.string().nullish(),
|
|
148
|
+
content: z3.array(
|
|
149
|
+
z3.discriminatedUnion("type", [
|
|
150
|
+
z3.object({
|
|
151
|
+
type: z3.literal("text"),
|
|
152
|
+
text: z3.string(),
|
|
153
|
+
citations: z3.array(
|
|
154
|
+
z3.discriminatedUnion("type", [
|
|
155
|
+
z3.object({
|
|
156
|
+
type: z3.literal("web_search_result_location"),
|
|
157
|
+
cited_text: z3.string(),
|
|
158
|
+
url: z3.string(),
|
|
159
|
+
title: z3.string(),
|
|
160
|
+
encrypted_index: z3.string()
|
|
82
161
|
}),
|
|
83
|
-
|
|
84
|
-
type:
|
|
85
|
-
cited_text:
|
|
86
|
-
document_index:
|
|
87
|
-
document_title:
|
|
88
|
-
start_page_number:
|
|
89
|
-
end_page_number:
|
|
162
|
+
z3.object({
|
|
163
|
+
type: z3.literal("page_location"),
|
|
164
|
+
cited_text: z3.string(),
|
|
165
|
+
document_index: z3.number(),
|
|
166
|
+
document_title: z3.string().nullable(),
|
|
167
|
+
start_page_number: z3.number(),
|
|
168
|
+
end_page_number: z3.number()
|
|
90
169
|
}),
|
|
91
|
-
|
|
92
|
-
type:
|
|
93
|
-
cited_text:
|
|
94
|
-
document_index:
|
|
95
|
-
document_title:
|
|
96
|
-
start_char_index:
|
|
97
|
-
end_char_index:
|
|
170
|
+
z3.object({
|
|
171
|
+
type: z3.literal("char_location"),
|
|
172
|
+
cited_text: z3.string(),
|
|
173
|
+
document_index: z3.number(),
|
|
174
|
+
document_title: z3.string().nullable(),
|
|
175
|
+
start_char_index: z3.number(),
|
|
176
|
+
end_char_index: z3.number()
|
|
98
177
|
})
|
|
99
178
|
])
|
|
100
179
|
).optional()
|
|
101
180
|
}),
|
|
102
|
-
|
|
103
|
-
type:
|
|
104
|
-
thinking:
|
|
105
|
-
signature:
|
|
181
|
+
z3.object({
|
|
182
|
+
type: z3.literal("thinking"),
|
|
183
|
+
thinking: z3.string(),
|
|
184
|
+
signature: z3.string()
|
|
106
185
|
}),
|
|
107
|
-
|
|
108
|
-
type:
|
|
109
|
-
data:
|
|
186
|
+
z3.object({
|
|
187
|
+
type: z3.literal("redacted_thinking"),
|
|
188
|
+
data: z3.string()
|
|
110
189
|
}),
|
|
111
|
-
|
|
112
|
-
type:
|
|
113
|
-
content:
|
|
190
|
+
z3.object({
|
|
191
|
+
type: z3.literal("compaction"),
|
|
192
|
+
content: z3.string()
|
|
114
193
|
}),
|
|
115
|
-
|
|
116
|
-
type:
|
|
117
|
-
id:
|
|
118
|
-
name:
|
|
119
|
-
input:
|
|
194
|
+
z3.object({
|
|
195
|
+
type: z3.literal("tool_use"),
|
|
196
|
+
id: z3.string(),
|
|
197
|
+
name: z3.string(),
|
|
198
|
+
input: z3.unknown(),
|
|
120
199
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
121
|
-
caller:
|
|
122
|
-
|
|
123
|
-
type:
|
|
124
|
-
tool_id:
|
|
200
|
+
caller: z3.union([
|
|
201
|
+
z3.object({
|
|
202
|
+
type: z3.literal("code_execution_20250825"),
|
|
203
|
+
tool_id: z3.string()
|
|
125
204
|
}),
|
|
126
|
-
|
|
127
|
-
type:
|
|
128
|
-
tool_id:
|
|
205
|
+
z3.object({
|
|
206
|
+
type: z3.literal("code_execution_20260120"),
|
|
207
|
+
tool_id: z3.string()
|
|
129
208
|
}),
|
|
130
|
-
|
|
131
|
-
type:
|
|
209
|
+
z3.object({
|
|
210
|
+
type: z3.literal("direct")
|
|
132
211
|
})
|
|
133
212
|
]).optional()
|
|
134
213
|
}),
|
|
135
|
-
|
|
136
|
-
type:
|
|
137
|
-
id:
|
|
138
|
-
name:
|
|
139
|
-
input:
|
|
140
|
-
caller:
|
|
141
|
-
|
|
142
|
-
type:
|
|
143
|
-
tool_id:
|
|
214
|
+
z3.object({
|
|
215
|
+
type: z3.literal("server_tool_use"),
|
|
216
|
+
id: z3.string(),
|
|
217
|
+
name: z3.string(),
|
|
218
|
+
input: z3.record(z3.string(), z3.unknown()).nullish(),
|
|
219
|
+
caller: z3.union([
|
|
220
|
+
z3.object({
|
|
221
|
+
type: z3.literal("code_execution_20260120"),
|
|
222
|
+
tool_id: z3.string()
|
|
144
223
|
}),
|
|
145
|
-
|
|
146
|
-
type:
|
|
224
|
+
z3.object({
|
|
225
|
+
type: z3.literal("direct")
|
|
147
226
|
})
|
|
148
227
|
]).optional()
|
|
149
228
|
}),
|
|
150
|
-
|
|
151
|
-
type:
|
|
152
|
-
id:
|
|
153
|
-
name:
|
|
154
|
-
input:
|
|
155
|
-
server_name:
|
|
229
|
+
z3.object({
|
|
230
|
+
type: z3.literal("mcp_tool_use"),
|
|
231
|
+
id: z3.string(),
|
|
232
|
+
name: z3.string(),
|
|
233
|
+
input: z3.unknown(),
|
|
234
|
+
server_name: z3.string()
|
|
156
235
|
}),
|
|
157
|
-
|
|
158
|
-
type:
|
|
159
|
-
tool_use_id:
|
|
160
|
-
is_error:
|
|
161
|
-
content:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
236
|
+
z3.object({
|
|
237
|
+
type: z3.literal("mcp_tool_result"),
|
|
238
|
+
tool_use_id: z3.string(),
|
|
239
|
+
is_error: z3.boolean(),
|
|
240
|
+
content: z3.array(
|
|
241
|
+
z3.union([
|
|
242
|
+
z3.string(),
|
|
243
|
+
z3.object({ type: z3.literal("text"), text: z3.string() })
|
|
165
244
|
])
|
|
166
245
|
)
|
|
167
246
|
}),
|
|
168
|
-
|
|
169
|
-
type:
|
|
170
|
-
tool_use_id:
|
|
171
|
-
content:
|
|
172
|
-
|
|
173
|
-
type:
|
|
174
|
-
url:
|
|
175
|
-
retrieved_at:
|
|
176
|
-
content:
|
|
177
|
-
type:
|
|
178
|
-
title:
|
|
179
|
-
citations:
|
|
180
|
-
source:
|
|
181
|
-
|
|
182
|
-
type:
|
|
183
|
-
media_type:
|
|
184
|
-
data:
|
|
247
|
+
z3.object({
|
|
248
|
+
type: z3.literal("web_fetch_tool_result"),
|
|
249
|
+
tool_use_id: z3.string(),
|
|
250
|
+
content: z3.union([
|
|
251
|
+
z3.object({
|
|
252
|
+
type: z3.literal("web_fetch_result"),
|
|
253
|
+
url: z3.string(),
|
|
254
|
+
retrieved_at: z3.string(),
|
|
255
|
+
content: z3.object({
|
|
256
|
+
type: z3.literal("document"),
|
|
257
|
+
title: z3.string().nullable(),
|
|
258
|
+
citations: z3.object({ enabled: z3.boolean() }).optional(),
|
|
259
|
+
source: z3.union([
|
|
260
|
+
z3.object({
|
|
261
|
+
type: z3.literal("base64"),
|
|
262
|
+
media_type: z3.literal("application/pdf"),
|
|
263
|
+
data: z3.string()
|
|
185
264
|
}),
|
|
186
|
-
|
|
187
|
-
type:
|
|
188
|
-
media_type:
|
|
189
|
-
data:
|
|
265
|
+
z3.object({
|
|
266
|
+
type: z3.literal("text"),
|
|
267
|
+
media_type: z3.literal("text/plain"),
|
|
268
|
+
data: z3.string()
|
|
190
269
|
})
|
|
191
270
|
])
|
|
192
271
|
})
|
|
193
272
|
}),
|
|
194
|
-
|
|
195
|
-
type:
|
|
196
|
-
error_code:
|
|
273
|
+
z3.object({
|
|
274
|
+
type: z3.literal("web_fetch_tool_result_error"),
|
|
275
|
+
error_code: z3.string()
|
|
197
276
|
})
|
|
198
277
|
])
|
|
199
278
|
}),
|
|
200
|
-
|
|
201
|
-
type:
|
|
202
|
-
tool_use_id:
|
|
203
|
-
content:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
type:
|
|
207
|
-
url:
|
|
208
|
-
title:
|
|
209
|
-
encrypted_content:
|
|
210
|
-
page_age:
|
|
279
|
+
z3.object({
|
|
280
|
+
type: z3.literal("web_search_tool_result"),
|
|
281
|
+
tool_use_id: z3.string(),
|
|
282
|
+
content: z3.union([
|
|
283
|
+
z3.array(
|
|
284
|
+
z3.object({
|
|
285
|
+
type: z3.literal("web_search_result"),
|
|
286
|
+
url: z3.string(),
|
|
287
|
+
title: z3.string(),
|
|
288
|
+
encrypted_content: z3.string(),
|
|
289
|
+
page_age: z3.string().nullish()
|
|
211
290
|
})
|
|
212
291
|
),
|
|
213
|
-
|
|
214
|
-
type:
|
|
215
|
-
error_code:
|
|
292
|
+
z3.object({
|
|
293
|
+
type: z3.literal("web_search_tool_result_error"),
|
|
294
|
+
error_code: z3.string()
|
|
216
295
|
})
|
|
217
296
|
])
|
|
218
297
|
}),
|
|
219
298
|
// code execution results for code_execution_20250522 tool:
|
|
220
|
-
|
|
221
|
-
type:
|
|
222
|
-
tool_use_id:
|
|
223
|
-
content:
|
|
224
|
-
|
|
225
|
-
type:
|
|
226
|
-
stdout:
|
|
227
|
-
stderr:
|
|
228
|
-
return_code:
|
|
229
|
-
content:
|
|
230
|
-
|
|
231
|
-
type:
|
|
232
|
-
file_id:
|
|
299
|
+
z3.object({
|
|
300
|
+
type: z3.literal("code_execution_tool_result"),
|
|
301
|
+
tool_use_id: z3.string(),
|
|
302
|
+
content: z3.union([
|
|
303
|
+
z3.object({
|
|
304
|
+
type: z3.literal("code_execution_result"),
|
|
305
|
+
stdout: z3.string(),
|
|
306
|
+
stderr: z3.string(),
|
|
307
|
+
return_code: z3.number(),
|
|
308
|
+
content: z3.array(
|
|
309
|
+
z3.object({
|
|
310
|
+
type: z3.literal("code_execution_output"),
|
|
311
|
+
file_id: z3.string()
|
|
233
312
|
})
|
|
234
313
|
).optional().default([])
|
|
235
314
|
}),
|
|
236
|
-
|
|
237
|
-
type:
|
|
238
|
-
encrypted_stdout:
|
|
239
|
-
stderr:
|
|
240
|
-
return_code:
|
|
241
|
-
content:
|
|
242
|
-
|
|
243
|
-
type:
|
|
244
|
-
file_id:
|
|
315
|
+
z3.object({
|
|
316
|
+
type: z3.literal("encrypted_code_execution_result"),
|
|
317
|
+
encrypted_stdout: z3.string(),
|
|
318
|
+
stderr: z3.string(),
|
|
319
|
+
return_code: z3.number(),
|
|
320
|
+
content: z3.array(
|
|
321
|
+
z3.object({
|
|
322
|
+
type: z3.literal("code_execution_output"),
|
|
323
|
+
file_id: z3.string()
|
|
245
324
|
})
|
|
246
325
|
).optional().default([])
|
|
247
326
|
}),
|
|
248
|
-
|
|
249
|
-
type:
|
|
250
|
-
error_code:
|
|
327
|
+
z3.object({
|
|
328
|
+
type: z3.literal("code_execution_tool_result_error"),
|
|
329
|
+
error_code: z3.string()
|
|
251
330
|
})
|
|
252
331
|
])
|
|
253
332
|
}),
|
|
254
333
|
// bash code execution results for code_execution_20250825 tool:
|
|
255
|
-
|
|
256
|
-
type:
|
|
257
|
-
tool_use_id:
|
|
258
|
-
content:
|
|
259
|
-
|
|
260
|
-
type:
|
|
261
|
-
content:
|
|
262
|
-
|
|
263
|
-
type:
|
|
264
|
-
file_id:
|
|
334
|
+
z3.object({
|
|
335
|
+
type: z3.literal("bash_code_execution_tool_result"),
|
|
336
|
+
tool_use_id: z3.string(),
|
|
337
|
+
content: z3.discriminatedUnion("type", [
|
|
338
|
+
z3.object({
|
|
339
|
+
type: z3.literal("bash_code_execution_result"),
|
|
340
|
+
content: z3.array(
|
|
341
|
+
z3.object({
|
|
342
|
+
type: z3.literal("bash_code_execution_output"),
|
|
343
|
+
file_id: z3.string()
|
|
265
344
|
})
|
|
266
345
|
),
|
|
267
|
-
stdout:
|
|
268
|
-
stderr:
|
|
269
|
-
return_code:
|
|
346
|
+
stdout: z3.string(),
|
|
347
|
+
stderr: z3.string(),
|
|
348
|
+
return_code: z3.number()
|
|
270
349
|
}),
|
|
271
|
-
|
|
272
|
-
type:
|
|
273
|
-
error_code:
|
|
350
|
+
z3.object({
|
|
351
|
+
type: z3.literal("bash_code_execution_tool_result_error"),
|
|
352
|
+
error_code: z3.string()
|
|
274
353
|
})
|
|
275
354
|
])
|
|
276
355
|
}),
|
|
277
356
|
// text editor code execution results for code_execution_20250825 tool:
|
|
278
|
-
|
|
279
|
-
type:
|
|
280
|
-
tool_use_id:
|
|
281
|
-
content:
|
|
282
|
-
|
|
283
|
-
type:
|
|
284
|
-
error_code:
|
|
357
|
+
z3.object({
|
|
358
|
+
type: z3.literal("text_editor_code_execution_tool_result"),
|
|
359
|
+
tool_use_id: z3.string(),
|
|
360
|
+
content: z3.discriminatedUnion("type", [
|
|
361
|
+
z3.object({
|
|
362
|
+
type: z3.literal("text_editor_code_execution_tool_result_error"),
|
|
363
|
+
error_code: z3.string()
|
|
285
364
|
}),
|
|
286
|
-
|
|
287
|
-
type:
|
|
288
|
-
content:
|
|
289
|
-
file_type:
|
|
290
|
-
num_lines:
|
|
291
|
-
start_line:
|
|
292
|
-
total_lines:
|
|
365
|
+
z3.object({
|
|
366
|
+
type: z3.literal("text_editor_code_execution_view_result"),
|
|
367
|
+
content: z3.string(),
|
|
368
|
+
file_type: z3.string(),
|
|
369
|
+
num_lines: z3.number().nullable(),
|
|
370
|
+
start_line: z3.number().nullable(),
|
|
371
|
+
total_lines: z3.number().nullable()
|
|
293
372
|
}),
|
|
294
|
-
|
|
295
|
-
type:
|
|
296
|
-
is_file_update:
|
|
373
|
+
z3.object({
|
|
374
|
+
type: z3.literal("text_editor_code_execution_create_result"),
|
|
375
|
+
is_file_update: z3.boolean()
|
|
297
376
|
}),
|
|
298
|
-
|
|
299
|
-
type:
|
|
377
|
+
z3.object({
|
|
378
|
+
type: z3.literal(
|
|
300
379
|
"text_editor_code_execution_str_replace_result"
|
|
301
380
|
),
|
|
302
|
-
lines:
|
|
303
|
-
new_lines:
|
|
304
|
-
new_start:
|
|
305
|
-
old_lines:
|
|
306
|
-
old_start:
|
|
381
|
+
lines: z3.array(z3.string()).nullable(),
|
|
382
|
+
new_lines: z3.number().nullable(),
|
|
383
|
+
new_start: z3.number().nullable(),
|
|
384
|
+
old_lines: z3.number().nullable(),
|
|
385
|
+
old_start: z3.number().nullable()
|
|
307
386
|
})
|
|
308
387
|
])
|
|
309
388
|
}),
|
|
310
389
|
// tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
|
|
311
|
-
|
|
312
|
-
type:
|
|
313
|
-
tool_use_id:
|
|
314
|
-
content:
|
|
315
|
-
|
|
316
|
-
type:
|
|
317
|
-
tool_references:
|
|
318
|
-
|
|
319
|
-
type:
|
|
320
|
-
tool_name:
|
|
390
|
+
z3.object({
|
|
391
|
+
type: z3.literal("tool_search_tool_result"),
|
|
392
|
+
tool_use_id: z3.string(),
|
|
393
|
+
content: z3.union([
|
|
394
|
+
z3.object({
|
|
395
|
+
type: z3.literal("tool_search_tool_search_result"),
|
|
396
|
+
tool_references: z3.array(
|
|
397
|
+
z3.object({
|
|
398
|
+
type: z3.literal("tool_reference"),
|
|
399
|
+
tool_name: z3.string()
|
|
321
400
|
})
|
|
322
401
|
)
|
|
323
402
|
}),
|
|
324
|
-
|
|
325
|
-
type:
|
|
326
|
-
error_code:
|
|
403
|
+
z3.object({
|
|
404
|
+
type: z3.literal("tool_search_tool_result_error"),
|
|
405
|
+
error_code: z3.string()
|
|
327
406
|
})
|
|
328
407
|
])
|
|
329
408
|
})
|
|
330
409
|
])
|
|
331
410
|
),
|
|
332
|
-
stop_reason:
|
|
333
|
-
stop_sequence:
|
|
334
|
-
usage:
|
|
335
|
-
input_tokens:
|
|
336
|
-
output_tokens:
|
|
337
|
-
cache_creation_input_tokens:
|
|
338
|
-
cache_read_input_tokens:
|
|
339
|
-
iterations:
|
|
340
|
-
|
|
341
|
-
type:
|
|
342
|
-
input_tokens:
|
|
343
|
-
output_tokens:
|
|
411
|
+
stop_reason: z3.string().nullish(),
|
|
412
|
+
stop_sequence: z3.string().nullish(),
|
|
413
|
+
usage: z3.looseObject({
|
|
414
|
+
input_tokens: z3.number(),
|
|
415
|
+
output_tokens: z3.number(),
|
|
416
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
417
|
+
cache_read_input_tokens: z3.number().nullish(),
|
|
418
|
+
iterations: z3.array(
|
|
419
|
+
z3.object({
|
|
420
|
+
type: z3.union([z3.literal("compaction"), z3.literal("message")]),
|
|
421
|
+
input_tokens: z3.number(),
|
|
422
|
+
output_tokens: z3.number()
|
|
344
423
|
})
|
|
345
424
|
).nullish()
|
|
346
425
|
}),
|
|
347
|
-
container:
|
|
348
|
-
expires_at:
|
|
349
|
-
id:
|
|
350
|
-
skills:
|
|
351
|
-
|
|
352
|
-
type:
|
|
353
|
-
skill_id:
|
|
354
|
-
version:
|
|
426
|
+
container: z3.object({
|
|
427
|
+
expires_at: z3.string(),
|
|
428
|
+
id: z3.string(),
|
|
429
|
+
skills: z3.array(
|
|
430
|
+
z3.object({
|
|
431
|
+
type: z3.union([z3.literal("anthropic"), z3.literal("custom")]),
|
|
432
|
+
skill_id: z3.string(),
|
|
433
|
+
version: z3.string()
|
|
355
434
|
})
|
|
356
435
|
).nullish()
|
|
357
436
|
}).nullish(),
|
|
358
|
-
context_management:
|
|
359
|
-
applied_edits:
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
type:
|
|
363
|
-
cleared_tool_uses:
|
|
364
|
-
cleared_input_tokens:
|
|
437
|
+
context_management: z3.object({
|
|
438
|
+
applied_edits: z3.array(
|
|
439
|
+
z3.union([
|
|
440
|
+
z3.object({
|
|
441
|
+
type: z3.literal("clear_tool_uses_20250919"),
|
|
442
|
+
cleared_tool_uses: z3.number(),
|
|
443
|
+
cleared_input_tokens: z3.number()
|
|
365
444
|
}),
|
|
366
|
-
|
|
367
|
-
type:
|
|
368
|
-
cleared_thinking_turns:
|
|
369
|
-
cleared_input_tokens:
|
|
445
|
+
z3.object({
|
|
446
|
+
type: z3.literal("clear_thinking_20251015"),
|
|
447
|
+
cleared_thinking_turns: z3.number(),
|
|
448
|
+
cleared_input_tokens: z3.number()
|
|
370
449
|
}),
|
|
371
|
-
|
|
372
|
-
type:
|
|
450
|
+
z3.object({
|
|
451
|
+
type: z3.literal("compact_20260112")
|
|
373
452
|
})
|
|
374
453
|
])
|
|
375
454
|
)
|
|
@@ -377,457 +456,457 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
377
456
|
})
|
|
378
457
|
)
|
|
379
458
|
);
|
|
380
|
-
var
|
|
381
|
-
() => (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
type:
|
|
385
|
-
message:
|
|
386
|
-
id:
|
|
387
|
-
model:
|
|
388
|
-
role:
|
|
389
|
-
usage:
|
|
390
|
-
input_tokens:
|
|
391
|
-
cache_creation_input_tokens:
|
|
392
|
-
cache_read_input_tokens:
|
|
459
|
+
var anthropicChunkSchema = lazySchema3(
|
|
460
|
+
() => zodSchema3(
|
|
461
|
+
z3.discriminatedUnion("type", [
|
|
462
|
+
z3.object({
|
|
463
|
+
type: z3.literal("message_start"),
|
|
464
|
+
message: z3.object({
|
|
465
|
+
id: z3.string().nullish(),
|
|
466
|
+
model: z3.string().nullish(),
|
|
467
|
+
role: z3.string().nullish(),
|
|
468
|
+
usage: z3.looseObject({
|
|
469
|
+
input_tokens: z3.number(),
|
|
470
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
471
|
+
cache_read_input_tokens: z3.number().nullish()
|
|
393
472
|
}),
|
|
394
473
|
// Programmatic tool calling: content may be pre-populated for deferred tool calls
|
|
395
|
-
content:
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
type:
|
|
399
|
-
id:
|
|
400
|
-
name:
|
|
401
|
-
input:
|
|
402
|
-
caller:
|
|
403
|
-
|
|
404
|
-
type:
|
|
405
|
-
tool_id:
|
|
474
|
+
content: z3.array(
|
|
475
|
+
z3.discriminatedUnion("type", [
|
|
476
|
+
z3.object({
|
|
477
|
+
type: z3.literal("tool_use"),
|
|
478
|
+
id: z3.string(),
|
|
479
|
+
name: z3.string(),
|
|
480
|
+
input: z3.unknown(),
|
|
481
|
+
caller: z3.union([
|
|
482
|
+
z3.object({
|
|
483
|
+
type: z3.literal("code_execution_20250825"),
|
|
484
|
+
tool_id: z3.string()
|
|
406
485
|
}),
|
|
407
|
-
|
|
408
|
-
type:
|
|
409
|
-
tool_id:
|
|
486
|
+
z3.object({
|
|
487
|
+
type: z3.literal("code_execution_20260120"),
|
|
488
|
+
tool_id: z3.string()
|
|
410
489
|
}),
|
|
411
|
-
|
|
412
|
-
type:
|
|
490
|
+
z3.object({
|
|
491
|
+
type: z3.literal("direct")
|
|
413
492
|
})
|
|
414
493
|
]).optional()
|
|
415
494
|
})
|
|
416
495
|
])
|
|
417
496
|
).nullish(),
|
|
418
|
-
stop_reason:
|
|
419
|
-
container:
|
|
420
|
-
expires_at:
|
|
421
|
-
id:
|
|
497
|
+
stop_reason: z3.string().nullish(),
|
|
498
|
+
container: z3.object({
|
|
499
|
+
expires_at: z3.string(),
|
|
500
|
+
id: z3.string()
|
|
422
501
|
}).nullish()
|
|
423
502
|
})
|
|
424
503
|
}),
|
|
425
|
-
|
|
426
|
-
type:
|
|
427
|
-
index:
|
|
428
|
-
content_block:
|
|
429
|
-
|
|
430
|
-
type:
|
|
431
|
-
text:
|
|
504
|
+
z3.object({
|
|
505
|
+
type: z3.literal("content_block_start"),
|
|
506
|
+
index: z3.number(),
|
|
507
|
+
content_block: z3.discriminatedUnion("type", [
|
|
508
|
+
z3.object({
|
|
509
|
+
type: z3.literal("text"),
|
|
510
|
+
text: z3.string()
|
|
432
511
|
}),
|
|
433
|
-
|
|
434
|
-
type:
|
|
435
|
-
thinking:
|
|
512
|
+
z3.object({
|
|
513
|
+
type: z3.literal("thinking"),
|
|
514
|
+
thinking: z3.string()
|
|
436
515
|
}),
|
|
437
|
-
|
|
438
|
-
type:
|
|
439
|
-
id:
|
|
440
|
-
name:
|
|
516
|
+
z3.object({
|
|
517
|
+
type: z3.literal("tool_use"),
|
|
518
|
+
id: z3.string(),
|
|
519
|
+
name: z3.string(),
|
|
441
520
|
// Programmatic tool calling: input may be present directly for deferred tool calls
|
|
442
|
-
input:
|
|
521
|
+
input: z3.record(z3.string(), z3.unknown()).optional(),
|
|
443
522
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
444
|
-
caller:
|
|
445
|
-
|
|
446
|
-
type:
|
|
447
|
-
tool_id:
|
|
523
|
+
caller: z3.union([
|
|
524
|
+
z3.object({
|
|
525
|
+
type: z3.literal("code_execution_20250825"),
|
|
526
|
+
tool_id: z3.string()
|
|
448
527
|
}),
|
|
449
|
-
|
|
450
|
-
type:
|
|
451
|
-
tool_id:
|
|
528
|
+
z3.object({
|
|
529
|
+
type: z3.literal("code_execution_20260120"),
|
|
530
|
+
tool_id: z3.string()
|
|
452
531
|
}),
|
|
453
|
-
|
|
454
|
-
type:
|
|
532
|
+
z3.object({
|
|
533
|
+
type: z3.literal("direct")
|
|
455
534
|
})
|
|
456
535
|
]).optional()
|
|
457
536
|
}),
|
|
458
|
-
|
|
459
|
-
type:
|
|
460
|
-
data:
|
|
537
|
+
z3.object({
|
|
538
|
+
type: z3.literal("redacted_thinking"),
|
|
539
|
+
data: z3.string()
|
|
461
540
|
}),
|
|
462
|
-
|
|
463
|
-
type:
|
|
464
|
-
content:
|
|
541
|
+
z3.object({
|
|
542
|
+
type: z3.literal("compaction"),
|
|
543
|
+
content: z3.string().nullish()
|
|
465
544
|
}),
|
|
466
|
-
|
|
467
|
-
type:
|
|
468
|
-
id:
|
|
469
|
-
name:
|
|
470
|
-
input:
|
|
471
|
-
caller:
|
|
472
|
-
|
|
473
|
-
type:
|
|
474
|
-
tool_id:
|
|
545
|
+
z3.object({
|
|
546
|
+
type: z3.literal("server_tool_use"),
|
|
547
|
+
id: z3.string(),
|
|
548
|
+
name: z3.string(),
|
|
549
|
+
input: z3.record(z3.string(), z3.unknown()).nullish(),
|
|
550
|
+
caller: z3.union([
|
|
551
|
+
z3.object({
|
|
552
|
+
type: z3.literal("code_execution_20260120"),
|
|
553
|
+
tool_id: z3.string()
|
|
475
554
|
}),
|
|
476
|
-
|
|
477
|
-
type:
|
|
555
|
+
z3.object({
|
|
556
|
+
type: z3.literal("direct")
|
|
478
557
|
})
|
|
479
558
|
]).optional()
|
|
480
559
|
}),
|
|
481
|
-
|
|
482
|
-
type:
|
|
483
|
-
id:
|
|
484
|
-
name:
|
|
485
|
-
input:
|
|
486
|
-
server_name:
|
|
560
|
+
z3.object({
|
|
561
|
+
type: z3.literal("mcp_tool_use"),
|
|
562
|
+
id: z3.string(),
|
|
563
|
+
name: z3.string(),
|
|
564
|
+
input: z3.unknown(),
|
|
565
|
+
server_name: z3.string()
|
|
487
566
|
}),
|
|
488
|
-
|
|
489
|
-
type:
|
|
490
|
-
tool_use_id:
|
|
491
|
-
is_error:
|
|
492
|
-
content:
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
567
|
+
z3.object({
|
|
568
|
+
type: z3.literal("mcp_tool_result"),
|
|
569
|
+
tool_use_id: z3.string(),
|
|
570
|
+
is_error: z3.boolean(),
|
|
571
|
+
content: z3.array(
|
|
572
|
+
z3.union([
|
|
573
|
+
z3.string(),
|
|
574
|
+
z3.object({ type: z3.literal("text"), text: z3.string() })
|
|
496
575
|
])
|
|
497
576
|
)
|
|
498
577
|
}),
|
|
499
|
-
|
|
500
|
-
type:
|
|
501
|
-
tool_use_id:
|
|
502
|
-
content:
|
|
503
|
-
|
|
504
|
-
type:
|
|
505
|
-
url:
|
|
506
|
-
retrieved_at:
|
|
507
|
-
content:
|
|
508
|
-
type:
|
|
509
|
-
title:
|
|
510
|
-
citations:
|
|
511
|
-
source:
|
|
512
|
-
|
|
513
|
-
type:
|
|
514
|
-
media_type:
|
|
515
|
-
data:
|
|
578
|
+
z3.object({
|
|
579
|
+
type: z3.literal("web_fetch_tool_result"),
|
|
580
|
+
tool_use_id: z3.string(),
|
|
581
|
+
content: z3.union([
|
|
582
|
+
z3.object({
|
|
583
|
+
type: z3.literal("web_fetch_result"),
|
|
584
|
+
url: z3.string(),
|
|
585
|
+
retrieved_at: z3.string(),
|
|
586
|
+
content: z3.object({
|
|
587
|
+
type: z3.literal("document"),
|
|
588
|
+
title: z3.string().nullable(),
|
|
589
|
+
citations: z3.object({ enabled: z3.boolean() }).optional(),
|
|
590
|
+
source: z3.union([
|
|
591
|
+
z3.object({
|
|
592
|
+
type: z3.literal("base64"),
|
|
593
|
+
media_type: z3.literal("application/pdf"),
|
|
594
|
+
data: z3.string()
|
|
516
595
|
}),
|
|
517
|
-
|
|
518
|
-
type:
|
|
519
|
-
media_type:
|
|
520
|
-
data:
|
|
596
|
+
z3.object({
|
|
597
|
+
type: z3.literal("text"),
|
|
598
|
+
media_type: z3.literal("text/plain"),
|
|
599
|
+
data: z3.string()
|
|
521
600
|
})
|
|
522
601
|
])
|
|
523
602
|
})
|
|
524
603
|
}),
|
|
525
|
-
|
|
526
|
-
type:
|
|
527
|
-
error_code:
|
|
604
|
+
z3.object({
|
|
605
|
+
type: z3.literal("web_fetch_tool_result_error"),
|
|
606
|
+
error_code: z3.string()
|
|
528
607
|
})
|
|
529
608
|
])
|
|
530
609
|
}),
|
|
531
|
-
|
|
532
|
-
type:
|
|
533
|
-
tool_use_id:
|
|
534
|
-
content:
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
type:
|
|
538
|
-
url:
|
|
539
|
-
title:
|
|
540
|
-
encrypted_content:
|
|
541
|
-
page_age:
|
|
610
|
+
z3.object({
|
|
611
|
+
type: z3.literal("web_search_tool_result"),
|
|
612
|
+
tool_use_id: z3.string(),
|
|
613
|
+
content: z3.union([
|
|
614
|
+
z3.array(
|
|
615
|
+
z3.object({
|
|
616
|
+
type: z3.literal("web_search_result"),
|
|
617
|
+
url: z3.string(),
|
|
618
|
+
title: z3.string(),
|
|
619
|
+
encrypted_content: z3.string(),
|
|
620
|
+
page_age: z3.string().nullish()
|
|
542
621
|
})
|
|
543
622
|
),
|
|
544
|
-
|
|
545
|
-
type:
|
|
546
|
-
error_code:
|
|
623
|
+
z3.object({
|
|
624
|
+
type: z3.literal("web_search_tool_result_error"),
|
|
625
|
+
error_code: z3.string()
|
|
547
626
|
})
|
|
548
627
|
])
|
|
549
628
|
}),
|
|
550
629
|
// code execution results for code_execution_20250522 tool:
|
|
551
|
-
|
|
552
|
-
type:
|
|
553
|
-
tool_use_id:
|
|
554
|
-
content:
|
|
555
|
-
|
|
556
|
-
type:
|
|
557
|
-
stdout:
|
|
558
|
-
stderr:
|
|
559
|
-
return_code:
|
|
560
|
-
content:
|
|
561
|
-
|
|
562
|
-
type:
|
|
563
|
-
file_id:
|
|
630
|
+
z3.object({
|
|
631
|
+
type: z3.literal("code_execution_tool_result"),
|
|
632
|
+
tool_use_id: z3.string(),
|
|
633
|
+
content: z3.union([
|
|
634
|
+
z3.object({
|
|
635
|
+
type: z3.literal("code_execution_result"),
|
|
636
|
+
stdout: z3.string(),
|
|
637
|
+
stderr: z3.string(),
|
|
638
|
+
return_code: z3.number(),
|
|
639
|
+
content: z3.array(
|
|
640
|
+
z3.object({
|
|
641
|
+
type: z3.literal("code_execution_output"),
|
|
642
|
+
file_id: z3.string()
|
|
564
643
|
})
|
|
565
644
|
).optional().default([])
|
|
566
645
|
}),
|
|
567
|
-
|
|
568
|
-
type:
|
|
569
|
-
encrypted_stdout:
|
|
570
|
-
stderr:
|
|
571
|
-
return_code:
|
|
572
|
-
content:
|
|
573
|
-
|
|
574
|
-
type:
|
|
575
|
-
file_id:
|
|
646
|
+
z3.object({
|
|
647
|
+
type: z3.literal("encrypted_code_execution_result"),
|
|
648
|
+
encrypted_stdout: z3.string(),
|
|
649
|
+
stderr: z3.string(),
|
|
650
|
+
return_code: z3.number(),
|
|
651
|
+
content: z3.array(
|
|
652
|
+
z3.object({
|
|
653
|
+
type: z3.literal("code_execution_output"),
|
|
654
|
+
file_id: z3.string()
|
|
576
655
|
})
|
|
577
656
|
).optional().default([])
|
|
578
657
|
}),
|
|
579
|
-
|
|
580
|
-
type:
|
|
581
|
-
error_code:
|
|
658
|
+
z3.object({
|
|
659
|
+
type: z3.literal("code_execution_tool_result_error"),
|
|
660
|
+
error_code: z3.string()
|
|
582
661
|
})
|
|
583
662
|
])
|
|
584
663
|
}),
|
|
585
664
|
// bash code execution results for code_execution_20250825 tool:
|
|
586
|
-
|
|
587
|
-
type:
|
|
588
|
-
tool_use_id:
|
|
589
|
-
content:
|
|
590
|
-
|
|
591
|
-
type:
|
|
592
|
-
content:
|
|
593
|
-
|
|
594
|
-
type:
|
|
595
|
-
file_id:
|
|
665
|
+
z3.object({
|
|
666
|
+
type: z3.literal("bash_code_execution_tool_result"),
|
|
667
|
+
tool_use_id: z3.string(),
|
|
668
|
+
content: z3.discriminatedUnion("type", [
|
|
669
|
+
z3.object({
|
|
670
|
+
type: z3.literal("bash_code_execution_result"),
|
|
671
|
+
content: z3.array(
|
|
672
|
+
z3.object({
|
|
673
|
+
type: z3.literal("bash_code_execution_output"),
|
|
674
|
+
file_id: z3.string()
|
|
596
675
|
})
|
|
597
676
|
),
|
|
598
|
-
stdout:
|
|
599
|
-
stderr:
|
|
600
|
-
return_code:
|
|
677
|
+
stdout: z3.string(),
|
|
678
|
+
stderr: z3.string(),
|
|
679
|
+
return_code: z3.number()
|
|
601
680
|
}),
|
|
602
|
-
|
|
603
|
-
type:
|
|
604
|
-
error_code:
|
|
681
|
+
z3.object({
|
|
682
|
+
type: z3.literal("bash_code_execution_tool_result_error"),
|
|
683
|
+
error_code: z3.string()
|
|
605
684
|
})
|
|
606
685
|
])
|
|
607
686
|
}),
|
|
608
687
|
// text editor code execution results for code_execution_20250825 tool:
|
|
609
|
-
|
|
610
|
-
type:
|
|
611
|
-
tool_use_id:
|
|
612
|
-
content:
|
|
613
|
-
|
|
614
|
-
type:
|
|
615
|
-
error_code:
|
|
688
|
+
z3.object({
|
|
689
|
+
type: z3.literal("text_editor_code_execution_tool_result"),
|
|
690
|
+
tool_use_id: z3.string(),
|
|
691
|
+
content: z3.discriminatedUnion("type", [
|
|
692
|
+
z3.object({
|
|
693
|
+
type: z3.literal("text_editor_code_execution_tool_result_error"),
|
|
694
|
+
error_code: z3.string()
|
|
616
695
|
}),
|
|
617
|
-
|
|
618
|
-
type:
|
|
619
|
-
content:
|
|
620
|
-
file_type:
|
|
621
|
-
num_lines:
|
|
622
|
-
start_line:
|
|
623
|
-
total_lines:
|
|
696
|
+
z3.object({
|
|
697
|
+
type: z3.literal("text_editor_code_execution_view_result"),
|
|
698
|
+
content: z3.string(),
|
|
699
|
+
file_type: z3.string(),
|
|
700
|
+
num_lines: z3.number().nullable(),
|
|
701
|
+
start_line: z3.number().nullable(),
|
|
702
|
+
total_lines: z3.number().nullable()
|
|
624
703
|
}),
|
|
625
|
-
|
|
626
|
-
type:
|
|
627
|
-
is_file_update:
|
|
704
|
+
z3.object({
|
|
705
|
+
type: z3.literal("text_editor_code_execution_create_result"),
|
|
706
|
+
is_file_update: z3.boolean()
|
|
628
707
|
}),
|
|
629
|
-
|
|
630
|
-
type:
|
|
708
|
+
z3.object({
|
|
709
|
+
type: z3.literal(
|
|
631
710
|
"text_editor_code_execution_str_replace_result"
|
|
632
711
|
),
|
|
633
|
-
lines:
|
|
634
|
-
new_lines:
|
|
635
|
-
new_start:
|
|
636
|
-
old_lines:
|
|
637
|
-
old_start:
|
|
712
|
+
lines: z3.array(z3.string()).nullable(),
|
|
713
|
+
new_lines: z3.number().nullable(),
|
|
714
|
+
new_start: z3.number().nullable(),
|
|
715
|
+
old_lines: z3.number().nullable(),
|
|
716
|
+
old_start: z3.number().nullable()
|
|
638
717
|
})
|
|
639
718
|
])
|
|
640
719
|
}),
|
|
641
720
|
// tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
|
|
642
|
-
|
|
643
|
-
type:
|
|
644
|
-
tool_use_id:
|
|
645
|
-
content:
|
|
646
|
-
|
|
647
|
-
type:
|
|
648
|
-
tool_references:
|
|
649
|
-
|
|
650
|
-
type:
|
|
651
|
-
tool_name:
|
|
721
|
+
z3.object({
|
|
722
|
+
type: z3.literal("tool_search_tool_result"),
|
|
723
|
+
tool_use_id: z3.string(),
|
|
724
|
+
content: z3.union([
|
|
725
|
+
z3.object({
|
|
726
|
+
type: z3.literal("tool_search_tool_search_result"),
|
|
727
|
+
tool_references: z3.array(
|
|
728
|
+
z3.object({
|
|
729
|
+
type: z3.literal("tool_reference"),
|
|
730
|
+
tool_name: z3.string()
|
|
652
731
|
})
|
|
653
732
|
)
|
|
654
733
|
}),
|
|
655
|
-
|
|
656
|
-
type:
|
|
657
|
-
error_code:
|
|
734
|
+
z3.object({
|
|
735
|
+
type: z3.literal("tool_search_tool_result_error"),
|
|
736
|
+
error_code: z3.string()
|
|
658
737
|
})
|
|
659
738
|
])
|
|
660
739
|
})
|
|
661
740
|
])
|
|
662
741
|
}),
|
|
663
|
-
|
|
664
|
-
type:
|
|
665
|
-
index:
|
|
666
|
-
delta:
|
|
667
|
-
|
|
668
|
-
type:
|
|
669
|
-
partial_json:
|
|
742
|
+
z3.object({
|
|
743
|
+
type: z3.literal("content_block_delta"),
|
|
744
|
+
index: z3.number(),
|
|
745
|
+
delta: z3.discriminatedUnion("type", [
|
|
746
|
+
z3.object({
|
|
747
|
+
type: z3.literal("input_json_delta"),
|
|
748
|
+
partial_json: z3.string()
|
|
670
749
|
}),
|
|
671
|
-
|
|
672
|
-
type:
|
|
673
|
-
text:
|
|
750
|
+
z3.object({
|
|
751
|
+
type: z3.literal("text_delta"),
|
|
752
|
+
text: z3.string()
|
|
674
753
|
}),
|
|
675
|
-
|
|
676
|
-
type:
|
|
677
|
-
thinking:
|
|
754
|
+
z3.object({
|
|
755
|
+
type: z3.literal("thinking_delta"),
|
|
756
|
+
thinking: z3.string()
|
|
678
757
|
}),
|
|
679
|
-
|
|
680
|
-
type:
|
|
681
|
-
signature:
|
|
758
|
+
z3.object({
|
|
759
|
+
type: z3.literal("signature_delta"),
|
|
760
|
+
signature: z3.string()
|
|
682
761
|
}),
|
|
683
|
-
|
|
684
|
-
type:
|
|
685
|
-
content:
|
|
762
|
+
z3.object({
|
|
763
|
+
type: z3.literal("compaction_delta"),
|
|
764
|
+
content: z3.string().nullish()
|
|
686
765
|
}),
|
|
687
|
-
|
|
688
|
-
type:
|
|
689
|
-
citation:
|
|
690
|
-
|
|
691
|
-
type:
|
|
692
|
-
cited_text:
|
|
693
|
-
url:
|
|
694
|
-
title:
|
|
695
|
-
encrypted_index:
|
|
766
|
+
z3.object({
|
|
767
|
+
type: z3.literal("citations_delta"),
|
|
768
|
+
citation: z3.discriminatedUnion("type", [
|
|
769
|
+
z3.object({
|
|
770
|
+
type: z3.literal("web_search_result_location"),
|
|
771
|
+
cited_text: z3.string(),
|
|
772
|
+
url: z3.string(),
|
|
773
|
+
title: z3.string(),
|
|
774
|
+
encrypted_index: z3.string()
|
|
696
775
|
}),
|
|
697
|
-
|
|
698
|
-
type:
|
|
699
|
-
cited_text:
|
|
700
|
-
document_index:
|
|
701
|
-
document_title:
|
|
702
|
-
start_page_number:
|
|
703
|
-
end_page_number:
|
|
776
|
+
z3.object({
|
|
777
|
+
type: z3.literal("page_location"),
|
|
778
|
+
cited_text: z3.string(),
|
|
779
|
+
document_index: z3.number(),
|
|
780
|
+
document_title: z3.string().nullable(),
|
|
781
|
+
start_page_number: z3.number(),
|
|
782
|
+
end_page_number: z3.number()
|
|
704
783
|
}),
|
|
705
|
-
|
|
706
|
-
type:
|
|
707
|
-
cited_text:
|
|
708
|
-
document_index:
|
|
709
|
-
document_title:
|
|
710
|
-
start_char_index:
|
|
711
|
-
end_char_index:
|
|
784
|
+
z3.object({
|
|
785
|
+
type: z3.literal("char_location"),
|
|
786
|
+
cited_text: z3.string(),
|
|
787
|
+
document_index: z3.number(),
|
|
788
|
+
document_title: z3.string().nullable(),
|
|
789
|
+
start_char_index: z3.number(),
|
|
790
|
+
end_char_index: z3.number()
|
|
712
791
|
})
|
|
713
792
|
])
|
|
714
793
|
})
|
|
715
794
|
])
|
|
716
795
|
}),
|
|
717
|
-
|
|
718
|
-
type:
|
|
719
|
-
index:
|
|
796
|
+
z3.object({
|
|
797
|
+
type: z3.literal("content_block_stop"),
|
|
798
|
+
index: z3.number()
|
|
720
799
|
}),
|
|
721
|
-
|
|
722
|
-
type:
|
|
723
|
-
error:
|
|
724
|
-
type:
|
|
725
|
-
message:
|
|
800
|
+
z3.object({
|
|
801
|
+
type: z3.literal("error"),
|
|
802
|
+
error: z3.object({
|
|
803
|
+
type: z3.string(),
|
|
804
|
+
message: z3.string()
|
|
726
805
|
})
|
|
727
806
|
}),
|
|
728
|
-
|
|
729
|
-
type:
|
|
730
|
-
delta:
|
|
731
|
-
stop_reason:
|
|
732
|
-
stop_sequence:
|
|
733
|
-
container:
|
|
734
|
-
expires_at:
|
|
735
|
-
id:
|
|
736
|
-
skills:
|
|
737
|
-
|
|
738
|
-
type:
|
|
739
|
-
|
|
740
|
-
|
|
807
|
+
z3.object({
|
|
808
|
+
type: z3.literal("message_delta"),
|
|
809
|
+
delta: z3.object({
|
|
810
|
+
stop_reason: z3.string().nullish(),
|
|
811
|
+
stop_sequence: z3.string().nullish(),
|
|
812
|
+
container: z3.object({
|
|
813
|
+
expires_at: z3.string(),
|
|
814
|
+
id: z3.string(),
|
|
815
|
+
skills: z3.array(
|
|
816
|
+
z3.object({
|
|
817
|
+
type: z3.union([
|
|
818
|
+
z3.literal("anthropic"),
|
|
819
|
+
z3.literal("custom")
|
|
741
820
|
]),
|
|
742
|
-
skill_id:
|
|
743
|
-
version:
|
|
821
|
+
skill_id: z3.string(),
|
|
822
|
+
version: z3.string()
|
|
744
823
|
})
|
|
745
824
|
).nullish()
|
|
746
825
|
}).nullish()
|
|
747
826
|
}),
|
|
748
|
-
usage:
|
|
749
|
-
input_tokens:
|
|
750
|
-
output_tokens:
|
|
751
|
-
cache_creation_input_tokens:
|
|
752
|
-
cache_read_input_tokens:
|
|
753
|
-
iterations:
|
|
754
|
-
|
|
755
|
-
type:
|
|
756
|
-
input_tokens:
|
|
757
|
-
output_tokens:
|
|
827
|
+
usage: z3.looseObject({
|
|
828
|
+
input_tokens: z3.number().nullish(),
|
|
829
|
+
output_tokens: z3.number(),
|
|
830
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
831
|
+
cache_read_input_tokens: z3.number().nullish(),
|
|
832
|
+
iterations: z3.array(
|
|
833
|
+
z3.object({
|
|
834
|
+
type: z3.union([z3.literal("compaction"), z3.literal("message")]),
|
|
835
|
+
input_tokens: z3.number(),
|
|
836
|
+
output_tokens: z3.number()
|
|
758
837
|
})
|
|
759
838
|
).nullish()
|
|
760
839
|
}),
|
|
761
|
-
context_management:
|
|
762
|
-
applied_edits:
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
type:
|
|
766
|
-
cleared_tool_uses:
|
|
767
|
-
cleared_input_tokens:
|
|
840
|
+
context_management: z3.object({
|
|
841
|
+
applied_edits: z3.array(
|
|
842
|
+
z3.union([
|
|
843
|
+
z3.object({
|
|
844
|
+
type: z3.literal("clear_tool_uses_20250919"),
|
|
845
|
+
cleared_tool_uses: z3.number(),
|
|
846
|
+
cleared_input_tokens: z3.number()
|
|
768
847
|
}),
|
|
769
|
-
|
|
770
|
-
type:
|
|
771
|
-
cleared_thinking_turns:
|
|
772
|
-
cleared_input_tokens:
|
|
848
|
+
z3.object({
|
|
849
|
+
type: z3.literal("clear_thinking_20251015"),
|
|
850
|
+
cleared_thinking_turns: z3.number(),
|
|
851
|
+
cleared_input_tokens: z3.number()
|
|
773
852
|
}),
|
|
774
|
-
|
|
775
|
-
type:
|
|
853
|
+
z3.object({
|
|
854
|
+
type: z3.literal("compact_20260112")
|
|
776
855
|
})
|
|
777
856
|
])
|
|
778
857
|
)
|
|
779
858
|
}).nullish()
|
|
780
859
|
}),
|
|
781
|
-
|
|
782
|
-
type:
|
|
860
|
+
z3.object({
|
|
861
|
+
type: z3.literal("message_stop")
|
|
783
862
|
}),
|
|
784
|
-
|
|
785
|
-
type:
|
|
863
|
+
z3.object({
|
|
864
|
+
type: z3.literal("ping")
|
|
786
865
|
})
|
|
787
866
|
])
|
|
788
867
|
)
|
|
789
868
|
);
|
|
790
|
-
var anthropicReasoningMetadataSchema = (
|
|
791
|
-
() => (
|
|
792
|
-
|
|
793
|
-
signature:
|
|
794
|
-
redactedData:
|
|
869
|
+
var anthropicReasoningMetadataSchema = lazySchema3(
|
|
870
|
+
() => zodSchema3(
|
|
871
|
+
z3.object({
|
|
872
|
+
signature: z3.string().optional(),
|
|
873
|
+
redactedData: z3.string().optional()
|
|
795
874
|
})
|
|
796
875
|
)
|
|
797
876
|
);
|
|
798
877
|
|
|
799
|
-
// src/anthropic-
|
|
800
|
-
|
|
801
|
-
var anthropicFilePartProviderOptions =
|
|
878
|
+
// src/anthropic-options.ts
|
|
879
|
+
import { z as z4 } from "zod/v4";
|
|
880
|
+
var anthropicFilePartProviderOptions = z4.object({
|
|
802
881
|
/**
|
|
803
882
|
* Citation configuration for this document.
|
|
804
883
|
* When enabled, this document will generate citations in the response.
|
|
805
884
|
*/
|
|
806
|
-
citations:
|
|
885
|
+
citations: z4.object({
|
|
807
886
|
/**
|
|
808
887
|
* Enable citations for this document
|
|
809
888
|
*/
|
|
810
|
-
enabled:
|
|
889
|
+
enabled: z4.boolean()
|
|
811
890
|
}).optional(),
|
|
812
891
|
/**
|
|
813
892
|
* Custom title for the document.
|
|
814
893
|
* If not provided, the filename will be used.
|
|
815
894
|
*/
|
|
816
|
-
title:
|
|
895
|
+
title: z4.string().optional(),
|
|
817
896
|
/**
|
|
818
897
|
* Context about the document that will be passed to the model
|
|
819
898
|
* but not used towards cited content.
|
|
820
899
|
* Useful for storing document metadata as text or stringified JSON.
|
|
821
900
|
*/
|
|
822
|
-
context:
|
|
901
|
+
context: z4.string().optional()
|
|
823
902
|
});
|
|
824
|
-
var anthropicLanguageModelOptions =
|
|
903
|
+
var anthropicLanguageModelOptions = z4.object({
|
|
825
904
|
/**
|
|
826
905
|
* Whether to send reasoning to the model.
|
|
827
906
|
*
|
|
828
907
|
* This allows you to deactivate reasoning inputs for models that do not support them.
|
|
829
908
|
*/
|
|
830
|
-
sendReasoning:
|
|
909
|
+
sendReasoning: z4.boolean().optional(),
|
|
831
910
|
/**
|
|
832
911
|
* Determines how structured outputs are generated.
|
|
833
912
|
*
|
|
@@ -835,52 +914,72 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
835
914
|
* - `jsonTool`: Use a special 'json' tool to specify the structured output format.
|
|
836
915
|
* - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
|
|
837
916
|
*/
|
|
838
|
-
structuredOutputMode:
|
|
917
|
+
structuredOutputMode: z4.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
839
918
|
/**
|
|
840
919
|
* Configuration for enabling Claude's extended thinking.
|
|
841
920
|
*
|
|
842
921
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
843
922
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
844
923
|
*/
|
|
845
|
-
thinking:
|
|
846
|
-
|
|
924
|
+
thinking: z4.discriminatedUnion("type", [
|
|
925
|
+
z4.object({
|
|
847
926
|
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
848
|
-
type:
|
|
927
|
+
type: z4.literal("adaptive"),
|
|
928
|
+
/**
|
|
929
|
+
* Controls whether thinking content is included in the response.
|
|
930
|
+
* - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
|
|
931
|
+
* - `"summarized"`: Thinking content is returned. Required to see reasoning output.
|
|
932
|
+
*/
|
|
933
|
+
display: z4.enum(["omitted", "summarized"]).optional()
|
|
849
934
|
}),
|
|
850
|
-
|
|
935
|
+
z4.object({
|
|
851
936
|
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
852
|
-
type:
|
|
853
|
-
budgetTokens:
|
|
937
|
+
type: z4.literal("enabled"),
|
|
938
|
+
budgetTokens: z4.number().optional()
|
|
854
939
|
}),
|
|
855
|
-
|
|
856
|
-
type:
|
|
940
|
+
z4.object({
|
|
941
|
+
type: z4.literal("disabled")
|
|
857
942
|
})
|
|
858
943
|
]).optional(),
|
|
859
944
|
/**
|
|
860
945
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
861
946
|
* When set to true, Claude will use at most one tool per response.
|
|
862
947
|
*/
|
|
863
|
-
disableParallelToolUse:
|
|
948
|
+
disableParallelToolUse: z4.boolean().optional(),
|
|
864
949
|
/**
|
|
865
950
|
* Cache control settings for this message.
|
|
866
951
|
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
867
952
|
*/
|
|
868
|
-
cacheControl:
|
|
869
|
-
type:
|
|
870
|
-
ttl:
|
|
953
|
+
cacheControl: z4.object({
|
|
954
|
+
type: z4.literal("ephemeral"),
|
|
955
|
+
ttl: z4.union([z4.literal("5m"), z4.literal("1h")]).optional()
|
|
956
|
+
}).optional(),
|
|
957
|
+
/**
|
|
958
|
+
* Metadata to include with the request.
|
|
959
|
+
*
|
|
960
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
961
|
+
*/
|
|
962
|
+
metadata: z4.object({
|
|
963
|
+
/**
|
|
964
|
+
* An external identifier for the user associated with the request.
|
|
965
|
+
*
|
|
966
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
967
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
968
|
+
*/
|
|
969
|
+
userId: z4.string().optional()
|
|
871
970
|
}).optional(),
|
|
872
971
|
/**
|
|
873
972
|
* MCP servers to be utilized in this request.
|
|
874
973
|
*/
|
|
875
|
-
mcpServers:
|
|
876
|
-
|
|
877
|
-
type:
|
|
878
|
-
name:
|
|
879
|
-
url:
|
|
880
|
-
authorizationToken:
|
|
881
|
-
toolConfiguration:
|
|
882
|
-
enabled:
|
|
883
|
-
allowedTools:
|
|
974
|
+
mcpServers: z4.array(
|
|
975
|
+
z4.object({
|
|
976
|
+
type: z4.literal("url"),
|
|
977
|
+
name: z4.string(),
|
|
978
|
+
url: z4.string(),
|
|
979
|
+
authorizationToken: z4.string().nullish(),
|
|
980
|
+
toolConfiguration: z4.object({
|
|
981
|
+
enabled: z4.boolean().nullish(),
|
|
982
|
+
allowedTools: z4.array(z4.string()).nullish()
|
|
884
983
|
}).nullish()
|
|
885
984
|
})
|
|
886
985
|
).optional(),
|
|
@@ -889,83 +988,112 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
889
988
|
* like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
|
|
890
989
|
* Requires code execution tool to be enabled.
|
|
891
990
|
*/
|
|
892
|
-
container:
|
|
893
|
-
id:
|
|
894
|
-
skills:
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
991
|
+
container: z4.object({
|
|
992
|
+
id: z4.string().optional(),
|
|
993
|
+
skills: z4.array(
|
|
994
|
+
z4.discriminatedUnion("type", [
|
|
995
|
+
z4.object({
|
|
996
|
+
type: z4.literal("anthropic"),
|
|
997
|
+
skillId: z4.string(),
|
|
998
|
+
version: z4.string().optional()
|
|
999
|
+
}),
|
|
1000
|
+
z4.object({
|
|
1001
|
+
type: z4.literal("custom"),
|
|
1002
|
+
providerReference: z4.record(z4.string(), z4.string()),
|
|
1003
|
+
version: z4.string().optional()
|
|
1004
|
+
})
|
|
1005
|
+
])
|
|
900
1006
|
).optional()
|
|
901
1007
|
}).optional(),
|
|
902
1008
|
/**
|
|
903
|
-
* Whether to enable
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
*
|
|
1009
|
+
* Whether to enable fine-grained (eager) streaming of tool call inputs
|
|
1010
|
+
* and structured outputs for every function tool in the request. When
|
|
1011
|
+
* true (the default), each function tool receives a default of
|
|
1012
|
+
* `eager_input_streaming: true` unless it explicitly sets
|
|
1013
|
+
* `providerOptions.anthropic.eagerInputStreaming`.
|
|
907
1014
|
*
|
|
908
1015
|
* @default true
|
|
909
1016
|
*/
|
|
910
|
-
toolStreaming:
|
|
1017
|
+
toolStreaming: z4.boolean().optional(),
|
|
911
1018
|
/**
|
|
912
1019
|
* @default 'high'
|
|
913
1020
|
*/
|
|
914
|
-
effort:
|
|
1021
|
+
effort: z4.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
1022
|
+
/**
|
|
1023
|
+
* Task budget for agentic turns. Informs the model of the total token budget
|
|
1024
|
+
* available for the current task, allowing it to prioritize work and wind down
|
|
1025
|
+
* gracefully as the budget is consumed.
|
|
1026
|
+
*
|
|
1027
|
+
* Advisory only — does not enforce a hard token limit.
|
|
1028
|
+
*/
|
|
1029
|
+
taskBudget: z4.object({
|
|
1030
|
+
type: z4.literal("tokens"),
|
|
1031
|
+
total: z4.number().int().min(2e4),
|
|
1032
|
+
remaining: z4.number().int().min(0).optional()
|
|
1033
|
+
}).optional(),
|
|
915
1034
|
/**
|
|
916
1035
|
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
917
1036
|
* Only supported with claude-opus-4-6.
|
|
918
1037
|
*/
|
|
919
|
-
speed:
|
|
1038
|
+
speed: z4.enum(["fast", "standard"]).optional(),
|
|
1039
|
+
/**
|
|
1040
|
+
* Controls where model inference runs for this request.
|
|
1041
|
+
*
|
|
1042
|
+
* - `"global"`: Inference may run in any available geography (default).
|
|
1043
|
+
* - `"us"`: Inference runs only in US-based infrastructure.
|
|
1044
|
+
*
|
|
1045
|
+
* See https://platform.claude.com/docs/en/build-with-claude/data-residency
|
|
1046
|
+
*/
|
|
1047
|
+
inferenceGeo: z4.enum(["us", "global"]).optional(),
|
|
920
1048
|
/**
|
|
921
1049
|
* A set of beta features to enable.
|
|
922
1050
|
* Allow a provider to receive the full `betas` set if it needs it.
|
|
923
1051
|
*/
|
|
924
|
-
anthropicBeta:
|
|
925
|
-
contextManagement:
|
|
926
|
-
edits:
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
type:
|
|
930
|
-
trigger:
|
|
931
|
-
|
|
932
|
-
type:
|
|
933
|
-
value:
|
|
1052
|
+
anthropicBeta: z4.array(z4.string()).optional(),
|
|
1053
|
+
contextManagement: z4.object({
|
|
1054
|
+
edits: z4.array(
|
|
1055
|
+
z4.discriminatedUnion("type", [
|
|
1056
|
+
z4.object({
|
|
1057
|
+
type: z4.literal("clear_tool_uses_20250919"),
|
|
1058
|
+
trigger: z4.discriminatedUnion("type", [
|
|
1059
|
+
z4.object({
|
|
1060
|
+
type: z4.literal("input_tokens"),
|
|
1061
|
+
value: z4.number()
|
|
934
1062
|
}),
|
|
935
|
-
|
|
936
|
-
type:
|
|
937
|
-
value:
|
|
1063
|
+
z4.object({
|
|
1064
|
+
type: z4.literal("tool_uses"),
|
|
1065
|
+
value: z4.number()
|
|
938
1066
|
})
|
|
939
1067
|
]).optional(),
|
|
940
|
-
keep:
|
|
941
|
-
type:
|
|
942
|
-
value:
|
|
1068
|
+
keep: z4.object({
|
|
1069
|
+
type: z4.literal("tool_uses"),
|
|
1070
|
+
value: z4.number()
|
|
943
1071
|
}).optional(),
|
|
944
|
-
clearAtLeast:
|
|
945
|
-
type:
|
|
946
|
-
value:
|
|
1072
|
+
clearAtLeast: z4.object({
|
|
1073
|
+
type: z4.literal("input_tokens"),
|
|
1074
|
+
value: z4.number()
|
|
947
1075
|
}).optional(),
|
|
948
|
-
clearToolInputs:
|
|
949
|
-
excludeTools:
|
|
1076
|
+
clearToolInputs: z4.boolean().optional(),
|
|
1077
|
+
excludeTools: z4.array(z4.string()).optional()
|
|
950
1078
|
}),
|
|
951
|
-
|
|
952
|
-
type:
|
|
953
|
-
keep:
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
type:
|
|
957
|
-
value:
|
|
1079
|
+
z4.object({
|
|
1080
|
+
type: z4.literal("clear_thinking_20251015"),
|
|
1081
|
+
keep: z4.union([
|
|
1082
|
+
z4.literal("all"),
|
|
1083
|
+
z4.object({
|
|
1084
|
+
type: z4.literal("thinking_turns"),
|
|
1085
|
+
value: z4.number()
|
|
958
1086
|
})
|
|
959
1087
|
]).optional()
|
|
960
1088
|
}),
|
|
961
|
-
|
|
962
|
-
type:
|
|
963
|
-
trigger:
|
|
964
|
-
type:
|
|
965
|
-
value:
|
|
1089
|
+
z4.object({
|
|
1090
|
+
type: z4.literal("compact_20260112"),
|
|
1091
|
+
trigger: z4.object({
|
|
1092
|
+
type: z4.literal("input_tokens"),
|
|
1093
|
+
value: z4.number()
|
|
966
1094
|
}).optional(),
|
|
967
|
-
pauseAfterCompaction:
|
|
968
|
-
instructions:
|
|
1095
|
+
pauseAfterCompaction: z4.boolean().optional(),
|
|
1096
|
+
instructions: z4.string().optional()
|
|
969
1097
|
})
|
|
970
1098
|
])
|
|
971
1099
|
)
|
|
@@ -973,7 +1101,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
973
1101
|
});
|
|
974
1102
|
|
|
975
1103
|
// src/anthropic-prepare-tools.ts
|
|
976
|
-
|
|
1104
|
+
import {
|
|
1105
|
+
UnsupportedFunctionalityError
|
|
1106
|
+
} from "@ai-sdk/provider";
|
|
977
1107
|
|
|
978
1108
|
// src/get-cache-control.ts
|
|
979
1109
|
var MAX_CACHE_BREAKPOINTS = 4;
|
|
@@ -1018,31 +1148,34 @@ var CacheControlValidator = class {
|
|
|
1018
1148
|
};
|
|
1019
1149
|
|
|
1020
1150
|
// src/tool/text-editor_20250728.ts
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1151
|
+
import {
|
|
1152
|
+
createProviderDefinedToolFactory,
|
|
1153
|
+
lazySchema as lazySchema4,
|
|
1154
|
+
zodSchema as zodSchema4
|
|
1155
|
+
} from "@ai-sdk/provider-utils";
|
|
1156
|
+
import { z as z5 } from "zod/v4";
|
|
1157
|
+
var textEditor_20250728ArgsSchema = lazySchema4(
|
|
1158
|
+
() => zodSchema4(
|
|
1159
|
+
z5.object({
|
|
1160
|
+
maxCharacters: z5.number().optional()
|
|
1028
1161
|
})
|
|
1029
1162
|
)
|
|
1030
1163
|
);
|
|
1031
|
-
var textEditor_20250728InputSchema = (
|
|
1032
|
-
() => (
|
|
1033
|
-
|
|
1034
|
-
command:
|
|
1035
|
-
path:
|
|
1036
|
-
file_text:
|
|
1037
|
-
insert_line:
|
|
1038
|
-
new_str:
|
|
1039
|
-
insert_text:
|
|
1040
|
-
old_str:
|
|
1041
|
-
view_range:
|
|
1164
|
+
var textEditor_20250728InputSchema = lazySchema4(
|
|
1165
|
+
() => zodSchema4(
|
|
1166
|
+
z5.object({
|
|
1167
|
+
command: z5.enum(["view", "create", "str_replace", "insert"]),
|
|
1168
|
+
path: z5.string(),
|
|
1169
|
+
file_text: z5.string().optional(),
|
|
1170
|
+
insert_line: z5.number().int().optional(),
|
|
1171
|
+
new_str: z5.string().optional(),
|
|
1172
|
+
insert_text: z5.string().optional(),
|
|
1173
|
+
old_str: z5.string().optional(),
|
|
1174
|
+
view_range: z5.array(z5.number().int()).optional()
|
|
1042
1175
|
})
|
|
1043
1176
|
)
|
|
1044
1177
|
);
|
|
1045
|
-
var factory = (
|
|
1178
|
+
var factory = createProviderDefinedToolFactory({
|
|
1046
1179
|
id: "anthropic.text_editor_20250728",
|
|
1047
1180
|
inputSchema: textEditor_20250728InputSchema
|
|
1048
1181
|
});
|
|
@@ -1051,45 +1184,49 @@ var textEditor_20250728 = (args = {}) => {
|
|
|
1051
1184
|
};
|
|
1052
1185
|
|
|
1053
1186
|
// src/tool/web-search_20260209.ts
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1187
|
+
import {
|
|
1188
|
+
createProviderExecutedToolFactory,
|
|
1189
|
+
lazySchema as lazySchema5,
|
|
1190
|
+
zodSchema as zodSchema5
|
|
1191
|
+
} from "@ai-sdk/provider-utils";
|
|
1192
|
+
import { z as z6 } from "zod/v4";
|
|
1193
|
+
var webSearch_20260209ArgsSchema = lazySchema5(
|
|
1194
|
+
() => zodSchema5(
|
|
1195
|
+
z6.object({
|
|
1196
|
+
maxUses: z6.number().optional(),
|
|
1197
|
+
allowedDomains: z6.array(z6.string()).optional(),
|
|
1198
|
+
blockedDomains: z6.array(z6.string()).optional(),
|
|
1199
|
+
userLocation: z6.object({
|
|
1200
|
+
type: z6.literal("approximate"),
|
|
1201
|
+
city: z6.string().optional(),
|
|
1202
|
+
region: z6.string().optional(),
|
|
1203
|
+
country: z6.string().optional(),
|
|
1204
|
+
timezone: z6.string().optional()
|
|
1068
1205
|
}).optional()
|
|
1069
1206
|
})
|
|
1070
1207
|
)
|
|
1071
1208
|
);
|
|
1072
|
-
var webSearch_20260209OutputSchema = (
|
|
1073
|
-
() => (
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
url:
|
|
1077
|
-
title:
|
|
1078
|
-
pageAge:
|
|
1079
|
-
encryptedContent:
|
|
1080
|
-
type:
|
|
1209
|
+
var webSearch_20260209OutputSchema = lazySchema5(
|
|
1210
|
+
() => zodSchema5(
|
|
1211
|
+
z6.array(
|
|
1212
|
+
z6.object({
|
|
1213
|
+
url: z6.string(),
|
|
1214
|
+
title: z6.string().nullable(),
|
|
1215
|
+
pageAge: z6.string().nullable(),
|
|
1216
|
+
encryptedContent: z6.string(),
|
|
1217
|
+
type: z6.literal("web_search_result")
|
|
1081
1218
|
})
|
|
1082
1219
|
)
|
|
1083
1220
|
)
|
|
1084
1221
|
);
|
|
1085
|
-
var webSearch_20260209InputSchema = (
|
|
1086
|
-
() => (
|
|
1087
|
-
|
|
1088
|
-
query:
|
|
1222
|
+
var webSearch_20260209InputSchema = lazySchema5(
|
|
1223
|
+
() => zodSchema5(
|
|
1224
|
+
z6.object({
|
|
1225
|
+
query: z6.string()
|
|
1089
1226
|
})
|
|
1090
1227
|
)
|
|
1091
1228
|
);
|
|
1092
|
-
var factory2 = (
|
|
1229
|
+
var factory2 = createProviderExecutedToolFactory({
|
|
1093
1230
|
id: "anthropic.web_search_20260209",
|
|
1094
1231
|
inputSchema: webSearch_20260209InputSchema,
|
|
1095
1232
|
outputSchema: webSearch_20260209OutputSchema,
|
|
@@ -1100,45 +1237,49 @@ var webSearch_20260209 = (args = {}) => {
|
|
|
1100
1237
|
};
|
|
1101
1238
|
|
|
1102
1239
|
// src/tool/web-search_20250305.ts
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1240
|
+
import {
|
|
1241
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
|
|
1242
|
+
lazySchema as lazySchema6,
|
|
1243
|
+
zodSchema as zodSchema6
|
|
1244
|
+
} from "@ai-sdk/provider-utils";
|
|
1245
|
+
import { z as z7 } from "zod/v4";
|
|
1246
|
+
var webSearch_20250305ArgsSchema = lazySchema6(
|
|
1247
|
+
() => zodSchema6(
|
|
1248
|
+
z7.object({
|
|
1249
|
+
maxUses: z7.number().optional(),
|
|
1250
|
+
allowedDomains: z7.array(z7.string()).optional(),
|
|
1251
|
+
blockedDomains: z7.array(z7.string()).optional(),
|
|
1252
|
+
userLocation: z7.object({
|
|
1253
|
+
type: z7.literal("approximate"),
|
|
1254
|
+
city: z7.string().optional(),
|
|
1255
|
+
region: z7.string().optional(),
|
|
1256
|
+
country: z7.string().optional(),
|
|
1257
|
+
timezone: z7.string().optional()
|
|
1117
1258
|
}).optional()
|
|
1118
1259
|
})
|
|
1119
1260
|
)
|
|
1120
1261
|
);
|
|
1121
|
-
var webSearch_20250305OutputSchema = (
|
|
1122
|
-
() => (
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
url:
|
|
1126
|
-
title:
|
|
1127
|
-
pageAge:
|
|
1128
|
-
encryptedContent:
|
|
1129
|
-
type:
|
|
1262
|
+
var webSearch_20250305OutputSchema = lazySchema6(
|
|
1263
|
+
() => zodSchema6(
|
|
1264
|
+
z7.array(
|
|
1265
|
+
z7.object({
|
|
1266
|
+
url: z7.string(),
|
|
1267
|
+
title: z7.string().nullable(),
|
|
1268
|
+
pageAge: z7.string().nullable(),
|
|
1269
|
+
encryptedContent: z7.string(),
|
|
1270
|
+
type: z7.literal("web_search_result")
|
|
1130
1271
|
})
|
|
1131
1272
|
)
|
|
1132
1273
|
)
|
|
1133
1274
|
);
|
|
1134
|
-
var webSearch_20250305InputSchema = (
|
|
1135
|
-
() => (
|
|
1136
|
-
|
|
1137
|
-
query:
|
|
1275
|
+
var webSearch_20250305InputSchema = lazySchema6(
|
|
1276
|
+
() => zodSchema6(
|
|
1277
|
+
z7.object({
|
|
1278
|
+
query: z7.string()
|
|
1138
1279
|
})
|
|
1139
1280
|
)
|
|
1140
1281
|
);
|
|
1141
|
-
var factory3 = (
|
|
1282
|
+
var factory3 = createProviderExecutedToolFactory2({
|
|
1142
1283
|
id: "anthropic.web_search_20250305",
|
|
1143
1284
|
inputSchema: webSearch_20250305InputSchema,
|
|
1144
1285
|
outputSchema: webSearch_20250305OutputSchema,
|
|
@@ -1149,53 +1290,57 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
1149
1290
|
};
|
|
1150
1291
|
|
|
1151
1292
|
// src/tool/web-fetch-20260209.ts
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1293
|
+
import {
|
|
1294
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
|
|
1295
|
+
lazySchema as lazySchema7,
|
|
1296
|
+
zodSchema as zodSchema7
|
|
1297
|
+
} from "@ai-sdk/provider-utils";
|
|
1298
|
+
import { z as z8 } from "zod/v4";
|
|
1299
|
+
var webFetch_20260209ArgsSchema = lazySchema7(
|
|
1300
|
+
() => zodSchema7(
|
|
1301
|
+
z8.object({
|
|
1302
|
+
maxUses: z8.number().optional(),
|
|
1303
|
+
allowedDomains: z8.array(z8.string()).optional(),
|
|
1304
|
+
blockedDomains: z8.array(z8.string()).optional(),
|
|
1305
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1306
|
+
maxContentTokens: z8.number().optional()
|
|
1162
1307
|
})
|
|
1163
1308
|
)
|
|
1164
1309
|
);
|
|
1165
|
-
var webFetch_20260209OutputSchema = (
|
|
1166
|
-
() => (
|
|
1167
|
-
|
|
1168
|
-
type:
|
|
1169
|
-
url:
|
|
1170
|
-
content:
|
|
1171
|
-
type:
|
|
1172
|
-
title:
|
|
1173
|
-
citations:
|
|
1174
|
-
source:
|
|
1175
|
-
|
|
1176
|
-
type:
|
|
1177
|
-
mediaType:
|
|
1178
|
-
data:
|
|
1310
|
+
var webFetch_20260209OutputSchema = lazySchema7(
|
|
1311
|
+
() => zodSchema7(
|
|
1312
|
+
z8.object({
|
|
1313
|
+
type: z8.literal("web_fetch_result"),
|
|
1314
|
+
url: z8.string(),
|
|
1315
|
+
content: z8.object({
|
|
1316
|
+
type: z8.literal("document"),
|
|
1317
|
+
title: z8.string().nullable(),
|
|
1318
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1319
|
+
source: z8.union([
|
|
1320
|
+
z8.object({
|
|
1321
|
+
type: z8.literal("base64"),
|
|
1322
|
+
mediaType: z8.literal("application/pdf"),
|
|
1323
|
+
data: z8.string()
|
|
1179
1324
|
}),
|
|
1180
|
-
|
|
1181
|
-
type:
|
|
1182
|
-
mediaType:
|
|
1183
|
-
data:
|
|
1325
|
+
z8.object({
|
|
1326
|
+
type: z8.literal("text"),
|
|
1327
|
+
mediaType: z8.literal("text/plain"),
|
|
1328
|
+
data: z8.string()
|
|
1184
1329
|
})
|
|
1185
1330
|
])
|
|
1186
1331
|
}),
|
|
1187
|
-
retrievedAt:
|
|
1332
|
+
retrievedAt: z8.string().nullable()
|
|
1188
1333
|
})
|
|
1189
1334
|
)
|
|
1190
1335
|
);
|
|
1191
|
-
var webFetch_20260209InputSchema = (
|
|
1192
|
-
() => (
|
|
1193
|
-
|
|
1194
|
-
url:
|
|
1336
|
+
var webFetch_20260209InputSchema = lazySchema7(
|
|
1337
|
+
() => zodSchema7(
|
|
1338
|
+
z8.object({
|
|
1339
|
+
url: z8.string()
|
|
1195
1340
|
})
|
|
1196
1341
|
)
|
|
1197
1342
|
);
|
|
1198
|
-
var factory4 = (
|
|
1343
|
+
var factory4 = createProviderExecutedToolFactory3({
|
|
1199
1344
|
id: "anthropic.web_fetch_20260209",
|
|
1200
1345
|
inputSchema: webFetch_20260209InputSchema,
|
|
1201
1346
|
outputSchema: webFetch_20260209OutputSchema,
|
|
@@ -1206,53 +1351,57 @@ var webFetch_20260209 = (args = {}) => {
|
|
|
1206
1351
|
};
|
|
1207
1352
|
|
|
1208
1353
|
// src/tool/web-fetch-20250910.ts
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1354
|
+
import {
|
|
1355
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
|
|
1356
|
+
lazySchema as lazySchema8,
|
|
1357
|
+
zodSchema as zodSchema8
|
|
1358
|
+
} from "@ai-sdk/provider-utils";
|
|
1359
|
+
import { z as z9 } from "zod/v4";
|
|
1360
|
+
var webFetch_20250910ArgsSchema = lazySchema8(
|
|
1361
|
+
() => zodSchema8(
|
|
1362
|
+
z9.object({
|
|
1363
|
+
maxUses: z9.number().optional(),
|
|
1364
|
+
allowedDomains: z9.array(z9.string()).optional(),
|
|
1365
|
+
blockedDomains: z9.array(z9.string()).optional(),
|
|
1366
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1367
|
+
maxContentTokens: z9.number().optional()
|
|
1219
1368
|
})
|
|
1220
1369
|
)
|
|
1221
1370
|
);
|
|
1222
|
-
var webFetch_20250910OutputSchema = (
|
|
1223
|
-
() => (
|
|
1224
|
-
|
|
1225
|
-
type:
|
|
1226
|
-
url:
|
|
1227
|
-
content:
|
|
1228
|
-
type:
|
|
1229
|
-
title:
|
|
1230
|
-
citations:
|
|
1231
|
-
source:
|
|
1232
|
-
|
|
1233
|
-
type:
|
|
1234
|
-
mediaType:
|
|
1235
|
-
data:
|
|
1371
|
+
var webFetch_20250910OutputSchema = lazySchema8(
|
|
1372
|
+
() => zodSchema8(
|
|
1373
|
+
z9.object({
|
|
1374
|
+
type: z9.literal("web_fetch_result"),
|
|
1375
|
+
url: z9.string(),
|
|
1376
|
+
content: z9.object({
|
|
1377
|
+
type: z9.literal("document"),
|
|
1378
|
+
title: z9.string().nullable(),
|
|
1379
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1380
|
+
source: z9.union([
|
|
1381
|
+
z9.object({
|
|
1382
|
+
type: z9.literal("base64"),
|
|
1383
|
+
mediaType: z9.literal("application/pdf"),
|
|
1384
|
+
data: z9.string()
|
|
1236
1385
|
}),
|
|
1237
|
-
|
|
1238
|
-
type:
|
|
1239
|
-
mediaType:
|
|
1240
|
-
data:
|
|
1386
|
+
z9.object({
|
|
1387
|
+
type: z9.literal("text"),
|
|
1388
|
+
mediaType: z9.literal("text/plain"),
|
|
1389
|
+
data: z9.string()
|
|
1241
1390
|
})
|
|
1242
1391
|
])
|
|
1243
1392
|
}),
|
|
1244
|
-
retrievedAt:
|
|
1393
|
+
retrievedAt: z9.string().nullable()
|
|
1245
1394
|
})
|
|
1246
1395
|
)
|
|
1247
1396
|
);
|
|
1248
|
-
var webFetch_20250910InputSchema = (
|
|
1249
|
-
() => (
|
|
1250
|
-
|
|
1251
|
-
url:
|
|
1397
|
+
var webFetch_20250910InputSchema = lazySchema8(
|
|
1398
|
+
() => zodSchema8(
|
|
1399
|
+
z9.object({
|
|
1400
|
+
url: z9.string()
|
|
1252
1401
|
})
|
|
1253
1402
|
)
|
|
1254
1403
|
);
|
|
1255
|
-
var factory5 = (
|
|
1404
|
+
var factory5 = createProviderExecutedToolFactory4({
|
|
1256
1405
|
id: "anthropic.web_fetch_20250910",
|
|
1257
1406
|
inputSchema: webFetch_20250910InputSchema,
|
|
1258
1407
|
outputSchema: webFetch_20250910OutputSchema,
|
|
@@ -1263,16 +1412,17 @@ var webFetch_20250910 = (args = {}) => {
|
|
|
1263
1412
|
};
|
|
1264
1413
|
|
|
1265
1414
|
// src/anthropic-prepare-tools.ts
|
|
1266
|
-
|
|
1415
|
+
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
1267
1416
|
async function prepareTools({
|
|
1268
1417
|
tools,
|
|
1269
1418
|
toolChoice,
|
|
1270
1419
|
disableParallelToolUse,
|
|
1271
1420
|
cacheControlValidator,
|
|
1272
1421
|
supportsStructuredOutput,
|
|
1273
|
-
supportsStrictTools
|
|
1422
|
+
supportsStrictTools,
|
|
1423
|
+
defaultEagerInputStreaming = false
|
|
1274
1424
|
}) {
|
|
1275
|
-
var _a;
|
|
1425
|
+
var _a, _b;
|
|
1276
1426
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1277
1427
|
const toolWarnings = [];
|
|
1278
1428
|
const betas = /* @__PURE__ */ new Set();
|
|
@@ -1289,7 +1439,7 @@ async function prepareTools({
|
|
|
1289
1439
|
canCache: true
|
|
1290
1440
|
});
|
|
1291
1441
|
const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
|
|
1292
|
-
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1442
|
+
const eagerInputStreaming = (_b = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming) != null ? _b : defaultEagerInputStreaming;
|
|
1293
1443
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1294
1444
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1295
1445
|
if (!supportsStrictTools && tool.strict != null) {
|
|
@@ -1413,7 +1563,7 @@ async function prepareTools({
|
|
|
1413
1563
|
break;
|
|
1414
1564
|
}
|
|
1415
1565
|
case "anthropic.text_editor_20250728": {
|
|
1416
|
-
const args = await
|
|
1566
|
+
const args = await validateTypes({
|
|
1417
1567
|
value: tool.args,
|
|
1418
1568
|
schema: textEditor_20250728ArgsSchema
|
|
1419
1569
|
});
|
|
@@ -1453,7 +1603,7 @@ async function prepareTools({
|
|
|
1453
1603
|
}
|
|
1454
1604
|
case "anthropic.web_fetch_20250910": {
|
|
1455
1605
|
betas.add("web-fetch-2025-09-10");
|
|
1456
|
-
const args = await
|
|
1606
|
+
const args = await validateTypes({
|
|
1457
1607
|
value: tool.args,
|
|
1458
1608
|
schema: webFetch_20250910ArgsSchema
|
|
1459
1609
|
});
|
|
@@ -1471,7 +1621,7 @@ async function prepareTools({
|
|
|
1471
1621
|
}
|
|
1472
1622
|
case "anthropic.web_fetch_20260209": {
|
|
1473
1623
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1474
|
-
const args = await
|
|
1624
|
+
const args = await validateTypes({
|
|
1475
1625
|
value: tool.args,
|
|
1476
1626
|
schema: webFetch_20260209ArgsSchema
|
|
1477
1627
|
});
|
|
@@ -1488,7 +1638,7 @@ async function prepareTools({
|
|
|
1488
1638
|
break;
|
|
1489
1639
|
}
|
|
1490
1640
|
case "anthropic.web_search_20250305": {
|
|
1491
|
-
const args = await
|
|
1641
|
+
const args = await validateTypes({
|
|
1492
1642
|
value: tool.args,
|
|
1493
1643
|
schema: webSearch_20250305ArgsSchema
|
|
1494
1644
|
});
|
|
@@ -1505,7 +1655,7 @@ async function prepareTools({
|
|
|
1505
1655
|
}
|
|
1506
1656
|
case "anthropic.web_search_20260209": {
|
|
1507
1657
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1508
|
-
const args = await
|
|
1658
|
+
const args = await validateTypes({
|
|
1509
1659
|
value: tool.args,
|
|
1510
1660
|
schema: webSearch_20260209ArgsSchema
|
|
1511
1661
|
});
|
|
@@ -1521,7 +1671,6 @@ async function prepareTools({
|
|
|
1521
1671
|
break;
|
|
1522
1672
|
}
|
|
1523
1673
|
case "anthropic.tool_search_regex_20251119": {
|
|
1524
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1525
1674
|
anthropicTools2.push({
|
|
1526
1675
|
type: "tool_search_tool_regex_20251119",
|
|
1527
1676
|
name: "tool_search_tool_regex"
|
|
@@ -1529,7 +1678,6 @@ async function prepareTools({
|
|
|
1529
1678
|
break;
|
|
1530
1679
|
}
|
|
1531
1680
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1532
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1533
1681
|
anthropicTools2.push({
|
|
1534
1682
|
type: "tool_search_tool_bm25_20251119",
|
|
1535
1683
|
name: "tool_search_tool_bm25"
|
|
@@ -1600,15 +1748,15 @@ async function prepareTools({
|
|
|
1600
1748
|
};
|
|
1601
1749
|
default: {
|
|
1602
1750
|
const _exhaustiveCheck = type;
|
|
1603
|
-
throw new
|
|
1751
|
+
throw new UnsupportedFunctionalityError({
|
|
1604
1752
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1605
1753
|
});
|
|
1606
1754
|
}
|
|
1607
1755
|
}
|
|
1608
1756
|
}
|
|
1609
1757
|
|
|
1610
|
-
// src/convert-anthropic-
|
|
1611
|
-
function
|
|
1758
|
+
// src/convert-anthropic-usage.ts
|
|
1759
|
+
function convertAnthropicUsage({
|
|
1612
1760
|
usage,
|
|
1613
1761
|
rawUsage
|
|
1614
1762
|
}) {
|
|
@@ -1647,37 +1795,52 @@ function convertAnthropicMessagesUsage({
|
|
|
1647
1795
|
};
|
|
1648
1796
|
}
|
|
1649
1797
|
|
|
1650
|
-
// src/convert-to-anthropic-
|
|
1651
|
-
|
|
1652
|
-
|
|
1798
|
+
// src/convert-to-anthropic-prompt.ts
|
|
1799
|
+
import {
|
|
1800
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
1801
|
+
} from "@ai-sdk/provider";
|
|
1802
|
+
import {
|
|
1803
|
+
convertBase64ToUint8Array,
|
|
1804
|
+
convertToBase64,
|
|
1805
|
+
getTopLevelMediaType,
|
|
1806
|
+
parseProviderOptions,
|
|
1807
|
+
resolveFullMediaType,
|
|
1808
|
+
resolveProviderReference,
|
|
1809
|
+
validateTypes as validateTypes2,
|
|
1810
|
+
isNonNullable
|
|
1811
|
+
} from "@ai-sdk/provider-utils";
|
|
1653
1812
|
|
|
1654
1813
|
// src/tool/code-execution_20250522.ts
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1814
|
+
import {
|
|
1815
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
|
|
1816
|
+
lazySchema as lazySchema9,
|
|
1817
|
+
zodSchema as zodSchema9
|
|
1818
|
+
} from "@ai-sdk/provider-utils";
|
|
1819
|
+
import { z as z10 } from "zod/v4";
|
|
1820
|
+
var codeExecution_20250522OutputSchema = lazySchema9(
|
|
1821
|
+
() => zodSchema9(
|
|
1822
|
+
z10.object({
|
|
1823
|
+
type: z10.literal("code_execution_result"),
|
|
1824
|
+
stdout: z10.string(),
|
|
1825
|
+
stderr: z10.string(),
|
|
1826
|
+
return_code: z10.number(),
|
|
1827
|
+
content: z10.array(
|
|
1828
|
+
z10.object({
|
|
1829
|
+
type: z10.literal("code_execution_output"),
|
|
1830
|
+
file_id: z10.string()
|
|
1668
1831
|
})
|
|
1669
1832
|
).optional().default([])
|
|
1670
1833
|
})
|
|
1671
1834
|
)
|
|
1672
1835
|
);
|
|
1673
|
-
var codeExecution_20250522InputSchema = (
|
|
1674
|
-
() => (
|
|
1675
|
-
|
|
1676
|
-
code:
|
|
1836
|
+
var codeExecution_20250522InputSchema = lazySchema9(
|
|
1837
|
+
() => zodSchema9(
|
|
1838
|
+
z10.object({
|
|
1839
|
+
code: z10.string()
|
|
1677
1840
|
})
|
|
1678
1841
|
)
|
|
1679
1842
|
);
|
|
1680
|
-
var factory6 = (
|
|
1843
|
+
var factory6 = createProviderExecutedToolFactory5({
|
|
1681
1844
|
id: "anthropic.code_execution_20250522",
|
|
1682
1845
|
inputSchema: codeExecution_20250522InputSchema,
|
|
1683
1846
|
outputSchema: codeExecution_20250522OutputSchema
|
|
@@ -1687,102 +1850,106 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
1687
1850
|
};
|
|
1688
1851
|
|
|
1689
1852
|
// src/tool/code-execution_20250825.ts
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1853
|
+
import {
|
|
1854
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
|
|
1855
|
+
lazySchema as lazySchema10,
|
|
1856
|
+
zodSchema as zodSchema10
|
|
1857
|
+
} from "@ai-sdk/provider-utils";
|
|
1858
|
+
import { z as z11 } from "zod/v4";
|
|
1859
|
+
var codeExecution_20250825OutputSchema = lazySchema10(
|
|
1860
|
+
() => zodSchema10(
|
|
1861
|
+
z11.discriminatedUnion("type", [
|
|
1862
|
+
z11.object({
|
|
1863
|
+
type: z11.literal("code_execution_result"),
|
|
1864
|
+
stdout: z11.string(),
|
|
1865
|
+
stderr: z11.string(),
|
|
1866
|
+
return_code: z11.number(),
|
|
1867
|
+
content: z11.array(
|
|
1868
|
+
z11.object({
|
|
1869
|
+
type: z11.literal("code_execution_output"),
|
|
1870
|
+
file_id: z11.string()
|
|
1704
1871
|
})
|
|
1705
1872
|
).optional().default([])
|
|
1706
1873
|
}),
|
|
1707
|
-
|
|
1708
|
-
type:
|
|
1709
|
-
content:
|
|
1710
|
-
|
|
1711
|
-
type:
|
|
1712
|
-
file_id:
|
|
1874
|
+
z11.object({
|
|
1875
|
+
type: z11.literal("bash_code_execution_result"),
|
|
1876
|
+
content: z11.array(
|
|
1877
|
+
z11.object({
|
|
1878
|
+
type: z11.literal("bash_code_execution_output"),
|
|
1879
|
+
file_id: z11.string()
|
|
1713
1880
|
})
|
|
1714
1881
|
),
|
|
1715
|
-
stdout:
|
|
1716
|
-
stderr:
|
|
1717
|
-
return_code:
|
|
1882
|
+
stdout: z11.string(),
|
|
1883
|
+
stderr: z11.string(),
|
|
1884
|
+
return_code: z11.number()
|
|
1718
1885
|
}),
|
|
1719
|
-
|
|
1720
|
-
type:
|
|
1721
|
-
error_code:
|
|
1886
|
+
z11.object({
|
|
1887
|
+
type: z11.literal("bash_code_execution_tool_result_error"),
|
|
1888
|
+
error_code: z11.string()
|
|
1722
1889
|
}),
|
|
1723
|
-
|
|
1724
|
-
type:
|
|
1725
|
-
error_code:
|
|
1890
|
+
z11.object({
|
|
1891
|
+
type: z11.literal("text_editor_code_execution_tool_result_error"),
|
|
1892
|
+
error_code: z11.string()
|
|
1726
1893
|
}),
|
|
1727
|
-
|
|
1728
|
-
type:
|
|
1729
|
-
content:
|
|
1730
|
-
file_type:
|
|
1731
|
-
num_lines:
|
|
1732
|
-
start_line:
|
|
1733
|
-
total_lines:
|
|
1894
|
+
z11.object({
|
|
1895
|
+
type: z11.literal("text_editor_code_execution_view_result"),
|
|
1896
|
+
content: z11.string(),
|
|
1897
|
+
file_type: z11.string(),
|
|
1898
|
+
num_lines: z11.number().nullable(),
|
|
1899
|
+
start_line: z11.number().nullable(),
|
|
1900
|
+
total_lines: z11.number().nullable()
|
|
1734
1901
|
}),
|
|
1735
|
-
|
|
1736
|
-
type:
|
|
1737
|
-
is_file_update:
|
|
1902
|
+
z11.object({
|
|
1903
|
+
type: z11.literal("text_editor_code_execution_create_result"),
|
|
1904
|
+
is_file_update: z11.boolean()
|
|
1738
1905
|
}),
|
|
1739
|
-
|
|
1740
|
-
type:
|
|
1741
|
-
lines:
|
|
1742
|
-
new_lines:
|
|
1743
|
-
new_start:
|
|
1744
|
-
old_lines:
|
|
1745
|
-
old_start:
|
|
1906
|
+
z11.object({
|
|
1907
|
+
type: z11.literal("text_editor_code_execution_str_replace_result"),
|
|
1908
|
+
lines: z11.array(z11.string()).nullable(),
|
|
1909
|
+
new_lines: z11.number().nullable(),
|
|
1910
|
+
new_start: z11.number().nullable(),
|
|
1911
|
+
old_lines: z11.number().nullable(),
|
|
1912
|
+
old_start: z11.number().nullable()
|
|
1746
1913
|
})
|
|
1747
1914
|
])
|
|
1748
1915
|
)
|
|
1749
1916
|
);
|
|
1750
|
-
var codeExecution_20250825InputSchema = (
|
|
1751
|
-
() => (
|
|
1752
|
-
|
|
1917
|
+
var codeExecution_20250825InputSchema = lazySchema10(
|
|
1918
|
+
() => zodSchema10(
|
|
1919
|
+
z11.discriminatedUnion("type", [
|
|
1753
1920
|
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1754
|
-
|
|
1755
|
-
type:
|
|
1756
|
-
code:
|
|
1921
|
+
z11.object({
|
|
1922
|
+
type: z11.literal("programmatic-tool-call"),
|
|
1923
|
+
code: z11.string()
|
|
1757
1924
|
}),
|
|
1758
|
-
|
|
1759
|
-
type:
|
|
1760
|
-
command:
|
|
1925
|
+
z11.object({
|
|
1926
|
+
type: z11.literal("bash_code_execution"),
|
|
1927
|
+
command: z11.string()
|
|
1761
1928
|
}),
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
type:
|
|
1765
|
-
command:
|
|
1766
|
-
path:
|
|
1929
|
+
z11.discriminatedUnion("command", [
|
|
1930
|
+
z11.object({
|
|
1931
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1932
|
+
command: z11.literal("view"),
|
|
1933
|
+
path: z11.string()
|
|
1767
1934
|
}),
|
|
1768
|
-
|
|
1769
|
-
type:
|
|
1770
|
-
command:
|
|
1771
|
-
path:
|
|
1772
|
-
file_text:
|
|
1935
|
+
z11.object({
|
|
1936
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1937
|
+
command: z11.literal("create"),
|
|
1938
|
+
path: z11.string(),
|
|
1939
|
+
file_text: z11.string().nullish()
|
|
1773
1940
|
}),
|
|
1774
|
-
|
|
1775
|
-
type:
|
|
1776
|
-
command:
|
|
1777
|
-
path:
|
|
1778
|
-
old_str:
|
|
1779
|
-
new_str:
|
|
1941
|
+
z11.object({
|
|
1942
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1943
|
+
command: z11.literal("str_replace"),
|
|
1944
|
+
path: z11.string(),
|
|
1945
|
+
old_str: z11.string(),
|
|
1946
|
+
new_str: z11.string()
|
|
1780
1947
|
})
|
|
1781
1948
|
])
|
|
1782
1949
|
])
|
|
1783
1950
|
)
|
|
1784
1951
|
);
|
|
1785
|
-
var factory7 = (
|
|
1952
|
+
var factory7 = createProviderExecutedToolFactory6({
|
|
1786
1953
|
id: "anthropic.code_execution_20250825",
|
|
1787
1954
|
inputSchema: codeExecution_20250825InputSchema,
|
|
1788
1955
|
outputSchema: codeExecution_20250825OutputSchema,
|
|
@@ -1796,113 +1963,117 @@ var codeExecution_20250825 = (args = {}) => {
|
|
|
1796
1963
|
};
|
|
1797
1964
|
|
|
1798
1965
|
// src/tool/code-execution_20260120.ts
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1966
|
+
import {
|
|
1967
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory7,
|
|
1968
|
+
lazySchema as lazySchema11,
|
|
1969
|
+
zodSchema as zodSchema11
|
|
1970
|
+
} from "@ai-sdk/provider-utils";
|
|
1971
|
+
import { z as z12 } from "zod/v4";
|
|
1972
|
+
var codeExecution_20260120OutputSchema = lazySchema11(
|
|
1973
|
+
() => zodSchema11(
|
|
1974
|
+
z12.discriminatedUnion("type", [
|
|
1975
|
+
z12.object({
|
|
1976
|
+
type: z12.literal("code_execution_result"),
|
|
1977
|
+
stdout: z12.string(),
|
|
1978
|
+
stderr: z12.string(),
|
|
1979
|
+
return_code: z12.number(),
|
|
1980
|
+
content: z12.array(
|
|
1981
|
+
z12.object({
|
|
1982
|
+
type: z12.literal("code_execution_output"),
|
|
1983
|
+
file_id: z12.string()
|
|
1813
1984
|
})
|
|
1814
1985
|
).optional().default([])
|
|
1815
1986
|
}),
|
|
1816
|
-
|
|
1817
|
-
type:
|
|
1818
|
-
encrypted_stdout:
|
|
1819
|
-
stderr:
|
|
1820
|
-
return_code:
|
|
1821
|
-
content:
|
|
1822
|
-
|
|
1823
|
-
type:
|
|
1824
|
-
file_id:
|
|
1987
|
+
z12.object({
|
|
1988
|
+
type: z12.literal("encrypted_code_execution_result"),
|
|
1989
|
+
encrypted_stdout: z12.string(),
|
|
1990
|
+
stderr: z12.string(),
|
|
1991
|
+
return_code: z12.number(),
|
|
1992
|
+
content: z12.array(
|
|
1993
|
+
z12.object({
|
|
1994
|
+
type: z12.literal("code_execution_output"),
|
|
1995
|
+
file_id: z12.string()
|
|
1825
1996
|
})
|
|
1826
1997
|
).optional().default([])
|
|
1827
1998
|
}),
|
|
1828
|
-
|
|
1829
|
-
type:
|
|
1830
|
-
content:
|
|
1831
|
-
|
|
1832
|
-
type:
|
|
1833
|
-
file_id:
|
|
1999
|
+
z12.object({
|
|
2000
|
+
type: z12.literal("bash_code_execution_result"),
|
|
2001
|
+
content: z12.array(
|
|
2002
|
+
z12.object({
|
|
2003
|
+
type: z12.literal("bash_code_execution_output"),
|
|
2004
|
+
file_id: z12.string()
|
|
1834
2005
|
})
|
|
1835
2006
|
),
|
|
1836
|
-
stdout:
|
|
1837
|
-
stderr:
|
|
1838
|
-
return_code:
|
|
2007
|
+
stdout: z12.string(),
|
|
2008
|
+
stderr: z12.string(),
|
|
2009
|
+
return_code: z12.number()
|
|
1839
2010
|
}),
|
|
1840
|
-
|
|
1841
|
-
type:
|
|
1842
|
-
error_code:
|
|
2011
|
+
z12.object({
|
|
2012
|
+
type: z12.literal("bash_code_execution_tool_result_error"),
|
|
2013
|
+
error_code: z12.string()
|
|
1843
2014
|
}),
|
|
1844
|
-
|
|
1845
|
-
type:
|
|
1846
|
-
error_code:
|
|
2015
|
+
z12.object({
|
|
2016
|
+
type: z12.literal("text_editor_code_execution_tool_result_error"),
|
|
2017
|
+
error_code: z12.string()
|
|
1847
2018
|
}),
|
|
1848
|
-
|
|
1849
|
-
type:
|
|
1850
|
-
content:
|
|
1851
|
-
file_type:
|
|
1852
|
-
num_lines:
|
|
1853
|
-
start_line:
|
|
1854
|
-
total_lines:
|
|
2019
|
+
z12.object({
|
|
2020
|
+
type: z12.literal("text_editor_code_execution_view_result"),
|
|
2021
|
+
content: z12.string(),
|
|
2022
|
+
file_type: z12.string(),
|
|
2023
|
+
num_lines: z12.number().nullable(),
|
|
2024
|
+
start_line: z12.number().nullable(),
|
|
2025
|
+
total_lines: z12.number().nullable()
|
|
1855
2026
|
}),
|
|
1856
|
-
|
|
1857
|
-
type:
|
|
1858
|
-
is_file_update:
|
|
2027
|
+
z12.object({
|
|
2028
|
+
type: z12.literal("text_editor_code_execution_create_result"),
|
|
2029
|
+
is_file_update: z12.boolean()
|
|
1859
2030
|
}),
|
|
1860
|
-
|
|
1861
|
-
type:
|
|
1862
|
-
lines:
|
|
1863
|
-
new_lines:
|
|
1864
|
-
new_start:
|
|
1865
|
-
old_lines:
|
|
1866
|
-
old_start:
|
|
2031
|
+
z12.object({
|
|
2032
|
+
type: z12.literal("text_editor_code_execution_str_replace_result"),
|
|
2033
|
+
lines: z12.array(z12.string()).nullable(),
|
|
2034
|
+
new_lines: z12.number().nullable(),
|
|
2035
|
+
new_start: z12.number().nullable(),
|
|
2036
|
+
old_lines: z12.number().nullable(),
|
|
2037
|
+
old_start: z12.number().nullable()
|
|
1867
2038
|
})
|
|
1868
2039
|
])
|
|
1869
2040
|
)
|
|
1870
2041
|
);
|
|
1871
|
-
var codeExecution_20260120InputSchema = (
|
|
1872
|
-
() => (
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
type:
|
|
1876
|
-
code:
|
|
2042
|
+
var codeExecution_20260120InputSchema = lazySchema11(
|
|
2043
|
+
() => zodSchema11(
|
|
2044
|
+
z12.discriminatedUnion("type", [
|
|
2045
|
+
z12.object({
|
|
2046
|
+
type: z12.literal("programmatic-tool-call"),
|
|
2047
|
+
code: z12.string()
|
|
1877
2048
|
}),
|
|
1878
|
-
|
|
1879
|
-
type:
|
|
1880
|
-
command:
|
|
2049
|
+
z12.object({
|
|
2050
|
+
type: z12.literal("bash_code_execution"),
|
|
2051
|
+
command: z12.string()
|
|
1881
2052
|
}),
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
type:
|
|
1885
|
-
command:
|
|
1886
|
-
path:
|
|
2053
|
+
z12.discriminatedUnion("command", [
|
|
2054
|
+
z12.object({
|
|
2055
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2056
|
+
command: z12.literal("view"),
|
|
2057
|
+
path: z12.string()
|
|
1887
2058
|
}),
|
|
1888
|
-
|
|
1889
|
-
type:
|
|
1890
|
-
command:
|
|
1891
|
-
path:
|
|
1892
|
-
file_text:
|
|
2059
|
+
z12.object({
|
|
2060
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2061
|
+
command: z12.literal("create"),
|
|
2062
|
+
path: z12.string(),
|
|
2063
|
+
file_text: z12.string().nullish()
|
|
1893
2064
|
}),
|
|
1894
|
-
|
|
1895
|
-
type:
|
|
1896
|
-
command:
|
|
1897
|
-
path:
|
|
1898
|
-
old_str:
|
|
1899
|
-
new_str:
|
|
2065
|
+
z12.object({
|
|
2066
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2067
|
+
command: z12.literal("str_replace"),
|
|
2068
|
+
path: z12.string(),
|
|
2069
|
+
old_str: z12.string(),
|
|
2070
|
+
new_str: z12.string()
|
|
1900
2071
|
})
|
|
1901
2072
|
])
|
|
1902
2073
|
])
|
|
1903
2074
|
)
|
|
1904
2075
|
);
|
|
1905
|
-
var factory8 = (
|
|
2076
|
+
var factory8 = createProviderExecutedToolFactory7({
|
|
1906
2077
|
id: "anthropic.code_execution_20260120",
|
|
1907
2078
|
inputSchema: codeExecution_20260120InputSchema,
|
|
1908
2079
|
outputSchema: codeExecution_20260120OutputSchema,
|
|
@@ -1913,21 +2084,25 @@ var codeExecution_20260120 = (args = {}) => {
|
|
|
1913
2084
|
};
|
|
1914
2085
|
|
|
1915
2086
|
// src/tool/tool-search-regex_20251119.ts
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
2087
|
+
import {
|
|
2088
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory8,
|
|
2089
|
+
lazySchema as lazySchema12,
|
|
2090
|
+
zodSchema as zodSchema12
|
|
2091
|
+
} from "@ai-sdk/provider-utils";
|
|
2092
|
+
import { z as z13 } from "zod/v4";
|
|
2093
|
+
var toolSearchRegex_20251119OutputSchema = lazySchema12(
|
|
2094
|
+
() => zodSchema12(
|
|
2095
|
+
z13.array(
|
|
2096
|
+
z13.object({
|
|
2097
|
+
type: z13.literal("tool_reference"),
|
|
2098
|
+
toolName: z13.string()
|
|
1924
2099
|
})
|
|
1925
2100
|
)
|
|
1926
2101
|
)
|
|
1927
2102
|
);
|
|
1928
|
-
var toolSearchRegex_20251119InputSchema = (
|
|
1929
|
-
() => (
|
|
1930
|
-
|
|
2103
|
+
var toolSearchRegex_20251119InputSchema = lazySchema12(
|
|
2104
|
+
() => zodSchema12(
|
|
2105
|
+
z13.object({
|
|
1931
2106
|
/**
|
|
1932
2107
|
* A regex pattern to search for tools.
|
|
1933
2108
|
* Uses Python re.search() syntax. Maximum 200 characters.
|
|
@@ -1938,15 +2113,15 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
|
|
|
1938
2113
|
* - "database.*query|query.*database" - OR patterns for flexibility
|
|
1939
2114
|
* - "(?i)slack" - case-insensitive search
|
|
1940
2115
|
*/
|
|
1941
|
-
pattern:
|
|
2116
|
+
pattern: z13.string(),
|
|
1942
2117
|
/**
|
|
1943
2118
|
* Maximum number of tools to return. Optional.
|
|
1944
2119
|
*/
|
|
1945
|
-
limit:
|
|
2120
|
+
limit: z13.number().optional()
|
|
1946
2121
|
})
|
|
1947
2122
|
)
|
|
1948
2123
|
);
|
|
1949
|
-
var factory9 = (
|
|
2124
|
+
var factory9 = createProviderExecutedToolFactory8({
|
|
1950
2125
|
id: "anthropic.tool_search_regex_20251119",
|
|
1951
2126
|
inputSchema: toolSearchRegex_20251119InputSchema,
|
|
1952
2127
|
outputSchema: toolSearchRegex_20251119OutputSchema,
|
|
@@ -1956,40 +2131,21 @@ var toolSearchRegex_20251119 = (args = {}) => {
|
|
|
1956
2131
|
return factory9(args);
|
|
1957
2132
|
};
|
|
1958
2133
|
|
|
1959
|
-
// src/convert-to-anthropic-
|
|
1960
|
-
function
|
|
2134
|
+
// src/convert-to-anthropic-prompt.ts
|
|
2135
|
+
function convertBytesDataToString(data) {
|
|
1961
2136
|
if (typeof data === "string") {
|
|
1962
|
-
return new TextDecoder().decode(
|
|
1963
|
-
}
|
|
1964
|
-
if (data instanceof Uint8Array) {
|
|
1965
|
-
return new TextDecoder().decode(data);
|
|
1966
|
-
}
|
|
1967
|
-
if (data instanceof URL) {
|
|
1968
|
-
throw new import_provider2.UnsupportedFunctionalityError({
|
|
1969
|
-
functionality: "URL-based text documents are not supported for citations"
|
|
1970
|
-
});
|
|
2137
|
+
return new TextDecoder().decode(convertBase64ToUint8Array(data));
|
|
1971
2138
|
}
|
|
1972
|
-
|
|
1973
|
-
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
1974
|
-
});
|
|
1975
|
-
}
|
|
1976
|
-
function isUrlData(data) {
|
|
1977
|
-
return data instanceof URL || isUrlString(data);
|
|
1978
|
-
}
|
|
1979
|
-
function isUrlString(data) {
|
|
1980
|
-
return typeof data === "string" && /^https?:\/\//i.test(data);
|
|
1981
|
-
}
|
|
1982
|
-
function getUrlString(data) {
|
|
1983
|
-
return data instanceof URL ? data.toString() : data;
|
|
2139
|
+
return new TextDecoder().decode(data);
|
|
1984
2140
|
}
|
|
1985
|
-
async function
|
|
2141
|
+
async function convertToAnthropicPrompt({
|
|
1986
2142
|
prompt,
|
|
1987
2143
|
sendReasoning,
|
|
1988
2144
|
warnings,
|
|
1989
2145
|
cacheControlValidator,
|
|
1990
2146
|
toolNameMapping
|
|
1991
2147
|
}) {
|
|
1992
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2148
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
1993
2149
|
const betas = /* @__PURE__ */ new Set();
|
|
1994
2150
|
const blocks = groupIntoBlocks(prompt);
|
|
1995
2151
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
@@ -1997,7 +2153,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1997
2153
|
const messages = [];
|
|
1998
2154
|
async function shouldEnableCitations(providerMetadata) {
|
|
1999
2155
|
var _a2, _b2;
|
|
2000
|
-
const anthropicOptions = await
|
|
2156
|
+
const anthropicOptions = await parseProviderOptions({
|
|
2001
2157
|
provider: "anthropic",
|
|
2002
2158
|
providerOptions: providerMetadata,
|
|
2003
2159
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2005,7 +2161,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2005
2161
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
2006
2162
|
}
|
|
2007
2163
|
async function getDocumentMetadata(providerMetadata) {
|
|
2008
|
-
const anthropicOptions = await
|
|
2164
|
+
const anthropicOptions = await parseProviderOptions({
|
|
2009
2165
|
provider: "anthropic",
|
|
2010
2166
|
providerOptions: providerMetadata,
|
|
2011
2167
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2022,7 +2178,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2022
2178
|
switch (type) {
|
|
2023
2179
|
case "system": {
|
|
2024
2180
|
if (system != null) {
|
|
2025
|
-
throw new
|
|
2181
|
+
throw new UnsupportedFunctionalityError2({
|
|
2026
2182
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
2027
2183
|
});
|
|
2028
2184
|
}
|
|
@@ -2062,72 +2218,131 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2062
2218
|
break;
|
|
2063
2219
|
}
|
|
2064
2220
|
case "file": {
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2221
|
+
switch (part.data.type) {
|
|
2222
|
+
case "reference": {
|
|
2223
|
+
const fileId = resolveProviderReference({
|
|
2224
|
+
reference: part.data.reference,
|
|
2225
|
+
provider: "anthropic"
|
|
2226
|
+
});
|
|
2227
|
+
betas.add("files-api-2025-04-14");
|
|
2228
|
+
if (getTopLevelMediaType(part.mediaType) === "image") {
|
|
2229
|
+
anthropicContent.push({
|
|
2230
|
+
type: "image",
|
|
2231
|
+
source: { type: "file", file_id: fileId },
|
|
2232
|
+
cache_control: cacheControl
|
|
2233
|
+
});
|
|
2234
|
+
} else {
|
|
2235
|
+
anthropicContent.push({
|
|
2236
|
+
type: "document",
|
|
2237
|
+
source: { type: "file", file_id: fileId },
|
|
2238
|
+
cache_control: cacheControl
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
break;
|
|
2242
|
+
}
|
|
2243
|
+
case "text": {
|
|
2244
|
+
const enableCitations = await shouldEnableCitations(
|
|
2245
|
+
part.providerOptions
|
|
2246
|
+
);
|
|
2247
|
+
const metadata = await getDocumentMetadata(
|
|
2248
|
+
part.providerOptions
|
|
2249
|
+
);
|
|
2250
|
+
anthropicContent.push({
|
|
2251
|
+
type: "document",
|
|
2252
|
+
source: {
|
|
2253
|
+
type: "text",
|
|
2254
|
+
media_type: "text/plain",
|
|
2255
|
+
data: part.data.text
|
|
2256
|
+
},
|
|
2257
|
+
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
2258
|
+
...metadata.context && {
|
|
2259
|
+
context: metadata.context
|
|
2260
|
+
},
|
|
2261
|
+
...enableCitations && {
|
|
2262
|
+
citations: { enabled: true }
|
|
2263
|
+
},
|
|
2264
|
+
cache_control: cacheControl
|
|
2265
|
+
});
|
|
2266
|
+
break;
|
|
2267
|
+
}
|
|
2268
|
+
case "url":
|
|
2269
|
+
case "data": {
|
|
2270
|
+
const topLevel = getTopLevelMediaType(part.mediaType);
|
|
2271
|
+
if (topLevel === "image") {
|
|
2272
|
+
anthropicContent.push({
|
|
2273
|
+
type: "image",
|
|
2274
|
+
source: part.data.type === "url" ? {
|
|
2275
|
+
type: "url",
|
|
2276
|
+
url: part.data.url.toString()
|
|
2277
|
+
} : {
|
|
2278
|
+
type: "base64",
|
|
2279
|
+
media_type: resolveFullMediaType({ part }),
|
|
2280
|
+
data: convertToBase64(part.data.data)
|
|
2281
|
+
},
|
|
2282
|
+
cache_control: cacheControl
|
|
2283
|
+
});
|
|
2284
|
+
} else if (topLevel === "application" && (part.data.type === "url" ? part.mediaType === "application/pdf" : resolveFullMediaType({ part }) === "application/pdf")) {
|
|
2285
|
+
betas.add("pdfs-2024-09-25");
|
|
2286
|
+
const enableCitations = await shouldEnableCitations(
|
|
2287
|
+
part.providerOptions
|
|
2288
|
+
);
|
|
2289
|
+
const metadata = await getDocumentMetadata(
|
|
2290
|
+
part.providerOptions
|
|
2291
|
+
);
|
|
2292
|
+
anthropicContent.push({
|
|
2293
|
+
type: "document",
|
|
2294
|
+
source: part.data.type === "url" ? {
|
|
2295
|
+
type: "url",
|
|
2296
|
+
url: part.data.url.toString()
|
|
2297
|
+
} : {
|
|
2298
|
+
type: "base64",
|
|
2299
|
+
media_type: "application/pdf",
|
|
2300
|
+
data: convertToBase64(part.data.data)
|
|
2301
|
+
},
|
|
2302
|
+
title: (_c = metadata.title) != null ? _c : part.filename,
|
|
2303
|
+
...metadata.context && {
|
|
2304
|
+
context: metadata.context
|
|
2305
|
+
},
|
|
2306
|
+
...enableCitations && {
|
|
2307
|
+
citations: { enabled: true }
|
|
2308
|
+
},
|
|
2309
|
+
cache_control: cacheControl
|
|
2310
|
+
});
|
|
2311
|
+
} else if (part.mediaType === "text/plain") {
|
|
2312
|
+
const enableCitations = await shouldEnableCitations(
|
|
2313
|
+
part.providerOptions
|
|
2314
|
+
);
|
|
2315
|
+
const metadata = await getDocumentMetadata(
|
|
2316
|
+
part.providerOptions
|
|
2317
|
+
);
|
|
2318
|
+
anthropicContent.push({
|
|
2319
|
+
type: "document",
|
|
2320
|
+
source: part.data.type === "url" ? {
|
|
2321
|
+
type: "url",
|
|
2322
|
+
url: part.data.url.toString()
|
|
2323
|
+
} : {
|
|
2324
|
+
type: "text",
|
|
2325
|
+
media_type: "text/plain",
|
|
2326
|
+
data: convertBytesDataToString(
|
|
2327
|
+
part.data.data
|
|
2328
|
+
)
|
|
2329
|
+
},
|
|
2330
|
+
title: (_d = metadata.title) != null ? _d : part.filename,
|
|
2331
|
+
...metadata.context && {
|
|
2332
|
+
context: metadata.context
|
|
2333
|
+
},
|
|
2334
|
+
...enableCitations && {
|
|
2335
|
+
citations: { enabled: true }
|
|
2336
|
+
},
|
|
2337
|
+
cache_control: cacheControl
|
|
2338
|
+
});
|
|
2339
|
+
} else {
|
|
2340
|
+
throw new UnsupportedFunctionalityError2({
|
|
2341
|
+
functionality: `media type: ${part.mediaType}`
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2344
|
+
break;
|
|
2345
|
+
}
|
|
2131
2346
|
}
|
|
2132
2347
|
break;
|
|
2133
2348
|
}
|
|
@@ -2142,10 +2357,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2142
2357
|
continue;
|
|
2143
2358
|
}
|
|
2144
2359
|
const isLastPart = i2 === content.length - 1;
|
|
2145
|
-
const cacheControl = (
|
|
2360
|
+
const cacheControl = (_e = validator.getCacheControl(part.providerOptions, {
|
|
2146
2361
|
type: "tool result part",
|
|
2147
2362
|
canCache: true
|
|
2148
|
-
})) != null ?
|
|
2363
|
+
})) != null ? _e : isLastPart ? validator.getCacheControl(message.providerOptions, {
|
|
2149
2364
|
type: "tool result message",
|
|
2150
2365
|
canCache: true
|
|
2151
2366
|
}) : void 0;
|
|
@@ -2161,26 +2376,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2161
2376
|
type: "text",
|
|
2162
2377
|
text: contentPart.text
|
|
2163
2378
|
};
|
|
2164
|
-
case "image-data": {
|
|
2165
|
-
return {
|
|
2166
|
-
type: "image",
|
|
2167
|
-
source: {
|
|
2168
|
-
type: "base64",
|
|
2169
|
-
media_type: contentPart.mediaType,
|
|
2170
|
-
data: contentPart.data
|
|
2171
|
-
}
|
|
2172
|
-
};
|
|
2173
|
-
}
|
|
2174
|
-
case "image-url": {
|
|
2175
|
-
return {
|
|
2176
|
-
type: "image",
|
|
2177
|
-
source: {
|
|
2178
|
-
type: "url",
|
|
2179
|
-
url: contentPart.url
|
|
2180
|
-
}
|
|
2181
|
-
};
|
|
2182
|
-
}
|
|
2183
2379
|
case "file-url": {
|
|
2380
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2381
|
+
return {
|
|
2382
|
+
type: "image",
|
|
2383
|
+
source: {
|
|
2384
|
+
type: "url",
|
|
2385
|
+
url: contentPart.url
|
|
2386
|
+
}
|
|
2387
|
+
};
|
|
2388
|
+
}
|
|
2184
2389
|
return {
|
|
2185
2390
|
type: "document",
|
|
2186
2391
|
source: {
|
|
@@ -2190,6 +2395,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2190
2395
|
};
|
|
2191
2396
|
}
|
|
2192
2397
|
case "file-data": {
|
|
2398
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2399
|
+
return {
|
|
2400
|
+
type: "image",
|
|
2401
|
+
source: {
|
|
2402
|
+
type: "base64",
|
|
2403
|
+
media_type: contentPart.mediaType,
|
|
2404
|
+
data: contentPart.data
|
|
2405
|
+
}
|
|
2406
|
+
};
|
|
2407
|
+
}
|
|
2193
2408
|
if (contentPart.mediaType === "application/pdf") {
|
|
2194
2409
|
betas.add("pdfs-2024-09-25");
|
|
2195
2410
|
return {
|
|
@@ -2229,14 +2444,14 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2229
2444
|
return void 0;
|
|
2230
2445
|
}
|
|
2231
2446
|
}
|
|
2232
|
-
}).filter(
|
|
2447
|
+
}).filter(isNonNullable);
|
|
2233
2448
|
break;
|
|
2234
2449
|
case "text":
|
|
2235
2450
|
case "error-text":
|
|
2236
2451
|
contentValue = output.value;
|
|
2237
2452
|
break;
|
|
2238
2453
|
case "execution-denied":
|
|
2239
|
-
contentValue = (
|
|
2454
|
+
contentValue = (_f = output.reason) != null ? _f : "Tool call execution denied.";
|
|
2240
2455
|
break;
|
|
2241
2456
|
case "json":
|
|
2242
2457
|
case "error-json":
|
|
@@ -2273,16 +2488,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2273
2488
|
for (let k = 0; k < content.length; k++) {
|
|
2274
2489
|
const part = content[k];
|
|
2275
2490
|
const isLastContentPart = k === content.length - 1;
|
|
2276
|
-
const cacheControl = (
|
|
2491
|
+
const cacheControl = (_g = validator.getCacheControl(part.providerOptions, {
|
|
2277
2492
|
type: "assistant message part",
|
|
2278
2493
|
canCache: true
|
|
2279
|
-
})) != null ?
|
|
2494
|
+
})) != null ? _g : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
|
|
2280
2495
|
type: "assistant message",
|
|
2281
2496
|
canCache: true
|
|
2282
2497
|
}) : void 0;
|
|
2283
2498
|
switch (part.type) {
|
|
2284
2499
|
case "text": {
|
|
2285
|
-
const textMetadata = (
|
|
2500
|
+
const textMetadata = (_h = part.providerOptions) == null ? void 0 : _h.anthropic;
|
|
2286
2501
|
if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
|
|
2287
2502
|
anthropicContent.push({
|
|
2288
2503
|
type: "compaction",
|
|
@@ -2305,7 +2520,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2305
2520
|
}
|
|
2306
2521
|
case "reasoning": {
|
|
2307
2522
|
if (sendReasoning) {
|
|
2308
|
-
const reasoningMetadata = await
|
|
2523
|
+
const reasoningMetadata = await parseProviderOptions({
|
|
2309
2524
|
provider: "anthropic",
|
|
2310
2525
|
providerOptions: part.providerOptions,
|
|
2311
2526
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -2355,10 +2570,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2355
2570
|
const providerToolName = toolNameMapping.toProviderToolName(
|
|
2356
2571
|
part.toolName
|
|
2357
2572
|
);
|
|
2358
|
-
const isMcpToolUse = ((
|
|
2573
|
+
const isMcpToolUse = ((_j = (_i = part.providerOptions) == null ? void 0 : _i.anthropic) == null ? void 0 : _j.type) === "mcp-tool-use";
|
|
2359
2574
|
if (isMcpToolUse) {
|
|
2360
2575
|
mcpToolUseIds.add(part.toolCallId);
|
|
2361
|
-
const serverName = (
|
|
2576
|
+
const serverName = (_l = (_k = part.providerOptions) == null ? void 0 : _k.anthropic) == null ? void 0 : _l.serverName;
|
|
2362
2577
|
if (serverName == null || typeof serverName !== "string") {
|
|
2363
2578
|
warnings.push({
|
|
2364
2579
|
type: "other",
|
|
@@ -2426,7 +2641,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2426
2641
|
}
|
|
2427
2642
|
break;
|
|
2428
2643
|
}
|
|
2429
|
-
const callerOptions = (
|
|
2644
|
+
const callerOptions = (_m = part.providerOptions) == null ? void 0 : _m.anthropic;
|
|
2430
2645
|
const caller = (callerOptions == null ? void 0 : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
|
|
2431
2646
|
type: callerOptions.caller.type,
|
|
2432
2647
|
tool_id: callerOptions.caller.toolId
|
|
@@ -2479,7 +2694,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2479
2694
|
tool_use_id: part.toolCallId,
|
|
2480
2695
|
content: {
|
|
2481
2696
|
type: "code_execution_tool_result_error",
|
|
2482
|
-
error_code: (
|
|
2697
|
+
error_code: (_n = errorInfo.errorCode) != null ? _n : "unknown"
|
|
2483
2698
|
},
|
|
2484
2699
|
cache_control: cacheControl
|
|
2485
2700
|
});
|
|
@@ -2490,7 +2705,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2490
2705
|
cache_control: cacheControl,
|
|
2491
2706
|
content: {
|
|
2492
2707
|
type: "bash_code_execution_tool_result_error",
|
|
2493
|
-
error_code: (
|
|
2708
|
+
error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
|
|
2494
2709
|
}
|
|
2495
2710
|
});
|
|
2496
2711
|
}
|
|
@@ -2511,7 +2726,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2511
2726
|
break;
|
|
2512
2727
|
}
|
|
2513
2728
|
if (output.value.type === "code_execution_result") {
|
|
2514
|
-
const codeExecutionOutput = await (
|
|
2729
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2515
2730
|
value: output.value,
|
|
2516
2731
|
schema: codeExecution_20250522OutputSchema
|
|
2517
2732
|
});
|
|
@@ -2523,12 +2738,12 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2523
2738
|
stdout: codeExecutionOutput.stdout,
|
|
2524
2739
|
stderr: codeExecutionOutput.stderr,
|
|
2525
2740
|
return_code: codeExecutionOutput.return_code,
|
|
2526
|
-
content: (
|
|
2741
|
+
content: (_p = codeExecutionOutput.content) != null ? _p : []
|
|
2527
2742
|
},
|
|
2528
2743
|
cache_control: cacheControl
|
|
2529
2744
|
});
|
|
2530
2745
|
} else if (output.value.type === "encrypted_code_execution_result") {
|
|
2531
|
-
const codeExecutionOutput = await (
|
|
2746
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2532
2747
|
value: output.value,
|
|
2533
2748
|
schema: codeExecution_20260120OutputSchema
|
|
2534
2749
|
});
|
|
@@ -2541,13 +2756,13 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2541
2756
|
encrypted_stdout: codeExecutionOutput.encrypted_stdout,
|
|
2542
2757
|
stderr: codeExecutionOutput.stderr,
|
|
2543
2758
|
return_code: codeExecutionOutput.return_code,
|
|
2544
|
-
content: (
|
|
2759
|
+
content: (_q = codeExecutionOutput.content) != null ? _q : []
|
|
2545
2760
|
},
|
|
2546
2761
|
cache_control: cacheControl
|
|
2547
2762
|
});
|
|
2548
2763
|
}
|
|
2549
2764
|
} else {
|
|
2550
|
-
const codeExecutionOutput = await (
|
|
2765
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2551
2766
|
value: output.value,
|
|
2552
2767
|
schema: codeExecution_20250825OutputSchema
|
|
2553
2768
|
});
|
|
@@ -2560,7 +2775,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2560
2775
|
stdout: codeExecutionOutput.stdout,
|
|
2561
2776
|
stderr: codeExecutionOutput.stderr,
|
|
2562
2777
|
return_code: codeExecutionOutput.return_code,
|
|
2563
|
-
content: (
|
|
2778
|
+
content: (_r = codeExecutionOutput.content) != null ? _r : []
|
|
2564
2779
|
},
|
|
2565
2780
|
cache_control: cacheControl
|
|
2566
2781
|
});
|
|
@@ -2593,7 +2808,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2593
2808
|
errorValue = output.value;
|
|
2594
2809
|
}
|
|
2595
2810
|
} catch (e) {
|
|
2596
|
-
const extractedErrorCode = (
|
|
2811
|
+
const extractedErrorCode = (_s = output.value) == null ? void 0 : _s.errorCode;
|
|
2597
2812
|
errorValue = {
|
|
2598
2813
|
errorCode: typeof extractedErrorCode === "string" ? extractedErrorCode : "unavailable"
|
|
2599
2814
|
};
|
|
@@ -2603,7 +2818,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2603
2818
|
tool_use_id: part.toolCallId,
|
|
2604
2819
|
content: {
|
|
2605
2820
|
type: "web_fetch_tool_result_error",
|
|
2606
|
-
error_code: (
|
|
2821
|
+
error_code: (_t = errorValue.errorCode) != null ? _t : "unavailable"
|
|
2607
2822
|
},
|
|
2608
2823
|
cache_control: cacheControl
|
|
2609
2824
|
});
|
|
@@ -2616,7 +2831,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2616
2831
|
});
|
|
2617
2832
|
break;
|
|
2618
2833
|
}
|
|
2619
|
-
const webFetchOutput = await (
|
|
2834
|
+
const webFetchOutput = await validateTypes2({
|
|
2620
2835
|
value: output.value,
|
|
2621
2836
|
schema: webFetch_20250910OutputSchema
|
|
2622
2837
|
});
|
|
@@ -2651,7 +2866,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2651
2866
|
});
|
|
2652
2867
|
break;
|
|
2653
2868
|
}
|
|
2654
|
-
const webSearchOutput = await (
|
|
2869
|
+
const webSearchOutput = await validateTypes2({
|
|
2655
2870
|
value: output.value,
|
|
2656
2871
|
schema: webSearch_20250305OutputSchema
|
|
2657
2872
|
});
|
|
@@ -2678,7 +2893,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2678
2893
|
});
|
|
2679
2894
|
break;
|
|
2680
2895
|
}
|
|
2681
|
-
const toolSearchOutput = await (
|
|
2896
|
+
const toolSearchOutput = await validateTypes2({
|
|
2682
2897
|
value: output.value,
|
|
2683
2898
|
schema: toolSearchRegex_20251119OutputSchema
|
|
2684
2899
|
});
|
|
@@ -2791,7 +3006,153 @@ function mapAnthropicStopReason({
|
|
|
2791
3006
|
}
|
|
2792
3007
|
}
|
|
2793
3008
|
|
|
2794
|
-
// src/
|
|
3009
|
+
// src/sanitize-json-schema.ts
|
|
3010
|
+
var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
|
|
3011
|
+
"date-time",
|
|
3012
|
+
"time",
|
|
3013
|
+
"date",
|
|
3014
|
+
"duration",
|
|
3015
|
+
"email",
|
|
3016
|
+
"hostname",
|
|
3017
|
+
"uri",
|
|
3018
|
+
"ipv4",
|
|
3019
|
+
"ipv6",
|
|
3020
|
+
"uuid"
|
|
3021
|
+
]);
|
|
3022
|
+
var DESCRIPTION_CONSTRAINT_KEYS = [
|
|
3023
|
+
"minimum",
|
|
3024
|
+
"maximum",
|
|
3025
|
+
"exclusiveMinimum",
|
|
3026
|
+
"exclusiveMaximum",
|
|
3027
|
+
"multipleOf",
|
|
3028
|
+
"minLength",
|
|
3029
|
+
"maxLength",
|
|
3030
|
+
"pattern",
|
|
3031
|
+
"minItems",
|
|
3032
|
+
"maxItems",
|
|
3033
|
+
"uniqueItems",
|
|
3034
|
+
"minProperties",
|
|
3035
|
+
"maxProperties",
|
|
3036
|
+
"not"
|
|
3037
|
+
];
|
|
3038
|
+
function sanitizeJsonSchema(schema) {
|
|
3039
|
+
return sanitizeSchema(schema);
|
|
3040
|
+
}
|
|
3041
|
+
function sanitizeDefinition(definition) {
|
|
3042
|
+
if (typeof definition === "boolean" || !isPlainObject(definition)) {
|
|
3043
|
+
return definition;
|
|
3044
|
+
}
|
|
3045
|
+
return sanitizeSchema(definition);
|
|
3046
|
+
}
|
|
3047
|
+
function sanitizeSchema(schema) {
|
|
3048
|
+
const result = {};
|
|
3049
|
+
const schemaWithDefs = schema;
|
|
3050
|
+
if (schema.$ref != null) {
|
|
3051
|
+
return { $ref: schema.$ref };
|
|
3052
|
+
}
|
|
3053
|
+
if (schema.$schema != null) {
|
|
3054
|
+
result.$schema = schema.$schema;
|
|
3055
|
+
}
|
|
3056
|
+
if (schema.$id != null) {
|
|
3057
|
+
result.$id = schema.$id;
|
|
3058
|
+
}
|
|
3059
|
+
if (schema.title != null) {
|
|
3060
|
+
result.title = schema.title;
|
|
3061
|
+
}
|
|
3062
|
+
if (schema.description != null) {
|
|
3063
|
+
result.description = schema.description;
|
|
3064
|
+
}
|
|
3065
|
+
if (schema.default !== void 0) {
|
|
3066
|
+
result.default = schema.default;
|
|
3067
|
+
}
|
|
3068
|
+
if (schema.const !== void 0) {
|
|
3069
|
+
result.const = schema.const;
|
|
3070
|
+
}
|
|
3071
|
+
if (schema.enum != null) {
|
|
3072
|
+
result.enum = schema.enum;
|
|
3073
|
+
}
|
|
3074
|
+
if (schema.type != null) {
|
|
3075
|
+
result.type = schema.type;
|
|
3076
|
+
}
|
|
3077
|
+
if (schema.anyOf != null) {
|
|
3078
|
+
result.anyOf = schema.anyOf.map(sanitizeDefinition);
|
|
3079
|
+
} else if (schema.oneOf != null) {
|
|
3080
|
+
result.anyOf = schema.oneOf.map(sanitizeDefinition);
|
|
3081
|
+
}
|
|
3082
|
+
if (schema.allOf != null) {
|
|
3083
|
+
result.allOf = schema.allOf.map(sanitizeDefinition);
|
|
3084
|
+
}
|
|
3085
|
+
if (schema.definitions != null) {
|
|
3086
|
+
result.definitions = Object.fromEntries(
|
|
3087
|
+
Object.entries(schema.definitions).map(([name, definition]) => [
|
|
3088
|
+
name,
|
|
3089
|
+
sanitizeDefinition(definition)
|
|
3090
|
+
])
|
|
3091
|
+
);
|
|
3092
|
+
}
|
|
3093
|
+
if (schemaWithDefs.$defs != null) {
|
|
3094
|
+
const resultWithDefs = result;
|
|
3095
|
+
resultWithDefs.$defs = Object.fromEntries(
|
|
3096
|
+
Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
|
|
3097
|
+
name,
|
|
3098
|
+
sanitizeDefinition(definition)
|
|
3099
|
+
])
|
|
3100
|
+
);
|
|
3101
|
+
}
|
|
3102
|
+
if (schema.type === "object" || schema.properties != null) {
|
|
3103
|
+
if (schema.properties != null) {
|
|
3104
|
+
result.properties = Object.fromEntries(
|
|
3105
|
+
Object.entries(schema.properties).map(([name, definition]) => [
|
|
3106
|
+
name,
|
|
3107
|
+
sanitizeDefinition(definition)
|
|
3108
|
+
])
|
|
3109
|
+
);
|
|
3110
|
+
}
|
|
3111
|
+
result.additionalProperties = false;
|
|
3112
|
+
if (schema.required != null) {
|
|
3113
|
+
result.required = schema.required;
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
if (schema.items != null) {
|
|
3117
|
+
result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
|
|
3118
|
+
}
|
|
3119
|
+
if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
|
|
3120
|
+
result.format = schema.format;
|
|
3121
|
+
}
|
|
3122
|
+
const constraintDescription = getConstraintDescription(schema);
|
|
3123
|
+
if (constraintDescription != null) {
|
|
3124
|
+
result.description = result.description == null ? constraintDescription : `${result.description}
|
|
3125
|
+
${constraintDescription}`;
|
|
3126
|
+
}
|
|
3127
|
+
return result;
|
|
3128
|
+
}
|
|
3129
|
+
function getConstraintDescription(schema) {
|
|
3130
|
+
const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
|
|
3131
|
+
const value = schema[key];
|
|
3132
|
+
if (value == null || value === false) {
|
|
3133
|
+
return [];
|
|
3134
|
+
}
|
|
3135
|
+
return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
|
|
3136
|
+
});
|
|
3137
|
+
if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
|
|
3138
|
+
descriptions.push(`format: ${schema.format}`);
|
|
3139
|
+
}
|
|
3140
|
+
return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
|
|
3141
|
+
}
|
|
3142
|
+
function formatConstraintName(key) {
|
|
3143
|
+
return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
|
|
3144
|
+
}
|
|
3145
|
+
function formatConstraintValue(value) {
|
|
3146
|
+
if (typeof value === "string") {
|
|
3147
|
+
return value;
|
|
3148
|
+
}
|
|
3149
|
+
return JSON.stringify(value);
|
|
3150
|
+
}
|
|
3151
|
+
function isPlainObject(value) {
|
|
3152
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
// src/anthropic-language-model.ts
|
|
2795
3156
|
function createCitationSource(citation, citationDocuments, generateId3) {
|
|
2796
3157
|
var _a;
|
|
2797
3158
|
if (citation.type === "web_search_result_location") {
|
|
@@ -2836,13 +3197,22 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
2836
3197
|
}
|
|
2837
3198
|
};
|
|
2838
3199
|
}
|
|
2839
|
-
var
|
|
3200
|
+
var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
2840
3201
|
constructor(modelId, config) {
|
|
2841
3202
|
this.specificationVersion = "v4";
|
|
2842
3203
|
var _a;
|
|
2843
3204
|
this.modelId = modelId;
|
|
2844
3205
|
this.config = config;
|
|
2845
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
3206
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
3207
|
+
}
|
|
3208
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
3209
|
+
return serializeModelOptions({
|
|
3210
|
+
modelId: model.modelId,
|
|
3211
|
+
config: model.config
|
|
3212
|
+
});
|
|
3213
|
+
}
|
|
3214
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
3215
|
+
return new _AnthropicLanguageModel(options.modelId, options.config);
|
|
2846
3216
|
}
|
|
2847
3217
|
supportsUrl(url) {
|
|
2848
3218
|
return url.protocol === "https:";
|
|
@@ -2877,10 +3247,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2877
3247
|
seed,
|
|
2878
3248
|
tools,
|
|
2879
3249
|
toolChoice,
|
|
3250
|
+
reasoning,
|
|
2880
3251
|
providerOptions,
|
|
2881
3252
|
stream
|
|
2882
3253
|
}) {
|
|
2883
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3254
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2884
3255
|
const warnings = [];
|
|
2885
3256
|
if (frequencyPenalty != null) {
|
|
2886
3257
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2916,12 +3287,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2916
3287
|
}
|
|
2917
3288
|
}
|
|
2918
3289
|
const providerOptionsName = this.providerOptionsName;
|
|
2919
|
-
const canonicalOptions = await (
|
|
3290
|
+
const canonicalOptions = await parseProviderOptions2({
|
|
2920
3291
|
provider: "anthropic",
|
|
2921
3292
|
providerOptions,
|
|
2922
3293
|
schema: anthropicLanguageModelOptions
|
|
2923
3294
|
});
|
|
2924
|
-
const customProviderOptions = providerOptionsName !== "anthropic" ? await (
|
|
3295
|
+
const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
|
|
2925
3296
|
provider: providerOptionsName,
|
|
2926
3297
|
providerOptions,
|
|
2927
3298
|
schema: anthropicLanguageModelOptions
|
|
@@ -2935,8 +3306,38 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2935
3306
|
const {
|
|
2936
3307
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2937
3308
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
3309
|
+
supportsAdaptiveThinking,
|
|
3310
|
+
rejectsSamplingParameters,
|
|
3311
|
+
supportsXhighEffort,
|
|
2938
3312
|
isKnownModel
|
|
2939
3313
|
} = getModelCapabilities(this.modelId);
|
|
3314
|
+
if (rejectsSamplingParameters) {
|
|
3315
|
+
if (temperature != null) {
|
|
3316
|
+
warnings.push({
|
|
3317
|
+
type: "unsupported",
|
|
3318
|
+
feature: "temperature",
|
|
3319
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
3320
|
+
});
|
|
3321
|
+
temperature = void 0;
|
|
3322
|
+
}
|
|
3323
|
+
if (topK != null) {
|
|
3324
|
+
warnings.push({
|
|
3325
|
+
type: "unsupported",
|
|
3326
|
+
feature: "topK",
|
|
3327
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
3328
|
+
});
|
|
3329
|
+
topK = void 0;
|
|
3330
|
+
}
|
|
3331
|
+
if (topP != null) {
|
|
3332
|
+
warnings.push({
|
|
3333
|
+
type: "unsupported",
|
|
3334
|
+
feature: "topP",
|
|
3335
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
3336
|
+
});
|
|
3337
|
+
topP = void 0;
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2940
3341
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2941
3342
|
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2942
3343
|
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
@@ -2949,7 +3350,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2949
3350
|
} : void 0;
|
|
2950
3351
|
const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
|
|
2951
3352
|
const cacheControlValidator = new CacheControlValidator();
|
|
2952
|
-
const toolNameMapping =
|
|
3353
|
+
const toolNameMapping = createToolNameMapping({
|
|
2953
3354
|
tools,
|
|
2954
3355
|
providerToolNames: {
|
|
2955
3356
|
"anthropic.code_execution_20250522": "code_execution",
|
|
@@ -2972,16 +3373,34 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2972
3373
|
"anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
|
|
2973
3374
|
}
|
|
2974
3375
|
});
|
|
2975
|
-
const { prompt: messagesPrompt, betas } = await
|
|
3376
|
+
const { prompt: messagesPrompt, betas } = await convertToAnthropicPrompt({
|
|
2976
3377
|
prompt,
|
|
2977
3378
|
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
2978
3379
|
warnings,
|
|
2979
3380
|
cacheControlValidator,
|
|
2980
3381
|
toolNameMapping
|
|
2981
3382
|
});
|
|
2982
|
-
|
|
3383
|
+
if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
|
|
3384
|
+
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
3385
|
+
reasoning,
|
|
3386
|
+
supportsAdaptiveThinking,
|
|
3387
|
+
supportsXhighEffort,
|
|
3388
|
+
maxOutputTokensForModel,
|
|
3389
|
+
warnings
|
|
3390
|
+
});
|
|
3391
|
+
if (reasoningConfig != null) {
|
|
3392
|
+
if (anthropicOptions.thinking == null) {
|
|
3393
|
+
anthropicOptions.thinking = reasoningConfig.thinking;
|
|
3394
|
+
}
|
|
3395
|
+
if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
|
|
3396
|
+
anthropicOptions.effort = reasoningConfig.effort;
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
|
|
2983
3401
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2984
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
3402
|
+
let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
|
|
3403
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
|
|
2985
3404
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2986
3405
|
const baseArgs = {
|
|
2987
3406
|
// model id:
|
|
@@ -2996,18 +3415,28 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2996
3415
|
...isThinking && {
|
|
2997
3416
|
thinking: {
|
|
2998
3417
|
type: thinkingType,
|
|
2999
|
-
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
3418
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
3419
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
3000
3420
|
}
|
|
3001
3421
|
},
|
|
3002
|
-
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
3422
|
+
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
3003
3423
|
output_config: {
|
|
3004
3424
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
3005
3425
|
effort: anthropicOptions.effort
|
|
3006
3426
|
},
|
|
3427
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
|
|
3428
|
+
task_budget: {
|
|
3429
|
+
type: anthropicOptions.taskBudget.type,
|
|
3430
|
+
total: anthropicOptions.taskBudget.total,
|
|
3431
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
3432
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
},
|
|
3007
3436
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
3008
3437
|
format: {
|
|
3009
3438
|
type: "json_schema",
|
|
3010
|
-
schema: responseFormat.schema
|
|
3439
|
+
schema: sanitizeJsonSchema(responseFormat.schema)
|
|
3011
3440
|
}
|
|
3012
3441
|
}
|
|
3013
3442
|
}
|
|
@@ -3015,9 +3444,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3015
3444
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
3016
3445
|
speed: anthropicOptions.speed
|
|
3017
3446
|
},
|
|
3447
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
|
|
3448
|
+
inference_geo: anthropicOptions.inferenceGeo
|
|
3449
|
+
},
|
|
3018
3450
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3019
3451
|
cache_control: anthropicOptions.cacheControl
|
|
3020
3452
|
},
|
|
3453
|
+
...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
|
|
3454
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3455
|
+
},
|
|
3021
3456
|
// mcp servers:
|
|
3022
3457
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3023
3458
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3039,7 +3474,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3039
3474
|
id: anthropicOptions.container.id,
|
|
3040
3475
|
skills: anthropicOptions.container.skills.map((skill) => ({
|
|
3041
3476
|
type: skill.type,
|
|
3042
|
-
skill_id: skill.
|
|
3477
|
+
skill_id: skill.type === "custom" ? resolveProviderReference2({
|
|
3478
|
+
reference: skill.providerReference,
|
|
3479
|
+
provider: "anthropic"
|
|
3480
|
+
}) : skill.skillId,
|
|
3043
3481
|
version: skill.version
|
|
3044
3482
|
}))
|
|
3045
3483
|
}
|
|
@@ -3141,7 +3579,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3141
3579
|
}
|
|
3142
3580
|
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
3143
3581
|
} else {
|
|
3144
|
-
if (topP != null && temperature != null) {
|
|
3582
|
+
if (isAnthropicModel && topP != null && temperature != null) {
|
|
3145
3583
|
warnings.push({
|
|
3146
3584
|
type: "unsupported",
|
|
3147
3585
|
feature: "topP",
|
|
@@ -3185,12 +3623,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3185
3623
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
3186
3624
|
betas.add("effort-2025-11-24");
|
|
3187
3625
|
}
|
|
3626
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
3627
|
+
betas.add("task-budgets-2026-03-13");
|
|
3628
|
+
}
|
|
3188
3629
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3189
3630
|
betas.add("fast-mode-2026-02-01");
|
|
3190
3631
|
}
|
|
3191
|
-
|
|
3192
|
-
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3193
|
-
}
|
|
3632
|
+
const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
|
|
3194
3633
|
const {
|
|
3195
3634
|
tools: anthropicTools2,
|
|
3196
3635
|
toolChoice: anthropicToolChoice,
|
|
@@ -3203,14 +3642,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3203
3642
|
disableParallelToolUse: true,
|
|
3204
3643
|
cacheControlValidator,
|
|
3205
3644
|
supportsStructuredOutput: false,
|
|
3206
|
-
supportsStrictTools
|
|
3645
|
+
supportsStrictTools,
|
|
3646
|
+
defaultEagerInputStreaming
|
|
3207
3647
|
} : {
|
|
3208
3648
|
tools: tools != null ? tools : [],
|
|
3209
3649
|
toolChoice,
|
|
3210
3650
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3211
3651
|
cacheControlValidator,
|
|
3212
3652
|
supportsStructuredOutput,
|
|
3213
|
-
supportsStrictTools
|
|
3653
|
+
supportsStrictTools,
|
|
3654
|
+
defaultEagerInputStreaming
|
|
3214
3655
|
}
|
|
3215
3656
|
);
|
|
3216
3657
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3227,7 +3668,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3227
3668
|
...betas,
|
|
3228
3669
|
...toolsBetas,
|
|
3229
3670
|
...userSuppliedBetas,
|
|
3230
|
-
...(
|
|
3671
|
+
...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
|
|
3231
3672
|
]),
|
|
3232
3673
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3233
3674
|
toolNameMapping,
|
|
@@ -3239,16 +3680,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3239
3680
|
betas,
|
|
3240
3681
|
headers
|
|
3241
3682
|
}) {
|
|
3242
|
-
return (
|
|
3243
|
-
await
|
|
3683
|
+
return combineHeaders2(
|
|
3684
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
3244
3685
|
headers,
|
|
3245
3686
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
3246
3687
|
);
|
|
3247
3688
|
}
|
|
3248
3689
|
async getBetasFromHeaders(requestHeaders) {
|
|
3249
3690
|
var _a, _b;
|
|
3250
|
-
const configHeaders = await
|
|
3251
|
-
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3691
|
+
const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
|
|
3692
|
+
const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3252
3693
|
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
3253
3694
|
return new Set(
|
|
3254
3695
|
[
|
|
@@ -3313,13 +3754,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3313
3754
|
responseHeaders,
|
|
3314
3755
|
value: response,
|
|
3315
3756
|
rawValue: rawResponse
|
|
3316
|
-
} = await
|
|
3757
|
+
} = await postJsonToApi({
|
|
3317
3758
|
url: this.buildRequestUrl(false),
|
|
3318
3759
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3319
3760
|
body: this.transformRequestBody(args, betas),
|
|
3320
3761
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3321
|
-
successfulResponseHandler: (
|
|
3322
|
-
|
|
3762
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
3763
|
+
anthropicResponseSchema
|
|
3323
3764
|
),
|
|
3324
3765
|
abortSignal: options.abortSignal,
|
|
3325
3766
|
fetch: this.config.fetch
|
|
@@ -3668,7 +4109,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3668
4109
|
}),
|
|
3669
4110
|
raw: (_e = response.stop_reason) != null ? _e : void 0
|
|
3670
4111
|
},
|
|
3671
|
-
usage:
|
|
4112
|
+
usage: convertAnthropicUsage({ usage: response.usage }),
|
|
3672
4113
|
request: { body: args },
|
|
3673
4114
|
response: {
|
|
3674
4115
|
id: (_f = response.id) != null ? _f : void 0,
|
|
@@ -3678,11 +4119,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3678
4119
|
},
|
|
3679
4120
|
warnings,
|
|
3680
4121
|
providerMetadata: (() => {
|
|
3681
|
-
var _a2, _b2, _c2, _d2
|
|
4122
|
+
var _a2, _b2, _c2, _d2;
|
|
3682
4123
|
const anthropicMetadata = {
|
|
3683
4124
|
usage: response.usage,
|
|
3684
|
-
|
|
3685
|
-
stopSequence: (_b2 = response.stop_sequence) != null ? _b2 : null,
|
|
4125
|
+
stopSequence: (_a2 = response.stop_sequence) != null ? _a2 : null,
|
|
3686
4126
|
iterations: response.usage.iterations ? response.usage.iterations.map((iter) => ({
|
|
3687
4127
|
type: iter.type,
|
|
3688
4128
|
inputTokens: iter.input_tokens,
|
|
@@ -3691,15 +4131,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3691
4131
|
container: response.container ? {
|
|
3692
4132
|
expiresAt: response.container.expires_at,
|
|
3693
4133
|
id: response.container.id,
|
|
3694
|
-
skills: (
|
|
4134
|
+
skills: (_c2 = (_b2 = response.container.skills) == null ? void 0 : _b2.map((skill) => ({
|
|
3695
4135
|
type: skill.type,
|
|
3696
4136
|
skillId: skill.skill_id,
|
|
3697
4137
|
version: skill.version
|
|
3698
|
-
}))) != null ?
|
|
4138
|
+
}))) != null ? _c2 : null
|
|
3699
4139
|
} : null,
|
|
3700
|
-
contextManagement: (
|
|
4140
|
+
contextManagement: (_d2 = mapAnthropicResponseContextManagement(
|
|
3701
4141
|
response.context_management
|
|
3702
|
-
)) != null ?
|
|
4142
|
+
)) != null ? _d2 : null
|
|
3703
4143
|
};
|
|
3704
4144
|
const providerMetadata = {
|
|
3705
4145
|
anthropic: anthropicMetadata
|
|
@@ -3712,6 +4152,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3712
4152
|
};
|
|
3713
4153
|
}
|
|
3714
4154
|
async doStream(options) {
|
|
4155
|
+
"use step";
|
|
3715
4156
|
var _a, _b;
|
|
3716
4157
|
const {
|
|
3717
4158
|
args: body,
|
|
@@ -3733,14 +4174,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3733
4174
|
body.tools
|
|
3734
4175
|
);
|
|
3735
4176
|
const url = this.buildRequestUrl(true);
|
|
3736
|
-
const { responseHeaders, value: response } = await
|
|
4177
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
3737
4178
|
url,
|
|
3738
4179
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3739
4180
|
body: this.transformRequestBody(body, betas),
|
|
3740
4181
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3741
|
-
successfulResponseHandler: (
|
|
3742
|
-
anthropicMessagesChunkSchema
|
|
3743
|
-
),
|
|
4182
|
+
successfulResponseHandler: createEventSourceResponseHandler(anthropicChunkSchema),
|
|
3744
4183
|
abortSignal: options.abortSignal,
|
|
3745
4184
|
fetch: this.config.fetch
|
|
3746
4185
|
});
|
|
@@ -3760,7 +4199,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3760
4199
|
const serverToolCalls = {};
|
|
3761
4200
|
let contextManagement = null;
|
|
3762
4201
|
let rawUsage = void 0;
|
|
3763
|
-
let cacheCreationInputTokens = null;
|
|
3764
4202
|
let stopSequence = null;
|
|
3765
4203
|
let container = null;
|
|
3766
4204
|
let isJsonResponseFromTool = false;
|
|
@@ -3772,7 +4210,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3772
4210
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3773
4211
|
},
|
|
3774
4212
|
transform(chunk, controller) {
|
|
3775
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
4213
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
3776
4214
|
if (options.includeRawChunks) {
|
|
3777
4215
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3778
4216
|
}
|
|
@@ -4307,7 +4745,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4307
4745
|
rawUsage = {
|
|
4308
4746
|
...value.message.usage
|
|
4309
4747
|
};
|
|
4310
|
-
cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
|
|
4311
4748
|
if (value.message.container != null) {
|
|
4312
4749
|
container = {
|
|
4313
4750
|
expiresAt: value.message.container.expires_at,
|
|
@@ -4326,8 +4763,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4326
4763
|
}
|
|
4327
4764
|
controller.enqueue({
|
|
4328
4765
|
type: "response-metadata",
|
|
4329
|
-
id: (
|
|
4330
|
-
modelId: (
|
|
4766
|
+
id: (_g = value.message.id) != null ? _g : void 0,
|
|
4767
|
+
modelId: (_h = value.message.model) != null ? _h : void 0
|
|
4331
4768
|
});
|
|
4332
4769
|
if (value.message.content != null) {
|
|
4333
4770
|
for (let contentIndex = 0; contentIndex < value.message.content.length; contentIndex++) {
|
|
@@ -4343,7 +4780,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4343
4780
|
id: part.id,
|
|
4344
4781
|
toolName: part.name
|
|
4345
4782
|
});
|
|
4346
|
-
const inputStr = JSON.stringify((
|
|
4783
|
+
const inputStr = JSON.stringify((_i = part.input) != null ? _i : {});
|
|
4347
4784
|
controller.enqueue({
|
|
4348
4785
|
type: "tool-input-delta",
|
|
4349
4786
|
id: part.id,
|
|
@@ -4381,7 +4818,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4381
4818
|
}
|
|
4382
4819
|
if (value.usage.cache_creation_input_tokens != null) {
|
|
4383
4820
|
usage.cache_creation_input_tokens = value.usage.cache_creation_input_tokens;
|
|
4384
|
-
cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
|
|
4385
4821
|
}
|
|
4386
4822
|
if (value.usage.iterations != null) {
|
|
4387
4823
|
usage.iterations = value.usage.iterations;
|
|
@@ -4391,17 +4827,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4391
4827
|
finishReason: value.delta.stop_reason,
|
|
4392
4828
|
isJsonResponseFromTool
|
|
4393
4829
|
}),
|
|
4394
|
-
raw: (
|
|
4830
|
+
raw: (_j = value.delta.stop_reason) != null ? _j : void 0
|
|
4395
4831
|
};
|
|
4396
|
-
stopSequence = (
|
|
4832
|
+
stopSequence = (_k = value.delta.stop_sequence) != null ? _k : null;
|
|
4397
4833
|
container = value.delta.container != null ? {
|
|
4398
4834
|
expiresAt: value.delta.container.expires_at,
|
|
4399
4835
|
id: value.delta.container.id,
|
|
4400
|
-
skills: (
|
|
4836
|
+
skills: (_m = (_l = value.delta.container.skills) == null ? void 0 : _l.map((skill) => ({
|
|
4401
4837
|
type: skill.type,
|
|
4402
4838
|
skillId: skill.skill_id,
|
|
4403
4839
|
version: skill.version
|
|
4404
|
-
}))) != null ?
|
|
4840
|
+
}))) != null ? _m : null
|
|
4405
4841
|
} : null;
|
|
4406
4842
|
if (value.context_management) {
|
|
4407
4843
|
contextManagement = mapAnthropicResponseContextManagement(
|
|
@@ -4417,7 +4853,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4417
4853
|
case "message_stop": {
|
|
4418
4854
|
const anthropicMetadata = {
|
|
4419
4855
|
usage: rawUsage != null ? rawUsage : null,
|
|
4420
|
-
cacheCreationInputTokens,
|
|
4421
4856
|
stopSequence,
|
|
4422
4857
|
iterations: usage.iterations ? usage.iterations.map((iter) => ({
|
|
4423
4858
|
type: iter.type,
|
|
@@ -4436,7 +4871,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4436
4871
|
controller.enqueue({
|
|
4437
4872
|
type: "finish",
|
|
4438
4873
|
finishReason,
|
|
4439
|
-
usage:
|
|
4874
|
+
usage: convertAnthropicUsage({ usage, rawUsage }),
|
|
4440
4875
|
providerMetadata
|
|
4441
4876
|
});
|
|
4442
4877
|
return;
|
|
@@ -4463,7 +4898,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4463
4898
|
}
|
|
4464
4899
|
if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
|
|
4465
4900
|
const error = result.value.error;
|
|
4466
|
-
throw new
|
|
4901
|
+
throw new APICallError({
|
|
4467
4902
|
message: error.message,
|
|
4468
4903
|
url,
|
|
4469
4904
|
requestBodyValues: body,
|
|
@@ -4486,46 +4921,76 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4486
4921
|
}
|
|
4487
4922
|
};
|
|
4488
4923
|
function getModelCapabilities(modelId) {
|
|
4489
|
-
if (modelId.includes("claude-
|
|
4924
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
4490
4925
|
return {
|
|
4491
4926
|
maxOutputTokens: 128e3,
|
|
4492
4927
|
supportsStructuredOutput: true,
|
|
4928
|
+
supportsAdaptiveThinking: true,
|
|
4929
|
+
rejectsSamplingParameters: true,
|
|
4930
|
+
supportsXhighEffort: true,
|
|
4931
|
+
isKnownModel: true
|
|
4932
|
+
};
|
|
4933
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
4934
|
+
return {
|
|
4935
|
+
maxOutputTokens: 128e3,
|
|
4936
|
+
supportsStructuredOutput: true,
|
|
4937
|
+
supportsAdaptiveThinking: true,
|
|
4938
|
+
rejectsSamplingParameters: false,
|
|
4939
|
+
supportsXhighEffort: false,
|
|
4493
4940
|
isKnownModel: true
|
|
4494
4941
|
};
|
|
4495
4942
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
4496
4943
|
return {
|
|
4497
4944
|
maxOutputTokens: 64e3,
|
|
4498
4945
|
supportsStructuredOutput: true,
|
|
4946
|
+
supportsAdaptiveThinking: false,
|
|
4947
|
+
rejectsSamplingParameters: false,
|
|
4948
|
+
supportsXhighEffort: false,
|
|
4499
4949
|
isKnownModel: true
|
|
4500
4950
|
};
|
|
4501
4951
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
4502
4952
|
return {
|
|
4503
4953
|
maxOutputTokens: 32e3,
|
|
4504
4954
|
supportsStructuredOutput: true,
|
|
4955
|
+
supportsAdaptiveThinking: false,
|
|
4956
|
+
rejectsSamplingParameters: false,
|
|
4957
|
+
supportsXhighEffort: false,
|
|
4505
4958
|
isKnownModel: true
|
|
4506
4959
|
};
|
|
4507
4960
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
4508
4961
|
return {
|
|
4509
4962
|
maxOutputTokens: 64e3,
|
|
4510
4963
|
supportsStructuredOutput: false,
|
|
4964
|
+
supportsAdaptiveThinking: false,
|
|
4965
|
+
rejectsSamplingParameters: false,
|
|
4966
|
+
supportsXhighEffort: false,
|
|
4511
4967
|
isKnownModel: true
|
|
4512
4968
|
};
|
|
4513
4969
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
4514
4970
|
return {
|
|
4515
4971
|
maxOutputTokens: 32e3,
|
|
4516
4972
|
supportsStructuredOutput: false,
|
|
4973
|
+
supportsAdaptiveThinking: false,
|
|
4974
|
+
rejectsSamplingParameters: false,
|
|
4975
|
+
supportsXhighEffort: false,
|
|
4517
4976
|
isKnownModel: true
|
|
4518
4977
|
};
|
|
4519
4978
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
4520
4979
|
return {
|
|
4521
4980
|
maxOutputTokens: 4096,
|
|
4522
4981
|
supportsStructuredOutput: false,
|
|
4982
|
+
supportsAdaptiveThinking: false,
|
|
4983
|
+
rejectsSamplingParameters: false,
|
|
4984
|
+
supportsXhighEffort: false,
|
|
4523
4985
|
isKnownModel: true
|
|
4524
4986
|
};
|
|
4525
4987
|
} else {
|
|
4526
4988
|
return {
|
|
4527
4989
|
maxOutputTokens: 4096,
|
|
4528
4990
|
supportsStructuredOutput: false,
|
|
4991
|
+
supportsAdaptiveThinking: false,
|
|
4992
|
+
rejectsSamplingParameters: false,
|
|
4993
|
+
supportsXhighEffort: false,
|
|
4529
4994
|
isKnownModel: false
|
|
4530
4995
|
};
|
|
4531
4996
|
}
|
|
@@ -4548,6 +5013,44 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
4548
5013
|
}
|
|
4549
5014
|
return hasWebTool20260209 && !hasCodeExecutionTool;
|
|
4550
5015
|
}
|
|
5016
|
+
function resolveAnthropicReasoningConfig({
|
|
5017
|
+
reasoning,
|
|
5018
|
+
supportsAdaptiveThinking,
|
|
5019
|
+
supportsXhighEffort,
|
|
5020
|
+
maxOutputTokensForModel,
|
|
5021
|
+
warnings
|
|
5022
|
+
}) {
|
|
5023
|
+
if (!isCustomReasoning(reasoning)) {
|
|
5024
|
+
return void 0;
|
|
5025
|
+
}
|
|
5026
|
+
if (reasoning === "none") {
|
|
5027
|
+
return { thinking: { type: "disabled" } };
|
|
5028
|
+
}
|
|
5029
|
+
if (supportsAdaptiveThinking) {
|
|
5030
|
+
const effort = mapReasoningToProviderEffort({
|
|
5031
|
+
reasoning,
|
|
5032
|
+
effortMap: {
|
|
5033
|
+
minimal: "low",
|
|
5034
|
+
low: "low",
|
|
5035
|
+
medium: "medium",
|
|
5036
|
+
high: "high",
|
|
5037
|
+
xhigh: supportsXhighEffort ? "xhigh" : "max"
|
|
5038
|
+
},
|
|
5039
|
+
warnings
|
|
5040
|
+
});
|
|
5041
|
+
return { thinking: { type: "adaptive" }, effort };
|
|
5042
|
+
}
|
|
5043
|
+
const budgetTokens = mapReasoningToProviderBudget({
|
|
5044
|
+
reasoning,
|
|
5045
|
+
maxOutputTokens: maxOutputTokensForModel,
|
|
5046
|
+
maxReasoningBudget: maxOutputTokensForModel,
|
|
5047
|
+
warnings
|
|
5048
|
+
});
|
|
5049
|
+
if (budgetTokens == null) {
|
|
5050
|
+
return void 0;
|
|
5051
|
+
}
|
|
5052
|
+
return { thinking: { type: "enabled", budgetTokens } };
|
|
5053
|
+
}
|
|
4551
5054
|
function mapAnthropicResponseContextManagement(contextManagement) {
|
|
4552
5055
|
return contextManagement ? {
|
|
4553
5056
|
appliedEdits: contextManagement.applied_edits.map((edit) => {
|
|
@@ -4575,44 +5078,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
|
|
|
4575
5078
|
}
|
|
4576
5079
|
|
|
4577
5080
|
// src/tool/bash_20241022.ts
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
5081
|
+
import {
|
|
5082
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
|
|
5083
|
+
lazySchema as lazySchema13,
|
|
5084
|
+
zodSchema as zodSchema13
|
|
5085
|
+
} from "@ai-sdk/provider-utils";
|
|
5086
|
+
import { z as z14 } from "zod/v4";
|
|
5087
|
+
var bash_20241022InputSchema = lazySchema13(
|
|
5088
|
+
() => zodSchema13(
|
|
5089
|
+
z14.object({
|
|
5090
|
+
command: z14.string(),
|
|
5091
|
+
restart: z14.boolean().optional()
|
|
4585
5092
|
})
|
|
4586
5093
|
)
|
|
4587
5094
|
);
|
|
4588
|
-
var bash_20241022 = (
|
|
5095
|
+
var bash_20241022 = createProviderDefinedToolFactory2({
|
|
4589
5096
|
id: "anthropic.bash_20241022",
|
|
4590
5097
|
inputSchema: bash_20241022InputSchema
|
|
4591
5098
|
});
|
|
4592
5099
|
|
|
4593
5100
|
// src/tool/bash_20250124.ts
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
5101
|
+
import {
|
|
5102
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory3,
|
|
5103
|
+
lazySchema as lazySchema14,
|
|
5104
|
+
zodSchema as zodSchema14
|
|
5105
|
+
} from "@ai-sdk/provider-utils";
|
|
5106
|
+
import { z as z15 } from "zod/v4";
|
|
5107
|
+
var bash_20250124InputSchema = lazySchema14(
|
|
5108
|
+
() => zodSchema14(
|
|
5109
|
+
z15.object({
|
|
5110
|
+
command: z15.string(),
|
|
5111
|
+
restart: z15.boolean().optional()
|
|
4601
5112
|
})
|
|
4602
5113
|
)
|
|
4603
5114
|
);
|
|
4604
|
-
var bash_20250124 = (
|
|
5115
|
+
var bash_20250124 = createProviderDefinedToolFactory3({
|
|
4605
5116
|
id: "anthropic.bash_20250124",
|
|
4606
5117
|
inputSchema: bash_20250124InputSchema
|
|
4607
5118
|
});
|
|
4608
5119
|
|
|
4609
5120
|
// src/tool/computer_20241022.ts
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
5121
|
+
import {
|
|
5122
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
|
|
5123
|
+
lazySchema as lazySchema15,
|
|
5124
|
+
zodSchema as zodSchema15
|
|
5125
|
+
} from "@ai-sdk/provider-utils";
|
|
5126
|
+
import { z as z16 } from "zod/v4";
|
|
5127
|
+
var computer_20241022InputSchema = lazySchema15(
|
|
5128
|
+
() => zodSchema15(
|
|
5129
|
+
z16.object({
|
|
5130
|
+
action: z16.enum([
|
|
4616
5131
|
"key",
|
|
4617
5132
|
"type",
|
|
4618
5133
|
"mouse_move",
|
|
@@ -4624,23 +5139,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
|
4624
5139
|
"screenshot",
|
|
4625
5140
|
"cursor_position"
|
|
4626
5141
|
]),
|
|
4627
|
-
coordinate:
|
|
4628
|
-
text:
|
|
5142
|
+
coordinate: z16.array(z16.number().int()).optional(),
|
|
5143
|
+
text: z16.string().optional()
|
|
4629
5144
|
})
|
|
4630
5145
|
)
|
|
4631
5146
|
);
|
|
4632
|
-
var computer_20241022 = (
|
|
5147
|
+
var computer_20241022 = createProviderDefinedToolFactory4({
|
|
4633
5148
|
id: "anthropic.computer_20241022",
|
|
4634
5149
|
inputSchema: computer_20241022InputSchema
|
|
4635
5150
|
});
|
|
4636
5151
|
|
|
4637
5152
|
// src/tool/computer_20250124.ts
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
5153
|
+
import {
|
|
5154
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
|
|
5155
|
+
lazySchema as lazySchema16,
|
|
5156
|
+
zodSchema as zodSchema16
|
|
5157
|
+
} from "@ai-sdk/provider-utils";
|
|
5158
|
+
import { z as z17 } from "zod/v4";
|
|
5159
|
+
var computer_20250124InputSchema = lazySchema16(
|
|
5160
|
+
() => zodSchema16(
|
|
5161
|
+
z17.object({
|
|
5162
|
+
action: z17.enum([
|
|
4644
5163
|
"key",
|
|
4645
5164
|
"hold_key",
|
|
4646
5165
|
"type",
|
|
@@ -4658,27 +5177,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
4658
5177
|
"wait",
|
|
4659
5178
|
"screenshot"
|
|
4660
5179
|
]),
|
|
4661
|
-
coordinate:
|
|
4662
|
-
duration:
|
|
4663
|
-
scroll_amount:
|
|
4664
|
-
scroll_direction:
|
|
4665
|
-
start_coordinate:
|
|
4666
|
-
text:
|
|
5180
|
+
coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5181
|
+
duration: z17.number().optional(),
|
|
5182
|
+
scroll_amount: z17.number().optional(),
|
|
5183
|
+
scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
|
|
5184
|
+
start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5185
|
+
text: z17.string().optional()
|
|
4667
5186
|
})
|
|
4668
5187
|
)
|
|
4669
5188
|
);
|
|
4670
|
-
var computer_20250124 = (
|
|
5189
|
+
var computer_20250124 = createProviderDefinedToolFactory5({
|
|
4671
5190
|
id: "anthropic.computer_20250124",
|
|
4672
5191
|
inputSchema: computer_20250124InputSchema
|
|
4673
5192
|
});
|
|
4674
5193
|
|
|
4675
5194
|
// src/tool/computer_20251124.ts
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
5195
|
+
import {
|
|
5196
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
|
|
5197
|
+
lazySchema as lazySchema17,
|
|
5198
|
+
zodSchema as zodSchema17
|
|
5199
|
+
} from "@ai-sdk/provider-utils";
|
|
5200
|
+
import { z as z18 } from "zod/v4";
|
|
5201
|
+
var computer_20251124InputSchema = lazySchema17(
|
|
5202
|
+
() => zodSchema17(
|
|
5203
|
+
z18.object({
|
|
5204
|
+
action: z18.enum([
|
|
4682
5205
|
"key",
|
|
4683
5206
|
"hold_key",
|
|
4684
5207
|
"type",
|
|
@@ -4697,166 +5220,186 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
|
4697
5220
|
"screenshot",
|
|
4698
5221
|
"zoom"
|
|
4699
5222
|
]),
|
|
4700
|
-
coordinate:
|
|
4701
|
-
duration:
|
|
4702
|
-
region:
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
5223
|
+
coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
5224
|
+
duration: z18.number().optional(),
|
|
5225
|
+
region: z18.tuple([
|
|
5226
|
+
z18.number().int(),
|
|
5227
|
+
z18.number().int(),
|
|
5228
|
+
z18.number().int(),
|
|
5229
|
+
z18.number().int()
|
|
4707
5230
|
]).optional(),
|
|
4708
|
-
scroll_amount:
|
|
4709
|
-
scroll_direction:
|
|
4710
|
-
start_coordinate:
|
|
4711
|
-
text:
|
|
5231
|
+
scroll_amount: z18.number().optional(),
|
|
5232
|
+
scroll_direction: z18.enum(["up", "down", "left", "right"]).optional(),
|
|
5233
|
+
start_coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
5234
|
+
text: z18.string().optional()
|
|
4712
5235
|
})
|
|
4713
5236
|
)
|
|
4714
5237
|
);
|
|
4715
|
-
var computer_20251124 = (
|
|
5238
|
+
var computer_20251124 = createProviderDefinedToolFactory6({
|
|
4716
5239
|
id: "anthropic.computer_20251124",
|
|
4717
5240
|
inputSchema: computer_20251124InputSchema
|
|
4718
5241
|
});
|
|
4719
5242
|
|
|
4720
5243
|
// src/tool/memory_20250818.ts
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
5244
|
+
import {
|
|
5245
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
|
|
5246
|
+
lazySchema as lazySchema18,
|
|
5247
|
+
zodSchema as zodSchema18
|
|
5248
|
+
} from "@ai-sdk/provider-utils";
|
|
5249
|
+
import { z as z19 } from "zod/v4";
|
|
5250
|
+
var memory_20250818InputSchema = lazySchema18(
|
|
5251
|
+
() => zodSchema18(
|
|
5252
|
+
z19.discriminatedUnion("command", [
|
|
5253
|
+
z19.object({
|
|
5254
|
+
command: z19.literal("view"),
|
|
5255
|
+
path: z19.string(),
|
|
5256
|
+
view_range: z19.tuple([z19.number(), z19.number()]).optional()
|
|
4730
5257
|
}),
|
|
4731
|
-
|
|
4732
|
-
command:
|
|
4733
|
-
path:
|
|
4734
|
-
file_text:
|
|
5258
|
+
z19.object({
|
|
5259
|
+
command: z19.literal("create"),
|
|
5260
|
+
path: z19.string(),
|
|
5261
|
+
file_text: z19.string()
|
|
4735
5262
|
}),
|
|
4736
|
-
|
|
4737
|
-
command:
|
|
4738
|
-
path:
|
|
4739
|
-
old_str:
|
|
4740
|
-
new_str:
|
|
5263
|
+
z19.object({
|
|
5264
|
+
command: z19.literal("str_replace"),
|
|
5265
|
+
path: z19.string(),
|
|
5266
|
+
old_str: z19.string(),
|
|
5267
|
+
new_str: z19.string()
|
|
4741
5268
|
}),
|
|
4742
|
-
|
|
4743
|
-
command:
|
|
4744
|
-
path:
|
|
4745
|
-
insert_line:
|
|
4746
|
-
insert_text:
|
|
5269
|
+
z19.object({
|
|
5270
|
+
command: z19.literal("insert"),
|
|
5271
|
+
path: z19.string(),
|
|
5272
|
+
insert_line: z19.number(),
|
|
5273
|
+
insert_text: z19.string()
|
|
4747
5274
|
}),
|
|
4748
|
-
|
|
4749
|
-
command:
|
|
4750
|
-
path:
|
|
5275
|
+
z19.object({
|
|
5276
|
+
command: z19.literal("delete"),
|
|
5277
|
+
path: z19.string()
|
|
4751
5278
|
}),
|
|
4752
|
-
|
|
4753
|
-
command:
|
|
4754
|
-
old_path:
|
|
4755
|
-
new_path:
|
|
5279
|
+
z19.object({
|
|
5280
|
+
command: z19.literal("rename"),
|
|
5281
|
+
old_path: z19.string(),
|
|
5282
|
+
new_path: z19.string()
|
|
4756
5283
|
})
|
|
4757
5284
|
])
|
|
4758
5285
|
)
|
|
4759
5286
|
);
|
|
4760
|
-
var memory_20250818 = (
|
|
5287
|
+
var memory_20250818 = createProviderDefinedToolFactory7({
|
|
4761
5288
|
id: "anthropic.memory_20250818",
|
|
4762
5289
|
inputSchema: memory_20250818InputSchema
|
|
4763
5290
|
});
|
|
4764
5291
|
|
|
4765
5292
|
// src/tool/text-editor_20241022.ts
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
5293
|
+
import {
|
|
5294
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
|
|
5295
|
+
lazySchema as lazySchema19,
|
|
5296
|
+
zodSchema as zodSchema19
|
|
5297
|
+
} from "@ai-sdk/provider-utils";
|
|
5298
|
+
import { z as z20 } from "zod/v4";
|
|
5299
|
+
var textEditor_20241022InputSchema = lazySchema19(
|
|
5300
|
+
() => zodSchema19(
|
|
5301
|
+
z20.object({
|
|
5302
|
+
command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5303
|
+
path: z20.string(),
|
|
5304
|
+
file_text: z20.string().optional(),
|
|
5305
|
+
insert_line: z20.number().int().optional(),
|
|
5306
|
+
new_str: z20.string().optional(),
|
|
5307
|
+
insert_text: z20.string().optional(),
|
|
5308
|
+
old_str: z20.string().optional(),
|
|
5309
|
+
view_range: z20.array(z20.number().int()).optional()
|
|
4779
5310
|
})
|
|
4780
5311
|
)
|
|
4781
5312
|
);
|
|
4782
|
-
var textEditor_20241022 = (
|
|
5313
|
+
var textEditor_20241022 = createProviderDefinedToolFactory8({
|
|
4783
5314
|
id: "anthropic.text_editor_20241022",
|
|
4784
5315
|
inputSchema: textEditor_20241022InputSchema
|
|
4785
5316
|
});
|
|
4786
5317
|
|
|
4787
5318
|
// src/tool/text-editor_20250124.ts
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
5319
|
+
import {
|
|
5320
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
|
|
5321
|
+
lazySchema as lazySchema20,
|
|
5322
|
+
zodSchema as zodSchema20
|
|
5323
|
+
} from "@ai-sdk/provider-utils";
|
|
5324
|
+
import { z as z21 } from "zod/v4";
|
|
5325
|
+
var textEditor_20250124InputSchema = lazySchema20(
|
|
5326
|
+
() => zodSchema20(
|
|
5327
|
+
z21.object({
|
|
5328
|
+
command: z21.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5329
|
+
path: z21.string(),
|
|
5330
|
+
file_text: z21.string().optional(),
|
|
5331
|
+
insert_line: z21.number().int().optional(),
|
|
5332
|
+
new_str: z21.string().optional(),
|
|
5333
|
+
insert_text: z21.string().optional(),
|
|
5334
|
+
old_str: z21.string().optional(),
|
|
5335
|
+
view_range: z21.array(z21.number().int()).optional()
|
|
4801
5336
|
})
|
|
4802
5337
|
)
|
|
4803
5338
|
);
|
|
4804
|
-
var textEditor_20250124 = (
|
|
5339
|
+
var textEditor_20250124 = createProviderDefinedToolFactory9({
|
|
4805
5340
|
id: "anthropic.text_editor_20250124",
|
|
4806
5341
|
inputSchema: textEditor_20250124InputSchema
|
|
4807
5342
|
});
|
|
4808
5343
|
|
|
4809
5344
|
// src/tool/text-editor_20250429.ts
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
5345
|
+
import {
|
|
5346
|
+
createProviderDefinedToolFactory as createProviderDefinedToolFactory10,
|
|
5347
|
+
lazySchema as lazySchema21,
|
|
5348
|
+
zodSchema as zodSchema21
|
|
5349
|
+
} from "@ai-sdk/provider-utils";
|
|
5350
|
+
import { z as z22 } from "zod/v4";
|
|
5351
|
+
var textEditor_20250429InputSchema = lazySchema21(
|
|
5352
|
+
() => zodSchema21(
|
|
5353
|
+
z22.object({
|
|
5354
|
+
command: z22.enum(["view", "create", "str_replace", "insert"]),
|
|
5355
|
+
path: z22.string(),
|
|
5356
|
+
file_text: z22.string().optional(),
|
|
5357
|
+
insert_line: z22.number().int().optional(),
|
|
5358
|
+
new_str: z22.string().optional(),
|
|
5359
|
+
insert_text: z22.string().optional(),
|
|
5360
|
+
old_str: z22.string().optional(),
|
|
5361
|
+
view_range: z22.array(z22.number().int()).optional()
|
|
4823
5362
|
})
|
|
4824
5363
|
)
|
|
4825
5364
|
);
|
|
4826
|
-
var textEditor_20250429 = (
|
|
5365
|
+
var textEditor_20250429 = createProviderDefinedToolFactory10({
|
|
4827
5366
|
id: "anthropic.text_editor_20250429",
|
|
4828
5367
|
inputSchema: textEditor_20250429InputSchema
|
|
4829
5368
|
});
|
|
4830
5369
|
|
|
4831
5370
|
// src/tool/tool-search-bm25_20251119.ts
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
5371
|
+
import {
|
|
5372
|
+
createProviderExecutedToolFactory as createProviderExecutedToolFactory9,
|
|
5373
|
+
lazySchema as lazySchema22,
|
|
5374
|
+
zodSchema as zodSchema22
|
|
5375
|
+
} from "@ai-sdk/provider-utils";
|
|
5376
|
+
import { z as z23 } from "zod/v4";
|
|
5377
|
+
var toolSearchBm25_20251119OutputSchema = lazySchema22(
|
|
5378
|
+
() => zodSchema22(
|
|
5379
|
+
z23.array(
|
|
5380
|
+
z23.object({
|
|
5381
|
+
type: z23.literal("tool_reference"),
|
|
5382
|
+
toolName: z23.string()
|
|
4840
5383
|
})
|
|
4841
5384
|
)
|
|
4842
5385
|
)
|
|
4843
5386
|
);
|
|
4844
|
-
var toolSearchBm25_20251119InputSchema = (
|
|
4845
|
-
() => (
|
|
4846
|
-
|
|
5387
|
+
var toolSearchBm25_20251119InputSchema = lazySchema22(
|
|
5388
|
+
() => zodSchema22(
|
|
5389
|
+
z23.object({
|
|
4847
5390
|
/**
|
|
4848
5391
|
* A natural language query to search for tools.
|
|
4849
5392
|
* Claude will use BM25 text search to find relevant tools.
|
|
4850
5393
|
*/
|
|
4851
|
-
query:
|
|
5394
|
+
query: z23.string(),
|
|
4852
5395
|
/**
|
|
4853
5396
|
* Maximum number of tools to return. Optional.
|
|
4854
5397
|
*/
|
|
4855
|
-
limit:
|
|
5398
|
+
limit: z23.number().optional()
|
|
4856
5399
|
})
|
|
4857
5400
|
)
|
|
4858
5401
|
);
|
|
4859
|
-
var factory10 = (
|
|
5402
|
+
var factory10 = createProviderExecutedToolFactory9({
|
|
4860
5403
|
id: "anthropic.tool_search_bm25_20251119",
|
|
4861
5404
|
inputSchema: toolSearchBm25_20251119InputSchema,
|
|
4862
5405
|
outputSchema: toolSearchBm25_20251119OutputSchema,
|
|
@@ -5068,31 +5611,163 @@ var anthropicTools = {
|
|
|
5068
5611
|
toolSearchBm25_20251119
|
|
5069
5612
|
};
|
|
5070
5613
|
|
|
5614
|
+
// src/skills/anthropic-skills.ts
|
|
5615
|
+
import {
|
|
5616
|
+
combineHeaders as combineHeaders3,
|
|
5617
|
+
convertInlineFileDataToUint8Array as convertInlineFileDataToUint8Array2,
|
|
5618
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
5619
|
+
getFromApi,
|
|
5620
|
+
postFormDataToApi as postFormDataToApi2,
|
|
5621
|
+
resolve as resolve2
|
|
5622
|
+
} from "@ai-sdk/provider-utils";
|
|
5623
|
+
|
|
5624
|
+
// src/skills/anthropic-skills-api.ts
|
|
5625
|
+
import { lazySchema as lazySchema23, zodSchema as zodSchema23 } from "@ai-sdk/provider-utils";
|
|
5626
|
+
import { z as z24 } from "zod/v4";
|
|
5627
|
+
var anthropicSkillResponseSchema = lazySchema23(
|
|
5628
|
+
() => zodSchema23(
|
|
5629
|
+
z24.object({
|
|
5630
|
+
id: z24.string(),
|
|
5631
|
+
display_title: z24.string().nullish(),
|
|
5632
|
+
name: z24.string().nullish(),
|
|
5633
|
+
description: z24.string().nullish(),
|
|
5634
|
+
latest_version: z24.string().nullish(),
|
|
5635
|
+
source: z24.string(),
|
|
5636
|
+
created_at: z24.string(),
|
|
5637
|
+
updated_at: z24.string()
|
|
5638
|
+
})
|
|
5639
|
+
)
|
|
5640
|
+
);
|
|
5641
|
+
var anthropicSkillVersionListResponseSchema = lazySchema23(
|
|
5642
|
+
() => zodSchema23(
|
|
5643
|
+
z24.object({
|
|
5644
|
+
data: z24.array(
|
|
5645
|
+
z24.object({
|
|
5646
|
+
version: z24.string()
|
|
5647
|
+
})
|
|
5648
|
+
)
|
|
5649
|
+
})
|
|
5650
|
+
)
|
|
5651
|
+
);
|
|
5652
|
+
var anthropicSkillVersionResponseSchema = lazySchema23(
|
|
5653
|
+
() => zodSchema23(
|
|
5654
|
+
z24.object({
|
|
5655
|
+
type: z24.string(),
|
|
5656
|
+
skill_id: z24.string(),
|
|
5657
|
+
name: z24.string().nullish(),
|
|
5658
|
+
description: z24.string().nullish()
|
|
5659
|
+
})
|
|
5660
|
+
)
|
|
5661
|
+
);
|
|
5662
|
+
|
|
5663
|
+
// src/skills/anthropic-skills.ts
|
|
5664
|
+
var AnthropicSkills = class {
|
|
5665
|
+
constructor(config) {
|
|
5666
|
+
this.config = config;
|
|
5667
|
+
this.specificationVersion = "v4";
|
|
5668
|
+
}
|
|
5669
|
+
get provider() {
|
|
5670
|
+
return this.config.provider;
|
|
5671
|
+
}
|
|
5672
|
+
async getHeaders() {
|
|
5673
|
+
return combineHeaders3(await resolve2(this.config.headers), {
|
|
5674
|
+
"anthropic-beta": "skills-2025-10-02"
|
|
5675
|
+
});
|
|
5676
|
+
}
|
|
5677
|
+
async fetchVersionMetadata({
|
|
5678
|
+
skillId,
|
|
5679
|
+
version,
|
|
5680
|
+
headers
|
|
5681
|
+
}) {
|
|
5682
|
+
const { value: versionResponse } = await getFromApi({
|
|
5683
|
+
url: `${this.config.baseURL}/skills/${skillId}/versions/${version}`,
|
|
5684
|
+
headers,
|
|
5685
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
5686
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
5687
|
+
anthropicSkillVersionResponseSchema
|
|
5688
|
+
),
|
|
5689
|
+
fetch: this.config.fetch
|
|
5690
|
+
});
|
|
5691
|
+
return {
|
|
5692
|
+
...versionResponse.name != null ? { name: versionResponse.name } : {},
|
|
5693
|
+
...versionResponse.description != null ? { description: versionResponse.description } : {}
|
|
5694
|
+
};
|
|
5695
|
+
}
|
|
5696
|
+
async uploadSkill(params) {
|
|
5697
|
+
var _a, _b;
|
|
5698
|
+
const warnings = [];
|
|
5699
|
+
const formData = new FormData();
|
|
5700
|
+
if (params.displayTitle != null) {
|
|
5701
|
+
formData.append("display_title", params.displayTitle);
|
|
5702
|
+
}
|
|
5703
|
+
for (const file of params.files) {
|
|
5704
|
+
const content = convertInlineFileDataToUint8Array2(file.data);
|
|
5705
|
+
formData.append("files[]", new Blob([content]), file.path);
|
|
5706
|
+
}
|
|
5707
|
+
const headers = await this.getHeaders();
|
|
5708
|
+
const { value: response } = await postFormDataToApi2({
|
|
5709
|
+
url: `${this.config.baseURL}/skills`,
|
|
5710
|
+
headers,
|
|
5711
|
+
formData,
|
|
5712
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
5713
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
5714
|
+
anthropicSkillResponseSchema
|
|
5715
|
+
),
|
|
5716
|
+
fetch: this.config.fetch
|
|
5717
|
+
});
|
|
5718
|
+
const versionMetadata = response.latest_version != null ? await this.fetchVersionMetadata({
|
|
5719
|
+
skillId: response.id,
|
|
5720
|
+
version: response.latest_version,
|
|
5721
|
+
headers
|
|
5722
|
+
}) : {};
|
|
5723
|
+
const name = (_a = versionMetadata.name) != null ? _a : response.name;
|
|
5724
|
+
const description = (_b = versionMetadata.description) != null ? _b : response.description;
|
|
5725
|
+
return {
|
|
5726
|
+
providerReference: { anthropic: response.id },
|
|
5727
|
+
...response.display_title != null ? { displayTitle: response.display_title } : {},
|
|
5728
|
+
...name != null ? { name } : {},
|
|
5729
|
+
...description != null ? { description } : {},
|
|
5730
|
+
...response.latest_version != null ? { latestVersion: response.latest_version } : {},
|
|
5731
|
+
providerMetadata: {
|
|
5732
|
+
anthropic: {
|
|
5733
|
+
...response.source != null ? { source: response.source } : {},
|
|
5734
|
+
...response.created_at != null ? { createdAt: response.created_at } : {},
|
|
5735
|
+
...response.updated_at != null ? { updatedAt: response.updated_at } : {}
|
|
5736
|
+
}
|
|
5737
|
+
},
|
|
5738
|
+
warnings
|
|
5739
|
+
};
|
|
5740
|
+
}
|
|
5741
|
+
};
|
|
5742
|
+
|
|
5743
|
+
// src/version.ts
|
|
5744
|
+
var VERSION = true ? "4.0.0-beta.41" : "0.0.0-test";
|
|
5745
|
+
|
|
5071
5746
|
// src/anthropic-provider.ts
|
|
5072
5747
|
function createAnthropic(options = {}) {
|
|
5073
5748
|
var _a, _b;
|
|
5074
|
-
const baseURL = (_a =
|
|
5075
|
-
|
|
5749
|
+
const baseURL = (_a = withoutTrailingSlash(
|
|
5750
|
+
loadOptionalSetting({
|
|
5076
5751
|
settingValue: options.baseURL,
|
|
5077
5752
|
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
5078
5753
|
})
|
|
5079
5754
|
)) != null ? _a : "https://api.anthropic.com/v1";
|
|
5080
5755
|
const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
|
|
5081
5756
|
if (options.apiKey && options.authToken) {
|
|
5082
|
-
throw new
|
|
5757
|
+
throw new InvalidArgumentError({
|
|
5083
5758
|
argument: "apiKey/authToken",
|
|
5084
5759
|
message: "Both apiKey and authToken were provided. Please use only one authentication method."
|
|
5085
5760
|
});
|
|
5086
5761
|
}
|
|
5087
5762
|
const getHeaders = () => {
|
|
5088
5763
|
const authHeaders = options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {
|
|
5089
|
-
"x-api-key":
|
|
5764
|
+
"x-api-key": loadApiKey({
|
|
5090
5765
|
apiKey: options.apiKey,
|
|
5091
5766
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
5092
5767
|
description: "Anthropic"
|
|
5093
5768
|
})
|
|
5094
5769
|
};
|
|
5095
|
-
return
|
|
5770
|
+
return withUserAgentSuffix(
|
|
5096
5771
|
{
|
|
5097
5772
|
"anthropic-version": "2023-06-01",
|
|
5098
5773
|
...authHeaders,
|
|
@@ -5103,18 +5778,24 @@ function createAnthropic(options = {}) {
|
|
|
5103
5778
|
};
|
|
5104
5779
|
const createChatModel = (modelId) => {
|
|
5105
5780
|
var _a2;
|
|
5106
|
-
return new
|
|
5781
|
+
return new AnthropicLanguageModel(modelId, {
|
|
5107
5782
|
provider: providerName,
|
|
5108
5783
|
baseURL,
|
|
5109
5784
|
headers: getHeaders,
|
|
5110
5785
|
fetch: options.fetch,
|
|
5111
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
5786
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : generateId2,
|
|
5112
5787
|
supportedUrls: () => ({
|
|
5113
5788
|
"image/*": [/^https?:\/\/.*$/],
|
|
5114
5789
|
"application/pdf": [/^https?:\/\/.*$/]
|
|
5115
5790
|
})
|
|
5116
5791
|
});
|
|
5117
5792
|
};
|
|
5793
|
+
const createSkills = () => new AnthropicSkills({
|
|
5794
|
+
provider: `${providerName.replace(".messages", "")}.skills`,
|
|
5795
|
+
baseURL,
|
|
5796
|
+
headers: getHeaders,
|
|
5797
|
+
fetch: options.fetch
|
|
5798
|
+
});
|
|
5118
5799
|
const provider = function(modelId) {
|
|
5119
5800
|
if (new.target) {
|
|
5120
5801
|
throw new Error(
|
|
@@ -5128,12 +5809,19 @@ function createAnthropic(options = {}) {
|
|
|
5128
5809
|
provider.chat = createChatModel;
|
|
5129
5810
|
provider.messages = createChatModel;
|
|
5130
5811
|
provider.embeddingModel = (modelId) => {
|
|
5131
|
-
throw new
|
|
5812
|
+
throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
5132
5813
|
};
|
|
5133
5814
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
5134
5815
|
provider.imageModel = (modelId) => {
|
|
5135
|
-
throw new
|
|
5816
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
5136
5817
|
};
|
|
5818
|
+
provider.files = () => new AnthropicFiles({
|
|
5819
|
+
provider: providerName,
|
|
5820
|
+
baseURL,
|
|
5821
|
+
headers: getHeaders,
|
|
5822
|
+
fetch: options.fetch
|
|
5823
|
+
});
|
|
5824
|
+
provider.skills = createSkills;
|
|
5137
5825
|
provider.tools = anthropicTools;
|
|
5138
5826
|
return provider;
|
|
5139
5827
|
}
|
|
@@ -5158,11 +5846,10 @@ function forwardAnthropicContainerIdFromLastStep({
|
|
|
5158
5846
|
}
|
|
5159
5847
|
return void 0;
|
|
5160
5848
|
}
|
|
5161
|
-
|
|
5162
|
-
0 && (module.exports = {
|
|
5849
|
+
export {
|
|
5163
5850
|
VERSION,
|
|
5164
5851
|
anthropic,
|
|
5165
5852
|
createAnthropic,
|
|
5166
5853
|
forwardAnthropicContainerIdFromLastStep
|
|
5167
|
-
}
|
|
5854
|
+
};
|
|
5168
5855
|
//# sourceMappingURL=index.js.map
|