@assemblyline-agents/runtime 5.0.10 → 6.0.1
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 +20 -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 +12 -11
- 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 +0 -8
- 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/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 +153 -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-atomic-json.d.ts +4 -0
- package/dist/sandbox-atomic-json.d.ts.map +1 -0
- package/dist/sandbox-atomic-json.js +23 -0
- package/dist/sandbox-atomic-json.js.map +1 -0
- package/dist/sandbox-authored-tool-executor.d.ts.map +1 -1
- package/dist/sandbox-authored-tool-executor.js +13 -3
- package/dist/sandbox-authored-tool-executor.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.d.ts.map +1 -1
- package/dist/sandbox-tool-bridge.js +23 -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 +122 -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/index.js
CHANGED
|
@@ -1,2159 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
|
-
import { builtInToolDefinition } from "./builtin-tools.js";
|
|
4
|
-
import { InMemoryModelCredentialStore } from "./model-credential-stores.js";
|
|
5
|
-
import { CredentialBroker, environmentCredentialStore } from "./credential-broker.js";
|
|
6
|
-
import { channelCredentialEnvironment } from "./channel-credential-environment.js";
|
|
7
|
-
import { performConfiguredChannelOperation } from "./channel-operation.js";
|
|
8
|
-
import { instrumentationSetupContext } from "./instrumentation-environment.js";
|
|
1
|
+
export { AssemblyLineRuntime } from "./assembly-line-runtime.js";
|
|
9
2
|
export * from "./public-api.js";
|
|
10
3
|
export { builtInToolDefaults, FILES_MOUNT_TOOL_NAME, FILES_SEARCH_TOOL_NAME, HISTORY_SEARCH_TOOL_NAME, PAIR_TOOL_NAME } from "./builtin-tools.js";
|
|
11
4
|
export { inspectAgentCapabilities } from "./capability-inspection.js";
|
|
12
5
|
export { CONNECTION_PAIRING_UNAVAILABLE_EVENT, executePairTool } from "./builtin-tool-executors.js";
|
|
13
|
-
import { evalRunOptionsForRun, resolveEvalToolStub, validateEvalRunOptions } from "./eval-run-options.js";
|
|
14
|
-
import { rememberDefaultOutboundRoute } from "./default-outbound-route.js";
|
|
15
|
-
import { audienceFromRun, audienceUserKey, normalizeAgentAudience } from "./audience.js";
|
|
16
|
-
import { AgentSourceModuleLoader } from "./source-loader.js";
|
|
17
|
-
import { SandboxAuthoredToolExecutor, resolveAuthoredToolExecutionPolicy } from "./sandbox-authored-tool-executor.js";
|
|
18
|
-
import { AgentEventHandlerRegistry } from "./agent-event-handlers.js";
|
|
19
|
-
import { createMainAgentHookController as createMainAgentHookControllerImpl, createSubagentHookController as createSubagentHookControllerImpl } from "./agent-hook-controller-factory.js";
|
|
20
|
-
import { durableAgentSurfaceScope, flattenSubagents, surfaceForPath, surfaceForRun } from "./agent-surface.js";
|
|
21
|
-
import { recoverAgentHookController, removeTerminalAgentHookState, resolvedInstructionsForRun as resolvedHookInstructionsForRun } from "./agent-hook-run-lifecycle.js";
|
|
22
|
-
import { compiledChannelProvider, providerIngressSecurityError, providerIngressSecurityWarnings, resolveCoreToolPolicy, trustedAttachmentProviderForTurn } from "./security.js";
|
|
23
6
|
export { constantTimeSecretEqual } from "./security.js";
|
|
24
7
|
export { RUN_STREAM_TERMINAL_EVENTS } from "./run-stream.js";
|
|
25
8
|
export { failRun } from "./run-outcome.js";
|
|
26
|
-
export { MAX_CHANNEL_TURN_COALESCING_WINDOW_MS, QUEUED_CHANNEL_TURN_COALESCING_KEY, QUEUED_CHANNEL_TURN_KEY, QUEUED_CHANNEL_TURN_MERGED_INTO_KEY, QUEUED_CHANNEL_TURN_PARTS_KEY } from "./conversation-turn-coalescing.js";
|
|
27
|
-
import { ARTIFACT_DIR_NAME, ASSEMBLY_LINE_MANIFEST_SCHEMA_VERSION, manifestCredentialNames, resolveNonSecretRuntimeConfig, resolveRuntimeConfig } from "@assemblyline-agents/core";
|
|
28
|
-
import { resolveBooleanEnv, resolveNonNegativeIntegerEnv, resolvePositiveIntegerEnv } from "./env-config.js";
|
|
29
|
-
import { humanInputModeForChannel, withHumanInputMode } from "./human-input-routing.js";
|
|
30
|
-
import { RunEventBus, withRunEventPublishing } from "./run-stream.js";
|
|
31
|
-
import { failRun as failRunImpl, handleRunExecutionError, logTerminalRunEvent, settleCompletionBoundaryControlImpl } from "./run-outcome.js";
|
|
32
|
-
import { eventRenewsRunProgress, RunProgressSupervisor } from "./run-heartbeat.js";
|
|
33
|
-
import { redactTruncateJson } from "./content-capture.js";
|
|
34
|
-
import { isJsonObject, safeJson } from "./json-util.js";
|
|
35
|
-
import { sandboxSessionKeyForRun } from "./sandbox-session-key.js";
|
|
9
|
+
export { MAX_CHANNEL_TURN_COALESCING_WINDOW_MS, QUEUED_CHANNEL_TURN_COALESCING_KEY, QUEUED_CHANNEL_TURN_KEY, QUEUED_CHANNEL_TURN_MERGED_INTO_KEY, QUEUED_CHANNEL_TURN_PARTS_KEY, } from "./conversation-turn-coalescing.js";
|
|
36
10
|
export { sandboxSessionKeyForRun } from "./sandbox-session-key.js";
|
|
37
|
-
import { conversationInitiator, defaultUserPrincipal, initiatorFromRun, normalizeAgentPrincipal, principalFromRun, principalUserId } from "./principals.js";
|
|
38
|
-
import { InMemoryConnectionEventStore } from "./connection-event-store.js";
|
|
39
|
-
import { acceptConnectionEvent, checkConnectionEvents, drainConnectionEventInbox, reconcileConnectionEvents } from "./connection-events.js";
|
|
40
|
-
import { InMemoryConnectionAuthorizationSessionStore, InMemoryConnectionGrantStore, RuntimeConnectionRegistry } from "./connections.js";
|
|
41
11
|
export { createConnectionAssetApi } from "./connection-assets.js";
|
|
42
|
-
export { FileConnectionEventStore, InMemoryConnectionEventStore } from "./connection-event-store.js";
|
|
12
|
+
export { FileConnectionEventStore, InMemoryConnectionEventStore, } from "./connection-event-store.js";
|
|
43
13
|
export { connectionEventUrl } from "./connection-events.js";
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
import { mergeJsonObjects, processRuntimeTurnMedia } from "./turn-media.js";
|
|
49
|
-
export { mergeJsonObjects, processTurnMedia } from "./turn-media.js";
|
|
50
|
-
export { attachmentFetchTimeoutMs, attachmentRemoteUrl, attachmentTrustedForProvider, firstDownloadableUrl } from "./attachments.js";
|
|
14
|
+
export { mergeJsonObjects, processTurnMedia, } from "./turn-media.js";
|
|
15
|
+
export { mediaProcessorForChannel } from "./media-processor.js";
|
|
16
|
+
export { attachmentRemoteUrl, attachmentTrustedForProvider } from "./attachments.js";
|
|
17
|
+
export { attachmentFetchTimeoutMs, firstDownloadableUrl } from "./attachment-download.js";
|
|
51
18
|
export { assertExternalHttpUrl, fetchExternalHttp, isPublicAddress } from "./outbound-http-policy.js";
|
|
52
|
-
import { LocalSandboxAdapter } from "./local-sandbox.js";
|
|
53
|
-
import { schedulerAdapterForKind } from "./scheduler.js";
|
|
54
|
-
import { isTelemetrySink, telemetrySinkFromSetupResult } from "./telemetry.js";
|
|
55
|
-
import { InMemoryStateAdapter, LocalBlobAdapter, StateMemoryStore, positiveLimit } from "./storage.js";
|
|
56
|
-
import { createJsonConsoleLogger, normalizeLogLevel } from "./logging.js";
|
|
57
|
-
import { runDueDeliveriesImpl, startDeliveryWorkerImpl } from "./delivery-queue.js";
|
|
58
|
-
import { recoverIncompleteRunsImpl, startBackgroundWorkersImpl } from "./run-recovery.js";
|
|
59
|
-
import { captureSandboxSnapshotImpl, disposeSandboxSessionImpl, inspectSandboxSyncJobImpl, retrySandboxSyncJobImpl, runDueSandboxSyncJobsImpl, sandboxSyncDiagnosticsImpl, startSandboxSyncWorkerImpl } from "./sandbox-sync-worker.js";
|
|
60
|
-
import { beginChannelTurnImpl, completeRunImpl, latestRunFailureMessageImpl, recordChannelTurnStartImpl, sendDeliveryImpl, stopUnclaimedChannelTurnImpl, stopChannelTurnImpl } from "./delivery-send.js";
|
|
61
|
-
import { backfillMemoryDocumentsFromFileIndexesImpl, hydrateLogicalPathForToolImpl, listResourcesForRunImpl, memoryScopeForRunImpl, projectLoadedSkillsIntoSandboxImpl, projectResourcesForRunImpl, projectSkillIntoSandboxImpl, readResourceForRunImpl, readSandboxTombstonesWithMissingProjectedFilesImpl, recordSandboxTombstoneImpl, runMemoryEmbeddingBackfillImpl } from "./resource-projection.js";
|
|
62
|
-
import { createSkillBundleIndex, createSkillResourceReader } from "./skill-bundles.js";
|
|
63
|
-
import { createSandboxHandleImpl } from "./sandbox-handle.js";
|
|
64
|
-
import { RuntimeWorkspaceManager } from "./workspace-runtime.js";
|
|
65
|
-
import { DynamicScheduleRuntimeMethods } from "./dynamic-schedule-runtime.js";
|
|
66
|
-
import { beginConnectionAuthorizationImpl, createConnectionRegistryForRunImpl, createConnectionRegistryForSessionImpl, createConnectionRegistryImpl, executeConnectionToolWithRecordImpl, skillLoadDetailsImpl } from "./builtin-tool-executors.js";
|
|
67
|
-
import { createMemoryToolApiImpl, createResourceToolApiImpl, durableStepImpl } from "./tool-apis.js";
|
|
68
|
-
import { executeToolImpl, executeToolWithRecordImpl, harnessExecuteToolImpl, modelToolsImpl, selectToolImpl, visibleToolSetImpl, wrapSandboxImpl } from "./tool-execution.js";
|
|
69
|
-
import { dispatchAutomationEventImpl, normalizeScheduleTriggerDefinitionImpl, registerManifestSchedulesImpl, runDueSchedulesImpl, startSchedulerPollingLoopImpl } from "./schedule-execution.js";
|
|
70
|
-
import { completeConnectionAuthorizationCallbackImpl, replayImpl, resumeApprovalNowImpl, resumeHarnessLoopImpl, resumeInputNowImpl, resumeRunFromContinuationImpl, resumeSuspendedNowImpl } from "./replay-resume.js";
|
|
71
|
-
import { recordRunReplayStarted, rerunFromSnapshot } from "./run-replay.js";
|
|
72
19
|
export { RunReplayError } from "./run-replay.js";
|
|
73
|
-
import { buildRunAgentResult } from "./run-result.js";
|
|
74
|
-
import { createSubagentRunImpl, executeSubagentRunImpl, finalizeSubagentHandoffImpl, readSubagentImpl, resumeSubagentImpl, runSubagentImpl, sendSubagentFollowupImpl } from "./subagent-execution.js";
|
|
75
|
-
import { acceptBackgroundSubagentHandoff } from "./subagent-handoff.js";
|
|
76
|
-
import { createHarnessContextImpl, DEFAULT_MAX_MODEL_ITERATIONS, DEFAULT_OUTPUT_VALIDATION_MAX_RETRIES, executeHarnessTurnImpl, persistHarnessContinuationImpl, resolveAgentHarnessImpl, runHarnessLoopImpl } from "./harness-loop.js";
|
|
77
|
-
import { getAgentControlImpl, requestRunControlImpl, setAgentEnabledImpl, setAgentMaintenanceImpl } from "./operator-controls.js";
|
|
78
|
-
import { acceptChannelTurnImpl, channelAttachmentResolverImpl, dispatchHttpChannelImpl, loadChannelModuleImpl, observeChannelMessageImpl, startChannelAgentTurnImpl, startChannelIngressImpl } from "./channel-ingress.js";
|
|
79
|
-
import { augmentChannelContextImpl, buildContextBundleImpl, prepareConversationImpl, recentHistoryImpl } from "./conversation-context.js";
|
|
80
|
-
import { loadResumableConversationTranscriptImpl } from "./conversation-transcript.js";
|
|
81
|
-
import { ConversationTurnDispatcher } from "./conversation-turn-dispatch.js";
|
|
82
|
-
import { BackgroundSubagentCoordinator } from "./background-subagents.js";
|
|
83
|
-
import { instructionsForRunTargetImpl } from "./target-instructions.js";
|
|
84
|
-
import { emitTelemetrySpanImpl, runSpanAttributesImpl } from "./telemetry.js";
|
|
85
|
-
import { normalizeRuntimeState } from "./state-stores.js";
|
|
86
|
-
import { COMPACTABLE_ACTIVE_CHECKPOINT_NAMES, checkpointDataForStorage as checkpointDataForBlobStorage, emptyCheckpointRetentionResult, hydrateCheckpointData as hydrateCheckpointDataFromBlob, resolveCheckpointRetentionPolicy } from "./checkpoints.js";
|
|
87
20
|
export * from "./state.js";
|
|
88
21
|
export * from "./principals.js";
|
|
89
22
|
export * from "./audience.js";
|
|
90
23
|
export { evalRunOptionsForRun, validateEvalRunOptions } from "./eval-run-options.js";
|
|
91
|
-
export { InMemoryConversationStore, InMemoryConversationTurnStore, InMemoryFileIndexStore, InMemoryMemoryStateStore, InMemoryRunStore, InMemorySandboxSessionStore, InMemoryScheduleStateStore, InMemoryUsageStore, InMemoryWorkspaceStore, composeStateStores, normalizeMemoryPath, normalizeRuntimeState } from "./state-stores.js";
|
|
24
|
+
export { InMemoryConversationStore, InMemoryConversationTurnStore, InMemoryFileIndexStore, InMemoryMemoryStateStore, InMemoryRunStore, InMemorySandboxSessionStore, InMemoryScheduleStateStore, InMemoryUsageStore, InMemoryWorkspaceStore, composeStateStores, normalizeMemoryPath, normalizeRuntimeState, } from "./state-stores.js";
|
|
92
25
|
export * from "./workspace.js";
|
|
93
|
-
export { applyDeliveryPatch, createDeliveryRecord, deliveryQueueRetryDelayMs, isDeliveryDue, normalizeDeliveryRecord, stateSupportsDeliveryQueue } from "./delivery-queue.js";
|
|
26
|
+
export { applyDeliveryPatch, createDeliveryRecord, deliveryQueueRetryDelayMs, isDeliveryDue, normalizeDeliveryRecord, stateSupportsDeliveryQueue, } from "./delivery-queue.js";
|
|
94
27
|
export { defaultRunStaleAfterMs } from "./run-recovery.js";
|
|
95
28
|
export { BoundedSemaphore, RunCapacityError, retryAfterSeconds } from "./concurrency.js";
|
|
96
|
-
import { BoundedSemaphore, RunCapacityError } from "./concurrency.js";
|
|
97
|
-
import { DEFAULT_MODEL_OUTPUT_MAX_CHARS } from "@assemblyline-agents/core";
|
|
98
|
-
import { visibleToolsForSkills } from "./sandbox-fs.js";
|
|
99
|
-
import { resolveResourceProjectionPolicy } from "./resource-projection-util.js";
|
|
100
|
-
import { syncMemoryFromSandbox, syncSkillsFromSandbox } from "./sandbox-state-sync.js";
|
|
101
|
-
import { acquireSandboxForRun as acquireSandboxSessionForRun } from "./sandbox-session-lifecycle.js";
|
|
102
|
-
import { resolveSandboxSnapshotPolicy } from "./sandbox-snapshot-policy.js";
|
|
103
|
-
import { inferToolInput } from "./channel-http-util.js";
|
|
104
|
-
import { connectionPrincipalKeyForGrant, durableAgentScopeForManifest, isInstrumentationDefinition, normalizeCapturePolicy, randomHex, timestamp, } from "./runtime-util.js";
|
|
105
|
-
export class AssemblyLineRuntime extends DynamicScheduleRuntimeMethods {
|
|
106
|
-
manifest;
|
|
107
|
-
authoredToolExecution;
|
|
108
|
-
state;
|
|
109
|
-
runEventBus = new RunEventBus();
|
|
110
|
-
eventHandlers;
|
|
111
|
-
agentHookControllers = new Map();
|
|
112
|
-
agentStateHandles = new Map();
|
|
113
|
-
blob;
|
|
114
|
-
sandbox;
|
|
115
|
-
scheduler;
|
|
116
|
-
scheduleStore;
|
|
117
|
-
schedulesConfig;
|
|
118
|
-
mediaProcessors;
|
|
119
|
-
deliveryMode;
|
|
120
|
-
toolStubs;
|
|
121
|
-
/** Per-run {results:[...]} stub cursors; in-memory by design (see eval-run-options.ts). */
|
|
122
|
-
evalStubCursors = new Map();
|
|
123
|
-
/** @deprecated See {@link RuntimeOptions.models}. */
|
|
124
|
-
models;
|
|
125
|
-
agentHarnessOverride;
|
|
126
|
-
modelCredentialStore;
|
|
127
|
-
defaultAgentHarness;
|
|
128
|
-
checkpointEveryIteration;
|
|
129
|
-
checkpointRetention;
|
|
130
|
-
checkpointBlobStorageEnabled;
|
|
131
|
-
devMode;
|
|
132
|
-
sourceBundle;
|
|
133
|
-
connections;
|
|
134
|
-
env;
|
|
135
|
-
/** Fully resolved non-secret runtime configuration. */
|
|
136
|
-
config;
|
|
137
|
-
fetch;
|
|
138
|
-
attachmentHostResolver;
|
|
139
|
-
logger;
|
|
140
|
-
connectionGrantStore;
|
|
141
|
-
credentialBroker;
|
|
142
|
-
gatewayCredentials;
|
|
143
|
-
connectionAuthorizationSessionStore;
|
|
144
|
-
connectionEventStore;
|
|
145
|
-
connectionCallbackBaseUrl;
|
|
146
|
-
skillStore;
|
|
147
|
-
learningStore;
|
|
148
|
-
memoryStore;
|
|
149
|
-
connectionDefinitionStore;
|
|
150
|
-
skillsConfig;
|
|
151
|
-
connectionsConfig;
|
|
152
|
-
runtimeLearning;
|
|
153
|
-
connectionScopeMigrated = false;
|
|
154
|
-
dynamicConnectionsCache;
|
|
155
|
-
schedulerEnabled;
|
|
156
|
-
schedulerTickMs;
|
|
157
|
-
scheduleMaxConsecutiveFailures;
|
|
158
|
-
now;
|
|
159
|
-
sandboxSnapshotPolicy;
|
|
160
|
-
sandboxSyncInline;
|
|
161
|
-
sandboxSyncLeaseMs;
|
|
162
|
-
sandboxSyncBatchSize;
|
|
163
|
-
sandboxSyncMaxAttempts;
|
|
164
|
-
deliveryQueueLeaseMs;
|
|
165
|
-
toolOutputMaxChars;
|
|
166
|
-
toolTimeoutMs;
|
|
167
|
-
deliveryQueueBatchSize;
|
|
168
|
-
deliveryQueueMaxAttempts;
|
|
169
|
-
deliveryQueueIntervalMs;
|
|
170
|
-
runHeartbeatMs;
|
|
171
|
-
runRecoveryIntervalMs;
|
|
172
|
-
maxModelIterations;
|
|
173
|
-
outputValidationMaxRetries;
|
|
174
|
-
runSemaphore;
|
|
175
|
-
conversationTurnDispatcher;
|
|
176
|
-
backgroundSubagents;
|
|
177
|
-
memoryEmbeddingProvider;
|
|
178
|
-
memoryEmbeddingsEnabled;
|
|
179
|
-
resourceProjectionPolicy;
|
|
180
|
-
coreToolPolicy;
|
|
181
|
-
telemetry;
|
|
182
|
-
instrumentationLoaded = false;
|
|
183
|
-
providerIngressSecurityLogged = false;
|
|
184
|
-
hostTelemetryProvided;
|
|
185
|
-
hostInstrumentationProvided;
|
|
186
|
-
instrumentationConfig;
|
|
187
|
-
sourceLoader;
|
|
188
|
-
sandboxAuthoredToolExecutor;
|
|
189
|
-
skillBundleIndex;
|
|
190
|
-
skillResourceReader;
|
|
191
|
-
contextPolicyPromise;
|
|
192
|
-
/** Fast local view of durable control intents, refreshed by run heartbeats. */
|
|
193
|
-
runControlIntents = new Map();
|
|
194
|
-
/** Runs currently owned by this process, used to route immediate control signals without leaking orphan ids. */
|
|
195
|
-
activeRunExecutions = new Set();
|
|
196
|
-
runProgress;
|
|
197
|
-
runStallTimeoutMs;
|
|
198
|
-
constructor(options) {
|
|
199
|
-
super();
|
|
200
|
-
this.manifest = options.manifest;
|
|
201
|
-
this.authoredToolExecution = resolveAuthoredToolExecutionPolicy(options.authoredToolExecution, options.devMode ?? false);
|
|
202
|
-
const normalizedState = normalizeRuntimeState(options.state ?? new InMemoryStateAdapter());
|
|
203
|
-
// Events fan out to live streams; terminal outcomes become log lines at
|
|
204
|
-
// this one choke point (logger read lazily — assigned below).
|
|
205
|
-
this.state = withRunEventPublishing(normalizedState.state, this.runEventBus, (runId, event) => logTerminalRunEvent(this.logger, runId, event), (runId, event) => this.handleRuntimeEvent(runId, event));
|
|
206
|
-
this.blob = options.blob ?? new LocalBlobAdapter();
|
|
207
|
-
this.sandbox = options.sandbox ?? new LocalSandboxAdapter();
|
|
208
|
-
this.scheduler = options.scheduler ?? schedulerAdapterForKind(this.manifest.gateway.scheduler?.kind);
|
|
209
|
-
this.mediaProcessors = options.mediaProcessors ?? [];
|
|
210
|
-
this.deliveryMode = options.deliveryMode ?? "send";
|
|
211
|
-
this.toolStubs = options.toolStubs ?? {};
|
|
212
|
-
this.devMode = options.devMode ?? false;
|
|
213
|
-
this.sourceBundle = options.sourceBundle ?? {};
|
|
214
|
-
this.connections = options.connections ?? {};
|
|
215
|
-
const resolvedEnvironment = resolveRuntimeConfig(this.manifest.productionConfig, options.env ?? process.env);
|
|
216
|
-
this.config = Object.freeze(resolveNonSecretRuntimeConfig({}, resolvedEnvironment, {}, manifestCredentialNames(this.manifest)));
|
|
217
|
-
this.env = Object.freeze(resolvedEnvironment);
|
|
218
|
-
this.fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
219
|
-
this.attachmentHostResolver = options.attachmentHostResolver;
|
|
220
|
-
this.logger = options.logger ??
|
|
221
|
-
createJsonConsoleLogger({ level: normalizeLogLevel(this.env.ASSEMBLY_LINE_LOG_LEVEL) ?? "info" });
|
|
222
|
-
this.eventHandlers = new AgentEventHandlerRegistry(this.agentName(), (runId, type, data) => this.state.appendEvent(runId, type, data), this.logger);
|
|
223
|
-
if (normalizedState.degradedFacets.length > 0) {
|
|
224
|
-
this.logger.warn("state.degraded", {
|
|
225
|
-
missingFacets: normalizedState.degradedFacets,
|
|
226
|
-
detail: "optional state facets not configured; using non-durable in-memory fallbacks"
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
this.coreToolPolicy = resolveCoreToolPolicy(options.coreToolPolicy, this.env, this.devMode);
|
|
230
|
-
this.models = options.models;
|
|
231
|
-
this.agentHarnessOverride = options.agentHarness;
|
|
232
|
-
this.modelCredentialStore = options.modelCredentialStore ?? new InMemoryModelCredentialStore();
|
|
233
|
-
this.checkpointEveryIteration = resolveBooleanEnv(this.env.ASSEMBLY_LINE_CHECKPOINT_EVERY_ITERATION, true);
|
|
234
|
-
this.checkpointRetention = resolveCheckpointRetentionPolicy(options.checkpointRetention, this.env);
|
|
235
|
-
this.checkpointBlobStorageEnabled = options.blob !== undefined && this.checkpointRetention.blobThresholdBytes > 0;
|
|
236
|
-
this.telemetry = options.telemetry;
|
|
237
|
-
this.hostTelemetryProvided = options.telemetry !== undefined;
|
|
238
|
-
this.hostInstrumentationProvided = options.instrumentation !== undefined;
|
|
239
|
-
const override = options.instrumentation;
|
|
240
|
-
this.instrumentationConfig = {
|
|
241
|
-
recordInputs: override?.recordInputs ?? false,
|
|
242
|
-
recordOutputs: override?.recordOutputs ?? false,
|
|
243
|
-
functionId: override?.functionId ?? override?.serviceName ?? this.agentName(),
|
|
244
|
-
serviceName: override?.serviceName ?? this.agentName(),
|
|
245
|
-
contentCapture: normalizeCapturePolicy(override?.captureContent)
|
|
246
|
-
};
|
|
247
|
-
this.connectionGrantStore = options.connectionGrantStore ?? new InMemoryConnectionGrantStore();
|
|
248
|
-
this.gatewayCredentials = Object.freeze({ ...(options.gatewayCredentials ?? {}) });
|
|
249
|
-
this.credentialBroker = new CredentialBroker({
|
|
250
|
-
store: options.credentialStore ?? environmentCredentialStore(options.env ?? process.env),
|
|
251
|
-
grantStore: this.connectionGrantStore,
|
|
252
|
-
audit: async (record) => {
|
|
253
|
-
if (record.runId) {
|
|
254
|
-
await this.state.appendEvent(record.runId, "connections.credential_used", {
|
|
255
|
-
credential: record.credential,
|
|
256
|
-
connection: record.connection,
|
|
257
|
-
principal: record.principal,
|
|
258
|
-
purpose: record.purpose,
|
|
259
|
-
delivery: record.delivery,
|
|
260
|
-
success: record.success,
|
|
261
|
-
...(record.expiresAt !== undefined ? { expiresAt: record.expiresAt } : {})
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
this.connectionAuthorizationSessionStore = options.connectionAuthorizationSessionStore ?? new InMemoryConnectionAuthorizationSessionStore();
|
|
267
|
-
this.connectionEventStore = options.connectionEventStore ?? new InMemoryConnectionEventStore();
|
|
268
|
-
this.connectionCallbackBaseUrl = options.connectionCallbackBaseUrl;
|
|
269
|
-
this.skillStore = options.skillStore ?? new InMemorySkillStore();
|
|
270
|
-
this.learningStore = options.learningStore ?? new InMemoryLearningStore();
|
|
271
|
-
this.memoryEmbeddingProvider = options.memoryEmbeddingProvider;
|
|
272
|
-
const memoryEmbeddingsRequested = options.memoryEmbeddingsEnabled ??
|
|
273
|
-
resolveBooleanEnv(this.env.ASSEMBLY_LINE_MEMORY_EMBEDDINGS_ENABLED, Boolean(options.memoryEmbeddingProvider));
|
|
274
|
-
const memoryEmbeddingStoreAvailable = this.state.supportsMemoryEmbeddings?.() ?? true;
|
|
275
|
-
this.memoryEmbeddingsEnabled = memoryEmbeddingsRequested && memoryEmbeddingStoreAvailable;
|
|
276
|
-
if (memoryEmbeddingsRequested && !memoryEmbeddingStoreAvailable) {
|
|
277
|
-
this.logger.warn("memory.embeddings_unavailable", {
|
|
278
|
-
detail: "semantic memory is disabled because the configured state store does not have its optional vector backend enabled"
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
this.memoryStore = options.memoryStore ?? new StateMemoryStore(this.state, this.memoryEmbeddingProvider, this.memoryEmbeddingsEnabled);
|
|
282
|
-
this.scheduleStore = options.scheduleStore ?? new InMemoryScheduleStore();
|
|
283
|
-
this.connectionDefinitionStore = options.connectionDefinitionStore ?? new InMemoryConnectionDefinitionStore();
|
|
284
|
-
this.skillsConfig = resolveSkillsConfig(this.manifest.agent.selfImprovement, this.env);
|
|
285
|
-
this.schedulesConfig = resolveSchedulesConfig(this.manifest.agent.dynamicAutomations ?? this.manifest.agent.dynamicSchedules, this.env);
|
|
286
|
-
this.connectionsConfig = resolveConnectionsConfig(this.manifest.agent.dynamicConnections, this.env);
|
|
287
|
-
this.schedulerEnabled = options.schedulerEnabled;
|
|
288
|
-
this.schedulerTickMs = options.schedulerTickMs ?? 60_000;
|
|
289
|
-
this.scheduleMaxConsecutiveFailures = resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_SCHEDULE_MAX_FAILURES, 5);
|
|
290
|
-
this.now = options.now ?? (() => new Date());
|
|
291
|
-
this.workspaceRuntime = new RuntimeWorkspaceManager({
|
|
292
|
-
state: this.state,
|
|
293
|
-
blob: this.blob,
|
|
294
|
-
agentScope: this.durableAgentScope(),
|
|
295
|
-
now: this.now,
|
|
296
|
-
env: this.env,
|
|
297
|
-
...(this.memoryEmbeddingProvider ? { embeddingProvider: this.memoryEmbeddingProvider } : {}),
|
|
298
|
-
sandboxSessionKey: (run) => this.sandboxSessionKey(run)
|
|
299
|
-
});
|
|
300
|
-
this.runtimeLearning = new RuntimeLearningManager({
|
|
301
|
-
state: this.state, manifest: this.manifest,
|
|
302
|
-
env: this.env, logger: this.logger,
|
|
303
|
-
learningStore: this.learningStore,
|
|
304
|
-
skillStore: this.skillStore, memoryStore: this.memoryStore,
|
|
305
|
-
skillsConfigForSurface: (surfacePath) => this.skillsConfigForSurface(surfacePath),
|
|
306
|
-
skillScopeForSurface: (surfacePath) => this.skillScopeForSurface(surfacePath),
|
|
307
|
-
anySkillsEnabled: () => this.anySkillsEnabled(),
|
|
308
|
-
memoryScopeForRun: (run) => this.memoryScopeForRun(run),
|
|
309
|
-
resolveAgentHarness: (modelSpec) => this.resolveAgentHarness(modelSpec),
|
|
310
|
-
now: () => this.now()
|
|
311
|
-
});
|
|
312
|
-
this.sandboxSnapshotPolicy = resolveSandboxSnapshotPolicy(this.manifest, this.env, options.sandboxSnapshotPolicy);
|
|
313
|
-
this.sandboxSyncInline = options.sandboxSyncInline ?? resolveBooleanEnv(this.env.ASSEMBLY_LINE_SANDBOX_SYNC_INLINE, false);
|
|
314
|
-
this.sandboxSyncLeaseMs = options.sandboxSyncLeaseMs ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_SANDBOX_SYNC_LEASE_MS, 5 * 60_000);
|
|
315
|
-
this.sandboxSyncBatchSize = options.sandboxSyncBatchSize ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_SANDBOX_SYNC_BATCH_SIZE, 10);
|
|
316
|
-
this.sandboxSyncMaxAttempts = options.sandboxSyncMaxAttempts ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_SANDBOX_SYNC_MAX_ATTEMPTS, 5);
|
|
317
|
-
this.deliveryQueueLeaseMs = options.deliveryQueueLeaseMs ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_DELIVERY_QUEUE_LEASE_MS, 60_000);
|
|
318
|
-
this.toolOutputMaxChars = resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_TOOL_OUTPUT_MAX_CHARS, DEFAULT_MODEL_OUTPUT_MAX_CHARS);
|
|
319
|
-
this.toolTimeoutMs = resolveNonNegativeIntegerEnv(this.env.ASSEMBLY_LINE_TOOL_TIMEOUT_MS, 600_000);
|
|
320
|
-
this.deliveryQueueBatchSize = options.deliveryQueueBatchSize ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_DELIVERY_QUEUE_BATCH_SIZE, 10);
|
|
321
|
-
this.deliveryQueueMaxAttempts = options.deliveryQueueMaxAttempts ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_DELIVERY_QUEUE_MAX_ATTEMPTS, 5);
|
|
322
|
-
this.deliveryQueueIntervalMs = options.deliveryQueueIntervalMs ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_DELIVERY_QUEUE_INTERVAL_MS, 15_000);
|
|
323
|
-
this.runHeartbeatMs = options.runHeartbeatMs ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_RUN_HEARTBEAT_MS, 30_000);
|
|
324
|
-
this.runStallTimeoutMs = options.runStallTimeoutMs ?? resolveNonNegativeIntegerEnv(this.env.ASSEMBLY_LINE_RUN_STALL_TIMEOUT_MS, 3_600_000);
|
|
325
|
-
this.runProgress = new RunProgressSupervisor({
|
|
326
|
-
state: this.state,
|
|
327
|
-
logger: this.logger,
|
|
328
|
-
runHeartbeatMs: this.runHeartbeatMs,
|
|
329
|
-
runStallTimeoutMs: this.runStallTimeoutMs,
|
|
330
|
-
runControlIntents: this.runControlIntents,
|
|
331
|
-
activeRuns: this.activeRunExecutions,
|
|
332
|
-
debugSwallow: (message, fields) => this.debugSwallow(message, fields)
|
|
333
|
-
});
|
|
334
|
-
this.runRecoveryIntervalMs = options.runRecoveryIntervalMs ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_RUN_RECOVERY_INTERVAL_MS, 60_000);
|
|
335
|
-
this.maxModelIterations = resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_MAX_MODEL_ITERATIONS, DEFAULT_MAX_MODEL_ITERATIONS);
|
|
336
|
-
this.outputValidationMaxRetries = resolveNonNegativeIntegerEnv(this.env.ASSEMBLY_LINE_OUTPUT_VALIDATION_MAX_RETRIES, DEFAULT_OUTPUT_VALIDATION_MAX_RETRIES);
|
|
337
|
-
this.runSemaphore = new BoundedSemaphore({
|
|
338
|
-
maxConcurrent: options.maxConcurrentRuns ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_MAX_CONCURRENT_RUNS, Infinity),
|
|
339
|
-
maxQueued: options.maxQueuedRuns ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_MAX_QUEUED_RUNS, 0)
|
|
340
|
-
});
|
|
341
|
-
this.conversationTurnDispatcher = new ConversationTurnDispatcher({
|
|
342
|
-
state: this.state, logger: this.logger,
|
|
343
|
-
agentScope: this.durableAgentScope(),
|
|
344
|
-
now: () => this.now(), agentEnabled: () => this.agentEnabled(),
|
|
345
|
-
admitRunOrReject: () => this.admitRunOrReject(),
|
|
346
|
-
runTurn: (turn, admission, onRunCreated) => this.run({
|
|
347
|
-
message: turn.message,
|
|
348
|
-
channel: turn.channel, turn, admission, startChannelTurnEarly: true,
|
|
349
|
-
onRunCreated
|
|
350
|
-
})
|
|
351
|
-
});
|
|
352
|
-
this.resourceProjectionPolicy = resolveResourceProjectionPolicy(options.resourceProjectionPolicy, this.env);
|
|
353
|
-
this.sourceLoader = new AgentSourceModuleLoader({
|
|
354
|
-
manifest: this.manifest, sourceBundle: this.sourceBundle,
|
|
355
|
-
...(options.resourcesRoot ? { resourcesRoot: options.resourcesRoot } : {}),
|
|
356
|
-
...(options.artifactRoot ? {
|
|
357
|
-
cacheRoot: join(resolve(options.artifactRoot), ARTIFACT_DIR_NAME, "module-cache"),
|
|
358
|
-
packageRoot: resolve(options.artifactRoot)
|
|
359
|
-
} : {})
|
|
360
|
-
});
|
|
361
|
-
this.sandboxAuthoredToolExecutor = new SandboxAuthoredToolExecutor(this.sourceLoader);
|
|
362
|
-
this.skillBundleIndex = createSkillBundleIndex(this.manifest);
|
|
363
|
-
this.skillResourceReader = createSkillResourceReader({
|
|
364
|
-
manifest: this.manifest,
|
|
365
|
-
...(options.resourcesRoot ? { resourcesRoot: options.resourcesRoot } : {}),
|
|
366
|
-
manifestRoot: this.manifest.root,
|
|
367
|
-
sourceBundle: this.sourceBundle
|
|
368
|
-
});
|
|
369
|
-
this.backgroundSubagents = new BackgroundSubagentCoordinator({
|
|
370
|
-
state: this.state,
|
|
371
|
-
logger: this.logger,
|
|
372
|
-
withRunAdmission: (work) => this.withRunAdmission(work),
|
|
373
|
-
execute: (childRunId) => executeSubagentRunImpl(this.subagentExecutionHost(), childRunId),
|
|
374
|
-
finalize: (timeline) => finalizeSubagentHandoffImpl(this.subagentExecutionHost(), timeline),
|
|
375
|
-
replay: (runId) => this.replay(runId),
|
|
376
|
-
cancel: (runId) => this.cancelRun(runId),
|
|
377
|
-
enqueueConversationTurn: (input) => this.conversationTurnDispatcher.enqueue(input)
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
boot() {
|
|
381
|
-
if (this.manifest.schemaVersion !== ASSEMBLY_LINE_MANIFEST_SCHEMA_VERSION) {
|
|
382
|
-
throw new Error(`Unsupported Assembly Line manifest schema ${this.manifest.schemaVersion}.`);
|
|
383
|
-
}
|
|
384
|
-
this.sourceLoader.ensureCacheReady();
|
|
385
|
-
if (!this.devMode) {
|
|
386
|
-
const credentials = new Set(manifestCredentialNames(this.manifest));
|
|
387
|
-
const missing = this.manifest.preflight.filter((requirement) => requirement.kind === "env" &&
|
|
388
|
-
requirement.required &&
|
|
389
|
-
requirement.adapter !== this.manifest.gateway.deploy?.kind &&
|
|
390
|
-
!credentials.has(requirement.name) &&
|
|
391
|
-
![requirement.name, ...(requirement.alternatives ?? [])]
|
|
392
|
-
.some((name) => Boolean(this.env[name]?.trim())));
|
|
393
|
-
if (missing.length > 0) {
|
|
394
|
-
throw new Error(`Missing required runtime bindings: ${missing
|
|
395
|
-
.map((requirement) => [requirement.name, ...(requirement.alternatives ?? [])].join(" or "))
|
|
396
|
-
.join(", ")}`);
|
|
397
|
-
}
|
|
398
|
-
this.validateProviderIngressSecurity();
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
this.logDevProviderIngressSecurity();
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
validateProviderIngressSecurity() {
|
|
405
|
-
const error = providerIngressSecurityError(this.manifest.channels, { ...this.env, ...this.gatewayCredentials });
|
|
406
|
-
if (error)
|
|
407
|
-
throw new Error(error);
|
|
408
|
-
}
|
|
409
|
-
debugSwallow(message, fields) {
|
|
410
|
-
return (error) => {
|
|
411
|
-
this.logger.debug(message, { ...fields, error: error instanceof Error ? error.message : String(error) });
|
|
412
|
-
return undefined;
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
warnSwallow(message, fields) {
|
|
416
|
-
return (error) => {
|
|
417
|
-
this.logger.warn(message, { ...fields, error: error instanceof Error ? error.message : String(error) });
|
|
418
|
-
return undefined;
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
async compactCheckpoints(options = {}) {
|
|
422
|
-
if (!this.state.compactCheckpoints)
|
|
423
|
-
return emptyCheckpointRetentionResult(options.dryRun === true);
|
|
424
|
-
return this.state.compactCheckpoints({
|
|
425
|
-
maxActivePerRunName: this.checkpointRetention.maxActivePerRunName,
|
|
426
|
-
activeNames: COMPACTABLE_ACTIVE_CHECKPOINT_NAMES,
|
|
427
|
-
terminalTtlMs: this.checkpointRetention.terminalTtlMs,
|
|
428
|
-
failedRunTtlMs: this.checkpointRetention.failedRunTtlMs,
|
|
429
|
-
scheduledRunTtlMs: this.checkpointRetention.scheduledRunTtlMs,
|
|
430
|
-
now: this.now(),
|
|
431
|
-
...options
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
async createCheckpoint(input) {
|
|
435
|
-
const storedData = await this.checkpointDataForStorage(input.runId, input.name, input.data);
|
|
436
|
-
const checkpoint = await this.state.createCheckpoint({ ...input, data: storedData });
|
|
437
|
-
await this.runProgress.renew(input.runId);
|
|
438
|
-
if (COMPACTABLE_ACTIVE_CHECKPOINT_NAMES.includes(input.name)) {
|
|
439
|
-
await this.compactCheckpoints({
|
|
440
|
-
runId: input.runId,
|
|
441
|
-
activeNames: COMPACTABLE_ACTIVE_CHECKPOINT_NAMES,
|
|
442
|
-
terminalTtlMs: undefined,
|
|
443
|
-
failedRunTtlMs: undefined,
|
|
444
|
-
scheduledRunTtlMs: undefined
|
|
445
|
-
}).catch(this.warnSwallow("checkpoint active compaction failed", { runId: input.runId, checkpointName: input.name }));
|
|
446
|
-
}
|
|
447
|
-
return { ...checkpoint, data: input.data };
|
|
448
|
-
}
|
|
449
|
-
async listHydratedCheckpoints(runId) {
|
|
450
|
-
const checkpoints = await this.state.listCheckpoints(runId);
|
|
451
|
-
return Promise.all(checkpoints.map(async (checkpoint) => ({
|
|
452
|
-
...checkpoint,
|
|
453
|
-
data: await this.hydrateCheckpointData(checkpoint.data)
|
|
454
|
-
})));
|
|
455
|
-
}
|
|
456
|
-
async checkpointDataForStorage(runId, name, data) {
|
|
457
|
-
return checkpointDataForBlobStorage({ blob: this.blob, enabled: this.checkpointBlobStorageEnabled, thresholdBytes: this.checkpointRetention.blobThresholdBytes, runId, name, data });
|
|
458
|
-
}
|
|
459
|
-
async hydrateCheckpointData(data) { return hydrateCheckpointDataFromBlob(data, this.blob); }
|
|
460
|
-
logDevProviderIngressSecurity() {
|
|
461
|
-
if (this.providerIngressSecurityLogged)
|
|
462
|
-
return;
|
|
463
|
-
const warnings = providerIngressSecurityWarnings(this.manifest.channels, { ...this.env, ...this.gatewayCredentials });
|
|
464
|
-
if (warnings.length === 0)
|
|
465
|
-
return;
|
|
466
|
-
this.providerIngressSecurityLogged = true;
|
|
467
|
-
for (const warning of warnings) {
|
|
468
|
-
this.logger.warn("provider ingress security warning", { warning });
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
skillScope() { return this.skillScopeForSurface("root"); }
|
|
472
|
-
skillScopeForSurface(surfacePath) {
|
|
473
|
-
surfaceForPath(this.manifest, surfacePath);
|
|
474
|
-
return durableAgentSurfaceScope(this.durableAgentScope(), surfacePath);
|
|
475
|
-
}
|
|
476
|
-
skillScopeForRun(run) {
|
|
477
|
-
return this.skillScopeForSurface(surfaceForRun(this.manifest, run).path);
|
|
478
|
-
}
|
|
479
|
-
skillsConfigForSurface(surfacePath) {
|
|
480
|
-
if (surfacePath === "root")
|
|
481
|
-
return this.skillsConfig;
|
|
482
|
-
const surface = surfaceForPath(this.manifest, surfacePath);
|
|
483
|
-
return resolveSkillsConfig({
|
|
484
|
-
...(this.manifest.agent.selfImprovement ?? {}),
|
|
485
|
-
...(surface.selfImprovement ?? {})
|
|
486
|
-
}, this.env);
|
|
487
|
-
}
|
|
488
|
-
skillsConfigForRun(run) {
|
|
489
|
-
return this.skillsConfigForSurface(surfaceForRun(this.manifest, run).path);
|
|
490
|
-
}
|
|
491
|
-
anySkillsEnabled() {
|
|
492
|
-
return ["root", ...flattenSubagents(this.manifest.subagents).map((subagent) => subagent.path)]
|
|
493
|
-
.some((surfacePath) => this.skillsConfigForSurface(surfacePath).enabled);
|
|
494
|
-
}
|
|
495
|
-
connectionScope() { return this.durableAgentScope(); }
|
|
496
|
-
durableAgentScope() { return durableAgentScopeForManifest(this.manifest); }
|
|
497
|
-
usesRevisionScopedDurableState() { return this.durableAgentScope() === this.manifest.agentRevision; }
|
|
498
|
-
scheduleScopeForRun(run) {
|
|
499
|
-
const audience = audienceFromRun(run);
|
|
500
|
-
return audienceUserKey(audience)
|
|
501
|
-
?? (!audience.private ? audience.conversationId : undefined)
|
|
502
|
-
?? this.durableAgentScope();
|
|
503
|
-
}
|
|
504
|
-
/** Seed the durable skill store from compiled manifest skills (idempotent). */
|
|
505
|
-
async ensureSkillsSeeded(surfacePath = "root") { return this.runtimeLearning.ensureSkillsSeeded(surfacePath); }
|
|
506
|
-
async migrateLegacyConnectionScope() {
|
|
507
|
-
if (this.connectionScopeMigrated)
|
|
508
|
-
return;
|
|
509
|
-
this.connectionScopeMigrated = true;
|
|
510
|
-
const scope = this.connectionScope();
|
|
511
|
-
const legacyScope = this.manifest.agentRevision;
|
|
512
|
-
if (scope === legacyScope)
|
|
513
|
-
return;
|
|
514
|
-
const current = await this.connectionDefinitionStore.list(scope);
|
|
515
|
-
if (current.length > 0)
|
|
516
|
-
return;
|
|
517
|
-
for (const definition of await this.connectionDefinitionStore.list(legacyScope)) {
|
|
518
|
-
await this.connectionDefinitionStore.put(scope, { ...definition, scope });
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
/** Live skill catalog (durable store, post-seed) for context assembly and inspection. */
|
|
522
|
-
async listSkills(surfacePath = "root") { return this.runtimeLearning.listSkills(surfacePath); }
|
|
523
|
-
/** Persist an agent/user authored skill, honoring the write-approval gate. */
|
|
524
|
-
async saveSkill(input, surfacePath = "root") { return this.runtimeLearning.saveSkill(input, surfacePath); }
|
|
525
|
-
async deleteSkill(name, surfacePath = "root") { return this.runtimeLearning.deleteSkill(name, surfacePath); }
|
|
526
|
-
async listSkillRevisions(name, surfacePath = "root") { return this.runtimeLearning.listSkillRevisions(name, surfacePath); }
|
|
527
|
-
async restoreSkillRevision(name, revision, surfacePath = "root") { return this.runtimeLearning.restoreSkillRevision(name, revision, surfacePath); }
|
|
528
|
-
async listPendingSkillChanges(surfacePath = "root") { return this.runtimeLearning.listPendingSkillChanges(surfacePath); }
|
|
529
|
-
async approveSkillChange(id, surfacePath = "root") { return this.runtimeLearning.approveSkillChange(id, surfacePath); }
|
|
530
|
-
async rejectSkillChange(id, surfacePath = "root") { return this.runtimeLearning.rejectSkillChange(id, surfacePath); }
|
|
531
|
-
async recordRunFeedback(runId, feedback) {
|
|
532
|
-
return this.runtimeLearning.recordRunFeedback(runId, feedback);
|
|
533
|
-
}
|
|
534
|
-
async listBackgroundReviews(surfacePath = "root") { return this.runtimeLearning.listBackgroundReviews(surfacePath); }
|
|
535
|
-
async runDueBackgroundReviews(options = {}) {
|
|
536
|
-
return this.runtimeLearning.runDueBackgroundReviews(options);
|
|
537
|
-
}
|
|
538
|
-
startBackgroundReviewWorker(options = {}) {
|
|
539
|
-
return this.runtimeLearning.startBackgroundReviewWorker(options);
|
|
540
|
-
}
|
|
541
|
-
/** Persist a runtime-provided connection definition (gated). Credentials route to the grant store. */
|
|
542
|
-
async saveConnectionDefinition(input) {
|
|
543
|
-
if (!this.connectionsConfig.dynamic) {
|
|
544
|
-
throw new Error("Dynamic connections are disabled (dynamicConnections.dynamic is false).");
|
|
545
|
-
}
|
|
546
|
-
if (input.protocol === "mcp" && (input.definition.transport === "stdio"
|
|
547
|
-
|| "command" in input.definition
|
|
548
|
-
|| "args" in input.definition
|
|
549
|
-
|| "cwd" in input.definition
|
|
550
|
-
|| "env" in input.definition)) {
|
|
551
|
-
throw new Error("Dynamic MCP connections are URL-only and cannot launch host processes.");
|
|
552
|
-
}
|
|
553
|
-
const url = typeof input.definition.url === "string" ? input.definition.url : undefined;
|
|
554
|
-
if (input.protocol === "mcp" && !url) {
|
|
555
|
-
throw new Error("Dynamic MCP connections must provide an HTTP url.");
|
|
556
|
-
}
|
|
557
|
-
if (url && !isHostAllowed(url, this.connectionsConfig.allowedHosts)) {
|
|
558
|
-
throw new Error(`Connection host is not allowlisted: ${url}`);
|
|
559
|
-
}
|
|
560
|
-
await this.migrateLegacyConnectionScope();
|
|
561
|
-
const scope = input.scope ?? this.connectionScope();
|
|
562
|
-
const now = timestamp();
|
|
563
|
-
await this.connectionDefinitionStore.put(scope, {
|
|
564
|
-
name: input.name,
|
|
565
|
-
scope,
|
|
566
|
-
protocol: input.protocol,
|
|
567
|
-
description: input.description,
|
|
568
|
-
definition: input.definition,
|
|
569
|
-
origin: "agent",
|
|
570
|
-
createdAt: now,
|
|
571
|
-
updatedAt: now
|
|
572
|
-
});
|
|
573
|
-
if (input.grant) {
|
|
574
|
-
const principal = input.grant.principal ?? { type: "app" };
|
|
575
|
-
await this.connectionGrantStore.saveGrant({
|
|
576
|
-
connectionName: input.name,
|
|
577
|
-
principalKey: input.grant.principalKey ?? connectionPrincipalKeyForGrant(principal),
|
|
578
|
-
principal,
|
|
579
|
-
token: input.grant.token,
|
|
580
|
-
createdAt: now,
|
|
581
|
-
updatedAt: now
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
this.dynamicConnectionsCache = undefined;
|
|
585
|
-
return { name: input.name };
|
|
586
|
-
}
|
|
587
|
-
async listConnectionDefinitions(scope) {
|
|
588
|
-
await this.migrateLegacyConnectionScope();
|
|
589
|
-
const stored = await this.connectionDefinitionStore.list(scope ?? this.connectionScope());
|
|
590
|
-
return stored.map((definition) => ({
|
|
591
|
-
name: definition.name,
|
|
592
|
-
protocol: definition.protocol,
|
|
593
|
-
description: definition.description,
|
|
594
|
-
origin: definition.origin
|
|
595
|
-
}));
|
|
596
|
-
}
|
|
597
|
-
async deleteConnectionDefinition(name, scope) {
|
|
598
|
-
await this.migrateLegacyConnectionScope();
|
|
599
|
-
await this.connectionDefinitionStore.delete(scope ?? this.connectionScope(), name);
|
|
600
|
-
this.dynamicConnectionsCache = undefined;
|
|
601
|
-
}
|
|
602
|
-
async syncMemoryFromSandbox(run, sandboxSession, tombstones) {
|
|
603
|
-
return syncMemoryFromSandbox(this.sandboxStateSyncHost(), run, sandboxSession, tombstones);
|
|
604
|
-
}
|
|
605
|
-
/** Reconcile skill files the agent explicitly edited/deleted under `/skills`. */
|
|
606
|
-
async syncSkillsFromSandbox(run, sandboxSession, tombstones) {
|
|
607
|
-
return syncSkillsFromSandbox(this.sandboxStateSyncHost(), run, sandboxSession, tombstones);
|
|
608
|
-
}
|
|
609
|
-
sandboxStateSyncHost() {
|
|
610
|
-
return {
|
|
611
|
-
state: this.state,
|
|
612
|
-
memoryStore: this.memoryStore,
|
|
613
|
-
skillStore: this.skillStore,
|
|
614
|
-
skillBundleIndex: this.skillBundleIndex,
|
|
615
|
-
learningStore: this.learningStore,
|
|
616
|
-
skillsConfigForRun: (run) => this.skillsConfigForRun(run),
|
|
617
|
-
memoryScopeForRun: (candidate) => this.memoryScopeForRun(candidate),
|
|
618
|
-
skillScopeForRun: (run) => this.skillScopeForRun(run)
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
createSandboxHandle(getRun, setRun, getBundle) {
|
|
622
|
-
return createSandboxHandleImpl({
|
|
623
|
-
state: this.state,
|
|
624
|
-
blob: this.blob,
|
|
625
|
-
acquireSandboxForRun: (run) => this.acquireSandboxForRun(run),
|
|
626
|
-
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
627
|
-
legacyFullSandboxHydration: () => this.legacyFullSandboxHydration(),
|
|
628
|
-
hydrateWorkspace: (run, session) => this.workspaceRuntime.service.hydrate(run, session, this.sandboxSessionKey(run)),
|
|
629
|
-
projectLoadedSkills: (run, session) => this.projectLoadedSkillsIntoSandbox(run, session),
|
|
630
|
-
createConnectionRegistryForRun: (run, channel, selectedConnections) => this.createConnectionRegistryForRun(run, channel, undefined, selectedConnections),
|
|
631
|
-
wrapSandbox: (runId, session) => this.wrapSandbox(runId, session),
|
|
632
|
-
disposeSandboxSession: (runId, session) => this.disposeSandboxSession(runId, session)
|
|
633
|
-
}, getRun, setRun, getBundle);
|
|
634
|
-
}
|
|
635
|
-
sandboxSessionKey(run) {
|
|
636
|
-
return sandboxSessionKeyForRun(this.durableAgentScope(), run);
|
|
637
|
-
}
|
|
638
|
-
async acquireSandboxForRun(run) {
|
|
639
|
-
return acquireSandboxSessionForRun({
|
|
640
|
-
manifest: this.manifest,
|
|
641
|
-
env: this.env,
|
|
642
|
-
state: this.state,
|
|
643
|
-
sandbox: this.sandbox,
|
|
644
|
-
sessionKey: (candidate) => this.sandboxSessionKey(candidate),
|
|
645
|
-
swallow: (message, fields) => this.debugSwallow(message, fields)
|
|
646
|
-
}, run);
|
|
647
|
-
}
|
|
648
|
-
legacyFullSandboxHydration() {
|
|
649
|
-
return this.env.ASSEMBLY_LINE_LEGACY_FULL_SANDBOX_HYDRATION === "1" ||
|
|
650
|
-
this.env.ASSEMBLY_LINE_LEGACY_FULL_SANDBOX_HYDRATION === "true";
|
|
651
|
-
}
|
|
652
|
-
async ensureDynamicConnections() {
|
|
653
|
-
if (!this.connectionsConfig.dynamic) {
|
|
654
|
-
this.dynamicConnectionsCache = { compiled: [], defs: new Map() };
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
if (this.dynamicConnectionsCache)
|
|
658
|
-
return;
|
|
659
|
-
await this.migrateLegacyConnectionScope();
|
|
660
|
-
const stored = await this.connectionDefinitionStore.list(this.connectionScope());
|
|
661
|
-
const compiled = [];
|
|
662
|
-
const defs = new Map();
|
|
663
|
-
for (const definition of stored) {
|
|
664
|
-
compiled.push(compiledConnectionFromStored(definition));
|
|
665
|
-
defs.set(definition.name, definition.definition);
|
|
666
|
-
}
|
|
667
|
-
this.dynamicConnectionsCache = { compiled, defs };
|
|
668
|
-
}
|
|
669
|
-
mergedConnections() {
|
|
670
|
-
const dynamic = this.dynamicConnectionsCache?.compiled ?? [];
|
|
671
|
-
if (dynamic.length === 0)
|
|
672
|
-
return this.manifest.connections;
|
|
673
|
-
const byName = new Map(this.manifest.connections.map((connection) => [connection.name, connection]));
|
|
674
|
-
for (const connection of dynamic)
|
|
675
|
-
byName.set(connection.name, connection);
|
|
676
|
-
return [...byName.values()];
|
|
677
|
-
}
|
|
678
|
-
/** True when a brand-new run would be admitted (or queued) instead of rejected. */
|
|
679
|
-
hasRunCapacity() {
|
|
680
|
-
return this.runSemaphore.hasCapacity();
|
|
681
|
-
}
|
|
682
|
-
/** Resolves once no runs (new or resumed) are executing or queued. Used by graceful shutdown. */
|
|
683
|
-
onIdle() {
|
|
684
|
-
return this.runSemaphore.onIdle();
|
|
685
|
-
}
|
|
686
|
-
/** Claim a new-run slot, returning the capacity error instead of throwing. */
|
|
687
|
-
admitRunOrReject() {
|
|
688
|
-
try {
|
|
689
|
-
return this.runSemaphore.admit();
|
|
690
|
-
}
|
|
691
|
-
catch (error) {
|
|
692
|
-
if (error instanceof RunCapacityError)
|
|
693
|
-
return error;
|
|
694
|
-
throw error;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
/** Count a resume/continuation entry point toward `onIdle()` without consuming run capacity. */
|
|
698
|
-
async withRunAdmission(work) {
|
|
699
|
-
const admission = this.runSemaphore.enter();
|
|
700
|
-
try {
|
|
701
|
-
return await work();
|
|
702
|
-
}
|
|
703
|
-
finally {
|
|
704
|
-
admission.release();
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Admission choke point: brand-new runs claim a `maxConcurrentRuns` slot
|
|
709
|
-
* (throwing `RunCapacityError` when saturated); resumes and scheduler
|
|
710
|
-
* continuations (`existingRun`) bypass the limit — queueing a resume behind
|
|
711
|
-
* the run it unblocks would deadlock — but still count toward `onIdle()`.
|
|
712
|
-
*/
|
|
713
|
-
async run(options) {
|
|
714
|
-
const admission = options.admission ??
|
|
715
|
-
(options.existingRun ? this.runSemaphore.enter() : this.runSemaphore.admit());
|
|
716
|
-
let earlyChannelTurn;
|
|
717
|
-
try {
|
|
718
|
-
await admission.ready;
|
|
719
|
-
if (options.startChannelTurnEarly) {
|
|
720
|
-
const channel = options.turn?.channel ?? options.channel ?? "local";
|
|
721
|
-
earlyChannelTurn = this.beginChannelTurn(channel, options.turn);
|
|
722
|
-
}
|
|
723
|
-
return await this.executeRun(options, earlyChannelTurn);
|
|
724
|
-
}
|
|
725
|
-
catch (error) {
|
|
726
|
-
if (earlyChannelTurn) {
|
|
727
|
-
const channel = options.turn?.channel ?? options.channel ?? "local";
|
|
728
|
-
await this.stopUnclaimedChannelTurn(await earlyChannelTurn, channel);
|
|
729
|
-
}
|
|
730
|
-
throw error;
|
|
731
|
-
}
|
|
732
|
-
finally {
|
|
733
|
-
admission.release();
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
async executeRun(options, earlyChannelTurn) {
|
|
737
|
-
this.boot();
|
|
738
|
-
await this.initializeInstrumentation();
|
|
739
|
-
await this.ensureSkillsSeeded();
|
|
740
|
-
await this.ensureDynamicConnections();
|
|
741
|
-
const spanStartedAt = timestamp();
|
|
742
|
-
const channel = (options.existingRun && typeof options.existingRun.input.channel === "string"
|
|
743
|
-
? options.existingRun.input.channel
|
|
744
|
-
: undefined) ?? options.turn?.channel ?? options.channel ?? "local";
|
|
745
|
-
const channelDefinition = this.manifest.channels.find((candidate) => candidate.name === channel);
|
|
746
|
-
const suppliedConversationId = (options.existingRun && typeof options.existingRun.input.conversationId === "string"
|
|
747
|
-
? options.existingRun.input.conversationId
|
|
748
|
-
: undefined) ?? options.turn?.conversationId ?? options.conversationId;
|
|
749
|
-
const legacyUserId = options.turn?.userId ?? options.userId;
|
|
750
|
-
const principal = (options.existingRun ? principalFromRun(options.existingRun) : undefined)
|
|
751
|
-
?? normalizeAgentPrincipal(options.turn?.principal ?? options.principal)
|
|
752
|
-
?? defaultUserPrincipal(legacyUserId, channel);
|
|
753
|
-
const initiator = (options.existingRun ? initiatorFromRun(options.existingRun) : undefined)
|
|
754
|
-
?? normalizeAgentPrincipal(options.turn?.initiator ?? options.initiator)
|
|
755
|
-
?? principal;
|
|
756
|
-
// Channel turns derive their audience from the authenticated turn, so it
|
|
757
|
-
// cannot disagree with the principal or conversation; other callers are
|
|
758
|
-
// trusted embedders and default to a private direct run.
|
|
759
|
-
const audience = (options.existingRun ? normalizeAgentAudience(options.existingRun.input.audience) : undefined)
|
|
760
|
-
?? normalizeAgentAudience(options.turn?.audience ?? options.audience)
|
|
761
|
-
?? { private: true };
|
|
762
|
-
const replyTarget = options.existingRun && isJsonObject(options.existingRun.input.replyTarget)
|
|
763
|
-
? options.existingRun.input.replyTarget
|
|
764
|
-
: safeJson({
|
|
765
|
-
channel,
|
|
766
|
-
conversationId: suppliedConversationId ?? null,
|
|
767
|
-
delivery: options.turn?.delivery ?? options.delivery ?? null
|
|
768
|
-
});
|
|
769
|
-
const runInput = {
|
|
770
|
-
message: options.message,
|
|
771
|
-
agentSurface: "root",
|
|
772
|
-
channel,
|
|
773
|
-
eventId: options.turn?.eventId ?? options.eventId ?? null,
|
|
774
|
-
conversationId: suppliedConversationId ?? options.existingRun?.input.conversationId ?? null,
|
|
775
|
-
autoConversation: suppliedConversationId
|
|
776
|
-
? false
|
|
777
|
-
: options.existingRun
|
|
778
|
-
? options.existingRun.input.autoConversation === true
|
|
779
|
-
: true,
|
|
780
|
-
userId: principalUserId(principal) ?? legacyUserId ?? null,
|
|
781
|
-
principal: principal ? safeJson(principal) : null,
|
|
782
|
-
initiator: initiator ? safeJson(initiator) : null,
|
|
783
|
-
audience: safeJson(audience),
|
|
784
|
-
projectId: options.projectId ?? options.existingRun?.input.projectId ?? null,
|
|
785
|
-
workspaceId: options.workspaceId ?? options.existingRun?.input.workspaceId ?? null,
|
|
786
|
-
tenantId: options.tenantId ?? options.existingRun?.input.tenantId ?? null,
|
|
787
|
-
delivery: isJsonObject(replyTarget.delivery) ? replyTarget.delivery : null,
|
|
788
|
-
replyTarget,
|
|
789
|
-
metadata: options.metadata ?? options.turn?.metadata ?? {},
|
|
790
|
-
sandboxCredentials: options.sandboxCredentials ?? (options.existingRun && isJsonObject(options.existingRun.input.sandboxCredentials) ? options.existingRun.input.sandboxCredentials : {}),
|
|
791
|
-
...(options.replay !== undefined ? { replay: safeJson(options.replay) } : {}),
|
|
792
|
-
...(options.eval !== undefined ? { eval: validateEvalRunOptions(options.eval) } : {})
|
|
793
|
-
};
|
|
794
|
-
await rememberDefaultOutboundRoute({ manifest: this.manifest, state: this.state, agentScope: this.durableAgentScope(), now: this.now() }, options, runInput);
|
|
795
|
-
let run = options.existingRun
|
|
796
|
-
? await this.state.updateRun(options.existingRun.id, {
|
|
797
|
-
input: {
|
|
798
|
-
...options.existingRun.input,
|
|
799
|
-
...runInput
|
|
800
|
-
}
|
|
801
|
-
})
|
|
802
|
-
: await this.state.createRun({
|
|
803
|
-
agentRevision: this.manifest.agentRevision,
|
|
804
|
-
status: "created",
|
|
805
|
-
input: runInput
|
|
806
|
-
});
|
|
807
|
-
try {
|
|
808
|
-
await options.onRunCreated?.(run);
|
|
809
|
-
}
|
|
810
|
-
catch (error) {
|
|
811
|
-
this.logger.warn("onRunCreated hook failed", { runId: run.id, error: error instanceof Error ? error.message : String(error) });
|
|
812
|
-
}
|
|
813
|
-
await this.state.appendEvent(run.id, "run.accepted", { agentRevision: this.manifest.agentRevision });
|
|
814
|
-
try {
|
|
815
|
-
await acceptBackgroundSubagentHandoff(this.state, run);
|
|
816
|
-
}
|
|
817
|
-
catch (error) {
|
|
818
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
819
|
-
run = await failRunImpl({ state: this.state }, run.id, {
|
|
820
|
-
reason: "subagent.handoff_failed",
|
|
821
|
-
error: message
|
|
822
|
-
});
|
|
823
|
-
return this.result(run, `Artifact handoff failed: ${message}`, false, false, false);
|
|
824
|
-
}
|
|
825
|
-
if (options.replay)
|
|
826
|
-
await recordRunReplayStarted(this.state, run.id, options.replay);
|
|
827
|
-
if (this.usesRevisionScopedDurableState() && (this.skillsConfig.enabled || this.connectionsConfig.dynamic)) {
|
|
828
|
-
await this.state.appendEvent(run.id, "agent.scope_fallback", {
|
|
829
|
-
reason: "missing_agent_id",
|
|
830
|
-
scope: this.manifest.agentRevision,
|
|
831
|
-
message: "Durable learned state is scoped to agentRevision because agent.id is not configured."
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
const preExecution = await this.state.getRun(run.id);
|
|
835
|
-
if (preExecution?.status === "cancelled") {
|
|
836
|
-
return this.result(preExecution, "Run was cancelled before execution started.");
|
|
837
|
-
}
|
|
838
|
-
run = await this.state.updateRun(run.id, { status: "running" });
|
|
839
|
-
const heartbeat = this.startRunHeartbeat(run.id);
|
|
840
|
-
const channelTurnStart = earlyChannelTurn
|
|
841
|
-
? await earlyChannelTurn
|
|
842
|
-
: await this.beginChannelTurn(channel, options.turn);
|
|
843
|
-
await this.recordChannelTurnStart(channelTurnStart, run, channel);
|
|
844
|
-
channelTurnStart.claimed = true;
|
|
845
|
-
const channelLifecycle = channelTurnStart.lifecycle;
|
|
846
|
-
let channelLifecycleStopped = false;
|
|
847
|
-
const trustedProvider = options.trustedAttachmentProvider ?? trustedAttachmentProviderForTurn(channelDefinition, options.turn);
|
|
848
|
-
const stopChannelLifecycle = async () => {
|
|
849
|
-
if (channelLifecycleStopped)
|
|
850
|
-
return;
|
|
851
|
-
channelLifecycleStopped = true;
|
|
852
|
-
await this.stopChannelTurn(channelLifecycle, run, channel);
|
|
853
|
-
};
|
|
854
|
-
try {
|
|
855
|
-
const channelModule = channelDefinition
|
|
856
|
-
? await this.loadChannelModule(channelDefinition)
|
|
857
|
-
: undefined;
|
|
858
|
-
const humanInputMode = humanInputModeForChannel(channelModule);
|
|
859
|
-
run = await this.state.updateRun(run.id, {
|
|
860
|
-
input: withHumanInputMode(run.input, humanInputMode)
|
|
861
|
-
});
|
|
862
|
-
await this.state.appendEvent(run.id, "human_input.route_selected", {
|
|
863
|
-
channel,
|
|
864
|
-
mode: humanInputMode
|
|
865
|
-
});
|
|
866
|
-
const turnAttachments = options.attachments ?? options.turn?.attachments ?? [];
|
|
867
|
-
let attachments = [];
|
|
868
|
-
if (turnAttachments.length > 0) {
|
|
869
|
-
if (typeof run.input.conversationId !== "string" || !run.input.conversationId) {
|
|
870
|
-
run = await this.state.updateRun(run.id, {
|
|
871
|
-
input: { ...run.input, conversationId: run.id }
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
const fileWorkspace = await this.workspaceRuntime.service.resolveForRun(run);
|
|
875
|
-
const resolveAttachment = await this.channelAttachmentResolver(channelDefinition, trustedProvider);
|
|
876
|
-
attachments = await materializeTurnAttachments({
|
|
877
|
-
run,
|
|
878
|
-
workspaceId: fileWorkspace.id,
|
|
879
|
-
channel,
|
|
880
|
-
attachments: turnAttachments,
|
|
881
|
-
...(trustedProvider ? { trustedProvider } : {}),
|
|
882
|
-
...(resolveAttachment ? { resolveAttachment } : {}),
|
|
883
|
-
allowRemoteDownload: options.allowRemoteAttachments === true,
|
|
884
|
-
env: this.env,
|
|
885
|
-
fetch: this.fetch,
|
|
886
|
-
...(this.attachmentHostResolver ? { hostResolver: this.attachmentHostResolver } : {}),
|
|
887
|
-
blob: this.blob,
|
|
888
|
-
state: this.state
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
const hydratedOptions = { ...options, attachments };
|
|
892
|
-
if (options.turn)
|
|
893
|
-
hydratedOptions.turn = { ...options.turn, attachments };
|
|
894
|
-
const conversation = await this.prepareConversation(run, hydratedOptions, channel);
|
|
895
|
-
if (!conversation)
|
|
896
|
-
throw new Error("Every run must resolve a conversation before agent hook evaluation.");
|
|
897
|
-
hydratedOptions.conversationId = conversation.id;
|
|
898
|
-
const persistedInitiator = conversationInitiator(conversation.metadata) ?? initiatorFromRun(run);
|
|
899
|
-
if (persistedInitiator) {
|
|
900
|
-
hydratedOptions.initiator = persistedInitiator;
|
|
901
|
-
if (hydratedOptions.turn)
|
|
902
|
-
hydratedOptions.turn = { ...hydratedOptions.turn, initiator: persistedInitiator };
|
|
903
|
-
}
|
|
904
|
-
if (run.input.conversationId !== conversation.id || persistedInitiator) {
|
|
905
|
-
run = await this.state.updateRun(run.id, {
|
|
906
|
-
input: {
|
|
907
|
-
...run.input,
|
|
908
|
-
conversationId: conversation.id,
|
|
909
|
-
...(persistedInitiator ? { initiator: safeJson(persistedInitiator) } : {})
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
const hookController = await this.createAgentHookController(run, hydratedOptions, channel, conversation.id, attachments);
|
|
914
|
-
const capabilitySnapshot = await hookController.evaluate(options.existingRun ? "recovery" : "run_start");
|
|
915
|
-
const capabilities = capabilitySnapshot.declaration;
|
|
916
|
-
run = await this.state.updateRun(run.id, {
|
|
917
|
-
input: {
|
|
918
|
-
...run.input,
|
|
919
|
-
model: capabilities.model,
|
|
920
|
-
agentSandbox: capabilities.sandbox ?? null,
|
|
921
|
-
agentConnections: capabilities.connections,
|
|
922
|
-
agentSubagents: capabilities.subagents,
|
|
923
|
-
attachmentMetadata: attachments
|
|
924
|
-
}
|
|
925
|
-
});
|
|
926
|
-
const media = await processRuntimeTurnMedia(this, run, attachments, hydratedOptions, channel, principalUserId(principal) ?? legacyUserId, conversation.id);
|
|
927
|
-
const augmentation = hydratedOptions.turn
|
|
928
|
-
? await this.augmentChannelContext(channel, hydratedOptions.turn, run)
|
|
929
|
-
: undefined;
|
|
930
|
-
const recentHistory = hydratedOptions.recentHistory ??
|
|
931
|
-
hydratedOptions.turn?.recentHistory ??
|
|
932
|
-
augmentation?.recentHistory ??
|
|
933
|
-
(conversation ? await this.recentHistory(conversation.id, run.id) : []);
|
|
934
|
-
const contextInput = {
|
|
935
|
-
message: hydratedOptions.message,
|
|
936
|
-
channel,
|
|
937
|
-
recentHistory,
|
|
938
|
-
attachments,
|
|
939
|
-
capabilities,
|
|
940
|
-
run
|
|
941
|
-
};
|
|
942
|
-
const channelContext = mergeJsonObjects(media.channelContext, augmentation?.channelContext);
|
|
943
|
-
if (channelContext)
|
|
944
|
-
contextInput.channelContext = channelContext;
|
|
945
|
-
const activeWork = await this.backgroundSubagents.listForRoot(run);
|
|
946
|
-
if (hydratedOptions.promptContext || activeWork.length > 0) {
|
|
947
|
-
contextInput.promptContext = {
|
|
948
|
-
...(hydratedOptions.promptContext ?? {}),
|
|
949
|
-
...(activeWork.length > 0
|
|
950
|
-
? {
|
|
951
|
-
activeWork: {
|
|
952
|
-
items: activeWork,
|
|
953
|
-
guidance: "These background tasks are still active. You may answer new messages while they run. Do not claim they are complete. Use manage_work to inspect or cancel them."
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
: {})
|
|
957
|
-
};
|
|
958
|
-
}
|
|
959
|
-
if (hydratedOptions.target)
|
|
960
|
-
contextInput.target = hydratedOptions.target;
|
|
961
|
-
let bundle = options.contextSnapshot ? structuredClone(options.contextSnapshot) : await this.buildContextBundle(contextInput);
|
|
962
|
-
const contextBlob = await this.blob.put(`context/${run.id}.json`, JSON.stringify(bundle, null, 2), "application/json");
|
|
963
|
-
run = await this.state.updateRun(run.id, { contextBundleId: contextBlob.id });
|
|
964
|
-
await this.state.appendEvent(run.id, "context.bundle_built", { contextBundleId: contextBlob.id });
|
|
965
|
-
await this.createCheckpoint({
|
|
966
|
-
runId: run.id,
|
|
967
|
-
name: "context.bundle_built",
|
|
968
|
-
data: { contextBundleId: contextBlob.id }
|
|
969
|
-
});
|
|
970
|
-
const sandboxHandle = this.createSandboxHandle(() => run, (nextRun) => {
|
|
971
|
-
run = nextRun;
|
|
972
|
-
}, () => bundle);
|
|
973
|
-
await this.state.appendEvent(run.id, "harness.started", { harness: this.manifest.gateway.runtime?.kind ?? "node" });
|
|
974
|
-
const targetInstructions = await this.instructionsForRunTarget(run, hydratedOptions.target, bundle.instructions);
|
|
975
|
-
let response = options.message;
|
|
976
|
-
let structuredOutput;
|
|
977
|
-
const tool = this.selectTool(hydratedOptions);
|
|
978
|
-
if (tool) {
|
|
979
|
-
if (!capabilities.tools.includes(tool.name) && tool.visibility !== "deferred") {
|
|
980
|
-
const message = `Forced tool ${tool.name} is not enabled by the current agent capability snapshot.`;
|
|
981
|
-
const error = new Error(message);
|
|
982
|
-
error.name = "AgentCapabilityViolationError";
|
|
983
|
-
run = await failRunImpl({ state: this.state }, run.id, {
|
|
984
|
-
reason: "run.capability_violation",
|
|
985
|
-
error: message,
|
|
986
|
-
data: { toolName: tool.name }
|
|
987
|
-
});
|
|
988
|
-
throw error;
|
|
989
|
-
}
|
|
990
|
-
const modelSpanStartedAt = timestamp();
|
|
991
|
-
await this.state.appendEvent(run.id, "model.request_started", { model: capabilities.model, forcedTool: tool.name });
|
|
992
|
-
await this.state.appendEvent(run.id, "model.response_completed", { model: capabilities.model, simulated: true });
|
|
993
|
-
await this.emitSpan("ai.streamText", modelSpanStartedAt, this.runSpanAttributes(run, {
|
|
994
|
-
model: capabilities.model,
|
|
995
|
-
stepIndex: 0,
|
|
996
|
-
forcedTool: tool.name,
|
|
997
|
-
simulated: true,
|
|
998
|
-
status: "completed"
|
|
999
|
-
}), {
|
|
1000
|
-
parentSpanId: this.turnSpanId(run.id),
|
|
1001
|
-
status: "ok"
|
|
1002
|
-
});
|
|
1003
|
-
const input = hydratedOptions.input ?? inferToolInput(tool, hydratedOptions.message);
|
|
1004
|
-
const outcome = await this.executeTool(run, tool, input, sandboxHandle, hydratedOptions.approve ?? false);
|
|
1005
|
-
run = outcome.run;
|
|
1006
|
-
const stalled = await this.runProgress.failIfStalled(run);
|
|
1007
|
-
if (stalled) {
|
|
1008
|
-
run = stalled;
|
|
1009
|
-
await stopChannelLifecycle();
|
|
1010
|
-
await sandboxHandle.dispose();
|
|
1011
|
-
return this.result(run, "Run stalled without durable progress.", false, false, false);
|
|
1012
|
-
}
|
|
1013
|
-
if (outcome.waitingForApproval || outcome.waitingForInput || outcome.waitingForConnection) {
|
|
1014
|
-
await stopChannelLifecycle();
|
|
1015
|
-
await this.emitSpan("ai.assembly-line.turn", spanStartedAt, this.runSpanAttributes(run, {
|
|
1016
|
-
status: run.status
|
|
1017
|
-
}), {
|
|
1018
|
-
spanId: this.turnSpanId(run.id),
|
|
1019
|
-
status: "ok"
|
|
1020
|
-
});
|
|
1021
|
-
return this.result(run, response, outcome.waitingForApproval, outcome.waitingForInput, outcome.waitingForConnection);
|
|
1022
|
-
}
|
|
1023
|
-
response = typeof outcome.modelOutput === "string" ? outcome.modelOutput : JSON.stringify(outcome.modelOutput);
|
|
1024
|
-
}
|
|
1025
|
-
else {
|
|
1026
|
-
const loopInput = {
|
|
1027
|
-
run,
|
|
1028
|
-
bundle,
|
|
1029
|
-
sandboxHandle,
|
|
1030
|
-
message: hydratedOptions.message,
|
|
1031
|
-
channel,
|
|
1032
|
-
controller: hookController,
|
|
1033
|
-
refreshBundle: async (nextCapabilities) => {
|
|
1034
|
-
contextInput.capabilities = nextCapabilities;
|
|
1035
|
-
run = await this.state.getRun(run.id) ?? run;
|
|
1036
|
-
contextInput.run = run;
|
|
1037
|
-
bundle = await this.buildContextBundle(contextInput);
|
|
1038
|
-
return bundle;
|
|
1039
|
-
},
|
|
1040
|
-
instructions: targetInstructions
|
|
1041
|
-
};
|
|
1042
|
-
if (hydratedOptions.turn)
|
|
1043
|
-
loopInput.turn = hydratedOptions.turn;
|
|
1044
|
-
if (conversation?.id) {
|
|
1045
|
-
loopInput.conversationId = conversation.id;
|
|
1046
|
-
if (!options.contextSnapshot)
|
|
1047
|
-
loopInput.transcript = await this.loadConversationTranscript(conversation.id, run.id);
|
|
1048
|
-
}
|
|
1049
|
-
const outcome = await this.runHarnessLoop(loopInput);
|
|
1050
|
-
run = outcome.run;
|
|
1051
|
-
if (outcome.waitingForApproval || outcome.waitingForInput || outcome.waitingForConnection) {
|
|
1052
|
-
await stopChannelLifecycle();
|
|
1053
|
-
await this.emitSpan("ai.assembly-line.turn", spanStartedAt, this.runSpanAttributes(run, {
|
|
1054
|
-
status: run.status
|
|
1055
|
-
}), {
|
|
1056
|
-
spanId: this.turnSpanId(run.id),
|
|
1057
|
-
status: "ok"
|
|
1058
|
-
});
|
|
1059
|
-
return this.result(run, outcome.response, outcome.waitingForApproval, outcome.waitingForInput, outcome.waitingForConnection);
|
|
1060
|
-
}
|
|
1061
|
-
if (outcome.failed || outcome.controlStopped) {
|
|
1062
|
-
await stopChannelLifecycle();
|
|
1063
|
-
await sandboxHandle.dispose();
|
|
1064
|
-
return this.result(run, outcome.response, false, false, false);
|
|
1065
|
-
}
|
|
1066
|
-
response = outcome.response;
|
|
1067
|
-
structuredOutput = outcome.output;
|
|
1068
|
-
}
|
|
1069
|
-
const boundaryControl = await this.settleCompletionBoundaryControl(run);
|
|
1070
|
-
if (boundaryControl) {
|
|
1071
|
-
run = boundaryControl;
|
|
1072
|
-
await stopChannelLifecycle();
|
|
1073
|
-
await sandboxHandle.dispose();
|
|
1074
|
-
return this.result(run, response, false, false, false);
|
|
1075
|
-
}
|
|
1076
|
-
await stopChannelLifecycle();
|
|
1077
|
-
const result = await this.completeRun(run, sandboxHandle, response, channel, hydratedOptions.turn, conversation?.id);
|
|
1078
|
-
if (structuredOutput !== undefined)
|
|
1079
|
-
result.output = structuredOutput;
|
|
1080
|
-
await this.emitSpan("ai.assembly-line.turn", spanStartedAt, this.runSpanAttributes(result.run, {
|
|
1081
|
-
status: result.run.status
|
|
1082
|
-
}), {
|
|
1083
|
-
spanId: this.turnSpanId(result.run.id),
|
|
1084
|
-
status: result.run.status === "failed" ? "error" : "ok"
|
|
1085
|
-
});
|
|
1086
|
-
await this.emitSpan("assembly-line.run", spanStartedAt, {
|
|
1087
|
-
runId: run.id,
|
|
1088
|
-
status: result.run.status,
|
|
1089
|
-
agentRevision: this.manifest.agentRevision
|
|
1090
|
-
});
|
|
1091
|
-
return result;
|
|
1092
|
-
}
|
|
1093
|
-
catch (error) {
|
|
1094
|
-
await handleRunExecutionError({
|
|
1095
|
-
state: this.state,
|
|
1096
|
-
logger: this.logger,
|
|
1097
|
-
deliveryQueueMaxAttempts: this.deliveryQueueMaxAttempts,
|
|
1098
|
-
now: () => this.now()
|
|
1099
|
-
}, run.id, error);
|
|
1100
|
-
throw error;
|
|
1101
|
-
}
|
|
1102
|
-
finally {
|
|
1103
|
-
heartbeat.stop();
|
|
1104
|
-
await stopChannelLifecycle();
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
/** Settle a control request that arrived during a forced direct-tool run (run-outcome.ts). */
|
|
1108
|
-
async settleCompletionBoundaryControl(run) {
|
|
1109
|
-
return settleCompletionBoundaryControlImpl({ state: this.state, runControlIntents: this.runControlIntents }, run);
|
|
1110
|
-
}
|
|
1111
|
-
/** Bump `updatedAt` while a run executes and supervise its progress lease. */
|
|
1112
|
-
startRunHeartbeat(runId) {
|
|
1113
|
-
return this.runProgress.start(runId);
|
|
1114
|
-
}
|
|
1115
|
-
conversationContextHost() {
|
|
1116
|
-
const runtime = this;
|
|
1117
|
-
return {
|
|
1118
|
-
state: this.state,
|
|
1119
|
-
manifest: this.manifest,
|
|
1120
|
-
logger: this.logger,
|
|
1121
|
-
coreToolPolicy: this.coreToolPolicy,
|
|
1122
|
-
memoryStore: this.memoryStore,
|
|
1123
|
-
skillStore: this.skillStore,
|
|
1124
|
-
skillBundleIndex: this.skillBundleIndex,
|
|
1125
|
-
sourceLoader: this.sourceLoader,
|
|
1126
|
-
get contextPolicyPromise() {
|
|
1127
|
-
return runtime.contextPolicyPromise;
|
|
1128
|
-
},
|
|
1129
|
-
set contextPolicyPromise(value) {
|
|
1130
|
-
runtime.contextPolicyPromise = value;
|
|
1131
|
-
},
|
|
1132
|
-
loadChannelModule: (channel) => this.loadChannelModule(channel),
|
|
1133
|
-
channelContext: (channel) => this.channelContext(channel),
|
|
1134
|
-
warnSwallow: (message, fields) => this.warnSwallow(message, fields),
|
|
1135
|
-
memoryScopeForRun: (run) => this.memoryScopeForRun(run),
|
|
1136
|
-
durableAgentScope: () => this.durableAgentScope(),
|
|
1137
|
-
ensureSkillsSeeded: (surfacePath) => this.ensureSkillsSeeded(surfacePath),
|
|
1138
|
-
skillScopeForSurface: (surfacePath) => this.skillScopeForSurface(surfacePath),
|
|
1139
|
-
surfaceForRun: (run) => surfaceForRun(this.manifest, run)
|
|
1140
|
-
};
|
|
1141
|
-
}
|
|
1142
|
-
async prepareConversation(run, options, channel) {
|
|
1143
|
-
return prepareConversationImpl(this.conversationContextHost(), run, options, channel);
|
|
1144
|
-
}
|
|
1145
|
-
async recentHistory(conversationId, excludeRunId) {
|
|
1146
|
-
return recentHistoryImpl(this.conversationContextHost(), conversationId, excludeRunId);
|
|
1147
|
-
}
|
|
1148
|
-
async augmentChannelContext(channelName, turn, run) {
|
|
1149
|
-
return augmentChannelContextImpl(this.conversationContextHost(), channelName, turn, run);
|
|
1150
|
-
}
|
|
1151
|
-
async buildContextBundle(input) {
|
|
1152
|
-
return buildContextBundleImpl(this.conversationContextHost(), input);
|
|
1153
|
-
}
|
|
1154
|
-
harnessLoopHost() {
|
|
1155
|
-
const runtime = this;
|
|
1156
|
-
return {
|
|
1157
|
-
state: this.state,
|
|
1158
|
-
blob: this.blob,
|
|
1159
|
-
manifest: this.manifest,
|
|
1160
|
-
env: this.env,
|
|
1161
|
-
logger: this.logger,
|
|
1162
|
-
models: this.models,
|
|
1163
|
-
modelCredentialStore: this.modelCredentialStore,
|
|
1164
|
-
agentHarnessOverride: this.agentHarnessOverride,
|
|
1165
|
-
checkpointEveryIteration: this.checkpointEveryIteration,
|
|
1166
|
-
maxModelIterations: this.maxModelIterations,
|
|
1167
|
-
outputValidationMaxRetries: this.outputValidationMaxRetries,
|
|
1168
|
-
now: () => this.now(),
|
|
1169
|
-
shouldStopRun: (runId) => this.runProgress.shouldStop(runId),
|
|
1170
|
-
runStalled: (runId) => this.runProgress.isStalled(runId),
|
|
1171
|
-
registerRunAbort: (runId, controller) => this.runProgress.registerAbort(runId, controller),
|
|
1172
|
-
runStallTimeoutMs: this.runStallTimeoutMs,
|
|
1173
|
-
runEventBus: this.runEventBus,
|
|
1174
|
-
connectionAuthorizationSessionStore: this.connectionAuthorizationSessionStore,
|
|
1175
|
-
get defaultAgentHarness() {
|
|
1176
|
-
return runtime.defaultAgentHarness;
|
|
1177
|
-
},
|
|
1178
|
-
set defaultAgentHarness(value) {
|
|
1179
|
-
runtime.defaultAgentHarness = value;
|
|
1180
|
-
},
|
|
1181
|
-
get instrumentationConfig() {
|
|
1182
|
-
return runtime.instrumentationConfig;
|
|
1183
|
-
},
|
|
1184
|
-
createConnectionRegistry: (channel, turn) => this.createConnectionRegistry(channel, turn),
|
|
1185
|
-
createConnectionRegistryForRun: (run, fallbackChannel, sandboxHandle, selectedConnections) => this.createConnectionRegistryForRun(run, fallbackChannel, sandboxHandle, selectedConnections),
|
|
1186
|
-
missingRequiredConnections: (selected) => this.missingRequiredConnections(selected),
|
|
1187
|
-
visibleToolSet: (defaultToolNames, activeSkills) => this.visibleToolSet(defaultToolNames, activeSkills),
|
|
1188
|
-
modelTools: (run, activeToolNames, sandboxHandle, connectionRegistry, discoveredConnectionTools, options) => this.modelTools(run, activeToolNames, sandboxHandle, connectionRegistry, discoveredConnectionTools, options),
|
|
1189
|
-
harnessExecuteTool: (call, state) => this.harnessExecuteTool(call, state),
|
|
1190
|
-
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1191
|
-
hydrateCheckpointData: (data) => this.hydrateCheckpointData(data),
|
|
1192
|
-
emitSpan: (name, startedAt, attributes, options) => this.emitSpan(name, startedAt, attributes, options),
|
|
1193
|
-
runSpanAttributes: (run, extra) => this.runSpanAttributes(run, extra),
|
|
1194
|
-
turnSpanId: (runId) => this.turnSpanId(runId)
|
|
1195
|
-
};
|
|
1196
|
-
}
|
|
1197
|
-
async resolveAgentHarness(modelSpec) {
|
|
1198
|
-
const resolvedModel = modelSpec ?? this.manifest.possibleModels[0];
|
|
1199
|
-
if (!resolvedModel)
|
|
1200
|
-
throw new Error("No compiled model is available for harness resolution.");
|
|
1201
|
-
return resolveAgentHarnessImpl(this.harnessLoopHost(), resolvedModel);
|
|
1202
|
-
}
|
|
1203
|
-
async runHarnessLoop(input) {
|
|
1204
|
-
return runHarnessLoopImpl(this.harnessLoopHost(), input);
|
|
1205
|
-
}
|
|
1206
|
-
/** Load the conversation's stored transcript for resume, or undefined when disabled/absent. */
|
|
1207
|
-
async loadConversationTranscript(conversationId, runId) {
|
|
1208
|
-
return loadResumableConversationTranscriptImpl(this.conversationContextHost(), {
|
|
1209
|
-
state: this.state,
|
|
1210
|
-
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1211
|
-
hydrateCheckpointData: (data) => this.hydrateCheckpointData(data)
|
|
1212
|
-
}, conversationId, runId);
|
|
1213
|
-
}
|
|
1214
|
-
createHarnessContext(session, loopState, resumed) {
|
|
1215
|
-
return createHarnessContextImpl(this.harnessLoopHost(), session, loopState, resumed);
|
|
1216
|
-
}
|
|
1217
|
-
async persistHarnessContinuation(runId, session, continuation, pause) {
|
|
1218
|
-
return persistHarnessContinuationImpl(this.harnessLoopHost(), runId, session, continuation, pause);
|
|
1219
|
-
}
|
|
1220
|
-
channelIngressHost() {
|
|
1221
|
-
return {
|
|
1222
|
-
state: this.state,
|
|
1223
|
-
manifest: this.manifest,
|
|
1224
|
-
devMode: this.devMode,
|
|
1225
|
-
logger: this.logger,
|
|
1226
|
-
runSemaphore: this.runSemaphore,
|
|
1227
|
-
boot: () => this.boot(),
|
|
1228
|
-
loadChannelModule: (channel) => this.loadChannelModule(channel),
|
|
1229
|
-
channelContext: (channel) => this.channelContext(channel),
|
|
1230
|
-
agentEnabled: () => this.agentEnabled(),
|
|
1231
|
-
admitRunOrReject: () => this.admitRunOrReject(),
|
|
1232
|
-
enqueueConversationTurn: (input) => this.conversationTurnDispatcher.enqueue(input),
|
|
1233
|
-
run: (options) => this.run(options),
|
|
1234
|
-
dispatchAutomationEvent: (event) => this.dispatchAutomationEvent(event)
|
|
1235
|
-
};
|
|
1236
|
-
}
|
|
1237
|
-
async dispatchHttpChannel(channelName, request) {
|
|
1238
|
-
return dispatchHttpChannelImpl(this.channelIngressHost(), channelName, request);
|
|
1239
|
-
}
|
|
1240
|
-
async acceptChannelTurn(channelName, input) {
|
|
1241
|
-
return acceptChannelTurnImpl(this.channelIngressHost(), channelName, input);
|
|
1242
|
-
}
|
|
1243
|
-
async startChannelIngress() {
|
|
1244
|
-
return startChannelIngressImpl(this.channelIngressHost());
|
|
1245
|
-
}
|
|
1246
|
-
replayResumeHost() {
|
|
1247
|
-
return {
|
|
1248
|
-
state: this.state,
|
|
1249
|
-
manifest: this.manifest,
|
|
1250
|
-
coreToolPolicy: this.coreToolPolicy,
|
|
1251
|
-
env: this.env,
|
|
1252
|
-
fetch: this.fetch,
|
|
1253
|
-
connectionAuthorizationSessionStore: this.connectionAuthorizationSessionStore,
|
|
1254
|
-
connectionGrantStore: this.connectionGrantStore,
|
|
1255
|
-
credentialBroker: this.credentialBroker,
|
|
1256
|
-
connectionCallbackBaseUrl: this.connectionCallbackBaseUrl,
|
|
1257
|
-
boot: () => this.boot(),
|
|
1258
|
-
initializeInstrumentation: () => this.initializeInstrumentation(),
|
|
1259
|
-
ensureDynamicConnections: () => this.ensureDynamicConnections(),
|
|
1260
|
-
withRunAdmission: (work) => this.withRunAdmission(work),
|
|
1261
|
-
listHydratedCheckpoints: (runId) => this.listHydratedCheckpoints(runId),
|
|
1262
|
-
hydrateCheckpointData: (data) => this.hydrateCheckpointData(data),
|
|
1263
|
-
resolveAgentHarness: (modelSpec) => this.resolveAgentHarness(modelSpec),
|
|
1264
|
-
ensureAgentHookController: (run) => this.ensureAgentHookController(run),
|
|
1265
|
-
resolvedInstructionsForRun: (run, bundle, capabilities) => resolvedHookInstructionsForRun(this.manifest, run, bundle.instructions, capabilities),
|
|
1266
|
-
buildContextBundle: (input) => this.buildContextBundle(input),
|
|
1267
|
-
createSandboxHandle: (getRun, setRun, getBundle) => this.createSandboxHandle(getRun, setRun, getBundle),
|
|
1268
|
-
executeToolWithRecord: (run, tool, toolCall, input, sandboxHandle, approvedToolCall) => this.executeToolWithRecord(run, tool, toolCall, input, sandboxHandle, approvedToolCall),
|
|
1269
|
-
executeConnectionToolWithRecord: (run, registry, toolName, toolCall, input) => this.executeConnectionToolWithRecord(run, registry, toolName, toolCall, input),
|
|
1270
|
-
createConnectionRegistry: (channel, turn) => this.createConnectionRegistry(channel, turn),
|
|
1271
|
-
createConnectionRegistryForRun: (run, fallbackChannel, sandboxHandle, selectedConnections) => this.createConnectionRegistryForRun(run, fallbackChannel, sandboxHandle, selectedConnections),
|
|
1272
|
-
createConnectionRegistryForSession: (session) => this.createConnectionRegistryForSession(session),
|
|
1273
|
-
mergedConnections: () => this.mergedConnections(),
|
|
1274
|
-
loadConnectionDefinition: (connection) => this.loadConnectionDefinition(connection),
|
|
1275
|
-
startRunHeartbeat: (runId) => this.startRunHeartbeat(runId),
|
|
1276
|
-
createHarnessContext: (session, loopState, resumed) => this.createHarnessContext(session, loopState, resumed),
|
|
1277
|
-
executeHarnessTurn: (harness, input, session, loopState, resumed, refreshCapabilities) => executeHarnessTurnImpl(this.harnessLoopHost(), harness, input, session, loopState, resumed, refreshCapabilities),
|
|
1278
|
-
persistHarnessContinuation: (runId, session, continuation, pause) => this.persistHarnessContinuation(runId, session, continuation, pause),
|
|
1279
|
-
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1280
|
-
result: (run, response, waitingForApproval, waitingForInput, waitingForConnection) => this.result(run, response, waitingForApproval, waitingForInput, waitingForConnection),
|
|
1281
|
-
completeRun: (run, sandboxHandle, response, channel, turn, conversationId) => this.completeRun(run, sandboxHandle, response, channel, turn, conversationId),
|
|
1282
|
-
runDeliveryChannel: (run) => this.runDeliveryChannel(run),
|
|
1283
|
-
enqueueConversationTurn: (input) => this.conversationTurnDispatcher.enqueue(input)
|
|
1284
|
-
};
|
|
1285
|
-
}
|
|
1286
|
-
async replay(runId) {
|
|
1287
|
-
return replayImpl(this.replayResumeHost(), runId);
|
|
1288
|
-
}
|
|
1289
|
-
/** Start a new, isolated run from a terminal run's verified durable input snapshot. */
|
|
1290
|
-
async rerun(runId, lifecycle) {
|
|
1291
|
-
return rerunFromSnapshot({ runId, state: this.state, blob: this.blob, manifest: this.manifest, run: (options) => this.run(options) }, lifecycle);
|
|
1292
|
-
}
|
|
1293
|
-
/** Resumes never consume run capacity (deadlock risk); they only count toward `onIdle()`. */
|
|
1294
|
-
async resumeApproval(runId) {
|
|
1295
|
-
const result = await this.withRunAdmission(() => this.resumeApprovalNow(runId));
|
|
1296
|
-
await this.conversationTurnDispatcher.settleRunResult(result);
|
|
1297
|
-
return result;
|
|
1298
|
-
}
|
|
1299
|
-
async resumeApprovalNow(runId) {
|
|
1300
|
-
return resumeApprovalNowImpl(this.replayResumeHost(), runId);
|
|
1301
|
-
}
|
|
1302
|
-
async completeConnectionAuthorizationCallback(callback) {
|
|
1303
|
-
const authorizationSession = callback.params.state
|
|
1304
|
-
? await this.connectionAuthorizationSessionStore.getSessionByState(callback.params.state)
|
|
1305
|
-
: undefined;
|
|
1306
|
-
const result = await completeConnectionAuthorizationCallbackImpl(this.replayResumeHost(), callback);
|
|
1307
|
-
if (result.runResult)
|
|
1308
|
-
await this.conversationTurnDispatcher.settleRunResult(result.runResult);
|
|
1309
|
-
if (authorizationSession) {
|
|
1310
|
-
await this.reconcileConnectionEvents({
|
|
1311
|
-
connection: authorizationSession.connectionName,
|
|
1312
|
-
principal: authorizationSession.principal,
|
|
1313
|
-
force: true
|
|
1314
|
-
}).catch((error) => this.logger.warn("connection event reconcile after authorization failed", {
|
|
1315
|
-
connection: authorizationSession.connectionName,
|
|
1316
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1317
|
-
}));
|
|
1318
|
-
}
|
|
1319
|
-
return result;
|
|
1320
|
-
}
|
|
1321
|
-
/**
|
|
1322
|
-
* Begin (or resume) the authorization flow for a named connection on behalf
|
|
1323
|
-
* of an operator surface such as a dashboard or CLI, outside any run. Backs
|
|
1324
|
-
* the node host's authenticated GET /assembly-line/connections/authorize route.
|
|
1325
|
-
* Idempotent by construction: an existing usable grant reports "connected"
|
|
1326
|
-
* and a pending session's challenge URL is reused, so this doubles as a
|
|
1327
|
-
* per-connection status probe while a consent flow is in flight. Connections
|
|
1328
|
-
* with subject "user" require the caller to supply the same user identity a
|
|
1329
|
-
* run would carry; otherwise they report unavailable (principal_required).
|
|
1330
|
-
*/
|
|
1331
|
-
async beginConnectionAuthorization(connectionName, session = {}) {
|
|
1332
|
-
return beginConnectionAuthorizationImpl(this.toolExecutionHost(), connectionName, session);
|
|
1333
|
-
}
|
|
1334
|
-
connectionEventsHost(publicUrl) {
|
|
1335
|
-
const resolvedPublicUrl = publicUrl ?? this.connectionCallbackBaseUrl;
|
|
1336
|
-
return {
|
|
1337
|
-
manifest: this.manifest,
|
|
1338
|
-
env: this.env,
|
|
1339
|
-
fetch: this.fetch,
|
|
1340
|
-
logger: this.logger,
|
|
1341
|
-
agentScope: this.durableAgentScope(),
|
|
1342
|
-
store: this.connectionEventStore,
|
|
1343
|
-
grantStore: this.connectionGrantStore,
|
|
1344
|
-
...(resolvedPublicUrl ? { publicUrl: resolvedPublicUrl } : {}),
|
|
1345
|
-
createRegistry: (principal) => new RuntimeConnectionRegistry({
|
|
1346
|
-
connections: this.mergedConnections(),
|
|
1347
|
-
config: this.env,
|
|
1348
|
-
credentialBroker: this.credentialBroker,
|
|
1349
|
-
fetch: this.fetch,
|
|
1350
|
-
session: {
|
|
1351
|
-
channel: "connection-event",
|
|
1352
|
-
principal,
|
|
1353
|
-
...(principal.type === "user" ? { userId: principal.id } : {})
|
|
1354
|
-
},
|
|
1355
|
-
agentId: this.manifest.agent.id ?? this.manifest.agentRevision,
|
|
1356
|
-
grantStore: this.connectionGrantStore,
|
|
1357
|
-
authorizationSessionStore: this.connectionAuthorizationSessionStore,
|
|
1358
|
-
...(this.connectionCallbackBaseUrl ? { callbackBaseUrl: this.connectionCallbackBaseUrl } : {}),
|
|
1359
|
-
loadDefinition: async (connection) => this.loadConnectionDefinition(connection)
|
|
1360
|
-
}),
|
|
1361
|
-
dispatchAutomationEvent: (event) => this.dispatchAutomationEvent(event),
|
|
1362
|
-
appendAudit: (type, data) => this.state.appendRuntimeControlEvent(this.durableAgentScope(), type, data)
|
|
1363
|
-
};
|
|
1364
|
-
}
|
|
1365
|
-
async reconcileConnectionEvents(options = {}) {
|
|
1366
|
-
return reconcileConnectionEvents(this.connectionEventsHost(options.publicUrl), options);
|
|
1367
|
-
}
|
|
1368
|
-
async checkConnectionEvents(connection) {
|
|
1369
|
-
return checkConnectionEvents(this.connectionEventsHost(), connection);
|
|
1370
|
-
}
|
|
1371
|
-
async acceptConnectionEvent(connectionName, bindingId, request) {
|
|
1372
|
-
return acceptConnectionEvent(this.connectionEventsHost(), connectionName, bindingId, request);
|
|
1373
|
-
}
|
|
1374
|
-
async runDueConnectionEvents(options = {}) {
|
|
1375
|
-
return drainConnectionEventInbox(this.connectionEventsHost(), options);
|
|
1376
|
-
}
|
|
1377
|
-
startConnectionEventWorker(options = {}) {
|
|
1378
|
-
const intervalMs = positiveLimit(options.intervalMs, 1_000);
|
|
1379
|
-
const tick = () => this.runDueConnectionEvents({
|
|
1380
|
-
...(options.batchSize !== undefined ? { limit: options.batchSize } : {}),
|
|
1381
|
-
...(options.leaseForMs !== undefined ? { leaseForMs: options.leaseForMs } : {})
|
|
1382
|
-
}).catch((error) => this.logger.warn("connection event worker tick failed", { error: error instanceof Error ? error.message : String(error) }));
|
|
1383
|
-
void tick();
|
|
1384
|
-
const timer = setInterval(() => void tick(), intervalMs);
|
|
1385
|
-
timer.unref?.();
|
|
1386
|
-
const reconcile = () => this.reconcileConnectionEvents().catch((error) => this.logger.warn("connection event reconcile tick failed", {
|
|
1387
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1388
|
-
}));
|
|
1389
|
-
void reconcile();
|
|
1390
|
-
const reconcileTimer = setInterval(() => void reconcile(), 60_000);
|
|
1391
|
-
reconcileTimer.unref?.();
|
|
1392
|
-
return { stop: () => { clearInterval(timer); clearInterval(reconcileTimer); } };
|
|
1393
|
-
}
|
|
1394
|
-
/** Resumes never consume run capacity (deadlock risk); they only count toward `onIdle()`. */
|
|
1395
|
-
async resumeInput(runId, answer) {
|
|
1396
|
-
const result = await this.withRunAdmission(() => this.resumeInputNow(runId, answer));
|
|
1397
|
-
await this.conversationTurnDispatcher.settleRunResult(result);
|
|
1398
|
-
return result;
|
|
1399
|
-
}
|
|
1400
|
-
async resumeInputNow(runId, answer) {
|
|
1401
|
-
return resumeInputNowImpl(this.replayResumeHost(), runId, answer);
|
|
1402
|
-
}
|
|
1403
|
-
/** Request cooperative cancellation, or synchronously cancel a parked run. */
|
|
1404
|
-
async cancelRun(runId) {
|
|
1405
|
-
const run = await requestRunControlImpl(this.operatorControlsHost(), runId, "cancel");
|
|
1406
|
-
if (run.status === "cancelled")
|
|
1407
|
-
await this.conversationTurnDispatcher.settleRunRecord(run);
|
|
1408
|
-
return run;
|
|
1409
|
-
}
|
|
1410
|
-
/** Request cooperative suspension of a currently running run. */
|
|
1411
|
-
async suspendRun(runId) {
|
|
1412
|
-
return requestRunControlImpl(this.operatorControlsHost(), runId, "suspend");
|
|
1413
|
-
}
|
|
1414
|
-
/** Resume a deliberately suspended run from its latest durable continuation. */
|
|
1415
|
-
async resumeSuspended(runId) {
|
|
1416
|
-
const result = await this.withRunAdmission(() => resumeSuspendedNowImpl(this.replayResumeHost(), runId));
|
|
1417
|
-
await this.conversationTurnDispatcher.settleRunResult(result);
|
|
1418
|
-
return result;
|
|
1419
|
-
}
|
|
1420
|
-
/** Read the durable ingress kill-switch for this stable agent identity. */
|
|
1421
|
-
async getAgentControl() {
|
|
1422
|
-
return getAgentControlImpl(this.operatorControlsHost());
|
|
1423
|
-
}
|
|
1424
|
-
/** Enable or disable new channel ingress without affecting in-flight runs or resumes. */
|
|
1425
|
-
async setAgentEnabled(enabled, metadata = {}) {
|
|
1426
|
-
const result = await setAgentEnabledImpl(this.operatorControlsHost(), enabled, metadata);
|
|
1427
|
-
if (enabled)
|
|
1428
|
-
this.conversationTurnDispatcher.requestDrain();
|
|
1429
|
-
return result;
|
|
1430
|
-
}
|
|
1431
|
-
/** Quiesce new ingress and background dispatch while in-flight work drains. */
|
|
1432
|
-
async setAgentMaintenance(maintenance, metadata = {}) {
|
|
1433
|
-
const result = await setAgentMaintenanceImpl(this.operatorControlsHost(), maintenance, metadata);
|
|
1434
|
-
if (!maintenance)
|
|
1435
|
-
this.conversationTurnDispatcher.requestDrain();
|
|
1436
|
-
return result;
|
|
1437
|
-
}
|
|
1438
|
-
async agentEnabled() {
|
|
1439
|
-
return (await this.getAgentControl()).acceptingWork;
|
|
1440
|
-
}
|
|
1441
|
-
operatorControlsHost() {
|
|
1442
|
-
return {
|
|
1443
|
-
state: this.state,
|
|
1444
|
-
boot: () => this.boot(),
|
|
1445
|
-
durableAgentScope: () => this.durableAgentScope(),
|
|
1446
|
-
cacheRunControl: (runId, intent) => this.runProgress.cacheControl(runId, intent)
|
|
1447
|
-
};
|
|
1448
|
-
}
|
|
1449
|
-
async resumeHarnessLoop(run, harness, restored, resume) {
|
|
1450
|
-
return resumeHarnessLoopImpl(this.replayResumeHost(), run, harness, restored, resume);
|
|
1451
|
-
}
|
|
1452
|
-
subagentExecutionHost() {
|
|
1453
|
-
return {
|
|
1454
|
-
state: this.state,
|
|
1455
|
-
blob: this.blob,
|
|
1456
|
-
manifest: this.manifest,
|
|
1457
|
-
sourceLoader: this.sourceLoader,
|
|
1458
|
-
resolveAgentHarness: (modelSpec) => this.resolveAgentHarness(modelSpec),
|
|
1459
|
-
replay: (runId) => this.replay(runId),
|
|
1460
|
-
listHydratedCheckpoints: (runId) => this.listHydratedCheckpoints(runId),
|
|
1461
|
-
buildContextBundle: (input) => this.buildContextBundle(input),
|
|
1462
|
-
createSubagentHookController: (run, subagent, message, conversationId) => this.createSubagentHookController(run, subagent, message, conversationId),
|
|
1463
|
-
createSandboxHandle: (getRun, setRun, getBundle) => this.createSandboxHandle(getRun, setRun, getBundle),
|
|
1464
|
-
startRunHeartbeat: (runId) => this.startRunHeartbeat(runId),
|
|
1465
|
-
runHarnessLoop: (input) => this.runHarnessLoop(input),
|
|
1466
|
-
resumeHarnessLoop: (run, harness, restored, resume) => this.resumeHarnessLoop(run, harness, restored, resume),
|
|
1467
|
-
completeRun: (run, sandboxHandle, response, channel, turn, conversationId) => this.completeRun(run, sandboxHandle, response, channel, turn, conversationId),
|
|
1468
|
-
emitSpan: (name, startedAt, attributes, options) => this.emitSpan(name, startedAt, attributes, options),
|
|
1469
|
-
runSpanAttributes: (run, extra) => this.runSpanAttributes(run, extra),
|
|
1470
|
-
turnSpanId: (runId) => this.turnSpanId(runId)
|
|
1471
|
-
};
|
|
1472
|
-
}
|
|
1473
|
-
async runSubagent(parentRunId, subagentName, task) {
|
|
1474
|
-
return runSubagentImpl(this.subagentExecutionHost(), parentRunId, subagentName, task);
|
|
1475
|
-
}
|
|
1476
|
-
async resumeSubagent(parentRunId, childRunId, subagentName, message) {
|
|
1477
|
-
return resumeSubagentImpl(this.subagentExecutionHost(), parentRunId, childRunId, subagentName, message);
|
|
1478
|
-
}
|
|
1479
|
-
async queueSubagent(parentRunId, subagentName, task) {
|
|
1480
|
-
const child = await createSubagentRunImpl(this.subagentExecutionHost(), parentRunId, subagentName, task, { background: true });
|
|
1481
|
-
this.backgroundSubagents.requestDrain();
|
|
1482
|
-
return child;
|
|
1483
|
-
}
|
|
1484
|
-
async listBackgroundWork(rootRunId, includeTerminal = false) {
|
|
1485
|
-
const root = await this.state.getRun(rootRunId);
|
|
1486
|
-
if (!root)
|
|
1487
|
-
throw new Error(`Run not found: ${rootRunId}`);
|
|
1488
|
-
return this.backgroundSubagents.listForRoot(root, includeTerminal);
|
|
1489
|
-
}
|
|
1490
|
-
async getBackgroundWork(rootRunId, childRunId) {
|
|
1491
|
-
const root = await this.state.getRun(rootRunId);
|
|
1492
|
-
if (!root)
|
|
1493
|
-
throw new Error(`Run not found: ${rootRunId}`);
|
|
1494
|
-
return this.backgroundSubagents.getForRoot(root, childRunId);
|
|
1495
|
-
}
|
|
1496
|
-
async cancelBackgroundWork(rootRunId, childRunId) {
|
|
1497
|
-
const root = await this.state.getRun(rootRunId);
|
|
1498
|
-
if (!root)
|
|
1499
|
-
throw new Error(`Run not found: ${rootRunId}`);
|
|
1500
|
-
return this.backgroundSubagents.cancelForRoot(root, childRunId);
|
|
1501
|
-
}
|
|
1502
|
-
async readSubagent(childRunId, cursor) {
|
|
1503
|
-
return readSubagentImpl(this.subagentExecutionHost(), childRunId, cursor);
|
|
1504
|
-
}
|
|
1505
|
-
async sendSubagentFollowup(childRunId, message) {
|
|
1506
|
-
return sendSubagentFollowupImpl(this.subagentExecutionHost(), childRunId, message);
|
|
1507
|
-
}
|
|
1508
|
-
async loadSkill(runId, skillName) {
|
|
1509
|
-
const run = await this.state.getRun(runId);
|
|
1510
|
-
if (!run)
|
|
1511
|
-
throw new Error(`Run not found: ${runId}`);
|
|
1512
|
-
const controller = await this.ensureAgentHookController(run);
|
|
1513
|
-
const snapshot = await controller.refreshIfDirty();
|
|
1514
|
-
if (!snapshot.declaration.skills.includes(skillName)) {
|
|
1515
|
-
throw new Error(`Skill ${skillName} is not enabled by the current agent capability snapshot.`);
|
|
1516
|
-
}
|
|
1517
|
-
const loaded = await this.skillLoadDetails(run, skillName);
|
|
1518
|
-
const output = {
|
|
1519
|
-
name: loaded.name,
|
|
1520
|
-
skillName: loaded.name,
|
|
1521
|
-
description: loaded.description,
|
|
1522
|
-
origin: loaded.origin,
|
|
1523
|
-
path: loaded.path,
|
|
1524
|
-
instructions: loaded.instructions
|
|
1525
|
-
};
|
|
1526
|
-
if (loaded.declaredTools.length > 0)
|
|
1527
|
-
output.declaredTools = loaded.declaredTools;
|
|
1528
|
-
await this.state.appendEvent(runId, "skill.loaded", {
|
|
1529
|
-
skill: loaded.name,
|
|
1530
|
-
origin: loaded.origin,
|
|
1531
|
-
path: loaded.path
|
|
1532
|
-
});
|
|
1533
|
-
return output;
|
|
1534
|
-
}
|
|
1535
|
-
async activateSkill(runId, skillName) {
|
|
1536
|
-
await this.loadSkill(runId, skillName);
|
|
1537
|
-
return visibleToolsForSkills(this.manifest);
|
|
1538
|
-
}
|
|
1539
|
-
scheduleExecutionHost() {
|
|
1540
|
-
return {
|
|
1541
|
-
manifest: this.manifest,
|
|
1542
|
-
state: this.state,
|
|
1543
|
-
blob: this.blob,
|
|
1544
|
-
env: this.env,
|
|
1545
|
-
fetch: this.fetch,
|
|
1546
|
-
logger: this.logger,
|
|
1547
|
-
memoryStore: this.memoryStore,
|
|
1548
|
-
skillStore: this.skillStore,
|
|
1549
|
-
scheduleStore: this.scheduleStore,
|
|
1550
|
-
schedulesConfig: this.schedulesConfig,
|
|
1551
|
-
schedulerTickMs: this.schedulerTickMs,
|
|
1552
|
-
scheduleMaxConsecutiveFailures: this.scheduleMaxConsecutiveFailures,
|
|
1553
|
-
sourceLoader: this.sourceLoader,
|
|
1554
|
-
boot: () => this.boot(),
|
|
1555
|
-
now: () => this.now(),
|
|
1556
|
-
admitRunOrReject: () => this.admitRunOrReject(),
|
|
1557
|
-
run: (options) => this.run(options),
|
|
1558
|
-
latestRunFailureMessage: (runId) => this.latestRunFailureMessage(runId),
|
|
1559
|
-
emitSpan: (name, startedAt, attributes, options) => this.emitSpan(name, startedAt, attributes, options),
|
|
1560
|
-
runSpanAttributes: (run, extra) => this.runSpanAttributes(run, extra),
|
|
1561
|
-
turnSpanId: (runId) => this.turnSpanId(runId),
|
|
1562
|
-
createSandboxHandle: (getRun, setRun, getBundle) => this.createSandboxHandle(getRun, setRun, getBundle),
|
|
1563
|
-
createMemoryToolApi: (run) => this.createMemoryToolApi(run),
|
|
1564
|
-
createResourceToolApi: (run, sandboxHandle) => this.createResourceToolApi(run, sandboxHandle),
|
|
1565
|
-
durableStep: (runId, key, fn, options) => this.durableStep(runId, key, fn, options),
|
|
1566
|
-
memoryScopeForRun: (run) => this.memoryScopeForRun(run),
|
|
1567
|
-
mergedConnections: () => this.mergedConnections(),
|
|
1568
|
-
skillScope: () => this.skillScope(),
|
|
1569
|
-
agentEnabled: () => this.agentEnabled()
|
|
1570
|
-
};
|
|
1571
|
-
}
|
|
1572
|
-
async registerManifestSchedules() {
|
|
1573
|
-
return registerManifestSchedulesImpl(this.scheduleExecutionHost());
|
|
1574
|
-
}
|
|
1575
|
-
async registerManifestAutomations() {
|
|
1576
|
-
return this.registerManifestSchedules();
|
|
1577
|
-
}
|
|
1578
|
-
/** @deprecated Use `runDueAutomations`. */
|
|
1579
|
-
async runDueSchedules(options = {}) {
|
|
1580
|
-
return runDueSchedulesImpl(this.scheduleExecutionHost(), options);
|
|
1581
|
-
}
|
|
1582
|
-
async runDueAutomations(options = {}) {
|
|
1583
|
-
return this.runDueSchedules(options);
|
|
1584
|
-
}
|
|
1585
|
-
async dispatchAutomationEvent(event) {
|
|
1586
|
-
return dispatchAutomationEventImpl(this.scheduleExecutionHost(), event);
|
|
1587
|
-
}
|
|
1588
|
-
normalizeScheduleTriggerDefinition(value) {
|
|
1589
|
-
return normalizeScheduleTriggerDefinitionImpl(this.scheduleExecutionHost(), value);
|
|
1590
|
-
}
|
|
1591
|
-
async startSchedulerLoop() {
|
|
1592
|
-
if (!this.shouldStartScheduler())
|
|
1593
|
-
return undefined;
|
|
1594
|
-
return this.scheduler.start(this);
|
|
1595
|
-
}
|
|
1596
|
-
async startSchedulerPollingLoop() {
|
|
1597
|
-
return startSchedulerPollingLoopImpl(this.scheduleExecutionHost());
|
|
1598
|
-
}
|
|
1599
|
-
shouldStartScheduler() {
|
|
1600
|
-
if (this.schedulerEnabled === false)
|
|
1601
|
-
return false;
|
|
1602
|
-
if (this.env.ASSEMBLY_LINE_SCHEDULER_ENABLED === "false" || this.env.ASSEMBLY_LINE_SCHEDULER_ENABLED === "0")
|
|
1603
|
-
return false;
|
|
1604
|
-
return true;
|
|
1605
|
-
}
|
|
1606
|
-
/**
|
|
1607
|
-
* Subscribe to a run's live event stream: every durable event as it is
|
|
1608
|
-
* persisted plus ephemeral `model.response_delta` token deltas. Returns an
|
|
1609
|
-
* unsubscribe function. For catch-up, replay `listEvents(runId)` first and
|
|
1610
|
-
* dedupe by `sequence`.
|
|
1611
|
-
*/
|
|
1612
|
-
subscribeRunStream(runId, listener) {
|
|
1613
|
-
return this.runEventBus.subscribe(runId, listener);
|
|
1614
|
-
}
|
|
1615
|
-
/** Staleness-guarded orphaned-run sweep. See {@link RunRecoveryOptions} for tuning. */
|
|
1616
|
-
async recoverIncompleteRuns(options = {}) {
|
|
1617
|
-
if (!(await this.agentEnabled()))
|
|
1618
|
-
return [];
|
|
1619
|
-
const host = {
|
|
1620
|
-
state: this.state,
|
|
1621
|
-
logger: this.logger,
|
|
1622
|
-
now: this.now,
|
|
1623
|
-
runHeartbeatMs: this.runHeartbeatMs,
|
|
1624
|
-
sandboxSyncMaxAttempts: this.sandboxSyncMaxAttempts,
|
|
1625
|
-
deliveryQueueMaxAttempts: this.deliveryQueueMaxAttempts,
|
|
1626
|
-
connectionAuthorizationSessionStore: this.connectionAuthorizationSessionStore,
|
|
1627
|
-
missingRequiredConnections: (selected) => this.missingRequiredConnections(selected),
|
|
1628
|
-
resumeRunFromContinuation: (run, context) => this.withRunAdmission(() => this.resumeRunFromContinuation(run, context)),
|
|
1629
|
-
listHydratedCheckpoints: (runId) => this.listHydratedCheckpoints(runId)
|
|
1630
|
-
};
|
|
1631
|
-
const recovered = await recoverIncompleteRunsImpl(host, options);
|
|
1632
|
-
for (const run of recovered) {
|
|
1633
|
-
await this.conversationTurnDispatcher.settleRunRecord(run);
|
|
1634
|
-
}
|
|
1635
|
-
await this.conversationTurnDispatcher.recover();
|
|
1636
|
-
return recovered;
|
|
1637
|
-
}
|
|
1638
|
-
/** Resume an orphaned run in place from its latest persisted continuation checkpoint (replay-resume.ts). */
|
|
1639
|
-
async resumeRunFromContinuation(run, context) {
|
|
1640
|
-
return resumeRunFromContinuationImpl(this.replayResumeHost(), run, context);
|
|
1641
|
-
}
|
|
1642
|
-
/** Start delivery, sandbox-sync, conversation-turn, subagent, background-review, and orphan-recovery workers. */
|
|
1643
|
-
startBackgroundWorkers(options = {}) {
|
|
1644
|
-
return startBackgroundWorkersImpl({
|
|
1645
|
-
env: this.env,
|
|
1646
|
-
logger: this.logger,
|
|
1647
|
-
runRecoveryIntervalMs: this.runRecoveryIntervalMs,
|
|
1648
|
-
startDeliveryWorker: (workerOptions) => this.startDeliveryWorker(workerOptions),
|
|
1649
|
-
startSandboxSyncWorker: (workerOptions) => this.startSandboxSyncWorker(workerOptions),
|
|
1650
|
-
startConversationTurnWorker: (workerOptions) => this.conversationTurnDispatcher.startWorker(workerOptions?.intervalMs),
|
|
1651
|
-
startBackgroundSubagentWorker: (workerOptions) => this.backgroundSubagents.startWorker(workerOptions?.intervalMs),
|
|
1652
|
-
startBackgroundReviewWorker: (workerOptions) => this.startBackgroundReviewWorker(workerOptions),
|
|
1653
|
-
startConnectionEventWorker: (workerOptions) => this.startConnectionEventWorker(workerOptions),
|
|
1654
|
-
recoverIncompleteRuns: (recoveryOptions) => this.recoverIncompleteRuns(recoveryOptions),
|
|
1655
|
-
agentEnabled: () => this.agentEnabled()
|
|
1656
|
-
}, options);
|
|
1657
|
-
}
|
|
1658
|
-
deliveryQueueHost() {
|
|
1659
|
-
return {
|
|
1660
|
-
state: this.state,
|
|
1661
|
-
logger: this.logger,
|
|
1662
|
-
now: this.now,
|
|
1663
|
-
leaseMs: this.deliveryQueueLeaseMs,
|
|
1664
|
-
batchSize: this.deliveryQueueBatchSize,
|
|
1665
|
-
agentEnabled: () => this.agentEnabled(),
|
|
1666
|
-
sendQueuedDelivery: async (delivery) => {
|
|
1667
|
-
const response = typeof delivery.payload.response === "string" ? delivery.payload.response : "";
|
|
1668
|
-
return this.sendDelivery(delivery, response, undefined);
|
|
1669
|
-
}
|
|
1670
|
-
};
|
|
1671
|
-
}
|
|
1672
|
-
/** Drain due deferred deliveries once: recover expired leases, lease, send, settle. */
|
|
1673
|
-
async runDueDeliveries(options = {}) {
|
|
1674
|
-
return runDueDeliveriesImpl(this.deliveryQueueHost(), options);
|
|
1675
|
-
}
|
|
1676
|
-
startDeliveryWorker(options = {}) {
|
|
1677
|
-
const intervalMs = positiveLimit(options.intervalMs, this.deliveryQueueIntervalMs);
|
|
1678
|
-
return startDeliveryWorkerImpl(this.deliveryQueueHost(), { ...options, intervalMs });
|
|
1679
|
-
}
|
|
1680
|
-
/** The run's originating channel, for routing deliveries on resume/degrade paths. */
|
|
1681
|
-
runDeliveryChannel(run) {
|
|
1682
|
-
return typeof run.input.channel === "string" && run.input.channel ? run.input.channel : "local";
|
|
1683
|
-
}
|
|
1684
|
-
deliverySendHost() {
|
|
1685
|
-
return {
|
|
1686
|
-
state: this.state,
|
|
1687
|
-
blob: this.blob,
|
|
1688
|
-
logger: this.logger,
|
|
1689
|
-
env: this.env,
|
|
1690
|
-
manifest: this.manifest,
|
|
1691
|
-
devMode: this.devMode,
|
|
1692
|
-
deliveryMode: this.deliveryMode,
|
|
1693
|
-
now: this.now,
|
|
1694
|
-
sandboxSyncInline: this.sandboxSyncInline,
|
|
1695
|
-
deliveryQueueLeaseMs: this.deliveryQueueLeaseMs,
|
|
1696
|
-
deliveryQueueMaxAttempts: this.deliveryQueueMaxAttempts,
|
|
1697
|
-
sandboxSyncMaxAttempts: this.sandboxSyncMaxAttempts,
|
|
1698
|
-
workspaceFilesForDelivery: async (run) => {
|
|
1699
|
-
const workspace = await this.workspaceRuntime.service.resolveForRun(run);
|
|
1700
|
-
return (await this.workspaceRuntime.service.loadManifest(workspace)).manifest.entries;
|
|
1701
|
-
},
|
|
1702
|
-
result: (run, response, waitingForApproval, waitingForInput, waitingForConnection) => this.result(run, response, waitingForApproval, waitingForInput, waitingForConnection),
|
|
1703
|
-
sandboxSessionKey: (run) => this.sandboxSessionKey(run),
|
|
1704
|
-
debugSwallow: (message, fields) => this.debugSwallow(message, fields),
|
|
1705
|
-
emitSpan: (name, startedAt, attributes, options) => this.emitSpan(name, startedAt, attributes, options),
|
|
1706
|
-
runSpanAttributes: (run, extra) => this.runSpanAttributes(run, extra),
|
|
1707
|
-
turnSpanId: (runId) => this.turnSpanId(runId),
|
|
1708
|
-
captureSandboxSnapshot: (run, sandboxSession, stage) => this.captureSandboxSnapshot(run, sandboxSession, stage),
|
|
1709
|
-
loadChannelModule: (channel) => this.loadChannelModule(channel),
|
|
1710
|
-
channelContext: (channel) => this.channelContext(channel)
|
|
1711
|
-
};
|
|
1712
|
-
}
|
|
1713
|
-
async completeRun(run, sandboxHandle, response, channel, turn, conversationId) {
|
|
1714
|
-
return completeRunImpl(this.deliverySendHost(), run, sandboxHandle, response, channel, turn, conversationId);
|
|
1715
|
-
}
|
|
1716
|
-
async latestRunFailureMessage(runId) {
|
|
1717
|
-
return latestRunFailureMessageImpl(this.deliverySendHost(), runId);
|
|
1718
|
-
}
|
|
1719
|
-
sandboxSyncWorkerHost() {
|
|
1720
|
-
return {
|
|
1721
|
-
state: this.state,
|
|
1722
|
-
blob: this.blob,
|
|
1723
|
-
sandbox: this.sandbox,
|
|
1724
|
-
logger: this.logger,
|
|
1725
|
-
env: this.env,
|
|
1726
|
-
now: this.now,
|
|
1727
|
-
sandboxSyncBatchSize: this.sandboxSyncBatchSize,
|
|
1728
|
-
sandboxSyncLeaseMs: this.sandboxSyncLeaseMs,
|
|
1729
|
-
sandboxSnapshotPolicy: this.sandboxSnapshotPolicy,
|
|
1730
|
-
readSandboxTombstonesWithMissingProjectedFiles: (sandbox) => this.readSandboxTombstonesWithMissingProjectedFiles(sandbox),
|
|
1731
|
-
syncMemoryFromSandbox: (run, sandboxSession, tombstones) => this.syncMemoryFromSandbox(run, sandboxSession, tombstones),
|
|
1732
|
-
syncSkillsFromSandbox: (run, sandboxSession, tombstones) => this.syncSkillsFromSandbox(run, sandboxSession, tombstones),
|
|
1733
|
-
syncWorkspace: (run, sandboxSession, syncJob) => this.workspaceRuntime.sync(run, sandboxSession, syncJob),
|
|
1734
|
-
emitSpan: (name, startedAt, attributes, options) => this.emitSpan(name, startedAt, attributes, options),
|
|
1735
|
-
runSpanAttributes: (run, extra) => this.runSpanAttributes(run, extra),
|
|
1736
|
-
turnSpanId: (runId) => this.turnSpanId(runId),
|
|
1737
|
-
warnSwallow: (message, fields) => this.warnSwallow(message, fields),
|
|
1738
|
-
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1739
|
-
sandboxSessionKey: (run) => this.sandboxSessionKey(run),
|
|
1740
|
-
agentEnabled: () => this.agentEnabled()
|
|
1741
|
-
};
|
|
1742
|
-
}
|
|
1743
|
-
async sandboxSyncDiagnostics(options = {}) {
|
|
1744
|
-
return sandboxSyncDiagnosticsImpl(this.sandboxSyncWorkerHost(), options);
|
|
1745
|
-
}
|
|
1746
|
-
async inspectSandboxSyncJob(jobId, options = {}) {
|
|
1747
|
-
return inspectSandboxSyncJobImpl(this.sandboxSyncWorkerHost(), jobId, options);
|
|
1748
|
-
}
|
|
1749
|
-
async retrySandboxSyncJob(jobId, options = {}) {
|
|
1750
|
-
return retrySandboxSyncJobImpl(this.sandboxSyncWorkerHost(), jobId, options);
|
|
1751
|
-
}
|
|
1752
|
-
async runDueSandboxSyncJobs(options = {}) {
|
|
1753
|
-
return runDueSandboxSyncJobsImpl(this.sandboxSyncWorkerHost(), options);
|
|
1754
|
-
}
|
|
1755
|
-
startSandboxSyncWorker(options = {}) {
|
|
1756
|
-
return startSandboxSyncWorkerImpl(this.sandboxSyncWorkerHost(), options);
|
|
1757
|
-
}
|
|
1758
|
-
async captureSandboxSnapshot(run, sandboxSession, stage) {
|
|
1759
|
-
return captureSandboxSnapshotImpl(this.sandboxSyncWorkerHost(), run, sandboxSession, stage);
|
|
1760
|
-
}
|
|
1761
|
-
async disposeSandboxSession(runId, sandboxSession) {
|
|
1762
|
-
return disposeSandboxSessionImpl(this.sandboxSyncWorkerHost(), runId, sandboxSession);
|
|
1763
|
-
}
|
|
1764
|
-
async beginChannelTurn(channelName, turn) {
|
|
1765
|
-
return beginChannelTurnImpl(this.deliverySendHost(), channelName, turn);
|
|
1766
|
-
}
|
|
1767
|
-
async recordChannelTurnStart(start, run, channelName) {
|
|
1768
|
-
return recordChannelTurnStartImpl(this.deliverySendHost(), start, run, channelName);
|
|
1769
|
-
}
|
|
1770
|
-
async stopUnclaimedChannelTurn(start, channelName) {
|
|
1771
|
-
return stopUnclaimedChannelTurnImpl(this.deliverySendHost(), start, channelName);
|
|
1772
|
-
}
|
|
1773
|
-
async stopChannelTurn(lifecycle, run, channelName) {
|
|
1774
|
-
return stopChannelTurnImpl(this.deliverySendHost(), lifecycle, run, channelName);
|
|
1775
|
-
}
|
|
1776
|
-
async sendDelivery(delivery, response, turn) {
|
|
1777
|
-
return sendDeliveryImpl(this.deliverySendHost(), delivery, response, turn);
|
|
1778
|
-
}
|
|
1779
|
-
visibleToolSet(defaultToolNames, activeSkills) {
|
|
1780
|
-
return visibleToolSetImpl(this.toolExecutionHost(), defaultToolNames, activeSkills);
|
|
1781
|
-
}
|
|
1782
|
-
async skillLoadDetails(run, skillName) {
|
|
1783
|
-
return skillLoadDetailsImpl(this.toolExecutionHost(), run, skillName);
|
|
1784
|
-
}
|
|
1785
|
-
async instructionsForRunTarget(run, target, baseInstructions) {
|
|
1786
|
-
return instructionsForRunTargetImpl({ appendEvent: (runId, type, data) => this.state.appendEvent(runId, type, data), skillLoadDetails: (skillName) => this.skillLoadDetails(run, skillName) }, run, target, baseInstructions);
|
|
1787
|
-
}
|
|
1788
|
-
async modelTools(run, activeToolNames, sandboxHandle, connectionRegistry, discoveredConnectionTools = new Map(), options) {
|
|
1789
|
-
return modelToolsImpl(this.toolExecutionHost(), run, activeToolNames, sandboxHandle, connectionRegistry, discoveredConnectionTools, options);
|
|
1790
|
-
}
|
|
1791
|
-
async harnessExecuteTool(call, state) {
|
|
1792
|
-
return harnessExecuteToolImpl(this.toolExecutionHost(), call, state);
|
|
1793
|
-
}
|
|
1794
|
-
createConnectionRegistry(channel, turn) {
|
|
1795
|
-
return createConnectionRegistryImpl(this.toolExecutionHost(), channel, turn);
|
|
1796
|
-
}
|
|
1797
|
-
createConnectionRegistryForRun(run, fallbackChannel, sandboxHandle, selectedConnections) {
|
|
1798
|
-
return createConnectionRegistryForRunImpl(this.toolExecutionHost(), run, fallbackChannel, sandboxHandle, selectedConnections);
|
|
1799
|
-
}
|
|
1800
|
-
createConnectionRegistryForSession(session) {
|
|
1801
|
-
return createConnectionRegistryForSessionImpl(this.toolExecutionHost(), session);
|
|
1802
|
-
}
|
|
1803
|
-
async executeConnectionToolWithRecord(run, registry, toolName, toolCall, input) {
|
|
1804
|
-
return executeConnectionToolWithRecordImpl(this.toolExecutionHost(), run, registry, toolName, toolCall, input);
|
|
1805
|
-
}
|
|
1806
|
-
async loadConnectionDefinition(connection) {
|
|
1807
|
-
const inline = this.dynamicConnectionsCache?.defs.get(connection.name);
|
|
1808
|
-
if (inline)
|
|
1809
|
-
return inline;
|
|
1810
|
-
const module = await this.sourceLoader.load(connection.source);
|
|
1811
|
-
return module.default;
|
|
1812
|
-
}
|
|
1813
|
-
async loadChannelModule(channel) {
|
|
1814
|
-
return loadChannelModuleImpl((source) => this.sourceLoader.load(source), channel);
|
|
1815
|
-
}
|
|
1816
|
-
async channelAttachmentResolver(channel, trustedProvider) {
|
|
1817
|
-
return channelAttachmentResolverImpl({
|
|
1818
|
-
loadChannelModule: (target) => this.loadChannelModule(target),
|
|
1819
|
-
channelContext: (target) => this.channelContext(target),
|
|
1820
|
-
channelProvider: compiledChannelProvider,
|
|
1821
|
-
warnSwallow: (message, fields) => this.warnSwallow(message, fields)
|
|
1822
|
-
}, channel, trustedProvider);
|
|
1823
|
-
}
|
|
1824
|
-
channelContext(channel) {
|
|
1825
|
-
return {
|
|
1826
|
-
channel,
|
|
1827
|
-
agentScope: this.durableAgentScope(),
|
|
1828
|
-
connections: this.connections,
|
|
1829
|
-
env: channelCredentialEnvironment(channel, this.env, this.gatewayCredentials),
|
|
1830
|
-
fetch: this.fetch,
|
|
1831
|
-
state: this.state,
|
|
1832
|
-
blob: this.blob,
|
|
1833
|
-
agent: {
|
|
1834
|
-
start: (turn) => startChannelAgentTurnImpl(this.channelIngressHost(), channel.name, turn),
|
|
1835
|
-
observe: (observation) => observeChannelMessageImpl(this.channelIngressHost(), channel, observation),
|
|
1836
|
-
cancel: (runId) => this.cancelRun(runId)
|
|
1837
|
-
}
|
|
1838
|
-
};
|
|
1839
|
-
}
|
|
1840
|
-
missingRequiredConnections(selected) {
|
|
1841
|
-
const selectedNames = new Set(selected);
|
|
1842
|
-
return this.manifest.connections
|
|
1843
|
-
.filter((connection) => selectedNames.has(connection.name) && connection.required && connection.protocol === "declaration")
|
|
1844
|
-
.map((connection) => connection.name)
|
|
1845
|
-
.filter((name) => this.connections[name] === undefined);
|
|
1846
|
-
}
|
|
1847
|
-
async emitSpan(name, startedAt, attributes, options = {}) {
|
|
1848
|
-
return emitTelemetrySpanImpl(this.telemetry, { name, startedAt, attributes, options, traceIdForRun: (runId) => this.traceIdForRun(runId), randomHex, timestamp });
|
|
1849
|
-
}
|
|
1850
|
-
async initializeInstrumentation() {
|
|
1851
|
-
if (this.instrumentationLoaded || !this.manifest.instrumentation) {
|
|
1852
|
-
this.instrumentationLoaded = true;
|
|
1853
|
-
return;
|
|
1854
|
-
}
|
|
1855
|
-
const instrumentation = this.manifest.instrumentation
|
|
1856
|
-
? await this.sourceLoader.load(this.manifest.instrumentation)
|
|
1857
|
-
: {};
|
|
1858
|
-
const defaultExport = instrumentation.default;
|
|
1859
|
-
const definition = isInstrumentationDefinition(defaultExport) ? defaultExport : undefined;
|
|
1860
|
-
if (definition && !this.hostInstrumentationProvided) {
|
|
1861
|
-
this.instrumentationConfig = {
|
|
1862
|
-
recordInputs: definition.recordInputs ?? false,
|
|
1863
|
-
recordOutputs: definition.recordOutputs ?? false,
|
|
1864
|
-
functionId: definition.functionId ?? definition.serviceName ?? this.agentName(),
|
|
1865
|
-
serviceName: definition.serviceName ?? this.agentName(),
|
|
1866
|
-
contentCapture: normalizeCapturePolicy(definition.captureContent)
|
|
1867
|
-
};
|
|
1868
|
-
}
|
|
1869
|
-
const setupResult = definition?.setup
|
|
1870
|
-
? await definition.setup(instrumentationSetupContext(definition, this.agentName(), this.manifest, this.env, this.gatewayCredentials))
|
|
1871
|
-
: undefined;
|
|
1872
|
-
const setupSink = telemetrySinkFromSetupResult(setupResult);
|
|
1873
|
-
const exportedSink = instrumentation.telemetry ?? definition?.telemetry;
|
|
1874
|
-
const sink = setupSink ?? exportedSink;
|
|
1875
|
-
if (!this.hostTelemetryProvided && isTelemetrySink(sink)) {
|
|
1876
|
-
this.telemetry = sink;
|
|
1877
|
-
}
|
|
1878
|
-
this.instrumentationLoaded = true;
|
|
1879
|
-
}
|
|
1880
|
-
agentName() {
|
|
1881
|
-
return this.manifest.agent.name ?? this.manifest.agent.description ?? `assembly-line-${this.manifest.agentRevision.slice(0, 12)}`;
|
|
1882
|
-
}
|
|
1883
|
-
traceIdForRun(runId) {
|
|
1884
|
-
return createHash("sha256").update(runId).digest("hex").slice(0, 32);
|
|
1885
|
-
}
|
|
1886
|
-
spanIdFor(runId, scope) {
|
|
1887
|
-
return createHash("sha256").update(runId).update(":").update(scope).digest("hex").slice(0, 16);
|
|
1888
|
-
}
|
|
1889
|
-
runSpanAttributes(run, extra = {}) {
|
|
1890
|
-
return runSpanAttributesImpl(this.manifest.agentRevision, this.instrumentationConfig, run, extra);
|
|
1891
|
-
}
|
|
1892
|
-
/** Tool argument/result span attributes, gated on the content-capture policy. */
|
|
1893
|
-
toolContentAttributes(input, output) {
|
|
1894
|
-
const policy = this.instrumentationConfig.contentCapture;
|
|
1895
|
-
if (!policy.includeToolIO)
|
|
1896
|
-
return {};
|
|
1897
|
-
const attributes = { "gen_ai.tool.input": redactTruncateJson(input, policy) };
|
|
1898
|
-
if (output !== undefined)
|
|
1899
|
-
attributes["gen_ai.tool.output"] = redactTruncateJson(output, policy);
|
|
1900
|
-
return attributes;
|
|
1901
|
-
}
|
|
1902
|
-
turnSpanId(runId) {
|
|
1903
|
-
return this.spanIdFor(runId, "turn");
|
|
1904
|
-
}
|
|
1905
|
-
toolExecutionHost() {
|
|
1906
|
-
return {
|
|
1907
|
-
state: this.state,
|
|
1908
|
-
blob: this.blob,
|
|
1909
|
-
env: this.env,
|
|
1910
|
-
fetch: this.fetch,
|
|
1911
|
-
manifest: this.manifest,
|
|
1912
|
-
coreToolPolicy: this.coreToolPolicy,
|
|
1913
|
-
skillStore: this.skillStore,
|
|
1914
|
-
skillBundleIndex: this.skillBundleIndex,
|
|
1915
|
-
memoryStore: this.memoryStore,
|
|
1916
|
-
sandbox: this.sandbox,
|
|
1917
|
-
connections: this.connections,
|
|
1918
|
-
connectionGrantStore: this.connectionGrantStore,
|
|
1919
|
-
credentialBroker: this.credentialBroker,
|
|
1920
|
-
connectionAuthorizationSessionStore: this.connectionAuthorizationSessionStore,
|
|
1921
|
-
connectionCallbackBaseUrl: this.connectionCallbackBaseUrl,
|
|
1922
|
-
toolOutputMaxChars: this.toolOutputMaxChars,
|
|
1923
|
-
authoredToolExecution: this.authoredToolExecution,
|
|
1924
|
-
toolTimeoutMs: this.toolTimeoutMs,
|
|
1925
|
-
sandboxSyncMaxAttempts: this.sandboxSyncMaxAttempts,
|
|
1926
|
-
skillsConfigForRun: (run) => this.skillsConfigForRun(run),
|
|
1927
|
-
schedulesConfig: this.schedulesConfig,
|
|
1928
|
-
connectionsConfig: this.connectionsConfig,
|
|
1929
|
-
surfaceForRun: (run) => surfaceForRun(this.manifest, run),
|
|
1930
|
-
agentStateForRun: (runId) => this.agentStateForRun(runId),
|
|
1931
|
-
reportRunProgress: async (runId, data = {}) => {
|
|
1932
|
-
await this.state.appendEvent(runId, "run.progress_reported", data);
|
|
1933
|
-
},
|
|
1934
|
-
performChannelOperation: (run, operation, input, channelName) => performConfiguredChannelOperation({
|
|
1935
|
-
run,
|
|
1936
|
-
operation,
|
|
1937
|
-
arguments: input,
|
|
1938
|
-
...(channelName ? { channelName } : {}),
|
|
1939
|
-
channels: this.manifest.channels,
|
|
1940
|
-
loadModule: (channel) => this.loadChannelModule(channel),
|
|
1941
|
-
context: (channel) => this.channelContext(channel)
|
|
1942
|
-
}),
|
|
1943
|
-
ensureSkillsSeeded: (run) => this.ensureSkillsSeeded(surfaceForRun(this.manifest, run).path),
|
|
1944
|
-
skillScopeForRun: (run) => this.skillScopeForRun(run),
|
|
1945
|
-
scheduleScopeForRun: (run) => this.scheduleScopeForRun(run),
|
|
1946
|
-
memoryScopeForRun: (run) => this.memoryScopeForRun(run),
|
|
1947
|
-
sandboxSessionKey: (run) => this.sandboxSessionKey(run),
|
|
1948
|
-
mergedConnections: () => this.mergedConnections(),
|
|
1949
|
-
loadConnectionDefinition: (connection) => this.loadConnectionDefinition(connection),
|
|
1950
|
-
resolveToolStub: (run, toolName) => this.resolveToolStub(run, toolName),
|
|
1951
|
-
loadTool: (tool, run) => this.loadTool(tool, run),
|
|
1952
|
-
shouldSandboxAuthoredTool: (tool, run) => this.shouldSandboxAuthoredTool(tool, run),
|
|
1953
|
-
describeSandboxedTool: (tool, sandboxHandle) => this.sandboxAuthoredToolExecutor.describe(tool, sandboxHandle),
|
|
1954
|
-
executeSandboxedTool: (tool, input, context, sandboxHandle, signal) => this.sandboxAuthoredToolExecutor.execute(tool, input, context, sandboxHandle, signal),
|
|
1955
|
-
runSubagent: (parentRunId, subagentName, task) => this.runSubagent(parentRunId, subagentName, task),
|
|
1956
|
-
queueSubagent: (parentRunId, subagentName, task) => this.queueSubagent(parentRunId, subagentName, task),
|
|
1957
|
-
resumeSubagent: (parentRunId, childRunId, subagentName, message) => this.resumeSubagent(parentRunId, childRunId, subagentName, message),
|
|
1958
|
-
listBackgroundWork: (rootRunId, includeTerminal) => this.listBackgroundWork(rootRunId, includeTerminal),
|
|
1959
|
-
getBackgroundWork: (rootRunId, childRunId) => this.getBackgroundWork(rootRunId, childRunId),
|
|
1960
|
-
cancelBackgroundWork: (rootRunId, childRunId) => this.cancelBackgroundWork(rootRunId, childRunId),
|
|
1961
|
-
projectSkillIntoSandbox: (run, sandbox, skillName) => this.projectSkillIntoSandbox(run, sandbox, skillName),
|
|
1962
|
-
hydrateLogicalPathForTool: (run, sandbox, path, options) => this.hydrateLogicalPathForTool(run, sandbox, path, options),
|
|
1963
|
-
recordSandboxTombstone: (run, sandbox, path) => this.recordSandboxTombstone(run, sandbox, path),
|
|
1964
|
-
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1965
|
-
listHydratedCheckpoints: (runId) => this.listHydratedCheckpoints(runId),
|
|
1966
|
-
executeWorkspaceTool: (run, toolName, input, sandboxHandle) => this.workspaceRuntime.executeTool(run, toolName, input, sandboxHandle),
|
|
1967
|
-
emitSpan: (name, startedAt, attributes, options) => this.emitSpan(name, startedAt, attributes, options),
|
|
1968
|
-
runSpanAttributes: (run, extra) => this.runSpanAttributes(run, extra),
|
|
1969
|
-
turnSpanId: (runId) => this.turnSpanId(runId),
|
|
1970
|
-
toolContentAttributes: (input, output) => this.toolContentAttributes(input, output),
|
|
1971
|
-
saveSkill: (input, run) => this.saveSkill(input, surfaceForRun(this.manifest, run).path),
|
|
1972
|
-
listSkills: (run) => this.listSkills(surfaceForRun(this.manifest, run).path),
|
|
1973
|
-
deleteSkill: (name, run) => this.deleteSkill(name, surfaceForRun(this.manifest, run).path),
|
|
1974
|
-
createDynamicSchedule: (input) => this.createDynamicSchedule(input),
|
|
1975
|
-
listDynamicSchedules: (scope) => this.listDynamicSchedules(scope),
|
|
1976
|
-
updateDynamicSchedule: (scope, id, patch) => this.updateDynamicSchedule(scope, id, patch),
|
|
1977
|
-
deleteDynamicSchedule: (scope, id) => this.deleteDynamicSchedule(scope, id),
|
|
1978
|
-
saveConnectionDefinition: (input) => this.saveConnectionDefinition(input),
|
|
1979
|
-
listConnectionDefinitions: (scope) => this.listConnectionDefinitions(scope),
|
|
1980
|
-
deleteConnectionDefinition: (name, scope) => this.deleteConnectionDefinition(name, scope),
|
|
1981
|
-
listResourcesForRun: (run, scope, input) => this.listResourcesForRun(run, scope, input),
|
|
1982
|
-
readResourceForRun: (run, scope, input) => this.readResourceForRun(run, scope, input),
|
|
1983
|
-
projectResourcesForRun: (run, scope, sandbox, input) => this.projectResourcesForRun(run, scope, sandbox, input)
|
|
1984
|
-
};
|
|
1985
|
-
}
|
|
1986
|
-
selectTool(options) {
|
|
1987
|
-
return selectToolImpl(this.toolExecutionHost(), options);
|
|
1988
|
-
}
|
|
1989
|
-
async executeTool(run, tool, input, sandboxHandle, approved, idempotencyKey) {
|
|
1990
|
-
const abortController = new AbortController();
|
|
1991
|
-
const unregisterAbort = this.runProgress.registerAbort(run.id, abortController);
|
|
1992
|
-
try {
|
|
1993
|
-
return await executeToolImpl(this.toolExecutionHost(), run, tool, input, sandboxHandle, approved, idempotencyKey, abortController.signal);
|
|
1994
|
-
}
|
|
1995
|
-
finally {
|
|
1996
|
-
unregisterAbort();
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
async executeToolWithRecord(run, tool, toolCall, input, sandboxHandle, approvedToolCall = false) {
|
|
2000
|
-
const abortController = new AbortController();
|
|
2001
|
-
const unregisterAbort = this.runProgress.registerAbort(run.id, abortController);
|
|
2002
|
-
try {
|
|
2003
|
-
return await executeToolWithRecordImpl(this.toolExecutionHost(), run, tool, toolCall, input, sandboxHandle, approvedToolCall, abortController.signal);
|
|
2004
|
-
}
|
|
2005
|
-
finally {
|
|
2006
|
-
unregisterAbort();
|
|
2007
|
-
}
|
|
2008
|
-
}
|
|
2009
|
-
async durableStep(runId, key, fn, options) {
|
|
2010
|
-
return durableStepImpl(this.toolExecutionHost(), runId, key, fn, options);
|
|
2011
|
-
}
|
|
2012
|
-
wrapSandbox(runId, session) {
|
|
2013
|
-
return wrapSandboxImpl(this.toolExecutionHost(), runId, session);
|
|
2014
|
-
}
|
|
2015
|
-
createMemoryToolApi(run) {
|
|
2016
|
-
return createMemoryToolApiImpl(this.toolExecutionHost(), run);
|
|
2017
|
-
}
|
|
2018
|
-
createResourceToolApi(run, sandboxHandle) {
|
|
2019
|
-
return createResourceToolApiImpl(this.toolExecutionHost(), run, sandboxHandle);
|
|
2020
|
-
}
|
|
2021
|
-
resourceProjectionHost() {
|
|
2022
|
-
return {
|
|
2023
|
-
state: this.state,
|
|
2024
|
-
blob: this.blob,
|
|
2025
|
-
memoryStore: this.memoryStore,
|
|
2026
|
-
skillStore: this.skillStore,
|
|
2027
|
-
skillBundleIndex: this.skillBundleIndex,
|
|
2028
|
-
skillResourceReader: this.skillResourceReader,
|
|
2029
|
-
resourceProjectionPolicy: this.resourceProjectionPolicy,
|
|
2030
|
-
memoryEmbeddingProvider: this.memoryEmbeddingProvider,
|
|
2031
|
-
memoryEmbeddingsEnabled: this.memoryEmbeddingsEnabled,
|
|
2032
|
-
skillScopeForRun: (run) => this.skillScopeForRun(run),
|
|
2033
|
-
durableAgentScope: () => this.durableAgentScope(),
|
|
2034
|
-
surfaceForRun: (run) => surfaceForRun(this.manifest, run)
|
|
2035
|
-
};
|
|
2036
|
-
}
|
|
2037
|
-
async listResourcesForRun(run, scope, input = {}) {
|
|
2038
|
-
return listResourcesForRunImpl(this.resourceProjectionHost(), run, scope, input);
|
|
2039
|
-
}
|
|
2040
|
-
async readResourceForRun(run, scope, input) {
|
|
2041
|
-
return readResourceForRunImpl(this.resourceProjectionHost(), run, scope, input);
|
|
2042
|
-
}
|
|
2043
|
-
async projectResourcesForRun(run, scope, sandbox, input) {
|
|
2044
|
-
return projectResourcesForRunImpl(this.resourceProjectionHost(), run, scope, sandbox, input);
|
|
2045
|
-
}
|
|
2046
|
-
async projectSkillIntoSandbox(run, sandbox, skillName) {
|
|
2047
|
-
return projectSkillIntoSandboxImpl(this.resourceProjectionHost(), run, sandbox, skillName);
|
|
2048
|
-
}
|
|
2049
|
-
async projectLoadedSkillsIntoSandbox(run, sandbox) {
|
|
2050
|
-
return projectLoadedSkillsIntoSandboxImpl(this.resourceProjectionHost(), run, sandbox);
|
|
2051
|
-
}
|
|
2052
|
-
async hydrateLogicalPathForTool(run, sandbox, path, options = {}) {
|
|
2053
|
-
return hydrateLogicalPathForToolImpl(this.resourceProjectionHost(), run, sandbox, path, options);
|
|
2054
|
-
}
|
|
2055
|
-
async recordSandboxTombstone(run, sandbox, path) {
|
|
2056
|
-
return recordSandboxTombstoneImpl(this.resourceProjectionHost(), run, sandbox, path);
|
|
2057
|
-
}
|
|
2058
|
-
async readSandboxTombstonesWithMissingProjectedFiles(sandbox) {
|
|
2059
|
-
return readSandboxTombstonesWithMissingProjectedFilesImpl(this.resourceProjectionHost(), sandbox);
|
|
2060
|
-
}
|
|
2061
|
-
memoryScopeForRun(run) {
|
|
2062
|
-
return memoryScopeForRunImpl(this.resourceProjectionHost(), run);
|
|
2063
|
-
}
|
|
2064
|
-
async backfillMemoryDocumentsFromFileIndexes(options = {}) {
|
|
2065
|
-
return backfillMemoryDocumentsFromFileIndexesImpl(this.resourceProjectionHost(), options);
|
|
2066
|
-
}
|
|
2067
|
-
async runMemoryEmbeddingBackfill(options = {}) {
|
|
2068
|
-
return runMemoryEmbeddingBackfillImpl(this.resourceProjectionHost(), options);
|
|
2069
|
-
}
|
|
2070
|
-
async dispatchHookEvent(runId, event) {
|
|
2071
|
-
await this.eventHandlers?.dispatch(runId, event);
|
|
2072
|
-
if (this.eventHandlers)
|
|
2073
|
-
removeTerminalAgentHookState(runId, event, this.eventHandlers, this.agentHookControllers, this.agentStateHandles);
|
|
2074
|
-
}
|
|
2075
|
-
async handleRuntimeEvent(runId, event) {
|
|
2076
|
-
if (eventRenewsRunProgress(event.type))
|
|
2077
|
-
await this.runProgress.renew(runId);
|
|
2078
|
-
await this.dispatchHookEvent(runId, event);
|
|
2079
|
-
await this.runtimeLearning.handleRuntimeEvent(runId, event.type);
|
|
2080
|
-
}
|
|
2081
|
-
async createAgentHookController(run, options, channel, conversationId, attachments) {
|
|
2082
|
-
const created = await createMainAgentHookControllerImpl(this.agentHookControllerFactoryHost(), run, options, channel, conversationId, attachments);
|
|
2083
|
-
return this.rememberAgentHookController(run.id, created);
|
|
2084
|
-
}
|
|
2085
|
-
async createSubagentHookController(run, subagent, message, conversationId) {
|
|
2086
|
-
const created = await createSubagentHookControllerImpl(this.agentHookControllerFactoryHost(), run, subagent, message, conversationId);
|
|
2087
|
-
return this.rememberAgentHookController(run.id, created);
|
|
2088
|
-
}
|
|
2089
|
-
agentHookControllerFactoryHost() {
|
|
2090
|
-
return {
|
|
2091
|
-
manifest: this.manifest,
|
|
2092
|
-
state: this.state,
|
|
2093
|
-
blob: this.blob,
|
|
2094
|
-
sourceLoader: this.sourceLoader,
|
|
2095
|
-
eventHandlers: this.eventHandlers,
|
|
2096
|
-
logger: this.logger,
|
|
2097
|
-
durableAgentScope: () => this.durableAgentScope(),
|
|
2098
|
-
listSkillNames: async (surfacePath) => (await this.listSkills(surfacePath)).map((skill) => skill.name).sort(),
|
|
2099
|
-
disabledToolsForRun: () => new Set(Object.entries(this.coreToolPolicy).filter(([, mode]) => mode === "disabled").map(([name]) => name)),
|
|
2100
|
-
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
2101
|
-
listCheckpoints: (runId) => this.listHydratedCheckpoints(runId)
|
|
2102
|
-
};
|
|
2103
|
-
}
|
|
2104
|
-
rememberAgentHookController(runId, created) {
|
|
2105
|
-
this.agentStateHandles.set(runId, created.agentState);
|
|
2106
|
-
this.agentHookControllers.set(runId, created.controller);
|
|
2107
|
-
return created.controller;
|
|
2108
|
-
}
|
|
2109
|
-
agentStateForRun(runId) {
|
|
2110
|
-
const handle = this.agentStateHandles.get(runId);
|
|
2111
|
-
if (!handle)
|
|
2112
|
-
throw new Error(`Agent state is unavailable before hook evaluation for run ${runId}.`);
|
|
2113
|
-
return handle;
|
|
2114
|
-
}
|
|
2115
|
-
async ensureAgentHookController(run) {
|
|
2116
|
-
const existing = this.agentHookControllers.get(run.id);
|
|
2117
|
-
if (existing)
|
|
2118
|
-
return existing;
|
|
2119
|
-
return recoverAgentHookController({
|
|
2120
|
-
run,
|
|
2121
|
-
manifest: this.manifest,
|
|
2122
|
-
createMain: (message, metadata, channel, conversationId, attachments) => this.createAgentHookController(run, { message, ...(metadata ? { metadata } : {}) }, channel, conversationId, attachments),
|
|
2123
|
-
createSubagent: (subagent, message, conversationId) => this.createSubagentHookController(run, subagent, message, conversationId)
|
|
2124
|
-
});
|
|
2125
|
-
}
|
|
2126
|
-
async loadTool(tool, run) {
|
|
2127
|
-
const stub = run ? this.resolveToolStub(run, tool.name) : this.toolStubs[tool.name];
|
|
2128
|
-
if (stub) {
|
|
2129
|
-
return {
|
|
2130
|
-
description: tool.description,
|
|
2131
|
-
inputSchema: tool.inputSchema,
|
|
2132
|
-
execute: async (input) => stub(input)
|
|
2133
|
-
};
|
|
2134
|
-
}
|
|
2135
|
-
if (tool.source.path.startsWith("__builtin__")) {
|
|
2136
|
-
const builtIn = builtInToolDefinition(tool.name);
|
|
2137
|
-
if (builtIn)
|
|
2138
|
-
return builtIn;
|
|
2139
|
-
}
|
|
2140
|
-
const module = await this.sourceLoader.load(tool.source);
|
|
2141
|
-
return module.default;
|
|
2142
|
-
}
|
|
2143
|
-
resolveToolStub(run, toolName) {
|
|
2144
|
-
return resolveEvalToolStub(this.evalStubCursors, run, toolName) ?? this.toolStubs[toolName];
|
|
2145
|
-
}
|
|
2146
|
-
shouldSandboxAuthoredTool(tool, run) {
|
|
2147
|
-
if (tool.source.path.startsWith("__builtin__"))
|
|
2148
|
-
return false;
|
|
2149
|
-
if (this.toolStubs[tool.name] || evalRunOptionsForRun(run)?.toolStubs?.[tool.name])
|
|
2150
|
-
return false;
|
|
2151
|
-
return this.authoredToolExecution === "sandbox" || tool.execution === "sandbox";
|
|
2152
|
-
}
|
|
2153
|
-
async result(run, response, waitingForApproval, waitingForInput, waitingForConnection) {
|
|
2154
|
-
return buildRunAgentResult(this.state, run, response, waitingForApproval, waitingForInput, waitingForConnection);
|
|
2155
|
-
}
|
|
2156
|
-
}
|
|
2157
|
-
export async function runLocalAgent(options) { return new AssemblyLineRuntime(options).run(options); }
|
|
2158
|
-
export function runtimeAdapter(options = {}) { return { kind: "runtime", options }; }
|
|
2159
29
|
//# sourceMappingURL=index.js.map
|