@zhin.js/agent 1.1.23 → 1.1.26
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 +46 -24
- package/lib/activity-feedback/adapter-integration.d.ts +1 -1
- package/lib/activity-feedback/adapter-integration.d.ts.map +1 -1
- package/lib/activity-feedback/index.d.ts +0 -1
- package/lib/activity-feedback/index.d.ts.map +1 -1
- package/lib/activity-feedback/index.js +0 -1
- package/lib/activity-feedback/index.js.map +1 -1
- package/lib/activity-feedback/subagent-prefix.d.ts +1 -1
- package/lib/activity-feedback/subagent-prefix.js +1 -1
- package/lib/ai-event-bus.d.ts +6 -10
- package/lib/ai-event-bus.d.ts.map +1 -1
- package/lib/ai-event-bus.js +0 -13
- package/lib/ai-event-bus.js.map +1 -1
- package/lib/ai-event-contract.d.ts +43 -0
- package/lib/ai-event-contract.d.ts.map +1 -0
- package/lib/ai-event-contract.js +2 -0
- package/lib/ai-event-contract.js.map +1 -0
- package/lib/ai-event-subscriber.d.ts +3 -5
- package/lib/ai-event-subscriber.d.ts.map +1 -1
- package/lib/ai-event-subscriber.js +0 -19
- package/lib/ai-event-subscriber.js.map +1 -1
- package/lib/ai-hook-runtime-bus.d.ts +3 -4
- package/lib/ai-hook-runtime-bus.d.ts.map +1 -1
- package/lib/ai-hook-runtime-bus.js +2 -3
- package/lib/ai-hook-runtime-bus.js.map +1 -1
- package/lib/assistant/deliver-schedule-to-adapter.d.ts +2 -4
- package/lib/assistant/deliver-schedule-to-adapter.d.ts.map +1 -1
- package/lib/assistant/deliver-schedule-to-adapter.js +1 -8
- package/lib/assistant/deliver-schedule-to-adapter.js.map +1 -1
- package/lib/assistant/domains/ha-home-backend.d.ts.map +1 -1
- package/lib/assistant/domains/ha-home-backend.js +1 -2
- package/lib/assistant/domains/ha-home-backend.js.map +1 -1
- package/lib/assistant/domains/ha-ws-transport.d.ts.map +1 -1
- package/lib/assistant/domains/ha-ws-transport.js +1 -2
- package/lib/assistant/domains/ha-ws-transport.js.map +1 -1
- package/lib/assistant/domains/home-state-watch.d.ts.map +1 -1
- package/lib/assistant/domains/home-state-watch.js +1 -2
- package/lib/assistant/domains/home-state-watch.js.map +1 -1
- package/lib/assistant/event-ingress.d.ts.map +1 -1
- package/lib/assistant/event-ingress.js +1 -2
- package/lib/assistant/event-ingress.js.map +1 -1
- package/lib/assistant/home-policy.d.ts +1 -1
- package/lib/assistant/home-policy.d.ts.map +1 -1
- package/lib/assistant/home-tools.d.ts.map +1 -1
- package/lib/assistant/home-tools.js.map +1 -1
- package/lib/assistant/index.d.ts +2 -2
- package/lib/assistant/index.d.ts.map +1 -1
- package/lib/assistant/index.js +2 -2
- package/lib/assistant/index.js.map +1 -1
- package/lib/assistant/job-engine.d.ts +3 -2
- package/lib/assistant/job-engine.d.ts.map +1 -1
- package/lib/assistant/job-engine.js +6 -4
- package/lib/assistant/job-engine.js.map +1 -1
- package/lib/assistant/job-scheduler.d.ts +2 -2
- package/lib/assistant/job-scheduler.d.ts.map +1 -1
- package/lib/assistant/job-scheduler.js +2 -11
- package/lib/assistant/job-scheduler.js.map +1 -1
- package/lib/assistant/job-worker.js +1 -1
- package/lib/assistant/job-worker.js.map +1 -1
- package/lib/assistant/notification-router.d.ts.map +1 -1
- package/lib/assistant/notification-router.js +2 -2
- package/lib/assistant/notification-router.js.map +1 -1
- package/lib/assistant/profile-loader.d.ts +0 -4
- package/lib/assistant/profile-loader.d.ts.map +1 -1
- package/lib/assistant/profile-loader.js +0 -4
- package/lib/assistant/profile-loader.js.map +1 -1
- package/lib/assistant/schedule-skills.d.ts.map +1 -1
- package/lib/assistant/schedule-skills.js +5 -7
- package/lib/assistant/schedule-skills.js.map +1 -1
- package/lib/authoring/bridge.d.ts +2 -16
- package/lib/authoring/bridge.d.ts.map +1 -1
- package/lib/authoring/bridge.js +1 -74
- package/lib/authoring/bridge.js.map +1 -1
- package/lib/authoring/disable-tool.d.ts +2 -2
- package/lib/authoring/disable-tool.d.ts.map +1 -1
- package/lib/authoring/disable-tool.js +2 -2
- package/lib/authoring/disable-tool.js.map +1 -1
- package/lib/authoring/index.d.ts +1 -11
- package/lib/authoring/index.d.ts.map +1 -1
- package/lib/authoring/index.js +1 -6
- package/lib/authoring/index.js.map +1 -1
- package/lib/authoring/types.d.ts +3 -116
- package/lib/authoring/types.d.ts.map +1 -1
- package/lib/authoring/types.js.map +1 -1
- package/lib/bootstrap.d.ts +3 -8
- package/lib/bootstrap.d.ts.map +1 -1
- package/lib/bootstrap.js +9 -29
- package/lib/bootstrap.js.map +1 -1
- package/lib/builtins/builtin-tool-service.js +1 -1
- package/lib/builtins/builtin-tool-service.js.map +1 -1
- package/lib/config/fix-ai-config.d.ts.map +1 -1
- package/lib/config/fix-ai-config.js +0 -57
- package/lib/config/fix-ai-config.js.map +1 -1
- package/lib/config/index.d.ts +2 -1
- package/lib/config/index.d.ts.map +1 -1
- package/lib/config/index.js +2 -1
- package/lib/config/index.js.map +1 -1
- package/lib/config/provider-instance.d.ts +3 -3
- package/lib/config/provider-instance.d.ts.map +1 -1
- package/lib/config/provider-instance.js.map +1 -1
- package/lib/config/resolve-five-agent-binding.d.ts +1 -1
- package/lib/config/resolve-five-agent-binding.d.ts.map +1 -1
- package/lib/config/validate-ai-config.d.ts +0 -1
- package/lib/config/validate-ai-config.d.ts.map +1 -1
- package/lib/config/validate-ai-config.js +0 -229
- package/lib/config/validate-ai-config.js.map +1 -1
- package/lib/config/zhin-agent-config.d.ts +1 -1
- package/lib/config/zhin-agent-config.d.ts.map +1 -1
- package/lib/config/zhin-agent-defaults.js +4 -4
- package/lib/config/zhin-agent-dependencies.d.ts +5 -5
- package/lib/config/zhin-agent-dependencies.d.ts.map +1 -1
- package/lib/context/agents-instruction.d.ts +0 -1
- package/lib/context/agents-instruction.d.ts.map +1 -1
- package/lib/context/agents-instruction.js +1 -14
- package/lib/context/agents-instruction.js.map +1 -1
- package/lib/context/context-system.d.ts.map +1 -1
- package/lib/context/context-system.js +2 -2
- package/lib/context/context-system.js.map +1 -1
- package/lib/context/index.d.ts +1 -1
- package/lib/context/index.d.ts.map +1 -1
- package/lib/context/index.js +1 -1
- package/lib/context/index.js.map +1 -1
- package/lib/context/turn-user-message.d.ts.map +1 -1
- package/lib/context/turn-user-message.js +1 -2
- 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 +17 -16
- package/lib/core/agent-core-run.js.map +1 -1
- package/lib/core/agent-loop-standalone.d.ts +2 -1
- package/lib/core/agent-loop-standalone.d.ts.map +1 -1
- package/lib/core/agent-loop-standalone.js +19 -18
- package/lib/core/agent-loop-standalone.js.map +1 -1
- package/lib/core/tool-calls-user-format.d.ts.map +1 -1
- package/lib/core/tool-calls-user-format.js +2 -76
- package/lib/core/tool-calls-user-format.js.map +1 -1
- package/lib/create-agent-session.d.ts +1 -1
- package/lib/create-agent-session.d.ts.map +1 -1
- package/lib/create-agent-session.js +2 -2
- package/lib/create-agent-session.js.map +1 -1
- package/lib/data-governance/disclosure-authority.d.ts +38 -0
- package/lib/data-governance/disclosure-authority.d.ts.map +1 -0
- package/lib/data-governance/disclosure-authority.js +2 -0
- package/lib/data-governance/disclosure-authority.js.map +1 -0
- package/lib/deferred-worker-runner.d.ts +2 -1
- package/lib/deferred-worker-runner.d.ts.map +1 -1
- package/lib/deferred-worker-runner.js +6 -4
- package/lib/deferred-worker-runner.js.map +1 -1
- package/lib/discovery/agent-surface-info.d.ts +5 -9
- package/lib/discovery/agent-surface-info.d.ts.map +1 -1
- package/lib/discovery/agent-surface-info.js +81 -45
- package/lib/discovery/agent-surface-info.js.map +1 -1
- package/lib/discovery/agent-surface.d.ts +2 -22
- package/lib/discovery/agent-surface.d.ts.map +1 -1
- package/lib/discovery/agent-surface.js +72 -287
- package/lib/discovery/agent-surface.js.map +1 -1
- package/lib/discovery/agents.d.ts +10 -12
- package/lib/discovery/agents.d.ts.map +1 -1
- package/lib/discovery/agents.js +91 -90
- package/lib/discovery/agents.js.map +1 -1
- package/lib/discovery/utils.d.ts +2 -15
- package/lib/discovery/utils.d.ts.map +1 -1
- package/lib/discovery/utils.js +2 -76
- package/lib/discovery/utils.js.map +1 -1
- package/lib/event/agent-stream-hooks.d.ts +0 -2
- package/lib/event/agent-stream-hooks.d.ts.map +1 -1
- package/lib/event/agent-stream-hooks.js +0 -8
- package/lib/event/agent-stream-hooks.js.map +1 -1
- package/lib/event/ai-event-bus.d.ts +13 -0
- package/lib/event/ai-event-bus.d.ts.map +1 -0
- package/lib/event/ai-event-bus.js +45 -0
- package/lib/event/ai-event-bus.js.map +1 -0
- package/lib/event/event-emitter.d.ts +8 -14
- package/lib/event/event-emitter.d.ts.map +1 -1
- package/lib/event/event-emitter.js +7 -37
- package/lib/event/event-emitter.js.map +1 -1
- package/lib/index.d.ts +42 -75
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +29 -59
- package/lib/index.js.map +1 -1
- package/lib/init/activate-ai-database-storage.d.ts +1 -1
- package/lib/init/activate-ai-database-storage.d.ts.map +1 -1
- package/lib/init/activate-ai-database-storage.js +28 -32
- package/lib/init/activate-ai-database-storage.js.map +1 -1
- package/lib/init/compose-zhin-agent-runtime.d.ts +2 -0
- package/lib/init/compose-zhin-agent-runtime.d.ts.map +1 -1
- package/lib/init/compose-zhin-agent-runtime.js +1 -0
- package/lib/init/compose-zhin-agent-runtime.js.map +1 -1
- package/lib/init/configure-zhin-agent.d.ts +3 -4
- package/lib/init/configure-zhin-agent.d.ts.map +1 -1
- package/lib/init/configure-zhin-agent.js +9 -7
- package/lib/init/configure-zhin-agent.js.map +1 -1
- package/lib/init/define-ai-database-models.js +1 -1
- package/lib/init/dispose-zhin-agent.d.ts +1 -1
- package/lib/init/dispose-zhin-agent.d.ts.map +1 -1
- package/lib/init/dispose-zhin-agent.js +0 -1
- package/lib/init/dispose-zhin-agent.js.map +1 -1
- package/lib/init/runtime-management-commands.d.ts +1 -2
- package/lib/init/runtime-management-commands.d.ts.map +1 -1
- package/lib/init/runtime-management-commands.js.map +1 -1
- package/lib/internal/agent-host.d.ts +10 -5
- package/lib/internal/agent-host.d.ts.map +1 -1
- package/lib/internal/host-types.d.ts +5 -7
- package/lib/internal/host-types.d.ts.map +1 -1
- package/lib/mcp-client/bridge.d.ts +1 -2
- package/lib/mcp-client/bridge.d.ts.map +1 -1
- package/lib/mcp-client/bridge.js +1 -2
- package/lib/mcp-client/bridge.js.map +1 -1
- package/lib/media/media-publisher.d.ts +1 -1
- package/lib/media/media-publisher.d.ts.map +1 -1
- package/lib/media/media-router.d.ts +4 -7
- package/lib/media/media-router.d.ts.map +1 -1
- package/lib/media/media-router.js +10 -26
- package/lib/media/media-router.js.map +1 -1
- package/lib/media/media-types.d.ts +4 -0
- package/lib/media/media-types.d.ts.map +1 -1
- package/lib/media/media-types.js.map +1 -1
- package/lib/media/resolve-config.d.ts +0 -1
- package/lib/media/resolve-config.d.ts.map +1 -1
- package/lib/media/resolve-config.js +0 -3
- package/lib/media/resolve-config.js.map +1 -1
- package/lib/media/subagent-inbound.d.ts +3 -2
- package/lib/media/subagent-inbound.d.ts.map +1 -1
- package/lib/media/subagent-inbound.js +5 -8
- package/lib/media/subagent-inbound.js.map +1 -1
- package/lib/memory/ai-compaction-strategy.d.ts +3 -2
- package/lib/memory/ai-compaction-strategy.d.ts.map +1 -1
- package/lib/memory/ai-compaction-strategy.js +4 -1
- package/lib/memory/ai-compaction-strategy.js.map +1 -1
- package/lib/memory/compaction-runtime.d.ts +23 -14
- package/lib/memory/compaction-runtime.d.ts.map +1 -1
- package/lib/memory/compaction-runtime.js +92 -76
- package/lib/memory/compaction-runtime.js.map +1 -1
- package/lib/memory/context-repository-store.js +1 -1
- package/lib/memory/context-repository-store.js.map +1 -1
- package/lib/memory/index.d.ts +2 -2
- package/lib/memory/index.d.ts.map +1 -1
- package/lib/memory/index.js +1 -1
- package/lib/memory/index.js.map +1 -1
- package/lib/memory/memory-system.d.ts.map +1 -1
- package/lib/memory/memory-system.js +5 -6
- package/lib/memory/memory-system.js.map +1 -1
- package/lib/memory-layers.d.ts +2 -6
- package/lib/memory-layers.d.ts.map +1 -1
- package/lib/memory-layers.js +23 -75
- package/lib/memory-layers.js.map +1 -1
- package/lib/orchestration/five-agent/index.d.ts.map +1 -0
- package/lib/orchestration/five-agent/index.js.map +1 -0
- package/lib/orchestration/five-agent/prompts.d.ts.map +1 -0
- package/lib/orchestration/five-agent/prompts.js.map +1 -0
- package/lib/orchestration/five-agent/role-capability-policy.d.ts.map +1 -0
- package/lib/orchestration/five-agent/role-capability-policy.js.map +1 -0
- package/lib/orchestration/five-agent/roles.d.ts.map +1 -0
- package/lib/orchestration/five-agent/roles.js.map +1 -0
- package/lib/plugin-ai-hook-bus.d.ts +3 -7
- package/lib/plugin-ai-hook-bus.d.ts.map +1 -1
- package/lib/plugin-ai-hook-bus.js +1 -7
- package/lib/plugin-ai-hook-bus.js.map +1 -1
- package/lib/plugin-runtime/agent-event-bus.d.ts +4 -0
- package/lib/plugin-runtime/agent-event-bus.d.ts.map +1 -0
- package/lib/plugin-runtime/agent-event-bus.js +4 -0
- package/lib/plugin-runtime/agent-event-bus.js.map +1 -0
- package/lib/plugin-runtime/agent-host-port.d.ts +0 -6
- 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 +1 -1
- package/lib/plugin-runtime/agent-runtime.d.ts.map +1 -1
- package/lib/plugin-runtime/agent-runtime.js +9 -4
- package/lib/plugin-runtime/agent-runtime.js.map +1 -1
- package/lib/plugin-runtime/capability-ingress.d.ts +1 -1
- package/lib/plugin-runtime/capability-ingress.d.ts.map +1 -1
- package/lib/plugin-runtime/capability-ingress.js +60 -16
- package/lib/plugin-runtime/capability-ingress.js.map +1 -1
- package/lib/plugin-runtime/capability-tools.d.ts.map +1 -1
- package/lib/plugin-runtime/capability-tools.js +5 -3
- package/lib/plugin-runtime/capability-tools.js.map +1 -1
- package/lib/plugin-runtime/deferred-capability-plan.d.ts.map +1 -1
- package/lib/plugin-runtime/deferred-capability-plan.js +50 -21
- package/lib/plugin-runtime/deferred-capability-plan.js.map +1 -1
- package/lib/plugin-runtime/file-edit-quote-utils.d.ts.map +1 -0
- package/lib/plugin-runtime/file-edit-quote-utils.js.map +1 -0
- package/lib/plugin-runtime/full-agent-turn-engine.d.ts.map +1 -1
- package/lib/plugin-runtime/full-agent-turn-engine.js +10 -10
- package/lib/plugin-runtime/full-agent-turn-engine.js.map +1 -1
- package/lib/plugin-runtime/github-actions-delivery-provider.d.ts +44 -0
- package/lib/plugin-runtime/github-actions-delivery-provider.d.ts.map +1 -0
- package/lib/plugin-runtime/github-actions-delivery-provider.js +246 -0
- package/lib/plugin-runtime/github-actions-delivery-provider.js.map +1 -0
- package/lib/plugin-runtime/github-exact-merge-gateway.d.ts +62 -0
- package/lib/plugin-runtime/github-exact-merge-gateway.d.ts.map +1 -0
- package/lib/plugin-runtime/github-exact-merge-gateway.js +79 -0
- package/lib/plugin-runtime/github-exact-merge-gateway.js.map +1 -0
- package/lib/plugin-runtime/github-workroom-capability.d.ts +15 -0
- package/lib/plugin-runtime/github-workroom-capability.d.ts.map +1 -0
- package/lib/plugin-runtime/github-workroom-capability.js +79 -0
- package/lib/plugin-runtime/github-workroom-capability.js.map +1 -0
- package/lib/plugin-runtime/host-tool-projection.d.ts +1 -1
- package/lib/plugin-runtime/host-tool-projection.d.ts.map +1 -1
- package/lib/plugin-runtime/host-tool-projection.js +5 -3
- package/lib/plugin-runtime/host-tool-projection.js.map +1 -1
- package/lib/plugin-runtime/index.d.ts +28 -1
- package/lib/plugin-runtime/index.d.ts.map +1 -1
- package/lib/plugin-runtime/index.js +25 -1
- package/lib/plugin-runtime/index.js.map +1 -1
- package/lib/plugin-runtime/native-bash-tool.d.ts +35 -0
- package/lib/plugin-runtime/native-bash-tool.d.ts.map +1 -0
- package/lib/plugin-runtime/native-bash-tool.js +110 -0
- package/lib/plugin-runtime/native-bash-tool.js.map +1 -0
- package/lib/plugin-runtime/native-file-tools.d.ts.map +1 -1
- package/lib/plugin-runtime/native-file-tools.js +10 -9
- package/lib/plugin-runtime/native-file-tools.js.map +1 -1
- package/lib/plugin-runtime/native-image-tool.d.ts +12 -0
- package/lib/plugin-runtime/native-image-tool.d.ts.map +1 -0
- package/lib/plugin-runtime/native-image-tool.js +73 -0
- package/lib/plugin-runtime/native-image-tool.js.map +1 -0
- 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-knowledge-tool.d.ts +34 -0
- package/lib/plugin-runtime/native-knowledge-tool.d.ts.map +1 -0
- package/lib/plugin-runtime/native-knowledge-tool.js +170 -0
- package/lib/plugin-runtime/native-knowledge-tool.js.map +1 -0
- package/lib/plugin-runtime/native-semantic-memory-tools.js +2 -2
- package/lib/plugin-runtime/native-semantic-memory-tools.js.map +1 -1
- package/lib/plugin-runtime/native-todo-tools.js +2 -2
- package/lib/plugin-runtime/native-todo-tools.js.map +1 -1
- package/lib/plugin-runtime/native-tool-suite.d.ts +15 -0
- package/lib/plugin-runtime/native-tool-suite.d.ts.map +1 -0
- package/lib/plugin-runtime/native-tool-suite.js +18 -0
- package/lib/plugin-runtime/native-tool-suite.js.map +1 -0
- package/lib/plugin-runtime/native-web-tools.d.ts.map +1 -1
- package/lib/plugin-runtime/native-web-tools.js +6 -19
- package/lib/plugin-runtime/native-web-tools.js.map +1 -1
- package/lib/plugin-runtime/schedule-capability-plan.js +6 -1
- package/lib/plugin-runtime/schedule-capability-plan.js.map +1 -1
- package/lib/plugin-runtime/self-delivery-project-composition.d.ts +25 -0
- package/lib/plugin-runtime/self-delivery-project-composition.d.ts.map +1 -0
- package/lib/plugin-runtime/self-delivery-project-composition.js +85 -0
- package/lib/plugin-runtime/self-delivery-project-composition.js.map +1 -0
- package/lib/plugin-runtime/self-delivery-project.d.ts +65 -0
- package/lib/plugin-runtime/self-delivery-project.d.ts.map +1 -0
- package/lib/plugin-runtime/self-delivery-project.js +140 -0
- package/lib/plugin-runtime/self-delivery-project.js.map +1 -0
- package/lib/plugin-runtime/workroom-acceptance-production-composition.d.ts +1 -1
- package/lib/plugin-runtime/workroom-acceptance-production-composition.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-acceptance-provider-composition.d.ts +1 -1
- package/lib/plugin-runtime/workroom-acceptance-provider-composition.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-accepted-source-runtime.d.ts +1 -1
- package/lib/plugin-runtime/workroom-accepted-source-runtime.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-assignment-authority-provider.d.ts +3 -77
- package/lib/plugin-runtime/workroom-assignment-authority-provider.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-assignment-authority-provider.js +10 -110
- package/lib/plugin-runtime/workroom-assignment-authority-provider.js.map +1 -1
- package/lib/plugin-runtime/workroom-assignment-knowledge-composition.d.ts +1 -1
- package/lib/plugin-runtime/workroom-assignment-knowledge-composition.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-data-governance-runtime.d.ts +4 -38
- package/lib/plugin-runtime/workroom-data-governance-runtime.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-data-governance-runtime.js +1 -1
- package/lib/plugin-runtime/workroom-data-governance-runtime.js.map +1 -1
- package/lib/plugin-runtime/workroom-delivery-gateway.d.ts +96 -0
- package/lib/plugin-runtime/workroom-delivery-gateway.d.ts.map +1 -0
- package/lib/plugin-runtime/workroom-delivery-gateway.js +129 -0
- package/lib/plugin-runtime/workroom-delivery-gateway.js.map +1 -0
- package/lib/plugin-runtime/workroom-effect-composition.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-effect-composition.js +12 -1
- package/lib/plugin-runtime/workroom-effect-composition.js.map +1 -1
- package/lib/plugin-runtime/workroom-effect-production.d.ts +5 -0
- package/lib/plugin-runtime/workroom-effect-production.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-effect-production.js +22 -3
- package/lib/plugin-runtime/workroom-effect-production.js.map +1 -1
- package/lib/plugin-runtime/workroom-effect-runtime.d.ts +1 -17
- package/lib/plugin-runtime/workroom-effect-runtime.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-effect-runtime.js +77 -17
- package/lib/plugin-runtime/workroom-effect-runtime.js.map +1 -1
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.d.ts +8 -3
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.js +21 -18
- package/lib/plugin-runtime/workroom-governed-dispatch-composition.js.map +1 -1
- package/lib/plugin-runtime/workroom-journal-payload-composition.d.ts +1 -1
- package/lib/plugin-runtime/workroom-journal-payload-composition.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-journal-payload-composition.js +1 -1
- package/lib/plugin-runtime/workroom-journal-payload-composition.js.map +1 -1
- package/lib/plugin-runtime/workroom-local-agent-core-adapter.js +3 -3
- package/lib/plugin-runtime/workroom-local-agent-core-adapter.js.map +1 -1
- package/lib/plugin-runtime/workroom-local-agent-loop.d.ts +1 -1
- package/lib/plugin-runtime/workroom-local-agent-loop.d.ts.map +1 -1
- package/lib/{workroom/local-assignment-executor.d.ts → plugin-runtime/workroom-local-assignment-executor.d.ts} +4 -4
- package/lib/plugin-runtime/workroom-local-assignment-executor.d.ts.map +1 -0
- package/lib/{workroom/local-assignment-executor.js → plugin-runtime/workroom-local-assignment-executor.js} +3 -3
- package/lib/plugin-runtime/workroom-local-assignment-executor.js.map +1 -0
- package/lib/plugin-runtime/workroom-local-assignment-runtime.js +1 -1
- package/lib/plugin-runtime/workroom-local-assignment-runtime.js.map +1 -1
- package/lib/plugin-runtime/workroom-portfolio-checkpoint-ack.d.ts +1 -1
- package/lib/plugin-runtime/workroom-portfolio-checkpoint-ack.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-portfolio-grant-assignment.d.ts +1 -1
- package/lib/plugin-runtime/workroom-portfolio-grant-assignment.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-portfolio-kernel-authority.d.ts +1 -1
- package/lib/plugin-runtime/workroom-portfolio-kernel-authority.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-preemption-runtime.d.ts +1 -1
- package/lib/plugin-runtime/workroom-preemption-runtime.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-priority-authority.d.ts +11 -3
- package/lib/plugin-runtime/workroom-priority-authority.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-priority-authority.js +51 -47
- package/lib/plugin-runtime/workroom-priority-authority.js.map +1 -1
- package/lib/plugin-runtime/workroom-projection-outbound.d.ts +1 -1
- package/lib/plugin-runtime/workroom-projection-outbound.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-projection-runtime.d.ts +3 -3
- package/lib/plugin-runtime/workroom-projection-runtime.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-projection-runtime.js +1 -1
- package/lib/plugin-runtime/workroom-projection-runtime.js.map +1 -1
- package/lib/plugin-runtime/workroom-remote-callback-runtime.d.ts +2 -2
- package/lib/plugin-runtime/workroom-remote-callback-runtime.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-remote-executor.d.ts +1 -12
- package/lib/plugin-runtime/workroom-remote-executor.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-remote-executor.js +1 -20
- package/lib/plugin-runtime/workroom-remote-executor.js.map +1 -1
- package/lib/plugin-runtime/workroom-run-profile-pin-authority.d.ts +1 -1
- package/lib/plugin-runtime/workroom-run-profile-pin-authority.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-scheduler-portfolio-composition.d.ts +1 -1
- package/lib/plugin-runtime/workroom-scheduler-portfolio-composition.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-scheduler-portfolio-request-authority.d.ts +1 -1
- package/lib/plugin-runtime/workroom-scheduler-portfolio-request-authority.d.ts.map +1 -1
- package/lib/plugin-runtime/workroom-scheduler-runtime.d.ts +1 -1
- package/lib/plugin-runtime/workroom-scheduler-runtime.d.ts.map +1 -1
- package/lib/prompt/assembly.d.ts.map +1 -1
- package/lib/prompt/assembly.js +1 -2
- package/lib/prompt/assembly.js.map +1 -1
- package/lib/prompt/git-context.d.ts +0 -2
- package/lib/prompt/git-context.d.ts.map +1 -1
- package/lib/prompt/git-context.js +1 -12
- package/lib/prompt/git-context.js.map +1 -1
- package/lib/prompt/index.d.ts +1 -1
- package/lib/prompt/index.d.ts.map +1 -1
- package/lib/prompt/index.js +1 -1
- package/lib/prompt/index.js.map +1 -1
- package/lib/prompt/prompt-assembly-registry.d.ts +1 -1
- package/lib/prompt/prompt-assembly-registry.d.ts.map +1 -1
- package/lib/prompt/prompt-assembly-registry.js.map +1 -1
- package/lib/prompt/system-prompt.d.ts +1 -1
- package/lib/prompt/system-prompt.d.ts.map +1 -1
- package/lib/prompt/system-prompt.js +1 -2
- package/lib/prompt/system-prompt.js.map +1 -1
- package/lib/prompt/templates.d.ts +2 -5
- package/lib/prompt/templates.d.ts.map +1 -1
- package/lib/prompt/templates.js +2 -16
- package/lib/prompt/templates.js.map +1 -1
- package/lib/prompt/workspace-prompt.d.ts +0 -1
- package/lib/prompt/workspace-prompt.d.ts.map +1 -1
- package/lib/prompt/workspace-prompt.js +1 -14
- package/lib/prompt/workspace-prompt.js.map +1 -1
- package/lib/reserved-tools.d.ts.map +1 -1
- package/lib/reserved-tools.js +0 -3
- package/lib/reserved-tools.js.map +1 -1
- package/lib/resource-hub/hook-registry.d.ts +1 -1
- package/lib/resource-hub/hook-registry.d.ts.map +1 -1
- package/lib/resource-hub/hook-registry.js +3 -15
- package/lib/resource-hub/hook-registry.js.map +1 -1
- package/lib/resource-hub/index.d.ts +4 -16
- package/lib/resource-hub/index.d.ts.map +1 -1
- package/lib/resource-hub/index.js +3 -20
- package/lib/resource-hub/index.js.map +1 -1
- package/lib/resource-hub/mcp-registry.js +1 -1
- package/lib/resource-hub/mcp-registry.js.map +1 -1
- package/lib/resource-hub/public-api.d.ts +0 -1
- package/lib/resource-hub/public-api.d.ts.map +1 -1
- package/lib/resource-hub/resolve-subagent-tools.d.ts.map +1 -1
- package/lib/resource-hub/resolve-subagent-tools.js +6 -4
- package/lib/resource-hub/resolve-subagent-tools.js.map +1 -1
- package/lib/resource-hub/role-configs.js +4 -4
- package/lib/resource-hub/role-configs.js.map +1 -1
- package/lib/resource-hub/skill-registry.d.ts +1 -1
- package/lib/resource-hub/skill-registry.js +1 -1
- package/lib/resource-hub/subagent-registry.d.ts +0 -2
- package/lib/resource-hub/subagent-registry.d.ts.map +1 -1
- package/lib/resource-hub/subagent-registry.js +0 -2
- package/lib/resource-hub/subagent-registry.js.map +1 -1
- package/lib/resource-hub/tool-selection.d.ts +4 -30
- package/lib/resource-hub/tool-selection.d.ts.map +1 -1
- package/lib/resource-hub/tool-selection.js +4 -289
- package/lib/resource-hub/tool-selection.js.map +1 -1
- package/lib/resource-hub/types.d.ts +6 -1
- package/lib/resource-hub/types.d.ts.map +1 -1
- package/lib/routing/route-matcher.d.ts +1 -1
- package/lib/routing/route-matcher.js +1 -1
- package/lib/schedule-manager.d.ts.map +1 -1
- package/lib/schedule-manager.js.map +1 -1
- package/lib/seam/index.d.ts +3 -3
- package/lib/seam/index.d.ts.map +1 -1
- package/lib/seam/index.js +1 -1
- package/lib/seam/index.js.map +1 -1
- package/lib/seam/seam-integration.d.ts +1 -9
- package/lib/seam/seam-integration.d.ts.map +1 -1
- package/lib/seam/seam-integration.js +0 -18
- package/lib/seam/seam-integration.js.map +1 -1
- package/lib/seam/skill-service.d.ts +0 -15
- package/lib/seam/skill-service.d.ts.map +1 -1
- package/lib/seam/tokens.d.ts +0 -3
- package/lib/seam/tokens.d.ts.map +1 -1
- package/lib/seam/tokens.js +0 -2
- package/lib/seam/tokens.js.map +1 -1
- package/lib/seam/tool-service.d.ts +3 -3
- package/lib/seam/tool-service.d.ts.map +1 -1
- package/lib/security/anomaly-detection.d.ts +2 -7
- package/lib/security/anomaly-detection.d.ts.map +1 -1
- package/lib/security/anomaly-detection.js +2 -20
- package/lib/security/anomaly-detection.js.map +1 -1
- package/lib/security/audit-logger.d.ts +0 -13
- package/lib/security/audit-logger.d.ts.map +1 -1
- package/lib/security/audit-logger.js +0 -30
- package/lib/security/audit-logger.js.map +1 -1
- package/lib/security/comm-message-context.d.ts +4 -0
- package/lib/security/comm-message-context.d.ts.map +1 -1
- package/lib/security/comm-message-context.js +9 -1
- package/lib/security/comm-message-context.js.map +1 -1
- package/lib/security/dangerous-tool-policy.d.ts +3 -3
- package/lib/security/dangerous-tool-policy.d.ts.map +1 -1
- package/lib/security/dangerous-tool-policy.js +8 -28
- package/lib/security/dangerous-tool-policy.js.map +1 -1
- package/lib/security/exec-policy.d.ts +4 -4
- package/lib/security/exec-policy.d.ts.map +1 -1
- package/lib/security/exec-policy.js +21 -62
- package/lib/security/exec-policy.js.map +1 -1
- package/lib/security/file-policy.d.ts.map +1 -1
- package/lib/security/file-policy.js +9 -57
- package/lib/security/file-policy.js.map +1 -1
- package/lib/security/file-role-policy.d.ts +1 -5
- package/lib/security/file-role-policy.d.ts.map +1 -1
- package/lib/security/file-role-policy.js +1 -25
- package/lib/security/file-role-policy.js.map +1 -1
- package/lib/security/index.d.ts +1 -1
- package/lib/security/index.d.ts.map +1 -1
- package/lib/security/index.js +1 -1
- package/lib/security/index.js.map +1 -1
- package/lib/security/owner-approval-contracts.d.ts +6 -0
- package/lib/security/owner-approval-contracts.d.ts.map +1 -0
- package/lib/security/owner-approval-contracts.js +2 -0
- package/lib/security/owner-approval-contracts.js.map +1 -0
- package/lib/security/owner-approval-runtime.d.ts +39 -0
- package/lib/security/owner-approval-runtime.d.ts.map +1 -0
- package/lib/security/owner-approval-runtime.js +159 -0
- package/lib/security/owner-approval-runtime.js.map +1 -0
- package/lib/security/owner-approval-store.d.ts +34 -0
- package/lib/security/owner-approval-store.d.ts.map +1 -0
- package/lib/security/owner-approval-store.js +154 -0
- package/lib/security/owner-approval-store.js.map +1 -0
- package/lib/security/policy-facade.d.ts +8 -15
- package/lib/security/policy-facade.d.ts.map +1 -1
- package/lib/security/policy-facade.js +33 -38
- package/lib/security/policy-facade.js.map +1 -1
- package/lib/security/sandbox.d.ts +0 -13
- package/lib/security/sandbox.d.ts.map +1 -1
- package/lib/security/sandbox.js +0 -21
- package/lib/security/sandbox.js.map +1 -1
- package/lib/security/turn-file-authority.d.ts.map +1 -1
- package/lib/security/turn-file-authority.js +0 -1
- package/lib/security/turn-file-authority.js.map +1 -1
- package/lib/service.d.ts +15 -19
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +42 -39
- package/lib/service.js.map +1 -1
- package/lib/session/approval-port.d.ts +16 -0
- package/lib/session/approval-port.d.ts.map +1 -1
- package/lib/session/approval-port.js.map +1 -1
- package/lib/session/approval-review-agent.d.ts +29 -0
- package/lib/session/approval-review-agent.d.ts.map +1 -0
- package/lib/session/approval-review-agent.js +183 -0
- package/lib/session/approval-review-agent.js.map +1 -0
- package/lib/session/branch-summarization-runtime.d.ts.map +1 -1
- package/lib/session/branch-summarization-runtime.js +3 -2
- package/lib/session/branch-summarization-runtime.js.map +1 -1
- package/lib/session/index.d.ts +2 -2
- package/lib/session/index.d.ts.map +1 -1
- package/lib/session/index.js +2 -2
- package/lib/session/index.js.map +1 -1
- package/lib/session/session-io.d.ts +7 -14
- package/lib/session/session-io.d.ts.map +1 -1
- package/lib/session/session-io.js +14 -47
- package/lib/session/session-io.js.map +1 -1
- package/lib/session/turn-ingress-session.d.ts +2 -5
- package/lib/session/turn-ingress-session.d.ts.map +1 -1
- package/lib/session/turn-ingress-session.js +8 -51
- package/lib/session/turn-ingress-session.js.map +1 -1
- package/lib/skill/skill-instruction-reader-factory.d.ts +5 -0
- package/lib/skill/skill-instruction-reader-factory.d.ts.map +1 -0
- package/lib/skill/skill-instruction-reader-factory.js +13 -0
- package/lib/skill/skill-instruction-reader-factory.js.map +1 -0
- package/lib/skill/skill-instruction-reader.d.ts +22 -0
- package/lib/skill/skill-instruction-reader.d.ts.map +1 -0
- package/lib/skill/skill-instruction-reader.js +44 -0
- package/lib/skill/skill-instruction-reader.js.map +1 -0
- package/lib/skill/skill-instructions.d.ts +5 -0
- package/lib/skill/skill-instructions.d.ts.map +1 -0
- package/lib/skill/skill-instructions.js +78 -0
- package/lib/skill/skill-instructions.js.map +1 -0
- package/lib/skill/skill-system.js +3 -3
- package/lib/skill/skill-system.js.map +1 -1
- package/lib/{builtin → spawn}/spawn-task-tool.d.ts +5 -6
- package/lib/spawn/spawn-task-tool.d.ts.map +1 -0
- package/lib/{builtin → spawn}/spawn-task-tool.js +17 -15
- package/lib/spawn/spawn-task-tool.js.map +1 -0
- package/lib/stability/memory-pressure.d.ts +5 -4
- package/lib/stability/memory-pressure.d.ts.map +1 -1
- package/lib/stability/memory-pressure.js +14 -23
- package/lib/stability/memory-pressure.js.map +1 -1
- package/lib/standalone/standalone-tool-catalog.d.ts +13 -0
- package/lib/standalone/standalone-tool-catalog.d.ts.map +1 -0
- package/lib/standalone/standalone-tool-catalog.js +46 -0
- package/lib/standalone/standalone-tool-catalog.js.map +1 -0
- package/lib/subagent/subagent-runtime.d.ts +7 -5
- package/lib/subagent/subagent-runtime.d.ts.map +1 -1
- package/lib/subagent/subagent-runtime.js +13 -16
- package/lib/subagent/subagent-runtime.js.map +1 -1
- package/lib/subagent/subagent-system-init.d.ts +2 -1
- package/lib/subagent/subagent-system-init.d.ts.map +1 -1
- package/lib/subagent/subagent-system-init.js +1 -0
- package/lib/subagent/subagent-system-init.js.map +1 -1
- package/lib/subagent-ai-events.d.ts +3 -2
- package/lib/subagent-ai-events.d.ts.map +1 -1
- package/lib/subagent-ai-events.js.map +1 -1
- package/lib/subagent-parent-context.js +1 -1
- package/lib/subagent-parent-context.js.map +1 -1
- package/lib/subagent-prompt.d.ts +1 -1
- package/lib/subagent-prompt.js +2 -5
- package/lib/subagent-prompt.js.map +1 -1
- package/lib/task-executor.d.ts +2 -14
- package/lib/task-executor.d.ts.map +1 -1
- package/lib/task-executor.js +2 -11
- package/lib/task-executor.js.map +1 -1
- package/lib/tool/builtin-policy-extractors.d.ts +2 -1
- package/lib/tool/builtin-policy-extractors.d.ts.map +1 -1
- package/lib/tool/builtin-policy-extractors.js +18 -15
- package/lib/tool/builtin-policy-extractors.js.map +1 -1
- package/lib/tool/context-tools.js +1 -1
- package/lib/tool/context-tools.js.map +1 -1
- package/lib/tool/conversation-reference-tool.d.ts.map +1 -1
- package/lib/tool/conversation-reference-tool.js +1 -1
- package/lib/tool/conversation-reference-tool.js.map +1 -1
- package/lib/tool/deferred-resolution.js +2 -2
- package/lib/tool/deferred-resolution.js.map +1 -1
- package/lib/tool/executable-tool-registry.d.ts +11 -0
- package/lib/tool/executable-tool-registry.d.ts.map +1 -0
- package/lib/tool/executable-tool-registry.js +25 -0
- package/lib/tool/executable-tool-registry.js.map +1 -0
- package/lib/tool/index.d.ts +1 -1
- package/lib/tool/index.d.ts.map +1 -1
- package/lib/tool/index.js +1 -1
- 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 +1 -2
- package/lib/tool/prepare-turn-tools.js.map +1 -1
- package/lib/tool/sources.d.ts.map +1 -1
- package/lib/tool/sources.js +5 -4
- package/lib/tool/sources.js.map +1 -1
- package/lib/tool/tool-approval-gate.d.ts +1 -2
- package/lib/tool/tool-approval-gate.d.ts.map +1 -1
- package/lib/tool/tool-approval-gate.js +24 -0
- package/lib/tool/tool-approval-gate.js.map +1 -1
- package/lib/tool/tool-execution-authority.d.ts +26 -0
- package/lib/tool/tool-execution-authority.d.ts.map +1 -0
- package/lib/tool/tool-execution-authority.js +84 -0
- package/lib/tool/tool-execution-authority.js.map +1 -0
- package/lib/tool/tool-runtime.d.ts +10 -9
- package/lib/tool/tool-runtime.d.ts.map +1 -1
- package/lib/tool/tool-runtime.js +77 -79
- package/lib/tool/tool-runtime.js.map +1 -1
- package/lib/tool/tool-system.js +1 -1
- package/lib/tool/tool-system.js.map +1 -1
- package/lib/tool/turn-tool-runtime.d.ts +6 -2
- package/lib/tool/turn-tool-runtime.d.ts.map +1 -1
- package/lib/tool/turn-tool-runtime.js +19 -5
- package/lib/tool/turn-tool-runtime.js.map +1 -1
- package/lib/tool-catalog/deferred-turn-controller.d.ts +2 -2
- package/lib/tool-catalog/deferred-turn-controller.d.ts.map +1 -1
- package/lib/tool-catalog/deferred-turn-controller.js +4 -4
- package/lib/tool-catalog/deferred-turn-controller.js.map +1 -1
- package/lib/turn/deferred-auto-continue.js +1 -1
- package/lib/turn/deferred-auto-continue.js.map +1 -1
- package/lib/turn/deferred-delivery.js +1 -1
- package/lib/turn/deferred-delivery.js.map +1 -1
- package/lib/turn/inbound-media.d.ts +8 -1
- package/lib/turn/inbound-media.d.ts.map +1 -1
- package/lib/turn/inbound-media.js +4 -6
- package/lib/turn/inbound-media.js.map +1 -1
- package/lib/turn/index.d.ts +2 -2
- package/lib/turn/index.d.ts.map +1 -1
- package/lib/turn/index.js +2 -2
- package/lib/turn/index.js.map +1 -1
- package/lib/turn/persist-deferred-context.js +1 -1
- package/lib/turn/prompt-api.d.ts +3 -4
- package/lib/turn/prompt-api.d.ts.map +1 -1
- package/lib/turn/prompt-api.js +7 -11
- package/lib/turn/prompt-api.js.map +1 -1
- package/lib/turn/task-continuation.d.ts +0 -5
- package/lib/turn/task-continuation.d.ts.map +1 -1
- package/lib/turn/task-continuation.js +0 -15
- package/lib/turn/task-continuation.js.map +1 -1
- package/lib/turn/turn-ingress.d.ts +1 -1
- package/lib/turn/turn-ingress.d.ts.map +1 -1
- package/lib/turn/turn-metrics.d.ts +0 -4
- package/lib/turn/turn-metrics.d.ts.map +1 -1
- package/lib/turn/turn-metrics.js +0 -8
- package/lib/turn/turn-metrics.js.map +1 -1
- package/lib/turn/turn-pipeline.js +7 -4
- package/lib/turn/turn-pipeline.js.map +1 -1
- package/lib/typing-indicator/adapter-integration.d.ts +1 -4
- package/lib/typing-indicator/adapter-integration.d.ts.map +1 -1
- package/lib/typing-indicator/adapter-integration.js.map +1 -1
- package/lib/typing-indicator/index.d.ts +0 -17
- package/lib/typing-indicator/index.d.ts.map +1 -1
- package/lib/typing-indicator/index.js +0 -31
- package/lib/typing-indicator/index.js.map +1 -1
- package/lib/user-profile.js +1 -1
- package/lib/user-profile.js.map +1 -1
- package/lib/utils/config-env.d.ts +1 -1
- package/lib/utils/config-env.js +1 -1
- package/lib/web/bing-search-html.d.ts.map +1 -0
- package/lib/{builtin → web}/bing-search-html.js +2 -6
- package/lib/web/bing-search-html.js.map +1 -0
- package/lib/web/web-search-locale.d.ts +5 -0
- package/lib/web/web-search-locale.d.ts.map +1 -0
- package/lib/web/web-search-locale.js +13 -0
- package/lib/web/web-search-locale.js.map +1 -0
- package/lib/{builtin → web}/web-tool-utils.d.ts +0 -1
- package/lib/web/web-tool-utils.d.ts.map +1 -0
- package/lib/{builtin → web}/web-tool-utils.js +0 -1
- package/lib/web/web-tool-utils.js.map +1 -0
- package/lib/workroom/acceptance-control.d.ts +2 -1
- package/lib/workroom/acceptance-control.d.ts.map +1 -1
- package/lib/workroom/acceptance-control.js +12 -2
- package/lib/workroom/acceptance-control.js.map +1 -1
- package/lib/workroom/accepted-source-memory-application.d.ts +1 -1
- package/lib/workroom/accepted-source-memory-application.d.ts.map +1 -1
- package/lib/workroom/assignment-authority-grant-application.d.ts +2 -2
- package/lib/workroom/assignment-authority-grant-application.d.ts.map +1 -1
- package/lib/workroom/assignment-authority-grant-application.js +1 -1
- package/lib/workroom/assignment-authority-grant-application.js.map +1 -1
- package/lib/workroom/assignment-authority-grant-repository.d.ts +1 -1
- package/lib/workroom/assignment-authority-grant-repository.d.ts.map +1 -1
- package/lib/workroom/assignment-authority.d.ts +75 -0
- package/lib/workroom/assignment-authority.d.ts.map +1 -0
- package/lib/workroom/assignment-authority.js +179 -0
- package/lib/workroom/assignment-authority.js.map +1 -0
- package/lib/workroom/catalog-definition.d.ts +0 -6
- package/lib/workroom/catalog-definition.d.ts.map +1 -1
- package/lib/workroom/catalog.js +1 -1
- package/lib/workroom/catalog.js.map +1 -1
- package/lib/workroom/coding-assignment-executor.d.ts +90 -0
- package/lib/workroom/coding-assignment-executor.d.ts.map +1 -0
- package/lib/workroom/coding-assignment-executor.js +250 -0
- package/lib/workroom/coding-assignment-executor.js.map +1 -0
- package/lib/workroom/coding-git-objects.d.ts +17 -0
- package/lib/workroom/coding-git-objects.d.ts.map +1 -0
- package/lib/workroom/coding-git-objects.js +68 -0
- package/lib/workroom/coding-git-objects.js.map +1 -0
- package/lib/workroom/durable-file-store.d.ts +2 -0
- package/lib/workroom/durable-file-store.d.ts.map +1 -1
- package/lib/workroom/durable-file-store.js +5 -0
- package/lib/workroom/durable-file-store.js.map +1 -1
- package/lib/workroom/effect-blocker-repository.d.ts +17 -1
- package/lib/workroom/effect-blocker-repository.d.ts.map +1 -1
- package/lib/workroom/effect-blocker-repository.js.map +1 -1
- package/lib/workroom/effect-ledger.d.ts +21 -1
- package/lib/workroom/effect-ledger.d.ts.map +1 -1
- package/lib/workroom/effect-ledger.js +44 -3
- package/lib/workroom/effect-ledger.js.map +1 -1
- package/lib/workroom/file-accepted-source-memory-repository.d.ts.map +1 -1
- package/lib/workroom/file-accepted-source-memory-repository.js +6 -3
- package/lib/workroom/file-accepted-source-memory-repository.js.map +1 -1
- package/lib/workroom/file-coding-execution-store.d.ts +25 -0
- package/lib/workroom/file-coding-execution-store.d.ts.map +1 -0
- package/lib/workroom/file-coding-execution-store.js +122 -0
- package/lib/workroom/file-coding-execution-store.js.map +1 -0
- package/lib/workroom/file-effect-ledger.d.ts.map +1 -1
- package/lib/workroom/file-effect-ledger.js +6 -3
- package/lib/workroom/file-effect-ledger.js.map +1 -1
- package/lib/workroom/git-workspace-gateway.d.ts +6 -3
- package/lib/workroom/git-workspace-gateway.d.ts.map +1 -1
- package/lib/workroom/git-workspace-gateway.js +10 -1
- package/lib/workroom/git-workspace-gateway.js.map +1 -1
- package/lib/workroom/github-workspace-transport.d.ts +30 -0
- package/lib/workroom/github-workspace-transport.d.ts.map +1 -0
- package/lib/workroom/github-workspace-transport.js +224 -0
- package/lib/workroom/github-workspace-transport.js.map +1 -0
- package/lib/{plugin-runtime/workroom-governed-dispatch-reasons.d.ts → workroom/governed-dispatch-reasons.d.ts} +2 -2
- package/lib/workroom/governed-dispatch-reasons.d.ts.map +1 -0
- package/lib/{plugin-runtime/workroom-governed-dispatch-reasons.js → workroom/governed-dispatch-reasons.js} +1 -1
- package/lib/workroom/governed-dispatch-reasons.js.map +1 -0
- package/lib/workroom/human-ingress-source-reader.d.ts +3 -3
- package/lib/workroom/human-ingress-source-reader.d.ts.map +1 -1
- package/lib/workroom/human-ingress-source-reader.js.map +1 -1
- package/lib/workroom/journal/activatable-journal.d.ts +15 -0
- package/lib/workroom/journal/activatable-journal.d.ts.map +1 -0
- package/lib/workroom/journal/activatable-journal.js +39 -0
- package/lib/workroom/journal/activatable-journal.js.map +1 -0
- package/lib/workroom/{journal.d.ts → journal/contracts.d.ts} +18 -96
- package/lib/workroom/journal/contracts.d.ts.map +1 -0
- package/lib/workroom/journal/contracts.js +19 -0
- package/lib/workroom/journal/contracts.js.map +1 -0
- package/lib/workroom/journal/database-journal.d.ts +31 -0
- package/lib/workroom/journal/database-journal.d.ts.map +1 -0
- package/lib/workroom/journal/database-journal.js +118 -0
- package/lib/workroom/journal/database-journal.js.map +1 -0
- package/lib/workroom/journal/event-codec.d.ts +26 -0
- package/lib/workroom/journal/event-codec.d.ts.map +1 -0
- package/lib/workroom/journal/event-codec.js +233 -0
- package/lib/workroom/journal/event-codec.js.map +1 -0
- package/lib/workroom/journal/event-validation.d.ts +10 -0
- package/lib/workroom/journal/event-validation.d.ts.map +1 -0
- package/lib/workroom/journal/event-validation.js +671 -0
- package/lib/workroom/journal/event-validation.js.map +1 -0
- package/lib/workroom/journal/file-journal.d.ts +15 -0
- package/lib/workroom/journal/file-journal.d.ts.map +1 -0
- package/lib/workroom/journal/file-journal.js +272 -0
- package/lib/workroom/journal/file-journal.js.map +1 -0
- package/lib/workroom/journal/index.d.ts +9 -0
- package/lib/workroom/journal/index.d.ts.map +1 -0
- package/lib/workroom/journal/index.js +8 -0
- package/lib/workroom/journal/index.js.map +1 -0
- package/lib/workroom/journal/memory-journal.d.ts +27 -0
- package/lib/workroom/journal/memory-journal.d.ts.map +1 -0
- package/lib/workroom/journal/memory-journal.js +103 -0
- package/lib/workroom/journal/memory-journal.js.map +1 -0
- package/lib/workroom/journal/payload-governance.d.ts +29 -0
- package/lib/workroom/journal/payload-governance.d.ts.map +1 -0
- package/lib/workroom/journal/payload-governance.js +282 -0
- package/lib/workroom/journal/payload-governance.js.map +1 -0
- package/lib/workroom/journal/payload-reference.d.ts +9 -0
- package/lib/workroom/journal/payload-reference.d.ts.map +1 -0
- package/lib/workroom/journal/payload-reference.js +60 -0
- package/lib/workroom/journal/payload-reference.js.map +1 -0
- package/lib/workroom/journal/stored-event-projection.d.ts +6 -0
- package/lib/workroom/journal/stored-event-projection.d.ts.map +1 -0
- package/lib/workroom/journal/stored-event-projection.js +280 -0
- package/lib/workroom/journal/stored-event-projection.js.map +1 -0
- package/lib/workroom/kernel-state.d.ts.map +1 -1
- package/lib/workroom/kernel-state.js +35 -3
- package/lib/workroom/kernel-state.js.map +1 -1
- package/lib/workroom/{projection-outbox.d.ts → projection-outbox/contracts.d.ts} +8 -72
- package/lib/workroom/projection-outbox/contracts.d.ts.map +1 -0
- package/lib/workroom/projection-outbox/contracts.js +11 -0
- package/lib/workroom/projection-outbox/contracts.js.map +1 -0
- package/lib/workroom/projection-outbox/delivery-worker.d.ts +22 -0
- package/lib/workroom/projection-outbox/delivery-worker.d.ts.map +1 -0
- package/lib/workroom/projection-outbox/delivery-worker.js +96 -0
- package/lib/workroom/projection-outbox/delivery-worker.js.map +1 -0
- package/lib/workroom/projection-outbox/file-repository.d.ts +11 -0
- package/lib/workroom/projection-outbox/file-repository.d.ts.map +1 -0
- package/lib/workroom/projection-outbox/file-repository.js +89 -0
- package/lib/workroom/projection-outbox/file-repository.js.map +1 -0
- package/lib/workroom/projection-outbox/index.d.ts +10 -0
- package/lib/workroom/projection-outbox/index.d.ts.map +1 -0
- package/lib/workroom/projection-outbox/index.js +8 -0
- package/lib/workroom/projection-outbox/index.js.map +1 -0
- package/lib/workroom/projection-outbox/memory-repository.d.ts +11 -0
- package/lib/workroom/projection-outbox/memory-repository.d.ts.map +1 -0
- package/lib/workroom/projection-outbox/memory-repository.js +40 -0
- package/lib/workroom/projection-outbox/memory-repository.js.map +1 -0
- package/lib/workroom/projection-outbox/projector.d.ts +36 -0
- package/lib/workroom/projection-outbox/projector.d.ts.map +1 -0
- package/lib/workroom/projection-outbox/projector.js +517 -0
- package/lib/workroom/projection-outbox/projector.js.map +1 -0
- package/lib/workroom/projection-outbox/repository-state.d.ts +17 -0
- package/lib/workroom/projection-outbox/repository-state.d.ts.map +1 -0
- package/lib/workroom/projection-outbox/repository-state.js +343 -0
- package/lib/workroom/projection-outbox/repository-state.js.map +1 -0
- package/lib/workroom/projection-outbox/tracer.d.ts +19 -0
- package/lib/workroom/projection-outbox/tracer.d.ts.map +1 -0
- package/lib/workroom/projection-outbox/tracer.js +201 -0
- package/lib/workroom/projection-outbox/tracer.js.map +1 -0
- package/lib/workroom/remote-dispatch-admission.d.ts +2 -2
- package/lib/workroom/remote-dispatch-admission.d.ts.map +1 -1
- package/lib/workroom/remote-dispatch-admission.js +1 -1
- package/lib/workroom/remote-dispatch-admission.js.map +1 -1
- package/lib/workroom/remote-dispatch-worker.d.ts +1 -1
- package/lib/workroom/remote-dispatch-worker.d.ts.map +1 -1
- package/lib/workroom/remote-dispatch-worker.js +1 -1
- package/lib/workroom/remote-dispatch-worker.js.map +1 -1
- package/lib/workroom/remote-executor.d.ts +15 -0
- package/lib/workroom/remote-executor.d.ts.map +1 -0
- package/lib/workroom/remote-executor.js +21 -0
- package/lib/workroom/remote-executor.js.map +1 -0
- package/lib/workroom/runtime.d.ts +1 -1
- package/lib/workroom/runtime.d.ts.map +1 -1
- package/lib/workroom/software-delivery-plan.d.ts +32 -0
- package/lib/workroom/software-delivery-plan.d.ts.map +1 -0
- package/lib/workroom/software-delivery-plan.js +60 -0
- package/lib/workroom/software-delivery-plan.js.map +1 -0
- package/lib/workroom/validate-catalog.d.ts +2 -0
- package/lib/workroom/validate-catalog.d.ts.map +1 -0
- package/lib/workroom/validate-catalog.js +230 -0
- package/lib/workroom/validate-catalog.js.map +1 -0
- package/lib/workroom/workroom-kernel.d.ts +1 -1
- package/lib/workroom/workroom-kernel.d.ts.map +1 -1
- package/lib/workroom/workroom-kernel.js +31 -13
- package/lib/workroom/workroom-kernel.js.map +1 -1
- package/lib/workroom/workroom-preemption.d.ts +1 -1
- package/lib/workroom/workroom-preemption.d.ts.map +1 -1
- package/lib/workroom/workroom-scheduler-application.d.ts +1 -1
- package/lib/workroom/workroom-scheduler-application.d.ts.map +1 -1
- package/lib/workroom/workroom-scheduler-application.js +1 -1
- package/lib/workroom/workroom-scheduler-application.js.map +1 -1
- package/lib/workroom/workroom-scheduler.js +3 -0
- package/lib/workroom/workroom-scheduler.js.map +1 -1
- package/lib/zhin-agent/index.d.ts +12 -6
- package/lib/zhin-agent/index.d.ts.map +1 -1
- package/lib/zhin-agent/index.js +18 -12
- package/lib/zhin-agent/index.js.map +1 -1
- package/package.json +14 -29
- package/lib/activity-feedback/ai-bus.d.ts +0 -21
- package/lib/activity-feedback/ai-bus.d.ts.map +0 -1
- package/lib/activity-feedback/ai-bus.js +0 -59
- package/lib/activity-feedback/ai-bus.js.map +0 -1
- package/lib/ai-hook-handlers.d.ts +0 -8
- package/lib/ai-hook-handlers.d.ts.map +0 -1
- package/lib/ai-hook-handlers.js +0 -46
- package/lib/ai-hook-handlers.js.map +0 -1
- package/lib/authoring/define-agent.d.ts +0 -4
- package/lib/authoring/define-agent.d.ts.map +0 -1
- package/lib/authoring/define-agent.js +0 -8
- package/lib/authoring/define-agent.js.map +0 -1
- package/lib/authoring/define-connection.d.ts +0 -5
- package/lib/authoring/define-connection.d.ts.map +0 -1
- package/lib/authoring/define-connection.js +0 -8
- package/lib/authoring/define-connection.js.map +0 -1
- package/lib/authoring/define-schedule.d.ts +0 -4
- package/lib/authoring/define-schedule.d.ts.map +0 -1
- package/lib/authoring/define-schedule.js +0 -8
- package/lib/authoring/define-schedule.js.map +0 -1
- package/lib/authoring/define-tool.d.ts +0 -20
- package/lib/authoring/define-tool.d.ts.map +0 -1
- package/lib/authoring/define-tool.js +0 -28
- package/lib/authoring/define-tool.js.map +0 -1
- package/lib/authoring/entries/connections.d.ts +0 -3
- package/lib/authoring/entries/connections.d.ts.map +0 -1
- package/lib/authoring/entries/connections.js +0 -2
- package/lib/authoring/entries/connections.js.map +0 -1
- package/lib/authoring/entries/schedules.d.ts +0 -3
- package/lib/authoring/entries/schedules.d.ts.map +0 -1
- package/lib/authoring/entries/schedules.js +0 -2
- package/lib/authoring/entries/schedules.js.map +0 -1
- package/lib/authoring/entries/tools.d.ts +0 -5
- package/lib/authoring/entries/tools.d.ts.map +0 -1
- package/lib/authoring/entries/tools.js +0 -3
- package/lib/authoring/entries/tools.js.map +0 -1
- package/lib/authoring/tool-policy.d.ts +0 -3
- package/lib/authoring/tool-policy.d.ts.map +0 -1
- package/lib/authoring/tool-policy.js +0 -2
- package/lib/authoring/tool-policy.js.map +0 -1
- package/lib/authoring/zod-schema.d.ts +0 -10
- package/lib/authoring/zod-schema.d.ts.map +0 -1
- package/lib/authoring/zod-schema.js +0 -7
- package/lib/authoring/zod-schema.js.map +0 -1
- package/lib/builtin/analyze-media-tool.d.ts +0 -13
- package/lib/builtin/analyze-media-tool.d.ts.map +0 -1
- package/lib/builtin/analyze-media-tool.js +0 -94
- package/lib/builtin/analyze-media-tool.js.map +0 -1
- package/lib/builtin/bash-tool.d.ts +0 -29
- package/lib/builtin/bash-tool.d.ts.map +0 -1
- package/lib/builtin/bash-tool.js +0 -107
- package/lib/builtin/bash-tool.js.map +0 -1
- package/lib/builtin/bing-search-html.d.ts.map +0 -1
- package/lib/builtin/bing-search-html.js.map +0 -1
- package/lib/builtin/builtin-base-tool.d.ts +0 -27
- package/lib/builtin/builtin-base-tool.d.ts.map +0 -1
- package/lib/builtin/builtin-base-tool.js +0 -35
- package/lib/builtin/builtin-base-tool.js.map +0 -1
- package/lib/builtin/edit-file-tool.d.ts +0 -13
- package/lib/builtin/edit-file-tool.d.ts.map +0 -1
- package/lib/builtin/edit-file-tool.js +0 -86
- package/lib/builtin/edit-file-tool.js.map +0 -1
- package/lib/builtin/file-edit-quote-utils.d.ts.map +0 -1
- package/lib/builtin/file-edit-quote-utils.js.map +0 -1
- package/lib/builtin/five-agent/index.d.ts.map +0 -1
- package/lib/builtin/five-agent/index.js.map +0 -1
- package/lib/builtin/five-agent/prompts.d.ts.map +0 -1
- package/lib/builtin/five-agent/prompts.js.map +0 -1
- package/lib/builtin/five-agent/role-capability-policy.d.ts.map +0 -1
- package/lib/builtin/five-agent/role-capability-policy.js.map +0 -1
- package/lib/builtin/five-agent/roles.d.ts.map +0 -1
- package/lib/builtin/five-agent/roles.js.map +0 -1
- package/lib/builtin/generate-image-tool.d.ts +0 -21
- package/lib/builtin/generate-image-tool.d.ts.map +0 -1
- package/lib/builtin/generate-image-tool.js +0 -138
- package/lib/builtin/generate-image-tool.js.map +0 -1
- package/lib/builtin/glob-tool.d.ts +0 -23
- package/lib/builtin/glob-tool.d.ts.map +0 -1
- package/lib/builtin/glob-tool.js +0 -53
- package/lib/builtin/glob-tool.js.map +0 -1
- package/lib/builtin/grep-tool.d.ts +0 -23
- package/lib/builtin/grep-tool.d.ts.map +0 -1
- package/lib/builtin/grep-tool.js +0 -121
- package/lib/builtin/grep-tool.js.map +0 -1
- package/lib/builtin/install-skill-tool.d.ts +0 -24
- package/lib/builtin/install-skill-tool.d.ts.map +0 -1
- package/lib/builtin/install-skill-tool.js +0 -76
- package/lib/builtin/install-skill-tool.js.map +0 -1
- package/lib/builtin/knowledge-search-tool.d.ts +0 -6
- package/lib/builtin/knowledge-search-tool.d.ts.map +0 -1
- package/lib/builtin/knowledge-search-tool.js +0 -184
- package/lib/builtin/knowledge-search-tool.js.map +0 -1
- package/lib/builtin/list-dir-tool.d.ts +0 -13
- package/lib/builtin/list-dir-tool.d.ts.map +0 -1
- package/lib/builtin/list-dir-tool.js +0 -57
- package/lib/builtin/list-dir-tool.js.map +0 -1
- package/lib/builtin/load-skill-tool.d.ts +0 -20
- package/lib/builtin/load-skill-tool.d.ts.map +0 -1
- package/lib/builtin/load-skill-tool.js +0 -60
- package/lib/builtin/load-skill-tool.js.map +0 -1
- package/lib/builtin/read-file-tool.d.ts +0 -14
- package/lib/builtin/read-file-tool.d.ts.map +0 -1
- package/lib/builtin/read-file-tool.js +0 -74
- package/lib/builtin/read-file-tool.js.map +0 -1
- package/lib/builtin/run-deferred-task-tool.d.ts +0 -23
- package/lib/builtin/run-deferred-task-tool.d.ts.map +0 -1
- package/lib/builtin/run-deferred-task-tool.js +0 -41
- package/lib/builtin/run-deferred-task-tool.js.map +0 -1
- package/lib/builtin/spawn-task-tool.d.ts.map +0 -1
- package/lib/builtin/spawn-task-tool.js.map +0 -1
- package/lib/builtin/todo-read-tool.d.ts +0 -14
- package/lib/builtin/todo-read-tool.d.ts.map +0 -1
- package/lib/builtin/todo-read-tool.js +0 -56
- package/lib/builtin/todo-read-tool.js.map +0 -1
- package/lib/builtin/todo-write-tool.d.ts +0 -14
- package/lib/builtin/todo-write-tool.d.ts.map +0 -1
- package/lib/builtin/todo-write-tool.js +0 -54
- package/lib/builtin/todo-write-tool.js.map +0 -1
- package/lib/builtin/web-fetch-tool.d.ts +0 -21
- package/lib/builtin/web-fetch-tool.d.ts.map +0 -1
- package/lib/builtin/web-fetch-tool.js +0 -86
- package/lib/builtin/web-fetch-tool.js.map +0 -1
- package/lib/builtin/web-search-locale.d.ts +0 -16
- package/lib/builtin/web-search-locale.d.ts.map +0 -1
- package/lib/builtin/web-search-locale.js +0 -74
- package/lib/builtin/web-search-locale.js.map +0 -1
- package/lib/builtin/web-search-tool.d.ts +0 -20
- package/lib/builtin/web-search-tool.d.ts.map +0 -1
- package/lib/builtin/web-search-tool.js +0 -115
- package/lib/builtin/web-search-tool.js.map +0 -1
- package/lib/builtin/web-tool-utils.d.ts.map +0 -1
- package/lib/builtin/web-tool-utils.js.map +0 -1
- package/lib/builtin/write-file-tool.d.ts +0 -13
- package/lib/builtin/write-file-tool.d.ts.map +0 -1
- package/lib/builtin/write-file-tool.js +0 -55
- package/lib/builtin/write-file-tool.js.map +0 -1
- package/lib/builtin-tools.d.ts +0 -25
- package/lib/builtin-tools.d.ts.map +0 -1
- package/lib/builtin-tools.js +0 -54
- package/lib/builtin-tools.js.map +0 -1
- package/lib/defaults/hooks.d.ts +0 -6
- package/lib/defaults/hooks.d.ts.map +0 -1
- package/lib/defaults/hooks.js +0 -9
- package/lib/defaults/hooks.js.map +0 -1
- package/lib/defaults/subagents.d.ts +0 -6
- package/lib/defaults/subagents.d.ts.map +0 -1
- package/lib/defaults/subagents.js +0 -23
- package/lib/defaults/subagents.js.map +0 -1
- package/lib/defaults/tools.d.ts +0 -5
- package/lib/defaults/tools.d.ts.map +0 -1
- package/lib/defaults/tools.js +0 -6
- package/lib/defaults/tools.js.map +0 -1
- package/lib/discovery/index.d.ts +0 -5
- package/lib/discovery/index.d.ts.map +0 -1
- package/lib/discovery/index.js +0 -5
- package/lib/discovery/index.js.map +0 -1
- package/lib/discovery/skills.d.ts +0 -53
- package/lib/discovery/skills.d.ts.map +0 -1
- package/lib/discovery/skills.js +0 -306
- package/lib/discovery/skills.js.map +0 -1
- package/lib/discovery/tools.d.ts +0 -53
- package/lib/discovery/tools.d.ts.map +0 -1
- package/lib/discovery/tools.js +0 -305
- package/lib/discovery/tools.js.map +0 -1
- package/lib/features/agent-feature.d.ts +0 -23
- package/lib/features/agent-feature.d.ts.map +0 -1
- package/lib/features/agent-feature.js +0 -51
- package/lib/features/agent-feature.js.map +0 -1
- package/lib/features/index.d.ts +0 -3
- package/lib/features/index.d.ts.map +0 -1
- package/lib/features/index.js +0 -3
- package/lib/features/index.js.map +0 -1
- package/lib/features/mcp-feature.d.ts +0 -25
- package/lib/features/mcp-feature.d.ts.map +0 -1
- package/lib/features/mcp-feature.js +0 -52
- package/lib/features/mcp-feature.js.map +0 -1
- package/lib/hooks.d.ts +0 -144
- package/lib/hooks.d.ts.map +0 -1
- package/lib/hooks.js +0 -82
- package/lib/hooks.js.map +0 -1
- package/lib/ingress/capability-ingress.d.ts +0 -76
- package/lib/ingress/capability-ingress.d.ts.map +0 -1
- package/lib/ingress/capability-ingress.js +0 -274
- package/lib/ingress/capability-ingress.js.map +0 -1
- package/lib/ingress/index.d.ts +0 -2
- package/lib/ingress/index.d.ts.map +0 -1
- package/lib/ingress/index.js +0 -2
- package/lib/ingress/index.js.map +0 -1
- package/lib/init/introspection-args.d.ts +0 -37
- package/lib/init/introspection-args.d.ts.map +0 -1
- package/lib/init/introspection-args.js +0 -71
- package/lib/init/introspection-args.js.map +0 -1
- package/lib/init/introspection-collectors.d.ts +0 -26
- package/lib/init/introspection-collectors.d.ts.map +0 -1
- package/lib/init/introspection-collectors.js +0 -108
- package/lib/init/introspection-collectors.js.map +0 -1
- package/lib/init/introspection-commands-format.d.ts +0 -40
- package/lib/init/introspection-commands-format.d.ts.map +0 -1
- package/lib/init/introspection-commands-format.js +0 -93
- package/lib/init/introspection-commands-format.js.map +0 -1
- package/lib/init/introspection-pagination.d.ts +0 -14
- package/lib/init/introspection-pagination.d.ts.map +0 -1
- package/lib/init/introspection-pagination.js +0 -33
- package/lib/init/introspection-pagination.js.map +0 -1
- package/lib/init/introspection-rest.d.ts +0 -24
- package/lib/init/introspection-rest.d.ts.map +0 -1
- package/lib/init/introspection-rest.js +0 -65
- package/lib/init/introspection-rest.js.map +0 -1
- package/lib/init/upgrade-agent-db-schema.d.ts +0 -49
- package/lib/init/upgrade-agent-db-schema.d.ts.map +0 -1
- package/lib/init/upgrade-agent-db-schema.js +0 -210
- package/lib/init/upgrade-agent-db-schema.js.map +0 -1
- package/lib/init/upgrade-endpoint-id-schema.d.ts +0 -12
- package/lib/init/upgrade-endpoint-id-schema.d.ts.map +0 -1
- package/lib/init/upgrade-endpoint-id-schema.js +0 -58
- package/lib/init/upgrade-endpoint-id-schema.js.map +0 -1
- package/lib/plugin-runtime/workroom-governed-dispatch-reasons.d.ts.map +0 -1
- package/lib/plugin-runtime/workroom-governed-dispatch-reasons.js.map +0 -1
- package/lib/resource-hub/tool-registry.d.ts +0 -60
- package/lib/resource-hub/tool-registry.d.ts.map +0 -1
- package/lib/resource-hub/tool-registry.js +0 -228
- package/lib/resource-hub/tool-registry.js.map +0 -1
- package/lib/security/owner-approve-always-store.d.ts +0 -67
- package/lib/security/owner-approve-always-store.d.ts.map +0 -1
- package/lib/security/owner-approve-always-store.js +0 -510
- package/lib/security/owner-approve-always-store.js.map +0 -1
- package/lib/security/turn-sandbox-authority.d.ts +0 -13
- package/lib/security/turn-sandbox-authority.d.ts.map +0 -1
- package/lib/security/turn-sandbox-authority.js +0 -42
- package/lib/security/turn-sandbox-authority.js.map +0 -1
- package/lib/skill/skill-load-opts.d.ts +0 -5
- package/lib/skill/skill-load-opts.d.ts.map +0 -1
- package/lib/skill/skill-load-opts.js +0 -14
- package/lib/skill/skill-load-opts.js.map +0 -1
- package/lib/stability/registry-cleanup.d.ts +0 -5
- package/lib/stability/registry-cleanup.d.ts.map +0 -1
- package/lib/stability/registry-cleanup.js +0 -20
- package/lib/stability/registry-cleanup.js.map +0 -1
- package/lib/tool/classic-tool-execution-authority.d.ts +0 -22
- package/lib/tool/classic-tool-execution-authority.d.ts.map +0 -1
- package/lib/tool/classic-tool-execution-authority.js +0 -80
- package/lib/tool/classic-tool-execution-authority.js.map +0 -1
- package/lib/tool/tool-registry-as-service.d.ts +0 -17
- package/lib/tool/tool-registry-as-service.d.ts.map +0 -1
- package/lib/tool/tool-registry-as-service.js +0 -54
- package/lib/tool/tool-registry-as-service.js.map +0 -1
- package/lib/tool/web-search-locale-attach.d.ts +0 -4
- package/lib/tool/web-search-locale-attach.d.ts.map +0 -1
- package/lib/tool/web-search-locale-attach.js +0 -20
- package/lib/tool/web-search-locale-attach.js.map +0 -1
- package/lib/typing-indicator/integration.d.ts +0 -89
- package/lib/typing-indicator/integration.d.ts.map +0 -1
- package/lib/typing-indicator/integration.js +0 -261
- package/lib/typing-indicator/integration.js.map +0 -1
- package/lib/workroom/journal.d.ts.map +0 -1
- package/lib/workroom/journal.js +0 -2038
- package/lib/workroom/journal.js.map +0 -1
- package/lib/workroom/local-assignment-executor.d.ts.map +0 -1
- package/lib/workroom/local-assignment-executor.js.map +0 -1
- package/lib/workroom/projection-outbox.d.ts.map +0 -1
- package/lib/workroom/projection-outbox.js +0 -1326
- package/lib/workroom/projection-outbox.js.map +0 -1
- /package/lib/{builtin → orchestration}/five-agent/index.d.ts +0 -0
- /package/lib/{builtin → orchestration}/five-agent/index.js +0 -0
- /package/lib/{builtin → orchestration}/five-agent/prompts.d.ts +0 -0
- /package/lib/{builtin → orchestration}/five-agent/prompts.js +0 -0
- /package/lib/{builtin → orchestration}/five-agent/role-capability-policy.d.ts +0 -0
- /package/lib/{builtin → orchestration}/five-agent/role-capability-policy.js +0 -0
- /package/lib/{builtin → orchestration}/five-agent/roles.d.ts +0 -0
- /package/lib/{builtin → orchestration}/five-agent/roles.js +0 -0
- /package/lib/{builtin → plugin-runtime}/file-edit-quote-utils.d.ts +0 -0
- /package/lib/{builtin → plugin-runtime}/file-edit-quote-utils.js +0 -0
- /package/lib/{builtin → web}/bing-search-html.d.ts +0 -0
package/lib/workroom/journal.js
DELETED
|
@@ -1,2038 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { readFile, readdir } from 'node:fs/promises';
|
|
3
|
-
import { basename, join } from 'node:path';
|
|
4
|
-
import { assertAcceptanceContract, assertPersistedAcceptanceRecord } from './acceptance-policy.js';
|
|
5
|
-
import { canonicalWorkroomJson, compareCanonicalWorkroomText, deepFreezeWorkroomValue as deepFreeze, digestCanonicalWorkroomValue, } from './canonical-value.js';
|
|
6
|
-
import { assertWorkflowPlanProposal } from './workflow-plan-builder.js';
|
|
7
|
-
import { assertWorkflowPlanRevisionCandidate } from './plan-revision.js';
|
|
8
|
-
import { parseWorkroomRemoteAssignmentIssuance } from './remote-assignment-issuance.js';
|
|
9
|
-
import { parseWorkroomLocalAssignmentIssuance } from './local-assignment-issuance.js';
|
|
10
|
-
import { isWorkroomRunCancelReasonCode, isWorkroomRunReplanReasonCode, } from './workroom-run-control.js';
|
|
11
|
-
import { assertWorkroomSchedulerPolicySnapshot, parseWorkroomDispatchTaskDecision, parseWorkroomPreemptionPrepareDecision, parseWorkroomPriorityChangeProposal, } from './workroom-scheduler.js';
|
|
12
|
-
import { DurableFileStore } from './durable-file-store.js';
|
|
13
|
-
import { FileLegacyEmbeddedPayloadReadAdapter, LegacyEmbeddedPayloadDetectedError, assertActiveStoreHasNoLegacyEmbeddedPayload, } from './legacy-embedded-payload-migration.js';
|
|
14
|
-
export class WorkroomJournalPayloadAuthorityUnavailableError extends Error {
|
|
15
|
-
constructor() {
|
|
16
|
-
super('Governed Workroom Journal payload authority is unavailable');
|
|
17
|
-
this.name = 'WorkroomJournalPayloadAuthorityUnavailableError';
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export class WorkroomSequenceConflictError extends Error {
|
|
21
|
-
runId;
|
|
22
|
-
expectedSequence;
|
|
23
|
-
actualSequence;
|
|
24
|
-
constructor(runId, expectedSequence, actualSequence) {
|
|
25
|
-
super(`Workroom ${runId} sequence conflict: expected ${expectedSequence}, actual ${actualSequence}`);
|
|
26
|
-
this.runId = runId;
|
|
27
|
-
this.expectedSequence = expectedSequence;
|
|
28
|
-
this.actualSequence = actualSequence;
|
|
29
|
-
this.name = 'WorkroomSequenceConflictError';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export class MemoryWorkroomJournal {
|
|
33
|
-
#runs = new Map();
|
|
34
|
-
#payloads;
|
|
35
|
-
constructor(payloads = new MemoryWorkroomJournalPayloadPort()) {
|
|
36
|
-
this.#payloads = payloads;
|
|
37
|
-
}
|
|
38
|
-
async listRunIds() {
|
|
39
|
-
return Object.freeze([...this.#runs.keys()].sort());
|
|
40
|
-
}
|
|
41
|
-
async scanStoredHeaders() {
|
|
42
|
-
return Object.freeze([...this.#runs.entries()]
|
|
43
|
-
.sort(([left], [right]) => compareCanonicalWorkroomText(left, right))
|
|
44
|
-
.map(([runId, events]) => storedRunHeaders(runId, events)));
|
|
45
|
-
}
|
|
46
|
-
async readStoredHeaders(runId) {
|
|
47
|
-
const events = this.#runs.get(runId) ?? [];
|
|
48
|
-
return events.length === 0 ? null : storedRunHeaders(runId, events);
|
|
49
|
-
}
|
|
50
|
-
async verifyGovernedPayloadPublication(intent) {
|
|
51
|
-
const events = this.#runs.get(intent.publicationScope ?? '') ?? [];
|
|
52
|
-
return verifyJournalPayloadPublication(intent, events);
|
|
53
|
-
}
|
|
54
|
-
async read(runId) {
|
|
55
|
-
const events = this.#runs.get(runId) ?? [];
|
|
56
|
-
return events.length === 0
|
|
57
|
-
? Object.freeze([])
|
|
58
|
-
: await materializeStoredEvents(events, this.#payloads);
|
|
59
|
-
}
|
|
60
|
-
async append(runId, expectedSequence, drafts) {
|
|
61
|
-
const current = this.#runs.get(runId) ?? [];
|
|
62
|
-
const actualSequence = current.at(-1)?.sequence ?? -1;
|
|
63
|
-
if (actualSequence !== expectedSequence) {
|
|
64
|
-
throw new WorkroomSequenceConflictError(runId, expectedSequence, actualSequence);
|
|
65
|
-
}
|
|
66
|
-
if (drafts.length === 0)
|
|
67
|
-
return [];
|
|
68
|
-
const appended = materializeEvents(runId, expectedSequence, drafts);
|
|
69
|
-
const projectId = projectIdForAppend(current, appended);
|
|
70
|
-
const protectedEvents = await protectEvents(appended, projectId, this.#payloads);
|
|
71
|
-
const winner = this.#runs.get(runId) ?? [];
|
|
72
|
-
const winnerSequence = winner.at(-1)?.sequence ?? -1;
|
|
73
|
-
if (winnerSequence !== expectedSequence) {
|
|
74
|
-
throw new WorkroomSequenceConflictError(runId, expectedSequence, winnerSequence);
|
|
75
|
-
}
|
|
76
|
-
this.#runs.set(runId, Object.freeze([...current, ...protectedEvents]));
|
|
77
|
-
return appended;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/** In-memory authority used by the non-production Memory journal. */
|
|
81
|
-
export class MemoryWorkroomJournalPayloadPort {
|
|
82
|
-
#values = new Map();
|
|
83
|
-
async write(input) {
|
|
84
|
-
if (digestCanonicalWorkroomValue(input.value) !== input.contentHash) {
|
|
85
|
-
throw new Error('Memory Workroom Journal payload content hash drift');
|
|
86
|
-
}
|
|
87
|
-
const objectId = createWorkroomJournalPayloadObjectId(input);
|
|
88
|
-
const vaultObjectId = `memory:${digestCanonicalWorkroomValue({ objectId, contentHash: input.contentHash })}`;
|
|
89
|
-
const existing = this.#values.get(vaultObjectId);
|
|
90
|
-
if (existing !== undefined
|
|
91
|
-
&& digestCanonicalWorkroomValue(existing) !== input.contentHash) {
|
|
92
|
-
throw new Error('Memory Workroom Journal payload identity conflict');
|
|
93
|
-
}
|
|
94
|
-
this.#values.set(vaultObjectId, structuredClone(input.value));
|
|
95
|
-
return Object.freeze({
|
|
96
|
-
descriptor: Object.freeze({
|
|
97
|
-
vaultObjectId,
|
|
98
|
-
objectId,
|
|
99
|
-
payloadHash: input.contentHash,
|
|
100
|
-
descriptorDigest: digestCanonicalWorkroomValue({
|
|
101
|
-
objectId,
|
|
102
|
-
payloadHash: input.contentHash,
|
|
103
|
-
projectId: input.projectId,
|
|
104
|
-
}),
|
|
105
|
-
locationManifestDigest: digestCanonicalWorkroomValue({ location: vaultObjectId }),
|
|
106
|
-
bytes: Buffer.byteLength(canonicalWorkroomJson(input.value)),
|
|
107
|
-
}),
|
|
108
|
-
source: Object.freeze({
|
|
109
|
-
kind: 'command',
|
|
110
|
-
ref: input.source.ref,
|
|
111
|
-
digest: input.source.digest,
|
|
112
|
-
bindingDigest: input.source.bindingDigest,
|
|
113
|
-
verification: 'verified',
|
|
114
|
-
}),
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
async read(input) {
|
|
118
|
-
const value = this.#values.get(input.receipt.descriptor.vaultObjectId);
|
|
119
|
-
if (value === undefined)
|
|
120
|
-
throw new Error('Memory Workroom Journal payload is unavailable');
|
|
121
|
-
return structuredClone(value);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Durable append-only journal. Every committed batch is an immutable segment;
|
|
126
|
-
* publishing its first sequence with an exclusive hard-link is the filesystem
|
|
127
|
-
* CAS. Separate generation instances and separate processes therefore cannot
|
|
128
|
-
* overwrite one another after reading the same expectedSequence.
|
|
129
|
-
*/
|
|
130
|
-
export class FileWorkroomJournal {
|
|
131
|
-
#directory;
|
|
132
|
-
#store;
|
|
133
|
-
#payloads;
|
|
134
|
-
constructor(directory, payloads) {
|
|
135
|
-
this.#directory = directory;
|
|
136
|
-
this.#store = new DurableFileStore(directory);
|
|
137
|
-
this.#payloads = payloads;
|
|
138
|
-
}
|
|
139
|
-
async listRunIds() {
|
|
140
|
-
let names;
|
|
141
|
-
try {
|
|
142
|
-
names = await readdir(this.#directory);
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
if (isMissingFile(error))
|
|
146
|
-
return Object.freeze([]);
|
|
147
|
-
throw error;
|
|
148
|
-
}
|
|
149
|
-
if (names.some(name => name.endsWith('.json') && !isSegmentName(name))) {
|
|
150
|
-
throw new Error('Invalid Workroom journal segment name');
|
|
151
|
-
}
|
|
152
|
-
const ids = new Set();
|
|
153
|
-
for (const name of names) {
|
|
154
|
-
if (!isSegmentName(name))
|
|
155
|
-
continue;
|
|
156
|
-
const events = await this.#readStoredFile(join(this.#directory, name), segmentFirstSequence(name));
|
|
157
|
-
const runId = events[0]?.runId;
|
|
158
|
-
if (runId)
|
|
159
|
-
ids.add(runId);
|
|
160
|
-
}
|
|
161
|
-
if (ids.size > 0)
|
|
162
|
-
await this.#store.syncLeaf();
|
|
163
|
-
return Object.freeze([...ids].sort());
|
|
164
|
-
}
|
|
165
|
-
async scanStoredHeaders() {
|
|
166
|
-
const groups = new Map();
|
|
167
|
-
let names;
|
|
168
|
-
try {
|
|
169
|
-
names = (await readdir(this.#directory)).filter(name => name.endsWith('.json')).sort();
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
if (isMissingFile(error))
|
|
173
|
-
return Object.freeze([]);
|
|
174
|
-
throw error;
|
|
175
|
-
}
|
|
176
|
-
if (names.some(name => !isSegmentName(name))) {
|
|
177
|
-
throw new Error('Invalid Workroom journal segment name');
|
|
178
|
-
}
|
|
179
|
-
for (const name of names) {
|
|
180
|
-
const events = await this.#readStoredFile(join(this.#directory, name), segmentFirstSequence(name));
|
|
181
|
-
const runId = events[0]?.runId;
|
|
182
|
-
if (!runId)
|
|
183
|
-
throw new Error('Workroom journal segment has no Run header');
|
|
184
|
-
groups.set(runId, [...(groups.get(runId) ?? []), ...events]);
|
|
185
|
-
}
|
|
186
|
-
if (groups.size > 0)
|
|
187
|
-
await this.#store.syncLeaf();
|
|
188
|
-
return Object.freeze([...groups.entries()]
|
|
189
|
-
.sort(([left], [right]) => compareCanonicalWorkroomText(left, right))
|
|
190
|
-
.map(([runId, events]) => storedRunHeaders(runId, events)));
|
|
191
|
-
}
|
|
192
|
-
async readStoredHeaders(runId) {
|
|
193
|
-
const events = await this.#readStoredWithoutPayloads(runId);
|
|
194
|
-
return events.length === 0 ? null : storedRunHeaders(runId, events);
|
|
195
|
-
}
|
|
196
|
-
async verifyGovernedPayloadPublication(intent) {
|
|
197
|
-
if (!intent.publicationScope)
|
|
198
|
-
return deepFreeze({ status: 'missing' });
|
|
199
|
-
return verifyJournalPayloadPublication(intent, await this.#readStoredWithoutPayloads(intent.publicationScope));
|
|
200
|
-
}
|
|
201
|
-
async read(runId) {
|
|
202
|
-
const digest = this.#digest(runId);
|
|
203
|
-
let names;
|
|
204
|
-
try {
|
|
205
|
-
const entries = await readdir(this.#directory);
|
|
206
|
-
names = entries
|
|
207
|
-
.filter(name => name.startsWith(`${digest}.`) && name.endsWith('.json'));
|
|
208
|
-
if (names.some(name => !isSegmentName(name))) {
|
|
209
|
-
throw new Error('Invalid Workroom journal segment name');
|
|
210
|
-
}
|
|
211
|
-
names.sort();
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
if (isMissingFile(error))
|
|
215
|
-
return [];
|
|
216
|
-
throw error;
|
|
217
|
-
}
|
|
218
|
-
const segments = await Promise.all(names.map(name => this.#readStoredFile(join(this.#directory, name), segmentFirstSequence(name))));
|
|
219
|
-
const events = segments.flat();
|
|
220
|
-
if (events.some(event => event.runId !== runId)) {
|
|
221
|
-
throw new Error('Workroom journal digest collision');
|
|
222
|
-
}
|
|
223
|
-
const ordered = events.sort((left, right) => left.sequence - right.sequence);
|
|
224
|
-
if (ordered.some((event, index) => event.sequence !== index)) {
|
|
225
|
-
throw new Error('Workroom journal sequence is not contiguous');
|
|
226
|
-
}
|
|
227
|
-
if (ordered.length > 0) {
|
|
228
|
-
await this.#store.syncLeaf();
|
|
229
|
-
await reconcileJournalPayloads(runId, ordered, this.#requirePayloads());
|
|
230
|
-
}
|
|
231
|
-
if (ordered.length === 0)
|
|
232
|
-
return Object.freeze([]);
|
|
233
|
-
return await materializeStoredEvents(Object.freeze(ordered), this.#requirePayloads());
|
|
234
|
-
}
|
|
235
|
-
async append(runId, expectedSequence, drafts) {
|
|
236
|
-
const current = await this.#readStored(runId);
|
|
237
|
-
const actualSequence = current.at(-1)?.sequence ?? -1;
|
|
238
|
-
if (actualSequence !== expectedSequence) {
|
|
239
|
-
throw new WorkroomSequenceConflictError(runId, expectedSequence, actualSequence);
|
|
240
|
-
}
|
|
241
|
-
if (drafts.length === 0)
|
|
242
|
-
return [];
|
|
243
|
-
const result = materializeEvents(runId, expectedSequence, drafts);
|
|
244
|
-
const projectId = projectIdForAppend(current, result);
|
|
245
|
-
await this.#store.ensureDurableLeaf('Workroom Journal');
|
|
246
|
-
await this.#assertNoLegacyEmbeddedPayload();
|
|
247
|
-
const protectedEvents = await protectEvents(result, projectId, this.#requirePayloads());
|
|
248
|
-
const segment = this.#segmentPath(runId, expectedSequence + 1);
|
|
249
|
-
const payload = Object.freeze({
|
|
250
|
-
version: 3,
|
|
251
|
-
runId,
|
|
252
|
-
expectedSequence,
|
|
253
|
-
events: protectedEvents,
|
|
254
|
-
});
|
|
255
|
-
const stored = Object.freeze({
|
|
256
|
-
...payload,
|
|
257
|
-
payloadDigest: digestCanonicalWorkroomValue(payload),
|
|
258
|
-
});
|
|
259
|
-
const receipts = collectGovernedPayloadReceipts(protectedEvents);
|
|
260
|
-
await this.#requirePayloads().prepare?.({ projectId, runId, receipts });
|
|
261
|
-
let headerPublished = false;
|
|
262
|
-
try {
|
|
263
|
-
const published = await this.#store.publishCreateOnly({
|
|
264
|
-
target: segment,
|
|
265
|
-
content: canonicalWorkroomJson(stored),
|
|
266
|
-
createdValue: result,
|
|
267
|
-
onConflict: async () => {
|
|
268
|
-
const winner = await this.#readStored(runId);
|
|
269
|
-
throw new WorkroomSequenceConflictError(runId, expectedSequence, winner.at(-1)?.sequence ?? -1);
|
|
270
|
-
},
|
|
271
|
-
});
|
|
272
|
-
headerPublished = true;
|
|
273
|
-
await this.#requirePayloads().publish?.({
|
|
274
|
-
projectId,
|
|
275
|
-
runId,
|
|
276
|
-
receipts,
|
|
277
|
-
publicationDigest: journalPublicationDigest(runId, [...current, ...protectedEvents]),
|
|
278
|
-
});
|
|
279
|
-
return published.value;
|
|
280
|
-
}
|
|
281
|
-
catch (error) {
|
|
282
|
-
if (!headerPublished) {
|
|
283
|
-
await this.#requirePayloads().abandon?.({ projectId, runId, receipts, reason: 'cas_lost' });
|
|
284
|
-
}
|
|
285
|
-
throw error;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
async #readStored(runId) {
|
|
289
|
-
const events = await this.#readStoredWithoutPayloads(runId);
|
|
290
|
-
if (events.length > 0)
|
|
291
|
-
await reconcileJournalPayloads(runId, events, this.#requirePayloads());
|
|
292
|
-
return events;
|
|
293
|
-
}
|
|
294
|
-
async #assertNoLegacyEmbeddedPayload() {
|
|
295
|
-
const names = await readdir(this.#directory);
|
|
296
|
-
const unexpected = names.find(name => !isSegmentName(name) && !isSegmentTemporaryName(name));
|
|
297
|
-
if (unexpected)
|
|
298
|
-
throw new Error('Invalid Workroom journal segment name');
|
|
299
|
-
const segments = names.filter(isSegmentName).sort();
|
|
300
|
-
if (segments.length === 0)
|
|
301
|
-
return;
|
|
302
|
-
await assertActiveStoreHasNoLegacyEmbeddedPayload(new FileLegacyEmbeddedPayloadReadAdapter(segments.map(name => ({ sourceKind: 'journal', path: join(this.#directory, name) }))));
|
|
303
|
-
}
|
|
304
|
-
async #readStoredWithoutPayloads(runId) {
|
|
305
|
-
const digest = this.#digest(runId);
|
|
306
|
-
let names;
|
|
307
|
-
try {
|
|
308
|
-
names = (await readdir(this.#directory))
|
|
309
|
-
.filter(name => name.startsWith(`${digest}.`) && name.endsWith('.json'))
|
|
310
|
-
.sort();
|
|
311
|
-
}
|
|
312
|
-
catch (error) {
|
|
313
|
-
if (isMissingFile(error))
|
|
314
|
-
return [];
|
|
315
|
-
throw error;
|
|
316
|
-
}
|
|
317
|
-
const events = (await Promise.all(names.map(name => this.#readStoredFile(join(this.#directory, name), segmentFirstSequence(name))))).flat().sort((left, right) => left.sequence - right.sequence);
|
|
318
|
-
if (events.some((event, index) => event.runId !== runId || event.sequence !== index)) {
|
|
319
|
-
throw new Error('Workroom journal sequence or Run binding is invalid');
|
|
320
|
-
}
|
|
321
|
-
if (events.length > 0)
|
|
322
|
-
await this.#store.syncLeaf();
|
|
323
|
-
return Object.freeze(events);
|
|
324
|
-
}
|
|
325
|
-
async #readStoredFile(path, expectedFirstSequence) {
|
|
326
|
-
try {
|
|
327
|
-
const parsed = JSON.parse(await readFile(path, 'utf8'));
|
|
328
|
-
if (Array.isArray(parsed)) {
|
|
329
|
-
throw legacyJournalPayloadError();
|
|
330
|
-
}
|
|
331
|
-
if (isRecord(parsed) && (parsed.version === 1 || parsed.version === 2)) {
|
|
332
|
-
throw legacyJournalPayloadError();
|
|
333
|
-
}
|
|
334
|
-
if (!isRecord(parsed) || parsed.version !== 3 || !isNonEmptyString(parsed.runId)
|
|
335
|
-
|| !Number.isSafeInteger(parsed.expectedSequence)
|
|
336
|
-
|| !Array.isArray(parsed.events) || typeof parsed.payloadDigest !== 'string') {
|
|
337
|
-
throw new Error('Invalid Workroom journal segment envelope');
|
|
338
|
-
}
|
|
339
|
-
if (parsed.expectedSequence !== expectedFirstSequence - 1) {
|
|
340
|
-
throw new Error('Workroom journal segment first sequence does not match its filename');
|
|
341
|
-
}
|
|
342
|
-
const events = parseStoredEvents(parsed.events);
|
|
343
|
-
const payload = Object.freeze({
|
|
344
|
-
version: 3,
|
|
345
|
-
runId: parsed.runId,
|
|
346
|
-
expectedSequence: parsed.expectedSequence,
|
|
347
|
-
events,
|
|
348
|
-
});
|
|
349
|
-
const stored = Object.freeze({
|
|
350
|
-
...payload,
|
|
351
|
-
payloadDigest: parsed.payloadDigest,
|
|
352
|
-
});
|
|
353
|
-
if (parsed.payloadDigest !== digestCanonicalWorkroomValue(payload)
|
|
354
|
-
|| canonicalWorkroomJson(parsed) !== canonicalWorkroomJson(stored)) {
|
|
355
|
-
throw new Error('Workroom journal segment payload digest mismatch');
|
|
356
|
-
}
|
|
357
|
-
if (events.some(event => event.runId !== parsed.runId)) {
|
|
358
|
-
throw new Error('Workroom journal segment Run binding drift');
|
|
359
|
-
}
|
|
360
|
-
if (basename(path) !== `${this.#digest(parsed.runId)}.${String(expectedFirstSequence).padStart(16, '0')}.json`) {
|
|
361
|
-
throw new Error('Workroom journal segment Run digest does not match its filename');
|
|
362
|
-
}
|
|
363
|
-
if (events.length === 0 || events[0].sequence !== expectedFirstSequence) {
|
|
364
|
-
throw new Error('Workroom journal segment first sequence does not match its filename');
|
|
365
|
-
}
|
|
366
|
-
if (events.some((event, index) => event.sequence !== expectedFirstSequence + index)) {
|
|
367
|
-
throw new Error('Workroom journal segment sequence is not contiguous');
|
|
368
|
-
}
|
|
369
|
-
return events;
|
|
370
|
-
}
|
|
371
|
-
catch (error) {
|
|
372
|
-
if (isMissingFile(error))
|
|
373
|
-
return [];
|
|
374
|
-
throw error;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
#digest(runId) {
|
|
378
|
-
return createHash('sha256').update(runId).digest('hex');
|
|
379
|
-
}
|
|
380
|
-
#segmentPath(runId, firstSequence) {
|
|
381
|
-
return join(this.#directory, `${this.#digest(runId)}.${String(firstSequence).padStart(16, '0')}.json`);
|
|
382
|
-
}
|
|
383
|
-
#requirePayloads() {
|
|
384
|
-
if (!this.#payloads)
|
|
385
|
-
throw new WorkroomJournalPayloadAuthorityUnavailableError();
|
|
386
|
-
return this.#payloads;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
/** Candidate-owned latch: no caller can observe a placeholder journal. */
|
|
390
|
-
export class ActivatableWorkroomJournal {
|
|
391
|
-
#delegate = null;
|
|
392
|
-
get active() {
|
|
393
|
-
return this.#delegate !== null;
|
|
394
|
-
}
|
|
395
|
-
activate(delegate) {
|
|
396
|
-
if (this.#delegate)
|
|
397
|
-
throw new Error('Workroom journal is already active');
|
|
398
|
-
this.#delegate = delegate;
|
|
399
|
-
}
|
|
400
|
-
listRunIds() {
|
|
401
|
-
return this.#require().listRunIds();
|
|
402
|
-
}
|
|
403
|
-
scanStoredHeaders() {
|
|
404
|
-
return this.#require().scanStoredHeaders();
|
|
405
|
-
}
|
|
406
|
-
readStoredHeaders(runId) {
|
|
407
|
-
return this.#require().readStoredHeaders(runId);
|
|
408
|
-
}
|
|
409
|
-
verifyGovernedPayloadPublication(intent) {
|
|
410
|
-
const delegate = this.#require();
|
|
411
|
-
return delegate.verifyGovernedPayloadPublication
|
|
412
|
-
? delegate.verifyGovernedPayloadPublication(intent)
|
|
413
|
-
: Promise.resolve(deepFreeze({ status: 'unknown' }));
|
|
414
|
-
}
|
|
415
|
-
read(runId) {
|
|
416
|
-
return this.#require().read(runId);
|
|
417
|
-
}
|
|
418
|
-
append(runId, expectedSequence, events) {
|
|
419
|
-
return this.#require().append(runId, expectedSequence, events);
|
|
420
|
-
}
|
|
421
|
-
#require() {
|
|
422
|
-
if (!this.#delegate)
|
|
423
|
-
throw new Error('Workroom journal is not active');
|
|
424
|
-
return this.#delegate;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
export class DatabaseWorkroomJournal {
|
|
428
|
-
#database;
|
|
429
|
-
#eventModel;
|
|
430
|
-
#payloads;
|
|
431
|
-
constructor(database, eventModel, payloads) {
|
|
432
|
-
this.#database = database;
|
|
433
|
-
this.#eventModel = eventModel;
|
|
434
|
-
this.#payloads = payloads;
|
|
435
|
-
}
|
|
436
|
-
async listRunIds() {
|
|
437
|
-
return Object.freeze((await this.scanStoredHeaders()).map(run => run.runId));
|
|
438
|
-
}
|
|
439
|
-
async scanStoredHeaders() {
|
|
440
|
-
const rows = await this.#eventModel.select().where({});
|
|
441
|
-
return Object.freeze([...parseStoredRowGroups(rows).entries()]
|
|
442
|
-
.map(([runId, events]) => storedRunHeaders(runId, events)));
|
|
443
|
-
}
|
|
444
|
-
async readStoredHeaders(runId) {
|
|
445
|
-
const rows = await this.#eventModel.select().where({ run_id: runId });
|
|
446
|
-
const events = parseStoredRows(runId, rows);
|
|
447
|
-
return events.length === 0 ? null : storedRunHeaders(runId, events);
|
|
448
|
-
}
|
|
449
|
-
async verifyGovernedPayloadPublication(intent) {
|
|
450
|
-
if (!intent.publicationScope)
|
|
451
|
-
return deepFreeze({ status: 'missing' });
|
|
452
|
-
const rows = await this.#eventModel.select().where({ run_id: intent.publicationScope });
|
|
453
|
-
return verifyJournalPayloadPublication(intent, parseStoredRows(intent.publicationScope, rows));
|
|
454
|
-
}
|
|
455
|
-
async read(runId) {
|
|
456
|
-
const rows = await this.#eventModel.select().where({ run_id: runId });
|
|
457
|
-
const events = parseStoredRows(runId, rows);
|
|
458
|
-
if (events.length === 0)
|
|
459
|
-
return Object.freeze([]);
|
|
460
|
-
await reconcileJournalPayloads(runId, events, this.#requirePayloads());
|
|
461
|
-
return await materializeStoredEvents(events, this.#requirePayloads());
|
|
462
|
-
}
|
|
463
|
-
async append(runId, expectedSequence, drafts) {
|
|
464
|
-
let publication;
|
|
465
|
-
let headerPublished = false;
|
|
466
|
-
try {
|
|
467
|
-
const allRows = await this.#eventModel.select().where({});
|
|
468
|
-
await assertActiveStoreHasNoLegacyEmbeddedPayload({
|
|
469
|
-
read: async () => legacyDatabaseJournalRecords(allRows),
|
|
470
|
-
});
|
|
471
|
-
const current = parseStoredRowGroups(allRows).get(runId) ?? Object.freeze([]);
|
|
472
|
-
if (current.length > 0) {
|
|
473
|
-
await reconcileJournalPayloads(runId, current, this.#requirePayloads());
|
|
474
|
-
}
|
|
475
|
-
const actualSequence = current.at(-1)?.sequence ?? -1;
|
|
476
|
-
if (actualSequence !== expectedSequence) {
|
|
477
|
-
throw new WorkroomSequenceConflictError(runId, expectedSequence, actualSequence);
|
|
478
|
-
}
|
|
479
|
-
if (drafts.length === 0)
|
|
480
|
-
return [];
|
|
481
|
-
const appended = materializeEvents(runId, expectedSequence, drafts);
|
|
482
|
-
const projectId = projectIdForAppend(current, appended);
|
|
483
|
-
const protectedEvents = await protectEvents(appended, projectId, this.#requirePayloads());
|
|
484
|
-
publication = { projectId, protectedEvents, current };
|
|
485
|
-
await this.#requirePayloads().prepare?.({
|
|
486
|
-
projectId,
|
|
487
|
-
runId,
|
|
488
|
-
receipts: collectGovernedPayloadReceipts(protectedEvents),
|
|
489
|
-
});
|
|
490
|
-
await this.#database.transaction(async (transaction) => {
|
|
491
|
-
const transactionRows = await transaction.select('workroom_events').where({});
|
|
492
|
-
await assertActiveStoreHasNoLegacyEmbeddedPayload({
|
|
493
|
-
read: async () => legacyDatabaseJournalRecords(transactionRows),
|
|
494
|
-
});
|
|
495
|
-
const transactionCurrent = parseStoredRowGroups(transactionRows).get(runId)
|
|
496
|
-
?? Object.freeze([]);
|
|
497
|
-
const transactionSequence = transactionCurrent.at(-1)?.sequence ?? -1;
|
|
498
|
-
if (transactionSequence !== expectedSequence) {
|
|
499
|
-
throw new WorkroomSequenceConflictError(runId, expectedSequence, transactionSequence);
|
|
500
|
-
}
|
|
501
|
-
await transaction.insertMany('workroom_events', protectedEvents.map(toRow));
|
|
502
|
-
}, { isolationLevel: 'SERIALIZABLE' });
|
|
503
|
-
headerPublished = true;
|
|
504
|
-
await this.#requirePayloads().publish?.({
|
|
505
|
-
projectId: publication.projectId,
|
|
506
|
-
runId,
|
|
507
|
-
receipts: collectGovernedPayloadReceipts(publication.protectedEvents),
|
|
508
|
-
publicationDigest: journalPublicationDigest(runId, [...publication.current, ...publication.protectedEvents]),
|
|
509
|
-
});
|
|
510
|
-
return appended;
|
|
511
|
-
}
|
|
512
|
-
catch (error) {
|
|
513
|
-
if (publication && !headerPublished) {
|
|
514
|
-
await this.#requirePayloads().abandon?.({
|
|
515
|
-
projectId: publication.projectId,
|
|
516
|
-
runId,
|
|
517
|
-
receipts: collectGovernedPayloadReceipts(publication.protectedEvents),
|
|
518
|
-
reason: error instanceof WorkroomSequenceConflictError ? 'cas_lost' : 'write_failed',
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
if (error instanceof WorkroomSequenceConflictError || headerPublished)
|
|
522
|
-
throw error;
|
|
523
|
-
// A serializable/unique-key loser is dialect-specific. Re-read the
|
|
524
|
-
// authoritative sequence and normalize only a proven concurrent winner;
|
|
525
|
-
// unrelated database failures retain their original error.
|
|
526
|
-
const actualSequence = (await this.read(runId)).at(-1)?.sequence ?? -1;
|
|
527
|
-
if (actualSequence !== expectedSequence) {
|
|
528
|
-
throw new WorkroomSequenceConflictError(runId, expectedSequence, actualSequence);
|
|
529
|
-
}
|
|
530
|
-
throw error;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
#requirePayloads() {
|
|
534
|
-
if (!this.#payloads)
|
|
535
|
-
throw new WorkroomJournalPayloadAuthorityUnavailableError();
|
|
536
|
-
return this.#payloads;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
function legacyDatabaseJournalRecords(rows) {
|
|
540
|
-
return Object.freeze(rows.map(row => {
|
|
541
|
-
let envelope;
|
|
542
|
-
try {
|
|
543
|
-
envelope = JSON.parse(String(row.payload_json));
|
|
544
|
-
}
|
|
545
|
-
catch {
|
|
546
|
-
throw new Error('Legacy Workroom Journal database payload is corrupt or unknown');
|
|
547
|
-
}
|
|
548
|
-
return Object.freeze({
|
|
549
|
-
storage: 'database',
|
|
550
|
-
sourceKind: 'journal',
|
|
551
|
-
recordRef: `workroom-events:${digestCanonicalWorkroomValue({
|
|
552
|
-
runId: String(row.run_id),
|
|
553
|
-
sequence: row.sequence,
|
|
554
|
-
})}`,
|
|
555
|
-
value: Object.freeze({ version: row.version, envelope }),
|
|
556
|
-
});
|
|
557
|
-
}));
|
|
558
|
-
}
|
|
559
|
-
function materializeEvents(runId, expectedSequence, drafts) {
|
|
560
|
-
if (!isNonEmptyString(runId) || !Number.isSafeInteger(expectedSequence) || expectedSequence < -1) {
|
|
561
|
-
throw new Error('Invalid Workroom append position');
|
|
562
|
-
}
|
|
563
|
-
return Object.freeze(drafts.map((draft, index) => {
|
|
564
|
-
if (!isNonEmptyString(draft.eventId) || !isFiniteNumber(draft.occurredAt)
|
|
565
|
-
|| !isWorkroomEventType(draft.type) || !isRecord(draft.payload)) {
|
|
566
|
-
throw new Error('Invalid Workroom event draft');
|
|
567
|
-
}
|
|
568
|
-
validatePayload(draft.type, draft.payload, expectedSequence + index + 1);
|
|
569
|
-
return Object.freeze({
|
|
570
|
-
...draft,
|
|
571
|
-
version: 1,
|
|
572
|
-
runId,
|
|
573
|
-
sequence: expectedSequence + index + 1,
|
|
574
|
-
payload: Object.freeze({ ...draft.payload }),
|
|
575
|
-
});
|
|
576
|
-
}));
|
|
577
|
-
}
|
|
578
|
-
function parseStoredEvents(values) {
|
|
579
|
-
const events = values.map((value) => {
|
|
580
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
581
|
-
throw new Error('Invalid Workroom journal event');
|
|
582
|
-
}
|
|
583
|
-
const raw = value;
|
|
584
|
-
if (raw.version === 1 || raw.version === 2)
|
|
585
|
-
throw legacyJournalPayloadError();
|
|
586
|
-
assertExactRecordKeys(raw, [
|
|
587
|
-
'version', 'eventId', 'runId', 'sequence', 'occurredAt', 'type', 'control', 'payload',
|
|
588
|
-
], 'Stored Workroom event');
|
|
589
|
-
const event = value;
|
|
590
|
-
if (event.version !== 3 || !isNonEmptyString(event.eventId) || !isNonEmptyString(event.runId)
|
|
591
|
-
|| !isSequence(event.sequence) || !isFiniteNumber(event.occurredAt)
|
|
592
|
-
|| !isWorkroomEventType(event.type) || !isRecord(event.control) || !isRecord(event.payload)) {
|
|
593
|
-
throw new Error('Invalid Workroom journal event');
|
|
594
|
-
}
|
|
595
|
-
validateStoredEventControl(event.type, event.control);
|
|
596
|
-
validateProtectedPayload(event.type, event.payload);
|
|
597
|
-
const sequence = Number(event.sequence);
|
|
598
|
-
return Object.freeze({
|
|
599
|
-
...event,
|
|
600
|
-
version: 3,
|
|
601
|
-
eventId: event.eventId,
|
|
602
|
-
runId: event.runId,
|
|
603
|
-
sequence,
|
|
604
|
-
occurredAt: event.occurredAt,
|
|
605
|
-
type: event.type,
|
|
606
|
-
control: deepFreeze({ ...event.control }),
|
|
607
|
-
payload: Object.freeze({ ...event.payload }),
|
|
608
|
-
});
|
|
609
|
-
});
|
|
610
|
-
return Object.freeze(events.sort((left, right) => left.sequence - right.sequence));
|
|
611
|
-
}
|
|
612
|
-
function isMissingFile(error) {
|
|
613
|
-
return !!error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT';
|
|
614
|
-
}
|
|
615
|
-
function isSegmentName(name) {
|
|
616
|
-
return /^[a-f0-9]{64}\.[0-9]{16}\.json$/u.test(name);
|
|
617
|
-
}
|
|
618
|
-
function isSegmentTemporaryName(name) {
|
|
619
|
-
return /^[a-f0-9]{64}\.[0-9]{16}\.json\.[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}\.tmp$/u
|
|
620
|
-
.test(name);
|
|
621
|
-
}
|
|
622
|
-
function segmentFirstSequence(name) {
|
|
623
|
-
if (!isSegmentName(name))
|
|
624
|
-
throw new Error('Invalid Workroom journal segment name');
|
|
625
|
-
const value = Number(name.slice(65, 81));
|
|
626
|
-
if (!Number.isSafeInteger(value) || value < 0) {
|
|
627
|
-
throw new Error('Invalid Workroom journal segment first sequence');
|
|
628
|
-
}
|
|
629
|
-
return value;
|
|
630
|
-
}
|
|
631
|
-
function toRow(event) {
|
|
632
|
-
const storedEventDigest = digestStoredWorkroomEvent(event);
|
|
633
|
-
const row = {
|
|
634
|
-
id: `${event.runId}:${event.sequence}`,
|
|
635
|
-
run_id: event.runId,
|
|
636
|
-
sequence: event.sequence,
|
|
637
|
-
version: event.version,
|
|
638
|
-
type: event.type,
|
|
639
|
-
payload_json: canonicalWorkroomJson({
|
|
640
|
-
eventId: event.eventId,
|
|
641
|
-
control: event.control,
|
|
642
|
-
payload: event.payload,
|
|
643
|
-
}),
|
|
644
|
-
occurred_at: event.occurredAt,
|
|
645
|
-
stored_event_digest: storedEventDigest,
|
|
646
|
-
};
|
|
647
|
-
return { ...row, row_binding_digest: digestWorkroomEventRowBinding(row) };
|
|
648
|
-
}
|
|
649
|
-
function parseStoredRows(runId, rows) {
|
|
650
|
-
const events = rows.map(row => {
|
|
651
|
-
if (row.version === 1 || row.version === 2)
|
|
652
|
-
throw legacyJournalPayloadError();
|
|
653
|
-
if (!isDigest(row.stored_event_digest) || !isDigest(row.row_binding_digest)) {
|
|
654
|
-
throw legacyJournalPayloadError();
|
|
655
|
-
}
|
|
656
|
-
if (row.version !== 3)
|
|
657
|
-
throw new Error(`Unsupported Workroom event version: ${String(row.version)}`);
|
|
658
|
-
let envelope;
|
|
659
|
-
try {
|
|
660
|
-
envelope = JSON.parse(String(row.payload_json));
|
|
661
|
-
}
|
|
662
|
-
catch {
|
|
663
|
-
throw new Error('Invalid Workroom event payload JSON');
|
|
664
|
-
}
|
|
665
|
-
if (!envelope || !isNonEmptyString(envelope.eventId) || !isRecord(envelope.control)
|
|
666
|
-
|| !isRecord(envelope.payload)
|
|
667
|
-
|| !isSequence(row.sequence) || !isFiniteNumber(row.occurred_at)
|
|
668
|
-
|| !isWorkroomEventType(row.type)) {
|
|
669
|
-
throw new Error('Invalid Workroom event payload envelope');
|
|
670
|
-
}
|
|
671
|
-
assertExactRecordKeys(envelope, ['eventId', 'control', 'payload'], 'Workroom event payload envelope');
|
|
672
|
-
const expectedId = `${runId}:${Number(row.sequence)}`;
|
|
673
|
-
if (row.id !== expectedId)
|
|
674
|
-
throw new Error('Workroom event row id binding is invalid');
|
|
675
|
-
if (String(row.payload_json) !== canonicalWorkroomJson(envelope)) {
|
|
676
|
-
throw new Error('Workroom event payload JSON is not canonical');
|
|
677
|
-
}
|
|
678
|
-
validateStoredEventControl(row.type, envelope.control);
|
|
679
|
-
validateProtectedPayload(row.type, envelope.payload);
|
|
680
|
-
const event = Object.freeze({
|
|
681
|
-
version: 3,
|
|
682
|
-
eventId: envelope.eventId,
|
|
683
|
-
runId,
|
|
684
|
-
sequence: row.sequence,
|
|
685
|
-
occurredAt: row.occurred_at,
|
|
686
|
-
type: row.type,
|
|
687
|
-
control: deepFreeze({ ...envelope.control }),
|
|
688
|
-
payload: Object.freeze({ ...envelope.payload }),
|
|
689
|
-
});
|
|
690
|
-
if (row.stored_event_digest !== digestStoredWorkroomEvent(event)) {
|
|
691
|
-
throw new Error('Workroom stored event digest mismatch');
|
|
692
|
-
}
|
|
693
|
-
if (row.row_binding_digest !== digestWorkroomEventRowBinding(row)) {
|
|
694
|
-
throw new Error('Workroom event row binding digest mismatch');
|
|
695
|
-
}
|
|
696
|
-
return event;
|
|
697
|
-
}).sort((left, right) => left.sequence - right.sequence);
|
|
698
|
-
const stored = Object.freeze(events);
|
|
699
|
-
if (stored.length > 0)
|
|
700
|
-
assertStoredEventReceiptBindings(stored);
|
|
701
|
-
return stored;
|
|
702
|
-
}
|
|
703
|
-
function parseStoredRowGroups(rows) {
|
|
704
|
-
const rowGroups = new Map();
|
|
705
|
-
for (const row of rows) {
|
|
706
|
-
const runId = String(row.run_id ?? '');
|
|
707
|
-
if (!isNonEmptyString(runId))
|
|
708
|
-
throw new Error('Invalid Workroom event Run id');
|
|
709
|
-
rowGroups.set(runId, [...(rowGroups.get(runId) ?? []), row]);
|
|
710
|
-
}
|
|
711
|
-
return new Map([...rowGroups.entries()]
|
|
712
|
-
.sort(([left], [right]) => compareCanonicalWorkroomText(left, right))
|
|
713
|
-
.map(([runId, runRows]) => [runId, parseStoredRows(runId, runRows)]));
|
|
714
|
-
}
|
|
715
|
-
export function digestStoredWorkroomEvent(event) {
|
|
716
|
-
return digestCanonicalWorkroomValue({
|
|
717
|
-
version: event.version,
|
|
718
|
-
eventId: event.eventId,
|
|
719
|
-
runId: event.runId,
|
|
720
|
-
sequence: event.sequence,
|
|
721
|
-
occurredAt: event.occurredAt,
|
|
722
|
-
type: event.type,
|
|
723
|
-
control: event.control,
|
|
724
|
-
payload: event.payload,
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
export function digestWorkroomEventRowBinding(row) {
|
|
728
|
-
return digestCanonicalWorkroomValue({
|
|
729
|
-
version: 1,
|
|
730
|
-
id: row.id,
|
|
731
|
-
runId: row.run_id,
|
|
732
|
-
sequence: row.sequence,
|
|
733
|
-
storedVersion: row.version,
|
|
734
|
-
type: row.type,
|
|
735
|
-
payloadJson: row.payload_json,
|
|
736
|
-
occurredAt: row.occurred_at,
|
|
737
|
-
storedEventDigest: row.stored_event_digest,
|
|
738
|
-
});
|
|
739
|
-
}
|
|
740
|
-
function storedRunHeaders(runId, values) {
|
|
741
|
-
if (!isNonEmptyString(runId) || values.length === 0
|
|
742
|
-
|| values.some((event, index) => event.runId !== runId || event.sequence !== index)) {
|
|
743
|
-
throw new Error('Stored Workroom Journal header sequence or Run binding is invalid');
|
|
744
|
-
}
|
|
745
|
-
assertStoredEventReceiptBindings(values);
|
|
746
|
-
const events = values.map((event) => {
|
|
747
|
-
const protectedPayloadDigest = digestCanonicalWorkroomValue(event.payload);
|
|
748
|
-
const body = deepFreeze({
|
|
749
|
-
version: 1,
|
|
750
|
-
eventRef: `workroom-event:${digestCanonicalWorkroomValue({
|
|
751
|
-
runId, eventId: event.eventId, sequence: event.sequence,
|
|
752
|
-
})}`,
|
|
753
|
-
runId,
|
|
754
|
-
sequence: event.sequence,
|
|
755
|
-
occurredAt: event.occurredAt,
|
|
756
|
-
type: event.type,
|
|
757
|
-
control: event.control,
|
|
758
|
-
protectedPayloadDigest,
|
|
759
|
-
protectedReceipts: storedProtectedReceiptHeaders(event.payload),
|
|
760
|
-
});
|
|
761
|
-
return deepFreeze({ ...body, digest: digestCanonicalWorkroomValue(body) });
|
|
762
|
-
});
|
|
763
|
-
const body = deepFreeze({ version: 1, runId, events });
|
|
764
|
-
return deepFreeze({ ...body, digest: digestCanonicalWorkroomValue(body) });
|
|
765
|
-
}
|
|
766
|
-
function deriveStoredEventControl(event) {
|
|
767
|
-
const payload = event.payload;
|
|
768
|
-
const taskKey = () => opaqueStoredRef('task', event.runId, storedHeaderText(payload, 'taskKey'));
|
|
769
|
-
const assignmentId = () => opaqueStoredRef('assignment', event.runId, storedHeaderText(payload, 'assignmentId'));
|
|
770
|
-
switch (event.type) {
|
|
771
|
-
case 'run.created': return deepFreeze({ projectId: storedHeaderText(payload, 'projectId') });
|
|
772
|
-
case 'task.planned': return deepFreeze({
|
|
773
|
-
taskKey: taskKey(),
|
|
774
|
-
required: payload.required === true,
|
|
775
|
-
maxAttempts: storedHeaderPositiveInteger(payload, 'maxAttempts'),
|
|
776
|
-
});
|
|
777
|
-
case 'task.blocked': return deepFreeze({
|
|
778
|
-
taskKey: taskKey(),
|
|
779
|
-
blockerId: opaqueStoredRef('blocker', event.runId, storedHeaderText(payload, 'blockerId')),
|
|
780
|
-
blockerKind: storedHeaderBlockerKind(payload.kind),
|
|
781
|
-
blockerDeadline: storedHeaderNonNegativeInteger(payload, 'deadline'),
|
|
782
|
-
blockerAllowedActions: Object.freeze(['resolve', 'replan', 'cancel']),
|
|
783
|
-
});
|
|
784
|
-
case 'task.blocker_resolved': return deepFreeze({
|
|
785
|
-
taskKey: taskKey(),
|
|
786
|
-
blockerId: opaqueStoredRef('blocker', event.runId, storedHeaderText(payload, 'blockerId')),
|
|
787
|
-
});
|
|
788
|
-
case 'assignment.claimed': return deepFreeze({
|
|
789
|
-
taskKey: taskKey(),
|
|
790
|
-
assignmentId: assignmentId(),
|
|
791
|
-
role: storedHeaderRole(payload.role),
|
|
792
|
-
attempt: storedHeaderPositiveInteger(payload, 'attempt'),
|
|
793
|
-
assignmentRevision: storedHeaderPositiveInteger(payload, 'assignmentRevision'),
|
|
794
|
-
fence: storedHeaderPositiveInteger(payload, 'fence'),
|
|
795
|
-
});
|
|
796
|
-
case 'assignment.started':
|
|
797
|
-
case 'assignment.progress':
|
|
798
|
-
case 'assignment.heartbeat':
|
|
799
|
-
case 'assignment.checkpointed':
|
|
800
|
-
case 'assignment.checkpoint_requested':
|
|
801
|
-
case 'assignment.preempted':
|
|
802
|
-
case 'assignment.execution_completed':
|
|
803
|
-
case 'assignment.cancel_requested':
|
|
804
|
-
case 'assignment.lease_expired': return deepFreeze({ assignmentId: assignmentId() });
|
|
805
|
-
case 'assignment.cancelled': return deepFreeze({
|
|
806
|
-
assignmentId: assignmentId(), outcome: storedHeaderOutcome(payload.outcome),
|
|
807
|
-
});
|
|
808
|
-
case 'task.accepted':
|
|
809
|
-
case 'task.acceptance_pinned':
|
|
810
|
-
case 'task.acceptance_blocked':
|
|
811
|
-
case 'task.cancel_requested':
|
|
812
|
-
case 'task.cancelled':
|
|
813
|
-
case 'task.failed':
|
|
814
|
-
case 'task.rework_requested': return deepFreeze({ taskKey: taskKey() });
|
|
815
|
-
case 'task.revised': return deepFreeze({
|
|
816
|
-
taskKey: taskKey(), maxAttempts: storedHeaderPositiveInteger(payload, 'maxAttempts'),
|
|
817
|
-
});
|
|
818
|
-
case 'task.plan_revised': return deepFreeze({
|
|
819
|
-
taskKey: taskKey(), required: payload.required === true,
|
|
820
|
-
maxAttempts: storedHeaderPositiveInteger(payload, 'maxAttempts'),
|
|
821
|
-
newTaskRevision: storedHeaderPositiveInteger(payload, 'newTaskRevision'),
|
|
822
|
-
});
|
|
823
|
-
case 'reviewer.assigned': {
|
|
824
|
-
const assignment = storedHeaderRecord(payload, 'assignment');
|
|
825
|
-
return deepFreeze({
|
|
826
|
-
taskKey: taskKey(),
|
|
827
|
-
waitId: opaqueStoredRef('reviewer', event.runId, storedHeaderText(assignment, 'id')),
|
|
828
|
-
waitStatus: storedHeaderText(assignment, 'status'),
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
case 'reviewer.claimed':
|
|
832
|
-
case 'reviewer.verdict_recorded':
|
|
833
|
-
case 'reviewer.expired': return deepFreeze({
|
|
834
|
-
taskKey: taskKey(),
|
|
835
|
-
waitId: opaqueStoredRef('reviewer', event.runId, storedHeaderText(payload, 'assignmentId')),
|
|
836
|
-
...(event.type === 'reviewer.verdict_recorded'
|
|
837
|
-
? { verdictOutcome: payload.outcome === 'passed' ? 'passed' : 'rework' }
|
|
838
|
-
: {}),
|
|
839
|
-
});
|
|
840
|
-
case 'sponsor_gate.opened': {
|
|
841
|
-
const gate = storedHeaderRecord(payload, 'gate');
|
|
842
|
-
return deepFreeze({
|
|
843
|
-
taskKey: taskKey(),
|
|
844
|
-
waitId: opaqueStoredRef('sponsor-gate', event.runId, storedHeaderText(gate, 'id')),
|
|
845
|
-
waitStatus: storedHeaderText(gate, 'status'),
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
case 'sponsor_gate.decided': return deepFreeze({
|
|
849
|
-
taskKey: taskKey(),
|
|
850
|
-
waitId: opaqueStoredRef('sponsor-gate', event.runId, storedHeaderText(payload, 'gateId')),
|
|
851
|
-
decision: storedHeaderDecision(payload.decision),
|
|
852
|
-
});
|
|
853
|
-
case 'sponsor_gate.expired': return deepFreeze({
|
|
854
|
-
taskKey: taskKey(),
|
|
855
|
-
waitId: opaqueStoredRef('sponsor-gate', event.runId, storedHeaderText(payload, 'gateId')),
|
|
856
|
-
});
|
|
857
|
-
default: return Object.freeze({});
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
const WORKROOM_EVENT_CONTROL_KEYS = Object.freeze({
|
|
861
|
-
'run.created': ['projectId'],
|
|
862
|
-
'task.planned': ['taskKey', 'required', 'maxAttempts'],
|
|
863
|
-
'task.blocked': [
|
|
864
|
-
'taskKey', 'blockerId', 'blockerKind', 'blockerDeadline', 'blockerAllowedActions',
|
|
865
|
-
],
|
|
866
|
-
'task.blocker_resolved': ['taskKey', 'blockerId'],
|
|
867
|
-
'assignment.claimed': [
|
|
868
|
-
'taskKey', 'assignmentId', 'role', 'attempt', 'assignmentRevision', 'fence',
|
|
869
|
-
],
|
|
870
|
-
'assignment.started': ['assignmentId'],
|
|
871
|
-
'assignment.progress': ['assignmentId'],
|
|
872
|
-
'assignment.heartbeat': ['assignmentId'],
|
|
873
|
-
'assignment.checkpointed': ['assignmentId'],
|
|
874
|
-
'assignment.checkpoint_requested': ['assignmentId'],
|
|
875
|
-
'assignment.preempted': ['assignmentId'],
|
|
876
|
-
'assignment.execution_completed': ['assignmentId'],
|
|
877
|
-
'assignment.cancel_requested': ['assignmentId'],
|
|
878
|
-
'assignment.cancelled': ['assignmentId', 'outcome'],
|
|
879
|
-
'assignment.lease_expired': ['assignmentId'],
|
|
880
|
-
'task.accepted': ['taskKey'],
|
|
881
|
-
'task.acceptance_pinned': ['taskKey'],
|
|
882
|
-
'task.acceptance_blocked': ['taskKey'],
|
|
883
|
-
'task.cancel_requested': ['taskKey'],
|
|
884
|
-
'task.cancelled': ['taskKey'],
|
|
885
|
-
'task.failed': ['taskKey'],
|
|
886
|
-
'task.rework_requested': ['taskKey'],
|
|
887
|
-
'task.revised': ['taskKey', 'maxAttempts'],
|
|
888
|
-
'task.plan_revised': ['taskKey', 'required', 'maxAttempts', 'newTaskRevision'],
|
|
889
|
-
'reviewer.assigned': ['taskKey', 'waitId', 'waitStatus'],
|
|
890
|
-
'reviewer.claimed': ['taskKey', 'waitId'],
|
|
891
|
-
'reviewer.verdict_recorded': ['taskKey', 'waitId', 'verdictOutcome'],
|
|
892
|
-
'reviewer.expired': ['taskKey', 'waitId'],
|
|
893
|
-
'sponsor_gate.opened': ['taskKey', 'waitId', 'waitStatus'],
|
|
894
|
-
'sponsor_gate.decided': ['taskKey', 'waitId', 'decision'],
|
|
895
|
-
'sponsor_gate.expired': ['taskKey', 'waitId'],
|
|
896
|
-
'plan.admitted': [],
|
|
897
|
-
'plan.revision_applied': [],
|
|
898
|
-
'plan_gate.decided': [],
|
|
899
|
-
'run.control_decided': [],
|
|
900
|
-
'run.replan_requested': [],
|
|
901
|
-
'run.cancel_requested': [],
|
|
902
|
-
'run.cancelled': [],
|
|
903
|
-
'scheduler.dispatch_requested': [],
|
|
904
|
-
'scheduler.priority_changed': [],
|
|
905
|
-
'scheduler.preemption_requested': [],
|
|
906
|
-
'scheduler.preemption_checkpoint_acknowledged': [],
|
|
907
|
-
'scheduler.preemption_timed_out': [],
|
|
908
|
-
'local_execution.requested': [],
|
|
909
|
-
'remote_dispatch.requested': [],
|
|
910
|
-
'clock.advanced': [],
|
|
911
|
-
});
|
|
912
|
-
function validateStoredEventControl(type, control) {
|
|
913
|
-
const keys = type === 'task.blocked' && Object.keys(control).length === 2
|
|
914
|
-
? ['taskKey', 'blockerId']
|
|
915
|
-
: WORKROOM_EVENT_CONTROL_KEYS[type];
|
|
916
|
-
assertExactRecordKeys(control, keys, 'Stored Workroom control');
|
|
917
|
-
if (control.projectId !== undefined)
|
|
918
|
-
storedHeaderText(control, 'projectId');
|
|
919
|
-
for (const key of ['taskKey', 'assignmentId', 'blockerId', 'waitId']) {
|
|
920
|
-
if (control[key] !== undefined && (typeof control[key] !== 'string'
|
|
921
|
-
|| !/^workroom-[a-z-]+:[a-f0-9]{64}$/u.test(control[key]))) {
|
|
922
|
-
throw new Error(`Stored Workroom control ${key} is invalid`);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
for (const key of ['maxAttempts', 'attempt', 'assignmentRevision', 'fence', 'newTaskRevision']) {
|
|
926
|
-
if (control[key] !== undefined)
|
|
927
|
-
storedHeaderPositiveInteger(control, key);
|
|
928
|
-
}
|
|
929
|
-
if (control.required !== undefined && typeof control.required !== 'boolean') {
|
|
930
|
-
throw new Error('Stored Workroom control required is invalid');
|
|
931
|
-
}
|
|
932
|
-
if (control.blockerKind !== undefined)
|
|
933
|
-
storedHeaderBlockerKind(control.blockerKind);
|
|
934
|
-
if (control.blockerDeadline !== undefined) {
|
|
935
|
-
storedHeaderNonNegativeInteger(control, 'blockerDeadline');
|
|
936
|
-
}
|
|
937
|
-
if (control.blockerAllowedActions !== undefined) {
|
|
938
|
-
storedHeaderBlockerActions(control.blockerAllowedActions);
|
|
939
|
-
}
|
|
940
|
-
if (control.role !== undefined)
|
|
941
|
-
storedHeaderRole(control.role);
|
|
942
|
-
if (control.outcome !== undefined)
|
|
943
|
-
storedHeaderOutcome(control.outcome);
|
|
944
|
-
if (control.decision !== undefined)
|
|
945
|
-
storedHeaderDecision(control.decision);
|
|
946
|
-
if (control.verdictOutcome !== undefined
|
|
947
|
-
&& control.verdictOutcome !== 'passed' && control.verdictOutcome !== 'rework') {
|
|
948
|
-
throw new Error('Stored Workroom control verdict outcome is invalid');
|
|
949
|
-
}
|
|
950
|
-
if (control.waitStatus !== undefined && ![
|
|
951
|
-
'open', 'claimed', 'passed', 'rework', 'expired', 'cancelled', 'satisfied', 'stale',
|
|
952
|
-
].includes(String(control.waitStatus))) {
|
|
953
|
-
throw new Error('Stored Workroom control wait status is invalid');
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
function storedProtectedReceiptHeaders(value) {
|
|
957
|
-
const headers = [];
|
|
958
|
-
const visit = (candidate) => {
|
|
959
|
-
if (isGovernedJournalPayloadReference(candidate)) {
|
|
960
|
-
headers.push(deepFreeze({
|
|
961
|
-
fieldPath: candidate.fieldPath,
|
|
962
|
-
contentHash: candidate.contentHash,
|
|
963
|
-
descriptorDigest: candidate.receipt.descriptor.descriptorDigest,
|
|
964
|
-
sourceDigest: candidate.receipt.source.digest,
|
|
965
|
-
sourceBindingDigest: candidate.receipt.source.bindingDigest,
|
|
966
|
-
}));
|
|
967
|
-
return;
|
|
968
|
-
}
|
|
969
|
-
if (Array.isArray(candidate)) {
|
|
970
|
-
for (const item of candidate)
|
|
971
|
-
visit(item);
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
if (isRecord(candidate))
|
|
975
|
-
for (const item of Object.values(candidate))
|
|
976
|
-
visit(item);
|
|
977
|
-
};
|
|
978
|
-
visit(value);
|
|
979
|
-
return deepFreeze(headers.sort((left, right) => compareCanonicalWorkroomText(left.fieldPath, right.fieldPath)));
|
|
980
|
-
}
|
|
981
|
-
function opaqueStoredRef(kind, runId, rawId) {
|
|
982
|
-
return `workroom-${kind}:${digestCanonicalWorkroomValue({ kind, runId, rawId }).slice('sha256:'.length)}`;
|
|
983
|
-
}
|
|
984
|
-
function storedHeaderText(payload, key) {
|
|
985
|
-
const value = payload[key];
|
|
986
|
-
if (!isNonEmptyString(value))
|
|
987
|
-
throw new Error(`Stored Workroom header ${key} is invalid`);
|
|
988
|
-
return value;
|
|
989
|
-
}
|
|
990
|
-
function storedHeaderPositiveInteger(payload, key) {
|
|
991
|
-
const value = payload[key];
|
|
992
|
-
if (!Number.isSafeInteger(value) || Number(value) < 1) {
|
|
993
|
-
throw new Error(`Stored Workroom header ${key} is invalid`);
|
|
994
|
-
}
|
|
995
|
-
return Number(value);
|
|
996
|
-
}
|
|
997
|
-
function storedHeaderNonNegativeInteger(payload, key) {
|
|
998
|
-
const value = payload[key];
|
|
999
|
-
if (!Number.isSafeInteger(value) || Number(value) < 0) {
|
|
1000
|
-
throw new Error(`Stored Workroom header ${key} is invalid`);
|
|
1001
|
-
}
|
|
1002
|
-
return Number(value);
|
|
1003
|
-
}
|
|
1004
|
-
function storedHeaderBlockerKind(value) {
|
|
1005
|
-
if (value !== 'dependency' && value !== 'approval' && value !== 'capability'
|
|
1006
|
-
&& value !== 'external' && value !== 'human_input') {
|
|
1007
|
-
throw new Error('Stored Workroom header Blocker kind is invalid');
|
|
1008
|
-
}
|
|
1009
|
-
return value;
|
|
1010
|
-
}
|
|
1011
|
-
function storedHeaderBlockerActions(value) {
|
|
1012
|
-
if (!Array.isArray(value)
|
|
1013
|
-
|| canonicalWorkroomJson(value) !== canonicalWorkroomJson(['resolve', 'replan', 'cancel'])) {
|
|
1014
|
-
throw new Error('Stored Workroom header Blocker allowedActions are invalid');
|
|
1015
|
-
}
|
|
1016
|
-
return Object.freeze([...value]);
|
|
1017
|
-
}
|
|
1018
|
-
function storedHeaderRecord(payload, key) {
|
|
1019
|
-
const value = payload[key];
|
|
1020
|
-
if (!isRecord(value))
|
|
1021
|
-
throw new Error(`Stored Workroom header ${key} is invalid`);
|
|
1022
|
-
return value;
|
|
1023
|
-
}
|
|
1024
|
-
function storedHeaderRole(value) {
|
|
1025
|
-
if (value !== 'executor' && value !== 'reviewer' && value !== 'integration') {
|
|
1026
|
-
throw new Error('Stored Workroom header Assignment role is invalid');
|
|
1027
|
-
}
|
|
1028
|
-
return value;
|
|
1029
|
-
}
|
|
1030
|
-
function storedHeaderOutcome(value) {
|
|
1031
|
-
if (value !== 'interrupted' && value !== 'committed' && value !== 'outcome_unknown') {
|
|
1032
|
-
throw new Error('Stored Workroom header Assignment outcome is invalid');
|
|
1033
|
-
}
|
|
1034
|
-
return value;
|
|
1035
|
-
}
|
|
1036
|
-
function storedHeaderDecision(value) {
|
|
1037
|
-
if (value !== 'approve' && value !== 'reject' && value !== 'request_changes' && value !== 'cancel') {
|
|
1038
|
-
throw new Error('Stored Workroom header Sponsor decision is invalid');
|
|
1039
|
-
}
|
|
1040
|
-
return value;
|
|
1041
|
-
}
|
|
1042
|
-
async function protectEvents(events, projectId, payloads) {
|
|
1043
|
-
return Object.freeze(await Promise.all(events.map(async (event) => Object.freeze({
|
|
1044
|
-
...event,
|
|
1045
|
-
version: 3,
|
|
1046
|
-
control: deriveStoredEventControl(event),
|
|
1047
|
-
payload: await protectValue(event.payload, '$.payload', event, projectId, payloads),
|
|
1048
|
-
}))));
|
|
1049
|
-
}
|
|
1050
|
-
async function protectValue(value, fieldPath, event, projectId, payloads) {
|
|
1051
|
-
if (Array.isArray(value)) {
|
|
1052
|
-
return Object.freeze(await Promise.all(value.map((item, index) => protectValue(item, `${fieldPath}[${index}]`, event, projectId, payloads))));
|
|
1053
|
-
}
|
|
1054
|
-
if (!isRecord(value))
|
|
1055
|
-
return value;
|
|
1056
|
-
const entries = [];
|
|
1057
|
-
for (const [key, child] of Object.entries(value)) {
|
|
1058
|
-
const path = `${fieldPath}.${key}`;
|
|
1059
|
-
if (!isContentFreeJournalValue(event.type, path, child) && containsGovernedValue(child)) {
|
|
1060
|
-
const contentHash = digestCanonicalWorkroomValue(child);
|
|
1061
|
-
const source = journalPayloadSource(event, path, contentHash);
|
|
1062
|
-
const receipt = await payloads.write({
|
|
1063
|
-
projectId,
|
|
1064
|
-
runId: event.runId,
|
|
1065
|
-
eventId: event.eventId,
|
|
1066
|
-
eventType: event.type,
|
|
1067
|
-
occurredAt: event.occurredAt,
|
|
1068
|
-
fieldPath: path,
|
|
1069
|
-
value: structuredClone(child),
|
|
1070
|
-
contentHash,
|
|
1071
|
-
source,
|
|
1072
|
-
});
|
|
1073
|
-
assertJournalPayloadReceipt(receipt, createWorkroomJournalPayloadObjectId({
|
|
1074
|
-
projectId,
|
|
1075
|
-
runId: event.runId,
|
|
1076
|
-
eventId: event.eventId,
|
|
1077
|
-
eventType: event.type,
|
|
1078
|
-
occurredAt: event.occurredAt,
|
|
1079
|
-
fieldPath: path,
|
|
1080
|
-
contentHash,
|
|
1081
|
-
}), contentHash, source);
|
|
1082
|
-
entries.push([key, Object.freeze({
|
|
1083
|
-
version: 1,
|
|
1084
|
-
kind: 'governed_workroom_journal_payload',
|
|
1085
|
-
fieldPath: path,
|
|
1086
|
-
contentHash,
|
|
1087
|
-
receipt,
|
|
1088
|
-
})]);
|
|
1089
|
-
continue;
|
|
1090
|
-
}
|
|
1091
|
-
entries.push([key, await protectValue(child, path, event, projectId, payloads)]);
|
|
1092
|
-
}
|
|
1093
|
-
return Object.freeze(Object.fromEntries(entries));
|
|
1094
|
-
}
|
|
1095
|
-
async function materializeStoredEvents(events, payloads) {
|
|
1096
|
-
assertStoredEventReceiptBindings(events);
|
|
1097
|
-
const projectId = storedProjectId(events);
|
|
1098
|
-
const materialized = await Promise.all(events.map(async (event) => {
|
|
1099
|
-
const payload = await materializeValue(event.payload, '$.payload', event, projectId, payloads);
|
|
1100
|
-
if (!isRecord(payload))
|
|
1101
|
-
throw new Error('Materialized Workroom Journal payload is invalid');
|
|
1102
|
-
validatePayload(event.type, payload, event.sequence);
|
|
1103
|
-
const derivedControl = deriveStoredEventControl({ ...event, version: 1, payload });
|
|
1104
|
-
const comparableControl = event.type === 'task.blocked'
|
|
1105
|
-
&& Object.keys(event.control).length === 2
|
|
1106
|
-
? Object.freeze({ taskKey: derivedControl.taskKey, blockerId: derivedControl.blockerId })
|
|
1107
|
-
: derivedControl;
|
|
1108
|
-
if (canonicalWorkroomJson(event.control) !== canonicalWorkroomJson(comparableControl)) {
|
|
1109
|
-
throw new Error('Stored Workroom control projection does not match the governed payload');
|
|
1110
|
-
}
|
|
1111
|
-
const { control: _control, ...eventHeader } = event;
|
|
1112
|
-
return Object.freeze({
|
|
1113
|
-
...eventHeader,
|
|
1114
|
-
version: 1,
|
|
1115
|
-
payload: Object.freeze({ ...payload }),
|
|
1116
|
-
});
|
|
1117
|
-
}));
|
|
1118
|
-
return Object.freeze(materialized);
|
|
1119
|
-
}
|
|
1120
|
-
async function reconcileJournalPayloads(runId, events, payloads) {
|
|
1121
|
-
if (!payloads.reconcile || events.length === 0)
|
|
1122
|
-
return;
|
|
1123
|
-
await payloads.reconcile({
|
|
1124
|
-
projectId: storedProjectId(events),
|
|
1125
|
-
runId,
|
|
1126
|
-
receipts: collectGovernedPayloadReceipts(events),
|
|
1127
|
-
publicationDigest: journalPublicationDigest(runId, events),
|
|
1128
|
-
});
|
|
1129
|
-
}
|
|
1130
|
-
function journalPublicationDigest(runId, events) {
|
|
1131
|
-
return digestCanonicalWorkroomValue({
|
|
1132
|
-
version: 1,
|
|
1133
|
-
runId,
|
|
1134
|
-
eventHeaders: events.map(event => ({
|
|
1135
|
-
eventId: event.eventId,
|
|
1136
|
-
sequence: event.sequence,
|
|
1137
|
-
type: event.type,
|
|
1138
|
-
control: event.control,
|
|
1139
|
-
payload: event.payload,
|
|
1140
|
-
})),
|
|
1141
|
-
});
|
|
1142
|
-
}
|
|
1143
|
-
function verifyJournalPayloadPublication(intent, events) {
|
|
1144
|
-
if (intent.consumer !== 'journal_header')
|
|
1145
|
-
return deepFreeze({ status: 'unknown' });
|
|
1146
|
-
const runId = intent.publicationScope;
|
|
1147
|
-
if (!runId || events.length === 0 || events.some(event => event.runId !== runId)) {
|
|
1148
|
-
return deepFreeze({ status: 'missing' });
|
|
1149
|
-
}
|
|
1150
|
-
const exact = collectGovernedPayloadReceipts(events).some(receipt => receipt.descriptor.objectId === intent.objectId
|
|
1151
|
-
&& receipt.descriptor.payloadHash === intent.payloadHash
|
|
1152
|
-
&& receipt.descriptor.descriptorDigest === intent.descriptorDigest
|
|
1153
|
-
&& receipt.source.bindingDigest === intent.sourceBindingDigest);
|
|
1154
|
-
return exact
|
|
1155
|
-
? deepFreeze({
|
|
1156
|
-
status: 'exact',
|
|
1157
|
-
publicationDigest: journalPublicationDigest(runId, events),
|
|
1158
|
-
})
|
|
1159
|
-
: deepFreeze({ status: 'missing' });
|
|
1160
|
-
}
|
|
1161
|
-
function collectGovernedPayloadReceipts(events) {
|
|
1162
|
-
const receipts = [];
|
|
1163
|
-
const visit = (value) => {
|
|
1164
|
-
if (isGovernedJournalPayloadReference(value)) {
|
|
1165
|
-
receipts.push(value.receipt);
|
|
1166
|
-
return;
|
|
1167
|
-
}
|
|
1168
|
-
if (Array.isArray(value)) {
|
|
1169
|
-
for (const item of value)
|
|
1170
|
-
visit(item);
|
|
1171
|
-
return;
|
|
1172
|
-
}
|
|
1173
|
-
if (isRecord(value)) {
|
|
1174
|
-
for (const item of Object.values(value))
|
|
1175
|
-
visit(item);
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
for (const event of events)
|
|
1179
|
-
visit(event.payload);
|
|
1180
|
-
return Object.freeze(receipts);
|
|
1181
|
-
}
|
|
1182
|
-
async function materializeValue(value, fieldPath, event, projectId, payloads) {
|
|
1183
|
-
if (isGovernedJournalPayloadReference(value)) {
|
|
1184
|
-
if (value.fieldPath !== fieldPath)
|
|
1185
|
-
throw new Error('Governed Workroom Journal payload field binding drift');
|
|
1186
|
-
const source = journalPayloadSource(event, fieldPath, value.contentHash);
|
|
1187
|
-
assertJournalPayloadReceipt(value.receipt, createWorkroomJournalPayloadObjectId({
|
|
1188
|
-
projectId,
|
|
1189
|
-
runId: event.runId,
|
|
1190
|
-
eventId: event.eventId,
|
|
1191
|
-
eventType: event.type,
|
|
1192
|
-
occurredAt: event.occurredAt,
|
|
1193
|
-
fieldPath,
|
|
1194
|
-
contentHash: value.contentHash,
|
|
1195
|
-
}), value.contentHash, source);
|
|
1196
|
-
const materialized = await payloads.read({
|
|
1197
|
-
projectId,
|
|
1198
|
-
runId: event.runId,
|
|
1199
|
-
eventId: event.eventId,
|
|
1200
|
-
eventType: event.type,
|
|
1201
|
-
fieldPath,
|
|
1202
|
-
contentHash: value.contentHash,
|
|
1203
|
-
receipt: value.receipt,
|
|
1204
|
-
purpose: 'kernel-replay',
|
|
1205
|
-
});
|
|
1206
|
-
if (digestCanonicalWorkroomValue(materialized) !== value.contentHash) {
|
|
1207
|
-
throw new Error('Governed Workroom Journal payload content hash mismatch');
|
|
1208
|
-
}
|
|
1209
|
-
if (Buffer.byteLength(canonicalWorkroomJson(materialized)) !== value.receipt.descriptor.bytes) {
|
|
1210
|
-
throw new Error('Governed Workroom Journal payload byte length mismatch');
|
|
1211
|
-
}
|
|
1212
|
-
return materialized;
|
|
1213
|
-
}
|
|
1214
|
-
if (Array.isArray(value)) {
|
|
1215
|
-
return Object.freeze(await Promise.all(value.map((item, index) => materializeValue(item, `${fieldPath}[${index}]`, event, projectId, payloads))));
|
|
1216
|
-
}
|
|
1217
|
-
if (!isRecord(value))
|
|
1218
|
-
return value;
|
|
1219
|
-
return Object.freeze(Object.fromEntries(await Promise.all(Object.entries(value).map(async ([key, child]) => [
|
|
1220
|
-
key,
|
|
1221
|
-
await materializeValue(child, `${fieldPath}.${key}`, event, projectId, payloads),
|
|
1222
|
-
]))));
|
|
1223
|
-
}
|
|
1224
|
-
function projectIdForAppend(current, appended) {
|
|
1225
|
-
if (current.length > 0)
|
|
1226
|
-
return storedProjectId(current);
|
|
1227
|
-
const created = appended[0];
|
|
1228
|
-
if (!created || created.type !== 'run.created' || !isNonEmptyString(created.payload.projectId)) {
|
|
1229
|
-
throw new Error('Workroom Journal first append must begin with a Project-bound run.created event');
|
|
1230
|
-
}
|
|
1231
|
-
return created.payload.projectId;
|
|
1232
|
-
}
|
|
1233
|
-
function storedProjectId(events) {
|
|
1234
|
-
const created = events[0];
|
|
1235
|
-
if (!created || created.type !== 'run.created' || !isNonEmptyString(created.payload.projectId)) {
|
|
1236
|
-
throw new Error('Stored Workroom Journal has no Project-bound run.created header');
|
|
1237
|
-
}
|
|
1238
|
-
return created.payload.projectId;
|
|
1239
|
-
}
|
|
1240
|
-
function journalPayloadSource(event, fieldPath, contentHash) {
|
|
1241
|
-
const ref = `workroom-journal-event:${event.runId}:${event.eventId}:${fieldPath}`;
|
|
1242
|
-
const sourceBody = Object.freeze({
|
|
1243
|
-
version: 1,
|
|
1244
|
-
runId: event.runId,
|
|
1245
|
-
eventId: event.eventId,
|
|
1246
|
-
eventType: event.type,
|
|
1247
|
-
fieldPath,
|
|
1248
|
-
contentHash,
|
|
1249
|
-
});
|
|
1250
|
-
const sourceDigest = digestCanonicalWorkroomValue(sourceBody);
|
|
1251
|
-
return Object.freeze({
|
|
1252
|
-
ref,
|
|
1253
|
-
digest: sourceDigest,
|
|
1254
|
-
bindingDigest: digestCanonicalWorkroomValue({ ref, sourceDigest, ...sourceBody }),
|
|
1255
|
-
});
|
|
1256
|
-
}
|
|
1257
|
-
function assertJournalPayloadReceipt(receipt, objectId, contentHash, source) {
|
|
1258
|
-
if (!receipt || !isRecord(receipt.descriptor) || !isRecord(receipt.source)
|
|
1259
|
-
|| !isNonEmptyString(receipt.descriptor.vaultObjectId)
|
|
1260
|
-
|| receipt.descriptor.objectId !== objectId
|
|
1261
|
-
|| receipt.descriptor.payloadHash !== contentHash
|
|
1262
|
-
|| !isDigest(receipt.descriptor.descriptorDigest)
|
|
1263
|
-
|| !isDigest(receipt.descriptor.locationManifestDigest)
|
|
1264
|
-
|| !Number.isSafeInteger(receipt.descriptor.bytes) || Number(receipt.descriptor.bytes) < 0
|
|
1265
|
-
|| receipt.source.kind !== 'command'
|
|
1266
|
-
|| receipt.source.ref !== source.ref
|
|
1267
|
-
|| receipt.source.digest !== source.digest
|
|
1268
|
-
|| receipt.source.bindingDigest !== source.bindingDigest
|
|
1269
|
-
|| receipt.source.verification !== 'verified') {
|
|
1270
|
-
throw new Error('Governed Workroom Journal payload receipt is forged or incomplete');
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
function assertStoredEventReceiptBindings(events) {
|
|
1274
|
-
if (events.length === 0)
|
|
1275
|
-
return;
|
|
1276
|
-
const projectId = storedProjectId(events);
|
|
1277
|
-
const visit = (value, fieldPath, event) => {
|
|
1278
|
-
if (isGovernedJournalPayloadReference(value)) {
|
|
1279
|
-
if (value.fieldPath !== fieldPath) {
|
|
1280
|
-
throw new Error('Governed Workroom Journal payload field binding drift');
|
|
1281
|
-
}
|
|
1282
|
-
const source = journalPayloadSource(event, fieldPath, value.contentHash);
|
|
1283
|
-
assertJournalPayloadReceipt(value.receipt, createWorkroomJournalPayloadObjectId({
|
|
1284
|
-
projectId,
|
|
1285
|
-
runId: event.runId,
|
|
1286
|
-
eventId: event.eventId,
|
|
1287
|
-
eventType: event.type,
|
|
1288
|
-
occurredAt: event.occurredAt,
|
|
1289
|
-
fieldPath,
|
|
1290
|
-
contentHash: value.contentHash,
|
|
1291
|
-
}), value.contentHash, source);
|
|
1292
|
-
return;
|
|
1293
|
-
}
|
|
1294
|
-
if (Array.isArray(value)) {
|
|
1295
|
-
value.forEach((item, index) => visit(item, `${fieldPath}[${index}]`, event));
|
|
1296
|
-
return;
|
|
1297
|
-
}
|
|
1298
|
-
if (isRecord(value)) {
|
|
1299
|
-
for (const [key, child] of Object.entries(value)) {
|
|
1300
|
-
visit(child, `${fieldPath}.${key}`, event);
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
};
|
|
1304
|
-
for (const event of events)
|
|
1305
|
-
visit(event.payload, '$.payload', event);
|
|
1306
|
-
}
|
|
1307
|
-
export function createWorkroomJournalPayloadObjectId(input) {
|
|
1308
|
-
return `workroom-journal-payload:${digestCanonicalWorkroomValue({
|
|
1309
|
-
version: 2,
|
|
1310
|
-
projectId: input.projectId,
|
|
1311
|
-
runId: input.runId,
|
|
1312
|
-
eventId: input.eventId,
|
|
1313
|
-
eventType: input.eventType,
|
|
1314
|
-
occurredAt: input.occurredAt,
|
|
1315
|
-
fieldPath: input.fieldPath,
|
|
1316
|
-
contentHash: input.contentHash,
|
|
1317
|
-
})}`;
|
|
1318
|
-
}
|
|
1319
|
-
function isGovernedJournalPayloadReference(value) {
|
|
1320
|
-
if (!isRecord(value) || value.version !== 1 || value.kind !== 'governed_workroom_journal_payload'
|
|
1321
|
-
|| !isNonEmptyString(value.fieldPath) || !isDigest(value.contentHash)
|
|
1322
|
-
|| !isRecord(value.receipt))
|
|
1323
|
-
return false;
|
|
1324
|
-
const keys = Object.keys(value).sort();
|
|
1325
|
-
return keys.length === 5
|
|
1326
|
-
&& ['contentHash', 'fieldPath', 'kind', 'receipt', 'version'].every((key, index) => keys[index] === key);
|
|
1327
|
-
}
|
|
1328
|
-
function validateProtectedPayload(type, payload) {
|
|
1329
|
-
assertAllowedPayloadKeys(type, payload);
|
|
1330
|
-
const visit = (value, fieldPath) => {
|
|
1331
|
-
if (isGovernedJournalPayloadReference(value)) {
|
|
1332
|
-
if (value.fieldPath !== fieldPath)
|
|
1333
|
-
throw new Error('Governed Workroom Journal payload path is invalid');
|
|
1334
|
-
return;
|
|
1335
|
-
}
|
|
1336
|
-
if (Array.isArray(value)) {
|
|
1337
|
-
value.forEach((item, index) => visit(item, `${fieldPath}[${index}]`));
|
|
1338
|
-
return;
|
|
1339
|
-
}
|
|
1340
|
-
if (!isRecord(value))
|
|
1341
|
-
return;
|
|
1342
|
-
for (const [key, child] of Object.entries(value)) {
|
|
1343
|
-
if (!isContentFreeJournalValue(type, `${fieldPath}.${key}`, child) && containsGovernedValue(child)
|
|
1344
|
-
&& !isGovernedJournalPayloadReference(child)) {
|
|
1345
|
-
throw legacyJournalPayloadError();
|
|
1346
|
-
}
|
|
1347
|
-
visit(child, `${fieldPath}.${key}`);
|
|
1348
|
-
}
|
|
1349
|
-
};
|
|
1350
|
-
visit(payload, '$.payload');
|
|
1351
|
-
}
|
|
1352
|
-
function isContentFreeJournalValue(type, fieldPath, value) {
|
|
1353
|
-
if (value === undefined || value === null || value === '')
|
|
1354
|
-
return true;
|
|
1355
|
-
if (typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value)))
|
|
1356
|
-
return true;
|
|
1357
|
-
if (typeof value !== 'string')
|
|
1358
|
-
return false;
|
|
1359
|
-
if (type === 'run.created' && fieldPath === '$.payload.projectId')
|
|
1360
|
-
return true;
|
|
1361
|
-
return isDigest(value);
|
|
1362
|
-
}
|
|
1363
|
-
function containsGovernedValue(value) {
|
|
1364
|
-
if (value === undefined || value === null || value === '')
|
|
1365
|
-
return false;
|
|
1366
|
-
if (Array.isArray(value))
|
|
1367
|
-
return value.length > 0;
|
|
1368
|
-
return typeof value !== 'object' || Object.keys(value).length > 0;
|
|
1369
|
-
}
|
|
1370
|
-
function legacyJournalPayloadError() {
|
|
1371
|
-
return new LegacyEmbeddedPayloadDetectedError('Legacy embedded Workroom Journal payload is quarantined; use offline export/purge verification before activation');
|
|
1372
|
-
}
|
|
1373
|
-
function isDigest(value) {
|
|
1374
|
-
return typeof value === 'string' && /^sha256:[a-f0-9]{64}$/u.test(value);
|
|
1375
|
-
}
|
|
1376
|
-
const WORKROOM_EVENT_TYPES = new Set([
|
|
1377
|
-
'run.created', 'run.control_decided', 'run.replan_requested',
|
|
1378
|
-
'run.cancel_requested', 'run.cancelled', 'plan.admitted', 'plan_gate.decided',
|
|
1379
|
-
'plan.revision_applied',
|
|
1380
|
-
'task.planned', 'task.blocked', 'task.blocker_resolved',
|
|
1381
|
-
'task.cancel_requested', 'task.cancelled', 'task.failed',
|
|
1382
|
-
'task.accepted', 'task.acceptance_pinned', 'task.acceptance_blocked', 'task.rework_requested', 'task.revised',
|
|
1383
|
-
'task.plan_revised',
|
|
1384
|
-
'reviewer.assigned', 'reviewer.claimed', 'reviewer.verdict_recorded', 'reviewer.expired',
|
|
1385
|
-
'sponsor_gate.opened', 'sponsor_gate.decided', 'sponsor_gate.expired',
|
|
1386
|
-
'assignment.claimed', 'assignment.started', 'assignment.heartbeat',
|
|
1387
|
-
'assignment.progress', 'assignment.checkpointed',
|
|
1388
|
-
'assignment.checkpoint_requested', 'assignment.preempted',
|
|
1389
|
-
'assignment.execution_completed', 'assignment.cancel_requested',
|
|
1390
|
-
'assignment.cancelled', 'assignment.lease_expired',
|
|
1391
|
-
'scheduler.dispatch_requested', 'scheduler.priority_changed', 'scheduler.preemption_requested',
|
|
1392
|
-
'scheduler.preemption_checkpoint_acknowledged', 'scheduler.preemption_timed_out',
|
|
1393
|
-
'local_execution.requested',
|
|
1394
|
-
'remote_dispatch.requested', 'clock.advanced',
|
|
1395
|
-
]);
|
|
1396
|
-
function isWorkroomEventType(value) {
|
|
1397
|
-
return typeof value === 'string' && WORKROOM_EVENT_TYPES.has(value);
|
|
1398
|
-
}
|
|
1399
|
-
/**
|
|
1400
|
-
* Closed top-level schema for every persisted Kernel fact. Values not listed
|
|
1401
|
-
* here are rejected before either the Journal header or Payload Vault is
|
|
1402
|
-
* written, so adding a future field requires an explicit governance choice.
|
|
1403
|
-
*/
|
|
1404
|
-
const WORKROOM_EVENT_PAYLOAD_KEYS = Object.freeze({
|
|
1405
|
-
'run.created': ['projectId', 'title'],
|
|
1406
|
-
'run.control_decided': [
|
|
1407
|
-
'operationId', 'action', 'reasonCode', 'expectedSequence', 'principalId', 'requestDigest',
|
|
1408
|
-
'catalogRevision', 'projectDigest', 'authorizationRef',
|
|
1409
|
-
'stateSequence', 'stateStatus', 'stateDigest',
|
|
1410
|
-
],
|
|
1411
|
-
'run.replan_requested': ['operationId', 'reasonCode', 'requestDigest'],
|
|
1412
|
-
'run.cancel_requested': ['reason'],
|
|
1413
|
-
'run.cancelled': ['reason'],
|
|
1414
|
-
'plan.admitted': [
|
|
1415
|
-
'operationId', 'sourceEventRef', 'sourceEventDigest', 'orchestratorAgentDefinitionId',
|
|
1416
|
-
'plan', 'schedulerPolicy',
|
|
1417
|
-
],
|
|
1418
|
-
'plan.revision_applied': ['candidate', 'planRevision', 'recomputedDiffDigest'],
|
|
1419
|
-
'plan_gate.decided': [
|
|
1420
|
-
'operationId', 'requestDigest', 'taskKey', 'taskRevision', 'gateId', 'planDigest',
|
|
1421
|
-
'policyRevisionId', 'policyDigest', 'decision', 'sponsorPrincipalId', 'authorizedBy',
|
|
1422
|
-
'reasonDigest',
|
|
1423
|
-
],
|
|
1424
|
-
'task.planned': [
|
|
1425
|
-
'type', 'taskKey', 'title', 'required', 'maxAttempts', 'role', 'dependsOn', 'requires',
|
|
1426
|
-
'sponsorLane', 'localRank', 'deadline', 'enqueuedAt', 'preemptibility', 'approvalGate',
|
|
1427
|
-
],
|
|
1428
|
-
'task.blocked': [
|
|
1429
|
-
'type', 'taskKey', 'blockerId', 'kind', 'owner', 'reason', 'deadline', 'allowedActions',
|
|
1430
|
-
],
|
|
1431
|
-
'task.blocker_resolved': ['type', 'taskKey', 'blockerId'],
|
|
1432
|
-
'task.cancel_requested': ['taskKey', 'reason'],
|
|
1433
|
-
'task.cancelled': ['taskKey', 'reason'],
|
|
1434
|
-
'task.failed': ['taskKey', 'reason'],
|
|
1435
|
-
'task.accepted': ['taskKey', 'reportRef', 'record'],
|
|
1436
|
-
'task.acceptance_pinned': ['taskKey', 'contract'],
|
|
1437
|
-
'task.acceptance_blocked': ['taskKey', 'reportRef', 'reason', 'evaluation'],
|
|
1438
|
-
'task.rework_requested': ['type', 'taskKey', 'reason', 'evaluation'],
|
|
1439
|
-
'task.revised': ['type', 'taskKey', 'title', 'reason', 'maxAttempts'],
|
|
1440
|
-
'task.plan_revised': [
|
|
1441
|
-
'taskKey', 'title', 'required', 'maxAttempts', 'role', 'dependsOn', 'requires',
|
|
1442
|
-
'sponsorLane', 'localRank', 'deadline', 'enqueuedAt', 'preemptibility', 'approvalGate',
|
|
1443
|
-
'expectedTaskRevision', 'newTaskRevision', 'reason',
|
|
1444
|
-
],
|
|
1445
|
-
'reviewer.assigned': ['taskKey', 'reason', 'assignment'],
|
|
1446
|
-
'reviewer.claimed': [
|
|
1447
|
-
'taskKey', 'assignmentId', 'reviewerPrincipalId', 'authorizedBy', 'authorization',
|
|
1448
|
-
],
|
|
1449
|
-
'reviewer.verdict_recorded': [
|
|
1450
|
-
'taskKey', 'assignmentId', 'reviewerPrincipalId', 'authorizedBy', 'outcome',
|
|
1451
|
-
'verdict', 'authorization',
|
|
1452
|
-
],
|
|
1453
|
-
'reviewer.expired': ['taskKey', 'assignmentId'],
|
|
1454
|
-
'sponsor_gate.opened': ['taskKey', 'reason', 'gate'],
|
|
1455
|
-
'sponsor_gate.decided': [
|
|
1456
|
-
'taskKey', 'gateId', 'sponsorPrincipalId', 'authorizedBy', 'reason', 'candidateHash',
|
|
1457
|
-
'decision', 'authorization',
|
|
1458
|
-
],
|
|
1459
|
-
'sponsor_gate.expired': ['taskKey', 'gateId'],
|
|
1460
|
-
'assignment.claimed': [
|
|
1461
|
-
'type', 'taskKey', 'assignmentId', 'owner', 'role', 'taskRevision', 'attempt',
|
|
1462
|
-
'assignmentRevision', 'fence', 'envelopeDigest', 'leaseExpiresAt',
|
|
1463
|
-
],
|
|
1464
|
-
'assignment.started': ['assignmentId'],
|
|
1465
|
-
'assignment.progress': [
|
|
1466
|
-
'assignmentId', 'observationId', 'observationDigest', 'envelopeDigest', 'progress',
|
|
1467
|
-
],
|
|
1468
|
-
'assignment.heartbeat': [
|
|
1469
|
-
'assignmentId', 'observationId', 'observationDigest', 'envelopeDigest', 'leaseExpiresAt',
|
|
1470
|
-
],
|
|
1471
|
-
'assignment.checkpointed': [
|
|
1472
|
-
'assignmentId', 'observationId', 'observationDigest', 'envelopeDigest',
|
|
1473
|
-
'checkpointRef', 'checkpointDigest',
|
|
1474
|
-
],
|
|
1475
|
-
'assignment.checkpoint_requested': [
|
|
1476
|
-
'decisionId', 'assignmentId', 'envelopeDigest', 'reservedTaskKey', 'requestedAt',
|
|
1477
|
-
'deadline', 'takeoverFence', 'owner', 'allowedSuccessors',
|
|
1478
|
-
],
|
|
1479
|
-
'assignment.preempted': [
|
|
1480
|
-
'decisionId', 'assignmentId', 'checkpointRef', 'checkpointDigest', 'outcome',
|
|
1481
|
-
],
|
|
1482
|
-
'assignment.execution_completed': [
|
|
1483
|
-
'assignmentId', 'observationId', 'observationDigest', 'envelopeDigest', 'reportRef',
|
|
1484
|
-
'reportDigest', 'candidateRef', 'candidateHash', 'completionReceiptDigest',
|
|
1485
|
-
],
|
|
1486
|
-
'assignment.cancel_requested': ['assignmentId', 'controlDeadline'],
|
|
1487
|
-
'assignment.cancelled': ['assignmentId', 'outcome'],
|
|
1488
|
-
'assignment.lease_expired': ['assignmentId'],
|
|
1489
|
-
'scheduler.dispatch_requested': [
|
|
1490
|
-
'version', 'type', 'decisionId', 'digest', 'projectId', 'runId', 'expectedSequence',
|
|
1491
|
-
'taskKey', 'taskRevision', 'role', 'sponsorLane', 'reason', 'policy',
|
|
1492
|
-
],
|
|
1493
|
-
'scheduler.priority_changed': [
|
|
1494
|
-
'version', 'type', 'proposalId', 'digest', 'projectId', 'runId', 'taskKey',
|
|
1495
|
-
'taskRevision', 'expectedSequence', 'currentLane', 'requestedLane', 'localRank',
|
|
1496
|
-
'principalId', 'authority', 'authorityRef', 'deadline', 'owner', 'allowedSuccessors',
|
|
1497
|
-
'authorizedBy',
|
|
1498
|
-
],
|
|
1499
|
-
'scheduler.preemption_requested': [
|
|
1500
|
-
'version', 'type', 'decisionId', 'digest', 'projectId', 'runId', 'expectedSequence',
|
|
1501
|
-
'victimTaskKey', 'victimTaskRevision', 'reservedTaskKey', 'reservedTaskRevision',
|
|
1502
|
-
'assignmentId', 'assignmentAttempt', 'assignmentFence', 'assignmentEnvelopeDigest',
|
|
1503
|
-
'owner', 'requestedAt', 'deadline', 'takeoverFence', 'reason', 'allowedSuccessors', 'policy',
|
|
1504
|
-
],
|
|
1505
|
-
'scheduler.preemption_checkpoint_acknowledged': [
|
|
1506
|
-
'decisionId', 'assignmentId', 'envelopeDigest', 'observationId', 'observationDigest',
|
|
1507
|
-
'checkpointRef', 'checkpointDigest', 'assignmentAttempt', 'assignmentFence', 'takeoverFence',
|
|
1508
|
-
],
|
|
1509
|
-
'scheduler.preemption_timed_out': [
|
|
1510
|
-
'decisionId', 'assignmentId', 'reservedTaskKey', 'blockerId', 'owner', 'deadline',
|
|
1511
|
-
'allowedSuccessors', 'reason',
|
|
1512
|
-
],
|
|
1513
|
-
'local_execution.requested': [
|
|
1514
|
-
'operationId', 'requestDigest', 'agentDefinitionId', 'issuedAt', 'envelope',
|
|
1515
|
-
],
|
|
1516
|
-
'remote_dispatch.requested': [
|
|
1517
|
-
'operationId', 'requestDigest', 'issuedAt', 'reconcileDeadline', 'envelope', 'dispatchItem',
|
|
1518
|
-
],
|
|
1519
|
-
'clock.advanced': ['now'],
|
|
1520
|
-
});
|
|
1521
|
-
function assertAllowedPayloadKeys(type, payload) {
|
|
1522
|
-
const allowed = WORKROOM_EVENT_PAYLOAD_KEYS[type];
|
|
1523
|
-
if (Object.keys(payload).some(key => !allowed.includes(key))) {
|
|
1524
|
-
throw new Error(`Invalid Workroom event payload keys: ${type}`);
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
function validatePayload(type, payload, sequence) {
|
|
1528
|
-
assertAllowedPayloadKeys(type, payload);
|
|
1529
|
-
switch (type) {
|
|
1530
|
-
case 'run.created':
|
|
1531
|
-
requirePayloadString(payload, 'projectId');
|
|
1532
|
-
requirePayloadString(payload, 'title');
|
|
1533
|
-
return;
|
|
1534
|
-
case 'run.control_decided':
|
|
1535
|
-
requirePayloadString(payload, 'operationId');
|
|
1536
|
-
requirePayloadEnum(payload, 'action', ['cancel', 'request_replan']);
|
|
1537
|
-
requirePayloadString(payload, 'reasonCode');
|
|
1538
|
-
if (payload.action === 'cancel'
|
|
1539
|
-
? !isWorkroomRunCancelReasonCode(payload.reasonCode)
|
|
1540
|
-
: !isWorkroomRunReplanReasonCode(payload.reasonCode)) {
|
|
1541
|
-
throw new Error('Invalid Workroom event payload: Run control reasonCode');
|
|
1542
|
-
}
|
|
1543
|
-
if (!Number.isSafeInteger(payload.expectedSequence) || Number(payload.expectedSequence) < 0) {
|
|
1544
|
-
throw new Error('Invalid Workroom event payload: expectedSequence');
|
|
1545
|
-
}
|
|
1546
|
-
requirePayloadString(payload, 'principalId');
|
|
1547
|
-
requirePayloadDigest(payload, 'requestDigest');
|
|
1548
|
-
requirePayloadString(payload, 'catalogRevision');
|
|
1549
|
-
requirePayloadDigest(payload, 'projectDigest');
|
|
1550
|
-
requirePayloadString(payload, 'authorizationRef');
|
|
1551
|
-
if (!Number.isSafeInteger(payload.stateSequence) || Number(payload.stateSequence) < 0) {
|
|
1552
|
-
throw new Error('Invalid Workroom event payload: stateSequence');
|
|
1553
|
-
}
|
|
1554
|
-
requirePayloadEnum(payload, 'stateStatus', [
|
|
1555
|
-
'active', 'blocked', 'needs_replan', 'cancelling', 'completed', 'cancelled',
|
|
1556
|
-
]);
|
|
1557
|
-
requirePayloadDigest(payload, 'stateDigest');
|
|
1558
|
-
return;
|
|
1559
|
-
case 'run.replan_requested':
|
|
1560
|
-
requirePayloadString(payload, 'operationId');
|
|
1561
|
-
requirePayloadString(payload, 'reasonCode');
|
|
1562
|
-
if (!isWorkroomRunReplanReasonCode(payload.reasonCode)) {
|
|
1563
|
-
throw new Error('Invalid Workroom event payload: replan reasonCode');
|
|
1564
|
-
}
|
|
1565
|
-
requirePayloadDigest(payload, 'requestDigest');
|
|
1566
|
-
return;
|
|
1567
|
-
case 'plan.admitted':
|
|
1568
|
-
requirePayloadString(payload, 'operationId');
|
|
1569
|
-
requirePayloadString(payload, 'sourceEventRef');
|
|
1570
|
-
requirePayloadDigest(payload, 'sourceEventDigest');
|
|
1571
|
-
requirePayloadString(payload, 'orchestratorAgentDefinitionId');
|
|
1572
|
-
assertWorkflowPlanProposal(requirePayloadRecord(payload, 'plan'));
|
|
1573
|
-
if (payload.schedulerPolicy !== undefined) {
|
|
1574
|
-
assertWorkroomSchedulerPolicySnapshot(payload.schedulerPolicy, sequence);
|
|
1575
|
-
}
|
|
1576
|
-
return;
|
|
1577
|
-
case 'plan.revision_applied': {
|
|
1578
|
-
const candidate = requirePayloadRecord(payload, 'candidate');
|
|
1579
|
-
assertWorkflowPlanRevisionCandidate(candidate);
|
|
1580
|
-
requirePayloadPositiveInteger(payload, 'planRevision');
|
|
1581
|
-
requirePayloadDigest(payload, 'recomputedDiffDigest');
|
|
1582
|
-
if (payload.recomputedDiffDigest !== digestCanonicalWorkroomValue(candidate.diff)) {
|
|
1583
|
-
throw new Error('Persisted Plan Revision recomputed diff digest is invalid');
|
|
1584
|
-
}
|
|
1585
|
-
return;
|
|
1586
|
-
}
|
|
1587
|
-
case 'plan_gate.decided':
|
|
1588
|
-
requirePayloadString(payload, 'operationId');
|
|
1589
|
-
requirePayloadDigest(payload, 'requestDigest');
|
|
1590
|
-
requirePayloadString(payload, 'taskKey');
|
|
1591
|
-
requirePayloadPositiveInteger(payload, 'taskRevision');
|
|
1592
|
-
requirePayloadString(payload, 'gateId');
|
|
1593
|
-
requirePayloadDigest(payload, 'planDigest');
|
|
1594
|
-
requirePayloadString(payload, 'policyRevisionId');
|
|
1595
|
-
requirePayloadDigest(payload, 'policyDigest');
|
|
1596
|
-
requirePayloadEnum(payload, 'decision', ['approve', 'reject', 'request_changes', 'cancel']);
|
|
1597
|
-
requirePayloadString(payload, 'sponsorPrincipalId');
|
|
1598
|
-
requirePayloadString(payload, 'authorizedBy');
|
|
1599
|
-
requirePayloadDigest(payload, 'reasonDigest');
|
|
1600
|
-
return;
|
|
1601
|
-
case 'local_execution.requested':
|
|
1602
|
-
parseWorkroomLocalAssignmentIssuance(payload);
|
|
1603
|
-
return;
|
|
1604
|
-
case 'remote_dispatch.requested':
|
|
1605
|
-
parseWorkroomRemoteAssignmentIssuance(payload);
|
|
1606
|
-
return;
|
|
1607
|
-
case 'scheduler.dispatch_requested':
|
|
1608
|
-
parseWorkroomDispatchTaskDecision(payload);
|
|
1609
|
-
return;
|
|
1610
|
-
case 'scheduler.priority_changed':
|
|
1611
|
-
requirePayloadString(payload, 'proposalId');
|
|
1612
|
-
requirePayloadDigest(payload, 'digest');
|
|
1613
|
-
requirePayloadString(payload, 'projectId');
|
|
1614
|
-
requirePayloadString(payload, 'runId');
|
|
1615
|
-
requirePayloadString(payload, 'taskKey');
|
|
1616
|
-
requirePayloadPositiveInteger(payload, 'taskRevision');
|
|
1617
|
-
requirePayloadEnum(payload, 'currentLane', ['urgent', 'high', 'normal', 'low']);
|
|
1618
|
-
requirePayloadEnum(payload, 'requestedLane', ['urgent', 'high', 'normal', 'low']);
|
|
1619
|
-
requirePayloadEnum(payload, 'authority', ['sponsor', 'orchestrator']);
|
|
1620
|
-
requirePayloadString(payload, 'principalId');
|
|
1621
|
-
requirePayloadString(payload, 'authorityRef');
|
|
1622
|
-
requirePayloadString(payload, 'owner');
|
|
1623
|
-
requirePayloadNumber(payload, 'deadline');
|
|
1624
|
-
requirePayloadString(payload, 'authorizedBy');
|
|
1625
|
-
parseWorkroomPriorityChangeProposal({
|
|
1626
|
-
version: payload.version,
|
|
1627
|
-
type: payload.type,
|
|
1628
|
-
proposalId: payload.proposalId,
|
|
1629
|
-
digest: payload.digest,
|
|
1630
|
-
projectId: payload.projectId,
|
|
1631
|
-
runId: payload.runId,
|
|
1632
|
-
taskKey: payload.taskKey,
|
|
1633
|
-
taskRevision: payload.taskRevision,
|
|
1634
|
-
expectedSequence: payload.expectedSequence,
|
|
1635
|
-
currentLane: payload.currentLane,
|
|
1636
|
-
requestedLane: payload.requestedLane,
|
|
1637
|
-
localRank: payload.localRank,
|
|
1638
|
-
principalId: payload.principalId,
|
|
1639
|
-
authority: payload.authority,
|
|
1640
|
-
authorityRef: payload.authorityRef,
|
|
1641
|
-
deadline: payload.deadline,
|
|
1642
|
-
owner: payload.owner,
|
|
1643
|
-
allowedSuccessors: payload.allowedSuccessors,
|
|
1644
|
-
});
|
|
1645
|
-
if (payload.authorizedBy !== payload.authorityRef) {
|
|
1646
|
-
throw new Error('Persisted Workroom priority authority proof is not exact');
|
|
1647
|
-
}
|
|
1648
|
-
return;
|
|
1649
|
-
case 'scheduler.preemption_requested':
|
|
1650
|
-
parseWorkroomPreemptionPrepareDecision(payload);
|
|
1651
|
-
return;
|
|
1652
|
-
case 'scheduler.preemption_checkpoint_acknowledged':
|
|
1653
|
-
requirePayloadString(payload, 'decisionId');
|
|
1654
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1655
|
-
requirePayloadDigest(payload, 'envelopeDigest');
|
|
1656
|
-
requirePayloadString(payload, 'observationId');
|
|
1657
|
-
requirePayloadDigest(payload, 'observationDigest');
|
|
1658
|
-
requirePayloadString(payload, 'checkpointRef');
|
|
1659
|
-
requirePayloadDigest(payload, 'checkpointDigest');
|
|
1660
|
-
requirePayloadPositiveInteger(payload, 'assignmentAttempt');
|
|
1661
|
-
requirePayloadPositiveInteger(payload, 'assignmentFence');
|
|
1662
|
-
requirePayloadPositiveInteger(payload, 'takeoverFence');
|
|
1663
|
-
if (payload.takeoverFence !== Number(payload.assignmentFence) + 1) {
|
|
1664
|
-
throw new Error('Invalid Workroom event payload: preemption takeover fence');
|
|
1665
|
-
}
|
|
1666
|
-
return;
|
|
1667
|
-
case 'scheduler.preemption_timed_out':
|
|
1668
|
-
requirePayloadString(payload, 'decisionId');
|
|
1669
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1670
|
-
requirePayloadString(payload, 'reservedTaskKey');
|
|
1671
|
-
requirePayloadString(payload, 'blockerId');
|
|
1672
|
-
requirePayloadString(payload, 'owner');
|
|
1673
|
-
requirePayloadNumber(payload, 'deadline');
|
|
1674
|
-
requirePayloadString(payload, 'reason');
|
|
1675
|
-
if (canonicalWorkroomJson(payload.allowedSuccessors) !== canonicalWorkroomJson(['replan', 'cancel_run'])) {
|
|
1676
|
-
throw new Error('Invalid Workroom event payload: preemption timeout successors');
|
|
1677
|
-
}
|
|
1678
|
-
return;
|
|
1679
|
-
case 'run.cancel_requested':
|
|
1680
|
-
case 'run.cancelled':
|
|
1681
|
-
requirePayloadString(payload, 'reason');
|
|
1682
|
-
return;
|
|
1683
|
-
case 'task.planned':
|
|
1684
|
-
requirePayloadString(payload, 'taskKey');
|
|
1685
|
-
requirePayloadString(payload, 'title');
|
|
1686
|
-
requirePayloadBoolean(payload, 'required');
|
|
1687
|
-
requirePayloadPositiveInteger(payload, 'maxAttempts');
|
|
1688
|
-
if (payload.approvalGate !== undefined) {
|
|
1689
|
-
const gate = requirePayloadRecord(payload, 'approvalGate');
|
|
1690
|
-
requirePayloadString(gate, 'id');
|
|
1691
|
-
requirePayloadEnum(gate, 'kind', ['sponsor']);
|
|
1692
|
-
requirePayloadString(gate, 'owner');
|
|
1693
|
-
requirePayloadPositiveInteger(gate, 'decisionTimeoutMs');
|
|
1694
|
-
requirePayloadString(gate, 'policyRevisionId');
|
|
1695
|
-
requirePayloadDigest(gate, 'policyDigest');
|
|
1696
|
-
if (!Array.isArray(gate.allowedActions)
|
|
1697
|
-
|| canonicalWorkroomJson(gate.allowedActions) !== canonicalWorkroomJson(['approve', 'reject', 'replan', 'cancel'])) {
|
|
1698
|
-
throw new Error('Invalid Workroom event payload: approvalGate allowedActions');
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
return;
|
|
1702
|
-
case 'task.blocked':
|
|
1703
|
-
requirePayloadString(payload, 'taskKey');
|
|
1704
|
-
requirePayloadString(payload, 'blockerId');
|
|
1705
|
-
requirePayloadEnum(payload, 'kind', ['dependency', 'approval', 'capability', 'external', 'human_input']);
|
|
1706
|
-
requirePayloadString(payload, 'owner');
|
|
1707
|
-
requirePayloadString(payload, 'reason');
|
|
1708
|
-
requirePayloadNumber(payload, 'deadline');
|
|
1709
|
-
return;
|
|
1710
|
-
case 'task.blocker_resolved':
|
|
1711
|
-
requirePayloadString(payload, 'taskKey');
|
|
1712
|
-
requirePayloadString(payload, 'blockerId');
|
|
1713
|
-
return;
|
|
1714
|
-
case 'task.cancel_requested':
|
|
1715
|
-
case 'task.cancelled':
|
|
1716
|
-
case 'task.failed':
|
|
1717
|
-
requirePayloadString(payload, 'taskKey');
|
|
1718
|
-
requirePayloadString(payload, 'reason');
|
|
1719
|
-
return;
|
|
1720
|
-
case 'task.accepted':
|
|
1721
|
-
requirePayloadString(payload, 'taskKey');
|
|
1722
|
-
requirePayloadString(payload, 'reportRef');
|
|
1723
|
-
assertPersistedAcceptanceRecord(payload.record, String(payload.taskKey), String(payload.reportRef), sequence);
|
|
1724
|
-
return;
|
|
1725
|
-
case 'task.acceptance_pinned': {
|
|
1726
|
-
requirePayloadString(payload, 'taskKey');
|
|
1727
|
-
const contract = requirePayloadRecord(payload, 'contract');
|
|
1728
|
-
assertAcceptanceContract(contract, String(payload.taskKey), Number(contract.taskRevision));
|
|
1729
|
-
return;
|
|
1730
|
-
}
|
|
1731
|
-
case 'task.acceptance_blocked':
|
|
1732
|
-
requirePayloadString(payload, 'taskKey');
|
|
1733
|
-
requirePayloadString(payload, 'reportRef');
|
|
1734
|
-
requirePayloadString(payload, 'reason');
|
|
1735
|
-
requirePayloadRecord(payload, 'evaluation');
|
|
1736
|
-
return;
|
|
1737
|
-
case 'reviewer.assigned':
|
|
1738
|
-
requirePayloadString(payload, 'taskKey');
|
|
1739
|
-
requirePayloadString(payload, 'reason');
|
|
1740
|
-
validateAcceptanceWait(requirePayloadRecord(payload, 'assignment'), String(payload.taskKey), true);
|
|
1741
|
-
return;
|
|
1742
|
-
case 'reviewer.expired':
|
|
1743
|
-
requirePayloadString(payload, 'taskKey');
|
|
1744
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1745
|
-
return;
|
|
1746
|
-
case 'reviewer.claimed':
|
|
1747
|
-
requirePayloadString(payload, 'taskKey');
|
|
1748
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1749
|
-
requirePayloadString(payload, 'reviewerPrincipalId');
|
|
1750
|
-
requirePayloadString(payload, 'authorizedBy');
|
|
1751
|
-
requirePayloadRecord(payload, 'authorization');
|
|
1752
|
-
return;
|
|
1753
|
-
case 'reviewer.verdict_recorded':
|
|
1754
|
-
requirePayloadString(payload, 'taskKey');
|
|
1755
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1756
|
-
requirePayloadEnum(payload, 'outcome', ['passed', 'rework']);
|
|
1757
|
-
requirePayloadRecord(payload, 'verdict');
|
|
1758
|
-
requirePayloadRecord(payload, 'authorization');
|
|
1759
|
-
return;
|
|
1760
|
-
case 'sponsor_gate.opened':
|
|
1761
|
-
requirePayloadString(payload, 'taskKey');
|
|
1762
|
-
requirePayloadString(payload, 'reason');
|
|
1763
|
-
validateAcceptanceWait(requirePayloadRecord(payload, 'gate'), String(payload.taskKey), false);
|
|
1764
|
-
return;
|
|
1765
|
-
case 'sponsor_gate.expired':
|
|
1766
|
-
requirePayloadString(payload, 'taskKey');
|
|
1767
|
-
requirePayloadString(payload, 'gateId');
|
|
1768
|
-
return;
|
|
1769
|
-
case 'sponsor_gate.decided':
|
|
1770
|
-
requirePayloadString(payload, 'taskKey');
|
|
1771
|
-
requirePayloadString(payload, 'gateId');
|
|
1772
|
-
requirePayloadString(payload, 'sponsorPrincipalId');
|
|
1773
|
-
requirePayloadString(payload, 'authorizedBy');
|
|
1774
|
-
requirePayloadString(payload, 'reason');
|
|
1775
|
-
requirePayloadString(payload, 'candidateHash');
|
|
1776
|
-
requirePayloadEnum(payload, 'decision', ['approve', 'reject', 'request_changes', 'cancel']);
|
|
1777
|
-
requirePayloadRecord(payload, 'authorization');
|
|
1778
|
-
return;
|
|
1779
|
-
case 'task.rework_requested':
|
|
1780
|
-
requirePayloadString(payload, 'taskKey');
|
|
1781
|
-
requirePayloadString(payload, 'reason');
|
|
1782
|
-
return;
|
|
1783
|
-
case 'task.revised':
|
|
1784
|
-
requirePayloadString(payload, 'taskKey');
|
|
1785
|
-
requirePayloadString(payload, 'title');
|
|
1786
|
-
requirePayloadString(payload, 'reason');
|
|
1787
|
-
requirePayloadPositiveInteger(payload, 'maxAttempts');
|
|
1788
|
-
return;
|
|
1789
|
-
case 'task.plan_revised':
|
|
1790
|
-
requirePayloadString(payload, 'taskKey');
|
|
1791
|
-
requirePayloadPositiveInteger(payload, 'expectedTaskRevision');
|
|
1792
|
-
requirePayloadPositiveInteger(payload, 'newTaskRevision');
|
|
1793
|
-
requirePayloadString(payload, 'title');
|
|
1794
|
-
requirePayloadBoolean(payload, 'required');
|
|
1795
|
-
requirePayloadPositiveInteger(payload, 'maxAttempts');
|
|
1796
|
-
requirePayloadString(payload, 'role');
|
|
1797
|
-
requirePayloadString(payload, 'reason');
|
|
1798
|
-
return;
|
|
1799
|
-
case 'assignment.claimed':
|
|
1800
|
-
requirePayloadString(payload, 'taskKey');
|
|
1801
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1802
|
-
requirePayloadString(payload, 'owner');
|
|
1803
|
-
requirePayloadEnum(payload, 'role', ['executor', 'reviewer', 'integration']);
|
|
1804
|
-
requirePayloadPositiveInteger(payload, 'taskRevision');
|
|
1805
|
-
requirePayloadPositiveInteger(payload, 'attempt');
|
|
1806
|
-
requirePayloadPositiveInteger(payload, 'assignmentRevision');
|
|
1807
|
-
requirePayloadPositiveInteger(payload, 'fence');
|
|
1808
|
-
requirePayloadDigest(payload, 'envelopeDigest');
|
|
1809
|
-
requirePayloadNumber(payload, 'leaseExpiresAt');
|
|
1810
|
-
return;
|
|
1811
|
-
case 'assignment.started':
|
|
1812
|
-
case 'assignment.lease_expired':
|
|
1813
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1814
|
-
return;
|
|
1815
|
-
case 'assignment.progress':
|
|
1816
|
-
validateAssignmentObservationHeader(payload);
|
|
1817
|
-
assertExactPayloadKeys(payload, [
|
|
1818
|
-
'assignmentId', 'observationId', 'observationDigest', 'envelopeDigest', 'progress',
|
|
1819
|
-
], type);
|
|
1820
|
-
validateProgress(requirePayloadRecord(payload, 'progress'));
|
|
1821
|
-
assertPersistedAssignmentObservationDigest(payload, {
|
|
1822
|
-
version: 1,
|
|
1823
|
-
type: 'progress',
|
|
1824
|
-
observationId: payload.observationId,
|
|
1825
|
-
envelopeDigest: payload.envelopeDigest,
|
|
1826
|
-
progress: payload.progress,
|
|
1827
|
-
});
|
|
1828
|
-
return;
|
|
1829
|
-
case 'assignment.heartbeat':
|
|
1830
|
-
validateAssignmentObservationHeader(payload);
|
|
1831
|
-
assertExactPayloadKeys(payload, [
|
|
1832
|
-
'assignmentId', 'observationId', 'observationDigest', 'envelopeDigest', 'leaseExpiresAt',
|
|
1833
|
-
], type);
|
|
1834
|
-
requirePayloadNumber(payload, 'leaseExpiresAt');
|
|
1835
|
-
assertPersistedAssignmentObservationDigest(payload, {
|
|
1836
|
-
version: 1,
|
|
1837
|
-
type: 'heartbeat',
|
|
1838
|
-
observationId: payload.observationId,
|
|
1839
|
-
envelopeDigest: payload.envelopeDigest,
|
|
1840
|
-
});
|
|
1841
|
-
return;
|
|
1842
|
-
case 'assignment.checkpointed':
|
|
1843
|
-
validateAssignmentObservationHeader(payload);
|
|
1844
|
-
assertExactPayloadKeys(payload, [
|
|
1845
|
-
'assignmentId', 'observationId', 'observationDigest', 'envelopeDigest',
|
|
1846
|
-
'checkpointRef', 'checkpointDigest',
|
|
1847
|
-
], type);
|
|
1848
|
-
requirePayloadString(payload, 'checkpointRef');
|
|
1849
|
-
requirePayloadDigest(payload, 'checkpointDigest');
|
|
1850
|
-
assertPersistedAssignmentObservationDigest(payload, {
|
|
1851
|
-
version: 1,
|
|
1852
|
-
type: 'checkpoint',
|
|
1853
|
-
observationId: payload.observationId,
|
|
1854
|
-
envelopeDigest: payload.envelopeDigest,
|
|
1855
|
-
checkpoint: { ref: payload.checkpointRef, digest: payload.checkpointDigest },
|
|
1856
|
-
});
|
|
1857
|
-
return;
|
|
1858
|
-
case 'assignment.checkpoint_requested':
|
|
1859
|
-
requirePayloadString(payload, 'decisionId');
|
|
1860
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1861
|
-
requirePayloadDigest(payload, 'envelopeDigest');
|
|
1862
|
-
requirePayloadString(payload, 'reservedTaskKey');
|
|
1863
|
-
requirePayloadNumber(payload, 'requestedAt');
|
|
1864
|
-
requirePayloadNumber(payload, 'deadline');
|
|
1865
|
-
requirePayloadPositiveInteger(payload, 'takeoverFence');
|
|
1866
|
-
requirePayloadString(payload, 'owner');
|
|
1867
|
-
if (Number(payload.deadline) <= Number(payload.requestedAt)
|
|
1868
|
-
|| canonicalWorkroomJson(payload.allowedSuccessors) !== canonicalWorkroomJson(['replan', 'cancel_run'])) {
|
|
1869
|
-
throw new Error('Invalid Workroom event payload: checkpoint request recovery metadata');
|
|
1870
|
-
}
|
|
1871
|
-
return;
|
|
1872
|
-
case 'assignment.preempted':
|
|
1873
|
-
requirePayloadString(payload, 'decisionId');
|
|
1874
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1875
|
-
requirePayloadString(payload, 'checkpointRef');
|
|
1876
|
-
requirePayloadDigest(payload, 'checkpointDigest');
|
|
1877
|
-
requirePayloadEnum(payload, 'outcome', ['interrupted']);
|
|
1878
|
-
return;
|
|
1879
|
-
case 'assignment.execution_completed':
|
|
1880
|
-
validateAssignmentObservationHeader(payload);
|
|
1881
|
-
assertExactPayloadKeys(payload, [
|
|
1882
|
-
'assignmentId', 'observationId', 'observationDigest', 'envelopeDigest',
|
|
1883
|
-
'reportRef', 'reportDigest', 'candidateRef', 'candidateHash',
|
|
1884
|
-
...(payload.completionReceiptDigest === undefined
|
|
1885
|
-
? []
|
|
1886
|
-
: ['completionReceiptDigest']),
|
|
1887
|
-
], type);
|
|
1888
|
-
requirePayloadString(payload, 'reportRef');
|
|
1889
|
-
requirePayloadDigest(payload, 'reportDigest');
|
|
1890
|
-
requirePayloadString(payload, 'candidateRef');
|
|
1891
|
-
requirePayloadDigest(payload, 'candidateHash');
|
|
1892
|
-
if (payload.completionReceiptDigest !== undefined) {
|
|
1893
|
-
requirePayloadDigest(payload, 'completionReceiptDigest');
|
|
1894
|
-
}
|
|
1895
|
-
assertPersistedAssignmentObservationDigest(payload, {
|
|
1896
|
-
version: 1,
|
|
1897
|
-
type: 'execution_completed',
|
|
1898
|
-
observationId: payload.observationId,
|
|
1899
|
-
envelopeDigest: payload.envelopeDigest,
|
|
1900
|
-
completion: {
|
|
1901
|
-
report: { ref: payload.reportRef, digest: payload.reportDigest },
|
|
1902
|
-
candidate: { ref: payload.candidateRef, hash: payload.candidateHash },
|
|
1903
|
-
...(payload.completionReceiptDigest === undefined
|
|
1904
|
-
? {}
|
|
1905
|
-
: { completionReceiptDigest: payload.completionReceiptDigest }),
|
|
1906
|
-
},
|
|
1907
|
-
});
|
|
1908
|
-
return;
|
|
1909
|
-
case 'assignment.cancel_requested':
|
|
1910
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1911
|
-
requirePayloadNumber(payload, 'controlDeadline');
|
|
1912
|
-
return;
|
|
1913
|
-
case 'assignment.cancelled':
|
|
1914
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1915
|
-
requirePayloadEnum(payload, 'outcome', ['interrupted', 'committed', 'outcome_unknown']);
|
|
1916
|
-
return;
|
|
1917
|
-
case 'clock.advanced':
|
|
1918
|
-
requirePayloadNumber(payload, 'now');
|
|
1919
|
-
return;
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
function validateAssignmentObservationHeader(payload) {
|
|
1923
|
-
requirePayloadString(payload, 'assignmentId');
|
|
1924
|
-
requirePayloadString(payload, 'observationId');
|
|
1925
|
-
requirePayloadDigest(payload, 'observationDigest');
|
|
1926
|
-
requirePayloadDigest(payload, 'envelopeDigest');
|
|
1927
|
-
}
|
|
1928
|
-
function assertPersistedAssignmentObservationDigest(payload, observation) {
|
|
1929
|
-
if (digestCanonicalWorkroomValue(observation) !== payload.observationDigest) {
|
|
1930
|
-
throw new Error('Invalid Workroom event payload: observationDigest does not match body');
|
|
1931
|
-
}
|
|
1932
|
-
}
|
|
1933
|
-
function validateProgress(progress) {
|
|
1934
|
-
const keys = Object.keys(progress);
|
|
1935
|
-
if (keys.some(key => !['summary', 'completedUnits', 'totalUnits'].includes(key))) {
|
|
1936
|
-
throw new Error('Invalid Workroom event payload: progress keys');
|
|
1937
|
-
}
|
|
1938
|
-
requirePayloadString(progress, 'summary');
|
|
1939
|
-
const completed = progress.completedUnits;
|
|
1940
|
-
const total = progress.totalUnits;
|
|
1941
|
-
if (completed !== undefined && (!Number.isSafeInteger(completed) || completed < 0)) {
|
|
1942
|
-
throw new Error('Invalid Workroom event payload: completedUnits');
|
|
1943
|
-
}
|
|
1944
|
-
if (total !== undefined && (!Number.isSafeInteger(total) || total < 1)) {
|
|
1945
|
-
throw new Error('Invalid Workroom event payload: totalUnits');
|
|
1946
|
-
}
|
|
1947
|
-
if (typeof completed === 'number' && typeof total === 'number' && completed > total) {
|
|
1948
|
-
throw new Error('Invalid Workroom event payload: completedUnits exceeds totalUnits');
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
function assertExactPayloadKeys(payload, expected, type) {
|
|
1952
|
-
const actual = Object.keys(payload).sort();
|
|
1953
|
-
const canonical = [...expected].sort();
|
|
1954
|
-
if (actual.length !== canonical.length || actual.some((key, index) => key !== canonical[index])) {
|
|
1955
|
-
throw new Error(`Invalid Workroom event payload keys: ${type}`);
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
function assertExactRecordKeys(value, expected, label) {
|
|
1959
|
-
const actual = Object.keys(value).sort();
|
|
1960
|
-
const canonical = [...expected].sort();
|
|
1961
|
-
if (actual.length !== canonical.length || actual.some((key, index) => key !== canonical[index])) {
|
|
1962
|
-
throw new Error(`${label} keys are invalid`);
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
function validateAcceptanceWait(value, taskKey, reviewer) {
|
|
1966
|
-
for (const key of ['id', 'taskKey', 'candidateHash', 'contractId', 'owner']) {
|
|
1967
|
-
requirePayloadString(value, key);
|
|
1968
|
-
}
|
|
1969
|
-
requirePayloadPositiveInteger(value, 'taskRevision');
|
|
1970
|
-
requirePayloadEnum(value, 'riskTier', ['low', 'medium', 'high', 'critical']);
|
|
1971
|
-
requirePayloadEnum(value, 'route', ['reviewer_required', 'sponsor_required', 'reviewer_then_sponsor']);
|
|
1972
|
-
if (value.taskKey !== taskKey)
|
|
1973
|
-
throw new Error('Invalid Workroom event payload: wait taskKey');
|
|
1974
|
-
requirePayloadNumber(value, 'deadline');
|
|
1975
|
-
requirePayloadEnum(value, 'status', ['open']);
|
|
1976
|
-
requirePayloadRecord(value, 'evaluation');
|
|
1977
|
-
const policy = requirePayloadRecord(value, 'policy');
|
|
1978
|
-
requirePayloadString(policy, 'id');
|
|
1979
|
-
requirePayloadString(policy, 'digest');
|
|
1980
|
-
requirePayloadPositiveInteger(policy, 'revision');
|
|
1981
|
-
if (reviewer)
|
|
1982
|
-
requirePayloadString(value, 'producerPrincipalId');
|
|
1983
|
-
if (!Array.isArray(value.allowedActions) || value.allowedActions.length === 0
|
|
1984
|
-
|| value.allowedActions.some(action => !isNonEmptyString(action)
|
|
1985
|
-
|| !ACCEPTANCE_WAIT_ACTIONS.has(action))) {
|
|
1986
|
-
throw new Error('Invalid Workroom event payload: allowedActions');
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
const ACCEPTANCE_WAIT_ACTIONS = new Set([
|
|
1990
|
-
'claim', 'submit_verdict', 'approve', 'reject', 'request_changes',
|
|
1991
|
-
'reassign', 'reopen', 'rebase', 'replan', 'cancel',
|
|
1992
|
-
]);
|
|
1993
|
-
function isRecord(value) {
|
|
1994
|
-
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
1995
|
-
}
|
|
1996
|
-
function isNonEmptyString(value) {
|
|
1997
|
-
return typeof value === 'string' && value.trim().length > 0;
|
|
1998
|
-
}
|
|
1999
|
-
function isFiniteNumber(value) {
|
|
2000
|
-
return typeof value === 'number' && Number.isFinite(value);
|
|
2001
|
-
}
|
|
2002
|
-
function isSequence(value) {
|
|
2003
|
-
return Number.isSafeInteger(value) && value >= 0;
|
|
2004
|
-
}
|
|
2005
|
-
function requirePayloadString(payload, key) {
|
|
2006
|
-
if (!isNonEmptyString(payload[key]))
|
|
2007
|
-
throw new Error(`Invalid Workroom event payload: ${key}`);
|
|
2008
|
-
}
|
|
2009
|
-
function requirePayloadNumber(payload, key) {
|
|
2010
|
-
if (!isFiniteNumber(payload[key]))
|
|
2011
|
-
throw new Error(`Invalid Workroom event payload: ${key}`);
|
|
2012
|
-
}
|
|
2013
|
-
function requirePayloadDigest(payload, key) {
|
|
2014
|
-
if (typeof payload[key] !== 'string' || !/^sha256:[a-f0-9]{64}$/u.test(payload[key])) {
|
|
2015
|
-
throw new Error(`Invalid Workroom event payload: ${key}`);
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
function requirePayloadRecord(payload, key) {
|
|
2019
|
-
if (!isRecord(payload[key]))
|
|
2020
|
-
throw new Error(`Invalid Workroom event payload: ${key}`);
|
|
2021
|
-
return payload[key];
|
|
2022
|
-
}
|
|
2023
|
-
function requirePayloadPositiveInteger(payload, key) {
|
|
2024
|
-
const value = payload[key];
|
|
2025
|
-
if (!Number.isSafeInteger(value) || value < 1) {
|
|
2026
|
-
throw new Error(`Invalid Workroom event payload: ${key}`);
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
function requirePayloadBoolean(payload, key) {
|
|
2030
|
-
if (typeof payload[key] !== 'boolean')
|
|
2031
|
-
throw new Error(`Invalid Workroom event payload: ${key}`);
|
|
2032
|
-
}
|
|
2033
|
-
function requirePayloadEnum(payload, key, values) {
|
|
2034
|
-
if (typeof payload[key] !== 'string' || !values.includes(payload[key])) {
|
|
2035
|
-
throw new Error(`Invalid Workroom event payload: ${key}`);
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
//# sourceMappingURL=journal.js.map
|