agents 0.11.9 → 0.12.0
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 +37 -1
- package/dist/{index-DSwOzhhd.d.ts → agent-tool-types-tBGRsPm0.d.ts} +584 -99
- package/dist/agent-tool-types.d.ts +34 -0
- package/dist/agent-tool-types.js +1 -0
- package/dist/agent-tools-BAdX1vdI.js +425 -0
- package/dist/agent-tools-BAdX1vdI.js.map +1 -0
- package/dist/agent-tools-CIO14miM.d.ts +14 -0
- package/dist/agent-tools.d.ts +68 -0
- package/dist/agent-tools.js +51 -0
- package/dist/agent-tools.js.map +1 -0
- package/dist/browser/ai.d.ts +1 -1
- package/dist/browser/ai.js +2 -2
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/tanstack-ai.d.ts +1 -1
- package/dist/browser/tanstack-ai.js +1 -1
- package/dist/chat/index.d.ts +3 -1
- package/dist/chat/index.js +3 -300
- package/dist/chat/index.js.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/{compaction-helpers-C_cN3z55.js → compaction-helpers-CSaqCmdE.js} +1 -1
- package/dist/{compaction-helpers-C_cN3z55.js.map → compaction-helpers-CSaqCmdE.js.map} +1 -1
- package/dist/{compaction-helpers-YzCLvunJ.d.ts → compaction-helpers-D92Ipstp.d.ts} +1 -1
- package/dist/experimental/memory/session/index.d.ts +1 -1
- package/dist/experimental/memory/session/index.js +1 -1
- package/dist/experimental/memory/utils/index.d.ts +1 -1
- package/dist/experimental/memory/utils/index.js +1 -1
- package/dist/index.d.ts +74 -42
- package/dist/index.js +1393 -296
- package/dist/index.js.map +1 -1
- package/dist/mcp/client.d.ts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/react.d.ts +16 -2
- package/dist/react.js +42 -1
- package/dist/react.js.map +1 -1
- package/dist/{serializable-Bg8ARWlN.d.ts → serializable-Brg7fRds.d.ts} +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/{shared-mfBbxjS1.js → shared-C6l4ZKRN.js} +1 -1
- package/dist/{shared-mfBbxjS1.js.map → shared-C6l4ZKRN.js.map} +1 -1
- package/dist/{shared-BUHZFGTk.d.ts → shared-Ch9slKdI.d.ts} +1 -1
- package/dist/sub-routing.d.ts +6 -6
- package/dist/workflows.d.ts +1 -1
- package/package.json +9 -4
package/dist/browser/ai.d.ts
CHANGED
package/dist/browser/ai.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as SEARCH_DESCRIPTION, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-
|
|
2
|
-
import { z } from "zod";
|
|
1
|
+
import { n as SEARCH_DESCRIPTION, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-C6l4ZKRN.js";
|
|
3
2
|
import { tool } from "ai";
|
|
3
|
+
import { z } from "zod";
|
|
4
4
|
//#region src/browser/ai.ts
|
|
5
5
|
/**
|
|
6
6
|
* Create AI SDK tools for browser automation via CDP code mode.
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createBrowserToolHandlers, i as ToolResult, n as EXECUTE_DESCRIPTION, r as SEARCH_DESCRIPTION, t as BrowserToolsOptions } from "../shared-
|
|
1
|
+
import { a as createBrowserToolHandlers, i as ToolResult, n as EXECUTE_DESCRIPTION, r as SEARCH_DESCRIPTION, t as BrowserToolsOptions } from "../shared-Ch9slKdI.js";
|
|
2
2
|
|
|
3
3
|
//#region src/browser/cdp-session.d.ts
|
|
4
4
|
interface DebugEntry {
|
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as connectBrowser, i as CdpSession, n as SEARCH_DESCRIPTION, o as connectUrl, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-
|
|
1
|
+
import { a as connectBrowser, i as CdpSession, n as SEARCH_DESCRIPTION, o as connectUrl, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-C6l4ZKRN.js";
|
|
2
2
|
export { CdpSession, EXECUTE_DESCRIPTION, SEARCH_DESCRIPTION, connectBrowser, connectUrl, createBrowserToolHandlers };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as SEARCH_DESCRIPTION, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-
|
|
1
|
+
import { n as SEARCH_DESCRIPTION, r as createBrowserToolHandlers, t as EXECUTE_DESCRIPTION } from "../shared-C6l4ZKRN.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { toolDefinition } from "@tanstack/ai";
|
|
4
4
|
//#region src/browser/tanstack-ai.ts
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { a as AgentToolEventState, i as AgentToolEventMessage, l as AgentToolRunState, r as AgentToolEvent } from "../agent-tool-types-tBGRsPm0.js";
|
|
2
|
+
import { n as createAgentToolEventState, t as applyAgentToolEvent } from "../agent-tools-CIO14miM.js";
|
|
1
3
|
import { JSONSchema7, Tool, ToolSet, UIMessage } from "ai";
|
|
2
4
|
import { Connection } from "agents";
|
|
3
5
|
|
|
@@ -836,5 +838,5 @@ declare function resolveToolMergeId(message: UIMessage, serverMessages: readonly
|
|
|
836
838
|
*/
|
|
837
839
|
declare function assistantContentKey(message: UIMessage, sanitize?: (message: UIMessage) => UIMessage): string | undefined;
|
|
838
840
|
//#endregion
|
|
839
|
-
export { AbortRegistry, type BroadcastStreamEvent, type BroadcastStreamState, type TransitionResult as BroadcastTransitionResult, CHAT_MESSAGE_TYPES, type ChatProtocolEvent, type ChatRecoveryContext, type ChatRecoveryOptions, type ChatResponseResult, type ChunkAction, type ChunkResult, type ClientToolSchema, type ContinuationConnection, type ContinuationDeferred, type ContinuationPending, ContinuationState, type EnqueueOptions, type MessageConcurrency, type MessagePart, type MessageParts, type NormalizedMessageConcurrency, ROW_MAX_BYTES, ResumableStream, type SaveMessagesOptions, type SaveMessagesResult, type SqlTaggedTemplate, StreamAccumulator, type StreamAccumulatorOptions, type StreamChunkData, SubmitConcurrencyController, type SubmitConcurrencyDecision, type ToolPartUpdate, TurnQueue, type TurnResult, applyChunkToParts, applyToolUpdate, assistantContentKey, transition as broadcastTransition, byteLength, createToolsFromClientSchemas, enforceRowSizeLimit, isReplayChunk, parseProtocolMessage, reconcileMessages, resolveToolMergeId, sanitizeMessage, toolApprovalUpdate, toolResultUpdate };
|
|
841
|
+
export { AbortRegistry, type AgentToolEvent, type AgentToolEventMessage, type AgentToolEventState, type AgentToolRunState, type BroadcastStreamEvent, type BroadcastStreamState, type TransitionResult as BroadcastTransitionResult, CHAT_MESSAGE_TYPES, type ChatProtocolEvent, type ChatRecoveryContext, type ChatRecoveryOptions, type ChatResponseResult, type ChunkAction, type ChunkResult, type ClientToolSchema, type ContinuationConnection, type ContinuationDeferred, type ContinuationPending, ContinuationState, type EnqueueOptions, type MessageConcurrency, type MessagePart, type MessageParts, type NormalizedMessageConcurrency, ROW_MAX_BYTES, ResumableStream, type SaveMessagesOptions, type SaveMessagesResult, type SqlTaggedTemplate, StreamAccumulator, type StreamAccumulatorOptions, type StreamChunkData, SubmitConcurrencyController, type SubmitConcurrencyDecision, type ToolPartUpdate, TurnQueue, type TurnResult, applyAgentToolEvent, applyChunkToParts, applyToolUpdate, assistantContentKey, transition as broadcastTransition, byteLength, createAgentToolEventState, createToolsFromClientSchemas, enforceRowSizeLimit, isReplayChunk, parseProtocolMessage, reconcileMessages, resolveToolMergeId, sanitizeMessage, toolApprovalUpdate, toolResultUpdate };
|
|
840
842
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/chat/index.js
CHANGED
|
@@ -1,303 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as isReplayChunk, n as createAgentToolEventState, r as applyChunkToParts, t as applyAgentToolEvent } from "../agent-tools-BAdX1vdI.js";
|
|
2
2
|
import { jsonSchema, tool } from "ai";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Applies a stream chunk to a mutable parts array, building up the message
|
|
6
|
-
* incrementally. Returns true if the chunk was handled, false if it was
|
|
7
|
-
* an unrecognized type (caller may handle it with additional logic).
|
|
8
|
-
*
|
|
9
|
-
* Handles all common chunk types that both server and client need:
|
|
10
|
-
* - text-start / text-delta / text-end
|
|
11
|
-
* - reasoning-start / reasoning-delta / reasoning-end
|
|
12
|
-
* - file
|
|
13
|
-
* - source-url / source-document
|
|
14
|
-
* - tool-input-start / tool-input-delta / tool-input-available / tool-input-error
|
|
15
|
-
* - tool-output-available / tool-output-error
|
|
16
|
-
* - step-start (aliased from start-step)
|
|
17
|
-
* - data-* (developer-defined typed JSON blobs)
|
|
18
|
-
*
|
|
19
|
-
* @param parts - The mutable parts array to update
|
|
20
|
-
* @param chunk - The parsed stream chunk data
|
|
21
|
-
* @returns true if handled, false if the chunk type is not recognized
|
|
22
|
-
*/
|
|
23
|
-
function applyChunkToParts(parts, chunk) {
|
|
24
|
-
switch (chunk.type) {
|
|
25
|
-
case "text-start":
|
|
26
|
-
parts.push({
|
|
27
|
-
type: "text",
|
|
28
|
-
text: "",
|
|
29
|
-
state: "streaming"
|
|
30
|
-
});
|
|
31
|
-
return true;
|
|
32
|
-
case "text-delta": {
|
|
33
|
-
const lastTextPart = findLastPartByType(parts, "text");
|
|
34
|
-
if (lastTextPart && lastTextPart.type === "text") lastTextPart.text += chunk.delta ?? "";
|
|
35
|
-
else parts.push({
|
|
36
|
-
type: "text",
|
|
37
|
-
text: chunk.delta ?? "",
|
|
38
|
-
state: "streaming"
|
|
39
|
-
});
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
case "text-end": {
|
|
43
|
-
const lastTextPart = findLastPartByType(parts, "text");
|
|
44
|
-
if (lastTextPart && "state" in lastTextPart) lastTextPart.state = "done";
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
case "reasoning-start":
|
|
48
|
-
parts.push({
|
|
49
|
-
type: "reasoning",
|
|
50
|
-
text: "",
|
|
51
|
-
state: "streaming"
|
|
52
|
-
});
|
|
53
|
-
return true;
|
|
54
|
-
case "reasoning-delta": {
|
|
55
|
-
const lastReasoningPart = findLastPartByType(parts, "reasoning");
|
|
56
|
-
if (lastReasoningPart && lastReasoningPart.type === "reasoning") {
|
|
57
|
-
lastReasoningPart.text += chunk.delta ?? "";
|
|
58
|
-
mergeProviderMetadata(lastReasoningPart, chunk.providerMetadata);
|
|
59
|
-
} else parts.push({
|
|
60
|
-
type: "reasoning",
|
|
61
|
-
text: chunk.delta ?? "",
|
|
62
|
-
state: "streaming",
|
|
63
|
-
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
64
|
-
});
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
case "reasoning-end": {
|
|
68
|
-
const lastReasoningPart = findLastPartByType(parts, "reasoning");
|
|
69
|
-
if (lastReasoningPart && "state" in lastReasoningPart) {
|
|
70
|
-
lastReasoningPart.state = "done";
|
|
71
|
-
mergeProviderMetadata(lastReasoningPart, chunk.providerMetadata);
|
|
72
|
-
}
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
case "file":
|
|
76
|
-
parts.push({
|
|
77
|
-
type: "file",
|
|
78
|
-
mediaType: chunk.mediaType,
|
|
79
|
-
url: chunk.url
|
|
80
|
-
});
|
|
81
|
-
return true;
|
|
82
|
-
case "source-url":
|
|
83
|
-
parts.push({
|
|
84
|
-
type: "source-url",
|
|
85
|
-
sourceId: chunk.sourceId,
|
|
86
|
-
url: chunk.url,
|
|
87
|
-
title: chunk.title,
|
|
88
|
-
providerMetadata: chunk.providerMetadata
|
|
89
|
-
});
|
|
90
|
-
return true;
|
|
91
|
-
case "source-document":
|
|
92
|
-
parts.push({
|
|
93
|
-
type: "source-document",
|
|
94
|
-
sourceId: chunk.sourceId,
|
|
95
|
-
mediaType: chunk.mediaType,
|
|
96
|
-
title: chunk.title,
|
|
97
|
-
filename: chunk.filename,
|
|
98
|
-
providerMetadata: chunk.providerMetadata
|
|
99
|
-
});
|
|
100
|
-
return true;
|
|
101
|
-
case "tool-input-start":
|
|
102
|
-
if (findToolPartByCallId(parts, chunk.toolCallId)) return true;
|
|
103
|
-
parts.push({
|
|
104
|
-
type: `tool-${chunk.toolName}`,
|
|
105
|
-
toolCallId: chunk.toolCallId,
|
|
106
|
-
toolName: chunk.toolName,
|
|
107
|
-
state: "input-streaming",
|
|
108
|
-
input: void 0,
|
|
109
|
-
...chunk.providerExecuted != null ? { providerExecuted: chunk.providerExecuted } : {},
|
|
110
|
-
...chunk.providerMetadata != null ? { callProviderMetadata: chunk.providerMetadata } : {},
|
|
111
|
-
...chunk.title != null ? { title: chunk.title } : {}
|
|
112
|
-
});
|
|
113
|
-
return true;
|
|
114
|
-
case "tool-input-delta": {
|
|
115
|
-
const toolPart = findToolPartByCallId(parts, chunk.toolCallId);
|
|
116
|
-
if (toolPart && toolPart.state === "input-streaming") toolPart.input = chunk.input;
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
case "tool-input-available": {
|
|
120
|
-
const existing = findToolPartByCallId(parts, chunk.toolCallId);
|
|
121
|
-
if (existing) {
|
|
122
|
-
const p = existing;
|
|
123
|
-
if (p.state === "input-streaming") {
|
|
124
|
-
p.state = "input-available";
|
|
125
|
-
p.input = chunk.input;
|
|
126
|
-
if (chunk.providerExecuted != null) p.providerExecuted = chunk.providerExecuted;
|
|
127
|
-
if (chunk.providerMetadata != null) p.callProviderMetadata = chunk.providerMetadata;
|
|
128
|
-
if (chunk.title != null) p.title = chunk.title;
|
|
129
|
-
}
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
parts.push({
|
|
133
|
-
type: `tool-${chunk.toolName}`,
|
|
134
|
-
toolCallId: chunk.toolCallId,
|
|
135
|
-
toolName: chunk.toolName,
|
|
136
|
-
state: "input-available",
|
|
137
|
-
input: chunk.input,
|
|
138
|
-
...chunk.providerExecuted != null ? { providerExecuted: chunk.providerExecuted } : {},
|
|
139
|
-
...chunk.providerMetadata != null ? { callProviderMetadata: chunk.providerMetadata } : {},
|
|
140
|
-
...chunk.title != null ? { title: chunk.title } : {}
|
|
141
|
-
});
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
case "tool-input-error": {
|
|
145
|
-
const existing = findToolPartByCallId(parts, chunk.toolCallId);
|
|
146
|
-
if (existing) {
|
|
147
|
-
const p = existing;
|
|
148
|
-
if (p.state === "output-available" || p.state === "output-error" || p.state === "output-denied") return true;
|
|
149
|
-
p.state = "output-error";
|
|
150
|
-
p.errorText = chunk.errorText;
|
|
151
|
-
p.input = chunk.input;
|
|
152
|
-
if (chunk.providerExecuted != null) p.providerExecuted = chunk.providerExecuted;
|
|
153
|
-
if (chunk.providerMetadata != null) p.callProviderMetadata = chunk.providerMetadata;
|
|
154
|
-
} else parts.push({
|
|
155
|
-
type: `tool-${chunk.toolName}`,
|
|
156
|
-
toolCallId: chunk.toolCallId,
|
|
157
|
-
toolName: chunk.toolName,
|
|
158
|
-
state: "output-error",
|
|
159
|
-
input: chunk.input,
|
|
160
|
-
errorText: chunk.errorText,
|
|
161
|
-
...chunk.providerExecuted != null ? { providerExecuted: chunk.providerExecuted } : {},
|
|
162
|
-
...chunk.providerMetadata != null ? { callProviderMetadata: chunk.providerMetadata } : {}
|
|
163
|
-
});
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
case "tool-approval-request": {
|
|
167
|
-
const toolPart = findToolPartByCallId(parts, chunk.toolCallId);
|
|
168
|
-
if (toolPart) {
|
|
169
|
-
const p = toolPart;
|
|
170
|
-
p.state = "approval-requested";
|
|
171
|
-
p.approval = { id: chunk.approvalId };
|
|
172
|
-
}
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
case "tool-output-denied": {
|
|
176
|
-
const toolPart = findToolPartByCallId(parts, chunk.toolCallId);
|
|
177
|
-
if (toolPart) {
|
|
178
|
-
const p = toolPart;
|
|
179
|
-
p.state = "output-denied";
|
|
180
|
-
}
|
|
181
|
-
return true;
|
|
182
|
-
}
|
|
183
|
-
case "tool-output-available": {
|
|
184
|
-
const toolPart = findToolPartByCallId(parts, chunk.toolCallId);
|
|
185
|
-
if (toolPart) {
|
|
186
|
-
const p = toolPart;
|
|
187
|
-
p.state = "output-available";
|
|
188
|
-
p.output = chunk.output;
|
|
189
|
-
if (chunk.preliminary !== void 0) p.preliminary = chunk.preliminary;
|
|
190
|
-
}
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
|
-
case "tool-output-error": {
|
|
194
|
-
const toolPart = findToolPartByCallId(parts, chunk.toolCallId);
|
|
195
|
-
if (toolPart) {
|
|
196
|
-
const p = toolPart;
|
|
197
|
-
p.state = "output-error";
|
|
198
|
-
p.errorText = chunk.errorText;
|
|
199
|
-
}
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
case "step-start":
|
|
203
|
-
case "start-step":
|
|
204
|
-
parts.push({ type: "step-start" });
|
|
205
|
-
return true;
|
|
206
|
-
default:
|
|
207
|
-
if (chunk.type.startsWith("data-")) {
|
|
208
|
-
if (chunk.transient) return true;
|
|
209
|
-
if (chunk.id != null) {
|
|
210
|
-
const existing = findDataPartByTypeAndId(parts, chunk.type, chunk.id);
|
|
211
|
-
if (existing) {
|
|
212
|
-
existing.data = chunk.data;
|
|
213
|
-
return true;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
parts.push({
|
|
217
|
-
type: chunk.type,
|
|
218
|
-
...chunk.id != null && { id: chunk.id },
|
|
219
|
-
data: chunk.data
|
|
220
|
-
});
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
return false;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Returns true if `chunk` would be a no-op replay against the already-known
|
|
228
|
-
* `parts` — i.e. some upstream is re-emitting events for a tool call that
|
|
229
|
-
* the message has already advanced past.
|
|
230
|
-
*
|
|
231
|
-
* Used by stream broadcasters to suppress re-broadcasting these chunks to
|
|
232
|
-
* connected clients. AI SDK v6's `updateToolPart` mutates an existing tool
|
|
233
|
-
* part in place when a chunk arrives with a matching `toolCallId`, so a
|
|
234
|
-
* replayed `tool-input-start` would clobber an `output-available` part back
|
|
235
|
-
* to `input-streaming` on the client (issue #1404).
|
|
236
|
-
*
|
|
237
|
-
* Only returns true when re-broadcasting would *visibly regress* state on
|
|
238
|
-
* a v6 client. Safe-by-construction chunk types (e.g. `tool-output-available`
|
|
239
|
-
* carrying the same output the part already has) return false.
|
|
240
|
-
*
|
|
241
|
-
* Conditions:
|
|
242
|
-
* - `tool-input-start` for a `toolCallId` that already exists in `parts`.
|
|
243
|
-
* - `tool-input-delta` for a `toolCallId` whose existing part is no longer
|
|
244
|
-
* `input-streaming`.
|
|
245
|
-
* - `tool-input-available` for a `toolCallId` whose existing part is no
|
|
246
|
-
* longer `input-streaming` (i.e. has already advanced to `input-available`
|
|
247
|
-
* or any terminal state).
|
|
248
|
-
*/
|
|
249
|
-
function isReplayChunk(parts, chunk) {
|
|
250
|
-
if (chunk.type !== "tool-input-start" && chunk.type !== "tool-input-delta" && chunk.type !== "tool-input-available") return false;
|
|
251
|
-
if (!chunk.toolCallId) return false;
|
|
252
|
-
const existing = findToolPartByCallId(parts, chunk.toolCallId);
|
|
253
|
-
if (!existing) return false;
|
|
254
|
-
if (chunk.type === "tool-input-start") return true;
|
|
255
|
-
return existing.state !== "input-streaming";
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Finds the last part in the array matching the given type.
|
|
259
|
-
* Searches from the end for efficiency (the part we want is usually recent).
|
|
260
|
-
*/
|
|
261
|
-
function findLastPartByType(parts, type) {
|
|
262
|
-
for (let i = parts.length - 1; i >= 0; i--) if (parts[i].type === type) return parts[i];
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Finds a tool part by its toolCallId.
|
|
266
|
-
* Searches from the end since the tool part is usually recent.
|
|
267
|
-
*/
|
|
268
|
-
function findToolPartByCallId(parts, toolCallId) {
|
|
269
|
-
if (!toolCallId) return void 0;
|
|
270
|
-
for (let i = parts.length - 1; i >= 0; i--) {
|
|
271
|
-
const p = parts[i];
|
|
272
|
-
if ("toolCallId" in p && p.toolCallId === toolCallId) return p;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Shallow-merges providerMetadata from a chunk onto an existing part.
|
|
277
|
-
* Preserves any metadata already on the part (e.g. from earlier deltas)
|
|
278
|
-
* while adding new keys from the chunk. This is critical for providers
|
|
279
|
-
* like Anthropic that emit the thinking block signature on reasoning-end.
|
|
280
|
-
*/
|
|
281
|
-
function mergeProviderMetadata(part, metadata) {
|
|
282
|
-
if (metadata == null) return;
|
|
283
|
-
const p = part;
|
|
284
|
-
p.providerMetadata = {
|
|
285
|
-
...p.providerMetadata,
|
|
286
|
-
...metadata
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Finds a data part by its type and id for reconciliation.
|
|
291
|
-
* Data parts use type+id as a composite key so when the same combination
|
|
292
|
-
* is seen again, the existing part's data is updated in-place.
|
|
293
|
-
*/
|
|
294
|
-
function findDataPartByTypeAndId(parts, type, id) {
|
|
295
|
-
for (let i = parts.length - 1; i >= 0; i--) {
|
|
296
|
-
const p = parts[i];
|
|
297
|
-
if (p.type === type && "id" in p && p.id === id) return p;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
//#endregion
|
|
3
|
+
import { nanoid } from "nanoid";
|
|
301
4
|
//#region src/chat/sanitize.ts
|
|
302
5
|
const textEncoder$1 = new TextEncoder();
|
|
303
6
|
/** Maximum serialized message size before compaction (bytes). 1.8MB with headroom below SQLite's 2MB limit. */
|
|
@@ -1615,6 +1318,6 @@ function findMessageByToolCallId(messages, toolCallId) {
|
|
|
1615
1318
|
}
|
|
1616
1319
|
}
|
|
1617
1320
|
//#endregion
|
|
1618
|
-
export { AbortRegistry, CHAT_MESSAGE_TYPES, ContinuationState, ROW_MAX_BYTES, ResumableStream, StreamAccumulator, SubmitConcurrencyController, TurnQueue, applyChunkToParts, applyToolUpdate, assistantContentKey, transition as broadcastTransition, byteLength, createToolsFromClientSchemas, enforceRowSizeLimit, isReplayChunk, parseProtocolMessage, reconcileMessages, resolveToolMergeId, sanitizeMessage, toolApprovalUpdate, toolResultUpdate };
|
|
1321
|
+
export { AbortRegistry, CHAT_MESSAGE_TYPES, ContinuationState, ROW_MAX_BYTES, ResumableStream, StreamAccumulator, SubmitConcurrencyController, TurnQueue, applyAgentToolEvent, applyChunkToParts, applyToolUpdate, assistantContentKey, transition as broadcastTransition, byteLength, createAgentToolEventState, createToolsFromClientSchemas, enforceRowSizeLimit, isReplayChunk, parseProtocolMessage, reconcileMessages, resolveToolMergeId, sanitizeMessage, toolApprovalUpdate, toolResultUpdate };
|
|
1619
1322
|
|
|
1620
1323
|
//# sourceMappingURL=index.js.map
|