@librechat/agents 3.6.9 → 3.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/agents/AgentContext.cjs +46 -39
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/agents/projection.cjs +2 -2
- package/dist/cjs/agents/projection.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +28 -18
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +87 -16
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +10 -0
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +14 -0
- package/dist/cjs/messages/alternation.cjs +125 -20
- package/dist/cjs/messages/alternation.cjs.map +1 -1
- package/dist/cjs/messages/core.cjs +195 -18
- package/dist/cjs/messages/core.cjs.map +1 -1
- package/dist/cjs/messages/format.cjs +488 -118
- package/dist/cjs/messages/format.cjs.map +1 -1
- package/dist/cjs/messages/handoffCue.cjs +3 -2
- package/dist/cjs/messages/handoffCue.cjs.map +1 -1
- package/dist/cjs/messages/index.cjs +1 -0
- package/dist/cjs/messages/injected.cjs +5 -2
- package/dist/cjs/messages/injected.cjs.map +1 -1
- package/dist/cjs/messages/provenance.cjs +411 -0
- package/dist/cjs/messages/provenance.cjs.map +1 -0
- package/dist/cjs/messages/prune.cjs +18 -13
- package/dist/cjs/messages/prune.cjs.map +1 -1
- package/dist/cjs/messages/toolResultTypes.cjs +663 -0
- package/dist/cjs/messages/toolResultTypes.cjs.map +1 -0
- package/dist/cjs/run.cjs +7 -4
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +21 -4
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/CallerCapabilities.cjs +48 -0
- package/dist/cjs/tools/CallerCapabilities.cjs.map +1 -0
- package/dist/cjs/tools/ProgrammaticCallerPolicy.cjs +34 -0
- package/dist/cjs/tools/ProgrammaticCallerPolicy.cjs.map +1 -0
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +21 -4
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +25 -24
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs +12 -4
- package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +13 -4
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs +47 -11
- package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
- package/dist/cjs/tools/ptcTimeout.cjs.map +1 -1
- package/dist/cjs/utils/toolContent.cjs +2 -2
- package/dist/cjs/utils/toolContent.cjs.map +1 -1
- package/dist/esm/agents/AgentContext.mjs +46 -39
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/agents/projection.mjs +2 -2
- package/dist/esm/agents/projection.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +30 -20
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +87 -16
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +10 -0
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/main.mjs +4 -3
- package/dist/esm/messages/alternation.mjs +125 -20
- package/dist/esm/messages/alternation.mjs.map +1 -1
- package/dist/esm/messages/core.mjs +196 -19
- package/dist/esm/messages/core.mjs.map +1 -1
- package/dist/esm/messages/format.mjs +488 -119
- package/dist/esm/messages/format.mjs.map +1 -1
- package/dist/esm/messages/handoffCue.mjs +3 -2
- package/dist/esm/messages/handoffCue.mjs.map +1 -1
- package/dist/esm/messages/index.mjs +1 -0
- package/dist/esm/messages/injected.mjs +5 -2
- package/dist/esm/messages/injected.mjs.map +1 -1
- package/dist/esm/messages/provenance.mjs +401 -0
- package/dist/esm/messages/provenance.mjs.map +1 -0
- package/dist/esm/messages/prune.mjs +18 -13
- package/dist/esm/messages/prune.mjs.map +1 -1
- package/dist/esm/messages/toolResultTypes.mjs +657 -0
- package/dist/esm/messages/toolResultTypes.mjs.map +1 -0
- package/dist/esm/run.mjs +7 -4
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs +21 -4
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/CallerCapabilities.mjs +45 -0
- package/dist/esm/tools/CallerCapabilities.mjs.map +1 -0
- package/dist/esm/tools/ProgrammaticCallerPolicy.mjs +32 -0
- package/dist/esm/tools/ProgrammaticCallerPolicy.mjs.map +1 -0
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +21 -4
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +25 -24
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs +14 -6
- package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +15 -6
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/local/resolveLocalExecutionTools.mjs +47 -12
- package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
- package/dist/esm/tools/ptcTimeout.mjs.map +1 -1
- package/dist/esm/utils/toolContent.mjs +2 -2
- package/dist/esm/utils/toolContent.mjs.map +1 -1
- package/dist/types/agents/AgentContext.d.ts +8 -13
- package/dist/types/agents/projection.d.ts +3 -1
- package/dist/types/graphs/Graph.d.ts +1 -1
- package/dist/types/llm/openai/index.d.ts +20 -0
- package/dist/types/messages/format.d.ts +5 -0
- package/dist/types/messages/index.d.ts +1 -0
- package/dist/types/messages/provenance.d.ts +85 -0
- package/dist/types/messages/toolResultTypes.d.ts +33 -0
- package/dist/types/tools/CallerCapabilities.d.ts +12 -0
- package/dist/types/tools/ProgrammaticCallerPolicy.d.ts +20 -0
- package/dist/types/tools/ToolNode.d.ts +4 -7
- package/dist/types/tools/local/resolveLocalExecutionTools.d.ts +4 -0
- package/dist/types/tools/ptcTimeout.d.ts +8 -0
- package/dist/types/types/graph.d.ts +3 -1
- package/dist/types/types/tools.d.ts +13 -2
- package/package.json +1 -1
- package/src/agents/AgentContext.ts +109 -67
- package/src/agents/projection.ts +9 -1
- package/src/graphs/Graph.ts +56 -23
- package/src/graphs/MultiAgentGraph.ts +175 -33
- package/src/llm/openai/index.ts +43 -0
- package/src/messages/alternation.ts +217 -34
- package/src/messages/core.ts +358 -38
- package/src/messages/format.ts +958 -137
- package/src/messages/handoffCue.ts +7 -4
- package/src/messages/index.ts +1 -0
- package/src/messages/injected.ts +9 -6
- package/src/messages/provenance.ts +897 -0
- package/src/messages/prune.ts +28 -10
- package/src/messages/toolResultTypes.ts +1174 -0
- package/src/run.ts +9 -4
- package/src/tools/BashProgrammaticToolCalling.ts +46 -12
- package/src/tools/CallerCapabilities.ts +78 -0
- package/src/tools/ProgrammaticCallerPolicy.ts +97 -0
- package/src/tools/ProgrammaticToolCalling.ts +41 -7
- package/src/tools/ToolNode.ts +70 -52
- package/src/tools/cloudflare/CloudflareProgrammaticToolCalling.ts +24 -26
- package/src/tools/local/LocalProgrammaticToolCalling.ts +28 -23
- package/src/tools/local/resolveLocalExecutionTools.ts +132 -13
- package/src/tools/ptcTimeout.ts +6 -0
- package/src/types/graph.ts +3 -0
- package/src/types/tools.ts +14 -3
- package/src/utils/toolContent.ts +2 -2
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
let node_util_types = require("node:util/types");
|
|
2
|
+
const PROVIDER_TOOL_PAIRING_MAX_OUTER_PARTS = 4096;
|
|
3
|
+
const TOOL_CALL_KINDS = ["tool"];
|
|
4
|
+
const SERVER_CALL_KINDS = ["server"];
|
|
5
|
+
const ANTHROPIC_SERVER_CALL_KINDS = ["anthropic-server"];
|
|
6
|
+
const MCP_CALL_KINDS = ["mcp"];
|
|
7
|
+
const GOOGLE_CALL_KINDS = ["google"];
|
|
8
|
+
const BEDROCK_CALL_KINDS = ["bedrock", "tool"];
|
|
9
|
+
const ADVISOR_TOOL_NAMES = ["advisor"];
|
|
10
|
+
const BASH_TOOL_NAMES = ["bash_code_execution"];
|
|
11
|
+
const CODE_EXECUTION_TOOL_NAMES = ["code_execution"];
|
|
12
|
+
const TEXT_EDITOR_TOOL_NAMES = ["text_editor_code_execution"];
|
|
13
|
+
const TOOL_SEARCH_TOOL_NAMES = ["tool_search_tool_regex", "tool_search_tool_bm25"];
|
|
14
|
+
const WEB_FETCH_TOOL_NAMES = ["web_fetch"];
|
|
15
|
+
const WEB_SEARCH_TOOL_NAMES = ["web_search"];
|
|
16
|
+
const ANTHROPIC_SERVER_TOOL_ID_PREFIX = "srvtoolu_";
|
|
17
|
+
function stringSet(values) {
|
|
18
|
+
return new Set(values);
|
|
19
|
+
}
|
|
20
|
+
const GOOGLE_CODE_EXECUTION_OUTCOMES = stringSet([
|
|
21
|
+
"OUTCOME_DEADLINE_EXCEEDED",
|
|
22
|
+
"OUTCOME_FAILED",
|
|
23
|
+
"OUTCOME_OK",
|
|
24
|
+
"OUTCOME_UNSPECIFIED",
|
|
25
|
+
"outcome_deadline_exceeded",
|
|
26
|
+
"outcome_failed",
|
|
27
|
+
"outcome_ok",
|
|
28
|
+
"outcome_unspecified"
|
|
29
|
+
]);
|
|
30
|
+
const PROVIDER_TOOL_CALL_KINDS = stringSet([
|
|
31
|
+
"anthropic-server",
|
|
32
|
+
"bedrock",
|
|
33
|
+
"google",
|
|
34
|
+
"mcp",
|
|
35
|
+
"server",
|
|
36
|
+
"tool"
|
|
37
|
+
]);
|
|
38
|
+
const ANTHROPIC_SERVER_TOOL_NAMES = stringSet([
|
|
39
|
+
...ADVISOR_TOOL_NAMES,
|
|
40
|
+
...BASH_TOOL_NAMES,
|
|
41
|
+
...CODE_EXECUTION_TOOL_NAMES,
|
|
42
|
+
...TEXT_EDITOR_TOOL_NAMES,
|
|
43
|
+
...TOOL_SEARCH_TOOL_NAMES,
|
|
44
|
+
...WEB_FETCH_TOOL_NAMES,
|
|
45
|
+
...WEB_SEARCH_TOOL_NAMES
|
|
46
|
+
]);
|
|
47
|
+
function getRecord(value) {
|
|
48
|
+
if (value == null || typeof value !== "object") return;
|
|
49
|
+
try {
|
|
50
|
+
if ((0, node_util_types.isProxy)(value) || Array.isArray(value)) return;
|
|
51
|
+
const prototype = Object.getPrototypeOf(value);
|
|
52
|
+
return prototype === Object.prototype || prototype === null ? value : void 0;
|
|
53
|
+
} catch {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function getPropertyContainer(value) {
|
|
58
|
+
if (value == null || typeof value !== "object") return;
|
|
59
|
+
try {
|
|
60
|
+
return !(0, node_util_types.isProxy)(value) && !Array.isArray(value) ? value : void 0;
|
|
61
|
+
} catch {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function getArray(value) {
|
|
66
|
+
if (value == null || typeof value !== "object") return;
|
|
67
|
+
try {
|
|
68
|
+
return !(0, node_util_types.isProxy)(value) && Array.isArray(value) ? value : void 0;
|
|
69
|
+
} catch {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function readDataProperty(record, key) {
|
|
74
|
+
try {
|
|
75
|
+
const descriptor = Object.getOwnPropertyDescriptor(record, key);
|
|
76
|
+
if (descriptor == null || descriptor.enumerable !== true || !("value" in descriptor)) return { found: false };
|
|
77
|
+
return {
|
|
78
|
+
found: true,
|
|
79
|
+
value: descriptor.value
|
|
80
|
+
};
|
|
81
|
+
} catch {
|
|
82
|
+
return { found: false };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function hasOnlyOwnDataProperties(record, allowed) {
|
|
86
|
+
try {
|
|
87
|
+
const keys = Reflect.ownKeys(record);
|
|
88
|
+
if (keys.length > allowed.length) return false;
|
|
89
|
+
for (let index = 0; index < keys.length; index++) {
|
|
90
|
+
const key = keys[index];
|
|
91
|
+
if (typeof key !== "string" || !allowed.includes(key)) return false;
|
|
92
|
+
const descriptor = Object.getOwnPropertyDescriptor(record, key);
|
|
93
|
+
if (descriptor == null || descriptor.enumerable !== true || !("value" in descriptor)) return false;
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
} catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function getBoundedDataArray(value, maxEntries, budget) {
|
|
101
|
+
const array = getArray(value);
|
|
102
|
+
if (array == null || array.length > maxEntries || budget != null && array.length > budget.remaining) return;
|
|
103
|
+
if (budget != null) budget.remaining -= array.length;
|
|
104
|
+
for (let index = 0; index < array.length; index++) {
|
|
105
|
+
let descriptor;
|
|
106
|
+
try {
|
|
107
|
+
descriptor = Object.getOwnPropertyDescriptor(array, String(index));
|
|
108
|
+
} catch {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (descriptor == null || descriptor.enumerable !== true || !("value" in descriptor)) return;
|
|
112
|
+
}
|
|
113
|
+
return array;
|
|
114
|
+
}
|
|
115
|
+
function getBoundedProviderPairingArray(value) {
|
|
116
|
+
return getBoundedDataArray(value, PROVIDER_TOOL_PAIRING_MAX_OUTER_PARTS);
|
|
117
|
+
}
|
|
118
|
+
function getBoundedProviderPairingArrayProperty(value, key) {
|
|
119
|
+
const record = getPropertyContainer(value);
|
|
120
|
+
if (record == null) return;
|
|
121
|
+
const property = readDataProperty(record, key);
|
|
122
|
+
return property.found ? getBoundedProviderPairingArray(property.value) : void 0;
|
|
123
|
+
}
|
|
124
|
+
function readString(record, key, allowEmpty = false) {
|
|
125
|
+
const property = readDataProperty(record, key);
|
|
126
|
+
return property.found && typeof property.value === "string" && (allowEmpty || property.value.length > 0) ? property.value : void 0;
|
|
127
|
+
}
|
|
128
|
+
function isBoundedProviderPairingString(value, allowEmpty = false) {
|
|
129
|
+
return typeof value === "string" && (allowEmpty || value.length > 0) && value.length <= 512;
|
|
130
|
+
}
|
|
131
|
+
function readPairingString(record, key, allowEmpty = false) {
|
|
132
|
+
const property = readDataProperty(record, key);
|
|
133
|
+
return property.found && isBoundedProviderPairingString(property.value, allowEmpty) ? property.value : void 0;
|
|
134
|
+
}
|
|
135
|
+
function hasRequiredDataProperties(record, keys) {
|
|
136
|
+
if (keys == null) return true;
|
|
137
|
+
for (let index = 0; index < keys.length; index++) {
|
|
138
|
+
const property = readDataProperty(record, keys[index]);
|
|
139
|
+
if (!property.found || property.value === void 0) return false;
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
function hasOptionalNullableString(record, key) {
|
|
144
|
+
const property = readDataProperty(record, key);
|
|
145
|
+
return !property.found || property.value === null || typeof property.value === "string";
|
|
146
|
+
}
|
|
147
|
+
function isCacheControl(value) {
|
|
148
|
+
if (value == null) return true;
|
|
149
|
+
const record = getRecord(value);
|
|
150
|
+
if (record == null || !hasOnlyOwnDataProperties(record, ["type", "ttl"]) || readString(record, "type") !== "ephemeral") return false;
|
|
151
|
+
const ttl = readDataProperty(record, "ttl");
|
|
152
|
+
return !ttl.found || ttl.value === null || ttl.value === "5m" || ttl.value === "1h";
|
|
153
|
+
}
|
|
154
|
+
function hasValidCacheControlProperty(record) {
|
|
155
|
+
const property = readDataProperty(record, "cache_control");
|
|
156
|
+
return !property.found || isCacheControl(property.value);
|
|
157
|
+
}
|
|
158
|
+
function isServerToolCaller(value) {
|
|
159
|
+
const record = getRecord(value);
|
|
160
|
+
if (record == null) return false;
|
|
161
|
+
const type = readString(record, "type");
|
|
162
|
+
if (type === "direct") return hasOnlyOwnDataProperties(record, ["type"]);
|
|
163
|
+
return (type === "code_execution_20250825" || type === "code_execution_20260120") && hasOnlyOwnDataProperties(record, ["type", "tool_id"]) && readPairingString(record, "tool_id") != null;
|
|
164
|
+
}
|
|
165
|
+
function hasValidCallerProperty(record) {
|
|
166
|
+
const property = readDataProperty(record, "caller");
|
|
167
|
+
return !property.found || isServerToolCaller(property.value);
|
|
168
|
+
}
|
|
169
|
+
function hasValidProviderMetadata(record) {
|
|
170
|
+
const id = readDataProperty(record, "id");
|
|
171
|
+
if (id.found && !isBoundedProviderPairingString(id.value)) return false;
|
|
172
|
+
const agentId = readDataProperty(record, "agentId");
|
|
173
|
+
if (agentId.found && !isBoundedProviderPairingString(agentId.value)) return false;
|
|
174
|
+
const index = readDataProperty(record, "index");
|
|
175
|
+
if (index.found && !(typeof index.value === "number" && Number.isSafeInteger(index.value) || isBoundedProviderPairingString(index.value))) return false;
|
|
176
|
+
const groupId = readDataProperty(record, "groupId");
|
|
177
|
+
if (groupId.found && !(typeof groupId.value === "number" && Number.isFinite(groupId.value))) return false;
|
|
178
|
+
const thought = readDataProperty(record, "thought");
|
|
179
|
+
if (thought.found && typeof thought.value !== "boolean") return false;
|
|
180
|
+
const signature = readDataProperty(record, "thoughtSignature");
|
|
181
|
+
return !signature.found || isBoundedProviderPairingString(signature.value, true);
|
|
182
|
+
}
|
|
183
|
+
const ANTHROPIC_STRUCTURED_RESULT_TOOL_NAMES = {
|
|
184
|
+
advisor_tool_result: ADVISOR_TOOL_NAMES,
|
|
185
|
+
bash_code_execution_tool_result: BASH_TOOL_NAMES,
|
|
186
|
+
code_execution_tool_result: CODE_EXECUTION_TOOL_NAMES,
|
|
187
|
+
text_editor_code_execution_tool_result: TEXT_EDITOR_TOOL_NAMES,
|
|
188
|
+
tool_search_tool_result: TOOL_SEARCH_TOOL_NAMES,
|
|
189
|
+
web_fetch_tool_result: WEB_FETCH_TOOL_NAMES
|
|
190
|
+
};
|
|
191
|
+
function isOpaqueBoundedArray(value) {
|
|
192
|
+
const array = getArray(value);
|
|
193
|
+
return array != null && array.length <= 256;
|
|
194
|
+
}
|
|
195
|
+
function isOpaqueStringOrBoundedArray(value) {
|
|
196
|
+
return typeof value === "string" || isOpaqueBoundedArray(value);
|
|
197
|
+
}
|
|
198
|
+
function isWebSearchResult(value) {
|
|
199
|
+
const record = getRecord(value);
|
|
200
|
+
return record != null && hasOnlyOwnDataProperties(record, [
|
|
201
|
+
"type",
|
|
202
|
+
"encrypted_content",
|
|
203
|
+
"title",
|
|
204
|
+
"url",
|
|
205
|
+
"page_age"
|
|
206
|
+
]) && readString(record, "type") === "web_search_result" && readString(record, "encrypted_content", true) != null && readString(record, "title", true) != null && readString(record, "url") != null && hasOptionalNullableString(record, "page_age");
|
|
207
|
+
}
|
|
208
|
+
function isWireWebSearchContent(value, budget) {
|
|
209
|
+
const error = getRecord(value);
|
|
210
|
+
if (error != null) return hasOnlyOwnDataProperties(error, ["type", "error_code"]) && readString(error, "type") === "web_search_tool_result_error" && readString(error, "error_code") != null;
|
|
211
|
+
const results = getBoundedDataArray(value, 256, budget);
|
|
212
|
+
if (results == null) return false;
|
|
213
|
+
for (let index = 0; index < results.length; index++) if (!isWebSearchResult(results[index])) return false;
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
function hasStructurallyValidAnthropicWebSearchResultContent(part) {
|
|
217
|
+
const record = getRecord(part);
|
|
218
|
+
if (record == null || readPairingString(record, "tool_use_id") == null) return false;
|
|
219
|
+
const content = readDataProperty(record, "content");
|
|
220
|
+
return content.found && isWireWebSearchContent(content.value, { remaining: 4096 });
|
|
221
|
+
}
|
|
222
|
+
function isGoogleCodeExecutionResult(record) {
|
|
223
|
+
const nested = readDataProperty(record, "codeExecutionResult");
|
|
224
|
+
const result = nested.found ? getRecord(nested.value) : void 0;
|
|
225
|
+
const outcome = result == null ? void 0 : readString(result, "outcome");
|
|
226
|
+
return result != null && hasOnlyOwnDataProperties(result, ["outcome", "output"]) && outcome != null && GOOGLE_CODE_EXECUTION_OUTCOMES.has(outcome) && readString(result, "output", true) != null;
|
|
227
|
+
}
|
|
228
|
+
function getGoogleToolResponseDescriptor(record, type) {
|
|
229
|
+
const nested = readDataProperty(record, "toolResponse");
|
|
230
|
+
const response = nested.found ? getRecord(nested.value) : void 0;
|
|
231
|
+
if (response == null) return;
|
|
232
|
+
const toolCallId = readPairingString(response, "id");
|
|
233
|
+
const responsePayload = readDataProperty(response, "response");
|
|
234
|
+
const resultPayload = readDataProperty(response, "result");
|
|
235
|
+
if (toolCallId == null) return;
|
|
236
|
+
if (responsePayload.found && responsePayload.value !== void 0 && !resultPayload.found && hasOnlyOwnDataProperties(response, [
|
|
237
|
+
"id",
|
|
238
|
+
"name",
|
|
239
|
+
"response"
|
|
240
|
+
])) {
|
|
241
|
+
const name = readPairingString(response, "name");
|
|
242
|
+
return name == null ? void 0 : {
|
|
243
|
+
type,
|
|
244
|
+
toolCallId,
|
|
245
|
+
compatibleCallKinds: GOOGLE_CALL_KINDS,
|
|
246
|
+
expectedToolNames: [name]
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (resultPayload.found && resultPayload.value !== void 0 && !responsePayload.found && hasOnlyOwnDataProperties(response, [
|
|
250
|
+
"id",
|
|
251
|
+
"toolType",
|
|
252
|
+
"result"
|
|
253
|
+
]) && readPairingString(response, "toolType") != null) return {
|
|
254
|
+
type,
|
|
255
|
+
toolCallId,
|
|
256
|
+
compatibleCallKinds: GOOGLE_CALL_KINDS
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function getBedrockDescriptor(record, type) {
|
|
260
|
+
const nested = readDataProperty(record, "toolResult");
|
|
261
|
+
const result = nested.found ? getRecord(nested.value) : void 0;
|
|
262
|
+
if (result == null || !hasOnlyOwnDataProperties(result, [
|
|
263
|
+
"toolUseId",
|
|
264
|
+
"content",
|
|
265
|
+
"status",
|
|
266
|
+
"type"
|
|
267
|
+
])) return;
|
|
268
|
+
const toolCallId = readPairingString(result, "toolUseId");
|
|
269
|
+
const content = readDataProperty(result, "content");
|
|
270
|
+
const status = readDataProperty(result, "status");
|
|
271
|
+
const nestedType = readDataProperty(result, "type");
|
|
272
|
+
if (toolCallId == null || !content.found || !isOpaqueBoundedArray(content.value) || status.found && status.value !== "success" && status.value !== "error" || nestedType.found && typeof nestedType.value !== "string") return;
|
|
273
|
+
return {
|
|
274
|
+
type,
|
|
275
|
+
toolCallId,
|
|
276
|
+
compatibleCallKinds: BEDROCK_CALL_KINDS,
|
|
277
|
+
allowHumanMessagePairing: true
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
const ANTHROPIC_RESULT_FIELDS = [
|
|
281
|
+
"type",
|
|
282
|
+
"tool_use_id",
|
|
283
|
+
"content",
|
|
284
|
+
"cache_control"
|
|
285
|
+
];
|
|
286
|
+
const ANTHROPIC_GENERIC_RESULT_FIELDS = [...ANTHROPIC_RESULT_FIELDS, "is_error"];
|
|
287
|
+
const ANTHROPIC_SERVER_RESULT_FIELDS = [...ANTHROPIC_RESULT_FIELDS, "caller"];
|
|
288
|
+
const LOCAL_RESULT_METADATA_FIELDS = [
|
|
289
|
+
"id",
|
|
290
|
+
"index",
|
|
291
|
+
"agentId",
|
|
292
|
+
"groupId"
|
|
293
|
+
];
|
|
294
|
+
const TOOL_RESULT_ENVELOPE_FIELDS = {
|
|
295
|
+
advisor_tool_result: ANTHROPIC_RESULT_FIELDS,
|
|
296
|
+
bash_code_execution_tool_result: ANTHROPIC_RESULT_FIELDS,
|
|
297
|
+
code_execution_tool_result: ANTHROPIC_RESULT_FIELDS,
|
|
298
|
+
mcp_tool_result: ANTHROPIC_GENERIC_RESULT_FIELDS,
|
|
299
|
+
text_editor_code_execution_tool_result: ANTHROPIC_RESULT_FIELDS,
|
|
300
|
+
tool_search_tool_result: ANTHROPIC_RESULT_FIELDS,
|
|
301
|
+
tool_result: ANTHROPIC_GENERIC_RESULT_FIELDS,
|
|
302
|
+
web_fetch_tool_result: ANTHROPIC_SERVER_RESULT_FIELDS,
|
|
303
|
+
web_search_tool_result: ANTHROPIC_SERVER_RESULT_FIELDS,
|
|
304
|
+
server_tool_call_result: [
|
|
305
|
+
"type",
|
|
306
|
+
"toolCallId",
|
|
307
|
+
"status",
|
|
308
|
+
"output",
|
|
309
|
+
...LOCAL_RESULT_METADATA_FIELDS
|
|
310
|
+
],
|
|
311
|
+
server_tool_result: [
|
|
312
|
+
"type",
|
|
313
|
+
"tool_call_id",
|
|
314
|
+
"status",
|
|
315
|
+
"output",
|
|
316
|
+
...LOCAL_RESULT_METADATA_FIELDS
|
|
317
|
+
],
|
|
318
|
+
codeExecutionResult: [
|
|
319
|
+
"type",
|
|
320
|
+
"codeExecutionResult",
|
|
321
|
+
"agentId",
|
|
322
|
+
"groupId"
|
|
323
|
+
],
|
|
324
|
+
toolResponse: [
|
|
325
|
+
"type",
|
|
326
|
+
"toolResponse",
|
|
327
|
+
"thought",
|
|
328
|
+
"thoughtSignature",
|
|
329
|
+
"agentId",
|
|
330
|
+
"groupId"
|
|
331
|
+
],
|
|
332
|
+
toolResult: [
|
|
333
|
+
"type",
|
|
334
|
+
"toolResult",
|
|
335
|
+
"agentId",
|
|
336
|
+
"groupId"
|
|
337
|
+
]
|
|
338
|
+
};
|
|
339
|
+
function anthropicDescriptor(record, type, expectedToolNames) {
|
|
340
|
+
const toolCallId = readPairingString(record, "tool_use_id");
|
|
341
|
+
const content = readDataProperty(record, "content");
|
|
342
|
+
return toolCallId != null && content.found && getRecord(content.value) != null ? {
|
|
343
|
+
type,
|
|
344
|
+
toolCallId,
|
|
345
|
+
compatibleCallKinds: ANTHROPIC_SERVER_CALL_KINDS,
|
|
346
|
+
expectedToolNames
|
|
347
|
+
} : void 0;
|
|
348
|
+
}
|
|
349
|
+
function getProviderToolResultPartDescriptor(part) {
|
|
350
|
+
const record = getRecord(part);
|
|
351
|
+
if (record == null) return;
|
|
352
|
+
const type = readString(record, "type");
|
|
353
|
+
const allowedFields = type == null ? void 0 : TOOL_RESULT_ENVELOPE_FIELDS[type];
|
|
354
|
+
if (type == null || allowedFields == null || !hasOnlyOwnDataProperties(record, allowedFields) || !hasValidProviderMetadata(record) || !hasValidCacheControlProperty(record) || !hasValidCallerProperty(record)) return;
|
|
355
|
+
const structuredToolNames = ANTHROPIC_STRUCTURED_RESULT_TOOL_NAMES[type];
|
|
356
|
+
if (structuredToolNames != null) return anthropicDescriptor(record, type, structuredToolNames);
|
|
357
|
+
if (type === "web_search_tool_result") {
|
|
358
|
+
const toolCallId = readPairingString(record, "tool_use_id");
|
|
359
|
+
const content = readDataProperty(record, "content");
|
|
360
|
+
return toolCallId != null && content.found && (getRecord(content.value) != null || isOpaqueBoundedArray(content.value)) ? {
|
|
361
|
+
type,
|
|
362
|
+
toolCallId,
|
|
363
|
+
compatibleCallKinds: ANTHROPIC_SERVER_CALL_KINDS,
|
|
364
|
+
expectedToolNames: WEB_SEARCH_TOOL_NAMES
|
|
365
|
+
} : void 0;
|
|
366
|
+
}
|
|
367
|
+
if (type === "mcp_tool_result") {
|
|
368
|
+
const toolCallId = readPairingString(record, "tool_use_id");
|
|
369
|
+
const content = readDataProperty(record, "content");
|
|
370
|
+
const isError = readDataProperty(record, "is_error");
|
|
371
|
+
return toolCallId != null && content.found && isOpaqueStringOrBoundedArray(content.value) && isError.found && typeof isError.value === "boolean" ? {
|
|
372
|
+
type,
|
|
373
|
+
toolCallId,
|
|
374
|
+
compatibleCallKinds: MCP_CALL_KINDS
|
|
375
|
+
} : void 0;
|
|
376
|
+
}
|
|
377
|
+
if (type === "server_tool_call_result" || type === "server_tool_result") {
|
|
378
|
+
const toolCallId = readPairingString(record, type === "server_tool_call_result" ? "toolCallId" : "tool_call_id");
|
|
379
|
+
const status = readString(record, "status");
|
|
380
|
+
const output = readDataProperty(record, "output");
|
|
381
|
+
return toolCallId != null && (status === "success" || status === "error") && output.found && output.value !== void 0 ? {
|
|
382
|
+
type,
|
|
383
|
+
toolCallId,
|
|
384
|
+
compatibleCallKinds: SERVER_CALL_KINDS
|
|
385
|
+
} : void 0;
|
|
386
|
+
}
|
|
387
|
+
if (type === "codeExecutionResult") return isGoogleCodeExecutionResult(record) ? {
|
|
388
|
+
type,
|
|
389
|
+
compatibleCallKinds: GOOGLE_CALL_KINDS,
|
|
390
|
+
requiresPreviousExecutableCode: true
|
|
391
|
+
} : void 0;
|
|
392
|
+
if (type === "toolResponse") return getGoogleToolResponseDescriptor(record, type);
|
|
393
|
+
if (type === "toolResult") return getBedrockDescriptor(record, type);
|
|
394
|
+
if (type === "tool_result") {
|
|
395
|
+
const toolCallId = readPairingString(record, "tool_use_id");
|
|
396
|
+
const content = readDataProperty(record, "content");
|
|
397
|
+
const isError = readDataProperty(record, "is_error");
|
|
398
|
+
return toolCallId != null && content.found && isOpaqueStringOrBoundedArray(content.value) && (!isError.found || typeof isError.value === "boolean") ? {
|
|
399
|
+
type,
|
|
400
|
+
toolCallId,
|
|
401
|
+
compatibleCallKinds: TOOL_CALL_KINDS,
|
|
402
|
+
allowHumanMessagePairing: true
|
|
403
|
+
} : void 0;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function optionalName(record) {
|
|
407
|
+
const property = readDataProperty(record, "name");
|
|
408
|
+
if (!property.found || property.value === void 0) return {};
|
|
409
|
+
return isBoundedProviderPairingString(property.value) ? { name: property.value } : void 0;
|
|
410
|
+
}
|
|
411
|
+
function hasExactCallShape(record, fields, required) {
|
|
412
|
+
return hasOnlyOwnDataProperties(record, fields) && hasRequiredDataProperties(record, required) && hasValidProviderMetadata(record);
|
|
413
|
+
}
|
|
414
|
+
function hasOptionalCallType(record, expected) {
|
|
415
|
+
const type = readDataProperty(record, "type");
|
|
416
|
+
return !type.found || type.value === expected;
|
|
417
|
+
}
|
|
418
|
+
function isAnthropicServerToolCall(callId, name) {
|
|
419
|
+
return callId.startsWith(ANTHROPIC_SERVER_TOOL_ID_PREFIX) && name != null && ANTHROPIC_SERVER_TOOL_NAMES.has(name);
|
|
420
|
+
}
|
|
421
|
+
function getAnthropicCallKind(type, callId, name) {
|
|
422
|
+
if (type === "mcp_tool_use") return "mcp";
|
|
423
|
+
if (type === "server_tool_use" || isAnthropicServerToolCall(callId, name)) return "anthropic-server";
|
|
424
|
+
return "tool";
|
|
425
|
+
}
|
|
426
|
+
const AI_TOOL_CALL_FIELDS = [
|
|
427
|
+
"type",
|
|
428
|
+
"id",
|
|
429
|
+
"name",
|
|
430
|
+
"args"
|
|
431
|
+
];
|
|
432
|
+
const LOCAL_CALL_METADATA_FIELDS = ["agentId", "groupId"];
|
|
433
|
+
const STANDARD_CALL_FIELDS = [
|
|
434
|
+
"type",
|
|
435
|
+
"id",
|
|
436
|
+
"name",
|
|
437
|
+
"args",
|
|
438
|
+
"index",
|
|
439
|
+
...LOCAL_CALL_METADATA_FIELDS
|
|
440
|
+
];
|
|
441
|
+
const LIBRECHAT_CALL_FIELDS = [
|
|
442
|
+
"type",
|
|
443
|
+
"id",
|
|
444
|
+
"name",
|
|
445
|
+
"args",
|
|
446
|
+
"output",
|
|
447
|
+
"outcome",
|
|
448
|
+
"auth",
|
|
449
|
+
"expires_at"
|
|
450
|
+
];
|
|
451
|
+
const ANTHROPIC_CALL_FIELDS = [
|
|
452
|
+
"type",
|
|
453
|
+
"id",
|
|
454
|
+
"name",
|
|
455
|
+
"input",
|
|
456
|
+
"caller",
|
|
457
|
+
"cache_control",
|
|
458
|
+
"index",
|
|
459
|
+
...LOCAL_CALL_METADATA_FIELDS
|
|
460
|
+
];
|
|
461
|
+
const ANTHROPIC_MCP_CALL_FIELDS = [
|
|
462
|
+
"type",
|
|
463
|
+
"id",
|
|
464
|
+
"name",
|
|
465
|
+
"input",
|
|
466
|
+
"server_name",
|
|
467
|
+
"cache_control",
|
|
468
|
+
"index",
|
|
469
|
+
...LOCAL_CALL_METADATA_FIELDS
|
|
470
|
+
];
|
|
471
|
+
const GOOGLE_CALL_FIELDS = [
|
|
472
|
+
"type",
|
|
473
|
+
"toolCall",
|
|
474
|
+
"thought",
|
|
475
|
+
"thoughtSignature",
|
|
476
|
+
...LOCAL_CALL_METADATA_FIELDS
|
|
477
|
+
];
|
|
478
|
+
function getProviderAIMessageToolCallDescriptor(toolCall) {
|
|
479
|
+
const record = getRecord(toolCall);
|
|
480
|
+
if (record == null || !hasExactCallShape(record, AI_TOOL_CALL_FIELDS, [
|
|
481
|
+
"id",
|
|
482
|
+
"name",
|
|
483
|
+
"args"
|
|
484
|
+
]) || !hasOptionalCallType(record, "tool_call")) return;
|
|
485
|
+
const callId = readPairingString(record, "id");
|
|
486
|
+
const name = optionalName(record);
|
|
487
|
+
return callId == null || name == null ? void 0 : {
|
|
488
|
+
callId,
|
|
489
|
+
kind: isAnthropicServerToolCall(callId, name.name) ? "anthropic-server" : "tool",
|
|
490
|
+
sourceType: "ai_tool_calls",
|
|
491
|
+
...name
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function getProviderToolCallPartDescriptor(part) {
|
|
495
|
+
const record = getRecord(part);
|
|
496
|
+
if (record == null) return;
|
|
497
|
+
const type = readString(record, "type");
|
|
498
|
+
if (type === "tool_call") {
|
|
499
|
+
const nested = readDataProperty(record, "tool_call");
|
|
500
|
+
const call = nested.found ? getRecord(nested.value) : record;
|
|
501
|
+
const outerIsValid = nested.found ? hasExactCallShape(record, [
|
|
502
|
+
"type",
|
|
503
|
+
"tool_call",
|
|
504
|
+
"agentId",
|
|
505
|
+
"groupId"
|
|
506
|
+
], ["tool_call"]) : hasExactCallShape(record, STANDARD_CALL_FIELDS, [
|
|
507
|
+
"id",
|
|
508
|
+
"name",
|
|
509
|
+
"args"
|
|
510
|
+
]);
|
|
511
|
+
const callIsValid = nested.found ? call != null && hasExactCallShape(call, LIBRECHAT_CALL_FIELDS, [
|
|
512
|
+
"id",
|
|
513
|
+
"name",
|
|
514
|
+
"args"
|
|
515
|
+
]) && hasOptionalCallType(call, "tool_call") : call != null;
|
|
516
|
+
if (!outerIsValid || !callIsValid) return;
|
|
517
|
+
const callId = call == null ? void 0 : readPairingString(call, "id");
|
|
518
|
+
const name = call == null ? void 0 : optionalName(call);
|
|
519
|
+
return callId == null || name == null ? void 0 : {
|
|
520
|
+
callId,
|
|
521
|
+
kind: isAnthropicServerToolCall(callId, name.name) ? "anthropic-server" : "tool",
|
|
522
|
+
sourceType: type,
|
|
523
|
+
...name
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
if (type === "tool_use" || type === "server_tool_use" || type === "mcp_tool_use") {
|
|
527
|
+
if (!hasExactCallShape(record, type === "mcp_tool_use" ? ANTHROPIC_MCP_CALL_FIELDS : ANTHROPIC_CALL_FIELDS, type === "mcp_tool_use" ? [
|
|
528
|
+
"id",
|
|
529
|
+
"name",
|
|
530
|
+
"input",
|
|
531
|
+
"server_name"
|
|
532
|
+
] : [
|
|
533
|
+
"id",
|
|
534
|
+
"name",
|
|
535
|
+
"input"
|
|
536
|
+
]) || !hasValidCacheControlProperty(record) || !hasValidCallerProperty(record) || type === "mcp_tool_use" && readPairingString(record, "server_name") == null) return;
|
|
537
|
+
const callId = readPairingString(record, "id");
|
|
538
|
+
const name = optionalName(record);
|
|
539
|
+
if (type === "server_tool_use" && (name?.name == null || !ANTHROPIC_SERVER_TOOL_NAMES.has(name.name))) return;
|
|
540
|
+
return callId == null || name == null ? void 0 : {
|
|
541
|
+
callId,
|
|
542
|
+
kind: getAnthropicCallKind(type, callId, name.name),
|
|
543
|
+
sourceType: type,
|
|
544
|
+
...name
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
if (type === "server_tool_call") {
|
|
548
|
+
if (!hasExactCallShape(record, STANDARD_CALL_FIELDS, [
|
|
549
|
+
"id",
|
|
550
|
+
"name",
|
|
551
|
+
"args"
|
|
552
|
+
])) return;
|
|
553
|
+
const callId = readPairingString(record, "id");
|
|
554
|
+
const name = optionalName(record);
|
|
555
|
+
return callId == null || name == null ? void 0 : {
|
|
556
|
+
callId,
|
|
557
|
+
kind: isAnthropicServerToolCall(callId, name.name) ? "anthropic-server" : "server",
|
|
558
|
+
sourceType: type,
|
|
559
|
+
...name
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
if (type === "toolCall" || type === "toolUse") {
|
|
563
|
+
if (!hasExactCallShape(record, type === "toolCall" ? GOOGLE_CALL_FIELDS : [
|
|
564
|
+
"type",
|
|
565
|
+
"toolUse",
|
|
566
|
+
"agentId",
|
|
567
|
+
"groupId"
|
|
568
|
+
], [type]) || !hasValidProviderMetadata(record)) return;
|
|
569
|
+
const nested = readDataProperty(record, type);
|
|
570
|
+
const call = nested.found ? getRecord(nested.value) : void 0;
|
|
571
|
+
if (call == null) return;
|
|
572
|
+
if (type === "toolCall") {
|
|
573
|
+
const isNamedVariant = hasExactCallShape(call, [
|
|
574
|
+
"id",
|
|
575
|
+
"name",
|
|
576
|
+
"args"
|
|
577
|
+
], [
|
|
578
|
+
"id",
|
|
579
|
+
"name",
|
|
580
|
+
"args"
|
|
581
|
+
]);
|
|
582
|
+
const isTypedVariant = hasExactCallShape(call, [
|
|
583
|
+
"id",
|
|
584
|
+
"toolType",
|
|
585
|
+
"args"
|
|
586
|
+
], [
|
|
587
|
+
"id",
|
|
588
|
+
"toolType",
|
|
589
|
+
"args"
|
|
590
|
+
]);
|
|
591
|
+
if (!isNamedVariant && !isTypedVariant || isTypedVariant && readPairingString(call, "toolType") == null) return;
|
|
592
|
+
} else {
|
|
593
|
+
const nestedType = readDataProperty(call, "type");
|
|
594
|
+
if (!hasExactCallShape(call, [
|
|
595
|
+
"toolUseId",
|
|
596
|
+
"name",
|
|
597
|
+
"input",
|
|
598
|
+
"type"
|
|
599
|
+
], [
|
|
600
|
+
"toolUseId",
|
|
601
|
+
"name",
|
|
602
|
+
"input"
|
|
603
|
+
]) || nestedType.found && typeof nestedType.value !== "string") return;
|
|
604
|
+
}
|
|
605
|
+
const callId = readPairingString(call, type === "toolCall" ? "id" : "toolUseId");
|
|
606
|
+
const name = optionalName(call);
|
|
607
|
+
return callId == null || name == null ? void 0 : {
|
|
608
|
+
callId,
|
|
609
|
+
kind: type === "toolCall" ? "google" : "bedrock",
|
|
610
|
+
sourceType: type,
|
|
611
|
+
...name
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function appendProviderToolCallDescriptor(index, descriptor) {
|
|
616
|
+
if (!PROVIDER_TOOL_CALL_KINDS.has(descriptor.kind) || !isBoundedProviderPairingString(descriptor.callId) || !isBoundedProviderPairingString(descriptor.sourceType) || descriptor.name != null && !isBoundedProviderPairingString(descriptor.name)) return;
|
|
617
|
+
const existing = index.get(descriptor.callId);
|
|
618
|
+
if (existing === void 0) {
|
|
619
|
+
if (index.size >= 4096) return;
|
|
620
|
+
index.set(descriptor.callId, { descriptor });
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
if (existing === null) return;
|
|
624
|
+
const isDualRepresentation = existing.secondarySourceType == null && existing.descriptor.sourceType !== descriptor.sourceType && (existing.descriptor.sourceType === "ai_tool_calls" || descriptor.sourceType === "ai_tool_calls");
|
|
625
|
+
if (existing.descriptor.kind === descriptor.kind && existing.descriptor.name === descriptor.name && isDualRepresentation) {
|
|
626
|
+
existing.secondarySourceType = descriptor.sourceType;
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
index.set(descriptor.callId, null);
|
|
630
|
+
}
|
|
631
|
+
function isExecutableCodePart(part) {
|
|
632
|
+
const record = getRecord(part);
|
|
633
|
+
if (record == null || readString(record, "type") !== "executableCode" || !hasOnlyOwnDataProperties(record, [
|
|
634
|
+
"type",
|
|
635
|
+
"executableCode",
|
|
636
|
+
"agentId",
|
|
637
|
+
"groupId"
|
|
638
|
+
]) || !hasValidProviderMetadata(record)) return false;
|
|
639
|
+
const nested = readDataProperty(record, "executableCode");
|
|
640
|
+
const executable = nested.found ? getRecord(nested.value) : void 0;
|
|
641
|
+
return executable != null && hasOnlyOwnDataProperties(executable, ["language", "code"]) && readString(executable, "language") != null && readString(executable, "code", true) != null;
|
|
642
|
+
}
|
|
643
|
+
function consumeProviderToolResultPair(descriptor, calls, previousPart) {
|
|
644
|
+
if (descriptor.requiresPreviousExecutableCode === true) return isExecutableCodePart(previousPart);
|
|
645
|
+
if (descriptor.toolCallId == null || !isBoundedProviderPairingString(descriptor.toolCallId)) return false;
|
|
646
|
+
const entry = calls.get(descriptor.toolCallId);
|
|
647
|
+
if (entry == null) return false;
|
|
648
|
+
const candidate = entry.descriptor;
|
|
649
|
+
if (!descriptor.compatibleCallKinds.includes(candidate.kind)) return false;
|
|
650
|
+
if (descriptor.expectedToolNames != null && (candidate.name == null || !descriptor.expectedToolNames.includes(candidate.name))) return false;
|
|
651
|
+
calls.delete(descriptor.toolCallId);
|
|
652
|
+
return true;
|
|
653
|
+
}
|
|
654
|
+
//#endregion
|
|
655
|
+
exports.appendProviderToolCallDescriptor = appendProviderToolCallDescriptor;
|
|
656
|
+
exports.consumeProviderToolResultPair = consumeProviderToolResultPair;
|
|
657
|
+
exports.getBoundedProviderPairingArrayProperty = getBoundedProviderPairingArrayProperty;
|
|
658
|
+
exports.getProviderAIMessageToolCallDescriptor = getProviderAIMessageToolCallDescriptor;
|
|
659
|
+
exports.getProviderToolCallPartDescriptor = getProviderToolCallPartDescriptor;
|
|
660
|
+
exports.getProviderToolResultPartDescriptor = getProviderToolResultPartDescriptor;
|
|
661
|
+
exports.hasStructurallyValidAnthropicWebSearchResultContent = hasStructurallyValidAnthropicWebSearchResultContent;
|
|
662
|
+
|
|
663
|
+
//# sourceMappingURL=toolResultTypes.cjs.map
|