@zhin.js/agent 1.1.13 → 1.1.14
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 +40 -20
- package/lib/ai-event-bus.d.ts +1 -1
- package/lib/ai-hook-handlers.d.ts +1 -1
- package/lib/assistant/config.d.ts +3 -17
- package/lib/assistant/config.d.ts.map +1 -1
- package/lib/assistant/config.js +1 -8
- package/lib/assistant/config.js.map +1 -1
- package/lib/assistant/index.d.ts +6 -9
- package/lib/assistant/index.d.ts.map +1 -1
- package/lib/assistant/index.js +4 -6
- package/lib/assistant/index.js.map +1 -1
- package/lib/assistant/job-engine.d.ts +0 -4
- package/lib/assistant/job-engine.d.ts.map +1 -1
- package/lib/assistant/job-engine.js +0 -2
- package/lib/assistant/job-engine.js.map +1 -1
- package/lib/assistant/job-store.d.ts +1 -8
- package/lib/assistant/job-store.d.ts.map +1 -1
- package/lib/assistant/job-store.js +3 -9
- package/lib/assistant/job-store.js.map +1 -1
- package/lib/assistant/job-worker.d.ts +2 -3
- package/lib/assistant/job-worker.d.ts.map +1 -1
- package/lib/assistant/job-worker.js +15 -25
- package/lib/assistant/job-worker.js.map +1 -1
- package/lib/assistant/runtime-contract.d.ts +22 -0
- package/lib/assistant/runtime-contract.d.ts.map +1 -0
- package/lib/assistant/runtime-contract.js +2 -0
- package/lib/assistant/runtime-contract.js.map +1 -0
- package/lib/assistant/types.d.ts +0 -10
- package/lib/assistant/types.d.ts.map +1 -1
- package/lib/assistant/types.js +0 -4
- package/lib/assistant/types.js.map +1 -1
- package/lib/authoring/bridge.d.ts +1 -1
- package/lib/authoring/index.d.ts +0 -4
- package/lib/authoring/index.d.ts.map +1 -1
- package/lib/authoring/index.js +0 -2
- package/lib/authoring/index.js.map +1 -1
- package/lib/authoring/types.d.ts +3 -39
- package/lib/authoring/types.d.ts.map +1 -1
- package/lib/authoring/types.js.map +1 -1
- package/lib/builtin/bash-tool.d.ts.map +1 -1
- package/lib/builtin/bash-tool.js +15 -2
- package/lib/builtin/bash-tool.js.map +1 -1
- package/lib/builtin/five-agent/index.d.ts +0 -1
- package/lib/builtin/five-agent/index.d.ts.map +1 -1
- package/lib/builtin/five-agent/index.js +0 -1
- package/lib/builtin/five-agent/index.js.map +1 -1
- package/lib/builtin/five-agent/role-capability-policy.d.ts +1 -1
- package/lib/builtin/five-agent/role-capability-policy.d.ts.map +1 -1
- package/lib/builtin/five-agent/role-capability-policy.js +1 -1
- package/lib/builtin/five-agent/role-capability-policy.js.map +1 -1
- package/lib/builtin/spawn-task-tool.d.ts +1 -1
- package/lib/builtin/spawn-task-tool.d.ts.map +1 -1
- package/lib/builtin/spawn-task-tool.js +4 -100
- package/lib/builtin/spawn-task-tool.js.map +1 -1
- package/lib/builtin-tools.d.ts +0 -2
- package/lib/builtin-tools.d.ts.map +1 -1
- package/lib/builtin-tools.js +0 -6
- package/lib/builtin-tools.js.map +1 -1
- package/lib/common-adapter-tools.d.ts +1 -1
- package/lib/config/agent-interfaces.d.ts +2 -1
- package/lib/config/agent-interfaces.d.ts.map +1 -1
- package/lib/config/index.d.ts +3 -3
- package/lib/config/index.d.ts.map +1 -1
- package/lib/config/index.js +2 -2
- package/lib/config/index.js.map +1 -1
- package/lib/config/keyword-triggers.d.ts +0 -1
- package/lib/config/keyword-triggers.d.ts.map +1 -1
- package/lib/config/keyword-triggers.js +0 -1
- package/lib/config/keyword-triggers.js.map +1 -1
- package/lib/config/normalize-ai-config.d.ts.map +1 -1
- package/lib/config/normalize-ai-config.js +9 -0
- package/lib/config/normalize-ai-config.js.map +1 -1
- package/lib/config/validate-ai-config.d.ts +1 -0
- package/lib/config/validate-ai-config.d.ts.map +1 -1
- package/lib/config/validate-ai-config.js +179 -0
- package/lib/config/validate-ai-config.js.map +1 -1
- package/lib/config/zhin-agent-config.d.ts +0 -3
- package/lib/config/zhin-agent-config.d.ts.map +1 -1
- package/lib/config/zhin-agent-constants.d.ts +0 -3
- package/lib/config/zhin-agent-constants.d.ts.map +1 -1
- package/lib/config/zhin-agent-constants.js +0 -14
- package/lib/config/zhin-agent-constants.js.map +1 -1
- package/lib/config/zhin-agent-defaults.d.ts.map +1 -1
- package/lib/config/zhin-agent-defaults.js +0 -3
- package/lib/config/zhin-agent-defaults.js.map +1 -1
- package/lib/config/zhin-agent-dependencies.d.ts +4 -5
- package/lib/config/zhin-agent-dependencies.d.ts.map +1 -1
- package/lib/context/context-system.d.ts +2 -1
- package/lib/context/context-system.d.ts.map +1 -1
- package/lib/context/context-system.js +1 -0
- package/lib/context/context-system.js.map +1 -1
- package/lib/context/context-tail-limit.d.ts +2 -2
- package/lib/context/context-tail-limit.d.ts.map +1 -1
- package/lib/context/context-tail-limit.js +2 -3
- package/lib/context/context-tail-limit.js.map +1 -1
- package/lib/context/im-turn-context-adapter.d.ts +1 -2
- package/lib/context/im-turn-context-adapter.d.ts.map +1 -1
- package/lib/context/im-turn-context-adapter.js +1 -5
- package/lib/context/im-turn-context-adapter.js.map +1 -1
- package/lib/context/turn-envelope.d.ts +1 -1
- package/lib/context/turn-envelope.d.ts.map +1 -1
- package/lib/context/turn-envelope.js +4 -0
- package/lib/context/turn-envelope.js.map +1 -1
- package/lib/context/turn-user-message.d.ts +1 -1
- package/lib/context/turn-user-message.d.ts.map +1 -1
- package/lib/context/turn-user-message.js +3 -3
- package/lib/context/turn-user-message.js.map +1 -1
- package/lib/core/agent-core-run.d.ts.map +1 -1
- package/lib/core/agent-core-run.js +36 -12
- package/lib/core/agent-core-run.js.map +1 -1
- package/lib/core/agent-loop-standalone.d.ts +1 -1
- package/lib/core/agent-loop-standalone.js +13 -6
- package/lib/core/agent-loop-standalone.js.map +1 -1
- package/lib/core/tool-execution-authority.d.ts +2 -2
- package/lib/core/tool-execution-authority.d.ts.map +1 -1
- package/lib/data-governance/data-governance.d.ts +198 -0
- package/lib/data-governance/data-governance.d.ts.map +1 -0
- package/lib/data-governance/data-governance.js +660 -0
- package/lib/data-governance/data-governance.js.map +1 -0
- package/lib/data-governance/database-payload-lifecycle-repository.d.ts +68 -0
- package/lib/data-governance/database-payload-lifecycle-repository.d.ts.map +1 -0
- package/lib/data-governance/database-payload-lifecycle-repository.js +226 -0
- package/lib/data-governance/database-payload-lifecycle-repository.js.map +1 -0
- package/lib/data-governance/disclosure-manifest.d.ts +110 -0
- package/lib/data-governance/disclosure-manifest.d.ts.map +1 -0
- package/lib/data-governance/disclosure-manifest.js +264 -0
- package/lib/data-governance/disclosure-manifest.js.map +1 -0
- package/lib/data-governance/encrypted-database-payload-vault.d.ts +107 -0
- package/lib/data-governance/encrypted-database-payload-vault.d.ts.map +1 -0
- package/lib/data-governance/encrypted-database-payload-vault.js +236 -0
- package/lib/data-governance/encrypted-database-payload-vault.js.map +1 -0
- package/lib/data-governance/encrypted-file-payload-vault.d.ts +117 -0
- package/lib/data-governance/encrypted-file-payload-vault.d.ts.map +1 -0
- package/lib/data-governance/encrypted-file-payload-vault.js +507 -0
- package/lib/data-governance/encrypted-file-payload-vault.js.map +1 -0
- package/lib/data-governance/file-payload-lifecycle-repository.d.ts +19 -0
- package/lib/data-governance/file-payload-lifecycle-repository.d.ts.map +1 -0
- package/lib/data-governance/file-payload-lifecycle-repository.js +194 -0
- package/lib/data-governance/file-payload-lifecycle-repository.js.map +1 -0
- package/lib/data-governance/governance-authority-repository.d.ts +148 -0
- package/lib/data-governance/governance-authority-repository.d.ts.map +1 -0
- package/lib/data-governance/governance-authority-repository.js +439 -0
- package/lib/data-governance/governance-authority-repository.js.map +1 -0
- package/lib/data-governance/governed-payload-write-saga.d.ts +126 -0
- package/lib/data-governance/governed-payload-write-saga.d.ts.map +1 -0
- package/lib/data-governance/governed-payload-write-saga.js +471 -0
- package/lib/data-governance/governed-payload-write-saga.js.map +1 -0
- package/lib/data-governance/payload-hold-overdue-projection.d.ts +57 -0
- package/lib/data-governance/payload-hold-overdue-projection.d.ts.map +1 -0
- package/lib/data-governance/payload-hold-overdue-projection.js +80 -0
- package/lib/data-governance/payload-hold-overdue-projection.js.map +1 -0
- package/lib/data-governance/payload-lifecycle.d.ts +359 -0
- package/lib/data-governance/payload-lifecycle.d.ts.map +1 -0
- package/lib/data-governance/payload-lifecycle.js +930 -0
- package/lib/data-governance/payload-lifecycle.js.map +1 -0
- package/lib/data-governance/payload-vault-storage-handoff.d.ts +255 -0
- package/lib/data-governance/payload-vault-storage-handoff.d.ts.map +1 -0
- package/lib/data-governance/payload-vault-storage-handoff.js +471 -0
- package/lib/data-governance/payload-vault-storage-handoff.js.map +1 -0
- package/lib/defaults/hooks.d.ts +2 -2
- package/lib/defaults/hooks.d.ts.map +1 -1
- package/lib/defaults/hooks.js +2 -2
- package/lib/defaults/hooks.js.map +1 -1
- package/lib/defaults/subagents.d.ts +2 -2
- package/lib/defaults/subagents.d.ts.map +1 -1
- package/lib/defaults/subagents.js +2 -2
- package/lib/defaults/subagents.js.map +1 -1
- package/lib/defaults/tools.d.ts +1 -2
- package/lib/defaults/tools.js +2 -2
- package/lib/defaults/tools.js.map +1 -1
- package/lib/discovery/agent-surface-info.d.ts +0 -2
- package/lib/discovery/agent-surface-info.d.ts.map +1 -1
- package/lib/discovery/agent-surface-info.js +0 -5
- package/lib/discovery/agent-surface-info.js.map +1 -1
- package/lib/discovery/agent-surface.d.ts.map +1 -1
- package/lib/discovery/agent-surface.js +0 -39
- package/lib/discovery/agent-surface.js.map +1 -1
- package/lib/event/agent-stream-hooks.d.ts +1 -1
- package/lib/event/hook-stream-sink.d.ts +1 -1
- package/lib/event/publish-agent-stream.d.ts +3 -3
- package/lib/event/publish-agent-stream.d.ts.map +1 -1
- package/lib/event/publish-agent-stream.js +1 -1
- package/lib/event/publish-agent-stream.js.map +1 -1
- package/lib/event/session-events.d.ts +1 -1
- package/lib/event/turn-event.d.ts +22 -2
- package/lib/event/turn-event.d.ts.map +1 -1
- package/lib/event/turn-event.js.map +1 -1
- package/lib/event/turn-to-agent-stream.js +6 -0
- package/lib/event/turn-to-agent-stream.js.map +1 -1
- package/lib/features/agent-feature.d.ts +1 -1
- package/lib/features/mcp-feature.d.ts +1 -1
- package/lib/index.d.ts +99 -33
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +94 -21
- package/lib/index.js.map +1 -1
- package/lib/ingress/capability-ingress.d.ts +5 -5
- package/lib/ingress/capability-ingress.d.ts.map +1 -1
- package/lib/ingress/capability-ingress.js +26 -26
- package/lib/ingress/capability-ingress.js.map +1 -1
- package/lib/init/activate-ai-database-storage.d.ts +5 -3
- package/lib/init/activate-ai-database-storage.d.ts.map +1 -1
- package/lib/init/activate-ai-database-storage.js +23 -32
- package/lib/init/activate-ai-database-storage.js.map +1 -1
- package/lib/init/configure-zhin-agent.d.ts +1 -1
- package/lib/init/configure-zhin-agent.d.ts.map +1 -1
- package/lib/init/configure-zhin-agent.js +3 -5
- package/lib/init/configure-zhin-agent.js.map +1 -1
- package/lib/init/define-ai-database-models.d.ts.map +1 -1
- package/lib/init/define-ai-database-models.js +21 -5
- package/lib/init/define-ai-database-models.js.map +1 -1
- package/lib/init/dispose-zhin-agent.d.ts +1 -3
- package/lib/init/dispose-zhin-agent.d.ts.map +1 -1
- package/lib/init/dispose-zhin-agent.js +0 -2
- package/lib/init/dispose-zhin-agent.js.map +1 -1
- package/lib/init/introspection-collectors.d.ts +1 -1
- package/lib/init/introspection-collectors.d.ts.map +1 -1
- package/lib/init/introspection-collectors.js +13 -14
- package/lib/init/introspection-collectors.js.map +1 -1
- package/lib/internal/agent-host.d.ts +5 -8
- package/lib/internal/agent-host.d.ts.map +1 -1
- package/lib/internal/host-types.d.ts +4 -0
- package/lib/internal/host-types.d.ts.map +1 -1
- package/lib/journal/persistent-turn-journal.d.ts +5 -1
- package/lib/journal/persistent-turn-journal.d.ts.map +1 -1
- package/lib/journal/persistent-turn-journal.js +11 -1
- package/lib/journal/persistent-turn-journal.js.map +1 -1
- package/lib/mcp-client/bridge.d.ts +1 -1
- package/lib/mcp-client/connection.d.ts +1 -1
- package/lib/mcp-client/index.d.ts +1 -1
- package/lib/media/media-normalize.d.ts +9 -5
- package/lib/media/media-normalize.d.ts.map +1 -1
- package/lib/media/media-normalize.js +125 -69
- package/lib/media/media-normalize.js.map +1 -1
- package/lib/media/media-publisher.d.ts.map +1 -1
- package/lib/media/media-publisher.js +48 -3
- package/lib/media/media-publisher.js.map +1 -1
- package/lib/media/vision-capability.js +1 -1
- package/lib/media/vision-capability.js.map +1 -1
- package/lib/memory/index.d.ts +1 -1
- package/lib/memory/index.d.ts.map +1 -1
- package/lib/plugin-ai-hook-bus.d.ts +1 -1
- package/lib/plugin-runtime/agent-host-port.d.ts +66 -4
- package/lib/plugin-runtime/agent-host-port.d.ts.map +1 -1
- package/lib/plugin-runtime/agent-host-port.js.map +1 -1
- package/lib/plugin-runtime/agent-runtime.d.ts +3 -0
- package/lib/plugin-runtime/agent-runtime.d.ts.map +1 -1
- package/lib/plugin-runtime/agent-runtime.js +73 -3
- package/lib/plugin-runtime/agent-runtime.js.map +1 -1
- package/lib/plugin-runtime/agent-trace-runtime.d.ts +37 -0
- package/lib/plugin-runtime/agent-trace-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/agent-trace-runtime.js +150 -0
- package/lib/plugin-runtime/agent-trace-runtime.js.map +1 -0
- package/lib/plugin-runtime/capability-tools.js +2 -2
- package/lib/plugin-runtime/capability-tools.js.map +1 -1
- package/lib/plugin-runtime/database-overlay-pack-promotion-repository.d.ts +70 -0
- package/lib/plugin-runtime/database-overlay-pack-promotion-repository.d.ts.map +1 -0
- package/lib/plugin-runtime/database-overlay-pack-promotion-repository.js +203 -0
- package/lib/plugin-runtime/database-overlay-pack-promotion-repository.js.map +1 -0
- package/lib/plugin-runtime/deferred-capability-plan.d.ts +26 -0
- package/lib/plugin-runtime/deferred-capability-plan.d.ts.map +1 -1
- package/lib/plugin-runtime/deferred-capability-plan.js +98 -4
- package/lib/plugin-runtime/deferred-capability-plan.js.map +1 -1
- package/lib/plugin-runtime/full-agent-turn-engine.js +48 -5
- package/lib/plugin-runtime/full-agent-turn-engine.js.map +1 -1
- package/lib/plugin-runtime/host-mcp-projection.d.ts +1 -1
- package/lib/plugin-runtime/index.d.ts +66 -0
- package/lib/plugin-runtime/index.d.ts.map +1 -1
- package/lib/plugin-runtime/index.js +65 -0
- package/lib/plugin-runtime/index.js.map +1 -1
- package/lib/plugin-runtime/native-interaction-tools.js +1 -1
- package/lib/plugin-runtime/native-interaction-tools.js.map +1 -1
- package/lib/plugin-runtime/native-semantic-memory-tools.d.ts +17 -0
- package/lib/plugin-runtime/native-semantic-memory-tools.d.ts.map +1 -0
- package/lib/plugin-runtime/native-semantic-memory-tools.js +169 -0
- package/lib/plugin-runtime/native-semantic-memory-tools.js.map +1 -0
- package/lib/plugin-runtime/turn-intent-resolver.d.ts +20 -0
- package/lib/plugin-runtime/turn-intent-resolver.d.ts.map +1 -0
- package/lib/plugin-runtime/turn-intent-resolver.js +8 -0
- package/lib/plugin-runtime/turn-intent-resolver.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-authority.d.ts +5 -0
- package/lib/plugin-runtime/workroom-acceptance-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-authority.js +14 -0
- package/lib/plugin-runtime/workroom-acceptance-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-fact-providers.d.ts +233 -0
- package/lib/plugin-runtime/workroom-acceptance-fact-providers.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-fact-providers.js +517 -0
- package/lib/plugin-runtime/workroom-acceptance-fact-providers.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-internal-providers.d.ts +139 -0
- package/lib/plugin-runtime/workroom-acceptance-internal-providers.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-internal-providers.js +430 -0
- package/lib/plugin-runtime/workroom-acceptance-internal-providers.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-policy.d.ts +4 -0
- package/lib/plugin-runtime/workroom-acceptance-policy.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-policy.js +20 -0
- package/lib/plugin-runtime/workroom-acceptance-policy.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-production-composition.d.ts +175 -0
- package/lib/plugin-runtime/workroom-acceptance-production-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-production-composition.js +793 -0
- package/lib/plugin-runtime/workroom-acceptance-production-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-provider-composition.d.ts +186 -0
- package/lib/plugin-runtime/workroom-acceptance-provider-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-provider-composition.js +553 -0
- package/lib/plugin-runtime/workroom-acceptance-provider-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-accepted-source-runtime.d.ts +75 -0
- package/lib/plugin-runtime/workroom-accepted-source-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-accepted-source-runtime.js +267 -0
- package/lib/plugin-runtime/workroom-accepted-source-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-authority-grant-runtime.d.ts +42 -0
- package/lib/plugin-runtime/workroom-assignment-authority-grant-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-authority-grant-runtime.js +90 -0
- package/lib/plugin-runtime/workroom-assignment-authority-grant-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-authority-provider.d.ts +159 -0
- package/lib/plugin-runtime/workroom-assignment-authority-provider.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-authority-provider.js +595 -0
- package/lib/plugin-runtime/workroom-assignment-authority-provider.js.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-knowledge-composition.d.ts +58 -0
- package/lib/plugin-runtime/workroom-assignment-knowledge-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-assignment-knowledge-composition.js +218 -0
- package/lib/plugin-runtime/workroom-assignment-knowledge-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-authority-writer.d.ts +47 -0
- package/lib/plugin-runtime/workroom-data-governance-authority-writer.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-authority-writer.js +115 -0
- package/lib/plugin-runtime/workroom-data-governance-authority-writer.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-composition.d.ts +28 -0
- package/lib/plugin-runtime/workroom-data-governance-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-composition.js +41 -0
- package/lib/plugin-runtime/workroom-data-governance-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-root-provider.d.ts +51 -0
- package/lib/plugin-runtime/workroom-data-governance-root-provider.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-root-provider.js +66 -0
- package/lib/plugin-runtime/workroom-data-governance-root-provider.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-runtime.d.ts +134 -0
- package/lib/plugin-runtime/workroom-data-governance-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-runtime.js +1253 -0
- package/lib/plugin-runtime/workroom-data-governance-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-storage.d.ts +66 -0
- package/lib/plugin-runtime/workroom-data-governance-storage.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-governance-storage.js +160 -0
- package/lib/plugin-runtime/workroom-data-governance-storage.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-composition.d.ts +37 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-composition.js +131 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-console.d.ts +238 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-console.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-console.js +495 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-console.js.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-human-ingress.d.ts +15 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-human-ingress.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-human-ingress.js +119 -0
- package/lib/plugin-runtime/workroom-data-lifecycle-human-ingress.js.map +1 -0
- package/lib/plugin-runtime/workroom-dynamic-planning-provider.d.ts +142 -0
- package/lib/plugin-runtime/workroom-dynamic-planning-provider.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-dynamic-planning-provider.js +301 -0
- package/lib/plugin-runtime/workroom-dynamic-planning-provider.js.map +1 -0
- package/lib/plugin-runtime/workroom-dynamic-planning.d.ts +4 -0
- package/lib/plugin-runtime/workroom-dynamic-planning.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-dynamic-planning.js +13 -0
- package/lib/plugin-runtime/workroom-dynamic-planning.js.map +1 -0
- package/lib/plugin-runtime/workroom-effect-composition.d.ts +37 -0
- package/lib/plugin-runtime/workroom-effect-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-effect-composition.js +69 -0
- package/lib/plugin-runtime/workroom-effect-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-effect-production.d.ts +133 -0
- package/lib/plugin-runtime/workroom-effect-production.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-effect-production.js +272 -0
- package/lib/plugin-runtime/workroom-effect-production.js.map +1 -0
- package/lib/plugin-runtime/workroom-effect-runtime.d.ts +72 -0
- package/lib/plugin-runtime/workroom-effect-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-effect-runtime.js +179 -0
- package/lib/plugin-runtime/workroom-effect-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.d.ts +27 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.js +40 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-reasons.d.ts +10 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-reasons.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-reasons.js +20 -0
- package/lib/plugin-runtime/workroom-governed-dispatch-reasons.js.map +1 -0
- package/lib/plugin-runtime/workroom-journal-payload-composition.d.ts +16 -0
- package/lib/plugin-runtime/workroom-journal-payload-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-journal-payload-composition.js +69 -0
- package/lib/plugin-runtime/workroom-journal-payload-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-agent-core-adapter.d.ts +17 -0
- package/lib/plugin-runtime/workroom-local-agent-core-adapter.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-local-agent-core-adapter.js +101 -0
- package/lib/plugin-runtime/workroom-local-agent-core-adapter.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-agent-loop.d.ts +90 -0
- package/lib/plugin-runtime/workroom-local-agent-loop.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-local-agent-loop.js +303 -0
- package/lib/plugin-runtime/workroom-local-agent-loop.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-authority.d.ts +5 -0
- package/lib/plugin-runtime/workroom-local-assignment-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-authority.js +16 -0
- package/lib/plugin-runtime/workroom-local-assignment-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-runtime.d.ts +33 -0
- package/lib/plugin-runtime/workroom-local-assignment-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-runtime.js +189 -0
- package/lib/plugin-runtime/workroom-local-assignment-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-supply.d.ts +39 -0
- package/lib/plugin-runtime/workroom-local-assignment-supply.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-supply.js +107 -0
- package/lib/plugin-runtime/workroom-local-assignment-supply.js.map +1 -0
- package/lib/plugin-runtime/workroom-overlay-pack-promotion.d.ts +145 -0
- package/lib/plugin-runtime/workroom-overlay-pack-promotion.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-overlay-pack-promotion.js +516 -0
- package/lib/plugin-runtime/workroom-overlay-pack-promotion.js.map +1 -0
- package/lib/plugin-runtime/workroom-payload-processor-recall.d.ts +91 -0
- package/lib/plugin-runtime/workroom-payload-processor-recall.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-payload-processor-recall.js +189 -0
- package/lib/plugin-runtime/workroom-payload-processor-recall.js.map +1 -0
- package/lib/plugin-runtime/workroom-plan-gate-authority.d.ts +7 -0
- package/lib/plugin-runtime/workroom-plan-gate-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-plan-gate-authority.js +40 -0
- package/lib/plugin-runtime/workroom-plan-gate-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-capacity.d.ts +132 -0
- package/lib/plugin-runtime/workroom-portfolio-capacity.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-capacity.js +189 -0
- package/lib/plugin-runtime/workroom-portfolio-capacity.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-checkpoint-ack.d.ts +38 -0
- package/lib/plugin-runtime/workroom-portfolio-checkpoint-ack.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-checkpoint-ack.js +103 -0
- package/lib/plugin-runtime/workroom-portfolio-checkpoint-ack.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-control-composition.d.ts +30 -0
- package/lib/plugin-runtime/workroom-portfolio-control-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-control-composition.js +102 -0
- package/lib/plugin-runtime/workroom-portfolio-control-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-control-runtime.d.ts +41 -0
- package/lib/plugin-runtime/workroom-portfolio-control-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-control-runtime.js +208 -0
- package/lib/plugin-runtime/workroom-portfolio-control-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-grant-assignment.d.ts +141 -0
- package/lib/plugin-runtime/workroom-portfolio-grant-assignment.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-grant-assignment.js +331 -0
- package/lib/plugin-runtime/workroom-portfolio-grant-assignment.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-kernel-authority.d.ts +23 -0
- package/lib/plugin-runtime/workroom-portfolio-kernel-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-kernel-authority.js +82 -0
- package/lib/plugin-runtime/workroom-portfolio-kernel-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-sponsor.d.ts +96 -0
- package/lib/plugin-runtime/workroom-portfolio-sponsor.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-portfolio-sponsor.js +313 -0
- package/lib/plugin-runtime/workroom-portfolio-sponsor.js.map +1 -0
- package/lib/plugin-runtime/workroom-preemption-runtime.d.ts +57 -0
- package/lib/plugin-runtime/workroom-preemption-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-preemption-runtime.js +163 -0
- package/lib/plugin-runtime/workroom-preemption-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-priority-authority.d.ts +11 -0
- package/lib/plugin-runtime/workroom-priority-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-priority-authority.js +72 -0
- package/lib/plugin-runtime/workroom-priority-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-profile-authority-composition.d.ts +61 -0
- package/lib/plugin-runtime/workroom-profile-authority-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-profile-authority-composition.js +231 -0
- package/lib/plugin-runtime/workroom-profile-authority-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-profile-authority-runtime.d.ts +228 -0
- package/lib/plugin-runtime/workroom-profile-authority-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-profile-authority-runtime.js +1132 -0
- package/lib/plugin-runtime/workroom-profile-authority-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-projection-outbound.d.ts +10 -0
- package/lib/plugin-runtime/workroom-projection-outbound.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-projection-outbound.js +35 -0
- package/lib/plugin-runtime/workroom-projection-outbound.js.map +1 -0
- package/lib/plugin-runtime/workroom-projection-runtime.d.ts +87 -0
- package/lib/plugin-runtime/workroom-projection-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-projection-runtime.js +421 -0
- package/lib/plugin-runtime/workroom-projection-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-remote-assignment-authority.d.ts +9 -0
- package/lib/plugin-runtime/workroom-remote-assignment-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-remote-assignment-authority.js +20 -0
- package/lib/plugin-runtime/workroom-remote-assignment-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-remote-callback-runtime.d.ts +38 -0
- package/lib/plugin-runtime/workroom-remote-callback-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-remote-callback-runtime.js +80 -0
- package/lib/plugin-runtime/workroom-remote-callback-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-remote-executor.d.ts +20 -0
- package/lib/plugin-runtime/workroom-remote-executor.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-remote-executor.js +42 -0
- package/lib/plugin-runtime/workroom-remote-executor.js.map +1 -0
- package/lib/plugin-runtime/workroom-reviewer-authority-runtime.d.ts +72 -0
- package/lib/plugin-runtime/workroom-reviewer-authority-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-reviewer-authority-runtime.js +142 -0
- package/lib/plugin-runtime/workroom-reviewer-authority-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-risk-acceptance-runtime.d.ts +112 -0
- package/lib/plugin-runtime/workroom-risk-acceptance-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-risk-acceptance-runtime.js +376 -0
- package/lib/plugin-runtime/workroom-risk-acceptance-runtime.js.map +1 -0
- package/lib/plugin-runtime/workroom-run-profile-pin-authority.d.ts +42 -0
- package/lib/plugin-runtime/workroom-run-profile-pin-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-run-profile-pin-authority.js +125 -0
- package/lib/plugin-runtime/workroom-run-profile-pin-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-composition.d.ts +25 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-composition.js +79 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-composition.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-contract.d.ts +16 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-contract.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-contract.js +49 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-contract.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-request-authority.d.ts +63 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-request-authority.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-request-authority.js +233 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-request-authority.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-supply.d.ts +37 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-supply.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-supply.js +122 -0
- package/lib/plugin-runtime/workroom-scheduler-portfolio-supply.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-route-registry.d.ts +27 -0
- package/lib/plugin-runtime/workroom-scheduler-route-registry.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-route-registry.js +136 -0
- package/lib/plugin-runtime/workroom-scheduler-route-registry.js.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-runtime.d.ts +84 -0
- package/lib/plugin-runtime/workroom-scheduler-runtime.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-scheduler-runtime.js +231 -0
- package/lib/plugin-runtime/workroom-scheduler-runtime.js.map +1 -0
- package/lib/portfolio/capacity-control-outbox.d.ts +174 -0
- package/lib/portfolio/capacity-control-outbox.d.ts.map +1 -0
- package/lib/portfolio/capacity-control-outbox.js +338 -0
- package/lib/portfolio/capacity-control-outbox.js.map +1 -0
- package/lib/portfolio/database-capacity-control-outbox.d.ts +62 -0
- package/lib/portfolio/database-capacity-control-outbox.d.ts.map +1 -0
- package/lib/portfolio/database-capacity-control-outbox.js +166 -0
- package/lib/portfolio/database-capacity-control-outbox.js.map +1 -0
- package/lib/portfolio/file-capacity-control-outbox.d.ts +10 -0
- package/lib/portfolio/file-capacity-control-outbox.d.ts.map +1 -0
- package/lib/portfolio/file-capacity-control-outbox.js +113 -0
- package/lib/portfolio/file-capacity-control-outbox.js.map +1 -0
- package/lib/portfolio/file-portfolio-journal.d.ts +11 -0
- package/lib/portfolio/file-portfolio-journal.d.ts.map +1 -0
- package/lib/portfolio/file-portfolio-journal.js +196 -0
- package/lib/portfolio/file-portfolio-journal.js.map +1 -0
- package/lib/portfolio/portfolio-admission.d.ts +95 -0
- package/lib/portfolio/portfolio-admission.d.ts.map +1 -0
- package/lib/portfolio/portfolio-admission.js +1080 -0
- package/lib/portfolio/portfolio-admission.js.map +1 -0
- package/lib/portfolio/portfolio-journal.d.ts +359 -0
- package/lib/portfolio/portfolio-journal.d.ts.map +1 -0
- package/lib/portfolio/portfolio-journal.js +844 -0
- package/lib/portfolio/portfolio-journal.js.map +1 -0
- package/lib/portfolio/resource-bundle.d.ts +136 -0
- package/lib/portfolio/resource-bundle.d.ts.map +1 -0
- package/lib/portfolio/resource-bundle.js +387 -0
- package/lib/portfolio/resource-bundle.js.map +1 -0
- package/lib/portfolio/sponsor-projection.d.ts +78 -0
- package/lib/portfolio/sponsor-projection.d.ts.map +1 -0
- package/lib/portfolio/sponsor-projection.js +135 -0
- package/lib/portfolio/sponsor-projection.js.map +1 -0
- package/lib/prompt/assembly.d.ts.map +1 -1
- package/lib/prompt/assembly.js +1 -3
- package/lib/prompt/assembly.js.map +1 -1
- package/lib/prompt/prompt-builder.d.ts +1 -1
- package/lib/prompt/prompt-builder.d.ts.map +1 -1
- package/lib/prompt/system-prompt.d.ts +1 -1
- package/lib/prompt/system-prompt.js +2 -2
- package/lib/prompt/system-prompt.js.map +1 -1
- package/lib/reserved-tools.d.ts.map +1 -1
- package/lib/reserved-tools.js +0 -1
- package/lib/reserved-tools.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/hook-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/hook-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/index.d.ts +4 -11
- package/lib/{orchestrator → resource-hub}/index.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/index.js +4 -8
- package/lib/{orchestrator → resource-hub}/index.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/mcp-lifecycle.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/mcp-lifecycle.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/mcp-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/mcp-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/resolve-subagent-tools.d.ts +3 -3
- package/lib/resource-hub/resolve-subagent-tools.d.ts.map +1 -0
- package/lib/{orchestrator → resource-hub}/resolve-subagent-tools.js +18 -13
- package/lib/resource-hub/resolve-subagent-tools.js.map +1 -0
- package/lib/{orchestrator → resource-hub}/resource-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/resource-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/role-configs.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/role-configs.js +0 -2
- package/lib/{orchestrator → resource-hub}/role-configs.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/skill-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/skill-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/subagent-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/subagent-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/tool-registry.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/tool-registry.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/tool-selection.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/tool-selection.js.map +1 -1
- package/lib/{orchestrator → resource-hub}/types.d.ts +1 -1
- package/lib/{orchestrator → resource-hub}/types.d.ts.map +1 -1
- package/lib/{orchestrator → resource-hub}/types.js.map +1 -1
- package/lib/routing/workroom-bot-identity.d.ts +22 -0
- package/lib/routing/workroom-bot-identity.d.ts.map +1 -0
- package/lib/routing/workroom-bot-identity.js +46 -0
- package/lib/routing/workroom-bot-identity.js.map +1 -0
- package/lib/schedule-domain/budget-guard.d.ts +1 -1
- package/lib/schedule-domain/budget-guard.d.ts.map +1 -1
- package/lib/schedule-domain/budget-guard.js +9 -1
- package/lib/schedule-domain/budget-guard.js.map +1 -1
- package/lib/schedule-domain/execution-domain.d.ts +1 -0
- package/lib/schedule-domain/execution-domain.d.ts.map +1 -1
- package/lib/schedule-domain/execution-domain.js +3 -1
- package/lib/schedule-domain/execution-domain.js.map +1 -1
- package/lib/schedule-domain/schedule-execution-queue.d.ts +24 -0
- package/lib/schedule-domain/schedule-execution-queue.d.ts.map +1 -0
- package/lib/schedule-domain/schedule-execution-queue.js +123 -0
- package/lib/schedule-domain/schedule-execution-queue.js.map +1 -0
- package/lib/seam/seam-integration.d.ts +1 -1
- package/lib/seam/seam-integration.js +1 -1
- package/lib/seam/skill-service.d.ts +1 -1
- package/lib/security/exec-policy.d.ts +11 -1
- package/lib/security/exec-policy.d.ts.map +1 -1
- package/lib/security/exec-policy.js +16 -4
- package/lib/security/exec-policy.js.map +1 -1
- package/lib/security/policy-facade.d.ts.map +1 -1
- package/lib/security/policy-facade.js +60 -5
- package/lib/security/policy-facade.js.map +1 -1
- package/lib/security/sandbox-docker.js +1 -1
- package/lib/security/sandbox-docker.js.map +1 -1
- package/lib/security/sandbox.d.ts +2 -0
- package/lib/security/sandbox.d.ts.map +1 -1
- package/lib/security/sandbox.js +16 -4
- package/lib/security/sandbox.js.map +1 -1
- package/lib/security/turn-file-authority.d.ts +1 -1
- package/lib/security/turn-file-authority.d.ts.map +1 -1
- package/lib/security/turn-file-authority.js +10 -3
- package/lib/security/turn-file-authority.js.map +1 -1
- package/lib/security/turn-sandbox-authority.d.ts +13 -0
- package/lib/security/turn-sandbox-authority.d.ts.map +1 -0
- package/lib/security/turn-sandbox-authority.js +42 -0
- package/lib/security/turn-sandbox-authority.js.map +1 -0
- package/lib/service.d.ts +2 -0
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +2 -1
- package/lib/service.js.map +1 -1
- package/lib/session/approval-port.d.ts +2 -0
- package/lib/session/approval-port.d.ts.map +1 -1
- package/lib/session/approval-port.js.map +1 -1
- package/lib/session/index.d.ts +2 -6
- package/lib/session/index.d.ts.map +1 -1
- package/lib/session/index.js +2 -4
- package/lib/session/index.js.map +1 -1
- package/lib/session/session-io.d.ts +2 -6
- package/lib/session/session-io.d.ts.map +1 -1
- package/lib/session/session-io.js +4 -20
- package/lib/session/session-io.js.map +1 -1
- package/lib/session/session-system.d.ts +0 -2
- package/lib/session/session-system.d.ts.map +1 -1
- package/lib/session/session-system.js +2 -13
- package/lib/session/session-system.js.map +1 -1
- package/lib/session/turn-ingress-session.d.ts +1 -5
- package/lib/session/turn-ingress-session.d.ts.map +1 -1
- package/lib/session/turn-ingress-session.js +27 -29
- package/lib/session/turn-ingress-session.js.map +1 -1
- package/lib/session-tree-runtime.d.ts +15 -0
- package/lib/session-tree-runtime.d.ts.map +1 -0
- package/lib/{session-tree-runtime-registry.js → session-tree-runtime.js} +5 -15
- package/lib/session-tree-runtime.js.map +1 -0
- package/lib/skill/index.d.ts +2 -2
- package/lib/skill/index.d.ts.map +1 -1
- package/lib/skill/index.js +1 -1
- package/lib/skill/skill-registry-as-service.d.ts +1 -1
- package/lib/skill/skill-system.d.ts +4 -4
- package/lib/skill/skill-system.d.ts.map +1 -1
- package/lib/skill/skill-system.js +2 -2
- package/lib/skill/skill-system.js.map +1 -1
- package/lib/subagent/subagent-runtime.d.ts +2 -7
- package/lib/subagent/subagent-runtime.d.ts.map +1 -1
- package/lib/subagent/subagent-runtime.js +4 -43
- package/lib/subagent/subagent-runtime.js.map +1 -1
- package/lib/subagent/subagent-system-init.d.ts.map +1 -1
- package/lib/subagent/subagent-system-init.js +0 -2
- package/lib/subagent/subagent-system-init.js.map +1 -1
- package/lib/subagent-ai-events.d.ts +1 -1
- package/lib/subagent-ai-events.js +1 -1
- package/lib/subagent-preset.d.ts +1 -1
- package/lib/subagent-preset.d.ts.map +1 -1
- package/lib/subagent-prompt.d.ts +0 -2
- package/lib/subagent-prompt.d.ts.map +1 -1
- package/lib/subagent-prompt.js +3 -3
- package/lib/subagent-prompt.js.map +1 -1
- package/lib/task-executor.d.ts +1 -0
- package/lib/task-executor.d.ts.map +1 -1
- package/lib/task-executor.js +4 -1
- package/lib/task-executor.js.map +1 -1
- package/lib/tool/classic-tool-execution-authority.js +2 -2
- package/lib/tool/classic-tool-execution-authority.js.map +1 -1
- package/lib/tool/context-tools.d.ts +1 -4
- package/lib/tool/context-tools.d.ts.map +1 -1
- package/lib/tool/context-tools.js +0 -50
- package/lib/tool/context-tools.js.map +1 -1
- package/lib/tool/contracts.d.ts +1 -1
- package/lib/tool/conversation-reference-tool.d.ts +5 -0
- package/lib/tool/conversation-reference-tool.d.ts.map +1 -0
- package/lib/tool/conversation-reference-tool.js +40 -0
- package/lib/tool/conversation-reference-tool.js.map +1 -0
- package/lib/tool/index.d.ts +1 -0
- package/lib/tool/index.d.ts.map +1 -1
- package/lib/tool/index.js +1 -0
- package/lib/tool/index.js.map +1 -1
- package/lib/tool/prepare-turn-tools.d.ts.map +1 -1
- package/lib/tool/prepare-turn-tools.js +7 -22
- package/lib/tool/prepare-turn-tools.js.map +1 -1
- package/lib/tool/runtime.d.ts +3 -4
- package/lib/tool/runtime.d.ts.map +1 -1
- package/lib/tool/runtime.js +0 -1
- package/lib/tool/runtime.js.map +1 -1
- package/lib/tool/sources.d.ts +3 -4
- package/lib/tool/sources.d.ts.map +1 -1
- package/lib/tool/sources.js +2 -6
- package/lib/tool/sources.js.map +1 -1
- package/lib/tool/tool-approval-once-store.d.ts +1 -1
- package/lib/tool/tool-approval-once-store.js +1 -1
- package/lib/tool/tool-system.d.ts.map +1 -1
- package/lib/tool/tool-system.js.map +1 -1
- package/lib/tool/turn-tool-runtime.d.ts +2 -1
- package/lib/tool/turn-tool-runtime.d.ts.map +1 -1
- package/lib/tool/turn-tool-runtime.js +76 -21
- package/lib/tool/turn-tool-runtime.js.map +1 -1
- package/lib/tool-bridge.d.ts +2 -2
- package/lib/tool-bridge.js +1 -1
- package/lib/tool-catalog/deferred-turn-controller.d.ts +1 -1
- package/lib/tool-catalog/tool-catalog.d.ts +1 -1
- package/lib/turn/auto-continue.d.ts +1 -1
- package/lib/turn/deferred-delivery.d.ts +1 -1
- package/lib/turn/inbound-media.d.ts +12 -8
- package/lib/turn/inbound-media.d.ts.map +1 -1
- package/lib/turn/inbound-media.js +61 -42
- package/lib/turn/inbound-media.js.map +1 -1
- package/lib/turn/inbound-queue-config.d.ts +1 -1
- package/lib/turn/inbound-queue-runtime.d.ts +1 -1
- package/lib/turn/inbound-turn-queue.d.ts +1 -1
- package/lib/turn/index.d.ts +1 -1
- package/lib/turn/index.d.ts.map +1 -1
- package/lib/turn/index.js.map +1 -1
- package/lib/turn/persist-deferred-context.d.ts +1 -1
- package/lib/turn/persist-subagent-context.d.ts +1 -1
- package/lib/turn/process-stream.d.ts +1 -1
- package/lib/turn/prompt-api.d.ts +1 -1
- package/lib/turn/prompt-controller.d.ts +6 -0
- package/lib/turn/prompt-controller.d.ts.map +1 -1
- package/lib/turn/prompt-controller.js +58 -5
- package/lib/turn/prompt-controller.js.map +1 -1
- package/lib/turn/turn-ingress.d.ts +55 -5
- package/lib/turn/turn-ingress.d.ts.map +1 -1
- package/lib/turn/turn-ingress.js +18 -0
- package/lib/turn/turn-ingress.js.map +1 -1
- package/lib/turn/turn-pipeline.d.ts.map +1 -1
- package/lib/turn/turn-pipeline.js +5 -4
- package/lib/turn/turn-pipeline.js.map +1 -1
- package/lib/utils/keyed-mutex.d.ts +1 -1
- package/lib/utils/keyed-mutex.d.ts.map +1 -1
- package/lib/utils/keyed-mutex.js +32 -5
- package/lib/utils/keyed-mutex.js.map +1 -1
- package/lib/workroom/acceptance-control.d.ts +76 -0
- package/lib/workroom/acceptance-control.d.ts.map +1 -0
- package/lib/workroom/acceptance-control.js +335 -0
- package/lib/workroom/acceptance-control.js.map +1 -0
- package/lib/workroom/acceptance-policy.d.ts +152 -0
- package/lib/workroom/acceptance-policy.d.ts.map +1 -0
- package/lib/workroom/acceptance-policy.js +610 -0
- package/lib/workroom/acceptance-policy.js.map +1 -0
- package/lib/workroom/accepted-source-memory-application.d.ts +113 -0
- package/lib/workroom/accepted-source-memory-application.d.ts.map +1 -0
- package/lib/workroom/accepted-source-memory-application.js +327 -0
- package/lib/workroom/accepted-source-memory-application.js.map +1 -0
- package/lib/workroom/accepted-source-projector.d.ts +89 -0
- package/lib/workroom/accepted-source-projector.d.ts.map +1 -0
- package/lib/workroom/accepted-source-projector.js +281 -0
- package/lib/workroom/accepted-source-projector.js.map +1 -0
- package/lib/workroom/assignment-authority-grant-application.d.ts +125 -0
- package/lib/workroom/assignment-authority-grant-application.d.ts.map +1 -0
- package/lib/workroom/assignment-authority-grant-application.js +317 -0
- package/lib/workroom/assignment-authority-grant-application.js.map +1 -0
- package/lib/workroom/assignment-authority-grant-repository.d.ts +151 -0
- package/lib/workroom/assignment-authority-grant-repository.d.ts.map +1 -0
- package/lib/workroom/assignment-authority-grant-repository.js +387 -0
- package/lib/workroom/assignment-authority-grant-repository.js.map +1 -0
- package/lib/workroom/assignment-executor.d.ts +110 -0
- package/lib/workroom/assignment-executor.d.ts.map +1 -0
- package/lib/workroom/assignment-executor.js +371 -0
- package/lib/workroom/assignment-executor.js.map +1 -0
- package/lib/workroom/assignment-observation-ingress.d.ts +21 -0
- package/lib/workroom/assignment-observation-ingress.d.ts.map +1 -0
- package/lib/workroom/assignment-observation-ingress.js +24 -0
- package/lib/workroom/assignment-observation-ingress.js.map +1 -0
- package/lib/workroom/canonical-value.d.ts +7 -0
- package/lib/workroom/canonical-value.d.ts.map +1 -0
- package/lib/workroom/canonical-value.js +32 -0
- package/lib/workroom/canonical-value.js.map +1 -0
- package/lib/workroom/catalog-definition.d.ts +49 -0
- package/lib/workroom/catalog-definition.d.ts.map +1 -0
- package/lib/workroom/catalog-definition.js +2 -0
- package/lib/workroom/catalog-definition.js.map +1 -0
- package/lib/workroom/catalog.d.ts +80 -0
- package/lib/workroom/catalog.d.ts.map +1 -0
- package/lib/workroom/catalog.js +372 -0
- package/lib/workroom/catalog.js.map +1 -0
- package/lib/workroom/database-project-knowledge-journal.d.ts +62 -0
- package/lib/workroom/database-project-knowledge-journal.d.ts.map +1 -0
- package/lib/workroom/database-project-knowledge-journal.js +161 -0
- package/lib/workroom/database-project-knowledge-journal.js.map +1 -0
- package/lib/workroom/durable-file-store.d.ts +52 -0
- package/lib/workroom/durable-file-store.d.ts.map +1 -0
- package/lib/workroom/durable-file-store.js +117 -0
- package/lib/workroom/durable-file-store.js.map +1 -0
- package/lib/workroom/dynamic-workflow-planner.d.ts +86 -0
- package/lib/workroom/dynamic-workflow-planner.d.ts.map +1 -0
- package/lib/workroom/dynamic-workflow-planner.js +260 -0
- package/lib/workroom/dynamic-workflow-planner.js.map +1 -0
- package/lib/workroom/effect-blocker-repository.d.ts +35 -0
- package/lib/workroom/effect-blocker-repository.d.ts.map +1 -0
- package/lib/workroom/effect-blocker-repository.js +174 -0
- package/lib/workroom/effect-blocker-repository.js.map +1 -0
- package/lib/workroom/effect-ledger.d.ts +191 -0
- package/lib/workroom/effect-ledger.d.ts.map +1 -0
- package/lib/workroom/effect-ledger.js +443 -0
- package/lib/workroom/effect-ledger.js.map +1 -0
- package/lib/workroom/file-accepted-source-memory-repository.d.ts +15 -0
- package/lib/workroom/file-accepted-source-memory-repository.d.ts.map +1 -0
- package/lib/workroom/file-accepted-source-memory-repository.js +133 -0
- package/lib/workroom/file-accepted-source-memory-repository.js.map +1 -0
- package/lib/workroom/file-effect-ledger.d.ts +10 -0
- package/lib/workroom/file-effect-ledger.d.ts.map +1 -0
- package/lib/workroom/file-effect-ledger.js +118 -0
- package/lib/workroom/file-effect-ledger.js.map +1 -0
- package/lib/workroom/file-human-ingress-application.d.ts +10 -0
- package/lib/workroom/file-human-ingress-application.d.ts.map +1 -0
- package/lib/workroom/file-human-ingress-application.js +177 -0
- package/lib/workroom/file-human-ingress-application.js.map +1 -0
- package/lib/workroom/file-human-ingress.d.ts +24 -0
- package/lib/workroom/file-human-ingress.d.ts.map +1 -0
- package/lib/workroom/file-human-ingress.js +234 -0
- package/lib/workroom/file-human-ingress.js.map +1 -0
- package/lib/workroom/file-interaction-space-binding-repository.d.ts +24 -0
- package/lib/workroom/file-interaction-space-binding-repository.d.ts.map +1 -0
- package/lib/workroom/file-interaction-space-binding-repository.js +293 -0
- package/lib/workroom/file-interaction-space-binding-repository.js.map +1 -0
- package/lib/workroom/file-profile-journal.d.ts +32 -0
- package/lib/workroom/file-profile-journal.d.ts.map +1 -0
- package/lib/workroom/file-profile-journal.js +308 -0
- package/lib/workroom/file-profile-journal.js.map +1 -0
- package/lib/workroom/git-workspace-gateway.d.ts +149 -0
- package/lib/workroom/git-workspace-gateway.d.ts.map +1 -0
- package/lib/workroom/git-workspace-gateway.js +248 -0
- package/lib/workroom/git-workspace-gateway.js.map +1 -0
- package/lib/workroom/human-ingress-application.d.ts +126 -0
- package/lib/workroom/human-ingress-application.d.ts.map +1 -0
- package/lib/workroom/human-ingress-application.js +414 -0
- package/lib/workroom/human-ingress-application.js.map +1 -0
- package/lib/workroom/human-ingress-orchestrator.d.ts +99 -0
- package/lib/workroom/human-ingress-orchestrator.d.ts.map +1 -0
- package/lib/workroom/human-ingress-orchestrator.js +234 -0
- package/lib/workroom/human-ingress-orchestrator.js.map +1 -0
- package/lib/workroom/human-ingress-source-reader.d.ts +29 -0
- package/lib/workroom/human-ingress-source-reader.d.ts.map +1 -0
- package/lib/workroom/human-ingress-source-reader.js +119 -0
- package/lib/workroom/human-ingress-source-reader.js.map +1 -0
- package/lib/workroom/human-ingress.d.ts +182 -0
- package/lib/workroom/human-ingress.d.ts.map +1 -0
- package/lib/workroom/human-ingress.js +526 -0
- package/lib/workroom/human-ingress.js.map +1 -0
- package/lib/workroom/interaction-space-binding-service.d.ts +57 -0
- package/lib/workroom/interaction-space-binding-service.d.ts.map +1 -0
- package/lib/workroom/interaction-space-binding-service.js +197 -0
- package/lib/workroom/interaction-space-binding-service.js.map +1 -0
- package/lib/workroom/interaction-space-router.d.ts +75 -0
- package/lib/workroom/interaction-space-router.d.ts.map +1 -0
- package/lib/workroom/interaction-space-router.js +243 -0
- package/lib/workroom/interaction-space-router.js.map +1 -0
- package/lib/workroom/journal-model.d.ts +40 -0
- package/lib/workroom/journal-model.d.ts.map +1 -0
- package/lib/workroom/journal-model.js +12 -0
- package/lib/workroom/journal-model.js.map +1 -0
- package/lib/workroom/journal.d.ts +214 -0
- package/lib/workroom/journal.d.ts.map +1 -0
- package/lib/workroom/journal.js +1935 -0
- package/lib/workroom/journal.js.map +1 -0
- package/lib/workroom/kernel-contracts.d.ts +167 -0
- package/lib/workroom/kernel-contracts.d.ts.map +1 -0
- package/lib/workroom/kernel-contracts.js +2 -0
- package/lib/workroom/kernel-contracts.js.map +1 -0
- package/lib/workroom/kernel-state.d.ts +5 -0
- package/lib/workroom/kernel-state.d.ts.map +1 -0
- package/lib/workroom/kernel-state.js +819 -0
- package/lib/workroom/kernel-state.js.map +1 -0
- package/lib/workroom/legacy-embedded-payload-migration.d.ts +89 -0
- package/lib/workroom/legacy-embedded-payload-migration.d.ts.map +1 -0
- package/lib/workroom/legacy-embedded-payload-migration.js +312 -0
- package/lib/workroom/legacy-embedded-payload-migration.js.map +1 -0
- package/lib/workroom/legacy-run-offline-migration.d.ts +84 -0
- package/lib/workroom/legacy-run-offline-migration.d.ts.map +1 -0
- package/lib/workroom/legacy-run-offline-migration.js +470 -0
- package/lib/workroom/legacy-run-offline-migration.js.map +1 -0
- package/lib/workroom/local-assignment-executor.d.ts +59 -0
- package/lib/workroom/local-assignment-executor.d.ts.map +1 -0
- package/lib/workroom/local-assignment-executor.js +197 -0
- package/lib/workroom/local-assignment-executor.js.map +1 -0
- package/lib/workroom/local-assignment-issuance.d.ts +68 -0
- package/lib/workroom/local-assignment-issuance.d.ts.map +1 -0
- package/lib/workroom/local-assignment-issuance.js +128 -0
- package/lib/workroom/local-assignment-issuance.js.map +1 -0
- package/lib/workroom/plan-approval-control.d.ts +52 -0
- package/lib/workroom/plan-approval-control.d.ts.map +1 -0
- package/lib/workroom/plan-approval-control.js +9 -0
- package/lib/workroom/plan-approval-control.js.map +1 -0
- package/lib/workroom/plan-revision.d.ts +44 -0
- package/lib/workroom/plan-revision.d.ts.map +1 -0
- package/lib/workroom/plan-revision.js +133 -0
- package/lib/workroom/plan-revision.js.map +1 -0
- package/lib/workroom/profile-compiler.d.ts +130 -0
- package/lib/workroom/profile-compiler.d.ts.map +1 -0
- package/lib/workroom/profile-compiler.js +357 -0
- package/lib/workroom/profile-compiler.js.map +1 -0
- package/lib/workroom/profile-registry.d.ts +191 -0
- package/lib/workroom/profile-registry.d.ts.map +1 -0
- package/lib/workroom/profile-registry.js +698 -0
- package/lib/workroom/profile-registry.js.map +1 -0
- package/lib/workroom/project-knowledge-registry.d.ts +136 -0
- package/lib/workroom/project-knowledge-registry.d.ts.map +1 -0
- package/lib/workroom/project-knowledge-registry.js +429 -0
- package/lib/workroom/project-knowledge-registry.js.map +1 -0
- package/lib/workroom/projection-outbox.d.ts +254 -0
- package/lib/workroom/projection-outbox.d.ts.map +1 -0
- package/lib/workroom/projection-outbox.js +1312 -0
- package/lib/workroom/projection-outbox.js.map +1 -0
- package/lib/workroom/remote-assignment-dispatch-command.d.ts +31 -0
- package/lib/workroom/remote-assignment-dispatch-command.d.ts.map +1 -0
- package/lib/workroom/remote-assignment-dispatch-command.js +56 -0
- package/lib/workroom/remote-assignment-dispatch-command.js.map +1 -0
- package/lib/workroom/remote-assignment-issuance.d.ts +88 -0
- package/lib/workroom/remote-assignment-issuance.d.ts.map +1 -0
- package/lib/workroom/remote-assignment-issuance.js +201 -0
- package/lib/workroom/remote-assignment-issuance.js.map +1 -0
- package/lib/workroom/remote-callback-application.d.ts +115 -0
- package/lib/workroom/remote-callback-application.d.ts.map +1 -0
- package/lib/workroom/remote-callback-application.js +570 -0
- package/lib/workroom/remote-callback-application.js.map +1 -0
- package/lib/workroom/remote-callback-gateway.d.ts +60 -0
- package/lib/workroom/remote-callback-gateway.d.ts.map +1 -0
- package/lib/workroom/remote-callback-gateway.js +173 -0
- package/lib/workroom/remote-callback-gateway.js.map +1 -0
- package/lib/workroom/remote-callback-inbox.d.ts +278 -0
- package/lib/workroom/remote-callback-inbox.d.ts.map +1 -0
- package/lib/workroom/remote-callback-inbox.js +1088 -0
- package/lib/workroom/remote-callback-inbox.js.map +1 -0
- package/lib/workroom/remote-callback-reconciliation-worker.d.ts +60 -0
- package/lib/workroom/remote-callback-reconciliation-worker.d.ts.map +1 -0
- package/lib/workroom/remote-callback-reconciliation-worker.js +197 -0
- package/lib/workroom/remote-callback-reconciliation-worker.js.map +1 -0
- package/lib/workroom/remote-dispatch-admission.d.ts +45 -0
- package/lib/workroom/remote-dispatch-admission.d.ts.map +1 -0
- package/lib/workroom/remote-dispatch-admission.js +187 -0
- package/lib/workroom/remote-dispatch-admission.js.map +1 -0
- package/lib/workroom/remote-dispatch-outbox.d.ts +203 -0
- package/lib/workroom/remote-dispatch-outbox.d.ts.map +1 -0
- package/lib/workroom/remote-dispatch-outbox.js +765 -0
- package/lib/workroom/remote-dispatch-outbox.js.map +1 -0
- package/lib/workroom/remote-dispatch-scheduler.d.ts +36 -0
- package/lib/workroom/remote-dispatch-scheduler.d.ts.map +1 -0
- package/lib/workroom/remote-dispatch-scheduler.js +133 -0
- package/lib/workroom/remote-dispatch-scheduler.js.map +1 -0
- package/lib/workroom/remote-dispatch-worker.d.ts +22 -0
- package/lib/workroom/remote-dispatch-worker.d.ts.map +1 -0
- package/lib/workroom/remote-dispatch-worker.js +124 -0
- package/lib/workroom/remote-dispatch-worker.js.map +1 -0
- package/lib/workroom/remote-dispatch.d.ts +79 -0
- package/lib/workroom/remote-dispatch.d.ts.map +1 -0
- package/lib/workroom/remote-dispatch.js +220 -0
- package/lib/workroom/remote-dispatch.js.map +1 -0
- package/lib/workroom/role-capability-snapshot.d.ts +88 -0
- package/lib/workroom/role-capability-snapshot.d.ts.map +1 -0
- package/lib/workroom/role-capability-snapshot.js +456 -0
- package/lib/workroom/role-capability-snapshot.js.map +1 -0
- package/lib/workroom/runtime.d.ts +109 -0
- package/lib/workroom/runtime.d.ts.map +1 -0
- package/lib/workroom/runtime.js +450 -0
- package/lib/workroom/runtime.js.map +1 -0
- package/lib/workroom/scheduler-priority-control.d.ts +35 -0
- package/lib/workroom/scheduler-priority-control.d.ts.map +1 -0
- package/lib/workroom/scheduler-priority-control.js +9 -0
- package/lib/workroom/scheduler-priority-control.js.map +1 -0
- package/lib/workroom/workflow-plan-builder.d.ts +88 -0
- package/lib/workroom/workflow-plan-builder.d.ts.map +1 -0
- package/lib/workroom/workflow-plan-builder.js +232 -0
- package/lib/workroom/workflow-plan-builder.js.map +1 -0
- package/lib/workroom/workroom-assignment-knowledge-context.d.ts +102 -0
- package/lib/workroom/workroom-assignment-knowledge-context.d.ts.map +1 -0
- package/lib/workroom/workroom-assignment-knowledge-context.js +127 -0
- package/lib/workroom/workroom-assignment-knowledge-context.js.map +1 -0
- package/lib/workroom/workroom-kernel.d.ts +141 -0
- package/lib/workroom/workroom-kernel.d.ts.map +1 -0
- package/lib/workroom/workroom-kernel.js +1325 -0
- package/lib/workroom/workroom-kernel.js.map +1 -0
- package/lib/workroom/workroom-preemption.d.ts +65 -0
- package/lib/workroom/workroom-preemption.d.ts.map +1 -0
- package/lib/workroom/workroom-preemption.js +213 -0
- package/lib/workroom/workroom-preemption.js.map +1 -0
- package/lib/workroom/workroom-scheduler-application.d.ts +43 -0
- package/lib/workroom/workroom-scheduler-application.d.ts.map +1 -0
- package/lib/workroom/workroom-scheduler-application.js +71 -0
- package/lib/workroom/workroom-scheduler-application.js.map +1 -0
- package/lib/workroom/workroom-scheduler.d.ts +135 -0
- package/lib/workroom/workroom-scheduler.d.ts.map +1 -0
- package/lib/workroom/workroom-scheduler.js +649 -0
- package/lib/workroom/workroom-scheduler.js.map +1 -0
- package/lib/workroom/workroom-task-report-store.d.ts +131 -0
- package/lib/workroom/workroom-task-report-store.d.ts.map +1 -0
- package/lib/workroom/workroom-task-report-store.js +528 -0
- package/lib/workroom/workroom-task-report-store.js.map +1 -0
- package/lib/zhin-agent/index.d.ts +7 -22
- package/lib/zhin-agent/index.d.ts.map +1 -1
- package/lib/zhin-agent/index.js +5 -33
- package/lib/zhin-agent/index.js.map +1 -1
- package/lib/zhin-agent/runtime-modules.d.ts +3 -3
- package/lib/zhin-agent/runtime-modules.d.ts.map +1 -1
- package/lib/zhin-agent/runtime-modules.js +3 -3
- package/lib/zhin-agent/runtime-modules.js.map +1 -1
- package/package.json +10 -16
- package/lib/a2a/delegation-message.d.ts +0 -14
- package/lib/a2a/delegation-message.d.ts.map +0 -1
- package/lib/a2a/delegation-message.js +0 -53
- package/lib/a2a/delegation-message.js.map +0 -1
- package/lib/a2a/task-state.d.ts +0 -9
- package/lib/a2a/task-state.d.ts.map +0 -1
- package/lib/a2a/task-state.js +0 -53
- package/lib/a2a/task-state.js.map +0 -1
- package/lib/assistant/runtime-registry.d.ts +0 -23
- package/lib/assistant/runtime-registry.d.ts.map +0 -1
- package/lib/assistant/runtime-registry.js +0 -27
- package/lib/assistant/runtime-registry.js.map +0 -1
- package/lib/authoring/define-dynamic.d.ts +0 -4
- package/lib/authoring/define-dynamic.d.ts.map +0 -1
- package/lib/authoring/define-dynamic.js +0 -8
- package/lib/authoring/define-dynamic.js.map +0 -1
- package/lib/authoring/define-state.d.ts +0 -4
- package/lib/authoring/define-state.d.ts.map +0 -1
- package/lib/authoring/define-state.js +0 -8
- package/lib/authoring/define-state.js.map +0 -1
- package/lib/builtin/five-agent/strategy.d.ts +0 -4
- package/lib/builtin/five-agent/strategy.d.ts.map +0 -1
- package/lib/builtin/five-agent/strategy.js +0 -42
- package/lib/builtin/five-agent/strategy.js.map +0 -1
- package/lib/builtin/memory-search-tool.d.ts +0 -2
- package/lib/builtin/memory-search-tool.d.ts.map +0 -1
- package/lib/builtin/memory-search-tool.js +0 -58
- package/lib/builtin/memory-search-tool.js.map +0 -1
- package/lib/builtin/memory-upsert-tool.d.ts +0 -2
- package/lib/builtin/memory-upsert-tool.d.ts.map +0 -1
- package/lib/builtin/memory-upsert-tool.js +0 -72
- package/lib/builtin/memory-upsert-tool.js.map +0 -1
- package/lib/builtin/orchestration-tools.d.ts +0 -7
- package/lib/builtin/orchestration-tools.d.ts.map +0 -1
- package/lib/builtin/orchestration-tools.js +0 -259
- package/lib/builtin/orchestration-tools.js.map +0 -1
- package/lib/connection/authorization-flow.d.ts +0 -26
- package/lib/connection/authorization-flow.d.ts.map +0 -1
- package/lib/connection/authorization-flow.js +0 -76
- package/lib/connection/authorization-flow.js.map +0 -1
- package/lib/connection/index.d.ts +0 -3
- package/lib/connection/index.d.ts.map +0 -1
- package/lib/connection/index.js +0 -2
- package/lib/connection/index.js.map +0 -1
- package/lib/dynamic/dynamic-registry.d.ts +0 -34
- package/lib/dynamic/dynamic-registry.d.ts.map +0 -1
- package/lib/dynamic/dynamic-registry.js +0 -52
- package/lib/dynamic/dynamic-registry.js.map +0 -1
- package/lib/init/bootstrap-gate.d.ts +0 -6
- package/lib/init/bootstrap-gate.d.ts.map +0 -1
- package/lib/init/bootstrap-gate.js +0 -28
- package/lib/init/bootstrap-gate.js.map +0 -1
- package/lib/memory-entry-registry.d.ts +0 -13
- package/lib/memory-entry-registry.d.ts.map +0 -1
- package/lib/memory-entry-registry.js +0 -24
- package/lib/memory-entry-registry.js.map +0 -1
- package/lib/orchestration-memory-hook.d.ts +0 -3
- package/lib/orchestration-memory-hook.d.ts.map +0 -1
- package/lib/orchestration-memory-hook.js +0 -22
- package/lib/orchestration-memory-hook.js.map +0 -1
- package/lib/orchestration-runtime-registry.d.ts +0 -16
- package/lib/orchestration-runtime-registry.d.ts.map +0 -1
- package/lib/orchestration-runtime-registry.js +0 -20
- package/lib/orchestration-runtime-registry.js.map +0 -1
- package/lib/orchestrator/agent-dispatcher.d.ts +0 -171
- package/lib/orchestrator/agent-dispatcher.d.ts.map +0 -1
- package/lib/orchestrator/agent-dispatcher.js +0 -415
- package/lib/orchestrator/agent-dispatcher.js.map +0 -1
- package/lib/orchestrator/bootstrap-executors.d.ts +0 -7
- package/lib/orchestrator/bootstrap-executors.d.ts.map +0 -1
- package/lib/orchestrator/bootstrap-executors.js +0 -73
- package/lib/orchestrator/bootstrap-executors.js.map +0 -1
- package/lib/orchestrator/orchestration-mappers.d.ts +0 -9
- package/lib/orchestrator/orchestration-mappers.d.ts.map +0 -1
- package/lib/orchestrator/orchestration-mappers.js +0 -117
- package/lib/orchestrator/orchestration-mappers.js.map +0 -1
- package/lib/orchestrator/orchestration-repository.d.ts +0 -91
- package/lib/orchestrator/orchestration-repository.d.ts.map +0 -1
- package/lib/orchestrator/orchestration-repository.js +0 -389
- package/lib/orchestrator/orchestration-repository.js.map +0 -1
- package/lib/orchestrator/orchestration-service.d.ts +0 -133
- package/lib/orchestrator/orchestration-service.d.ts.map +0 -1
- package/lib/orchestrator/orchestration-service.js +0 -582
- package/lib/orchestrator/orchestration-service.js.map +0 -1
- package/lib/orchestrator/orchestration-source.d.ts +0 -5
- package/lib/orchestrator/orchestration-source.d.ts.map +0 -1
- package/lib/orchestrator/orchestration-source.js +0 -22
- package/lib/orchestrator/orchestration-source.js.map +0 -1
- package/lib/orchestrator/orchestration-types.d.ts +0 -88
- package/lib/orchestrator/orchestration-types.d.ts.map +0 -1
- package/lib/orchestrator/orchestration-types.js +0 -2
- package/lib/orchestrator/orchestration-types.js.map +0 -1
- package/lib/orchestrator/remote-agent-registry.d.ts +0 -37
- package/lib/orchestrator/remote-agent-registry.d.ts.map +0 -1
- package/lib/orchestrator/remote-agent-registry.js +0 -178
- package/lib/orchestrator/remote-agent-registry.js.map +0 -1
- package/lib/orchestrator/remote-task-executor.d.ts +0 -10
- package/lib/orchestrator/remote-task-executor.d.ts.map +0 -1
- package/lib/orchestrator/remote-task-executor.js +0 -231
- package/lib/orchestrator/remote-task-executor.js.map +0 -1
- package/lib/orchestrator/remote-task-poller.d.ts +0 -18
- package/lib/orchestrator/remote-task-poller.d.ts.map +0 -1
- package/lib/orchestrator/remote-task-poller.js +0 -84
- package/lib/orchestrator/remote-task-poller.js.map +0 -1
- package/lib/orchestrator/resolve-subagent-tools.d.ts.map +0 -1
- package/lib/orchestrator/resolve-subagent-tools.js.map +0 -1
- package/lib/orchestrator/task-queue.d.ts +0 -167
- package/lib/orchestrator/task-queue.d.ts.map +0 -1
- package/lib/orchestrator/task-queue.js +0 -416
- package/lib/orchestrator/task-queue.js.map +0 -1
- package/lib/session/passive-group-buffer.d.ts +0 -15
- package/lib/session/passive-group-buffer.d.ts.map +0 -1
- package/lib/session/passive-group-buffer.js +0 -50
- package/lib/session/passive-group-buffer.js.map +0 -1
- package/lib/session/passive-group-session.d.ts +0 -10
- package/lib/session/passive-group-session.d.ts.map +0 -1
- package/lib/session/passive-group-session.js +0 -32
- package/lib/session/passive-group-session.js.map +0 -1
- package/lib/session-tree-runtime-registry.d.ts +0 -22
- package/lib/session-tree-runtime-registry.d.ts.map +0 -1
- package/lib/session-tree-runtime-registry.js.map +0 -1
- package/lib/state/agent-state-store.d.ts +0 -18
- package/lib/state/agent-state-store.d.ts.map +0 -1
- package/lib/state/agent-state-store.js +0 -50
- package/lib/state/agent-state-store.js.map +0 -1
- /package/lib/{orchestrator → resource-hub}/hook-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/hook-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/mcp-lifecycle.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/mcp-lifecycle.js +0 -0
- /package/lib/{orchestrator → resource-hub}/mcp-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/mcp-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/resource-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/resource-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/role-configs.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/skill-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/skill-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/subagent-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/subagent-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/tool-registry.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/tool-registry.js +0 -0
- /package/lib/{orchestrator → resource-hub}/tool-selection.d.ts +0 -0
- /package/lib/{orchestrator → resource-hub}/tool-selection.js +0 -0
- /package/lib/{orchestrator → resource-hub}/types.js +0 -0
|
@@ -0,0 +1,1325 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { WorkroomSequenceConflictError } from './journal.js';
|
|
3
|
+
import { assertAssignmentExecutionEnvelope, validateAssignmentExecutionObservation, } from './assignment-executor.js';
|
|
4
|
+
import { compareCanonicalWorkroomText, canonicalWorkroomJson, digestCanonicalWorkroomValue, } from './canonical-value.js';
|
|
5
|
+
import { assertWorkflowPlanProposal, } from './workflow-plan-builder.js';
|
|
6
|
+
import { assertWorkflowPlanRevisionCandidate, computeWorkflowPlanRevisionDiff, } from './plan-revision.js';
|
|
7
|
+
import { createAcceptanceDecisionInput, createAcceptanceContractPinInput, assertAcceptanceContract, freezeAcceptanceContract, decideTaskAcceptance, } from './acceptance-policy.js';
|
|
8
|
+
import { decideWorkroom, replayWorkroom } from './kernel-state.js';
|
|
9
|
+
import { decideReviewerClaim, decideReviewerVerdict, decideSponsorGate, } from './acceptance-control.js';
|
|
10
|
+
import { materializeWorkroomRemoteAssignment, normalizeWorkroomRemoteAssignmentClaimRequest, parseWorkroomRemoteAssignmentIssuance, workroomRemoteAssignmentId, workroomRemoteAssignmentRequestDigest, } from './remote-assignment-issuance.js';
|
|
11
|
+
import { materializeWorkroomLocalAssignment, normalizeWorkroomLocalAssignmentClaimRequest, parseWorkroomLocalAssignmentIssuance, workroomLocalAssignmentId, workroomLocalAssignmentRequestDigest, } from './local-assignment-issuance.js';
|
|
12
|
+
import { decideWorkroomSchedule, getWorkroomScheduledTaskSnapshot, parseWorkroomPriorityChangeProposal, } from './workroom-scheduler.js';
|
|
13
|
+
import { decideWorkroomPreemptionTimeout, replayWorkroomPreemptions, } from './workroom-preemption.js';
|
|
14
|
+
import { WorkroomPriorityUnauthorizedError, } from './scheduler-priority-control.js';
|
|
15
|
+
import { WorkroomPlanGateUnauthorizedError, } from './plan-approval-control.js';
|
|
16
|
+
/** The sole command and state-transition authority for Workroom Run facts. */
|
|
17
|
+
export class WorkroomKernel {
|
|
18
|
+
#journal;
|
|
19
|
+
#now;
|
|
20
|
+
#createId;
|
|
21
|
+
#acceptancePolicy;
|
|
22
|
+
#acceptanceAuthority;
|
|
23
|
+
#assignmentHeartbeatLeaseMs;
|
|
24
|
+
#remoteAssignmentAuthority;
|
|
25
|
+
#localAssignmentAuthority;
|
|
26
|
+
#planGateAuthority;
|
|
27
|
+
#priorityAuthority;
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.#journal = options.journal;
|
|
30
|
+
this.#now = options.now ?? Date.now;
|
|
31
|
+
this.#createId = options.createId ?? (() => randomUUID());
|
|
32
|
+
this.#acceptancePolicy = options.acceptancePolicy;
|
|
33
|
+
this.#acceptanceAuthority = options.acceptanceAuthority;
|
|
34
|
+
this.#assignmentHeartbeatLeaseMs = options.assignmentHeartbeatLeaseMs ?? 30_000;
|
|
35
|
+
this.#remoteAssignmentAuthority = options.remoteAssignmentAuthority;
|
|
36
|
+
this.#localAssignmentAuthority = options.localAssignmentAuthority;
|
|
37
|
+
this.#planGateAuthority = options.planGateAuthority;
|
|
38
|
+
this.#priorityAuthority = options.priorityAuthority;
|
|
39
|
+
if (!Number.isSafeInteger(this.#assignmentHeartbeatLeaseMs)
|
|
40
|
+
|| this.#assignmentHeartbeatLeaseMs < 1) {
|
|
41
|
+
throw new Error('Assignment heartbeat lease must be a positive safe integer');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async createRun(input) {
|
|
45
|
+
if (!input.projectId.trim())
|
|
46
|
+
throw new Error('Workroom projectId is required');
|
|
47
|
+
if (!input.title.trim())
|
|
48
|
+
throw new Error('Workroom title is required');
|
|
49
|
+
const projectId = input.projectId.trim();
|
|
50
|
+
const title = input.title.trim();
|
|
51
|
+
const runId = input.runId ?? this.#createId();
|
|
52
|
+
assertRunId(runId);
|
|
53
|
+
const existing = await this.#journal.read(runId);
|
|
54
|
+
if (existing.length > 0)
|
|
55
|
+
throw new Error(`Workroom run ${runId} already exists`);
|
|
56
|
+
await this.#journal.append(runId, -1, [this.#event('run.created', {
|
|
57
|
+
projectId,
|
|
58
|
+
title,
|
|
59
|
+
})]);
|
|
60
|
+
return this.read(projectId, runId);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Atomic, exact-replay admission of an Orchestrator proposal. The model can
|
|
64
|
+
* only provide a validated WorkflowPlanProposal; this Kernel method is the
|
|
65
|
+
* sole writer that materializes Run and Task facts.
|
|
66
|
+
*/
|
|
67
|
+
async admitWorkflowPlan(input) {
|
|
68
|
+
const normalized = normalizePlanAdmission(input);
|
|
69
|
+
const runId = planAdmissionRunId(normalized.operationId);
|
|
70
|
+
const admittedPayload = Object.freeze({
|
|
71
|
+
operationId: normalized.operationId,
|
|
72
|
+
sourceEventRef: normalized.sourceEventRef,
|
|
73
|
+
sourceEventDigest: normalized.sourceEventDigest,
|
|
74
|
+
orchestratorAgentDefinitionId: normalized.orchestratorAgentDefinitionId,
|
|
75
|
+
plan: normalized.plan,
|
|
76
|
+
schedulerPolicy: normalized.plan.schedulerPolicy,
|
|
77
|
+
});
|
|
78
|
+
const taskDrafts = normalized.plan.tasks.flatMap(task => {
|
|
79
|
+
const draft = this.#event('task.planned', {
|
|
80
|
+
taskKey: task.key,
|
|
81
|
+
title: task.title,
|
|
82
|
+
required: task.required,
|
|
83
|
+
maxAttempts: task.maxAttempts,
|
|
84
|
+
role: task.role,
|
|
85
|
+
dependsOn: task.dependsOn,
|
|
86
|
+
requires: task.requires,
|
|
87
|
+
sponsorLane: task.scheduler.sponsorLane,
|
|
88
|
+
localRank: task.scheduler.localRank,
|
|
89
|
+
deadline: task.scheduler.deadline,
|
|
90
|
+
enqueuedAt: task.scheduler.enqueuedAt,
|
|
91
|
+
preemptibility: task.scheduler.preemptibility,
|
|
92
|
+
...(task.approvalGate ? { approvalGate: task.approvalGate } : {}),
|
|
93
|
+
});
|
|
94
|
+
return [
|
|
95
|
+
draft,
|
|
96
|
+
...(task.approvalGate
|
|
97
|
+
? [this.#event('task.blocked', {
|
|
98
|
+
taskKey: task.key,
|
|
99
|
+
blockerId: task.approvalGate.id,
|
|
100
|
+
kind: 'approval',
|
|
101
|
+
owner: task.approvalGate.owner,
|
|
102
|
+
reason: `Workflow Plan Sponsor Gate ${task.approvalGate.id}`,
|
|
103
|
+
deadline: task.approvalGate.deadline,
|
|
104
|
+
})]
|
|
105
|
+
: []),
|
|
106
|
+
];
|
|
107
|
+
});
|
|
108
|
+
const drafts = Object.freeze([
|
|
109
|
+
this.#event('run.created', {
|
|
110
|
+
projectId: normalized.projectId,
|
|
111
|
+
title: normalized.title,
|
|
112
|
+
}),
|
|
113
|
+
this.#event('plan.admitted', admittedPayload),
|
|
114
|
+
...taskDrafts,
|
|
115
|
+
]);
|
|
116
|
+
let existing = await this.#journal.read(runId);
|
|
117
|
+
if (existing.length === 0) {
|
|
118
|
+
try {
|
|
119
|
+
await this.#journal.append(runId, -1, drafts);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (!(error instanceof WorkroomSequenceConflictError))
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
existing = await this.#journal.read(runId);
|
|
126
|
+
}
|
|
127
|
+
assertExactPlanAdmission(existing, normalized, admittedPayload);
|
|
128
|
+
const state = replayWorkroom(existing);
|
|
129
|
+
const receiptRef = `workroom-run:${runId}:plan:${encodeURIComponent(normalized.plan.proposalId)}`;
|
|
130
|
+
return Object.freeze({
|
|
131
|
+
runId,
|
|
132
|
+
receiptRef,
|
|
133
|
+
receiptDigest: digestCanonicalWorkroomValue({
|
|
134
|
+
version: 1,
|
|
135
|
+
runId,
|
|
136
|
+
operationId: normalized.operationId,
|
|
137
|
+
planDigest: normalized.plan.digest,
|
|
138
|
+
sourceEventDigest: normalized.sourceEventDigest,
|
|
139
|
+
}),
|
|
140
|
+
state,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** Kernel CAS admission for a non-authoritative, complete Plan Revision proposal. */
|
|
144
|
+
async admitPlanRevision(candidate) {
|
|
145
|
+
assertWorkflowPlanRevisionCandidate(candidate);
|
|
146
|
+
const events = await this.#journal.read(candidate.runId);
|
|
147
|
+
if (events.length === 0)
|
|
148
|
+
throw new Error(`Workroom run ${candidate.runId} not found`);
|
|
149
|
+
const state = replayWorkroom(events);
|
|
150
|
+
assertProject(state, candidate.projectId);
|
|
151
|
+
const current = currentWorkflowPlan(events);
|
|
152
|
+
const replay = events.find(event => event.type === 'plan.revision_applied'
|
|
153
|
+
&& event.payload.candidate?.proposalId === candidate.proposalId);
|
|
154
|
+
if (replay) {
|
|
155
|
+
const persisted = replay.payload.candidate;
|
|
156
|
+
if (canonicalWorkroomJson(persisted) !== canonicalWorkroomJson(candidate)) {
|
|
157
|
+
throw new Error(`Plan Revision proposal replay payload drift: ${candidate.proposalId}`);
|
|
158
|
+
}
|
|
159
|
+
return Object.freeze({
|
|
160
|
+
status: 'applied', planRevision: Number(replay.payload.planRevision), duplicate: true, state,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (candidate.expectedSequence !== state.sequence
|
|
164
|
+
|| candidate.basePlanRevision !== current.revision
|
|
165
|
+
|| candidate.basePlanDigest !== current.plan.digest) {
|
|
166
|
+
return Object.freeze({
|
|
167
|
+
status: 'stale', planRevision: current.revision, actualSequence: state.sequence,
|
|
168
|
+
actualPlanDigest: current.plan.digest,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const expectedTaskKeys = current.plan.tasks.map(task => task.key).sort();
|
|
172
|
+
const candidateTaskKeys = Object.keys(candidate.baseTaskRevisions).sort();
|
|
173
|
+
if (canonicalWorkroomJson(expectedTaskKeys) !== canonicalWorkroomJson(candidateTaskKeys)) {
|
|
174
|
+
return Object.freeze({
|
|
175
|
+
status: 'rejected', planRevision: current.revision,
|
|
176
|
+
reason: 'Plan Revision base Task revisions are incomplete for the current Plan',
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
for (const [taskKey, revision] of Object.entries(candidate.baseTaskRevisions)) {
|
|
180
|
+
if (state.tasks[taskKey]?.revision !== revision) {
|
|
181
|
+
return Object.freeze({
|
|
182
|
+
status: 'stale', planRevision: current.revision, actualSequence: state.sequence,
|
|
183
|
+
actualPlanDigest: current.plan.digest,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
let recomputed;
|
|
188
|
+
try {
|
|
189
|
+
recomputed = computeWorkflowPlanRevisionDiff(current.plan, candidate.nextPlan, candidate.baseTaskRevisions);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
return Object.freeze({
|
|
193
|
+
status: 'rejected', planRevision: current.revision,
|
|
194
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
if (canonicalWorkroomJson(recomputed) !== canonicalWorkroomJson(candidate.diff)) {
|
|
198
|
+
return Object.freeze({
|
|
199
|
+
status: 'rejected', planRevision: current.revision,
|
|
200
|
+
reason: 'Plan Revision claimed diff differs from the Kernel recomputation',
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
const reused = recomputed.added.filter(task => state.tasks[task.key]).map(task => task.key).sort();
|
|
204
|
+
if (reused.length > 0) {
|
|
205
|
+
return Object.freeze({
|
|
206
|
+
status: 'rejected', planRevision: current.revision,
|
|
207
|
+
reason: `Plan Revision cannot reuse historical Task keys: ${reused.join(', ')}`,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
const changedKeys = [...recomputed.replaced, ...recomputed.removed].map(change => change.taskKey);
|
|
211
|
+
const active = changedKeys.filter(key => {
|
|
212
|
+
const status = state.tasks[key]?.status;
|
|
213
|
+
return status === 'executing' || status === 'awaiting_acceptance' || status === 'cancelling';
|
|
214
|
+
}).sort();
|
|
215
|
+
if (active.length > 0) {
|
|
216
|
+
return Object.freeze({
|
|
217
|
+
status: 'preemption_required', planRevision: current.revision, taskKeys: Object.freeze(active),
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
const immutable = changedKeys.filter(key => state.tasks[key]?.status === 'accepted').sort();
|
|
221
|
+
if (immutable.length > 0) {
|
|
222
|
+
return Object.freeze({
|
|
223
|
+
status: 'rejected', planRevision: current.revision,
|
|
224
|
+
reason: `Accepted Tasks are immutable: ${immutable.join(', ')}`,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
const planRevision = current.revision + 1;
|
|
228
|
+
const drafts = [this.#event('plan.revision_applied', {
|
|
229
|
+
candidate,
|
|
230
|
+
planRevision,
|
|
231
|
+
recomputedDiffDigest: digestCanonicalWorkroomValue(recomputed),
|
|
232
|
+
})];
|
|
233
|
+
for (const task of recomputed.added)
|
|
234
|
+
drafts.push(...this.#planTaskDrafts(task));
|
|
235
|
+
for (const replacement of recomputed.replaced) {
|
|
236
|
+
drafts.push(this.#event('task.plan_revised', {
|
|
237
|
+
...planTaskPayload(replacement.task),
|
|
238
|
+
expectedTaskRevision: replacement.expectedTaskRevision,
|
|
239
|
+
newTaskRevision: replacement.expectedTaskRevision + 1,
|
|
240
|
+
reason: candidate.reason,
|
|
241
|
+
}));
|
|
242
|
+
if (replacement.task.approvalGate) {
|
|
243
|
+
drafts.push(this.#planTaskBlockerDraft(replacement.task));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
for (const removal of recomputed.removed) {
|
|
247
|
+
drafts.push(this.#event('task.cancelled', {
|
|
248
|
+
taskKey: removal.taskKey,
|
|
249
|
+
reason: `Removed by Plan Revision ${candidate.proposalId}: ${candidate.reason}`,
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
try {
|
|
253
|
+
await this.#journal.append(candidate.runId, candidate.expectedSequence, drafts);
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
if (!(error instanceof WorkroomSequenceConflictError))
|
|
257
|
+
throw error;
|
|
258
|
+
const latestEvents = await this.#journal.read(candidate.runId);
|
|
259
|
+
const latest = currentWorkflowPlan(latestEvents);
|
|
260
|
+
return Object.freeze({
|
|
261
|
+
status: 'stale', planRevision: latest.revision,
|
|
262
|
+
actualSequence: latestEvents.at(-1)?.sequence ?? -1,
|
|
263
|
+
actualPlanDigest: latest.plan.digest,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
return Object.freeze({
|
|
267
|
+
status: 'applied', planRevision, duplicate: false,
|
|
268
|
+
state: await this.read(candidate.projectId, candidate.runId),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/** Exact authority verification followed by one Scheduler priority Journal fact. */
|
|
272
|
+
async commitPriorityChange(value) {
|
|
273
|
+
const proposal = parseWorkroomPriorityChangeProposal(value);
|
|
274
|
+
const events = await this.#journal.read(proposal.runId);
|
|
275
|
+
if (events.length === 0)
|
|
276
|
+
throw new Error(`Workroom run ${proposal.runId} not found`);
|
|
277
|
+
const duplicate = events.find(event => event.type === 'scheduler.priority_changed'
|
|
278
|
+
&& event.payload.proposalId === proposal.proposalId);
|
|
279
|
+
if (duplicate) {
|
|
280
|
+
const persisted = { ...duplicate.payload };
|
|
281
|
+
delete persisted.authorizedBy;
|
|
282
|
+
if (canonicalWorkroomJson(persisted) !== canonicalWorkroomJson(proposal)) {
|
|
283
|
+
throw new Error(`Workroom priority proposal replay payload drift: ${proposal.proposalId}`);
|
|
284
|
+
}
|
|
285
|
+
return Object.freeze({
|
|
286
|
+
status: 'duplicate', proposalId: proposal.proposalId, sequence: duplicate.sequence,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
const state = replayWorkroom(events);
|
|
290
|
+
assertProject(state, proposal.projectId);
|
|
291
|
+
if (state.sequence !== proposal.expectedSequence) {
|
|
292
|
+
throw new WorkroomSequenceConflictError(proposal.runId, proposal.expectedSequence, state.sequence);
|
|
293
|
+
}
|
|
294
|
+
const currentTask = getWorkroomScheduledTaskSnapshot(events, proposal.taskKey);
|
|
295
|
+
if (currentTask.taskRevision !== proposal.taskRevision
|
|
296
|
+
|| currentTask.sponsorLane !== proposal.currentLane) {
|
|
297
|
+
throw new Error('Workroom priority proposal targets a stale Task revision or lane');
|
|
298
|
+
}
|
|
299
|
+
if (proposal.deadline < state.now)
|
|
300
|
+
throw new Error('Workroom priority proposal is expired');
|
|
301
|
+
const authority = this.#priorityAuthority;
|
|
302
|
+
if (!authority)
|
|
303
|
+
throw new Error('Workroom priority authority is not installed');
|
|
304
|
+
const planAuthority = currentWorkflowPlan(events).plan.authority;
|
|
305
|
+
const authorizationInput = Object.freeze({
|
|
306
|
+
version: 1,
|
|
307
|
+
proposal,
|
|
308
|
+
projectAuthority: Object.freeze({
|
|
309
|
+
catalogRevision: planAuthority.projectRevision,
|
|
310
|
+
projectDigest: planAuthority.projectDigest,
|
|
311
|
+
orchestratorAgentDefinitionId: planAuthority.orchestratorAgentDefinitionId,
|
|
312
|
+
}),
|
|
313
|
+
currentTask,
|
|
314
|
+
});
|
|
315
|
+
const authorization = await authority.authorize(authorizationInput);
|
|
316
|
+
if (!authorization.authorized)
|
|
317
|
+
throw new WorkroomPriorityUnauthorizedError(authorization.reason);
|
|
318
|
+
if (authorization.authority !== proposal.authority
|
|
319
|
+
|| authorization.principalId !== proposal.principalId
|
|
320
|
+
|| authorization.authorizationRef !== proposal.authorityRef
|
|
321
|
+
|| authorization.proposalDigest !== proposal.digest) {
|
|
322
|
+
throw new Error('Workroom priority authority returned a stale or mismatched exact proof');
|
|
323
|
+
}
|
|
324
|
+
if (proposal.requestedLane !== proposal.currentLane && authorization.authority !== 'sponsor') {
|
|
325
|
+
throw new Error('Only an exact Sponsor authority may move a Task across lanes');
|
|
326
|
+
}
|
|
327
|
+
const appended = await this.#journal.append(proposal.runId, proposal.expectedSequence, [this.#event('scheduler.priority_changed', { ...proposal, authorizedBy: authorization.authorizationRef })]);
|
|
328
|
+
return Object.freeze({
|
|
329
|
+
status: 'committed', proposalId: proposal.proposalId, sequence: appended[0].sequence,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
/** Typed pre-execution Sponsor decision; generic blocker resolution is forbidden for approval gates. */
|
|
333
|
+
async decidePlanApprovalGate(input) {
|
|
334
|
+
const normalized = normalizePlanGateDecision(input);
|
|
335
|
+
const requestDigest = digestCanonicalWorkroomValue(normalized);
|
|
336
|
+
let events = await this.#journal.read(normalized.runId);
|
|
337
|
+
const replay = events.find(event => event.type === 'plan_gate.decided'
|
|
338
|
+
&& event.payload.operationId === normalized.operationId);
|
|
339
|
+
if (replay) {
|
|
340
|
+
if (replay.payload.requestDigest !== requestDigest) {
|
|
341
|
+
throw new Error(`Plan Sponsor Gate operation payload conflict: ${normalized.operationId}`);
|
|
342
|
+
}
|
|
343
|
+
const state = replayWorkroom(events);
|
|
344
|
+
assertProject(state, normalized.projectId);
|
|
345
|
+
return planGateReceipt('duplicate', normalized, requestDigest, state);
|
|
346
|
+
}
|
|
347
|
+
const state = replayWorkroom(events);
|
|
348
|
+
assertProject(state, normalized.projectId);
|
|
349
|
+
if (state.sequence !== normalized.expectedSequence) {
|
|
350
|
+
throw new WorkroomSequenceConflictError(normalized.runId, normalized.expectedSequence, state.sequence);
|
|
351
|
+
}
|
|
352
|
+
const planEvents = events.filter(event => event.type === 'plan.admitted');
|
|
353
|
+
if (planEvents.length !== 1)
|
|
354
|
+
throw new Error('Plan Sponsor Gate requires one exact admitted Plan');
|
|
355
|
+
const plan = planEvents[0].payload.plan;
|
|
356
|
+
assertWorkflowPlanProposal(plan);
|
|
357
|
+
const plannedTask = plan.tasks.find(task => task.key === normalized.taskKey);
|
|
358
|
+
const task = state.tasks[normalized.taskKey];
|
|
359
|
+
if (!plannedTask || !task || task.revision !== normalized.taskRevision) {
|
|
360
|
+
throw new Error('Plan Sponsor Gate decision targets a stale Task revision');
|
|
361
|
+
}
|
|
362
|
+
const gate = plannedTask.approvalGate;
|
|
363
|
+
if (!gate || gate.id !== normalized.gateId
|
|
364
|
+
|| !task.blockers.some(blocker => blocker.id === gate.id && blocker.kind === 'approval')) {
|
|
365
|
+
throw new Error('Plan Sponsor Gate decision targets an absent or settled gate');
|
|
366
|
+
}
|
|
367
|
+
const authority = this.#planGateAuthority;
|
|
368
|
+
if (!authority)
|
|
369
|
+
throw new Error('Plan Sponsor Gate authority is not installed');
|
|
370
|
+
const authorizationInput = Object.freeze({
|
|
371
|
+
version: 1,
|
|
372
|
+
...normalized,
|
|
373
|
+
planProposalId: plan.proposalId,
|
|
374
|
+
planDigest: plan.digest,
|
|
375
|
+
projectRevision: plan.authority.projectRevision,
|
|
376
|
+
projectDigest: plan.authority.projectDigest,
|
|
377
|
+
sourceParameterDigest: plan.parameterDigest,
|
|
378
|
+
profileRevisionId: plan.authority.profileRevisionId,
|
|
379
|
+
profileDigest: plan.authority.profileDigest,
|
|
380
|
+
policyRevisionId: gate.policyRevisionId,
|
|
381
|
+
policyDigest: gate.policyDigest,
|
|
382
|
+
gateOwner: gate.owner,
|
|
383
|
+
gateDeadline: gate.deadline,
|
|
384
|
+
});
|
|
385
|
+
const authorization = await authority.authorize(authorizationInput);
|
|
386
|
+
if (!authorization.authorized)
|
|
387
|
+
throw new WorkroomPlanGateUnauthorizedError(authorization.reason);
|
|
388
|
+
if (authorization.principalId !== normalized.sponsorPrincipalId
|
|
389
|
+
|| typeof authorization.authorizationRef !== 'string'
|
|
390
|
+
|| !authorization.authorizationRef.trim()) {
|
|
391
|
+
throw new Error('Plan Sponsor Gate authority returned a stale principal proof');
|
|
392
|
+
}
|
|
393
|
+
const audit = this.#event('plan_gate.decided', {
|
|
394
|
+
operationId: normalized.operationId,
|
|
395
|
+
requestDigest,
|
|
396
|
+
taskKey: normalized.taskKey,
|
|
397
|
+
taskRevision: normalized.taskRevision,
|
|
398
|
+
gateId: normalized.gateId,
|
|
399
|
+
planDigest: plan.digest,
|
|
400
|
+
policyRevisionId: gate.policyRevisionId,
|
|
401
|
+
policyDigest: gate.policyDigest,
|
|
402
|
+
decision: normalized.decision,
|
|
403
|
+
sponsorPrincipalId: authorization.principalId,
|
|
404
|
+
authorizedBy: authorization.authorizationRef,
|
|
405
|
+
reasonDigest: digestCanonicalWorkroomValue({ reason: normalized.reason }),
|
|
406
|
+
});
|
|
407
|
+
const action = normalized.decision === 'approve'
|
|
408
|
+
? [this.#event('task.blocker_resolved', {
|
|
409
|
+
taskKey: normalized.taskKey,
|
|
410
|
+
blockerId: normalized.gateId,
|
|
411
|
+
})]
|
|
412
|
+
: normalized.decision === 'cancel'
|
|
413
|
+
? decideWorkroom(state, {
|
|
414
|
+
type: 'cancel_run',
|
|
415
|
+
reason: `Plan Sponsor Gate ${normalized.gateId} cancelled`,
|
|
416
|
+
controlDeadline: state.now,
|
|
417
|
+
}, (type, payload) => this.#event(type, payload))
|
|
418
|
+
: [this.#event('task.failed', {
|
|
419
|
+
taskKey: normalized.taskKey,
|
|
420
|
+
reason: `Plan Sponsor Gate ${normalized.gateId} ${normalized.decision}`,
|
|
421
|
+
})];
|
|
422
|
+
await this.#journal.append(normalized.runId, normalized.expectedSequence, [audit, ...action]);
|
|
423
|
+
events = await this.#journal.read(normalized.runId);
|
|
424
|
+
return planGateReceipt('committed', normalized, requestDigest, replayWorkroom(events));
|
|
425
|
+
}
|
|
426
|
+
/** Kernel-owned CAS commit for one exact deterministic Scheduler selection. */
|
|
427
|
+
async commitSchedulerDecision(decision) {
|
|
428
|
+
const events = await this.#journal.read(decision.runId);
|
|
429
|
+
if (events.length === 0)
|
|
430
|
+
throw new Error(`Workroom run ${decision.runId} not found`);
|
|
431
|
+
const decisionEventType = decision.type === 'dispatch_task'
|
|
432
|
+
? 'scheduler.dispatch_requested'
|
|
433
|
+
: 'scheduler.preemption_requested';
|
|
434
|
+
const duplicate = events.find(event => event.type === decisionEventType
|
|
435
|
+
&& event.payload.decisionId === decision.decisionId);
|
|
436
|
+
if (duplicate) {
|
|
437
|
+
if (canonicalWorkroomJson(duplicate.payload) !== canonicalWorkroomJson(decision)) {
|
|
438
|
+
throw new Error(`Workroom Scheduler decision replay payload drift: ${decision.decisionId}`);
|
|
439
|
+
}
|
|
440
|
+
return Object.freeze({
|
|
441
|
+
status: 'duplicate',
|
|
442
|
+
decisionId: decision.decisionId,
|
|
443
|
+
sequence: duplicate.sequence,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
const expected = decideWorkroomSchedule(events);
|
|
447
|
+
if (!expected || canonicalWorkroomJson(expected) !== canonicalWorkroomJson(decision)) {
|
|
448
|
+
throw new Error('Workroom Scheduler decision is stale or differs from the deterministic Kernel decision');
|
|
449
|
+
}
|
|
450
|
+
const state = replayWorkroom(events);
|
|
451
|
+
assertProject(state, decision.projectId);
|
|
452
|
+
if (state.sequence !== decision.expectedSequence) {
|
|
453
|
+
throw new WorkroomSequenceConflictError(decision.runId, decision.expectedSequence, state.sequence);
|
|
454
|
+
}
|
|
455
|
+
const drafts = decision.type === 'dispatch_task'
|
|
456
|
+
? [Object.freeze({
|
|
457
|
+
eventId: decision.decisionId,
|
|
458
|
+
occurredAt: state.now,
|
|
459
|
+
type: 'scheduler.dispatch_requested',
|
|
460
|
+
payload: decision,
|
|
461
|
+
})]
|
|
462
|
+
: [
|
|
463
|
+
Object.freeze({
|
|
464
|
+
eventId: decision.decisionId,
|
|
465
|
+
occurredAt: state.now,
|
|
466
|
+
type: 'scheduler.preemption_requested',
|
|
467
|
+
payload: decision,
|
|
468
|
+
}),
|
|
469
|
+
this.#event('assignment.checkpoint_requested', {
|
|
470
|
+
decisionId: decision.decisionId,
|
|
471
|
+
assignmentId: decision.assignmentId,
|
|
472
|
+
envelopeDigest: decision.assignmentEnvelopeDigest,
|
|
473
|
+
reservedTaskKey: decision.reservedTaskKey,
|
|
474
|
+
requestedAt: decision.requestedAt,
|
|
475
|
+
deadline: decision.deadline,
|
|
476
|
+
takeoverFence: decision.takeoverFence,
|
|
477
|
+
owner: decision.owner,
|
|
478
|
+
allowedSuccessors: decision.allowedSuccessors,
|
|
479
|
+
}),
|
|
480
|
+
];
|
|
481
|
+
const appended = await this.#journal.append(decision.runId, decision.expectedSequence, drafts);
|
|
482
|
+
if (appended.length !== drafts.length)
|
|
483
|
+
throw new Error('Workroom Scheduler Kernel append did not commit one decision batch');
|
|
484
|
+
return Object.freeze({
|
|
485
|
+
status: 'committed',
|
|
486
|
+
decisionId: decision.decisionId,
|
|
487
|
+
sequence: appended.at(-1).sequence,
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
async execute(projectId, runId, command) {
|
|
491
|
+
assertProjectId(projectId);
|
|
492
|
+
const scopedProjectId = projectId.trim();
|
|
493
|
+
assertRunId(runId);
|
|
494
|
+
const state = await this.#readUnscoped(runId);
|
|
495
|
+
assertProject(state, scopedProjectId);
|
|
496
|
+
const events = command.type === 'advance_clock' ? await this.#journal.read(runId) : undefined;
|
|
497
|
+
const drafts = [
|
|
498
|
+
...decideWorkroom(state, command, (type, payload) => this.#event(type, payload)),
|
|
499
|
+
...(command.type === 'advance_clock' && events
|
|
500
|
+
? decideWorkroomPreemptionTimeout(events, command.now, (type, payload) => this.#event(type, payload))
|
|
501
|
+
: []),
|
|
502
|
+
];
|
|
503
|
+
await this.#journal.append(runId, state.sequence, drafts);
|
|
504
|
+
return drafts.length === 0 ? state : this.read(scopedProjectId, runId);
|
|
505
|
+
}
|
|
506
|
+
/** Atomically persists the local Assignment claim and its exact Envelope. */
|
|
507
|
+
async previewLocalAssignment(input) {
|
|
508
|
+
const request = normalizeWorkroomLocalAssignmentClaimRequest(input);
|
|
509
|
+
const events = await this.#journal.read(request.runId);
|
|
510
|
+
const state = replayWorkroom(events);
|
|
511
|
+
assertProject(state, request.projectId);
|
|
512
|
+
const existing = findLocalAssignmentIssuance(events, request.operationId);
|
|
513
|
+
if (existing)
|
|
514
|
+
assertLocalAssignmentReplay(existing, workroomLocalAssignmentRequestDigest(request));
|
|
515
|
+
const task = state.tasks[request.taskKey];
|
|
516
|
+
if (!task)
|
|
517
|
+
throw new Error(`Task ${request.taskKey} not found`);
|
|
518
|
+
if (!existing && task.status !== 'ready')
|
|
519
|
+
throw new Error(`Task ${task.key} is ${task.status}`);
|
|
520
|
+
return assignmentPreview({
|
|
521
|
+
kind: 'local', assignmentRef: existing?.envelope.assignmentId
|
|
522
|
+
?? workroomLocalAssignmentId(request.operationId),
|
|
523
|
+
claimDigest: digestCanonicalWorkroomValue({ kind: 'local', request }),
|
|
524
|
+
taskRevision: existing?.envelope.taskRevision ?? task.revision,
|
|
525
|
+
kernelSequence: state.sequence,
|
|
526
|
+
kernelStateDigest: digestCanonicalWorkroomValue(events),
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
async findLocalAssignment(input) {
|
|
530
|
+
const request = normalizeWorkroomLocalAssignmentClaimRequest(input);
|
|
531
|
+
const events = await this.#journal.read(request.runId);
|
|
532
|
+
const issued = findLocalAssignmentIssuance(events, request.operationId);
|
|
533
|
+
if (!issued)
|
|
534
|
+
return undefined;
|
|
535
|
+
assertLocalAssignmentReplay(issued, workroomLocalAssignmentRequestDigest(request));
|
|
536
|
+
const state = replayWorkroom(events);
|
|
537
|
+
assertProject(state, request.projectId);
|
|
538
|
+
return Object.freeze({ ...issued, state });
|
|
539
|
+
}
|
|
540
|
+
async issueLocalAssignment(input) {
|
|
541
|
+
const request = normalizeWorkroomLocalAssignmentClaimRequest(input);
|
|
542
|
+
const requestDigest = workroomLocalAssignmentRequestDigest(request);
|
|
543
|
+
const existingEvents = await this.#journal.read(request.runId);
|
|
544
|
+
const replayed = findLocalAssignmentIssuance(existingEvents, request.operationId);
|
|
545
|
+
if (replayed) {
|
|
546
|
+
assertLocalAssignmentReplay(replayed, requestDigest);
|
|
547
|
+
const state = replayWorkroom(existingEvents);
|
|
548
|
+
assertProject(state, request.projectId);
|
|
549
|
+
return Object.freeze({ ...replayed, state });
|
|
550
|
+
}
|
|
551
|
+
const authorityPort = this.#localAssignmentAuthority;
|
|
552
|
+
if (!authorityPort)
|
|
553
|
+
throw new Error('Local Assignment authority resolver is not installed');
|
|
554
|
+
const state = replayWorkroom(existingEvents);
|
|
555
|
+
assertProject(state, request.projectId);
|
|
556
|
+
const task = state.tasks[request.taskKey];
|
|
557
|
+
if (!task)
|
|
558
|
+
throw new Error(`Task ${request.taskKey} not found`);
|
|
559
|
+
if (task.status !== 'ready')
|
|
560
|
+
throw new Error(`Task ${task.key} is ${task.status}`);
|
|
561
|
+
if (!task.acceptanceContract) {
|
|
562
|
+
throw new Error(`Task ${task.key} Acceptance Contract is not pinned`);
|
|
563
|
+
}
|
|
564
|
+
const attempt = task.attempt + 1;
|
|
565
|
+
const fence = Object.values(state.assignments)
|
|
566
|
+
.filter(assignment => assignment.taskKey === task.key)
|
|
567
|
+
.reduce((highest, assignment) => Math.max(highest, assignment.fence), 0) + 1;
|
|
568
|
+
const assignmentId = workroomLocalAssignmentId(request.operationId);
|
|
569
|
+
const factAnchor = Object.freeze({
|
|
570
|
+
ref: `workroom-journal:${encodeURIComponent(state.runId)}:${state.sequence}`,
|
|
571
|
+
sequence: state.sequence,
|
|
572
|
+
digest: digestCanonicalWorkroomValue(existingEvents),
|
|
573
|
+
});
|
|
574
|
+
const assignment = Object.freeze({
|
|
575
|
+
id: assignmentId,
|
|
576
|
+
revision: 1,
|
|
577
|
+
attempt,
|
|
578
|
+
fence,
|
|
579
|
+
});
|
|
580
|
+
const authority = await authorityPort.resolveLocal(Object.freeze({
|
|
581
|
+
projectId: state.projectId,
|
|
582
|
+
runId: state.runId,
|
|
583
|
+
task: Object.freeze({
|
|
584
|
+
key: task.key,
|
|
585
|
+
revision: task.revision,
|
|
586
|
+
acceptanceContract: task.acceptanceContract,
|
|
587
|
+
}),
|
|
588
|
+
assignment,
|
|
589
|
+
requestedAgentDefinitionId: request.agentDefinitionId,
|
|
590
|
+
factAnchor,
|
|
591
|
+
}));
|
|
592
|
+
const timing = this.#trustedAssignmentTiming('Local');
|
|
593
|
+
const issued = materializeWorkroomLocalAssignment({
|
|
594
|
+
request,
|
|
595
|
+
taskRevision: task.revision,
|
|
596
|
+
assignmentId,
|
|
597
|
+
assignmentRevision: assignment.revision,
|
|
598
|
+
attempt,
|
|
599
|
+
fence,
|
|
600
|
+
issuedAt: timing.issuedAt,
|
|
601
|
+
factAnchor,
|
|
602
|
+
authority,
|
|
603
|
+
});
|
|
604
|
+
const claimDrafts = decideWorkroom(state, {
|
|
605
|
+
type: 'claim_task',
|
|
606
|
+
taskKey: task.key,
|
|
607
|
+
assignmentId,
|
|
608
|
+
assignmentRevision: issued.envelope.assignmentRevision,
|
|
609
|
+
fence,
|
|
610
|
+
envelopeDigest: issued.envelope.digest,
|
|
611
|
+
owner: issued.envelope.principalId,
|
|
612
|
+
role: issued.envelope.role,
|
|
613
|
+
leaseExpiresAt: timing.leaseExpiresAt,
|
|
614
|
+
}, (type, payload) => this.#event(type, payload));
|
|
615
|
+
const drafts = Object.freeze([
|
|
616
|
+
...claimDrafts,
|
|
617
|
+
this.#event('local_execution.requested', issued),
|
|
618
|
+
]);
|
|
619
|
+
try {
|
|
620
|
+
await this.#journal.append(request.runId, state.sequence, drafts);
|
|
621
|
+
}
|
|
622
|
+
catch (error) {
|
|
623
|
+
if (!(error instanceof WorkroomSequenceConflictError))
|
|
624
|
+
throw error;
|
|
625
|
+
const winnerEvents = await this.#journal.read(request.runId);
|
|
626
|
+
const winner = findLocalAssignmentIssuance(winnerEvents, request.operationId);
|
|
627
|
+
if (!winner)
|
|
628
|
+
throw error;
|
|
629
|
+
assertLocalAssignmentReplay(winner, requestDigest);
|
|
630
|
+
const winnerState = replayWorkroom(winnerEvents);
|
|
631
|
+
assertProject(winnerState, request.projectId);
|
|
632
|
+
return Object.freeze({ ...winner, state: winnerState });
|
|
633
|
+
}
|
|
634
|
+
return Object.freeze({
|
|
635
|
+
...issued,
|
|
636
|
+
state: await this.read(request.projectId, request.runId),
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Atomically persists the Kernel claim and its exact Remote Dispatch intent.
|
|
641
|
+
* A caller names only the desired definition/endpoint; the current-generation
|
|
642
|
+
* authority port supplies every executable snapshot and grant.
|
|
643
|
+
*/
|
|
644
|
+
async previewRemoteAssignment(input) {
|
|
645
|
+
const request = normalizeWorkroomRemoteAssignmentClaimRequest(input);
|
|
646
|
+
const events = await this.#journal.read(request.runId);
|
|
647
|
+
const state = replayWorkroom(events);
|
|
648
|
+
assertProject(state, request.projectId);
|
|
649
|
+
const existing = findRemoteAssignmentIssuance(events, request.operationId);
|
|
650
|
+
if (existing)
|
|
651
|
+
assertRemoteAssignmentReplay(existing, workroomRemoteAssignmentRequestDigest(request));
|
|
652
|
+
const task = state.tasks[request.taskKey];
|
|
653
|
+
if (!task)
|
|
654
|
+
throw new Error(`Task ${request.taskKey} not found`);
|
|
655
|
+
if (!existing && task.status !== 'ready')
|
|
656
|
+
throw new Error(`Task ${task.key} is ${task.status}`);
|
|
657
|
+
return assignmentPreview({
|
|
658
|
+
kind: 'remote', assignmentRef: existing?.envelope.assignmentId
|
|
659
|
+
?? workroomRemoteAssignmentId(request.operationId),
|
|
660
|
+
claimDigest: digestCanonicalWorkroomValue({ kind: 'remote', request }),
|
|
661
|
+
taskRevision: existing?.envelope.taskRevision ?? task.revision,
|
|
662
|
+
kernelSequence: state.sequence,
|
|
663
|
+
kernelStateDigest: digestCanonicalWorkroomValue(events),
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
async findRemoteAssignment(input) {
|
|
667
|
+
const request = normalizeWorkroomRemoteAssignmentClaimRequest(input);
|
|
668
|
+
const events = await this.#journal.read(request.runId);
|
|
669
|
+
const issued = findRemoteAssignmentIssuance(events, request.operationId);
|
|
670
|
+
if (!issued)
|
|
671
|
+
return undefined;
|
|
672
|
+
assertRemoteAssignmentReplay(issued, workroomRemoteAssignmentRequestDigest(request));
|
|
673
|
+
const state = replayWorkroom(events);
|
|
674
|
+
assertProject(state, request.projectId);
|
|
675
|
+
return Object.freeze({ ...issued, state });
|
|
676
|
+
}
|
|
677
|
+
async issueRemoteAssignment(input) {
|
|
678
|
+
const request = normalizeWorkroomRemoteAssignmentClaimRequest(input);
|
|
679
|
+
const requestDigest = workroomRemoteAssignmentRequestDigest(request);
|
|
680
|
+
const existingEvents = await this.#journal.read(request.runId);
|
|
681
|
+
const replayed = findRemoteAssignmentIssuance(existingEvents, request.operationId);
|
|
682
|
+
if (replayed) {
|
|
683
|
+
assertRemoteAssignmentReplay(replayed, requestDigest);
|
|
684
|
+
const state = replayWorkroom(existingEvents);
|
|
685
|
+
assertProject(state, request.projectId);
|
|
686
|
+
return Object.freeze({ ...replayed, state });
|
|
687
|
+
}
|
|
688
|
+
const authorityPort = this.#remoteAssignmentAuthority;
|
|
689
|
+
if (!authorityPort) {
|
|
690
|
+
throw new Error('Remote Assignment authority resolver is not installed');
|
|
691
|
+
}
|
|
692
|
+
const state = replayWorkroom(existingEvents);
|
|
693
|
+
assertProject(state, request.projectId);
|
|
694
|
+
const task = state.tasks[request.taskKey];
|
|
695
|
+
if (!task)
|
|
696
|
+
throw new Error(`Task ${request.taskKey} not found`);
|
|
697
|
+
if (task.status !== 'ready')
|
|
698
|
+
throw new Error(`Task ${task.key} is ${task.status}`);
|
|
699
|
+
if (!task.acceptanceContract) {
|
|
700
|
+
throw new Error(`Task ${task.key} Acceptance Contract is not pinned`);
|
|
701
|
+
}
|
|
702
|
+
const attempt = task.attempt + 1;
|
|
703
|
+
const fence = Object.values(state.assignments)
|
|
704
|
+
.filter(assignment => assignment.taskKey === task.key)
|
|
705
|
+
.reduce((highest, assignment) => Math.max(highest, assignment.fence), 0) + 1;
|
|
706
|
+
const assignmentId = workroomRemoteAssignmentId(request.operationId);
|
|
707
|
+
const factAnchor = Object.freeze({
|
|
708
|
+
ref: `workroom-journal:${encodeURIComponent(state.runId)}:${state.sequence}`,
|
|
709
|
+
sequence: state.sequence,
|
|
710
|
+
digest: digestCanonicalWorkroomValue(existingEvents),
|
|
711
|
+
});
|
|
712
|
+
const assignment = Object.freeze({
|
|
713
|
+
id: assignmentId,
|
|
714
|
+
revision: 1,
|
|
715
|
+
attempt,
|
|
716
|
+
fence,
|
|
717
|
+
});
|
|
718
|
+
const authority = await authorityPort.resolve(Object.freeze({
|
|
719
|
+
projectId: state.projectId,
|
|
720
|
+
runId: state.runId,
|
|
721
|
+
task: Object.freeze({
|
|
722
|
+
key: task.key,
|
|
723
|
+
revision: task.revision,
|
|
724
|
+
acceptanceContract: task.acceptanceContract,
|
|
725
|
+
}),
|
|
726
|
+
assignment,
|
|
727
|
+
requestedAgentDefinitionId: request.agentDefinitionId,
|
|
728
|
+
requestedEndpointId: request.endpointId,
|
|
729
|
+
factAnchor,
|
|
730
|
+
}));
|
|
731
|
+
const timing = this.#trustedAssignmentTiming('Remote');
|
|
732
|
+
const leaseExpiresAt = timing.leaseExpiresAt;
|
|
733
|
+
const issued = materializeWorkroomRemoteAssignment({
|
|
734
|
+
request,
|
|
735
|
+
taskRevision: task.revision,
|
|
736
|
+
assignmentId,
|
|
737
|
+
assignmentRevision: assignment.revision,
|
|
738
|
+
attempt,
|
|
739
|
+
fence,
|
|
740
|
+
issuedAt: timing.issuedAt,
|
|
741
|
+
leaseExpiresAt,
|
|
742
|
+
reconcileDeadline: timing.reconcileDeadline,
|
|
743
|
+
acceptanceContract: task.acceptanceContract,
|
|
744
|
+
factAnchor,
|
|
745
|
+
authority,
|
|
746
|
+
});
|
|
747
|
+
const claimDrafts = decideWorkroom(state, {
|
|
748
|
+
type: 'claim_task',
|
|
749
|
+
taskKey: task.key,
|
|
750
|
+
assignmentId,
|
|
751
|
+
assignmentRevision: issued.envelope.assignmentRevision,
|
|
752
|
+
fence,
|
|
753
|
+
envelopeDigest: issued.envelope.digest,
|
|
754
|
+
owner: issued.envelope.principalId,
|
|
755
|
+
role: issued.envelope.role,
|
|
756
|
+
leaseExpiresAt,
|
|
757
|
+
}, (type, payload) => this.#event(type, payload));
|
|
758
|
+
const drafts = Object.freeze([
|
|
759
|
+
...claimDrafts,
|
|
760
|
+
this.#event('remote_dispatch.requested', issued),
|
|
761
|
+
]);
|
|
762
|
+
try {
|
|
763
|
+
await this.#journal.append(request.runId, state.sequence, drafts);
|
|
764
|
+
}
|
|
765
|
+
catch (error) {
|
|
766
|
+
if (!(error instanceof WorkroomSequenceConflictError))
|
|
767
|
+
throw error;
|
|
768
|
+
const winnerEvents = await this.#journal.read(request.runId);
|
|
769
|
+
const winner = findRemoteAssignmentIssuance(winnerEvents, request.operationId);
|
|
770
|
+
if (!winner)
|
|
771
|
+
throw error;
|
|
772
|
+
assertRemoteAssignmentReplay(winner, requestDigest);
|
|
773
|
+
const winnerState = replayWorkroom(winnerEvents);
|
|
774
|
+
assertProject(winnerState, request.projectId);
|
|
775
|
+
return Object.freeze({ ...winner, state: winnerState });
|
|
776
|
+
}
|
|
777
|
+
return Object.freeze({
|
|
778
|
+
...issued,
|
|
779
|
+
state: await this.read(request.projectId, request.runId),
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
async applyAssignmentObservation(envelope, value, expectedSequence) {
|
|
783
|
+
assertAssignmentExecutionEnvelope(envelope);
|
|
784
|
+
const observation = validateAssignmentExecutionObservation(envelope, value);
|
|
785
|
+
if (!Number.isSafeInteger(expectedSequence) || expectedSequence < 0) {
|
|
786
|
+
throw new Error('Assignment observation expectedSequence must be a non-negative safe integer');
|
|
787
|
+
}
|
|
788
|
+
const events = await this.#journal.read(envelope.runId);
|
|
789
|
+
if (events.length === 0)
|
|
790
|
+
throw new Error(`Workroom run ${envelope.runId} not found`);
|
|
791
|
+
const state = replayWorkroom(events);
|
|
792
|
+
assertProject(state, envelope.projectId);
|
|
793
|
+
const task = state.tasks[envelope.taskKey];
|
|
794
|
+
const assignment = state.assignments[envelope.assignmentId];
|
|
795
|
+
if (!task || !assignment
|
|
796
|
+
|| task.revision !== envelope.taskRevision
|
|
797
|
+
|| assignment.taskKey !== task.key
|
|
798
|
+
|| assignment.taskRevision !== envelope.taskRevision
|
|
799
|
+
|| assignment.revision !== envelope.assignmentRevision
|
|
800
|
+
|| assignment.attempt !== envelope.attempt
|
|
801
|
+
|| assignment.fence !== envelope.fence
|
|
802
|
+
|| assignment.envelopeDigest !== envelope.digest
|
|
803
|
+
|| assignment.owner !== envelope.principalId
|
|
804
|
+
|| assignment.role !== envelope.role) {
|
|
805
|
+
throw new Error('Assignment observation Envelope is stale or targets another authority scope');
|
|
806
|
+
}
|
|
807
|
+
const observationDigest = digestCanonicalWorkroomValue(observation);
|
|
808
|
+
const persistedDigest = assignment.observationDigests[observation.observationId];
|
|
809
|
+
if (persistedDigest) {
|
|
810
|
+
if (persistedDigest !== observationDigest) {
|
|
811
|
+
throw new Error(`Assignment observationId conflict: ${observation.observationId}`);
|
|
812
|
+
}
|
|
813
|
+
return state;
|
|
814
|
+
}
|
|
815
|
+
if (task.currentAssignmentId !== assignment.id) {
|
|
816
|
+
throw new Error('Assignment observation Envelope is stale or targets another authority scope');
|
|
817
|
+
}
|
|
818
|
+
if (state.sequence !== expectedSequence) {
|
|
819
|
+
throw new WorkroomSequenceConflictError(envelope.runId, expectedSequence, state.sequence);
|
|
820
|
+
}
|
|
821
|
+
const header = {
|
|
822
|
+
assignmentId: assignment.id,
|
|
823
|
+
observationId: observation.observationId,
|
|
824
|
+
observationDigest,
|
|
825
|
+
envelopeDigest: envelope.digest,
|
|
826
|
+
};
|
|
827
|
+
let draft;
|
|
828
|
+
switch (observation.type) {
|
|
829
|
+
case 'progress':
|
|
830
|
+
requireObservationStatus(assignment.status, ['running']);
|
|
831
|
+
draft = this.#event('assignment.progress', { ...header, progress: observation.progress });
|
|
832
|
+
break;
|
|
833
|
+
case 'heartbeat':
|
|
834
|
+
requireObservationStatus(assignment.status, ['leased', 'running']);
|
|
835
|
+
draft = this.#event('assignment.heartbeat', {
|
|
836
|
+
...header,
|
|
837
|
+
leaseExpiresAt: this.#trustedHeartbeatLeaseExpiry(assignment.leaseExpiresAt),
|
|
838
|
+
});
|
|
839
|
+
break;
|
|
840
|
+
case 'checkpoint':
|
|
841
|
+
requireObservationStatus(assignment.status, ['running']);
|
|
842
|
+
draft = this.#event('assignment.checkpointed', {
|
|
843
|
+
...header,
|
|
844
|
+
checkpointRef: observation.checkpoint.ref,
|
|
845
|
+
checkpointDigest: observation.checkpoint.digest,
|
|
846
|
+
});
|
|
847
|
+
break;
|
|
848
|
+
case 'execution_completed':
|
|
849
|
+
requireObservationStatus(assignment.status, ['running']);
|
|
850
|
+
draft = this.#event('assignment.execution_completed', {
|
|
851
|
+
...header,
|
|
852
|
+
reportRef: observation.completion.report.ref,
|
|
853
|
+
reportDigest: observation.completion.report.digest,
|
|
854
|
+
candidateRef: observation.completion.candidate.ref,
|
|
855
|
+
candidateHash: observation.completion.candidate.hash,
|
|
856
|
+
...(observation.completion.completionReceiptDigest === undefined
|
|
857
|
+
? {}
|
|
858
|
+
: { completionReceiptDigest: observation.completion.completionReceiptDigest }),
|
|
859
|
+
});
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
const preemption = replayWorkroomPreemptions(events).pending;
|
|
863
|
+
const drafts = observation.type === 'checkpoint'
|
|
864
|
+
&& preemption?.assignmentId === assignment.id
|
|
865
|
+
? [
|
|
866
|
+
draft,
|
|
867
|
+
this.#event('scheduler.preemption_checkpoint_acknowledged', {
|
|
868
|
+
decisionId: preemption.decisionId,
|
|
869
|
+
assignmentId: assignment.id,
|
|
870
|
+
envelopeDigest: envelope.digest,
|
|
871
|
+
observationId: observation.observationId,
|
|
872
|
+
observationDigest,
|
|
873
|
+
checkpointRef: observation.checkpoint.ref,
|
|
874
|
+
checkpointDigest: observation.checkpoint.digest,
|
|
875
|
+
assignmentAttempt: assignment.attempt,
|
|
876
|
+
assignmentFence: assignment.fence,
|
|
877
|
+
takeoverFence: preemption.takeoverFence,
|
|
878
|
+
}),
|
|
879
|
+
this.#event('assignment.preempted', {
|
|
880
|
+
decisionId: preemption.decisionId,
|
|
881
|
+
assignmentId: assignment.id,
|
|
882
|
+
checkpointRef: observation.checkpoint.ref,
|
|
883
|
+
checkpointDigest: observation.checkpoint.digest,
|
|
884
|
+
outcome: 'interrupted',
|
|
885
|
+
}),
|
|
886
|
+
]
|
|
887
|
+
: [draft];
|
|
888
|
+
await this.#journal.append(envelope.runId, expectedSequence, drafts);
|
|
889
|
+
return this.read(envelope.projectId, envelope.runId);
|
|
890
|
+
}
|
|
891
|
+
async evaluateTaskAcceptance(projectId, runId, taskKey) {
|
|
892
|
+
assertProjectId(projectId);
|
|
893
|
+
const scopedProjectId = projectId.trim();
|
|
894
|
+
assertRunId(runId);
|
|
895
|
+
const policy = this.#acceptancePolicy;
|
|
896
|
+
if (!policy)
|
|
897
|
+
throw new Error('Acceptance Policy Decision Port is not installed');
|
|
898
|
+
const state = await this.#readUnscoped(runId);
|
|
899
|
+
assertProject(state, scopedProjectId);
|
|
900
|
+
const input = createAcceptanceDecisionInput(state, taskKey);
|
|
901
|
+
const decision = await policy.decide(input);
|
|
902
|
+
const assignment = state.assignments[input.assignment.id];
|
|
903
|
+
if (!assignment?.candidateRef
|
|
904
|
+
|| !assignment.candidateHash
|
|
905
|
+
|| decision.candidate.id !== assignment.candidateRef
|
|
906
|
+
|| decision.candidate.hash !== assignment.candidateHash) {
|
|
907
|
+
throw new Error('Acceptance Candidate does not match the Executor completion candidate');
|
|
908
|
+
}
|
|
909
|
+
const drafts = decideTaskAcceptance(input, decision, (type, payload) => this.#event(type, payload));
|
|
910
|
+
await this.#journal.append(runId, input.expectedSequence, drafts);
|
|
911
|
+
return this.read(scopedProjectId, runId);
|
|
912
|
+
}
|
|
913
|
+
async pinTaskAcceptance(projectId, runId, taskKey) {
|
|
914
|
+
assertProjectId(projectId);
|
|
915
|
+
const scopedProjectId = projectId.trim();
|
|
916
|
+
assertRunId(runId);
|
|
917
|
+
const policy = this.#acceptancePolicy;
|
|
918
|
+
if (!policy)
|
|
919
|
+
throw new Error('Acceptance Policy Decision Port is not installed');
|
|
920
|
+
const state = await this.#readUnscoped(runId);
|
|
921
|
+
assertProject(state, scopedProjectId);
|
|
922
|
+
const input = createAcceptanceContractPinInput(state, taskKey);
|
|
923
|
+
const contract = await policy.pinContract(input);
|
|
924
|
+
assertAcceptanceContract(contract, input.task.key, input.task.revision);
|
|
925
|
+
const pinnedContract = freezeAcceptanceContract(contract);
|
|
926
|
+
const drafts = [this.#event('task.acceptance_pinned', {
|
|
927
|
+
taskKey: input.task.key,
|
|
928
|
+
contract: pinnedContract,
|
|
929
|
+
})];
|
|
930
|
+
await this.#journal.append(runId, input.expectedSequence, drafts);
|
|
931
|
+
return this.read(scopedProjectId, runId);
|
|
932
|
+
}
|
|
933
|
+
async claimReviewerAssignment(projectId, runId, assignmentId, principalId) {
|
|
934
|
+
const { scopedProjectId, state } = await this.#readProject(projectId, runId);
|
|
935
|
+
const assignment = state.reviewerAssignments[assignmentId];
|
|
936
|
+
if (!assignment)
|
|
937
|
+
throw new Error(`Reviewer Assignment ${assignmentId} not found`);
|
|
938
|
+
const authorization = await this.#authorize(state, {
|
|
939
|
+
action: 'claim_review',
|
|
940
|
+
principalId,
|
|
941
|
+
requiredRole: 'reviewer',
|
|
942
|
+
taskKey: assignment.taskKey,
|
|
943
|
+
targetId: assignment.id,
|
|
944
|
+
});
|
|
945
|
+
const drafts = decideReviewerClaim(state, { assignmentId, principalId, authorization }, (type, payload) => this.#event(type, payload));
|
|
946
|
+
await this.#journal.append(runId, state.sequence, drafts);
|
|
947
|
+
return this.read(scopedProjectId, runId);
|
|
948
|
+
}
|
|
949
|
+
async submitReviewerVerdict(projectId, runId, assignmentId, principalId, verdict) {
|
|
950
|
+
const { scopedProjectId, state } = await this.#readProject(projectId, runId);
|
|
951
|
+
const assignment = state.reviewerAssignments[assignmentId];
|
|
952
|
+
if (!assignment)
|
|
953
|
+
throw new Error(`Reviewer Assignment ${assignmentId} not found`);
|
|
954
|
+
const authorization = await this.#authorize(state, {
|
|
955
|
+
action: 'submit_review',
|
|
956
|
+
principalId,
|
|
957
|
+
requiredRole: 'reviewer',
|
|
958
|
+
taskKey: assignment.taskKey,
|
|
959
|
+
targetId: assignment.id,
|
|
960
|
+
});
|
|
961
|
+
const drafts = decideReviewerVerdict(state, { assignmentId, principalId, authorization, verdict }, (type, payload) => this.#event(type, payload));
|
|
962
|
+
await this.#journal.append(runId, state.sequence, drafts);
|
|
963
|
+
return this.read(scopedProjectId, runId);
|
|
964
|
+
}
|
|
965
|
+
async decideSponsorGate(projectId, runId, gateId, principalId, input) {
|
|
966
|
+
const { scopedProjectId, state } = await this.#readProject(projectId, runId);
|
|
967
|
+
const gate = state.sponsorGates[gateId];
|
|
968
|
+
if (!gate)
|
|
969
|
+
throw new Error(`Sponsor Gate ${gateId} not found`);
|
|
970
|
+
const authorization = await this.#authorize(state, {
|
|
971
|
+
action: 'decide_sponsor',
|
|
972
|
+
principalId,
|
|
973
|
+
requiredRole: 'sponsor',
|
|
974
|
+
taskKey: gate.taskKey,
|
|
975
|
+
targetId: gate.id,
|
|
976
|
+
});
|
|
977
|
+
const drafts = decideSponsorGate(state, { gateId, principalId, authorization, ...input }, (type, payload) => this.#event(type, payload));
|
|
978
|
+
await this.#journal.append(runId, state.sequence, drafts);
|
|
979
|
+
return this.read(scopedProjectId, runId);
|
|
980
|
+
}
|
|
981
|
+
async read(projectId, runId) {
|
|
982
|
+
assertProjectId(projectId);
|
|
983
|
+
const scopedProjectId = projectId.trim();
|
|
984
|
+
assertRunId(runId);
|
|
985
|
+
const state = await this.#readUnscoped(runId);
|
|
986
|
+
assertProject(state, scopedProjectId);
|
|
987
|
+
return state;
|
|
988
|
+
}
|
|
989
|
+
async list(projectId) {
|
|
990
|
+
assertProjectId(projectId);
|
|
991
|
+
const scopedProjectId = projectId.trim();
|
|
992
|
+
const states = await Promise.all((await this.#journal.listRunIds()).map(runId => this.#readUnscoped(runId)));
|
|
993
|
+
return Object.freeze(states
|
|
994
|
+
.filter(state => state.projectId === scopedProjectId)
|
|
995
|
+
.sort((left, right) => right.now - left.now));
|
|
996
|
+
}
|
|
997
|
+
/** Durable remote dispatch intents used by the generation recovery projector. */
|
|
998
|
+
async listLocalAssignmentIssuances() {
|
|
999
|
+
const receipts = [];
|
|
1000
|
+
for (const runId of await this.#journal.listRunIds()) {
|
|
1001
|
+
const events = await this.#journal.read(runId);
|
|
1002
|
+
if (events.length === 0)
|
|
1003
|
+
continue;
|
|
1004
|
+
const state = replayWorkroom(events);
|
|
1005
|
+
for (const event of events) {
|
|
1006
|
+
if (event.type !== 'local_execution.requested')
|
|
1007
|
+
continue;
|
|
1008
|
+
receipts.push(Object.freeze({
|
|
1009
|
+
...parseWorkroomLocalAssignmentIssuance(event.payload),
|
|
1010
|
+
state,
|
|
1011
|
+
}));
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
return Object.freeze(receipts.sort((left, right) => compareCanonicalWorkroomText(left.operationId, right.operationId)));
|
|
1015
|
+
}
|
|
1016
|
+
/** Durable remote dispatch intents used by the generation recovery projector. */
|
|
1017
|
+
async listRemoteAssignmentIssuances() {
|
|
1018
|
+
const receipts = [];
|
|
1019
|
+
for (const runId of await this.#journal.listRunIds()) {
|
|
1020
|
+
const events = await this.#journal.read(runId);
|
|
1021
|
+
if (events.length === 0)
|
|
1022
|
+
continue;
|
|
1023
|
+
const state = replayWorkroom(events);
|
|
1024
|
+
for (const event of events) {
|
|
1025
|
+
if (event.type !== 'remote_dispatch.requested')
|
|
1026
|
+
continue;
|
|
1027
|
+
receipts.push(Object.freeze({
|
|
1028
|
+
...parseWorkroomRemoteAssignmentIssuance(event.payload),
|
|
1029
|
+
state,
|
|
1030
|
+
}));
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
return Object.freeze(receipts.sort((left, right) => compareCanonicalWorkroomText(left.operationId, right.operationId)));
|
|
1034
|
+
}
|
|
1035
|
+
async #readUnscoped(runId) {
|
|
1036
|
+
const events = await this.#journal.read(runId);
|
|
1037
|
+
if (events.length === 0)
|
|
1038
|
+
throw new Error(`Workroom run ${runId} not found`);
|
|
1039
|
+
return replayWorkroom(events);
|
|
1040
|
+
}
|
|
1041
|
+
async #readProject(projectId, runId) {
|
|
1042
|
+
assertProjectId(projectId);
|
|
1043
|
+
const scopedProjectId = projectId.trim();
|
|
1044
|
+
assertRunId(runId);
|
|
1045
|
+
const state = await this.#readUnscoped(runId);
|
|
1046
|
+
assertProject(state, scopedProjectId);
|
|
1047
|
+
return { scopedProjectId, state };
|
|
1048
|
+
}
|
|
1049
|
+
async #authorize(state, input) {
|
|
1050
|
+
const authority = this.#acceptanceAuthority;
|
|
1051
|
+
if (!authority)
|
|
1052
|
+
throw new Error('Workroom Acceptance Authority Port is not installed');
|
|
1053
|
+
return await authority.authorize(Object.freeze({
|
|
1054
|
+
...input,
|
|
1055
|
+
projectId: state.projectId,
|
|
1056
|
+
runId: state.runId,
|
|
1057
|
+
expectedSequence: state.sequence,
|
|
1058
|
+
}));
|
|
1059
|
+
}
|
|
1060
|
+
#planTaskDrafts(task) {
|
|
1061
|
+
return Object.freeze([
|
|
1062
|
+
this.#event('task.planned', planTaskPayload(task)),
|
|
1063
|
+
...(task.approvalGate ? [this.#planTaskBlockerDraft(task)] : []),
|
|
1064
|
+
]);
|
|
1065
|
+
}
|
|
1066
|
+
#planTaskBlockerDraft(task) {
|
|
1067
|
+
const gate = task.approvalGate;
|
|
1068
|
+
if (!gate)
|
|
1069
|
+
throw new Error(`Workflow Plan Task ${task.key} has no Sponsor Gate`);
|
|
1070
|
+
return this.#event('task.blocked', {
|
|
1071
|
+
taskKey: task.key,
|
|
1072
|
+
blockerId: gate.id,
|
|
1073
|
+
kind: 'approval',
|
|
1074
|
+
owner: gate.owner,
|
|
1075
|
+
reason: `Workflow Plan Sponsor Gate ${gate.id}`,
|
|
1076
|
+
deadline: gate.deadline,
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
#event(type, payload) {
|
|
1080
|
+
return Object.freeze({
|
|
1081
|
+
eventId: this.#createId(),
|
|
1082
|
+
occurredAt: this.#now(),
|
|
1083
|
+
type,
|
|
1084
|
+
payload: Object.freeze({ ...payload }),
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
#trustedHeartbeatLeaseExpiry(currentLeaseExpiresAt) {
|
|
1088
|
+
const now = this.#now();
|
|
1089
|
+
if (!Number.isFinite(now))
|
|
1090
|
+
throw new Error('Assignment heartbeat clock must be finite');
|
|
1091
|
+
if (now >= currentLeaseExpiresAt) {
|
|
1092
|
+
throw new Error('Assignment heartbeat cannot revive an expired lease');
|
|
1093
|
+
}
|
|
1094
|
+
const leaseExpiresAt = now + this.#assignmentHeartbeatLeaseMs;
|
|
1095
|
+
if (!Number.isFinite(leaseExpiresAt))
|
|
1096
|
+
throw new Error('Assignment heartbeat lease expiry must be finite');
|
|
1097
|
+
if (leaseExpiresAt <= currentLeaseExpiresAt) {
|
|
1098
|
+
throw new Error('Assignment heartbeat must strictly extend the current lease');
|
|
1099
|
+
}
|
|
1100
|
+
return leaseExpiresAt;
|
|
1101
|
+
}
|
|
1102
|
+
#trustedAssignmentTiming(kind) {
|
|
1103
|
+
const now = this.#now();
|
|
1104
|
+
if (!Number.isFinite(now) || now < 0) {
|
|
1105
|
+
throw new Error(`${kind} Assignment claim clock must be a finite timestamp`);
|
|
1106
|
+
}
|
|
1107
|
+
const expiresAt = now + this.#assignmentHeartbeatLeaseMs;
|
|
1108
|
+
const reconcileDeadline = expiresAt + this.#assignmentHeartbeatLeaseMs;
|
|
1109
|
+
if (!Number.isFinite(expiresAt) || !Number.isFinite(reconcileDeadline)) {
|
|
1110
|
+
throw new Error(`${kind} Assignment lease expiry must be finite`);
|
|
1111
|
+
}
|
|
1112
|
+
return Object.freeze({
|
|
1113
|
+
issuedAt: now,
|
|
1114
|
+
leaseExpiresAt: expiresAt,
|
|
1115
|
+
reconcileDeadline,
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
function assignmentPreview(input) {
|
|
1120
|
+
const body = Object.freeze({ version: 1, ...input });
|
|
1121
|
+
return Object.freeze({ ...body, previewDigest: digestCanonicalWorkroomValue(body) });
|
|
1122
|
+
}
|
|
1123
|
+
function currentWorkflowPlan(events) {
|
|
1124
|
+
const admitted = events.filter(event => event.type === 'plan.admitted');
|
|
1125
|
+
if (admitted.length !== 1)
|
|
1126
|
+
throw new Error('Plan Revision requires one exact admitted Plan');
|
|
1127
|
+
let plan = admitted[0].payload.plan;
|
|
1128
|
+
assertWorkflowPlanProposal(plan);
|
|
1129
|
+
let revision = 1;
|
|
1130
|
+
for (const event of events) {
|
|
1131
|
+
if (event.type !== 'plan.revision_applied')
|
|
1132
|
+
continue;
|
|
1133
|
+
const candidate = event.payload.candidate;
|
|
1134
|
+
assertWorkflowPlanRevisionCandidate(candidate);
|
|
1135
|
+
const nextRevision = Number(event.payload.planRevision);
|
|
1136
|
+
if (candidate.basePlanRevision !== revision || candidate.basePlanDigest !== plan.digest
|
|
1137
|
+
|| nextRevision !== revision + 1) {
|
|
1138
|
+
throw new Error('Persisted Plan Revision chain is not contiguous');
|
|
1139
|
+
}
|
|
1140
|
+
plan = candidate.nextPlan;
|
|
1141
|
+
revision = nextRevision;
|
|
1142
|
+
}
|
|
1143
|
+
return Object.freeze({ revision, plan });
|
|
1144
|
+
}
|
|
1145
|
+
function planTaskPayload(task) {
|
|
1146
|
+
return {
|
|
1147
|
+
taskKey: task.key,
|
|
1148
|
+
title: task.title,
|
|
1149
|
+
required: task.required,
|
|
1150
|
+
maxAttempts: task.maxAttempts,
|
|
1151
|
+
role: task.role,
|
|
1152
|
+
dependsOn: task.dependsOn,
|
|
1153
|
+
requires: task.requires,
|
|
1154
|
+
sponsorLane: task.scheduler.sponsorLane,
|
|
1155
|
+
localRank: task.scheduler.localRank,
|
|
1156
|
+
deadline: task.scheduler.deadline,
|
|
1157
|
+
enqueuedAt: task.scheduler.enqueuedAt,
|
|
1158
|
+
preemptibility: task.scheduler.preemptibility,
|
|
1159
|
+
...(task.approvalGate ? { approvalGate: task.approvalGate } : {}),
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
function requireObservationStatus(status, allowed) {
|
|
1163
|
+
if (!allowed.includes(status))
|
|
1164
|
+
throw new Error(`Assignment cannot observe execution while ${status}`);
|
|
1165
|
+
}
|
|
1166
|
+
function assertRunId(runId) {
|
|
1167
|
+
if (!/^[A-Za-z0-9_-]{1,128}$/u.test(runId)) {
|
|
1168
|
+
throw new Error('Workroom runId must contain only letters, digits, underscore or hyphen');
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
function assertProjectId(projectId) {
|
|
1172
|
+
if (!projectId.trim())
|
|
1173
|
+
throw new Error('Workroom projectId is required');
|
|
1174
|
+
}
|
|
1175
|
+
function assertProject(state, projectId) {
|
|
1176
|
+
if (state.projectId !== projectId)
|
|
1177
|
+
throw new Error('Workroom run does not belong to the requested Project');
|
|
1178
|
+
}
|
|
1179
|
+
function findLocalAssignmentIssuance(events, operationId) {
|
|
1180
|
+
const matches = events.filter(event => event.type === 'local_execution.requested'
|
|
1181
|
+
&& event.payload.operationId === operationId);
|
|
1182
|
+
if (matches.length > 1) {
|
|
1183
|
+
throw new Error(`Local Assignment operation ${operationId} is duplicated in the Kernel Journal`);
|
|
1184
|
+
}
|
|
1185
|
+
return matches[0]
|
|
1186
|
+
? parseWorkroomLocalAssignmentIssuance(matches[0].payload)
|
|
1187
|
+
: undefined;
|
|
1188
|
+
}
|
|
1189
|
+
function assertLocalAssignmentReplay(issuance, requestDigest) {
|
|
1190
|
+
if (issuance.requestDigest !== requestDigest) {
|
|
1191
|
+
throw new Error(`Local Assignment operation payload conflict: ${issuance.operationId}`);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
function findRemoteAssignmentIssuance(events, operationId) {
|
|
1195
|
+
const matches = events.filter(event => event.type === 'remote_dispatch.requested'
|
|
1196
|
+
&& event.payload.operationId === operationId);
|
|
1197
|
+
if (matches.length > 1) {
|
|
1198
|
+
throw new Error(`Remote Assignment operation ${operationId} is duplicated in the Kernel Journal`);
|
|
1199
|
+
}
|
|
1200
|
+
return matches[0]
|
|
1201
|
+
? parseWorkroomRemoteAssignmentIssuance(matches[0].payload)
|
|
1202
|
+
: undefined;
|
|
1203
|
+
}
|
|
1204
|
+
function assertRemoteAssignmentReplay(issuance, requestDigest) {
|
|
1205
|
+
if (issuance.requestDigest !== requestDigest) {
|
|
1206
|
+
throw new Error(`Remote Assignment operation payload conflict: ${issuance.operationId}`);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
function normalizePlanAdmission(input) {
|
|
1210
|
+
requireCanonicalText(input.operationId, 'operationId');
|
|
1211
|
+
assertProjectId(input.projectId);
|
|
1212
|
+
requireCanonicalText(input.title, 'title');
|
|
1213
|
+
requireCanonicalText(input.sourceEventRef, 'sourceEventRef');
|
|
1214
|
+
requireDigest(input.sourceEventDigest, 'sourceEventDigest');
|
|
1215
|
+
requireCanonicalText(input.orchestratorAgentDefinitionId, 'orchestratorAgentDefinitionId');
|
|
1216
|
+
assertWorkflowPlanProposal(input.plan);
|
|
1217
|
+
if (input.plan.projectId !== input.projectId.trim()) {
|
|
1218
|
+
throw new Error('Workflow Plan proposal belongs to another Project');
|
|
1219
|
+
}
|
|
1220
|
+
return Object.freeze({
|
|
1221
|
+
...structuredClone(input),
|
|
1222
|
+
projectId: input.projectId.trim(),
|
|
1223
|
+
title: input.title.trim(),
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
function normalizePlanGateDecision(input) {
|
|
1227
|
+
for (const [value, label] of [
|
|
1228
|
+
[input.operationId, 'operationId'], [input.projectId, 'projectId'], [input.runId, 'runId'],
|
|
1229
|
+
[input.taskKey, 'taskKey'], [input.gateId, 'gateId'], [input.reason, 'reason'],
|
|
1230
|
+
[input.sponsorPrincipalId, 'sponsorPrincipalId'], [input.sponsorAuthorityRef, 'sponsorAuthorityRef'],
|
|
1231
|
+
])
|
|
1232
|
+
requireCanonicalText(value, label);
|
|
1233
|
+
if (!Number.isSafeInteger(input.taskRevision) || input.taskRevision < 1) {
|
|
1234
|
+
throw new Error('Plan Sponsor Gate taskRevision must be a positive safe integer');
|
|
1235
|
+
}
|
|
1236
|
+
if (!Number.isSafeInteger(input.expectedSequence) || input.expectedSequence < 0) {
|
|
1237
|
+
throw new Error('Plan Sponsor Gate expectedSequence must be a non-negative safe integer');
|
|
1238
|
+
}
|
|
1239
|
+
if (!['approve', 'reject', 'request_changes', 'cancel'].includes(input.decision)) {
|
|
1240
|
+
throw new Error('Plan Sponsor Gate decision is invalid');
|
|
1241
|
+
}
|
|
1242
|
+
return Object.freeze(structuredClone(input));
|
|
1243
|
+
}
|
|
1244
|
+
function planGateReceipt(status, input, requestDigest, state) {
|
|
1245
|
+
const receiptRef = `workroom-run:${input.runId}:plan-gate:${encodeURIComponent(input.operationId)}`;
|
|
1246
|
+
return Object.freeze({
|
|
1247
|
+
status,
|
|
1248
|
+
operationId: input.operationId,
|
|
1249
|
+
receiptRef,
|
|
1250
|
+
receiptDigest: digestCanonicalWorkroomValue({
|
|
1251
|
+
version: 1,
|
|
1252
|
+
operationId: input.operationId,
|
|
1253
|
+
requestDigest,
|
|
1254
|
+
decision: input.decision,
|
|
1255
|
+
}),
|
|
1256
|
+
state,
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
function planAdmissionRunId(operationId) {
|
|
1260
|
+
return `run-${digestCanonicalWorkroomValue({ operationId }).slice('sha256:'.length, 38)}`;
|
|
1261
|
+
}
|
|
1262
|
+
function assertExactPlanAdmission(events, input, admittedPayload) {
|
|
1263
|
+
const expectedTypes = [
|
|
1264
|
+
'run.created',
|
|
1265
|
+
'plan.admitted',
|
|
1266
|
+
...input.plan.tasks.flatMap(task => [
|
|
1267
|
+
'task.planned',
|
|
1268
|
+
...(task.approvalGate ? ['task.blocked'] : []),
|
|
1269
|
+
]),
|
|
1270
|
+
];
|
|
1271
|
+
if (events.length !== expectedTypes.length
|
|
1272
|
+
|| events.some((event, index) => event.type !== expectedTypes[index])) {
|
|
1273
|
+
throw new Error('Workflow Plan operation replay conflicts with persisted Run shape');
|
|
1274
|
+
}
|
|
1275
|
+
const created = events[0];
|
|
1276
|
+
const admitted = events[1];
|
|
1277
|
+
if (created.payload.projectId !== input.projectId
|
|
1278
|
+
|| created.payload.title !== input.title
|
|
1279
|
+
|| canonicalWorkroomJson(admitted.payload) !== canonicalWorkroomJson(admittedPayload)) {
|
|
1280
|
+
throw new Error('Workflow Plan operation replay payload drift');
|
|
1281
|
+
}
|
|
1282
|
+
let cursor = 2;
|
|
1283
|
+
for (const task of input.plan.tasks) {
|
|
1284
|
+
const payload = events[cursor++].payload;
|
|
1285
|
+
const expected = {
|
|
1286
|
+
taskKey: task.key, title: task.title, required: task.required,
|
|
1287
|
+
maxAttempts: task.maxAttempts, role: task.role,
|
|
1288
|
+
dependsOn: task.dependsOn, requires: task.requires,
|
|
1289
|
+
sponsorLane: task.scheduler.sponsorLane,
|
|
1290
|
+
localRank: task.scheduler.localRank,
|
|
1291
|
+
deadline: task.scheduler.deadline,
|
|
1292
|
+
enqueuedAt: task.scheduler.enqueuedAt,
|
|
1293
|
+
preemptibility: task.scheduler.preemptibility,
|
|
1294
|
+
...(task.approvalGate ? { approvalGate: task.approvalGate } : {}),
|
|
1295
|
+
};
|
|
1296
|
+
if (canonicalWorkroomJson(payload) !== canonicalWorkroomJson(expected)) {
|
|
1297
|
+
throw new Error('Workflow Plan operation replay Task payload drift');
|
|
1298
|
+
}
|
|
1299
|
+
if (task.approvalGate) {
|
|
1300
|
+
const blocker = events[cursor++].payload;
|
|
1301
|
+
const expectedBlocker = {
|
|
1302
|
+
taskKey: task.key,
|
|
1303
|
+
blockerId: task.approvalGate.id,
|
|
1304
|
+
kind: 'approval',
|
|
1305
|
+
owner: task.approvalGate.owner,
|
|
1306
|
+
reason: `Workflow Plan Sponsor Gate ${task.approvalGate.id}`,
|
|
1307
|
+
deadline: task.approvalGate.deadline,
|
|
1308
|
+
};
|
|
1309
|
+
if (canonicalWorkroomJson(blocker) !== canonicalWorkroomJson(expectedBlocker)) {
|
|
1310
|
+
throw new Error('Workflow Plan operation replay Sponsor Gate payload drift');
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
function requireCanonicalText(value, label) {
|
|
1316
|
+
if (typeof value !== 'string' || !value.trim() || value !== value.trim()) {
|
|
1317
|
+
throw new Error(`Workroom Plan admission ${label} must be canonical text`);
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
function requireDigest(value, label) {
|
|
1321
|
+
if (typeof value !== 'string' || !/^sha256:[a-f0-9]{64}$/u.test(value)) {
|
|
1322
|
+
throw new Error(`Workroom Plan admission ${label} must be a canonical SHA-256 digest`);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
//# sourceMappingURL=workroom-kernel.js.map
|