veryfront 0.1.1011 → 0.1.1012
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/hosted/chat-execution-runtime.d.ts +4 -0
- package/esm/src/agent/hosted/chat-execution-runtime.d.ts.map +1 -1
- package/esm/src/agent/hosted/chat-execution-runtime.js +54 -2
- 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
|
@@ -48,6 +48,8 @@ export interface CreateHostedChatExecutionRuntimeBootstrapInput {
|
|
|
48
48
|
abortSignal: AbortSignal;
|
|
49
49
|
traceStream?: <T>(operation: () => Promise<T>) => Promise<T>;
|
|
50
50
|
createRootStreamWatchdog?: () => HostedChatExecutionRootStreamWatchdog;
|
|
51
|
+
streamBootstrapKeepaliveIntervalMs?: number;
|
|
52
|
+
streamBootstrapTimeoutMs?: number;
|
|
51
53
|
}
|
|
52
54
|
/** Input payload for create hosted chat execution runtime. */
|
|
53
55
|
export interface CreateHostedChatExecutionRuntimeInput {
|
|
@@ -92,6 +94,8 @@ export interface CreateBootstrappedHostedChatExecutionRuntimeInput {
|
|
|
92
94
|
terminalErrorCode?: string;
|
|
93
95
|
incompleteToolCallsPartErrorText?: string;
|
|
94
96
|
createRootStreamWatchdog?: CreateHostedChatExecutionRuntimeBootstrapInput["createRootStreamWatchdog"];
|
|
97
|
+
streamBootstrapKeepaliveIntervalMs?: CreateHostedChatExecutionRuntimeBootstrapInput["streamBootstrapKeepaliveIntervalMs"];
|
|
98
|
+
streamBootstrapTimeoutMs?: CreateHostedChatExecutionRuntimeBootstrapInput["streamBootstrapTimeoutMs"];
|
|
95
99
|
createTerminalAdapter?: CreateHostedRootRunLifecycleRuntimeAdapterInput["createTerminalAdapter"];
|
|
96
100
|
}
|
|
97
101
|
/** Public API contract for bootstrapped hosted chat execution runtime. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-execution-runtime.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/chat-execution-runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat-execution-runtime.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/chat-execution-runtime.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAC9F,OAAO,EAGL,KAAK,+CAA+C,EACpD,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC5B,6BAA6B,EAE9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,KAAK,oCAAoC,EAK1C,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAGL,KAAK,6BAA6B,EAClC,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACrC,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EACL,wBAAwB,EAEzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,qCAAqC,CAAC;AAC/F,YAAY,EAAE,mCAAmC,EAAE,MAAM,qCAAqC,CAAC;AAQ/F,6DAA6D;AAC7D,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,aAAa,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC;IAClE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,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CAAC;CAC1C,GAAG,CACF,SAAS,EAAE,OAAO,KACf,OAAO,CAAC,+BAA+B,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC,CA2BjF;AAmJD,4CAA4C;AAC5C,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,qCAAqC,GAC3C,0BAA0B,CAwH5B"}
|
|
@@ -6,9 +6,11 @@ import { dispatchConversationHostedStreamErrorState, dispatchConversationHostedT
|
|
|
6
6
|
import { createHostedMirroredUiStream, createMirroredToolChunkState, } from "../streaming/mirrored-tool-chunk-state.js";
|
|
7
7
|
import { finalizeHostedDetached, finalizeHostedResponse, } from "./stream-finalization.js";
|
|
8
8
|
import { getEmptyHostedFinalizedMessageTerminalError, getHostedStreamErrorText, shouldFailEmptyHostedFinalizedMessage, } from "./stream-terminal-error.js";
|
|
9
|
-
import { createChatStreamWatchdog } from "../../chat/stream-watchdog.js";
|
|
9
|
+
import { createChatStreamWatchdog, DEFAULT_CHAT_STREAM_TOOL_RUNNING_TIMEOUT_MS, } from "../../chat/stream-watchdog.js";
|
|
10
10
|
const INCOMPLETE_TOOL_CALLS_PART_ERROR_TEXT = "Assistant ended before tool execution completed";
|
|
11
11
|
const FINALIZATION_TERMINAL_STATE_FALLBACK_MODEL_ID = "";
|
|
12
|
+
const DEFAULT_STREAM_BOOTSTRAP_KEEPALIVE_INTERVAL_MS = 30_000;
|
|
13
|
+
const DEFAULT_STREAM_BOOTSTRAP_TIMEOUT_MS = DEFAULT_CHAT_STREAM_TOOL_RUNNING_TIMEOUT_MS;
|
|
12
14
|
/** State for to hosted chat execution final. */
|
|
13
15
|
export function toHostedChatExecutionFinalState(input) {
|
|
14
16
|
return toConversationHostedTerminalState({
|
|
@@ -37,6 +39,42 @@ function createHostedChatExecutionCleanup(cleanup) {
|
|
|
37
39
|
function createDefaultHostedChatExecutionRootStreamWatchdog() {
|
|
38
40
|
return createChatStreamWatchdog();
|
|
39
41
|
}
|
|
42
|
+
function resolveStreamBootstrapKeepaliveIntervalMs(intervalMs) {
|
|
43
|
+
if (typeof intervalMs !== "number" || !Number.isFinite(intervalMs) || intervalMs <= 0) {
|
|
44
|
+
return DEFAULT_STREAM_BOOTSTRAP_KEEPALIVE_INTERVAL_MS;
|
|
45
|
+
}
|
|
46
|
+
return intervalMs;
|
|
47
|
+
}
|
|
48
|
+
function resolveStreamBootstrapTimeoutMs(timeoutMs) {
|
|
49
|
+
if (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
50
|
+
return DEFAULT_STREAM_BOOTSTRAP_TIMEOUT_MS;
|
|
51
|
+
}
|
|
52
|
+
return timeoutMs;
|
|
53
|
+
}
|
|
54
|
+
function createStreamBootstrapWatchdogKeepalive(input) {
|
|
55
|
+
const intervalMs = resolveStreamBootstrapKeepaliveIntervalMs(input.intervalMs);
|
|
56
|
+
const timeoutMs = resolveStreamBootstrapTimeoutMs(input.timeoutMs);
|
|
57
|
+
const timeoutController = new AbortController();
|
|
58
|
+
const interval = globalThis.setInterval(() => {
|
|
59
|
+
input.rootStreamWatchdog.observe({
|
|
60
|
+
type: "message-metadata",
|
|
61
|
+
messageMetadata: {
|
|
62
|
+
createdAt: new Date().toISOString(),
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}, intervalMs);
|
|
66
|
+
const timeout = globalThis.setTimeout(() => {
|
|
67
|
+
timeoutController.abort(new DOMException(`Chat stream bootstrap timeout after ${timeoutMs}ms`, "AbortError"));
|
|
68
|
+
clearInterval(interval);
|
|
69
|
+
}, timeoutMs);
|
|
70
|
+
return {
|
|
71
|
+
signal: timeoutController.signal,
|
|
72
|
+
dispose: () => {
|
|
73
|
+
clearInterval(interval);
|
|
74
|
+
clearTimeout(timeout);
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
40
78
|
function traceHostedChatRuntimeStream(traceStream, operation) {
|
|
41
79
|
if (!traceStream) {
|
|
42
80
|
return operation();
|
|
@@ -53,7 +91,16 @@ export async function createHostedChatExecutionRuntimeBootstrap(input) {
|
|
|
53
91
|
const rootStreamWatchdog = input.createRootStreamWatchdog
|
|
54
92
|
? input.createRootStreamWatchdog()
|
|
55
93
|
: createDefaultHostedChatExecutionRootStreamWatchdog();
|
|
56
|
-
const
|
|
94
|
+
const bootstrapKeepalive = createStreamBootstrapWatchdogKeepalive({
|
|
95
|
+
rootStreamWatchdog,
|
|
96
|
+
intervalMs: input.streamBootstrapKeepaliveIntervalMs,
|
|
97
|
+
timeoutMs: input.streamBootstrapTimeoutMs,
|
|
98
|
+
});
|
|
99
|
+
const streamAbortSignal = AbortSignal.any([
|
|
100
|
+
input.abortSignal,
|
|
101
|
+
rootStreamWatchdog.signal,
|
|
102
|
+
bootstrapKeepalive.signal,
|
|
103
|
+
]);
|
|
57
104
|
let streamResult;
|
|
58
105
|
try {
|
|
59
106
|
streamResult = await traceHostedChatRuntimeStream(input.traceStream, () => input.agent.stream({
|
|
@@ -65,6 +112,9 @@ export async function createHostedChatExecutionRuntimeBootstrap(input) {
|
|
|
65
112
|
rootStreamWatchdog.dispose();
|
|
66
113
|
throw error;
|
|
67
114
|
}
|
|
115
|
+
finally {
|
|
116
|
+
bootstrapKeepalive.dispose();
|
|
117
|
+
}
|
|
68
118
|
return {
|
|
69
119
|
cleanup,
|
|
70
120
|
lifecycleAdapter: input.lifecycleAdapter,
|
|
@@ -100,6 +150,8 @@ async function createBootstrappedHostedChatRuntime(input, agentRunSpan) {
|
|
|
100
150
|
...(input.createRootStreamWatchdog
|
|
101
151
|
? { createRootStreamWatchdog: input.createRootStreamWatchdog }
|
|
102
152
|
: {}),
|
|
153
|
+
streamBootstrapKeepaliveIntervalMs: input.streamBootstrapKeepaliveIntervalMs,
|
|
154
|
+
streamBootstrapTimeoutMs: input.streamBootstrapTimeoutMs,
|
|
103
155
|
});
|
|
104
156
|
}
|
|
105
157
|
catch (error) {
|