veryfront 0.1.1189 → 0.1.1190
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/analyze-chunks/command.d.ts.map +1 -1
- package/esm/cli/commands/analyze-chunks/command.js +3 -1
- package/esm/cli/commands/schedule/command-help.d.ts.map +1 -1
- package/esm/cli/commands/schedule/command-help.js +5 -1
- package/esm/cli/commands/schedule/handler.d.ts +17 -0
- package/esm/cli/commands/schedule/handler.d.ts.map +1 -1
- package/esm/cli/commands/schedule/handler.js +119 -29
- package/esm/cli/commands/webhook/command-help.d.ts.map +1 -1
- package/esm/cli/commands/webhook/command-help.js +5 -1
- package/esm/cli/commands/webhook/handler.d.ts +5 -0
- package/esm/cli/commands/webhook/handler.d.ts.map +1 -1
- package/esm/cli/commands/webhook/handler.js +62 -7
- package/esm/cli/templates/manifest.js +2 -2
- package/esm/deno.js +6 -3
- package/esm/src/agent/conversation/durable.d.ts.map +1 -1
- package/esm/src/agent/conversation/durable.js +61 -50
- package/esm/src/agent/conversation/private-run-event.d.ts +13 -0
- package/esm/src/agent/conversation/private-run-event.d.ts.map +1 -0
- package/esm/src/agent/conversation/private-run-event.js +38 -0
- package/esm/src/agent/conversation/run-event-limits.d.ts +6 -3
- package/esm/src/agent/conversation/run-event-limits.d.ts.map +1 -1
- package/esm/src/agent/conversation/run-event-limits.js +17 -3
- package/esm/src/agent/conversation/run-event-normalization.d.ts.map +1 -1
- package/esm/src/agent/conversation/run-event-normalization.js +5 -3
- package/esm/src/agent/hosted/chat-execution-runtime.d.ts +3 -3
- package/esm/src/agent/hosted/chat-execution-runtime.d.ts.map +1 -1
- package/esm/src/agent/hosted/chat-execution-runtime.js +14 -16
- package/esm/src/agent/hosted/child-fork-execution-runner.d.ts.map +1 -1
- package/esm/src/agent/hosted/child-fork-execution-runner.js +10 -12
- package/esm/src/agent/hosted/durable-run-event-sink.d.ts +10 -0
- package/esm/src/agent/hosted/durable-run-event-sink.d.ts.map +1 -0
- package/esm/src/agent/hosted/durable-run-event-sink.js +102 -0
- package/esm/src/agent/index.d.ts +2 -1
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +1 -0
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +0 -6
- package/esm/src/agent/types.d.ts +0 -7
- package/esm/src/agent/types.d.ts.map +1 -1
- package/esm/src/discovery/handlers/schedule-handler.d.ts.map +1 -1
- package/esm/src/discovery/handlers/schedule-handler.js +2 -1
- package/esm/src/discovery/handlers/webhook-handler.d.ts.map +1 -1
- package/esm/src/discovery/handlers/webhook-handler.js +2 -1
- package/esm/src/embedding/local-json-store-lock.d.ts +15 -0
- package/esm/src/embedding/local-json-store-lock.d.ts.map +1 -0
- package/esm/src/embedding/local-json-store-lock.js +457 -0
- package/esm/src/embedding/rag-store.d.ts.map +1 -1
- package/esm/src/embedding/rag-store.js +342 -165
- package/esm/src/errors/error-registry/agent.d.ts +2 -0
- package/esm/src/errors/error-registry/agent.d.ts.map +1 -1
- package/esm/src/errors/error-registry/agent.js +8 -0
- package/esm/src/errors/error-registry/server.d.ts +6 -0
- package/esm/src/errors/error-registry/server.d.ts.map +1 -1
- package/esm/src/errors/error-registry/server.js +18 -0
- package/esm/src/errors/error-registry.d.ts +3 -0
- package/esm/src/errors/error-registry.d.ts.map +1 -1
- package/esm/src/errors/index.d.ts +1 -1
- package/esm/src/errors/index.d.ts.map +1 -1
- package/esm/src/errors/index.js +2 -2
- package/esm/src/extensions/builtin-extensions.d.ts +10 -10
- package/esm/src/extensions/builtin-extensions.d.ts.map +1 -1
- package/esm/src/extensions/builtin-extensions.js +22 -63
- package/esm/src/extensions/first-party-defaults.d.ts +105 -0
- package/esm/src/extensions/first-party-defaults.d.ts.map +1 -0
- package/esm/src/extensions/first-party-defaults.js +178 -0
- package/esm/src/extensions/orchestrate.d.ts.map +1 -1
- package/esm/src/extensions/orchestrate.js +41 -4
- package/esm/src/extensions/websocket/node-websocket-server-provider.d.ts +4 -4
- package/esm/src/extensions/websocket/node-websocket-server-provider.d.ts.map +1 -1
- package/esm/src/extensions/websocket/node-websocket-server-provider.js +4 -4
- package/esm/src/html/hydration-script-builder/hydration-runtime.generated.js +1 -1
- package/esm/src/observability/instruments/instruments-factory.d.ts.map +1 -1
- package/esm/src/observability/instruments/instruments-factory.js +0 -8
- package/esm/src/observability/metrics/index.d.ts +1 -14
- package/esm/src/observability/metrics/index.d.ts.map +1 -1
- package/esm/src/observability/metrics/index.js +0 -28
- package/esm/src/observability/metrics/recorder.d.ts +1 -9
- package/esm/src/observability/metrics/recorder.d.ts.map +1 -1
- package/esm/src/observability/metrics/recorder.js +0 -12
- package/esm/src/observability/metrics/types.d.ts +0 -12
- package/esm/src/observability/metrics/types.d.ts.map +1 -1
- package/esm/src/observability/metrics/types.js +1 -17
- package/esm/src/platform/adapters/file-snapshot-error.d.ts +7 -0
- package/esm/src/platform/adapters/file-snapshot-error.d.ts.map +1 -1
- package/esm/src/platform/adapters/file-snapshot-error.js +13 -0
- package/esm/src/platform/adapters/fs/cache/size-estimator.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/cache/size-estimator.js +12 -2
- package/esm/src/platform/adapters/fs/github/cache-scope.d.ts +8 -0
- package/esm/src/platform/adapters/fs/github/cache-scope.d.ts.map +1 -0
- package/esm/src/platform/adapters/fs/github/cache-scope.js +12 -0
- package/esm/src/platform/adapters/fs/github/directory-operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/github/directory-operations.js +2 -1
- package/esm/src/platform/adapters/fs/github/path-utils.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/github/path-utils.js +27 -4
- package/esm/src/platform/adapters/fs/github/read-operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/github/read-operations.js +4 -3
- package/esm/src/platform/adapters/fs/github/stat-operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/github/stat-operations.js +3 -2
- package/esm/src/platform/adapters/fs/integration.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/integration.js +4 -0
- package/esm/src/platform/adapters/fs/veryfront/adapter-helpers.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/adapter-helpers.js +21 -6
- package/esm/src/platform/adapters/fs/veryfront/path-normalizer.d.ts +2 -0
- package/esm/src/platform/adapters/fs/veryfront/path-normalizer.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/path-normalizer.js +57 -5
- package/esm/src/platform/adapters/fs/veryfront/retry.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/retry.js +66 -13
- package/esm/src/platform/adapters/fs/veryfront/types.d.ts +3 -1
- package/esm/src/platform/adapters/fs/veryfront/types.d.ts.map +1 -1
- package/esm/src/platform/adapters/mock.d.ts.map +1 -1
- package/esm/src/platform/adapters/mock.js +3 -7
- package/esm/src/platform/adapters/path-containment.d.ts +9 -0
- package/esm/src/platform/adapters/path-containment.d.ts.map +1 -0
- package/esm/src/platform/adapters/path-containment.js +13 -0
- package/esm/src/platform/adapters/runtime/shared/native-snapshot-identity.d.ts +13 -0
- package/esm/src/platform/adapters/runtime/shared/native-snapshot-identity.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/native-snapshot-identity.js +12 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.d.ts +7 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.d.ts.map +1 -1
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.js +62 -18
- package/esm/src/rendering/app-route-resolver.d.ts +4 -5
- package/esm/src/rendering/app-route-resolver.d.ts.map +1 -1
- package/esm/src/rendering/app-route-resolver.js +142 -87
- package/esm/src/rendering/chunk-optimizer/contracts.d.ts +49 -0
- package/esm/src/rendering/chunk-optimizer/contracts.d.ts.map +1 -0
- package/esm/src/rendering/chunk-optimizer/contracts.js +1 -0
- package/esm/src/rendering/chunk-optimizer/data-properties.d.ts +12 -0
- package/esm/src/rendering/chunk-optimizer/data-properties.d.ts.map +1 -0
- package/esm/src/rendering/chunk-optimizer/data-properties.js +24 -0
- package/esm/src/rendering/chunk-optimizer/file-discovery.d.ts +3 -0
- package/esm/src/rendering/chunk-optimizer/file-discovery.d.ts.map +1 -0
- package/esm/src/rendering/chunk-optimizer/file-discovery.js +167 -0
- package/esm/src/rendering/chunk-optimizer/filesystem.d.ts +7 -0
- package/esm/src/rendering/chunk-optimizer/filesystem.d.ts.map +1 -0
- package/esm/src/rendering/chunk-optimizer/filesystem.js +51 -0
- package/esm/src/rendering/chunk-optimizer/limits.d.ts +23 -0
- package/esm/src/rendering/chunk-optimizer/limits.d.ts.map +1 -0
- package/esm/src/rendering/chunk-optimizer/limits.js +22 -0
- package/esm/src/rendering/chunk-optimizer/manifest.d.ts +4 -0
- package/esm/src/rendering/chunk-optimizer/manifest.d.ts.map +1 -0
- package/esm/src/rendering/chunk-optimizer/manifest.js +220 -0
- package/esm/src/rendering/chunk-optimizer/source-imports.d.ts +9 -0
- package/esm/src/rendering/chunk-optimizer/source-imports.d.ts.map +1 -0
- package/esm/src/rendering/chunk-optimizer/source-imports.js +359 -0
- package/esm/src/rendering/chunk-optimizer/specifier.d.ts +5 -0
- package/esm/src/rendering/chunk-optimizer/specifier.d.ts.map +1 -0
- package/esm/src/rendering/chunk-optimizer/specifier.js +10 -0
- package/esm/src/rendering/chunk-optimizer/suggestions.d.ts +3 -0
- package/esm/src/rendering/chunk-optimizer/suggestions.d.ts.map +1 -0
- package/esm/src/rendering/chunk-optimizer/suggestions.js +164 -0
- package/esm/src/rendering/chunk-optimizer.d.ts +10 -43
- package/esm/src/rendering/chunk-optimizer.d.ts.map +1 -1
- package/esm/src/rendering/chunk-optimizer.js +39 -161
- package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/pipeline.js +6 -2
- package/esm/src/rendering/page-resolution/page-resolver.d.ts +3 -2
- package/esm/src/rendering/page-resolution/page-resolver.d.ts.map +1 -1
- package/esm/src/rendering/page-resolution/page-resolver.js +21 -10
- package/esm/src/runtime/model-call-context.d.ts +7 -4
- package/esm/src/runtime/model-call-context.d.ts.map +1 -1
- package/esm/src/runtime/run-event-sink-context.d.ts +17 -0
- package/esm/src/runtime/run-event-sink-context.d.ts.map +1 -0
- package/esm/src/runtime/run-event-sink-context.js +47 -0
- package/esm/src/runtime/runtime-bridge.d.ts +0 -3
- package/esm/src/runtime/runtime-bridge.d.ts.map +1 -1
- package/esm/src/runtime/runtime-bridge.js +26 -8
- package/esm/src/security/http/outbound-fetch.d.ts +1 -0
- package/esm/src/security/http/outbound-fetch.d.ts.map +1 -1
- package/esm/src/security/http/outbound-fetch.js +14 -0
- package/esm/src/server/bootstrap.d.ts +1 -1
- package/esm/src/server/bootstrap.d.ts.map +1 -1
- package/esm/src/server/bootstrap.js +1 -1
- package/esm/src/server/dev-server/server.d.ts +1 -1
- package/esm/src/server/dev-server/server.d.ts.map +1 -1
- package/esm/src/server/dev-server/server.js +1 -1
- package/esm/src/server/handlers/request/api/api-handler-wrapper.d.ts.map +1 -1
- package/esm/src/server/handlers/request/api/api-handler-wrapper.js +7 -3
- package/esm/src/server/handlers/request/api/app-router-resolver.d.ts.map +1 -1
- package/esm/src/server/handlers/request/api/app-router-resolver.js +28 -30
- package/esm/src/server/service-server.d.ts +1 -1
- package/esm/src/server/service-server.d.ts.map +1 -1
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.d.ts.map +1 -1
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +2 -2
- package/esm/src/types/entities/getEntityInfo.d.ts +57 -3
- package/esm/src/types/entities/getEntityInfo.d.ts.map +1 -1
- package/esm/src/types/entities/getEntityInfo.js +1015 -231
- package/esm/src/types/entities.d.ts +9 -1
- package/esm/src/types/entities.d.ts.map +1 -1
- package/esm/src/types/entities.js +92 -0
- package/esm/src/utils/constants/limits.d.ts +2 -0
- package/esm/src/utils/constants/limits.d.ts.map +1 -1
- package/esm/src/utils/constants/limits.js +2 -0
- package/esm/src/utils/route-path-utils.d.ts +9 -0
- package/esm/src/utils/route-path-utils.d.ts.map +1 -1
- package/esm/src/utils/route-path-utils.js +56 -20
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +8 -6
- package/esm/src/agent/conversation/model-call-context-run-event.d.ts +0 -41
- package/esm/src/agent/conversation/model-call-context-run-event.d.ts.map +0 -1
- package/esm/src/agent/conversation/model-call-context-run-event.js +0 -74
- package/esm/src/agent/hosted/model-call-context-run-event-recorder.d.ts +0 -35
- package/esm/src/agent/hosted/model-call-context-run-event-recorder.d.ts.map +0 -1
- package/esm/src/agent/hosted/model-call-context-run-event-recorder.js +0 -266
- package/esm/src/observability/instruments/model-call-context-instruments.d.ts +0 -18
- package/esm/src/observability/instruments/model-call-context-instruments.d.ts.map +0 -1
- package/esm/src/observability/instruments/model-call-context-instruments.js +0 -25
- package/esm/src/runtime/model-call-recorder-context.d.ts +0 -8
- package/esm/src/runtime/model-call-recorder-context.d.ts.map +0 -1
- package/esm/src/runtime/model-call-recorder-context.js +0 -14
|
@@ -5,7 +5,8 @@ import { AppendConversationRunEventsError, isCursorMismatchConversationRunAppend
|
|
|
5
5
|
export { AppendConversationRunEventsResponseSchema, CompleteConversationRunResponseSchema, ConversationRunProjectionSchema, ConversationRunStatusSchema, ConversationRunTargetsSchema, CreateConversationRunAcceptedSchema, getAppendConversationRunEventsResponseSchema, getCompleteConversationRunResponseSchema, getConversationRunProjectionSchema, getConversationRunStatusSchema, getConversationRunTargetsSchema, getCreateConversationRunAcceptedSchema, resolveConversationRunTargets, } from "./durable-contracts.js";
|
|
6
6
|
export { AppendConversationRunEventsError, isCursorMismatchConversationRunAppendError, isIgnorableConversationRunAppendError, isPermanentAuthConversationRunAppendError, parseAppendConversationRunEventsErrorBody, } from "./durable-append-errors.js";
|
|
7
7
|
import { normalizeConversationRunEvents } from "./run-event-normalization.js";
|
|
8
|
-
import {
|
|
8
|
+
import { MAX_CONVERSATION_RUN_EVENT_APPEND_REQUEST_BYTES } from "./run-event-limits.js";
|
|
9
|
+
import { DurableRunEventPersistenceError, isPrivateConversationRunEvent, } from "./private-run-event.js";
|
|
9
10
|
const AGENT_RUN_API_TIMEOUT_MS = 15_000;
|
|
10
11
|
function createTimedAbortSignal(timeoutMs, abortSignal) {
|
|
11
12
|
const controller = new AbortController();
|
|
@@ -38,6 +39,40 @@ function createTimedAbortSignal(timeoutMs, abortSignal) {
|
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
const DEFAULT_MAX_CONVERSATION_RUN_BATCH_BYTES = 512 * 1024;
|
|
42
|
+
function backfillPurePrivateEventResponseCursor(responseBody, latestExternalEventSequence) {
|
|
43
|
+
if (!responseBody || typeof responseBody !== "object" || Array.isArray(responseBody)) {
|
|
44
|
+
return responseBody;
|
|
45
|
+
}
|
|
46
|
+
const body = responseBody;
|
|
47
|
+
const needsBodyCursor = body.latestExternalEventSequence === undefined &&
|
|
48
|
+
body.latest_external_event_sequence === undefined;
|
|
49
|
+
const run = body.run;
|
|
50
|
+
const runBody = run && typeof run === "object" && !Array.isArray(run)
|
|
51
|
+
? run
|
|
52
|
+
: undefined;
|
|
53
|
+
const needsRunCursor = runBody !== undefined &&
|
|
54
|
+
runBody.latestExternalEventSequence === undefined &&
|
|
55
|
+
runBody.latest_external_event_sequence === undefined;
|
|
56
|
+
if (!needsBodyCursor && !needsRunCursor) {
|
|
57
|
+
return responseBody;
|
|
58
|
+
}
|
|
59
|
+
const result = { ...body };
|
|
60
|
+
if (needsBodyCursor) {
|
|
61
|
+
const cursorKey = body.latestEventId !== undefined
|
|
62
|
+
? "latestExternalEventSequence"
|
|
63
|
+
: "latest_external_event_sequence";
|
|
64
|
+
result[cursorKey] = latestExternalEventSequence;
|
|
65
|
+
}
|
|
66
|
+
if (needsRunCursor && runBody) {
|
|
67
|
+
const runResult = { ...runBody };
|
|
68
|
+
const cursorKey = runBody.latestEventId !== undefined
|
|
69
|
+
? "latestExternalEventSequence"
|
|
70
|
+
: "latest_external_event_sequence";
|
|
71
|
+
runResult[cursorKey] = latestExternalEventSequence;
|
|
72
|
+
result.run = runResult;
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
41
76
|
/** Error shape for conversation run terminal state. */
|
|
42
77
|
export class ConversationRunTerminalStateError extends Error {
|
|
43
78
|
status;
|
|
@@ -308,7 +343,7 @@ export async function flushConversationRunEventBatches(input) {
|
|
|
308
343
|
if (!batch) {
|
|
309
344
|
continue;
|
|
310
345
|
}
|
|
311
|
-
const cursorMode = batch.some(
|
|
346
|
+
const cursorMode = batch.some(isPrivateConversationRunEvent)
|
|
312
347
|
? "durable_event_id"
|
|
313
348
|
: "external_sequence";
|
|
314
349
|
try {
|
|
@@ -703,40 +738,39 @@ export async function appendConversationRunEvents(input) {
|
|
|
703
738
|
if (input.abortSignal?.aborted) {
|
|
704
739
|
throw new DOMException("This operation was aborted", "AbortError");
|
|
705
740
|
}
|
|
706
|
-
const timedAbort = createTimedAbortSignal(AGENT_RUN_API_TIMEOUT_MS, input.abortSignal);
|
|
707
741
|
const normalizedEvents = normalizeConversationRunEvents(input.events);
|
|
708
|
-
const requiresDurableCursor = normalizedEvents.some(
|
|
709
|
-
const
|
|
710
|
-
normalizedEvents.every(
|
|
742
|
+
const requiresDurableCursor = normalizedEvents.some(isPrivateConversationRunEvent);
|
|
743
|
+
const isPurePrivateEventBatch = normalizedEvents.length > 0 &&
|
|
744
|
+
normalizedEvents.every(isPrivateConversationRunEvent);
|
|
711
745
|
if (requiresDurableCursor && input.expectedPreviousEventId === undefined) {
|
|
712
|
-
|
|
713
|
-
throw new ModelCallContextPersistenceError("Model-call context append requires expected_previous_event_id");
|
|
746
|
+
throw new DurableRunEventPersistenceError("Private run event append requires expected_previous_event_id");
|
|
714
747
|
}
|
|
748
|
+
const timedAbort = createTimedAbortSignal(AGENT_RUN_API_TIMEOUT_MS, input.abortSignal);
|
|
715
749
|
// The timed abort must stay armed while the body is read: a server that
|
|
716
750
|
// stalls mid-body would otherwise hang past the timeout.
|
|
717
751
|
try {
|
|
752
|
+
const requestBody = JSON.stringify({
|
|
753
|
+
...(input.expectedPreviousEventId !== undefined
|
|
754
|
+
? { expected_previous_event_id: input.expectedPreviousEventId }
|
|
755
|
+
: {}),
|
|
756
|
+
...(!requiresDurableCursor && input.expectedPreviousExternalEventSequence !== undefined
|
|
757
|
+
? {
|
|
758
|
+
expected_previous_external_event_sequence: input.expectedPreviousExternalEventSequence,
|
|
759
|
+
}
|
|
760
|
+
: {}),
|
|
761
|
+
events: normalizedEvents,
|
|
762
|
+
});
|
|
763
|
+
if (new TextEncoder().encode(requestBody).byteLength >
|
|
764
|
+
MAX_CONVERSATION_RUN_EVENT_APPEND_REQUEST_BYTES) {
|
|
765
|
+
throw new DurableRunEventPersistenceError("Run event append request exceeds the supported payload size");
|
|
766
|
+
}
|
|
718
767
|
const response = await (input.fetch ?? globalThis.fetch)(`${input.apiUrl}/conversations/${input.conversationId}/runs/${input.runId}/events`, {
|
|
719
768
|
method: "POST",
|
|
720
769
|
headers: {
|
|
721
770
|
Authorization: `Bearer ${input.authToken}`,
|
|
722
771
|
"Content-Type": "application/json",
|
|
723
772
|
},
|
|
724
|
-
body:
|
|
725
|
-
...(input.expectedPreviousEventId !== undefined
|
|
726
|
-
? { expected_previous_event_id: input.expectedPreviousEventId }
|
|
727
|
-
: {}),
|
|
728
|
-
...(!requiresDurableCursor && input.expectedPreviousExternalEventSequence !== undefined
|
|
729
|
-
? {
|
|
730
|
-
expected_previous_external_event_sequence: input.expectedPreviousExternalEventSequence,
|
|
731
|
-
}
|
|
732
|
-
: {}),
|
|
733
|
-
// Chokepoint guard: every append path funnels through here, so enforce the
|
|
734
|
-
// per-event size limit here too. Upstream mirrors already normalize, but
|
|
735
|
-
// direct callers (hosted lifecycle, child-run progress) do not — this makes
|
|
736
|
-
// it impossible to POST an event the API would reject for size. Idempotent
|
|
737
|
-
// on already-normalized events.
|
|
738
|
-
events: normalizedEvents,
|
|
739
|
-
}),
|
|
773
|
+
body: requestBody,
|
|
740
774
|
signal: timedAbort.signal,
|
|
741
775
|
});
|
|
742
776
|
if (!response.ok) {
|
|
@@ -747,35 +781,12 @@ export async function appendConversationRunEvents(input) {
|
|
|
747
781
|
statusText: response.statusText,
|
|
748
782
|
});
|
|
749
783
|
}
|
|
750
|
-
|
|
784
|
+
let responseBody = await response.json();
|
|
751
785
|
// Pure private-event appends do not advance the external cursor and the API
|
|
752
786
|
// intentionally omits it. Preserve the caller's known cursor so the shared
|
|
753
787
|
// queue result remains total; mixed batches return the advanced API value.
|
|
754
|
-
if (
|
|
755
|
-
responseBody
|
|
756
|
-
const body = responseBody;
|
|
757
|
-
if (body.latestExternalEventSequence === undefined &&
|
|
758
|
-
body.latest_external_event_sequence === undefined) {
|
|
759
|
-
if (body.latestEventId !== undefined) {
|
|
760
|
-
body.latestExternalEventSequence = input.expectedPreviousExternalEventSequence;
|
|
761
|
-
}
|
|
762
|
-
else {
|
|
763
|
-
body.latest_external_event_sequence = input.expectedPreviousExternalEventSequence;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
const run = body.run;
|
|
767
|
-
if (run && typeof run === "object" && !Array.isArray(run)) {
|
|
768
|
-
const runBody = run;
|
|
769
|
-
if (runBody.latestExternalEventSequence === undefined &&
|
|
770
|
-
runBody.latest_external_event_sequence === undefined) {
|
|
771
|
-
if (runBody.latestEventId !== undefined) {
|
|
772
|
-
runBody.latestExternalEventSequence = input.expectedPreviousExternalEventSequence;
|
|
773
|
-
}
|
|
774
|
-
else {
|
|
775
|
-
runBody.latest_external_event_sequence = input.expectedPreviousExternalEventSequence;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
}
|
|
788
|
+
if (isPurePrivateEventBatch && input.expectedPreviousExternalEventSequence !== undefined) {
|
|
789
|
+
responseBody = backfillPurePrivateEventResponseCursor(responseBody, input.expectedPreviousExternalEventSequence);
|
|
779
790
|
}
|
|
780
791
|
return AppendConversationRunEventsResponseSchema.parse(responseBody);
|
|
781
792
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VeryfrontError } from "../../errors/index.js";
|
|
2
|
+
/** Return whether an event declares the private durable run-event discriminator. */
|
|
3
|
+
export declare function hasPrivateConversationRunEventType(value: unknown): value is object;
|
|
4
|
+
/** Return whether an event belongs to the private durable run-event sequence. */
|
|
5
|
+
export declare function isPrivateConversationRunEvent(value: unknown): boolean;
|
|
6
|
+
/** Failure to persist a required run event before its associated operation. */
|
|
7
|
+
export declare class DurableRunEventPersistenceError extends VeryfrontError {
|
|
8
|
+
name: string;
|
|
9
|
+
constructor(detail: string, options?: {
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=private-run-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-run-event.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/conversation/private-run-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAO7F,oFAAoF;AACpF,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAGlF;AAED,iFAAiF;AACjF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CASrE;AAED,+EAA+E;AAC/E,qBAAa,+BAAgC,SAAQ,cAAc;IACxD,IAAI,SAAqC;gBAEtC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAY9D"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DURABLE_RUN_EVENT_PERSISTENCE_FAILED, VeryfrontError } from "../../errors/index.js";
|
|
2
|
+
function ownDataValue(record, key) {
|
|
3
|
+
const descriptor = Object.getOwnPropertyDescriptor(record, key);
|
|
4
|
+
return descriptor && "value" in descriptor ? descriptor.value : undefined;
|
|
5
|
+
}
|
|
6
|
+
/** Return whether an event declares the private durable run-event discriminator. */
|
|
7
|
+
export function hasPrivateConversationRunEventType(value) {
|
|
8
|
+
return !!value && typeof value === "object" && !Array.isArray(value) &&
|
|
9
|
+
ownDataValue(value, "type") === "AGENT_RUN_MODEL_CALL_CONTEXT";
|
|
10
|
+
}
|
|
11
|
+
/** Return whether an event belongs to the private durable run-event sequence. */
|
|
12
|
+
export function isPrivateConversationRunEvent(value) {
|
|
13
|
+
if (!hasPrivateConversationRunEventType(value))
|
|
14
|
+
return false;
|
|
15
|
+
if (!Array.isArray(ownDataValue(value, "messages")))
|
|
16
|
+
return false;
|
|
17
|
+
const toolsDescriptor = Object.getOwnPropertyDescriptor(value, "tools");
|
|
18
|
+
if (toolsDescriptor !== undefined &&
|
|
19
|
+
(!("value" in toolsDescriptor) || !Array.isArray(toolsDescriptor.value)))
|
|
20
|
+
return false;
|
|
21
|
+
return Object.keys(value).every((key) => key === "type" || key === "messages" || key === "tools");
|
|
22
|
+
}
|
|
23
|
+
/** Failure to persist a required run event before its associated operation. */
|
|
24
|
+
export class DurableRunEventPersistenceError extends VeryfrontError {
|
|
25
|
+
name = "DurableRunEventPersistenceError";
|
|
26
|
+
constructor(detail, options = {}) {
|
|
27
|
+
super(detail, {
|
|
28
|
+
slug: DURABLE_RUN_EVENT_PERSISTENCE_FAILED.slug,
|
|
29
|
+
category: DURABLE_RUN_EVENT_PERSISTENCE_FAILED.category,
|
|
30
|
+
status: DURABLE_RUN_EVENT_PERSISTENCE_FAILED.status,
|
|
31
|
+
title: DURABLE_RUN_EVENT_PERSISTENCE_FAILED.title,
|
|
32
|
+
suggestion: DURABLE_RUN_EVENT_PERSISTENCE_FAILED.suggestion,
|
|
33
|
+
detail,
|
|
34
|
+
cause: options.cause,
|
|
35
|
+
});
|
|
36
|
+
this.name = "DurableRunEventPersistenceError";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-event payload budget the conversation run append endpoint accepts.
|
|
3
3
|
*
|
|
4
|
-
* Owned by a leaf module so every producer of durable run events
|
|
5
|
-
*
|
|
6
|
-
* number instead of a duplicated literal.
|
|
4
|
+
* Owned by a leaf module so every producer of durable run events sizes against
|
|
5
|
+
* one number instead of a duplicated literal.
|
|
7
6
|
*/
|
|
8
7
|
export declare const MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES: number;
|
|
8
|
+
/** Maximum JSON body accepted by the trusted conversation run-event endpoint. */
|
|
9
|
+
export declare const MAX_CONVERSATION_RUN_EVENT_APPEND_REQUEST_BYTES: number;
|
|
10
|
+
/** Return the conservative append-request size for one private durable event. */
|
|
11
|
+
export declare function getPrivateRunEventAppendRequestByteLength(event: unknown): number;
|
|
9
12
|
//# sourceMappingURL=run-event-limits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-event-limits.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/conversation/run-event-limits.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"run-event-limits.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/conversation/run-event-limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,wCAAwC,QAAa,CAAC;AAEnE,iFAAiF;AACjF,eAAO,MAAM,+CAA+C,QAAmB,CAAC;AAIhF,iFAAiF;AACjF,wBAAgB,yCAAyC,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAShF"}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-event payload budget the conversation run append endpoint accepts.
|
|
3
3
|
*
|
|
4
|
-
* Owned by a leaf module so every producer of durable run events
|
|
5
|
-
*
|
|
6
|
-
* number instead of a duplicated literal.
|
|
4
|
+
* Owned by a leaf module so every producer of durable run events sizes against
|
|
5
|
+
* one number instead of a duplicated literal.
|
|
7
6
|
*/
|
|
8
7
|
export const MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES = 240 * 1024;
|
|
8
|
+
/** Maximum JSON body accepted by the trusted conversation run-event endpoint. */
|
|
9
|
+
export const MAX_CONVERSATION_RUN_EVENT_APPEND_REQUEST_BYTES = 10 * 1024 * 1024;
|
|
10
|
+
const encoder = new TextEncoder();
|
|
11
|
+
/** Return the conservative append-request size for one private durable event. */
|
|
12
|
+
export function getPrivateRunEventAppendRequestByteLength(event) {
|
|
13
|
+
try {
|
|
14
|
+
return encoder.encode(JSON.stringify({
|
|
15
|
+
expected_previous_event_id: Number.MAX_SAFE_INTEGER,
|
|
16
|
+
events: [event],
|
|
17
|
+
})).byteLength;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return Number.POSITIVE_INFINITY;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-event-normalization.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/conversation/run-event-normalization.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-event-normalization.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/conversation/run-event-normalization.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wCAAwC,EAAE,MAAM,uBAAuB,CAAC;AASjF,KAAK,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAS7E,sDAAsD;AACtD,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAM5E;AAED,oDAAoD;AACpD,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,0BAA0B,GAChC,0BAA0B,EAAE,CAc9B;AA0CD,0CAA0C;AAC1C,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,0BAA0B,EAAE,GACnC,0BAA0B,EAAE,CAE9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assertValidModelCallContextRunEvent, isModelCallContextRunEvent, } from "./model-call-context-run-event.js";
|
|
2
1
|
import { MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES } from "./run-event-limits.js";
|
|
2
|
+
import { DurableRunEventPersistenceError, hasPrivateConversationRunEventType, isPrivateConversationRunEvent, } from "./private-run-event.js";
|
|
3
3
|
export { MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES } from "./run-event-limits.js";
|
|
4
4
|
const OMITTED_CONVERSATION_RUN_EVENT_TYPE = "CUSTOM";
|
|
5
5
|
const MAX_SUMMARY_DEPTH = 4;
|
|
@@ -21,8 +21,10 @@ export function getConversationRunEventJsonByteLength(value) {
|
|
|
21
21
|
}
|
|
22
22
|
/** Event emitted for normalize conversation run. */
|
|
23
23
|
export function normalizeConversationRunEvent(event) {
|
|
24
|
-
if (
|
|
25
|
-
|
|
24
|
+
if (hasPrivateConversationRunEventType(event)) {
|
|
25
|
+
if (!isPrivateConversationRunEvent(event)) {
|
|
26
|
+
throw new DurableRunEventPersistenceError("Invalid private run event shape");
|
|
27
|
+
}
|
|
26
28
|
return [event];
|
|
27
29
|
}
|
|
28
30
|
if (getConversationRunEventJsonByteLength(event) <= MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES) {
|
|
@@ -9,7 +9,7 @@ import { type MirroredToolChunkState } from "../streaming/mirrored-tool-chunk-st
|
|
|
9
9
|
import { type FinalizeHostedResponseOptions, type HostedDetachedFinalizationState, type HostedResponseFinalizationState } from "./stream-finalization.js";
|
|
10
10
|
import { createChatStreamWatchdog } from "../../chat/stream-watchdog.js";
|
|
11
11
|
import type { HostedChatExecutionLifecycleAdapter } from "./chat-execution-lifecycle-types.js";
|
|
12
|
-
import type {
|
|
12
|
+
import type { AgentRunEventSink } from "../../runtime/model-call-context.js";
|
|
13
13
|
export type { HostedChatExecutionLifecycleAdapter } from "./chat-execution-lifecycle-types.js";
|
|
14
14
|
/** Public API contract for hosted chat execution runtime. */
|
|
15
15
|
export interface HostedChatExecutionRuntime {
|
|
@@ -39,7 +39,7 @@ export interface HostedChatExecutionRuntimeBootstrap {
|
|
|
39
39
|
capturedMessageId: string | null;
|
|
40
40
|
capturedConversationId?: string;
|
|
41
41
|
mirroredToolChunkState: MirroredToolChunkState;
|
|
42
|
-
|
|
42
|
+
runEventSink?: AgentRunEventSink;
|
|
43
43
|
}
|
|
44
44
|
/** Input payload for create hosted chat execution runtime bootstrap. */
|
|
45
45
|
export interface CreateHostedChatExecutionRuntimeBootstrapInput {
|
|
@@ -53,7 +53,7 @@ export interface CreateHostedChatExecutionRuntimeBootstrapInput {
|
|
|
53
53
|
createRootStreamWatchdog?: () => HostedChatExecutionRootStreamWatchdog;
|
|
54
54
|
streamBootstrapKeepaliveIntervalMs?: number;
|
|
55
55
|
streamBootstrapTimeoutMs?: number;
|
|
56
|
-
|
|
56
|
+
durableRunEventMirror?: ConversationRunChunkMirror;
|
|
57
57
|
}
|
|
58
58
|
/** Input payload for create hosted chat execution runtime. */
|
|
59
59
|
export interface CreateHostedChatExecutionRuntimeInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-execution-runtime.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/chat-execution-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAC9F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACtF,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,EACL,KAAK,6BAA6B,EAClC,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACrC,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EACL,wBAAwB,EAEzB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-execution-runtime.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/chat-execution-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAC9F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACtF,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,EACL,KAAK,6BAA6B,EAClC,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACrC,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EACL,wBAAwB,EAEzB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,qCAAq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gBAAgB,EAAE,mCAAmC,CAAC;IACtD,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,gCAAgC,EAAE,MAAM,CAAC;CAC1C,GAAG,CACF,SAAS,EAAE,OAAO,KACf,OAAO,CAAC,+BAA+B,CAAC,aAAa,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC,CA4BhG;AAED,4DAA4D;AAC5D,wBAAgB,0CAA0C,CAAC,KAAK,EAAE;IAChE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,mCAAmC,CAAC;IACtD,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,qBAAqB,EAAE,OAAO,CAAC;IAC/B,gCAAgC,EAAE,MAAM,CAAC;CAC1C,GAAG,CACF,SAAS,EAAE,OAAO,KACf,OAAO,CAAC,+BAA+B,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC,CA2BjF;AAkID,4CAA4C;AAC5C,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,qCAAqC,GAC3C,0BAA0B,CAsI5B"}
|
|
@@ -9,8 +9,8 @@ import { createChatStreamWatchdog, DEFAULT_CHAT_STREAM_TOOL_RUNNING_TIMEOUT_MS,
|
|
|
9
9
|
import { unrefTimer } from "../../platform/compat/process.js";
|
|
10
10
|
import { AGENT_DELEGATE_TOOL_PREFIX } from "../runtime/agent-delegation-names.js";
|
|
11
11
|
import { finalizeHostedChatRun } from "./hosted-chat-finalization.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { runWithMandatoryRunEventSink, scopeAsyncIterableWithMandatoryRunEventSink, } from "../../runtime/run-event-sink-context.js";
|
|
13
|
+
import { createDurableRunEventSink, DurableRunEventPersistenceError, } from "./durable-run-event-sink.js";
|
|
14
14
|
const INCOMPLETE_TOOL_CALLS_PART_ERROR_TEXT = "Assistant ended before tool execution completed";
|
|
15
15
|
const FINALIZATION_TERMINAL_STATE_FALLBACK_MODEL_ID = "";
|
|
16
16
|
const DEFAULT_STREAM_BOOTSTRAP_KEEPALIVE_INTERVAL_MS = 30_000;
|
|
@@ -97,8 +97,8 @@ export async function createHostedChatExecutionRuntimeBootstrap(input) {
|
|
|
97
97
|
if (input.conversationId && !streamingMessageId) {
|
|
98
98
|
throw INVALID_ARGUMENT.create({ detail: "DURABLE_CHAT_ROOT_REQUIRES_CONVERSATION" });
|
|
99
99
|
}
|
|
100
|
-
if (input.lifecycleAdapter.durableRootRun && !input.
|
|
101
|
-
throw new
|
|
100
|
+
if (input.lifecycleAdapter.durableRootRun && !input.durableRunEventMirror) {
|
|
101
|
+
throw new DurableRunEventPersistenceError("Durable hosted root run requires an authorized private event mirror");
|
|
102
102
|
}
|
|
103
103
|
const rootStreamWatchdog = input.createRootStreamWatchdog
|
|
104
104
|
? input.createRootStreamWatchdog()
|
|
@@ -113,9 +113,9 @@ export async function createHostedChatExecutionRuntimeBootstrap(input) {
|
|
|
113
113
|
rootStreamWatchdog.signal,
|
|
114
114
|
bootstrapKeepalive.signal,
|
|
115
115
|
]);
|
|
116
|
-
const
|
|
117
|
-
?
|
|
118
|
-
mirror: input.
|
|
116
|
+
const runEventSink = input.durableRunEventMirror
|
|
117
|
+
? createDurableRunEventSink({
|
|
118
|
+
mirror: input.durableRunEventMirror,
|
|
119
119
|
abortSignal: streamAbortSignal,
|
|
120
120
|
})
|
|
121
121
|
: undefined;
|
|
@@ -125,9 +125,7 @@ export async function createHostedChatExecutionRuntimeBootstrap(input) {
|
|
|
125
125
|
messages: input.finalMessages,
|
|
126
126
|
abortSignal: streamAbortSignal,
|
|
127
127
|
});
|
|
128
|
-
streamResult = await traceHostedChatRuntimeStream(input.traceStream, () =>
|
|
129
|
-
? runWithModelCallRecorder(modelCallRecorder, startStream)
|
|
130
|
-
: startStream());
|
|
128
|
+
streamResult = await traceHostedChatRuntimeStream(input.traceStream, () => runEventSink ? runWithMandatoryRunEventSink(runEventSink, startStream) : startStream());
|
|
131
129
|
}
|
|
132
130
|
catch (error) {
|
|
133
131
|
rootStreamWatchdog.dispose();
|
|
@@ -145,7 +143,7 @@ export async function createHostedChatExecutionRuntimeBootstrap(input) {
|
|
|
145
143
|
capturedMessageId: streamingMessageId,
|
|
146
144
|
...(input.conversationId ? { capturedConversationId: input.conversationId } : {}),
|
|
147
145
|
mirroredToolChunkState: createMirroredToolChunkState(),
|
|
148
|
-
...(
|
|
146
|
+
...(runEventSink ? { runEventSink } : {}),
|
|
149
147
|
};
|
|
150
148
|
}
|
|
151
149
|
async function createBootstrappedHostedChatRuntime(input, agentRunSpan) {
|
|
@@ -168,7 +166,7 @@ async function createBootstrappedHostedChatRuntime(input, agentRunSpan) {
|
|
|
168
166
|
finalMessages: input.finalMessages,
|
|
169
167
|
conversationId: input.conversationId,
|
|
170
168
|
...(input.rootRunContext.privateDurableRunMirror
|
|
171
|
-
? {
|
|
169
|
+
? { durableRunEventMirror: input.rootRunContext.privateDurableRunMirror }
|
|
172
170
|
: {}),
|
|
173
171
|
abortSignal: input.abortSignal,
|
|
174
172
|
traceStream: input.traceStream,
|
|
@@ -473,11 +471,11 @@ export function createHostedChatExecutionRuntime(input) {
|
|
|
473
471
|
streamOptions.generateMessageId = () => responseMessageId;
|
|
474
472
|
}
|
|
475
473
|
const createAgentUiStream = () => input.bootstrap.streamResult.toUIMessageStream(streamOptions);
|
|
476
|
-
const unscopedAgentUIStream = input.bootstrap.
|
|
477
|
-
?
|
|
474
|
+
const unscopedAgentUIStream = input.bootstrap.runEventSink
|
|
475
|
+
? runWithMandatoryRunEventSink(input.bootstrap.runEventSink, createAgentUiStream)
|
|
478
476
|
: createAgentUiStream();
|
|
479
|
-
const agentUIStream = input.bootstrap.
|
|
480
|
-
?
|
|
477
|
+
const agentUIStream = input.bootstrap.runEventSink
|
|
478
|
+
? scopeAsyncIterableWithMandatoryRunEventSink(input.bootstrap.runEventSink, unscopedAgentUIStream)
|
|
481
479
|
: unscopedAgentUIStream;
|
|
482
480
|
return {
|
|
483
481
|
agentUIStream: createHostedMirroredUiStream({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"child-fork-execution-runner.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/child-fork-execution-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAKL,KAAK,gCAAgC,EACtC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,wCAAwC,EAAE,MAAM,4BAA4B,CAAC;AAK3F,OAAO,EAEL,KAAK,kCAAkC,EACxC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,wCAAwC,EAE9C,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,KAAK,6BAA6B,EAElC,KAAK,6CAA6C,EACnD,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEL,KAAK,8BAA8B,EAEpC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAEV,+CAA+C,EAChD,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,KAAK,EACV,2BAA2B,EAC3B,+BAA+B,EAChC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,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gBAAgB,CAAC,CAAC;IAC3E,eAAe,EAAE,wCAAwC,CAAC,iBAAiB,CAAC,CAAC;IAC7E,sBAAsB,CAAC,EAAE,CACvB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,4BAA4B,CAAC,gBAAgB,CAAC,KAC3D,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACzC,gBAAgB,CAAC,EAAE,CACjB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,4BAA4B,CAAC,gBAAgB,CAAC,KAC3D,sBAAsB,GAAG,SAAS,CAAC;IACxC,oBAAoB,CAAC,EAAE,wCAAwC,CAAC,sBAAsB,CAAC,CAAC;IACxF,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,4BAA4B,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF,gCAAgC,CAAC,EAAE,OAAO,CAAC;CAC5C,CAAC;AAkFJ,wDAAwD;AACxD,wBAAsB,+BAA+B,CACnD,WAAW,SAAS,uBAAuB,GAAG,uBAAuB,EAErE,KAAK,EAAE,sCAAsC,CAAC,WAAW,CAAC,GACzD,OAAO,CAAC,uBAAuB,CAAC,CAQlC;
|
|
1
|
+
{"version":3,"file":"child-fork-execution-runner.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/child-fork-execution-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAKL,KAAK,gCAAgC,EACtC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,wCAAwC,EAAE,MAAM,4BAA4B,CAAC;AAK3F,OAAO,EAEL,KAAK,kCAAkC,EACxC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,wCAAwC,EAE9C,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,KAAK,6BAA6B,EAElC,KAAK,6CAA6C,EACnD,MAAM,+BAA+B,CAAC;AACvC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xD,wBAAsB,+BAA+B,CACnD,WAAW,SAAS,uBAAuB,GAAG,uBAAuB,EAErE,KAAK,EAAE,sCAAsC,CAAC,WAAW,CAAC,GACzD,OAAO,CAAC,uBAAuB,CAAC,CAQlC;AAqKD,qDAAqD;AACrD,wBAAsB,uCAAuC,CAC3D,WAAW,SAAS,uBAAuB,GAAG,uBAAuB,EAErE,KAAK,EAAE,4CAA4C,CAAC,WAAW,CAAC,GAC/D,OAAO,CAAC,uBAAuB,CAAC,CA2BlC"}
|
|
@@ -9,8 +9,8 @@ import { getActiveHostedRunEventWriterCapability, runWithHostedRunEventWriterCap
|
|
|
9
9
|
import { throwIfChildRunAborted } from "../child-run/execution-support.js";
|
|
10
10
|
import { resolveHostedChildForkRuntimeConfig, withHostedChildInvocationContext, } from "./child-tool-input.js";
|
|
11
11
|
import { requireConfirmedHostedProjectReference, resolveHostedProjectReference, } from "./project-reference-resolver.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { runWithMandatoryRunEventSink } from "../../runtime/run-event-sink-context.js";
|
|
13
|
+
import { createDurableRunEventSink, DurableRunEventPersistenceError, } from "./durable-run-event-sink.js";
|
|
14
14
|
/** Default value for hosted child fork stream idle timeout ms. */
|
|
15
15
|
export const DEFAULT_HOSTED_CHILD_FORK_STREAM_IDLE_TIMEOUT_MS = 45_000;
|
|
16
16
|
/** Default value for hosted child fork stream active tool timeout ms. */
|
|
@@ -146,10 +146,10 @@ async function executeHostedChildForkWithoutWriterAuthority(input, runContext, s
|
|
|
146
146
|
: undefined;
|
|
147
147
|
const startRuntime = input.startRuntime ?? startHostedChildForkRuntimeWithHostTools;
|
|
148
148
|
if (input.durableChildRun && !runContext.durableRunMirror) {
|
|
149
|
-
throw new
|
|
149
|
+
throw new DurableRunEventPersistenceError("Durable hosted child run requires an event mirror");
|
|
150
150
|
}
|
|
151
|
-
const
|
|
152
|
-
?
|
|
151
|
+
const startupRunEventSink = runContext.durableRunMirror
|
|
152
|
+
? createDurableRunEventSink({
|
|
153
153
|
mirror: runContext.durableRunMirror,
|
|
154
154
|
abortSignal: input.abortSignal,
|
|
155
155
|
})
|
|
@@ -185,16 +185,16 @@ async function executeHostedChildForkWithoutWriterAuthority(input, runContext, s
|
|
|
185
185
|
runStep: input.runStep ?? runAgentRuntimeForkStep,
|
|
186
186
|
traceTools,
|
|
187
187
|
});
|
|
188
|
-
const started = await (
|
|
189
|
-
?
|
|
188
|
+
const started = await (startupRunEventSink
|
|
189
|
+
? runWithMandatoryRunEventSink(startupRunEventSink, start)
|
|
190
190
|
: start());
|
|
191
191
|
childRunMonitorAbortController = started.childRunMonitorAbortController;
|
|
192
192
|
childRunMonitorPromise = started.childRunMonitorPromise;
|
|
193
193
|
const streamAbortSignal = input.abortSignal
|
|
194
194
|
? AbortSignal.any([input.abortSignal, started.forkStreamAbortController.signal])
|
|
195
195
|
: started.forkStreamAbortController.signal;
|
|
196
|
-
const
|
|
197
|
-
?
|
|
196
|
+
const runEventSink = runContext.durableRunMirror
|
|
197
|
+
? createDurableRunEventSink({
|
|
198
198
|
mirror: runContext.durableRunMirror,
|
|
199
199
|
abortSignal: streamAbortSignal,
|
|
200
200
|
})
|
|
@@ -228,9 +228,7 @@ async function executeHostedChildForkWithoutWriterAuthority(input, runContext, s
|
|
|
228
228
|
writeLog: input.writeLog,
|
|
229
229
|
tracePart: input.instrumentation?.tracePart,
|
|
230
230
|
});
|
|
231
|
-
return await (
|
|
232
|
-
? runWithModelCallRecorder(modelCallRecorder, consume)
|
|
233
|
-
: consume());
|
|
231
|
+
return await (runEventSink ? runWithMandatoryRunEventSink(runEventSink, consume) : consume());
|
|
234
232
|
}
|
|
235
233
|
catch (error) {
|
|
236
234
|
return handleHostedChildForkRunContextError({
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ConversationRunChunkMirror } from "../conversation/run-chunk-mirror.js";
|
|
2
|
+
import type { AgentRunEventSink } from "../../runtime/model-call-context.js";
|
|
3
|
+
export { DurableRunEventPersistenceError } from "../conversation/private-run-event.js";
|
|
4
|
+
/** Create the internal fail-closed sink used by hosted durable runs. */
|
|
5
|
+
export declare function createDurableRunEventSink(input: {
|
|
6
|
+
mirror: ConversationRunChunkMirror;
|
|
7
|
+
abortSignal?: AbortSignal;
|
|
8
|
+
timeoutMs?: number;
|
|
9
|
+
}): AgentRunEventSink;
|
|
10
|
+
//# sourceMappingURL=durable-run-event-sink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-run-event-sink.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/durable-run-event-sink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAOtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAK7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AA8EvF,wEAAwE;AACxE,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,MAAM,EAAE,0BAA0B,CAAC;IACnC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,iBAAiB,CAqCpB"}
|