@ai-sdk/anthropic 1.1.8 → 1.1.10
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 +17 -0
- package/dist/index.d.mts +51 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +272 -109
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +275 -111
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +51 -1
- package/internal/dist/index.d.ts +51 -1
- package/internal/dist/index.js +272 -109
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +275 -111
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -49,8 +49,114 @@ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorRe
|
|
|
49
49
|
errorToMessage: (data) => data.error.message
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
// src/
|
|
52
|
+
// src/anthropic-prepare-tools.ts
|
|
53
53
|
var import_provider = require("@ai-sdk/provider");
|
|
54
|
+
function prepareTools(mode) {
|
|
55
|
+
var _a;
|
|
56
|
+
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
|
|
57
|
+
const toolWarnings = [];
|
|
58
|
+
const betas = /* @__PURE__ */ new Set();
|
|
59
|
+
if (tools == null) {
|
|
60
|
+
return { tools: void 0, tool_choice: void 0, toolWarnings, betas };
|
|
61
|
+
}
|
|
62
|
+
const anthropicTools2 = [];
|
|
63
|
+
for (const tool of tools) {
|
|
64
|
+
switch (tool.type) {
|
|
65
|
+
case "function":
|
|
66
|
+
anthropicTools2.push({
|
|
67
|
+
name: tool.name,
|
|
68
|
+
description: tool.description,
|
|
69
|
+
input_schema: tool.parameters
|
|
70
|
+
});
|
|
71
|
+
break;
|
|
72
|
+
case "provider-defined":
|
|
73
|
+
betas.add("computer-use-2024-10-22");
|
|
74
|
+
switch (tool.id) {
|
|
75
|
+
case "anthropic.computer_20250124":
|
|
76
|
+
anthropicTools2.push({
|
|
77
|
+
name: tool.name,
|
|
78
|
+
type: "computer_20250124",
|
|
79
|
+
display_width_px: tool.args.displayWidthPx,
|
|
80
|
+
display_height_px: tool.args.displayHeightPx,
|
|
81
|
+
display_number: tool.args.displayNumber
|
|
82
|
+
});
|
|
83
|
+
break;
|
|
84
|
+
case "anthropic.computer_20241022":
|
|
85
|
+
anthropicTools2.push({
|
|
86
|
+
name: tool.name,
|
|
87
|
+
type: "computer_20241022",
|
|
88
|
+
display_width_px: tool.args.displayWidthPx,
|
|
89
|
+
display_height_px: tool.args.displayHeightPx,
|
|
90
|
+
display_number: tool.args.displayNumber
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
case "anthropic.text_editor_20241022":
|
|
94
|
+
anthropicTools2.push({
|
|
95
|
+
name: tool.name,
|
|
96
|
+
type: "text_editor_20241022"
|
|
97
|
+
});
|
|
98
|
+
break;
|
|
99
|
+
case "anthropic.bash_20241022":
|
|
100
|
+
anthropicTools2.push({
|
|
101
|
+
name: tool.name,
|
|
102
|
+
type: "bash_20241022"
|
|
103
|
+
});
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const toolChoice = mode.toolChoice;
|
|
116
|
+
if (toolChoice == null) {
|
|
117
|
+
return {
|
|
118
|
+
tools: anthropicTools2,
|
|
119
|
+
tool_choice: void 0,
|
|
120
|
+
toolWarnings,
|
|
121
|
+
betas
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const type = toolChoice.type;
|
|
125
|
+
switch (type) {
|
|
126
|
+
case "auto":
|
|
127
|
+
return {
|
|
128
|
+
tools: anthropicTools2,
|
|
129
|
+
tool_choice: { type: "auto" },
|
|
130
|
+
toolWarnings,
|
|
131
|
+
betas
|
|
132
|
+
};
|
|
133
|
+
case "required":
|
|
134
|
+
return {
|
|
135
|
+
tools: anthropicTools2,
|
|
136
|
+
tool_choice: { type: "any" },
|
|
137
|
+
toolWarnings,
|
|
138
|
+
betas
|
|
139
|
+
};
|
|
140
|
+
case "none":
|
|
141
|
+
return { tools: void 0, tool_choice: void 0, toolWarnings, betas };
|
|
142
|
+
case "tool":
|
|
143
|
+
return {
|
|
144
|
+
tools: anthropicTools2,
|
|
145
|
+
tool_choice: { type: "tool", name: toolChoice.toolName },
|
|
146
|
+
toolWarnings,
|
|
147
|
+
betas
|
|
148
|
+
};
|
|
149
|
+
default: {
|
|
150
|
+
const _exhaustiveCheck = type;
|
|
151
|
+
throw new import_provider.UnsupportedFunctionalityError({
|
|
152
|
+
functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/convert-to-anthropic-messages-prompt.ts
|
|
159
|
+
var import_provider2 = require("@ai-sdk/provider");
|
|
54
160
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
55
161
|
function convertToAnthropicMessagesPrompt({
|
|
56
162
|
prompt
|
|
@@ -73,7 +179,7 @@ function convertToAnthropicMessagesPrompt({
|
|
|
73
179
|
switch (type) {
|
|
74
180
|
case "system": {
|
|
75
181
|
if (system != null) {
|
|
76
|
-
throw new
|
|
182
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
77
183
|
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
78
184
|
});
|
|
79
185
|
}
|
|
@@ -105,7 +211,7 @@ function convertToAnthropicMessagesPrompt({
|
|
|
105
211
|
}
|
|
106
212
|
case "image": {
|
|
107
213
|
if (part.image instanceof URL) {
|
|
108
|
-
throw new
|
|
214
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
109
215
|
functionality: "Image URLs in user messages"
|
|
110
216
|
});
|
|
111
217
|
}
|
|
@@ -122,12 +228,12 @@ function convertToAnthropicMessagesPrompt({
|
|
|
122
228
|
}
|
|
123
229
|
case "file": {
|
|
124
230
|
if (part.data instanceof URL) {
|
|
125
|
-
throw new
|
|
231
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
126
232
|
functionality: "Image URLs in user messages"
|
|
127
233
|
});
|
|
128
234
|
}
|
|
129
235
|
if (part.mimeType !== "application/pdf") {
|
|
130
|
-
throw new
|
|
236
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
131
237
|
functionality: "Non-PDF files in user messages"
|
|
132
238
|
});
|
|
133
239
|
}
|
|
@@ -216,6 +322,23 @@ function convertToAnthropicMessagesPrompt({
|
|
|
216
322
|
});
|
|
217
323
|
break;
|
|
218
324
|
}
|
|
325
|
+
case "reasoning": {
|
|
326
|
+
anthropicContent.push({
|
|
327
|
+
type: "thinking",
|
|
328
|
+
thinking: part.text,
|
|
329
|
+
signature: part.signature,
|
|
330
|
+
cache_control: cacheControl
|
|
331
|
+
});
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case "redacted-reasoning": {
|
|
335
|
+
anthropicContent.push({
|
|
336
|
+
type: "redacted_thinking",
|
|
337
|
+
data: part.data,
|
|
338
|
+
cache_control: cacheControl
|
|
339
|
+
});
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
219
342
|
case "tool-call": {
|
|
220
343
|
anthropicContent.push({
|
|
221
344
|
type: "tool_use",
|
|
@@ -226,6 +349,10 @@ function convertToAnthropicMessagesPrompt({
|
|
|
226
349
|
});
|
|
227
350
|
break;
|
|
228
351
|
}
|
|
352
|
+
default: {
|
|
353
|
+
const _exhaustiveCheck = part;
|
|
354
|
+
throw new Error(`Unsupported part: ${_exhaustiveCheck}`);
|
|
355
|
+
}
|
|
229
356
|
}
|
|
230
357
|
}
|
|
231
358
|
}
|
|
@@ -305,103 +432,6 @@ function mapAnthropicStopReason(finishReason) {
|
|
|
305
432
|
}
|
|
306
433
|
}
|
|
307
434
|
|
|
308
|
-
// src/anthropic-prepare-tools.ts
|
|
309
|
-
var import_provider2 = require("@ai-sdk/provider");
|
|
310
|
-
function prepareTools(mode) {
|
|
311
|
-
var _a;
|
|
312
|
-
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
|
|
313
|
-
const toolWarnings = [];
|
|
314
|
-
const betas = /* @__PURE__ */ new Set();
|
|
315
|
-
if (tools == null) {
|
|
316
|
-
return { tools: void 0, tool_choice: void 0, toolWarnings, betas };
|
|
317
|
-
}
|
|
318
|
-
const anthropicTools2 = [];
|
|
319
|
-
for (const tool of tools) {
|
|
320
|
-
switch (tool.type) {
|
|
321
|
-
case "function":
|
|
322
|
-
anthropicTools2.push({
|
|
323
|
-
name: tool.name,
|
|
324
|
-
description: tool.description,
|
|
325
|
-
input_schema: tool.parameters
|
|
326
|
-
});
|
|
327
|
-
break;
|
|
328
|
-
case "provider-defined":
|
|
329
|
-
betas.add("computer-use-2024-10-22");
|
|
330
|
-
switch (tool.id) {
|
|
331
|
-
case "anthropic.computer_20241022":
|
|
332
|
-
anthropicTools2.push({
|
|
333
|
-
name: tool.name,
|
|
334
|
-
type: "computer_20241022",
|
|
335
|
-
display_width_px: tool.args.displayWidthPx,
|
|
336
|
-
display_height_px: tool.args.displayHeightPx,
|
|
337
|
-
display_number: tool.args.displayNumber
|
|
338
|
-
});
|
|
339
|
-
break;
|
|
340
|
-
case "anthropic.text_editor_20241022":
|
|
341
|
-
anthropicTools2.push({
|
|
342
|
-
name: tool.name,
|
|
343
|
-
type: "text_editor_20241022"
|
|
344
|
-
});
|
|
345
|
-
break;
|
|
346
|
-
case "anthropic.bash_20241022":
|
|
347
|
-
anthropicTools2.push({
|
|
348
|
-
name: tool.name,
|
|
349
|
-
type: "bash_20241022"
|
|
350
|
-
});
|
|
351
|
-
break;
|
|
352
|
-
default:
|
|
353
|
-
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
break;
|
|
357
|
-
default:
|
|
358
|
-
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
359
|
-
break;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
const toolChoice = mode.toolChoice;
|
|
363
|
-
if (toolChoice == null) {
|
|
364
|
-
return {
|
|
365
|
-
tools: anthropicTools2,
|
|
366
|
-
tool_choice: void 0,
|
|
367
|
-
toolWarnings,
|
|
368
|
-
betas
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
const type = toolChoice.type;
|
|
372
|
-
switch (type) {
|
|
373
|
-
case "auto":
|
|
374
|
-
return {
|
|
375
|
-
tools: anthropicTools2,
|
|
376
|
-
tool_choice: { type: "auto" },
|
|
377
|
-
toolWarnings,
|
|
378
|
-
betas
|
|
379
|
-
};
|
|
380
|
-
case "required":
|
|
381
|
-
return {
|
|
382
|
-
tools: anthropicTools2,
|
|
383
|
-
tool_choice: { type: "any" },
|
|
384
|
-
toolWarnings,
|
|
385
|
-
betas
|
|
386
|
-
};
|
|
387
|
-
case "none":
|
|
388
|
-
return { tools: void 0, tool_choice: void 0, toolWarnings, betas };
|
|
389
|
-
case "tool":
|
|
390
|
-
return {
|
|
391
|
-
tools: anthropicTools2,
|
|
392
|
-
tool_choice: { type: "tool", name: toolChoice.toolName },
|
|
393
|
-
toolWarnings,
|
|
394
|
-
betas
|
|
395
|
-
};
|
|
396
|
-
default: {
|
|
397
|
-
const _exhaustiveCheck = type;
|
|
398
|
-
throw new import_provider2.UnsupportedFunctionalityError({
|
|
399
|
-
functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
435
|
// src/anthropic-messages-language-model.ts
|
|
406
436
|
var AnthropicMessagesLanguageModel = class {
|
|
407
437
|
constructor(modelId, settings, config) {
|
|
@@ -418,7 +448,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
418
448
|
async getArgs({
|
|
419
449
|
mode,
|
|
420
450
|
prompt,
|
|
421
|
-
maxTokens,
|
|
451
|
+
maxTokens = 4096,
|
|
452
|
+
// 4096: max model output tokens TODO update default in v5
|
|
422
453
|
temperature,
|
|
423
454
|
topP,
|
|
424
455
|
topK,
|
|
@@ -426,8 +457,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
426
457
|
presencePenalty,
|
|
427
458
|
stopSequences,
|
|
428
459
|
responseFormat,
|
|
429
|
-
seed
|
|
460
|
+
seed,
|
|
461
|
+
providerMetadata: providerOptions
|
|
430
462
|
}) {
|
|
463
|
+
var _a, _b, _c;
|
|
431
464
|
const type = mode.type;
|
|
432
465
|
const warnings = [];
|
|
433
466
|
if (frequencyPenalty != null) {
|
|
@@ -458,20 +491,67 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
458
491
|
const { prompt: messagesPrompt, betas: messagesBetas } = convertToAnthropicMessagesPrompt({
|
|
459
492
|
prompt
|
|
460
493
|
});
|
|
494
|
+
const thinkingOptions = thinkingOptionsSchema.safeParse(
|
|
495
|
+
(_a = providerOptions == null ? void 0 : providerOptions.anthropic) == null ? void 0 : _a.thinking
|
|
496
|
+
);
|
|
497
|
+
if (!thinkingOptions.success) {
|
|
498
|
+
throw new import_provider3.InvalidArgumentError({
|
|
499
|
+
argument: "providerOptions.anthropic.thinking",
|
|
500
|
+
message: "invalid thinking options",
|
|
501
|
+
cause: thinkingOptions.error
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
const isThinking = ((_b = thinkingOptions.data) == null ? void 0 : _b.type) === "enabled";
|
|
505
|
+
const thinkingBudget = (_c = thinkingOptions.data) == null ? void 0 : _c.budgetTokens;
|
|
461
506
|
const baseArgs = {
|
|
462
507
|
// model id:
|
|
463
508
|
model: this.modelId,
|
|
464
509
|
// standardized settings:
|
|
465
|
-
max_tokens: maxTokens
|
|
466
|
-
// 4096: max model output tokens TODO remove
|
|
510
|
+
max_tokens: maxTokens,
|
|
467
511
|
temperature,
|
|
468
512
|
top_k: topK,
|
|
469
513
|
top_p: topP,
|
|
470
514
|
stop_sequences: stopSequences,
|
|
515
|
+
// provider specific settings:
|
|
516
|
+
...isThinking && {
|
|
517
|
+
thinking: { type: "enabled", budget_tokens: thinkingBudget }
|
|
518
|
+
},
|
|
471
519
|
// prompt:
|
|
472
520
|
system: messagesPrompt.system,
|
|
473
521
|
messages: messagesPrompt.messages
|
|
474
522
|
};
|
|
523
|
+
if (isThinking) {
|
|
524
|
+
if (thinkingBudget == null) {
|
|
525
|
+
throw new import_provider3.UnsupportedFunctionalityError({
|
|
526
|
+
functionality: "thinking requires a budget"
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
if (baseArgs.temperature != null) {
|
|
530
|
+
baseArgs.temperature = void 0;
|
|
531
|
+
warnings.push({
|
|
532
|
+
type: "unsupported-setting",
|
|
533
|
+
setting: "temperature",
|
|
534
|
+
details: "temperature is not supported when thinking is enabled"
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
if (topK != null) {
|
|
538
|
+
baseArgs.top_k = void 0;
|
|
539
|
+
warnings.push({
|
|
540
|
+
type: "unsupported-setting",
|
|
541
|
+
setting: "topK",
|
|
542
|
+
details: "topK is not supported when thinking is enabled"
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
if (topP != null) {
|
|
546
|
+
baseArgs.top_p = void 0;
|
|
547
|
+
warnings.push({
|
|
548
|
+
type: "unsupported-setting",
|
|
549
|
+
setting: "topP",
|
|
550
|
+
details: "topP is not supported when thinking is enabled"
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
baseArgs.max_tokens = maxTokens + thinkingBudget;
|
|
554
|
+
}
|
|
475
555
|
switch (type) {
|
|
476
556
|
case "regular": {
|
|
477
557
|
const {
|
|
@@ -562,8 +642,21 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
562
642
|
}
|
|
563
643
|
}
|
|
564
644
|
}
|
|
645
|
+
const reasoning = response.content.filter(
|
|
646
|
+
(content) => content.type === "redacted_thinking" || content.type === "thinking"
|
|
647
|
+
).map(
|
|
648
|
+
(content) => content.type === "thinking" ? {
|
|
649
|
+
type: "text",
|
|
650
|
+
text: content.thinking,
|
|
651
|
+
signature: content.signature
|
|
652
|
+
} : {
|
|
653
|
+
type: "redacted",
|
|
654
|
+
data: content.data
|
|
655
|
+
}
|
|
656
|
+
);
|
|
565
657
|
return {
|
|
566
658
|
text,
|
|
659
|
+
reasoning: reasoning.length > 0 ? reasoning : void 0,
|
|
567
660
|
toolCalls,
|
|
568
661
|
finishReason: mapAnthropicStopReason(response.stop_reason),
|
|
569
662
|
usage: {
|
|
@@ -608,7 +701,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
608
701
|
};
|
|
609
702
|
const toolCallContentBlocks = {};
|
|
610
703
|
let providerMetadata = void 0;
|
|
611
|
-
|
|
704
|
+
let blockType = void 0;
|
|
612
705
|
return {
|
|
613
706
|
stream: response.pipeThrough(
|
|
614
707
|
new TransformStream({
|
|
@@ -625,8 +718,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
625
718
|
}
|
|
626
719
|
case "content_block_start": {
|
|
627
720
|
const contentBlockType = value.content_block.type;
|
|
721
|
+
blockType = contentBlockType;
|
|
628
722
|
switch (contentBlockType) {
|
|
629
|
-
case "text":
|
|
723
|
+
case "text":
|
|
724
|
+
case "thinking": {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
case "redacted_thinking": {
|
|
728
|
+
controller.enqueue({
|
|
729
|
+
type: "redacted-reasoning",
|
|
730
|
+
data: value.content_block.data
|
|
731
|
+
});
|
|
630
732
|
return;
|
|
631
733
|
}
|
|
632
734
|
case "tool_use": {
|
|
@@ -657,6 +759,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
657
759
|
});
|
|
658
760
|
delete toolCallContentBlocks[value.index];
|
|
659
761
|
}
|
|
762
|
+
blockType = void 0;
|
|
660
763
|
return;
|
|
661
764
|
}
|
|
662
765
|
case "content_block_delta": {
|
|
@@ -669,6 +772,22 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
669
772
|
});
|
|
670
773
|
return;
|
|
671
774
|
}
|
|
775
|
+
case "thinking_delta": {
|
|
776
|
+
controller.enqueue({
|
|
777
|
+
type: "reasoning",
|
|
778
|
+
textDelta: value.delta.thinking
|
|
779
|
+
});
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
case "signature_delta": {
|
|
783
|
+
if (blockType === "thinking") {
|
|
784
|
+
controller.enqueue({
|
|
785
|
+
type: "reasoning-signature",
|
|
786
|
+
signature: value.delta.signature
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
672
791
|
case "input_json_delta": {
|
|
673
792
|
const contentBlock = toolCallContentBlocks[value.index];
|
|
674
793
|
controller.enqueue({
|
|
@@ -748,6 +867,15 @@ var anthropicMessagesResponseSchema = import_zod2.z.object({
|
|
|
748
867
|
type: import_zod2.z.literal("text"),
|
|
749
868
|
text: import_zod2.z.string()
|
|
750
869
|
}),
|
|
870
|
+
import_zod2.z.object({
|
|
871
|
+
type: import_zod2.z.literal("thinking"),
|
|
872
|
+
thinking: import_zod2.z.string(),
|
|
873
|
+
signature: import_zod2.z.string()
|
|
874
|
+
}),
|
|
875
|
+
import_zod2.z.object({
|
|
876
|
+
type: import_zod2.z.literal("redacted_thinking"),
|
|
877
|
+
data: import_zod2.z.string()
|
|
878
|
+
}),
|
|
751
879
|
import_zod2.z.object({
|
|
752
880
|
type: import_zod2.z.literal("tool_use"),
|
|
753
881
|
id: import_zod2.z.string(),
|
|
@@ -786,10 +914,18 @@ var anthropicMessagesChunkSchema = import_zod2.z.discriminatedUnion("type", [
|
|
|
786
914
|
type: import_zod2.z.literal("text"),
|
|
787
915
|
text: import_zod2.z.string()
|
|
788
916
|
}),
|
|
917
|
+
import_zod2.z.object({
|
|
918
|
+
type: import_zod2.z.literal("thinking"),
|
|
919
|
+
thinking: import_zod2.z.string()
|
|
920
|
+
}),
|
|
789
921
|
import_zod2.z.object({
|
|
790
922
|
type: import_zod2.z.literal("tool_use"),
|
|
791
923
|
id: import_zod2.z.string(),
|
|
792
924
|
name: import_zod2.z.string()
|
|
925
|
+
}),
|
|
926
|
+
import_zod2.z.object({
|
|
927
|
+
type: import_zod2.z.literal("redacted_thinking"),
|
|
928
|
+
data: import_zod2.z.string()
|
|
793
929
|
})
|
|
794
930
|
])
|
|
795
931
|
}),
|
|
@@ -804,6 +940,14 @@ var anthropicMessagesChunkSchema = import_zod2.z.discriminatedUnion("type", [
|
|
|
804
940
|
import_zod2.z.object({
|
|
805
941
|
type: import_zod2.z.literal("text_delta"),
|
|
806
942
|
text: import_zod2.z.string()
|
|
943
|
+
}),
|
|
944
|
+
import_zod2.z.object({
|
|
945
|
+
type: import_zod2.z.literal("thinking_delta"),
|
|
946
|
+
thinking: import_zod2.z.string()
|
|
947
|
+
}),
|
|
948
|
+
import_zod2.z.object({
|
|
949
|
+
type: import_zod2.z.literal("signature_delta"),
|
|
950
|
+
signature: import_zod2.z.string()
|
|
807
951
|
})
|
|
808
952
|
])
|
|
809
953
|
}),
|
|
@@ -830,6 +974,10 @@ var anthropicMessagesChunkSchema = import_zod2.z.discriminatedUnion("type", [
|
|
|
830
974
|
type: import_zod2.z.literal("ping")
|
|
831
975
|
})
|
|
832
976
|
]);
|
|
977
|
+
var thinkingOptionsSchema = import_zod2.z.object({
|
|
978
|
+
type: import_zod2.z.union([import_zod2.z.literal("enabled"), import_zod2.z.literal("disabled")]),
|
|
979
|
+
budgetTokens: import_zod2.z.number().optional()
|
|
980
|
+
}).optional();
|
|
833
981
|
|
|
834
982
|
// src/anthropic-tools.ts
|
|
835
983
|
var import_zod3 = require("zod");
|
|
@@ -896,10 +1044,25 @@ function computerTool_20241022(options) {
|
|
|
896
1044
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
897
1045
|
};
|
|
898
1046
|
}
|
|
1047
|
+
function computerTool_20250124(options) {
|
|
1048
|
+
return {
|
|
1049
|
+
type: "provider-defined",
|
|
1050
|
+
id: "anthropic.computer_20250124",
|
|
1051
|
+
args: {
|
|
1052
|
+
displayWidthPx: options.displayWidthPx,
|
|
1053
|
+
displayHeightPx: options.displayHeightPx,
|
|
1054
|
+
displayNumber: options.displayNumber
|
|
1055
|
+
},
|
|
1056
|
+
parameters: Computer20241022Parameters,
|
|
1057
|
+
execute: options.execute,
|
|
1058
|
+
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
899
1061
|
var anthropicTools = {
|
|
900
1062
|
bash_20241022: bashTool_20241022,
|
|
901
1063
|
textEditor_20241022: textEditorTool_20241022,
|
|
902
|
-
computer_20241022: computerTool_20241022
|
|
1064
|
+
computer_20241022: computerTool_20241022,
|
|
1065
|
+
computer_20250124: computerTool_20250124
|
|
903
1066
|
};
|
|
904
1067
|
|
|
905
1068
|
// src/anthropic-provider.ts
|