@assemblyline-agents/runtime 5.0.9 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -5
- package/dist/a2a-client.d.ts +1 -3
- package/dist/a2a-client.d.ts.map +1 -1
- package/dist/a2a-client.js +1 -4
- package/dist/a2a-client.js.map +1 -1
- package/dist/agent-event-handlers.d.ts +2 -0
- package/dist/agent-event-handlers.d.ts.map +1 -1
- package/dist/agent-event-handlers.js +1 -1
- package/dist/agent-event-handlers.js.map +1 -1
- package/dist/agent-hook-context.d.ts.map +1 -1
- package/dist/agent-hook-context.js +3 -1
- package/dist/agent-hook-context.js.map +1 -1
- package/dist/agent-hook-controller-factory.d.ts +5 -1
- package/dist/agent-hook-controller-factory.d.ts.map +1 -1
- package/dist/agent-hook-controller-factory.js +11 -9
- package/dist/agent-hook-controller-factory.js.map +1 -1
- package/dist/agent-hook-evaluation.d.ts +0 -2
- package/dist/agent-hook-evaluation.d.ts.map +1 -1
- package/dist/agent-hook-evaluation.js +10 -10
- package/dist/agent-hook-evaluation.js.map +1 -1
- package/dist/agent-hook-run-lifecycle.d.ts +1 -2
- package/dist/agent-hook-run-lifecycle.d.ts.map +1 -1
- package/dist/agent-hook-run-lifecycle.js +1 -2
- package/dist/agent-hook-run-lifecycle.js.map +1 -1
- package/dist/agent-surface.d.ts +5 -2
- package/dist/agent-surface.d.ts.map +1 -1
- package/dist/agent-surface.js +11 -3
- package/dist/agent-surface.js.map +1 -1
- package/dist/artifact-selection.js +1 -1
- package/dist/artifact-selection.js.map +1 -1
- package/dist/assembly-line-runtime.d.ts +9 -0
- package/dist/assembly-line-runtime.d.ts.map +1 -0
- package/dist/assembly-line-runtime.js +9 -0
- package/dist/assembly-line-runtime.js.map +1 -0
- package/dist/attachment-download.d.ts +17 -0
- package/dist/attachment-download.d.ts.map +1 -0
- package/dist/attachment-download.js +51 -0
- package/dist/attachment-download.js.map +1 -0
- package/dist/attachments.d.ts +2 -14
- package/dist/attachments.d.ts.map +1 -1
- package/dist/attachments.js +8 -80
- package/dist/attachments.js.map +1 -1
- package/dist/background-review-types.d.ts +2 -0
- package/dist/background-review-types.d.ts.map +1 -1
- package/dist/background-review.d.ts.map +1 -1
- package/dist/background-review.js +13 -0
- package/dist/background-review.js.map +1 -1
- package/dist/background-subagents.d.ts +1 -1
- package/dist/background-subagents.d.ts.map +1 -1
- package/dist/blob-storage.d.ts +12 -0
- package/dist/blob-storage.d.ts.map +1 -0
- package/dist/blob-storage.js +86 -0
- package/dist/blob-storage.js.map +1 -0
- package/dist/builtin-tool-executors.d.ts.map +1 -1
- package/dist/builtin-tool-executors.js +38 -29
- package/dist/builtin-tool-executors.js.map +1 -1
- package/dist/builtin-tools.d.ts +1 -2
- package/dist/builtin-tools.d.ts.map +1 -1
- package/dist/builtin-tools.js +20 -18
- package/dist/builtin-tools.js.map +1 -1
- package/dist/capability-inspection.d.ts +4 -0
- package/dist/capability-inspection.d.ts.map +1 -1
- package/dist/capability-inspection.js +10 -11
- package/dist/capability-inspection.js.map +1 -1
- package/dist/channel-credential-environment.d.ts +1 -1
- package/dist/channel-credential-environment.d.ts.map +1 -1
- package/dist/channel-credential-environment.js +1 -6
- package/dist/channel-credential-environment.js.map +1 -1
- package/dist/channel-ingress.d.ts +1 -2
- package/dist/channel-ingress.d.ts.map +1 -1
- package/dist/channel-ingress.js +2 -2
- package/dist/channel-ingress.js.map +1 -1
- package/dist/channel-operation.d.ts +0 -1
- package/dist/channel-operation.d.ts.map +1 -1
- package/dist/channel-operation.js +1 -2
- package/dist/channel-operation.js.map +1 -1
- package/dist/channel.d.ts +32 -3
- package/dist/channel.d.ts.map +1 -1
- package/dist/connection-assets.d.ts.map +1 -1
- package/dist/connection-assets.js.map +1 -1
- package/dist/connection-authorization-service.d.ts +52 -0
- package/dist/connection-authorization-service.d.ts.map +1 -0
- package/dist/connection-authorization-service.js +417 -0
- package/dist/connection-authorization-service.js.map +1 -0
- package/dist/connection-credential-materialization.d.ts +23 -0
- package/dist/connection-credential-materialization.d.ts.map +1 -0
- package/dist/connection-credential-materialization.js +223 -0
- package/dist/connection-credential-materialization.js.map +1 -0
- package/dist/connection-definition-loader.d.ts +6 -0
- package/dist/connection-definition-loader.d.ts.map +1 -0
- package/dist/connection-definition-loader.js +102 -0
- package/dist/connection-definition-loader.js.map +1 -0
- package/dist/connection-discovery.d.ts +11 -0
- package/dist/connection-discovery.d.ts.map +1 -0
- package/dist/connection-discovery.js +105 -0
- package/dist/connection-discovery.js.map +1 -0
- package/dist/connection-events.d.ts.map +1 -1
- package/dist/connection-events.js.map +1 -1
- package/dist/connection-oauth-client.d.ts +3 -0
- package/dist/connection-oauth-client.d.ts.map +1 -0
- package/dist/connection-oauth-client.js +64 -0
- package/dist/connection-oauth-client.js.map +1 -0
- package/dist/connection-runtime-types.d.ts +78 -0
- package/dist/connection-runtime-types.d.ts.map +1 -0
- package/dist/connection-runtime-types.js +31 -0
- package/dist/connection-runtime-types.js.map +1 -0
- package/dist/connection-search-scope.d.ts +13 -0
- package/dist/connection-search-scope.d.ts.map +1 -0
- package/dist/connection-search-scope.js +24 -0
- package/dist/connection-search-scope.js.map +1 -0
- package/dist/connections.d.ts +18 -167
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +71 -1017
- package/dist/connections.js.map +1 -1
- package/dist/context-policy-util.d.ts +0 -4
- package/dist/context-policy-util.d.ts.map +1 -1
- package/dist/context-policy-util.js +0 -10
- package/dist/context-policy-util.js.map +1 -1
- package/dist/conversation-context.d.ts +1 -1
- package/dist/conversation-context.d.ts.map +1 -1
- package/dist/conversation-context.js +12 -9
- package/dist/conversation-context.js.map +1 -1
- package/dist/default-outbound-route.d.ts +1 -0
- package/dist/default-outbound-route.d.ts.map +1 -1
- package/dist/default-outbound-route.js +1 -1
- package/dist/default-outbound-route.js.map +1 -1
- package/dist/delivery-queue.d.ts +1 -1
- package/dist/delivery-send.d.ts.map +1 -1
- package/dist/delivery-send.js +3 -2
- package/dist/delivery-send.js.map +1 -1
- package/dist/dynamic-schedule-execution.d.ts +4 -0
- package/dist/dynamic-schedule-execution.d.ts.map +1 -0
- package/dist/dynamic-schedule-execution.js +136 -0
- package/dist/dynamic-schedule-execution.js.map +1 -0
- package/dist/dynamic-schedule-runtime.d.ts +11 -20
- package/dist/dynamic-schedule-runtime.d.ts.map +1 -1
- package/dist/dynamic-schedule-runtime.js +27 -39
- package/dist/dynamic-schedule-runtime.js.map +1 -1
- package/dist/evolution-tracker.d.ts +52 -0
- package/dist/evolution-tracker.d.ts.map +1 -0
- package/dist/evolution-tracker.js +179 -0
- package/dist/evolution-tracker.js.map +1 -0
- package/dist/harness-capabilities.d.ts +7 -0
- package/dist/harness-capabilities.d.ts.map +1 -0
- package/dist/harness-capabilities.js +56 -0
- package/dist/harness-capabilities.js.map +1 -0
- package/dist/harness-continuation-persistence.d.ts +6 -0
- package/dist/harness-continuation-persistence.d.ts.map +1 -0
- package/dist/harness-continuation-persistence.js +11 -0
- package/dist/harness-continuation-persistence.js.map +1 -0
- package/dist/harness-execution-context.d.ts +10 -0
- package/dist/harness-execution-context.d.ts.map +1 -0
- package/dist/harness-execution-context.js +193 -0
- package/dist/harness-execution-context.js.map +1 -0
- package/dist/harness-loop-types.d.ts +67 -0
- package/dist/harness-loop-types.d.ts.map +1 -0
- package/dist/harness-loop-types.js +2 -0
- package/dist/harness-loop-types.js.map +1 -0
- package/dist/harness-loop.d.ts +13 -94
- package/dist/harness-loop.d.ts.map +1 -1
- package/dist/harness-loop.js +19 -551
- package/dist/harness-loop.js.map +1 -1
- package/dist/harness-tool-execution.d.ts +30 -0
- package/dist/harness-tool-execution.d.ts.map +1 -0
- package/dist/harness-tool-execution.js +397 -0
- package/dist/harness-tool-execution.js.map +1 -0
- package/dist/harness-transcript-resume.d.ts +18 -0
- package/dist/harness-transcript-resume.d.ts.map +1 -0
- package/dist/harness-transcript-resume.js +102 -0
- package/dist/harness-transcript-resume.js.map +1 -0
- package/dist/harness-turn-execution.d.ts +11 -0
- package/dist/harness-turn-execution.d.ts.map +1 -0
- package/dist/harness-turn-execution.js +157 -0
- package/dist/harness-turn-execution.js.map +1 -0
- package/dist/index.d.ts +10 -499
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2139
- package/dist/index.js.map +1 -1
- package/dist/local-sandbox.d.ts +2 -1
- package/dist/local-sandbox.d.ts.map +1 -1
- package/dist/mcp-client.d.ts +11 -1
- package/dist/mcp-client.d.ts.map +1 -1
- package/dist/mcp-client.js +39 -7
- package/dist/mcp-client.js.map +1 -1
- package/dist/media-processor.d.ts +3 -1
- package/dist/media-processor.d.ts.map +1 -1
- package/dist/media-processor.js +15 -1
- package/dist/media-processor.js.map +1 -1
- package/dist/memory-storage.d.ts +51 -0
- package/dist/memory-storage.d.ts.map +1 -0
- package/dist/memory-storage.js +324 -0
- package/dist/memory-storage.js.map +1 -0
- package/dist/model-credential-stores.d.ts.map +1 -1
- package/dist/model-credential-stores.js +6 -12
- package/dist/model-credential-stores.js.map +1 -1
- package/dist/model-provider-environment.d.ts +4 -0
- package/dist/model-provider-environment.d.ts.map +1 -0
- package/dist/model-provider-environment.js +36 -0
- package/dist/model-provider-environment.js.map +1 -0
- package/dist/plugin-embeddings.d.ts +4 -0
- package/dist/plugin-embeddings.d.ts.map +1 -0
- package/dist/plugin-embeddings.js +75 -0
- package/dist/plugin-embeddings.js.map +1 -0
- package/dist/public-api.d.ts +8 -5
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +6 -4
- package/dist/public-api.js.map +1 -1
- package/dist/relay-mcp-client.js +1 -1
- package/dist/relay-mcp-client.js.map +1 -1
- package/dist/replay-resume-authorization.d.ts +8 -0
- package/dist/replay-resume-authorization.d.ts.map +1 -0
- package/dist/replay-resume-authorization.js +181 -0
- package/dist/replay-resume-authorization.js.map +1 -0
- package/dist/replay-resume-connection.d.ts +6 -0
- package/dist/replay-resume-connection.d.ts.map +1 -0
- package/dist/replay-resume-connection.js +75 -0
- package/dist/replay-resume-connection.js.map +1 -0
- package/dist/replay-resume-controls.d.ts +6 -0
- package/dist/replay-resume-controls.d.ts.map +1 -0
- package/dist/replay-resume-controls.js +157 -0
- package/dist/replay-resume-controls.js.map +1 -0
- package/dist/replay-resume-harness.d.ts +14 -0
- package/dist/replay-resume-harness.d.ts.map +1 -0
- package/dist/replay-resume-harness.js +158 -0
- package/dist/replay-resume-harness.js.map +1 -0
- package/dist/replay-resume-recovery.d.ts +10 -0
- package/dist/replay-resume-recovery.d.ts.map +1 -0
- package/dist/replay-resume-recovery.js +62 -0
- package/dist/replay-resume-recovery.js.map +1 -0
- package/dist/replay-resume-shared.d.ts +16 -0
- package/dist/replay-resume-shared.d.ts.map +1 -0
- package/dist/replay-resume-shared.js +55 -0
- package/dist/replay-resume-shared.js.map +1 -0
- package/dist/replay-resume-types.d.ts +85 -0
- package/dist/replay-resume-types.d.ts.map +1 -0
- package/dist/replay-resume-types.js +2 -0
- package/dist/replay-resume-types.js.map +1 -0
- package/dist/replay-resume.d.ts +7 -119
- package/dist/replay-resume.d.ts.map +1 -1
- package/dist/replay-resume.js +5 -715
- package/dist/replay-resume.js.map +1 -1
- package/dist/resource-projection-util.d.ts +1 -2
- package/dist/resource-projection-util.d.ts.map +1 -1
- package/dist/resource-projection-util.js +2 -11
- package/dist/resource-projection-util.js.map +1 -1
- package/dist/resource-projection.d.ts.map +1 -1
- package/dist/resource-projection.js +67 -22
- package/dist/resource-projection.js.map +1 -1
- package/dist/run-execution-host.d.ts +98 -0
- package/dist/run-execution-host.d.ts.map +1 -0
- package/dist/run-execution-host.js +2 -0
- package/dist/run-execution-host.js.map +1 -0
- package/dist/run-execution.d.ts +6 -0
- package/dist/run-execution.d.ts.map +1 -0
- package/dist/run-execution.js +313 -0
- package/dist/run-execution.js.map +1 -0
- package/dist/run-initialization.d.ts +19 -0
- package/dist/run-initialization.d.ts.map +1 -0
- package/dist/run-initialization.js +171 -0
- package/dist/run-initialization.js.map +1 -0
- package/dist/run-recovery.d.ts +1 -1
- package/dist/run-recovery.js.map +1 -1
- package/dist/runtime-connection-definitions.d.ts +35 -0
- package/dist/runtime-connection-definitions.d.ts.map +1 -0
- package/dist/runtime-connection-definitions.js +97 -0
- package/dist/runtime-connection-definitions.js.map +1 -0
- package/dist/runtime-engine-background.d.ts +64 -0
- package/dist/runtime-engine-background.d.ts.map +1 -0
- package/dist/runtime-engine-background.js +136 -0
- package/dist/runtime-engine-background.js.map +1 -0
- package/dist/runtime-engine-base.d.ts +60 -0
- package/dist/runtime-engine-base.d.ts.map +1 -0
- package/dist/runtime-engine-base.js +192 -0
- package/dist/runtime-engine-base.js.map +1 -0
- package/dist/runtime-engine-capabilities.d.ts +81 -0
- package/dist/runtime-engine-capabilities.d.ts.map +1 -0
- package/dist/runtime-engine-capabilities.js +198 -0
- package/dist/runtime-engine-capabilities.js.map +1 -0
- package/dist/runtime-engine-config.d.ts +77 -0
- package/dist/runtime-engine-config.d.ts.map +1 -0
- package/dist/runtime-engine-config.js +187 -0
- package/dist/runtime-engine-config.js.map +1 -0
- package/dist/runtime-engine-foundation.d.ts +11 -0
- package/dist/runtime-engine-foundation.d.ts.map +1 -0
- package/dist/runtime-engine-foundation.js +121 -0
- package/dist/runtime-engine-foundation.js.map +1 -0
- package/dist/runtime-engine-hooks.d.ts +33 -0
- package/dist/runtime-engine-hooks.d.ts.map +1 -0
- package/dist/runtime-engine-hooks.js +149 -0
- package/dist/runtime-engine-hooks.js.map +1 -0
- package/dist/runtime-engine-integrations.d.ts +16 -0
- package/dist/runtime-engine-integrations.d.ts.map +1 -0
- package/dist/runtime-engine-integrations.js +177 -0
- package/dist/runtime-engine-integrations.js.map +1 -0
- package/dist/runtime-engine-operations.d.ts +87 -0
- package/dist/runtime-engine-operations.d.ts.map +1 -0
- package/dist/runtime-engine-operations.js +204 -0
- package/dist/runtime-engine-operations.js.map +1 -0
- package/dist/runtime-engine-resources.d.ts +18 -0
- package/dist/runtime-engine-resources.d.ts.map +1 -0
- package/dist/runtime-engine-resources.js +49 -0
- package/dist/runtime-engine-resources.js.map +1 -0
- package/dist/runtime-engine-run.d.ts +70 -0
- package/dist/runtime-engine-run.d.ts.map +1 -0
- package/dist/runtime-engine-run.js +202 -0
- package/dist/runtime-engine-run.js.map +1 -0
- package/dist/runtime-engine-scheduling.d.ts +22 -0
- package/dist/runtime-engine-scheduling.d.ts.map +1 -0
- package/dist/runtime-engine-scheduling.js +45 -0
- package/dist/runtime-engine-scheduling.js.map +1 -0
- package/dist/runtime-engine-tools.d.ts +8 -0
- package/dist/runtime-engine-tools.d.ts.map +1 -0
- package/dist/runtime-engine-tools.js +80 -0
- package/dist/runtime-engine-tools.js.map +1 -0
- package/dist/runtime-evolution.d.ts +17 -0
- package/dist/runtime-evolution.d.ts.map +1 -0
- package/dist/runtime-evolution.js +51 -0
- package/dist/runtime-evolution.js.map +1 -0
- package/dist/runtime-learning.d.ts +4 -6
- package/dist/runtime-learning.d.ts.map +1 -1
- package/dist/runtime-learning.js +109 -99
- package/dist/runtime-learning.js.map +1 -1
- package/dist/runtime-types.d.ts +21 -7
- package/dist/runtime-types.d.ts.map +1 -1
- package/dist/runtime-util.d.ts +4 -3
- package/dist/runtime-util.d.ts.map +1 -1
- package/dist/runtime-util.js +0 -7
- package/dist/runtime-util.js.map +1 -1
- package/dist/sandbox-fs.d.ts +2 -7
- package/dist/sandbox-fs.d.ts.map +1 -1
- package/dist/sandbox-fs.js +6 -37
- package/dist/sandbox-fs.js.map +1 -1
- package/dist/sandbox-handle.d.ts +1 -3
- package/dist/sandbox-handle.d.ts.map +1 -1
- package/dist/sandbox-handle.js +2 -5
- package/dist/sandbox-handle.js.map +1 -1
- package/dist/sandbox-state-sync.d.ts +2 -0
- package/dist/sandbox-state-sync.d.ts.map +1 -1
- package/dist/sandbox-state-sync.js +26 -2
- package/dist/sandbox-state-sync.js.map +1 -1
- package/dist/sandbox-tool-bridge.js +2 -3
- package/dist/sandbox-tool-bridge.js.map +1 -1
- package/dist/schedule-execution.d.ts +4 -4
- package/dist/schedule-execution.d.ts.map +1 -1
- package/dist/schedule-execution.js +45 -440
- package/dist/schedule-execution.js.map +1 -1
- package/dist/schedule-trigger-context.d.ts +18 -0
- package/dist/schedule-trigger-context.d.ts.map +1 -0
- package/dist/schedule-trigger-context.js +276 -0
- package/dist/schedule-trigger-context.js.map +1 -0
- package/dist/scheduler.d.ts +1 -14
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +1 -37
- package/dist/scheduler.js.map +1 -1
- package/dist/security.d.ts +0 -4
- package/dist/security.d.ts.map +1 -1
- package/dist/security.js +0 -22
- package/dist/security.js.map +1 -1
- package/dist/self-improvement.d.ts +5 -21
- package/dist/self-improvement.d.ts.map +1 -1
- package/dist/self-improvement.js +10 -40
- package/dist/self-improvement.js.map +1 -1
- package/dist/source-loader.d.ts +0 -3
- package/dist/source-loader.d.ts.map +1 -1
- package/dist/source-loader.js +1 -10
- package/dist/source-loader.js.map +1 -1
- package/dist/state/conversation-state.d.ts +117 -0
- package/dist/state/conversation-state.d.ts.map +1 -0
- package/dist/state/conversation-state.js +2 -0
- package/dist/state/conversation-state.js.map +1 -0
- package/dist/state/run-state.d.ts +129 -0
- package/dist/state/run-state.d.ts.map +1 -0
- package/dist/state/run-state.js +3 -0
- package/dist/state/run-state.js.map +1 -0
- package/dist/state/sandbox-memory-state.d.ts +159 -0
- package/dist/state/sandbox-memory-state.d.ts.map +1 -0
- package/dist/state/sandbox-memory-state.js +2 -0
- package/dist/state/sandbox-memory-state.js.map +1 -0
- package/dist/state/store-contracts.d.ts +329 -0
- package/dist/state/store-contracts.d.ts.map +1 -0
- package/dist/state/store-contracts.js +26 -0
- package/dist/state/store-contracts.js.map +1 -0
- package/dist/state/usage-state.d.ts +111 -0
- package/dist/state/usage-state.d.ts.map +1 -0
- package/dist/state/usage-state.js +2 -0
- package/dist/state/usage-state.js.map +1 -0
- package/dist/state/workspace-state.d.ts +126 -0
- package/dist/state/workspace-state.d.ts.map +1 -0
- package/dist/state/workspace-state.js +16 -0
- package/dist/state/workspace-state.js.map +1 -0
- package/dist/state-stores.d.ts +3 -15
- package/dist/state-stores.d.ts.map +1 -1
- package/dist/state-stores.js +36 -82
- package/dist/state-stores.js.map +1 -1
- package/dist/state.d.ts +7 -1075
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +7 -88
- package/dist/state.js.map +1 -1
- package/dist/storage.d.ts +4 -64
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +5 -408
- package/dist/storage.js.map +1 -1
- package/dist/subagent-execution.d.ts +1 -2
- package/dist/subagent-execution.d.ts.map +1 -1
- package/dist/subagent-execution.js +2 -26
- package/dist/subagent-execution.js.map +1 -1
- package/dist/subagent-handoff.d.ts +13 -0
- package/dist/subagent-handoff.d.ts.map +1 -1
- package/dist/subagent-handoff.js +74 -9
- package/dist/subagent-handoff.js.map +1 -1
- package/dist/tool-apis.d.ts +2 -2
- package/dist/tool-apis.d.ts.map +1 -1
- package/dist/tool-apis.js +26 -14
- package/dist/tool-apis.js.map +1 -1
- package/dist/tool-execution-host.d.ts +121 -0
- package/dist/tool-execution-host.d.ts.map +1 -0
- package/dist/tool-execution-host.js +2 -0
- package/dist/tool-execution-host.js.map +1 -0
- package/dist/tool-execution.d.ts +5 -141
- package/dist/tool-execution.d.ts.map +1 -1
- package/dist/tool-execution.js +6 -395
- package/dist/tool-execution.js.map +1 -1
- package/dist/usage-reconciliation-support.d.ts +20 -0
- package/dist/usage-reconciliation-support.d.ts.map +1 -0
- package/dist/usage-reconciliation-support.js +95 -0
- package/dist/usage-reconciliation-support.js.map +1 -0
- package/dist/usage-reconciliation.d.ts +14 -35
- package/dist/usage-reconciliation.d.ts.map +1 -1
- package/dist/usage-reconciliation.js +17 -394
- package/dist/usage-reconciliation.js.map +1 -1
- package/dist/workspace-paths.d.ts +3 -0
- package/dist/workspace-paths.d.ts.map +1 -0
- package/dist/workspace-paths.js +13 -0
- package/dist/workspace-paths.js.map +1 -0
- package/dist/workspace-service.d.ts +0 -1
- package/dist/workspace-service.d.ts.map +1 -1
- package/dist/workspace-service.js +1 -4
- package/dist/workspace-service.js.map +1 -1
- package/package.json +3 -3
- package/dist/run-timeline.d.ts +0 -11
- package/dist/run-timeline.d.ts.map +0 -1
- package/dist/run-timeline.js +0 -2
- package/dist/run-timeline.js.map +0 -1
- package/dist/trusted-attachments.d.ts +0 -20
- package/dist/trusted-attachments.d.ts.map +0 -1
- package/dist/trusted-attachments.js +0 -276
- package/dist/trusted-attachments.js.map +0 -1
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeTriggerPrepareResult, triggerPrepareContext } from "./channel-http-util.js";
|
|
2
2
|
import { RunCapacityError } from "./concurrency.js";
|
|
3
|
-
import { dueTimeForSchedule,
|
|
4
|
-
import { buildDefaultContextBundle } from "./sandbox-fs.js";
|
|
3
|
+
import { dueTimeForSchedule, timestamp } from "./runtime-util.js";
|
|
5
4
|
import { isJsonObject, safeJson } from "./json-util.js";
|
|
6
5
|
import { failRun } from "./run-outcome.js";
|
|
7
6
|
import { loadDefaultOutboundRoute } from "./default-outbound-route.js";
|
|
8
7
|
import { isRuntimeSettingsStore } from "./state.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { audienceFromMetadata, audienceFromRun, normalizeAgentAudience } from "./audience.js";
|
|
8
|
+
import { defaultUserPrincipal } from "./principals.js";
|
|
9
|
+
import { normalizeAgentAudience } from "./audience.js";
|
|
12
10
|
import { matchingEventAutomations } from "./automation-event-match.js";
|
|
11
|
+
import { surfaceForPath } from "./agent-surface.js";
|
|
12
|
+
import { createTriggerHandlerContext, loadTriggerHandler, resolvedScheduleAudience, trustedScheduleAudience } from "./schedule-trigger-context.js";
|
|
13
|
+
import { runDueDynamicSchedules } from "./dynamic-schedule-execution.js";
|
|
14
|
+
export { normalizeScheduleTriggerDefinitionImpl } from "./schedule-trigger-context.js";
|
|
13
15
|
export async function registerManifestSchedulesImpl(host) {
|
|
14
16
|
const records = [];
|
|
15
17
|
for (const schedule of manifestScheduleRegistrations(host)) {
|
|
@@ -20,14 +22,13 @@ export async function registerManifestSchedulesImpl(host) {
|
|
|
20
22
|
...(schedule.timezone ? { timezone: schedule.timezone } : {}),
|
|
21
23
|
metadata: {
|
|
22
24
|
agentRevision: host.manifest.agentRevision,
|
|
23
|
-
message: schedule.message ?? compiledSchedule(host, schedule.schedule)?.message ?? null
|
|
24
|
-
trigger: schedule.trigger ? safeJson(schedule.trigger) : null
|
|
25
|
+
message: schedule.message ?? compiledSchedule(host, schedule.schedule)?.message ?? null
|
|
25
26
|
}
|
|
26
27
|
}));
|
|
27
28
|
}
|
|
28
29
|
return records;
|
|
29
30
|
}
|
|
30
|
-
export async function
|
|
31
|
+
export async function runDueAutomationsImpl(host, options = {}) {
|
|
31
32
|
host.boot();
|
|
32
33
|
if (!(await host.agentEnabled()))
|
|
33
34
|
return [];
|
|
@@ -61,7 +62,7 @@ export async function runDueSchedulesImpl(host, options = {}) {
|
|
|
61
62
|
// tick without burning the key (the next sweep retries). Triggered
|
|
62
63
|
// schedules use an existingRun and bypass admission (enter()).
|
|
63
64
|
let admission;
|
|
64
|
-
if (!schedule.
|
|
65
|
+
if (!schedule.lifecycle) {
|
|
65
66
|
const admitted = host.admitRunOrReject();
|
|
66
67
|
if (admitted instanceof RunCapacityError) {
|
|
67
68
|
results.push({ schedule: schedule.schedule, dueAt: dueAtIso, idempotencyKey, status: "skipped", error: "run capacity saturated" });
|
|
@@ -104,7 +105,7 @@ export async function runDueSchedulesImpl(host, options = {}) {
|
|
|
104
105
|
results.push({ schedule: schedule.schedule, dueAt: dueAtIso, idempotencyKey, status: "failed", error: message });
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
results.push(...(await runDueDynamicSchedules(host, now)));
|
|
108
|
+
results.push(...(await runDueDynamicSchedules(host, now, (schedule) => runScheduleExecution(host, schedule))));
|
|
108
109
|
return results;
|
|
109
110
|
}
|
|
110
111
|
export async function dispatchAutomationEventImpl(host, event) {
|
|
@@ -213,6 +214,7 @@ function eventAutomationExecution(host, automation, event, idempotencyKey) {
|
|
|
213
214
|
channel: "automation",
|
|
214
215
|
...(automation.lifecycle ? { lifecycle: automation.lifecycle } : {}),
|
|
215
216
|
...(automation.target ? { target: automation.target } : {}),
|
|
217
|
+
...(automation.surface ? { surface: automation.surface } : {}),
|
|
216
218
|
automationEvent: event,
|
|
217
219
|
metadata: {
|
|
218
220
|
automation: automation.automation,
|
|
@@ -249,9 +251,9 @@ async function manifestScheduleExecution(host, schedule, dueAtIso, idempotencyKe
|
|
|
249
251
|
idempotencyKey,
|
|
250
252
|
message: scheduleMessage(host, schedule.schedule),
|
|
251
253
|
channel: "schedule",
|
|
252
|
-
...(schedule.trigger ? { trigger: schedule.trigger } : {}),
|
|
253
254
|
...(schedule.lifecycle ? { lifecycle: schedule.lifecycle } : {}),
|
|
254
255
|
...(schedule.target ? { target: schedule.target } : {}),
|
|
256
|
+
...(schedule.surface ? { surface: schedule.surface } : {}),
|
|
255
257
|
metadata: {
|
|
256
258
|
...compiledMetadata,
|
|
257
259
|
schedule: schedule.schedule,
|
|
@@ -260,13 +262,16 @@ async function manifestScheduleExecution(host, schedule, dueAtIso, idempotencyKe
|
|
|
260
262
|
},
|
|
261
263
|
definition: safeJson(compiled ?? schedule)
|
|
262
264
|
};
|
|
263
|
-
|
|
265
|
+
if (compiledMetadata.delivery === "silent")
|
|
266
|
+
return execution;
|
|
267
|
+
const surface = surfaceForPath(host.manifest, schedule.surface);
|
|
268
|
+
const channel = surface.defaultOutboundChannel?.trim();
|
|
264
269
|
if (!channel)
|
|
265
270
|
return execution;
|
|
266
271
|
if (!isRuntimeSettingsStore(host.state)) {
|
|
267
272
|
throw new Error(`Default outbound channel "${channel}" requires durable runtime settings.`);
|
|
268
273
|
}
|
|
269
|
-
const saved = await loadDefaultOutboundRoute(host.state, host.skillScope(), channel);
|
|
274
|
+
const saved = await loadDefaultOutboundRoute(host.state, host.skillScope(surface.path), channel);
|
|
270
275
|
if (!saved) {
|
|
271
276
|
throw new Error(`Default outbound channel "${channel}" has no saved route. Send the agent a message on that channel first.`);
|
|
272
277
|
}
|
|
@@ -341,6 +346,8 @@ function scheduleRunOptions(host, schedule, message, metadata, overrides = {}) {
|
|
|
341
346
|
options.tenantId = schedule.tenantId;
|
|
342
347
|
if (schedule.delivery)
|
|
343
348
|
options.delivery = schedule.delivery;
|
|
349
|
+
if (schedule.surface)
|
|
350
|
+
options.agentSurface = schedule.surface;
|
|
344
351
|
if (schedule.conversationId) {
|
|
345
352
|
options.turn = {
|
|
346
353
|
eventId: schedule.idempotencyKey,
|
|
@@ -379,6 +386,7 @@ async function runTriggeredSchedule(host, schedule) {
|
|
|
379
386
|
status: "created",
|
|
380
387
|
input: {
|
|
381
388
|
message: schedule.message,
|
|
389
|
+
agentSurface: schedule.surface ?? "root",
|
|
382
390
|
channel: schedule.channel,
|
|
383
391
|
eventId: schedule.idempotencyKey,
|
|
384
392
|
conversationId: schedule.conversationId ?? null,
|
|
@@ -589,395 +597,6 @@ async function runTriggeredSchedule(host, schedule) {
|
|
|
589
597
|
...(finalizeResult.error ? { error: finalizeResult.error } : {})
|
|
590
598
|
};
|
|
591
599
|
}
|
|
592
|
-
function resolvedScheduleAudience(host, schedule) {
|
|
593
|
-
if (schedule.audience)
|
|
594
|
-
return schedule.audience;
|
|
595
|
-
if (host.manifest.agent.audienceIsolation !== true)
|
|
596
|
-
return trustedScheduleAudience(schedule);
|
|
597
|
-
if (schedule.conversationId)
|
|
598
|
-
return { private: false, conversationId: schedule.conversationId };
|
|
599
|
-
if (schedule.principal)
|
|
600
|
-
return { private: true, principal: schedule.principal };
|
|
601
|
-
return { private: true };
|
|
602
|
-
}
|
|
603
|
-
/** Without audienceIsolation, schedule fallbacks are trusted like every other run. */
|
|
604
|
-
function trustedScheduleAudience(schedule) {
|
|
605
|
-
return {
|
|
606
|
-
private: true,
|
|
607
|
-
...(schedule.principal ? { principal: schedule.principal } : {}),
|
|
608
|
-
...(schedule.conversationId ? { conversationId: schedule.conversationId } : {})
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
async function loadTriggerHandler(host, handler) {
|
|
612
|
-
const module = await host.sourceLoader.load(handler.source);
|
|
613
|
-
const candidates = [module.default, module[handler.name], ...Object.values(module)];
|
|
614
|
-
const definition = candidates.find(isTriggerHandlerDefinition);
|
|
615
|
-
if (!definition)
|
|
616
|
-
throw new Error(`Trigger handler ${handler.name} did not export a trigger handler definition.`);
|
|
617
|
-
return definition;
|
|
618
|
-
}
|
|
619
|
-
export function normalizeScheduleTriggerDefinitionImpl(host, value) {
|
|
620
|
-
if (!isJsonObject(value))
|
|
621
|
-
throw new Error("Schedule trigger must be an object.");
|
|
622
|
-
const handler = stringValue(value.handler);
|
|
623
|
-
if (!handler)
|
|
624
|
-
throw new Error("Schedule trigger requires handler.");
|
|
625
|
-
if (!automationLifecycleSources(host).some((candidate) => candidate.name === handler)) {
|
|
626
|
-
throw new Error(`Unknown trigger handler: ${handler}`);
|
|
627
|
-
}
|
|
628
|
-
const trigger = { handler };
|
|
629
|
-
if (value.target !== undefined && value.target !== null) {
|
|
630
|
-
trigger.target = normalizeTriggerTarget(value.target);
|
|
631
|
-
}
|
|
632
|
-
if (value.metadata !== undefined) {
|
|
633
|
-
if (!isJsonObject(value.metadata))
|
|
634
|
-
throw new Error("Schedule trigger metadata must be an object.");
|
|
635
|
-
trigger.metadata = value.metadata;
|
|
636
|
-
}
|
|
637
|
-
return trigger;
|
|
638
|
-
}
|
|
639
|
-
function normalizeTriggerTarget(value) {
|
|
640
|
-
if (!isJsonObject(value))
|
|
641
|
-
throw new Error("Schedule trigger target must be an object.");
|
|
642
|
-
const type = stringValue(value.type);
|
|
643
|
-
if (type === "skill") {
|
|
644
|
-
const name = stringValue(value.name);
|
|
645
|
-
if (!name)
|
|
646
|
-
throw new Error("Skill trigger targets require name.");
|
|
647
|
-
return { type, name, ...(isJsonObject(value.metadata) ? { metadata: value.metadata } : {}) };
|
|
648
|
-
}
|
|
649
|
-
if (type === "agent") {
|
|
650
|
-
if (value.model !== undefined) {
|
|
651
|
-
throw new Error("Automation targets cannot select a model; use useModel() in agent.ts setup().");
|
|
652
|
-
}
|
|
653
|
-
const name = stringValue(value.name);
|
|
654
|
-
const target = { type };
|
|
655
|
-
if (name)
|
|
656
|
-
target.name = name;
|
|
657
|
-
if (isJsonObject(value.metadata))
|
|
658
|
-
target.metadata = value.metadata;
|
|
659
|
-
return target;
|
|
660
|
-
}
|
|
661
|
-
if (type === "playbook") {
|
|
662
|
-
const name = stringValue(value.name);
|
|
663
|
-
if (!name)
|
|
664
|
-
throw new Error("Playbook trigger targets require name.");
|
|
665
|
-
return { type, name, ...(isJsonObject(value.metadata) ? { metadata: value.metadata } : {}) };
|
|
666
|
-
}
|
|
667
|
-
throw new Error(`Unsupported schedule trigger target type: ${type || "missing"}`);
|
|
668
|
-
}
|
|
669
|
-
function createTriggerHandlerContext(host, run, schedule, trigger, prepare) {
|
|
670
|
-
const sandboxHandle = host.createSandboxHandle(() => run, () => undefined, () => buildDefaultContextBundle(host.manifest, {
|
|
671
|
-
message: typeof run.input.message === "string" ? run.input.message : schedule.message,
|
|
672
|
-
channel: schedule.channel
|
|
673
|
-
}));
|
|
674
|
-
return {
|
|
675
|
-
runId: run.id,
|
|
676
|
-
agentRevision: host.manifest.agentRevision,
|
|
677
|
-
...(principalFromRun(run) ? { principal: principalFromRun(run) } : {}),
|
|
678
|
-
...(initiatorFromRun(run) ? { initiator: initiatorFromRun(run) } : {}),
|
|
679
|
-
audience: audienceFromRun(run),
|
|
680
|
-
trigger,
|
|
681
|
-
state: createTriggerStateApi(host, run),
|
|
682
|
-
memory: host.createMemoryToolApi(run),
|
|
683
|
-
resources: createTriggerResourceApi(host, run, sandboxHandle),
|
|
684
|
-
blob: {
|
|
685
|
-
put: async (key, value, contentTypeOrOptions) => host.blob.put(key, value, contentTypeOrOptions),
|
|
686
|
-
get: async (key) => host.blob.get(key)
|
|
687
|
-
},
|
|
688
|
-
schedule: {
|
|
689
|
-
definition: schedule.definition,
|
|
690
|
-
run: {
|
|
691
|
-
scheduleId: schedule.resultSchedule,
|
|
692
|
-
runId: run.id,
|
|
693
|
-
runAt: trigger.dueAt ?? trigger.event?.occurredAt ?? schedule.dueAtIso,
|
|
694
|
-
idempotencyKey: trigger.idempotencyKey
|
|
695
|
-
}
|
|
696
|
-
},
|
|
697
|
-
env: host.env,
|
|
698
|
-
fetch: host.fetch,
|
|
699
|
-
prepare,
|
|
700
|
-
emit: async (eventType, data = {}) => {
|
|
701
|
-
await host.state.appendEvent(run.id, eventType, data);
|
|
702
|
-
},
|
|
703
|
-
idempotencyKey: (scope) => `${trigger.idempotencyKey}:${scope}`,
|
|
704
|
-
step: (key, fn, options) => host.durableStep(run.id, key, fn, options)
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
function createTriggerStateApi(host, run) {
|
|
708
|
-
const runtime = host;
|
|
709
|
-
return {
|
|
710
|
-
async upsertRoutineRun(input) {
|
|
711
|
-
const current = await runtime.state.getRun(run.id) ?? run;
|
|
712
|
-
const metadata = isJsonObject(current.input.metadata) ? current.input.metadata : {};
|
|
713
|
-
const existing = isJsonObject(metadata.routineRun) ? metadata.routineRun : {};
|
|
714
|
-
const record = normalizeRoutineRunRecord({
|
|
715
|
-
existing,
|
|
716
|
-
runId: run.id,
|
|
717
|
-
kind: input.kind,
|
|
718
|
-
triggerKey: input.triggerKey,
|
|
719
|
-
status: input.status ?? (stringValue(existing.status) || current.status),
|
|
720
|
-
metadata: input.metadata ?? (isJsonObject(existing.metadata) ? existing.metadata : {})
|
|
721
|
-
});
|
|
722
|
-
await runtime.state.updateRun(run.id, {
|
|
723
|
-
input: {
|
|
724
|
-
...current.input,
|
|
725
|
-
metadata: {
|
|
726
|
-
...metadata,
|
|
727
|
-
routineRun: safeJson(record)
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
});
|
|
731
|
-
await runtime.state.appendEvent(run.id, "routine.run_upserted", safeJson(record));
|
|
732
|
-
return record;
|
|
733
|
-
},
|
|
734
|
-
async completeRoutineRun(input) {
|
|
735
|
-
const current = await runtime.state.getRun(run.id) ?? run;
|
|
736
|
-
const metadata = isJsonObject(current.input.metadata) ? current.input.metadata : {};
|
|
737
|
-
const existing = isJsonObject(metadata.routineRun) ? metadata.routineRun : {};
|
|
738
|
-
const completeInput = {
|
|
739
|
-
existing,
|
|
740
|
-
runId: input.runId || run.id,
|
|
741
|
-
kind: stringValue(existing.kind) || "routine",
|
|
742
|
-
triggerKey: stringValue(existing.triggerKey) || "",
|
|
743
|
-
status: input.status,
|
|
744
|
-
metadata: input.metadata ?? (isJsonObject(existing.metadata) ? existing.metadata : {})
|
|
745
|
-
};
|
|
746
|
-
if (input.summary)
|
|
747
|
-
completeInput.summary = input.summary;
|
|
748
|
-
const record = normalizeRoutineRunRecord(completeInput);
|
|
749
|
-
await runtime.state.updateRun(run.id, {
|
|
750
|
-
input: {
|
|
751
|
-
...current.input,
|
|
752
|
-
metadata: {
|
|
753
|
-
...metadata,
|
|
754
|
-
routineRun: safeJson(record)
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
await runtime.state.appendEvent(run.id, "routine.run_completed", safeJson(record));
|
|
759
|
-
return record;
|
|
760
|
-
}
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
function createTriggerResourceApi(host, run, sandboxHandle) {
|
|
764
|
-
const base = host.createResourceToolApi(run, sandboxHandle);
|
|
765
|
-
return {
|
|
766
|
-
...base,
|
|
767
|
-
collect: async (input = {}) => collectTriggerResources(host, run, input)
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
async function collectTriggerResources(host, run, input = {}) {
|
|
771
|
-
const requested = new Set(input.sources ?? ["memory", "history", "connections"]);
|
|
772
|
-
const limit = positiveLimit(input.limit, 50);
|
|
773
|
-
const resources = [];
|
|
774
|
-
const sections = [];
|
|
775
|
-
if (requested.has("memory")) {
|
|
776
|
-
const documents = await host.memoryStore.list(host.memoryScopeForRun(run), { limit });
|
|
777
|
-
resources.push(...documents.map((document) => memoryDocumentSummary(document)));
|
|
778
|
-
if (documents.length > 0) {
|
|
779
|
-
sections.push([
|
|
780
|
-
"# Memory",
|
|
781
|
-
...documents.map((document) => [
|
|
782
|
-
`## ${document.path}`,
|
|
783
|
-
memoryBodyText(document)
|
|
784
|
-
].join("\n"))
|
|
785
|
-
].join("\n\n"));
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
if (requested.has("history")) {
|
|
789
|
-
const conversationId = typeof run.input.conversationId === "string" ? run.input.conversationId : undefined;
|
|
790
|
-
const messages = conversationId ? await host.state.listRecentMessages(conversationId, limit) : [];
|
|
791
|
-
resources.push(...messages.map((message) => ({
|
|
792
|
-
kind: "history",
|
|
793
|
-
role: message.role,
|
|
794
|
-
createdAt: message.createdAt,
|
|
795
|
-
runId: message.runId ?? null
|
|
796
|
-
})));
|
|
797
|
-
if (messages.length > 0) {
|
|
798
|
-
sections.push([
|
|
799
|
-
"# History",
|
|
800
|
-
...messages.map((message) => {
|
|
801
|
-
const text = typeof message.content.text === "string" ? message.content.text : JSON.stringify(message.content);
|
|
802
|
-
return `- ${message.role}: ${text}`;
|
|
803
|
-
})
|
|
804
|
-
].join("\n"));
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
if (requested.has("connections")) {
|
|
808
|
-
const connections = host.mergedConnections().slice(0, limit);
|
|
809
|
-
resources.push(...connections.map((connection) => ({
|
|
810
|
-
kind: "connection",
|
|
811
|
-
name: connection.name,
|
|
812
|
-
protocol: connection.protocol,
|
|
813
|
-
provider: connection.provider,
|
|
814
|
-
required: connection.required
|
|
815
|
-
})));
|
|
816
|
-
if (connections.length > 0) {
|
|
817
|
-
sections.push([
|
|
818
|
-
"# Connections",
|
|
819
|
-
...connections.map((connection) => `- ${connection.name} (${connection.protocol}, ${connection.provider})`)
|
|
820
|
-
].join("\n"));
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
if (requested.has("skills")) {
|
|
824
|
-
const skills = (await host.skillStore.list(host.skillScope())).filter((skill) => !skill.pending && !skill.archived).slice(0, limit);
|
|
825
|
-
resources.push(...skills.map((skill) => ({
|
|
826
|
-
kind: "skill",
|
|
827
|
-
name: skill.name,
|
|
828
|
-
origin: skill.origin,
|
|
829
|
-
updatedAt: skill.updatedAt
|
|
830
|
-
})));
|
|
831
|
-
if (skills.length > 0) {
|
|
832
|
-
sections.push([
|
|
833
|
-
"# Skills",
|
|
834
|
-
...skills.map((skill) => `- ${skill.name} (${skill.origin})`)
|
|
835
|
-
].join("\n"));
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
await host.state.appendEvent(run.id, "trigger.resources_collected", {
|
|
839
|
-
sources: [...requested],
|
|
840
|
-
count: resources.length,
|
|
841
|
-
since: input.since ?? null
|
|
842
|
-
});
|
|
843
|
-
return {
|
|
844
|
-
markdown: sections.join("\n\n").trim(),
|
|
845
|
-
resources
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
|
-
* Dispatch application-managed dynamic schedules: atomically lease due rows
|
|
850
|
-
* and start one durable run per row. At-least-once; tasks should be idempotent.
|
|
851
|
-
*/
|
|
852
|
-
async function runDueDynamicSchedules(host, now) {
|
|
853
|
-
if (!host.schedulesConfig.dynamic)
|
|
854
|
-
return [];
|
|
855
|
-
const results = [];
|
|
856
|
-
const due = await host.scheduleStore.claimDue({ now, limit: 25, leaseForMs: 5 * 60_000 });
|
|
857
|
-
for (const job of due) {
|
|
858
|
-
const dueAtIso = job.nextRunAt;
|
|
859
|
-
const idempotencyKey = `dynamic:${job.id}:${dueAtIso}`;
|
|
860
|
-
const leaseToken = job.leaseToken ?? "";
|
|
861
|
-
try {
|
|
862
|
-
// assembly_line_schedule_runs rows reference assembly_line_schedules; dynamic jobs
|
|
863
|
-
// live in the schedule store, so upsert a parent row before recording runs.
|
|
864
|
-
await host.state.registerSchedule({
|
|
865
|
-
id: `dynamic:${job.id}`,
|
|
866
|
-
name: `dynamic:${job.id}`,
|
|
867
|
-
cron: job.cron ?? (job.everyMinutes ? `@every ${job.everyMinutes}m` : `@at ${dueAtIso}`),
|
|
868
|
-
...(job.timezone ? { timezone: job.timezone } : {}),
|
|
869
|
-
metadata: { source: "dynamic", scope: job.scope }
|
|
870
|
-
});
|
|
871
|
-
const schedule = dynamicScheduleExecution(host, job, dueAtIso, idempotencyKey);
|
|
872
|
-
const result = await runScheduleExecution(host, schedule);
|
|
873
|
-
await host.scheduleStore.complete(job.id, leaseToken, { ranAt: dueAtIso });
|
|
874
|
-
if (result.runId) {
|
|
875
|
-
await host.state.appendEvent(result.runId, "schedule.dynamic_dispatched", {
|
|
876
|
-
dynamicScheduleId: job.id,
|
|
877
|
-
dueAt: dueAtIso,
|
|
878
|
-
trigger: job.trigger ? safeJson(job.trigger) : null
|
|
879
|
-
});
|
|
880
|
-
}
|
|
881
|
-
results.push(result);
|
|
882
|
-
}
|
|
883
|
-
catch (error) {
|
|
884
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
885
|
-
try {
|
|
886
|
-
await host.state.recordScheduleRun({
|
|
887
|
-
scheduleId: `dynamic:${job.id}`,
|
|
888
|
-
runAt: dueAtIso,
|
|
889
|
-
idempotencyKey,
|
|
890
|
-
status: "failed"
|
|
891
|
-
});
|
|
892
|
-
}
|
|
893
|
-
catch (recordError) {
|
|
894
|
-
host.logger.warn("dynamic schedule failure bookkeeping failed", {
|
|
895
|
-
dynamicScheduleId: job.id,
|
|
896
|
-
error: recordError instanceof Error ? recordError.message : String(recordError)
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
// Escalating backoff on the failure streak (5min base, 2x, capped 6h);
|
|
900
|
-
// the store disables the schedule atomically once the streak hits the
|
|
901
|
-
// cap so a poison schedule cannot burn a model run every cycle forever.
|
|
902
|
-
const failureStreak = (job.consecutiveFailures ?? 0) + 1;
|
|
903
|
-
const retryDelayMs = Math.min(300_000 * 2 ** (failureStreak - 1), 6 * 3_600_000);
|
|
904
|
-
const disabled = failureStreak >= host.scheduleMaxConsecutiveFailures;
|
|
905
|
-
await host.scheduleStore.release(job.id, leaseToken, new Date(now.getTime() + retryDelayMs), {
|
|
906
|
-
maxConsecutiveFailures: host.scheduleMaxConsecutiveFailures
|
|
907
|
-
});
|
|
908
|
-
if (disabled) {
|
|
909
|
-
host.logger.warn("dynamic schedule disabled after consecutive failures", {
|
|
910
|
-
dynamicScheduleId: job.id,
|
|
911
|
-
scope: job.scope,
|
|
912
|
-
consecutiveFailures: failureStreak,
|
|
913
|
-
error: message
|
|
914
|
-
});
|
|
915
|
-
if (isRuntimeSettingsStore(host.state)) {
|
|
916
|
-
await host.state.appendRuntimeControlEvent(job.scope, "schedule.disabled_after_failures", {
|
|
917
|
-
dynamicScheduleId: job.id,
|
|
918
|
-
consecutiveFailures: failureStreak,
|
|
919
|
-
error: message
|
|
920
|
-
}).catch(() => undefined);
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
results.push({ schedule: `dynamic:${job.id}`, dueAt: dueAtIso, idempotencyKey, status: "failed", error: message });
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
return results;
|
|
927
|
-
}
|
|
928
|
-
function dynamicScheduleExecution(host, job, dueAtIso, idempotencyKey) {
|
|
929
|
-
const target = isJsonObject(job.target) ? job.target : {};
|
|
930
|
-
const targetConversation = typeof target.conversationId === "string" ? target.conversationId : undefined;
|
|
931
|
-
const targetProject = typeof target.projectId === "string" ? target.projectId : undefined;
|
|
932
|
-
const conversationId = job.conversationId ?? targetConversation;
|
|
933
|
-
const projectId = job.projectId ?? targetProject;
|
|
934
|
-
const delivery = isJsonObject(job.target) ? job.target : undefined;
|
|
935
|
-
const principal = job.principal ?? defaultUserPrincipal(job.userId, job.channel);
|
|
936
|
-
const initiator = job.initiator ?? principal;
|
|
937
|
-
const audience = audienceFromMetadata(job.metadata)
|
|
938
|
-
?? (host.manifest.agent.audienceIsolation !== true
|
|
939
|
-
? trustedScheduleAudience({ ...(principal ? { principal } : {}), ...(conversationId ? { conversationId } : {}) })
|
|
940
|
-
: principal
|
|
941
|
-
? { private: true, principal }
|
|
942
|
-
: conversationId
|
|
943
|
-
? { private: false, conversationId }
|
|
944
|
-
: { private: true });
|
|
945
|
-
const message = dynamicScheduleMessage(job);
|
|
946
|
-
const trigger = job.trigger ? normalizeScheduleTriggerDefinitionImpl(host, job.trigger) : undefined;
|
|
947
|
-
const metadata = {
|
|
948
|
-
...(job.metadata ?? {}),
|
|
949
|
-
dynamicScheduleId: job.id,
|
|
950
|
-
scope: job.scope,
|
|
951
|
-
source: "dynamic",
|
|
952
|
-
schedule: `dynamic:${job.id}`,
|
|
953
|
-
dueAt: dueAtIso,
|
|
954
|
-
idempotencyKey
|
|
955
|
-
};
|
|
956
|
-
if (job.target)
|
|
957
|
-
metadata.target = safeJson(job.target);
|
|
958
|
-
const definition = { ...job };
|
|
959
|
-
if (trigger)
|
|
960
|
-
definition.trigger = trigger;
|
|
961
|
-
return {
|
|
962
|
-
source: "dynamic",
|
|
963
|
-
scheduleId: job.id,
|
|
964
|
-
resultSchedule: `dynamic:${job.id}`,
|
|
965
|
-
dueAtIso,
|
|
966
|
-
idempotencyKey,
|
|
967
|
-
message,
|
|
968
|
-
channel: job.channel,
|
|
969
|
-
...(trigger ? { trigger } : {}),
|
|
970
|
-
metadata,
|
|
971
|
-
definition: safeJson(definition),
|
|
972
|
-
...(job.userId ? { userId: job.userId } : {}),
|
|
973
|
-
...(principal ? { principal } : {}),
|
|
974
|
-
...(initiator ? { initiator } : {}),
|
|
975
|
-
audience,
|
|
976
|
-
...(conversationId ? { conversationId } : {}),
|
|
977
|
-
...(projectId ? { projectId } : {}),
|
|
978
|
-
...(delivery ? { delivery } : {})
|
|
979
|
-
};
|
|
980
|
-
}
|
|
981
600
|
export async function startSchedulerPollingLoopImpl(host) {
|
|
982
601
|
if (!hasScheduledWork(host))
|
|
983
602
|
return undefined;
|
|
@@ -988,7 +607,7 @@ export async function startSchedulerPollingLoopImpl(host) {
|
|
|
988
607
|
return [];
|
|
989
608
|
inFlight = true;
|
|
990
609
|
try {
|
|
991
|
-
return await
|
|
610
|
+
return await runDueAutomationsImpl(host, { now: host.now(), lookbackMs: host.schedulerTickMs });
|
|
992
611
|
}
|
|
993
612
|
catch (error) {
|
|
994
613
|
// The interval invokes tick as a floating promise; a throw here would
|
|
@@ -1020,8 +639,7 @@ function hasScheduledWork(host) {
|
|
|
1020
639
|
return manifestScheduleRegistrations(host).length > 0;
|
|
1021
640
|
}
|
|
1022
641
|
function compiledSchedule(host, name) {
|
|
1023
|
-
return host.manifest.automations
|
|
1024
|
-
?? host.manifest.schedules.find((schedule) => schedule.name === name);
|
|
642
|
+
return host.manifest.automations.find((automation) => automation.name === name);
|
|
1025
643
|
}
|
|
1026
644
|
function scheduleMessage(host, name) {
|
|
1027
645
|
const registration = manifestScheduleRegistrations(host).find((schedule) => schedule.schedule === name);
|
|
@@ -1030,52 +648,39 @@ function scheduleMessage(host, name) {
|
|
|
1030
648
|
}
|
|
1031
649
|
function resolveAutomationLifecycle(host, schedule) {
|
|
1032
650
|
const lifecycle = schedule.lifecycle;
|
|
1033
|
-
if (lifecycle?.kind === "inline") {
|
|
1034
|
-
const compiled = host.manifest.automationLifecycles?.find((candidate) => candidate.automation === schedule.resultSchedule) ?? host.manifest.automations?.find((candidate) => candidate.name === schedule.resultSchedule);
|
|
1035
|
-
return compiled ? { name: schedule.resultSchedule, source: compiled.source } : undefined;
|
|
1036
|
-
}
|
|
1037
651
|
const handlerName = lifecycle?.handler ?? schedule.trigger?.handler;
|
|
1038
652
|
return handlerName
|
|
1039
653
|
? automationLifecycleSources(host).find((candidate) => candidate.name === handlerName)
|
|
1040
654
|
: undefined;
|
|
1041
655
|
}
|
|
1042
656
|
function automationLifecycleSources(host) {
|
|
1043
|
-
const inline = (host.manifest.automationLifecycles ?? []).map((lifecycle) => ({
|
|
1044
|
-
name: lifecycle.automation,
|
|
1045
|
-
source: lifecycle.source
|
|
1046
|
-
}));
|
|
1047
|
-
const legacy = [
|
|
1048
|
-
...(host.manifest.automationHandlers ?? []),
|
|
1049
|
-
...(host.manifest.triggerHandlers ?? [])
|
|
1050
|
-
];
|
|
1051
657
|
const sources = new Map();
|
|
1052
|
-
for (const candidate of
|
|
658
|
+
for (const candidate of host.manifest.automationHandlers) {
|
|
1053
659
|
if (!sources.has(candidate.name))
|
|
1054
660
|
sources.set(candidate.name, candidate);
|
|
1055
661
|
}
|
|
1056
662
|
return [...sources.values()];
|
|
1057
663
|
}
|
|
1058
664
|
function manifestScheduleRegistrations(host) {
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
}
|
|
1079
|
-
return host.manifest.scheduleRegistrations ?? [];
|
|
665
|
+
return host.manifest.automationRegistrations.flatMap((automation) => {
|
|
666
|
+
if (automation.trigger.type !== "schedule")
|
|
667
|
+
return [];
|
|
668
|
+
const registration = {
|
|
669
|
+
schedule: automation.automation,
|
|
670
|
+
cron: automation.trigger.cron,
|
|
671
|
+
idempotencyKey: automation.idempotencyKey
|
|
672
|
+
};
|
|
673
|
+
if (automation.trigger.timezone)
|
|
674
|
+
registration.timezone = automation.trigger.timezone;
|
|
675
|
+
if (automation.message)
|
|
676
|
+
registration.message = automation.message;
|
|
677
|
+
if (automation.target)
|
|
678
|
+
registration.target = automation.target;
|
|
679
|
+
if (automation.lifecycle)
|
|
680
|
+
registration.lifecycle = automation.lifecycle;
|
|
681
|
+
if (automation.surface)
|
|
682
|
+
registration.surface = automation.surface;
|
|
683
|
+
return [registration];
|
|
684
|
+
});
|
|
1080
685
|
}
|
|
1081
686
|
//# sourceMappingURL=schedule-execution.js.map
|