veryfront 0.1.1132 → 0.1.1135
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/esm/cli/commands/eval/command.d.ts +11 -0
- package/esm/cli/commands/eval/command.d.ts.map +1 -1
- package/esm/cli/mcp/tools/deploy-tool.d.ts.map +1 -1
- package/esm/cli/mcp/tools/deploy-tool.js +4 -1
- package/esm/deno.js +2 -1
- package/esm/src/agent/ag-ui/browser-encoder.d.ts.map +1 -1
- package/esm/src/agent/ag-ui/browser-encoder.js +3 -1
- package/esm/src/agent/ag-ui/runtime-chat-stream-encoder.d.ts.map +1 -1
- package/esm/src/agent/ag-ui/runtime-chat-stream-encoder.js +11 -1
- package/esm/src/agent/conversation/run-events.js +3 -3
- package/esm/src/agent/hosted/chat-execution-runtime.d.ts.map +1 -1
- package/esm/src/agent/hosted/chat-execution-runtime.js +6 -0
- package/esm/src/agent/hosted/child-fork-stream-execution.d.ts.map +1 -1
- package/esm/src/agent/hosted/child-fork-stream-execution.js +15 -0
- package/esm/src/agent/hosted/child-mirror.d.ts +1 -1
- package/esm/src/agent/hosted/child-mirror.d.ts.map +1 -1
- package/esm/src/agent/react/index.d.ts +1 -1
- package/esm/src/agent/react/index.d.ts.map +1 -1
- package/esm/src/agent/react/use-chat/index.d.ts +1 -1
- package/esm/src/agent/react/use-chat/index.d.ts.map +1 -1
- package/esm/src/agent/react/use-chat/streaming/handler.d.ts.map +1 -1
- package/esm/src/agent/react/use-chat/streaming/handler.js +53 -5
- package/esm/src/agent/react/use-chat/types.d.ts +2 -2
- package/esm/src/agent/react/use-chat/types.d.ts.map +1 -1
- package/esm/src/agent/runtime/message-adapter.d.ts +3 -3
- package/esm/src/agent/runtime/message-adapter.d.ts.map +1 -1
- package/esm/src/agent/runtime/message-adapter.js +6 -0
- package/esm/src/agent/schemas/agent.schema.d.ts +44 -0
- package/esm/src/agent/schemas/agent.schema.d.ts.map +1 -1
- package/esm/src/agent/schemas/agent.schema.js +15 -0
- package/esm/src/agent/streaming/chat-ui-message-stream.d.ts.map +1 -1
- package/esm/src/agent/streaming/chat-ui-message-stream.js +74 -4
- package/esm/src/agent/streaming/fork-runtime-part-mapper.d.ts.map +1 -1
- package/esm/src/agent/streaming/fork-runtime-part-mapper.js +52 -0
- package/esm/src/agent/streaming/fork-runtime-types.d.ts +3 -1
- package/esm/src/agent/streaming/fork-runtime-types.d.ts.map +1 -1
- package/esm/src/agent/streaming/mirrored-tool-chunk-state.d.ts +1 -0
- package/esm/src/agent/streaming/mirrored-tool-chunk-state.d.ts.map +1 -1
- package/esm/src/agent/streaming/mirrored-tool-chunk-state.js +87 -20
- package/esm/src/chat/conversation.d.ts +12 -0
- package/esm/src/chat/conversation.d.ts.map +1 -1
- package/esm/src/chat/conversation.js +18 -1
- package/esm/src/chat/hosted-ui-chunk-mapping.d.ts.map +1 -1
- package/esm/src/chat/hosted-ui-chunk-mapping.js +16 -2
- package/esm/src/{agent/streaming → chat}/knowledge-source-document.d.ts +1 -1
- package/esm/src/chat/knowledge-source-document.d.ts.map +1 -0
- package/esm/src/{agent/streaming → chat}/knowledge-source-document.js +4 -2
- package/esm/src/chat/protocol.d.ts +25 -2
- package/esm/src/chat/protocol.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/utils/message-parts.d.ts +3 -2
- package/esm/src/react/components/chat/chat/utils/message-parts.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/utils/message-parts.js +14 -2
- package/esm/src/react/head-collector.d.ts.map +1 -1
- package/esm/src/react/head-collector.js +74 -2
- package/esm/src/react/runtime/core.d.ts.map +1 -1
- package/esm/src/react/runtime/core.js +24 -6
- package/esm/src/server/handlers/dev/framework-candidates.generated.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/framework-candidates.generated.js +7 -3
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +5 -5
- package/esm/src/agent/streaming/knowledge-source-document.d.ts.map +0 -1
|
@@ -91,6 +91,17 @@ export declare const getMessagePartSchema: () => import("../../internal-agents/s
|
|
|
91
91
|
toolCallId: import("../../internal-agents/schema.js").Schema<string>;
|
|
92
92
|
toolName: import("../../internal-agents/schema.js").Schema<string>;
|
|
93
93
|
args: import("../../internal-agents/schema.js").Schema<Record<string, unknown>>;
|
|
94
|
+
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
95
|
+
type: import("../../internal-agents/schema.js").Schema<"source-url">;
|
|
96
|
+
sourceId: import("../../internal-agents/schema.js").Schema<string>;
|
|
97
|
+
url: import("../../internal-agents/schema.js").Schema<string>;
|
|
98
|
+
title: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
99
|
+
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
100
|
+
type: import("../../internal-agents/schema.js").Schema<"source-document">;
|
|
101
|
+
sourceId: import("../../internal-agents/schema.js").Schema<string>;
|
|
102
|
+
title: import("../../internal-agents/schema.js").Schema<string>;
|
|
103
|
+
mediaType: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
104
|
+
filename: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
94
105
|
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
95
106
|
type: import("../../internal-agents/schema.js").Schema<"image">;
|
|
96
107
|
url: import("../../internal-agents/schema.js").Schema<string>;
|
|
@@ -136,6 +147,17 @@ export declare const getMessageSchema: () => import("../../internal-agents/schem
|
|
|
136
147
|
toolCallId: import("../../internal-agents/schema.js").Schema<string>;
|
|
137
148
|
toolName: import("../../internal-agents/schema.js").Schema<string>;
|
|
138
149
|
args: import("../../internal-agents/schema.js").Schema<Record<string, unknown>>;
|
|
150
|
+
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
151
|
+
type: import("../../internal-agents/schema.js").Schema<"source-url">;
|
|
152
|
+
sourceId: import("../../internal-agents/schema.js").Schema<string>;
|
|
153
|
+
url: import("../../internal-agents/schema.js").Schema<string>;
|
|
154
|
+
title: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
155
|
+
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
156
|
+
type: import("../../internal-agents/schema.js").Schema<"source-document">;
|
|
157
|
+
sourceId: import("../../internal-agents/schema.js").Schema<string>;
|
|
158
|
+
title: import("../../internal-agents/schema.js").Schema<string>;
|
|
159
|
+
mediaType: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
160
|
+
filename: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
139
161
|
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
140
162
|
type: import("../../internal-agents/schema.js").Schema<"image">;
|
|
141
163
|
url: import("../../internal-agents/schema.js").Schema<string>;
|
|
@@ -201,6 +223,17 @@ export declare const getAgentResponseSchema: () => import("../../internal-agents
|
|
|
201
223
|
toolCallId: import("../../internal-agents/schema.js").Schema<string>;
|
|
202
224
|
toolName: import("../../internal-agents/schema.js").Schema<string>;
|
|
203
225
|
args: import("../../internal-agents/schema.js").Schema<Record<string, unknown>>;
|
|
226
|
+
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
227
|
+
type: import("../../internal-agents/schema.js").Schema<"source-url">;
|
|
228
|
+
sourceId: import("../../internal-agents/schema.js").Schema<string>;
|
|
229
|
+
url: import("../../internal-agents/schema.js").Schema<string>;
|
|
230
|
+
title: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
231
|
+
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
232
|
+
type: import("../../internal-agents/schema.js").Schema<"source-document">;
|
|
233
|
+
sourceId: import("../../internal-agents/schema.js").Schema<string>;
|
|
234
|
+
title: import("../../internal-agents/schema.js").Schema<string>;
|
|
235
|
+
mediaType: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
236
|
+
filename: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
204
237
|
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
205
238
|
type: import("../../internal-agents/schema.js").Schema<"image">;
|
|
206
239
|
url: import("../../internal-agents/schema.js").Schema<string>;
|
|
@@ -289,6 +322,17 @@ export declare const getAgentContextSchema: () => import("../../internal-agents/
|
|
|
289
322
|
toolCallId: import("../../internal-agents/schema.js").Schema<string>;
|
|
290
323
|
toolName: import("../../internal-agents/schema.js").Schema<string>;
|
|
291
324
|
args: import("../../internal-agents/schema.js").Schema<Record<string, unknown>>;
|
|
325
|
+
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
326
|
+
type: import("../../internal-agents/schema.js").Schema<"source-url">;
|
|
327
|
+
sourceId: import("../../internal-agents/schema.js").Schema<string>;
|
|
328
|
+
url: import("../../internal-agents/schema.js").Schema<string>;
|
|
329
|
+
title: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
330
|
+
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
331
|
+
type: import("../../internal-agents/schema.js").Schema<"source-document">;
|
|
332
|
+
sourceId: import("../../internal-agents/schema.js").Schema<string>;
|
|
333
|
+
title: import("../../internal-agents/schema.js").Schema<string>;
|
|
334
|
+
mediaType: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
335
|
+
filename: import("../../internal-agents/schema.js").Schema<string | undefined>;
|
|
292
336
|
}> | import("../../extensions/schema/schema-validator.js").InferShape<{
|
|
293
337
|
type: import("../../internal-agents/schema.js").Schema<"image">;
|
|
294
338
|
url: import("../../internal-agents/schema.js").Schema<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.schema.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/schemas/agent.schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,kCAAkC,CAAC;AAErF,eAAO,MAAM,sBAAsB,qGAElC,CAAC;AAEF,eAAO,MAAM,oBAAoB,sIAWhC,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;GASjC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;GAO/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MAAM,cAAc,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC;AACrF,yCAAyC;AACzC,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC;AACzE,kCAAkC;AAClC,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC;AACnF,yBAAyB;AACzB,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC"}
|
|
@@ -64,6 +64,19 @@ const inlineToolCallPartShape = (v) => v.object({
|
|
|
64
64
|
toolName: v.string(),
|
|
65
65
|
args: v.record(v.string(), v.unknown()),
|
|
66
66
|
});
|
|
67
|
+
const sourceUrlPartShape = (v) => v.object({
|
|
68
|
+
type: v.literal("source-url"),
|
|
69
|
+
sourceId: v.string(),
|
|
70
|
+
url: v.string(),
|
|
71
|
+
title: v.string().optional(),
|
|
72
|
+
});
|
|
73
|
+
const sourceDocumentPartShape = (v) => v.object({
|
|
74
|
+
type: v.literal("source-document"),
|
|
75
|
+
sourceId: v.string(),
|
|
76
|
+
title: v.string(),
|
|
77
|
+
mediaType: v.string().optional(),
|
|
78
|
+
filename: v.string().optional(),
|
|
79
|
+
});
|
|
67
80
|
export const getMessagePartSchema = defineSchema((v) => v.union([
|
|
68
81
|
v.object({
|
|
69
82
|
type: v.literal("text"),
|
|
@@ -78,6 +91,8 @@ export const getMessagePartSchema = defineSchema((v) => v.union([
|
|
|
78
91
|
getToolCallPartSchema(),
|
|
79
92
|
inlineToolCallPartShape(v),
|
|
80
93
|
getToolResultPartSchema(),
|
|
94
|
+
sourceUrlPartShape(v),
|
|
95
|
+
sourceDocumentPartShape(v),
|
|
81
96
|
v.object({
|
|
82
97
|
type: v.literal("image"),
|
|
83
98
|
url: v.string(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-ui-message-stream.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/chat-ui-message-stream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAmB,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAEV,aAAa,EACb,kBAAkB,EAClB,eAAe,EAChB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-ui-message-stream.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/chat-ui-message-stream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAmB,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAEV,aAAa,EACb,kBAAkB,EAClB,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAiB7B,kEAAkE;AAClE,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,gBAAgB,CAAC;IAC/B,eAAe,EAAE,gBAAgB,CAAC;IAClC,UAAU,EAAE;QACV,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,EAAE;YACjB,aAAa,CAAC,EAAE,MAAM,CAAC;YACvB,eAAe,CAAC,EAAE,MAAM,CAAC;YACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;SAC3B,CAAC;QACF,kBAAkB,EAAE;YAClB,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,eAAe,CAAC,EAAE,MAAM,CAAC;SAC1B,CAAC;QACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,uBAAuB,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AA;KAAE,KAAK,IAAI,CAAC;CAClF,CAAC;AAihBF,sDAAsD;AACtD,wBAAgB,uCAAuC,CAAC,gBAAgB,GAAG,eAAe,EACxF,KAAK,EAAE;IAAE,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;CAAE,EAC7C,OAAO,GAAE,0BAA0B,CAAC,gBAAgB,CAAM,GACzD,aAAa,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAgIpD"}
|
|
@@ -2,11 +2,14 @@ import * as dntShim from "../../../_dnt.shims.js";
|
|
|
2
2
|
import { createAgUiRuntimeChatStreamEncoder, } from "../ag-ui/runtime-chat-stream-encoder.js";
|
|
3
3
|
import { mergeToolInputDelta, parseToolInputObject, streamDataStreamEvents, stripLeadingEmptyObjectPlaceholder, } from "./data-stream.js";
|
|
4
4
|
import { normalizeChatMessageMetadata, normalizeChatUiMessageStream, } from "../../chat/chat-ui-message-helpers.js";
|
|
5
|
+
import { deriveKnowledgeSourceDocumentChunk } from "../../chat/knowledge-source-document.js";
|
|
5
6
|
function createFrameworkUiMessageState() {
|
|
6
7
|
return {
|
|
7
8
|
textBlocks: new Map(),
|
|
8
9
|
reasoningBlocks: new Map(),
|
|
9
10
|
toolParts: new Map(),
|
|
11
|
+
sourceDocumentParts: new Map(),
|
|
12
|
+
sourceUrlParts: new Map(),
|
|
10
13
|
dataParts: [],
|
|
11
14
|
pendingToolDeltas: new Map(),
|
|
12
15
|
nextOrder: 0,
|
|
@@ -66,10 +69,10 @@ function getParsedStreamedToolInput(inputText) {
|
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
function observeChatStreamEvent(input) {
|
|
69
|
-
const { event, responseMessageId, state } = input;
|
|
72
|
+
const { event, responseMessageId, state, replaceExistingSourceDocument = false } = input;
|
|
70
73
|
switch (event.type) {
|
|
71
74
|
case "text-start": {
|
|
72
|
-
const id = event.id || responseMessageId;
|
|
75
|
+
const id = event.contentId || event.id || responseMessageId;
|
|
73
76
|
if (!state.textBlocks.has(id)) {
|
|
74
77
|
state.textBlocks.set(id, { id, order: state.nextOrder, text: "" });
|
|
75
78
|
state.nextOrder += 1;
|
|
@@ -77,7 +80,7 @@ function observeChatStreamEvent(input) {
|
|
|
77
80
|
return;
|
|
78
81
|
}
|
|
79
82
|
case "text-delta": {
|
|
80
|
-
const id = event.id || responseMessageId;
|
|
83
|
+
const id = event.contentId || event.id || responseMessageId;
|
|
81
84
|
const existingBlock = state.textBlocks.get(id);
|
|
82
85
|
if (existingBlock) {
|
|
83
86
|
existingBlock.text += event.delta;
|
|
@@ -226,6 +229,38 @@ function observeChatStreamEvent(input) {
|
|
|
226
229
|
state.nextOrder += 1;
|
|
227
230
|
return;
|
|
228
231
|
}
|
|
232
|
+
case "source-document": {
|
|
233
|
+
const existingSource = state.sourceDocumentParts.get(event.sourceId);
|
|
234
|
+
if (existingSource && !replaceExistingSourceDocument) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
state.sourceDocumentParts.set(event.sourceId, {
|
|
238
|
+
type: "source-document",
|
|
239
|
+
sourceId: event.sourceId,
|
|
240
|
+
mediaType: event.mediaType,
|
|
241
|
+
title: event.title,
|
|
242
|
+
...(event.filename ? { filename: event.filename } : {}),
|
|
243
|
+
order: existingSource?.order ?? state.nextOrder,
|
|
244
|
+
});
|
|
245
|
+
if (!existingSource) {
|
|
246
|
+
state.nextOrder += 1;
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
case "source-url": {
|
|
251
|
+
if (state.sourceUrlParts.has(event.sourceId)) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
state.sourceUrlParts.set(event.sourceId, {
|
|
255
|
+
type: "source-url",
|
|
256
|
+
sourceId: event.sourceId,
|
|
257
|
+
url: event.url,
|
|
258
|
+
...(event.title ? { title: event.title } : {}),
|
|
259
|
+
order: state.nextOrder,
|
|
260
|
+
});
|
|
261
|
+
state.nextOrder += 1;
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
229
264
|
default: {
|
|
230
265
|
if (!event.type.startsWith("data-")) {
|
|
231
266
|
return;
|
|
@@ -322,6 +357,14 @@ function buildResponseMessageParts(state) {
|
|
|
322
357
|
part,
|
|
323
358
|
});
|
|
324
359
|
}
|
|
360
|
+
for (const sourceDocumentPart of state.sourceDocumentParts.values()) {
|
|
361
|
+
const { order, ...part } = sourceDocumentPart;
|
|
362
|
+
orderedParts.push({ order, part });
|
|
363
|
+
}
|
|
364
|
+
for (const sourceUrlPart of state.sourceUrlParts.values()) {
|
|
365
|
+
const { order, ...part } = sourceUrlPart;
|
|
366
|
+
orderedParts.push({ order, part });
|
|
367
|
+
}
|
|
325
368
|
for (const dataPart of state.dataParts) {
|
|
326
369
|
orderedParts.push({
|
|
327
370
|
order: dataPart.order,
|
|
@@ -391,6 +434,7 @@ export function createChatUiMessageStreamFromDataStream(input, options = {}) {
|
|
|
391
434
|
onError: options.onError,
|
|
392
435
|
});
|
|
393
436
|
const materializedToolCallIds = new Set();
|
|
437
|
+
const derivedSourceDocumentIds = new Set();
|
|
394
438
|
let finishReason = "stop";
|
|
395
439
|
return normalizeChatUiMessageStream((async function* () {
|
|
396
440
|
const ensureStepStarted = function* (shouldStartStep) {
|
|
@@ -411,15 +455,41 @@ export function createChatUiMessageStreamFromDataStream(input, options = {}) {
|
|
|
411
455
|
const chatEvents = chatEventEncoder.encode(event);
|
|
412
456
|
finishReason = chatEventEncoder.state.finishReason;
|
|
413
457
|
for (const chatEvent of chatEvents) {
|
|
458
|
+
const replacesDerivedSourceDocument = chatEvent.type === "source-document" &&
|
|
459
|
+
state.sourceDocumentParts.has(chatEvent.sourceId) &&
|
|
460
|
+
derivedSourceDocumentIds.delete(chatEvent.sourceId);
|
|
461
|
+
const isDuplicateSourceDocument = chatEvent.type === "source-document" &&
|
|
462
|
+
state.sourceDocumentParts.has(chatEvent.sourceId) &&
|
|
463
|
+
!replacesDerivedSourceDocument;
|
|
464
|
+
const isDuplicateSourceUrl = chatEvent.type === "source-url" &&
|
|
465
|
+
state.sourceUrlParts.has(chatEvent.sourceId);
|
|
414
466
|
observeChatStreamEvent({
|
|
415
467
|
event: chatEvent,
|
|
416
468
|
responseMessageId,
|
|
417
469
|
state,
|
|
470
|
+
replaceExistingSourceDocument: replacesDerivedSourceDocument,
|
|
418
471
|
});
|
|
419
472
|
const chunk = toUiChunk(chatEvent);
|
|
420
|
-
if (chunk) {
|
|
473
|
+
if (chunk && !isDuplicateSourceDocument && !isDuplicateSourceUrl) {
|
|
421
474
|
yield chunk;
|
|
422
475
|
}
|
|
476
|
+
if (chatEvent.type !== "tool-output-available") {
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
const sourceChunk = deriveKnowledgeSourceDocumentChunk({
|
|
480
|
+
toolName: state.toolParts.get(chatEvent.toolCallId)?.toolName,
|
|
481
|
+
output: chatEvent.output,
|
|
482
|
+
});
|
|
483
|
+
if (!sourceChunk || state.sourceDocumentParts.has(sourceChunk.sourceId)) {
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
derivedSourceDocumentIds.add(sourceChunk.sourceId);
|
|
487
|
+
observeChatStreamEvent({
|
|
488
|
+
event: sourceChunk,
|
|
489
|
+
responseMessageId,
|
|
490
|
+
state,
|
|
491
|
+
});
|
|
492
|
+
yield sourceChunk;
|
|
423
493
|
}
|
|
424
494
|
}
|
|
425
495
|
for (const [toolCallId, pendingToolDelta] of state.pendingToolDeltas.entries()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork-runtime-part-mapper.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/fork-runtime-part-mapper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fork-runtime-part-mapper.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/fork-runtime-part-mapper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAM1E,OAAO,KAAK,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BAAuB,CACrC,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,uBAAuB,GAC7B,KAAK,CAAC,gBAAgB,GAAG,kBAAkB,CAAC,CAyD9C;AAMD,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAe5F;AA0ED,oDAAoD;AACpD,wBAAgB,mCAAmC,CACjD,KAAK,GAAE;IAAE,MAAM,CAAC,EAAE,uBAAuB,CAAA;CAAO,GAC/C,6BAA6B,CAO/B;AAED,6CAA6C;AAC7C,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE,6BAA6B,GACnC,QAAQ,EAAE,CAgKZ;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,GAAE;IAAE,MAAM,CAAC,EAAE,uBAAuB,CAAA;CAAO,GAC/C,6BAA6B,CAE/B;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE,6BAA6B,GACnC,QAAQ,EAAE,CAEZ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isRecord } from "../../chat/conversation.js";
|
|
2
|
+
import { toRenderableCustomChunk } from "../../chat/ag-ui-helpers.js";
|
|
2
3
|
import { safeJsonParse } from "../../chat/provider-errors.js";
|
|
3
4
|
import { mergeToolInputDelta, parseToolInputObject, stripLeadingEmptyObjectPlaceholder, } from "./data-stream.js";
|
|
4
5
|
function warnForkRuntimeStream(logger, message, metadata) {
|
|
@@ -86,6 +87,48 @@ function buildToolCallPartIfNeeded(toolCallId, state) {
|
|
|
86
87
|
},
|
|
87
88
|
];
|
|
88
89
|
}
|
|
90
|
+
function mapRenderableSourceToForkPart(value) {
|
|
91
|
+
const chunk = toRenderableCustomChunk(value);
|
|
92
|
+
if (!chunk) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
if (chunk.type === "source-url") {
|
|
96
|
+
return {
|
|
97
|
+
type: "source",
|
|
98
|
+
id: chunk.sourceId,
|
|
99
|
+
sourceType: "url",
|
|
100
|
+
url: chunk.url,
|
|
101
|
+
...(chunk.title ? { title: chunk.title } : {}),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (chunk.type === "source-document") {
|
|
105
|
+
return {
|
|
106
|
+
type: "source",
|
|
107
|
+
id: chunk.sourceId,
|
|
108
|
+
sourceType: "document",
|
|
109
|
+
mediaType: chunk.mediaType,
|
|
110
|
+
title: chunk.title,
|
|
111
|
+
...(chunk.filename ? { filename: chunk.filename } : {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
function mapWrappedSourceDataToForkPart(event) {
|
|
117
|
+
if (!isRecord(event.data)) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const name = event.data.name;
|
|
121
|
+
if (name !== "source-document" && name !== "source-url") {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const sourcePart = mapRenderableSourceToForkPart(event.data.value);
|
|
125
|
+
if (!sourcePart ||
|
|
126
|
+
(name === "source-document" && sourcePart.sourceType !== "document") ||
|
|
127
|
+
(name === "source-url" && sourcePart.sourceType !== "url")) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return sourcePart;
|
|
131
|
+
}
|
|
89
132
|
/** State for create fork runtime stream mapping. */
|
|
90
133
|
export function createForkRuntimeStreamMappingState(input = {}) {
|
|
91
134
|
return {
|
|
@@ -104,6 +147,15 @@ export function mapAgUiRuntimeEventToForkParts(event, state) {
|
|
|
104
147
|
: [];
|
|
105
148
|
case "text-delta":
|
|
106
149
|
return typeof event.delta === "string" ? [{ type: "text-delta", text: event.delta }] : [];
|
|
150
|
+
case "source-document":
|
|
151
|
+
case "source-url": {
|
|
152
|
+
const sourcePart = mapRenderableSourceToForkPart(event);
|
|
153
|
+
return sourcePart ? [sourcePart] : [];
|
|
154
|
+
}
|
|
155
|
+
case "data": {
|
|
156
|
+
const sourcePart = mapWrappedSourceDataToForkPart(event);
|
|
157
|
+
return sourcePart ? [sourcePart] : [];
|
|
158
|
+
}
|
|
107
159
|
case "tool-input-start": {
|
|
108
160
|
const toolCallId = typeof event.toolCallId === "string" ? event.toolCallId : null;
|
|
109
161
|
const toolName = typeof event.toolName === "string" ? event.toolName : null;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { HostedStreamSourcePart } from "../../chat/hosted-ui-chunk-mapping.js";
|
|
1
2
|
interface ForkStreamPart {
|
|
2
3
|
type: "reasoning-delta" | "text-delta";
|
|
3
4
|
text: string;
|
|
4
5
|
}
|
|
6
|
+
export type ForkSourcePart = HostedStreamSourcePart;
|
|
5
7
|
interface ForkToolInputStartPart {
|
|
6
8
|
type: "tool-input-start";
|
|
7
9
|
toolCallId: string;
|
|
@@ -54,7 +56,7 @@ export interface ForkRuntimeStep {
|
|
|
54
56
|
finishReason: string | null;
|
|
55
57
|
}
|
|
56
58
|
/** Public API contract for fork part. */
|
|
57
|
-
export type ForkPart = ForkStreamPart | ForkToolInputStartPart | ForkToolInputDeltaPart | ForkToolCallPart | ForkToolResultPart | ForkToolErrorPart | ForkErrorPart;
|
|
59
|
+
export type ForkPart = ForkStreamPart | ForkSourcePart | ForkToolInputStartPart | ForkToolInputDeltaPart | ForkToolCallPart | ForkToolResultPart | ForkToolErrorPart | ForkErrorPart;
|
|
58
60
|
/** Public API contract for fork runtime stream logger. */
|
|
59
61
|
export type ForkRuntimeStreamLogger = {
|
|
60
62
|
warn: (message: string, metadata?: Record<string, unknown>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork-runtime-types.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/fork-runtime-types.ts"],"names":[],"mappings":"AAAA,UAAU,cAAc;IACtB,IAAI,EAAE,iBAAiB,GAAG,YAAY,CAAC;IACvC,IAAI,EAAE,MAA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C,CAAC;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,yCAAyC;AACzC,MAAM,MAAM,QAAQ,GAChB,cAAc,GACd,sBAAsB,GACtB,sBAAsB,GACtB,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,aAAa,CAAC;AAElB,0DAA0D;AAC1D,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACrE,CAAC"}
|
|
1
|
+
{"version":3,"file":"fork-runtime-types.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/fork-runtime-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAEpF,UAAU,cAAc;IACtB,IAAI,EAAE,iBAAiB,GAAG,YAAY,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAEpD,UAAU,sBAAsB;IAC9B,IAAI,EAAE,kBAAkB,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,sBAAsB;IAC9B,IAAI,EAAE,kBAAkB,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,UAAU,iBAAiB;IACzB,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;CACd;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;CACd;AAED,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC,CAAC;IACH,WAAW,EAAE,KAAK,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,OAAO,CAAC;QACf,MAAM,EAAE,OAAO,CAAC;KACjB,CAAC,CAAC;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,yCAAyC;AACzC,MAAM,MAAM,QAAQ,GAChB,cAAc,GACd,cAAc,GACd,sBAAsB,GACtB,sBAAsB,GACtB,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,aAAa,CAAC;AAElB,0DAA0D;AAC1D,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACrE,CAAC"}
|
|
@@ -47,6 +47,7 @@ export interface CreateHostedMirroredUiStreamInput {
|
|
|
47
47
|
mirroredToolChunkState: MirroredToolChunkState;
|
|
48
48
|
appendChunk?: (chunk: ChatUiMessageChunk<ChatMessageMetadata>) => Promise<void> | void;
|
|
49
49
|
setMirroredOutput?: (value: boolean) => void;
|
|
50
|
+
registerPendingDerivedSourceFlush?: (flush: () => Promise<void>) => void;
|
|
50
51
|
logger?: HostedMirroredUiStreamLogger;
|
|
51
52
|
}
|
|
52
53
|
/** Input payload for close hosted mirrored open tool calls. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mirrored-tool-chunk-state.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/mirrored-tool-chunk-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGtF,yDAAyD;AACzD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,GAC7C,OAAO,CAoBT;AAED,qCAAqC;AACrC,MAAM,WAAW,sBAAsB;IACrC,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,yBAAyB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,0BAA0B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,uBAAuB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,4CAA4C;AAC5C,wBAAgB,4BAA4B,IAAI,sBAAsB,CASrE;AAED,2CAA2C;AAC3C,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,sBAAsB,GAC5B,sBAAsB,CASxB;AAED,4CAA4C;AAC5C,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,GAC7C,IAAI,CAsCN;AAED,+CAA+C;AAC/C,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAA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AK,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,KAC3C,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,gCAAgC,CAAC;CAC3C;AAUD,+CAA+C;AAC/C,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,CAQ5E;AAED,+BAA+B;AAC/B,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,sBAAsB,GAC5B,aAAa,CAyBf;AAED,oDAAoD;AACpD,wBAAsB,gCAAgC,CACpD,KAAK,EAAE,qCAAqC,GAC3C,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED,wCAAwC;AACxC,wBAAuB,4BAA4B,CACjD,KAAK,EAAE,iCAAiC,GACvC,aAAa,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"mirrored-tool-chunk-state.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/mirrored-tool-chunk-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGtF,yDAAyD;AACzD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,GAC7C,OAAO,CAoBT;AAED,qCAAqC;AACrC,MAAM,WAAW,sBAAsB;IACrC,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,yBAAyB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvC,0BAA0B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,uBAAuB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,4CAA4C;AAC5C,wBAAgB,4BAA4B,IAAI,sBAAsB,CASrE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AAkB,CAAC,mBAAmB,CAAC,KAC3C,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1B,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,iCAAiC,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IACzE,MAAM,CAAC,EAAE,4BAA4B,CAAC;CACvC;AAED,+DAA+D;AAC/D,MAAM,WAAW,qCAAqC;IACpD,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,CACX,KAAK,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,KAC3C,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,gCAAgC,CAAC;CAC3C;AAUD,+CAA+C;AAC/C,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,CAQ5E;AAED,+BAA+B;AAC/B,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,sBAAsB,GAC5B,aAAa,CAyBf;AAED,oDAAoD;AACpD,wBAAsB,gCAAgC,CACpD,KAAK,EAAE,qCAAqC,GAC3C,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED,wCAAwC;AACxC,wBAAuB,4BAA4B,CACjD,KAAK,EAAE,iCAAiC,GACvC,aAAa,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC,CAwIxD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { deriveKnowledgeSourceDocumentChunk } from "
|
|
1
|
+
import { deriveKnowledgeSourceDocumentChunk } from "../../chat/knowledge-source-document.js";
|
|
2
2
|
/** Check whether a durable chunk mirrors tool output. */
|
|
3
3
|
export function isDurableMirroredOutputChunk(chunk) {
|
|
4
4
|
switch (chunk.type) {
|
|
@@ -151,39 +151,106 @@ export async function closeHostedMirroredOpenToolCalls(input) {
|
|
|
151
151
|
export async function* createHostedMirroredUiStream(input) {
|
|
152
152
|
let streamError = null;
|
|
153
153
|
const emittedKnowledgeSourceIds = new Set();
|
|
154
|
+
const mirroredKnowledgeSourceIds = new Set();
|
|
155
|
+
const emittedDerivedKnowledgeSourceIds = new Set();
|
|
156
|
+
let pendingDerivedSource = null;
|
|
157
|
+
const mirrorChunk = async (chunk) => {
|
|
158
|
+
input.rootStreamWatchdog.observe(chunk);
|
|
159
|
+
if (isDurableMirroredOutputChunk(chunk)) {
|
|
160
|
+
input.setMirroredOutput?.(true);
|
|
161
|
+
}
|
|
162
|
+
recordMirroredToolChunkState(input.mirroredToolChunkState, chunk);
|
|
163
|
+
if (input.appendChunk) {
|
|
164
|
+
await Promise.resolve(input.appendChunk(chunk)).catch((error) => {
|
|
165
|
+
input.logger?.error("Durable run mirror failed to handle chunk", {
|
|
166
|
+
chunkType: chunk.type,
|
|
167
|
+
error: error instanceof Error ? error.message : String(error),
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
const takePendingDerivedSource = () => {
|
|
173
|
+
const source = pendingDerivedSource;
|
|
174
|
+
pendingDerivedSource = null;
|
|
175
|
+
if (!source || emittedKnowledgeSourceIds.has(source.sourceId)) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
emittedKnowledgeSourceIds.add(source.sourceId);
|
|
179
|
+
return source;
|
|
180
|
+
};
|
|
181
|
+
const mirrorSourceOnce = async (source) => {
|
|
182
|
+
if (mirroredKnowledgeSourceIds.has(source.sourceId)) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
mirroredKnowledgeSourceIds.add(source.sourceId);
|
|
186
|
+
await mirrorChunk(source);
|
|
187
|
+
};
|
|
188
|
+
input.registerPendingDerivedSourceFlush?.(async () => {
|
|
189
|
+
if (!pendingDerivedSource || emittedKnowledgeSourceIds.has(pendingDerivedSource.sourceId)) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
await mirrorSourceOnce(pendingDerivedSource);
|
|
193
|
+
});
|
|
154
194
|
try {
|
|
155
195
|
for await (const sourceChunk of input.sourceStream) {
|
|
196
|
+
if (pendingDerivedSource &&
|
|
197
|
+
sourceChunk.type === "source-document" &&
|
|
198
|
+
sourceChunk.sourceId === pendingDerivedSource.sourceId) {
|
|
199
|
+
pendingDerivedSource = null;
|
|
200
|
+
if (!emittedKnowledgeSourceIds.has(sourceChunk.sourceId)) {
|
|
201
|
+
emittedKnowledgeSourceIds.add(sourceChunk.sourceId);
|
|
202
|
+
mirroredKnowledgeSourceIds.add(sourceChunk.sourceId);
|
|
203
|
+
await mirrorChunk(sourceChunk);
|
|
204
|
+
yield sourceChunk;
|
|
205
|
+
}
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const pendingSource = takePendingDerivedSource();
|
|
209
|
+
if (pendingSource) {
|
|
210
|
+
emittedDerivedKnowledgeSourceIds.add(pendingSource.sourceId);
|
|
211
|
+
await mirrorSourceOnce(pendingSource);
|
|
212
|
+
yield pendingSource;
|
|
213
|
+
}
|
|
214
|
+
if (sourceChunk.type === "source-document") {
|
|
215
|
+
if (emittedKnowledgeSourceIds.has(sourceChunk.sourceId)) {
|
|
216
|
+
if (emittedDerivedKnowledgeSourceIds.delete(sourceChunk.sourceId)) {
|
|
217
|
+
await mirrorChunk(sourceChunk);
|
|
218
|
+
yield sourceChunk;
|
|
219
|
+
}
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
emittedKnowledgeSourceIds.add(sourceChunk.sourceId);
|
|
223
|
+
await mirrorSourceOnce(sourceChunk);
|
|
224
|
+
yield sourceChunk;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
156
227
|
const derivedSource = sourceChunk.type === "tool-output-available"
|
|
157
228
|
? deriveKnowledgeSourceDocumentChunk({
|
|
158
229
|
toolName: input.mirroredToolChunkState.toolCallNames.get(sourceChunk.toolCallId),
|
|
159
230
|
output: sourceChunk.output,
|
|
160
231
|
})
|
|
161
232
|
: null;
|
|
162
|
-
const chunks = [sourceChunk];
|
|
163
233
|
if (derivedSource && !emittedKnowledgeSourceIds.has(derivedSource.sourceId)) {
|
|
164
|
-
|
|
165
|
-
chunks.push(derivedSource);
|
|
166
|
-
}
|
|
167
|
-
for (const chunk of chunks) {
|
|
168
|
-
input.rootStreamWatchdog.observe(chunk);
|
|
169
|
-
if (isDurableMirroredOutputChunk(chunk)) {
|
|
170
|
-
input.setMirroredOutput?.(true);
|
|
171
|
-
}
|
|
172
|
-
recordMirroredToolChunkState(input.mirroredToolChunkState, chunk);
|
|
173
|
-
if (input.appendChunk) {
|
|
174
|
-
await Promise.resolve(input.appendChunk(chunk)).catch((error) => {
|
|
175
|
-
input.logger?.error("Durable run mirror failed to handle chunk", {
|
|
176
|
-
chunkType: chunk.type,
|
|
177
|
-
error: error instanceof Error ? error.message : String(error),
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
yield chunk;
|
|
234
|
+
pendingDerivedSource = derivedSource;
|
|
182
235
|
}
|
|
236
|
+
await mirrorChunk(sourceChunk);
|
|
237
|
+
yield sourceChunk;
|
|
238
|
+
}
|
|
239
|
+
const pendingSource = takePendingDerivedSource();
|
|
240
|
+
if (pendingSource) {
|
|
241
|
+
emittedDerivedKnowledgeSourceIds.add(pendingSource.sourceId);
|
|
242
|
+
await mirrorSourceOnce(pendingSource);
|
|
243
|
+
yield pendingSource;
|
|
183
244
|
}
|
|
184
245
|
}
|
|
185
246
|
catch (error) {
|
|
186
247
|
streamError = error;
|
|
248
|
+
const pendingSource = takePendingDerivedSource();
|
|
249
|
+
if (pendingSource) {
|
|
250
|
+
emittedDerivedKnowledgeSourceIds.add(pendingSource.sourceId);
|
|
251
|
+
await mirrorSourceOnce(pendingSource);
|
|
252
|
+
yield pendingSource;
|
|
253
|
+
}
|
|
187
254
|
throw error;
|
|
188
255
|
}
|
|
189
256
|
finally {
|
|
@@ -48,6 +48,12 @@ export declare const getMessagePartSchema: () => import("../internal-agents/sche
|
|
|
48
48
|
url: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
49
49
|
title: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
50
50
|
quote: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
51
|
+
}> | import("../extensions/schema/schema-validator.js").InferShape<{
|
|
52
|
+
type: import("../internal-agents/schema.js").Schema<"source_document">;
|
|
53
|
+
source_id: import("../internal-agents/schema.js").Schema<string>;
|
|
54
|
+
media_type: import("../internal-agents/schema.js").Schema<string>;
|
|
55
|
+
title: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
56
|
+
filename: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
51
57
|
}> | import("../extensions/schema/schema-validator.js").InferShape<{
|
|
52
58
|
type: import("../internal-agents/schema.js").Schema<"step_start">;
|
|
53
59
|
}> | import("../extensions/schema/schema-validator.js").InferShape<{
|
|
@@ -131,6 +137,12 @@ export declare const getApiMessageSchema: () => import("../internal-agents/schem
|
|
|
131
137
|
url: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
132
138
|
title: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
133
139
|
quote: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
140
|
+
}> | import("../extensions/schema/schema-validator.js").InferShape<{
|
|
141
|
+
type: import("../internal-agents/schema.js").Schema<"source_document">;
|
|
142
|
+
source_id: import("../internal-agents/schema.js").Schema<string>;
|
|
143
|
+
media_type: import("../internal-agents/schema.js").Schema<string>;
|
|
144
|
+
title: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
145
|
+
filename: import("../internal-agents/schema.js").Schema<string | undefined>;
|
|
134
146
|
}> | import("../extensions/schema/schema-validator.js").InferShape<{
|
|
135
147
|
type: import("../internal-agents/schema.js").Schema<"step_start">;
|
|
136
148
|
}> | import("../extensions/schema/schema-validator.js").InferShape<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/src/chat/conversation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAEV,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,QAAA,MAAM,gCAAgC,eAAuD,CAAC;AAE9F,8DAA8D;AAC9D,MAAM,MAAM,gCAAgC,GAAG,oBAAoB,GAAG;IACpE,CAAC,gCAAgC,CAAC,CAAC,EAAE,MAAM,CAAC;CAC7C,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,GAAG,SAAS,CAEjG;AAED,6EAA6E;AAC7E,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,oBAAoB,EAC7B,QAAQ,EAAE,MAAM,GACf,oBAAoB,CAQtB;AAED,uFAAuF;AACvF,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,oBAAoB,EAC7E,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,CAAC,GACR,CAAC,CAGH;AAED,uCAAuC;AACvC,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/src/chat/conversation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAEV,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,QAAA,MAAM,gCAAgC,eAAuD,CAAC;AAE9F,8DAA8D;AAC9D,MAAM,MAAM,gCAAgC,GAAG,oBAAoB,GAAG;IACpE,CAAC,gCAAgC,CAAC,CAAC,EAAE,MAAM,CAAC;CAC7C,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,GAAG,SAAS,C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AA6C;AAC7C,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAChB,aAAa,CAaf;AA8BD,iDAAiD;AACjD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAOpE;AAED,mDAAmD;AACnD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAOxE;AAED,4CAA4C;AAC5C,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEhE;AAED,iDAAiD;AACjD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAK1E;AAED,2CAA2C;AAC3C,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAoB5E;AAmdD,sDAAsD;AACtD,wBAAgB,wCAAwC,CACtD,QAAQ,EAAE,aAAa,EAAE,GACxB,oBAAoB,EAAE,CAmCxB"}
|
|
@@ -61,6 +61,13 @@ export const getMessagePartSchema = defineSchema((v) => v.discriminatedUnion("ty
|
|
|
61
61
|
title: v.string().optional(),
|
|
62
62
|
quote: v.string().optional(),
|
|
63
63
|
}),
|
|
64
|
+
v.object({
|
|
65
|
+
type: v.literal("source_document"),
|
|
66
|
+
source_id: v.string(),
|
|
67
|
+
media_type: v.string(),
|
|
68
|
+
title: v.string().optional(),
|
|
69
|
+
filename: v.string().optional(),
|
|
70
|
+
}),
|
|
64
71
|
v.object({ type: v.literal("step_start") }),
|
|
65
72
|
v.object({
|
|
66
73
|
type: v.literal("error"),
|
|
@@ -291,10 +298,20 @@ export function toConversationPartsFromUiMessage(message) {
|
|
|
291
298
|
continue;
|
|
292
299
|
}
|
|
293
300
|
if (part.type === "source-document") {
|
|
301
|
+
if (!part.mediaType) {
|
|
302
|
+
parts.push({
|
|
303
|
+
type: "citation",
|
|
304
|
+
source_id: part.sourceId,
|
|
305
|
+
title: part.title,
|
|
306
|
+
});
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
294
309
|
parts.push({
|
|
295
|
-
type: "
|
|
310
|
+
type: "source_document",
|
|
296
311
|
source_id: part.sourceId,
|
|
312
|
+
media_type: part.mediaType,
|
|
297
313
|
title: part.title,
|
|
314
|
+
...(part.filename ? { filename: part.filename } : {}),
|
|
298
315
|
});
|
|
299
316
|
continue;
|
|
300
317
|
}
|