@openclaw/ai 2026.10.5 → 2026.10.10-beta.2
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/README.md +11 -0
- package/dist/{anthropic-DIIiiz99.mjs → anthropic-D6spfBri.mjs} +16 -18
- package/dist/{anthropic-payload-policy-DGblkHL5.d.mts → anthropic-payload-policy-Cr8xjazC.d.mts} +6 -3
- package/dist/{anthropic-stream-reducer-DfMVFm-r.mjs → anthropic-stream-reducer-CzPXOaLM.mjs} +55 -227
- package/dist/anthropic-tool-projection-BdAS3rtJ.mjs +165 -0
- package/dist/anthropic-tool-projection-DKH-aEWU.d.mts +51 -0
- package/dist/{api-registry-BhXXYdRA.d.mts → api-registry-gDt0faai.d.mts} +2 -2
- package/dist/{assistant-output-BuhRpLeD.mjs → assistant-output-6iFA1nbC.mjs} +2 -2
- package/dist/{azure-openai-responses-DGQnXRMs.mjs → azure-openai-responses-0TqHwnlD.mjs} +8 -8
- package/dist/{cloudflare-5qSGvIUH.mjs → cloudflare-Dttf8jKq.mjs} +1 -1
- package/dist/{credential-redaction-BHxruEH6.d.mts → credential-redaction-XvsPf7Yi.d.mts} +1 -0
- package/dist/{diagnostics-tQasYct1.mjs → diagnostics-Cv7cW3pS.mjs} +3 -3
- package/dist/diagnostics.d.mts +6 -6
- package/dist/diagnostics.mjs +2 -2
- package/dist/{env-api-keys-CrxwdylR.mjs → env-api-keys-Xd8dm_aV.mjs} +10 -34
- package/dist/event-stream-CDpFza-M.d.mts +1 -0
- package/dist/{event-stream-BcqWLo_u.d.mts → event-stream-CzpE1g_o.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/{github-copilot-request-facts-DEE6gcB9.mjs → github-copilot-request-facts-F-EmvkpW.mjs} +1 -1
- package/dist/{google-interactions-zIz70M2e.mjs → google-interactions-DVQ7AaSF.mjs} +29 -50
- package/dist/{google-messages-CNbUJK5E.mjs → google-messages-DfpHVTaD.mjs} +15 -5
- package/dist/{google-provider-stream-Cn0XF1MG.mjs → google-provider-stream-DJ8ANfsS.mjs} +6 -6
- package/dist/{google-shared-BPnWP4tT.mjs → google-shared-VTcCJLW3.mjs} +21 -29
- package/dist/{google-vertex-XQ7OQtaM.mjs → google-vertex-Bkfizj7M.mjs} +3 -3
- package/dist/{google-BlbTC1Xp.mjs → google-zWpkDSeN.mjs} +4 -4
- package/dist/{host-Bf3NjYNj.mjs → host-B2gk-d1H.mjs} +5 -11
- package/dist/{host-CTDz7LXD.d.mts → host-jJOffdlW.d.mts} +4 -6
- package/dist/{host-policy-BzZluO6_.mjs → host-policy-mpqGhbeM.mjs} +1 -1
- package/dist/{index-BYDvopUB.d.mts → index-DSprYWaz.d.mts} +7 -5
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +6 -6
- package/dist/internal/anthropic.d.mts +7 -53
- package/dist/internal/anthropic.mjs +6 -5
- package/dist/internal/google-model-family.mjs +1 -1
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +3 -3
- package/dist/internal/openai.d.mts +17 -26
- package/dist/internal/openai.mjs +10 -10
- package/dist/internal/retry-after.d.mts +1 -1
- package/dist/internal/retry-after.mjs +80 -55
- package/dist/internal/runtime.d.mts +9 -31
- package/dist/internal/runtime.mjs +10 -116
- package/dist/internal/shared.d.mts +9 -7
- package/dist/internal/shared.mjs +8 -6
- package/dist/internal/tool-schema.d.mts +83 -5
- package/dist/internal/tool-schema.mjs +4 -3
- package/dist/{mistral-dCDCR5ur.mjs → mistral-CATJrwne.mjs} +32 -35
- package/dist/model-request-body-BD5vy4rP.d.mts +17 -0
- package/dist/{number-coercion-C3hztWoY.mjs → number-coercion-37gmNkuA.mjs} +1 -1
- package/dist/{openai-chatgpt-responses-D8-q7cgy.mjs → openai-chatgpt-responses-CtdnpWwe.mjs} +95 -63
- package/dist/{openai-completions-CMN24pza.mjs → openai-completions-B6sET3oI.mjs} +10 -8
- package/dist/{openai-completions-compat-i-nLZxFy.d.mts → openai-completions-compat-1gsjP-KO.d.mts} +6 -3
- package/dist/{openai-completions-compat-CYX18uDk.mjs → openai-completions-compat-CFhQ3UVU.mjs} +7 -2
- package/dist/{openai-completions-transport-DuXQOxrH.mjs → openai-completions-transport-DviPEqw3.mjs} +369 -237
- package/dist/{openai-prompt-cache-r93BJhjm.mjs → openai-prompt-cache-DJ_P143P.mjs} +1 -1
- package/dist/{openai-prompt-cache-DIPMrMFy.d.mts → openai-prompt-cache-DgjD-UL5.d.mts} +2 -2
- package/dist/{openai-responses-BMxoJdTC.mjs → openai-responses-BXsJK-mD.mjs} +13 -15
- package/dist/{openai-responses-compaction-replay-B2FE4Nw8.d.mts → openai-responses-compaction-replay-Cvnl_nCq.d.mts} +5 -5
- package/dist/{openai-responses-contracts-DlKMMTxK.mjs → openai-responses-contracts-Bx-16mnf.mjs} +45 -6
- package/dist/{openai-responses-contracts-DKqMJ1Ct.d.mts → openai-responses-contracts-CQ4_AWjL.d.mts} +20 -8
- package/dist/{openai-responses-endpoint-CinGh4VZ.mjs → openai-responses-endpoint-D4v-eeYy.mjs} +55 -22
- package/dist/{openai-responses-payload-policy-C7GsA1y0.d.mts → openai-responses-payload-policy-BzM52TTH.d.mts} +9 -3
- package/dist/openai-responses-request-lifecycle-CTdAb2v1.mjs +246 -0
- package/dist/{openai-responses-shared-afo9-s16.mjs → openai-responses-shared-Bv_1NtH9.mjs} +284 -173
- package/dist/{openai-responses-terminal-usage-BygjiAdi.d.mts → openai-responses-terminal-usage-CpVjkqn-.d.mts} +2 -2
- package/dist/{openai-tool-schema-DDPXsvJP.mjs → openai-tool-schema-Buv0GXFb.mjs} +170 -237
- package/dist/overflow-DJHXTNBQ.mjs +117 -0
- package/dist/{positive-integer-CqWjqSi9.mjs → positive-integer-Bb4Evc7L.mjs} +1 -1
- package/dist/prompt-cache-stability-D_MeCQFI.mjs +32 -0
- package/dist/{provider-error-xumb1V3F.d.mts → provider-error-CnaWYTRY.d.mts} +1 -0
- package/dist/{provider-error-CF9GWCs2.mjs → provider-error-qtZD2inE.mjs} +75 -13
- package/dist/{provider-options-CVrXZBtA.d.mts → provider-options-DeYeaflL.d.mts} +52 -6
- package/dist/{transport-utils-34BQoXq3.mjs → provider-replay-context-J6CfU3m1.mjs} +28 -5
- package/dist/{provider-transport-turn-state-BYrELw8H.mjs → provider-transport-turn-state-Jxppzuc2.mjs} +5 -5
- package/dist/{provider-types-CHtRx0dI.d.mts → provider-types-ODq57rG_.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +11 -11
- package/dist/{reasoning-tag-text-partitioner-CpOy9-IQ.mjs → reasoning-tag-text-partitioner-DzlRubwU.mjs} +134 -47
- package/dist/{required-api-key-CFJvcFy_.mjs → required-api-key-D088S4Cd.mjs} +1 -1
- package/dist/{retry-after-CdCURCVg.d.mts → retry-after-sw-XX8aC.d.mts} +1 -1
- package/dist/sanitize-unicode-CRGuMONI.mjs +8 -0
- package/dist/sanitize-unicode-ZqVLLEKC.d.mts +27 -0
- package/dist/{session-resources-D1wgDQ8C.mjs → session-resources-vKvGIE3J.mjs} +1 -10
- package/dist/{simple-options-BAu4B54D.mjs → simple-options-BYgC6kse.mjs} +68 -79
- package/dist/{src-C44MKrW5.mjs → src-CyA0zJnt.mjs} +6 -2
- package/dist/{stream-Dd8DwRFL.mjs → stream-DLBirT0e.mjs} +8 -47
- package/dist/{stream-first-event-timeout-Dc42hKv6.mjs → stream-first-event-timeout-D_TfJHRJ.mjs} +1 -1
- package/dist/{string-coerce-CtgOVOSv.mjs → string-coerce-Cj8sqWHx.mjs} +26 -1
- package/dist/tool-schema-json-projection-B0hHDV7N.mjs +492 -0
- package/dist/{transport-stream-shared-BmpzDtdQ.d.mts → transport-stream-shared-8ru8eX4s.d.mts} +5 -5
- package/dist/{transport-stream-shared-CWGOuLcA.mjs → transport-stream-shared-CzQlAzJH.mjs} +27 -75
- package/dist/transports.d.mts +33 -28
- package/dist/transports.mjs +42 -48
- package/dist/{types-CQc6JNG4.mjs → types-BXd0kI8-.mjs} +1 -1
- package/dist/types-CBJthzJX.d.mts +1 -0
- package/dist/{types-Bd2T86VJ.d.mts → types-CVYzKrMl.d.mts} +20 -3
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +4 -4
- package/dist/{validation-ZX_sPVV0.mjs → validation-9FSkE8T-.mjs} +22 -3
- package/dist/{validation-DdGB1yy3.d.mts → validation-BQ5u20Ru.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +3 -3
- package/dist/assistant-text-phase-mvdMcrY-.mjs +0 -50
- package/dist/event-stream-6UNs-AhN.d.mts +0 -1
- package/dist/expect-lbe3Hgrh.mjs +0 -8
- package/dist/json-schema-Bp07Qui3.mjs +0 -22
- package/dist/openai-responses-request-lifecycle-NSIJo9jY.mjs +0 -67
- package/dist/openai-tool-projection-793cE3QX.d.mts +0 -37
- package/dist/openai-tool-schema-a5ysBBga.d.mts +0 -32
- package/dist/rolldown-runtime-BhDjJH2R.mjs +0 -15
- package/dist/sanitize-unicode-CjDG6jJx.d.mts +0 -5
- package/dist/string-normalization-I3ux50s9.mjs +0 -28
- package/dist/text-signature-CUXnvk_c.mjs +0 -34
- package/dist/tool-schema-json-projection-B8sG1I9v.mjs +0 -180
- package/dist/types-Kdfw_04V.d.mts +0 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
|
+
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-D_MeCQFI.mjs";
|
|
3
|
+
import { _ as SCHEMA_MAP_KEYS, d as inheritToolSchemaTruncation, g as SCHEMA_ARRAY_KEYS, i as publishRuntimeToolInputSchema, r as projectRuntimeToolInputSchema, t as getPublishedRuntimeToolInputSchema, y as SCHEMA_OBJECT_KEYS } from "./tool-schema-json-projection-B0hHDV7N.mjs";
|
|
4
|
+
//#region packages/ai/src/providers/anthropic-tool-projection.ts
|
|
5
|
+
const CLAUDE_CODE_TOOL_LOOKUP = new Map([
|
|
6
|
+
"Read",
|
|
7
|
+
"Write",
|
|
8
|
+
"Edit",
|
|
9
|
+
"Bash",
|
|
10
|
+
"Grep",
|
|
11
|
+
"Glob",
|
|
12
|
+
"AskUserQuestion",
|
|
13
|
+
"EnterPlanMode",
|
|
14
|
+
"ExitPlanMode",
|
|
15
|
+
"KillShell",
|
|
16
|
+
"NotebookEdit",
|
|
17
|
+
"Skill",
|
|
18
|
+
"Task",
|
|
19
|
+
"TaskOutput",
|
|
20
|
+
"TodoWrite",
|
|
21
|
+
"WebFetch",
|
|
22
|
+
"WebSearch"
|
|
23
|
+
].map((name) => [name.toLowerCase(), name]));
|
|
24
|
+
/** Preserve Claude Code's canonical tool casing for subscription OAuth requests. */
|
|
25
|
+
function toClaudeCodeToolName(name) {
|
|
26
|
+
return CLAUDE_CODE_TOOL_LOOKUP.get(name.toLowerCase()) ?? name;
|
|
27
|
+
}
|
|
28
|
+
/** Anthropic rejects forced tools while extended thinking is enabled. */
|
|
29
|
+
function normalizeAnthropicToolChoice(thinkingEnabled, toolChoice) {
|
|
30
|
+
if (thinkingEnabled && (toolChoice === "any" || typeof toolChoice === "object" && toolChoice.type === "tool")) return { type: "auto" };
|
|
31
|
+
return typeof toolChoice === "string" ? { type: toolChoice } : toolChoice;
|
|
32
|
+
}
|
|
33
|
+
/** Anthropic tool identifiers accept only ASCII word characters and dashes. */
|
|
34
|
+
function normalizeAnthropicToolCallId(id) {
|
|
35
|
+
return id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
|
36
|
+
}
|
|
37
|
+
function isProviderSupportedViolation(violation) {
|
|
38
|
+
return violation.endsWith(".$dynamicRef") || violation.endsWith(".$dynamicAnchor");
|
|
39
|
+
}
|
|
40
|
+
/** Normalize the detached JSON projection and report tuple changes to enclosing schemas. */
|
|
41
|
+
function normalizeAnthropicJsonSchema(schema) {
|
|
42
|
+
if (!isRecord(schema)) return false;
|
|
43
|
+
let changed = false;
|
|
44
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
45
|
+
if (key !== "additionalItems" && SCHEMA_OBJECT_KEYS.has(key) && !Array.isArray(value)) {
|
|
46
|
+
changed = normalizeAnthropicJsonSchema(value) || changed;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (key !== "items" && SCHEMA_ARRAY_KEYS.has(key) && Array.isArray(value)) {
|
|
50
|
+
for (const entry of value) changed = normalizeAnthropicJsonSchema(entry) || changed;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (SCHEMA_MAP_KEYS.has(key) && isRecord(value)) for (const entry of Object.values(value)) changed = normalizeAnthropicJsonSchema(entry) || changed;
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(schema.items)) {
|
|
56
|
+
for (const entry of schema.items) normalizeAnthropicJsonSchema(entry);
|
|
57
|
+
schema.prefixItems = schema.items;
|
|
58
|
+
const additionalItems = schema.additionalItems;
|
|
59
|
+
if (typeof additionalItems === "boolean" || isRecord(additionalItems)) {
|
|
60
|
+
normalizeAnthropicJsonSchema(additionalItems);
|
|
61
|
+
schema.items = additionalItems;
|
|
62
|
+
} else delete schema.items;
|
|
63
|
+
delete schema.additionalItems;
|
|
64
|
+
changed = true;
|
|
65
|
+
}
|
|
66
|
+
if (changed) delete schema.$schema;
|
|
67
|
+
return changed;
|
|
68
|
+
}
|
|
69
|
+
const publishedAnthropicSchemas = /* @__PURE__ */ new WeakMap();
|
|
70
|
+
/** Prepare a detached JSON projection for Anthropic's tuple dialect. */
|
|
71
|
+
function prepareAnthropicInputSchema(schema) {
|
|
72
|
+
const published = getPublishedRuntimeToolInputSchema(schema);
|
|
73
|
+
const cached = published ? publishedAnthropicSchemas.get(schema) : void 0;
|
|
74
|
+
if (cached !== void 0) return cached;
|
|
75
|
+
const normalized = published ? JSON.parse(published.json) : schema;
|
|
76
|
+
normalizeAnthropicJsonSchema(normalized);
|
|
77
|
+
const properties = normalized.properties;
|
|
78
|
+
const required = normalized.required;
|
|
79
|
+
if (properties !== void 0 && properties !== null && !isRecord(properties) || required !== void 0 && required !== null && (!Array.isArray(required) || required.some((entry) => typeof entry !== "string"))) {
|
|
80
|
+
if (published) publishedAnthropicSchemas.set(schema, null);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const inputSchema = {
|
|
84
|
+
...normalized,
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: properties ?? {},
|
|
87
|
+
required: required ?? []
|
|
88
|
+
};
|
|
89
|
+
inheritToolSchemaTruncation(schema, inputSchema);
|
|
90
|
+
if (!published) return inputSchema;
|
|
91
|
+
const result = publishRuntimeToolInputSchema(inputSchema).schema;
|
|
92
|
+
publishedAnthropicSchemas.set(schema, result);
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
/** Snapshots direct/custom tool descriptors before Anthropic payload construction. */
|
|
96
|
+
function projectAnthropicTools(tools, toWireName) {
|
|
97
|
+
const projectedTools = [];
|
|
98
|
+
const originalNameByWireName = /* @__PURE__ */ new Map();
|
|
99
|
+
const unavailableOriginalNames = /* @__PURE__ */ new Set();
|
|
100
|
+
for (const tool of tools) {
|
|
101
|
+
let projectedTool;
|
|
102
|
+
let originalName;
|
|
103
|
+
try {
|
|
104
|
+
const name = tool.name;
|
|
105
|
+
originalName = name;
|
|
106
|
+
if (!name) continue;
|
|
107
|
+
const schemaProjection = projectRuntimeToolInputSchema(tool.parameters, `${name}.parameters`, name);
|
|
108
|
+
if (!isRecord(schemaProjection.schema) || schemaProjection.violations.some((violation) => !isProviderSupportedViolation(violation))) {
|
|
109
|
+
unavailableOriginalNames.add(name);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const inputSchema = prepareAnthropicInputSchema(schemaProjection.schema);
|
|
113
|
+
if (!inputSchema) {
|
|
114
|
+
unavailableOriginalNames.add(name);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
let description;
|
|
118
|
+
try {
|
|
119
|
+
description = typeof tool.description === "string" ? tool.description : void 0;
|
|
120
|
+
} catch {}
|
|
121
|
+
projectedTool = {
|
|
122
|
+
originalName: name,
|
|
123
|
+
wireName: toWireName(name),
|
|
124
|
+
...description ? { description } : {},
|
|
125
|
+
inputSchema
|
|
126
|
+
};
|
|
127
|
+
} catch {
|
|
128
|
+
if (originalName) unavailableOriginalNames.add(originalName);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const conflictingName = originalNameByWireName.get(projectedTool.wireName);
|
|
132
|
+
if (conflictingName !== void 0 && conflictingName !== projectedTool.originalName) throw new Error(`Anthropic tool names "${conflictingName}" and "${projectedTool.originalName}" both map to "${projectedTool.wireName}"`);
|
|
133
|
+
originalNameByWireName.set(projectedTool.wireName, projectedTool.originalName);
|
|
134
|
+
projectedTools.push(projectedTool);
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
inputToolCount: tools.length,
|
|
138
|
+
unavailableOriginalNames,
|
|
139
|
+
tools: sortPromptCacheToolsByName(projectedTools)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/** Keeps forced Anthropic tool choices aligned with the projected wire names. */
|
|
143
|
+
function reconcileAnthropicToolChoice(choice, projection) {
|
|
144
|
+
if (projection.inputToolCount === 0) return choice;
|
|
145
|
+
if (choice.type === "tool") {
|
|
146
|
+
const requestedName = choice.name;
|
|
147
|
+
const matchedTool = projection.tools.find((tool) => tool.originalName === requestedName) ?? (projection.unavailableOriginalNames.has(requestedName) ? void 0 : projection.tools.find((tool) => tool.wireName === requestedName));
|
|
148
|
+
if (!matchedTool) throw new Error(`Anthropic tool_choice requested unavailable tool "${requestedName}" after schema conversion`);
|
|
149
|
+
return {
|
|
150
|
+
...choice,
|
|
151
|
+
name: matchedTool.wireName
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (projection.tools.length === 0) {
|
|
155
|
+
if (choice.type === "auto") return;
|
|
156
|
+
if (choice.type === "any") throw new Error("Anthropic tool_choice requires a tool, but no tools survived schema conversion");
|
|
157
|
+
}
|
|
158
|
+
return choice;
|
|
159
|
+
}
|
|
160
|
+
/** Maps Claude Code wire names without trusting every direct/custom descriptor. */
|
|
161
|
+
function resolveOriginalAnthropicToolName(name, projection) {
|
|
162
|
+
return projection?.tools.find((tool) => tool.wireName === name)?.originalName ?? name;
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
export { reconcileAnthropicToolChoice as a, projectAnthropicTools as i, normalizeAnthropicToolChoice as n, resolveOriginalAnthropicToolName as o, prepareAnthropicInputSchema as r, toClaudeCodeToolName as s, normalizeAnthropicToolCallId as t };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { r as AnthropicOptions } from "./provider-options-DeYeaflL.mjs";
|
|
2
|
+
import { Tool } from "@anthropic-ai/sdk/resources/messages.js";
|
|
3
|
+
//#region packages/ai/src/providers/anthropic-tool-projection.d.ts
|
|
4
|
+
type AnthropicToolDescriptor = {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly parameters: unknown;
|
|
8
|
+
};
|
|
9
|
+
type AnthropicProjectedTool = {
|
|
10
|
+
readonly originalName: string;
|
|
11
|
+
readonly wireName: string;
|
|
12
|
+
readonly description?: string;
|
|
13
|
+
readonly inputSchema: Tool["input_schema"] & {
|
|
14
|
+
readonly properties: Record<string, unknown>;
|
|
15
|
+
readonly required: string[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
type AnthropicToolProjection = {
|
|
19
|
+
readonly inputToolCount: number;
|
|
20
|
+
readonly unavailableOriginalNames: ReadonlySet<string>;
|
|
21
|
+
readonly tools: readonly AnthropicProjectedTool[];
|
|
22
|
+
};
|
|
23
|
+
type AnthropicParallelToolChoice = {
|
|
24
|
+
readonly disable_parallel_tool_use?: boolean;
|
|
25
|
+
};
|
|
26
|
+
type AnthropicProjectedToolChoice = ({
|
|
27
|
+
readonly type: "auto";
|
|
28
|
+
} & AnthropicParallelToolChoice) | ({
|
|
29
|
+
readonly type: "any";
|
|
30
|
+
} & AnthropicParallelToolChoice) | {
|
|
31
|
+
readonly type: "none";
|
|
32
|
+
} | ({
|
|
33
|
+
readonly type: "tool";
|
|
34
|
+
readonly name: string;
|
|
35
|
+
} & AnthropicParallelToolChoice);
|
|
36
|
+
/** Preserve Claude Code's canonical tool casing for subscription OAuth requests. */
|
|
37
|
+
declare function toClaudeCodeToolName(name: string): string;
|
|
38
|
+
/** Anthropic rejects forced tools while extended thinking is enabled. */
|
|
39
|
+
declare function normalizeAnthropicToolChoice(thinkingEnabled: boolean, toolChoice: NonNullable<AnthropicOptions["toolChoice"]>): AnthropicProjectedToolChoice;
|
|
40
|
+
/** Anthropic tool identifiers accept only ASCII word characters and dashes. */
|
|
41
|
+
declare function normalizeAnthropicToolCallId(id: string): string;
|
|
42
|
+
/** Prepare a detached JSON projection for Anthropic's tuple dialect. */
|
|
43
|
+
declare function prepareAnthropicInputSchema(schema: Record<string, unknown>): AnthropicProjectedTool["inputSchema"] | null;
|
|
44
|
+
/** Snapshots direct/custom tool descriptors before Anthropic payload construction. */
|
|
45
|
+
declare function projectAnthropicTools(tools: readonly AnthropicToolDescriptor[], toWireName: (name: string) => string): AnthropicToolProjection;
|
|
46
|
+
/** Keeps forced Anthropic tool choices aligned with the projected wire names. */
|
|
47
|
+
declare function reconcileAnthropicToolChoice(choice: AnthropicProjectedToolChoice, projection: AnthropicToolProjection): AnthropicProjectedToolChoice | undefined;
|
|
48
|
+
/** Maps Claude Code wire names without trusting every direct/custom descriptor. */
|
|
49
|
+
declare function resolveOriginalAnthropicToolName(name: string, projection: AnthropicToolProjection | undefined): string;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { prepareAnthropicInputSchema as a, resolveOriginalAnthropicToolName as c, normalizeAnthropicToolChoice as i, toClaudeCodeToolName as l, AnthropicToolProjection as n, projectAnthropicTools as o, normalizeAnthropicToolCallId as r, reconcileAnthropicToolChoice as s, AnthropicProjectedToolChoice as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { Q as SimpleStreamOptions, n as Api, nt as StreamOptions, tt as StreamFunction } from "./types-
|
|
1
|
+
import "./index-DSprYWaz.mjs";
|
|
2
|
+
import { Q as SimpleStreamOptions, n as Api, nt as StreamOptions, tt as StreamFunction } from "./types-CVYzKrMl.mjs";
|
|
3
3
|
//#region packages/ai/src/api-registry.d.ts
|
|
4
4
|
/** Runtime stream adapter signature stored in the API provider registry. */
|
|
5
5
|
type ApiStreamFunction = StreamFunction;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as transformMessages } from "./host-
|
|
2
|
-
import { a as createEmptyTransportUsage } from "./transport-stream-shared-
|
|
1
|
+
import { c as transformMessages } from "./host-B2gk-d1H.mjs";
|
|
2
|
+
import { a as createEmptyTransportUsage } from "./transport-stream-shared-CzQlAzJH.mjs";
|
|
3
3
|
//#region packages/ai/src/provider-transcript-transform.ts
|
|
4
4
|
const IMAGE_OMISSION = "(image omitted: model does not support images)";
|
|
5
5
|
const VIDEO_OMISSION = "(video omitted: provider does not support video input)";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
2
|
-
import { r as getAiTransportHost } from "./host-
|
|
3
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
2
|
+
import { r as getAiTransportHost } from "./host-B2gk-d1H.mjs";
|
|
3
|
+
import { n as buildBaseOptions } from "./simple-options-BYgC6kse.mjs";
|
|
4
|
+
import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
|
|
5
|
+
import { t as createAssistantOutput } from "./assistant-output-6iFA1nbC.mjs";
|
|
6
|
+
import { F as convertProviderResponsesMessages, It as resolvePromptCacheKey, Lt as withOpenAIErrorResponseHook, r as runResponsesStreamLifecycle, t as applyCommonResponsesParams, vt as resolveOpenAISimpleReasoningEffort } from "./openai-responses-shared-Bv_1NtH9.mjs";
|
|
7
7
|
import { i as resolveAzureDeploymentNameFromMap, n as isTraditionalAzureOpenAIHost, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-D0dvJMbZ.mjs";
|
|
8
|
-
import { t as requireApiKey } from "./required-api-key-
|
|
8
|
+
import { t as requireApiKey } from "./required-api-key-D088S4Cd.mjs";
|
|
9
9
|
import OpenAI, { AzureOpenAI } from "openai";
|
|
10
10
|
//#region packages/ai/src/providers/azure-openai-responses.ts
|
|
11
11
|
const DEFAULT_AZURE_API_VERSION = "v1";
|
|
@@ -86,10 +86,10 @@ function createClient(model, apiKeyInput, options) {
|
|
|
86
86
|
dangerouslyAllowBrowser: true,
|
|
87
87
|
defaultHeaders: headers,
|
|
88
88
|
baseURL: baseUrl,
|
|
89
|
-
fetch: getAiTransportHost().buildModelFetch({
|
|
89
|
+
fetch: withOpenAIErrorResponseHook(getAiTransportHost().buildModelFetch({
|
|
90
90
|
...model,
|
|
91
91
|
baseUrl
|
|
92
|
-
}),
|
|
92
|
+
}) ?? globalThis.fetch, options?.onResponse, model),
|
|
93
93
|
maxRetries: 0
|
|
94
94
|
};
|
|
95
95
|
return isOpenAICompatibleAzureResponsesBaseUrl(baseUrl) ? new OpenAI(clientOptions) : new AzureOpenAI({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as projectCopilotRequestFacts } from "./github-copilot-request-facts-
|
|
1
|
+
import { t as projectCopilotRequestFacts } from "./github-copilot-request-facts-F-EmvkpW.mjs";
|
|
2
2
|
//#region packages/ai/src/providers/cache-retention.ts
|
|
3
3
|
/**
|
|
4
4
|
* Resolve cache retention preference.
|
|
@@ -9,6 +9,7 @@ type DiagnosticMediaField = {
|
|
|
9
9
|
source?: string | Uint8Array;
|
|
10
10
|
};
|
|
11
11
|
type DiagnosticProjectionPolicy = {
|
|
12
|
+
redactCredentials?: boolean;
|
|
12
13
|
omitField?: (key: string) => boolean;
|
|
13
14
|
propertyScope?: "enumerable" | "error";
|
|
14
15
|
projectBinary?: (binary: Uint8Array) => unknown;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as isProviderRefusalAssistantError } from "./diagnostics-DzrF1h4J.mjs";
|
|
2
2
|
import { i as asOptionalRecord, o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { n as asNonNegativeFiniteNumber, t as asFiniteNumber } from "./number-coercion-
|
|
5
|
-
import "./provider-error-
|
|
3
|
+
import { r as normalizeLowercaseStringOrEmpty } from "./string-coerce-Cj8sqWHx.mjs";
|
|
4
|
+
import { n as asNonNegativeFiniteNumber, t as asFiniteNumber } from "./number-coercion-37gmNkuA.mjs";
|
|
5
|
+
import "./provider-error-qtZD2inE.mjs";
|
|
6
6
|
//#region packages/normalization-core/src/error-coercion.ts
|
|
7
7
|
function readProperty(value, key) {
|
|
8
8
|
try {
|
package/dist/diagnostics.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { o as ProviderRefusalReview, s as readProviderRefusalReview } from "./index-
|
|
2
|
-
import { At as extractDiagnosticError, Dt as DiagnosticErrorInfo, Et as AssistantMessageDiagnostic, Mt as isProviderRefusalAssistantError, Ot as appendAssistantMessageDiagnostic, a as AssistantMessage, jt as formatThrownValue, kt as createAssistantMessageDiagnostic } from "./types-
|
|
3
|
-
import "./types-
|
|
4
|
-
import { n as isResponsesOutputLimitToolCallError } from "./openai-responses-terminal-usage-
|
|
5
|
-
import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-
|
|
6
|
-
import { i as projectDiagnosticValue, t as DiagnosticProjectionPolicy } from "./credential-redaction-
|
|
1
|
+
import { o as ProviderRefusalReview, s as readProviderRefusalReview } from "./index-DSprYWaz.mjs";
|
|
2
|
+
import { At as extractDiagnosticError, Dt as DiagnosticErrorInfo, Et as AssistantMessageDiagnostic, Mt as isProviderRefusalAssistantError, Ot as appendAssistantMessageDiagnostic, a as AssistantMessage, jt as formatThrownValue, kt as createAssistantMessageDiagnostic } from "./types-CVYzKrMl.mjs";
|
|
3
|
+
import "./types-CBJthzJX.mjs";
|
|
4
|
+
import { n as isResponsesOutputLimitToolCallError } from "./openai-responses-terminal-usage-CpVjkqn-.mjs";
|
|
5
|
+
import { n as ProviderErrorRedactor, r as configureProviderErrorRedactor } from "./provider-error-CnaWYTRY.mjs";
|
|
6
|
+
import { i as projectDiagnosticValue, t as DiagnosticProjectionPolicy } from "./credential-redaction-XvsPf7Yi.mjs";
|
|
7
7
|
import { i as emitModelTransportError, n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./model-transport-url-BrsjjdjR.mjs";
|
|
8
8
|
//#region packages/ai/src/transports/openai-responses-stream-errors.d.ts
|
|
9
9
|
/** Resume only a response that could not have completed tools or exposed visible output. */
|
package/dist/diagnostics.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as isProviderRefusalAssistantError, i as formatThrownValue, n as createAssistantMessageDiagnostic, o as readProviderRefusalReview, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
|
|
2
|
-
import { a as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-
|
|
3
|
-
import { c as hasRetryableConnectionErrorCode, i as emitModelTransportError, l as isTransientNetworkError, m as isResponsesOutputLimitToolCallError, n as formatModelTransportDebugUrl, p as resolveResponsesOutputIdentityRetry, r as emitModelTransportDebug, s as WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, t as formatModelTransportDebugBaseUrl } from "./diagnostics-
|
|
2
|
+
import { a as projectDiagnosticValue, t as configureProviderErrorRedactor } from "./provider-error-qtZD2inE.mjs";
|
|
3
|
+
import { c as hasRetryableConnectionErrorCode, i as emitModelTransportError, l as isTransientNetworkError, m as isResponsesOutputLimitToolCallError, n as formatModelTransportDebugUrl, p as resolveResponsesOutputIdentityRetry, r as emitModelTransportDebug, s as WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, t as formatModelTransportDebugBaseUrl } from "./diagnostics-Cv7cW3pS.mjs";
|
|
4
4
|
export { WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, appendAssistantMessageDiagnostic, configureProviderErrorRedactor, createAssistantMessageDiagnostic, emitModelTransportDebug, emitModelTransportError, extractDiagnosticError, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, formatThrownValue, hasRetryableConnectionErrorCode, isProviderRefusalAssistantError, isResponsesOutputLimitToolCallError, isTransientNetworkError, projectDiagnosticValue, readProviderRefusalReview, resolveResponsesOutputIdentityRetry };
|
|
@@ -1,42 +1,19 @@
|
|
|
1
|
-
import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
1
|
//#region packages/ai/src/env-api-keys.ts
|
|
3
2
|
let nodeHelpers;
|
|
4
|
-
const dynamicImport = (specifier) => import(specifier);
|
|
5
|
-
const NODE_FS_SPECIFIER = "node:fs";
|
|
6
|
-
const NODE_OS_SPECIFIER = "node:os";
|
|
7
|
-
const NODE_PATH_SPECIFIER = "node:path";
|
|
8
|
-
function loadNodeBuiltinModule(specifier) {
|
|
9
|
-
const getBuiltinModule = typeof process !== "undefined" ? process : void 0;
|
|
10
|
-
if (typeof getBuiltinModule?.getBuiltinModule === "function") return getBuiltinModule.getBuiltinModule(specifier);
|
|
11
|
-
if (typeof __require === "function") return __require(specifier);
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
3
|
function loadNodeHelpersSync() {
|
|
15
4
|
try {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
existsSync
|
|
21
|
-
homedir
|
|
22
|
-
join
|
|
5
|
+
const { existsSync } = process.getBuiltinModule("node:fs");
|
|
6
|
+
const { homedir } = process.getBuiltinModule("node:os");
|
|
7
|
+
const { join } = process.getBuiltinModule("node:path");
|
|
8
|
+
nodeHelpers = {
|
|
9
|
+
existsSync,
|
|
10
|
+
homedir,
|
|
11
|
+
join
|
|
23
12
|
};
|
|
24
13
|
} catch {}
|
|
25
14
|
return nodeHelpers;
|
|
26
15
|
}
|
|
27
|
-
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun))
|
|
28
|
-
if (!loadNodeHelpersSync()) Promise.all([
|
|
29
|
-
dynamicImport(NODE_FS_SPECIFIER),
|
|
30
|
-
dynamicImport(NODE_OS_SPECIFIER),
|
|
31
|
-
dynamicImport(NODE_PATH_SPECIFIER)
|
|
32
|
-
]).then(([fsModule, osModule, pathModule]) => {
|
|
33
|
-
nodeHelpers = {
|
|
34
|
-
existsSync: fsModule.existsSync,
|
|
35
|
-
homedir: osModule.homedir,
|
|
36
|
-
join: pathModule.join
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}
|
|
16
|
+
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) loadNodeHelpersSync();
|
|
40
17
|
let procEnvCache = null;
|
|
41
18
|
function getProcessEnv() {
|
|
42
19
|
return typeof process === "undefined" ? void 0 : process.env;
|
|
@@ -52,9 +29,8 @@ function getProcEnv(key) {
|
|
|
52
29
|
if (procEnvCache === null) {
|
|
53
30
|
procEnvCache = /* @__PURE__ */ new Map();
|
|
54
31
|
try {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
const data = fsModule.readFileSync("/proc/self/environ", "utf-8");
|
|
32
|
+
const { readFileSync } = process.getBuiltinModule("node:fs");
|
|
33
|
+
const data = readFileSync("/proc/self/environ", "utf-8");
|
|
58
34
|
for (const entry of data.split("\0")) {
|
|
59
35
|
const idx = entry.indexOf("=");
|
|
60
36
|
if (idx > 0) procEnvCache.set(entry.slice(0, idx), entry.slice(idx + 1));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./event-stream-CzpE1g_o.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AssistantMessage, o as AssistantMessageEvent, ot as ThinkingContent, s as AssistantMessageEventStreamContract } from "./types-
|
|
1
|
+
import { a as AssistantMessage, o as AssistantMessageEvent, ot as ThinkingContent, s as AssistantMessageEventStreamContract } from "./types-CVYzKrMl.mjs";
|
|
2
2
|
//#region packages/llm-core/src/utils/event-stream.d.ts
|
|
3
3
|
/** Returns only an append whose current and previously observed snapshots still match. */
|
|
4
4
|
declare function readAssistantThinkingAppend(block: ThinkingContent, previous: string): string | undefined;
|
package/dist/event-stream.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
2
|
-
import "./event-stream-
|
|
1
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-CzpE1g_o.mjs";
|
|
2
|
+
import "./event-stream-CDpFza-M.mjs";
|
|
3
3
|
export { AssistantMessageEventStream, EventStream, createAssistantMessageEventStream };
|
package/dist/{github-copilot-request-facts-DEE6gcB9.mjs → github-copilot-request-facts-F-EmvkpW.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as hasRuntimeContextMarker } from "./types-
|
|
1
|
+
import { f as hasRuntimeContextMarker } from "./types-BXd0kI8-.mjs";
|
|
2
2
|
import "./types.mjs";
|
|
3
3
|
//#region packages/ai/src/providers/github-copilot-request-facts.ts
|
|
4
4
|
/** Request facts shared by Copilot transports; identity headers remain plugin-owned. */
|
|
@@ -1,41 +1,21 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
2
2
|
import { a as asRecord, i as asOptionalRecord, s as readStringField } from "./record-coerce-CNDovvft.mjs";
|
|
3
|
-
import { O as calculateCost, a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { n as getEnvApiKey } from "./env-api-keys-
|
|
9
|
-
import { n as transformProviderMessages, t as createAssistantOutput } from "./assistant-output-
|
|
10
|
-
import { n as buildGoogleInteractionsSimpleThinking } from "./google-shared-
|
|
11
|
-
|
|
3
|
+
import { O as calculateCost, a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-B2gk-d1H.mjs";
|
|
4
|
+
import { t as buildGuardedModelFetch } from "./host-policy-mpqGhbeM.mjs";
|
|
5
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
|
|
6
|
+
import { n as buildBaseOptions, w as stripSystemPromptCacheBoundary } from "./simple-options-BYgC6kse.mjs";
|
|
7
|
+
import { b as transportAbortError, c as failTransportStream, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, m as notifyProviderHttpResponse, w as parseJsonPreservingUnsafeIntegers } from "./transport-stream-shared-CzQlAzJH.mjs";
|
|
8
|
+
import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
|
|
9
|
+
import { n as transformProviderMessages, t as createAssistantOutput } from "./assistant-output-6iFA1nbC.mjs";
|
|
10
|
+
import { n as buildGoogleInteractionsSimpleThinking } from "./google-shared-VTcCJLW3.mjs";
|
|
11
|
+
//#region packages/ai/package.json
|
|
12
|
+
var version = "2026.10.10-beta.2";
|
|
13
|
+
//#endregion
|
|
12
14
|
//#region packages/ai/src/providers/google-interactions-request.ts
|
|
13
15
|
const DEFAULT_GOOGLE_API_BASE_URL = "https://generativelanguage.googleapis.com";
|
|
14
16
|
let packageVersionMemo;
|
|
15
17
|
function resolvePackageVersion() {
|
|
16
|
-
if (packageVersionMemo)
|
|
17
|
-
if (typeof process !== "undefined" && process.env?.OPENCLAW_VERSION) {
|
|
18
|
-
packageVersionMemo = process.env.OPENCLAW_VERSION;
|
|
19
|
-
return packageVersionMemo;
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
const require = createRequire(import.meta.url);
|
|
23
|
-
for (const candidate of [
|
|
24
|
-
"../package.json",
|
|
25
|
-
"../../package.json",
|
|
26
|
-
"../../../package.json",
|
|
27
|
-
"../../../../package.json"
|
|
28
|
-
]) try {
|
|
29
|
-
const parsed = asRecord(require(candidate));
|
|
30
|
-
const name = readStringField(parsed, "name");
|
|
31
|
-
const version = readStringField(parsed, "version");
|
|
32
|
-
if (version && (name === "openclaw" || name === "@openclaw/ai")) {
|
|
33
|
-
packageVersionMemo = version;
|
|
34
|
-
return packageVersionMemo;
|
|
35
|
-
}
|
|
36
|
-
} catch {}
|
|
37
|
-
} catch {}
|
|
38
|
-
packageVersionMemo = "0.0";
|
|
18
|
+
if (!packageVersionMemo) packageVersionMemo = typeof process !== "undefined" && process.env?.OPENCLAW_VERSION || version;
|
|
39
19
|
return packageVersionMemo;
|
|
40
20
|
}
|
|
41
21
|
function resolveGoogleApiClientHeaders(params) {
|
|
@@ -271,20 +251,19 @@ async function runGoogleInteractionsLifecycle(params) {
|
|
|
271
251
|
let buffer = "";
|
|
272
252
|
let currentBlock = null;
|
|
273
253
|
let currentBlockIndex = -1;
|
|
274
|
-
let currentToolArgs = "";
|
|
275
254
|
let latestThoughtSignature;
|
|
276
255
|
let latestUsage;
|
|
277
256
|
const endCurrentBlock = () => {
|
|
278
257
|
if (!currentBlock) return;
|
|
279
258
|
if (currentBlock.type === "toolCall") {
|
|
280
|
-
if (
|
|
259
|
+
if (currentBlock.partialJson?.trim()) currentBlock.arguments = parseTerminalToolCallArguments(currentBlock.partialJson);
|
|
260
|
+
delete currentBlock.partialJson;
|
|
281
261
|
stream.push({
|
|
282
262
|
type: "toolcall_end",
|
|
283
263
|
contentIndex: currentBlockIndex,
|
|
284
264
|
toolCall: currentBlock,
|
|
285
265
|
partial: output
|
|
286
266
|
});
|
|
287
|
-
currentToolArgs = "";
|
|
288
267
|
} else {
|
|
289
268
|
if (currentBlock.type === "thinking") {
|
|
290
269
|
if (!currentBlock.thinkingSignature && latestThoughtSignature) currentBlock.thinkingSignature = latestThoughtSignature;
|
|
@@ -345,9 +324,9 @@ async function runGoogleInteractionsLifecycle(params) {
|
|
|
345
324
|
type: "toolCall",
|
|
346
325
|
id: readStringField(source, "id") ?? nextToolCallId(name),
|
|
347
326
|
name,
|
|
348
|
-
arguments: args
|
|
327
|
+
arguments: args,
|
|
328
|
+
partialJson: Object.keys(args).length > 0 ? JSON.stringify(args) : ""
|
|
349
329
|
};
|
|
350
|
-
currentToolArgs = Object.keys(args).length > 0 ? JSON.stringify(args) : "";
|
|
351
330
|
output.content.push(toolCall);
|
|
352
331
|
stream.push({
|
|
353
332
|
type: "toolcall_start",
|
|
@@ -360,16 +339,14 @@ async function runGoogleInteractionsLifecycle(params) {
|
|
|
360
339
|
let sawCompletion = false;
|
|
361
340
|
while (!streamDone) {
|
|
362
341
|
const { done, value } = await reader.read();
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const dataStr = frame.split(/\r\n|\r|\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5)).join("\n").trim();
|
|
372
|
-
if (!dataStr) continue;
|
|
342
|
+
if (done) break;
|
|
343
|
+
buffer += decoder.decode(value, { stream: true });
|
|
344
|
+
const lines = buffer.split("\n");
|
|
345
|
+
buffer = lines.pop() ?? "";
|
|
346
|
+
for (const line of lines) {
|
|
347
|
+
const trimmed = line.trim();
|
|
348
|
+
if (!trimmed || !trimmed.startsWith("data:")) continue;
|
|
349
|
+
const dataStr = trimmed.slice(5).trim();
|
|
373
350
|
if (dataStr === "[DONE]") {
|
|
374
351
|
streamDone = true;
|
|
375
352
|
break;
|
|
@@ -377,8 +354,8 @@ async function runGoogleInteractionsLifecycle(params) {
|
|
|
377
354
|
let event;
|
|
378
355
|
try {
|
|
379
356
|
event = asRecord(parseJsonPreservingUnsafeIntegers(dataStr));
|
|
380
|
-
} catch
|
|
381
|
-
|
|
357
|
+
} catch {
|
|
358
|
+
continue;
|
|
382
359
|
}
|
|
383
360
|
const eventType = event.event_type || event.type;
|
|
384
361
|
logGoogleInteractionsDebug("stream event", { eventType: typeof eventType === "string" ? eventType : "unknown" });
|
|
@@ -422,7 +399,7 @@ async function runGoogleInteractionsLifecycle(params) {
|
|
|
422
399
|
if (streamedToolName && (!currentBlock.name || currentBlock.name === "tool")) currentBlock.name = streamedToolName;
|
|
423
400
|
const streamedToolCallId = readStringField(delta, "id");
|
|
424
401
|
if (streamedToolCallId) currentBlock.id = streamedToolCallId;
|
|
425
|
-
|
|
402
|
+
currentBlock.partialJson = (currentBlock.partialJson ?? "") + argText;
|
|
426
403
|
stream.push({
|
|
427
404
|
type: "toolcall_delta",
|
|
428
405
|
contentIndex: currentBlockIndex,
|
|
@@ -454,6 +431,7 @@ async function runGoogleInteractionsLifecycle(params) {
|
|
|
454
431
|
const outputTokens = candidatesTokens + thoughtTokens;
|
|
455
432
|
const totalTokens = Number(usage.total_tokens ?? promptTokens + outputTokens + toolUseTokens);
|
|
456
433
|
output.usage = {
|
|
434
|
+
usageReport: { state: typeof usage.total_input_tokens === "number" && typeof usage.total_output_tokens === "number" ? "available" : "unavailable" },
|
|
457
435
|
input: Math.max(0, promptTokens - cacheRead) + toolUseTokens,
|
|
458
436
|
output: outputTokens,
|
|
459
437
|
cacheRead,
|
|
@@ -493,6 +471,7 @@ async function runGoogleInteractionsLifecycle(params) {
|
|
|
493
471
|
stream.end();
|
|
494
472
|
} catch (error) {
|
|
495
473
|
const failure = options?.signal?.aborted ? transportAbortError(options.signal) : error;
|
|
474
|
+
for (const block of output.content) if (block.type === "toolCall") delete block.partialJson;
|
|
496
475
|
failTransportStream({
|
|
497
476
|
stream,
|
|
498
477
|
output,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { r as appendAssistantThinking } from "./event-stream-X2gmsUWv.mjs";
|
|
2
|
-
import { N as isImageWithMediaPayload, O as calculateCost } from "./host-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { N as isImageWithMediaPayload, O as calculateCost } from "./host-B2gk-d1H.mjs";
|
|
3
|
+
import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
|
|
4
|
+
import { r as sortPromptCacheToolsByName } from "./prompt-cache-stability-D_MeCQFI.mjs";
|
|
5
|
+
import { f as extractToolResultText, l as describeToolResultMediaPlaceholder } from "./simple-options-BYgC6kse.mjs";
|
|
6
|
+
import { a as createEmptyTransportUsage, b as transportAbortError, r as coerceTransportToolCallArguments, v as sanitizeTransportPayloadText } from "./transport-stream-shared-CzQlAzJH.mjs";
|
|
5
7
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-CfMuh5cC.mjs";
|
|
6
8
|
import { isGoogleGemini4Model } from "./internal/google-model-family.mjs";
|
|
7
9
|
//#region packages/ai/src/transports/google-thinking-level.ts
|
|
@@ -99,6 +101,7 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
99
101
|
const outputTokens = knownUsage.candidatesTokenCount + knownUsage.thoughtsTokenCount;
|
|
100
102
|
params.output.usage = {
|
|
101
103
|
...createEmptyTransportUsage(),
|
|
104
|
+
usageReport: { state: sawTerminalReason || chunk.candidates?.some((candidate) => candidate.finishReason && candidate.finishReason !== "FINISH_REASON_UNSPECIFIED") ? "available" : "unavailable" },
|
|
102
105
|
input: Math.max(0, promptTokens - cacheRead) + toolUsePromptTokens,
|
|
103
106
|
output: outputTokens,
|
|
104
107
|
cacheRead,
|
|
@@ -191,11 +194,18 @@ async function consumeGoogleGenerateContentStream(params) {
|
|
|
191
194
|
contentIndex: blockIndex(),
|
|
192
195
|
partial: params.output
|
|
193
196
|
});
|
|
197
|
+
const streamingCall = {
|
|
198
|
+
...toolCall,
|
|
199
|
+
partialJson: JSON.stringify(toolCall.arguments)
|
|
200
|
+
};
|
|
194
201
|
params.stream.push({
|
|
195
202
|
type: "toolcall_delta",
|
|
196
203
|
contentIndex: blockIndex(),
|
|
197
|
-
delta:
|
|
198
|
-
partial:
|
|
204
|
+
delta: streamingCall.partialJson,
|
|
205
|
+
partial: {
|
|
206
|
+
...params.output,
|
|
207
|
+
content: [...params.output.content.slice(0, -1), streamingCall]
|
|
208
|
+
}
|
|
199
209
|
});
|
|
200
210
|
params.stream.push({
|
|
201
211
|
type: "toolcall_end",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
2
|
-
import { a as resolveAiTransportHeaderSentinels } from "./host-
|
|
3
|
-
import { n as buildManagedModelFetch } from "./host-policy-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
7
|
-
import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-
|
|
2
|
+
import { a as resolveAiTransportHeaderSentinels } from "./host-B2gk-d1H.mjs";
|
|
3
|
+
import { n as buildManagedModelFetch } from "./host-policy-mpqGhbeM.mjs";
|
|
4
|
+
import { n as buildBaseOptions } from "./simple-options-BYgC6kse.mjs";
|
|
5
|
+
import { f as mergeTransportHeaders } from "./transport-stream-shared-CzQlAzJH.mjs";
|
|
6
|
+
import { t as createAssistantOutput } from "./assistant-output-6iFA1nbC.mjs";
|
|
7
|
+
import { i as runGoogleGenerateContentLifecycle, r as buildGoogleSimpleThinking, t as buildGoogleGenerateContentParams } from "./google-shared-VTcCJLW3.mjs";
|
|
8
8
|
import { ResourceScope } from "@google/genai";
|
|
9
9
|
//#region packages/ai/src/providers/google-http-options.ts
|
|
10
10
|
function buildGoogleHttpOptions(model, optionsHeaders, profile) {
|