@ai-sdk/anthropic 4.0.0-beta.3 → 4.0.0-beta.32
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 +236 -4
- package/README.md +2 -0
- package/dist/index.d.ts +60 -34
- package/dist/index.js +1757 -1226
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +72 -36
- package/dist/internal/index.js +1516 -1211
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +105 -4
- package/package.json +9 -12
- package/src/anthropic-files.ts +96 -0
- package/src/anthropic-messages-api.ts +4 -0
- package/src/anthropic-messages-language-model.ts +223 -13
- package/src/anthropic-messages-options.ts +67 -10
- package/src/anthropic-prepare-tools.ts +27 -6
- package/src/anthropic-provider.ts +30 -1
- package/src/convert-to-anthropic-messages-prompt.ts +42 -20
- package/src/internal/index.ts +4 -1
- package/src/skills/anthropic-skills-api.ts +44 -0
- package/src/skills/anthropic-skills.ts +136 -0
- package/dist/index.d.mts +0 -1090
- package/dist/index.mjs +0 -5233
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -960
- package/dist/internal/index.mjs +0 -5125
- package/dist/internal/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,375 +1,451 @@
|
|
|
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 src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
VERSION: () => VERSION,
|
|
24
|
-
anthropic: () => anthropic,
|
|
25
|
-
createAnthropic: () => createAnthropic,
|
|
26
|
-
forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(src_exports);
|
|
29
|
-
|
|
30
1
|
// src/anthropic-provider.ts
|
|
31
|
-
|
|
32
|
-
|
|
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";
|
|
33
13
|
|
|
34
|
-
// src/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
14
|
+
// src/anthropic-files.ts
|
|
15
|
+
import {
|
|
16
|
+
combineHeaders,
|
|
17
|
+
convertBase64ToUint8Array,
|
|
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
|
|
|
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 = data instanceof Uint8Array ? data : convertBase64ToUint8Array(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-messages-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
|
+
|
|
60
136
|
// src/anthropic-messages-api.ts
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var anthropicMessagesResponseSchema = (
|
|
64
|
-
() => (
|
|
65
|
-
|
|
66
|
-
type:
|
|
67
|
-
id:
|
|
68
|
-
model:
|
|
69
|
-
content:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
type:
|
|
73
|
-
text:
|
|
74
|
-
citations:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
type:
|
|
78
|
-
cited_text:
|
|
79
|
-
url:
|
|
80
|
-
title:
|
|
81
|
-
encrypted_index:
|
|
137
|
+
import { lazySchema as lazySchema3, zodSchema as zodSchema3 } from "@ai-sdk/provider-utils";
|
|
138
|
+
import { z as z3 } from "zod/v4";
|
|
139
|
+
var anthropicMessagesResponseSchema = lazySchema3(
|
|
140
|
+
() => zodSchema3(
|
|
141
|
+
z3.object({
|
|
142
|
+
type: z3.literal("message"),
|
|
143
|
+
id: z3.string().nullish(),
|
|
144
|
+
model: z3.string().nullish(),
|
|
145
|
+
content: z3.array(
|
|
146
|
+
z3.discriminatedUnion("type", [
|
|
147
|
+
z3.object({
|
|
148
|
+
type: z3.literal("text"),
|
|
149
|
+
text: z3.string(),
|
|
150
|
+
citations: z3.array(
|
|
151
|
+
z3.discriminatedUnion("type", [
|
|
152
|
+
z3.object({
|
|
153
|
+
type: z3.literal("web_search_result_location"),
|
|
154
|
+
cited_text: z3.string(),
|
|
155
|
+
url: z3.string(),
|
|
156
|
+
title: z3.string(),
|
|
157
|
+
encrypted_index: z3.string()
|
|
82
158
|
}),
|
|
83
|
-
|
|
84
|
-
type:
|
|
85
|
-
cited_text:
|
|
86
|
-
document_index:
|
|
87
|
-
document_title:
|
|
88
|
-
start_page_number:
|
|
89
|
-
end_page_number:
|
|
159
|
+
z3.object({
|
|
160
|
+
type: z3.literal("page_location"),
|
|
161
|
+
cited_text: z3.string(),
|
|
162
|
+
document_index: z3.number(),
|
|
163
|
+
document_title: z3.string().nullable(),
|
|
164
|
+
start_page_number: z3.number(),
|
|
165
|
+
end_page_number: z3.number()
|
|
90
166
|
}),
|
|
91
|
-
|
|
92
|
-
type:
|
|
93
|
-
cited_text:
|
|
94
|
-
document_index:
|
|
95
|
-
document_title:
|
|
96
|
-
start_char_index:
|
|
97
|
-
end_char_index:
|
|
167
|
+
z3.object({
|
|
168
|
+
type: z3.literal("char_location"),
|
|
169
|
+
cited_text: z3.string(),
|
|
170
|
+
document_index: z3.number(),
|
|
171
|
+
document_title: z3.string().nullable(),
|
|
172
|
+
start_char_index: z3.number(),
|
|
173
|
+
end_char_index: z3.number()
|
|
98
174
|
})
|
|
99
175
|
])
|
|
100
176
|
).optional()
|
|
101
177
|
}),
|
|
102
|
-
|
|
103
|
-
type:
|
|
104
|
-
thinking:
|
|
105
|
-
signature:
|
|
178
|
+
z3.object({
|
|
179
|
+
type: z3.literal("thinking"),
|
|
180
|
+
thinking: z3.string(),
|
|
181
|
+
signature: z3.string()
|
|
106
182
|
}),
|
|
107
|
-
|
|
108
|
-
type:
|
|
109
|
-
data:
|
|
183
|
+
z3.object({
|
|
184
|
+
type: z3.literal("redacted_thinking"),
|
|
185
|
+
data: z3.string()
|
|
110
186
|
}),
|
|
111
|
-
|
|
112
|
-
type:
|
|
113
|
-
content:
|
|
187
|
+
z3.object({
|
|
188
|
+
type: z3.literal("compaction"),
|
|
189
|
+
content: z3.string()
|
|
114
190
|
}),
|
|
115
|
-
|
|
116
|
-
type:
|
|
117
|
-
id:
|
|
118
|
-
name:
|
|
119
|
-
input:
|
|
191
|
+
z3.object({
|
|
192
|
+
type: z3.literal("tool_use"),
|
|
193
|
+
id: z3.string(),
|
|
194
|
+
name: z3.string(),
|
|
195
|
+
input: z3.unknown(),
|
|
120
196
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
121
|
-
caller:
|
|
122
|
-
|
|
123
|
-
type:
|
|
124
|
-
tool_id:
|
|
197
|
+
caller: z3.union([
|
|
198
|
+
z3.object({
|
|
199
|
+
type: z3.literal("code_execution_20250825"),
|
|
200
|
+
tool_id: z3.string()
|
|
125
201
|
}),
|
|
126
|
-
|
|
127
|
-
type:
|
|
128
|
-
tool_id:
|
|
202
|
+
z3.object({
|
|
203
|
+
type: z3.literal("code_execution_20260120"),
|
|
204
|
+
tool_id: z3.string()
|
|
129
205
|
}),
|
|
130
|
-
|
|
131
|
-
type:
|
|
206
|
+
z3.object({
|
|
207
|
+
type: z3.literal("direct")
|
|
132
208
|
})
|
|
133
209
|
]).optional()
|
|
134
210
|
}),
|
|
135
|
-
|
|
136
|
-
type:
|
|
137
|
-
id:
|
|
138
|
-
name:
|
|
139
|
-
input:
|
|
140
|
-
caller:
|
|
141
|
-
|
|
142
|
-
type:
|
|
143
|
-
tool_id:
|
|
211
|
+
z3.object({
|
|
212
|
+
type: z3.literal("server_tool_use"),
|
|
213
|
+
id: z3.string(),
|
|
214
|
+
name: z3.string(),
|
|
215
|
+
input: z3.record(z3.string(), z3.unknown()).nullish(),
|
|
216
|
+
caller: z3.union([
|
|
217
|
+
z3.object({
|
|
218
|
+
type: z3.literal("code_execution_20260120"),
|
|
219
|
+
tool_id: z3.string()
|
|
144
220
|
}),
|
|
145
|
-
|
|
146
|
-
type:
|
|
221
|
+
z3.object({
|
|
222
|
+
type: z3.literal("direct")
|
|
147
223
|
})
|
|
148
224
|
]).optional()
|
|
149
225
|
}),
|
|
150
|
-
|
|
151
|
-
type:
|
|
152
|
-
id:
|
|
153
|
-
name:
|
|
154
|
-
input:
|
|
155
|
-
server_name:
|
|
226
|
+
z3.object({
|
|
227
|
+
type: z3.literal("mcp_tool_use"),
|
|
228
|
+
id: z3.string(),
|
|
229
|
+
name: z3.string(),
|
|
230
|
+
input: z3.unknown(),
|
|
231
|
+
server_name: z3.string()
|
|
156
232
|
}),
|
|
157
|
-
|
|
158
|
-
type:
|
|
159
|
-
tool_use_id:
|
|
160
|
-
is_error:
|
|
161
|
-
content:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
233
|
+
z3.object({
|
|
234
|
+
type: z3.literal("mcp_tool_result"),
|
|
235
|
+
tool_use_id: z3.string(),
|
|
236
|
+
is_error: z3.boolean(),
|
|
237
|
+
content: z3.array(
|
|
238
|
+
z3.union([
|
|
239
|
+
z3.string(),
|
|
240
|
+
z3.object({ type: z3.literal("text"), text: z3.string() })
|
|
165
241
|
])
|
|
166
242
|
)
|
|
167
243
|
}),
|
|
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:
|
|
244
|
+
z3.object({
|
|
245
|
+
type: z3.literal("web_fetch_tool_result"),
|
|
246
|
+
tool_use_id: z3.string(),
|
|
247
|
+
content: z3.union([
|
|
248
|
+
z3.object({
|
|
249
|
+
type: z3.literal("web_fetch_result"),
|
|
250
|
+
url: z3.string(),
|
|
251
|
+
retrieved_at: z3.string(),
|
|
252
|
+
content: z3.object({
|
|
253
|
+
type: z3.literal("document"),
|
|
254
|
+
title: z3.string().nullable(),
|
|
255
|
+
citations: z3.object({ enabled: z3.boolean() }).optional(),
|
|
256
|
+
source: z3.union([
|
|
257
|
+
z3.object({
|
|
258
|
+
type: z3.literal("base64"),
|
|
259
|
+
media_type: z3.literal("application/pdf"),
|
|
260
|
+
data: z3.string()
|
|
185
261
|
}),
|
|
186
|
-
|
|
187
|
-
type:
|
|
188
|
-
media_type:
|
|
189
|
-
data:
|
|
262
|
+
z3.object({
|
|
263
|
+
type: z3.literal("text"),
|
|
264
|
+
media_type: z3.literal("text/plain"),
|
|
265
|
+
data: z3.string()
|
|
190
266
|
})
|
|
191
267
|
])
|
|
192
268
|
})
|
|
193
269
|
}),
|
|
194
|
-
|
|
195
|
-
type:
|
|
196
|
-
error_code:
|
|
270
|
+
z3.object({
|
|
271
|
+
type: z3.literal("web_fetch_tool_result_error"),
|
|
272
|
+
error_code: z3.string()
|
|
197
273
|
})
|
|
198
274
|
])
|
|
199
275
|
}),
|
|
200
|
-
|
|
201
|
-
type:
|
|
202
|
-
tool_use_id:
|
|
203
|
-
content:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
type:
|
|
207
|
-
url:
|
|
208
|
-
title:
|
|
209
|
-
encrypted_content:
|
|
210
|
-
page_age:
|
|
276
|
+
z3.object({
|
|
277
|
+
type: z3.literal("web_search_tool_result"),
|
|
278
|
+
tool_use_id: z3.string(),
|
|
279
|
+
content: z3.union([
|
|
280
|
+
z3.array(
|
|
281
|
+
z3.object({
|
|
282
|
+
type: z3.literal("web_search_result"),
|
|
283
|
+
url: z3.string(),
|
|
284
|
+
title: z3.string(),
|
|
285
|
+
encrypted_content: z3.string(),
|
|
286
|
+
page_age: z3.string().nullish()
|
|
211
287
|
})
|
|
212
288
|
),
|
|
213
|
-
|
|
214
|
-
type:
|
|
215
|
-
error_code:
|
|
289
|
+
z3.object({
|
|
290
|
+
type: z3.literal("web_search_tool_result_error"),
|
|
291
|
+
error_code: z3.string()
|
|
216
292
|
})
|
|
217
293
|
])
|
|
218
294
|
}),
|
|
219
295
|
// 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:
|
|
296
|
+
z3.object({
|
|
297
|
+
type: z3.literal("code_execution_tool_result"),
|
|
298
|
+
tool_use_id: z3.string(),
|
|
299
|
+
content: z3.union([
|
|
300
|
+
z3.object({
|
|
301
|
+
type: z3.literal("code_execution_result"),
|
|
302
|
+
stdout: z3.string(),
|
|
303
|
+
stderr: z3.string(),
|
|
304
|
+
return_code: z3.number(),
|
|
305
|
+
content: z3.array(
|
|
306
|
+
z3.object({
|
|
307
|
+
type: z3.literal("code_execution_output"),
|
|
308
|
+
file_id: z3.string()
|
|
233
309
|
})
|
|
234
310
|
).optional().default([])
|
|
235
311
|
}),
|
|
236
|
-
|
|
237
|
-
type:
|
|
238
|
-
encrypted_stdout:
|
|
239
|
-
stderr:
|
|
240
|
-
return_code:
|
|
241
|
-
content:
|
|
242
|
-
|
|
243
|
-
type:
|
|
244
|
-
file_id:
|
|
312
|
+
z3.object({
|
|
313
|
+
type: z3.literal("encrypted_code_execution_result"),
|
|
314
|
+
encrypted_stdout: z3.string(),
|
|
315
|
+
stderr: z3.string(),
|
|
316
|
+
return_code: z3.number(),
|
|
317
|
+
content: z3.array(
|
|
318
|
+
z3.object({
|
|
319
|
+
type: z3.literal("code_execution_output"),
|
|
320
|
+
file_id: z3.string()
|
|
245
321
|
})
|
|
246
322
|
).optional().default([])
|
|
247
323
|
}),
|
|
248
|
-
|
|
249
|
-
type:
|
|
250
|
-
error_code:
|
|
324
|
+
z3.object({
|
|
325
|
+
type: z3.literal("code_execution_tool_result_error"),
|
|
326
|
+
error_code: z3.string()
|
|
251
327
|
})
|
|
252
328
|
])
|
|
253
329
|
}),
|
|
254
330
|
// 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:
|
|
331
|
+
z3.object({
|
|
332
|
+
type: z3.literal("bash_code_execution_tool_result"),
|
|
333
|
+
tool_use_id: z3.string(),
|
|
334
|
+
content: z3.discriminatedUnion("type", [
|
|
335
|
+
z3.object({
|
|
336
|
+
type: z3.literal("bash_code_execution_result"),
|
|
337
|
+
content: z3.array(
|
|
338
|
+
z3.object({
|
|
339
|
+
type: z3.literal("bash_code_execution_output"),
|
|
340
|
+
file_id: z3.string()
|
|
265
341
|
})
|
|
266
342
|
),
|
|
267
|
-
stdout:
|
|
268
|
-
stderr:
|
|
269
|
-
return_code:
|
|
343
|
+
stdout: z3.string(),
|
|
344
|
+
stderr: z3.string(),
|
|
345
|
+
return_code: z3.number()
|
|
270
346
|
}),
|
|
271
|
-
|
|
272
|
-
type:
|
|
273
|
-
error_code:
|
|
347
|
+
z3.object({
|
|
348
|
+
type: z3.literal("bash_code_execution_tool_result_error"),
|
|
349
|
+
error_code: z3.string()
|
|
274
350
|
})
|
|
275
351
|
])
|
|
276
352
|
}),
|
|
277
353
|
// 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:
|
|
354
|
+
z3.object({
|
|
355
|
+
type: z3.literal("text_editor_code_execution_tool_result"),
|
|
356
|
+
tool_use_id: z3.string(),
|
|
357
|
+
content: z3.discriminatedUnion("type", [
|
|
358
|
+
z3.object({
|
|
359
|
+
type: z3.literal("text_editor_code_execution_tool_result_error"),
|
|
360
|
+
error_code: z3.string()
|
|
285
361
|
}),
|
|
286
|
-
|
|
287
|
-
type:
|
|
288
|
-
content:
|
|
289
|
-
file_type:
|
|
290
|
-
num_lines:
|
|
291
|
-
start_line:
|
|
292
|
-
total_lines:
|
|
362
|
+
z3.object({
|
|
363
|
+
type: z3.literal("text_editor_code_execution_view_result"),
|
|
364
|
+
content: z3.string(),
|
|
365
|
+
file_type: z3.string(),
|
|
366
|
+
num_lines: z3.number().nullable(),
|
|
367
|
+
start_line: z3.number().nullable(),
|
|
368
|
+
total_lines: z3.number().nullable()
|
|
293
369
|
}),
|
|
294
|
-
|
|
295
|
-
type:
|
|
296
|
-
is_file_update:
|
|
370
|
+
z3.object({
|
|
371
|
+
type: z3.literal("text_editor_code_execution_create_result"),
|
|
372
|
+
is_file_update: z3.boolean()
|
|
297
373
|
}),
|
|
298
|
-
|
|
299
|
-
type:
|
|
374
|
+
z3.object({
|
|
375
|
+
type: z3.literal(
|
|
300
376
|
"text_editor_code_execution_str_replace_result"
|
|
301
377
|
),
|
|
302
|
-
lines:
|
|
303
|
-
new_lines:
|
|
304
|
-
new_start:
|
|
305
|
-
old_lines:
|
|
306
|
-
old_start:
|
|
378
|
+
lines: z3.array(z3.string()).nullable(),
|
|
379
|
+
new_lines: z3.number().nullable(),
|
|
380
|
+
new_start: z3.number().nullable(),
|
|
381
|
+
old_lines: z3.number().nullable(),
|
|
382
|
+
old_start: z3.number().nullable()
|
|
307
383
|
})
|
|
308
384
|
])
|
|
309
385
|
}),
|
|
310
386
|
// 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:
|
|
387
|
+
z3.object({
|
|
388
|
+
type: z3.literal("tool_search_tool_result"),
|
|
389
|
+
tool_use_id: z3.string(),
|
|
390
|
+
content: z3.union([
|
|
391
|
+
z3.object({
|
|
392
|
+
type: z3.literal("tool_search_tool_search_result"),
|
|
393
|
+
tool_references: z3.array(
|
|
394
|
+
z3.object({
|
|
395
|
+
type: z3.literal("tool_reference"),
|
|
396
|
+
tool_name: z3.string()
|
|
321
397
|
})
|
|
322
398
|
)
|
|
323
399
|
}),
|
|
324
|
-
|
|
325
|
-
type:
|
|
326
|
-
error_code:
|
|
400
|
+
z3.object({
|
|
401
|
+
type: z3.literal("tool_search_tool_result_error"),
|
|
402
|
+
error_code: z3.string()
|
|
327
403
|
})
|
|
328
404
|
])
|
|
329
405
|
})
|
|
330
406
|
])
|
|
331
407
|
),
|
|
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:
|
|
408
|
+
stop_reason: z3.string().nullish(),
|
|
409
|
+
stop_sequence: z3.string().nullish(),
|
|
410
|
+
usage: z3.looseObject({
|
|
411
|
+
input_tokens: z3.number(),
|
|
412
|
+
output_tokens: z3.number(),
|
|
413
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
414
|
+
cache_read_input_tokens: z3.number().nullish(),
|
|
415
|
+
iterations: z3.array(
|
|
416
|
+
z3.object({
|
|
417
|
+
type: z3.union([z3.literal("compaction"), z3.literal("message")]),
|
|
418
|
+
input_tokens: z3.number(),
|
|
419
|
+
output_tokens: z3.number()
|
|
344
420
|
})
|
|
345
421
|
).nullish()
|
|
346
422
|
}),
|
|
347
|
-
container:
|
|
348
|
-
expires_at:
|
|
349
|
-
id:
|
|
350
|
-
skills:
|
|
351
|
-
|
|
352
|
-
type:
|
|
353
|
-
skill_id:
|
|
354
|
-
version:
|
|
423
|
+
container: z3.object({
|
|
424
|
+
expires_at: z3.string(),
|
|
425
|
+
id: z3.string(),
|
|
426
|
+
skills: z3.array(
|
|
427
|
+
z3.object({
|
|
428
|
+
type: z3.union([z3.literal("anthropic"), z3.literal("custom")]),
|
|
429
|
+
skill_id: z3.string(),
|
|
430
|
+
version: z3.string()
|
|
355
431
|
})
|
|
356
432
|
).nullish()
|
|
357
433
|
}).nullish(),
|
|
358
|
-
context_management:
|
|
359
|
-
applied_edits:
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
type:
|
|
363
|
-
cleared_tool_uses:
|
|
364
|
-
cleared_input_tokens:
|
|
434
|
+
context_management: z3.object({
|
|
435
|
+
applied_edits: z3.array(
|
|
436
|
+
z3.union([
|
|
437
|
+
z3.object({
|
|
438
|
+
type: z3.literal("clear_tool_uses_20250919"),
|
|
439
|
+
cleared_tool_uses: z3.number(),
|
|
440
|
+
cleared_input_tokens: z3.number()
|
|
365
441
|
}),
|
|
366
|
-
|
|
367
|
-
type:
|
|
368
|
-
cleared_thinking_turns:
|
|
369
|
-
cleared_input_tokens:
|
|
442
|
+
z3.object({
|
|
443
|
+
type: z3.literal("clear_thinking_20251015"),
|
|
444
|
+
cleared_thinking_turns: z3.number(),
|
|
445
|
+
cleared_input_tokens: z3.number()
|
|
370
446
|
}),
|
|
371
|
-
|
|
372
|
-
type:
|
|
447
|
+
z3.object({
|
|
448
|
+
type: z3.literal("compact_20260112")
|
|
373
449
|
})
|
|
374
450
|
])
|
|
375
451
|
)
|
|
@@ -377,457 +453,457 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
377
453
|
})
|
|
378
454
|
)
|
|
379
455
|
);
|
|
380
|
-
var anthropicMessagesChunkSchema = (
|
|
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:
|
|
456
|
+
var anthropicMessagesChunkSchema = lazySchema3(
|
|
457
|
+
() => zodSchema3(
|
|
458
|
+
z3.discriminatedUnion("type", [
|
|
459
|
+
z3.object({
|
|
460
|
+
type: z3.literal("message_start"),
|
|
461
|
+
message: z3.object({
|
|
462
|
+
id: z3.string().nullish(),
|
|
463
|
+
model: z3.string().nullish(),
|
|
464
|
+
role: z3.string().nullish(),
|
|
465
|
+
usage: z3.looseObject({
|
|
466
|
+
input_tokens: z3.number(),
|
|
467
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
468
|
+
cache_read_input_tokens: z3.number().nullish()
|
|
393
469
|
}),
|
|
394
470
|
// 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:
|
|
471
|
+
content: z3.array(
|
|
472
|
+
z3.discriminatedUnion("type", [
|
|
473
|
+
z3.object({
|
|
474
|
+
type: z3.literal("tool_use"),
|
|
475
|
+
id: z3.string(),
|
|
476
|
+
name: z3.string(),
|
|
477
|
+
input: z3.unknown(),
|
|
478
|
+
caller: z3.union([
|
|
479
|
+
z3.object({
|
|
480
|
+
type: z3.literal("code_execution_20250825"),
|
|
481
|
+
tool_id: z3.string()
|
|
406
482
|
}),
|
|
407
|
-
|
|
408
|
-
type:
|
|
409
|
-
tool_id:
|
|
483
|
+
z3.object({
|
|
484
|
+
type: z3.literal("code_execution_20260120"),
|
|
485
|
+
tool_id: z3.string()
|
|
410
486
|
}),
|
|
411
|
-
|
|
412
|
-
type:
|
|
487
|
+
z3.object({
|
|
488
|
+
type: z3.literal("direct")
|
|
413
489
|
})
|
|
414
490
|
]).optional()
|
|
415
491
|
})
|
|
416
492
|
])
|
|
417
493
|
).nullish(),
|
|
418
|
-
stop_reason:
|
|
419
|
-
container:
|
|
420
|
-
expires_at:
|
|
421
|
-
id:
|
|
494
|
+
stop_reason: z3.string().nullish(),
|
|
495
|
+
container: z3.object({
|
|
496
|
+
expires_at: z3.string(),
|
|
497
|
+
id: z3.string()
|
|
422
498
|
}).nullish()
|
|
423
499
|
})
|
|
424
500
|
}),
|
|
425
|
-
|
|
426
|
-
type:
|
|
427
|
-
index:
|
|
428
|
-
content_block:
|
|
429
|
-
|
|
430
|
-
type:
|
|
431
|
-
text:
|
|
501
|
+
z3.object({
|
|
502
|
+
type: z3.literal("content_block_start"),
|
|
503
|
+
index: z3.number(),
|
|
504
|
+
content_block: z3.discriminatedUnion("type", [
|
|
505
|
+
z3.object({
|
|
506
|
+
type: z3.literal("text"),
|
|
507
|
+
text: z3.string()
|
|
432
508
|
}),
|
|
433
|
-
|
|
434
|
-
type:
|
|
435
|
-
thinking:
|
|
509
|
+
z3.object({
|
|
510
|
+
type: z3.literal("thinking"),
|
|
511
|
+
thinking: z3.string()
|
|
436
512
|
}),
|
|
437
|
-
|
|
438
|
-
type:
|
|
439
|
-
id:
|
|
440
|
-
name:
|
|
513
|
+
z3.object({
|
|
514
|
+
type: z3.literal("tool_use"),
|
|
515
|
+
id: z3.string(),
|
|
516
|
+
name: z3.string(),
|
|
441
517
|
// Programmatic tool calling: input may be present directly for deferred tool calls
|
|
442
|
-
input:
|
|
518
|
+
input: z3.record(z3.string(), z3.unknown()).optional(),
|
|
443
519
|
// Programmatic tool calling: caller info when triggered from code execution
|
|
444
|
-
caller:
|
|
445
|
-
|
|
446
|
-
type:
|
|
447
|
-
tool_id:
|
|
520
|
+
caller: z3.union([
|
|
521
|
+
z3.object({
|
|
522
|
+
type: z3.literal("code_execution_20250825"),
|
|
523
|
+
tool_id: z3.string()
|
|
448
524
|
}),
|
|
449
|
-
|
|
450
|
-
type:
|
|
451
|
-
tool_id:
|
|
525
|
+
z3.object({
|
|
526
|
+
type: z3.literal("code_execution_20260120"),
|
|
527
|
+
tool_id: z3.string()
|
|
452
528
|
}),
|
|
453
|
-
|
|
454
|
-
type:
|
|
529
|
+
z3.object({
|
|
530
|
+
type: z3.literal("direct")
|
|
455
531
|
})
|
|
456
532
|
]).optional()
|
|
457
533
|
}),
|
|
458
|
-
|
|
459
|
-
type:
|
|
460
|
-
data:
|
|
534
|
+
z3.object({
|
|
535
|
+
type: z3.literal("redacted_thinking"),
|
|
536
|
+
data: z3.string()
|
|
461
537
|
}),
|
|
462
|
-
|
|
463
|
-
type:
|
|
464
|
-
content:
|
|
538
|
+
z3.object({
|
|
539
|
+
type: z3.literal("compaction"),
|
|
540
|
+
content: z3.string().nullish()
|
|
465
541
|
}),
|
|
466
|
-
|
|
467
|
-
type:
|
|
468
|
-
id:
|
|
469
|
-
name:
|
|
470
|
-
input:
|
|
471
|
-
caller:
|
|
472
|
-
|
|
473
|
-
type:
|
|
474
|
-
tool_id:
|
|
542
|
+
z3.object({
|
|
543
|
+
type: z3.literal("server_tool_use"),
|
|
544
|
+
id: z3.string(),
|
|
545
|
+
name: z3.string(),
|
|
546
|
+
input: z3.record(z3.string(), z3.unknown()).nullish(),
|
|
547
|
+
caller: z3.union([
|
|
548
|
+
z3.object({
|
|
549
|
+
type: z3.literal("code_execution_20260120"),
|
|
550
|
+
tool_id: z3.string()
|
|
475
551
|
}),
|
|
476
|
-
|
|
477
|
-
type:
|
|
552
|
+
z3.object({
|
|
553
|
+
type: z3.literal("direct")
|
|
478
554
|
})
|
|
479
555
|
]).optional()
|
|
480
556
|
}),
|
|
481
|
-
|
|
482
|
-
type:
|
|
483
|
-
id:
|
|
484
|
-
name:
|
|
485
|
-
input:
|
|
486
|
-
server_name:
|
|
557
|
+
z3.object({
|
|
558
|
+
type: z3.literal("mcp_tool_use"),
|
|
559
|
+
id: z3.string(),
|
|
560
|
+
name: z3.string(),
|
|
561
|
+
input: z3.unknown(),
|
|
562
|
+
server_name: z3.string()
|
|
487
563
|
}),
|
|
488
|
-
|
|
489
|
-
type:
|
|
490
|
-
tool_use_id:
|
|
491
|
-
is_error:
|
|
492
|
-
content:
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
564
|
+
z3.object({
|
|
565
|
+
type: z3.literal("mcp_tool_result"),
|
|
566
|
+
tool_use_id: z3.string(),
|
|
567
|
+
is_error: z3.boolean(),
|
|
568
|
+
content: z3.array(
|
|
569
|
+
z3.union([
|
|
570
|
+
z3.string(),
|
|
571
|
+
z3.object({ type: z3.literal("text"), text: z3.string() })
|
|
496
572
|
])
|
|
497
573
|
)
|
|
498
574
|
}),
|
|
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:
|
|
575
|
+
z3.object({
|
|
576
|
+
type: z3.literal("web_fetch_tool_result"),
|
|
577
|
+
tool_use_id: z3.string(),
|
|
578
|
+
content: z3.union([
|
|
579
|
+
z3.object({
|
|
580
|
+
type: z3.literal("web_fetch_result"),
|
|
581
|
+
url: z3.string(),
|
|
582
|
+
retrieved_at: z3.string(),
|
|
583
|
+
content: z3.object({
|
|
584
|
+
type: z3.literal("document"),
|
|
585
|
+
title: z3.string().nullable(),
|
|
586
|
+
citations: z3.object({ enabled: z3.boolean() }).optional(),
|
|
587
|
+
source: z3.union([
|
|
588
|
+
z3.object({
|
|
589
|
+
type: z3.literal("base64"),
|
|
590
|
+
media_type: z3.literal("application/pdf"),
|
|
591
|
+
data: z3.string()
|
|
516
592
|
}),
|
|
517
|
-
|
|
518
|
-
type:
|
|
519
|
-
media_type:
|
|
520
|
-
data:
|
|
593
|
+
z3.object({
|
|
594
|
+
type: z3.literal("text"),
|
|
595
|
+
media_type: z3.literal("text/plain"),
|
|
596
|
+
data: z3.string()
|
|
521
597
|
})
|
|
522
598
|
])
|
|
523
599
|
})
|
|
524
600
|
}),
|
|
525
|
-
|
|
526
|
-
type:
|
|
527
|
-
error_code:
|
|
601
|
+
z3.object({
|
|
602
|
+
type: z3.literal("web_fetch_tool_result_error"),
|
|
603
|
+
error_code: z3.string()
|
|
528
604
|
})
|
|
529
605
|
])
|
|
530
606
|
}),
|
|
531
|
-
|
|
532
|
-
type:
|
|
533
|
-
tool_use_id:
|
|
534
|
-
content:
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
type:
|
|
538
|
-
url:
|
|
539
|
-
title:
|
|
540
|
-
encrypted_content:
|
|
541
|
-
page_age:
|
|
607
|
+
z3.object({
|
|
608
|
+
type: z3.literal("web_search_tool_result"),
|
|
609
|
+
tool_use_id: z3.string(),
|
|
610
|
+
content: z3.union([
|
|
611
|
+
z3.array(
|
|
612
|
+
z3.object({
|
|
613
|
+
type: z3.literal("web_search_result"),
|
|
614
|
+
url: z3.string(),
|
|
615
|
+
title: z3.string(),
|
|
616
|
+
encrypted_content: z3.string(),
|
|
617
|
+
page_age: z3.string().nullish()
|
|
542
618
|
})
|
|
543
619
|
),
|
|
544
|
-
|
|
545
|
-
type:
|
|
546
|
-
error_code:
|
|
620
|
+
z3.object({
|
|
621
|
+
type: z3.literal("web_search_tool_result_error"),
|
|
622
|
+
error_code: z3.string()
|
|
547
623
|
})
|
|
548
624
|
])
|
|
549
625
|
}),
|
|
550
626
|
// 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:
|
|
627
|
+
z3.object({
|
|
628
|
+
type: z3.literal("code_execution_tool_result"),
|
|
629
|
+
tool_use_id: z3.string(),
|
|
630
|
+
content: z3.union([
|
|
631
|
+
z3.object({
|
|
632
|
+
type: z3.literal("code_execution_result"),
|
|
633
|
+
stdout: z3.string(),
|
|
634
|
+
stderr: z3.string(),
|
|
635
|
+
return_code: z3.number(),
|
|
636
|
+
content: z3.array(
|
|
637
|
+
z3.object({
|
|
638
|
+
type: z3.literal("code_execution_output"),
|
|
639
|
+
file_id: z3.string()
|
|
564
640
|
})
|
|
565
641
|
).optional().default([])
|
|
566
642
|
}),
|
|
567
|
-
|
|
568
|
-
type:
|
|
569
|
-
encrypted_stdout:
|
|
570
|
-
stderr:
|
|
571
|
-
return_code:
|
|
572
|
-
content:
|
|
573
|
-
|
|
574
|
-
type:
|
|
575
|
-
file_id:
|
|
643
|
+
z3.object({
|
|
644
|
+
type: z3.literal("encrypted_code_execution_result"),
|
|
645
|
+
encrypted_stdout: z3.string(),
|
|
646
|
+
stderr: z3.string(),
|
|
647
|
+
return_code: z3.number(),
|
|
648
|
+
content: z3.array(
|
|
649
|
+
z3.object({
|
|
650
|
+
type: z3.literal("code_execution_output"),
|
|
651
|
+
file_id: z3.string()
|
|
576
652
|
})
|
|
577
653
|
).optional().default([])
|
|
578
654
|
}),
|
|
579
|
-
|
|
580
|
-
type:
|
|
581
|
-
error_code:
|
|
655
|
+
z3.object({
|
|
656
|
+
type: z3.literal("code_execution_tool_result_error"),
|
|
657
|
+
error_code: z3.string()
|
|
582
658
|
})
|
|
583
659
|
])
|
|
584
660
|
}),
|
|
585
661
|
// 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:
|
|
662
|
+
z3.object({
|
|
663
|
+
type: z3.literal("bash_code_execution_tool_result"),
|
|
664
|
+
tool_use_id: z3.string(),
|
|
665
|
+
content: z3.discriminatedUnion("type", [
|
|
666
|
+
z3.object({
|
|
667
|
+
type: z3.literal("bash_code_execution_result"),
|
|
668
|
+
content: z3.array(
|
|
669
|
+
z3.object({
|
|
670
|
+
type: z3.literal("bash_code_execution_output"),
|
|
671
|
+
file_id: z3.string()
|
|
596
672
|
})
|
|
597
673
|
),
|
|
598
|
-
stdout:
|
|
599
|
-
stderr:
|
|
600
|
-
return_code:
|
|
674
|
+
stdout: z3.string(),
|
|
675
|
+
stderr: z3.string(),
|
|
676
|
+
return_code: z3.number()
|
|
601
677
|
}),
|
|
602
|
-
|
|
603
|
-
type:
|
|
604
|
-
error_code:
|
|
678
|
+
z3.object({
|
|
679
|
+
type: z3.literal("bash_code_execution_tool_result_error"),
|
|
680
|
+
error_code: z3.string()
|
|
605
681
|
})
|
|
606
682
|
])
|
|
607
683
|
}),
|
|
608
684
|
// 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:
|
|
685
|
+
z3.object({
|
|
686
|
+
type: z3.literal("text_editor_code_execution_tool_result"),
|
|
687
|
+
tool_use_id: z3.string(),
|
|
688
|
+
content: z3.discriminatedUnion("type", [
|
|
689
|
+
z3.object({
|
|
690
|
+
type: z3.literal("text_editor_code_execution_tool_result_error"),
|
|
691
|
+
error_code: z3.string()
|
|
616
692
|
}),
|
|
617
|
-
|
|
618
|
-
type:
|
|
619
|
-
content:
|
|
620
|
-
file_type:
|
|
621
|
-
num_lines:
|
|
622
|
-
start_line:
|
|
623
|
-
total_lines:
|
|
693
|
+
z3.object({
|
|
694
|
+
type: z3.literal("text_editor_code_execution_view_result"),
|
|
695
|
+
content: z3.string(),
|
|
696
|
+
file_type: z3.string(),
|
|
697
|
+
num_lines: z3.number().nullable(),
|
|
698
|
+
start_line: z3.number().nullable(),
|
|
699
|
+
total_lines: z3.number().nullable()
|
|
624
700
|
}),
|
|
625
|
-
|
|
626
|
-
type:
|
|
627
|
-
is_file_update:
|
|
701
|
+
z3.object({
|
|
702
|
+
type: z3.literal("text_editor_code_execution_create_result"),
|
|
703
|
+
is_file_update: z3.boolean()
|
|
628
704
|
}),
|
|
629
|
-
|
|
630
|
-
type:
|
|
705
|
+
z3.object({
|
|
706
|
+
type: z3.literal(
|
|
631
707
|
"text_editor_code_execution_str_replace_result"
|
|
632
708
|
),
|
|
633
|
-
lines:
|
|
634
|
-
new_lines:
|
|
635
|
-
new_start:
|
|
636
|
-
old_lines:
|
|
637
|
-
old_start:
|
|
709
|
+
lines: z3.array(z3.string()).nullable(),
|
|
710
|
+
new_lines: z3.number().nullable(),
|
|
711
|
+
new_start: z3.number().nullable(),
|
|
712
|
+
old_lines: z3.number().nullable(),
|
|
713
|
+
old_start: z3.number().nullable()
|
|
638
714
|
})
|
|
639
715
|
])
|
|
640
716
|
}),
|
|
641
717
|
// 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:
|
|
718
|
+
z3.object({
|
|
719
|
+
type: z3.literal("tool_search_tool_result"),
|
|
720
|
+
tool_use_id: z3.string(),
|
|
721
|
+
content: z3.union([
|
|
722
|
+
z3.object({
|
|
723
|
+
type: z3.literal("tool_search_tool_search_result"),
|
|
724
|
+
tool_references: z3.array(
|
|
725
|
+
z3.object({
|
|
726
|
+
type: z3.literal("tool_reference"),
|
|
727
|
+
tool_name: z3.string()
|
|
652
728
|
})
|
|
653
729
|
)
|
|
654
730
|
}),
|
|
655
|
-
|
|
656
|
-
type:
|
|
657
|
-
error_code:
|
|
731
|
+
z3.object({
|
|
732
|
+
type: z3.literal("tool_search_tool_result_error"),
|
|
733
|
+
error_code: z3.string()
|
|
658
734
|
})
|
|
659
735
|
])
|
|
660
736
|
})
|
|
661
737
|
])
|
|
662
738
|
}),
|
|
663
|
-
|
|
664
|
-
type:
|
|
665
|
-
index:
|
|
666
|
-
delta:
|
|
667
|
-
|
|
668
|
-
type:
|
|
669
|
-
partial_json:
|
|
739
|
+
z3.object({
|
|
740
|
+
type: z3.literal("content_block_delta"),
|
|
741
|
+
index: z3.number(),
|
|
742
|
+
delta: z3.discriminatedUnion("type", [
|
|
743
|
+
z3.object({
|
|
744
|
+
type: z3.literal("input_json_delta"),
|
|
745
|
+
partial_json: z3.string()
|
|
670
746
|
}),
|
|
671
|
-
|
|
672
|
-
type:
|
|
673
|
-
text:
|
|
747
|
+
z3.object({
|
|
748
|
+
type: z3.literal("text_delta"),
|
|
749
|
+
text: z3.string()
|
|
674
750
|
}),
|
|
675
|
-
|
|
676
|
-
type:
|
|
677
|
-
thinking:
|
|
751
|
+
z3.object({
|
|
752
|
+
type: z3.literal("thinking_delta"),
|
|
753
|
+
thinking: z3.string()
|
|
678
754
|
}),
|
|
679
|
-
|
|
680
|
-
type:
|
|
681
|
-
signature:
|
|
755
|
+
z3.object({
|
|
756
|
+
type: z3.literal("signature_delta"),
|
|
757
|
+
signature: z3.string()
|
|
682
758
|
}),
|
|
683
|
-
|
|
684
|
-
type:
|
|
685
|
-
content:
|
|
759
|
+
z3.object({
|
|
760
|
+
type: z3.literal("compaction_delta"),
|
|
761
|
+
content: z3.string().nullish()
|
|
686
762
|
}),
|
|
687
|
-
|
|
688
|
-
type:
|
|
689
|
-
citation:
|
|
690
|
-
|
|
691
|
-
type:
|
|
692
|
-
cited_text:
|
|
693
|
-
url:
|
|
694
|
-
title:
|
|
695
|
-
encrypted_index:
|
|
763
|
+
z3.object({
|
|
764
|
+
type: z3.literal("citations_delta"),
|
|
765
|
+
citation: z3.discriminatedUnion("type", [
|
|
766
|
+
z3.object({
|
|
767
|
+
type: z3.literal("web_search_result_location"),
|
|
768
|
+
cited_text: z3.string(),
|
|
769
|
+
url: z3.string(),
|
|
770
|
+
title: z3.string(),
|
|
771
|
+
encrypted_index: z3.string()
|
|
696
772
|
}),
|
|
697
|
-
|
|
698
|
-
type:
|
|
699
|
-
cited_text:
|
|
700
|
-
document_index:
|
|
701
|
-
document_title:
|
|
702
|
-
start_page_number:
|
|
703
|
-
end_page_number:
|
|
773
|
+
z3.object({
|
|
774
|
+
type: z3.literal("page_location"),
|
|
775
|
+
cited_text: z3.string(),
|
|
776
|
+
document_index: z3.number(),
|
|
777
|
+
document_title: z3.string().nullable(),
|
|
778
|
+
start_page_number: z3.number(),
|
|
779
|
+
end_page_number: z3.number()
|
|
704
780
|
}),
|
|
705
|
-
|
|
706
|
-
type:
|
|
707
|
-
cited_text:
|
|
708
|
-
document_index:
|
|
709
|
-
document_title:
|
|
710
|
-
start_char_index:
|
|
711
|
-
end_char_index:
|
|
781
|
+
z3.object({
|
|
782
|
+
type: z3.literal("char_location"),
|
|
783
|
+
cited_text: z3.string(),
|
|
784
|
+
document_index: z3.number(),
|
|
785
|
+
document_title: z3.string().nullable(),
|
|
786
|
+
start_char_index: z3.number(),
|
|
787
|
+
end_char_index: z3.number()
|
|
712
788
|
})
|
|
713
789
|
])
|
|
714
790
|
})
|
|
715
791
|
])
|
|
716
792
|
}),
|
|
717
|
-
|
|
718
|
-
type:
|
|
719
|
-
index:
|
|
793
|
+
z3.object({
|
|
794
|
+
type: z3.literal("content_block_stop"),
|
|
795
|
+
index: z3.number()
|
|
720
796
|
}),
|
|
721
|
-
|
|
722
|
-
type:
|
|
723
|
-
error:
|
|
724
|
-
type:
|
|
725
|
-
message:
|
|
797
|
+
z3.object({
|
|
798
|
+
type: z3.literal("error"),
|
|
799
|
+
error: z3.object({
|
|
800
|
+
type: z3.string(),
|
|
801
|
+
message: z3.string()
|
|
726
802
|
})
|
|
727
803
|
}),
|
|
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
|
-
|
|
804
|
+
z3.object({
|
|
805
|
+
type: z3.literal("message_delta"),
|
|
806
|
+
delta: z3.object({
|
|
807
|
+
stop_reason: z3.string().nullish(),
|
|
808
|
+
stop_sequence: z3.string().nullish(),
|
|
809
|
+
container: z3.object({
|
|
810
|
+
expires_at: z3.string(),
|
|
811
|
+
id: z3.string(),
|
|
812
|
+
skills: z3.array(
|
|
813
|
+
z3.object({
|
|
814
|
+
type: z3.union([
|
|
815
|
+
z3.literal("anthropic"),
|
|
816
|
+
z3.literal("custom")
|
|
741
817
|
]),
|
|
742
|
-
skill_id:
|
|
743
|
-
version:
|
|
818
|
+
skill_id: z3.string(),
|
|
819
|
+
version: z3.string()
|
|
744
820
|
})
|
|
745
821
|
).nullish()
|
|
746
822
|
}).nullish()
|
|
747
823
|
}),
|
|
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:
|
|
824
|
+
usage: z3.looseObject({
|
|
825
|
+
input_tokens: z3.number().nullish(),
|
|
826
|
+
output_tokens: z3.number(),
|
|
827
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
828
|
+
cache_read_input_tokens: z3.number().nullish(),
|
|
829
|
+
iterations: z3.array(
|
|
830
|
+
z3.object({
|
|
831
|
+
type: z3.union([z3.literal("compaction"), z3.literal("message")]),
|
|
832
|
+
input_tokens: z3.number(),
|
|
833
|
+
output_tokens: z3.number()
|
|
758
834
|
})
|
|
759
835
|
).nullish()
|
|
760
836
|
}),
|
|
761
|
-
context_management:
|
|
762
|
-
applied_edits:
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
type:
|
|
766
|
-
cleared_tool_uses:
|
|
767
|
-
cleared_input_tokens:
|
|
837
|
+
context_management: z3.object({
|
|
838
|
+
applied_edits: z3.array(
|
|
839
|
+
z3.union([
|
|
840
|
+
z3.object({
|
|
841
|
+
type: z3.literal("clear_tool_uses_20250919"),
|
|
842
|
+
cleared_tool_uses: z3.number(),
|
|
843
|
+
cleared_input_tokens: z3.number()
|
|
768
844
|
}),
|
|
769
|
-
|
|
770
|
-
type:
|
|
771
|
-
cleared_thinking_turns:
|
|
772
|
-
cleared_input_tokens:
|
|
845
|
+
z3.object({
|
|
846
|
+
type: z3.literal("clear_thinking_20251015"),
|
|
847
|
+
cleared_thinking_turns: z3.number(),
|
|
848
|
+
cleared_input_tokens: z3.number()
|
|
773
849
|
}),
|
|
774
|
-
|
|
775
|
-
type:
|
|
850
|
+
z3.object({
|
|
851
|
+
type: z3.literal("compact_20260112")
|
|
776
852
|
})
|
|
777
853
|
])
|
|
778
854
|
)
|
|
779
855
|
}).nullish()
|
|
780
856
|
}),
|
|
781
|
-
|
|
782
|
-
type:
|
|
857
|
+
z3.object({
|
|
858
|
+
type: z3.literal("message_stop")
|
|
783
859
|
}),
|
|
784
|
-
|
|
785
|
-
type:
|
|
860
|
+
z3.object({
|
|
861
|
+
type: z3.literal("ping")
|
|
786
862
|
})
|
|
787
863
|
])
|
|
788
864
|
)
|
|
789
865
|
);
|
|
790
|
-
var anthropicReasoningMetadataSchema = (
|
|
791
|
-
() => (
|
|
792
|
-
|
|
793
|
-
signature:
|
|
794
|
-
redactedData:
|
|
866
|
+
var anthropicReasoningMetadataSchema = lazySchema3(
|
|
867
|
+
() => zodSchema3(
|
|
868
|
+
z3.object({
|
|
869
|
+
signature: z3.string().optional(),
|
|
870
|
+
redactedData: z3.string().optional()
|
|
795
871
|
})
|
|
796
872
|
)
|
|
797
873
|
);
|
|
798
874
|
|
|
799
875
|
// src/anthropic-messages-options.ts
|
|
800
|
-
|
|
801
|
-
var anthropicFilePartProviderOptions =
|
|
876
|
+
import { z as z4 } from "zod/v4";
|
|
877
|
+
var anthropicFilePartProviderOptions = z4.object({
|
|
802
878
|
/**
|
|
803
879
|
* Citation configuration for this document.
|
|
804
880
|
* When enabled, this document will generate citations in the response.
|
|
805
881
|
*/
|
|
806
|
-
citations:
|
|
882
|
+
citations: z4.object({
|
|
807
883
|
/**
|
|
808
884
|
* Enable citations for this document
|
|
809
885
|
*/
|
|
810
|
-
enabled:
|
|
886
|
+
enabled: z4.boolean()
|
|
811
887
|
}).optional(),
|
|
812
888
|
/**
|
|
813
889
|
* Custom title for the document.
|
|
814
890
|
* If not provided, the filename will be used.
|
|
815
891
|
*/
|
|
816
|
-
title:
|
|
892
|
+
title: z4.string().optional(),
|
|
817
893
|
/**
|
|
818
894
|
* Context about the document that will be passed to the model
|
|
819
895
|
* but not used towards cited content.
|
|
820
896
|
* Useful for storing document metadata as text or stringified JSON.
|
|
821
897
|
*/
|
|
822
|
-
context:
|
|
898
|
+
context: z4.string().optional()
|
|
823
899
|
});
|
|
824
|
-
var anthropicLanguageModelOptions =
|
|
900
|
+
var anthropicLanguageModelOptions = z4.object({
|
|
825
901
|
/**
|
|
826
902
|
* Whether to send reasoning to the model.
|
|
827
903
|
*
|
|
828
904
|
* This allows you to deactivate reasoning inputs for models that do not support them.
|
|
829
905
|
*/
|
|
830
|
-
sendReasoning:
|
|
906
|
+
sendReasoning: z4.boolean().optional(),
|
|
831
907
|
/**
|
|
832
908
|
* Determines how structured outputs are generated.
|
|
833
909
|
*
|
|
@@ -835,52 +911,72 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
835
911
|
* - `jsonTool`: Use a special 'json' tool to specify the structured output format.
|
|
836
912
|
* - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default).
|
|
837
913
|
*/
|
|
838
|
-
structuredOutputMode:
|
|
914
|
+
structuredOutputMode: z4.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
839
915
|
/**
|
|
840
916
|
* Configuration for enabling Claude's extended thinking.
|
|
841
917
|
*
|
|
842
918
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
843
919
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
844
920
|
*/
|
|
845
|
-
thinking:
|
|
846
|
-
|
|
921
|
+
thinking: z4.discriminatedUnion("type", [
|
|
922
|
+
z4.object({
|
|
847
923
|
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
848
|
-
type:
|
|
924
|
+
type: z4.literal("adaptive"),
|
|
925
|
+
/**
|
|
926
|
+
* Controls whether thinking content is included in the response.
|
|
927
|
+
* - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
|
|
928
|
+
* - `"summarized"`: Thinking content is returned. Required to see reasoning output.
|
|
929
|
+
*/
|
|
930
|
+
display: z4.enum(["omitted", "summarized"]).optional()
|
|
849
931
|
}),
|
|
850
|
-
|
|
932
|
+
z4.object({
|
|
851
933
|
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
852
|
-
type:
|
|
853
|
-
budgetTokens:
|
|
934
|
+
type: z4.literal("enabled"),
|
|
935
|
+
budgetTokens: z4.number().optional()
|
|
854
936
|
}),
|
|
855
|
-
|
|
856
|
-
type:
|
|
937
|
+
z4.object({
|
|
938
|
+
type: z4.literal("disabled")
|
|
857
939
|
})
|
|
858
940
|
]).optional(),
|
|
859
941
|
/**
|
|
860
942
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
861
943
|
* When set to true, Claude will use at most one tool per response.
|
|
862
944
|
*/
|
|
863
|
-
disableParallelToolUse:
|
|
945
|
+
disableParallelToolUse: z4.boolean().optional(),
|
|
864
946
|
/**
|
|
865
947
|
* Cache control settings for this message.
|
|
866
948
|
* See https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
|
867
949
|
*/
|
|
868
|
-
cacheControl:
|
|
869
|
-
type:
|
|
870
|
-
ttl:
|
|
950
|
+
cacheControl: z4.object({
|
|
951
|
+
type: z4.literal("ephemeral"),
|
|
952
|
+
ttl: z4.union([z4.literal("5m"), z4.literal("1h")]).optional()
|
|
953
|
+
}).optional(),
|
|
954
|
+
/**
|
|
955
|
+
* Metadata to include with the request.
|
|
956
|
+
*
|
|
957
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
958
|
+
*/
|
|
959
|
+
metadata: z4.object({
|
|
960
|
+
/**
|
|
961
|
+
* An external identifier for the user associated with the request.
|
|
962
|
+
*
|
|
963
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
964
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
965
|
+
*/
|
|
966
|
+
userId: z4.string().optional()
|
|
871
967
|
}).optional(),
|
|
872
968
|
/**
|
|
873
969
|
* MCP servers to be utilized in this request.
|
|
874
970
|
*/
|
|
875
|
-
mcpServers:
|
|
876
|
-
|
|
877
|
-
type:
|
|
878
|
-
name:
|
|
879
|
-
url:
|
|
880
|
-
authorizationToken:
|
|
881
|
-
toolConfiguration:
|
|
882
|
-
enabled:
|
|
883
|
-
allowedTools:
|
|
971
|
+
mcpServers: z4.array(
|
|
972
|
+
z4.object({
|
|
973
|
+
type: z4.literal("url"),
|
|
974
|
+
name: z4.string(),
|
|
975
|
+
url: z4.string(),
|
|
976
|
+
authorizationToken: z4.string().nullish(),
|
|
977
|
+
toolConfiguration: z4.object({
|
|
978
|
+
enabled: z4.boolean().nullish(),
|
|
979
|
+
allowedTools: z4.array(z4.string()).nullish()
|
|
884
980
|
}).nullish()
|
|
885
981
|
})
|
|
886
982
|
).optional(),
|
|
@@ -889,83 +985,112 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
889
985
|
* like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
|
|
890
986
|
* Requires code execution tool to be enabled.
|
|
891
987
|
*/
|
|
892
|
-
container:
|
|
893
|
-
id:
|
|
894
|
-
skills:
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
988
|
+
container: z4.object({
|
|
989
|
+
id: z4.string().optional(),
|
|
990
|
+
skills: z4.array(
|
|
991
|
+
z4.discriminatedUnion("type", [
|
|
992
|
+
z4.object({
|
|
993
|
+
type: z4.literal("anthropic"),
|
|
994
|
+
skillId: z4.string(),
|
|
995
|
+
version: z4.string().optional()
|
|
996
|
+
}),
|
|
997
|
+
z4.object({
|
|
998
|
+
type: z4.literal("custom"),
|
|
999
|
+
providerReference: z4.record(z4.string(), z4.string()),
|
|
1000
|
+
version: z4.string().optional()
|
|
1001
|
+
})
|
|
1002
|
+
])
|
|
900
1003
|
).optional()
|
|
901
1004
|
}).optional(),
|
|
902
1005
|
/**
|
|
903
|
-
* Whether to enable
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
*
|
|
1006
|
+
* Whether to enable fine-grained (eager) streaming of tool call inputs
|
|
1007
|
+
* and structured outputs for every function tool in the request. When
|
|
1008
|
+
* true (the default), each function tool receives a default of
|
|
1009
|
+
* `eager_input_streaming: true` unless it explicitly sets
|
|
1010
|
+
* `providerOptions.anthropic.eagerInputStreaming`.
|
|
907
1011
|
*
|
|
908
1012
|
* @default true
|
|
909
1013
|
*/
|
|
910
|
-
toolStreaming:
|
|
1014
|
+
toolStreaming: z4.boolean().optional(),
|
|
911
1015
|
/**
|
|
912
1016
|
* @default 'high'
|
|
913
1017
|
*/
|
|
914
|
-
effort:
|
|
1018
|
+
effort: z4.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
1019
|
+
/**
|
|
1020
|
+
* Task budget for agentic turns. Informs the model of the total token budget
|
|
1021
|
+
* available for the current task, allowing it to prioritize work and wind down
|
|
1022
|
+
* gracefully as the budget is consumed.
|
|
1023
|
+
*
|
|
1024
|
+
* Advisory only — does not enforce a hard token limit.
|
|
1025
|
+
*/
|
|
1026
|
+
taskBudget: z4.object({
|
|
1027
|
+
type: z4.literal("tokens"),
|
|
1028
|
+
total: z4.number().int().min(2e4),
|
|
1029
|
+
remaining: z4.number().int().min(0).optional()
|
|
1030
|
+
}).optional(),
|
|
915
1031
|
/**
|
|
916
1032
|
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
917
1033
|
* Only supported with claude-opus-4-6.
|
|
918
1034
|
*/
|
|
919
|
-
speed:
|
|
1035
|
+
speed: z4.enum(["fast", "standard"]).optional(),
|
|
1036
|
+
/**
|
|
1037
|
+
* Controls where model inference runs for this request.
|
|
1038
|
+
*
|
|
1039
|
+
* - `"global"`: Inference may run in any available geography (default).
|
|
1040
|
+
* - `"us"`: Inference runs only in US-based infrastructure.
|
|
1041
|
+
*
|
|
1042
|
+
* See https://platform.claude.com/docs/en/build-with-claude/data-residency
|
|
1043
|
+
*/
|
|
1044
|
+
inferenceGeo: z4.enum(["us", "global"]).optional(),
|
|
920
1045
|
/**
|
|
921
1046
|
* A set of beta features to enable.
|
|
922
1047
|
* Allow a provider to receive the full `betas` set if it needs it.
|
|
923
1048
|
*/
|
|
924
|
-
anthropicBeta:
|
|
925
|
-
contextManagement:
|
|
926
|
-
edits:
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
type:
|
|
930
|
-
trigger:
|
|
931
|
-
|
|
932
|
-
type:
|
|
933
|
-
value:
|
|
1049
|
+
anthropicBeta: z4.array(z4.string()).optional(),
|
|
1050
|
+
contextManagement: z4.object({
|
|
1051
|
+
edits: z4.array(
|
|
1052
|
+
z4.discriminatedUnion("type", [
|
|
1053
|
+
z4.object({
|
|
1054
|
+
type: z4.literal("clear_tool_uses_20250919"),
|
|
1055
|
+
trigger: z4.discriminatedUnion("type", [
|
|
1056
|
+
z4.object({
|
|
1057
|
+
type: z4.literal("input_tokens"),
|
|
1058
|
+
value: z4.number()
|
|
934
1059
|
}),
|
|
935
|
-
|
|
936
|
-
type:
|
|
937
|
-
value:
|
|
1060
|
+
z4.object({
|
|
1061
|
+
type: z4.literal("tool_uses"),
|
|
1062
|
+
value: z4.number()
|
|
938
1063
|
})
|
|
939
1064
|
]).optional(),
|
|
940
|
-
keep:
|
|
941
|
-
type:
|
|
942
|
-
value:
|
|
1065
|
+
keep: z4.object({
|
|
1066
|
+
type: z4.literal("tool_uses"),
|
|
1067
|
+
value: z4.number()
|
|
943
1068
|
}).optional(),
|
|
944
|
-
clearAtLeast:
|
|
945
|
-
type:
|
|
946
|
-
value:
|
|
1069
|
+
clearAtLeast: z4.object({
|
|
1070
|
+
type: z4.literal("input_tokens"),
|
|
1071
|
+
value: z4.number()
|
|
947
1072
|
}).optional(),
|
|
948
|
-
clearToolInputs:
|
|
949
|
-
excludeTools:
|
|
1073
|
+
clearToolInputs: z4.boolean().optional(),
|
|
1074
|
+
excludeTools: z4.array(z4.string()).optional()
|
|
950
1075
|
}),
|
|
951
|
-
|
|
952
|
-
type:
|
|
953
|
-
keep:
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
type:
|
|
957
|
-
value:
|
|
1076
|
+
z4.object({
|
|
1077
|
+
type: z4.literal("clear_thinking_20251015"),
|
|
1078
|
+
keep: z4.union([
|
|
1079
|
+
z4.literal("all"),
|
|
1080
|
+
z4.object({
|
|
1081
|
+
type: z4.literal("thinking_turns"),
|
|
1082
|
+
value: z4.number()
|
|
958
1083
|
})
|
|
959
1084
|
]).optional()
|
|
960
1085
|
}),
|
|
961
|
-
|
|
962
|
-
type:
|
|
963
|
-
trigger:
|
|
964
|
-
type:
|
|
965
|
-
value:
|
|
1086
|
+
z4.object({
|
|
1087
|
+
type: z4.literal("compact_20260112"),
|
|
1088
|
+
trigger: z4.object({
|
|
1089
|
+
type: z4.literal("input_tokens"),
|
|
1090
|
+
value: z4.number()
|
|
966
1091
|
}).optional(),
|
|
967
|
-
pauseAfterCompaction:
|
|
968
|
-
instructions:
|
|
1092
|
+
pauseAfterCompaction: z4.boolean().optional(),
|
|
1093
|
+
instructions: z4.string().optional()
|
|
969
1094
|
})
|
|
970
1095
|
])
|
|
971
1096
|
)
|
|
@@ -973,7 +1098,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
973
1098
|
});
|
|
974
1099
|
|
|
975
1100
|
// src/anthropic-prepare-tools.ts
|
|
976
|
-
|
|
1101
|
+
import {
|
|
1102
|
+
UnsupportedFunctionalityError
|
|
1103
|
+
} from "@ai-sdk/provider";
|
|
977
1104
|
|
|
978
1105
|
// src/get-cache-control.ts
|
|
979
1106
|
var MAX_CACHE_BREAKPOINTS = 4;
|
|
@@ -1018,31 +1145,31 @@ var CacheControlValidator = class {
|
|
|
1018
1145
|
};
|
|
1019
1146
|
|
|
1020
1147
|
// src/tool/text-editor_20250728.ts
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
var textEditor_20250728ArgsSchema = (
|
|
1025
|
-
() => (
|
|
1026
|
-
|
|
1027
|
-
maxCharacters:
|
|
1148
|
+
import { createProviderToolFactory } from "@ai-sdk/provider-utils";
|
|
1149
|
+
import { z as z5 } from "zod/v4";
|
|
1150
|
+
import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
|
|
1151
|
+
var textEditor_20250728ArgsSchema = lazySchema4(
|
|
1152
|
+
() => zodSchema4(
|
|
1153
|
+
z5.object({
|
|
1154
|
+
maxCharacters: z5.number().optional()
|
|
1028
1155
|
})
|
|
1029
1156
|
)
|
|
1030
1157
|
);
|
|
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:
|
|
1158
|
+
var textEditor_20250728InputSchema = lazySchema4(
|
|
1159
|
+
() => zodSchema4(
|
|
1160
|
+
z5.object({
|
|
1161
|
+
command: z5.enum(["view", "create", "str_replace", "insert"]),
|
|
1162
|
+
path: z5.string(),
|
|
1163
|
+
file_text: z5.string().optional(),
|
|
1164
|
+
insert_line: z5.number().int().optional(),
|
|
1165
|
+
new_str: z5.string().optional(),
|
|
1166
|
+
insert_text: z5.string().optional(),
|
|
1167
|
+
old_str: z5.string().optional(),
|
|
1168
|
+
view_range: z5.array(z5.number().int()).optional()
|
|
1042
1169
|
})
|
|
1043
1170
|
)
|
|
1044
1171
|
);
|
|
1045
|
-
var factory =
|
|
1172
|
+
var factory = createProviderToolFactory({
|
|
1046
1173
|
id: "anthropic.text_editor_20250728",
|
|
1047
1174
|
inputSchema: textEditor_20250728InputSchema
|
|
1048
1175
|
});
|
|
@@ -1051,45 +1178,49 @@ var textEditor_20250728 = (args = {}) => {
|
|
|
1051
1178
|
};
|
|
1052
1179
|
|
|
1053
1180
|
// src/tool/web-search_20260209.ts
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1181
|
+
import {
|
|
1182
|
+
createProviderToolFactoryWithOutputSchema,
|
|
1183
|
+
lazySchema as lazySchema5,
|
|
1184
|
+
zodSchema as zodSchema5
|
|
1185
|
+
} from "@ai-sdk/provider-utils";
|
|
1186
|
+
import { z as z6 } from "zod/v4";
|
|
1187
|
+
var webSearch_20260209ArgsSchema = lazySchema5(
|
|
1188
|
+
() => zodSchema5(
|
|
1189
|
+
z6.object({
|
|
1190
|
+
maxUses: z6.number().optional(),
|
|
1191
|
+
allowedDomains: z6.array(z6.string()).optional(),
|
|
1192
|
+
blockedDomains: z6.array(z6.string()).optional(),
|
|
1193
|
+
userLocation: z6.object({
|
|
1194
|
+
type: z6.literal("approximate"),
|
|
1195
|
+
city: z6.string().optional(),
|
|
1196
|
+
region: z6.string().optional(),
|
|
1197
|
+
country: z6.string().optional(),
|
|
1198
|
+
timezone: z6.string().optional()
|
|
1068
1199
|
}).optional()
|
|
1069
1200
|
})
|
|
1070
1201
|
)
|
|
1071
1202
|
);
|
|
1072
|
-
var webSearch_20260209OutputSchema = (
|
|
1073
|
-
() => (
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
url:
|
|
1077
|
-
title:
|
|
1078
|
-
pageAge:
|
|
1079
|
-
encryptedContent:
|
|
1080
|
-
type:
|
|
1203
|
+
var webSearch_20260209OutputSchema = lazySchema5(
|
|
1204
|
+
() => zodSchema5(
|
|
1205
|
+
z6.array(
|
|
1206
|
+
z6.object({
|
|
1207
|
+
url: z6.string(),
|
|
1208
|
+
title: z6.string().nullable(),
|
|
1209
|
+
pageAge: z6.string().nullable(),
|
|
1210
|
+
encryptedContent: z6.string(),
|
|
1211
|
+
type: z6.literal("web_search_result")
|
|
1081
1212
|
})
|
|
1082
1213
|
)
|
|
1083
1214
|
)
|
|
1084
1215
|
);
|
|
1085
|
-
var webSearch_20260209InputSchema = (
|
|
1086
|
-
() => (
|
|
1087
|
-
|
|
1088
|
-
query:
|
|
1216
|
+
var webSearch_20260209InputSchema = lazySchema5(
|
|
1217
|
+
() => zodSchema5(
|
|
1218
|
+
z6.object({
|
|
1219
|
+
query: z6.string()
|
|
1089
1220
|
})
|
|
1090
1221
|
)
|
|
1091
1222
|
);
|
|
1092
|
-
var factory2 =
|
|
1223
|
+
var factory2 = createProviderToolFactoryWithOutputSchema({
|
|
1093
1224
|
id: "anthropic.web_search_20260209",
|
|
1094
1225
|
inputSchema: webSearch_20260209InputSchema,
|
|
1095
1226
|
outputSchema: webSearch_20260209OutputSchema,
|
|
@@ -1100,45 +1231,49 @@ var webSearch_20260209 = (args = {}) => {
|
|
|
1100
1231
|
};
|
|
1101
1232
|
|
|
1102
1233
|
// src/tool/web-search_20250305.ts
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1234
|
+
import {
|
|
1235
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
|
|
1236
|
+
lazySchema as lazySchema6,
|
|
1237
|
+
zodSchema as zodSchema6
|
|
1238
|
+
} from "@ai-sdk/provider-utils";
|
|
1239
|
+
import { z as z7 } from "zod/v4";
|
|
1240
|
+
var webSearch_20250305ArgsSchema = lazySchema6(
|
|
1241
|
+
() => zodSchema6(
|
|
1242
|
+
z7.object({
|
|
1243
|
+
maxUses: z7.number().optional(),
|
|
1244
|
+
allowedDomains: z7.array(z7.string()).optional(),
|
|
1245
|
+
blockedDomains: z7.array(z7.string()).optional(),
|
|
1246
|
+
userLocation: z7.object({
|
|
1247
|
+
type: z7.literal("approximate"),
|
|
1248
|
+
city: z7.string().optional(),
|
|
1249
|
+
region: z7.string().optional(),
|
|
1250
|
+
country: z7.string().optional(),
|
|
1251
|
+
timezone: z7.string().optional()
|
|
1117
1252
|
}).optional()
|
|
1118
1253
|
})
|
|
1119
1254
|
)
|
|
1120
1255
|
);
|
|
1121
|
-
var webSearch_20250305OutputSchema = (
|
|
1122
|
-
() => (
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
url:
|
|
1126
|
-
title:
|
|
1127
|
-
pageAge:
|
|
1128
|
-
encryptedContent:
|
|
1129
|
-
type:
|
|
1256
|
+
var webSearch_20250305OutputSchema = lazySchema6(
|
|
1257
|
+
() => zodSchema6(
|
|
1258
|
+
z7.array(
|
|
1259
|
+
z7.object({
|
|
1260
|
+
url: z7.string(),
|
|
1261
|
+
title: z7.string().nullable(),
|
|
1262
|
+
pageAge: z7.string().nullable(),
|
|
1263
|
+
encryptedContent: z7.string(),
|
|
1264
|
+
type: z7.literal("web_search_result")
|
|
1130
1265
|
})
|
|
1131
1266
|
)
|
|
1132
1267
|
)
|
|
1133
1268
|
);
|
|
1134
|
-
var webSearch_20250305InputSchema = (
|
|
1135
|
-
() => (
|
|
1136
|
-
|
|
1137
|
-
query:
|
|
1269
|
+
var webSearch_20250305InputSchema = lazySchema6(
|
|
1270
|
+
() => zodSchema6(
|
|
1271
|
+
z7.object({
|
|
1272
|
+
query: z7.string()
|
|
1138
1273
|
})
|
|
1139
1274
|
)
|
|
1140
1275
|
);
|
|
1141
|
-
var factory3 = (
|
|
1276
|
+
var factory3 = createProviderToolFactoryWithOutputSchema2({
|
|
1142
1277
|
id: "anthropic.web_search_20250305",
|
|
1143
1278
|
inputSchema: webSearch_20250305InputSchema,
|
|
1144
1279
|
outputSchema: webSearch_20250305OutputSchema,
|
|
@@ -1149,53 +1284,57 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
1149
1284
|
};
|
|
1150
1285
|
|
|
1151
1286
|
// src/tool/web-fetch-20260209.ts
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1287
|
+
import {
|
|
1288
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
|
|
1289
|
+
lazySchema as lazySchema7,
|
|
1290
|
+
zodSchema as zodSchema7
|
|
1291
|
+
} from "@ai-sdk/provider-utils";
|
|
1292
|
+
import { z as z8 } from "zod/v4";
|
|
1293
|
+
var webFetch_20260209ArgsSchema = lazySchema7(
|
|
1294
|
+
() => zodSchema7(
|
|
1295
|
+
z8.object({
|
|
1296
|
+
maxUses: z8.number().optional(),
|
|
1297
|
+
allowedDomains: z8.array(z8.string()).optional(),
|
|
1298
|
+
blockedDomains: z8.array(z8.string()).optional(),
|
|
1299
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1300
|
+
maxContentTokens: z8.number().optional()
|
|
1162
1301
|
})
|
|
1163
1302
|
)
|
|
1164
1303
|
);
|
|
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:
|
|
1304
|
+
var webFetch_20260209OutputSchema = lazySchema7(
|
|
1305
|
+
() => zodSchema7(
|
|
1306
|
+
z8.object({
|
|
1307
|
+
type: z8.literal("web_fetch_result"),
|
|
1308
|
+
url: z8.string(),
|
|
1309
|
+
content: z8.object({
|
|
1310
|
+
type: z8.literal("document"),
|
|
1311
|
+
title: z8.string().nullable(),
|
|
1312
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1313
|
+
source: z8.union([
|
|
1314
|
+
z8.object({
|
|
1315
|
+
type: z8.literal("base64"),
|
|
1316
|
+
mediaType: z8.literal("application/pdf"),
|
|
1317
|
+
data: z8.string()
|
|
1179
1318
|
}),
|
|
1180
|
-
|
|
1181
|
-
type:
|
|
1182
|
-
mediaType:
|
|
1183
|
-
data:
|
|
1319
|
+
z8.object({
|
|
1320
|
+
type: z8.literal("text"),
|
|
1321
|
+
mediaType: z8.literal("text/plain"),
|
|
1322
|
+
data: z8.string()
|
|
1184
1323
|
})
|
|
1185
1324
|
])
|
|
1186
1325
|
}),
|
|
1187
|
-
retrievedAt:
|
|
1326
|
+
retrievedAt: z8.string().nullable()
|
|
1188
1327
|
})
|
|
1189
1328
|
)
|
|
1190
1329
|
);
|
|
1191
|
-
var webFetch_20260209InputSchema = (
|
|
1192
|
-
() => (
|
|
1193
|
-
|
|
1194
|
-
url:
|
|
1330
|
+
var webFetch_20260209InputSchema = lazySchema7(
|
|
1331
|
+
() => zodSchema7(
|
|
1332
|
+
z8.object({
|
|
1333
|
+
url: z8.string()
|
|
1195
1334
|
})
|
|
1196
1335
|
)
|
|
1197
1336
|
);
|
|
1198
|
-
var factory4 = (
|
|
1337
|
+
var factory4 = createProviderToolFactoryWithOutputSchema3({
|
|
1199
1338
|
id: "anthropic.web_fetch_20260209",
|
|
1200
1339
|
inputSchema: webFetch_20260209InputSchema,
|
|
1201
1340
|
outputSchema: webFetch_20260209OutputSchema,
|
|
@@ -1206,53 +1345,57 @@ var webFetch_20260209 = (args = {}) => {
|
|
|
1206
1345
|
};
|
|
1207
1346
|
|
|
1208
1347
|
// src/tool/web-fetch-20250910.ts
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1348
|
+
import {
|
|
1349
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
|
|
1350
|
+
lazySchema as lazySchema8,
|
|
1351
|
+
zodSchema as zodSchema8
|
|
1352
|
+
} from "@ai-sdk/provider-utils";
|
|
1353
|
+
import { z as z9 } from "zod/v4";
|
|
1354
|
+
var webFetch_20250910ArgsSchema = lazySchema8(
|
|
1355
|
+
() => zodSchema8(
|
|
1356
|
+
z9.object({
|
|
1357
|
+
maxUses: z9.number().optional(),
|
|
1358
|
+
allowedDomains: z9.array(z9.string()).optional(),
|
|
1359
|
+
blockedDomains: z9.array(z9.string()).optional(),
|
|
1360
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1361
|
+
maxContentTokens: z9.number().optional()
|
|
1219
1362
|
})
|
|
1220
1363
|
)
|
|
1221
1364
|
);
|
|
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:
|
|
1365
|
+
var webFetch_20250910OutputSchema = lazySchema8(
|
|
1366
|
+
() => zodSchema8(
|
|
1367
|
+
z9.object({
|
|
1368
|
+
type: z9.literal("web_fetch_result"),
|
|
1369
|
+
url: z9.string(),
|
|
1370
|
+
content: z9.object({
|
|
1371
|
+
type: z9.literal("document"),
|
|
1372
|
+
title: z9.string().nullable(),
|
|
1373
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1374
|
+
source: z9.union([
|
|
1375
|
+
z9.object({
|
|
1376
|
+
type: z9.literal("base64"),
|
|
1377
|
+
mediaType: z9.literal("application/pdf"),
|
|
1378
|
+
data: z9.string()
|
|
1236
1379
|
}),
|
|
1237
|
-
|
|
1238
|
-
type:
|
|
1239
|
-
mediaType:
|
|
1240
|
-
data:
|
|
1380
|
+
z9.object({
|
|
1381
|
+
type: z9.literal("text"),
|
|
1382
|
+
mediaType: z9.literal("text/plain"),
|
|
1383
|
+
data: z9.string()
|
|
1241
1384
|
})
|
|
1242
1385
|
])
|
|
1243
1386
|
}),
|
|
1244
|
-
retrievedAt:
|
|
1387
|
+
retrievedAt: z9.string().nullable()
|
|
1245
1388
|
})
|
|
1246
1389
|
)
|
|
1247
1390
|
);
|
|
1248
|
-
var webFetch_20250910InputSchema = (
|
|
1249
|
-
() => (
|
|
1250
|
-
|
|
1251
|
-
url:
|
|
1391
|
+
var webFetch_20250910InputSchema = lazySchema8(
|
|
1392
|
+
() => zodSchema8(
|
|
1393
|
+
z9.object({
|
|
1394
|
+
url: z9.string()
|
|
1252
1395
|
})
|
|
1253
1396
|
)
|
|
1254
1397
|
);
|
|
1255
|
-
var factory5 = (
|
|
1398
|
+
var factory5 = createProviderToolFactoryWithOutputSchema4({
|
|
1256
1399
|
id: "anthropic.web_fetch_20250910",
|
|
1257
1400
|
inputSchema: webFetch_20250910InputSchema,
|
|
1258
1401
|
outputSchema: webFetch_20250910OutputSchema,
|
|
@@ -1263,15 +1406,17 @@ var webFetch_20250910 = (args = {}) => {
|
|
|
1263
1406
|
};
|
|
1264
1407
|
|
|
1265
1408
|
// src/anthropic-prepare-tools.ts
|
|
1266
|
-
|
|
1409
|
+
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
1267
1410
|
async function prepareTools({
|
|
1268
1411
|
tools,
|
|
1269
1412
|
toolChoice,
|
|
1270
1413
|
disableParallelToolUse,
|
|
1271
1414
|
cacheControlValidator,
|
|
1272
|
-
supportsStructuredOutput
|
|
1415
|
+
supportsStructuredOutput,
|
|
1416
|
+
supportsStrictTools,
|
|
1417
|
+
defaultEagerInputStreaming = false
|
|
1273
1418
|
}) {
|
|
1274
|
-
var _a;
|
|
1419
|
+
var _a, _b;
|
|
1275
1420
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1276
1421
|
const toolWarnings = [];
|
|
1277
1422
|
const betas = /* @__PURE__ */ new Set();
|
|
@@ -1288,16 +1433,23 @@ async function prepareTools({
|
|
|
1288
1433
|
canCache: true
|
|
1289
1434
|
});
|
|
1290
1435
|
const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
|
|
1291
|
-
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1436
|
+
const eagerInputStreaming = (_b = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming) != null ? _b : defaultEagerInputStreaming;
|
|
1292
1437
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1293
1438
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1439
|
+
if (!supportsStrictTools && tool.strict != null) {
|
|
1440
|
+
toolWarnings.push({
|
|
1441
|
+
type: "unsupported",
|
|
1442
|
+
feature: "strict",
|
|
1443
|
+
details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1294
1446
|
anthropicTools2.push({
|
|
1295
1447
|
name: tool.name,
|
|
1296
1448
|
description: tool.description,
|
|
1297
1449
|
input_schema: tool.inputSchema,
|
|
1298
1450
|
cache_control: cacheControl,
|
|
1299
1451
|
...eagerInputStreaming ? { eager_input_streaming: true } : {},
|
|
1300
|
-
...
|
|
1452
|
+
...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
|
|
1301
1453
|
...deferLoading != null ? { defer_loading: deferLoading } : {},
|
|
1302
1454
|
...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
|
|
1303
1455
|
...tool.inputExamples != null ? {
|
|
@@ -1405,7 +1557,7 @@ async function prepareTools({
|
|
|
1405
1557
|
break;
|
|
1406
1558
|
}
|
|
1407
1559
|
case "anthropic.text_editor_20250728": {
|
|
1408
|
-
const args = await
|
|
1560
|
+
const args = await validateTypes({
|
|
1409
1561
|
value: tool.args,
|
|
1410
1562
|
schema: textEditor_20250728ArgsSchema
|
|
1411
1563
|
});
|
|
@@ -1445,7 +1597,7 @@ async function prepareTools({
|
|
|
1445
1597
|
}
|
|
1446
1598
|
case "anthropic.web_fetch_20250910": {
|
|
1447
1599
|
betas.add("web-fetch-2025-09-10");
|
|
1448
|
-
const args = await
|
|
1600
|
+
const args = await validateTypes({
|
|
1449
1601
|
value: tool.args,
|
|
1450
1602
|
schema: webFetch_20250910ArgsSchema
|
|
1451
1603
|
});
|
|
@@ -1463,7 +1615,7 @@ async function prepareTools({
|
|
|
1463
1615
|
}
|
|
1464
1616
|
case "anthropic.web_fetch_20260209": {
|
|
1465
1617
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1466
|
-
const args = await
|
|
1618
|
+
const args = await validateTypes({
|
|
1467
1619
|
value: tool.args,
|
|
1468
1620
|
schema: webFetch_20260209ArgsSchema
|
|
1469
1621
|
});
|
|
@@ -1480,7 +1632,7 @@ async function prepareTools({
|
|
|
1480
1632
|
break;
|
|
1481
1633
|
}
|
|
1482
1634
|
case "anthropic.web_search_20250305": {
|
|
1483
|
-
const args = await
|
|
1635
|
+
const args = await validateTypes({
|
|
1484
1636
|
value: tool.args,
|
|
1485
1637
|
schema: webSearch_20250305ArgsSchema
|
|
1486
1638
|
});
|
|
@@ -1497,7 +1649,7 @@ async function prepareTools({
|
|
|
1497
1649
|
}
|
|
1498
1650
|
case "anthropic.web_search_20260209": {
|
|
1499
1651
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1500
|
-
const args = await
|
|
1652
|
+
const args = await validateTypes({
|
|
1501
1653
|
value: tool.args,
|
|
1502
1654
|
schema: webSearch_20260209ArgsSchema
|
|
1503
1655
|
});
|
|
@@ -1513,7 +1665,6 @@ async function prepareTools({
|
|
|
1513
1665
|
break;
|
|
1514
1666
|
}
|
|
1515
1667
|
case "anthropic.tool_search_regex_20251119": {
|
|
1516
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1517
1668
|
anthropicTools2.push({
|
|
1518
1669
|
type: "tool_search_tool_regex_20251119",
|
|
1519
1670
|
name: "tool_search_tool_regex"
|
|
@@ -1521,7 +1672,6 @@ async function prepareTools({
|
|
|
1521
1672
|
break;
|
|
1522
1673
|
}
|
|
1523
1674
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1524
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1525
1675
|
anthropicTools2.push({
|
|
1526
1676
|
type: "tool_search_tool_bm25_20251119",
|
|
1527
1677
|
name: "tool_search_tool_bm25"
|
|
@@ -1592,7 +1742,7 @@ async function prepareTools({
|
|
|
1592
1742
|
};
|
|
1593
1743
|
default: {
|
|
1594
1744
|
const _exhaustiveCheck = type;
|
|
1595
|
-
throw new
|
|
1745
|
+
throw new UnsupportedFunctionalityError({
|
|
1596
1746
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1597
1747
|
});
|
|
1598
1748
|
}
|
|
@@ -1640,36 +1790,50 @@ function convertAnthropicMessagesUsage({
|
|
|
1640
1790
|
}
|
|
1641
1791
|
|
|
1642
1792
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
1643
|
-
|
|
1644
|
-
|
|
1793
|
+
import {
|
|
1794
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
1795
|
+
} from "@ai-sdk/provider";
|
|
1796
|
+
import {
|
|
1797
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
1798
|
+
convertToBase64,
|
|
1799
|
+
isProviderReference,
|
|
1800
|
+
parseProviderOptions,
|
|
1801
|
+
resolveProviderReference,
|
|
1802
|
+
validateTypes as validateTypes2,
|
|
1803
|
+
isNonNullable
|
|
1804
|
+
} from "@ai-sdk/provider-utils";
|
|
1645
1805
|
|
|
1646
1806
|
// src/tool/code-execution_20250522.ts
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1807
|
+
import {
|
|
1808
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
|
|
1809
|
+
lazySchema as lazySchema9,
|
|
1810
|
+
zodSchema as zodSchema9
|
|
1811
|
+
} from "@ai-sdk/provider-utils";
|
|
1812
|
+
import { z as z10 } from "zod/v4";
|
|
1813
|
+
var codeExecution_20250522OutputSchema = lazySchema9(
|
|
1814
|
+
() => zodSchema9(
|
|
1815
|
+
z10.object({
|
|
1816
|
+
type: z10.literal("code_execution_result"),
|
|
1817
|
+
stdout: z10.string(),
|
|
1818
|
+
stderr: z10.string(),
|
|
1819
|
+
return_code: z10.number(),
|
|
1820
|
+
content: z10.array(
|
|
1821
|
+
z10.object({
|
|
1822
|
+
type: z10.literal("code_execution_output"),
|
|
1823
|
+
file_id: z10.string()
|
|
1660
1824
|
})
|
|
1661
1825
|
).optional().default([])
|
|
1662
1826
|
})
|
|
1663
1827
|
)
|
|
1664
1828
|
);
|
|
1665
|
-
var codeExecution_20250522InputSchema = (
|
|
1666
|
-
() => (
|
|
1667
|
-
|
|
1668
|
-
code:
|
|
1829
|
+
var codeExecution_20250522InputSchema = lazySchema9(
|
|
1830
|
+
() => zodSchema9(
|
|
1831
|
+
z10.object({
|
|
1832
|
+
code: z10.string()
|
|
1669
1833
|
})
|
|
1670
1834
|
)
|
|
1671
1835
|
);
|
|
1672
|
-
var factory6 = (
|
|
1836
|
+
var factory6 = createProviderToolFactoryWithOutputSchema5({
|
|
1673
1837
|
id: "anthropic.code_execution_20250522",
|
|
1674
1838
|
inputSchema: codeExecution_20250522InputSchema,
|
|
1675
1839
|
outputSchema: codeExecution_20250522OutputSchema
|
|
@@ -1679,102 +1843,106 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
1679
1843
|
};
|
|
1680
1844
|
|
|
1681
1845
|
// src/tool/code-execution_20250825.ts
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1846
|
+
import {
|
|
1847
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
|
|
1848
|
+
lazySchema as lazySchema10,
|
|
1849
|
+
zodSchema as zodSchema10
|
|
1850
|
+
} from "@ai-sdk/provider-utils";
|
|
1851
|
+
import { z as z11 } from "zod/v4";
|
|
1852
|
+
var codeExecution_20250825OutputSchema = lazySchema10(
|
|
1853
|
+
() => zodSchema10(
|
|
1854
|
+
z11.discriminatedUnion("type", [
|
|
1855
|
+
z11.object({
|
|
1856
|
+
type: z11.literal("code_execution_result"),
|
|
1857
|
+
stdout: z11.string(),
|
|
1858
|
+
stderr: z11.string(),
|
|
1859
|
+
return_code: z11.number(),
|
|
1860
|
+
content: z11.array(
|
|
1861
|
+
z11.object({
|
|
1862
|
+
type: z11.literal("code_execution_output"),
|
|
1863
|
+
file_id: z11.string()
|
|
1696
1864
|
})
|
|
1697
1865
|
).optional().default([])
|
|
1698
1866
|
}),
|
|
1699
|
-
|
|
1700
|
-
type:
|
|
1701
|
-
content:
|
|
1702
|
-
|
|
1703
|
-
type:
|
|
1704
|
-
file_id:
|
|
1867
|
+
z11.object({
|
|
1868
|
+
type: z11.literal("bash_code_execution_result"),
|
|
1869
|
+
content: z11.array(
|
|
1870
|
+
z11.object({
|
|
1871
|
+
type: z11.literal("bash_code_execution_output"),
|
|
1872
|
+
file_id: z11.string()
|
|
1705
1873
|
})
|
|
1706
1874
|
),
|
|
1707
|
-
stdout:
|
|
1708
|
-
stderr:
|
|
1709
|
-
return_code:
|
|
1875
|
+
stdout: z11.string(),
|
|
1876
|
+
stderr: z11.string(),
|
|
1877
|
+
return_code: z11.number()
|
|
1710
1878
|
}),
|
|
1711
|
-
|
|
1712
|
-
type:
|
|
1713
|
-
error_code:
|
|
1879
|
+
z11.object({
|
|
1880
|
+
type: z11.literal("bash_code_execution_tool_result_error"),
|
|
1881
|
+
error_code: z11.string()
|
|
1714
1882
|
}),
|
|
1715
|
-
|
|
1716
|
-
type:
|
|
1717
|
-
error_code:
|
|
1883
|
+
z11.object({
|
|
1884
|
+
type: z11.literal("text_editor_code_execution_tool_result_error"),
|
|
1885
|
+
error_code: z11.string()
|
|
1718
1886
|
}),
|
|
1719
|
-
|
|
1720
|
-
type:
|
|
1721
|
-
content:
|
|
1722
|
-
file_type:
|
|
1723
|
-
num_lines:
|
|
1724
|
-
start_line:
|
|
1725
|
-
total_lines:
|
|
1887
|
+
z11.object({
|
|
1888
|
+
type: z11.literal("text_editor_code_execution_view_result"),
|
|
1889
|
+
content: z11.string(),
|
|
1890
|
+
file_type: z11.string(),
|
|
1891
|
+
num_lines: z11.number().nullable(),
|
|
1892
|
+
start_line: z11.number().nullable(),
|
|
1893
|
+
total_lines: z11.number().nullable()
|
|
1726
1894
|
}),
|
|
1727
|
-
|
|
1728
|
-
type:
|
|
1729
|
-
is_file_update:
|
|
1895
|
+
z11.object({
|
|
1896
|
+
type: z11.literal("text_editor_code_execution_create_result"),
|
|
1897
|
+
is_file_update: z11.boolean()
|
|
1730
1898
|
}),
|
|
1731
|
-
|
|
1732
|
-
type:
|
|
1733
|
-
lines:
|
|
1734
|
-
new_lines:
|
|
1735
|
-
new_start:
|
|
1736
|
-
old_lines:
|
|
1737
|
-
old_start:
|
|
1899
|
+
z11.object({
|
|
1900
|
+
type: z11.literal("text_editor_code_execution_str_replace_result"),
|
|
1901
|
+
lines: z11.array(z11.string()).nullable(),
|
|
1902
|
+
new_lines: z11.number().nullable(),
|
|
1903
|
+
new_start: z11.number().nullable(),
|
|
1904
|
+
old_lines: z11.number().nullable(),
|
|
1905
|
+
old_start: z11.number().nullable()
|
|
1738
1906
|
})
|
|
1739
1907
|
])
|
|
1740
1908
|
)
|
|
1741
1909
|
);
|
|
1742
|
-
var codeExecution_20250825InputSchema = (
|
|
1743
|
-
() => (
|
|
1744
|
-
|
|
1910
|
+
var codeExecution_20250825InputSchema = lazySchema10(
|
|
1911
|
+
() => zodSchema10(
|
|
1912
|
+
z11.discriminatedUnion("type", [
|
|
1745
1913
|
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1746
|
-
|
|
1747
|
-
type:
|
|
1748
|
-
code:
|
|
1914
|
+
z11.object({
|
|
1915
|
+
type: z11.literal("programmatic-tool-call"),
|
|
1916
|
+
code: z11.string()
|
|
1749
1917
|
}),
|
|
1750
|
-
|
|
1751
|
-
type:
|
|
1752
|
-
command:
|
|
1918
|
+
z11.object({
|
|
1919
|
+
type: z11.literal("bash_code_execution"),
|
|
1920
|
+
command: z11.string()
|
|
1753
1921
|
}),
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
type:
|
|
1757
|
-
command:
|
|
1758
|
-
path:
|
|
1922
|
+
z11.discriminatedUnion("command", [
|
|
1923
|
+
z11.object({
|
|
1924
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1925
|
+
command: z11.literal("view"),
|
|
1926
|
+
path: z11.string()
|
|
1759
1927
|
}),
|
|
1760
|
-
|
|
1761
|
-
type:
|
|
1762
|
-
command:
|
|
1763
|
-
path:
|
|
1764
|
-
file_text:
|
|
1928
|
+
z11.object({
|
|
1929
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1930
|
+
command: z11.literal("create"),
|
|
1931
|
+
path: z11.string(),
|
|
1932
|
+
file_text: z11.string().nullish()
|
|
1765
1933
|
}),
|
|
1766
|
-
|
|
1767
|
-
type:
|
|
1768
|
-
command:
|
|
1769
|
-
path:
|
|
1770
|
-
old_str:
|
|
1771
|
-
new_str:
|
|
1934
|
+
z11.object({
|
|
1935
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1936
|
+
command: z11.literal("str_replace"),
|
|
1937
|
+
path: z11.string(),
|
|
1938
|
+
old_str: z11.string(),
|
|
1939
|
+
new_str: z11.string()
|
|
1772
1940
|
})
|
|
1773
1941
|
])
|
|
1774
1942
|
])
|
|
1775
1943
|
)
|
|
1776
1944
|
);
|
|
1777
|
-
var factory7 = (
|
|
1945
|
+
var factory7 = createProviderToolFactoryWithOutputSchema6({
|
|
1778
1946
|
id: "anthropic.code_execution_20250825",
|
|
1779
1947
|
inputSchema: codeExecution_20250825InputSchema,
|
|
1780
1948
|
outputSchema: codeExecution_20250825OutputSchema,
|
|
@@ -1788,113 +1956,117 @@ var codeExecution_20250825 = (args = {}) => {
|
|
|
1788
1956
|
};
|
|
1789
1957
|
|
|
1790
1958
|
// src/tool/code-execution_20260120.ts
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1959
|
+
import {
|
|
1960
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
|
|
1961
|
+
lazySchema as lazySchema11,
|
|
1962
|
+
zodSchema as zodSchema11
|
|
1963
|
+
} from "@ai-sdk/provider-utils";
|
|
1964
|
+
import { z as z12 } from "zod/v4";
|
|
1965
|
+
var codeExecution_20260120OutputSchema = lazySchema11(
|
|
1966
|
+
() => zodSchema11(
|
|
1967
|
+
z12.discriminatedUnion("type", [
|
|
1968
|
+
z12.object({
|
|
1969
|
+
type: z12.literal("code_execution_result"),
|
|
1970
|
+
stdout: z12.string(),
|
|
1971
|
+
stderr: z12.string(),
|
|
1972
|
+
return_code: z12.number(),
|
|
1973
|
+
content: z12.array(
|
|
1974
|
+
z12.object({
|
|
1975
|
+
type: z12.literal("code_execution_output"),
|
|
1976
|
+
file_id: z12.string()
|
|
1805
1977
|
})
|
|
1806
1978
|
).optional().default([])
|
|
1807
1979
|
}),
|
|
1808
|
-
|
|
1809
|
-
type:
|
|
1810
|
-
encrypted_stdout:
|
|
1811
|
-
stderr:
|
|
1812
|
-
return_code:
|
|
1813
|
-
content:
|
|
1814
|
-
|
|
1815
|
-
type:
|
|
1816
|
-
file_id:
|
|
1980
|
+
z12.object({
|
|
1981
|
+
type: z12.literal("encrypted_code_execution_result"),
|
|
1982
|
+
encrypted_stdout: z12.string(),
|
|
1983
|
+
stderr: z12.string(),
|
|
1984
|
+
return_code: z12.number(),
|
|
1985
|
+
content: z12.array(
|
|
1986
|
+
z12.object({
|
|
1987
|
+
type: z12.literal("code_execution_output"),
|
|
1988
|
+
file_id: z12.string()
|
|
1817
1989
|
})
|
|
1818
1990
|
).optional().default([])
|
|
1819
1991
|
}),
|
|
1820
|
-
|
|
1821
|
-
type:
|
|
1822
|
-
content:
|
|
1823
|
-
|
|
1824
|
-
type:
|
|
1825
|
-
file_id:
|
|
1992
|
+
z12.object({
|
|
1993
|
+
type: z12.literal("bash_code_execution_result"),
|
|
1994
|
+
content: z12.array(
|
|
1995
|
+
z12.object({
|
|
1996
|
+
type: z12.literal("bash_code_execution_output"),
|
|
1997
|
+
file_id: z12.string()
|
|
1826
1998
|
})
|
|
1827
1999
|
),
|
|
1828
|
-
stdout:
|
|
1829
|
-
stderr:
|
|
1830
|
-
return_code:
|
|
2000
|
+
stdout: z12.string(),
|
|
2001
|
+
stderr: z12.string(),
|
|
2002
|
+
return_code: z12.number()
|
|
1831
2003
|
}),
|
|
1832
|
-
|
|
1833
|
-
type:
|
|
1834
|
-
error_code:
|
|
2004
|
+
z12.object({
|
|
2005
|
+
type: z12.literal("bash_code_execution_tool_result_error"),
|
|
2006
|
+
error_code: z12.string()
|
|
1835
2007
|
}),
|
|
1836
|
-
|
|
1837
|
-
type:
|
|
1838
|
-
error_code:
|
|
2008
|
+
z12.object({
|
|
2009
|
+
type: z12.literal("text_editor_code_execution_tool_result_error"),
|
|
2010
|
+
error_code: z12.string()
|
|
1839
2011
|
}),
|
|
1840
|
-
|
|
1841
|
-
type:
|
|
1842
|
-
content:
|
|
1843
|
-
file_type:
|
|
1844
|
-
num_lines:
|
|
1845
|
-
start_line:
|
|
1846
|
-
total_lines:
|
|
2012
|
+
z12.object({
|
|
2013
|
+
type: z12.literal("text_editor_code_execution_view_result"),
|
|
2014
|
+
content: z12.string(),
|
|
2015
|
+
file_type: z12.string(),
|
|
2016
|
+
num_lines: z12.number().nullable(),
|
|
2017
|
+
start_line: z12.number().nullable(),
|
|
2018
|
+
total_lines: z12.number().nullable()
|
|
1847
2019
|
}),
|
|
1848
|
-
|
|
1849
|
-
type:
|
|
1850
|
-
is_file_update:
|
|
2020
|
+
z12.object({
|
|
2021
|
+
type: z12.literal("text_editor_code_execution_create_result"),
|
|
2022
|
+
is_file_update: z12.boolean()
|
|
1851
2023
|
}),
|
|
1852
|
-
|
|
1853
|
-
type:
|
|
1854
|
-
lines:
|
|
1855
|
-
new_lines:
|
|
1856
|
-
new_start:
|
|
1857
|
-
old_lines:
|
|
1858
|
-
old_start:
|
|
2024
|
+
z12.object({
|
|
2025
|
+
type: z12.literal("text_editor_code_execution_str_replace_result"),
|
|
2026
|
+
lines: z12.array(z12.string()).nullable(),
|
|
2027
|
+
new_lines: z12.number().nullable(),
|
|
2028
|
+
new_start: z12.number().nullable(),
|
|
2029
|
+
old_lines: z12.number().nullable(),
|
|
2030
|
+
old_start: z12.number().nullable()
|
|
1859
2031
|
})
|
|
1860
2032
|
])
|
|
1861
2033
|
)
|
|
1862
2034
|
);
|
|
1863
|
-
var codeExecution_20260120InputSchema = (
|
|
1864
|
-
() => (
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
type:
|
|
1868
|
-
code:
|
|
2035
|
+
var codeExecution_20260120InputSchema = lazySchema11(
|
|
2036
|
+
() => zodSchema11(
|
|
2037
|
+
z12.discriminatedUnion("type", [
|
|
2038
|
+
z12.object({
|
|
2039
|
+
type: z12.literal("programmatic-tool-call"),
|
|
2040
|
+
code: z12.string()
|
|
1869
2041
|
}),
|
|
1870
|
-
|
|
1871
|
-
type:
|
|
1872
|
-
command:
|
|
2042
|
+
z12.object({
|
|
2043
|
+
type: z12.literal("bash_code_execution"),
|
|
2044
|
+
command: z12.string()
|
|
1873
2045
|
}),
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
type:
|
|
1877
|
-
command:
|
|
1878
|
-
path:
|
|
2046
|
+
z12.discriminatedUnion("command", [
|
|
2047
|
+
z12.object({
|
|
2048
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2049
|
+
command: z12.literal("view"),
|
|
2050
|
+
path: z12.string()
|
|
1879
2051
|
}),
|
|
1880
|
-
|
|
1881
|
-
type:
|
|
1882
|
-
command:
|
|
1883
|
-
path:
|
|
1884
|
-
file_text:
|
|
2052
|
+
z12.object({
|
|
2053
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2054
|
+
command: z12.literal("create"),
|
|
2055
|
+
path: z12.string(),
|
|
2056
|
+
file_text: z12.string().nullish()
|
|
1885
2057
|
}),
|
|
1886
|
-
|
|
1887
|
-
type:
|
|
1888
|
-
command:
|
|
1889
|
-
path:
|
|
1890
|
-
old_str:
|
|
1891
|
-
new_str:
|
|
2058
|
+
z12.object({
|
|
2059
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2060
|
+
command: z12.literal("str_replace"),
|
|
2061
|
+
path: z12.string(),
|
|
2062
|
+
old_str: z12.string(),
|
|
2063
|
+
new_str: z12.string()
|
|
1892
2064
|
})
|
|
1893
2065
|
])
|
|
1894
2066
|
])
|
|
1895
2067
|
)
|
|
1896
2068
|
);
|
|
1897
|
-
var factory8 = (
|
|
2069
|
+
var factory8 = createProviderToolFactoryWithOutputSchema7({
|
|
1898
2070
|
id: "anthropic.code_execution_20260120",
|
|
1899
2071
|
inputSchema: codeExecution_20260120InputSchema,
|
|
1900
2072
|
outputSchema: codeExecution_20260120OutputSchema,
|
|
@@ -1905,21 +2077,25 @@ var codeExecution_20260120 = (args = {}) => {
|
|
|
1905
2077
|
};
|
|
1906
2078
|
|
|
1907
2079
|
// src/tool/tool-search-regex_20251119.ts
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
2080
|
+
import {
|
|
2081
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
|
|
2082
|
+
lazySchema as lazySchema12,
|
|
2083
|
+
zodSchema as zodSchema12
|
|
2084
|
+
} from "@ai-sdk/provider-utils";
|
|
2085
|
+
import { z as z13 } from "zod/v4";
|
|
2086
|
+
var toolSearchRegex_20251119OutputSchema = lazySchema12(
|
|
2087
|
+
() => zodSchema12(
|
|
2088
|
+
z13.array(
|
|
2089
|
+
z13.object({
|
|
2090
|
+
type: z13.literal("tool_reference"),
|
|
2091
|
+
toolName: z13.string()
|
|
1916
2092
|
})
|
|
1917
2093
|
)
|
|
1918
2094
|
)
|
|
1919
2095
|
);
|
|
1920
|
-
var toolSearchRegex_20251119InputSchema = (
|
|
1921
|
-
() => (
|
|
1922
|
-
|
|
2096
|
+
var toolSearchRegex_20251119InputSchema = lazySchema12(
|
|
2097
|
+
() => zodSchema12(
|
|
2098
|
+
z13.object({
|
|
1923
2099
|
/**
|
|
1924
2100
|
* A regex pattern to search for tools.
|
|
1925
2101
|
* Uses Python re.search() syntax. Maximum 200 characters.
|
|
@@ -1930,15 +2106,15 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
|
|
|
1930
2106
|
* - "database.*query|query.*database" - OR patterns for flexibility
|
|
1931
2107
|
* - "(?i)slack" - case-insensitive search
|
|
1932
2108
|
*/
|
|
1933
|
-
pattern:
|
|
2109
|
+
pattern: z13.string(),
|
|
1934
2110
|
/**
|
|
1935
2111
|
* Maximum number of tools to return. Optional.
|
|
1936
2112
|
*/
|
|
1937
|
-
limit:
|
|
2113
|
+
limit: z13.number().optional()
|
|
1938
2114
|
})
|
|
1939
2115
|
)
|
|
1940
2116
|
);
|
|
1941
|
-
var factory9 = (
|
|
2117
|
+
var factory9 = createProviderToolFactoryWithOutputSchema8({
|
|
1942
2118
|
id: "anthropic.tool_search_regex_20251119",
|
|
1943
2119
|
inputSchema: toolSearchRegex_20251119InputSchema,
|
|
1944
2120
|
outputSchema: toolSearchRegex_20251119OutputSchema,
|
|
@@ -1951,17 +2127,17 @@ var toolSearchRegex_20251119 = (args = {}) => {
|
|
|
1951
2127
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
1952
2128
|
function convertToString(data) {
|
|
1953
2129
|
if (typeof data === "string") {
|
|
1954
|
-
return new TextDecoder().decode((
|
|
2130
|
+
return new TextDecoder().decode(convertBase64ToUint8Array2(data));
|
|
1955
2131
|
}
|
|
1956
2132
|
if (data instanceof Uint8Array) {
|
|
1957
2133
|
return new TextDecoder().decode(data);
|
|
1958
2134
|
}
|
|
1959
2135
|
if (data instanceof URL) {
|
|
1960
|
-
throw new
|
|
2136
|
+
throw new UnsupportedFunctionalityError2({
|
|
1961
2137
|
functionality: "URL-based text documents are not supported for citations"
|
|
1962
2138
|
});
|
|
1963
2139
|
}
|
|
1964
|
-
throw new
|
|
2140
|
+
throw new UnsupportedFunctionalityError2({
|
|
1965
2141
|
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
1966
2142
|
});
|
|
1967
2143
|
}
|
|
@@ -1989,7 +2165,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1989
2165
|
const messages = [];
|
|
1990
2166
|
async function shouldEnableCitations(providerMetadata) {
|
|
1991
2167
|
var _a2, _b2;
|
|
1992
|
-
const anthropicOptions = await
|
|
2168
|
+
const anthropicOptions = await parseProviderOptions({
|
|
1993
2169
|
provider: "anthropic",
|
|
1994
2170
|
providerOptions: providerMetadata,
|
|
1995
2171
|
schema: anthropicFilePartProviderOptions
|
|
@@ -1997,7 +2173,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1997
2173
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
1998
2174
|
}
|
|
1999
2175
|
async function getDocumentMetadata(providerMetadata) {
|
|
2000
|
-
const anthropicOptions = await
|
|
2176
|
+
const anthropicOptions = await parseProviderOptions({
|
|
2001
2177
|
provider: "anthropic",
|
|
2002
2178
|
providerOptions: providerMetadata,
|
|
2003
2179
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2014,7 +2190,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2014
2190
|
switch (type) {
|
|
2015
2191
|
case "system": {
|
|
2016
2192
|
if (system != null) {
|
|
2017
|
-
throw new
|
|
2193
|
+
throw new UnsupportedFunctionalityError2({
|
|
2018
2194
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
2019
2195
|
});
|
|
2020
2196
|
}
|
|
@@ -2054,7 +2230,26 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2054
2230
|
break;
|
|
2055
2231
|
}
|
|
2056
2232
|
case "file": {
|
|
2057
|
-
if (part.
|
|
2233
|
+
if (isProviderReference(part.data)) {
|
|
2234
|
+
const fileId = resolveProviderReference({
|
|
2235
|
+
reference: part.data,
|
|
2236
|
+
provider: "anthropic"
|
|
2237
|
+
});
|
|
2238
|
+
betas.add("files-api-2025-04-14");
|
|
2239
|
+
if (part.mediaType.startsWith("image/")) {
|
|
2240
|
+
anthropicContent.push({
|
|
2241
|
+
type: "image",
|
|
2242
|
+
source: { type: "file", file_id: fileId },
|
|
2243
|
+
cache_control: cacheControl
|
|
2244
|
+
});
|
|
2245
|
+
} else {
|
|
2246
|
+
anthropicContent.push({
|
|
2247
|
+
type: "document",
|
|
2248
|
+
source: { type: "file", file_id: fileId },
|
|
2249
|
+
cache_control: cacheControl
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
} else if (part.mediaType.startsWith("image/")) {
|
|
2058
2253
|
anthropicContent.push({
|
|
2059
2254
|
type: "image",
|
|
2060
2255
|
source: isUrlData(part.data) ? {
|
|
@@ -2063,7 +2258,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2063
2258
|
} : {
|
|
2064
2259
|
type: "base64",
|
|
2065
2260
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
2066
|
-
data:
|
|
2261
|
+
data: convertToBase64(part.data)
|
|
2067
2262
|
},
|
|
2068
2263
|
cache_control: cacheControl
|
|
2069
2264
|
});
|
|
@@ -2083,7 +2278,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2083
2278
|
} : {
|
|
2084
2279
|
type: "base64",
|
|
2085
2280
|
media_type: "application/pdf",
|
|
2086
|
-
data:
|
|
2281
|
+
data: convertToBase64(part.data)
|
|
2087
2282
|
},
|
|
2088
2283
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
2089
2284
|
...metadata.context && { context: metadata.context },
|
|
@@ -2117,7 +2312,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2117
2312
|
cache_control: cacheControl
|
|
2118
2313
|
});
|
|
2119
2314
|
} else {
|
|
2120
|
-
throw new
|
|
2315
|
+
throw new UnsupportedFunctionalityError2({
|
|
2121
2316
|
functionality: `media type: ${part.mediaType}`
|
|
2122
2317
|
});
|
|
2123
2318
|
}
|
|
@@ -2153,26 +2348,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2153
2348
|
type: "text",
|
|
2154
2349
|
text: contentPart.text
|
|
2155
2350
|
};
|
|
2156
|
-
case "image-data": {
|
|
2157
|
-
return {
|
|
2158
|
-
type: "image",
|
|
2159
|
-
source: {
|
|
2160
|
-
type: "base64",
|
|
2161
|
-
media_type: contentPart.mediaType,
|
|
2162
|
-
data: contentPart.data
|
|
2163
|
-
}
|
|
2164
|
-
};
|
|
2165
|
-
}
|
|
2166
|
-
case "image-url": {
|
|
2167
|
-
return {
|
|
2168
|
-
type: "image",
|
|
2169
|
-
source: {
|
|
2170
|
-
type: "url",
|
|
2171
|
-
url: contentPart.url
|
|
2172
|
-
}
|
|
2173
|
-
};
|
|
2174
|
-
}
|
|
2175
2351
|
case "file-url": {
|
|
2352
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2353
|
+
return {
|
|
2354
|
+
type: "image",
|
|
2355
|
+
source: {
|
|
2356
|
+
type: "url",
|
|
2357
|
+
url: contentPart.url
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2360
|
+
}
|
|
2176
2361
|
return {
|
|
2177
2362
|
type: "document",
|
|
2178
2363
|
source: {
|
|
@@ -2182,6 +2367,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2182
2367
|
};
|
|
2183
2368
|
}
|
|
2184
2369
|
case "file-data": {
|
|
2370
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2371
|
+
return {
|
|
2372
|
+
type: "image",
|
|
2373
|
+
source: {
|
|
2374
|
+
type: "base64",
|
|
2375
|
+
media_type: contentPart.mediaType,
|
|
2376
|
+
data: contentPart.data
|
|
2377
|
+
}
|
|
2378
|
+
};
|
|
2379
|
+
}
|
|
2185
2380
|
if (contentPart.mediaType === "application/pdf") {
|
|
2186
2381
|
betas.add("pdfs-2024-09-25");
|
|
2187
2382
|
return {
|
|
@@ -2221,7 +2416,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2221
2416
|
return void 0;
|
|
2222
2417
|
}
|
|
2223
2418
|
}
|
|
2224
|
-
}).filter(
|
|
2419
|
+
}).filter(isNonNullable);
|
|
2225
2420
|
break;
|
|
2226
2421
|
case "text":
|
|
2227
2422
|
case "error-text":
|
|
@@ -2297,7 +2492,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2297
2492
|
}
|
|
2298
2493
|
case "reasoning": {
|
|
2299
2494
|
if (sendReasoning) {
|
|
2300
|
-
const reasoningMetadata = await
|
|
2495
|
+
const reasoningMetadata = await parseProviderOptions({
|
|
2301
2496
|
provider: "anthropic",
|
|
2302
2497
|
providerOptions: part.providerOptions,
|
|
2303
2498
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -2503,7 +2698,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2503
2698
|
break;
|
|
2504
2699
|
}
|
|
2505
2700
|
if (output.value.type === "code_execution_result") {
|
|
2506
|
-
const codeExecutionOutput = await (
|
|
2701
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2507
2702
|
value: output.value,
|
|
2508
2703
|
schema: codeExecution_20250522OutputSchema
|
|
2509
2704
|
});
|
|
@@ -2520,7 +2715,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2520
2715
|
cache_control: cacheControl
|
|
2521
2716
|
});
|
|
2522
2717
|
} else if (output.value.type === "encrypted_code_execution_result") {
|
|
2523
|
-
const codeExecutionOutput = await (
|
|
2718
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2524
2719
|
value: output.value,
|
|
2525
2720
|
schema: codeExecution_20260120OutputSchema
|
|
2526
2721
|
});
|
|
@@ -2539,7 +2734,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2539
2734
|
});
|
|
2540
2735
|
}
|
|
2541
2736
|
} else {
|
|
2542
|
-
const codeExecutionOutput = await (
|
|
2737
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2543
2738
|
value: output.value,
|
|
2544
2739
|
schema: codeExecution_20250825OutputSchema
|
|
2545
2740
|
});
|
|
@@ -2608,7 +2803,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2608
2803
|
});
|
|
2609
2804
|
break;
|
|
2610
2805
|
}
|
|
2611
|
-
const webFetchOutput = await (
|
|
2806
|
+
const webFetchOutput = await validateTypes2({
|
|
2612
2807
|
value: output.value,
|
|
2613
2808
|
schema: webFetch_20250910OutputSchema
|
|
2614
2809
|
});
|
|
@@ -2643,7 +2838,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2643
2838
|
});
|
|
2644
2839
|
break;
|
|
2645
2840
|
}
|
|
2646
|
-
const webSearchOutput = await (
|
|
2841
|
+
const webSearchOutput = await validateTypes2({
|
|
2647
2842
|
value: output.value,
|
|
2648
2843
|
schema: webSearch_20250305OutputSchema
|
|
2649
2844
|
});
|
|
@@ -2670,7 +2865,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2670
2865
|
});
|
|
2671
2866
|
break;
|
|
2672
2867
|
}
|
|
2673
|
-
const toolSearchOutput = await (
|
|
2868
|
+
const toolSearchOutput = await validateTypes2({
|
|
2674
2869
|
value: output.value,
|
|
2675
2870
|
schema: toolSearchRegex_20251119OutputSchema
|
|
2676
2871
|
});
|
|
@@ -2828,13 +3023,22 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
2828
3023
|
}
|
|
2829
3024
|
};
|
|
2830
3025
|
}
|
|
2831
|
-
var AnthropicMessagesLanguageModel = class {
|
|
3026
|
+
var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
|
|
2832
3027
|
constructor(modelId, config) {
|
|
2833
3028
|
this.specificationVersion = "v4";
|
|
2834
3029
|
var _a;
|
|
2835
3030
|
this.modelId = modelId;
|
|
2836
3031
|
this.config = config;
|
|
2837
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
3032
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
3033
|
+
}
|
|
3034
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
3035
|
+
return serializeModelOptions({
|
|
3036
|
+
modelId: model.modelId,
|
|
3037
|
+
config: model.config
|
|
3038
|
+
});
|
|
3039
|
+
}
|
|
3040
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
3041
|
+
return new _AnthropicMessagesLanguageModel(options.modelId, options.config);
|
|
2838
3042
|
}
|
|
2839
3043
|
supportsUrl(url) {
|
|
2840
3044
|
return url.protocol === "https:";
|
|
@@ -2869,10 +3073,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2869
3073
|
seed,
|
|
2870
3074
|
tools,
|
|
2871
3075
|
toolChoice,
|
|
3076
|
+
reasoning,
|
|
2872
3077
|
providerOptions,
|
|
2873
3078
|
stream
|
|
2874
3079
|
}) {
|
|
2875
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3080
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2876
3081
|
const warnings = [];
|
|
2877
3082
|
if (frequencyPenalty != null) {
|
|
2878
3083
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2908,12 +3113,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2908
3113
|
}
|
|
2909
3114
|
}
|
|
2910
3115
|
const providerOptionsName = this.providerOptionsName;
|
|
2911
|
-
const canonicalOptions = await (
|
|
3116
|
+
const canonicalOptions = await parseProviderOptions2({
|
|
2912
3117
|
provider: "anthropic",
|
|
2913
3118
|
providerOptions,
|
|
2914
3119
|
schema: anthropicLanguageModelOptions
|
|
2915
3120
|
});
|
|
2916
|
-
const customProviderOptions = providerOptionsName !== "anthropic" ? await (
|
|
3121
|
+
const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
|
|
2917
3122
|
provider: providerOptionsName,
|
|
2918
3123
|
providerOptions,
|
|
2919
3124
|
schema: anthropicLanguageModelOptions
|
|
@@ -2927,10 +3132,41 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2927
3132
|
const {
|
|
2928
3133
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2929
3134
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
3135
|
+
supportsAdaptiveThinking,
|
|
3136
|
+
rejectsSamplingParameters,
|
|
3137
|
+
supportsXhighEffort,
|
|
2930
3138
|
isKnownModel
|
|
2931
3139
|
} = getModelCapabilities(this.modelId);
|
|
3140
|
+
if (rejectsSamplingParameters) {
|
|
3141
|
+
if (temperature != null) {
|
|
3142
|
+
warnings.push({
|
|
3143
|
+
type: "unsupported",
|
|
3144
|
+
feature: "temperature",
|
|
3145
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
3146
|
+
});
|
|
3147
|
+
temperature = void 0;
|
|
3148
|
+
}
|
|
3149
|
+
if (topK != null) {
|
|
3150
|
+
warnings.push({
|
|
3151
|
+
type: "unsupported",
|
|
3152
|
+
feature: "topK",
|
|
3153
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
3154
|
+
});
|
|
3155
|
+
topK = void 0;
|
|
3156
|
+
}
|
|
3157
|
+
if (topP != null) {
|
|
3158
|
+
warnings.push({
|
|
3159
|
+
type: "unsupported",
|
|
3160
|
+
feature: "topP",
|
|
3161
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
3162
|
+
});
|
|
3163
|
+
topP = void 0;
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2932
3167
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2933
|
-
const
|
|
3168
|
+
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
3169
|
+
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
2934
3170
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2935
3171
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
2936
3172
|
type: "function",
|
|
@@ -2940,7 +3176,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2940
3176
|
} : void 0;
|
|
2941
3177
|
const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
|
|
2942
3178
|
const cacheControlValidator = new CacheControlValidator();
|
|
2943
|
-
const toolNameMapping =
|
|
3179
|
+
const toolNameMapping = createToolNameMapping({
|
|
2944
3180
|
tools,
|
|
2945
3181
|
providerToolNames: {
|
|
2946
3182
|
"anthropic.code_execution_20250522": "code_execution",
|
|
@@ -2965,14 +3201,32 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2965
3201
|
});
|
|
2966
3202
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
2967
3203
|
prompt,
|
|
2968
|
-
sendReasoning: (
|
|
3204
|
+
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
2969
3205
|
warnings,
|
|
2970
3206
|
cacheControlValidator,
|
|
2971
3207
|
toolNameMapping
|
|
2972
3208
|
});
|
|
2973
|
-
|
|
3209
|
+
if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
|
|
3210
|
+
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
3211
|
+
reasoning,
|
|
3212
|
+
supportsAdaptiveThinking,
|
|
3213
|
+
supportsXhighEffort,
|
|
3214
|
+
maxOutputTokensForModel,
|
|
3215
|
+
warnings
|
|
3216
|
+
});
|
|
3217
|
+
if (reasoningConfig != null) {
|
|
3218
|
+
if (anthropicOptions.thinking == null) {
|
|
3219
|
+
anthropicOptions.thinking = reasoningConfig.thinking;
|
|
3220
|
+
}
|
|
3221
|
+
if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
|
|
3222
|
+
anthropicOptions.effort = reasoningConfig.effort;
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
|
|
2974
3227
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2975
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
3228
|
+
let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
|
|
3229
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
|
|
2976
3230
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2977
3231
|
const baseArgs = {
|
|
2978
3232
|
// model id:
|
|
@@ -2987,14 +3241,24 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2987
3241
|
...isThinking && {
|
|
2988
3242
|
thinking: {
|
|
2989
3243
|
type: thinkingType,
|
|
2990
|
-
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
3244
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
3245
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
2991
3246
|
}
|
|
2992
3247
|
},
|
|
2993
|
-
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
3248
|
+
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
2994
3249
|
output_config: {
|
|
2995
3250
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
2996
3251
|
effort: anthropicOptions.effort
|
|
2997
3252
|
},
|
|
3253
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
|
|
3254
|
+
task_budget: {
|
|
3255
|
+
type: anthropicOptions.taskBudget.type,
|
|
3256
|
+
total: anthropicOptions.taskBudget.total,
|
|
3257
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
3258
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
},
|
|
2998
3262
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
2999
3263
|
format: {
|
|
3000
3264
|
type: "json_schema",
|
|
@@ -3006,9 +3270,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3006
3270
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
3007
3271
|
speed: anthropicOptions.speed
|
|
3008
3272
|
},
|
|
3273
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
|
|
3274
|
+
inference_geo: anthropicOptions.inferenceGeo
|
|
3275
|
+
},
|
|
3009
3276
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3010
3277
|
cache_control: anthropicOptions.cacheControl
|
|
3011
3278
|
},
|
|
3279
|
+
...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
|
|
3280
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3281
|
+
},
|
|
3012
3282
|
// mcp servers:
|
|
3013
3283
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3014
3284
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3030,7 +3300,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3030
3300
|
id: anthropicOptions.container.id,
|
|
3031
3301
|
skills: anthropicOptions.container.skills.map((skill) => ({
|
|
3032
3302
|
type: skill.type,
|
|
3033
|
-
skill_id: skill.
|
|
3303
|
+
skill_id: skill.type === "custom" ? resolveProviderReference2({
|
|
3304
|
+
reference: skill.providerReference,
|
|
3305
|
+
provider: "anthropic"
|
|
3306
|
+
}) : skill.skillId,
|
|
3034
3307
|
version: skill.version
|
|
3035
3308
|
}))
|
|
3036
3309
|
}
|
|
@@ -3132,7 +3405,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3132
3405
|
}
|
|
3133
3406
|
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
3134
3407
|
} else {
|
|
3135
|
-
if (topP != null && temperature != null) {
|
|
3408
|
+
if (isAnthropicModel && topP != null && temperature != null) {
|
|
3136
3409
|
warnings.push({
|
|
3137
3410
|
type: "unsupported",
|
|
3138
3411
|
feature: "topP",
|
|
@@ -3176,12 +3449,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3176
3449
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
3177
3450
|
betas.add("effort-2025-11-24");
|
|
3178
3451
|
}
|
|
3452
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
3453
|
+
betas.add("task-budgets-2026-03-13");
|
|
3454
|
+
}
|
|
3179
3455
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3180
3456
|
betas.add("fast-mode-2026-02-01");
|
|
3181
3457
|
}
|
|
3182
|
-
|
|
3183
|
-
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3184
|
-
}
|
|
3458
|
+
const defaultEagerInputStreaming = stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true);
|
|
3185
3459
|
const {
|
|
3186
3460
|
tools: anthropicTools2,
|
|
3187
3461
|
toolChoice: anthropicToolChoice,
|
|
@@ -3193,13 +3467,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3193
3467
|
toolChoice: { type: "required" },
|
|
3194
3468
|
disableParallelToolUse: true,
|
|
3195
3469
|
cacheControlValidator,
|
|
3196
|
-
supportsStructuredOutput: false
|
|
3470
|
+
supportsStructuredOutput: false,
|
|
3471
|
+
supportsStrictTools,
|
|
3472
|
+
defaultEagerInputStreaming
|
|
3197
3473
|
} : {
|
|
3198
3474
|
tools: tools != null ? tools : [],
|
|
3199
3475
|
toolChoice,
|
|
3200
3476
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3201
3477
|
cacheControlValidator,
|
|
3202
|
-
supportsStructuredOutput
|
|
3478
|
+
supportsStructuredOutput,
|
|
3479
|
+
supportsStrictTools,
|
|
3480
|
+
defaultEagerInputStreaming
|
|
3203
3481
|
}
|
|
3204
3482
|
);
|
|
3205
3483
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3216,7 +3494,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3216
3494
|
...betas,
|
|
3217
3495
|
...toolsBetas,
|
|
3218
3496
|
...userSuppliedBetas,
|
|
3219
|
-
...(
|
|
3497
|
+
...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
|
|
3220
3498
|
]),
|
|
3221
3499
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3222
3500
|
toolNameMapping,
|
|
@@ -3228,16 +3506,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3228
3506
|
betas,
|
|
3229
3507
|
headers
|
|
3230
3508
|
}) {
|
|
3231
|
-
return (
|
|
3232
|
-
await
|
|
3509
|
+
return combineHeaders2(
|
|
3510
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
3233
3511
|
headers,
|
|
3234
3512
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
3235
3513
|
);
|
|
3236
3514
|
}
|
|
3237
3515
|
async getBetasFromHeaders(requestHeaders) {
|
|
3238
3516
|
var _a, _b;
|
|
3239
|
-
const configHeaders = await
|
|
3240
|
-
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3517
|
+
const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
|
|
3518
|
+
const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3241
3519
|
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
3242
3520
|
return new Set(
|
|
3243
3521
|
[
|
|
@@ -3302,12 +3580,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3302
3580
|
responseHeaders,
|
|
3303
3581
|
value: response,
|
|
3304
3582
|
rawValue: rawResponse
|
|
3305
|
-
} = await
|
|
3583
|
+
} = await postJsonToApi({
|
|
3306
3584
|
url: this.buildRequestUrl(false),
|
|
3307
3585
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3308
3586
|
body: this.transformRequestBody(args, betas),
|
|
3309
3587
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3310
|
-
successfulResponseHandler: (
|
|
3588
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
3311
3589
|
anthropicMessagesResponseSchema
|
|
3312
3590
|
),
|
|
3313
3591
|
abortSignal: options.abortSignal,
|
|
@@ -3701,6 +3979,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3701
3979
|
};
|
|
3702
3980
|
}
|
|
3703
3981
|
async doStream(options) {
|
|
3982
|
+
"use step";
|
|
3704
3983
|
var _a, _b;
|
|
3705
3984
|
const {
|
|
3706
3985
|
args: body,
|
|
@@ -3722,12 +4001,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3722
4001
|
body.tools
|
|
3723
4002
|
);
|
|
3724
4003
|
const url = this.buildRequestUrl(true);
|
|
3725
|
-
const { responseHeaders, value: response } = await
|
|
4004
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
3726
4005
|
url,
|
|
3727
4006
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3728
4007
|
body: this.transformRequestBody(body, betas),
|
|
3729
4008
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3730
|
-
successfulResponseHandler:
|
|
4009
|
+
successfulResponseHandler: createEventSourceResponseHandler(
|
|
3731
4010
|
anthropicMessagesChunkSchema
|
|
3732
4011
|
),
|
|
3733
4012
|
abortSignal: options.abortSignal,
|
|
@@ -4452,7 +4731,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4452
4731
|
}
|
|
4453
4732
|
if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
|
|
4454
4733
|
const error = result.value.error;
|
|
4455
|
-
throw new
|
|
4734
|
+
throw new APICallError({
|
|
4456
4735
|
message: error.message,
|
|
4457
4736
|
url,
|
|
4458
4737
|
requestBodyValues: body,
|
|
@@ -4475,46 +4754,76 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4475
4754
|
}
|
|
4476
4755
|
};
|
|
4477
4756
|
function getModelCapabilities(modelId) {
|
|
4478
|
-
if (modelId.includes("claude-
|
|
4757
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
4758
|
+
return {
|
|
4759
|
+
maxOutputTokens: 128e3,
|
|
4760
|
+
supportsStructuredOutput: true,
|
|
4761
|
+
supportsAdaptiveThinking: true,
|
|
4762
|
+
rejectsSamplingParameters: true,
|
|
4763
|
+
supportsXhighEffort: true,
|
|
4764
|
+
isKnownModel: true
|
|
4765
|
+
};
|
|
4766
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
4479
4767
|
return {
|
|
4480
4768
|
maxOutputTokens: 128e3,
|
|
4481
4769
|
supportsStructuredOutput: true,
|
|
4770
|
+
supportsAdaptiveThinking: true,
|
|
4771
|
+
rejectsSamplingParameters: false,
|
|
4772
|
+
supportsXhighEffort: false,
|
|
4482
4773
|
isKnownModel: true
|
|
4483
4774
|
};
|
|
4484
4775
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
4485
4776
|
return {
|
|
4486
4777
|
maxOutputTokens: 64e3,
|
|
4487
4778
|
supportsStructuredOutput: true,
|
|
4779
|
+
supportsAdaptiveThinking: false,
|
|
4780
|
+
rejectsSamplingParameters: false,
|
|
4781
|
+
supportsXhighEffort: false,
|
|
4488
4782
|
isKnownModel: true
|
|
4489
4783
|
};
|
|
4490
4784
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
4491
4785
|
return {
|
|
4492
4786
|
maxOutputTokens: 32e3,
|
|
4493
4787
|
supportsStructuredOutput: true,
|
|
4788
|
+
supportsAdaptiveThinking: false,
|
|
4789
|
+
rejectsSamplingParameters: false,
|
|
4790
|
+
supportsXhighEffort: false,
|
|
4494
4791
|
isKnownModel: true
|
|
4495
4792
|
};
|
|
4496
4793
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
4497
4794
|
return {
|
|
4498
4795
|
maxOutputTokens: 64e3,
|
|
4499
4796
|
supportsStructuredOutput: false,
|
|
4797
|
+
supportsAdaptiveThinking: false,
|
|
4798
|
+
rejectsSamplingParameters: false,
|
|
4799
|
+
supportsXhighEffort: false,
|
|
4500
4800
|
isKnownModel: true
|
|
4501
4801
|
};
|
|
4502
4802
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
4503
4803
|
return {
|
|
4504
4804
|
maxOutputTokens: 32e3,
|
|
4505
4805
|
supportsStructuredOutput: false,
|
|
4806
|
+
supportsAdaptiveThinking: false,
|
|
4807
|
+
rejectsSamplingParameters: false,
|
|
4808
|
+
supportsXhighEffort: false,
|
|
4506
4809
|
isKnownModel: true
|
|
4507
4810
|
};
|
|
4508
4811
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
4509
4812
|
return {
|
|
4510
4813
|
maxOutputTokens: 4096,
|
|
4511
4814
|
supportsStructuredOutput: false,
|
|
4815
|
+
supportsAdaptiveThinking: false,
|
|
4816
|
+
rejectsSamplingParameters: false,
|
|
4817
|
+
supportsXhighEffort: false,
|
|
4512
4818
|
isKnownModel: true
|
|
4513
4819
|
};
|
|
4514
4820
|
} else {
|
|
4515
4821
|
return {
|
|
4516
4822
|
maxOutputTokens: 4096,
|
|
4517
4823
|
supportsStructuredOutput: false,
|
|
4824
|
+
supportsAdaptiveThinking: false,
|
|
4825
|
+
rejectsSamplingParameters: false,
|
|
4826
|
+
supportsXhighEffort: false,
|
|
4518
4827
|
isKnownModel: false
|
|
4519
4828
|
};
|
|
4520
4829
|
}
|
|
@@ -4537,6 +4846,44 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
4537
4846
|
}
|
|
4538
4847
|
return hasWebTool20260209 && !hasCodeExecutionTool;
|
|
4539
4848
|
}
|
|
4849
|
+
function resolveAnthropicReasoningConfig({
|
|
4850
|
+
reasoning,
|
|
4851
|
+
supportsAdaptiveThinking,
|
|
4852
|
+
supportsXhighEffort,
|
|
4853
|
+
maxOutputTokensForModel,
|
|
4854
|
+
warnings
|
|
4855
|
+
}) {
|
|
4856
|
+
if (!isCustomReasoning(reasoning)) {
|
|
4857
|
+
return void 0;
|
|
4858
|
+
}
|
|
4859
|
+
if (reasoning === "none") {
|
|
4860
|
+
return { thinking: { type: "disabled" } };
|
|
4861
|
+
}
|
|
4862
|
+
if (supportsAdaptiveThinking) {
|
|
4863
|
+
const effort = mapReasoningToProviderEffort({
|
|
4864
|
+
reasoning,
|
|
4865
|
+
effortMap: {
|
|
4866
|
+
minimal: "low",
|
|
4867
|
+
low: "low",
|
|
4868
|
+
medium: "medium",
|
|
4869
|
+
high: "high",
|
|
4870
|
+
xhigh: supportsXhighEffort ? "xhigh" : "max"
|
|
4871
|
+
},
|
|
4872
|
+
warnings
|
|
4873
|
+
});
|
|
4874
|
+
return { thinking: { type: "adaptive" }, effort };
|
|
4875
|
+
}
|
|
4876
|
+
const budgetTokens = mapReasoningToProviderBudget({
|
|
4877
|
+
reasoning,
|
|
4878
|
+
maxOutputTokens: maxOutputTokensForModel,
|
|
4879
|
+
maxReasoningBudget: maxOutputTokensForModel,
|
|
4880
|
+
warnings
|
|
4881
|
+
});
|
|
4882
|
+
if (budgetTokens == null) {
|
|
4883
|
+
return void 0;
|
|
4884
|
+
}
|
|
4885
|
+
return { thinking: { type: "enabled", budgetTokens } };
|
|
4886
|
+
}
|
|
4540
4887
|
function mapAnthropicResponseContextManagement(contextManagement) {
|
|
4541
4888
|
return contextManagement ? {
|
|
4542
4889
|
appliedEdits: contextManagement.applied_edits.map((edit) => {
|
|
@@ -4564,44 +4911,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
|
|
|
4564
4911
|
}
|
|
4565
4912
|
|
|
4566
4913
|
// src/tool/bash_20241022.ts
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4914
|
+
import {
|
|
4915
|
+
createProviderToolFactory as createProviderToolFactory2,
|
|
4916
|
+
lazySchema as lazySchema13,
|
|
4917
|
+
zodSchema as zodSchema13
|
|
4918
|
+
} from "@ai-sdk/provider-utils";
|
|
4919
|
+
import { z as z14 } from "zod/v4";
|
|
4920
|
+
var bash_20241022InputSchema = lazySchema13(
|
|
4921
|
+
() => zodSchema13(
|
|
4922
|
+
z14.object({
|
|
4923
|
+
command: z14.string(),
|
|
4924
|
+
restart: z14.boolean().optional()
|
|
4574
4925
|
})
|
|
4575
4926
|
)
|
|
4576
4927
|
);
|
|
4577
|
-
var bash_20241022 = (
|
|
4928
|
+
var bash_20241022 = createProviderToolFactory2({
|
|
4578
4929
|
id: "anthropic.bash_20241022",
|
|
4579
4930
|
inputSchema: bash_20241022InputSchema
|
|
4580
4931
|
});
|
|
4581
4932
|
|
|
4582
4933
|
// src/tool/bash_20250124.ts
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4934
|
+
import {
|
|
4935
|
+
createProviderToolFactory as createProviderToolFactory3,
|
|
4936
|
+
lazySchema as lazySchema14,
|
|
4937
|
+
zodSchema as zodSchema14
|
|
4938
|
+
} from "@ai-sdk/provider-utils";
|
|
4939
|
+
import { z as z15 } from "zod/v4";
|
|
4940
|
+
var bash_20250124InputSchema = lazySchema14(
|
|
4941
|
+
() => zodSchema14(
|
|
4942
|
+
z15.object({
|
|
4943
|
+
command: z15.string(),
|
|
4944
|
+
restart: z15.boolean().optional()
|
|
4590
4945
|
})
|
|
4591
4946
|
)
|
|
4592
4947
|
);
|
|
4593
|
-
var bash_20250124 = (
|
|
4948
|
+
var bash_20250124 = createProviderToolFactory3({
|
|
4594
4949
|
id: "anthropic.bash_20250124",
|
|
4595
4950
|
inputSchema: bash_20250124InputSchema
|
|
4596
4951
|
});
|
|
4597
4952
|
|
|
4598
4953
|
// src/tool/computer_20241022.ts
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4954
|
+
import {
|
|
4955
|
+
createProviderToolFactory as createProviderToolFactory4,
|
|
4956
|
+
lazySchema as lazySchema15,
|
|
4957
|
+
zodSchema as zodSchema15
|
|
4958
|
+
} from "@ai-sdk/provider-utils";
|
|
4959
|
+
import { z as z16 } from "zod/v4";
|
|
4960
|
+
var computer_20241022InputSchema = lazySchema15(
|
|
4961
|
+
() => zodSchema15(
|
|
4962
|
+
z16.object({
|
|
4963
|
+
action: z16.enum([
|
|
4605
4964
|
"key",
|
|
4606
4965
|
"type",
|
|
4607
4966
|
"mouse_move",
|
|
@@ -4613,23 +4972,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
|
4613
4972
|
"screenshot",
|
|
4614
4973
|
"cursor_position"
|
|
4615
4974
|
]),
|
|
4616
|
-
coordinate:
|
|
4617
|
-
text:
|
|
4975
|
+
coordinate: z16.array(z16.number().int()).optional(),
|
|
4976
|
+
text: z16.string().optional()
|
|
4618
4977
|
})
|
|
4619
4978
|
)
|
|
4620
4979
|
);
|
|
4621
|
-
var computer_20241022 = (
|
|
4980
|
+
var computer_20241022 = createProviderToolFactory4({
|
|
4622
4981
|
id: "anthropic.computer_20241022",
|
|
4623
4982
|
inputSchema: computer_20241022InputSchema
|
|
4624
4983
|
});
|
|
4625
4984
|
|
|
4626
4985
|
// src/tool/computer_20250124.ts
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4986
|
+
import {
|
|
4987
|
+
createProviderToolFactory as createProviderToolFactory5,
|
|
4988
|
+
lazySchema as lazySchema16,
|
|
4989
|
+
zodSchema as zodSchema16
|
|
4990
|
+
} from "@ai-sdk/provider-utils";
|
|
4991
|
+
import { z as z17 } from "zod/v4";
|
|
4992
|
+
var computer_20250124InputSchema = lazySchema16(
|
|
4993
|
+
() => zodSchema16(
|
|
4994
|
+
z17.object({
|
|
4995
|
+
action: z17.enum([
|
|
4633
4996
|
"key",
|
|
4634
4997
|
"hold_key",
|
|
4635
4998
|
"type",
|
|
@@ -4647,27 +5010,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
4647
5010
|
"wait",
|
|
4648
5011
|
"screenshot"
|
|
4649
5012
|
]),
|
|
4650
|
-
coordinate:
|
|
4651
|
-
duration:
|
|
4652
|
-
scroll_amount:
|
|
4653
|
-
scroll_direction:
|
|
4654
|
-
start_coordinate:
|
|
4655
|
-
text:
|
|
5013
|
+
coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5014
|
+
duration: z17.number().optional(),
|
|
5015
|
+
scroll_amount: z17.number().optional(),
|
|
5016
|
+
scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
|
|
5017
|
+
start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5018
|
+
text: z17.string().optional()
|
|
4656
5019
|
})
|
|
4657
5020
|
)
|
|
4658
5021
|
);
|
|
4659
|
-
var computer_20250124 = (
|
|
5022
|
+
var computer_20250124 = createProviderToolFactory5({
|
|
4660
5023
|
id: "anthropic.computer_20250124",
|
|
4661
5024
|
inputSchema: computer_20250124InputSchema
|
|
4662
5025
|
});
|
|
4663
5026
|
|
|
4664
5027
|
// src/tool/computer_20251124.ts
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
5028
|
+
import {
|
|
5029
|
+
createProviderToolFactory as createProviderToolFactory6,
|
|
5030
|
+
lazySchema as lazySchema17,
|
|
5031
|
+
zodSchema as zodSchema17
|
|
5032
|
+
} from "@ai-sdk/provider-utils";
|
|
5033
|
+
import { z as z18 } from "zod/v4";
|
|
5034
|
+
var computer_20251124InputSchema = lazySchema17(
|
|
5035
|
+
() => zodSchema17(
|
|
5036
|
+
z18.object({
|
|
5037
|
+
action: z18.enum([
|
|
4671
5038
|
"key",
|
|
4672
5039
|
"hold_key",
|
|
4673
5040
|
"type",
|
|
@@ -4686,166 +5053,186 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
|
4686
5053
|
"screenshot",
|
|
4687
5054
|
"zoom"
|
|
4688
5055
|
]),
|
|
4689
|
-
coordinate:
|
|
4690
|
-
duration:
|
|
4691
|
-
region:
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
5056
|
+
coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
5057
|
+
duration: z18.number().optional(),
|
|
5058
|
+
region: z18.tuple([
|
|
5059
|
+
z18.number().int(),
|
|
5060
|
+
z18.number().int(),
|
|
5061
|
+
z18.number().int(),
|
|
5062
|
+
z18.number().int()
|
|
4696
5063
|
]).optional(),
|
|
4697
|
-
scroll_amount:
|
|
4698
|
-
scroll_direction:
|
|
4699
|
-
start_coordinate:
|
|
4700
|
-
text:
|
|
5064
|
+
scroll_amount: z18.number().optional(),
|
|
5065
|
+
scroll_direction: z18.enum(["up", "down", "left", "right"]).optional(),
|
|
5066
|
+
start_coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
5067
|
+
text: z18.string().optional()
|
|
4701
5068
|
})
|
|
4702
5069
|
)
|
|
4703
5070
|
);
|
|
4704
|
-
var computer_20251124 = (
|
|
5071
|
+
var computer_20251124 = createProviderToolFactory6({
|
|
4705
5072
|
id: "anthropic.computer_20251124",
|
|
4706
5073
|
inputSchema: computer_20251124InputSchema
|
|
4707
5074
|
});
|
|
4708
5075
|
|
|
4709
5076
|
// src/tool/memory_20250818.ts
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
5077
|
+
import {
|
|
5078
|
+
createProviderToolFactory as createProviderToolFactory7,
|
|
5079
|
+
lazySchema as lazySchema18,
|
|
5080
|
+
zodSchema as zodSchema18
|
|
5081
|
+
} from "@ai-sdk/provider-utils";
|
|
5082
|
+
import { z as z19 } from "zod/v4";
|
|
5083
|
+
var memory_20250818InputSchema = lazySchema18(
|
|
5084
|
+
() => zodSchema18(
|
|
5085
|
+
z19.discriminatedUnion("command", [
|
|
5086
|
+
z19.object({
|
|
5087
|
+
command: z19.literal("view"),
|
|
5088
|
+
path: z19.string(),
|
|
5089
|
+
view_range: z19.tuple([z19.number(), z19.number()]).optional()
|
|
4719
5090
|
}),
|
|
4720
|
-
|
|
4721
|
-
command:
|
|
4722
|
-
path:
|
|
4723
|
-
file_text:
|
|
5091
|
+
z19.object({
|
|
5092
|
+
command: z19.literal("create"),
|
|
5093
|
+
path: z19.string(),
|
|
5094
|
+
file_text: z19.string()
|
|
4724
5095
|
}),
|
|
4725
|
-
|
|
4726
|
-
command:
|
|
4727
|
-
path:
|
|
4728
|
-
old_str:
|
|
4729
|
-
new_str:
|
|
5096
|
+
z19.object({
|
|
5097
|
+
command: z19.literal("str_replace"),
|
|
5098
|
+
path: z19.string(),
|
|
5099
|
+
old_str: z19.string(),
|
|
5100
|
+
new_str: z19.string()
|
|
4730
5101
|
}),
|
|
4731
|
-
|
|
4732
|
-
command:
|
|
4733
|
-
path:
|
|
4734
|
-
insert_line:
|
|
4735
|
-
insert_text:
|
|
5102
|
+
z19.object({
|
|
5103
|
+
command: z19.literal("insert"),
|
|
5104
|
+
path: z19.string(),
|
|
5105
|
+
insert_line: z19.number(),
|
|
5106
|
+
insert_text: z19.string()
|
|
4736
5107
|
}),
|
|
4737
|
-
|
|
4738
|
-
command:
|
|
4739
|
-
path:
|
|
5108
|
+
z19.object({
|
|
5109
|
+
command: z19.literal("delete"),
|
|
5110
|
+
path: z19.string()
|
|
4740
5111
|
}),
|
|
4741
|
-
|
|
4742
|
-
command:
|
|
4743
|
-
old_path:
|
|
4744
|
-
new_path:
|
|
5112
|
+
z19.object({
|
|
5113
|
+
command: z19.literal("rename"),
|
|
5114
|
+
old_path: z19.string(),
|
|
5115
|
+
new_path: z19.string()
|
|
4745
5116
|
})
|
|
4746
5117
|
])
|
|
4747
5118
|
)
|
|
4748
5119
|
);
|
|
4749
|
-
var memory_20250818 = (
|
|
5120
|
+
var memory_20250818 = createProviderToolFactory7({
|
|
4750
5121
|
id: "anthropic.memory_20250818",
|
|
4751
5122
|
inputSchema: memory_20250818InputSchema
|
|
4752
5123
|
});
|
|
4753
5124
|
|
|
4754
5125
|
// src/tool/text-editor_20241022.ts
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
5126
|
+
import {
|
|
5127
|
+
createProviderToolFactory as createProviderToolFactory8,
|
|
5128
|
+
lazySchema as lazySchema19,
|
|
5129
|
+
zodSchema as zodSchema19
|
|
5130
|
+
} from "@ai-sdk/provider-utils";
|
|
5131
|
+
import { z as z20 } from "zod/v4";
|
|
5132
|
+
var textEditor_20241022InputSchema = lazySchema19(
|
|
5133
|
+
() => zodSchema19(
|
|
5134
|
+
z20.object({
|
|
5135
|
+
command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5136
|
+
path: z20.string(),
|
|
5137
|
+
file_text: z20.string().optional(),
|
|
5138
|
+
insert_line: z20.number().int().optional(),
|
|
5139
|
+
new_str: z20.string().optional(),
|
|
5140
|
+
insert_text: z20.string().optional(),
|
|
5141
|
+
old_str: z20.string().optional(),
|
|
5142
|
+
view_range: z20.array(z20.number().int()).optional()
|
|
4768
5143
|
})
|
|
4769
5144
|
)
|
|
4770
5145
|
);
|
|
4771
|
-
var textEditor_20241022 = (
|
|
5146
|
+
var textEditor_20241022 = createProviderToolFactory8({
|
|
4772
5147
|
id: "anthropic.text_editor_20241022",
|
|
4773
5148
|
inputSchema: textEditor_20241022InputSchema
|
|
4774
5149
|
});
|
|
4775
5150
|
|
|
4776
5151
|
// src/tool/text-editor_20250124.ts
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
5152
|
+
import {
|
|
5153
|
+
createProviderToolFactory as createProviderToolFactory9,
|
|
5154
|
+
lazySchema as lazySchema20,
|
|
5155
|
+
zodSchema as zodSchema20
|
|
5156
|
+
} from "@ai-sdk/provider-utils";
|
|
5157
|
+
import { z as z21 } from "zod/v4";
|
|
5158
|
+
var textEditor_20250124InputSchema = lazySchema20(
|
|
5159
|
+
() => zodSchema20(
|
|
5160
|
+
z21.object({
|
|
5161
|
+
command: z21.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5162
|
+
path: z21.string(),
|
|
5163
|
+
file_text: z21.string().optional(),
|
|
5164
|
+
insert_line: z21.number().int().optional(),
|
|
5165
|
+
new_str: z21.string().optional(),
|
|
5166
|
+
insert_text: z21.string().optional(),
|
|
5167
|
+
old_str: z21.string().optional(),
|
|
5168
|
+
view_range: z21.array(z21.number().int()).optional()
|
|
4790
5169
|
})
|
|
4791
5170
|
)
|
|
4792
5171
|
);
|
|
4793
|
-
var textEditor_20250124 = (
|
|
5172
|
+
var textEditor_20250124 = createProviderToolFactory9({
|
|
4794
5173
|
id: "anthropic.text_editor_20250124",
|
|
4795
5174
|
inputSchema: textEditor_20250124InputSchema
|
|
4796
5175
|
});
|
|
4797
5176
|
|
|
4798
5177
|
// src/tool/text-editor_20250429.ts
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
5178
|
+
import {
|
|
5179
|
+
createProviderToolFactory as createProviderToolFactory10,
|
|
5180
|
+
lazySchema as lazySchema21,
|
|
5181
|
+
zodSchema as zodSchema21
|
|
5182
|
+
} from "@ai-sdk/provider-utils";
|
|
5183
|
+
import { z as z22 } from "zod/v4";
|
|
5184
|
+
var textEditor_20250429InputSchema = lazySchema21(
|
|
5185
|
+
() => zodSchema21(
|
|
5186
|
+
z22.object({
|
|
5187
|
+
command: z22.enum(["view", "create", "str_replace", "insert"]),
|
|
5188
|
+
path: z22.string(),
|
|
5189
|
+
file_text: z22.string().optional(),
|
|
5190
|
+
insert_line: z22.number().int().optional(),
|
|
5191
|
+
new_str: z22.string().optional(),
|
|
5192
|
+
insert_text: z22.string().optional(),
|
|
5193
|
+
old_str: z22.string().optional(),
|
|
5194
|
+
view_range: z22.array(z22.number().int()).optional()
|
|
4812
5195
|
})
|
|
4813
5196
|
)
|
|
4814
5197
|
);
|
|
4815
|
-
var textEditor_20250429 = (
|
|
5198
|
+
var textEditor_20250429 = createProviderToolFactory10({
|
|
4816
5199
|
id: "anthropic.text_editor_20250429",
|
|
4817
5200
|
inputSchema: textEditor_20250429InputSchema
|
|
4818
5201
|
});
|
|
4819
5202
|
|
|
4820
5203
|
// src/tool/tool-search-bm25_20251119.ts
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
5204
|
+
import {
|
|
5205
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
|
|
5206
|
+
lazySchema as lazySchema22,
|
|
5207
|
+
zodSchema as zodSchema22
|
|
5208
|
+
} from "@ai-sdk/provider-utils";
|
|
5209
|
+
import { z as z23 } from "zod/v4";
|
|
5210
|
+
var toolSearchBm25_20251119OutputSchema = lazySchema22(
|
|
5211
|
+
() => zodSchema22(
|
|
5212
|
+
z23.array(
|
|
5213
|
+
z23.object({
|
|
5214
|
+
type: z23.literal("tool_reference"),
|
|
5215
|
+
toolName: z23.string()
|
|
4829
5216
|
})
|
|
4830
5217
|
)
|
|
4831
5218
|
)
|
|
4832
5219
|
);
|
|
4833
|
-
var toolSearchBm25_20251119InputSchema = (
|
|
4834
|
-
() => (
|
|
4835
|
-
|
|
5220
|
+
var toolSearchBm25_20251119InputSchema = lazySchema22(
|
|
5221
|
+
() => zodSchema22(
|
|
5222
|
+
z23.object({
|
|
4836
5223
|
/**
|
|
4837
5224
|
* A natural language query to search for tools.
|
|
4838
5225
|
* Claude will use BM25 text search to find relevant tools.
|
|
4839
5226
|
*/
|
|
4840
|
-
query:
|
|
5227
|
+
query: z23.string(),
|
|
4841
5228
|
/**
|
|
4842
5229
|
* Maximum number of tools to return. Optional.
|
|
4843
5230
|
*/
|
|
4844
|
-
limit:
|
|
5231
|
+
limit: z23.number().optional()
|
|
4845
5232
|
})
|
|
4846
5233
|
)
|
|
4847
5234
|
);
|
|
4848
|
-
var factory10 = (
|
|
5235
|
+
var factory10 = createProviderToolFactoryWithOutputSchema9({
|
|
4849
5236
|
id: "anthropic.tool_search_bm25_20251119",
|
|
4850
5237
|
inputSchema: toolSearchBm25_20251119InputSchema,
|
|
4851
5238
|
outputSchema: toolSearchBm25_20251119OutputSchema,
|
|
@@ -5057,31 +5444,163 @@ var anthropicTools = {
|
|
|
5057
5444
|
toolSearchBm25_20251119
|
|
5058
5445
|
};
|
|
5059
5446
|
|
|
5447
|
+
// src/skills/anthropic-skills.ts
|
|
5448
|
+
import {
|
|
5449
|
+
combineHeaders as combineHeaders3,
|
|
5450
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array3,
|
|
5451
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
5452
|
+
getFromApi,
|
|
5453
|
+
postFormDataToApi as postFormDataToApi2,
|
|
5454
|
+
resolve as resolve2
|
|
5455
|
+
} from "@ai-sdk/provider-utils";
|
|
5456
|
+
|
|
5457
|
+
// src/skills/anthropic-skills-api.ts
|
|
5458
|
+
import { lazySchema as lazySchema23, zodSchema as zodSchema23 } from "@ai-sdk/provider-utils";
|
|
5459
|
+
import { z as z24 } from "zod/v4";
|
|
5460
|
+
var anthropicSkillResponseSchema = lazySchema23(
|
|
5461
|
+
() => zodSchema23(
|
|
5462
|
+
z24.object({
|
|
5463
|
+
id: z24.string(),
|
|
5464
|
+
display_title: z24.string().nullish(),
|
|
5465
|
+
name: z24.string().nullish(),
|
|
5466
|
+
description: z24.string().nullish(),
|
|
5467
|
+
latest_version: z24.string().nullish(),
|
|
5468
|
+
source: z24.string(),
|
|
5469
|
+
created_at: z24.string(),
|
|
5470
|
+
updated_at: z24.string()
|
|
5471
|
+
})
|
|
5472
|
+
)
|
|
5473
|
+
);
|
|
5474
|
+
var anthropicSkillVersionListResponseSchema = lazySchema23(
|
|
5475
|
+
() => zodSchema23(
|
|
5476
|
+
z24.object({
|
|
5477
|
+
data: z24.array(
|
|
5478
|
+
z24.object({
|
|
5479
|
+
version: z24.string()
|
|
5480
|
+
})
|
|
5481
|
+
)
|
|
5482
|
+
})
|
|
5483
|
+
)
|
|
5484
|
+
);
|
|
5485
|
+
var anthropicSkillVersionResponseSchema = lazySchema23(
|
|
5486
|
+
() => zodSchema23(
|
|
5487
|
+
z24.object({
|
|
5488
|
+
type: z24.string(),
|
|
5489
|
+
skill_id: z24.string(),
|
|
5490
|
+
name: z24.string().nullish(),
|
|
5491
|
+
description: z24.string().nullish()
|
|
5492
|
+
})
|
|
5493
|
+
)
|
|
5494
|
+
);
|
|
5495
|
+
|
|
5496
|
+
// src/skills/anthropic-skills.ts
|
|
5497
|
+
var AnthropicSkills = class {
|
|
5498
|
+
constructor(config) {
|
|
5499
|
+
this.config = config;
|
|
5500
|
+
this.specificationVersion = "v4";
|
|
5501
|
+
}
|
|
5502
|
+
get provider() {
|
|
5503
|
+
return this.config.provider;
|
|
5504
|
+
}
|
|
5505
|
+
async getHeaders() {
|
|
5506
|
+
return combineHeaders3(await resolve2(this.config.headers), {
|
|
5507
|
+
"anthropic-beta": "skills-2025-10-02"
|
|
5508
|
+
});
|
|
5509
|
+
}
|
|
5510
|
+
async fetchVersionMetadata({
|
|
5511
|
+
skillId,
|
|
5512
|
+
version,
|
|
5513
|
+
headers
|
|
5514
|
+
}) {
|
|
5515
|
+
const { value: versionResponse } = await getFromApi({
|
|
5516
|
+
url: `${this.config.baseURL}/skills/${skillId}/versions/${version}`,
|
|
5517
|
+
headers,
|
|
5518
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
5519
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
5520
|
+
anthropicSkillVersionResponseSchema
|
|
5521
|
+
),
|
|
5522
|
+
fetch: this.config.fetch
|
|
5523
|
+
});
|
|
5524
|
+
return {
|
|
5525
|
+
...versionResponse.name != null ? { name: versionResponse.name } : {},
|
|
5526
|
+
...versionResponse.description != null ? { description: versionResponse.description } : {}
|
|
5527
|
+
};
|
|
5528
|
+
}
|
|
5529
|
+
async uploadSkill(params) {
|
|
5530
|
+
var _a, _b;
|
|
5531
|
+
const warnings = [];
|
|
5532
|
+
const formData = new FormData();
|
|
5533
|
+
if (params.displayTitle != null) {
|
|
5534
|
+
formData.append("display_title", params.displayTitle);
|
|
5535
|
+
}
|
|
5536
|
+
for (const file of params.files) {
|
|
5537
|
+
const content = typeof file.content === "string" ? convertBase64ToUint8Array3(file.content) : file.content;
|
|
5538
|
+
formData.append("files[]", new Blob([content]), file.path);
|
|
5539
|
+
}
|
|
5540
|
+
const headers = await this.getHeaders();
|
|
5541
|
+
const { value: response } = await postFormDataToApi2({
|
|
5542
|
+
url: `${this.config.baseURL}/skills`,
|
|
5543
|
+
headers,
|
|
5544
|
+
formData,
|
|
5545
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
5546
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
5547
|
+
anthropicSkillResponseSchema
|
|
5548
|
+
),
|
|
5549
|
+
fetch: this.config.fetch
|
|
5550
|
+
});
|
|
5551
|
+
const versionMetadata = response.latest_version != null ? await this.fetchVersionMetadata({
|
|
5552
|
+
skillId: response.id,
|
|
5553
|
+
version: response.latest_version,
|
|
5554
|
+
headers
|
|
5555
|
+
}) : {};
|
|
5556
|
+
const name = (_a = versionMetadata.name) != null ? _a : response.name;
|
|
5557
|
+
const description = (_b = versionMetadata.description) != null ? _b : response.description;
|
|
5558
|
+
return {
|
|
5559
|
+
providerReference: { anthropic: response.id },
|
|
5560
|
+
...response.display_title != null ? { displayTitle: response.display_title } : {},
|
|
5561
|
+
...name != null ? { name } : {},
|
|
5562
|
+
...description != null ? { description } : {},
|
|
5563
|
+
...response.latest_version != null ? { latestVersion: response.latest_version } : {},
|
|
5564
|
+
providerMetadata: {
|
|
5565
|
+
anthropic: {
|
|
5566
|
+
...response.source != null ? { source: response.source } : {},
|
|
5567
|
+
...response.created_at != null ? { createdAt: response.created_at } : {},
|
|
5568
|
+
...response.updated_at != null ? { updatedAt: response.updated_at } : {}
|
|
5569
|
+
}
|
|
5570
|
+
},
|
|
5571
|
+
warnings
|
|
5572
|
+
};
|
|
5573
|
+
}
|
|
5574
|
+
};
|
|
5575
|
+
|
|
5576
|
+
// src/version.ts
|
|
5577
|
+
var VERSION = true ? "4.0.0-beta.32" : "0.0.0-test";
|
|
5578
|
+
|
|
5060
5579
|
// src/anthropic-provider.ts
|
|
5061
5580
|
function createAnthropic(options = {}) {
|
|
5062
5581
|
var _a, _b;
|
|
5063
|
-
const baseURL = (_a =
|
|
5064
|
-
|
|
5582
|
+
const baseURL = (_a = withoutTrailingSlash(
|
|
5583
|
+
loadOptionalSetting({
|
|
5065
5584
|
settingValue: options.baseURL,
|
|
5066
5585
|
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
5067
5586
|
})
|
|
5068
5587
|
)) != null ? _a : "https://api.anthropic.com/v1";
|
|
5069
5588
|
const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
|
|
5070
5589
|
if (options.apiKey && options.authToken) {
|
|
5071
|
-
throw new
|
|
5590
|
+
throw new InvalidArgumentError({
|
|
5072
5591
|
argument: "apiKey/authToken",
|
|
5073
5592
|
message: "Both apiKey and authToken were provided. Please use only one authentication method."
|
|
5074
5593
|
});
|
|
5075
5594
|
}
|
|
5076
5595
|
const getHeaders = () => {
|
|
5077
5596
|
const authHeaders = options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {
|
|
5078
|
-
"x-api-key":
|
|
5597
|
+
"x-api-key": loadApiKey({
|
|
5079
5598
|
apiKey: options.apiKey,
|
|
5080
5599
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
5081
5600
|
description: "Anthropic"
|
|
5082
5601
|
})
|
|
5083
5602
|
};
|
|
5084
|
-
return
|
|
5603
|
+
return withUserAgentSuffix(
|
|
5085
5604
|
{
|
|
5086
5605
|
"anthropic-version": "2023-06-01",
|
|
5087
5606
|
...authHeaders,
|
|
@@ -5097,13 +5616,19 @@ function createAnthropic(options = {}) {
|
|
|
5097
5616
|
baseURL,
|
|
5098
5617
|
headers: getHeaders,
|
|
5099
5618
|
fetch: options.fetch,
|
|
5100
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
5619
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : generateId2,
|
|
5101
5620
|
supportedUrls: () => ({
|
|
5102
5621
|
"image/*": [/^https?:\/\/.*$/],
|
|
5103
5622
|
"application/pdf": [/^https?:\/\/.*$/]
|
|
5104
5623
|
})
|
|
5105
5624
|
});
|
|
5106
5625
|
};
|
|
5626
|
+
const createSkills = () => new AnthropicSkills({
|
|
5627
|
+
provider: `${providerName.replace(".messages", "")}.skills`,
|
|
5628
|
+
baseURL,
|
|
5629
|
+
headers: getHeaders,
|
|
5630
|
+
fetch: options.fetch
|
|
5631
|
+
});
|
|
5107
5632
|
const provider = function(modelId) {
|
|
5108
5633
|
if (new.target) {
|
|
5109
5634
|
throw new Error(
|
|
@@ -5117,12 +5642,19 @@ function createAnthropic(options = {}) {
|
|
|
5117
5642
|
provider.chat = createChatModel;
|
|
5118
5643
|
provider.messages = createChatModel;
|
|
5119
5644
|
provider.embeddingModel = (modelId) => {
|
|
5120
|
-
throw new
|
|
5645
|
+
throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
5121
5646
|
};
|
|
5122
5647
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
5123
5648
|
provider.imageModel = (modelId) => {
|
|
5124
|
-
throw new
|
|
5649
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
5125
5650
|
};
|
|
5651
|
+
provider.files = () => new AnthropicFiles({
|
|
5652
|
+
provider: providerName,
|
|
5653
|
+
baseURL,
|
|
5654
|
+
headers: getHeaders,
|
|
5655
|
+
fetch: options.fetch
|
|
5656
|
+
});
|
|
5657
|
+
provider.skills = createSkills;
|
|
5126
5658
|
provider.tools = anthropicTools;
|
|
5127
5659
|
return provider;
|
|
5128
5660
|
}
|
|
@@ -5147,11 +5679,10 @@ function forwardAnthropicContainerIdFromLastStep({
|
|
|
5147
5679
|
}
|
|
5148
5680
|
return void 0;
|
|
5149
5681
|
}
|
|
5150
|
-
|
|
5151
|
-
0 && (module.exports = {
|
|
5682
|
+
export {
|
|
5152
5683
|
VERSION,
|
|
5153
5684
|
anthropic,
|
|
5154
5685
|
createAnthropic,
|
|
5155
5686
|
forwardAnthropicContainerIdFromLastStep
|
|
5156
|
-
}
|
|
5687
|
+
};
|
|
5157
5688
|
//# sourceMappingURL=index.js.map
|