@ai-sdk/anthropic 4.0.0-beta.3 → 4.0.0-beta.31
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 +230 -4
- package/README.md +2 -0
- package/dist/index.d.ts +60 -34
- package/dist/index.js +1747 -1218
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +67 -36
- package/dist/internal/index.js +1506 -1203
- 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 +219 -9
- package/src/anthropic-messages-options.ts +62 -6
- package/src/anthropic-prepare-tools.ts +16 -4
- 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,14 +985,21 @@ 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
|
/**
|
|
@@ -907,65 +1010,86 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
907
1010
|
*
|
|
908
1011
|
* @default true
|
|
909
1012
|
*/
|
|
910
|
-
toolStreaming:
|
|
1013
|
+
toolStreaming: z4.boolean().optional(),
|
|
911
1014
|
/**
|
|
912
1015
|
* @default 'high'
|
|
913
1016
|
*/
|
|
914
|
-
effort:
|
|
1017
|
+
effort: z4.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
1018
|
+
/**
|
|
1019
|
+
* Task budget for agentic turns. Informs the model of the total token budget
|
|
1020
|
+
* available for the current task, allowing it to prioritize work and wind down
|
|
1021
|
+
* gracefully as the budget is consumed.
|
|
1022
|
+
*
|
|
1023
|
+
* Advisory only — does not enforce a hard token limit.
|
|
1024
|
+
*/
|
|
1025
|
+
taskBudget: z4.object({
|
|
1026
|
+
type: z4.literal("tokens"),
|
|
1027
|
+
total: z4.number().int().min(2e4),
|
|
1028
|
+
remaining: z4.number().int().min(0).optional()
|
|
1029
|
+
}).optional(),
|
|
915
1030
|
/**
|
|
916
1031
|
* Enable fast mode for faster inference (2.5x faster output token speeds).
|
|
917
1032
|
* Only supported with claude-opus-4-6.
|
|
918
1033
|
*/
|
|
919
|
-
speed:
|
|
1034
|
+
speed: z4.enum(["fast", "standard"]).optional(),
|
|
1035
|
+
/**
|
|
1036
|
+
* Controls where model inference runs for this request.
|
|
1037
|
+
*
|
|
1038
|
+
* - `"global"`: Inference may run in any available geography (default).
|
|
1039
|
+
* - `"us"`: Inference runs only in US-based infrastructure.
|
|
1040
|
+
*
|
|
1041
|
+
* See https://platform.claude.com/docs/en/build-with-claude/data-residency
|
|
1042
|
+
*/
|
|
1043
|
+
inferenceGeo: z4.enum(["us", "global"]).optional(),
|
|
920
1044
|
/**
|
|
921
1045
|
* A set of beta features to enable.
|
|
922
1046
|
* Allow a provider to receive the full `betas` set if it needs it.
|
|
923
1047
|
*/
|
|
924
|
-
anthropicBeta:
|
|
925
|
-
contextManagement:
|
|
926
|
-
edits:
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
type:
|
|
930
|
-
trigger:
|
|
931
|
-
|
|
932
|
-
type:
|
|
933
|
-
value:
|
|
1048
|
+
anthropicBeta: z4.array(z4.string()).optional(),
|
|
1049
|
+
contextManagement: z4.object({
|
|
1050
|
+
edits: z4.array(
|
|
1051
|
+
z4.discriminatedUnion("type", [
|
|
1052
|
+
z4.object({
|
|
1053
|
+
type: z4.literal("clear_tool_uses_20250919"),
|
|
1054
|
+
trigger: z4.discriminatedUnion("type", [
|
|
1055
|
+
z4.object({
|
|
1056
|
+
type: z4.literal("input_tokens"),
|
|
1057
|
+
value: z4.number()
|
|
934
1058
|
}),
|
|
935
|
-
|
|
936
|
-
type:
|
|
937
|
-
value:
|
|
1059
|
+
z4.object({
|
|
1060
|
+
type: z4.literal("tool_uses"),
|
|
1061
|
+
value: z4.number()
|
|
938
1062
|
})
|
|
939
1063
|
]).optional(),
|
|
940
|
-
keep:
|
|
941
|
-
type:
|
|
942
|
-
value:
|
|
1064
|
+
keep: z4.object({
|
|
1065
|
+
type: z4.literal("tool_uses"),
|
|
1066
|
+
value: z4.number()
|
|
943
1067
|
}).optional(),
|
|
944
|
-
clearAtLeast:
|
|
945
|
-
type:
|
|
946
|
-
value:
|
|
1068
|
+
clearAtLeast: z4.object({
|
|
1069
|
+
type: z4.literal("input_tokens"),
|
|
1070
|
+
value: z4.number()
|
|
947
1071
|
}).optional(),
|
|
948
|
-
clearToolInputs:
|
|
949
|
-
excludeTools:
|
|
1072
|
+
clearToolInputs: z4.boolean().optional(),
|
|
1073
|
+
excludeTools: z4.array(z4.string()).optional()
|
|
950
1074
|
}),
|
|
951
|
-
|
|
952
|
-
type:
|
|
953
|
-
keep:
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
type:
|
|
957
|
-
value:
|
|
1075
|
+
z4.object({
|
|
1076
|
+
type: z4.literal("clear_thinking_20251015"),
|
|
1077
|
+
keep: z4.union([
|
|
1078
|
+
z4.literal("all"),
|
|
1079
|
+
z4.object({
|
|
1080
|
+
type: z4.literal("thinking_turns"),
|
|
1081
|
+
value: z4.number()
|
|
958
1082
|
})
|
|
959
1083
|
]).optional()
|
|
960
1084
|
}),
|
|
961
|
-
|
|
962
|
-
type:
|
|
963
|
-
trigger:
|
|
964
|
-
type:
|
|
965
|
-
value:
|
|
1085
|
+
z4.object({
|
|
1086
|
+
type: z4.literal("compact_20260112"),
|
|
1087
|
+
trigger: z4.object({
|
|
1088
|
+
type: z4.literal("input_tokens"),
|
|
1089
|
+
value: z4.number()
|
|
966
1090
|
}).optional(),
|
|
967
|
-
pauseAfterCompaction:
|
|
968
|
-
instructions:
|
|
1091
|
+
pauseAfterCompaction: z4.boolean().optional(),
|
|
1092
|
+
instructions: z4.string().optional()
|
|
969
1093
|
})
|
|
970
1094
|
])
|
|
971
1095
|
)
|
|
@@ -973,7 +1097,9 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
973
1097
|
});
|
|
974
1098
|
|
|
975
1099
|
// src/anthropic-prepare-tools.ts
|
|
976
|
-
|
|
1100
|
+
import {
|
|
1101
|
+
UnsupportedFunctionalityError
|
|
1102
|
+
} from "@ai-sdk/provider";
|
|
977
1103
|
|
|
978
1104
|
// src/get-cache-control.ts
|
|
979
1105
|
var MAX_CACHE_BREAKPOINTS = 4;
|
|
@@ -1018,31 +1144,31 @@ var CacheControlValidator = class {
|
|
|
1018
1144
|
};
|
|
1019
1145
|
|
|
1020
1146
|
// src/tool/text-editor_20250728.ts
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
var textEditor_20250728ArgsSchema = (
|
|
1025
|
-
() => (
|
|
1026
|
-
|
|
1027
|
-
maxCharacters:
|
|
1147
|
+
import { createProviderToolFactory } from "@ai-sdk/provider-utils";
|
|
1148
|
+
import { z as z5 } from "zod/v4";
|
|
1149
|
+
import { lazySchema as lazySchema4, zodSchema as zodSchema4 } from "@ai-sdk/provider-utils";
|
|
1150
|
+
var textEditor_20250728ArgsSchema = lazySchema4(
|
|
1151
|
+
() => zodSchema4(
|
|
1152
|
+
z5.object({
|
|
1153
|
+
maxCharacters: z5.number().optional()
|
|
1028
1154
|
})
|
|
1029
1155
|
)
|
|
1030
1156
|
);
|
|
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:
|
|
1157
|
+
var textEditor_20250728InputSchema = lazySchema4(
|
|
1158
|
+
() => zodSchema4(
|
|
1159
|
+
z5.object({
|
|
1160
|
+
command: z5.enum(["view", "create", "str_replace", "insert"]),
|
|
1161
|
+
path: z5.string(),
|
|
1162
|
+
file_text: z5.string().optional(),
|
|
1163
|
+
insert_line: z5.number().int().optional(),
|
|
1164
|
+
new_str: z5.string().optional(),
|
|
1165
|
+
insert_text: z5.string().optional(),
|
|
1166
|
+
old_str: z5.string().optional(),
|
|
1167
|
+
view_range: z5.array(z5.number().int()).optional()
|
|
1042
1168
|
})
|
|
1043
1169
|
)
|
|
1044
1170
|
);
|
|
1045
|
-
var factory =
|
|
1171
|
+
var factory = createProviderToolFactory({
|
|
1046
1172
|
id: "anthropic.text_editor_20250728",
|
|
1047
1173
|
inputSchema: textEditor_20250728InputSchema
|
|
1048
1174
|
});
|
|
@@ -1051,45 +1177,49 @@ var textEditor_20250728 = (args = {}) => {
|
|
|
1051
1177
|
};
|
|
1052
1178
|
|
|
1053
1179
|
// src/tool/web-search_20260209.ts
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1180
|
+
import {
|
|
1181
|
+
createProviderToolFactoryWithOutputSchema,
|
|
1182
|
+
lazySchema as lazySchema5,
|
|
1183
|
+
zodSchema as zodSchema5
|
|
1184
|
+
} from "@ai-sdk/provider-utils";
|
|
1185
|
+
import { z as z6 } from "zod/v4";
|
|
1186
|
+
var webSearch_20260209ArgsSchema = lazySchema5(
|
|
1187
|
+
() => zodSchema5(
|
|
1188
|
+
z6.object({
|
|
1189
|
+
maxUses: z6.number().optional(),
|
|
1190
|
+
allowedDomains: z6.array(z6.string()).optional(),
|
|
1191
|
+
blockedDomains: z6.array(z6.string()).optional(),
|
|
1192
|
+
userLocation: z6.object({
|
|
1193
|
+
type: z6.literal("approximate"),
|
|
1194
|
+
city: z6.string().optional(),
|
|
1195
|
+
region: z6.string().optional(),
|
|
1196
|
+
country: z6.string().optional(),
|
|
1197
|
+
timezone: z6.string().optional()
|
|
1068
1198
|
}).optional()
|
|
1069
1199
|
})
|
|
1070
1200
|
)
|
|
1071
1201
|
);
|
|
1072
|
-
var webSearch_20260209OutputSchema = (
|
|
1073
|
-
() => (
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
url:
|
|
1077
|
-
title:
|
|
1078
|
-
pageAge:
|
|
1079
|
-
encryptedContent:
|
|
1080
|
-
type:
|
|
1202
|
+
var webSearch_20260209OutputSchema = lazySchema5(
|
|
1203
|
+
() => zodSchema5(
|
|
1204
|
+
z6.array(
|
|
1205
|
+
z6.object({
|
|
1206
|
+
url: z6.string(),
|
|
1207
|
+
title: z6.string().nullable(),
|
|
1208
|
+
pageAge: z6.string().nullable(),
|
|
1209
|
+
encryptedContent: z6.string(),
|
|
1210
|
+
type: z6.literal("web_search_result")
|
|
1081
1211
|
})
|
|
1082
1212
|
)
|
|
1083
1213
|
)
|
|
1084
1214
|
);
|
|
1085
|
-
var webSearch_20260209InputSchema = (
|
|
1086
|
-
() => (
|
|
1087
|
-
|
|
1088
|
-
query:
|
|
1215
|
+
var webSearch_20260209InputSchema = lazySchema5(
|
|
1216
|
+
() => zodSchema5(
|
|
1217
|
+
z6.object({
|
|
1218
|
+
query: z6.string()
|
|
1089
1219
|
})
|
|
1090
1220
|
)
|
|
1091
1221
|
);
|
|
1092
|
-
var factory2 =
|
|
1222
|
+
var factory2 = createProviderToolFactoryWithOutputSchema({
|
|
1093
1223
|
id: "anthropic.web_search_20260209",
|
|
1094
1224
|
inputSchema: webSearch_20260209InputSchema,
|
|
1095
1225
|
outputSchema: webSearch_20260209OutputSchema,
|
|
@@ -1100,45 +1230,49 @@ var webSearch_20260209 = (args = {}) => {
|
|
|
1100
1230
|
};
|
|
1101
1231
|
|
|
1102
1232
|
// src/tool/web-search_20250305.ts
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1233
|
+
import {
|
|
1234
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
|
|
1235
|
+
lazySchema as lazySchema6,
|
|
1236
|
+
zodSchema as zodSchema6
|
|
1237
|
+
} from "@ai-sdk/provider-utils";
|
|
1238
|
+
import { z as z7 } from "zod/v4";
|
|
1239
|
+
var webSearch_20250305ArgsSchema = lazySchema6(
|
|
1240
|
+
() => zodSchema6(
|
|
1241
|
+
z7.object({
|
|
1242
|
+
maxUses: z7.number().optional(),
|
|
1243
|
+
allowedDomains: z7.array(z7.string()).optional(),
|
|
1244
|
+
blockedDomains: z7.array(z7.string()).optional(),
|
|
1245
|
+
userLocation: z7.object({
|
|
1246
|
+
type: z7.literal("approximate"),
|
|
1247
|
+
city: z7.string().optional(),
|
|
1248
|
+
region: z7.string().optional(),
|
|
1249
|
+
country: z7.string().optional(),
|
|
1250
|
+
timezone: z7.string().optional()
|
|
1117
1251
|
}).optional()
|
|
1118
1252
|
})
|
|
1119
1253
|
)
|
|
1120
1254
|
);
|
|
1121
|
-
var webSearch_20250305OutputSchema = (
|
|
1122
|
-
() => (
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
url:
|
|
1126
|
-
title:
|
|
1127
|
-
pageAge:
|
|
1128
|
-
encryptedContent:
|
|
1129
|
-
type:
|
|
1255
|
+
var webSearch_20250305OutputSchema = lazySchema6(
|
|
1256
|
+
() => zodSchema6(
|
|
1257
|
+
z7.array(
|
|
1258
|
+
z7.object({
|
|
1259
|
+
url: z7.string(),
|
|
1260
|
+
title: z7.string().nullable(),
|
|
1261
|
+
pageAge: z7.string().nullable(),
|
|
1262
|
+
encryptedContent: z7.string(),
|
|
1263
|
+
type: z7.literal("web_search_result")
|
|
1130
1264
|
})
|
|
1131
1265
|
)
|
|
1132
1266
|
)
|
|
1133
1267
|
);
|
|
1134
|
-
var webSearch_20250305InputSchema = (
|
|
1135
|
-
() => (
|
|
1136
|
-
|
|
1137
|
-
query:
|
|
1268
|
+
var webSearch_20250305InputSchema = lazySchema6(
|
|
1269
|
+
() => zodSchema6(
|
|
1270
|
+
z7.object({
|
|
1271
|
+
query: z7.string()
|
|
1138
1272
|
})
|
|
1139
1273
|
)
|
|
1140
1274
|
);
|
|
1141
|
-
var factory3 = (
|
|
1275
|
+
var factory3 = createProviderToolFactoryWithOutputSchema2({
|
|
1142
1276
|
id: "anthropic.web_search_20250305",
|
|
1143
1277
|
inputSchema: webSearch_20250305InputSchema,
|
|
1144
1278
|
outputSchema: webSearch_20250305OutputSchema,
|
|
@@ -1149,53 +1283,57 @@ var webSearch_20250305 = (args = {}) => {
|
|
|
1149
1283
|
};
|
|
1150
1284
|
|
|
1151
1285
|
// src/tool/web-fetch-20260209.ts
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1286
|
+
import {
|
|
1287
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
|
|
1288
|
+
lazySchema as lazySchema7,
|
|
1289
|
+
zodSchema as zodSchema7
|
|
1290
|
+
} from "@ai-sdk/provider-utils";
|
|
1291
|
+
import { z as z8 } from "zod/v4";
|
|
1292
|
+
var webFetch_20260209ArgsSchema = lazySchema7(
|
|
1293
|
+
() => zodSchema7(
|
|
1294
|
+
z8.object({
|
|
1295
|
+
maxUses: z8.number().optional(),
|
|
1296
|
+
allowedDomains: z8.array(z8.string()).optional(),
|
|
1297
|
+
blockedDomains: z8.array(z8.string()).optional(),
|
|
1298
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1299
|
+
maxContentTokens: z8.number().optional()
|
|
1162
1300
|
})
|
|
1163
1301
|
)
|
|
1164
1302
|
);
|
|
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:
|
|
1303
|
+
var webFetch_20260209OutputSchema = lazySchema7(
|
|
1304
|
+
() => zodSchema7(
|
|
1305
|
+
z8.object({
|
|
1306
|
+
type: z8.literal("web_fetch_result"),
|
|
1307
|
+
url: z8.string(),
|
|
1308
|
+
content: z8.object({
|
|
1309
|
+
type: z8.literal("document"),
|
|
1310
|
+
title: z8.string().nullable(),
|
|
1311
|
+
citations: z8.object({ enabled: z8.boolean() }).optional(),
|
|
1312
|
+
source: z8.union([
|
|
1313
|
+
z8.object({
|
|
1314
|
+
type: z8.literal("base64"),
|
|
1315
|
+
mediaType: z8.literal("application/pdf"),
|
|
1316
|
+
data: z8.string()
|
|
1179
1317
|
}),
|
|
1180
|
-
|
|
1181
|
-
type:
|
|
1182
|
-
mediaType:
|
|
1183
|
-
data:
|
|
1318
|
+
z8.object({
|
|
1319
|
+
type: z8.literal("text"),
|
|
1320
|
+
mediaType: z8.literal("text/plain"),
|
|
1321
|
+
data: z8.string()
|
|
1184
1322
|
})
|
|
1185
1323
|
])
|
|
1186
1324
|
}),
|
|
1187
|
-
retrievedAt:
|
|
1325
|
+
retrievedAt: z8.string().nullable()
|
|
1188
1326
|
})
|
|
1189
1327
|
)
|
|
1190
1328
|
);
|
|
1191
|
-
var webFetch_20260209InputSchema = (
|
|
1192
|
-
() => (
|
|
1193
|
-
|
|
1194
|
-
url:
|
|
1329
|
+
var webFetch_20260209InputSchema = lazySchema7(
|
|
1330
|
+
() => zodSchema7(
|
|
1331
|
+
z8.object({
|
|
1332
|
+
url: z8.string()
|
|
1195
1333
|
})
|
|
1196
1334
|
)
|
|
1197
1335
|
);
|
|
1198
|
-
var factory4 = (
|
|
1336
|
+
var factory4 = createProviderToolFactoryWithOutputSchema3({
|
|
1199
1337
|
id: "anthropic.web_fetch_20260209",
|
|
1200
1338
|
inputSchema: webFetch_20260209InputSchema,
|
|
1201
1339
|
outputSchema: webFetch_20260209OutputSchema,
|
|
@@ -1206,53 +1344,57 @@ var webFetch_20260209 = (args = {}) => {
|
|
|
1206
1344
|
};
|
|
1207
1345
|
|
|
1208
1346
|
// src/tool/web-fetch-20250910.ts
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1347
|
+
import {
|
|
1348
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
|
|
1349
|
+
lazySchema as lazySchema8,
|
|
1350
|
+
zodSchema as zodSchema8
|
|
1351
|
+
} from "@ai-sdk/provider-utils";
|
|
1352
|
+
import { z as z9 } from "zod/v4";
|
|
1353
|
+
var webFetch_20250910ArgsSchema = lazySchema8(
|
|
1354
|
+
() => zodSchema8(
|
|
1355
|
+
z9.object({
|
|
1356
|
+
maxUses: z9.number().optional(),
|
|
1357
|
+
allowedDomains: z9.array(z9.string()).optional(),
|
|
1358
|
+
blockedDomains: z9.array(z9.string()).optional(),
|
|
1359
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1360
|
+
maxContentTokens: z9.number().optional()
|
|
1219
1361
|
})
|
|
1220
1362
|
)
|
|
1221
1363
|
);
|
|
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:
|
|
1364
|
+
var webFetch_20250910OutputSchema = lazySchema8(
|
|
1365
|
+
() => zodSchema8(
|
|
1366
|
+
z9.object({
|
|
1367
|
+
type: z9.literal("web_fetch_result"),
|
|
1368
|
+
url: z9.string(),
|
|
1369
|
+
content: z9.object({
|
|
1370
|
+
type: z9.literal("document"),
|
|
1371
|
+
title: z9.string().nullable(),
|
|
1372
|
+
citations: z9.object({ enabled: z9.boolean() }).optional(),
|
|
1373
|
+
source: z9.union([
|
|
1374
|
+
z9.object({
|
|
1375
|
+
type: z9.literal("base64"),
|
|
1376
|
+
mediaType: z9.literal("application/pdf"),
|
|
1377
|
+
data: z9.string()
|
|
1236
1378
|
}),
|
|
1237
|
-
|
|
1238
|
-
type:
|
|
1239
|
-
mediaType:
|
|
1240
|
-
data:
|
|
1379
|
+
z9.object({
|
|
1380
|
+
type: z9.literal("text"),
|
|
1381
|
+
mediaType: z9.literal("text/plain"),
|
|
1382
|
+
data: z9.string()
|
|
1241
1383
|
})
|
|
1242
1384
|
])
|
|
1243
1385
|
}),
|
|
1244
|
-
retrievedAt:
|
|
1386
|
+
retrievedAt: z9.string().nullable()
|
|
1245
1387
|
})
|
|
1246
1388
|
)
|
|
1247
1389
|
);
|
|
1248
|
-
var webFetch_20250910InputSchema = (
|
|
1249
|
-
() => (
|
|
1250
|
-
|
|
1251
|
-
url:
|
|
1390
|
+
var webFetch_20250910InputSchema = lazySchema8(
|
|
1391
|
+
() => zodSchema8(
|
|
1392
|
+
z9.object({
|
|
1393
|
+
url: z9.string()
|
|
1252
1394
|
})
|
|
1253
1395
|
)
|
|
1254
1396
|
);
|
|
1255
|
-
var factory5 = (
|
|
1397
|
+
var factory5 = createProviderToolFactoryWithOutputSchema4({
|
|
1256
1398
|
id: "anthropic.web_fetch_20250910",
|
|
1257
1399
|
inputSchema: webFetch_20250910InputSchema,
|
|
1258
1400
|
outputSchema: webFetch_20250910OutputSchema,
|
|
@@ -1263,13 +1405,14 @@ var webFetch_20250910 = (args = {}) => {
|
|
|
1263
1405
|
};
|
|
1264
1406
|
|
|
1265
1407
|
// src/anthropic-prepare-tools.ts
|
|
1266
|
-
|
|
1408
|
+
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
1267
1409
|
async function prepareTools({
|
|
1268
1410
|
tools,
|
|
1269
1411
|
toolChoice,
|
|
1270
1412
|
disableParallelToolUse,
|
|
1271
1413
|
cacheControlValidator,
|
|
1272
|
-
supportsStructuredOutput
|
|
1414
|
+
supportsStructuredOutput,
|
|
1415
|
+
supportsStrictTools
|
|
1273
1416
|
}) {
|
|
1274
1417
|
var _a;
|
|
1275
1418
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -1291,13 +1434,20 @@ async function prepareTools({
|
|
|
1291
1434
|
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1292
1435
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1293
1436
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1437
|
+
if (!supportsStrictTools && tool.strict != null) {
|
|
1438
|
+
toolWarnings.push({
|
|
1439
|
+
type: "unsupported",
|
|
1440
|
+
feature: "strict",
|
|
1441
|
+
details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1294
1444
|
anthropicTools2.push({
|
|
1295
1445
|
name: tool.name,
|
|
1296
1446
|
description: tool.description,
|
|
1297
1447
|
input_schema: tool.inputSchema,
|
|
1298
1448
|
cache_control: cacheControl,
|
|
1299
1449
|
...eagerInputStreaming ? { eager_input_streaming: true } : {},
|
|
1300
|
-
...
|
|
1450
|
+
...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
|
|
1301
1451
|
...deferLoading != null ? { defer_loading: deferLoading } : {},
|
|
1302
1452
|
...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
|
|
1303
1453
|
...tool.inputExamples != null ? {
|
|
@@ -1405,7 +1555,7 @@ async function prepareTools({
|
|
|
1405
1555
|
break;
|
|
1406
1556
|
}
|
|
1407
1557
|
case "anthropic.text_editor_20250728": {
|
|
1408
|
-
const args = await
|
|
1558
|
+
const args = await validateTypes({
|
|
1409
1559
|
value: tool.args,
|
|
1410
1560
|
schema: textEditor_20250728ArgsSchema
|
|
1411
1561
|
});
|
|
@@ -1445,7 +1595,7 @@ async function prepareTools({
|
|
|
1445
1595
|
}
|
|
1446
1596
|
case "anthropic.web_fetch_20250910": {
|
|
1447
1597
|
betas.add("web-fetch-2025-09-10");
|
|
1448
|
-
const args = await
|
|
1598
|
+
const args = await validateTypes({
|
|
1449
1599
|
value: tool.args,
|
|
1450
1600
|
schema: webFetch_20250910ArgsSchema
|
|
1451
1601
|
});
|
|
@@ -1463,7 +1613,7 @@ async function prepareTools({
|
|
|
1463
1613
|
}
|
|
1464
1614
|
case "anthropic.web_fetch_20260209": {
|
|
1465
1615
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1466
|
-
const args = await
|
|
1616
|
+
const args = await validateTypes({
|
|
1467
1617
|
value: tool.args,
|
|
1468
1618
|
schema: webFetch_20260209ArgsSchema
|
|
1469
1619
|
});
|
|
@@ -1480,7 +1630,7 @@ async function prepareTools({
|
|
|
1480
1630
|
break;
|
|
1481
1631
|
}
|
|
1482
1632
|
case "anthropic.web_search_20250305": {
|
|
1483
|
-
const args = await
|
|
1633
|
+
const args = await validateTypes({
|
|
1484
1634
|
value: tool.args,
|
|
1485
1635
|
schema: webSearch_20250305ArgsSchema
|
|
1486
1636
|
});
|
|
@@ -1497,7 +1647,7 @@ async function prepareTools({
|
|
|
1497
1647
|
}
|
|
1498
1648
|
case "anthropic.web_search_20260209": {
|
|
1499
1649
|
betas.add("code-execution-web-tools-2026-02-09");
|
|
1500
|
-
const args = await
|
|
1650
|
+
const args = await validateTypes({
|
|
1501
1651
|
value: tool.args,
|
|
1502
1652
|
schema: webSearch_20260209ArgsSchema
|
|
1503
1653
|
});
|
|
@@ -1513,7 +1663,6 @@ async function prepareTools({
|
|
|
1513
1663
|
break;
|
|
1514
1664
|
}
|
|
1515
1665
|
case "anthropic.tool_search_regex_20251119": {
|
|
1516
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1517
1666
|
anthropicTools2.push({
|
|
1518
1667
|
type: "tool_search_tool_regex_20251119",
|
|
1519
1668
|
name: "tool_search_tool_regex"
|
|
@@ -1521,7 +1670,6 @@ async function prepareTools({
|
|
|
1521
1670
|
break;
|
|
1522
1671
|
}
|
|
1523
1672
|
case "anthropic.tool_search_bm25_20251119": {
|
|
1524
|
-
betas.add("advanced-tool-use-2025-11-20");
|
|
1525
1673
|
anthropicTools2.push({
|
|
1526
1674
|
type: "tool_search_tool_bm25_20251119",
|
|
1527
1675
|
name: "tool_search_tool_bm25"
|
|
@@ -1592,7 +1740,7 @@ async function prepareTools({
|
|
|
1592
1740
|
};
|
|
1593
1741
|
default: {
|
|
1594
1742
|
const _exhaustiveCheck = type;
|
|
1595
|
-
throw new
|
|
1743
|
+
throw new UnsupportedFunctionalityError({
|
|
1596
1744
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1597
1745
|
});
|
|
1598
1746
|
}
|
|
@@ -1640,36 +1788,50 @@ function convertAnthropicMessagesUsage({
|
|
|
1640
1788
|
}
|
|
1641
1789
|
|
|
1642
1790
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
1643
|
-
|
|
1644
|
-
|
|
1791
|
+
import {
|
|
1792
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
1793
|
+
} from "@ai-sdk/provider";
|
|
1794
|
+
import {
|
|
1795
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
1796
|
+
convertToBase64,
|
|
1797
|
+
isProviderReference,
|
|
1798
|
+
parseProviderOptions,
|
|
1799
|
+
resolveProviderReference,
|
|
1800
|
+
validateTypes as validateTypes2,
|
|
1801
|
+
isNonNullable
|
|
1802
|
+
} from "@ai-sdk/provider-utils";
|
|
1645
1803
|
|
|
1646
1804
|
// src/tool/code-execution_20250522.ts
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1805
|
+
import {
|
|
1806
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
|
|
1807
|
+
lazySchema as lazySchema9,
|
|
1808
|
+
zodSchema as zodSchema9
|
|
1809
|
+
} from "@ai-sdk/provider-utils";
|
|
1810
|
+
import { z as z10 } from "zod/v4";
|
|
1811
|
+
var codeExecution_20250522OutputSchema = lazySchema9(
|
|
1812
|
+
() => zodSchema9(
|
|
1813
|
+
z10.object({
|
|
1814
|
+
type: z10.literal("code_execution_result"),
|
|
1815
|
+
stdout: z10.string(),
|
|
1816
|
+
stderr: z10.string(),
|
|
1817
|
+
return_code: z10.number(),
|
|
1818
|
+
content: z10.array(
|
|
1819
|
+
z10.object({
|
|
1820
|
+
type: z10.literal("code_execution_output"),
|
|
1821
|
+
file_id: z10.string()
|
|
1660
1822
|
})
|
|
1661
1823
|
).optional().default([])
|
|
1662
1824
|
})
|
|
1663
1825
|
)
|
|
1664
1826
|
);
|
|
1665
|
-
var codeExecution_20250522InputSchema = (
|
|
1666
|
-
() => (
|
|
1667
|
-
|
|
1668
|
-
code:
|
|
1827
|
+
var codeExecution_20250522InputSchema = lazySchema9(
|
|
1828
|
+
() => zodSchema9(
|
|
1829
|
+
z10.object({
|
|
1830
|
+
code: z10.string()
|
|
1669
1831
|
})
|
|
1670
1832
|
)
|
|
1671
1833
|
);
|
|
1672
|
-
var factory6 = (
|
|
1834
|
+
var factory6 = createProviderToolFactoryWithOutputSchema5({
|
|
1673
1835
|
id: "anthropic.code_execution_20250522",
|
|
1674
1836
|
inputSchema: codeExecution_20250522InputSchema,
|
|
1675
1837
|
outputSchema: codeExecution_20250522OutputSchema
|
|
@@ -1679,102 +1841,106 @@ var codeExecution_20250522 = (args = {}) => {
|
|
|
1679
1841
|
};
|
|
1680
1842
|
|
|
1681
1843
|
// src/tool/code-execution_20250825.ts
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1844
|
+
import {
|
|
1845
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
|
|
1846
|
+
lazySchema as lazySchema10,
|
|
1847
|
+
zodSchema as zodSchema10
|
|
1848
|
+
} from "@ai-sdk/provider-utils";
|
|
1849
|
+
import { z as z11 } from "zod/v4";
|
|
1850
|
+
var codeExecution_20250825OutputSchema = lazySchema10(
|
|
1851
|
+
() => zodSchema10(
|
|
1852
|
+
z11.discriminatedUnion("type", [
|
|
1853
|
+
z11.object({
|
|
1854
|
+
type: z11.literal("code_execution_result"),
|
|
1855
|
+
stdout: z11.string(),
|
|
1856
|
+
stderr: z11.string(),
|
|
1857
|
+
return_code: z11.number(),
|
|
1858
|
+
content: z11.array(
|
|
1859
|
+
z11.object({
|
|
1860
|
+
type: z11.literal("code_execution_output"),
|
|
1861
|
+
file_id: z11.string()
|
|
1696
1862
|
})
|
|
1697
1863
|
).optional().default([])
|
|
1698
1864
|
}),
|
|
1699
|
-
|
|
1700
|
-
type:
|
|
1701
|
-
content:
|
|
1702
|
-
|
|
1703
|
-
type:
|
|
1704
|
-
file_id:
|
|
1865
|
+
z11.object({
|
|
1866
|
+
type: z11.literal("bash_code_execution_result"),
|
|
1867
|
+
content: z11.array(
|
|
1868
|
+
z11.object({
|
|
1869
|
+
type: z11.literal("bash_code_execution_output"),
|
|
1870
|
+
file_id: z11.string()
|
|
1705
1871
|
})
|
|
1706
1872
|
),
|
|
1707
|
-
stdout:
|
|
1708
|
-
stderr:
|
|
1709
|
-
return_code:
|
|
1873
|
+
stdout: z11.string(),
|
|
1874
|
+
stderr: z11.string(),
|
|
1875
|
+
return_code: z11.number()
|
|
1710
1876
|
}),
|
|
1711
|
-
|
|
1712
|
-
type:
|
|
1713
|
-
error_code:
|
|
1877
|
+
z11.object({
|
|
1878
|
+
type: z11.literal("bash_code_execution_tool_result_error"),
|
|
1879
|
+
error_code: z11.string()
|
|
1714
1880
|
}),
|
|
1715
|
-
|
|
1716
|
-
type:
|
|
1717
|
-
error_code:
|
|
1881
|
+
z11.object({
|
|
1882
|
+
type: z11.literal("text_editor_code_execution_tool_result_error"),
|
|
1883
|
+
error_code: z11.string()
|
|
1718
1884
|
}),
|
|
1719
|
-
|
|
1720
|
-
type:
|
|
1721
|
-
content:
|
|
1722
|
-
file_type:
|
|
1723
|
-
num_lines:
|
|
1724
|
-
start_line:
|
|
1725
|
-
total_lines:
|
|
1885
|
+
z11.object({
|
|
1886
|
+
type: z11.literal("text_editor_code_execution_view_result"),
|
|
1887
|
+
content: z11.string(),
|
|
1888
|
+
file_type: z11.string(),
|
|
1889
|
+
num_lines: z11.number().nullable(),
|
|
1890
|
+
start_line: z11.number().nullable(),
|
|
1891
|
+
total_lines: z11.number().nullable()
|
|
1726
1892
|
}),
|
|
1727
|
-
|
|
1728
|
-
type:
|
|
1729
|
-
is_file_update:
|
|
1893
|
+
z11.object({
|
|
1894
|
+
type: z11.literal("text_editor_code_execution_create_result"),
|
|
1895
|
+
is_file_update: z11.boolean()
|
|
1730
1896
|
}),
|
|
1731
|
-
|
|
1732
|
-
type:
|
|
1733
|
-
lines:
|
|
1734
|
-
new_lines:
|
|
1735
|
-
new_start:
|
|
1736
|
-
old_lines:
|
|
1737
|
-
old_start:
|
|
1897
|
+
z11.object({
|
|
1898
|
+
type: z11.literal("text_editor_code_execution_str_replace_result"),
|
|
1899
|
+
lines: z11.array(z11.string()).nullable(),
|
|
1900
|
+
new_lines: z11.number().nullable(),
|
|
1901
|
+
new_start: z11.number().nullable(),
|
|
1902
|
+
old_lines: z11.number().nullable(),
|
|
1903
|
+
old_start: z11.number().nullable()
|
|
1738
1904
|
})
|
|
1739
1905
|
])
|
|
1740
1906
|
)
|
|
1741
1907
|
);
|
|
1742
|
-
var codeExecution_20250825InputSchema = (
|
|
1743
|
-
() => (
|
|
1744
|
-
|
|
1908
|
+
var codeExecution_20250825InputSchema = lazySchema10(
|
|
1909
|
+
() => zodSchema10(
|
|
1910
|
+
z11.discriminatedUnion("type", [
|
|
1745
1911
|
// Programmatic tool calling format (mapped from { code } by AI SDK)
|
|
1746
|
-
|
|
1747
|
-
type:
|
|
1748
|
-
code:
|
|
1912
|
+
z11.object({
|
|
1913
|
+
type: z11.literal("programmatic-tool-call"),
|
|
1914
|
+
code: z11.string()
|
|
1749
1915
|
}),
|
|
1750
|
-
|
|
1751
|
-
type:
|
|
1752
|
-
command:
|
|
1916
|
+
z11.object({
|
|
1917
|
+
type: z11.literal("bash_code_execution"),
|
|
1918
|
+
command: z11.string()
|
|
1753
1919
|
}),
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
type:
|
|
1757
|
-
command:
|
|
1758
|
-
path:
|
|
1920
|
+
z11.discriminatedUnion("command", [
|
|
1921
|
+
z11.object({
|
|
1922
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1923
|
+
command: z11.literal("view"),
|
|
1924
|
+
path: z11.string()
|
|
1759
1925
|
}),
|
|
1760
|
-
|
|
1761
|
-
type:
|
|
1762
|
-
command:
|
|
1763
|
-
path:
|
|
1764
|
-
file_text:
|
|
1926
|
+
z11.object({
|
|
1927
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1928
|
+
command: z11.literal("create"),
|
|
1929
|
+
path: z11.string(),
|
|
1930
|
+
file_text: z11.string().nullish()
|
|
1765
1931
|
}),
|
|
1766
|
-
|
|
1767
|
-
type:
|
|
1768
|
-
command:
|
|
1769
|
-
path:
|
|
1770
|
-
old_str:
|
|
1771
|
-
new_str:
|
|
1932
|
+
z11.object({
|
|
1933
|
+
type: z11.literal("text_editor_code_execution"),
|
|
1934
|
+
command: z11.literal("str_replace"),
|
|
1935
|
+
path: z11.string(),
|
|
1936
|
+
old_str: z11.string(),
|
|
1937
|
+
new_str: z11.string()
|
|
1772
1938
|
})
|
|
1773
1939
|
])
|
|
1774
1940
|
])
|
|
1775
1941
|
)
|
|
1776
1942
|
);
|
|
1777
|
-
var factory7 = (
|
|
1943
|
+
var factory7 = createProviderToolFactoryWithOutputSchema6({
|
|
1778
1944
|
id: "anthropic.code_execution_20250825",
|
|
1779
1945
|
inputSchema: codeExecution_20250825InputSchema,
|
|
1780
1946
|
outputSchema: codeExecution_20250825OutputSchema,
|
|
@@ -1788,113 +1954,117 @@ var codeExecution_20250825 = (args = {}) => {
|
|
|
1788
1954
|
};
|
|
1789
1955
|
|
|
1790
1956
|
// src/tool/code-execution_20260120.ts
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1957
|
+
import {
|
|
1958
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
|
|
1959
|
+
lazySchema as lazySchema11,
|
|
1960
|
+
zodSchema as zodSchema11
|
|
1961
|
+
} from "@ai-sdk/provider-utils";
|
|
1962
|
+
import { z as z12 } from "zod/v4";
|
|
1963
|
+
var codeExecution_20260120OutputSchema = lazySchema11(
|
|
1964
|
+
() => zodSchema11(
|
|
1965
|
+
z12.discriminatedUnion("type", [
|
|
1966
|
+
z12.object({
|
|
1967
|
+
type: z12.literal("code_execution_result"),
|
|
1968
|
+
stdout: z12.string(),
|
|
1969
|
+
stderr: z12.string(),
|
|
1970
|
+
return_code: z12.number(),
|
|
1971
|
+
content: z12.array(
|
|
1972
|
+
z12.object({
|
|
1973
|
+
type: z12.literal("code_execution_output"),
|
|
1974
|
+
file_id: z12.string()
|
|
1805
1975
|
})
|
|
1806
1976
|
).optional().default([])
|
|
1807
1977
|
}),
|
|
1808
|
-
|
|
1809
|
-
type:
|
|
1810
|
-
encrypted_stdout:
|
|
1811
|
-
stderr:
|
|
1812
|
-
return_code:
|
|
1813
|
-
content:
|
|
1814
|
-
|
|
1815
|
-
type:
|
|
1816
|
-
file_id:
|
|
1978
|
+
z12.object({
|
|
1979
|
+
type: z12.literal("encrypted_code_execution_result"),
|
|
1980
|
+
encrypted_stdout: z12.string(),
|
|
1981
|
+
stderr: z12.string(),
|
|
1982
|
+
return_code: z12.number(),
|
|
1983
|
+
content: z12.array(
|
|
1984
|
+
z12.object({
|
|
1985
|
+
type: z12.literal("code_execution_output"),
|
|
1986
|
+
file_id: z12.string()
|
|
1817
1987
|
})
|
|
1818
1988
|
).optional().default([])
|
|
1819
1989
|
}),
|
|
1820
|
-
|
|
1821
|
-
type:
|
|
1822
|
-
content:
|
|
1823
|
-
|
|
1824
|
-
type:
|
|
1825
|
-
file_id:
|
|
1990
|
+
z12.object({
|
|
1991
|
+
type: z12.literal("bash_code_execution_result"),
|
|
1992
|
+
content: z12.array(
|
|
1993
|
+
z12.object({
|
|
1994
|
+
type: z12.literal("bash_code_execution_output"),
|
|
1995
|
+
file_id: z12.string()
|
|
1826
1996
|
})
|
|
1827
1997
|
),
|
|
1828
|
-
stdout:
|
|
1829
|
-
stderr:
|
|
1830
|
-
return_code:
|
|
1998
|
+
stdout: z12.string(),
|
|
1999
|
+
stderr: z12.string(),
|
|
2000
|
+
return_code: z12.number()
|
|
1831
2001
|
}),
|
|
1832
|
-
|
|
1833
|
-
type:
|
|
1834
|
-
error_code:
|
|
2002
|
+
z12.object({
|
|
2003
|
+
type: z12.literal("bash_code_execution_tool_result_error"),
|
|
2004
|
+
error_code: z12.string()
|
|
1835
2005
|
}),
|
|
1836
|
-
|
|
1837
|
-
type:
|
|
1838
|
-
error_code:
|
|
2006
|
+
z12.object({
|
|
2007
|
+
type: z12.literal("text_editor_code_execution_tool_result_error"),
|
|
2008
|
+
error_code: z12.string()
|
|
1839
2009
|
}),
|
|
1840
|
-
|
|
1841
|
-
type:
|
|
1842
|
-
content:
|
|
1843
|
-
file_type:
|
|
1844
|
-
num_lines:
|
|
1845
|
-
start_line:
|
|
1846
|
-
total_lines:
|
|
2010
|
+
z12.object({
|
|
2011
|
+
type: z12.literal("text_editor_code_execution_view_result"),
|
|
2012
|
+
content: z12.string(),
|
|
2013
|
+
file_type: z12.string(),
|
|
2014
|
+
num_lines: z12.number().nullable(),
|
|
2015
|
+
start_line: z12.number().nullable(),
|
|
2016
|
+
total_lines: z12.number().nullable()
|
|
1847
2017
|
}),
|
|
1848
|
-
|
|
1849
|
-
type:
|
|
1850
|
-
is_file_update:
|
|
2018
|
+
z12.object({
|
|
2019
|
+
type: z12.literal("text_editor_code_execution_create_result"),
|
|
2020
|
+
is_file_update: z12.boolean()
|
|
1851
2021
|
}),
|
|
1852
|
-
|
|
1853
|
-
type:
|
|
1854
|
-
lines:
|
|
1855
|
-
new_lines:
|
|
1856
|
-
new_start:
|
|
1857
|
-
old_lines:
|
|
1858
|
-
old_start:
|
|
2022
|
+
z12.object({
|
|
2023
|
+
type: z12.literal("text_editor_code_execution_str_replace_result"),
|
|
2024
|
+
lines: z12.array(z12.string()).nullable(),
|
|
2025
|
+
new_lines: z12.number().nullable(),
|
|
2026
|
+
new_start: z12.number().nullable(),
|
|
2027
|
+
old_lines: z12.number().nullable(),
|
|
2028
|
+
old_start: z12.number().nullable()
|
|
1859
2029
|
})
|
|
1860
2030
|
])
|
|
1861
2031
|
)
|
|
1862
2032
|
);
|
|
1863
|
-
var codeExecution_20260120InputSchema = (
|
|
1864
|
-
() => (
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
type:
|
|
1868
|
-
code:
|
|
2033
|
+
var codeExecution_20260120InputSchema = lazySchema11(
|
|
2034
|
+
() => zodSchema11(
|
|
2035
|
+
z12.discriminatedUnion("type", [
|
|
2036
|
+
z12.object({
|
|
2037
|
+
type: z12.literal("programmatic-tool-call"),
|
|
2038
|
+
code: z12.string()
|
|
1869
2039
|
}),
|
|
1870
|
-
|
|
1871
|
-
type:
|
|
1872
|
-
command:
|
|
2040
|
+
z12.object({
|
|
2041
|
+
type: z12.literal("bash_code_execution"),
|
|
2042
|
+
command: z12.string()
|
|
1873
2043
|
}),
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
type:
|
|
1877
|
-
command:
|
|
1878
|
-
path:
|
|
2044
|
+
z12.discriminatedUnion("command", [
|
|
2045
|
+
z12.object({
|
|
2046
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2047
|
+
command: z12.literal("view"),
|
|
2048
|
+
path: z12.string()
|
|
1879
2049
|
}),
|
|
1880
|
-
|
|
1881
|
-
type:
|
|
1882
|
-
command:
|
|
1883
|
-
path:
|
|
1884
|
-
file_text:
|
|
2050
|
+
z12.object({
|
|
2051
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2052
|
+
command: z12.literal("create"),
|
|
2053
|
+
path: z12.string(),
|
|
2054
|
+
file_text: z12.string().nullish()
|
|
1885
2055
|
}),
|
|
1886
|
-
|
|
1887
|
-
type:
|
|
1888
|
-
command:
|
|
1889
|
-
path:
|
|
1890
|
-
old_str:
|
|
1891
|
-
new_str:
|
|
2056
|
+
z12.object({
|
|
2057
|
+
type: z12.literal("text_editor_code_execution"),
|
|
2058
|
+
command: z12.literal("str_replace"),
|
|
2059
|
+
path: z12.string(),
|
|
2060
|
+
old_str: z12.string(),
|
|
2061
|
+
new_str: z12.string()
|
|
1892
2062
|
})
|
|
1893
2063
|
])
|
|
1894
2064
|
])
|
|
1895
2065
|
)
|
|
1896
2066
|
);
|
|
1897
|
-
var factory8 = (
|
|
2067
|
+
var factory8 = createProviderToolFactoryWithOutputSchema7({
|
|
1898
2068
|
id: "anthropic.code_execution_20260120",
|
|
1899
2069
|
inputSchema: codeExecution_20260120InputSchema,
|
|
1900
2070
|
outputSchema: codeExecution_20260120OutputSchema,
|
|
@@ -1905,21 +2075,25 @@ var codeExecution_20260120 = (args = {}) => {
|
|
|
1905
2075
|
};
|
|
1906
2076
|
|
|
1907
2077
|
// src/tool/tool-search-regex_20251119.ts
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
2078
|
+
import {
|
|
2079
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
|
|
2080
|
+
lazySchema as lazySchema12,
|
|
2081
|
+
zodSchema as zodSchema12
|
|
2082
|
+
} from "@ai-sdk/provider-utils";
|
|
2083
|
+
import { z as z13 } from "zod/v4";
|
|
2084
|
+
var toolSearchRegex_20251119OutputSchema = lazySchema12(
|
|
2085
|
+
() => zodSchema12(
|
|
2086
|
+
z13.array(
|
|
2087
|
+
z13.object({
|
|
2088
|
+
type: z13.literal("tool_reference"),
|
|
2089
|
+
toolName: z13.string()
|
|
1916
2090
|
})
|
|
1917
2091
|
)
|
|
1918
2092
|
)
|
|
1919
2093
|
);
|
|
1920
|
-
var toolSearchRegex_20251119InputSchema = (
|
|
1921
|
-
() => (
|
|
1922
|
-
|
|
2094
|
+
var toolSearchRegex_20251119InputSchema = lazySchema12(
|
|
2095
|
+
() => zodSchema12(
|
|
2096
|
+
z13.object({
|
|
1923
2097
|
/**
|
|
1924
2098
|
* A regex pattern to search for tools.
|
|
1925
2099
|
* Uses Python re.search() syntax. Maximum 200 characters.
|
|
@@ -1930,15 +2104,15 @@ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils13.lazySchema
|
|
|
1930
2104
|
* - "database.*query|query.*database" - OR patterns for flexibility
|
|
1931
2105
|
* - "(?i)slack" - case-insensitive search
|
|
1932
2106
|
*/
|
|
1933
|
-
pattern:
|
|
2107
|
+
pattern: z13.string(),
|
|
1934
2108
|
/**
|
|
1935
2109
|
* Maximum number of tools to return. Optional.
|
|
1936
2110
|
*/
|
|
1937
|
-
limit:
|
|
2111
|
+
limit: z13.number().optional()
|
|
1938
2112
|
})
|
|
1939
2113
|
)
|
|
1940
2114
|
);
|
|
1941
|
-
var factory9 = (
|
|
2115
|
+
var factory9 = createProviderToolFactoryWithOutputSchema8({
|
|
1942
2116
|
id: "anthropic.tool_search_regex_20251119",
|
|
1943
2117
|
inputSchema: toolSearchRegex_20251119InputSchema,
|
|
1944
2118
|
outputSchema: toolSearchRegex_20251119OutputSchema,
|
|
@@ -1951,17 +2125,17 @@ var toolSearchRegex_20251119 = (args = {}) => {
|
|
|
1951
2125
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
1952
2126
|
function convertToString(data) {
|
|
1953
2127
|
if (typeof data === "string") {
|
|
1954
|
-
return new TextDecoder().decode((
|
|
2128
|
+
return new TextDecoder().decode(convertBase64ToUint8Array2(data));
|
|
1955
2129
|
}
|
|
1956
2130
|
if (data instanceof Uint8Array) {
|
|
1957
2131
|
return new TextDecoder().decode(data);
|
|
1958
2132
|
}
|
|
1959
2133
|
if (data instanceof URL) {
|
|
1960
|
-
throw new
|
|
2134
|
+
throw new UnsupportedFunctionalityError2({
|
|
1961
2135
|
functionality: "URL-based text documents are not supported for citations"
|
|
1962
2136
|
});
|
|
1963
2137
|
}
|
|
1964
|
-
throw new
|
|
2138
|
+
throw new UnsupportedFunctionalityError2({
|
|
1965
2139
|
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
1966
2140
|
});
|
|
1967
2141
|
}
|
|
@@ -1989,7 +2163,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1989
2163
|
const messages = [];
|
|
1990
2164
|
async function shouldEnableCitations(providerMetadata) {
|
|
1991
2165
|
var _a2, _b2;
|
|
1992
|
-
const anthropicOptions = await
|
|
2166
|
+
const anthropicOptions = await parseProviderOptions({
|
|
1993
2167
|
provider: "anthropic",
|
|
1994
2168
|
providerOptions: providerMetadata,
|
|
1995
2169
|
schema: anthropicFilePartProviderOptions
|
|
@@ -1997,7 +2171,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1997
2171
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
1998
2172
|
}
|
|
1999
2173
|
async function getDocumentMetadata(providerMetadata) {
|
|
2000
|
-
const anthropicOptions = await
|
|
2174
|
+
const anthropicOptions = await parseProviderOptions({
|
|
2001
2175
|
provider: "anthropic",
|
|
2002
2176
|
providerOptions: providerMetadata,
|
|
2003
2177
|
schema: anthropicFilePartProviderOptions
|
|
@@ -2014,7 +2188,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2014
2188
|
switch (type) {
|
|
2015
2189
|
case "system": {
|
|
2016
2190
|
if (system != null) {
|
|
2017
|
-
throw new
|
|
2191
|
+
throw new UnsupportedFunctionalityError2({
|
|
2018
2192
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
2019
2193
|
});
|
|
2020
2194
|
}
|
|
@@ -2054,7 +2228,26 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2054
2228
|
break;
|
|
2055
2229
|
}
|
|
2056
2230
|
case "file": {
|
|
2057
|
-
if (part.
|
|
2231
|
+
if (isProviderReference(part.data)) {
|
|
2232
|
+
const fileId = resolveProviderReference({
|
|
2233
|
+
reference: part.data,
|
|
2234
|
+
provider: "anthropic"
|
|
2235
|
+
});
|
|
2236
|
+
betas.add("files-api-2025-04-14");
|
|
2237
|
+
if (part.mediaType.startsWith("image/")) {
|
|
2238
|
+
anthropicContent.push({
|
|
2239
|
+
type: "image",
|
|
2240
|
+
source: { type: "file", file_id: fileId },
|
|
2241
|
+
cache_control: cacheControl
|
|
2242
|
+
});
|
|
2243
|
+
} else {
|
|
2244
|
+
anthropicContent.push({
|
|
2245
|
+
type: "document",
|
|
2246
|
+
source: { type: "file", file_id: fileId },
|
|
2247
|
+
cache_control: cacheControl
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
} else if (part.mediaType.startsWith("image/")) {
|
|
2058
2251
|
anthropicContent.push({
|
|
2059
2252
|
type: "image",
|
|
2060
2253
|
source: isUrlData(part.data) ? {
|
|
@@ -2063,7 +2256,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2063
2256
|
} : {
|
|
2064
2257
|
type: "base64",
|
|
2065
2258
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
2066
|
-
data:
|
|
2259
|
+
data: convertToBase64(part.data)
|
|
2067
2260
|
},
|
|
2068
2261
|
cache_control: cacheControl
|
|
2069
2262
|
});
|
|
@@ -2083,7 +2276,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2083
2276
|
} : {
|
|
2084
2277
|
type: "base64",
|
|
2085
2278
|
media_type: "application/pdf",
|
|
2086
|
-
data:
|
|
2279
|
+
data: convertToBase64(part.data)
|
|
2087
2280
|
},
|
|
2088
2281
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
2089
2282
|
...metadata.context && { context: metadata.context },
|
|
@@ -2117,7 +2310,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2117
2310
|
cache_control: cacheControl
|
|
2118
2311
|
});
|
|
2119
2312
|
} else {
|
|
2120
|
-
throw new
|
|
2313
|
+
throw new UnsupportedFunctionalityError2({
|
|
2121
2314
|
functionality: `media type: ${part.mediaType}`
|
|
2122
2315
|
});
|
|
2123
2316
|
}
|
|
@@ -2153,26 +2346,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2153
2346
|
type: "text",
|
|
2154
2347
|
text: contentPart.text
|
|
2155
2348
|
};
|
|
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
2349
|
case "file-url": {
|
|
2350
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2351
|
+
return {
|
|
2352
|
+
type: "image",
|
|
2353
|
+
source: {
|
|
2354
|
+
type: "url",
|
|
2355
|
+
url: contentPart.url
|
|
2356
|
+
}
|
|
2357
|
+
};
|
|
2358
|
+
}
|
|
2176
2359
|
return {
|
|
2177
2360
|
type: "document",
|
|
2178
2361
|
source: {
|
|
@@ -2182,6 +2365,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2182
2365
|
};
|
|
2183
2366
|
}
|
|
2184
2367
|
case "file-data": {
|
|
2368
|
+
if (contentPart.mediaType.startsWith("image/")) {
|
|
2369
|
+
return {
|
|
2370
|
+
type: "image",
|
|
2371
|
+
source: {
|
|
2372
|
+
type: "base64",
|
|
2373
|
+
media_type: contentPart.mediaType,
|
|
2374
|
+
data: contentPart.data
|
|
2375
|
+
}
|
|
2376
|
+
};
|
|
2377
|
+
}
|
|
2185
2378
|
if (contentPart.mediaType === "application/pdf") {
|
|
2186
2379
|
betas.add("pdfs-2024-09-25");
|
|
2187
2380
|
return {
|
|
@@ -2221,7 +2414,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2221
2414
|
return void 0;
|
|
2222
2415
|
}
|
|
2223
2416
|
}
|
|
2224
|
-
}).filter(
|
|
2417
|
+
}).filter(isNonNullable);
|
|
2225
2418
|
break;
|
|
2226
2419
|
case "text":
|
|
2227
2420
|
case "error-text":
|
|
@@ -2297,7 +2490,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2297
2490
|
}
|
|
2298
2491
|
case "reasoning": {
|
|
2299
2492
|
if (sendReasoning) {
|
|
2300
|
-
const reasoningMetadata = await
|
|
2493
|
+
const reasoningMetadata = await parseProviderOptions({
|
|
2301
2494
|
provider: "anthropic",
|
|
2302
2495
|
providerOptions: part.providerOptions,
|
|
2303
2496
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -2503,7 +2696,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2503
2696
|
break;
|
|
2504
2697
|
}
|
|
2505
2698
|
if (output.value.type === "code_execution_result") {
|
|
2506
|
-
const codeExecutionOutput = await (
|
|
2699
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2507
2700
|
value: output.value,
|
|
2508
2701
|
schema: codeExecution_20250522OutputSchema
|
|
2509
2702
|
});
|
|
@@ -2520,7 +2713,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2520
2713
|
cache_control: cacheControl
|
|
2521
2714
|
});
|
|
2522
2715
|
} else if (output.value.type === "encrypted_code_execution_result") {
|
|
2523
|
-
const codeExecutionOutput = await (
|
|
2716
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2524
2717
|
value: output.value,
|
|
2525
2718
|
schema: codeExecution_20260120OutputSchema
|
|
2526
2719
|
});
|
|
@@ -2539,7 +2732,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2539
2732
|
});
|
|
2540
2733
|
}
|
|
2541
2734
|
} else {
|
|
2542
|
-
const codeExecutionOutput = await (
|
|
2735
|
+
const codeExecutionOutput = await validateTypes2({
|
|
2543
2736
|
value: output.value,
|
|
2544
2737
|
schema: codeExecution_20250825OutputSchema
|
|
2545
2738
|
});
|
|
@@ -2608,7 +2801,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2608
2801
|
});
|
|
2609
2802
|
break;
|
|
2610
2803
|
}
|
|
2611
|
-
const webFetchOutput = await (
|
|
2804
|
+
const webFetchOutput = await validateTypes2({
|
|
2612
2805
|
value: output.value,
|
|
2613
2806
|
schema: webFetch_20250910OutputSchema
|
|
2614
2807
|
});
|
|
@@ -2643,7 +2836,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2643
2836
|
});
|
|
2644
2837
|
break;
|
|
2645
2838
|
}
|
|
2646
|
-
const webSearchOutput = await (
|
|
2839
|
+
const webSearchOutput = await validateTypes2({
|
|
2647
2840
|
value: output.value,
|
|
2648
2841
|
schema: webSearch_20250305OutputSchema
|
|
2649
2842
|
});
|
|
@@ -2670,7 +2863,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2670
2863
|
});
|
|
2671
2864
|
break;
|
|
2672
2865
|
}
|
|
2673
|
-
const toolSearchOutput = await (
|
|
2866
|
+
const toolSearchOutput = await validateTypes2({
|
|
2674
2867
|
value: output.value,
|
|
2675
2868
|
schema: toolSearchRegex_20251119OutputSchema
|
|
2676
2869
|
});
|
|
@@ -2828,13 +3021,22 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
2828
3021
|
}
|
|
2829
3022
|
};
|
|
2830
3023
|
}
|
|
2831
|
-
var AnthropicMessagesLanguageModel = class {
|
|
3024
|
+
var AnthropicMessagesLanguageModel = class _AnthropicMessagesLanguageModel {
|
|
2832
3025
|
constructor(modelId, config) {
|
|
2833
3026
|
this.specificationVersion = "v4";
|
|
2834
3027
|
var _a;
|
|
2835
3028
|
this.modelId = modelId;
|
|
2836
3029
|
this.config = config;
|
|
2837
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
3030
|
+
this.generateId = (_a = config.generateId) != null ? _a : generateId;
|
|
3031
|
+
}
|
|
3032
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
3033
|
+
return serializeModelOptions({
|
|
3034
|
+
modelId: model.modelId,
|
|
3035
|
+
config: model.config
|
|
3036
|
+
});
|
|
3037
|
+
}
|
|
3038
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
3039
|
+
return new _AnthropicMessagesLanguageModel(options.modelId, options.config);
|
|
2838
3040
|
}
|
|
2839
3041
|
supportsUrl(url) {
|
|
2840
3042
|
return url.protocol === "https:";
|
|
@@ -2869,10 +3071,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2869
3071
|
seed,
|
|
2870
3072
|
tools,
|
|
2871
3073
|
toolChoice,
|
|
3074
|
+
reasoning,
|
|
2872
3075
|
providerOptions,
|
|
2873
3076
|
stream
|
|
2874
3077
|
}) {
|
|
2875
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3078
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2876
3079
|
const warnings = [];
|
|
2877
3080
|
if (frequencyPenalty != null) {
|
|
2878
3081
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2908,12 +3111,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2908
3111
|
}
|
|
2909
3112
|
}
|
|
2910
3113
|
const providerOptionsName = this.providerOptionsName;
|
|
2911
|
-
const canonicalOptions = await (
|
|
3114
|
+
const canonicalOptions = await parseProviderOptions2({
|
|
2912
3115
|
provider: "anthropic",
|
|
2913
3116
|
providerOptions,
|
|
2914
3117
|
schema: anthropicLanguageModelOptions
|
|
2915
3118
|
});
|
|
2916
|
-
const customProviderOptions = providerOptionsName !== "anthropic" ? await (
|
|
3119
|
+
const customProviderOptions = providerOptionsName !== "anthropic" ? await parseProviderOptions2({
|
|
2917
3120
|
provider: providerOptionsName,
|
|
2918
3121
|
providerOptions,
|
|
2919
3122
|
schema: anthropicLanguageModelOptions
|
|
@@ -2927,10 +3130,41 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2927
3130
|
const {
|
|
2928
3131
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2929
3132
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
3133
|
+
supportsAdaptiveThinking,
|
|
3134
|
+
rejectsSamplingParameters,
|
|
3135
|
+
supportsXhighEffort,
|
|
2930
3136
|
isKnownModel
|
|
2931
3137
|
} = getModelCapabilities(this.modelId);
|
|
3138
|
+
if (rejectsSamplingParameters) {
|
|
3139
|
+
if (temperature != null) {
|
|
3140
|
+
warnings.push({
|
|
3141
|
+
type: "unsupported",
|
|
3142
|
+
feature: "temperature",
|
|
3143
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
3144
|
+
});
|
|
3145
|
+
temperature = void 0;
|
|
3146
|
+
}
|
|
3147
|
+
if (topK != null) {
|
|
3148
|
+
warnings.push({
|
|
3149
|
+
type: "unsupported",
|
|
3150
|
+
feature: "topK",
|
|
3151
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
3152
|
+
});
|
|
3153
|
+
topK = void 0;
|
|
3154
|
+
}
|
|
3155
|
+
if (topP != null) {
|
|
3156
|
+
warnings.push({
|
|
3157
|
+
type: "unsupported",
|
|
3158
|
+
feature: "topP",
|
|
3159
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
3160
|
+
});
|
|
3161
|
+
topP = void 0;
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
2932
3165
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2933
|
-
const
|
|
3166
|
+
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
3167
|
+
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
2934
3168
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2935
3169
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
2936
3170
|
type: "function",
|
|
@@ -2940,7 +3174,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2940
3174
|
} : void 0;
|
|
2941
3175
|
const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
|
|
2942
3176
|
const cacheControlValidator = new CacheControlValidator();
|
|
2943
|
-
const toolNameMapping =
|
|
3177
|
+
const toolNameMapping = createToolNameMapping({
|
|
2944
3178
|
tools,
|
|
2945
3179
|
providerToolNames: {
|
|
2946
3180
|
"anthropic.code_execution_20250522": "code_execution",
|
|
@@ -2965,14 +3199,32 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2965
3199
|
});
|
|
2966
3200
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
2967
3201
|
prompt,
|
|
2968
|
-
sendReasoning: (
|
|
3202
|
+
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
2969
3203
|
warnings,
|
|
2970
3204
|
cacheControlValidator,
|
|
2971
3205
|
toolNameMapping
|
|
2972
3206
|
});
|
|
2973
|
-
|
|
3207
|
+
if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
|
|
3208
|
+
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
3209
|
+
reasoning,
|
|
3210
|
+
supportsAdaptiveThinking,
|
|
3211
|
+
supportsXhighEffort,
|
|
3212
|
+
maxOutputTokensForModel,
|
|
3213
|
+
warnings
|
|
3214
|
+
});
|
|
3215
|
+
if (reasoningConfig != null) {
|
|
3216
|
+
if (anthropicOptions.thinking == null) {
|
|
3217
|
+
anthropicOptions.thinking = reasoningConfig.thinking;
|
|
3218
|
+
}
|
|
3219
|
+
if (reasoningConfig.effort != null && ((_e = anthropicOptions.thinking) == null ? void 0 : _e.type) !== "disabled") {
|
|
3220
|
+
anthropicOptions.effort = reasoningConfig.effort;
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
const thinkingType = (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.type;
|
|
2974
3225
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2975
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
3226
|
+
let thinkingBudget = thinkingType === "enabled" ? (_g = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _g.budgetTokens : void 0;
|
|
3227
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_h = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _h.display : void 0;
|
|
2976
3228
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2977
3229
|
const baseArgs = {
|
|
2978
3230
|
// model id:
|
|
@@ -2987,14 +3239,24 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2987
3239
|
...isThinking && {
|
|
2988
3240
|
thinking: {
|
|
2989
3241
|
type: thinkingType,
|
|
2990
|
-
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
3242
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
3243
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
2991
3244
|
}
|
|
2992
3245
|
},
|
|
2993
|
-
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
3246
|
+
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
2994
3247
|
output_config: {
|
|
2995
3248
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
2996
3249
|
effort: anthropicOptions.effort
|
|
2997
3250
|
},
|
|
3251
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) && {
|
|
3252
|
+
task_budget: {
|
|
3253
|
+
type: anthropicOptions.taskBudget.type,
|
|
3254
|
+
total: anthropicOptions.taskBudget.total,
|
|
3255
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
3256
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
},
|
|
2998
3260
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
2999
3261
|
format: {
|
|
3000
3262
|
type: "json_schema",
|
|
@@ -3006,9 +3268,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3006
3268
|
...(anthropicOptions == null ? void 0 : anthropicOptions.speed) && {
|
|
3007
3269
|
speed: anthropicOptions.speed
|
|
3008
3270
|
},
|
|
3271
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
|
|
3272
|
+
inference_geo: anthropicOptions.inferenceGeo
|
|
3273
|
+
},
|
|
3009
3274
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3010
3275
|
cache_control: anthropicOptions.cacheControl
|
|
3011
3276
|
},
|
|
3277
|
+
...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
|
|
3278
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3279
|
+
},
|
|
3012
3280
|
// mcp servers:
|
|
3013
3281
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3014
3282
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3030,7 +3298,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3030
3298
|
id: anthropicOptions.container.id,
|
|
3031
3299
|
skills: anthropicOptions.container.skills.map((skill) => ({
|
|
3032
3300
|
type: skill.type,
|
|
3033
|
-
skill_id: skill.
|
|
3301
|
+
skill_id: skill.type === "custom" ? resolveProviderReference2({
|
|
3302
|
+
reference: skill.providerReference,
|
|
3303
|
+
provider: "anthropic"
|
|
3304
|
+
}) : skill.skillId,
|
|
3034
3305
|
version: skill.version
|
|
3035
3306
|
}))
|
|
3036
3307
|
}
|
|
@@ -3132,7 +3403,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3132
3403
|
}
|
|
3133
3404
|
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
3134
3405
|
} else {
|
|
3135
|
-
if (topP != null && temperature != null) {
|
|
3406
|
+
if (isAnthropicModel && topP != null && temperature != null) {
|
|
3136
3407
|
warnings.push({
|
|
3137
3408
|
type: "unsupported",
|
|
3138
3409
|
feature: "topP",
|
|
@@ -3176,10 +3447,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3176
3447
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
3177
3448
|
betas.add("effort-2025-11-24");
|
|
3178
3449
|
}
|
|
3450
|
+
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
3451
|
+
betas.add("task-budgets-2026-03-13");
|
|
3452
|
+
}
|
|
3179
3453
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3180
3454
|
betas.add("fast-mode-2026-02-01");
|
|
3181
3455
|
}
|
|
3182
|
-
if (stream && ((
|
|
3456
|
+
if (stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true)) {
|
|
3183
3457
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3184
3458
|
}
|
|
3185
3459
|
const {
|
|
@@ -3193,13 +3467,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3193
3467
|
toolChoice: { type: "required" },
|
|
3194
3468
|
disableParallelToolUse: true,
|
|
3195
3469
|
cacheControlValidator,
|
|
3196
|
-
supportsStructuredOutput: false
|
|
3470
|
+
supportsStructuredOutput: false,
|
|
3471
|
+
supportsStrictTools
|
|
3197
3472
|
} : {
|
|
3198
3473
|
tools: tools != null ? tools : [],
|
|
3199
3474
|
toolChoice,
|
|
3200
3475
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3201
3476
|
cacheControlValidator,
|
|
3202
|
-
supportsStructuredOutput
|
|
3477
|
+
supportsStructuredOutput,
|
|
3478
|
+
supportsStrictTools
|
|
3203
3479
|
}
|
|
3204
3480
|
);
|
|
3205
3481
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3216,7 +3492,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3216
3492
|
...betas,
|
|
3217
3493
|
...toolsBetas,
|
|
3218
3494
|
...userSuppliedBetas,
|
|
3219
|
-
...(
|
|
3495
|
+
...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
|
|
3220
3496
|
]),
|
|
3221
3497
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3222
3498
|
toolNameMapping,
|
|
@@ -3228,16 +3504,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3228
3504
|
betas,
|
|
3229
3505
|
headers
|
|
3230
3506
|
}) {
|
|
3231
|
-
return (
|
|
3232
|
-
await
|
|
3507
|
+
return combineHeaders2(
|
|
3508
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
3233
3509
|
headers,
|
|
3234
3510
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
3235
3511
|
);
|
|
3236
3512
|
}
|
|
3237
3513
|
async getBetasFromHeaders(requestHeaders) {
|
|
3238
3514
|
var _a, _b;
|
|
3239
|
-
const configHeaders = await
|
|
3240
|
-
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3515
|
+
const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
|
|
3516
|
+
const configBetaHeader = (_a = configHeaders == null ? void 0 : configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
3241
3517
|
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
3242
3518
|
return new Set(
|
|
3243
3519
|
[
|
|
@@ -3302,12 +3578,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3302
3578
|
responseHeaders,
|
|
3303
3579
|
value: response,
|
|
3304
3580
|
rawValue: rawResponse
|
|
3305
|
-
} = await
|
|
3581
|
+
} = await postJsonToApi({
|
|
3306
3582
|
url: this.buildRequestUrl(false),
|
|
3307
3583
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3308
3584
|
body: this.transformRequestBody(args, betas),
|
|
3309
3585
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3310
|
-
successfulResponseHandler: (
|
|
3586
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
3311
3587
|
anthropicMessagesResponseSchema
|
|
3312
3588
|
),
|
|
3313
3589
|
abortSignal: options.abortSignal,
|
|
@@ -3701,6 +3977,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3701
3977
|
};
|
|
3702
3978
|
}
|
|
3703
3979
|
async doStream(options) {
|
|
3980
|
+
"use step";
|
|
3704
3981
|
var _a, _b;
|
|
3705
3982
|
const {
|
|
3706
3983
|
args: body,
|
|
@@ -3722,12 +3999,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3722
3999
|
body.tools
|
|
3723
4000
|
);
|
|
3724
4001
|
const url = this.buildRequestUrl(true);
|
|
3725
|
-
const { responseHeaders, value: response } = await
|
|
4002
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
3726
4003
|
url,
|
|
3727
4004
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
3728
4005
|
body: this.transformRequestBody(body, betas),
|
|
3729
4006
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
3730
|
-
successfulResponseHandler:
|
|
4007
|
+
successfulResponseHandler: createEventSourceResponseHandler(
|
|
3731
4008
|
anthropicMessagesChunkSchema
|
|
3732
4009
|
),
|
|
3733
4010
|
abortSignal: options.abortSignal,
|
|
@@ -4452,7 +4729,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4452
4729
|
}
|
|
4453
4730
|
if (((_b = result.value) == null ? void 0 : _b.type) === "error") {
|
|
4454
4731
|
const error = result.value.error;
|
|
4455
|
-
throw new
|
|
4732
|
+
throw new APICallError({
|
|
4456
4733
|
message: error.message,
|
|
4457
4734
|
url,
|
|
4458
4735
|
requestBodyValues: body,
|
|
@@ -4475,46 +4752,76 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
4475
4752
|
}
|
|
4476
4753
|
};
|
|
4477
4754
|
function getModelCapabilities(modelId) {
|
|
4478
|
-
if (modelId.includes("claude-
|
|
4755
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
4756
|
+
return {
|
|
4757
|
+
maxOutputTokens: 128e3,
|
|
4758
|
+
supportsStructuredOutput: true,
|
|
4759
|
+
supportsAdaptiveThinking: true,
|
|
4760
|
+
rejectsSamplingParameters: true,
|
|
4761
|
+
supportsXhighEffort: true,
|
|
4762
|
+
isKnownModel: true
|
|
4763
|
+
};
|
|
4764
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
4479
4765
|
return {
|
|
4480
4766
|
maxOutputTokens: 128e3,
|
|
4481
4767
|
supportsStructuredOutput: true,
|
|
4768
|
+
supportsAdaptiveThinking: true,
|
|
4769
|
+
rejectsSamplingParameters: false,
|
|
4770
|
+
supportsXhighEffort: false,
|
|
4482
4771
|
isKnownModel: true
|
|
4483
4772
|
};
|
|
4484
4773
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
4485
4774
|
return {
|
|
4486
4775
|
maxOutputTokens: 64e3,
|
|
4487
4776
|
supportsStructuredOutput: true,
|
|
4777
|
+
supportsAdaptiveThinking: false,
|
|
4778
|
+
rejectsSamplingParameters: false,
|
|
4779
|
+
supportsXhighEffort: false,
|
|
4488
4780
|
isKnownModel: true
|
|
4489
4781
|
};
|
|
4490
4782
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
4491
4783
|
return {
|
|
4492
4784
|
maxOutputTokens: 32e3,
|
|
4493
4785
|
supportsStructuredOutput: true,
|
|
4786
|
+
supportsAdaptiveThinking: false,
|
|
4787
|
+
rejectsSamplingParameters: false,
|
|
4788
|
+
supportsXhighEffort: false,
|
|
4494
4789
|
isKnownModel: true
|
|
4495
4790
|
};
|
|
4496
4791
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
4497
4792
|
return {
|
|
4498
4793
|
maxOutputTokens: 64e3,
|
|
4499
4794
|
supportsStructuredOutput: false,
|
|
4795
|
+
supportsAdaptiveThinking: false,
|
|
4796
|
+
rejectsSamplingParameters: false,
|
|
4797
|
+
supportsXhighEffort: false,
|
|
4500
4798
|
isKnownModel: true
|
|
4501
4799
|
};
|
|
4502
4800
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
4503
4801
|
return {
|
|
4504
4802
|
maxOutputTokens: 32e3,
|
|
4505
4803
|
supportsStructuredOutput: false,
|
|
4804
|
+
supportsAdaptiveThinking: false,
|
|
4805
|
+
rejectsSamplingParameters: false,
|
|
4806
|
+
supportsXhighEffort: false,
|
|
4506
4807
|
isKnownModel: true
|
|
4507
4808
|
};
|
|
4508
4809
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
4509
4810
|
return {
|
|
4510
4811
|
maxOutputTokens: 4096,
|
|
4511
4812
|
supportsStructuredOutput: false,
|
|
4813
|
+
supportsAdaptiveThinking: false,
|
|
4814
|
+
rejectsSamplingParameters: false,
|
|
4815
|
+
supportsXhighEffort: false,
|
|
4512
4816
|
isKnownModel: true
|
|
4513
4817
|
};
|
|
4514
4818
|
} else {
|
|
4515
4819
|
return {
|
|
4516
4820
|
maxOutputTokens: 4096,
|
|
4517
4821
|
supportsStructuredOutput: false,
|
|
4822
|
+
supportsAdaptiveThinking: false,
|
|
4823
|
+
rejectsSamplingParameters: false,
|
|
4824
|
+
supportsXhighEffort: false,
|
|
4518
4825
|
isKnownModel: false
|
|
4519
4826
|
};
|
|
4520
4827
|
}
|
|
@@ -4537,6 +4844,44 @@ function hasWebTool20260209WithoutCodeExecution(tools) {
|
|
|
4537
4844
|
}
|
|
4538
4845
|
return hasWebTool20260209 && !hasCodeExecutionTool;
|
|
4539
4846
|
}
|
|
4847
|
+
function resolveAnthropicReasoningConfig({
|
|
4848
|
+
reasoning,
|
|
4849
|
+
supportsAdaptiveThinking,
|
|
4850
|
+
supportsXhighEffort,
|
|
4851
|
+
maxOutputTokensForModel,
|
|
4852
|
+
warnings
|
|
4853
|
+
}) {
|
|
4854
|
+
if (!isCustomReasoning(reasoning)) {
|
|
4855
|
+
return void 0;
|
|
4856
|
+
}
|
|
4857
|
+
if (reasoning === "none") {
|
|
4858
|
+
return { thinking: { type: "disabled" } };
|
|
4859
|
+
}
|
|
4860
|
+
if (supportsAdaptiveThinking) {
|
|
4861
|
+
const effort = mapReasoningToProviderEffort({
|
|
4862
|
+
reasoning,
|
|
4863
|
+
effortMap: {
|
|
4864
|
+
minimal: "low",
|
|
4865
|
+
low: "low",
|
|
4866
|
+
medium: "medium",
|
|
4867
|
+
high: "high",
|
|
4868
|
+
xhigh: supportsXhighEffort ? "xhigh" : "max"
|
|
4869
|
+
},
|
|
4870
|
+
warnings
|
|
4871
|
+
});
|
|
4872
|
+
return { thinking: { type: "adaptive" }, effort };
|
|
4873
|
+
}
|
|
4874
|
+
const budgetTokens = mapReasoningToProviderBudget({
|
|
4875
|
+
reasoning,
|
|
4876
|
+
maxOutputTokens: maxOutputTokensForModel,
|
|
4877
|
+
maxReasoningBudget: maxOutputTokensForModel,
|
|
4878
|
+
warnings
|
|
4879
|
+
});
|
|
4880
|
+
if (budgetTokens == null) {
|
|
4881
|
+
return void 0;
|
|
4882
|
+
}
|
|
4883
|
+
return { thinking: { type: "enabled", budgetTokens } };
|
|
4884
|
+
}
|
|
4540
4885
|
function mapAnthropicResponseContextManagement(contextManagement) {
|
|
4541
4886
|
return contextManagement ? {
|
|
4542
4887
|
appliedEdits: contextManagement.applied_edits.map((edit) => {
|
|
@@ -4564,44 +4909,56 @@ function mapAnthropicResponseContextManagement(contextManagement) {
|
|
|
4564
4909
|
}
|
|
4565
4910
|
|
|
4566
4911
|
// src/tool/bash_20241022.ts
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4912
|
+
import {
|
|
4913
|
+
createProviderToolFactory as createProviderToolFactory2,
|
|
4914
|
+
lazySchema as lazySchema13,
|
|
4915
|
+
zodSchema as zodSchema13
|
|
4916
|
+
} from "@ai-sdk/provider-utils";
|
|
4917
|
+
import { z as z14 } from "zod/v4";
|
|
4918
|
+
var bash_20241022InputSchema = lazySchema13(
|
|
4919
|
+
() => zodSchema13(
|
|
4920
|
+
z14.object({
|
|
4921
|
+
command: z14.string(),
|
|
4922
|
+
restart: z14.boolean().optional()
|
|
4574
4923
|
})
|
|
4575
4924
|
)
|
|
4576
4925
|
);
|
|
4577
|
-
var bash_20241022 = (
|
|
4926
|
+
var bash_20241022 = createProviderToolFactory2({
|
|
4578
4927
|
id: "anthropic.bash_20241022",
|
|
4579
4928
|
inputSchema: bash_20241022InputSchema
|
|
4580
4929
|
});
|
|
4581
4930
|
|
|
4582
4931
|
// src/tool/bash_20250124.ts
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4932
|
+
import {
|
|
4933
|
+
createProviderToolFactory as createProviderToolFactory3,
|
|
4934
|
+
lazySchema as lazySchema14,
|
|
4935
|
+
zodSchema as zodSchema14
|
|
4936
|
+
} from "@ai-sdk/provider-utils";
|
|
4937
|
+
import { z as z15 } from "zod/v4";
|
|
4938
|
+
var bash_20250124InputSchema = lazySchema14(
|
|
4939
|
+
() => zodSchema14(
|
|
4940
|
+
z15.object({
|
|
4941
|
+
command: z15.string(),
|
|
4942
|
+
restart: z15.boolean().optional()
|
|
4590
4943
|
})
|
|
4591
4944
|
)
|
|
4592
4945
|
);
|
|
4593
|
-
var bash_20250124 = (
|
|
4946
|
+
var bash_20250124 = createProviderToolFactory3({
|
|
4594
4947
|
id: "anthropic.bash_20250124",
|
|
4595
4948
|
inputSchema: bash_20250124InputSchema
|
|
4596
4949
|
});
|
|
4597
4950
|
|
|
4598
4951
|
// src/tool/computer_20241022.ts
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4952
|
+
import {
|
|
4953
|
+
createProviderToolFactory as createProviderToolFactory4,
|
|
4954
|
+
lazySchema as lazySchema15,
|
|
4955
|
+
zodSchema as zodSchema15
|
|
4956
|
+
} from "@ai-sdk/provider-utils";
|
|
4957
|
+
import { z as z16 } from "zod/v4";
|
|
4958
|
+
var computer_20241022InputSchema = lazySchema15(
|
|
4959
|
+
() => zodSchema15(
|
|
4960
|
+
z16.object({
|
|
4961
|
+
action: z16.enum([
|
|
4605
4962
|
"key",
|
|
4606
4963
|
"type",
|
|
4607
4964
|
"mouse_move",
|
|
@@ -4613,23 +4970,27 @@ var computer_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
|
4613
4970
|
"screenshot",
|
|
4614
4971
|
"cursor_position"
|
|
4615
4972
|
]),
|
|
4616
|
-
coordinate:
|
|
4617
|
-
text:
|
|
4973
|
+
coordinate: z16.array(z16.number().int()).optional(),
|
|
4974
|
+
text: z16.string().optional()
|
|
4618
4975
|
})
|
|
4619
4976
|
)
|
|
4620
4977
|
);
|
|
4621
|
-
var computer_20241022 = (
|
|
4978
|
+
var computer_20241022 = createProviderToolFactory4({
|
|
4622
4979
|
id: "anthropic.computer_20241022",
|
|
4623
4980
|
inputSchema: computer_20241022InputSchema
|
|
4624
4981
|
});
|
|
4625
4982
|
|
|
4626
4983
|
// src/tool/computer_20250124.ts
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4984
|
+
import {
|
|
4985
|
+
createProviderToolFactory as createProviderToolFactory5,
|
|
4986
|
+
lazySchema as lazySchema16,
|
|
4987
|
+
zodSchema as zodSchema16
|
|
4988
|
+
} from "@ai-sdk/provider-utils";
|
|
4989
|
+
import { z as z17 } from "zod/v4";
|
|
4990
|
+
var computer_20250124InputSchema = lazySchema16(
|
|
4991
|
+
() => zodSchema16(
|
|
4992
|
+
z17.object({
|
|
4993
|
+
action: z17.enum([
|
|
4633
4994
|
"key",
|
|
4634
4995
|
"hold_key",
|
|
4635
4996
|
"type",
|
|
@@ -4647,27 +5008,31 @@ var computer_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
4647
5008
|
"wait",
|
|
4648
5009
|
"screenshot"
|
|
4649
5010
|
]),
|
|
4650
|
-
coordinate:
|
|
4651
|
-
duration:
|
|
4652
|
-
scroll_amount:
|
|
4653
|
-
scroll_direction:
|
|
4654
|
-
start_coordinate:
|
|
4655
|
-
text:
|
|
5011
|
+
coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5012
|
+
duration: z17.number().optional(),
|
|
5013
|
+
scroll_amount: z17.number().optional(),
|
|
5014
|
+
scroll_direction: z17.enum(["up", "down", "left", "right"]).optional(),
|
|
5015
|
+
start_coordinate: z17.tuple([z17.number().int(), z17.number().int()]).optional(),
|
|
5016
|
+
text: z17.string().optional()
|
|
4656
5017
|
})
|
|
4657
5018
|
)
|
|
4658
5019
|
);
|
|
4659
|
-
var computer_20250124 = (
|
|
5020
|
+
var computer_20250124 = createProviderToolFactory5({
|
|
4660
5021
|
id: "anthropic.computer_20250124",
|
|
4661
5022
|
inputSchema: computer_20250124InputSchema
|
|
4662
5023
|
});
|
|
4663
5024
|
|
|
4664
5025
|
// src/tool/computer_20251124.ts
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
5026
|
+
import {
|
|
5027
|
+
createProviderToolFactory as createProviderToolFactory6,
|
|
5028
|
+
lazySchema as lazySchema17,
|
|
5029
|
+
zodSchema as zodSchema17
|
|
5030
|
+
} from "@ai-sdk/provider-utils";
|
|
5031
|
+
import { z as z18 } from "zod/v4";
|
|
5032
|
+
var computer_20251124InputSchema = lazySchema17(
|
|
5033
|
+
() => zodSchema17(
|
|
5034
|
+
z18.object({
|
|
5035
|
+
action: z18.enum([
|
|
4671
5036
|
"key",
|
|
4672
5037
|
"hold_key",
|
|
4673
5038
|
"type",
|
|
@@ -4686,166 +5051,186 @@ var computer_20251124InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
|
4686
5051
|
"screenshot",
|
|
4687
5052
|
"zoom"
|
|
4688
5053
|
]),
|
|
4689
|
-
coordinate:
|
|
4690
|
-
duration:
|
|
4691
|
-
region:
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
5054
|
+
coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
5055
|
+
duration: z18.number().optional(),
|
|
5056
|
+
region: z18.tuple([
|
|
5057
|
+
z18.number().int(),
|
|
5058
|
+
z18.number().int(),
|
|
5059
|
+
z18.number().int(),
|
|
5060
|
+
z18.number().int()
|
|
4696
5061
|
]).optional(),
|
|
4697
|
-
scroll_amount:
|
|
4698
|
-
scroll_direction:
|
|
4699
|
-
start_coordinate:
|
|
4700
|
-
text:
|
|
5062
|
+
scroll_amount: z18.number().optional(),
|
|
5063
|
+
scroll_direction: z18.enum(["up", "down", "left", "right"]).optional(),
|
|
5064
|
+
start_coordinate: z18.tuple([z18.number().int(), z18.number().int()]).optional(),
|
|
5065
|
+
text: z18.string().optional()
|
|
4701
5066
|
})
|
|
4702
5067
|
)
|
|
4703
5068
|
);
|
|
4704
|
-
var computer_20251124 = (
|
|
5069
|
+
var computer_20251124 = createProviderToolFactory6({
|
|
4705
5070
|
id: "anthropic.computer_20251124",
|
|
4706
5071
|
inputSchema: computer_20251124InputSchema
|
|
4707
5072
|
});
|
|
4708
5073
|
|
|
4709
5074
|
// src/tool/memory_20250818.ts
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
5075
|
+
import {
|
|
5076
|
+
createProviderToolFactory as createProviderToolFactory7,
|
|
5077
|
+
lazySchema as lazySchema18,
|
|
5078
|
+
zodSchema as zodSchema18
|
|
5079
|
+
} from "@ai-sdk/provider-utils";
|
|
5080
|
+
import { z as z19 } from "zod/v4";
|
|
5081
|
+
var memory_20250818InputSchema = lazySchema18(
|
|
5082
|
+
() => zodSchema18(
|
|
5083
|
+
z19.discriminatedUnion("command", [
|
|
5084
|
+
z19.object({
|
|
5085
|
+
command: z19.literal("view"),
|
|
5086
|
+
path: z19.string(),
|
|
5087
|
+
view_range: z19.tuple([z19.number(), z19.number()]).optional()
|
|
4719
5088
|
}),
|
|
4720
|
-
|
|
4721
|
-
command:
|
|
4722
|
-
path:
|
|
4723
|
-
file_text:
|
|
5089
|
+
z19.object({
|
|
5090
|
+
command: z19.literal("create"),
|
|
5091
|
+
path: z19.string(),
|
|
5092
|
+
file_text: z19.string()
|
|
4724
5093
|
}),
|
|
4725
|
-
|
|
4726
|
-
command:
|
|
4727
|
-
path:
|
|
4728
|
-
old_str:
|
|
4729
|
-
new_str:
|
|
5094
|
+
z19.object({
|
|
5095
|
+
command: z19.literal("str_replace"),
|
|
5096
|
+
path: z19.string(),
|
|
5097
|
+
old_str: z19.string(),
|
|
5098
|
+
new_str: z19.string()
|
|
4730
5099
|
}),
|
|
4731
|
-
|
|
4732
|
-
command:
|
|
4733
|
-
path:
|
|
4734
|
-
insert_line:
|
|
4735
|
-
insert_text:
|
|
5100
|
+
z19.object({
|
|
5101
|
+
command: z19.literal("insert"),
|
|
5102
|
+
path: z19.string(),
|
|
5103
|
+
insert_line: z19.number(),
|
|
5104
|
+
insert_text: z19.string()
|
|
4736
5105
|
}),
|
|
4737
|
-
|
|
4738
|
-
command:
|
|
4739
|
-
path:
|
|
5106
|
+
z19.object({
|
|
5107
|
+
command: z19.literal("delete"),
|
|
5108
|
+
path: z19.string()
|
|
4740
5109
|
}),
|
|
4741
|
-
|
|
4742
|
-
command:
|
|
4743
|
-
old_path:
|
|
4744
|
-
new_path:
|
|
5110
|
+
z19.object({
|
|
5111
|
+
command: z19.literal("rename"),
|
|
5112
|
+
old_path: z19.string(),
|
|
5113
|
+
new_path: z19.string()
|
|
4745
5114
|
})
|
|
4746
5115
|
])
|
|
4747
5116
|
)
|
|
4748
5117
|
);
|
|
4749
|
-
var memory_20250818 = (
|
|
5118
|
+
var memory_20250818 = createProviderToolFactory7({
|
|
4750
5119
|
id: "anthropic.memory_20250818",
|
|
4751
5120
|
inputSchema: memory_20250818InputSchema
|
|
4752
5121
|
});
|
|
4753
5122
|
|
|
4754
5123
|
// src/tool/text-editor_20241022.ts
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
5124
|
+
import {
|
|
5125
|
+
createProviderToolFactory as createProviderToolFactory8,
|
|
5126
|
+
lazySchema as lazySchema19,
|
|
5127
|
+
zodSchema as zodSchema19
|
|
5128
|
+
} from "@ai-sdk/provider-utils";
|
|
5129
|
+
import { z as z20 } from "zod/v4";
|
|
5130
|
+
var textEditor_20241022InputSchema = lazySchema19(
|
|
5131
|
+
() => zodSchema19(
|
|
5132
|
+
z20.object({
|
|
5133
|
+
command: z20.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5134
|
+
path: z20.string(),
|
|
5135
|
+
file_text: z20.string().optional(),
|
|
5136
|
+
insert_line: z20.number().int().optional(),
|
|
5137
|
+
new_str: z20.string().optional(),
|
|
5138
|
+
insert_text: z20.string().optional(),
|
|
5139
|
+
old_str: z20.string().optional(),
|
|
5140
|
+
view_range: z20.array(z20.number().int()).optional()
|
|
4768
5141
|
})
|
|
4769
5142
|
)
|
|
4770
5143
|
);
|
|
4771
|
-
var textEditor_20241022 = (
|
|
5144
|
+
var textEditor_20241022 = createProviderToolFactory8({
|
|
4772
5145
|
id: "anthropic.text_editor_20241022",
|
|
4773
5146
|
inputSchema: textEditor_20241022InputSchema
|
|
4774
5147
|
});
|
|
4775
5148
|
|
|
4776
5149
|
// src/tool/text-editor_20250124.ts
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
5150
|
+
import {
|
|
5151
|
+
createProviderToolFactory as createProviderToolFactory9,
|
|
5152
|
+
lazySchema as lazySchema20,
|
|
5153
|
+
zodSchema as zodSchema20
|
|
5154
|
+
} from "@ai-sdk/provider-utils";
|
|
5155
|
+
import { z as z21 } from "zod/v4";
|
|
5156
|
+
var textEditor_20250124InputSchema = lazySchema20(
|
|
5157
|
+
() => zodSchema20(
|
|
5158
|
+
z21.object({
|
|
5159
|
+
command: z21.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5160
|
+
path: z21.string(),
|
|
5161
|
+
file_text: z21.string().optional(),
|
|
5162
|
+
insert_line: z21.number().int().optional(),
|
|
5163
|
+
new_str: z21.string().optional(),
|
|
5164
|
+
insert_text: z21.string().optional(),
|
|
5165
|
+
old_str: z21.string().optional(),
|
|
5166
|
+
view_range: z21.array(z21.number().int()).optional()
|
|
4790
5167
|
})
|
|
4791
5168
|
)
|
|
4792
5169
|
);
|
|
4793
|
-
var textEditor_20250124 = (
|
|
5170
|
+
var textEditor_20250124 = createProviderToolFactory9({
|
|
4794
5171
|
id: "anthropic.text_editor_20250124",
|
|
4795
5172
|
inputSchema: textEditor_20250124InputSchema
|
|
4796
5173
|
});
|
|
4797
5174
|
|
|
4798
5175
|
// src/tool/text-editor_20250429.ts
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
5176
|
+
import {
|
|
5177
|
+
createProviderToolFactory as createProviderToolFactory10,
|
|
5178
|
+
lazySchema as lazySchema21,
|
|
5179
|
+
zodSchema as zodSchema21
|
|
5180
|
+
} from "@ai-sdk/provider-utils";
|
|
5181
|
+
import { z as z22 } from "zod/v4";
|
|
5182
|
+
var textEditor_20250429InputSchema = lazySchema21(
|
|
5183
|
+
() => zodSchema21(
|
|
5184
|
+
z22.object({
|
|
5185
|
+
command: z22.enum(["view", "create", "str_replace", "insert"]),
|
|
5186
|
+
path: z22.string(),
|
|
5187
|
+
file_text: z22.string().optional(),
|
|
5188
|
+
insert_line: z22.number().int().optional(),
|
|
5189
|
+
new_str: z22.string().optional(),
|
|
5190
|
+
insert_text: z22.string().optional(),
|
|
5191
|
+
old_str: z22.string().optional(),
|
|
5192
|
+
view_range: z22.array(z22.number().int()).optional()
|
|
4812
5193
|
})
|
|
4813
5194
|
)
|
|
4814
5195
|
);
|
|
4815
|
-
var textEditor_20250429 = (
|
|
5196
|
+
var textEditor_20250429 = createProviderToolFactory10({
|
|
4816
5197
|
id: "anthropic.text_editor_20250429",
|
|
4817
5198
|
inputSchema: textEditor_20250429InputSchema
|
|
4818
5199
|
});
|
|
4819
5200
|
|
|
4820
5201
|
// src/tool/tool-search-bm25_20251119.ts
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
5202
|
+
import {
|
|
5203
|
+
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
|
|
5204
|
+
lazySchema as lazySchema22,
|
|
5205
|
+
zodSchema as zodSchema22
|
|
5206
|
+
} from "@ai-sdk/provider-utils";
|
|
5207
|
+
import { z as z23 } from "zod/v4";
|
|
5208
|
+
var toolSearchBm25_20251119OutputSchema = lazySchema22(
|
|
5209
|
+
() => zodSchema22(
|
|
5210
|
+
z23.array(
|
|
5211
|
+
z23.object({
|
|
5212
|
+
type: z23.literal("tool_reference"),
|
|
5213
|
+
toolName: z23.string()
|
|
4829
5214
|
})
|
|
4830
5215
|
)
|
|
4831
5216
|
)
|
|
4832
5217
|
);
|
|
4833
|
-
var toolSearchBm25_20251119InputSchema = (
|
|
4834
|
-
() => (
|
|
4835
|
-
|
|
5218
|
+
var toolSearchBm25_20251119InputSchema = lazySchema22(
|
|
5219
|
+
() => zodSchema22(
|
|
5220
|
+
z23.object({
|
|
4836
5221
|
/**
|
|
4837
5222
|
* A natural language query to search for tools.
|
|
4838
5223
|
* Claude will use BM25 text search to find relevant tools.
|
|
4839
5224
|
*/
|
|
4840
|
-
query:
|
|
5225
|
+
query: z23.string(),
|
|
4841
5226
|
/**
|
|
4842
5227
|
* Maximum number of tools to return. Optional.
|
|
4843
5228
|
*/
|
|
4844
|
-
limit:
|
|
5229
|
+
limit: z23.number().optional()
|
|
4845
5230
|
})
|
|
4846
5231
|
)
|
|
4847
5232
|
);
|
|
4848
|
-
var factory10 = (
|
|
5233
|
+
var factory10 = createProviderToolFactoryWithOutputSchema9({
|
|
4849
5234
|
id: "anthropic.tool_search_bm25_20251119",
|
|
4850
5235
|
inputSchema: toolSearchBm25_20251119InputSchema,
|
|
4851
5236
|
outputSchema: toolSearchBm25_20251119OutputSchema,
|
|
@@ -5057,31 +5442,163 @@ var anthropicTools = {
|
|
|
5057
5442
|
toolSearchBm25_20251119
|
|
5058
5443
|
};
|
|
5059
5444
|
|
|
5445
|
+
// src/skills/anthropic-skills.ts
|
|
5446
|
+
import {
|
|
5447
|
+
combineHeaders as combineHeaders3,
|
|
5448
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array3,
|
|
5449
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
5450
|
+
getFromApi,
|
|
5451
|
+
postFormDataToApi as postFormDataToApi2,
|
|
5452
|
+
resolve as resolve2
|
|
5453
|
+
} from "@ai-sdk/provider-utils";
|
|
5454
|
+
|
|
5455
|
+
// src/skills/anthropic-skills-api.ts
|
|
5456
|
+
import { lazySchema as lazySchema23, zodSchema as zodSchema23 } from "@ai-sdk/provider-utils";
|
|
5457
|
+
import { z as z24 } from "zod/v4";
|
|
5458
|
+
var anthropicSkillResponseSchema = lazySchema23(
|
|
5459
|
+
() => zodSchema23(
|
|
5460
|
+
z24.object({
|
|
5461
|
+
id: z24.string(),
|
|
5462
|
+
display_title: z24.string().nullish(),
|
|
5463
|
+
name: z24.string().nullish(),
|
|
5464
|
+
description: z24.string().nullish(),
|
|
5465
|
+
latest_version: z24.string().nullish(),
|
|
5466
|
+
source: z24.string(),
|
|
5467
|
+
created_at: z24.string(),
|
|
5468
|
+
updated_at: z24.string()
|
|
5469
|
+
})
|
|
5470
|
+
)
|
|
5471
|
+
);
|
|
5472
|
+
var anthropicSkillVersionListResponseSchema = lazySchema23(
|
|
5473
|
+
() => zodSchema23(
|
|
5474
|
+
z24.object({
|
|
5475
|
+
data: z24.array(
|
|
5476
|
+
z24.object({
|
|
5477
|
+
version: z24.string()
|
|
5478
|
+
})
|
|
5479
|
+
)
|
|
5480
|
+
})
|
|
5481
|
+
)
|
|
5482
|
+
);
|
|
5483
|
+
var anthropicSkillVersionResponseSchema = lazySchema23(
|
|
5484
|
+
() => zodSchema23(
|
|
5485
|
+
z24.object({
|
|
5486
|
+
type: z24.string(),
|
|
5487
|
+
skill_id: z24.string(),
|
|
5488
|
+
name: z24.string().nullish(),
|
|
5489
|
+
description: z24.string().nullish()
|
|
5490
|
+
})
|
|
5491
|
+
)
|
|
5492
|
+
);
|
|
5493
|
+
|
|
5494
|
+
// src/skills/anthropic-skills.ts
|
|
5495
|
+
var AnthropicSkills = class {
|
|
5496
|
+
constructor(config) {
|
|
5497
|
+
this.config = config;
|
|
5498
|
+
this.specificationVersion = "v4";
|
|
5499
|
+
}
|
|
5500
|
+
get provider() {
|
|
5501
|
+
return this.config.provider;
|
|
5502
|
+
}
|
|
5503
|
+
async getHeaders() {
|
|
5504
|
+
return combineHeaders3(await resolve2(this.config.headers), {
|
|
5505
|
+
"anthropic-beta": "skills-2025-10-02"
|
|
5506
|
+
});
|
|
5507
|
+
}
|
|
5508
|
+
async fetchVersionMetadata({
|
|
5509
|
+
skillId,
|
|
5510
|
+
version,
|
|
5511
|
+
headers
|
|
5512
|
+
}) {
|
|
5513
|
+
const { value: versionResponse } = await getFromApi({
|
|
5514
|
+
url: `${this.config.baseURL}/skills/${skillId}/versions/${version}`,
|
|
5515
|
+
headers,
|
|
5516
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
5517
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
5518
|
+
anthropicSkillVersionResponseSchema
|
|
5519
|
+
),
|
|
5520
|
+
fetch: this.config.fetch
|
|
5521
|
+
});
|
|
5522
|
+
return {
|
|
5523
|
+
...versionResponse.name != null ? { name: versionResponse.name } : {},
|
|
5524
|
+
...versionResponse.description != null ? { description: versionResponse.description } : {}
|
|
5525
|
+
};
|
|
5526
|
+
}
|
|
5527
|
+
async uploadSkill(params) {
|
|
5528
|
+
var _a, _b;
|
|
5529
|
+
const warnings = [];
|
|
5530
|
+
const formData = new FormData();
|
|
5531
|
+
if (params.displayTitle != null) {
|
|
5532
|
+
formData.append("display_title", params.displayTitle);
|
|
5533
|
+
}
|
|
5534
|
+
for (const file of params.files) {
|
|
5535
|
+
const content = typeof file.content === "string" ? convertBase64ToUint8Array3(file.content) : file.content;
|
|
5536
|
+
formData.append("files[]", new Blob([content]), file.path);
|
|
5537
|
+
}
|
|
5538
|
+
const headers = await this.getHeaders();
|
|
5539
|
+
const { value: response } = await postFormDataToApi2({
|
|
5540
|
+
url: `${this.config.baseURL}/skills`,
|
|
5541
|
+
headers,
|
|
5542
|
+
formData,
|
|
5543
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
5544
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
5545
|
+
anthropicSkillResponseSchema
|
|
5546
|
+
),
|
|
5547
|
+
fetch: this.config.fetch
|
|
5548
|
+
});
|
|
5549
|
+
const versionMetadata = response.latest_version != null ? await this.fetchVersionMetadata({
|
|
5550
|
+
skillId: response.id,
|
|
5551
|
+
version: response.latest_version,
|
|
5552
|
+
headers
|
|
5553
|
+
}) : {};
|
|
5554
|
+
const name = (_a = versionMetadata.name) != null ? _a : response.name;
|
|
5555
|
+
const description = (_b = versionMetadata.description) != null ? _b : response.description;
|
|
5556
|
+
return {
|
|
5557
|
+
providerReference: { anthropic: response.id },
|
|
5558
|
+
...response.display_title != null ? { displayTitle: response.display_title } : {},
|
|
5559
|
+
...name != null ? { name } : {},
|
|
5560
|
+
...description != null ? { description } : {},
|
|
5561
|
+
...response.latest_version != null ? { latestVersion: response.latest_version } : {},
|
|
5562
|
+
providerMetadata: {
|
|
5563
|
+
anthropic: {
|
|
5564
|
+
...response.source != null ? { source: response.source } : {},
|
|
5565
|
+
...response.created_at != null ? { createdAt: response.created_at } : {},
|
|
5566
|
+
...response.updated_at != null ? { updatedAt: response.updated_at } : {}
|
|
5567
|
+
}
|
|
5568
|
+
},
|
|
5569
|
+
warnings
|
|
5570
|
+
};
|
|
5571
|
+
}
|
|
5572
|
+
};
|
|
5573
|
+
|
|
5574
|
+
// src/version.ts
|
|
5575
|
+
var VERSION = true ? "4.0.0-beta.31" : "0.0.0-test";
|
|
5576
|
+
|
|
5060
5577
|
// src/anthropic-provider.ts
|
|
5061
5578
|
function createAnthropic(options = {}) {
|
|
5062
5579
|
var _a, _b;
|
|
5063
|
-
const baseURL = (_a =
|
|
5064
|
-
|
|
5580
|
+
const baseURL = (_a = withoutTrailingSlash(
|
|
5581
|
+
loadOptionalSetting({
|
|
5065
5582
|
settingValue: options.baseURL,
|
|
5066
5583
|
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
5067
5584
|
})
|
|
5068
5585
|
)) != null ? _a : "https://api.anthropic.com/v1";
|
|
5069
5586
|
const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
|
|
5070
5587
|
if (options.apiKey && options.authToken) {
|
|
5071
|
-
throw new
|
|
5588
|
+
throw new InvalidArgumentError({
|
|
5072
5589
|
argument: "apiKey/authToken",
|
|
5073
5590
|
message: "Both apiKey and authToken were provided. Please use only one authentication method."
|
|
5074
5591
|
});
|
|
5075
5592
|
}
|
|
5076
5593
|
const getHeaders = () => {
|
|
5077
5594
|
const authHeaders = options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {
|
|
5078
|
-
"x-api-key":
|
|
5595
|
+
"x-api-key": loadApiKey({
|
|
5079
5596
|
apiKey: options.apiKey,
|
|
5080
5597
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
5081
5598
|
description: "Anthropic"
|
|
5082
5599
|
})
|
|
5083
5600
|
};
|
|
5084
|
-
return
|
|
5601
|
+
return withUserAgentSuffix(
|
|
5085
5602
|
{
|
|
5086
5603
|
"anthropic-version": "2023-06-01",
|
|
5087
5604
|
...authHeaders,
|
|
@@ -5097,13 +5614,19 @@ function createAnthropic(options = {}) {
|
|
|
5097
5614
|
baseURL,
|
|
5098
5615
|
headers: getHeaders,
|
|
5099
5616
|
fetch: options.fetch,
|
|
5100
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
5617
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : generateId2,
|
|
5101
5618
|
supportedUrls: () => ({
|
|
5102
5619
|
"image/*": [/^https?:\/\/.*$/],
|
|
5103
5620
|
"application/pdf": [/^https?:\/\/.*$/]
|
|
5104
5621
|
})
|
|
5105
5622
|
});
|
|
5106
5623
|
};
|
|
5624
|
+
const createSkills = () => new AnthropicSkills({
|
|
5625
|
+
provider: `${providerName.replace(".messages", "")}.skills`,
|
|
5626
|
+
baseURL,
|
|
5627
|
+
headers: getHeaders,
|
|
5628
|
+
fetch: options.fetch
|
|
5629
|
+
});
|
|
5107
5630
|
const provider = function(modelId) {
|
|
5108
5631
|
if (new.target) {
|
|
5109
5632
|
throw new Error(
|
|
@@ -5117,12 +5640,19 @@ function createAnthropic(options = {}) {
|
|
|
5117
5640
|
provider.chat = createChatModel;
|
|
5118
5641
|
provider.messages = createChatModel;
|
|
5119
5642
|
provider.embeddingModel = (modelId) => {
|
|
5120
|
-
throw new
|
|
5643
|
+
throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
5121
5644
|
};
|
|
5122
5645
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
5123
5646
|
provider.imageModel = (modelId) => {
|
|
5124
|
-
throw new
|
|
5647
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
5125
5648
|
};
|
|
5649
|
+
provider.files = () => new AnthropicFiles({
|
|
5650
|
+
provider: providerName,
|
|
5651
|
+
baseURL,
|
|
5652
|
+
headers: getHeaders,
|
|
5653
|
+
fetch: options.fetch
|
|
5654
|
+
});
|
|
5655
|
+
provider.skills = createSkills;
|
|
5126
5656
|
provider.tools = anthropicTools;
|
|
5127
5657
|
return provider;
|
|
5128
5658
|
}
|
|
@@ -5147,11 +5677,10 @@ function forwardAnthropicContainerIdFromLastStep({
|
|
|
5147
5677
|
}
|
|
5148
5678
|
return void 0;
|
|
5149
5679
|
}
|
|
5150
|
-
|
|
5151
|
-
0 && (module.exports = {
|
|
5680
|
+
export {
|
|
5152
5681
|
VERSION,
|
|
5153
5682
|
anthropic,
|
|
5154
5683
|
createAnthropic,
|
|
5155
5684
|
forwardAnthropicContainerIdFromLastStep
|
|
5156
|
-
}
|
|
5685
|
+
};
|
|
5157
5686
|
//# sourceMappingURL=index.js.map
|