veryfront 0.1.620 → 0.1.621
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/deno.js +1 -1
- package/esm/src/agent/runtime/chat-stream-handler.d.ts +0 -9
- package/esm/src/agent/runtime/chat-stream-handler.d.ts.map +1 -1
- package/esm/src/agent/runtime/chat-stream-handler.js +29 -1
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
package/esm/deno.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model Runtime Stream Handler
|
|
3
|
-
*
|
|
4
|
-
* Processes model-runtime `streamText()` fullStream parts and emits SSE
|
|
5
|
-
* events in the Data Stream Protocol format. Stream parts map 1:1 to the
|
|
6
|
-
* framework SSE protocol with minimal field remapping.
|
|
7
|
-
*
|
|
8
|
-
* @module agent/runtime/chat-stream-handler
|
|
9
|
-
*/
|
|
10
1
|
import type { RuntimeStreamResult } from "./runtime-tool-types.js";
|
|
11
2
|
export interface StreamingToolCall {
|
|
12
3
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-stream-handler.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/chat-stream-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat-stream-handler.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/chat-stream-handler.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAqB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAiBtF,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;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
|
|
7
7
|
*
|
|
8
8
|
* @module agent/runtime/chat-stream-handler
|
|
9
9
|
*/
|
|
10
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
10
11
|
import { sendSSE } from "./sse-utils.js";
|
|
11
12
|
import { mergeToolCallInput, mergeToolInputDelta, parseToolInputObject, } from "../streaming/data-stream.js";
|
|
12
13
|
import { isDynamicTool } from "./tool-helpers.js";
|
|
@@ -16,6 +17,7 @@ import { setActiveSpanAttributes, withSpan } from "../../observability/tracing/o
|
|
|
16
17
|
import { getHostEnv } from "../../platform/compat/process.js";
|
|
17
18
|
import { stringifyToolError, throwIfAborted } from "./error-utils.js";
|
|
18
19
|
const logger = serverLogger.component("agent");
|
|
20
|
+
const LOCAL_TOOL_COMMIT_GRACE_MS = 250;
|
|
19
21
|
function isRecord(value) {
|
|
20
22
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21
23
|
}
|
|
@@ -118,6 +120,22 @@ async function readNextStreamPart(iterator, state) {
|
|
|
118
120
|
return { done: true, value: undefined };
|
|
119
121
|
}
|
|
120
122
|
}
|
|
123
|
+
async function readNextStreamPartWithTimeout(iterator, state, timeoutMs) {
|
|
124
|
+
let timeoutId;
|
|
125
|
+
try {
|
|
126
|
+
return await Promise.race([
|
|
127
|
+
readNextStreamPart(iterator, state),
|
|
128
|
+
new Promise((resolve) => {
|
|
129
|
+
timeoutId = dntShim.setTimeout(() => resolve("timeout"), timeoutMs);
|
|
130
|
+
}),
|
|
131
|
+
]);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
if (timeoutId) {
|
|
135
|
+
clearTimeout(timeoutId);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
121
139
|
export function createStreamState() {
|
|
122
140
|
return {
|
|
123
141
|
accumulatedText: "",
|
|
@@ -142,6 +160,7 @@ export function processStream(result, state, controller, encoder, textPartId, ca
|
|
|
142
160
|
let eventCount = 0;
|
|
143
161
|
let textOpen = false;
|
|
144
162
|
let activeReasoningId = null;
|
|
163
|
+
let shouldStopForCommittedLocalToolCall = false;
|
|
145
164
|
const normalizeReasoningId = (part) => typeof part.id === "string" && part.id.length > 0 ? part.id : "reasoning";
|
|
146
165
|
const openTextSegment = () => {
|
|
147
166
|
if (textOpen) {
|
|
@@ -251,7 +270,13 @@ export function processStream(result, state, controller, encoder, textPartId, ca
|
|
|
251
270
|
throwIfAborted(abortSignal);
|
|
252
271
|
const streamIterator = result.fullStream[Symbol.asyncIterator]();
|
|
253
272
|
while (true) {
|
|
254
|
-
const next =
|
|
273
|
+
const next = shouldStopForCommittedLocalToolCall
|
|
274
|
+
? await readNextStreamPartWithTimeout(streamIterator, state, LOCAL_TOOL_COMMIT_GRACE_MS)
|
|
275
|
+
: await readNextStreamPart(streamIterator, state);
|
|
276
|
+
if (next === "timeout") {
|
|
277
|
+
await streamIterator.return?.();
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
255
280
|
if (next.done) {
|
|
256
281
|
break;
|
|
257
282
|
}
|
|
@@ -368,6 +393,9 @@ export function processStream(result, state, controller, encoder, textPartId, ca
|
|
|
368
393
|
: {}),
|
|
369
394
|
...(dynamic ? { dynamic: true } : {}),
|
|
370
395
|
});
|
|
396
|
+
if (typedPart.providerExecuted !== true) {
|
|
397
|
+
shouldStopForCommittedLocalToolCall = true;
|
|
398
|
+
}
|
|
371
399
|
break;
|
|
372
400
|
}
|
|
373
401
|
case "tool-result": {
|