@assemblyline-agents/runtime 5.0.9 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -5
- package/dist/a2a-client.d.ts +1 -3
- package/dist/a2a-client.d.ts.map +1 -1
- package/dist/a2a-client.js +1 -4
- package/dist/a2a-client.js.map +1 -1
- package/dist/agent-event-handlers.d.ts +2 -0
- package/dist/agent-event-handlers.d.ts.map +1 -1
- package/dist/agent-event-handlers.js +1 -1
- package/dist/agent-event-handlers.js.map +1 -1
- package/dist/agent-hook-context.d.ts.map +1 -1
- package/dist/agent-hook-context.js +3 -1
- package/dist/agent-hook-context.js.map +1 -1
- package/dist/agent-hook-controller-factory.d.ts +5 -1
- package/dist/agent-hook-controller-factory.d.ts.map +1 -1
- package/dist/agent-hook-controller-factory.js +11 -9
- package/dist/agent-hook-controller-factory.js.map +1 -1
- package/dist/agent-hook-evaluation.d.ts +0 -2
- package/dist/agent-hook-evaluation.d.ts.map +1 -1
- package/dist/agent-hook-evaluation.js +10 -10
- package/dist/agent-hook-evaluation.js.map +1 -1
- package/dist/agent-hook-run-lifecycle.d.ts +1 -2
- package/dist/agent-hook-run-lifecycle.d.ts.map +1 -1
- package/dist/agent-hook-run-lifecycle.js +1 -2
- package/dist/agent-hook-run-lifecycle.js.map +1 -1
- package/dist/agent-surface.d.ts +5 -2
- package/dist/agent-surface.d.ts.map +1 -1
- package/dist/agent-surface.js +11 -3
- package/dist/agent-surface.js.map +1 -1
- package/dist/artifact-selection.js +1 -1
- package/dist/artifact-selection.js.map +1 -1
- package/dist/assembly-line-runtime.d.ts +9 -0
- package/dist/assembly-line-runtime.d.ts.map +1 -0
- package/dist/assembly-line-runtime.js +9 -0
- package/dist/assembly-line-runtime.js.map +1 -0
- package/dist/attachment-download.d.ts +17 -0
- package/dist/attachment-download.d.ts.map +1 -0
- package/dist/attachment-download.js +51 -0
- package/dist/attachment-download.js.map +1 -0
- package/dist/attachments.d.ts +2 -14
- package/dist/attachments.d.ts.map +1 -1
- package/dist/attachments.js +8 -80
- package/dist/attachments.js.map +1 -1
- package/dist/background-review-types.d.ts +2 -0
- package/dist/background-review-types.d.ts.map +1 -1
- package/dist/background-review.d.ts.map +1 -1
- package/dist/background-review.js +13 -0
- package/dist/background-review.js.map +1 -1
- package/dist/background-subagents.d.ts +1 -1
- package/dist/background-subagents.d.ts.map +1 -1
- package/dist/blob-storage.d.ts +12 -0
- package/dist/blob-storage.d.ts.map +1 -0
- package/dist/blob-storage.js +86 -0
- package/dist/blob-storage.js.map +1 -0
- package/dist/builtin-tool-executors.d.ts.map +1 -1
- package/dist/builtin-tool-executors.js +38 -29
- package/dist/builtin-tool-executors.js.map +1 -1
- package/dist/builtin-tools.d.ts +1 -2
- package/dist/builtin-tools.d.ts.map +1 -1
- package/dist/builtin-tools.js +20 -18
- package/dist/builtin-tools.js.map +1 -1
- package/dist/capability-inspection.d.ts +4 -0
- package/dist/capability-inspection.d.ts.map +1 -1
- package/dist/capability-inspection.js +10 -11
- package/dist/capability-inspection.js.map +1 -1
- package/dist/channel-credential-environment.d.ts +1 -1
- package/dist/channel-credential-environment.d.ts.map +1 -1
- package/dist/channel-credential-environment.js +1 -6
- package/dist/channel-credential-environment.js.map +1 -1
- package/dist/channel-ingress.d.ts +1 -2
- package/dist/channel-ingress.d.ts.map +1 -1
- package/dist/channel-ingress.js +2 -2
- package/dist/channel-ingress.js.map +1 -1
- package/dist/channel-operation.d.ts +0 -1
- package/dist/channel-operation.d.ts.map +1 -1
- package/dist/channel-operation.js +1 -2
- package/dist/channel-operation.js.map +1 -1
- package/dist/channel.d.ts +32 -3
- package/dist/channel.d.ts.map +1 -1
- package/dist/connection-assets.d.ts.map +1 -1
- package/dist/connection-assets.js.map +1 -1
- package/dist/connection-authorization-service.d.ts +52 -0
- package/dist/connection-authorization-service.d.ts.map +1 -0
- package/dist/connection-authorization-service.js +417 -0
- package/dist/connection-authorization-service.js.map +1 -0
- package/dist/connection-credential-materialization.d.ts +23 -0
- package/dist/connection-credential-materialization.d.ts.map +1 -0
- package/dist/connection-credential-materialization.js +223 -0
- package/dist/connection-credential-materialization.js.map +1 -0
- package/dist/connection-definition-loader.d.ts +6 -0
- package/dist/connection-definition-loader.d.ts.map +1 -0
- package/dist/connection-definition-loader.js +102 -0
- package/dist/connection-definition-loader.js.map +1 -0
- package/dist/connection-discovery.d.ts +11 -0
- package/dist/connection-discovery.d.ts.map +1 -0
- package/dist/connection-discovery.js +105 -0
- package/dist/connection-discovery.js.map +1 -0
- package/dist/connection-events.d.ts.map +1 -1
- package/dist/connection-events.js.map +1 -1
- package/dist/connection-oauth-client.d.ts +3 -0
- package/dist/connection-oauth-client.d.ts.map +1 -0
- package/dist/connection-oauth-client.js +64 -0
- package/dist/connection-oauth-client.js.map +1 -0
- package/dist/connection-runtime-types.d.ts +78 -0
- package/dist/connection-runtime-types.d.ts.map +1 -0
- package/dist/connection-runtime-types.js +31 -0
- package/dist/connection-runtime-types.js.map +1 -0
- package/dist/connection-search-scope.d.ts +13 -0
- package/dist/connection-search-scope.d.ts.map +1 -0
- package/dist/connection-search-scope.js +24 -0
- package/dist/connection-search-scope.js.map +1 -0
- package/dist/connections.d.ts +18 -167
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +71 -1017
- package/dist/connections.js.map +1 -1
- package/dist/context-policy-util.d.ts +0 -4
- package/dist/context-policy-util.d.ts.map +1 -1
- package/dist/context-policy-util.js +0 -10
- package/dist/context-policy-util.js.map +1 -1
- package/dist/conversation-context.d.ts +1 -1
- package/dist/conversation-context.d.ts.map +1 -1
- package/dist/conversation-context.js +12 -9
- package/dist/conversation-context.js.map +1 -1
- package/dist/default-outbound-route.d.ts +1 -0
- package/dist/default-outbound-route.d.ts.map +1 -1
- package/dist/default-outbound-route.js +1 -1
- package/dist/default-outbound-route.js.map +1 -1
- package/dist/delivery-queue.d.ts +1 -1
- package/dist/delivery-send.d.ts.map +1 -1
- package/dist/delivery-send.js +3 -2
- package/dist/delivery-send.js.map +1 -1
- package/dist/dynamic-schedule-execution.d.ts +4 -0
- package/dist/dynamic-schedule-execution.d.ts.map +1 -0
- package/dist/dynamic-schedule-execution.js +136 -0
- package/dist/dynamic-schedule-execution.js.map +1 -0
- package/dist/dynamic-schedule-runtime.d.ts +11 -20
- package/dist/dynamic-schedule-runtime.d.ts.map +1 -1
- package/dist/dynamic-schedule-runtime.js +27 -39
- package/dist/dynamic-schedule-runtime.js.map +1 -1
- package/dist/evolution-tracker.d.ts +52 -0
- package/dist/evolution-tracker.d.ts.map +1 -0
- package/dist/evolution-tracker.js +179 -0
- package/dist/evolution-tracker.js.map +1 -0
- package/dist/harness-capabilities.d.ts +7 -0
- package/dist/harness-capabilities.d.ts.map +1 -0
- package/dist/harness-capabilities.js +56 -0
- package/dist/harness-capabilities.js.map +1 -0
- package/dist/harness-continuation-persistence.d.ts +6 -0
- package/dist/harness-continuation-persistence.d.ts.map +1 -0
- package/dist/harness-continuation-persistence.js +11 -0
- package/dist/harness-continuation-persistence.js.map +1 -0
- package/dist/harness-execution-context.d.ts +10 -0
- package/dist/harness-execution-context.d.ts.map +1 -0
- package/dist/harness-execution-context.js +193 -0
- package/dist/harness-execution-context.js.map +1 -0
- package/dist/harness-loop-types.d.ts +67 -0
- package/dist/harness-loop-types.d.ts.map +1 -0
- package/dist/harness-loop-types.js +2 -0
- package/dist/harness-loop-types.js.map +1 -0
- package/dist/harness-loop.d.ts +13 -94
- package/dist/harness-loop.d.ts.map +1 -1
- package/dist/harness-loop.js +19 -551
- package/dist/harness-loop.js.map +1 -1
- package/dist/harness-tool-execution.d.ts +30 -0
- package/dist/harness-tool-execution.d.ts.map +1 -0
- package/dist/harness-tool-execution.js +397 -0
- package/dist/harness-tool-execution.js.map +1 -0
- package/dist/harness-transcript-resume.d.ts +18 -0
- package/dist/harness-transcript-resume.d.ts.map +1 -0
- package/dist/harness-transcript-resume.js +102 -0
- package/dist/harness-transcript-resume.js.map +1 -0
- package/dist/harness-turn-execution.d.ts +11 -0
- package/dist/harness-turn-execution.d.ts.map +1 -0
- package/dist/harness-turn-execution.js +157 -0
- package/dist/harness-turn-execution.js.map +1 -0
- package/dist/index.d.ts +10 -499
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2139
- package/dist/index.js.map +1 -1
- package/dist/local-sandbox.d.ts +2 -1
- package/dist/local-sandbox.d.ts.map +1 -1
- package/dist/mcp-client.d.ts +11 -1
- package/dist/mcp-client.d.ts.map +1 -1
- package/dist/mcp-client.js +39 -7
- package/dist/mcp-client.js.map +1 -1
- package/dist/media-processor.d.ts +3 -1
- package/dist/media-processor.d.ts.map +1 -1
- package/dist/media-processor.js +15 -1
- package/dist/media-processor.js.map +1 -1
- package/dist/memory-storage.d.ts +51 -0
- package/dist/memory-storage.d.ts.map +1 -0
- package/dist/memory-storage.js +324 -0
- package/dist/memory-storage.js.map +1 -0
- package/dist/model-credential-stores.d.ts.map +1 -1
- package/dist/model-credential-stores.js +6 -12
- package/dist/model-credential-stores.js.map +1 -1
- package/dist/model-provider-environment.d.ts +4 -0
- package/dist/model-provider-environment.d.ts.map +1 -0
- package/dist/model-provider-environment.js +36 -0
- package/dist/model-provider-environment.js.map +1 -0
- package/dist/plugin-embeddings.d.ts +4 -0
- package/dist/plugin-embeddings.d.ts.map +1 -0
- package/dist/plugin-embeddings.js +75 -0
- package/dist/plugin-embeddings.js.map +1 -0
- package/dist/public-api.d.ts +8 -5
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +6 -4
- package/dist/public-api.js.map +1 -1
- package/dist/relay-mcp-client.js +1 -1
- package/dist/relay-mcp-client.js.map +1 -1
- package/dist/replay-resume-authorization.d.ts +8 -0
- package/dist/replay-resume-authorization.d.ts.map +1 -0
- package/dist/replay-resume-authorization.js +181 -0
- package/dist/replay-resume-authorization.js.map +1 -0
- package/dist/replay-resume-connection.d.ts +6 -0
- package/dist/replay-resume-connection.d.ts.map +1 -0
- package/dist/replay-resume-connection.js +75 -0
- package/dist/replay-resume-connection.js.map +1 -0
- package/dist/replay-resume-controls.d.ts +6 -0
- package/dist/replay-resume-controls.d.ts.map +1 -0
- package/dist/replay-resume-controls.js +157 -0
- package/dist/replay-resume-controls.js.map +1 -0
- package/dist/replay-resume-harness.d.ts +14 -0
- package/dist/replay-resume-harness.d.ts.map +1 -0
- package/dist/replay-resume-harness.js +158 -0
- package/dist/replay-resume-harness.js.map +1 -0
- package/dist/replay-resume-recovery.d.ts +10 -0
- package/dist/replay-resume-recovery.d.ts.map +1 -0
- package/dist/replay-resume-recovery.js +62 -0
- package/dist/replay-resume-recovery.js.map +1 -0
- package/dist/replay-resume-shared.d.ts +16 -0
- package/dist/replay-resume-shared.d.ts.map +1 -0
- package/dist/replay-resume-shared.js +55 -0
- package/dist/replay-resume-shared.js.map +1 -0
- package/dist/replay-resume-types.d.ts +85 -0
- package/dist/replay-resume-types.d.ts.map +1 -0
- package/dist/replay-resume-types.js +2 -0
- package/dist/replay-resume-types.js.map +1 -0
- package/dist/replay-resume.d.ts +7 -119
- package/dist/replay-resume.d.ts.map +1 -1
- package/dist/replay-resume.js +5 -715
- package/dist/replay-resume.js.map +1 -1
- package/dist/resource-projection-util.d.ts +1 -2
- package/dist/resource-projection-util.d.ts.map +1 -1
- package/dist/resource-projection-util.js +2 -11
- package/dist/resource-projection-util.js.map +1 -1
- package/dist/resource-projection.d.ts.map +1 -1
- package/dist/resource-projection.js +67 -22
- package/dist/resource-projection.js.map +1 -1
- package/dist/run-execution-host.d.ts +98 -0
- package/dist/run-execution-host.d.ts.map +1 -0
- package/dist/run-execution-host.js +2 -0
- package/dist/run-execution-host.js.map +1 -0
- package/dist/run-execution.d.ts +6 -0
- package/dist/run-execution.d.ts.map +1 -0
- package/dist/run-execution.js +313 -0
- package/dist/run-execution.js.map +1 -0
- package/dist/run-initialization.d.ts +19 -0
- package/dist/run-initialization.d.ts.map +1 -0
- package/dist/run-initialization.js +171 -0
- package/dist/run-initialization.js.map +1 -0
- package/dist/run-recovery.d.ts +1 -1
- package/dist/run-recovery.js.map +1 -1
- package/dist/runtime-connection-definitions.d.ts +35 -0
- package/dist/runtime-connection-definitions.d.ts.map +1 -0
- package/dist/runtime-connection-definitions.js +97 -0
- package/dist/runtime-connection-definitions.js.map +1 -0
- package/dist/runtime-engine-background.d.ts +64 -0
- package/dist/runtime-engine-background.d.ts.map +1 -0
- package/dist/runtime-engine-background.js +136 -0
- package/dist/runtime-engine-background.js.map +1 -0
- package/dist/runtime-engine-base.d.ts +60 -0
- package/dist/runtime-engine-base.d.ts.map +1 -0
- package/dist/runtime-engine-base.js +192 -0
- package/dist/runtime-engine-base.js.map +1 -0
- package/dist/runtime-engine-capabilities.d.ts +81 -0
- package/dist/runtime-engine-capabilities.d.ts.map +1 -0
- package/dist/runtime-engine-capabilities.js +198 -0
- package/dist/runtime-engine-capabilities.js.map +1 -0
- package/dist/runtime-engine-config.d.ts +77 -0
- package/dist/runtime-engine-config.d.ts.map +1 -0
- package/dist/runtime-engine-config.js +187 -0
- package/dist/runtime-engine-config.js.map +1 -0
- package/dist/runtime-engine-foundation.d.ts +11 -0
- package/dist/runtime-engine-foundation.d.ts.map +1 -0
- package/dist/runtime-engine-foundation.js +121 -0
- package/dist/runtime-engine-foundation.js.map +1 -0
- package/dist/runtime-engine-hooks.d.ts +33 -0
- package/dist/runtime-engine-hooks.d.ts.map +1 -0
- package/dist/runtime-engine-hooks.js +149 -0
- package/dist/runtime-engine-hooks.js.map +1 -0
- package/dist/runtime-engine-integrations.d.ts +16 -0
- package/dist/runtime-engine-integrations.d.ts.map +1 -0
- package/dist/runtime-engine-integrations.js +177 -0
- package/dist/runtime-engine-integrations.js.map +1 -0
- package/dist/runtime-engine-operations.d.ts +87 -0
- package/dist/runtime-engine-operations.d.ts.map +1 -0
- package/dist/runtime-engine-operations.js +204 -0
- package/dist/runtime-engine-operations.js.map +1 -0
- package/dist/runtime-engine-resources.d.ts +18 -0
- package/dist/runtime-engine-resources.d.ts.map +1 -0
- package/dist/runtime-engine-resources.js +49 -0
- package/dist/runtime-engine-resources.js.map +1 -0
- package/dist/runtime-engine-run.d.ts +70 -0
- package/dist/runtime-engine-run.d.ts.map +1 -0
- package/dist/runtime-engine-run.js +202 -0
- package/dist/runtime-engine-run.js.map +1 -0
- package/dist/runtime-engine-scheduling.d.ts +22 -0
- package/dist/runtime-engine-scheduling.d.ts.map +1 -0
- package/dist/runtime-engine-scheduling.js +45 -0
- package/dist/runtime-engine-scheduling.js.map +1 -0
- package/dist/runtime-engine-tools.d.ts +8 -0
- package/dist/runtime-engine-tools.d.ts.map +1 -0
- package/dist/runtime-engine-tools.js +80 -0
- package/dist/runtime-engine-tools.js.map +1 -0
- package/dist/runtime-evolution.d.ts +17 -0
- package/dist/runtime-evolution.d.ts.map +1 -0
- package/dist/runtime-evolution.js +51 -0
- package/dist/runtime-evolution.js.map +1 -0
- package/dist/runtime-learning.d.ts +4 -6
- package/dist/runtime-learning.d.ts.map +1 -1
- package/dist/runtime-learning.js +109 -99
- package/dist/runtime-learning.js.map +1 -1
- package/dist/runtime-types.d.ts +21 -7
- package/dist/runtime-types.d.ts.map +1 -1
- package/dist/runtime-util.d.ts +4 -3
- package/dist/runtime-util.d.ts.map +1 -1
- package/dist/runtime-util.js +0 -7
- package/dist/runtime-util.js.map +1 -1
- package/dist/sandbox-fs.d.ts +2 -7
- package/dist/sandbox-fs.d.ts.map +1 -1
- package/dist/sandbox-fs.js +6 -37
- package/dist/sandbox-fs.js.map +1 -1
- package/dist/sandbox-handle.d.ts +1 -3
- package/dist/sandbox-handle.d.ts.map +1 -1
- package/dist/sandbox-handle.js +2 -5
- package/dist/sandbox-handle.js.map +1 -1
- package/dist/sandbox-state-sync.d.ts +2 -0
- package/dist/sandbox-state-sync.d.ts.map +1 -1
- package/dist/sandbox-state-sync.js +26 -2
- package/dist/sandbox-state-sync.js.map +1 -1
- package/dist/sandbox-tool-bridge.js +2 -3
- package/dist/sandbox-tool-bridge.js.map +1 -1
- package/dist/schedule-execution.d.ts +4 -4
- package/dist/schedule-execution.d.ts.map +1 -1
- package/dist/schedule-execution.js +45 -440
- package/dist/schedule-execution.js.map +1 -1
- package/dist/schedule-trigger-context.d.ts +18 -0
- package/dist/schedule-trigger-context.d.ts.map +1 -0
- package/dist/schedule-trigger-context.js +276 -0
- package/dist/schedule-trigger-context.js.map +1 -0
- package/dist/scheduler.d.ts +1 -14
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +1 -37
- package/dist/scheduler.js.map +1 -1
- package/dist/security.d.ts +0 -4
- package/dist/security.d.ts.map +1 -1
- package/dist/security.js +0 -22
- package/dist/security.js.map +1 -1
- package/dist/self-improvement.d.ts +5 -21
- package/dist/self-improvement.d.ts.map +1 -1
- package/dist/self-improvement.js +10 -40
- package/dist/self-improvement.js.map +1 -1
- package/dist/source-loader.d.ts +0 -3
- package/dist/source-loader.d.ts.map +1 -1
- package/dist/source-loader.js +1 -10
- package/dist/source-loader.js.map +1 -1
- package/dist/state/conversation-state.d.ts +117 -0
- package/dist/state/conversation-state.d.ts.map +1 -0
- package/dist/state/conversation-state.js +2 -0
- package/dist/state/conversation-state.js.map +1 -0
- package/dist/state/run-state.d.ts +129 -0
- package/dist/state/run-state.d.ts.map +1 -0
- package/dist/state/run-state.js +3 -0
- package/dist/state/run-state.js.map +1 -0
- package/dist/state/sandbox-memory-state.d.ts +159 -0
- package/dist/state/sandbox-memory-state.d.ts.map +1 -0
- package/dist/state/sandbox-memory-state.js +2 -0
- package/dist/state/sandbox-memory-state.js.map +1 -0
- package/dist/state/store-contracts.d.ts +329 -0
- package/dist/state/store-contracts.d.ts.map +1 -0
- package/dist/state/store-contracts.js +26 -0
- package/dist/state/store-contracts.js.map +1 -0
- package/dist/state/usage-state.d.ts +111 -0
- package/dist/state/usage-state.d.ts.map +1 -0
- package/dist/state/usage-state.js +2 -0
- package/dist/state/usage-state.js.map +1 -0
- package/dist/state/workspace-state.d.ts +126 -0
- package/dist/state/workspace-state.d.ts.map +1 -0
- package/dist/state/workspace-state.js +16 -0
- package/dist/state/workspace-state.js.map +1 -0
- package/dist/state-stores.d.ts +3 -15
- package/dist/state-stores.d.ts.map +1 -1
- package/dist/state-stores.js +36 -82
- package/dist/state-stores.js.map +1 -1
- package/dist/state.d.ts +7 -1075
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +7 -88
- package/dist/state.js.map +1 -1
- package/dist/storage.d.ts +4 -64
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +5 -408
- package/dist/storage.js.map +1 -1
- package/dist/subagent-execution.d.ts +1 -2
- package/dist/subagent-execution.d.ts.map +1 -1
- package/dist/subagent-execution.js +2 -26
- package/dist/subagent-execution.js.map +1 -1
- package/dist/subagent-handoff.d.ts +13 -0
- package/dist/subagent-handoff.d.ts.map +1 -1
- package/dist/subagent-handoff.js +74 -9
- package/dist/subagent-handoff.js.map +1 -1
- package/dist/tool-apis.d.ts +2 -2
- package/dist/tool-apis.d.ts.map +1 -1
- package/dist/tool-apis.js +26 -14
- package/dist/tool-apis.js.map +1 -1
- package/dist/tool-execution-host.d.ts +121 -0
- package/dist/tool-execution-host.d.ts.map +1 -0
- package/dist/tool-execution-host.js +2 -0
- package/dist/tool-execution-host.js.map +1 -0
- package/dist/tool-execution.d.ts +5 -141
- package/dist/tool-execution.d.ts.map +1 -1
- package/dist/tool-execution.js +6 -395
- package/dist/tool-execution.js.map +1 -1
- package/dist/usage-reconciliation-support.d.ts +20 -0
- package/dist/usage-reconciliation-support.d.ts.map +1 -0
- package/dist/usage-reconciliation-support.js +95 -0
- package/dist/usage-reconciliation-support.js.map +1 -0
- package/dist/usage-reconciliation.d.ts +14 -35
- package/dist/usage-reconciliation.d.ts.map +1 -1
- package/dist/usage-reconciliation.js +17 -394
- package/dist/usage-reconciliation.js.map +1 -1
- package/dist/workspace-paths.d.ts +3 -0
- package/dist/workspace-paths.d.ts.map +1 -0
- package/dist/workspace-paths.js +13 -0
- package/dist/workspace-paths.js.map +1 -0
- package/dist/workspace-service.d.ts +0 -1
- package/dist/workspace-service.d.ts.map +1 -1
- package/dist/workspace-service.js +1 -4
- package/dist/workspace-service.js.map +1 -1
- package/package.json +3 -3
- package/dist/run-timeline.d.ts +0 -11
- package/dist/run-timeline.d.ts.map +0 -1
- package/dist/run-timeline.js +0 -2
- package/dist/run-timeline.js.map +0 -1
- package/dist/trusted-attachments.d.ts +0 -20
- package/dist/trusted-attachments.d.ts.map +0 -1
- package/dist/trusted-attachments.js +0 -276
- package/dist/trusted-attachments.js.map +0 -1
package/dist/replay-resume.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { isJsonObject, redactedToolCallRecord } from "./json-util.js";
|
|
7
|
-
import { prepareToolModelOutput } from "./model-media.js";
|
|
8
|
-
import { crashResumeReport } from "./run-recovery.js";
|
|
9
|
-
import { applyCoreToolPolicy } from "./security.js";
|
|
10
|
-
import { surfaceForRun } from "./agent-surface.js";
|
|
11
|
-
import { runUsesChannelReplyForHumanInput } from "./human-input-routing.js";
|
|
12
|
-
import { normalizeAgentAudience } from "./audience.js";
|
|
1
|
+
import { redactedToolCallRecord } from "./json-util.js";
|
|
2
|
+
export { completeConnectionAuthorizationCallbackImpl } from "./replay-resume-authorization.js";
|
|
3
|
+
export { resumeApprovalNowImpl, resumeInputNowImpl, resumeSuspendedNowImpl } from "./replay-resume-controls.js";
|
|
4
|
+
export { resumeHarnessLoopImpl } from "./replay-resume-harness.js";
|
|
5
|
+
export { resumeRunFromContinuationImpl } from "./replay-resume-recovery.js";
|
|
13
6
|
export async function replayImpl(host, runId) {
|
|
14
7
|
const run = await host.state.getRun(runId);
|
|
15
8
|
if (!run)
|
|
@@ -23,707 +16,4 @@ export async function replayImpl(host, runId) {
|
|
|
23
16
|
usage: await host.state.listUsage(runId)
|
|
24
17
|
};
|
|
25
18
|
}
|
|
26
|
-
/** How long a claimed-but-unprogressed resume must sit before it may be reclaimed. */
|
|
27
|
-
const RESUME_RECLAIM_STALE_MS = 5 * 60_000;
|
|
28
|
-
/**
|
|
29
|
-
* A resume claim was already taken, but resume claims are not leases: if the
|
|
30
|
-
* claimer crashed between the claim and the run's status transition, the pause
|
|
31
|
-
* would be permanently un-resumable. A run that is still parked and has not
|
|
32
|
-
* been touched for RESUME_RECLAIM_STALE_MS has no live resumer (a live one
|
|
33
|
-
* bumps `updatedAt` immediately and heartbeats after), so a retry generation
|
|
34
|
-
* may be claimed. The reclaim bumps `updatedAt` first, keeping later retry
|
|
35
|
-
* generations distinct if this one also dies.
|
|
36
|
-
*/
|
|
37
|
-
async function reclaimStaleResume(host, run, baseKey, kind) {
|
|
38
|
-
const inProgress = new Error(`Run ${run.id} ${kind} resume is already in progress.`);
|
|
39
|
-
if (Date.parse(run.updatedAt) > Date.now() - RESUME_RECLAIM_STALE_MS)
|
|
40
|
-
throw inProgress;
|
|
41
|
-
const reclaimed = await host.state.reserveIdempotencyKey("resume", `${baseKey}:retry:${run.updatedAt}`, run.id);
|
|
42
|
-
if (!reclaimed)
|
|
43
|
-
throw inProgress;
|
|
44
|
-
await host.state.updateRun(run.id, {});
|
|
45
|
-
}
|
|
46
|
-
export async function resumeApprovalNowImpl(host, runId) {
|
|
47
|
-
host.boot();
|
|
48
|
-
await host.initializeInstrumentation();
|
|
49
|
-
let run = await host.state.getRun(runId);
|
|
50
|
-
if (!run)
|
|
51
|
-
throw new Error(`Run not found: ${runId}`);
|
|
52
|
-
if (run.status !== "waiting_for_approval")
|
|
53
|
-
throw new Error(`Run ${runId} is not waiting for approval.`);
|
|
54
|
-
const toolCall = (await host.state.listToolCalls(runId)).find((candidate) => candidate.status === "waiting_for_approval");
|
|
55
|
-
if (!toolCall)
|
|
56
|
-
throw new Error(`Run ${runId} has no approval-gated tool call to resume.`);
|
|
57
|
-
// Per-pause-generation claim: a double-clicked approval (or a concurrent
|
|
58
|
-
// replica) must execute the gated tool exactly once. `updatedAt` changes
|
|
59
|
-
// on every pause, so later legitimate pauses of the same tool call get a
|
|
60
|
-
// fresh key.
|
|
61
|
-
const resumeClaimed = await host.state.reserveIdempotencyKey("resume", `${run.id}:${toolCall.id}:${toolCall.updatedAt}`, run.id);
|
|
62
|
-
if (!resumeClaimed) {
|
|
63
|
-
await reclaimStaleResume(host, run, `${run.id}:${toolCall.id}:${toolCall.updatedAt}`, "approval");
|
|
64
|
-
}
|
|
65
|
-
if (parseQualifiedName(toolCall.toolName)) {
|
|
66
|
-
await host.state.appendEvent(run.id, "tool.approval_resumed", { toolCallId: toolCall.id, toolName: toolCall.toolName });
|
|
67
|
-
return resumeConnectionToolContinuation(host, run, toolCall);
|
|
68
|
-
}
|
|
69
|
-
const tool = runtimeToolsForSurface(surfaceForRun(host.manifest, run).tools)
|
|
70
|
-
.find((candidate) => candidate.name === toolCall.toolName);
|
|
71
|
-
if (!tool)
|
|
72
|
-
throw new Error(`Tool not found: ${toolCall.toolName}`);
|
|
73
|
-
const policyTool = applyCoreToolPolicy(tool, host.coreToolPolicy);
|
|
74
|
-
if (!policyTool)
|
|
75
|
-
throw new Error(`Core tool ${tool.name} is disabled by the Assembly Line core tool policy.`);
|
|
76
|
-
let currentRun = await host.state.updateRun(run.id, { status: "running" });
|
|
77
|
-
await host.state.appendEvent(currentRun.id, "tool.approval_resumed", { toolCallId: toolCall.id, toolName: policyTool.name });
|
|
78
|
-
const hookController = await host.ensureAgentHookController(currentRun);
|
|
79
|
-
const approvalCapabilities = hookController.current.declaration;
|
|
80
|
-
let bundle = await host.buildContextBundle({
|
|
81
|
-
message: "approval resume",
|
|
82
|
-
channel: "local",
|
|
83
|
-
capabilities: approvalCapabilities,
|
|
84
|
-
run: currentRun
|
|
85
|
-
});
|
|
86
|
-
bundle = {
|
|
87
|
-
...bundle,
|
|
88
|
-
instructions: host.resolvedInstructionsForRun(currentRun, bundle, approvalCapabilities)
|
|
89
|
-
};
|
|
90
|
-
const sandboxHandle = host.createSandboxHandle(() => currentRun, (nextRun) => {
|
|
91
|
-
currentRun = nextRun;
|
|
92
|
-
}, () => bundle);
|
|
93
|
-
// The approved tool may run for minutes; without a heartbeat the orphan
|
|
94
|
-
// sweep would claim this run as crashed mid-execution.
|
|
95
|
-
const heartbeat = host.startRunHeartbeat(currentRun.id);
|
|
96
|
-
const outcome = await host
|
|
97
|
-
.executeToolWithRecord(currentRun, policyTool, toolCall, toolCall.input, sandboxHandle, true)
|
|
98
|
-
.finally(() => heartbeat.stop());
|
|
99
|
-
if (outcome.waitingForInput) {
|
|
100
|
-
return host.result(outcome.run, "Human input required.", false, true);
|
|
101
|
-
}
|
|
102
|
-
// Feed the approved tool's result back into the model loop so the agent
|
|
103
|
-
// can continue reasoning, instead of ending the run with raw tool output.
|
|
104
|
-
const resumable = await restoreMatchingContinuation(host, run.id, toolCall.toolName);
|
|
105
|
-
if (resumable) {
|
|
106
|
-
const toolResult = preparedResumeToolResult(toolCall.toolName, outcome.modelOutput, host.env);
|
|
107
|
-
return resumeHarnessLoopImpl(host, outcome.run, resumable.harness, resumable.restored, {
|
|
108
|
-
toolResult
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
// No usable continuation (pre-upgrade run or non-resumable harness):
|
|
112
|
-
// degrade to completing with the tool output, observably.
|
|
113
|
-
await host.state.appendEvent(run.id, "harness.resume_degraded", {
|
|
114
|
-
reason: "approval-resume-without-continuation",
|
|
115
|
-
toolCallId: toolCall.id,
|
|
116
|
-
toolName: toolCall.toolName
|
|
117
|
-
});
|
|
118
|
-
const response = typeof outcome.modelOutput === "string" ? outcome.modelOutput : JSON.stringify(outcome.modelOutput);
|
|
119
|
-
return host.completeRun(outcome.run, sandboxHandle, response, host.runDeliveryChannel(outcome.run));
|
|
120
|
-
}
|
|
121
|
-
/** Restore the latest continuation checkpoint if it matches the resolved harness. */
|
|
122
|
-
async function restoreMatchingContinuation(host, runId, toolName) {
|
|
123
|
-
const restored = readHarnessContinuation(undefined, await host.listHydratedCheckpoints(runId), toolName);
|
|
124
|
-
if (!restored)
|
|
125
|
-
return undefined;
|
|
126
|
-
const harness = await host.resolveAgentHarness(restored.runtime.modelSpec);
|
|
127
|
-
if (restored.continuation.harness !== harness.id || restored.continuation.version !== harness.continuationVersion) {
|
|
128
|
-
await host.state.appendEvent(runId, "harness.continuation_mismatch", {
|
|
129
|
-
expectedHarness: harness.id,
|
|
130
|
-
expectedVersion: harness.continuationVersion,
|
|
131
|
-
storedHarness: restored.continuation.harness,
|
|
132
|
-
storedVersion: restored.continuation.version
|
|
133
|
-
});
|
|
134
|
-
return undefined;
|
|
135
|
-
}
|
|
136
|
-
return { harness, restored };
|
|
137
|
-
}
|
|
138
|
-
export async function completeConnectionAuthorizationCallbackImpl(host, callback) {
|
|
139
|
-
host.boot();
|
|
140
|
-
await host.initializeInstrumentation();
|
|
141
|
-
await host.ensureDynamicConnections();
|
|
142
|
-
const registry = new RuntimeConnectionRegistry({
|
|
143
|
-
connections: host.mergedConnections(),
|
|
144
|
-
config: host.env,
|
|
145
|
-
credentialBroker: host.credentialBroker,
|
|
146
|
-
fetch: host.fetch,
|
|
147
|
-
session: { channel: "authorization" },
|
|
148
|
-
grantStore: host.connectionGrantStore,
|
|
149
|
-
authorizationSessionStore: host.connectionAuthorizationSessionStore,
|
|
150
|
-
...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
|
|
151
|
-
loadDefinition: async (connection) => host.loadConnectionDefinition(connection)
|
|
152
|
-
});
|
|
153
|
-
const session = await registry.completeAuthorization(callback);
|
|
154
|
-
if (!session.runId || !session.toolCallId) {
|
|
155
|
-
return {
|
|
156
|
-
status: 200,
|
|
157
|
-
body: {
|
|
158
|
-
ok: true,
|
|
159
|
-
connection: session.connectionName,
|
|
160
|
-
status: session.status
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
const run = await host.state.getRun(session.runId);
|
|
165
|
-
if (!run)
|
|
166
|
-
throw new Error(`Run not found for authorization callback: ${session.runId}`);
|
|
167
|
-
const toolCall = (await host.state.listToolCalls(run.id)).find((candidate) => candidate.id === session.toolCallId);
|
|
168
|
-
if (!toolCall)
|
|
169
|
-
throw new Error(`Tool call not found for authorization callback: ${session.toolCallId}`);
|
|
170
|
-
await host.state.appendEvent(run.id, "authorization.completed", {
|
|
171
|
-
connectionName: session.connectionName,
|
|
172
|
-
authorizationSessionId: session.id,
|
|
173
|
-
toolCallId: toolCall.id
|
|
174
|
-
});
|
|
175
|
-
if (runUsesChannelReplyForHumanInput(run)) {
|
|
176
|
-
if (run.status === "running" || run.status === "created") {
|
|
177
|
-
await host.state.appendEvent(run.id, "authorization.available_to_active_run", {
|
|
178
|
-
connectionName: session.connectionName,
|
|
179
|
-
authorizationSessionId: session.id,
|
|
180
|
-
toolCallId: toolCall.id
|
|
181
|
-
});
|
|
182
|
-
return {
|
|
183
|
-
status: 200,
|
|
184
|
-
body: {
|
|
185
|
-
ok: true,
|
|
186
|
-
connection: session.connectionName,
|
|
187
|
-
runId: run.id,
|
|
188
|
-
runStatus: run.status,
|
|
189
|
-
continuation: "active_run"
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
if (run.status !== "completed" && run.status !== "waiting_for_connection") {
|
|
194
|
-
return {
|
|
195
|
-
status: 200,
|
|
196
|
-
body: {
|
|
197
|
-
ok: true,
|
|
198
|
-
connection: session.connectionName,
|
|
199
|
-
runId: run.id,
|
|
200
|
-
runStatus: run.status,
|
|
201
|
-
continuation: "not_resumed"
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
const turn = authorizationContinuationTurn(run, session);
|
|
206
|
-
if (!turn) {
|
|
207
|
-
return {
|
|
208
|
-
status: 200,
|
|
209
|
-
body: {
|
|
210
|
-
ok: true,
|
|
211
|
-
connection: session.connectionName,
|
|
212
|
-
runId: run.id,
|
|
213
|
-
runStatus: run.status,
|
|
214
|
-
continuation: "unavailable"
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
const queued = await host.enqueueConversationTurn({
|
|
219
|
-
turn,
|
|
220
|
-
idempotencyScope: "connection:authorization-continuation",
|
|
221
|
-
idempotencyKey: session.id
|
|
222
|
-
});
|
|
223
|
-
let detachedRun = run;
|
|
224
|
-
if (run.status === "waiting_for_connection") {
|
|
225
|
-
detachedRun = await host.state.updateRun(run.id, { status: "completed" });
|
|
226
|
-
await host.state.appendEvent(run.id, "run.completed", {
|
|
227
|
-
response: "",
|
|
228
|
-
detachedAuthorization: true
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
await host.state.appendEvent(run.id, "authorization.continuation_queued", {
|
|
232
|
-
connectionName: session.connectionName,
|
|
233
|
-
authorizationSessionId: session.id,
|
|
234
|
-
toolCallId: toolCall.id,
|
|
235
|
-
inserted: queued.inserted
|
|
236
|
-
});
|
|
237
|
-
return {
|
|
238
|
-
status: 202,
|
|
239
|
-
body: {
|
|
240
|
-
ok: true,
|
|
241
|
-
connection: session.connectionName,
|
|
242
|
-
runId: detachedRun.id,
|
|
243
|
-
runStatus: detachedRun.status,
|
|
244
|
-
continuation: queued.inserted ? "queued" : "already_queued"
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
// Protocol-owned waits resume in place. Claim this pause generation before
|
|
249
|
-
// executing the gated tool so replayed callbacks cannot repeat side effects.
|
|
250
|
-
const resumeClaimed = await host.state.reserveIdempotencyKey("resume", `${run.id}:${toolCall.id}:${toolCall.updatedAt}`, run.id);
|
|
251
|
-
if (!resumeClaimed) {
|
|
252
|
-
return {
|
|
253
|
-
status: 200,
|
|
254
|
-
body: {
|
|
255
|
-
ok: true,
|
|
256
|
-
connection: session.connectionName,
|
|
257
|
-
runId: run.id,
|
|
258
|
-
runStatus: run.status,
|
|
259
|
-
response: "Authorization already processed."
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
const runResult = await host.withRunAdmission(() => resumeConnectionToolContinuation(host, run, toolCall, session));
|
|
264
|
-
return {
|
|
265
|
-
status: 200,
|
|
266
|
-
body: {
|
|
267
|
-
ok: true,
|
|
268
|
-
connection: session.connectionName,
|
|
269
|
-
runId: runResult.run.id,
|
|
270
|
-
runStatus: runResult.run.status,
|
|
271
|
-
response: runResult.response ?? ""
|
|
272
|
-
},
|
|
273
|
-
runResult
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function authorizationContinuationTurn(run, session) {
|
|
277
|
-
const channel = typeof run.input.channel === "string" ? run.input.channel : undefined;
|
|
278
|
-
const conversationId = typeof run.input.conversationId === "string" ? run.input.conversationId : undefined;
|
|
279
|
-
if (!channel || !conversationId)
|
|
280
|
-
return undefined;
|
|
281
|
-
const turn = {
|
|
282
|
-
eventId: `connection-authorization:${run.id}:${session.toolCallId ?? session.connectionName}`,
|
|
283
|
-
channel,
|
|
284
|
-
conversationId,
|
|
285
|
-
message: [
|
|
286
|
-
`Authorization for ${session.connectionName} completed.`,
|
|
287
|
-
`Continue the prior user request from conversation history and retry ${session.toolName ?? "the connection operation"} if it is still appropriate.`,
|
|
288
|
-
"Do not repeat side effects that already completed."
|
|
289
|
-
].join(" ")
|
|
290
|
-
};
|
|
291
|
-
if (typeof run.input.userId === "string")
|
|
292
|
-
turn.userId = run.input.userId;
|
|
293
|
-
if (isJsonObject(run.input.principal))
|
|
294
|
-
turn.principal = run.input.principal;
|
|
295
|
-
if (isJsonObject(run.input.initiator))
|
|
296
|
-
turn.initiator = run.input.initiator;
|
|
297
|
-
const audience = normalizeAgentAudience(run.input.audience);
|
|
298
|
-
if (audience)
|
|
299
|
-
turn.audience = audience;
|
|
300
|
-
if (isJsonObject(run.input.delivery))
|
|
301
|
-
turn.delivery = run.input.delivery;
|
|
302
|
-
turn.metadata = {
|
|
303
|
-
...(isJsonObject(run.input.metadata) ? run.input.metadata : {}),
|
|
304
|
-
assemblyLine: {
|
|
305
|
-
kind: "connection_authorization_continuation",
|
|
306
|
-
sourceRunId: run.id,
|
|
307
|
-
connectionName: session.connectionName
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
return turn;
|
|
311
|
-
}
|
|
312
|
-
export async function resumeInputNowImpl(host, runId, answer) {
|
|
313
|
-
host.boot();
|
|
314
|
-
await host.initializeInstrumentation();
|
|
315
|
-
const run = await host.state.getRun(runId);
|
|
316
|
-
if (!run)
|
|
317
|
-
throw new Error(`Run not found: ${runId}`);
|
|
318
|
-
if (run.status !== "waiting_for_input")
|
|
319
|
-
throw new Error(`Run ${runId} is not waiting for input.`);
|
|
320
|
-
// The pending question is the tool call parked by HumanInputRequired.
|
|
321
|
-
const toolCall = (await host.state.listToolCalls(runId)).find((candidate) => candidate.status === "waiting_for_approval");
|
|
322
|
-
// Per-pause-generation claim so a double-submitted answer resumes once.
|
|
323
|
-
const resumeClaimed = await host.state.reserveIdempotencyKey("resume", toolCall ? `${run.id}:${toolCall.id}:${toolCall.updatedAt}` : `${run.id}:input:${run.updatedAt}`, run.id);
|
|
324
|
-
if (!resumeClaimed) {
|
|
325
|
-
await reclaimStaleResume(host, run, toolCall ? `${run.id}:${toolCall.id}:${toolCall.updatedAt}` : `${run.id}:input:${run.updatedAt}`, "input");
|
|
326
|
-
}
|
|
327
|
-
let running = await host.state.updateRun(run.id, { status: "running" });
|
|
328
|
-
await host.state.appendEvent(run.id, "human_input.received", { answer });
|
|
329
|
-
if (toolCall) {
|
|
330
|
-
await host.state.updateToolCall(toolCall.id, {
|
|
331
|
-
status: "completed",
|
|
332
|
-
result: { answer },
|
|
333
|
-
modelOutput: { answer }
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
// Feed the human's answer back into the model loop as the pending tool's
|
|
337
|
-
// result so the agent that asked actually sees it and continues.
|
|
338
|
-
const toolName = toolCall?.toolName ?? "human_input";
|
|
339
|
-
const resumable = await restoreMatchingContinuation(host, run.id, toolName);
|
|
340
|
-
if (resumable) {
|
|
341
|
-
return resumeHarnessLoopImpl(host, running, resumable.harness, resumable.restored, {
|
|
342
|
-
toolResult: { toolName, output: { answer } }
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
await host.state.appendEvent(run.id, "harness.resume_degraded", {
|
|
346
|
-
reason: "input-resume-without-continuation",
|
|
347
|
-
toolCallId: toolCall?.id ?? null,
|
|
348
|
-
toolName
|
|
349
|
-
});
|
|
350
|
-
const hookController = await host.ensureAgentHookController(running);
|
|
351
|
-
const inputCapabilities = hookController.current.declaration;
|
|
352
|
-
let bundle = await host.buildContextBundle({
|
|
353
|
-
message: answer,
|
|
354
|
-
channel: "local",
|
|
355
|
-
capabilities: inputCapabilities,
|
|
356
|
-
run: running
|
|
357
|
-
});
|
|
358
|
-
bundle = {
|
|
359
|
-
...bundle,
|
|
360
|
-
instructions: host.resolvedInstructionsForRun(running, bundle, inputCapabilities)
|
|
361
|
-
};
|
|
362
|
-
const sandboxHandle = host.createSandboxHandle(() => running, (nextRun) => {
|
|
363
|
-
running = nextRun;
|
|
364
|
-
}, () => bundle);
|
|
365
|
-
return host.completeRun(running, sandboxHandle, `Received input: ${answer}`, host.runDeliveryChannel(running));
|
|
366
|
-
}
|
|
367
|
-
export async function resumeSuspendedNowImpl(host, runId) {
|
|
368
|
-
host.boot();
|
|
369
|
-
await host.initializeInstrumentation();
|
|
370
|
-
await host.ensureDynamicConnections();
|
|
371
|
-
const run = await host.state.getRun(runId);
|
|
372
|
-
if (!run)
|
|
373
|
-
throw new Error(`Run not found: ${runId}`);
|
|
374
|
-
if (run.status !== "suspended")
|
|
375
|
-
throw new Error(`Run ${runId} is not suspended.`);
|
|
376
|
-
const resumeClaimed = await host.state.reserveIdempotencyKey("resume:suspended", `${run.id}:${run.updatedAt}`, run.id);
|
|
377
|
-
if (!resumeClaimed)
|
|
378
|
-
throw new Error(`Run ${runId} suspended resume is already in progress.`);
|
|
379
|
-
const restored = readHarnessContinuation(undefined, await host.listHydratedCheckpoints(runId));
|
|
380
|
-
if (!restored)
|
|
381
|
-
throw new Error(`Run ${runId} has no harness continuation to resume.`);
|
|
382
|
-
const harness = await host.resolveAgentHarness(restored.runtime.modelSpec);
|
|
383
|
-
if (restored.continuation.harness !== harness.id || restored.continuation.version !== harness.continuationVersion) {
|
|
384
|
-
await host.state.appendEvent(run.id, "harness.continuation_mismatch", {
|
|
385
|
-
expectedHarness: harness.id,
|
|
386
|
-
expectedVersion: harness.continuationVersion,
|
|
387
|
-
storedHarness: restored.continuation.harness,
|
|
388
|
-
storedVersion: restored.continuation.version
|
|
389
|
-
});
|
|
390
|
-
throw new Error(`Run ${runId} harness continuation is incompatible with the configured harness.`);
|
|
391
|
-
}
|
|
392
|
-
const running = await host.state.updateRun(run.id, { status: "running" });
|
|
393
|
-
await host.state.appendEvent(run.id, "run.resumed", { from: "suspended" });
|
|
394
|
-
return resumeHarnessLoopImpl(host, running, harness, restored, {});
|
|
395
|
-
}
|
|
396
|
-
async function resumeConnectionToolContinuation(host, run, toolCall, authorizationSession) {
|
|
397
|
-
const running = await host.state.updateRun(run.id, { status: "running" });
|
|
398
|
-
const hookController = await host.ensureAgentHookController(running);
|
|
399
|
-
const capabilities = hookController.current.declaration;
|
|
400
|
-
const fallbackChannel = typeof run.input.channel === "string" ? run.input.channel : "local";
|
|
401
|
-
const parsed = parseQualifiedName(toolCall.toolName);
|
|
402
|
-
if (parsed && !capabilities.connections.includes(parsed.connectionName)) {
|
|
403
|
-
throw new Error(`Connection ${parsed.connectionName} is no longer active on the current agent surface.`);
|
|
404
|
-
}
|
|
405
|
-
const sandboxCli = parsed
|
|
406
|
-
? host.mergedConnections().find((connection) => connection.name === parsed.connectionName)?.protocol === "cli"
|
|
407
|
-
: false;
|
|
408
|
-
let sandboxRun = running;
|
|
409
|
-
let sandboxHandle;
|
|
410
|
-
if (sandboxCli) {
|
|
411
|
-
const bundle = await host.buildContextBundle({
|
|
412
|
-
message: "connection approval resume",
|
|
413
|
-
channel: fallbackChannel,
|
|
414
|
-
capabilities,
|
|
415
|
-
run: sandboxRun
|
|
416
|
-
});
|
|
417
|
-
sandboxHandle = host.createSandboxHandle(() => sandboxRun, (nextRun) => {
|
|
418
|
-
sandboxRun = nextRun;
|
|
419
|
-
}, () => bundle);
|
|
420
|
-
}
|
|
421
|
-
const registry = sandboxHandle
|
|
422
|
-
? host.createConnectionRegistryForRun(running, fallbackChannel, sandboxHandle, new Set(capabilities.connections))
|
|
423
|
-
: authorizationSession
|
|
424
|
-
? host.createConnectionRegistryForSession(authorizationSession)
|
|
425
|
-
: host.createConnectionRegistry(fallbackChannel);
|
|
426
|
-
// The resumed connection tool may run for minutes; without a heartbeat the
|
|
427
|
-
// orphan sweep would claim this run as crashed mid-execution.
|
|
428
|
-
const heartbeat = host.startRunHeartbeat(running.id);
|
|
429
|
-
const outcome = await host
|
|
430
|
-
.executeConnectionToolWithRecord(running, registry, toolCall.toolName, toolCall, toolCall.input)
|
|
431
|
-
.finally(() => heartbeat.stop());
|
|
432
|
-
sandboxRun = outcome.run;
|
|
433
|
-
if (outcome.waitingForConnection) {
|
|
434
|
-
await sandboxHandle?.dispose();
|
|
435
|
-
return host.result(outcome.run, await connectionAuthorizationPrompt(host.connectionAuthorizationSessionStore, outcome.authorizationSessionId, ""), false, false, true);
|
|
436
|
-
}
|
|
437
|
-
let restored = readHarnessContinuation(authorizationSession?.continuation, await host.listHydratedCheckpoints(run.id), toolCall.toolName);
|
|
438
|
-
const harness = await host.resolveAgentHarness(restored?.runtime.modelSpec);
|
|
439
|
-
if (restored && (restored.continuation.harness !== harness.id || restored.continuation.version !== harness.continuationVersion)) {
|
|
440
|
-
await host.state.appendEvent(run.id, "harness.continuation_mismatch", {
|
|
441
|
-
expectedHarness: harness.id,
|
|
442
|
-
expectedVersion: harness.continuationVersion,
|
|
443
|
-
storedHarness: restored.continuation.harness,
|
|
444
|
-
storedVersion: restored.continuation.version
|
|
445
|
-
});
|
|
446
|
-
restored = undefined;
|
|
447
|
-
}
|
|
448
|
-
if (!restored) {
|
|
449
|
-
const response = typeof outcome.modelOutput === "string" ? outcome.modelOutput : JSON.stringify(outcome.modelOutput ?? {});
|
|
450
|
-
if (sandboxHandle) {
|
|
451
|
-
return host.completeRun(sandboxRun, sandboxHandle, response, host.runDeliveryChannel(sandboxRun));
|
|
452
|
-
}
|
|
453
|
-
let fallbackRun = outcome.run;
|
|
454
|
-
const bundle = await host.buildContextBundle({
|
|
455
|
-
message: "connection resume",
|
|
456
|
-
channel: "local",
|
|
457
|
-
capabilities,
|
|
458
|
-
run: fallbackRun
|
|
459
|
-
});
|
|
460
|
-
const fallbackSandboxHandle = host.createSandboxHandle(() => fallbackRun, (nextRun) => {
|
|
461
|
-
fallbackRun = nextRun;
|
|
462
|
-
}, () => bundle);
|
|
463
|
-
return host.completeRun(fallbackRun, fallbackSandboxHandle, response, host.runDeliveryChannel(fallbackRun));
|
|
464
|
-
}
|
|
465
|
-
const toolResult = preparedResumeToolResult(toolCall.toolName, outcome.modelOutput, host.env);
|
|
466
|
-
await sandboxHandle?.dispose();
|
|
467
|
-
return resumeHarnessLoopImpl(host, outcome.run, harness, restored, { toolResult });
|
|
468
|
-
}
|
|
469
|
-
/** Resume an orphaned run in place from its latest persisted continuation checkpoint. */
|
|
470
|
-
export async function resumeRunFromContinuationImpl(host, run, context) {
|
|
471
|
-
const checkpoints = await host.listHydratedCheckpoints(run.id);
|
|
472
|
-
let restored;
|
|
473
|
-
let checkpointCreatedAt;
|
|
474
|
-
for (let index = checkpoints.length - 1; index >= 0 && !restored; index -= 1) {
|
|
475
|
-
const checkpoint = checkpoints[index];
|
|
476
|
-
if (!checkpoint || checkpoint.name !== "harness.continuation")
|
|
477
|
-
continue;
|
|
478
|
-
restored = storedHarnessContinuation(checkpoint.data);
|
|
479
|
-
if (restored)
|
|
480
|
-
checkpointCreatedAt = checkpoint.createdAt;
|
|
481
|
-
}
|
|
482
|
-
if (!restored)
|
|
483
|
-
return undefined;
|
|
484
|
-
const harness = await host.resolveAgentHarness(restored.runtime.modelSpec);
|
|
485
|
-
if (restored.continuation.harness !== harness.id || restored.continuation.version !== harness.continuationVersion) {
|
|
486
|
-
await host.state.appendEvent(run.id, "harness.continuation_mismatch", {
|
|
487
|
-
expectedHarness: harness.id,
|
|
488
|
-
expectedVersion: harness.continuationVersion,
|
|
489
|
-
storedHarness: restored.continuation.harness,
|
|
490
|
-
storedVersion: restored.continuation.version
|
|
491
|
-
});
|
|
492
|
-
return undefined;
|
|
493
|
-
}
|
|
494
|
-
await host.state.appendEvent(run.id, "run.recovery_resume_attempted", { harness: harness.id });
|
|
495
|
-
const running = await host.state.updateRun(run.id, { status: "running" });
|
|
496
|
-
// If the continuation is parked on a tool that was mid-execution at crash
|
|
497
|
-
// time, resume with an explicit interrupted result so the model knows the
|
|
498
|
-
// side effects are indeterminate instead of silently re-requesting the
|
|
499
|
-
// tool. Otherwise resume from the iteration boundary as-is.
|
|
500
|
-
const pendingToolName = restored.runtime.pendingToolName;
|
|
501
|
-
const interrupted = context?.interruptedTools?.find((tool) => tool.toolName === pendingToolName);
|
|
502
|
-
const resume = interrupted
|
|
503
|
-
? {
|
|
504
|
-
toolResult: {
|
|
505
|
-
toolName: interrupted.toolName,
|
|
506
|
-
output: {
|
|
507
|
-
interrupted: true,
|
|
508
|
-
error: "This tool execution was interrupted by a runtime restart; its side effects may or may not have happened. Verify before re-running side-effecting operations."
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
: {};
|
|
513
|
-
// Crash mid-tool-batch: the restored checkpoint predates the batch's tool
|
|
514
|
-
// calls, so surface their durable outcomes as a follow-up message rather
|
|
515
|
-
// than letting the model silently re-execute completed side effects.
|
|
516
|
-
// (The pause path above splices the pending tool directly and needs no report.)
|
|
517
|
-
if (!interrupted) {
|
|
518
|
-
const report = crashResumeReport(await host.state.listToolCalls(run.id), checkpointCreatedAt, context?.interruptedTools ?? []);
|
|
519
|
-
if (report)
|
|
520
|
-
resume.message = report;
|
|
521
|
-
}
|
|
522
|
-
try {
|
|
523
|
-
const result = await resumeHarnessLoopImpl(host, running, harness, restored, resume);
|
|
524
|
-
return result.run;
|
|
525
|
-
}
|
|
526
|
-
catch (error) {
|
|
527
|
-
// A continuation parked on a completed assistant turn (or empty context)
|
|
528
|
-
// has nothing to resume; the harness signals this by refusing to continue.
|
|
529
|
-
// That is not a resume failure — it means the run already produced its
|
|
530
|
-
// final response — so degrade to "no usable continuation" and let recovery
|
|
531
|
-
// deliver the completed response instead of logging a spurious failure.
|
|
532
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
533
|
-
if (/continue from message role/iu.test(message) || /no messages in context/iu.test(message)) {
|
|
534
|
-
await host.state.appendEvent(run.id, "run.recovery_resume_unavailable", { reason: message });
|
|
535
|
-
return undefined;
|
|
536
|
-
}
|
|
537
|
-
throw error;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
export async function resumeHarnessLoopImpl(host, run, harness, restored, resume) {
|
|
541
|
-
let currentRun = run;
|
|
542
|
-
const controller = await host.ensureAgentHookController(currentRun);
|
|
543
|
-
let appliedSnapshotId = controller.current.id;
|
|
544
|
-
const capabilities = controller.current.declaration;
|
|
545
|
-
let appliedPromptKey = capabilityPromptKey(capabilities);
|
|
546
|
-
harness = await host.resolveAgentHarness(capabilities.model);
|
|
547
|
-
if (restored.continuation.harness !== harness.id || restored.continuation.version !== harness.continuationVersion) {
|
|
548
|
-
throw new Error(`Recovered capabilities select harness "${harness.id}" v${harness.continuationVersion}, which cannot read the stored ${restored.continuation.harness} v${restored.continuation.version} continuation.`);
|
|
549
|
-
}
|
|
550
|
-
const activeSkills = new Set(capabilities.skills);
|
|
551
|
-
const rootSurface = currentRun.input.agentSurface === "root";
|
|
552
|
-
const defaultToolNames = new Set(capabilityToolNames(capabilities, rootSurface));
|
|
553
|
-
const discoveredConnectionTools = new Map();
|
|
554
|
-
let pause;
|
|
555
|
-
let bundle = await host.buildContextBundle({
|
|
556
|
-
message: "harness resume",
|
|
557
|
-
channel: restored.runtime.channel,
|
|
558
|
-
capabilities,
|
|
559
|
-
run: currentRun
|
|
560
|
-
});
|
|
561
|
-
bundle = {
|
|
562
|
-
...bundle,
|
|
563
|
-
instructions: host.resolvedInstructionsForRun(currentRun, bundle, capabilities)
|
|
564
|
-
};
|
|
565
|
-
const sandboxHandle = host.createSandboxHandle(() => currentRun, (nextRun) => {
|
|
566
|
-
currentRun = nextRun;
|
|
567
|
-
}, () => bundle);
|
|
568
|
-
const connectionRegistry = host.createConnectionRegistryForRun(run, restored.runtime.channel, sandboxHandle, new Set(capabilities.connections));
|
|
569
|
-
const session = {
|
|
570
|
-
modelSpec: capabilities.model,
|
|
571
|
-
reasoning: capabilities.reasoning,
|
|
572
|
-
systemPrompt: capabilitySystemPrompt(bundle, capabilities.outputSchema, ""),
|
|
573
|
-
outputSchema: capabilities.outputSchema,
|
|
574
|
-
maxIterations: restored.runtime.maxIterations,
|
|
575
|
-
sessionId: restored.runtime.sessionId,
|
|
576
|
-
channel: restored.runtime.channel,
|
|
577
|
-
activeSkills,
|
|
578
|
-
defaultToolNames,
|
|
579
|
-
discoveredConnectionTools
|
|
580
|
-
};
|
|
581
|
-
if (restored.runtime.conversationId)
|
|
582
|
-
session.conversationId = restored.runtime.conversationId;
|
|
583
|
-
const loopState = {
|
|
584
|
-
run: () => currentRun,
|
|
585
|
-
setRun: (nextRun) => {
|
|
586
|
-
currentRun = nextRun;
|
|
587
|
-
},
|
|
588
|
-
sandboxHandle,
|
|
589
|
-
activeSkills,
|
|
590
|
-
defaultToolNames,
|
|
591
|
-
connectionRegistry,
|
|
592
|
-
discoveredConnectionTools,
|
|
593
|
-
exposedDeferredToolNames: new Set(),
|
|
594
|
-
setPause: (nextPause) => {
|
|
595
|
-
// First pause wins: in a tool batch where several calls pause, the
|
|
596
|
-
// run parks on the first one and later pauses must not repoint the
|
|
597
|
-
// resume bookkeeping mid-flight.
|
|
598
|
-
pause ??= nextPause;
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
const refreshCapabilities = async () => {
|
|
602
|
-
const snapshot = await controller.refreshIfDirty();
|
|
603
|
-
if (snapshot.id !== appliedSnapshotId) {
|
|
604
|
-
const nextSandbox = snapshot.declaration.sandbox ?? null;
|
|
605
|
-
const sandboxChanged = (currentRun.input.agentSandbox ?? null) !== nextSandbox;
|
|
606
|
-
if (sandboxChanged)
|
|
607
|
-
await sandboxHandle.reset();
|
|
608
|
-
currentRun = await host.state.updateRun(currentRun.id, {
|
|
609
|
-
input: {
|
|
610
|
-
...currentRun.input,
|
|
611
|
-
model: snapshot.declaration.model,
|
|
612
|
-
agentSandbox: nextSandbox,
|
|
613
|
-
agentConnections: snapshot.declaration.connections,
|
|
614
|
-
agentSubagents: snapshot.declaration.subagents
|
|
615
|
-
}
|
|
616
|
-
});
|
|
617
|
-
loopState.setRun(currentRun);
|
|
618
|
-
const nextPromptKey = capabilityPromptKey(snapshot.declaration);
|
|
619
|
-
const promptChanged = nextPromptKey !== appliedPromptKey;
|
|
620
|
-
if (promptChanged) {
|
|
621
|
-
bundle = await host.buildContextBundle({
|
|
622
|
-
message: "harness resume",
|
|
623
|
-
channel: restored.runtime.channel,
|
|
624
|
-
capabilities: snapshot.declaration,
|
|
625
|
-
run: currentRun
|
|
626
|
-
});
|
|
627
|
-
bundle = {
|
|
628
|
-
...bundle,
|
|
629
|
-
instructions: host.resolvedInstructionsForRun(currentRun, bundle, snapshot.declaration)
|
|
630
|
-
};
|
|
631
|
-
appliedPromptKey = nextPromptKey;
|
|
632
|
-
}
|
|
633
|
-
appliedSnapshotId = snapshot.id;
|
|
634
|
-
replaceCapabilitySet(activeSkills, snapshot.declaration.skills);
|
|
635
|
-
replaceCapabilitySet(defaultToolNames, capabilityToolNames(snapshot.declaration, rootSurface));
|
|
636
|
-
loopState.connectionRegistry = host.createConnectionRegistryForRun(currentRun, restored.runtime.channel, sandboxHandle, new Set(snapshot.declaration.connections));
|
|
637
|
-
discoveredConnectionTools.clear();
|
|
638
|
-
loopState.exposedDeferredToolNames.clear();
|
|
639
|
-
session.modelSpec = snapshot.declaration.model;
|
|
640
|
-
session.reasoning = snapshot.declaration.reasoning;
|
|
641
|
-
session.outputSchema = snapshot.declaration.outputSchema;
|
|
642
|
-
if (promptChanged) {
|
|
643
|
-
session.systemPrompt = capabilitySystemPrompt(bundle, snapshot.declaration.outputSchema, "");
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
return {
|
|
647
|
-
modelSpec: session.modelSpec,
|
|
648
|
-
systemPrompt: session.systemPrompt,
|
|
649
|
-
...(session.reasoning !== undefined ? { reasoning: session.reasoning } : {}),
|
|
650
|
-
...(session.outputSchema !== undefined ? { outputSchema: session.outputSchema } : {})
|
|
651
|
-
};
|
|
652
|
-
};
|
|
653
|
-
const heartbeat = host.startRunHeartbeat(run.id);
|
|
654
|
-
let policy;
|
|
655
|
-
try {
|
|
656
|
-
policy = await host.executeHarnessTurn(harness, {
|
|
657
|
-
kind: "resume",
|
|
658
|
-
continuation: restored.continuation,
|
|
659
|
-
...(resume.toolResult ? { toolResult: resume.toolResult } : {}),
|
|
660
|
-
...(resume.message !== undefined ? { message: resume.message } : {})
|
|
661
|
-
}, session, loopState, true, refreshCapabilities);
|
|
662
|
-
}
|
|
663
|
-
finally {
|
|
664
|
-
heartbeat.stop();
|
|
665
|
-
}
|
|
666
|
-
const result = policy.result;
|
|
667
|
-
if (pause) {
|
|
668
|
-
await host.persistHarnessContinuation(pause.run.id, session, result.continuation, pause);
|
|
669
|
-
return host.result(pause.run, result.response, pause.waitingForApproval, pause.waitingForInput, pause.waitingForConnection);
|
|
670
|
-
}
|
|
671
|
-
if (policy.failed || policy.controlStopped) {
|
|
672
|
-
await sandboxHandle.dispose();
|
|
673
|
-
return host.result(currentRun, result.response, false, false, false);
|
|
674
|
-
}
|
|
675
|
-
const completed = await host.completeRun(currentRun, sandboxHandle, result.response, restored.runtime.channel, undefined, restored.runtime.conversationId);
|
|
676
|
-
if (policy.output !== undefined)
|
|
677
|
-
completed.output = policy.output;
|
|
678
|
-
// Keep the conversation's transcript pointer current: a paused turn that
|
|
679
|
-
// completed here would otherwise leave the pointer at the pre-pause run and
|
|
680
|
-
// the next conversation turn would resume a transcript missing this one.
|
|
681
|
-
if (restored.runtime.conversationId && result.continuation && !policy.failed && !policy.controlStopped) {
|
|
682
|
-
try {
|
|
683
|
-
await persistConversationTranscriptImpl({
|
|
684
|
-
state: host.state,
|
|
685
|
-
createCheckpoint: (input) => host.createCheckpoint(input),
|
|
686
|
-
hydrateCheckpointData: (data) => host.hydrateCheckpointData(data)
|
|
687
|
-
}, {
|
|
688
|
-
runId: run.id,
|
|
689
|
-
conversationId: restored.runtime.conversationId,
|
|
690
|
-
session,
|
|
691
|
-
continuation: result.continuation,
|
|
692
|
-
...(session.lastInputTokens !== undefined ? { lastInputTokens: session.lastInputTokens } : {})
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
catch {
|
|
696
|
-
// Best-effort acceleration layer; the durable history is unaffected.
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
return completed;
|
|
700
|
-
}
|
|
701
|
-
function preparedResumeToolResult(toolName, output, env) {
|
|
702
|
-
const prepared = prepareToolModelOutput(output, env);
|
|
703
|
-
const result = {
|
|
704
|
-
toolName,
|
|
705
|
-
output: prepared.output
|
|
706
|
-
};
|
|
707
|
-
if (prepared.media.length > 0)
|
|
708
|
-
result.media = prepared.media;
|
|
709
|
-
return result;
|
|
710
|
-
}
|
|
711
|
-
function readHarnessContinuation(stored, checkpoints, toolName) {
|
|
712
|
-
if (stored)
|
|
713
|
-
return storedHarnessContinuation(stored);
|
|
714
|
-
for (let index = checkpoints.length - 1; index >= 0; index -= 1) {
|
|
715
|
-
const checkpoint = checkpoints[index];
|
|
716
|
-
if (!checkpoint)
|
|
717
|
-
continue;
|
|
718
|
-
if (checkpoint.name !== "harness.continuation")
|
|
719
|
-
continue;
|
|
720
|
-
const restored = storedHarnessContinuation(checkpoint.data);
|
|
721
|
-
if (!restored)
|
|
722
|
-
continue;
|
|
723
|
-
const pendingToolName = restored.runtime.pendingToolName;
|
|
724
|
-
if (toolName === undefined || typeof pendingToolName !== "string" || pendingToolName === toolName)
|
|
725
|
-
return restored;
|
|
726
|
-
}
|
|
727
|
-
return undefined;
|
|
728
|
-
}
|
|
729
19
|
//# sourceMappingURL=replay-resume.js.map
|