@xyd-js/ask-ai-edge 0.0.0-build-56377ca-20251013180714 → 0.0.0-build-1f6458c-20251015205119
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/dist/index.js +458 -103
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -18955,7 +18955,7 @@ async function* executeTool({
|
|
|
18955
18955
|
}
|
|
18956
18956
|
}
|
|
18957
18957
|
|
|
18958
|
-
// ../../node_modules/.pnpm/@ai-sdk+gateway@1.0.
|
|
18958
|
+
// ../../node_modules/.pnpm/@ai-sdk+gateway@1.0.40_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
18959
18959
|
var import_oidc = __toESM(require_dist(), 1);
|
|
18960
18960
|
var import_oidc2 = __toESM(require_dist(), 1);
|
|
18961
18961
|
var marker15 = "vercel.ai.gateway.error";
|
|
@@ -19521,7 +19521,7 @@ async function getVercelRequestId() {
|
|
|
19521
19521
|
var _a82;
|
|
19522
19522
|
return (_a82 = import_oidc.getContext().headers) == null ? undefined : _a82["x-vercel-id"];
|
|
19523
19523
|
}
|
|
19524
|
-
var VERSION2 = "1.0.
|
|
19524
|
+
var VERSION2 = "1.0.40";
|
|
19525
19525
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
19526
19526
|
function createGatewayProvider(options = {}) {
|
|
19527
19527
|
var _a82, _b8;
|
|
@@ -19651,7 +19651,7 @@ async function getGatewayAuthToken(options) {
|
|
|
19651
19651
|
}
|
|
19652
19652
|
}
|
|
19653
19653
|
|
|
19654
|
-
// ../../node_modules/.pnpm/ai@5.0.
|
|
19654
|
+
// ../../node_modules/.pnpm/ai@5.0.72_zod@3.25.76/node_modules/ai/dist/index.mjs
|
|
19655
19655
|
var import_api2 = __toESM(require_src(), 1);
|
|
19656
19656
|
var import_api3 = __toESM(require_src(), 1);
|
|
19657
19657
|
var __defProp2 = Object.defineProperty;
|
|
@@ -20077,7 +20077,7 @@ function detectMediaType({
|
|
|
20077
20077
|
}
|
|
20078
20078
|
return;
|
|
20079
20079
|
}
|
|
20080
|
-
var VERSION3 = "5.0.
|
|
20080
|
+
var VERSION3 = "5.0.72";
|
|
20081
20081
|
var download = async ({ url: url2 }) => {
|
|
20082
20082
|
var _a172;
|
|
20083
20083
|
const urlText = url2.toString();
|
|
@@ -21319,7 +21319,12 @@ function writeToServerResponse({
|
|
|
21319
21319
|
const { done, value } = await reader.read();
|
|
21320
21320
|
if (done)
|
|
21321
21321
|
break;
|
|
21322
|
-
response.write(value);
|
|
21322
|
+
const canContinue = response.write(value);
|
|
21323
|
+
if (!canContinue) {
|
|
21324
|
+
await new Promise((resolve2) => {
|
|
21325
|
+
response.once("drain", resolve2);
|
|
21326
|
+
});
|
|
21327
|
+
}
|
|
21323
21328
|
}
|
|
21324
21329
|
} catch (error40) {
|
|
21325
21330
|
throw error40;
|
|
@@ -25236,8 +25241,8 @@ async function pkceChallenge(length) {
|
|
|
25236
25241
|
};
|
|
25237
25242
|
}
|
|
25238
25243
|
|
|
25239
|
-
// ../../node_modules/.pnpm/@ai-sdk+anthropic@2.0.
|
|
25240
|
-
var VERSION4 = "2.0.
|
|
25244
|
+
// ../../node_modules/.pnpm/@ai-sdk+anthropic@2.0.30_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
25245
|
+
var VERSION4 = "2.0.30";
|
|
25241
25246
|
var anthropicErrorDataSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
25242
25247
|
type: exports_external.literal("error"),
|
|
25243
25248
|
error: exports_external.object({
|
|
@@ -25361,6 +25366,56 @@ var anthropicMessagesResponseSchema = lazySchema(() => zodSchema(exports_externa
|
|
|
25361
25366
|
error_code: exports_external.string()
|
|
25362
25367
|
})
|
|
25363
25368
|
])
|
|
25369
|
+
}),
|
|
25370
|
+
exports_external.object({
|
|
25371
|
+
type: exports_external.literal("bash_code_execution_tool_result"),
|
|
25372
|
+
tool_use_id: exports_external.string(),
|
|
25373
|
+
content: exports_external.discriminatedUnion("type", [
|
|
25374
|
+
exports_external.object({
|
|
25375
|
+
type: exports_external.literal("bash_code_execution_result"),
|
|
25376
|
+
content: exports_external.array(exports_external.object({
|
|
25377
|
+
type: exports_external.literal("bash_code_execution_output"),
|
|
25378
|
+
file_id: exports_external.string()
|
|
25379
|
+
})),
|
|
25380
|
+
stdout: exports_external.string(),
|
|
25381
|
+
stderr: exports_external.string(),
|
|
25382
|
+
return_code: exports_external.number()
|
|
25383
|
+
}),
|
|
25384
|
+
exports_external.object({
|
|
25385
|
+
type: exports_external.literal("bash_code_execution_tool_result_error"),
|
|
25386
|
+
error_code: exports_external.string()
|
|
25387
|
+
})
|
|
25388
|
+
])
|
|
25389
|
+
}),
|
|
25390
|
+
exports_external.object({
|
|
25391
|
+
type: exports_external.literal("text_editor_code_execution_tool_result"),
|
|
25392
|
+
tool_use_id: exports_external.string(),
|
|
25393
|
+
content: exports_external.discriminatedUnion("type", [
|
|
25394
|
+
exports_external.object({
|
|
25395
|
+
type: exports_external.literal("text_editor_code_execution_tool_result_error"),
|
|
25396
|
+
error_code: exports_external.string()
|
|
25397
|
+
}),
|
|
25398
|
+
exports_external.object({
|
|
25399
|
+
type: exports_external.literal("text_editor_code_execution_view_result"),
|
|
25400
|
+
content: exports_external.string(),
|
|
25401
|
+
file_type: exports_external.string(),
|
|
25402
|
+
num_lines: exports_external.number().nullable(),
|
|
25403
|
+
start_line: exports_external.number().nullable(),
|
|
25404
|
+
total_lines: exports_external.number().nullable()
|
|
25405
|
+
}),
|
|
25406
|
+
exports_external.object({
|
|
25407
|
+
type: exports_external.literal("text_editor_code_execution_create_result"),
|
|
25408
|
+
is_file_update: exports_external.boolean()
|
|
25409
|
+
}),
|
|
25410
|
+
exports_external.object({
|
|
25411
|
+
type: exports_external.literal("text_editor_code_execution_str_replace_result"),
|
|
25412
|
+
lines: exports_external.array(exports_external.string()).nullable(),
|
|
25413
|
+
new_lines: exports_external.number().nullable(),
|
|
25414
|
+
new_start: exports_external.number().nullable(),
|
|
25415
|
+
old_lines: exports_external.number().nullable(),
|
|
25416
|
+
old_start: exports_external.number().nullable()
|
|
25417
|
+
})
|
|
25418
|
+
])
|
|
25364
25419
|
})
|
|
25365
25420
|
])),
|
|
25366
25421
|
stop_reason: exports_external.string().nullish(),
|
|
@@ -25469,6 +25524,56 @@ var anthropicMessagesChunkSchema = lazySchema(() => zodSchema(exports_external.d
|
|
|
25469
25524
|
error_code: exports_external.string()
|
|
25470
25525
|
})
|
|
25471
25526
|
])
|
|
25527
|
+
}),
|
|
25528
|
+
exports_external.object({
|
|
25529
|
+
type: exports_external.literal("bash_code_execution_tool_result"),
|
|
25530
|
+
tool_use_id: exports_external.string(),
|
|
25531
|
+
content: exports_external.discriminatedUnion("type", [
|
|
25532
|
+
exports_external.object({
|
|
25533
|
+
type: exports_external.literal("bash_code_execution_result"),
|
|
25534
|
+
content: exports_external.array(exports_external.object({
|
|
25535
|
+
type: exports_external.literal("bash_code_execution_output"),
|
|
25536
|
+
file_id: exports_external.string()
|
|
25537
|
+
})),
|
|
25538
|
+
stdout: exports_external.string(),
|
|
25539
|
+
stderr: exports_external.string(),
|
|
25540
|
+
return_code: exports_external.number()
|
|
25541
|
+
}),
|
|
25542
|
+
exports_external.object({
|
|
25543
|
+
type: exports_external.literal("bash_code_execution_tool_result_error"),
|
|
25544
|
+
error_code: exports_external.string()
|
|
25545
|
+
})
|
|
25546
|
+
])
|
|
25547
|
+
}),
|
|
25548
|
+
exports_external.object({
|
|
25549
|
+
type: exports_external.literal("text_editor_code_execution_tool_result"),
|
|
25550
|
+
tool_use_id: exports_external.string(),
|
|
25551
|
+
content: exports_external.discriminatedUnion("type", [
|
|
25552
|
+
exports_external.object({
|
|
25553
|
+
type: exports_external.literal("text_editor_code_execution_tool_result_error"),
|
|
25554
|
+
error_code: exports_external.string()
|
|
25555
|
+
}),
|
|
25556
|
+
exports_external.object({
|
|
25557
|
+
type: exports_external.literal("text_editor_code_execution_view_result"),
|
|
25558
|
+
content: exports_external.string(),
|
|
25559
|
+
file_type: exports_external.string(),
|
|
25560
|
+
num_lines: exports_external.number().nullable(),
|
|
25561
|
+
start_line: exports_external.number().nullable(),
|
|
25562
|
+
total_lines: exports_external.number().nullable()
|
|
25563
|
+
}),
|
|
25564
|
+
exports_external.object({
|
|
25565
|
+
type: exports_external.literal("text_editor_code_execution_create_result"),
|
|
25566
|
+
is_file_update: exports_external.boolean()
|
|
25567
|
+
}),
|
|
25568
|
+
exports_external.object({
|
|
25569
|
+
type: exports_external.literal("text_editor_code_execution_str_replace_result"),
|
|
25570
|
+
lines: exports_external.array(exports_external.string()).nullable(),
|
|
25571
|
+
new_lines: exports_external.number().nullable(),
|
|
25572
|
+
new_start: exports_external.number().nullable(),
|
|
25573
|
+
old_lines: exports_external.number().nullable(),
|
|
25574
|
+
old_start: exports_external.number().nullable()
|
|
25575
|
+
})
|
|
25576
|
+
])
|
|
25472
25577
|
})
|
|
25473
25578
|
])
|
|
25474
25579
|
}),
|
|
@@ -25706,6 +25811,14 @@ async function prepareTools({
|
|
|
25706
25811
|
});
|
|
25707
25812
|
break;
|
|
25708
25813
|
}
|
|
25814
|
+
case "anthropic.code_execution_20250825": {
|
|
25815
|
+
betas.add("code-execution-2025-08-25");
|
|
25816
|
+
anthropicTools2.push({
|
|
25817
|
+
type: "code_execution_20250825",
|
|
25818
|
+
name: "code_execution"
|
|
25819
|
+
});
|
|
25820
|
+
break;
|
|
25821
|
+
}
|
|
25709
25822
|
case "anthropic.computer_20250124": {
|
|
25710
25823
|
betas.add("computer-use-2025-01-24");
|
|
25711
25824
|
anthropicTools2.push({
|
|
@@ -25780,6 +25893,14 @@ async function prepareTools({
|
|
|
25780
25893
|
});
|
|
25781
25894
|
break;
|
|
25782
25895
|
}
|
|
25896
|
+
case "anthropic.memory_20250818": {
|
|
25897
|
+
betas.add("context-management-2025-06-27");
|
|
25898
|
+
anthropicTools2.push({
|
|
25899
|
+
name: "memory",
|
|
25900
|
+
type: "memory_20250818"
|
|
25901
|
+
});
|
|
25902
|
+
break;
|
|
25903
|
+
}
|
|
25783
25904
|
case "anthropic.web_fetch_20250910": {
|
|
25784
25905
|
betas.add("web-fetch-2025-09-10");
|
|
25785
25906
|
const args = await validateTypes({
|
|
@@ -25894,6 +26015,81 @@ var factory4 = createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
25894
26015
|
var codeExecution_20250522 = (args = {}) => {
|
|
25895
26016
|
return factory4(args);
|
|
25896
26017
|
};
|
|
26018
|
+
var codeExecution_20250825OutputSchema = lazySchema(() => zodSchema(exports_external.discriminatedUnion("type", [
|
|
26019
|
+
exports_external.object({
|
|
26020
|
+
type: exports_external.literal("bash_code_execution_result"),
|
|
26021
|
+
content: exports_external.array(exports_external.object({
|
|
26022
|
+
type: exports_external.literal("bash_code_execution_output"),
|
|
26023
|
+
file_id: exports_external.string()
|
|
26024
|
+
})),
|
|
26025
|
+
stdout: exports_external.string(),
|
|
26026
|
+
stderr: exports_external.string(),
|
|
26027
|
+
return_code: exports_external.number()
|
|
26028
|
+
}),
|
|
26029
|
+
exports_external.object({
|
|
26030
|
+
type: exports_external.literal("bash_code_execution_tool_result_error"),
|
|
26031
|
+
error_code: exports_external.string()
|
|
26032
|
+
}),
|
|
26033
|
+
exports_external.object({
|
|
26034
|
+
type: exports_external.literal("text_editor_code_execution_tool_result_error"),
|
|
26035
|
+
error_code: exports_external.string()
|
|
26036
|
+
}),
|
|
26037
|
+
exports_external.object({
|
|
26038
|
+
type: exports_external.literal("text_editor_code_execution_view_result"),
|
|
26039
|
+
content: exports_external.string(),
|
|
26040
|
+
file_type: exports_external.string(),
|
|
26041
|
+
num_lines: exports_external.number().nullable(),
|
|
26042
|
+
start_line: exports_external.number().nullable(),
|
|
26043
|
+
total_lines: exports_external.number().nullable()
|
|
26044
|
+
}),
|
|
26045
|
+
exports_external.object({
|
|
26046
|
+
type: exports_external.literal("text_editor_code_execution_create_result"),
|
|
26047
|
+
is_file_update: exports_external.boolean()
|
|
26048
|
+
}),
|
|
26049
|
+
exports_external.object({
|
|
26050
|
+
type: exports_external.literal("text_editor_code_execution_str_replace_result"),
|
|
26051
|
+
lines: exports_external.array(exports_external.string()).nullable(),
|
|
26052
|
+
new_lines: exports_external.number().nullable(),
|
|
26053
|
+
new_start: exports_external.number().nullable(),
|
|
26054
|
+
old_lines: exports_external.number().nullable(),
|
|
26055
|
+
old_start: exports_external.number().nullable()
|
|
26056
|
+
})
|
|
26057
|
+
])));
|
|
26058
|
+
var codeExecution_20250825InputSchema = lazySchema(() => zodSchema(exports_external.discriminatedUnion("type", [
|
|
26059
|
+
exports_external.object({
|
|
26060
|
+
type: exports_external.literal("bash_code_execution"),
|
|
26061
|
+
command: exports_external.string()
|
|
26062
|
+
}),
|
|
26063
|
+
exports_external.discriminatedUnion("command", [
|
|
26064
|
+
exports_external.object({
|
|
26065
|
+
type: exports_external.literal("text_editor_code_execution"),
|
|
26066
|
+
command: exports_external.literal("view"),
|
|
26067
|
+
path: exports_external.string()
|
|
26068
|
+
}),
|
|
26069
|
+
exports_external.object({
|
|
26070
|
+
type: exports_external.literal("text_editor_code_execution"),
|
|
26071
|
+
command: exports_external.literal("create"),
|
|
26072
|
+
path: exports_external.string(),
|
|
26073
|
+
file_text: exports_external.string().nullish()
|
|
26074
|
+
}),
|
|
26075
|
+
exports_external.object({
|
|
26076
|
+
type: exports_external.literal("text_editor_code_execution"),
|
|
26077
|
+
command: exports_external.literal("str_replace"),
|
|
26078
|
+
path: exports_external.string(),
|
|
26079
|
+
old_str: exports_external.string(),
|
|
26080
|
+
new_str: exports_external.string()
|
|
26081
|
+
})
|
|
26082
|
+
])
|
|
26083
|
+
])));
|
|
26084
|
+
var factory5 = createProviderDefinedToolFactoryWithOutputSchema({
|
|
26085
|
+
id: "anthropic.code_execution_20250825",
|
|
26086
|
+
name: "code_execution",
|
|
26087
|
+
inputSchema: codeExecution_20250825InputSchema,
|
|
26088
|
+
outputSchema: codeExecution_20250825OutputSchema
|
|
26089
|
+
});
|
|
26090
|
+
var codeExecution_20250825 = (args = {}) => {
|
|
26091
|
+
return factory5(args);
|
|
26092
|
+
};
|
|
25897
26093
|
function convertToString(data) {
|
|
25898
26094
|
if (typeof data === "string") {
|
|
25899
26095
|
return Buffer.from(data, "base64").toString("utf-8");
|
|
@@ -26182,7 +26378,15 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
26182
26378
|
}
|
|
26183
26379
|
case "tool-call": {
|
|
26184
26380
|
if (part.providerExecuted) {
|
|
26185
|
-
if (part.toolName === "code_execution"
|
|
26381
|
+
if (part.toolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && typeof part.input.type === "string" && (part.input.type === "bash_code_execution" || part.input.type === "text_editor_code_execution")) {
|
|
26382
|
+
anthropicContent.push({
|
|
26383
|
+
type: "server_tool_use",
|
|
26384
|
+
id: part.toolCallId,
|
|
26385
|
+
name: part.input.type,
|
|
26386
|
+
input: part.input,
|
|
26387
|
+
cache_control: cacheControl
|
|
26388
|
+
});
|
|
26389
|
+
} else if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
|
|
26186
26390
|
anthropicContent.push({
|
|
26187
26391
|
type: "server_tool_use",
|
|
26188
26392
|
id: part.toolCallId,
|
|
@@ -26217,21 +26421,46 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
26217
26421
|
});
|
|
26218
26422
|
break;
|
|
26219
26423
|
}
|
|
26220
|
-
|
|
26221
|
-
|
|
26222
|
-
|
|
26223
|
-
|
|
26224
|
-
|
|
26225
|
-
|
|
26226
|
-
|
|
26227
|
-
|
|
26228
|
-
|
|
26229
|
-
|
|
26230
|
-
|
|
26231
|
-
|
|
26232
|
-
|
|
26233
|
-
|
|
26234
|
-
|
|
26424
|
+
if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
|
|
26425
|
+
warnings.push({
|
|
26426
|
+
type: "other",
|
|
26427
|
+
message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
|
|
26428
|
+
});
|
|
26429
|
+
break;
|
|
26430
|
+
}
|
|
26431
|
+
if (output.value.type === "code_execution_result") {
|
|
26432
|
+
const codeExecutionOutput = await validateTypes({
|
|
26433
|
+
value: output.value,
|
|
26434
|
+
schema: codeExecution_20250522OutputSchema
|
|
26435
|
+
});
|
|
26436
|
+
anthropicContent.push({
|
|
26437
|
+
type: "code_execution_tool_result",
|
|
26438
|
+
tool_use_id: part.toolCallId,
|
|
26439
|
+
content: {
|
|
26440
|
+
type: codeExecutionOutput.type,
|
|
26441
|
+
stdout: codeExecutionOutput.stdout,
|
|
26442
|
+
stderr: codeExecutionOutput.stderr,
|
|
26443
|
+
return_code: codeExecutionOutput.return_code
|
|
26444
|
+
},
|
|
26445
|
+
cache_control: cacheControl
|
|
26446
|
+
});
|
|
26447
|
+
} else {
|
|
26448
|
+
const codeExecutionOutput = await validateTypes({
|
|
26449
|
+
value: output.value,
|
|
26450
|
+
schema: codeExecution_20250825OutputSchema
|
|
26451
|
+
});
|
|
26452
|
+
anthropicContent.push(codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
|
|
26453
|
+
type: "bash_code_execution_tool_result",
|
|
26454
|
+
tool_use_id: part.toolCallId,
|
|
26455
|
+
cache_control: cacheControl,
|
|
26456
|
+
content: codeExecutionOutput
|
|
26457
|
+
} : {
|
|
26458
|
+
type: "text_editor_code_execution_tool_result",
|
|
26459
|
+
tool_use_id: part.toolCallId,
|
|
26460
|
+
cache_control: cacheControl,
|
|
26461
|
+
content: codeExecutionOutput
|
|
26462
|
+
});
|
|
26463
|
+
}
|
|
26235
26464
|
break;
|
|
26236
26465
|
}
|
|
26237
26466
|
if (part.toolName === "web_fetch") {
|
|
@@ -26677,7 +26906,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
26677
26906
|
break;
|
|
26678
26907
|
}
|
|
26679
26908
|
case "server_tool_use": {
|
|
26680
|
-
if (part.name === "
|
|
26909
|
+
if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
|
|
26910
|
+
content.push({
|
|
26911
|
+
type: "tool-call",
|
|
26912
|
+
toolCallId: part.id,
|
|
26913
|
+
toolName: "code_execution",
|
|
26914
|
+
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
26915
|
+
providerExecuted: true
|
|
26916
|
+
});
|
|
26917
|
+
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
26681
26918
|
content.push({
|
|
26682
26919
|
type: "tool-call",
|
|
26683
26920
|
toolCallId: part.id,
|
|
@@ -26802,6 +27039,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
26802
27039
|
}
|
|
26803
27040
|
break;
|
|
26804
27041
|
}
|
|
27042
|
+
case "bash_code_execution_tool_result":
|
|
27043
|
+
case "text_editor_code_execution_tool_result": {
|
|
27044
|
+
content.push({
|
|
27045
|
+
type: "tool-result",
|
|
27046
|
+
toolCallId: part.tool_use_id,
|
|
27047
|
+
toolName: "code_execution",
|
|
27048
|
+
result: part.content,
|
|
27049
|
+
providerExecuted: true
|
|
27050
|
+
});
|
|
27051
|
+
break;
|
|
27052
|
+
}
|
|
26805
27053
|
}
|
|
26806
27054
|
}
|
|
26807
27055
|
return {
|
|
@@ -26915,7 +27163,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
26915
27163
|
type: "tool-call",
|
|
26916
27164
|
toolCallId: value.content_block.id,
|
|
26917
27165
|
toolName: value.content_block.name,
|
|
26918
|
-
input: ""
|
|
27166
|
+
input: "",
|
|
27167
|
+
firstDelta: true
|
|
26919
27168
|
};
|
|
26920
27169
|
controller.enqueue(usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
|
|
26921
27170
|
type: "tool-input-start",
|
|
@@ -26925,18 +27174,26 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
26925
27174
|
return;
|
|
26926
27175
|
}
|
|
26927
27176
|
case "server_tool_use": {
|
|
26928
|
-
if (
|
|
27177
|
+
if ([
|
|
27178
|
+
"web_fetch",
|
|
27179
|
+
"web_search",
|
|
27180
|
+
"code_execution",
|
|
27181
|
+
"text_editor_code_execution",
|
|
27182
|
+
"bash_code_execution"
|
|
27183
|
+
].includes(value.content_block.name)) {
|
|
26929
27184
|
contentBlocks[value.index] = {
|
|
26930
27185
|
type: "tool-call",
|
|
26931
27186
|
toolCallId: value.content_block.id,
|
|
26932
27187
|
toolName: value.content_block.name,
|
|
26933
27188
|
input: "",
|
|
26934
|
-
providerExecuted: true
|
|
27189
|
+
providerExecuted: true,
|
|
27190
|
+
firstDelta: true
|
|
26935
27191
|
};
|
|
27192
|
+
const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
|
|
26936
27193
|
controller.enqueue({
|
|
26937
27194
|
type: "tool-input-start",
|
|
26938
27195
|
id: value.content_block.id,
|
|
26939
|
-
toolName:
|
|
27196
|
+
toolName: mappedToolName,
|
|
26940
27197
|
providerExecuted: true
|
|
26941
27198
|
});
|
|
26942
27199
|
}
|
|
@@ -27058,6 +27315,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
27058
27315
|
}
|
|
27059
27316
|
return;
|
|
27060
27317
|
}
|
|
27318
|
+
case "bash_code_execution_tool_result":
|
|
27319
|
+
case "text_editor_code_execution_tool_result": {
|
|
27320
|
+
const part = value.content_block;
|
|
27321
|
+
controller.enqueue({
|
|
27322
|
+
type: "tool-result",
|
|
27323
|
+
toolCallId: part.tool_use_id,
|
|
27324
|
+
toolName: "code_execution",
|
|
27325
|
+
result: part.content,
|
|
27326
|
+
providerExecuted: true
|
|
27327
|
+
});
|
|
27328
|
+
return;
|
|
27329
|
+
}
|
|
27061
27330
|
default: {
|
|
27062
27331
|
const _exhaustiveCheck = contentBlockType;
|
|
27063
27332
|
throw new Error(`Unsupported content block type: ${_exhaustiveCheck}`);
|
|
@@ -27088,7 +27357,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
27088
27357
|
type: "tool-input-end",
|
|
27089
27358
|
id: contentBlock.toolCallId
|
|
27090
27359
|
});
|
|
27091
|
-
|
|
27360
|
+
const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
|
|
27361
|
+
controller.enqueue({
|
|
27362
|
+
type: "tool-call",
|
|
27363
|
+
toolCallId: contentBlock.toolCallId,
|
|
27364
|
+
toolName,
|
|
27365
|
+
input: contentBlock.input,
|
|
27366
|
+
providerExecuted: contentBlock.providerExecuted
|
|
27367
|
+
});
|
|
27092
27368
|
}
|
|
27093
27369
|
break;
|
|
27094
27370
|
}
|
|
@@ -27136,7 +27412,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
27136
27412
|
}
|
|
27137
27413
|
case "input_json_delta": {
|
|
27138
27414
|
const contentBlock = contentBlocks[value.index];
|
|
27139
|
-
|
|
27415
|
+
let delta = value.delta.partial_json;
|
|
27416
|
+
if (delta.length === 0) {
|
|
27417
|
+
return;
|
|
27418
|
+
}
|
|
27140
27419
|
if (usesJsonResponseTool) {
|
|
27141
27420
|
if ((contentBlock == null ? undefined : contentBlock.type) !== "text") {
|
|
27142
27421
|
return;
|
|
@@ -27150,12 +27429,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
27150
27429
|
if ((contentBlock == null ? undefined : contentBlock.type) !== "tool-call") {
|
|
27151
27430
|
return;
|
|
27152
27431
|
}
|
|
27432
|
+
if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
|
|
27433
|
+
delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
|
|
27434
|
+
}
|
|
27153
27435
|
controller.enqueue({
|
|
27154
27436
|
type: "tool-input-delta",
|
|
27155
27437
|
id: contentBlock.toolCallId,
|
|
27156
27438
|
delta
|
|
27157
27439
|
});
|
|
27158
27440
|
contentBlock.input += delta;
|
|
27441
|
+
contentBlock.firstDelta = false;
|
|
27159
27442
|
}
|
|
27160
27443
|
return;
|
|
27161
27444
|
}
|
|
@@ -27302,6 +27585,44 @@ var computer_20250124 = createProviderDefinedToolFactory({
|
|
|
27302
27585
|
name: "computer",
|
|
27303
27586
|
inputSchema: computer_20250124InputSchema
|
|
27304
27587
|
});
|
|
27588
|
+
var memory_20250818InputSchema = lazySchema(() => zodSchema(exports_external.discriminatedUnion("command", [
|
|
27589
|
+
exports_external.object({
|
|
27590
|
+
command: exports_external.literal("view"),
|
|
27591
|
+
path: exports_external.string(),
|
|
27592
|
+
view_range: exports_external.tuple([exports_external.number(), exports_external.number()]).optional()
|
|
27593
|
+
}),
|
|
27594
|
+
exports_external.object({
|
|
27595
|
+
command: exports_external.literal("create"),
|
|
27596
|
+
path: exports_external.string(),
|
|
27597
|
+
file_text: exports_external.string()
|
|
27598
|
+
}),
|
|
27599
|
+
exports_external.object({
|
|
27600
|
+
command: exports_external.literal("str_replace"),
|
|
27601
|
+
path: exports_external.string(),
|
|
27602
|
+
old_str: exports_external.string(),
|
|
27603
|
+
new_str: exports_external.string()
|
|
27604
|
+
}),
|
|
27605
|
+
exports_external.object({
|
|
27606
|
+
command: exports_external.literal("insert"),
|
|
27607
|
+
path: exports_external.string(),
|
|
27608
|
+
insert_line: exports_external.number(),
|
|
27609
|
+
insert_text: exports_external.string()
|
|
27610
|
+
}),
|
|
27611
|
+
exports_external.object({
|
|
27612
|
+
command: exports_external.literal("delete"),
|
|
27613
|
+
path: exports_external.string()
|
|
27614
|
+
}),
|
|
27615
|
+
exports_external.object({
|
|
27616
|
+
command: exports_external.literal("rename"),
|
|
27617
|
+
old_path: exports_external.string(),
|
|
27618
|
+
new_path: exports_external.string()
|
|
27619
|
+
})
|
|
27620
|
+
])));
|
|
27621
|
+
var memory_20250818 = createProviderDefinedToolFactory({
|
|
27622
|
+
id: "anthropic.memory_20250818",
|
|
27623
|
+
name: "memory",
|
|
27624
|
+
inputSchema: memory_20250818InputSchema
|
|
27625
|
+
});
|
|
27305
27626
|
var textEditor_20241022InputSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
27306
27627
|
command: exports_external.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
27307
27628
|
path: exports_external.string(),
|
|
@@ -27348,8 +27669,10 @@ var anthropicTools = {
|
|
|
27348
27669
|
bash_20241022,
|
|
27349
27670
|
bash_20250124,
|
|
27350
27671
|
codeExecution_20250522,
|
|
27672
|
+
codeExecution_20250825,
|
|
27351
27673
|
computer_20241022,
|
|
27352
27674
|
computer_20250124,
|
|
27675
|
+
memory_20250818,
|
|
27353
27676
|
textEditor_20241022,
|
|
27354
27677
|
textEditor_20250124,
|
|
27355
27678
|
textEditor_20250429,
|
|
@@ -27402,7 +27725,7 @@ function createAnthropic(options = {}) {
|
|
|
27402
27725
|
}
|
|
27403
27726
|
var anthropic = createAnthropic();
|
|
27404
27727
|
|
|
27405
|
-
// ../../node_modules/.pnpm/@ai-sdk+openai@2.0.
|
|
27728
|
+
// ../../node_modules/.pnpm/@ai-sdk+openai@2.0.52_zod@3.25.76/node_modules/@ai-sdk/openai/dist/index.mjs
|
|
27406
27729
|
var openaiErrorDataSchema = exports_external.object({
|
|
27407
27730
|
error: exports_external.object({
|
|
27408
27731
|
message: exports_external.string(),
|
|
@@ -28943,9 +29266,7 @@ var localShell = createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
28943
29266
|
outputSchema: localShellOutputSchema
|
|
28944
29267
|
});
|
|
28945
29268
|
var webSearchArgsSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
28946
|
-
filters: exports_external.object({
|
|
28947
|
-
allowedDomains: exports_external.array(exports_external.string()).optional()
|
|
28948
|
-
}).optional(),
|
|
29269
|
+
filters: exports_external.object({ allowedDomains: exports_external.array(exports_external.string()).optional() }).optional(),
|
|
28949
29270
|
searchContextSize: exports_external.enum(["low", "medium", "high"]).optional(),
|
|
28950
29271
|
userLocation: exports_external.object({
|
|
28951
29272
|
type: exports_external.literal("approximate"),
|
|
@@ -28955,14 +29276,15 @@ var webSearchArgsSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
|
28955
29276
|
timezone: exports_external.string().optional()
|
|
28956
29277
|
}).optional()
|
|
28957
29278
|
})));
|
|
28958
|
-
var webSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
29279
|
+
var webSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({})));
|
|
29280
|
+
var webSearchOutputSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
28959
29281
|
action: exports_external.discriminatedUnion("type", [
|
|
28960
29282
|
exports_external.object({
|
|
28961
29283
|
type: exports_external.literal("search"),
|
|
28962
|
-
query: exports_external.string().
|
|
29284
|
+
query: exports_external.string().optional()
|
|
28963
29285
|
}),
|
|
28964
29286
|
exports_external.object({
|
|
28965
|
-
type: exports_external.literal("
|
|
29287
|
+
type: exports_external.literal("openPage"),
|
|
28966
29288
|
url: exports_external.string()
|
|
28967
29289
|
}),
|
|
28968
29290
|
exports_external.object({
|
|
@@ -28970,16 +29292,15 @@ var webSearchInputSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
|
28970
29292
|
url: exports_external.string(),
|
|
28971
29293
|
pattern: exports_external.string()
|
|
28972
29294
|
})
|
|
28973
|
-
])
|
|
29295
|
+
])
|
|
28974
29296
|
})));
|
|
28975
|
-
var webSearchToolFactory =
|
|
29297
|
+
var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
28976
29298
|
id: "openai.web_search",
|
|
28977
29299
|
name: "web_search",
|
|
28978
|
-
inputSchema: webSearchInputSchema
|
|
29300
|
+
inputSchema: webSearchInputSchema,
|
|
29301
|
+
outputSchema: webSearchOutputSchema
|
|
28979
29302
|
});
|
|
28980
|
-
var webSearch = (args = {}) =>
|
|
28981
|
-
return webSearchToolFactory(args);
|
|
28982
|
-
};
|
|
29303
|
+
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
28983
29304
|
var webSearchPreviewArgsSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
28984
29305
|
searchContextSize: exports_external.enum(["low", "medium", "high"]).optional(),
|
|
28985
29306
|
userLocation: exports_external.object({
|
|
@@ -28990,14 +29311,15 @@ var webSearchPreviewArgsSchema = lazySchema(() => zodSchema(exports_external.obj
|
|
|
28990
29311
|
timezone: exports_external.string().optional()
|
|
28991
29312
|
}).optional()
|
|
28992
29313
|
})));
|
|
28993
|
-
var webSearchPreviewInputSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
29314
|
+
var webSearchPreviewInputSchema = lazySchema(() => zodSchema(exports_external.object({})));
|
|
29315
|
+
var webSearchPreviewOutputSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
28994
29316
|
action: exports_external.discriminatedUnion("type", [
|
|
28995
29317
|
exports_external.object({
|
|
28996
29318
|
type: exports_external.literal("search"),
|
|
28997
|
-
query: exports_external.string().
|
|
29319
|
+
query: exports_external.string().optional()
|
|
28998
29320
|
}),
|
|
28999
29321
|
exports_external.object({
|
|
29000
|
-
type: exports_external.literal("
|
|
29322
|
+
type: exports_external.literal("openPage"),
|
|
29001
29323
|
url: exports_external.string()
|
|
29002
29324
|
}),
|
|
29003
29325
|
exports_external.object({
|
|
@@ -29005,12 +29327,13 @@ var webSearchPreviewInputSchema = lazySchema(() => zodSchema(exports_external.ob
|
|
|
29005
29327
|
url: exports_external.string(),
|
|
29006
29328
|
pattern: exports_external.string()
|
|
29007
29329
|
})
|
|
29008
|
-
])
|
|
29330
|
+
])
|
|
29009
29331
|
})));
|
|
29010
|
-
var webSearchPreview =
|
|
29332
|
+
var webSearchPreview = createProviderDefinedToolFactoryWithOutputSchema({
|
|
29011
29333
|
id: "openai.web_search_preview",
|
|
29012
29334
|
name: "web_search_preview",
|
|
29013
|
-
inputSchema: webSearchPreviewInputSchema
|
|
29335
|
+
inputSchema: webSearchPreviewInputSchema,
|
|
29336
|
+
outputSchema: webSearchPreviewOutputSchema
|
|
29014
29337
|
});
|
|
29015
29338
|
var openaiTools = {
|
|
29016
29339
|
codeInterpreter,
|
|
@@ -29214,6 +29537,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
29214
29537
|
input.push(reasoningMessages[reasoningId]);
|
|
29215
29538
|
} else {
|
|
29216
29539
|
reasoningMessage.summary.push(...summaryParts);
|
|
29540
|
+
if ((providerOptions == null ? undefined : providerOptions.reasoningEncryptedContent) != null) {
|
|
29541
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
29542
|
+
}
|
|
29217
29543
|
}
|
|
29218
29544
|
}
|
|
29219
29545
|
} else {
|
|
@@ -29368,11 +29694,7 @@ var openaiResponsesChunkSchema = lazyValidator(() => zodSchema(exports_external.
|
|
|
29368
29694
|
exports_external.object({
|
|
29369
29695
|
type: exports_external.literal("web_search_call"),
|
|
29370
29696
|
id: exports_external.string(),
|
|
29371
|
-
status: exports_external.string()
|
|
29372
|
-
action: exports_external.object({
|
|
29373
|
-
type: exports_external.literal("search"),
|
|
29374
|
-
query: exports_external.string().optional()
|
|
29375
|
-
}).nullish()
|
|
29697
|
+
status: exports_external.string()
|
|
29376
29698
|
}),
|
|
29377
29699
|
exports_external.object({
|
|
29378
29700
|
type: exports_external.literal("computer_call"),
|
|
@@ -29454,7 +29776,7 @@ var openaiResponsesChunkSchema = lazyValidator(() => zodSchema(exports_external.
|
|
|
29454
29776
|
url: exports_external.string(),
|
|
29455
29777
|
pattern: exports_external.string()
|
|
29456
29778
|
})
|
|
29457
|
-
])
|
|
29779
|
+
])
|
|
29458
29780
|
}),
|
|
29459
29781
|
exports_external.object({
|
|
29460
29782
|
type: exports_external.literal("file_search_call"),
|
|
@@ -29542,6 +29864,11 @@ var openaiResponsesChunkSchema = lazyValidator(() => zodSchema(exports_external.
|
|
|
29542
29864
|
summary_index: exports_external.number(),
|
|
29543
29865
|
delta: exports_external.string()
|
|
29544
29866
|
}),
|
|
29867
|
+
exports_external.object({
|
|
29868
|
+
type: exports_external.literal("response.reasoning_summary_part.done"),
|
|
29869
|
+
item_id: exports_external.string(),
|
|
29870
|
+
summary_index: exports_external.number()
|
|
29871
|
+
}),
|
|
29545
29872
|
exports_external.object({
|
|
29546
29873
|
type: exports_external.literal("error"),
|
|
29547
29874
|
code: exports_external.string(),
|
|
@@ -29619,7 +29946,7 @@ var openaiResponsesResponseSchema = lazyValidator(() => zodSchema(exports_extern
|
|
|
29619
29946
|
url: exports_external.string(),
|
|
29620
29947
|
pattern: exports_external.string()
|
|
29621
29948
|
})
|
|
29622
|
-
])
|
|
29949
|
+
])
|
|
29623
29950
|
}),
|
|
29624
29951
|
exports_external.object({
|
|
29625
29952
|
type: exports_external.literal("file_search_call"),
|
|
@@ -30113,7 +30440,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30113
30440
|
tools: openaiTools2,
|
|
30114
30441
|
tool_choice: openaiToolChoice
|
|
30115
30442
|
},
|
|
30116
|
-
warnings: [...warnings, ...toolWarnings]
|
|
30443
|
+
warnings: [...warnings, ...toolWarnings],
|
|
30444
|
+
store
|
|
30117
30445
|
};
|
|
30118
30446
|
}
|
|
30119
30447
|
async doGenerate(options) {
|
|
@@ -30266,14 +30594,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30266
30594
|
type: "tool-call",
|
|
30267
30595
|
toolCallId: part.id,
|
|
30268
30596
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
30269
|
-
input: JSON.stringify({
|
|
30597
|
+
input: JSON.stringify({}),
|
|
30270
30598
|
providerExecuted: true
|
|
30271
30599
|
});
|
|
30272
30600
|
content.push({
|
|
30273
30601
|
type: "tool-result",
|
|
30274
30602
|
toolCallId: part.id,
|
|
30275
30603
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
30276
|
-
result:
|
|
30604
|
+
result: mapWebSearchOutput(part.action),
|
|
30277
30605
|
providerExecuted: true
|
|
30278
30606
|
});
|
|
30279
30607
|
break;
|
|
@@ -30386,7 +30714,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30386
30714
|
const {
|
|
30387
30715
|
args: body,
|
|
30388
30716
|
warnings,
|
|
30389
|
-
webSearchToolName
|
|
30717
|
+
webSearchToolName,
|
|
30718
|
+
store
|
|
30390
30719
|
} = await this.getArgs(options);
|
|
30391
30720
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
30392
30721
|
url: this.config.url({
|
|
@@ -30422,7 +30751,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30422
30751
|
controller.enqueue({ type: "stream-start", warnings });
|
|
30423
30752
|
},
|
|
30424
30753
|
transform(chunk, controller) {
|
|
30425
|
-
var _a18, _b8, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v
|
|
30754
|
+
var _a18, _b8, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
30426
30755
|
if (options.includeRawChunks) {
|
|
30427
30756
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
30428
30757
|
}
|
|
@@ -30454,6 +30783,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30454
30783
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
30455
30784
|
providerExecuted: true
|
|
30456
30785
|
});
|
|
30786
|
+
controller.enqueue({
|
|
30787
|
+
type: "tool-input-end",
|
|
30788
|
+
id: value.item.id
|
|
30789
|
+
});
|
|
30790
|
+
controller.enqueue({
|
|
30791
|
+
type: "tool-call",
|
|
30792
|
+
toolCallId: value.item.id,
|
|
30793
|
+
toolName: "web_search",
|
|
30794
|
+
input: JSON.stringify({}),
|
|
30795
|
+
providerExecuted: true
|
|
30796
|
+
});
|
|
30457
30797
|
} else if (value.item.type === "computer_call") {
|
|
30458
30798
|
ongoingToolCalls[value.output_index] = {
|
|
30459
30799
|
toolName: "computer_use",
|
|
@@ -30510,10 +30850,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30510
30850
|
}
|
|
30511
30851
|
}
|
|
30512
30852
|
});
|
|
30513
|
-
} else if (
|
|
30853
|
+
} else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
|
|
30514
30854
|
activeReasoning[value.item.id] = {
|
|
30515
30855
|
encryptedContent: value.item.encrypted_content,
|
|
30516
|
-
summaryParts:
|
|
30856
|
+
summaryParts: { 0: "active" }
|
|
30517
30857
|
};
|
|
30518
30858
|
controller.enqueue({
|
|
30519
30859
|
type: "reasoning-start",
|
|
@@ -30547,22 +30887,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30547
30887
|
});
|
|
30548
30888
|
} else if (value.item.type === "web_search_call") {
|
|
30549
30889
|
ongoingToolCalls[value.output_index] = undefined;
|
|
30550
|
-
controller.enqueue({
|
|
30551
|
-
type: "tool-input-end",
|
|
30552
|
-
id: value.item.id
|
|
30553
|
-
});
|
|
30554
|
-
controller.enqueue({
|
|
30555
|
-
type: "tool-call",
|
|
30556
|
-
toolCallId: value.item.id,
|
|
30557
|
-
toolName: "web_search",
|
|
30558
|
-
input: JSON.stringify({ action: value.item.action }),
|
|
30559
|
-
providerExecuted: true
|
|
30560
|
-
});
|
|
30561
30890
|
controller.enqueue({
|
|
30562
30891
|
type: "tool-result",
|
|
30563
30892
|
toolCallId: value.item.id,
|
|
30564
30893
|
toolName: "web_search",
|
|
30565
|
-
result:
|
|
30894
|
+
result: mapWebSearchOutput(value.item.action),
|
|
30566
30895
|
providerExecuted: true
|
|
30567
30896
|
});
|
|
30568
30897
|
} else if (value.item.type === "computer_call") {
|
|
@@ -30652,9 +30981,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30652
30981
|
type: "text-end",
|
|
30653
30982
|
id: value.item.id
|
|
30654
30983
|
});
|
|
30655
|
-
} else if (
|
|
30984
|
+
} else if (value.item.type === "reasoning") {
|
|
30656
30985
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
30657
|
-
|
|
30986
|
+
const summaryPartIndices = Object.entries(activeReasoningPart.summaryParts).filter(([_, status]) => status === "active" || status === "can-conclude").map(([summaryIndex]) => summaryIndex);
|
|
30987
|
+
for (const summaryIndex of summaryPartIndices) {
|
|
30658
30988
|
controller.enqueue({
|
|
30659
30989
|
type: "reasoning-end",
|
|
30660
30990
|
id: `${value.item.id}:${summaryIndex}`,
|
|
@@ -30726,21 +31056,32 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30726
31056
|
if (((_f = (_e = options.providerOptions) == null ? undefined : _e.openai) == null ? undefined : _f.logprobs) && value.logprobs) {
|
|
30727
31057
|
logprobs.push(value.logprobs);
|
|
30728
31058
|
}
|
|
30729
|
-
} else if (
|
|
31059
|
+
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
30730
31060
|
if (value.summary_index > 0) {
|
|
30731
|
-
|
|
31061
|
+
const activeReasoningPart = activeReasoning[value.item_id];
|
|
31062
|
+
activeReasoningPart.summaryParts[value.summary_index] = "active";
|
|
31063
|
+
for (const summaryIndex of Object.keys(activeReasoningPart.summaryParts)) {
|
|
31064
|
+
if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
|
|
31065
|
+
controller.enqueue({
|
|
31066
|
+
type: "reasoning-end",
|
|
31067
|
+
id: `${value.item_id}:${summaryIndex}`,
|
|
31068
|
+
providerMetadata: { openai: { itemId: value.item_id } }
|
|
31069
|
+
});
|
|
31070
|
+
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
31071
|
+
}
|
|
31072
|
+
}
|
|
30732
31073
|
controller.enqueue({
|
|
30733
31074
|
type: "reasoning-start",
|
|
30734
31075
|
id: `${value.item_id}:${value.summary_index}`,
|
|
30735
31076
|
providerMetadata: {
|
|
30736
31077
|
openai: {
|
|
30737
31078
|
itemId: value.item_id,
|
|
30738
|
-
reasoningEncryptedContent: (
|
|
31079
|
+
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? undefined : _g.encryptedContent) != null ? _h : null
|
|
30739
31080
|
}
|
|
30740
31081
|
}
|
|
30741
31082
|
});
|
|
30742
31083
|
}
|
|
30743
|
-
} else if (
|
|
31084
|
+
} else if (value.type === "response.reasoning_summary_text.delta") {
|
|
30744
31085
|
controller.enqueue({
|
|
30745
31086
|
type: "reasoning-delta",
|
|
30746
31087
|
id: `${value.item_id}:${value.summary_index}`,
|
|
@@ -30751,16 +31092,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30751
31092
|
}
|
|
30752
31093
|
}
|
|
30753
31094
|
});
|
|
31095
|
+
} else if (value.type === "response.reasoning_summary_part.done") {
|
|
31096
|
+
if (store) {
|
|
31097
|
+
controller.enqueue({
|
|
31098
|
+
type: "reasoning-end",
|
|
31099
|
+
id: `${value.item_id}:${value.summary_index}`,
|
|
31100
|
+
providerMetadata: {
|
|
31101
|
+
openai: { itemId: value.item_id }
|
|
31102
|
+
}
|
|
31103
|
+
});
|
|
31104
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
|
|
31105
|
+
} else {
|
|
31106
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
|
|
31107
|
+
}
|
|
30754
31108
|
} else if (isResponseFinishedChunk(value)) {
|
|
30755
31109
|
finishReason = mapOpenAIResponseFinishReason({
|
|
30756
|
-
finishReason: (
|
|
31110
|
+
finishReason: (_i = value.response.incomplete_details) == null ? undefined : _i.reason,
|
|
30757
31111
|
hasFunctionCall
|
|
30758
31112
|
});
|
|
30759
31113
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
30760
31114
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
30761
31115
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
30762
|
-
usage.reasoningTokens = (
|
|
30763
|
-
usage.cachedInputTokens = (
|
|
31116
|
+
usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? undefined : _j.reasoning_tokens) != null ? _k : undefined;
|
|
31117
|
+
usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? undefined : _l.cached_tokens) != null ? _m : undefined;
|
|
30764
31118
|
if (typeof value.response.service_tier === "string") {
|
|
30765
31119
|
serviceTier = value.response.service_tier;
|
|
30766
31120
|
}
|
|
@@ -30769,7 +31123,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30769
31123
|
controller.enqueue({
|
|
30770
31124
|
type: "source",
|
|
30771
31125
|
sourceType: "url",
|
|
30772
|
-
id: (
|
|
31126
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? undefined : _o.call(_n)) != null ? _p : generateId(),
|
|
30773
31127
|
url: value.annotation.url,
|
|
30774
31128
|
title: value.annotation.title
|
|
30775
31129
|
});
|
|
@@ -30777,10 +31131,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
30777
31131
|
controller.enqueue({
|
|
30778
31132
|
type: "source",
|
|
30779
31133
|
sourceType: "document",
|
|
30780
|
-
id: (
|
|
31134
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? undefined : _r.call(_q)) != null ? _s : generateId(),
|
|
30781
31135
|
mediaType: "text/plain",
|
|
30782
|
-
title: (
|
|
30783
|
-
filename: (
|
|
31136
|
+
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
31137
|
+
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
|
|
30784
31138
|
});
|
|
30785
31139
|
}
|
|
30786
31140
|
} else if (isErrorChunk(value)) {
|
|
@@ -30818,9 +31172,6 @@ function isTextDeltaChunk(chunk) {
|
|
|
30818
31172
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
30819
31173
|
return chunk.type === "response.output_item.done";
|
|
30820
31174
|
}
|
|
30821
|
-
function isResponseOutputItemDoneReasoningChunk(chunk) {
|
|
30822
|
-
return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
|
|
30823
|
-
}
|
|
30824
31175
|
function isResponseFinishedChunk(chunk) {
|
|
30825
31176
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
30826
31177
|
}
|
|
@@ -30839,18 +31190,9 @@ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
|
30839
31190
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
30840
31191
|
return chunk.type === "response.output_item.added";
|
|
30841
31192
|
}
|
|
30842
|
-
function isResponseOutputItemAddedReasoningChunk(chunk) {
|
|
30843
|
-
return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
|
|
30844
|
-
}
|
|
30845
31193
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
30846
31194
|
return chunk.type === "response.output_text.annotation.added";
|
|
30847
31195
|
}
|
|
30848
|
-
function isResponseReasoningSummaryPartAddedChunk(chunk) {
|
|
30849
|
-
return chunk.type === "response.reasoning_summary_part.added";
|
|
30850
|
-
}
|
|
30851
|
-
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
30852
|
-
return chunk.type === "response.reasoning_summary_text.delta";
|
|
30853
|
-
}
|
|
30854
31196
|
function isErrorChunk(chunk) {
|
|
30855
31197
|
return chunk.type === "error";
|
|
30856
31198
|
}
|
|
@@ -30888,6 +31230,19 @@ function getResponsesModelConfig(modelId) {
|
|
|
30888
31230
|
isReasoningModel: false
|
|
30889
31231
|
};
|
|
30890
31232
|
}
|
|
31233
|
+
function mapWebSearchOutput(action) {
|
|
31234
|
+
var _a18;
|
|
31235
|
+
switch (action.type) {
|
|
31236
|
+
case "search":
|
|
31237
|
+
return { action: { type: "search", query: (_a18 = action.query) != null ? _a18 : undefined } };
|
|
31238
|
+
case "open_page":
|
|
31239
|
+
return { action: { type: "openPage", url: action.url } };
|
|
31240
|
+
case "find":
|
|
31241
|
+
return {
|
|
31242
|
+
action: { type: "find", url: action.url, pattern: action.pattern }
|
|
31243
|
+
};
|
|
31244
|
+
}
|
|
31245
|
+
}
|
|
30891
31246
|
var openaiSpeechProviderOptionsSchema = lazyValidator(() => zodSchema(exports_external.object({
|
|
30892
31247
|
instructions: exports_external.string().nullish(),
|
|
30893
31248
|
speed: exports_external.number().min(0.25).max(4).default(1).nullish()
|
|
@@ -31177,7 +31532,7 @@ var OpenAITranscriptionModel = class {
|
|
|
31177
31532
|
};
|
|
31178
31533
|
}
|
|
31179
31534
|
};
|
|
31180
|
-
var VERSION5 = "2.0.
|
|
31535
|
+
var VERSION5 = "2.0.52";
|
|
31181
31536
|
function createOpenAI(options = {}) {
|
|
31182
31537
|
var _a18, _b8;
|
|
31183
31538
|
const baseURL = (_a18 = withoutTrailingSlash(loadOptionalSetting({
|
|
@@ -34943,9 +35298,9 @@ class wa {
|
|
|
34943
35298
|
return console.error("Error:", { status: e3, message: t2 }), new Response(JSON.stringify({ error: t2 }), { status: e3, headers: { ...this.corsHeaders, "Content-Type": "application/json" } });
|
|
34944
35299
|
}
|
|
34945
35300
|
}
|
|
34946
|
-
|
|
35301
|
+
function ba(e3) {
|
|
34947
35302
|
if (e3 instanceof Request) {
|
|
34948
|
-
return
|
|
35303
|
+
return wa.New({ ...wa.defaultConfig() })(e3);
|
|
34949
35304
|
}
|
|
34950
35305
|
return wa.New(e3);
|
|
34951
35306
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyd-js/ask-ai-edge",
|
|
3
|
-
"version": "0.0.0-build-
|
|
3
|
+
"version": "0.0.0-build-1f6458c-20251015205119",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xyd-js/ask-ai": "0.0.0-build-
|
|
13
|
+
"@xyd-js/ask-ai": "0.0.0-build-1f6458c-20251015205119"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "bun build index.ts --outdir dist --target node --format esm"
|