@caupulican/pi-adaptative 0.81.42 → 0.84.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +52 -49
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +62 -57
- package/dist/bundled-resources/prompts/skillify.md +1 -1
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +16 -19
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +12 -26
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +15 -121
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +52 -79
- package/dist/bundled-resources/runtimes/pi-shell-engine/escapes.py +70 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +110 -61
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +106 -23
- package/dist/bundled-resources/runtimes/pi-shell-engine/paths.py +10 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +12 -4
- package/dist/bundled-resources/runtimes/pi-shell-engine/shell_args.py +22 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +9 -2
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +129 -259
- package/dist/bundled-resources/skills/authorized-web-security-audit/SKILL.md +187 -0
- package/dist/bundled-resources/skills/authorized-web-security-audit/references/assessment-contract.md +92 -0
- package/dist/bundled-resources/skills/deduplicate-by-evidence/SKILL.md +134 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/SKILL.md +93 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/references/evidence-model.md +27 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/references/security-scanners.md +24 -0
- package/dist/bundled-resources/skills/harness-self-adaptation/SKILL.md +4 -2
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/SKILL.md +217 -0
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/defensive-exploit-catalogue.md +175 -0
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/tool-boundary-checklist.md +87 -0
- package/dist/bundled-resources/skills/skill-architect/SKILL.md +2 -2
- package/dist/bundled-resources/skills/skill-creator/SKILL.md +188 -0
- package/dist/bundled-resources/skills/skill-creator/references/pi-skill-contract.md +73 -0
- package/dist/bundled-resources/skills/skill-creator/scripts/init-skill.mjs +142 -0
- package/dist/bundled-resources/skills/skill-creator/scripts/validate-skill.mjs +122 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +8 -8
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/piped-stdin.d.ts +4 -0
- package/dist/cli/piped-stdin.d.ts.map +1 -0
- package/dist/cli/piped-stdin.js +13 -0
- package/dist/cli/piped-stdin.js.map +1 -0
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -15
- package/dist/config.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts.map +1 -1
- package/dist/core/agent-directory-layout.js.map +1 -1
- package/dist/core/agent-paths.d.ts +1 -1
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +1 -1
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +5 -9
- package/dist/core/agent-session-contracts.d.ts.map +1 -1
- package/dist/core/agent-session-contracts.js +1 -12
- package/dist/core/agent-session-contracts.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +10 -25
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +24 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +210 -237
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/auth-storage.d.ts +4 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +13 -39
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
- package/dist/core/autonomy/evidence-finding-projection.d.ts +11 -0
- package/dist/core/autonomy/evidence-finding-projection.d.ts.map +1 -0
- package/dist/core/autonomy/evidence-finding-projection.js +37 -0
- package/dist/core/autonomy/evidence-finding-projection.js.map +1 -0
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
- package/dist/core/autonomy/lane-private-paths.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +2 -3
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/path-scope.d.ts.map +1 -1
- package/dist/core/autonomy/path-scope.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/status.d.ts.map +1 -1
- package/dist/core/autonomy/status.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -1
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +2 -4
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +2 -15
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/background-tool-task-controller.d.ts +88 -0
- package/dist/core/background-tool-task-controller.d.ts.map +1 -0
- package/dist/core/background-tool-task-controller.js +470 -0
- package/dist/core/background-tool-task-controller.js.map +1 -0
- package/dist/core/bash-execution-controller.d.ts +1 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +5 -4
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts.map +1 -1
- package/dist/core/bedrock-sso-login.js.map +1 -1
- package/dist/core/billing-failover-controller.d.ts.map +1 -1
- package/dist/core/billing-failover-controller.js +3 -3
- package/dist/core/billing-failover-controller.js.map +1 -1
- package/dist/core/billing-failover.d.ts.map +1 -1
- package/dist/core/billing-failover.js.map +1 -1
- package/dist/core/capability-contract.d.ts.map +1 -1
- package/dist/core/catalog-manager.d.ts.map +1 -1
- package/dist/core/catalog-manager.js +0 -0
- package/dist/core/catalog-manager.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +2 -0
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +21 -8
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +8 -0
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +0 -2
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
- package/dist/core/context/artifact-retrieval.js.map +1 -1
- package/dist/core/context/brain-curator.d.ts.map +1 -1
- package/dist/core/context/brain-curator.js +14 -33
- package/dist/core/context/brain-curator.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +16 -24
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-audit.d.ts.map +1 -1
- package/dist/core/context/context-audit.js +3 -17
- package/dist/core/context/context-audit.js.map +1 -1
- package/dist/core/context/context-composition.d.ts.map +1 -1
- package/dist/core/context/context-composition.js.map +1 -1
- package/dist/core/context/context-item.d.ts.map +1 -1
- package/dist/core/context/context-item.js.map +1 -1
- package/dist/core/context/context-prompt-enforcement.d.ts.map +1 -1
- package/dist/core/context/context-prompt-enforcement.js +3 -16
- package/dist/core/context/context-prompt-enforcement.js.map +1 -1
- package/dist/core/context/context-prompt-policy.d.ts.map +1 -1
- package/dist/core/context/context-prompt-policy.js.map +1 -1
- package/dist/core/context/context-retention.d.ts.map +1 -1
- package/dist/core/context/context-retention.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/context-store.d.ts.map +1 -1
- package/dist/core/context/context-store.js.map +1 -1
- package/dist/core/context/context-tool-result.d.ts +4 -0
- package/dist/core/context/context-tool-result.d.ts.map +1 -0
- package/dist/core/context/context-tool-result.js +15 -0
- package/dist/core/context/context-tool-result.js.map +1 -0
- package/dist/core/context/current-work-memory.d.ts.map +1 -1
- package/dist/core/context/current-work-memory.js.map +1 -1
- package/dist/core/context/file-store-memory-provider.d.ts.map +1 -1
- package/dist/core/context/file-store-memory-provider.js +7 -28
- package/dist/core/context/file-store-memory-provider.js.map +1 -1
- package/dist/core/context/local-memory-search.d.ts +11 -0
- package/dist/core/context/local-memory-search.d.ts.map +1 -0
- package/dist/core/context/local-memory-search.js +37 -0
- package/dist/core/context/local-memory-search.js.map +1 -0
- package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
- package/dist/core/context/long-term-memory-trigger.js.map +1 -1
- package/dist/core/context/memory-diagnostics.d.ts.map +1 -1
- package/dist/core/context/memory-diagnostics.js.map +1 -1
- package/dist/core/context/memory-index-store.d.ts.map +1 -1
- package/dist/core/context/memory-index-store.js.map +1 -1
- package/dist/core/context/memory-prompt-block.d.ts.map +1 -1
- package/dist/core/context/memory-prompt-block.js.map +1 -1
- package/dist/core/context/memory-prompt-budget.d.ts.map +1 -1
- package/dist/core/context/memory-prompt-budget.js.map +1 -1
- package/dist/core/context/memory-provider-contract.d.ts.map +1 -1
- package/dist/core/context/memory-provider-contract.js.map +1 -1
- package/dist/core/context/memory-retrieval.d.ts.map +1 -1
- package/dist/core/context/memory-retrieval.js.map +1 -1
- package/dist/core/context/memory-tier-composer.d.ts.map +1 -1
- package/dist/core/context/memory-tier-composer.js.map +1 -1
- package/dist/core/context/message-text.d.ts +7 -0
- package/dist/core/context/message-text.d.ts.map +1 -0
- package/dist/core/context/message-text.js +68 -0
- package/dist/core/context/message-text.js.map +1 -0
- package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
- package/dist/core/context/okf-memory-provider.js +4 -30
- package/dist/core/context/okf-memory-provider.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/policy-engine.d.ts.map +1 -1
- package/dist/core/context/policy-engine.js.map +1 -1
- package/dist/core/context/policy-types.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context/storage-authority.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.js.map +1 -1
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +14 -21
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -3
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +64 -145
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/cost/session-usage.d.ts.map +1 -1
- package/dist/core/cost/session-usage.js.map +1 -1
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.js +2 -6
- package/dist/core/delegation/managed-lane-controller.js.map +1 -1
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/session-worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-action-journal.d.ts.map +1 -1
- package/dist/core/delegation/worker-action-journal.js +0 -4
- package/dist/core/delegation/worker-action-journal.js.map +1 -1
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +1 -0
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +13 -15
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js +1 -4
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
- package/dist/core/delegation/worker-conversation-store.js +0 -2
- package/dist/core/delegation/worker-conversation-store.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +5 -14
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.js +5 -6
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
- package/dist/core/delegation/worker-lane-projection.js.map +1 -1
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +0 -3
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.js +4 -5
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-process-owner.d.ts.map +1 -1
- package/dist/core/delegation/worker-process-owner.js.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.js +1 -2
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +3 -4
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-resource-catalog.d.ts.map +1 -1
- package/dist/core/delegation/worker-resource-catalog.js.map +1 -1
- package/dist/core/delegation/worker-resource-materializer.d.ts.map +1 -1
- package/dist/core/delegation/worker-resource-materializer.js +1 -4
- package/dist/core/delegation/worker-resource-materializer.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +2 -4
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +6 -18
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -1
- package/dist/core/delegation/worker-task-label.js.map +1 -1
- package/dist/core/delegation/worker-terminal-finalizer.d.ts.map +1 -1
- package/dist/core/delegation/worker-terminal-finalizer.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.js +1 -4
- package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation.js +0 -2
- package/dist/core/delegation/worker-write-reservation.js.map +1 -1
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/doctor.d.ts +5 -5
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +16 -20
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +26 -7
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js +21 -74
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +4 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/session-tree-foundations.d.mts +67 -0
- package/dist/core/export-html/session-tree-foundations.mjs +313 -0
- package/dist/core/export-html/template.css +14 -41
- package/dist/core/export-html/template.html +3 -1
- package/dist/core/export-html/template.js +26 -435
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extension-import-authority.d.ts.map +1 -1
- package/dist/core/extension-import-authority.js.map +1 -1
- package/dist/core/extension-metadata.d.ts.map +1 -1
- package/dist/core/extension-metadata.js.map +1 -1
- package/dist/core/extensions/builtin.d.ts +17 -0
- package/dist/core/extensions/builtin.d.ts.map +1 -1
- package/dist/core/extensions/builtin.js +18 -54
- package/dist/core/extensions/builtin.js.map +1 -1
- package/dist/core/extensions/entry-resolution.d.ts +3 -0
- package/dist/core/extensions/entry-resolution.d.ts.map +1 -0
- package/dist/core/extensions/entry-resolution.js +17 -0
- package/dist/core/extensions/entry-resolution.js.map +1 -0
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +76 -21
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +2 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +41 -112
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts.map +1 -1
- package/dist/core/extensions/storage.d.ts.map +1 -1
- package/dist/core/extensions/storage.js.map +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +2 -5
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +27 -33
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +0 -4
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +7 -5
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +0 -1
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
- package/dist/core/goals/compact-goal-context.js +2 -4
- package/dist/core/goals/compact-goal-context.js.map +1 -1
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -1
- package/dist/core/goals/goal-acceptance.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +1 -3
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
- package/dist/core/goals/goal-lifecycle.js.map +1 -1
- package/dist/core/goals/goal-record.d.ts.map +1 -1
- package/dist/core/goals/goal-record.js.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +15 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +27 -3
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +35 -51
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/natural-language-goal.d.ts +9 -0
- package/dist/core/goals/natural-language-goal.d.ts.map +1 -0
- package/dist/core/goals/natural-language-goal.js +23 -0
- package/dist/core/goals/natural-language-goal.js.map +1 -0
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/human-input-controller.d.ts.map +1 -1
- package/dist/core/human-input-controller.js +2 -3
- package/dist/core/human-input-controller.js.map +1 -1
- package/dist/core/human-input.d.ts.map +1 -1
- package/dist/core/human-input.js.map +1 -1
- package/dist/core/improvement-loop.d.ts.map +1 -1
- package/dist/core/improvement-loop.js +11 -11
- package/dist/core/improvement-loop.js.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -1
- package/dist/core/install-telemetry.js.map +1 -1
- package/dist/core/isolated-text-completion.d.ts +17 -0
- package/dist/core/isolated-text-completion.d.ts.map +1 -0
- package/dist/core/isolated-text-completion.js +15 -0
- package/dist/core/isolated-text-completion.js.map +1 -0
- package/dist/core/keybindings.d.ts +47 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +12 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/observation-store.d.ts.map +1 -1
- package/dist/core/learning/observation-store.js +0 -2
- package/dist/core/learning/observation-store.js.map +1 -1
- package/dist/core/learning/reflection-engine.d.ts +1 -1
- package/dist/core/learning/reflection-engine.d.ts.map +1 -1
- package/dist/core/learning/reflection-engine.js +3 -0
- package/dist/core/learning/reflection-engine.js.map +1 -1
- package/dist/core/learning/reflection-turn-analysis.d.ts +20 -0
- package/dist/core/learning/reflection-turn-analysis.d.ts.map +1 -0
- package/dist/core/learning/reflection-turn-analysis.js +136 -0
- package/dist/core/learning/reflection-turn-analysis.js.map +1 -0
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/learning/skill-curator.d.ts.map +1 -1
- package/dist/core/learning/skill-curator.js +0 -3
- package/dist/core/learning/skill-curator.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +39 -0
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +41 -62
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/effectiveness-tracker.d.ts.map +1 -1
- package/dist/core/memory/effectiveness-tracker.js +4 -2
- package/dist/core/memory/effectiveness-tracker.js.map +1 -1
- package/dist/core/memory/memory-manager.d.ts.map +1 -1
- package/dist/core/memory/memory-manager.js +7 -7
- package/dist/core/memory/memory-manager.js.map +1 -1
- package/dist/core/memory/memory-provider.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +7 -0
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +48 -13
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts +47 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.js +50 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.js.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker.d.ts +2 -0
- package/dist/core/memory/providers/transcript-recall-worker.d.ts.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker.js +143 -0
- package/dist/core/memory/providers/transcript-recall-worker.js.map +1 -0
- package/dist/core/memory/providers/transcript-recall.d.ts +24 -13
- package/dist/core/memory/providers/transcript-recall.d.ts.map +1 -1
- package/dist/core/memory/providers/transcript-recall.js +143 -141
- package/dist/core/memory/providers/transcript-recall.js.map +1 -1
- package/dist/core/memory/providers/user-memory-archive.d.ts +39 -0
- package/dist/core/memory/providers/user-memory-archive.d.ts.map +1 -0
- package/dist/core/memory/providers/user-memory-archive.js +258 -0
- package/dist/core/memory/providers/user-memory-archive.js.map +1 -0
- package/dist/core/memory/transcript-index.d.ts.map +1 -1
- package/dist/core/memory/transcript-index.js +1 -1
- package/dist/core/memory/transcript-index.js.map +1 -1
- package/dist/core/memory-controller.d.ts +9 -0
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +57 -16
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-output-json.d.ts +10 -0
- package/dist/core/model-output-json.d.ts.map +1 -0
- package/dist/core/model-output-json.js +43 -0
- package/dist/core/model-output-json.js.map +1 -0
- package/dist/core/model-registry.d.ts +8 -8
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +29 -52
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/config-diagnostics.d.ts.map +1 -1
- package/dist/core/model-router/config-diagnostics.js.map +1 -1
- package/dist/core/model-router/executor-route.d.ts.map +1 -1
- package/dist/core/model-router/executor-route.js.map +1 -1
- package/dist/core/model-router/fitness-gate.d.ts.map +1 -1
- package/dist/core/model-router/fitness-gate.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/route-judge.d.ts.map +1 -1
- package/dist/core/model-router/route-judge.js +18 -36
- package/dist/core/model-router/route-judge.js.map +1 -1
- package/dist/core/model-router/session-buffer.d.ts.map +1 -1
- package/dist/core/model-router/session-buffer.js.map +1 -1
- package/dist/core/model-router/status.d.ts.map +1 -1
- package/dist/core/model-router/status.js.map +1 -1
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +1 -0
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +25 -56
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +10 -0
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js +0 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts.map +1 -1
- package/dist/core/model-tool-protocol.js.map +1 -1
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +0 -1
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/context-sizing.d.ts.map +1 -1
- package/dist/core/models/context-sizing.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +0 -1
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts.map +1 -1
- package/dist/core/models/host-state-store.js +1 -6
- package/dist/core/models/host-state-store.js.map +1 -1
- package/dist/core/models/llamacpp-runtime.d.ts +4 -19
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
- package/dist/core/models/llamacpp-runtime.js +32 -136
- package/dist/core/models/llamacpp-runtime.js.map +1 -1
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +82 -115
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/models/local-runtime.d.ts +12 -18
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +60 -204
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/model-endpoint.d.ts.map +1 -1
- package/dist/core/models/model-endpoint.js.map +1 -1
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/needle-runtime.d.ts +7 -3
- package/dist/core/models/needle-runtime.d.ts.map +1 -1
- package/dist/core/models/needle-runtime.js +16 -92
- package/dist/core/models/needle-runtime.js.map +1 -1
- package/dist/core/models/perf-profile.d.ts +1 -1
- package/dist/core/models/perf-profile.d.ts.map +1 -1
- package/dist/core/models/perf-profile.js +6 -13
- package/dist/core/models/perf-profile.js.map +1 -1
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -1
- package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -1
- package/dist/core/models/runtime-arbiter.d.ts.map +1 -1
- package/dist/core/models/runtime-arbiter.js +3 -15
- package/dist/core/models/runtime-arbiter.js.map +1 -1
- package/dist/core/models/runtime-process.d.ts +100 -0
- package/dist/core/models/runtime-process.d.ts.map +1 -0
- package/dist/core/models/runtime-process.js +183 -0
- package/dist/core/models/runtime-process.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -1
- package/dist/core/orchestration/agent-resume.js.map +1 -1
- package/dist/core/orchestration/attempt-usage.d.ts.map +1 -1
- package/dist/core/orchestration/attempt-usage.js.map +1 -1
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +0 -14
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +0 -2
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/event-store.d.ts.map +1 -1
- package/dist/core/orchestration/event-store.js +1 -14
- package/dist/core/orchestration/event-store.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/model-binding.d.ts.map +1 -1
- package/dist/core/orchestration/model-binding.js.map +1 -1
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
- package/dist/core/orchestration/policy-compiler.js +0 -3
- package/dist/core/orchestration/policy-compiler.js.map +1 -1
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -1
- package/dist/core/orchestration/policy-gate.js +0 -2
- package/dist/core/orchestration/policy-gate.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +1 -1
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/profile-store.d.ts.map +1 -1
- package/dist/core/orchestration/profile-store.js +0 -3
- package/dist/core/orchestration/profile-store.js.map +1 -1
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
- package/dist/core/orchestration/risk-budget.js.map +1 -1
- package/dist/core/orchestration/task-runtime.d.ts +1 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +27 -42
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
- package/dist/core/orchestration/work-state-projection.js.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -1
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -1
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager.d.ts +3 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +88 -353
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts.map +1 -1
- package/dist/core/process-identity.js.map +1 -1
- package/dist/core/process-liveness.d.ts +3 -0
- package/dist/core/process-liveness.d.ts.map +1 -0
- package/dist/core/process-liveness.js +17 -0
- package/dist/core/process-liveness.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts.map +1 -1
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -1
- package/dist/core/process-matrix/resume-launcher.js.map +1 -1
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/process-matrix/store.d.ts.map +1 -1
- package/dist/core/process-matrix/store.js.map +1 -1
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
- package/dist/core/process-matrix/supervisor.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +7 -8
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +1 -2
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/profile-resource-selection.d.ts.map +1 -1
- package/dist/core/profile-resource-selection.js +18 -59
- package/dist/core/profile-resource-selection.js.map +1 -1
- package/dist/core/prompt-markup.d.ts +3 -0
- package/dist/core/prompt-markup.d.ts.map +1 -0
- package/dist/core/prompt-markup.js +7 -0
- package/dist/core/prompt-markup.js.map +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +13 -39
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/python-runtime.d.ts.map +1 -1
- package/dist/core/python-runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +22 -1
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +143 -25
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts +2 -1
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +4 -14
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/request-auth.d.ts.map +1 -1
- package/dist/core/request-auth.js.map +1 -1
- package/dist/core/research/automata-provider.d.ts.map +1 -1
- package/dist/core/research/automata-provider.js.map +1 -1
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -1
- package/dist/core/research/lane-model-resolver.js +0 -1
- package/dist/core/research/lane-model-resolver.js.map +1 -1
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -1
- package/dist/core/research/model-fitness-controller.js +17 -33
- package/dist/core/research/model-fitness-controller.js.map +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -25
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts.map +1 -1
- package/dist/core/research/research-lane-controller.js +5 -10
- package/dist/core/research/research-lane-controller.js.map +1 -1
- package/dist/core/research/research-runner.d.ts +2 -4
- package/dist/core/research/research-runner.d.ts.map +1 -1
- package/dist/core/research/research-runner.js +17 -48
- package/dist/core/research/research-runner.js.map +1 -1
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/research/workspace-collector.d.ts.map +1 -1
- package/dist/core/research/workspace-collector.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-ignore.d.ts +6 -0
- package/dist/core/resource-ignore.d.ts.map +1 -0
- package/dist/core/resource-ignore.js +44 -0
- package/dist/core/resource-ignore.js.map +1 -0
- package/dist/core/resource-loader.d.ts +0 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +52 -187
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/resource-profile-blocks.d.ts +3 -1
- package/dist/core/resource-profile-blocks.d.ts.map +1 -1
- package/dist/core/resource-profile-blocks.js +8 -5
- package/dist/core/resource-profile-blocks.js.map +1 -1
- package/dist/core/resource-profile-equality.d.ts.map +1 -1
- package/dist/core/resource-profile-equality.js.map +1 -1
- package/dist/core/resource-traversal.d.ts +43 -0
- package/dist/core/resource-traversal.d.ts.map +1 -0
- package/dist/core/resource-traversal.js +84 -0
- package/dist/core/resource-traversal.js.map +1 -0
- package/dist/core/risk-classifier.d.ts.map +1 -1
- package/dist/core/risk-classifier.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +4 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +25 -50
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +0 -1
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +101 -43
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -1
- package/dist/core/secrets/secret-dotenv.js +0 -1
- package/dist/core/secrets/secret-dotenv.js.map +1 -1
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -1
- package/dist/core/secrets/secret-vault-format.js +0 -1
- package/dist/core/secrets/secret-vault-format.js.map +1 -1
- package/dist/core/secrets/secret-vault.d.ts.map +1 -1
- package/dist/core/secrets/secret-vault.js +2 -10
- package/dist/core/secrets/secret-vault.js.map +1 -1
- package/dist/core/security/secret-text.d.ts.map +1 -1
- package/dist/core/security/secret-text.js.map +1 -1
- package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
- package/dist/core/security/untrusted-boundary.js.map +1 -1
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +18 -50
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-artifact-bundle.d.ts.map +1 -1
- package/dist/core/session-artifact-bundle.js.map +1 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +0 -1
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-entry-index.d.ts +8 -0
- package/dist/core/session-entry-index.d.ts.map +1 -0
- package/dist/core/session-entry-index.js +16 -0
- package/dist/core/session-entry-index.js.map +1 -0
- package/dist/core/session-image-store.d.ts.map +1 -1
- package/dist/core/session-image-store.js +0 -3
- package/dist/core/session-image-store.js.map +1 -1
- package/dist/core/session-jsonl-writer.d.ts +3 -0
- package/dist/core/session-jsonl-writer.d.ts.map +1 -0
- package/dist/core/session-jsonl-writer.js +38 -0
- package/dist/core/session-jsonl-writer.js.map +1 -0
- package/dist/core/session-manager-factory.d.ts.map +1 -1
- package/dist/core/session-manager-factory.js.map +1 -1
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-snapshot.d.ts.map +1 -1
- package/dist/core/session-snapshot.js.map +1 -1
- package/dist/core/session-supervision-runtime.d.ts.map +1 -1
- package/dist/core/session-supervision-runtime.js +1 -4
- package/dist/core/session-supervision-runtime.js.map +1 -1
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +0 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +64 -162
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skill-block.d.mts +8 -0
- package/dist/core/skill-block.mjs +52 -0
- package/dist/core/skill-discovery.d.ts +5 -0
- package/dist/core/skill-discovery.d.ts.map +1 -0
- package/dist/core/skill-discovery.js +34 -0
- package/dist/core/skill-discovery.js.map +1 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +23 -159
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/spawned-usage.d.ts +21 -0
- package/dist/core/spawned-usage.d.ts.map +1 -0
- package/dist/core/spawned-usage.js +29 -0
- package/dist/core/spawned-usage.js.map +1 -0
- package/dist/core/system-prompt-builder.d.ts +4 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +15 -8
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +53 -35
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-command.d.ts.map +1 -1
- package/dist/core/tasks/task-command.js.map +1 -1
- package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -1
- package/dist/core/tasks/task-contract-monitor.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts.map +1 -1
- package/dist/core/tasks/task-projection.js.map +1 -1
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/text-preview.d.ts +4 -0
- package/dist/core/text-preview.d.ts.map +1 -0
- package/dist/core/text-preview.js +33 -0
- package/dist/core/text-preview.js.map +1 -0
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +86 -87
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +4 -1
- package/dist/core/tool-protocol-controller.d.ts.map +1 -1
- package/dist/core/tool-protocol-controller.js +19 -23
- package/dist/core/tool-protocol-controller.js.map +1 -1
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-recovery-log-worker.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-worker.js.map +1 -1
- package/dist/core/tool-recovery-logger.d.ts.map +1 -1
- package/dist/core/tool-recovery-logger.js +12 -24
- package/dist/core/tool-recovery-logger.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js +16 -22
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tool-repair-health.d.ts.map +1 -1
- package/dist/core/tool-repair-health.js.map +1 -1
- package/dist/core/tool-repair-settings.d.ts.map +1 -1
- package/dist/core/tool-repair-settings.js.map +1 -1
- package/dist/core/tool-selection/expected-utility.d.ts.map +1 -1
- package/dist/core/tool-selection/expected-utility.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts.map +1 -1
- package/dist/core/tool-selection/promotion.js.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.d.ts +2 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +49 -7
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tool-selection/tool-phase-timing.d.ts +19 -0
- package/dist/core/tool-selection/tool-phase-timing.d.ts.map +1 -0
- package/dist/core/tool-selection/tool-phase-timing.js +63 -0
- package/dist/core/tool-selection/tool-phase-timing.js.map +1 -0
- package/dist/core/tool-selection/tool-selection-controller.d.ts +2 -5
- package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.js +50 -30
- package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
- package/dist/core/toolkit/reflex-interpreter.d.ts +16 -0
- package/dist/core/toolkit/reflex-interpreter.d.ts.map +1 -1
- package/dist/core/toolkit/reflex-interpreter.js +21 -0
- package/dist/core/toolkit/reflex-interpreter.js.map +1 -1
- package/dist/core/toolkit/script-registry.d.ts.map +1 -1
- package/dist/core/toolkit/script-registry.js.map +1 -1
- package/dist/core/toolkit/script-runner.d.ts.map +1 -1
- package/dist/core/toolkit/script-runner.js.map +1 -1
- package/dist/core/tools/artifact-retrieve.d.ts.map +1 -1
- package/dist/core/tools/artifact-retrieve.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +2 -3
- package/dist/core/tools/ask-question.d.ts.map +1 -1
- package/dist/core/tools/ask-question.js +14 -40
- package/dist/core/tools/ask-question.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +83 -30
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/context-scout.d.ts.map +1 -1
- package/dist/core/tools/context-scout.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +9 -7
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +6 -6
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/fff-search-backend.d.ts +19 -0
- package/dist/core/tools/fff-search-backend.d.ts.map +1 -1
- package/dist/core/tools/fff-search-backend.js +28 -2
- package/dist/core/tools/fff-search-backend.js.map +1 -1
- package/dist/core/tools/file-encoding-policy.d.ts.map +1 -1
- package/dist/core/tools/file-encoding-policy.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +44 -108
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +7 -7
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/grep.d.ts +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +42 -102
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +20 -36
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +5 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +5 -5
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +2 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +24 -36
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/persistent-process-coordinator.d.ts +31 -0
- package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -0
- package/dist/core/tools/persistent-process-coordinator.js +123 -0
- package/dist/core/tools/persistent-process-coordinator.js.map +1 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +14 -13
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +29 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +31 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/run-process.d.ts.map +1 -1
- package/dist/core/tools/run-process.js.map +1 -1
- package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
- package/dist/core/tools/run-toolkit-script.js.map +1 -1
- package/dist/core/tools/search-command-guard.d.ts +10 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -1
- package/dist/core/tools/search-command-guard.js +118 -31
- package/dist/core/tools/search-command-guard.js.map +1 -1
- package/dist/core/tools/search-router.d.ts.map +1 -1
- package/dist/core/tools/search-router.js.map +1 -1
- package/dist/core/tools/search-tool-runtime.d.ts +19 -0
- package/dist/core/tools/search-tool-runtime.d.ts.map +1 -0
- package/dist/core/tools/search-tool-runtime.js +12 -0
- package/dist/core/tools/search-tool-runtime.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -1
- package/dist/core/tools/secret-store.js.map +1 -1
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -1
- package/dist/core/tools/shell-command-parser.js.map +1 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +4 -1
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-execution-session.d.ts +4 -0
- package/dist/core/tools/shell-execution-session.d.ts.map +1 -0
- package/dist/core/tools/shell-execution-session.js +11 -0
- package/dist/core/tools/shell-execution-session.js.map +1 -0
- package/dist/core/tools/shell-output-projection.d.ts +49 -0
- package/dist/core/tools/shell-output-projection.d.ts.map +1 -0
- package/dist/core/tools/shell-output-projection.js +381 -0
- package/dist/core/tools/shell-output-projection.js.map +1 -0
- package/dist/core/tools/shell-session.d.ts +2 -13
- package/dist/core/tools/shell-session.d.ts.map +1 -1
- package/dist/core/tools/shell-session.js +36 -136
- package/dist/core/tools/shell-session.js.map +1 -1
- package/dist/core/tools/skill-audit.d.ts.map +1 -1
- package/dist/core/tools/skill-audit.js.map +1 -1
- package/dist/core/tools/skillify.d.ts.map +1 -1
- package/dist/core/tools/skillify.js.map +1 -1
- package/dist/core/tools/task-steps.d.ts +8 -8
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +17 -18
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/tool-task.d.ts +23 -0
- package/dist/core/tools/tool-task.d.ts.map +1 -0
- package/dist/core/tools/tool-task.js +93 -0
- package/dist/core/tools/tool-task.js.map +1 -0
- package/dist/core/tools/windows-shell-engine.d.ts +17 -11
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +339 -117
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/tools/windows-shell-state.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-state.js.map +1 -1
- package/dist/core/tools/worktree-sync.d.ts.map +1 -1
- package/dist/core/tools/worktree-sync.js +8 -12
- package/dist/core/tools/worktree-sync.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +0 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +7 -40
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +19 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +50 -15
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/util/bounded-file.d.ts.map +1 -1
- package/dist/core/util/bounded-file.js.map +1 -1
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -1
- package/dist/core/util/bounded-jsonl.js +2 -9
- package/dist/core/util/bounded-jsonl.js.map +1 -1
- package/dist/core/util/bounded-value.d.ts.map +1 -1
- package/dist/core/util/bounded-value.js.map +1 -1
- package/dist/core/util/json-size.d.ts +3 -0
- package/dist/core/util/json-size.d.ts.map +1 -0
- package/dist/core/util/json-size.js +95 -0
- package/dist/core/util/json-size.js.map +1 -0
- package/dist/core/util/minimatch-cache.d.ts.map +1 -1
- package/dist/core/util/minimatch-cache.js.map +1 -1
- package/dist/core/util/value-guards.d.ts.map +1 -1
- package/dist/core/util/value-guards.js.map +1 -1
- package/dist/core/worktree-sync/codes.d.ts.map +1 -1
- package/dist/core/worktree-sync/git-engine.d.ts.map +1 -1
- package/dist/core/worktree-sync/git-engine.js +20 -36
- package/dist/core/worktree-sync/git-engine.js.map +1 -1
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
- package/dist/core/worktree-sync/lane-gate.js +1 -4
- package/dist/core/worktree-sync/lane-gate.js.map +1 -1
- package/dist/core/worktree-sync/runtime.d.ts.map +1 -1
- package/dist/core/worktree-sync/runtime.js.map +1 -1
- package/dist/core/worktree-sync/store.d.ts.map +1 -1
- package/dist/core/worktree-sync/store.js.map +1 -1
- package/dist/core/worktree-sync/watcher.d.ts.map +1 -1
- package/dist/core/worktree-sync/watcher.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +10 -32
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +6 -19
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +3 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +96 -132
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +1 -31
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +86 -307
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/autocomplete-provider.d.ts.map +1 -1
- package/dist/modes/interactive/autocomplete-provider.js.map +1 -1
- package/dist/modes/interactive/autonomy-commands.d.ts.map +1 -1
- package/dist/modes/interactive/autonomy-commands.js +2 -8
- package/dist/modes/interactive/autonomy-commands.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +5 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +17 -0
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/compaction-queue.d.ts.map +1 -1
- package/dist/modes/interactive/compaction-queue.js +13 -18
- package/dist/modes/interactive/compaction-queue.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
- package/dist/modes/interactive/components/activity-lane.js +6 -10
- package/dist/modes/interactive/components/activity-lane.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts +1 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js +10 -21
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +1 -6
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +4 -9
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +0 -3
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +3 -8
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +13 -35
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +3 -8
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +14 -36
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +20 -43
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +0 -5
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +4 -8
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -6
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +6 -8
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +0 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/expandable-markdown-message.d.ts +21 -0
- package/dist/modes/interactive/components/expandable-markdown-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-markdown-message.js +48 -0
- package/dist/modes/interactive/components/expandable-markdown-message.js.map +1 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/expandable-text.js +0 -2
- package/dist/modes/interactive/components/expandable-text.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +1 -9
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +2 -8
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +5 -20
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.js +0 -1
- package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -5
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +4 -10
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +21 -44
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/model-suggestion-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-suggestion-selector.js +0 -1
- package/dist/modes/interactive/components/model-suggestion-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +16 -32
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.d.ts +3 -4
- package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.js +34 -93
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
- package/dist/modes/interactive/components/profile-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-selector.js +0 -1
- package/dist/modes/interactive/components/profile-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +3 -4
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +34 -79
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/selector-list.d.ts +63 -0
- package/dist/modes/interactive/components/selector-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/selector-list.js +186 -0
- package/dist/modes/interactive/components/selector-list.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +34 -59
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +40 -138
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts +2 -4
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +9 -28
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +3 -8
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +12 -40
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts +2 -5
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +11 -37
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +2 -4
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +9 -31
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -28
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +2 -3
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/tool-panel-registry.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-panel-registry.js +5 -3
- package/dist/modes/interactive/components/tool-panel-registry.js.map +1 -1
- package/dist/modes/interactive/components/tool-title.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-title.js +0 -4
- package/dist/modes/interactive/components/tool-title.js.map +1 -1
- package/dist/modes/interactive/components/transcript-pager.d.ts +26 -0
- package/dist/modes/interactive/components/transcript-pager.d.ts.map +1 -0
- package/dist/modes/interactive/components/transcript-pager.js +81 -0
- package/dist/modes/interactive/components/transcript-pager.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -12
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +42 -402
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +4 -16
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.js +2 -10
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +3 -6
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +0 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/editor-overlay-host.d.ts.map +1 -1
- package/dist/modes/interactive/editor-overlay-host.js +0 -3
- package/dist/modes/interactive/editor-overlay-host.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +2 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +51 -72
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -15
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.js +23 -16
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +13 -4
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +126 -207
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-selection-prompts.d.ts +20 -0
- package/dist/modes/interactive/interactive-selection-prompts.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-selection-prompts.js +43 -0
- package/dist/modes/interactive/interactive-selection-prompts.js.map +1 -0
- package/dist/modes/interactive/key-handlers.d.ts +2 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +4 -2
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +4 -9
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/model-fitness-presentation.d.ts +21 -0
- package/dist/modes/interactive/model-fitness-presentation.d.ts.map +1 -0
- package/dist/modes/interactive/model-fitness-presentation.js +13 -0
- package/dist/modes/interactive/model-fitness-presentation.js.map +1 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts +2 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +79 -171
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts +2 -0
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +12 -6
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +6 -23
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +21 -25
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
- package/dist/modes/interactive/signal-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/signal-lifecycle.js.map +1 -1
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +12 -8
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +10 -76
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -1
- package/dist/modes/interactive/usage-commands.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +5 -22
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +1 -1
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -8
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +5 -20
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/termination-signals.d.ts +4 -0
- package/dist/modes/termination-signals.d.ts.map +1 -0
- package/dist/modes/termination-signals.js +21 -0
- package/dist/modes/termination-signals.js.map +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi-colors.d.ts +5 -0
- package/dist/utils/ansi-colors.d.ts.map +1 -0
- package/dist/utils/ansi-colors.js +38 -0
- package/dist/utils/ansi-colors.js.map +1 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/deprecation.d.ts.map +1 -1
- package/dist/utils/deprecation.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/external-editor-command.d.ts.map +1 -1
- package/dist/utils/external-editor-command.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +20 -28
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/highlight-js-languages.d.ts.map +1 -1
- package/dist/utils/html.d.ts.map +1 -1
- package/dist/utils/html.js.map +1 -1
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.d.ts.map +1 -1
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/json.d.ts.map +1 -1
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/process-memory.d.ts.map +1 -1
- package/dist/utils/process-memory.js.map +1 -1
- package/dist/utils/safe-write-stream.d.ts.map +1 -1
- package/dist/utils/safe-write-stream.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/sleep.d.ts.map +1 -1
- package/dist/utils/sleep.js +2 -15
- package/dist/utils/sleep.js.map +1 -1
- package/dist/utils/stdin-events.d.ts +8 -0
- package/dist/utils/stdin-events.d.ts.map +1 -0
- package/dist/utils/stdin-events.js +19 -0
- package/dist/utils/stdin-events.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +20 -13
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +6 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +59 -2
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/windows-self-update.d.ts.map +1 -1
- package/dist/utils/windows-self-update.js.map +1 -1
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/compaction.md +11 -3
- package/docs/development.md +1 -1
- package/docs/sessions.md +6 -0
- package/docs/settings.md +1 -1
- package/docs/windows.md +28 -3
- package/docs/work-directory.md +10 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +27 -27
- package/package.json +11 -11
- package/dist/utils/streaming-lines.d.ts +0 -20
- package/dist/utils/streaming-lines.d.ts.map +0 -1
- package/dist/utils/streaming-lines.js +0 -79
- package/dist/utils/streaming-lines.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-store.js","sourceRoot":"","sources":["../../../src/core/orchestration/event-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAEN,oBAAoB,EACpB,4BAA4B,GAE5B,MAAM,gBAAgB,CAAC;AAExB,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAC9C,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AACjD,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,sBAAsB,G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AAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAC/B,MAAM,IAAI,4BAA4B,CAAC,2CAA2C,IAAI,EAAE,CAAC,CAAC;YAC3F,CAAC;YACD,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;gBAC1B,IAAI,CAAC,8BAA8B,CAClC,KAAK,CAAC,cAAc,EACpB,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,CAC9D,CAAC;YACH,CAAC;QACF,CAAC;QACD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;YAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAChE,IAAI,OAAO,IAAI,eAAe;gBAAE,OAAO,KAAK,CAAC;YAC7C,IAAI,CAAC;gBACJ,OAAO,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1D,CAAC;YAAC,MAAM,CAAC;gBACR,OAAO,KAAK,CAAC;YACd,CAAC;QAAA,CACD,EAAE,CAAC,CAAC,CAAC;QACN,mBAAmB,CAClB,IAAI,CAAC,UAAU,EACf,gBAAgB,CACf,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAwB,EACrE,gBAAgB,EAChB,sBAAsB,CACtB,CACD,CAAC;QACF,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAAA,CAC3C;CACD","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { existsSync, statSync, unlinkSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { orchestrationEventStoreDir } from \"../agent-paths.ts\";\nimport type { JsonObject } from \"../autonomy/contracts.ts\";\nimport { withFileLockSync, writeFileAtomicSync } from \"../util/atomic-file.ts\";\nimport { readBoundedDirectoryNamesSync, readBoundedTextFileSync } from \"../util/bounded-file.ts\";\nimport {\n\ttype AppendOrchestrationEventInput,\n\tisOrchestrationEvent,\n\tORCHESTRATION_SCHEMA_VERSION,\n\ttype OrchestrationEvent,\n} from \"./contracts.ts\";\n\nconst EVENT_FILE_PATTERN = /^(\\d{16})\\.json$/;\nconst SNAPSHOT_FILE_PATTERN = /^(\\d{16})\\.json$/;\nconst DEFAULT_MAX_TAIL_EVENTS = 256;\nconst DEFAULT_MAX_TAIL_BYTES = 4 * 1024 * 1024;\nconst DEFAULT_MAX_IDEMPOTENCY_EVENTS = 512;\nconst MAX_CONFIGURED_TAIL_EVENTS = 1_024;\nconst MAX_CONFIGURED_TAIL_BYTES = 16 * 1024 * 1024;\nconst MAX_CONFIGURED_IDEMPOTENCY_EVENTS = 1_024;\nconst MAX_EVENT_DIRECTORY_ENTRIES = 2_048;\nconst MAX_IDEMPOTENCY_DIRECTORY_ENTRIES = 2_048;\nconst MAX_SNAPSHOT_DIRECTORY_ENTRIES = 8;\nconst MAX_CURSOR_BYTES = 64 * 1024;\nconst MAX_BASELINE_BYTES = 64 * 1024;\nconst MAX_IDEMPOTENCY_MARKER_BYTES = 64 * 1024;\n/** Full current task state plus retained idempotency evidence; intentionally above the 16MiB tail cap. */\nconst MAX_PROJECTION_SNAPSHOT_BYTES = 32 * 1024 * 1024;\n\ninterface EventCursor {\n\tversion: 1;\n\tlastOrdinal: number;\n\ttailBytes?: number;\n}\n\ninterface SynchronizedIndexes {\n\tlastOrdinal: number;\n\ttailBytes: number;\n}\n\ninterface IdempotencyMarker {\n\tversion: 1;\n\tkey: string;\n\tordinal: number;\n}\n\ninterface ProjectionSnapshotContent {\n\tversion: 1;\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tthroughOrdinal: number;\n\tcreatedAt: string;\n\tprojection: JsonObject;\n\tidempotencyEvents: OrchestrationEvent[];\n}\n\ninterface ProjectionSnapshot extends ProjectionSnapshotContent {\n\tdigest: string;\n}\n\ninterface SnapshotBaseline {\n\tversion: 1;\n\tthroughOrdinal: number;\n\tdigest: string;\n\tsnapshotFile: string;\n}\n\ninterface SnapshotFileSignature {\n\tsize: number;\n\tmtimeMs: number;\n\tctimeMs: number;\n}\n\ninterface VerifiedSnapshotBaseline {\n\tbaseline: SnapshotBaseline;\n\tsignature: SnapshotFileSignature;\n}\n\nexport interface OrchestrationEventStoreOptions {\n\tagentDir: string;\n\tsessionId: string;\n\tnow?: () => string;\n\tcreateEventId?: () => string;\n\tmaxTailEvents?: number;\n\tmaxTailBytes?: number;\n\tmaxIdempotencyEvents?: number;\n}\n\nexport class OrchestrationEventStoreError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"OrchestrationEventStoreError\";\n\t}\n}\n\nexport class OrchestrationConcurrencyError extends OrchestrationEventStoreError {\n\tconstructor(expected: number, actual: number) {\n\t\tsuper(`Orchestration event cursor changed: expected ${expected}, actual ${actual}.`);\n\t\tthis.name = \"OrchestrationConcurrencyError\";\n\t}\n}\n\nexport class OrchestrationSnapshotRequiredError extends OrchestrationEventStoreError {\n\treadonly throughOrdinal: number;\n\n\tconstructor(throughOrdinal: number) {\n\t\tsuper(`Orchestration projection snapshot through ordinal ${throughOrdinal} is required.`);\n\t\tthis.name = \"OrchestrationSnapshotRequiredError\";\n\t\tthis.throughOrdinal = throughOrdinal;\n\t}\n}\n\nfunction parseCursor(filePath: string): EventCursor | undefined {\n\tif (!existsSync(filePath)) return undefined;\n\tlet content: string;\n\ttry {\n\t\tcontent = readBoundedTextFileSync(filePath, MAX_CURSOR_BYTES, \"Orchestration cursor\");\n\t} catch (error) {\n\t\tthrow new OrchestrationEventStoreError(\n\t\t\t`Failed to read orchestration cursor: ${error instanceof Error ? error.message : String(error)}`,\n\t\t);\n\t}\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(content);\n\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) return undefined;\n\t\tconst record = parsed as Record<string, unknown>;\n\t\tif (record.version !== 1 || !Number.isSafeInteger(record.lastOrdinal) || Number(record.lastOrdinal) < 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (record.tailBytes !== undefined && (!Number.isSafeInteger(record.tailBytes) || Number(record.tailBytes) < 0)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn {\n\t\t\tversion: 1,\n\t\t\tlastOrdinal: Number(record.lastOrdinal),\n\t\t\t...(record.tailBytes !== undefined ? { tailBytes: Number(record.tailBytes) } : {}),\n\t\t};\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction serialize(value: unknown): string {\n\treturn `${JSON.stringify(value, null, \"\\t\")}\\n`;\n}\n\nfunction serializeBounded(\n\tvalue: unknown,\n\tmaxBytes: number,\n\tlabel: string,\n\toversizedMessage = `${label} exceeds its byte limit.`,\n): string {\n\tconst serialized = serialize(value);\n\tif (Buffer.byteLength(serialized, \"utf-8\") > maxBytes) {\n\t\tthrow new OrchestrationEventStoreError(oversizedMessage);\n\t}\n\treturn serialized;\n}\n\nfunction eventFileName(ordinal: number): string {\n\treturn `${String(ordinal).padStart(16, \"0\")}.json`;\n}\n\nfunction snapshotDigest(content: ProjectionSnapshotContent): string {\n\treturn createHash(\"sha256\").update(JSON.stringify(content)).digest(\"hex\");\n}\n\nfunction positiveSafeInteger(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst resolved = value ?? fallback;\n\tif (!Number.isSafeInteger(resolved) || resolved < 1) {\n\t\tthrow new OrchestrationEventStoreError(`${label} must be a positive safe integer.`);\n\t}\n\tif (resolved > maximum) throw new OrchestrationEventStoreError(`${label} must not exceed ${maximum}.`);\n\treturn resolved;\n}\n\n/**\n * Append-only event tail with a replaceable full-state projection snapshot. Atomic rename prevents\n * torn records. Snapshot publication is two-phase (payload, then small baseline pointer), after which\n * covered event/idempotency files are pruned. A crash at any point leaves either the old replay prefix\n * or the new verified snapshot authoritative; ordinals never reset.\n */\nexport class OrchestrationEventStore {\n\treadonly rootDir: string;\n\treadonly eventsDir: string;\n\treadonly idempotencyDir: string;\n\treadonly cursorPath: string;\n\treadonly snapshotsDir: string;\n\treadonly baselinePath: string;\n\tprivate readonly now: () => string;\n\tprivate readonly createEventId: () => string;\n\tprivate readonly maxTailEvents: number;\n\tprivate readonly maxTailBytes: number;\n\tprivate readonly maxIdempotencyEvents: number;\n\tprivate readonly listeners = new Set<(event: OrchestrationEvent) => void>();\n\tprivate verifiedSnapshotBaseline: VerifiedSnapshotBaseline | undefined;\n\n\tconstructor(options: OrchestrationEventStoreOptions) {\n\t\tthis.rootDir = orchestrationEventStoreDir(options.agentDir, options.sessionId);\n\t\tthis.eventsDir = join(this.rootDir, \"events\");\n\t\tthis.idempotencyDir = join(this.rootDir, \"idempotency\");\n\t\tthis.cursorPath = join(this.rootDir, \"cursor.json\");\n\t\tthis.snapshotsDir = join(this.rootDir, \"snapshots\");\n\t\tthis.baselinePath = join(this.rootDir, \"projection-baseline.json\");\n\t\tthis.now = options.now ?? (() => new Date().toISOString());\n\t\tthis.createEventId = options.createEventId ?? randomUUID;\n\t\tthis.maxTailEvents = positiveSafeInteger(\n\t\t\toptions.maxTailEvents,\n\t\t\tDEFAULT_MAX_TAIL_EVENTS,\n\t\t\tMAX_CONFIGURED_TAIL_EVENTS,\n\t\t\t\"maxTailEvents\",\n\t\t);\n\t\tthis.maxTailBytes = positiveSafeInteger(\n\t\t\toptions.maxTailBytes,\n\t\t\tDEFAULT_MAX_TAIL_BYTES,\n\t\t\tMAX_CONFIGURED_TAIL_BYTES,\n\t\t\t\"maxTailBytes\",\n\t\t);\n\t\tthis.maxIdempotencyEvents = positiveSafeInteger(\n\t\t\toptions.maxIdempotencyEvents,\n\t\t\tDEFAULT_MAX_IDEMPOTENCY_EVENTS,\n\t\t\tMAX_CONFIGURED_IDEMPOTENCY_EVENTS,\n\t\t\t\"maxIdempotencyEvents\",\n\t\t);\n\t}\n\n\tappend(input: AppendOrchestrationEventInput, options: { expectedLastOrdinal?: number } = {}): OrchestrationEvent {\n\t\tconst committed = withFileLockSync(this.cursorPath, (): { event: OrchestrationEvent; appended: boolean } => {\n\t\t\tconst cursor = this.synchronizeIndexesUnlocked();\n\t\t\tconst actual = cursor.lastOrdinal;\n\t\t\tif (input.idempotencyKey) {\n\t\t\t\tconst existing = this.readIdempotentEventUnlocked(input.idempotencyKey);\n\t\t\t\tif (existing) return { event: existing, appended: false };\n\t\t\t}\n\t\t\tif (options.expectedLastOrdinal !== undefined) {\n\t\t\t\tif (actual !== options.expectedLastOrdinal) {\n\t\t\t\t\tthrow new OrchestrationConcurrencyError(options.expectedLastOrdinal, actual);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst ordinal = actual + 1;\n\t\t\tconst next: OrchestrationEvent = {\n\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\tordinal,\n\t\t\t\teventId: this.createEventId(),\n\t\t\t\ttype: input.type,\n\t\t\t\taggregateId: input.aggregateId,\n\t\t\t\tactor: input.actor,\n\t\t\t\toccurredAt: this.now(),\n\t\t\t\t...(input.correlationId ? { correlationId: input.correlationId } : {}),\n\t\t\t\t...(input.causationId ? { causationId: input.causationId } : {}),\n\t\t\t\t...(input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : {}),\n\t\t\t\tpayload: structuredClone(input.payload),\n\t\t\t};\n\t\t\tconst serializedEvent = serializeBounded(\n\t\t\t\tnext,\n\t\t\t\tthis.maxTailBytes,\n\t\t\t\t\"Orchestration event\",\n\t\t\t\t\"Orchestration event exceeds its configured tail byte limit.\",\n\t\t\t);\n\t\t\tconst serializedMarker = input.idempotencyKey\n\t\t\t\t? this.serializeIdempotencyMarker(input.idempotencyKey, ordinal)\n\t\t\t\t: undefined;\n\t\t\tconst serializedCursor = serializeBounded(\n\t\t\t\t{\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tlastOrdinal: ordinal,\n\t\t\t\t\ttailBytes: cursor.tailBytes + Buffer.byteLength(serializedEvent),\n\t\t\t\t} satisfies EventCursor,\n\t\t\t\tMAX_CURSOR_BYTES,\n\t\t\t\t\"Orchestration cursor\",\n\t\t\t);\n\t\t\twriteFileAtomicSync(join(this.eventsDir, eventFileName(ordinal)), serializedEvent);\n\t\t\tif (input.idempotencyKey && serializedMarker) {\n\t\t\t\tthis.writeIdempotencyMarkerUnlocked(input.idempotencyKey, serializedMarker);\n\t\t\t}\n\t\t\twriteFileAtomicSync(this.cursorPath, serializedCursor);\n\t\t\treturn { event: next, appended: true };\n\t\t});\n\n\t\tif (committed.appended) {\n\t\t\tfor (const listener of this.listeners) listener(structuredClone(committed.event));\n\t\t}\n\t\treturn structuredClone(committed.event);\n\t}\n\n\treadAll(): OrchestrationEvent[] {\n\t\treturn this.readAllUnlocked();\n\t}\n\n\treadAfter(ordinal: number): OrchestrationEvent[] {\n\t\tconst baseline = this.readBaselineUnlocked();\n\t\tif (baseline && ordinal < baseline.throughOrdinal) {\n\t\t\tthrow new OrchestrationSnapshotRequiredError(baseline.throughOrdinal);\n\t\t}\n\t\tconst events: OrchestrationEvent[] = [];\n\t\tconst names = this.eventFileNamesUnlocked();\n\t\tthis.assertReadableTailUnlocked(names, baseline?.throughOrdinal ?? 0);\n\t\tlet previousOrdinal = ordinal;\n\t\tfor (const name of names) {\n\t\t\tconst match = EVENT_FILE_PATTERN.exec(name);\n\t\t\tif (!match) continue;\n\t\t\tconst fileOrdinal = Number(match[1]);\n\t\t\tif (fileOrdinal <= ordinal) continue;\n\t\t\tconst event = this.readEventFileUnlocked(name);\n\t\t\tif (event.ordinal !== fileOrdinal || event.ordinal <= previousOrdinal) {\n\t\t\t\tthrow new OrchestrationEventStoreError(`Non-monotonic orchestration event ordinal in ${name}`);\n\t\t\t}\n\t\t\tpreviousOrdinal = event.ordinal;\n\t\t\tevents.push(structuredClone(event));\n\t\t}\n\t\treturn events;\n\t}\n\n\treadProjectionSnapshot(): { throughOrdinal: number; projection: JsonObject } | undefined {\n\t\tconst snapshot = this.readProjectionSnapshotUnlocked();\n\t\treturn snapshot\n\t\t\t? { throughOrdinal: snapshot.throughOrdinal, projection: structuredClone(snapshot.projection) }\n\t\t\t: undefined;\n\t}\n\n\t/** Replace a large replay prefix with one verified current-state snapshot and a bounded tail. */\n\tcompactIfNeeded(throughOrdinal: number, projection: () => JsonObject): boolean {\n\t\tconst baselineBeforeLock = this.readBaselineUnlocked()?.throughOrdinal ?? 0;\n\t\tconst cursorBeforeLock = parseCursor(this.cursorPath);\n\t\tif (\n\t\t\tcursorBeforeLock?.lastOrdinal === throughOrdinal &&\n\t\t\tcursorBeforeLock.tailBytes !== undefined &&\n\t\t\tthroughOrdinal - baselineBeforeLock < this.maxTailEvents &&\n\t\t\tcursorBeforeLock.tailBytes < this.maxTailBytes\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn withFileLockSync(this.cursorPath, () => {\n\t\t\tconst cursor = this.synchronizeIndexesUnlocked();\n\t\t\tif (cursor.lastOrdinal !== throughOrdinal) return false;\n\t\t\tconst baselineOrdinal = this.readBaselineUnlocked()?.throughOrdinal ?? 0;\n\t\t\tconst tailNames = this.eventFileNamesUnlocked().filter(\n\t\t\t\t(name) => Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0) > baselineOrdinal,\n\t\t\t);\n\t\t\tif (tailNames.length < this.maxTailEvents && cursor.tailBytes < this.maxTailBytes) return false;\n\n\t\t\tconst retainedByKey = new Map<string, OrchestrationEvent>();\n\t\t\tfor (const event of this.readProjectionSnapshotUnlocked()?.idempotencyEvents ?? []) {\n\t\t\t\tif (event.idempotencyKey) retainedByKey.set(event.idempotencyKey, event);\n\t\t\t}\n\t\t\tfor (const name of tailNames) {\n\t\t\t\tconst event = this.readEventFileUnlocked(name);\n\t\t\t\tif (event.ordinal <= throughOrdinal && event.idempotencyKey) {\n\t\t\t\t\tretainedByKey.set(event.idempotencyKey, event);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst idempotencyEvents = [...retainedByKey.values()]\n\t\t\t\t.sort((left, right) => left.ordinal - right.ordinal)\n\t\t\t\t.slice(-this.maxIdempotencyEvents)\n\t\t\t\t.map((event) => structuredClone(event));\n\t\t\tconst content: ProjectionSnapshotContent = {\n\t\t\t\tversion: 1,\n\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\tthroughOrdinal,\n\t\t\t\tcreatedAt: this.now(),\n\t\t\t\tprojection: structuredClone(projection()),\n\t\t\t\tidempotencyEvents,\n\t\t\t};\n\t\t\tconst digest = snapshotDigest(content);\n\t\t\tconst snapshotFile = eventFileName(throughOrdinal);\n\t\t\tconst serializedSnapshot = serializeBounded(\n\t\t\t\t{ ...content, digest } satisfies ProjectionSnapshot,\n\t\t\t\tMAX_PROJECTION_SNAPSHOT_BYTES,\n\t\t\t\t\"Orchestration projection snapshot\",\n\t\t\t);\n\t\t\tconst serializedBaseline = serializeBounded(\n\t\t\t\t{ version: 1, throughOrdinal, digest, snapshotFile } satisfies SnapshotBaseline,\n\t\t\t\tMAX_BASELINE_BYTES,\n\t\t\t\t\"Orchestration snapshot baseline\",\n\t\t\t);\n\t\t\tconst serializedCursor = serializeBounded(\n\t\t\t\t{ version: 1, lastOrdinal: throughOrdinal, tailBytes: 0 } satisfies EventCursor,\n\t\t\t\tMAX_CURSOR_BYTES,\n\t\t\t\t\"Orchestration cursor\",\n\t\t\t);\n\t\t\twriteFileAtomicSync(join(this.snapshotsDir, snapshotFile), serializedSnapshot);\n\t\t\twriteFileAtomicSync(this.baselinePath, serializedBaseline);\n\n\t\t\tfor (const name of this.idempotencyFileNamesUnlocked()) {\n\t\t\t\tthis.unlinkManagedFile(join(this.idempotencyDir, name));\n\t\t\t}\n\t\t\tfor (const name of this.eventFileNamesUnlocked()) {\n\t\t\t\tconst ordinal = Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0);\n\t\t\t\tif (ordinal <= throughOrdinal) this.unlinkManagedFile(join(this.eventsDir, name));\n\t\t\t}\n\t\t\tfor (const name of this.snapshotFileNamesUnlocked()) {\n\t\t\t\tif (name !== snapshotFile) this.unlinkManagedFile(join(this.snapshotsDir, name));\n\t\t\t}\n\t\t\twriteFileAtomicSync(this.cursorPath, serializedCursor);\n\t\t\treturn true;\n\t\t});\n\t}\n\n\tsubscribe(listener: (event: OrchestrationEvent) => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => this.listeners.delete(listener);\n\t}\n\n\tprivate readAllUnlocked(): OrchestrationEvent[] {\n\t\tconst names = this.eventFileNamesUnlocked();\n\t\tconst events: OrchestrationEvent[] = [];\n\t\tconst baselineOrdinal = this.readProjectionSnapshotUnlocked()?.throughOrdinal ?? 0;\n\t\tthis.assertReadableTailUnlocked(names, baselineOrdinal);\n\t\tlet previousOrdinal = baselineOrdinal;\n\t\tfor (const name of names) {\n\t\t\tconst match = EVENT_FILE_PATTERN.exec(name);\n\t\t\tif (!match) continue;\n\t\t\tconst fileOrdinal = Number(match[1]);\n\t\t\tif (fileOrdinal <= baselineOrdinal) continue;\n\t\t\tconst parsed = this.readEventFileUnlocked(name);\n\t\t\tif (parsed.ordinal !== fileOrdinal || parsed.ordinal <= previousOrdinal) {\n\t\t\t\tthrow new OrchestrationEventStoreError(`Non-monotonic orchestration event ordinal in ${name}`);\n\t\t\t}\n\t\t\tpreviousOrdinal = parsed.ordinal;\n\t\t\tevents.push(structuredClone(parsed));\n\t\t}\n\t\treturn events;\n\t}\n\n\tprivate eventFileNamesUnlocked(): string[] {\n\t\ttry {\n\t\t\treturn readBoundedDirectoryNamesSync(\n\t\t\t\tthis.eventsDir,\n\t\t\t\tMAX_EVENT_DIRECTORY_ENTRIES,\n\t\t\t\t\"Orchestration events directory\",\n\t\t\t)\n\t\t\t\t.filter((candidate) => EVENT_FILE_PATTERN.test(candidate))\n\t\t\t\t.sort();\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate idempotencyFileNamesUnlocked(): string[] {\n\t\ttry {\n\t\t\treturn readBoundedDirectoryNamesSync(\n\t\t\t\tthis.idempotencyDir,\n\t\t\t\tMAX_IDEMPOTENCY_DIRECTORY_ENTRIES,\n\t\t\t\t\"Orchestration idempotency directory\",\n\t\t\t).filter((candidate) => candidate.endsWith(\".json\"));\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate snapshotFileNamesUnlocked(): string[] {\n\t\ttry {\n\t\t\treturn readBoundedDirectoryNamesSync(\n\t\t\t\tthis.snapshotsDir,\n\t\t\t\tMAX_SNAPSHOT_DIRECTORY_ENTRIES,\n\t\t\t\t\"Orchestration snapshots directory\",\n\t\t\t)\n\t\t\t\t.filter((candidate) => SNAPSHOT_FILE_PATTERN.test(candidate))\n\t\t\t\t.sort();\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Event files are a contiguous append-only tail after the published snapshot. */\n\tprivate assertContiguousTailOrdinalsUnlocked(names: readonly string[], baselineOrdinal: number): void {\n\t\tlet expectedOrdinal = baselineOrdinal + 1;\n\t\tfor (const name of names) {\n\t\t\tconst ordinal = Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0);\n\t\t\t// A crash after publishing the baseline but before pruning is safe: the snapshot covers these files.\n\t\t\tif (ordinal <= baselineOrdinal) continue;\n\t\t\tif (ordinal !== expectedOrdinal) {\n\t\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t\t`Missing orchestration event ordinal ${expectedOrdinal} before ${name}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\texpectedOrdinal++;\n\t\t}\n\t}\n\n\t/** A valid cursor may lag a newly published snapshot, but it must never lead its committed tail. */\n\tprivate assertReadableTailUnlocked(names: readonly string[], baselineOrdinal: number): void {\n\t\tthis.assertContiguousTailOrdinalsUnlocked(names, baselineOrdinal);\n\t\tconst highestEventOrdinal = names.length > 0 ? Number(EVENT_FILE_PATTERN.exec(names.at(-1)!)?.[1] ?? 0) : 0;\n\t\tconst highestCommittedOrdinal = Math.max(baselineOrdinal, highestEventOrdinal);\n\t\tconst cursor = parseCursor(this.cursorPath);\n\t\tif (cursor && cursor.lastOrdinal > highestCommittedOrdinal) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Orchestration cursor ${cursor.lastOrdinal} is ahead of the last committed event ${highestCommittedOrdinal}.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate readBaselineUnlocked(): SnapshotBaseline | undefined {\n\t\tif (!existsSync(this.baselinePath)) return undefined;\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(\n\t\t\t\treadBoundedTextFileSync(this.baselinePath, MAX_BASELINE_BYTES, \"Orchestration snapshot baseline\"),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Failed to parse orchestration snapshot baseline: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration snapshot baseline.\");\n\t\t}\n\t\tconst baseline = parsed as Record<string, unknown>;\n\t\tif (\n\t\t\tbaseline.version !== 1 ||\n\t\t\t!Number.isSafeInteger(baseline.throughOrdinal) ||\n\t\t\tNumber(baseline.throughOrdinal) < 1 ||\n\t\t\ttypeof baseline.digest !== \"string\" ||\n\t\t\tbaseline.digest.length === 0 ||\n\t\t\ttypeof baseline.snapshotFile !== \"string\" ||\n\t\t\t!SNAPSHOT_FILE_PATTERN.test(baseline.snapshotFile) ||\n\t\t\tNumber(SNAPSHOT_FILE_PATTERN.exec(baseline.snapshotFile)?.[1] ?? 0) !== Number(baseline.throughOrdinal)\n\t\t) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration snapshot baseline.\");\n\t\t}\n\t\treturn {\n\t\t\tversion: 1,\n\t\t\tthroughOrdinal: Number(baseline.throughOrdinal),\n\t\t\tdigest: baseline.digest,\n\t\t\tsnapshotFile: baseline.snapshotFile,\n\t\t};\n\t}\n\n\tprivate readProjectionSnapshotUnlocked(): ProjectionSnapshot | undefined {\n\t\tconst baseline = this.readBaselineUnlocked();\n\t\tif (!baseline) return undefined;\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(\n\t\t\t\treadBoundedTextFileSync(\n\t\t\t\t\tjoin(this.snapshotsDir, baseline.snapshotFile),\n\t\t\t\t\tMAX_PROJECTION_SNAPSHOT_BYTES,\n\t\t\t\t\t\"Orchestration projection snapshot\",\n\t\t\t\t),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Failed to parse orchestration projection snapshot: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration projection snapshot.\");\n\t\t}\n\t\tconst snapshot = parsed as Record<string, unknown>;\n\t\tif (\n\t\t\tsnapshot.version !== 1 ||\n\t\t\tsnapshot.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION ||\n\t\t\tsnapshot.throughOrdinal !== baseline.throughOrdinal ||\n\t\t\ttypeof snapshot.createdAt !== \"string\" ||\n\t\t\t!snapshot.projection ||\n\t\t\ttypeof snapshot.projection !== \"object\" ||\n\t\t\tArray.isArray(snapshot.projection) ||\n\t\t\t!Array.isArray(snapshot.idempotencyEvents) ||\n\t\t\tsnapshot.idempotencyEvents.length > this.maxIdempotencyEvents ||\n\t\t\t!snapshot.idempotencyEvents.every(isOrchestrationEvent) ||\n\t\t\t!snapshot.idempotencyEvents.every(\n\t\t\t\t(event) => event.ordinal <= baseline.throughOrdinal && event.idempotencyKey !== undefined,\n\t\t\t) ||\n\t\t\tnew Set(snapshot.idempotencyEvents.map((event) => event.idempotencyKey)).size !==\n\t\t\t\tsnapshot.idempotencyEvents.length ||\n\t\t\ttypeof snapshot.digest !== \"string\" ||\n\t\t\tsnapshot.digest !== baseline.digest\n\t\t) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration projection snapshot.\");\n\t\t}\n\t\tconst content: ProjectionSnapshotContent = {\n\t\t\tversion: 1,\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\tthroughOrdinal: baseline.throughOrdinal,\n\t\t\tcreatedAt: snapshot.createdAt,\n\t\t\tprojection: structuredClone(snapshot.projection) as JsonObject,\n\t\t\tidempotencyEvents: snapshot.idempotencyEvents.map((event) => structuredClone(event)),\n\t\t};\n\t\tif (snapshotDigest(content) !== baseline.digest) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Orchestration projection snapshot digest mismatch.\");\n\t\t}\n\t\treturn { ...content, digest: baseline.digest };\n\t}\n\n\t/**\n\t * Appends need a verified snapshot baseline but must not deserialize its projection on every event.\n\t * The baseline pointer remains small and is reread each time; an immutable snapshot is reparsed only\n\t * when its pointer or filesystem identity changes.\n\t */\n\tprivate readVerifiedSnapshotBaselineUnlocked(): SnapshotBaseline | undefined {\n\t\tconst baseline = this.readBaselineUnlocked();\n\t\tif (!baseline) {\n\t\t\tthis.verifiedSnapshotBaseline = undefined;\n\t\t\treturn undefined;\n\t\t}\n\t\tconst signature = this.snapshotFileSignatureUnlocked(baseline);\n\t\tconst cached = this.verifiedSnapshotBaseline;\n\t\tif (\n\t\t\tcached &&\n\t\t\tcached.baseline.throughOrdinal === baseline.throughOrdinal &&\n\t\t\tcached.baseline.digest === baseline.digest &&\n\t\t\tcached.baseline.snapshotFile === baseline.snapshotFile &&\n\t\t\tcached.signature.size === signature.size &&\n\t\t\tcached.signature.mtimeMs === signature.mtimeMs &&\n\t\t\tcached.signature.ctimeMs === signature.ctimeMs\n\t\t) {\n\t\t\treturn baseline;\n\t\t}\n\t\tthis.readProjectionSnapshotUnlocked();\n\t\tconst verifiedSignature = this.snapshotFileSignatureUnlocked(baseline);\n\t\tif (\n\t\t\tverifiedSignature.size !== signature.size ||\n\t\t\tverifiedSignature.mtimeMs !== signature.mtimeMs ||\n\t\t\tverifiedSignature.ctimeMs !== signature.ctimeMs\n\t\t) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Orchestration projection snapshot changed while being verified.\");\n\t\t}\n\t\tthis.verifiedSnapshotBaseline = { baseline, signature };\n\t\treturn baseline;\n\t}\n\n\tprivate snapshotFileSignatureUnlocked(baseline: SnapshotBaseline): SnapshotFileSignature {\n\t\ttry {\n\t\t\tconst stats = statSync(join(this.snapshotsDir, baseline.snapshotFile));\n\t\t\tif (!stats.isFile())\n\t\t\t\tthrow new OrchestrationEventStoreError(\"Orchestration projection snapshot is not a file.\");\n\t\t\treturn { size: stats.size, mtimeMs: stats.mtimeMs, ctimeMs: stats.ctimeMs };\n\t\t} catch (error) {\n\t\t\tif (error instanceof OrchestrationEventStoreError) throw error;\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Failed to parse orchestration projection snapshot: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate unlinkManagedFile(filePath: string): void {\n\t\ttry {\n\t\t\tunlinkSync(filePath);\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n\t\t}\n\t}\n\n\tprivate readEventFileUnlocked(name: string): OrchestrationEvent {\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(\n\t\t\t\treadBoundedTextFileSync(join(this.eventsDir, name), this.maxTailBytes, `Orchestration event ${name}`),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Failed to parse orchestration event ${name}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (!isOrchestrationEvent(parsed)) {\n\t\t\tthrow new OrchestrationEventStoreError(`Invalid orchestration event record: ${name}`);\n\t\t}\n\t\treturn parsed;\n\t}\n\n\tprivate idempotencyPath(key: string): string {\n\t\treturn join(this.idempotencyDir, `${createHash(\"sha256\").update(key).digest(\"hex\")}.json`);\n\t}\n\n\tprivate serializeIdempotencyMarker(key: string, ordinal: number): string {\n\t\treturn serializeBounded(\n\t\t\t{ version: 1, key, ordinal } satisfies IdempotencyMarker,\n\t\t\tMAX_IDEMPOTENCY_MARKER_BYTES,\n\t\t\t\"Orchestration idempotency marker\",\n\t\t);\n\t}\n\n\tprivate writeIdempotencyMarkerUnlocked(key: string, serializedMarker: string): void {\n\t\twriteFileAtomicSync(this.idempotencyPath(key), serializedMarker);\n\t}\n\n\tprivate readIdempotentEventUnlocked(key: string): OrchestrationEvent | undefined {\n\t\tconst markerPath = this.idempotencyPath(key);\n\t\tif (!existsSync(markerPath)) {\n\t\t\treturn this.readProjectionSnapshotUnlocked()?.idempotencyEvents.find((event) => event.idempotencyKey === key);\n\t\t}\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(\n\t\t\t\treadBoundedTextFileSync(markerPath, MAX_IDEMPOTENCY_MARKER_BYTES, \"Orchestration idempotency marker\"),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Failed to parse orchestration idempotency marker: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration idempotency marker.\");\n\t\t}\n\t\tconst marker = parsed as Record<string, unknown>;\n\t\tif (\n\t\t\tmarker.version !== 1 ||\n\t\t\tmarker.key !== key ||\n\t\t\t!Number.isSafeInteger(marker.ordinal) ||\n\t\t\tNumber(marker.ordinal) < 1\n\t\t) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration idempotency marker.\");\n\t\t}\n\t\tconst ordinal = Number(marker.ordinal);\n\t\tif (!existsSync(join(this.eventsDir, eventFileName(ordinal)))) {\n\t\t\tconst retained = this.readProjectionSnapshotUnlocked()?.idempotencyEvents.find(\n\t\t\t\t(event) => event.idempotencyKey === key && event.ordinal === ordinal,\n\t\t\t);\n\t\t\tif (retained) return retained;\n\t\t}\n\t\tconst event = this.readEventFileUnlocked(eventFileName(ordinal));\n\t\tif (event.ordinal !== ordinal || event.idempotencyKey !== key) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Orchestration idempotency marker does not match its event.\");\n\t\t}\n\t\treturn event;\n\t}\n\n\t/**\n\t * Reconcile only the crash tail when an event rename committed before its marker/cursor. Normal\n\t * appends read directory metadata plus one marker, never the accumulated event payload prefix.\n\t */\n\tprivate synchronizeIndexesUnlocked(): SynchronizedIndexes {\n\t\tconst names = this.eventFileNamesUnlocked();\n\t\tconst baselineOrdinal = this.readVerifiedSnapshotBaselineUnlocked()?.throughOrdinal ?? 0;\n\t\tthis.assertReadableTailUnlocked(names, baselineOrdinal);\n\t\tconst highestEventOrdinal = names.length > 0 ? Number(EVENT_FILE_PATTERN.exec(names.at(-1)!)?.[1] ?? 0) : 0;\n\t\tconst highest = Math.max(baselineOrdinal, highestEventOrdinal);\n\t\tconst cursor = parseCursor(this.cursorPath);\n\t\tif (\n\t\t\tcursor?.lastOrdinal === highest &&\n\t\t\tcursor.tailBytes !== undefined &&\n\t\t\t(highest > baselineOrdinal || cursor.tailBytes === 0)\n\t\t) {\n\t\t\treturn { lastOrdinal: highest, tailBytes: cursor.tailBytes };\n\t\t}\n\t\tif (cursor && cursor.lastOrdinal > highest) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Orchestration cursor ${cursor.lastOrdinal} is ahead of the last committed event ${highest}.`,\n\t\t\t);\n\t\t}\n\t\tconst rebuildFrom = Math.max(\n\t\t\tbaselineOrdinal + 1,\n\t\t\tcursor && cursor.lastOrdinal >= baselineOrdinal && cursor.lastOrdinal <= highest\n\t\t\t\t? cursor.lastOrdinal + 1\n\t\t\t\t: baselineOrdinal + 1,\n\t\t);\n\t\tfor (const name of names) {\n\t\t\tconst ordinal = Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0);\n\t\t\tif (ordinal < rebuildFrom || ordinal <= baselineOrdinal) continue;\n\t\t\tconst event = this.readEventFileUnlocked(name);\n\t\t\tif (event.ordinal !== ordinal) {\n\t\t\t\tthrow new OrchestrationEventStoreError(`Event ordinal does not match file name: ${name}`);\n\t\t\t}\n\t\t\tif (event.idempotencyKey) {\n\t\t\t\tthis.writeIdempotencyMarkerUnlocked(\n\t\t\t\t\tevent.idempotencyKey,\n\t\t\t\t\tthis.serializeIdempotencyMarker(event.idempotencyKey, ordinal),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconst tailBytes = names.reduce((total, name) => {\n\t\t\tconst ordinal = Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0);\n\t\t\tif (ordinal <= baselineOrdinal) return total;\n\t\t\ttry {\n\t\t\t\treturn total + statSync(join(this.eventsDir, name)).size;\n\t\t\t} catch {\n\t\t\t\treturn total;\n\t\t\t}\n\t\t}, 0);\n\t\twriteFileAtomicSync(\n\t\t\tthis.cursorPath,\n\t\t\tserializeBounded(\n\t\t\t\t{ version: 1, lastOrdinal: highest, tailBytes } satisfies EventCursor,\n\t\t\t\tMAX_CURSOR_BYTES,\n\t\t\t\t\"Orchestration cursor\",\n\t\t\t),\n\t\t);\n\t\treturn { lastOrdinal: highest, tailBytes };\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"event-store.js","sourceRoot":"","sources":["../../../src/core/orchestration/event-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,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AC/C,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAC/B,MAAM,IAAI,4BAA4B,CAAC,2CAA2C,IAAI,EAAE,CAAC,CAAC;YAC3F,CAAC;YACD,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;gBAC1B,IAAI,CAAC,8BAA8B,CAClC,KAAK,CAAC,cAAc,EACpB,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,CAC9D,CAAC;YACH,CAAC;QACF,CAAC;QACD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAC9C,MAAM,OAAO,GAAG,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAChE,IAAI,OAAO,IAAI,eAAe;gBAAE,OAAO,KAAK,CAAC;YAC7C,IAAI,CAAC;gBACJ,OAAO,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1D,CAAC;YAAC,MAAM,CAAC;gBACR,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC,EAAE,CAAC,CAAC,CAAC;QACN,mBAAmB,CAClB,IAAI,CAAC,UAAU,EACf,gBAAgB,CACf,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAwB,EACrE,gBAAgB,EAChB,sBAAsB,CACtB,CACD,CAAC;QACF,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC5C,CAAC;CACD","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport { existsSync, statSync, unlinkSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { orchestrationEventStoreDir } from \"../agent-paths.ts\";\nimport type { JsonObject } from \"../autonomy/contracts.ts\";\nimport { withFileLockSync, writeFileAtomicSync } from \"../util/atomic-file.ts\";\nimport { readBoundedDirectoryNamesSync, readBoundedTextFileSync } from \"../util/bounded-file.ts\";\nimport {\n\ttype AppendOrchestrationEventInput,\n\tisOrchestrationEvent,\n\tORCHESTRATION_SCHEMA_VERSION,\n\ttype OrchestrationEvent,\n} from \"./contracts.ts\";\n\nconst EVENT_FILE_PATTERN = /^(\\d{16})\\.json$/;\nconst SNAPSHOT_FILE_PATTERN = /^(\\d{16})\\.json$/;\nconst DEFAULT_MAX_TAIL_EVENTS = 256;\nconst DEFAULT_MAX_TAIL_BYTES = 4 * 1024 * 1024;\nconst DEFAULT_MAX_IDEMPOTENCY_EVENTS = 512;\nconst MAX_CONFIGURED_TAIL_EVENTS = 1_024;\nconst MAX_CONFIGURED_TAIL_BYTES = 16 * 1024 * 1024;\nconst MAX_CONFIGURED_IDEMPOTENCY_EVENTS = 1_024;\nconst MAX_EVENT_DIRECTORY_ENTRIES = 2_048;\nconst MAX_IDEMPOTENCY_DIRECTORY_ENTRIES = 2_048;\nconst MAX_SNAPSHOT_DIRECTORY_ENTRIES = 8;\nconst MAX_CURSOR_BYTES = 64 * 1024;\nconst MAX_BASELINE_BYTES = 64 * 1024;\nconst MAX_IDEMPOTENCY_MARKER_BYTES = 64 * 1024;\n/** Full current task state plus retained idempotency evidence; intentionally above the 16MiB tail cap. */\nconst MAX_PROJECTION_SNAPSHOT_BYTES = 32 * 1024 * 1024;\n\ninterface EventCursor {\n\tversion: 1;\n\tlastOrdinal: number;\n\ttailBytes?: number;\n}\n\ninterface SynchronizedIndexes {\n\tlastOrdinal: number;\n\ttailBytes: number;\n}\n\ninterface IdempotencyMarker {\n\tversion: 1;\n\tkey: string;\n\tordinal: number;\n}\n\ninterface ProjectionSnapshotContent {\n\tversion: 1;\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tthroughOrdinal: number;\n\tcreatedAt: string;\n\tprojection: JsonObject;\n\tidempotencyEvents: OrchestrationEvent[];\n}\n\ninterface ProjectionSnapshot extends ProjectionSnapshotContent {\n\tdigest: string;\n}\n\ninterface SnapshotBaseline {\n\tversion: 1;\n\tthroughOrdinal: number;\n\tdigest: string;\n\tsnapshotFile: string;\n}\n\ninterface SnapshotFileSignature {\n\tsize: number;\n\tmtimeMs: number;\n\tctimeMs: number;\n}\n\ninterface VerifiedSnapshotBaseline {\n\tbaseline: SnapshotBaseline;\n\tsignature: SnapshotFileSignature;\n}\n\nexport interface OrchestrationEventStoreOptions {\n\tagentDir: string;\n\tsessionId: string;\n\tnow?: () => string;\n\tcreateEventId?: () => string;\n\tmaxTailEvents?: number;\n\tmaxTailBytes?: number;\n\tmaxIdempotencyEvents?: number;\n}\n\nexport class OrchestrationEventStoreError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"OrchestrationEventStoreError\";\n\t}\n}\n\nexport class OrchestrationConcurrencyError extends OrchestrationEventStoreError {\n\tconstructor(expected: number, actual: number) {\n\t\tsuper(`Orchestration event cursor changed: expected ${expected}, actual ${actual}.`);\n\t\tthis.name = \"OrchestrationConcurrencyError\";\n\t}\n}\n\nexport class OrchestrationSnapshotRequiredError extends OrchestrationEventStoreError {\n\treadonly throughOrdinal: number;\n\n\tconstructor(throughOrdinal: number) {\n\t\tsuper(`Orchestration projection snapshot through ordinal ${throughOrdinal} is required.`);\n\t\tthis.name = \"OrchestrationSnapshotRequiredError\";\n\t\tthis.throughOrdinal = throughOrdinal;\n\t}\n}\n\nfunction parseCursor(filePath: string): EventCursor | undefined {\n\tif (!existsSync(filePath)) return undefined;\n\tlet content: string;\n\ttry {\n\t\tcontent = readBoundedTextFileSync(filePath, MAX_CURSOR_BYTES, \"Orchestration cursor\");\n\t} catch (error) {\n\t\tthrow new OrchestrationEventStoreError(\n\t\t\t`Failed to read orchestration cursor: ${error instanceof Error ? error.message : String(error)}`,\n\t\t);\n\t}\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(content);\n\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) return undefined;\n\t\tconst record = parsed as Record<string, unknown>;\n\t\tif (record.version !== 1 || !Number.isSafeInteger(record.lastOrdinal) || Number(record.lastOrdinal) < 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (record.tailBytes !== undefined && (!Number.isSafeInteger(record.tailBytes) || Number(record.tailBytes) < 0)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn {\n\t\t\tversion: 1,\n\t\t\tlastOrdinal: Number(record.lastOrdinal),\n\t\t\t...(record.tailBytes !== undefined ? { tailBytes: Number(record.tailBytes) } : {}),\n\t\t};\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction serialize(value: unknown): string {\n\treturn `${JSON.stringify(value, null, \"\\t\")}\\n`;\n}\n\nfunction serializeBounded(\n\tvalue: unknown,\n\tmaxBytes: number,\n\tlabel: string,\n\toversizedMessage = `${label} exceeds its byte limit.`,\n): string {\n\tconst serialized = serialize(value);\n\tif (Buffer.byteLength(serialized, \"utf-8\") > maxBytes) {\n\t\tthrow new OrchestrationEventStoreError(oversizedMessage);\n\t}\n\treturn serialized;\n}\n\nfunction eventFileName(ordinal: number): string {\n\treturn `${String(ordinal).padStart(16, \"0\")}.json`;\n}\n\nfunction snapshotDigest(content: ProjectionSnapshotContent): string {\n\treturn createHash(\"sha256\").update(JSON.stringify(content)).digest(\"hex\");\n}\n\nfunction positiveSafeInteger(value: number | undefined, fallback: number, maximum: number, label: string): number {\n\tconst resolved = value ?? fallback;\n\tif (!Number.isSafeInteger(resolved) || resolved < 1) {\n\t\tthrow new OrchestrationEventStoreError(`${label} must be a positive safe integer.`);\n\t}\n\tif (resolved > maximum) throw new OrchestrationEventStoreError(`${label} must not exceed ${maximum}.`);\n\treturn resolved;\n}\n\n/**\n * Append-only event tail with a replaceable full-state projection snapshot. Atomic rename prevents\n * torn records. Snapshot publication is two-phase (payload, then small baseline pointer), after which\n * covered event/idempotency files are pruned. A crash at any point leaves either the old replay prefix\n * or the new verified snapshot authoritative; ordinals never reset.\n */\nexport class OrchestrationEventStore {\n\treadonly rootDir: string;\n\treadonly eventsDir: string;\n\treadonly idempotencyDir: string;\n\treadonly cursorPath: string;\n\treadonly snapshotsDir: string;\n\treadonly baselinePath: string;\n\tprivate readonly now: () => string;\n\tprivate readonly createEventId: () => string;\n\tprivate readonly maxTailEvents: number;\n\tprivate readonly maxTailBytes: number;\n\tprivate readonly maxIdempotencyEvents: number;\n\tprivate readonly listeners = new Set<(event: OrchestrationEvent) => void>();\n\tprivate verifiedSnapshotBaseline: VerifiedSnapshotBaseline | undefined;\n\n\tconstructor(options: OrchestrationEventStoreOptions) {\n\t\tthis.rootDir = orchestrationEventStoreDir(options.agentDir, options.sessionId);\n\t\tthis.eventsDir = join(this.rootDir, \"events\");\n\t\tthis.idempotencyDir = join(this.rootDir, \"idempotency\");\n\t\tthis.cursorPath = join(this.rootDir, \"cursor.json\");\n\t\tthis.snapshotsDir = join(this.rootDir, \"snapshots\");\n\t\tthis.baselinePath = join(this.rootDir, \"projection-baseline.json\");\n\t\tthis.now = options.now ?? (() => new Date().toISOString());\n\t\tthis.createEventId = options.createEventId ?? randomUUID;\n\t\tthis.maxTailEvents = positiveSafeInteger(\n\t\t\toptions.maxTailEvents,\n\t\t\tDEFAULT_MAX_TAIL_EVENTS,\n\t\t\tMAX_CONFIGURED_TAIL_EVENTS,\n\t\t\t\"maxTailEvents\",\n\t\t);\n\t\tthis.maxTailBytes = positiveSafeInteger(\n\t\t\toptions.maxTailBytes,\n\t\t\tDEFAULT_MAX_TAIL_BYTES,\n\t\t\tMAX_CONFIGURED_TAIL_BYTES,\n\t\t\t\"maxTailBytes\",\n\t\t);\n\t\tthis.maxIdempotencyEvents = positiveSafeInteger(\n\t\t\toptions.maxIdempotencyEvents,\n\t\t\tDEFAULT_MAX_IDEMPOTENCY_EVENTS,\n\t\t\tMAX_CONFIGURED_IDEMPOTENCY_EVENTS,\n\t\t\t\"maxIdempotencyEvents\",\n\t\t);\n\t}\n\n\tappend(input: AppendOrchestrationEventInput, options: { expectedLastOrdinal?: number } = {}): OrchestrationEvent {\n\t\tconst committed = withFileLockSync(this.cursorPath, (): { event: OrchestrationEvent; appended: boolean } => {\n\t\t\tconst cursor = this.synchronizeIndexesUnlocked();\n\t\t\tconst actual = cursor.lastOrdinal;\n\t\t\tif (input.idempotencyKey) {\n\t\t\t\tconst existing = this.readIdempotentEventUnlocked(input.idempotencyKey);\n\t\t\t\tif (existing) return { event: existing, appended: false };\n\t\t\t}\n\t\t\tif (options.expectedLastOrdinal !== undefined) {\n\t\t\t\tif (actual !== options.expectedLastOrdinal) {\n\t\t\t\t\tthrow new OrchestrationConcurrencyError(options.expectedLastOrdinal, actual);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst ordinal = actual + 1;\n\t\t\tconst next: OrchestrationEvent = {\n\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\tordinal,\n\t\t\t\teventId: this.createEventId(),\n\t\t\t\ttype: input.type,\n\t\t\t\taggregateId: input.aggregateId,\n\t\t\t\tactor: input.actor,\n\t\t\t\toccurredAt: this.now(),\n\t\t\t\t...(input.correlationId ? { correlationId: input.correlationId } : {}),\n\t\t\t\t...(input.causationId ? { causationId: input.causationId } : {}),\n\t\t\t\t...(input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : {}),\n\t\t\t\tpayload: structuredClone(input.payload),\n\t\t\t};\n\t\t\tconst serializedEvent = serializeBounded(\n\t\t\t\tnext,\n\t\t\t\tthis.maxTailBytes,\n\t\t\t\t\"Orchestration event\",\n\t\t\t\t\"Orchestration event exceeds its configured tail byte limit.\",\n\t\t\t);\n\t\t\tconst serializedMarker = input.idempotencyKey\n\t\t\t\t? this.serializeIdempotencyMarker(input.idempotencyKey, ordinal)\n\t\t\t\t: undefined;\n\t\t\tconst serializedCursor = serializeBounded(\n\t\t\t\t{\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tlastOrdinal: ordinal,\n\t\t\t\t\ttailBytes: cursor.tailBytes + Buffer.byteLength(serializedEvent),\n\t\t\t\t} satisfies EventCursor,\n\t\t\t\tMAX_CURSOR_BYTES,\n\t\t\t\t\"Orchestration cursor\",\n\t\t\t);\n\t\t\twriteFileAtomicSync(join(this.eventsDir, eventFileName(ordinal)), serializedEvent);\n\t\t\tif (input.idempotencyKey && serializedMarker) {\n\t\t\t\tthis.writeIdempotencyMarkerUnlocked(input.idempotencyKey, serializedMarker);\n\t\t\t}\n\t\t\twriteFileAtomicSync(this.cursorPath, serializedCursor);\n\t\t\treturn { event: next, appended: true };\n\t\t});\n\n\t\tif (committed.appended) {\n\t\t\tfor (const listener of this.listeners) listener(structuredClone(committed.event));\n\t\t}\n\t\treturn structuredClone(committed.event);\n\t}\n\n\treadAll(): OrchestrationEvent[] {\n\t\treturn this.readAllUnlocked();\n\t}\n\n\treadAfter(ordinal: number): OrchestrationEvent[] {\n\t\tconst baseline = this.readBaselineUnlocked();\n\t\tif (baseline && ordinal < baseline.throughOrdinal) {\n\t\t\tthrow new OrchestrationSnapshotRequiredError(baseline.throughOrdinal);\n\t\t}\n\t\tconst events: OrchestrationEvent[] = [];\n\t\tconst names = this.eventFileNamesUnlocked();\n\t\tthis.assertReadableTailUnlocked(names, baseline?.throughOrdinal ?? 0);\n\t\tlet previousOrdinal = ordinal;\n\t\tfor (const name of names) {\n\t\t\tconst match = EVENT_FILE_PATTERN.exec(name);\n\t\t\tif (!match) continue;\n\t\t\tconst fileOrdinal = Number(match[1]);\n\t\t\tif (fileOrdinal <= ordinal) continue;\n\t\t\tconst event = this.readEventFileUnlocked(name);\n\t\t\tif (event.ordinal !== fileOrdinal || event.ordinal <= previousOrdinal) {\n\t\t\t\tthrow new OrchestrationEventStoreError(`Non-monotonic orchestration event ordinal in ${name}`);\n\t\t\t}\n\t\t\tpreviousOrdinal = event.ordinal;\n\t\t\tevents.push(structuredClone(event));\n\t\t}\n\t\treturn events;\n\t}\n\n\treadProjectionSnapshot(): { throughOrdinal: number; projection: JsonObject } | undefined {\n\t\tconst snapshot = this.readProjectionSnapshotUnlocked();\n\t\treturn snapshot\n\t\t\t? { throughOrdinal: snapshot.throughOrdinal, projection: structuredClone(snapshot.projection) }\n\t\t\t: undefined;\n\t}\n\n\t/** Replace a large replay prefix with one verified current-state snapshot and a bounded tail. */\n\tcompactIfNeeded(throughOrdinal: number, projection: () => JsonObject): boolean {\n\t\tconst baselineBeforeLock = this.readBaselineUnlocked()?.throughOrdinal ?? 0;\n\t\tconst cursorBeforeLock = parseCursor(this.cursorPath);\n\t\tif (\n\t\t\tcursorBeforeLock?.lastOrdinal === throughOrdinal &&\n\t\t\tcursorBeforeLock.tailBytes !== undefined &&\n\t\t\tthroughOrdinal - baselineBeforeLock < this.maxTailEvents &&\n\t\t\tcursorBeforeLock.tailBytes < this.maxTailBytes\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn withFileLockSync(this.cursorPath, () => {\n\t\t\tconst cursor = this.synchronizeIndexesUnlocked();\n\t\t\tif (cursor.lastOrdinal !== throughOrdinal) return false;\n\t\t\tconst baselineOrdinal = this.readBaselineUnlocked()?.throughOrdinal ?? 0;\n\t\t\tconst tailNames = this.eventFileNamesUnlocked().filter(\n\t\t\t\t(name) => Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0) > baselineOrdinal,\n\t\t\t);\n\t\t\tif (tailNames.length < this.maxTailEvents && cursor.tailBytes < this.maxTailBytes) return false;\n\n\t\t\tconst retainedByKey = new Map<string, OrchestrationEvent>();\n\t\t\tfor (const event of this.readProjectionSnapshotUnlocked()?.idempotencyEvents ?? []) {\n\t\t\t\tif (event.idempotencyKey) retainedByKey.set(event.idempotencyKey, event);\n\t\t\t}\n\t\t\tfor (const name of tailNames) {\n\t\t\t\tconst event = this.readEventFileUnlocked(name);\n\t\t\t\tif (event.ordinal <= throughOrdinal && event.idempotencyKey) {\n\t\t\t\t\tretainedByKey.set(event.idempotencyKey, event);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst idempotencyEvents = [...retainedByKey.values()]\n\t\t\t\t.sort((left, right) => left.ordinal - right.ordinal)\n\t\t\t\t.slice(-this.maxIdempotencyEvents)\n\t\t\t\t.map((event) => structuredClone(event));\n\t\t\tconst content: ProjectionSnapshotContent = {\n\t\t\t\tversion: 1,\n\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\tthroughOrdinal,\n\t\t\t\tcreatedAt: this.now(),\n\t\t\t\tprojection: structuredClone(projection()),\n\t\t\t\tidempotencyEvents,\n\t\t\t};\n\t\t\tconst digest = snapshotDigest(content);\n\t\t\tconst snapshotFile = eventFileName(throughOrdinal);\n\t\t\tconst serializedSnapshot = serializeBounded(\n\t\t\t\t{ ...content, digest } satisfies ProjectionSnapshot,\n\t\t\t\tMAX_PROJECTION_SNAPSHOT_BYTES,\n\t\t\t\t\"Orchestration projection snapshot\",\n\t\t\t);\n\t\t\tconst serializedBaseline = serializeBounded(\n\t\t\t\t{ version: 1, throughOrdinal, digest, snapshotFile } satisfies SnapshotBaseline,\n\t\t\t\tMAX_BASELINE_BYTES,\n\t\t\t\t\"Orchestration snapshot baseline\",\n\t\t\t);\n\t\t\tconst serializedCursor = serializeBounded(\n\t\t\t\t{ version: 1, lastOrdinal: throughOrdinal, tailBytes: 0 } satisfies EventCursor,\n\t\t\t\tMAX_CURSOR_BYTES,\n\t\t\t\t\"Orchestration cursor\",\n\t\t\t);\n\t\t\twriteFileAtomicSync(join(this.snapshotsDir, snapshotFile), serializedSnapshot);\n\t\t\twriteFileAtomicSync(this.baselinePath, serializedBaseline);\n\n\t\t\tfor (const name of this.idempotencyFileNamesUnlocked()) {\n\t\t\t\tthis.unlinkManagedFile(join(this.idempotencyDir, name));\n\t\t\t}\n\t\t\tfor (const name of this.eventFileNamesUnlocked()) {\n\t\t\t\tconst ordinal = Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0);\n\t\t\t\tif (ordinal <= throughOrdinal) this.unlinkManagedFile(join(this.eventsDir, name));\n\t\t\t}\n\t\t\tfor (const name of this.snapshotFileNamesUnlocked()) {\n\t\t\t\tif (name !== snapshotFile) this.unlinkManagedFile(join(this.snapshotsDir, name));\n\t\t\t}\n\t\t\twriteFileAtomicSync(this.cursorPath, serializedCursor);\n\t\t\treturn true;\n\t\t});\n\t}\n\n\tsubscribe(listener: (event: OrchestrationEvent) => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => this.listeners.delete(listener);\n\t}\n\n\tprivate readAllUnlocked(): OrchestrationEvent[] {\n\t\tconst names = this.eventFileNamesUnlocked();\n\t\tconst events: OrchestrationEvent[] = [];\n\t\tconst baselineOrdinal = this.readProjectionSnapshotUnlocked()?.throughOrdinal ?? 0;\n\t\tthis.assertReadableTailUnlocked(names, baselineOrdinal);\n\t\tlet previousOrdinal = baselineOrdinal;\n\t\tfor (const name of names) {\n\t\t\tconst match = EVENT_FILE_PATTERN.exec(name);\n\t\t\tif (!match) continue;\n\t\t\tconst fileOrdinal = Number(match[1]);\n\t\t\tif (fileOrdinal <= baselineOrdinal) continue;\n\t\t\tconst parsed = this.readEventFileUnlocked(name);\n\t\t\tif (parsed.ordinal !== fileOrdinal || parsed.ordinal <= previousOrdinal) {\n\t\t\t\tthrow new OrchestrationEventStoreError(`Non-monotonic orchestration event ordinal in ${name}`);\n\t\t\t}\n\t\t\tpreviousOrdinal = parsed.ordinal;\n\t\t\tevents.push(structuredClone(parsed));\n\t\t}\n\t\treturn events;\n\t}\n\n\tprivate eventFileNamesUnlocked(): string[] {\n\t\ttry {\n\t\t\treturn readBoundedDirectoryNamesSync(\n\t\t\t\tthis.eventsDir,\n\t\t\t\tMAX_EVENT_DIRECTORY_ENTRIES,\n\t\t\t\t\"Orchestration events directory\",\n\t\t\t)\n\t\t\t\t.filter((candidate) => EVENT_FILE_PATTERN.test(candidate))\n\t\t\t\t.sort();\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate idempotencyFileNamesUnlocked(): string[] {\n\t\ttry {\n\t\t\treturn readBoundedDirectoryNamesSync(\n\t\t\t\tthis.idempotencyDir,\n\t\t\t\tMAX_IDEMPOTENCY_DIRECTORY_ENTRIES,\n\t\t\t\t\"Orchestration idempotency directory\",\n\t\t\t).filter((candidate) => candidate.endsWith(\".json\"));\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate snapshotFileNamesUnlocked(): string[] {\n\t\ttry {\n\t\t\treturn readBoundedDirectoryNamesSync(\n\t\t\t\tthis.snapshotsDir,\n\t\t\t\tMAX_SNAPSHOT_DIRECTORY_ENTRIES,\n\t\t\t\t\"Orchestration snapshots directory\",\n\t\t\t)\n\t\t\t\t.filter((candidate) => SNAPSHOT_FILE_PATTERN.test(candidate))\n\t\t\t\t.sort();\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/** Event files are a contiguous append-only tail after the published snapshot. */\n\tprivate assertContiguousTailOrdinalsUnlocked(names: readonly string[], baselineOrdinal: number): void {\n\t\tlet expectedOrdinal = baselineOrdinal + 1;\n\t\tfor (const name of names) {\n\t\t\tconst ordinal = Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0);\n\t\t\t// A crash after publishing the baseline but before pruning is safe: the snapshot covers these files.\n\t\t\tif (ordinal <= baselineOrdinal) continue;\n\t\t\tif (ordinal !== expectedOrdinal) {\n\t\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t\t`Missing orchestration event ordinal ${expectedOrdinal} before ${name}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\texpectedOrdinal++;\n\t\t}\n\t}\n\n\t/** A valid cursor may lag a newly published snapshot, but it must never lead its committed tail. */\n\tprivate assertReadableTailUnlocked(names: readonly string[], baselineOrdinal: number): void {\n\t\tthis.assertContiguousTailOrdinalsUnlocked(names, baselineOrdinal);\n\t\tconst highestEventOrdinal = names.length > 0 ? Number(EVENT_FILE_PATTERN.exec(names.at(-1)!)?.[1] ?? 0) : 0;\n\t\tconst highestCommittedOrdinal = Math.max(baselineOrdinal, highestEventOrdinal);\n\t\tconst cursor = parseCursor(this.cursorPath);\n\t\tif (cursor && cursor.lastOrdinal > highestCommittedOrdinal) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Orchestration cursor ${cursor.lastOrdinal} is ahead of the last committed event ${highestCommittedOrdinal}.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate readBaselineUnlocked(): SnapshotBaseline | undefined {\n\t\tif (!existsSync(this.baselinePath)) return undefined;\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(\n\t\t\t\treadBoundedTextFileSync(this.baselinePath, MAX_BASELINE_BYTES, \"Orchestration snapshot baseline\"),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Failed to parse orchestration snapshot baseline: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration snapshot baseline.\");\n\t\t}\n\t\tconst baseline = parsed as Record<string, unknown>;\n\t\tif (\n\t\t\tbaseline.version !== 1 ||\n\t\t\t!Number.isSafeInteger(baseline.throughOrdinal) ||\n\t\t\tNumber(baseline.throughOrdinal) < 1 ||\n\t\t\ttypeof baseline.digest !== \"string\" ||\n\t\t\tbaseline.digest.length === 0 ||\n\t\t\ttypeof baseline.snapshotFile !== \"string\" ||\n\t\t\t!SNAPSHOT_FILE_PATTERN.test(baseline.snapshotFile) ||\n\t\t\tNumber(SNAPSHOT_FILE_PATTERN.exec(baseline.snapshotFile)?.[1] ?? 0) !== Number(baseline.throughOrdinal)\n\t\t) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration snapshot baseline.\");\n\t\t}\n\t\treturn {\n\t\t\tversion: 1,\n\t\t\tthroughOrdinal: Number(baseline.throughOrdinal),\n\t\t\tdigest: baseline.digest,\n\t\t\tsnapshotFile: baseline.snapshotFile,\n\t\t};\n\t}\n\n\tprivate readProjectionSnapshotUnlocked(): ProjectionSnapshot | undefined {\n\t\tconst baseline = this.readBaselineUnlocked();\n\t\tif (!baseline) return undefined;\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(\n\t\t\t\treadBoundedTextFileSync(\n\t\t\t\t\tjoin(this.snapshotsDir, baseline.snapshotFile),\n\t\t\t\t\tMAX_PROJECTION_SNAPSHOT_BYTES,\n\t\t\t\t\t\"Orchestration projection snapshot\",\n\t\t\t\t),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Failed to parse orchestration projection snapshot: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration projection snapshot.\");\n\t\t}\n\t\tconst snapshot = parsed as Record<string, unknown>;\n\t\tif (\n\t\t\tsnapshot.version !== 1 ||\n\t\t\tsnapshot.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION ||\n\t\t\tsnapshot.throughOrdinal !== baseline.throughOrdinal ||\n\t\t\ttypeof snapshot.createdAt !== \"string\" ||\n\t\t\t!snapshot.projection ||\n\t\t\ttypeof snapshot.projection !== \"object\" ||\n\t\t\tArray.isArray(snapshot.projection) ||\n\t\t\t!Array.isArray(snapshot.idempotencyEvents) ||\n\t\t\tsnapshot.idempotencyEvents.length > this.maxIdempotencyEvents ||\n\t\t\t!snapshot.idempotencyEvents.every(isOrchestrationEvent) ||\n\t\t\t!snapshot.idempotencyEvents.every(\n\t\t\t\t(event) => event.ordinal <= baseline.throughOrdinal && event.idempotencyKey !== undefined,\n\t\t\t) ||\n\t\t\tnew Set(snapshot.idempotencyEvents.map((event) => event.idempotencyKey)).size !==\n\t\t\t\tsnapshot.idempotencyEvents.length ||\n\t\t\ttypeof snapshot.digest !== \"string\" ||\n\t\t\tsnapshot.digest !== baseline.digest\n\t\t) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration projection snapshot.\");\n\t\t}\n\t\tconst content: ProjectionSnapshotContent = {\n\t\t\tversion: 1,\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\tthroughOrdinal: baseline.throughOrdinal,\n\t\t\tcreatedAt: snapshot.createdAt,\n\t\t\tprojection: structuredClone(snapshot.projection) as JsonObject,\n\t\t\tidempotencyEvents: snapshot.idempotencyEvents.map((event) => structuredClone(event)),\n\t\t};\n\t\tif (snapshotDigest(content) !== baseline.digest) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Orchestration projection snapshot digest mismatch.\");\n\t\t}\n\t\treturn { ...content, digest: baseline.digest };\n\t}\n\n\t/**\n\t * Appends need a verified snapshot baseline but must not deserialize its projection on every event.\n\t * The baseline pointer remains small and is reread each time; an immutable snapshot is reparsed only\n\t * when its pointer or filesystem identity changes.\n\t */\n\tprivate readVerifiedSnapshotBaselineUnlocked(): SnapshotBaseline | undefined {\n\t\tconst baseline = this.readBaselineUnlocked();\n\t\tif (!baseline) {\n\t\t\tthis.verifiedSnapshotBaseline = undefined;\n\t\t\treturn undefined;\n\t\t}\n\t\tconst signature = this.snapshotFileSignatureUnlocked(baseline);\n\t\tconst cached = this.verifiedSnapshotBaseline;\n\t\tif (\n\t\t\tcached &&\n\t\t\tcached.baseline.throughOrdinal === baseline.throughOrdinal &&\n\t\t\tcached.baseline.digest === baseline.digest &&\n\t\t\tcached.baseline.snapshotFile === baseline.snapshotFile &&\n\t\t\tcached.signature.size === signature.size &&\n\t\t\tcached.signature.mtimeMs === signature.mtimeMs &&\n\t\t\tcached.signature.ctimeMs === signature.ctimeMs\n\t\t) {\n\t\t\treturn baseline;\n\t\t}\n\t\tthis.readProjectionSnapshotUnlocked();\n\t\tconst verifiedSignature = this.snapshotFileSignatureUnlocked(baseline);\n\t\tif (\n\t\t\tverifiedSignature.size !== signature.size ||\n\t\t\tverifiedSignature.mtimeMs !== signature.mtimeMs ||\n\t\t\tverifiedSignature.ctimeMs !== signature.ctimeMs\n\t\t) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Orchestration projection snapshot changed while being verified.\");\n\t\t}\n\t\tthis.verifiedSnapshotBaseline = { baseline, signature };\n\t\treturn baseline;\n\t}\n\n\tprivate snapshotFileSignatureUnlocked(baseline: SnapshotBaseline): SnapshotFileSignature {\n\t\ttry {\n\t\t\tconst stats = statSync(join(this.snapshotsDir, baseline.snapshotFile));\n\t\t\tif (!stats.isFile())\n\t\t\t\tthrow new OrchestrationEventStoreError(\"Orchestration projection snapshot is not a file.\");\n\t\t\treturn { size: stats.size, mtimeMs: stats.mtimeMs, ctimeMs: stats.ctimeMs };\n\t\t} catch (error) {\n\t\t\tif (error instanceof OrchestrationEventStoreError) throw error;\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Failed to parse orchestration projection snapshot: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate unlinkManagedFile(filePath: string): void {\n\t\ttry {\n\t\t\tunlinkSync(filePath);\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n\t\t}\n\t}\n\n\tprivate readEventFileUnlocked(name: string): OrchestrationEvent {\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(\n\t\t\t\treadBoundedTextFileSync(join(this.eventsDir, name), this.maxTailBytes, `Orchestration event ${name}`),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Failed to parse orchestration event ${name}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (!isOrchestrationEvent(parsed)) {\n\t\t\tthrow new OrchestrationEventStoreError(`Invalid orchestration event record: ${name}`);\n\t\t}\n\t\treturn parsed;\n\t}\n\n\tprivate idempotencyPath(key: string): string {\n\t\treturn join(this.idempotencyDir, `${createHash(\"sha256\").update(key).digest(\"hex\")}.json`);\n\t}\n\n\tprivate serializeIdempotencyMarker(key: string, ordinal: number): string {\n\t\treturn serializeBounded(\n\t\t\t{ version: 1, key, ordinal } satisfies IdempotencyMarker,\n\t\t\tMAX_IDEMPOTENCY_MARKER_BYTES,\n\t\t\t\"Orchestration idempotency marker\",\n\t\t);\n\t}\n\n\tprivate writeIdempotencyMarkerUnlocked(key: string, serializedMarker: string): void {\n\t\twriteFileAtomicSync(this.idempotencyPath(key), serializedMarker);\n\t}\n\n\tprivate readIdempotentEventUnlocked(key: string): OrchestrationEvent | undefined {\n\t\tconst markerPath = this.idempotencyPath(key);\n\t\tif (!existsSync(markerPath)) {\n\t\t\treturn this.readProjectionSnapshotUnlocked()?.idempotencyEvents.find((event) => event.idempotencyKey === key);\n\t\t}\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(\n\t\t\t\treadBoundedTextFileSync(markerPath, MAX_IDEMPOTENCY_MARKER_BYTES, \"Orchestration idempotency marker\"),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Failed to parse orchestration idempotency marker: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration idempotency marker.\");\n\t\t}\n\t\tconst marker = parsed as Record<string, unknown>;\n\t\tif (\n\t\t\tmarker.version !== 1 ||\n\t\t\tmarker.key !== key ||\n\t\t\t!Number.isSafeInteger(marker.ordinal) ||\n\t\t\tNumber(marker.ordinal) < 1\n\t\t) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Invalid orchestration idempotency marker.\");\n\t\t}\n\t\tconst ordinal = Number(marker.ordinal);\n\t\tif (!existsSync(join(this.eventsDir, eventFileName(ordinal)))) {\n\t\t\tconst retained = this.readProjectionSnapshotUnlocked()?.idempotencyEvents.find(\n\t\t\t\t(event) => event.idempotencyKey === key && event.ordinal === ordinal,\n\t\t\t);\n\t\t\tif (retained) return retained;\n\t\t}\n\t\tconst event = this.readEventFileUnlocked(eventFileName(ordinal));\n\t\tif (event.ordinal !== ordinal || event.idempotencyKey !== key) {\n\t\t\tthrow new OrchestrationEventStoreError(\"Orchestration idempotency marker does not match its event.\");\n\t\t}\n\t\treturn event;\n\t}\n\n\t/**\n\t * Reconcile only the crash tail when an event rename committed before its marker/cursor. Normal\n\t * appends read directory metadata plus one marker, never the accumulated event payload prefix.\n\t */\n\tprivate synchronizeIndexesUnlocked(): SynchronizedIndexes {\n\t\tconst names = this.eventFileNamesUnlocked();\n\t\tconst baselineOrdinal = this.readVerifiedSnapshotBaselineUnlocked()?.throughOrdinal ?? 0;\n\t\tthis.assertReadableTailUnlocked(names, baselineOrdinal);\n\t\tconst highestEventOrdinal = names.length > 0 ? Number(EVENT_FILE_PATTERN.exec(names.at(-1)!)?.[1] ?? 0) : 0;\n\t\tconst highest = Math.max(baselineOrdinal, highestEventOrdinal);\n\t\tconst cursor = parseCursor(this.cursorPath);\n\t\tif (\n\t\t\tcursor?.lastOrdinal === highest &&\n\t\t\tcursor.tailBytes !== undefined &&\n\t\t\t(highest > baselineOrdinal || cursor.tailBytes === 0)\n\t\t) {\n\t\t\treturn { lastOrdinal: highest, tailBytes: cursor.tailBytes };\n\t\t}\n\t\tif (cursor && cursor.lastOrdinal > highest) {\n\t\t\tthrow new OrchestrationEventStoreError(\n\t\t\t\t`Orchestration cursor ${cursor.lastOrdinal} is ahead of the last committed event ${highest}.`,\n\t\t\t);\n\t\t}\n\t\tconst rebuildFrom = Math.max(\n\t\t\tbaselineOrdinal + 1,\n\t\t\tcursor && cursor.lastOrdinal >= baselineOrdinal && cursor.lastOrdinal <= highest\n\t\t\t\t? cursor.lastOrdinal + 1\n\t\t\t\t: baselineOrdinal + 1,\n\t\t);\n\t\tfor (const name of names) {\n\t\t\tconst ordinal = Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0);\n\t\t\tif (ordinal < rebuildFrom || ordinal <= baselineOrdinal) continue;\n\t\t\tconst event = this.readEventFileUnlocked(name);\n\t\t\tif (event.ordinal !== ordinal) {\n\t\t\t\tthrow new OrchestrationEventStoreError(`Event ordinal does not match file name: ${name}`);\n\t\t\t}\n\t\t\tif (event.idempotencyKey) {\n\t\t\t\tthis.writeIdempotencyMarkerUnlocked(\n\t\t\t\t\tevent.idempotencyKey,\n\t\t\t\t\tthis.serializeIdempotencyMarker(event.idempotencyKey, ordinal),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tconst tailBytes = names.reduce((total, name) => {\n\t\t\tconst ordinal = Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0);\n\t\t\tif (ordinal <= baselineOrdinal) return total;\n\t\t\ttry {\n\t\t\t\treturn total + statSync(join(this.eventsDir, name)).size;\n\t\t\t} catch {\n\t\t\t\treturn total;\n\t\t\t}\n\t\t}, 0);\n\t\twriteFileAtomicSync(\n\t\t\tthis.cursorPath,\n\t\t\tserializeBounded(\n\t\t\t\t{ version: 1, lastOrdinal: highest, tailBytes } satisfies EventCursor,\n\t\t\t\tMAX_CURSOR_BYTES,\n\t\t\t\t\"Orchestration cursor\",\n\t\t\t),\n\t\t);\n\t\treturn { lastOrdinal: highest, tailBytes };\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lane-tool-manifests.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/lane-tool-manifests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,eAAO,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"lane-tool-manifests.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/lane-tool-manifests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,eAAO,MAAM,0BAA0B,YACtC,MAAM,EACN,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,MAAM,EACN,QAAQ,EACR,aAAa,CACJ,CAAC;AACX,eAAO,MAAM,gCAAgC,kHAA0E,CAAC;AAExH;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,oBAAoB,EAC7B,gBAAgB,EAAE,SAAS,MAAM,EAAE,GACjC,sBAAsB,EAAE,CAkB1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lane-tool-manifests.js","sourceRoot":"","sources":["../../../src/core/orchestration/lane-tool-manifests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAGrG,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACzC,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,OAAO;IACP,MAAM;IACN,QAAQ;IACR,aAAa;CACJ,CAAC;AACX,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,GAAG,0BAA0B,EAAE,UAAU,EAAE,iBAAiB,CAAU,CAAC;AAExH;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACrC,OAA6B,EAC7B,gBAAmC
|
|
1
|
+
{"version":3,"file":"lane-tool-manifests.js","sourceRoot":"","sources":["../../../src/core/orchestration/lane-tool-manifests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAGrG,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACzC,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,OAAO;IACP,MAAM;IACN,QAAQ;IACR,aAAa;CACJ,CAAC;AACX,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,GAAG,0BAA0B,EAAE,UAAU,EAAE,iBAAiB,CAAU,CAAC;AAExH;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACrC,OAA6B,EAC7B,gBAAmC;IAEnC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC1C,MAAM,SAAS,GAA6B,EAAE,CAAC;IAE/C,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QAC1C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,SAAS;QACrC,MAAM,MAAM,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QACjD,MAAM,UAAU,GAAG,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnE,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM;YAAE,SAAS;QACrC,SAAS,CAAC,IAAI,CAAC;YACd,QAAQ;YACR,eAAe,EAAE,YAAY,QAAQ,KAAK;YAC1C,YAAY,EAAE,CAAC,UAAU,CAAC;YAC1B,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;YACrB,YAAY,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC;SAClC,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { getToolCapabilityPolicy, resolveProfileToolCapability } from \"../tool-capability-policy.ts\";\nimport type { OrchestrationProfile, ToolCapabilityManifest } from \"./contracts.ts\";\n\nexport const CLASSIFIED_LANE_TOOL_NAMES = [\n\t\"read\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"write\",\n\t\"edit\",\n\t\"memory\",\n\t\"run_process\",\n] as const;\nexport const ORCHESTRATION_PROFILE_TOOL_NAMES = [...CLASSIFIED_LANE_TOOL_NAMES, \"delegate\", \"delegate_status\"] as const;\n\n/**\n * Manifest-only lane catalogue. It contains no tool factories, so policy compilation can omit\n * denied tools before their executable implementations are constructed.\n */\nexport function buildLaneToolManifests(\n\tprofile: OrchestrationProfile,\n\tenabledToolNames: readonly string[],\n): ToolCapabilityManifest[] {\n\tconst enabled = new Set(enabledToolNames);\n\tconst manifests: ToolCapabilityManifest[] = [];\n\n\tfor (const toolName of profile.toolNames) {\n\t\tif (!enabled.has(toolName)) continue;\n\t\tconst policy = getToolCapabilityPolicy(toolName);\n\t\tconst capability = resolveProfileToolCapability(profile, toolName);\n\t\tif (!capability || !policy) continue;\n\t\tmanifests.push({\n\t\t\ttoolName,\n\t\t\tmoduleSpecifier: `../tools/${toolName}.ts`,\n\t\t\tcapabilities: [capability],\n\t\t\troles: [profile.role],\n\t\t\tenforcements: [policy.enforcement],\n\t\t});\n\t}\n\treturn manifests;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-binding.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/model-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAA8B,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtF,MAAM,WAAW,0BAA0B;IAC1C,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,OAAO,EAAE,yBAAyB,CAAC;CACnC;AAED,wBAAgB,+BAA+B,CAC9C,OAAO,EAAE,yBAAyB,EAClC,aAAa,EAAE,aAAa,EAC5B,aAAa,GAAE,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,OAAqB,GACzD,0BAA0B,GAAG,SAAS,CAWxC;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAClD,OAAO,EAAE,oBAAoB,EAC7B,aAAa,EAAE,aAAa,EAC5B,aAAa,GAAE,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,OAAqB,GACzD,0BAA0B,GAAG,SAAS,CAUxC"
|
|
1
|
+
{"version":3,"file":"model-binding.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/model-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAA8B,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtF,MAAM,WAAW,0BAA0B;IAC1C,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,OAAO,EAAE,yBAAyB,CAAC;CACnC;AAED,wBAAgB,+BAA+B,CAC9C,OAAO,EAAE,yBAAyB,EAClC,aAAa,EAAE,aAAa,EAC5B,aAAa,GAAE,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,OAAqB,GACzD,0BAA0B,GAAG,SAAS,CAWxC;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAClD,OAAO,EAAE,oBAAoB,EAC7B,aAAa,EAAE,aAAa,EAC5B,aAAa,GAAE,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,OAAqB,GACzD,0BAA0B,GAAG,SAAS,CAUxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-binding.js","sourceRoot":"","sources":["../../../src/core/orchestration/model-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,0BAA0B,EAAc,MAAM,mBAAmB,CAAC;AASrF,MAAM,UAAU,+BAA+B,CAC9C,OAAkC,EAClC,aAA4B,EAC5B,aAAa,GAAmC,GAAG,EAAE,CAAC,KAAK
|
|
1
|
+
{"version":3,"file":"model-binding.js","sourceRoot":"","sources":["../../../src/core/orchestration/model-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,0BAA0B,EAAc,MAAM,mBAAmB,CAAC;AASrF,MAAM,UAAU,+BAA+B,CAC9C,OAAkC,EAClC,aAA4B,EAC5B,aAAa,GAAmC,GAAG,EAAE,CAAC,KAAK;IAE3D,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACpE,IACC,CAAC,KAAK;QACN,CAAC,aAAa,CAAC,iBAAiB,CAAC,KAAK,CAAC;QACvC,aAAa,CAAC,KAAK,CAAC;QACpB,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,EACjE,CAAC;QACF,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CAClD,OAA6B,EAC7B,aAA4B,EAC5B,aAAa,GAAmC,GAAG,EAAE,CAAC,KAAK;IAE3D,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;QACtD,MAAM,QAAQ,GAAG,+BAA+B,CAAC,OAAO,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;QACxF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO;gBAAE,OAAO,SAAS,CAAC;YAC3D,SAAS;QACV,CAAC;QACD,OAAO,QAAQ,CAAC;IACjB,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { type Api, getSupportedThinkingLevels, type Model } from \"@caupulican/pi-ai\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { OrchestrationModelBinding, OrchestrationProfile } from \"./contracts.ts\";\n\nexport interface ResolvedOrchestrationModel {\n\tmodel: Model<Api>;\n\tbinding: OrchestrationModelBinding;\n}\n\nexport function resolvePinnedOrchestrationModel(\n\tbinding: OrchestrationModelBinding,\n\tmodelRegistry: ModelRegistry,\n\tisUnavailable: (model: Model<Api>) => boolean = () => false,\n): ResolvedOrchestrationModel | undefined {\n\tconst model = modelRegistry.find(binding.provider, binding.modelId);\n\tif (\n\t\t!model ||\n\t\t!modelRegistry.hasConfiguredAuth(model) ||\n\t\tisUnavailable(model) ||\n\t\t!getSupportedThinkingLevels(model).includes(binding.thinkingLevel)\n\t) {\n\t\treturn undefined;\n\t}\n\treturn { model, binding: structuredClone(binding) };\n}\n\n/**\n * Resolve an owner-authored model policy without weakening it. Fixed policies never fall through;\n * ordered policies use only their declared order, and every candidate must have configured auth\n * plus exact support for its pinned thinking level.\n */\nexport function resolveConfiguredOrchestrationModel(\n\tprofile: OrchestrationProfile,\n\tmodelRegistry: ModelRegistry,\n\tisUnavailable: (model: Model<Api>) => boolean = () => false,\n): ResolvedOrchestrationModel | undefined {\n\tfor (const binding of profile.modelPolicy.candidates) {\n\t\tconst resolved = resolvePinnedOrchestrationModel(binding, modelRegistry, isUnavailable);\n\t\tif (!resolved) {\n\t\t\tif (profile.modelPolicy.mode === \"fixed\") return undefined;\n\t\t\tcontinue;\n\t\t}\n\t\treturn resolved;\n\t}\n\treturn undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-compiler.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/policy-compiler.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,MAAM,gBAAgB,C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AS,kBAAkB,EAAE,CAAC;IAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAEjG,MAAM,WAAW,qBAAqB;IACrC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,CAAC,CAAC,CAAC;CACpF;AAkDD,qBAAa,uBAAuB;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA6D;IAEpG,YAAY,OAAO,GAAE,qBAA0B,EAI9C;IAED,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,uBAAuB,CAmIlE;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport {\n\ttype ApprovalRequestContract,\n\ttype CapabilityDecision,\n\ttype ExecutionGrant,\n\ttype HarnessCapability,\n\tORCHESTRATION_SCHEMA_VERSION,\n\ttype ResourcePointer,\n\ttype RiskBudget,\n\ttype ToolCapabilityManifest,\n\ttype WorkerRole,\n} from \"./contracts.ts\";\nimport { exceededRiskBudgetFields, intersectRiskBudgets, validateRiskBudget } from \"./risk-budget.ts\";\n\nexport const DEFAULT_ROLE_CAPABILITY_CEILINGS: Readonly<Record<WorkerRole, readonly HarnessCapability[]>> = {\n\torchestrator: [\"workflow.delegate\"],\n\tplanner: [\"workflow.plan\"],\n\texplorer: [\"filesystem.read\", \"worktree.read\", \"network.http\", \"service.mcp\", \"memory.query\"],\n\timplementer: [\"filesystem.read\", \"filesystem.write\", \"worktree.read\", \"worktree.mutate\", \"memory.query\"],\n\toperator: [\"filesystem.read\", \"worktree.read\", \"process.exec\", \"tests.execute\", \"network.http\", \"service.mcp\"],\n\tverifier: [\"filesystem.read\", \"worktree.read\", \"process.exec\", \"tests.execute\", \"network.http\", \"service.mcp\"],\n\tdatabase: [\"memory.query\", \"memory.mutate\"],\n};\n\nexport interface CompileExecutionGrantInput {\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tsubjectId: string;\n\trole: WorkerRole;\n\trequiredCapabilities: readonly HarnessCapability[];\n\trequestedCapabilities?: readonly HarnessCapability[];\n\tauthorityCapabilities: readonly HarnessCapability[];\n\trequestedTools: readonly string[];\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\tresources?: readonly ResourcePointer[];\n\treadPaths?: readonly string[];\n\twritePaths?: readonly string[];\n\tdeniedPaths?: readonly string[];\n\trequestedBudget?: RiskBudget;\n\tauthorityBudget?: RiskBudget;\n\tpolicyVersion: string;\n\texpiresAt?: string;\n}\n\nexport type PolicyCompilationResult =\n\t| { outcome: \"allow\"; grant: ExecutionGrant; toolManifests: readonly ToolCapabilityManifest[] }\n\t| {\n\t\t\toutcome: \"approval-required\";\n\t\t\tapproval: ApprovalRequestContract;\n\t\t\tdecisions: readonly CapabilityDecision[];\n\t\t\treasonCodes: readonly string[];\n\t }\n\t| { outcome: \"deny\"; decisions: readonly CapabilityDecision[]; reasonCodes: readonly string[] };\n\nexport interface PolicyCompilerOptions {\n\tnow?: () => string;\n\tcreateId?: () => string;\n\troleCapabilityCeilings?: Readonly<Record<WorkerRole, readonly HarnessCapability[]>>;\n}\n\nfunction unique<T>(values: readonly T[]): T[] {\n\treturn [...new Set(values)];\n}\n\nfunction freezeGrant(grant: ExecutionGrant): ExecutionGrant {\n\tfor (const resource of grant.resources) {\n\t\tif (resource.metadata) Object.freeze(resource.metadata);\n\t\tObject.freeze(resource);\n\t}\n\tfor (const decision of grant.decisionTrace) Object.freeze(decision);\n\tObject.freeze(grant.capabilities);\n\tObject.freeze(grant.allowedTools);\n\tObject.freeze(grant.resources);\n\tObject.freeze(grant.readPaths);\n\tObject.freeze(grant.writePaths);\n\tObject.freeze(grant.deniedPaths);\n\tObject.freeze(grant.budget);\n\tObject.freeze(grant.decisionTrace);\n\treturn Object.freeze(grant);\n}\n\nconst CAPABILITY_ENFORCEMENT = new Map<HarnessCapability, ToolCapabilityManifest[\"enforcements\"][number]>([\n\t[\"filesystem.read\", \"path-scope\"],\n\t[\"filesystem.write\", \"path-scope\"],\n\t[\"worktree.read\", \"path-scope\"],\n\t[\"worktree.mutate\", \"path-scope\"],\n\t[\"process.exec\", \"process-launcher\"],\n\t[\"tests.execute\", \"process-launcher\"],\n\t[\"network.http\", \"service-proxy\"],\n\t[\"service.mcp\", \"service-proxy\"],\n\t[\"credentials.use\", \"service-proxy\"],\n\t[\"credentials.modify\", \"control-plane\"],\n\t[\"memory.query\", \"memory-broker\"],\n\t[\"memory.mutate\", \"memory-broker\"],\n\t[\"settings.read\", \"control-plane\"],\n\t[\"settings.write\", \"control-plane\"],\n\t[\"skill.read\", \"path-scope\"],\n\t[\"skill.write\", \"path-scope\"],\n\t[\"source.read\", \"path-scope\"],\n\t[\"source.write\", \"path-scope\"],\n\t[\"research.execute\", \"control-plane\"],\n\t[\"workflow.plan\", \"control-plane\"],\n\t[\"workflow.delegate\", \"control-plane\"],\n\t[\"policy.modify\", \"control-plane\"],\n\t[\"learning.propose\", \"control-plane\"],\n\t[\"publish.execute\", \"control-plane\"],\n]);\n\nexport class ExecutionPolicyCompiler {\n\tprivate readonly now: () => string;\n\tprivate readonly createId: () => string;\n\tprivate readonly roleCapabilityCeilings: Readonly<Record<WorkerRole, readonly HarnessCapability[]>>;\n\n\tconstructor(options: PolicyCompilerOptions = {}) {\n\t\tthis.now = options.now ?? (() => new Date().toISOString());\n\t\tthis.createId = options.createId ?? randomUUID;\n\t\tthis.roleCapabilityCeilings = options.roleCapabilityCeilings ?? DEFAULT_ROLE_CAPABILITY_CEILINGS;\n\t}\n\n\tcompile(input: CompileExecutionGrantInput): PolicyCompilationResult {\n\t\tconst required = unique(input.requiredCapabilities);\n\t\tconst requested = unique([...(input.requestedCapabilities ?? required), ...required]);\n\t\tconst authority = new Set(input.authorityCapabilities);\n\t\tconst roleCeiling = new Set(this.roleCapabilityCeilings[input.role]);\n\t\tconst decisions: CapabilityDecision[] = [];\n\t\tconst roleDenied: HarnessCapability[] = [];\n\t\tconst approvalCapabilities: HarnessCapability[] = [];\n\t\tconst granted: HarnessCapability[] = [];\n\n\t\tfor (const capability of requested) {\n\t\t\tif (!roleCeiling.has(capability)) {\n\t\t\t\troleDenied.push(capability);\n\t\t\t\tdecisions.push({ capability, outcome: \"deny\", reasonCode: \"role_ceiling_denied\", source: input.role });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!authority.has(capability)) {\n\t\t\t\tapprovalCapabilities.push(capability);\n\t\t\t\tdecisions.push({\n\t\t\t\t\tcapability,\n\t\t\t\t\toutcome: \"deny\",\n\t\t\t\t\treasonCode: \"owner_authority_required\",\n\t\t\t\t\tsource: \"authority\",\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tgranted.push(capability);\n\t\t\tdecisions.push({ capability, outcome: \"allow\", reasonCode: \"role_and_authority_allowed\", source: input.role });\n\t\t}\n\n\t\tif (roleDenied.some((capability) => required.includes(capability))) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: [\"required_capability_exceeds_role_ceiling\"] };\n\t\t}\n\n\t\tconst requestedBudget = { ...(input.requestedBudget ?? {}) };\n\t\tconst authorityBudget = { ...(input.authorityBudget ?? {}) };\n\t\tvalidateRiskBudget(requestedBudget, \"requestedBudget\");\n\t\tvalidateRiskBudget(authorityBudget, \"authorityBudget\");\n\t\tconst exceededBudgetFields = exceededRiskBudgetFields(requestedBudget, authorityBudget);\n\t\tif (approvalCapabilities.some((capability) => required.includes(capability)) || exceededBudgetFields.length > 0) {\n\t\t\tconst approval: ApprovalRequestContract = {\n\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\tapprovalId: `approval-${this.createId()}`,\n\t\t\t\tobjectiveId: input.objectiveId,\n\t\t\t\ttaskId: input.taskId,\n\t\t\t\tattemptId: input.attemptId,\n\t\t\t\treasonCode:\n\t\t\t\t\texceededBudgetFields.length > 0\n\t\t\t\t\t\t? \"requested_budget_exceeds_authority\"\n\t\t\t\t\t\t: \"required_capability_needs_authority\",\n\t\t\t\tsummary:\n\t\t\t\t\texceededBudgetFields.length > 0\n\t\t\t\t\t\t? `Requested budget exceeds authority for: ${exceededBudgetFields.join(\", \")}.`\n\t\t\t\t\t\t: `Required capabilities need owner authority: ${approvalCapabilities.join(\", \")}.`,\n\t\t\t\trequestedCapabilities: approvalCapabilities,\n\t\t\t\t...(Object.keys(requestedBudget).length > 0 ? { requestedBudget } : {}),\n\t\t\t\treversible: true,\n\t\t\t\tcreatedAt: this.now(),\n\t\t\t};\n\t\t\treturn {\n\t\t\t\toutcome: \"approval-required\",\n\t\t\t\tapproval,\n\t\t\t\tdecisions,\n\t\t\t\treasonCodes: [approval.reasonCode],\n\t\t\t};\n\t\t}\n\n\t\tconst manifestsByName = new Map(input.toolManifests.map((manifest) => [manifest.toolName, manifest]));\n\t\tconst allowedManifests: ToolCapabilityManifest[] = [];\n\t\tconst toolReasonCodes: string[] = [];\n\t\tfor (const toolName of unique(input.requestedTools)) {\n\t\t\tconst manifest = manifestsByName.get(toolName);\n\t\t\tif (!manifest) {\n\t\t\t\ttoolReasonCodes.push(`unknown_tool:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!manifest.roles.includes(input.role)) {\n\t\t\t\ttoolReasonCodes.push(`tool_role_denied:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!manifest.capabilities.every((capability) => granted.includes(capability))) {\n\t\t\t\ttoolReasonCodes.push(`tool_capability_denied:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!manifest.capabilities.every((capability) => {\n\t\t\t\t\tconst enforcement = CAPABILITY_ENFORCEMENT.get(capability);\n\t\t\t\t\treturn enforcement !== undefined && manifest.enforcements.includes(enforcement);\n\t\t\t\t})\n\t\t\t) {\n\t\t\t\ttoolReasonCodes.push(`tool_enforcement_missing:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tallowedManifests.push(structuredClone(manifest));\n\t\t}\n\n\t\tif (toolReasonCodes.length > 0) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: toolReasonCodes };\n\t\t}\n\n\t\tconst readPaths = unique(input.readPaths ?? []);\n\t\tconst writePaths = unique(input.writePaths ?? []);\n\t\tconst deniedPaths = unique(input.deniedPaths ?? []);\n\t\tif ((granted.includes(\"filesystem.read\") || granted.includes(\"worktree.read\")) && readPaths.length === 0) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: [\"read_capability_missing_positive_path_scope\"] };\n\t\t}\n\t\tif ((granted.includes(\"filesystem.write\") || granted.includes(\"worktree.mutate\")) && writePaths.length === 0) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: [\"write_capability_missing_positive_path_scope\"] };\n\t\t}\n\n\t\tconst grant = freezeGrant({\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\tgrantId: `grant-${this.createId()}`,\n\t\t\tobjectiveId: input.objectiveId,\n\t\t\ttaskId: input.taskId,\n\t\t\tattemptId: input.attemptId,\n\t\t\tsubjectId: input.subjectId,\n\t\t\trole: input.role,\n\t\t\tcapabilities: granted,\n\t\t\tallowedTools: allowedManifests.map((manifest) => manifest.toolName),\n\t\t\tresources: structuredClone(input.resources ?? []),\n\t\t\treadPaths,\n\t\t\twritePaths,\n\t\t\tdeniedPaths,\n\t\t\tbudget: intersectRiskBudgets(requestedBudget, authorityBudget),\n\t\t\tpolicyVersion: input.policyVersion,\n\t\t\tdecisionTrace: decisions,\n\t\t\tissuedAt: this.now(),\n\t\t\t...(input.expiresAt ? { expiresAt: input.expiresAt } : {}),\n\t\t});\n\t\treturn { outcome: \"allow\", grant, toolManifests: allowedManifests };\n\t}\n}\n"]}
|
|
1
|
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AAC,aAAa,EAAE,SAAS,sBAAsB,EAAE,CAAA;CAAE,GAC7F;IACA,OAAO,EAAE,mBAAmB,CAAC;IAC7B,QAAQ,EAAE,uBAAuB,CAAC;IAClC,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACzC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,GACD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAEjG,MAAM,WAAW,qBAAqB;IACrC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,CAAC,CAAC,CAAC;CACpF;AAkDD,qBAAa,uBAAuB;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA6D;IAEpG,YAAY,OAAO,GAAE,qBAA0B,EAI9C;IAED,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,uBAAuB,CAmIlE;CACD"}
|
|
@@ -58,9 +58,6 @@ const CAPABILITY_ENFORCEMENT = new Map([
|
|
|
58
58
|
["publish.execute", "control-plane"],
|
|
59
59
|
]);
|
|
60
60
|
export class ExecutionPolicyCompiler {
|
|
61
|
-
now;
|
|
62
|
-
createId;
|
|
63
|
-
roleCapabilityCeilings;
|
|
64
61
|
constructor(options = {}) {
|
|
65
62
|
this.now = options.now ?? (() => new Date().toISOString());
|
|
66
63
|
this.createId = options.createId ?? randomUUID;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-compiler.js","sourceRoot":"","sources":["../../../src/core/orchestration/policy-compiler.ts"],"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,EAAE,EAAE;YACnC,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,YAAY,EAAE,OAAO;YACrB,YAAY,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACnE,SAAS,EAAE,eAAe,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC;YACjD,SAAS;YACT,UAAU;YACV,WAAW;YACX,MAAM,EAAE,oBAAoB,CAAC,eAAe,EAAE,eAAe,CAAC;YAC9D,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,aAAa,EAAE,SAAS;YACxB,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE;YACpB,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1D,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC;IAAA,CACpE;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport {\n\ttype ApprovalRequestContract,\n\ttype CapabilityDecision,\n\ttype ExecutionGrant,\n\ttype HarnessCapability,\n\tORCHESTRATION_SCHEMA_VERSION,\n\ttype ResourcePointer,\n\ttype RiskBudget,\n\ttype ToolCapabilityManifest,\n\ttype WorkerRole,\n} from \"./contracts.ts\";\nimport { exceededRiskBudgetFields, intersectRiskBudgets, validateRiskBudget } from \"./risk-budget.ts\";\n\nexport const DEFAULT_ROLE_CAPABILITY_CEILINGS: Readonly<Record<WorkerRole, readonly HarnessCapability[]>> = {\n\torchestrator: [\"workflow.delegate\"],\n\tplanner: [\"workflow.plan\"],\n\texplorer: [\"filesystem.read\", \"worktree.read\", \"network.http\", \"service.mcp\", \"memory.query\"],\n\timplementer: [\"filesystem.read\", \"filesystem.write\", \"worktree.read\", \"worktree.mutate\", \"memory.query\"],\n\toperator: [\"filesystem.read\", \"worktree.read\", \"process.exec\", \"tests.execute\", \"network.http\", \"service.mcp\"],\n\tverifier: [\"filesystem.read\", \"worktree.read\", \"process.exec\", \"tests.execute\", \"network.http\", \"service.mcp\"],\n\tdatabase: [\"memory.query\", \"memory.mutate\"],\n};\n\nexport interface CompileExecutionGrantInput {\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tsubjectId: string;\n\trole: WorkerRole;\n\trequiredCapabilities: readonly HarnessCapability[];\n\trequestedCapabilities?: readonly HarnessCapability[];\n\tauthorityCapabilities: readonly HarnessCapability[];\n\trequestedTools: readonly string[];\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\tresources?: readonly ResourcePointer[];\n\treadPaths?: readonly string[];\n\twritePaths?: readonly string[];\n\tdeniedPaths?: readonly string[];\n\trequestedBudget?: RiskBudget;\n\tauthorityBudget?: RiskBudget;\n\tpolicyVersion: string;\n\texpiresAt?: string;\n}\n\nexport type PolicyCompilationResult =\n\t| { outcome: \"allow\"; grant: ExecutionGrant; toolManifests: readonly ToolCapabilityManifest[] }\n\t| {\n\t\t\toutcome: \"approval-required\";\n\t\t\tapproval: ApprovalRequestContract;\n\t\t\tdecisions: readonly CapabilityDecision[];\n\t\t\treasonCodes: readonly string[];\n\t }\n\t| { outcome: \"deny\"; decisions: readonly CapabilityDecision[]; reasonCodes: readonly string[] };\n\nexport interface PolicyCompilerOptions {\n\tnow?: () => string;\n\tcreateId?: () => string;\n\troleCapabilityCeilings?: Readonly<Record<WorkerRole, readonly HarnessCapability[]>>;\n}\n\nfunction unique<T>(values: readonly T[]): T[] {\n\treturn [...new Set(values)];\n}\n\nfunction freezeGrant(grant: ExecutionGrant): ExecutionGrant {\n\tfor (const resource of grant.resources) {\n\t\tif (resource.metadata) Object.freeze(resource.metadata);\n\t\tObject.freeze(resource);\n\t}\n\tfor (const decision of grant.decisionTrace) Object.freeze(decision);\n\tObject.freeze(grant.capabilities);\n\tObject.freeze(grant.allowedTools);\n\tObject.freeze(grant.resources);\n\tObject.freeze(grant.readPaths);\n\tObject.freeze(grant.writePaths);\n\tObject.freeze(grant.deniedPaths);\n\tObject.freeze(grant.budget);\n\tObject.freeze(grant.decisionTrace);\n\treturn Object.freeze(grant);\n}\n\nconst CAPABILITY_ENFORCEMENT = new Map<HarnessCapability, ToolCapabilityManifest[\"enforcements\"][number]>([\n\t[\"filesystem.read\", \"path-scope\"],\n\t[\"filesystem.write\", \"path-scope\"],\n\t[\"worktree.read\", \"path-scope\"],\n\t[\"worktree.mutate\", \"path-scope\"],\n\t[\"process.exec\", \"process-launcher\"],\n\t[\"tests.execute\", \"process-launcher\"],\n\t[\"network.http\", \"service-proxy\"],\n\t[\"service.mcp\", \"service-proxy\"],\n\t[\"credentials.use\", \"service-proxy\"],\n\t[\"credentials.modify\", \"control-plane\"],\n\t[\"memory.query\", \"memory-broker\"],\n\t[\"memory.mutate\", \"memory-broker\"],\n\t[\"settings.read\", \"control-plane\"],\n\t[\"settings.write\", \"control-plane\"],\n\t[\"skill.read\", \"path-scope\"],\n\t[\"skill.write\", \"path-scope\"],\n\t[\"source.read\", \"path-scope\"],\n\t[\"source.write\", \"path-scope\"],\n\t[\"research.execute\", \"control-plane\"],\n\t[\"workflow.plan\", \"control-plane\"],\n\t[\"workflow.delegate\", \"control-plane\"],\n\t[\"policy.modify\", \"control-plane\"],\n\t[\"learning.propose\", \"control-plane\"],\n\t[\"publish.execute\", \"control-plane\"],\n]);\n\nexport class ExecutionPolicyCompiler {\n\tprivate readonly now: () => string;\n\tprivate readonly createId: () => string;\n\tprivate readonly roleCapabilityCeilings: Readonly<Record<WorkerRole, readonly HarnessCapability[]>>;\n\n\tconstructor(options: PolicyCompilerOptions = {}) {\n\t\tthis.now = options.now ?? (() => new Date().toISOString());\n\t\tthis.createId = options.createId ?? randomUUID;\n\t\tthis.roleCapabilityCeilings = options.roleCapabilityCeilings ?? DEFAULT_ROLE_CAPABILITY_CEILINGS;\n\t}\n\n\tcompile(input: CompileExecutionGrantInput): PolicyCompilationResult {\n\t\tconst required = unique(input.requiredCapabilities);\n\t\tconst requested = unique([...(input.requestedCapabilities ?? required), ...required]);\n\t\tconst authority = new Set(input.authorityCapabilities);\n\t\tconst roleCeiling = new Set(this.roleCapabilityCeilings[input.role]);\n\t\tconst decisions: CapabilityDecision[] = [];\n\t\tconst roleDenied: HarnessCapability[] = [];\n\t\tconst approvalCapabilities: HarnessCapability[] = [];\n\t\tconst granted: HarnessCapability[] = [];\n\n\t\tfor (const capability of requested) {\n\t\t\tif (!roleCeiling.has(capability)) {\n\t\t\t\troleDenied.push(capability);\n\t\t\t\tdecisions.push({ capability, outcome: \"deny\", reasonCode: \"role_ceiling_denied\", source: input.role });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!authority.has(capability)) {\n\t\t\t\tapprovalCapabilities.push(capability);\n\t\t\t\tdecisions.push({\n\t\t\t\t\tcapability,\n\t\t\t\t\toutcome: \"deny\",\n\t\t\t\t\treasonCode: \"owner_authority_required\",\n\t\t\t\t\tsource: \"authority\",\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tgranted.push(capability);\n\t\t\tdecisions.push({ capability, outcome: \"allow\", reasonCode: \"role_and_authority_allowed\", source: input.role });\n\t\t}\n\n\t\tif (roleDenied.some((capability) => required.includes(capability))) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: [\"required_capability_exceeds_role_ceiling\"] };\n\t\t}\n\n\t\tconst requestedBudget = { ...(input.requestedBudget ?? {}) };\n\t\tconst authorityBudget = { ...(input.authorityBudget ?? {}) };\n\t\tvalidateRiskBudget(requestedBudget, \"requestedBudget\");\n\t\tvalidateRiskBudget(authorityBudget, \"authorityBudget\");\n\t\tconst exceededBudgetFields = exceededRiskBudgetFields(requestedBudget, authorityBudget);\n\t\tif (approvalCapabilities.some((capability) => required.includes(capability)) || exceededBudgetFields.length > 0) {\n\t\t\tconst approval: ApprovalRequestContract = {\n\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\tapprovalId: `approval-${this.createId()}`,\n\t\t\t\tobjectiveId: input.objectiveId,\n\t\t\t\ttaskId: input.taskId,\n\t\t\t\tattemptId: input.attemptId,\n\t\t\t\treasonCode:\n\t\t\t\t\texceededBudgetFields.length > 0\n\t\t\t\t\t\t? \"requested_budget_exceeds_authority\"\n\t\t\t\t\t\t: \"required_capability_needs_authority\",\n\t\t\t\tsummary:\n\t\t\t\t\texceededBudgetFields.length > 0\n\t\t\t\t\t\t? `Requested budget exceeds authority for: ${exceededBudgetFields.join(\", \")}.`\n\t\t\t\t\t\t: `Required capabilities need owner authority: ${approvalCapabilities.join(\", \")}.`,\n\t\t\t\trequestedCapabilities: approvalCapabilities,\n\t\t\t\t...(Object.keys(requestedBudget).length > 0 ? { requestedBudget } : {}),\n\t\t\t\treversible: true,\n\t\t\t\tcreatedAt: this.now(),\n\t\t\t};\n\t\t\treturn {\n\t\t\t\toutcome: \"approval-required\",\n\t\t\t\tapproval,\n\t\t\t\tdecisions,\n\t\t\t\treasonCodes: [approval.reasonCode],\n\t\t\t};\n\t\t}\n\n\t\tconst manifestsByName = new Map(input.toolManifests.map((manifest) => [manifest.toolName, manifest]));\n\t\tconst allowedManifests: ToolCapabilityManifest[] = [];\n\t\tconst toolReasonCodes: string[] = [];\n\t\tfor (const toolName of unique(input.requestedTools)) {\n\t\t\tconst manifest = manifestsByName.get(toolName);\n\t\t\tif (!manifest) {\n\t\t\t\ttoolReasonCodes.push(`unknown_tool:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!manifest.roles.includes(input.role)) {\n\t\t\t\ttoolReasonCodes.push(`tool_role_denied:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!manifest.capabilities.every((capability) => granted.includes(capability))) {\n\t\t\t\ttoolReasonCodes.push(`tool_capability_denied:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!manifest.capabilities.every((capability) => {\n\t\t\t\t\tconst enforcement = CAPABILITY_ENFORCEMENT.get(capability);\n\t\t\t\t\treturn enforcement !== undefined && manifest.enforcements.includes(enforcement);\n\t\t\t\t})\n\t\t\t) {\n\t\t\t\ttoolReasonCodes.push(`tool_enforcement_missing:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tallowedManifests.push(structuredClone(manifest));\n\t\t}\n\n\t\tif (toolReasonCodes.length > 0) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: toolReasonCodes };\n\t\t}\n\n\t\tconst readPaths = unique(input.readPaths ?? []);\n\t\tconst writePaths = unique(input.writePaths ?? []);\n\t\tconst deniedPaths = unique(input.deniedPaths ?? []);\n\t\tif ((granted.includes(\"filesystem.read\") || granted.includes(\"worktree.read\")) && readPaths.length === 0) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: [\"read_capability_missing_positive_path_scope\"] };\n\t\t}\n\t\tif ((granted.includes(\"filesystem.write\") || granted.includes(\"worktree.mutate\")) && writePaths.length === 0) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: [\"write_capability_missing_positive_path_scope\"] };\n\t\t}\n\n\t\tconst grant = freezeGrant({\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\tgrantId: `grant-${this.createId()}`,\n\t\t\tobjectiveId: input.objectiveId,\n\t\t\ttaskId: input.taskId,\n\t\t\tattemptId: input.attemptId,\n\t\t\tsubjectId: input.subjectId,\n\t\t\trole: input.role,\n\t\t\tcapabilities: granted,\n\t\t\tallowedTools: allowedManifests.map((manifest) => manifest.toolName),\n\t\t\tresources: structuredClone(input.resources ?? []),\n\t\t\treadPaths,\n\t\t\twritePaths,\n\t\t\tdeniedPaths,\n\t\t\tbudget: intersectRiskBudgets(requestedBudget, authorityBudget),\n\t\t\tpolicyVersion: input.policyVersion,\n\t\t\tdecisionTrace: decisions,\n\t\t\tissuedAt: this.now(),\n\t\t\t...(input.expiresAt ? { expiresAt: input.expiresAt } : {}),\n\t\t});\n\t\treturn { outcome: \"allow\", grant, toolManifests: allowedManifests };\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"policy-compiler.js","sourceRoot":"","sources":["../../../src/core/orchestration/policy-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAKN,4BAA4B,GAK5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtG,MAAM,CAAC,MAAM,gCAAgC,GAA+D;IAC3G,YAAY,EAAE,CAAC,mBAAmB,CAAC;IACnC,OAAO,EAAE,CAAC,eAAe,CAAC;IAC1B,QAAQ,EAAE,CAAC,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,CAAC;IAC7F,WAAW,EAAE,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,CAAC;IACxG,QAAQ,EAAE,CAAC,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,CAAC;IAC9G,QAAQ,EAAE,CAAC,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,CAAC;IAC9G,QAAQ,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;CAC3C,CAAC;AAuCF,SAAS,MAAM,CAAI,MAAoB;IACtC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,WAAW,CAAC,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AAM,KAAK,CAAC,EAAE,CAAC;YAC9G,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,8CAA8C,CAAC,EAAE,CAAC;QACtG,CAAC;QAED,MAAM,KAAK,GAAG,WAAW,CAAC;YACzB,aAAa,EAAE,4BAA4B;YAC3C,OAAO,EAAE,SAAS,IAAI,CAAC,QAAQ,EAAE,EAAE;YACnC,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,YAAY,EAAE,OAAO;YACrB,YAAY,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACnE,SAAS,EAAE,eAAe,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC;YACjD,SAAS;YACT,UAAU;YACV,WAAW;YACX,MAAM,EAAE,oBAAoB,CAAC,eAAe,EAAE,eAAe,CAAC;YAC9D,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,aAAa,EAAE,SAAS;YACxB,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE;YACpB,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1D,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC;IACrE,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport {\n\ttype ApprovalRequestContract,\n\ttype CapabilityDecision,\n\ttype ExecutionGrant,\n\ttype HarnessCapability,\n\tORCHESTRATION_SCHEMA_VERSION,\n\ttype ResourcePointer,\n\ttype RiskBudget,\n\ttype ToolCapabilityManifest,\n\ttype WorkerRole,\n} from \"./contracts.ts\";\nimport { exceededRiskBudgetFields, intersectRiskBudgets, validateRiskBudget } from \"./risk-budget.ts\";\n\nexport const DEFAULT_ROLE_CAPABILITY_CEILINGS: Readonly<Record<WorkerRole, readonly HarnessCapability[]>> = {\n\torchestrator: [\"workflow.delegate\"],\n\tplanner: [\"workflow.plan\"],\n\texplorer: [\"filesystem.read\", \"worktree.read\", \"network.http\", \"service.mcp\", \"memory.query\"],\n\timplementer: [\"filesystem.read\", \"filesystem.write\", \"worktree.read\", \"worktree.mutate\", \"memory.query\"],\n\toperator: [\"filesystem.read\", \"worktree.read\", \"process.exec\", \"tests.execute\", \"network.http\", \"service.mcp\"],\n\tverifier: [\"filesystem.read\", \"worktree.read\", \"process.exec\", \"tests.execute\", \"network.http\", \"service.mcp\"],\n\tdatabase: [\"memory.query\", \"memory.mutate\"],\n};\n\nexport interface CompileExecutionGrantInput {\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tsubjectId: string;\n\trole: WorkerRole;\n\trequiredCapabilities: readonly HarnessCapability[];\n\trequestedCapabilities?: readonly HarnessCapability[];\n\tauthorityCapabilities: readonly HarnessCapability[];\n\trequestedTools: readonly string[];\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\tresources?: readonly ResourcePointer[];\n\treadPaths?: readonly string[];\n\twritePaths?: readonly string[];\n\tdeniedPaths?: readonly string[];\n\trequestedBudget?: RiskBudget;\n\tauthorityBudget?: RiskBudget;\n\tpolicyVersion: string;\n\texpiresAt?: string;\n}\n\nexport type PolicyCompilationResult =\n\t| { outcome: \"allow\"; grant: ExecutionGrant; toolManifests: readonly ToolCapabilityManifest[] }\n\t| {\n\t\t\toutcome: \"approval-required\";\n\t\t\tapproval: ApprovalRequestContract;\n\t\t\tdecisions: readonly CapabilityDecision[];\n\t\t\treasonCodes: readonly string[];\n\t }\n\t| { outcome: \"deny\"; decisions: readonly CapabilityDecision[]; reasonCodes: readonly string[] };\n\nexport interface PolicyCompilerOptions {\n\tnow?: () => string;\n\tcreateId?: () => string;\n\troleCapabilityCeilings?: Readonly<Record<WorkerRole, readonly HarnessCapability[]>>;\n}\n\nfunction unique<T>(values: readonly T[]): T[] {\n\treturn [...new Set(values)];\n}\n\nfunction freezeGrant(grant: ExecutionGrant): ExecutionGrant {\n\tfor (const resource of grant.resources) {\n\t\tif (resource.metadata) Object.freeze(resource.metadata);\n\t\tObject.freeze(resource);\n\t}\n\tfor (const decision of grant.decisionTrace) Object.freeze(decision);\n\tObject.freeze(grant.capabilities);\n\tObject.freeze(grant.allowedTools);\n\tObject.freeze(grant.resources);\n\tObject.freeze(grant.readPaths);\n\tObject.freeze(grant.writePaths);\n\tObject.freeze(grant.deniedPaths);\n\tObject.freeze(grant.budget);\n\tObject.freeze(grant.decisionTrace);\n\treturn Object.freeze(grant);\n}\n\nconst CAPABILITY_ENFORCEMENT = new Map<HarnessCapability, ToolCapabilityManifest[\"enforcements\"][number]>([\n\t[\"filesystem.read\", \"path-scope\"],\n\t[\"filesystem.write\", \"path-scope\"],\n\t[\"worktree.read\", \"path-scope\"],\n\t[\"worktree.mutate\", \"path-scope\"],\n\t[\"process.exec\", \"process-launcher\"],\n\t[\"tests.execute\", \"process-launcher\"],\n\t[\"network.http\", \"service-proxy\"],\n\t[\"service.mcp\", \"service-proxy\"],\n\t[\"credentials.use\", \"service-proxy\"],\n\t[\"credentials.modify\", \"control-plane\"],\n\t[\"memory.query\", \"memory-broker\"],\n\t[\"memory.mutate\", \"memory-broker\"],\n\t[\"settings.read\", \"control-plane\"],\n\t[\"settings.write\", \"control-plane\"],\n\t[\"skill.read\", \"path-scope\"],\n\t[\"skill.write\", \"path-scope\"],\n\t[\"source.read\", \"path-scope\"],\n\t[\"source.write\", \"path-scope\"],\n\t[\"research.execute\", \"control-plane\"],\n\t[\"workflow.plan\", \"control-plane\"],\n\t[\"workflow.delegate\", \"control-plane\"],\n\t[\"policy.modify\", \"control-plane\"],\n\t[\"learning.propose\", \"control-plane\"],\n\t[\"publish.execute\", \"control-plane\"],\n]);\n\nexport class ExecutionPolicyCompiler {\n\tprivate readonly now: () => string;\n\tprivate readonly createId: () => string;\n\tprivate readonly roleCapabilityCeilings: Readonly<Record<WorkerRole, readonly HarnessCapability[]>>;\n\n\tconstructor(options: PolicyCompilerOptions = {}) {\n\t\tthis.now = options.now ?? (() => new Date().toISOString());\n\t\tthis.createId = options.createId ?? randomUUID;\n\t\tthis.roleCapabilityCeilings = options.roleCapabilityCeilings ?? DEFAULT_ROLE_CAPABILITY_CEILINGS;\n\t}\n\n\tcompile(input: CompileExecutionGrantInput): PolicyCompilationResult {\n\t\tconst required = unique(input.requiredCapabilities);\n\t\tconst requested = unique([...(input.requestedCapabilities ?? required), ...required]);\n\t\tconst authority = new Set(input.authorityCapabilities);\n\t\tconst roleCeiling = new Set(this.roleCapabilityCeilings[input.role]);\n\t\tconst decisions: CapabilityDecision[] = [];\n\t\tconst roleDenied: HarnessCapability[] = [];\n\t\tconst approvalCapabilities: HarnessCapability[] = [];\n\t\tconst granted: HarnessCapability[] = [];\n\n\t\tfor (const capability of requested) {\n\t\t\tif (!roleCeiling.has(capability)) {\n\t\t\t\troleDenied.push(capability);\n\t\t\t\tdecisions.push({ capability, outcome: \"deny\", reasonCode: \"role_ceiling_denied\", source: input.role });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!authority.has(capability)) {\n\t\t\t\tapprovalCapabilities.push(capability);\n\t\t\t\tdecisions.push({\n\t\t\t\t\tcapability,\n\t\t\t\t\toutcome: \"deny\",\n\t\t\t\t\treasonCode: \"owner_authority_required\",\n\t\t\t\t\tsource: \"authority\",\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tgranted.push(capability);\n\t\t\tdecisions.push({ capability, outcome: \"allow\", reasonCode: \"role_and_authority_allowed\", source: input.role });\n\t\t}\n\n\t\tif (roleDenied.some((capability) => required.includes(capability))) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: [\"required_capability_exceeds_role_ceiling\"] };\n\t\t}\n\n\t\tconst requestedBudget = { ...(input.requestedBudget ?? {}) };\n\t\tconst authorityBudget = { ...(input.authorityBudget ?? {}) };\n\t\tvalidateRiskBudget(requestedBudget, \"requestedBudget\");\n\t\tvalidateRiskBudget(authorityBudget, \"authorityBudget\");\n\t\tconst exceededBudgetFields = exceededRiskBudgetFields(requestedBudget, authorityBudget);\n\t\tif (approvalCapabilities.some((capability) => required.includes(capability)) || exceededBudgetFields.length > 0) {\n\t\t\tconst approval: ApprovalRequestContract = {\n\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\tapprovalId: `approval-${this.createId()}`,\n\t\t\t\tobjectiveId: input.objectiveId,\n\t\t\t\ttaskId: input.taskId,\n\t\t\t\tattemptId: input.attemptId,\n\t\t\t\treasonCode:\n\t\t\t\t\texceededBudgetFields.length > 0\n\t\t\t\t\t\t? \"requested_budget_exceeds_authority\"\n\t\t\t\t\t\t: \"required_capability_needs_authority\",\n\t\t\t\tsummary:\n\t\t\t\t\texceededBudgetFields.length > 0\n\t\t\t\t\t\t? `Requested budget exceeds authority for: ${exceededBudgetFields.join(\", \")}.`\n\t\t\t\t\t\t: `Required capabilities need owner authority: ${approvalCapabilities.join(\", \")}.`,\n\t\t\t\trequestedCapabilities: approvalCapabilities,\n\t\t\t\t...(Object.keys(requestedBudget).length > 0 ? { requestedBudget } : {}),\n\t\t\t\treversible: true,\n\t\t\t\tcreatedAt: this.now(),\n\t\t\t};\n\t\t\treturn {\n\t\t\t\toutcome: \"approval-required\",\n\t\t\t\tapproval,\n\t\t\t\tdecisions,\n\t\t\t\treasonCodes: [approval.reasonCode],\n\t\t\t};\n\t\t}\n\n\t\tconst manifestsByName = new Map(input.toolManifests.map((manifest) => [manifest.toolName, manifest]));\n\t\tconst allowedManifests: ToolCapabilityManifest[] = [];\n\t\tconst toolReasonCodes: string[] = [];\n\t\tfor (const toolName of unique(input.requestedTools)) {\n\t\t\tconst manifest = manifestsByName.get(toolName);\n\t\t\tif (!manifest) {\n\t\t\t\ttoolReasonCodes.push(`unknown_tool:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!manifest.roles.includes(input.role)) {\n\t\t\t\ttoolReasonCodes.push(`tool_role_denied:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!manifest.capabilities.every((capability) => granted.includes(capability))) {\n\t\t\t\ttoolReasonCodes.push(`tool_capability_denied:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!manifest.capabilities.every((capability) => {\n\t\t\t\t\tconst enforcement = CAPABILITY_ENFORCEMENT.get(capability);\n\t\t\t\t\treturn enforcement !== undefined && manifest.enforcements.includes(enforcement);\n\t\t\t\t})\n\t\t\t) {\n\t\t\t\ttoolReasonCodes.push(`tool_enforcement_missing:${toolName}`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tallowedManifests.push(structuredClone(manifest));\n\t\t}\n\n\t\tif (toolReasonCodes.length > 0) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: toolReasonCodes };\n\t\t}\n\n\t\tconst readPaths = unique(input.readPaths ?? []);\n\t\tconst writePaths = unique(input.writePaths ?? []);\n\t\tconst deniedPaths = unique(input.deniedPaths ?? []);\n\t\tif ((granted.includes(\"filesystem.read\") || granted.includes(\"worktree.read\")) && readPaths.length === 0) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: [\"read_capability_missing_positive_path_scope\"] };\n\t\t}\n\t\tif ((granted.includes(\"filesystem.write\") || granted.includes(\"worktree.mutate\")) && writePaths.length === 0) {\n\t\t\treturn { outcome: \"deny\", decisions, reasonCodes: [\"write_capability_missing_positive_path_scope\"] };\n\t\t}\n\n\t\tconst grant = freezeGrant({\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\tgrantId: `grant-${this.createId()}`,\n\t\t\tobjectiveId: input.objectiveId,\n\t\t\ttaskId: input.taskId,\n\t\t\tattemptId: input.attemptId,\n\t\t\tsubjectId: input.subjectId,\n\t\t\trole: input.role,\n\t\t\tcapabilities: granted,\n\t\t\tallowedTools: allowedManifests.map((manifest) => manifest.toolName),\n\t\t\tresources: structuredClone(input.resources ?? []),\n\t\t\treadPaths,\n\t\t\twritePaths,\n\t\t\tdeniedPaths,\n\t\t\tbudget: intersectRiskBudgets(requestedBudget, authorityBudget),\n\t\t\tpolicyVersion: input.policyVersion,\n\t\t\tdecisionTrace: decisions,\n\t\t\tissuedAt: this.now(),\n\t\t\t...(input.expiresAt ? { expiresAt: input.expiresAt } : {}),\n\t\t});\n\t\treturn { outcome: \"allow\", grant, toolManifests: allowedManifests };\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-gate.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/policy-gate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CACnC;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IAEnD,YAAY,OAAO,EAAE,0BAA0B,EAG9C;IAED,QAAQ,CAAC,KAAK,EAAE,0BAA0B,GAAG,uBAAuB,CAQnE;CACD"
|
|
1
|
+
{"version":3,"file":"policy-gate.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/policy-gate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CACnC;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IAEnD,YAAY,OAAO,EAAE,0BAA0B,EAG9C;IAED,QAAQ,CAAC,KAAK,EAAE,0BAA0B,GAAG,uBAAuB,CAQnE;CACD"}
|
|
@@ -4,8 +4,6 @@ import { ExecutionPolicyCompiler } from "./policy-compiler.js";
|
|
|
4
4
|
* its grant before execution can lease the attempt; an approval result persists the owner request.
|
|
5
5
|
*/
|
|
6
6
|
export class ExecutionPolicyGate {
|
|
7
|
-
runtime;
|
|
8
|
-
compiler;
|
|
9
7
|
constructor(options) {
|
|
10
8
|
this.runtime = options.runtime;
|
|
11
9
|
this.compiler = options.compiler ?? new ExecutionPolicyCompiler();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-gate.js","sourceRoot":"","sources":["../../../src/core/orchestration/policy-gate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAQ/D;;;GAGG;AACH,MAAM,OAAO,mBAAmB;
|
|
1
|
+
{"version":3,"file":"policy-gate.js","sourceRoot":"","sources":["../../../src/core/orchestration/policy-gate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAQ/D;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAI/B,YAAY,OAAmC;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,uBAAuB,EAAE,CAAC;IACnE,CAAC;IAED,QAAQ,CAAC,KAAiC;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9D,CAAC;aAAM,IAAI,MAAM,CAAC,OAAO,KAAK,mBAAmB,EAAE,CAAC;YACnD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;CACD","sourcesContent":["import type { CompileExecutionGrantInput, PolicyCompilationResult } from \"./policy-compiler.ts\";\nimport { ExecutionPolicyCompiler } from \"./policy-compiler.ts\";\nimport type { DurableTaskRuntime } from \"./task-runtime.ts\";\n\nexport interface ExecutionPolicyGateOptions {\n\truntime: DurableTaskRuntime;\n\tcompiler?: ExecutionPolicyCompiler;\n}\n\n/**\n * Atomic control-plane seam between policy evaluation and durable task state. An allow result binds\n * its grant before execution can lease the attempt; an approval result persists the owner request.\n */\nexport class ExecutionPolicyGate {\n\tprivate readonly runtime: DurableTaskRuntime;\n\tprivate readonly compiler: ExecutionPolicyCompiler;\n\n\tconstructor(options: ExecutionPolicyGateOptions) {\n\t\tthis.runtime = options.runtime;\n\t\tthis.compiler = options.compiler ?? new ExecutionPolicyCompiler();\n\t}\n\n\tevaluate(input: CompileExecutionGrantInput): PolicyCompilationResult {\n\t\tconst result = this.compiler.compile(input);\n\t\tif (result.outcome === \"allow\") {\n\t\t\tthis.runtime.bindAttemptGrant(input.attemptId, result.grant);\n\t\t} else if (result.outcome === \"approval-required\") {\n\t\t\tthis.runtime.requestApproval(result.approval);\n\t\t}\n\t\treturn result;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-registry.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/profile-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,cAAc,EACd,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EAEf,YAAY,EACZ,sBAAsB,EACtB,MAAM,gBAAgB,CAAC;AAiBxB,OAAO,EAGN,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,MAAM,sBAAsB,CAAC;AAG9B,MAAM,WAAW,eAAe;IAC/B,SAAS,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC;CACvD;AAED,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,KAAK,EAAE,yBAAyB,CAAC;IACjC,KAAK,EAAE,cAAc,CAAC;IACtB,aAAa,EAAE,SAAS,sBAAsB,EAAE,CAAC;CACjD;AAED,MAAM,MAAM,yBAAyB,GAClC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,GAC/C,OAAO,CAAC,uBAAuB,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,GACtD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,SAAS,EAAE,CAAC;IAAC,WAAW,EAAE,SAAS,CAAC,2BAA2B,CAAC,CAAA;CAAE,CAAC;AAEpG,qBAAa,yBAA0B,SAAQ,KAAK;IACnD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AAYD,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,GAAG,4BAA4B,CAiC9F;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAqLhF;AAUD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAmJnG;AAoBD,qBAAa,4BAA4B;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2C;IAEpE,YAAY,QAAQ,GAAE,SAAS,oBAAoB,EAAO,EA2CzD;IAED,QAAQ,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAM5C;IAED,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAGvD;IAED,IAAI,IAAI,oBAAoB,EAAE,CAE7B;CACD;AAED,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,eAAe,GACrB,yBAAyB,GAAG,SAAS,CAOvC;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACzC,OAAO,EAAE,4BAA4B,CAAC;IACtC,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,4BAA4B,CAAC;IACvC,MAAM,EAAE,eAAe,CAAC;IACxB,cAAc,EAAE,uBAAuB,CAAC;IACxC,aAAa,EAAE,SAAS,sBAAsB,EAAE,CAAC;IACjD,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IACtC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;CACtB,GAAG,yBAAyB,CAoC5B","sourcesContent":["import { describeToolCapabilityAuthority, resolveProfileToolCapability } from \"../tool-capability-policy.ts\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\nimport type {\n\tExecutionGrant,\n\tOrchestrationDispatchRequest,\n\tOrchestrationModelBinding,\n\tOrchestrationProfile,\n\tResourcePointer,\n\tRiskBudget,\n\tTaskContract,\n\tToolCapabilityManifest,\n} from \"./contracts.ts\";\nimport {\n\tHARNESS_CAPABILITIES,\n\tMAX_ORCHESTRATION_COLLECTION_LENGTH,\n\tMAX_ORCHESTRATION_DESCRIPTION_LENGTH,\n\tMAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH,\n\tMAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tORCHESTRATION_SCHEMA_VERSION,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttoJsonObject,\n\tWORKER_ROLES,\n} from \"./contracts.ts\";\nimport { ORCHESTRATION_PROFILE_TOOL_NAMES } from \"./lane-tool-manifests.ts\";\nimport {\n\ttype CompileExecutionGrantInput,\n\tDEFAULT_ROLE_CAPABILITY_CEILINGS,\n\ttype ExecutionPolicyCompiler,\n\ttype PolicyCompilationResult,\n} from \"./policy-compiler.ts\";\nimport { parseRiskBudget, validateRiskBudget } from \"./risk-budget.ts\";\n\nexport interface ModelHealthView {\n\tisHealthy(binding: OrchestrationModelBinding): boolean;\n}\n\nexport interface ProfileDispatchPlan {\n\tprofile: OrchestrationProfile;\n\tmodel: OrchestrationModelBinding;\n\tgrant: ExecutionGrant;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n}\n\nexport type ProfileDispatchPlanResult =\n\t| { outcome: \"allow\"; plan: ProfileDispatchPlan }\n\t| Exclude<PolicyCompilationResult, { outcome: \"allow\" }>\n\t| { outcome: \"deny\"; decisions: readonly []; reasonCodes: readonly [\"profile_model_unavailable\"] };\n\nexport class OrchestrationProfileError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"OrchestrationProfileError\";\n\t}\n}\n\nfunction duplicateStrings(values: readonly string[]): string[] {\n\tconst seen = new Set<string>();\n\tconst duplicates = new Set<string>();\n\tfor (const value of values) {\n\t\tif (seen.has(value)) duplicates.add(value);\n\t\tseen.add(value);\n\t}\n\treturn [...duplicates];\n}\n\nexport function parseOrchestrationDispatchRequest(value: unknown): OrchestrationDispatchRequest {\n\tif (!isPlainRecord(value)) throw new OrchestrationProfileError(\"Dispatch request must be an object.\");\n\tif (!hasOnlyKeys(value, [\"taskId\", \"profileId\", \"instructions\", \"resourcePointerIds\"])) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t\"Dispatch request contains an unsupported field. Model and thinking overrides are forbidden; select a profileId.\",\n\t\t);\n\t}\n\tif (\n\t\ttypeof value.taskId !== \"string\" ||\n\t\t!value.taskId ||\n\t\tvalue.taskId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.profileId !== \"string\" ||\n\t\t!value.profileId ||\n\t\tvalue.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.instructions !== \"string\" ||\n\t\tvalue.instructions.length > MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH ||\n\t\t!value.instructions.trim() ||\n\t\t!Array.isArray(value.resourcePointerIds) ||\n\t\tvalue.resourcePointerIds.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t!value.resourcePointerIds.every(\n\t\t\t(entry) =>\n\t\t\t\ttypeof entry === \"string\" && entry.length > 0 && entry.length <= MAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\t\t) ||\n\t\tnew Set(value.resourcePointerIds).size !== value.resourcePointerIds.length\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Dispatch request is invalid.\");\n\t}\n\treturn {\n\t\ttaskId: value.taskId,\n\t\tprofileId: value.profileId,\n\t\tinstructions: value.instructions.trim(),\n\t\tresourcePointerIds: [...value.resourcePointerIds],\n\t};\n}\n\nexport function validateOrchestrationProfile(profile: OrchestrationProfile): void {\n\tif (profile.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' has an unsupported schema version.`);\n\t}\n\tif (\n\t\tprofile.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t!profile.profileId.trim() ||\n\t\tprofile.description.length > MAX_ORCHESTRATION_DESCRIPTION_LENGTH ||\n\t\t!profile.description.trim()\n\t)\n\t\tthrow new OrchestrationProfileError(\"Profile id and description are required.\");\n\tif (profile.role !== \"orchestrator\" && profile.dispatchProfileIds.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Only orchestrator profiles may declare dispatchProfileIds ('${profile.profileId}').`,\n\t\t);\n\t}\n\tif (profile.dispatchProfileIds.includes(profile.profileId)) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' cannot dispatch itself.`);\n\t}\n\tif (profile.requireIndependentVerification) {\n\t\tif (profile.role === \"verifier\") {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Verifier profile '${profile.profileId}' cannot require another verifier.`,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t!profile.verificationProfileId?.trim() ||\n\t\t\tprofile.verificationProfileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' requires independent verification but has no verificationProfileId.`,\n\t\t\t);\n\t\t}\n\t} else if (profile.verificationProfileId !== undefined) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot declare verificationProfileId without requiring verification.`,\n\t\t);\n\t}\n\tif (profile.verificationProfileId === profile.profileId) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' cannot verify itself.`);\n\t}\n\tif (\n\t\t!profile.createdAt.trim() ||\n\t\tprofile.createdAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t!profile.updatedAt.trim() ||\n\t\tprofile.updatedAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' timestamps are invalid.`);\n\t}\n\tfor (const [label, values] of [\n\t\t[\"capabilityCeiling\", profile.capabilityCeiling],\n\t\t[\"toolNames\", profile.toolNames],\n\t\t[\"resourceProfileNames\", profile.resourceProfileNames],\n\t\t[\"dispatchProfileIds\", profile.dispatchProfileIds],\n\t] as const) {\n\t\tif (\n\t\t\tvalues.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tvalues.some((value) => !value.trim() || value.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH)\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' contains an invalid ${label}.`);\n\t\t}\n\t\tconst duplicates = duplicateStrings(values);\n\t\tif (duplicates.length > 0) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' contains duplicate ${label}: ${duplicates.join(\", \")}.`,\n\t\t\t);\n\t\t}\n\t}\n\tconst roleCeiling = new Set(DEFAULT_ROLE_CAPABILITY_CEILINGS[profile.role]);\n\tconst outOfRoleCapabilities = profile.capabilityCeiling.filter((capability) => !roleCeiling.has(capability));\n\tif (outOfRoleCapabilities.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' exceeds the ${profile.role} role ceiling: ${outOfRoleCapabilities.join(\", \")}.`,\n\t\t);\n\t}\n\tif (\n\t\tprofile.modelPolicy.candidates.length === 0 ||\n\t\tprofile.modelPolicy.candidates.length > MAX_ORCHESTRATION_COLLECTION_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' must declare a model candidate.`);\n\t}\n\tif (profile.modelPolicy.mode === \"fixed\" && profile.modelPolicy.candidates.length !== 1) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Fixed profile '${profile.profileId}' must declare exactly one model candidate.`,\n\t\t);\n\t}\n\tfor (const candidate of profile.modelPolicy.candidates) {\n\t\tif (\n\t\t\tcandidate.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\t!candidate.provider.trim() ||\n\t\t\tcandidate.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t\t!candidate.modelId.trim()\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' contains an invalid model binding.`);\n\t\t}\n\t}\n\tconst duplicateModels = duplicateStrings(\n\t\tprofile.modelPolicy.candidates.map((candidate) => `${candidate.provider}/${candidate.modelId}`),\n\t);\n\tif (duplicateModels.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' contains duplicate model candidates: ${duplicateModels.join(\", \")}.`,\n\t\t);\n\t}\n\tif (!Number.isSafeInteger(profile.maxConcurrent) || profile.maxConcurrent <= 0) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' maxConcurrent must be positive.`);\n\t}\n\tif (!Number.isSafeInteger(profile.leaseTtlMs) || profile.leaseTtlMs <= 0) {\n\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' leaseTtlMs must be positive.`);\n\t}\n\ttry {\n\t\tvalidateRiskBudget(profile.budget, `Profile '${profile.profileId}' budget`);\n\t} catch (error) {\n\t\tthrow new OrchestrationProfileError(error instanceof Error ? error.message : String(error));\n\t}\n\tif (profile.budget.maxWallClockMs !== undefined && profile.budget.maxWallClockMs <= 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' maxWallClockMs budget must be positive when specified.`,\n\t\t);\n\t}\n\tif (profile.budget.maxWallClockMs !== undefined && profile.leaseTtlMs < profile.budget.maxWallClockMs) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' leaseTtlMs must cover its maxWallClockMs budget.`,\n\t\t);\n\t}\n\tconst processCapable =\n\t\tprofile.capabilityCeiling.includes(\"process.exec\") || profile.capabilityCeiling.includes(\"tests.execute\");\n\tif (processCapable && (!profile.executionPolicy || profile.executionPolicy.allowedExecutables.length === 0)) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' must declare executionPolicy.allowedExecutables for process capabilities.`,\n\t\t);\n\t}\n\tif (!processCapable && profile.executionPolicy) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot declare executionPolicy without process capabilities.`,\n\t\t);\n\t}\n\tif (profile.executionPolicy) {\n\t\tif (\n\t\t\tprofile.executionPolicy.allowedExecutables.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tprofile.executionPolicy.allowedEnvironmentVariables.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t\tprofile.executionPolicy.allowedExecutables.some(\n\t\t\t\t(executable) =>\n\t\t\t\t\t!executable.trim() ||\n\t\t\t\t\texecutable.length > MAX_WORKER_AUTHORITY_PATH_LENGTH ||\n\t\t\t\t\t/[\\0\\r\\n]/.test(executable),\n\t\t\t) ||\n\t\t\tprofile.executionPolicy.allowedEnvironmentVariables.some(\n\t\t\t\t(name) => name.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(name),\n\t\t\t) ||\n\t\t\t!Number.isSafeInteger(profile.executionPolicy.maxOutputBytes) ||\n\t\t\tprofile.executionPolicy.maxOutputBytes <= 0 ||\n\t\t\tprofile.executionPolicy.maxOutputBytes > MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(`Profile '${profile.profileId}' executionPolicy is invalid.`);\n\t\t}\n\t}\n\tconst unrestrictedProcessTools = profile.toolNames.filter((toolName) =>\n\t\t[\"bash\", \"python\", \"powershell\", \"run_toolkit_script\"].includes(toolName),\n\t);\n\tif (unrestrictedProcessTools.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' cannot expose unrestricted process tools (${unrestrictedProcessTools.join(\", \")}); use run_process with executionPolicy.`,\n\t\t);\n\t}\n\tconst unknownTools = profile.toolNames.filter(\n\t\t(toolName) => !(ORCHESTRATION_PROFILE_TOOL_NAMES as readonly string[]).includes(toolName),\n\t);\n\tif (unknownTools.length > 0) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\t`Profile '${profile.profileId}' contains unclassified orchestration tools: ${unknownTools.join(\", \")}.`,\n\t\t);\n\t}\n\tfor (const toolName of profile.toolNames) {\n\t\tif (!resolveProfileToolCapability(profile, toolName)) {\n\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t`Profile '${profile.profileId}' tool '${toolName}' lacks ${describeToolCapabilityAuthority(toolName)} authority.`,\n\t\t\t);\n\t\t}\n\t}\n\ttoJsonObject({ profile });\n}\n\nfunction isStringArray(value: unknown, maxLength = MAX_ORCHESTRATION_IDENTIFIER_LENGTH): value is string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length <= MAX_ORCHESTRATION_COLLECTION_LENGTH &&\n\t\tvalue.every((entry) => typeof entry === \"string\" && entry.length > 0 && entry.length <= maxLength)\n\t);\n}\n\nexport function parseOrchestrationProfile(value: unknown, sourcePath?: string): OrchestrationProfile {\n\tif (!isPlainRecord(value)) throw new OrchestrationProfileError(\"Orchestration profile must be an object.\");\n\tif (\n\t\t!hasOnlyKeys(value, [\n\t\t\t\"schemaVersion\",\n\t\t\t\"profileId\",\n\t\t\t\"description\",\n\t\t\t\"role\",\n\t\t\t\"modelPolicy\",\n\t\t\t\"capabilityCeiling\",\n\t\t\t\"toolNames\",\n\t\t\t\"resourceProfileNames\",\n\t\t\t\"dispatchProfileIds\",\n\t\t\t\"executionPolicy\",\n\t\t\t\"budget\",\n\t\t\t\"maxConcurrent\",\n\t\t\t\"leaseTtlMs\",\n\t\t\t\"requireIndependentVerification\",\n\t\t\t\"verificationProfileId\",\n\t\t\t\"createdAt\",\n\t\t\t\"updatedAt\",\n\t\t])\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile contains an unsupported field.\");\n\t}\n\tconst modelPolicy = value.modelPolicy;\n\tconst rawBudget = value.budget;\n\tlet budget: RiskBudget;\n\tconst executionPolicy = value.executionPolicy;\n\tif (\n\t\t!isPlainRecord(modelPolicy) ||\n\t\t!hasOnlyKeys(modelPolicy, [\"mode\", \"candidates\"]) ||\n\t\t!Array.isArray(modelPolicy.candidates) ||\n\t\tmodelPolicy.candidates.length > MAX_ORCHESTRATION_COLLECTION_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile modelPolicy is invalid.\");\n\t}\n\ttry {\n\t\tbudget = parseRiskBudget(rawBudget, \"Orchestration profile budget\");\n\t} catch (error) {\n\t\tthrow new OrchestrationProfileError(\n\t\t\terror instanceof Error ? error.message : \"Orchestration profile budget is invalid.\",\n\t\t);\n\t}\n\tif (\n\t\texecutionPolicy !== undefined &&\n\t\t(!isPlainRecord(executionPolicy) ||\n\t\t\t!hasOnlyKeys(executionPolicy, [\"allowedExecutables\", \"allowedEnvironmentVariables\", \"maxOutputBytes\"]) ||\n\t\t\t!isStringArray(executionPolicy.allowedExecutables, MAX_WORKER_AUTHORITY_PATH_LENGTH) ||\n\t\t\t!isStringArray(executionPolicy.allowedEnvironmentVariables) ||\n\t\t\t!Number.isSafeInteger(executionPolicy.maxOutputBytes))\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile executionPolicy is invalid.\");\n\t}\n\tconst candidates = modelPolicy.candidates.map((candidate) => {\n\t\tif (!isPlainRecord(candidate) || !hasOnlyKeys(candidate, [\"provider\", \"modelId\", \"thinkingLevel\"])) {\n\t\t\tthrow new OrchestrationProfileError(\"Orchestration profile model candidate is invalid.\");\n\t\t}\n\t\tif (\n\t\t\ttypeof candidate.provider !== \"string\" ||\n\t\t\tcandidate.provider.length === 0 ||\n\t\t\tcandidate.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\ttypeof candidate.modelId !== \"string\" ||\n\t\t\tcandidate.modelId.length === 0 ||\n\t\t\tcandidate.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH ||\n\t\t\ttypeof candidate.thinkingLevel !== \"string\" ||\n\t\t\t!ORCHESTRATION_THINKING_LEVELS.includes(\n\t\t\t\tcandidate.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t\t\t)\n\t\t) {\n\t\t\tthrow new OrchestrationProfileError(\"Orchestration profile model candidate is invalid.\");\n\t\t}\n\t\treturn {\n\t\t\tprovider: candidate.provider,\n\t\t\tmodelId: candidate.modelId,\n\t\t\tthinkingLevel: candidate.thinkingLevel as (typeof ORCHESTRATION_THINKING_LEVELS)[number],\n\t\t};\n\t});\n\tif (\n\t\tvalue.schemaVersion !== ORCHESTRATION_SCHEMA_VERSION ||\n\t\ttypeof value.profileId !== \"string\" ||\n\t\tvalue.profileId.length === 0 ||\n\t\tvalue.profileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.description !== \"string\" ||\n\t\tvalue.description.length === 0 ||\n\t\tvalue.description.length > MAX_ORCHESTRATION_DESCRIPTION_LENGTH ||\n\t\ttypeof value.role !== \"string\" ||\n\t\t!WORKER_ROLES.includes(value.role as (typeof WORKER_ROLES)[number]) ||\n\t\t(modelPolicy.mode !== \"fixed\" && modelPolicy.mode !== \"ordered-fallback\") ||\n\t\t!Array.isArray(value.capabilityCeiling) ||\n\t\tvalue.capabilityCeiling.length > MAX_ORCHESTRATION_COLLECTION_LENGTH ||\n\t\t!value.capabilityCeiling.every(\n\t\t\t(capability) =>\n\t\t\t\ttypeof capability === \"string\" &&\n\t\t\t\tHARNESS_CAPABILITIES.includes(capability as (typeof HARNESS_CAPABILITIES)[number]),\n\t\t) ||\n\t\t!isStringArray(value.toolNames) ||\n\t\t!isStringArray(value.resourceProfileNames) ||\n\t\t!isStringArray(value.dispatchProfileIds) ||\n\t\t!Number.isSafeInteger(value.maxConcurrent) ||\n\t\t!Number.isSafeInteger(value.leaseTtlMs) ||\n\t\ttypeof value.requireIndependentVerification !== \"boolean\" ||\n\t\t(value.verificationProfileId !== undefined &&\n\t\t\t(typeof value.verificationProfileId !== \"string\" ||\n\t\t\t\tvalue.verificationProfileId.length === 0 ||\n\t\t\t\tvalue.verificationProfileId.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH)) ||\n\t\ttypeof value.createdAt !== \"string\" ||\n\t\tvalue.createdAt.length === 0 ||\n\t\tvalue.createdAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\ttypeof value.updatedAt !== \"string\" ||\n\t\tvalue.updatedAt.length === 0 ||\n\t\tvalue.updatedAt.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH\n\t) {\n\t\tthrow new OrchestrationProfileError(\"Orchestration profile is invalid.\");\n\t}\n\tconst profile = structuredClone({\n\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\tprofileId: value.profileId,\n\t\tdescription: value.description,\n\t\trole: value.role as OrchestrationProfile[\"role\"],\n\t\tmodelPolicy: { mode: modelPolicy.mode as OrchestrationProfile[\"modelPolicy\"][\"mode\"], candidates },\n\t\tcapabilityCeiling: value.capabilityCeiling as OrchestrationProfile[\"capabilityCeiling\"],\n\t\ttoolNames: value.toolNames,\n\t\tresourceProfileNames: value.resourceProfileNames,\n\t\tdispatchProfileIds: value.dispatchProfileIds,\n\t\t...(executionPolicy\n\t\t\t? {\n\t\t\t\t\texecutionPolicy: {\n\t\t\t\t\t\tallowedExecutables: executionPolicy.allowedExecutables as string[],\n\t\t\t\t\t\tallowedEnvironmentVariables: executionPolicy.allowedEnvironmentVariables as string[],\n\t\t\t\t\t\tmaxOutputBytes: Number(executionPolicy.maxOutputBytes),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tbudget,\n\t\tmaxConcurrent: Number(value.maxConcurrent),\n\t\tleaseTtlMs: Number(value.leaseTtlMs),\n\t\trequireIndependentVerification: value.requireIndependentVerification,\n\t\t...(typeof value.verificationProfileId === \"string\"\n\t\t\t? { verificationProfileId: value.verificationProfileId }\n\t\t\t: {}),\n\t\t...(sourcePath ? { sourcePath } : {}),\n\t\tcreatedAt: value.createdAt,\n\t\tupdatedAt: value.updatedAt,\n\t}) as OrchestrationProfile;\n\tvalidateOrchestrationProfile(profile);\n\treturn profile;\n}\n\nfunction freezeProfile(profile: OrchestrationProfile): OrchestrationProfile {\n\tconst clone = structuredClone(profile);\n\tfor (const candidate of clone.modelPolicy.candidates) Object.freeze(candidate);\n\tObject.freeze(clone.modelPolicy.candidates);\n\tObject.freeze(clone.modelPolicy);\n\tObject.freeze(clone.capabilityCeiling);\n\tObject.freeze(clone.toolNames);\n\tObject.freeze(clone.resourceProfileNames);\n\tObject.freeze(clone.dispatchProfileIds);\n\tif (clone.executionPolicy) {\n\t\tObject.freeze(clone.executionPolicy.allowedExecutables);\n\t\tObject.freeze(clone.executionPolicy.allowedEnvironmentVariables);\n\t\tObject.freeze(clone.executionPolicy);\n\t}\n\tObject.freeze(clone.budget);\n\treturn Object.freeze(clone);\n}\n\nexport class OrchestrationProfileRegistry {\n\tprivate readonly profiles = new Map<string, OrchestrationProfile>();\n\n\tconstructor(profiles: readonly OrchestrationProfile[] = []) {\n\t\tfor (const profile of profiles) this.register(profile);\n\t\tfor (const profile of this.profiles.values()) {\n\t\t\tfor (const dispatchedProfileId of profile.dispatchProfileIds) {\n\t\t\t\tconst target = this.profiles.get(dispatchedProfileId);\n\t\t\t\tif (!target) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' dispatches missing profile '${dispatchedProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (target.role === \"orchestrator\") {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' cannot recursively dispatch orchestrator '${dispatchedProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (profile.verificationProfileId) {\n\t\t\t\tconst verifier = this.profiles.get(profile.verificationProfileId);\n\t\t\t\tif (!verifier) {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' requires missing verifier profile '${profile.verificationProfileId}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (verifier.role !== \"verifier\") {\n\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t`Profile '${profile.profileId}' verificationProfileId '${profile.verificationProfileId}' is not a verifier.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (profile.role === \"orchestrator\") {\n\t\t\t\tfor (const dispatchedProfileId of profile.dispatchProfileIds) {\n\t\t\t\t\tconst worker = this.profiles.get(dispatchedProfileId);\n\t\t\t\t\tif (\n\t\t\t\t\t\tworker?.verificationProfileId &&\n\t\t\t\t\t\t!profile.dispatchProfileIds.includes(worker.verificationProfileId)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthrow new OrchestrationProfileError(\n\t\t\t\t\t\t\t`Orchestrator '${profile.profileId}' dispatches '${worker.profileId}' but not its verifier '${worker.verificationProfileId}'.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tregister(profile: OrchestrationProfile): void {\n\t\tvalidateOrchestrationProfile(profile);\n\t\tif (this.profiles.has(profile.profileId)) {\n\t\t\tthrow new OrchestrationProfileError(`Duplicate orchestration profile '${profile.profileId}'.`);\n\t\t}\n\t\tthis.profiles.set(profile.profileId, freezeProfile(profile));\n\t}\n\n\tget(profileId: string): OrchestrationProfile | undefined {\n\t\tconst profile = this.profiles.get(profileId);\n\t\treturn profile ? structuredClone(profile) : undefined;\n\t}\n\n\tlist(): OrchestrationProfile[] {\n\t\treturn [...this.profiles.values()].map((profile) => structuredClone(profile));\n\t}\n}\n\nexport function resolveProfileModel(\n\tprofile: OrchestrationProfile,\n\thealth: ModelHealthView,\n): OrchestrationModelBinding | undefined {\n\tif (profile.modelPolicy.mode === \"fixed\") {\n\t\tconst fixed = profile.modelPolicy.candidates[0];\n\t\treturn fixed && health.isHealthy(fixed) ? structuredClone(fixed) : undefined;\n\t}\n\tconst selected = profile.modelPolicy.candidates.find((candidate) => health.isHealthy(candidate));\n\treturn selected ? structuredClone(selected) : undefined;\n}\n\nexport function planProfileDispatch(args: {\n\trequest: OrchestrationDispatchRequest;\n\ttask: TaskContract;\n\tattemptId: string;\n\tsubjectId: string;\n\tregistry: OrchestrationProfileRegistry;\n\thealth: ModelHealthView;\n\tpolicyCompiler: ExecutionPolicyCompiler;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\tresources: readonly ResourcePointer[];\n\treadPaths: readonly string[];\n\twritePaths?: readonly string[];\n\tdeniedPaths?: readonly string[];\n\tpolicyVersion: string;\n}): ProfileDispatchPlanResult {\n\tconst profile = args.registry.get(args.request.profileId);\n\tif (!profile) return { outcome: \"deny\", decisions: [], reasonCodes: [\"profile_model_unavailable\"] };\n\tif (profile.role !== args.task.role) {\n\t\treturn { outcome: \"deny\", decisions: [], reasonCodes: [\"required_capability_exceeds_role_ceiling\"] };\n\t}\n\tconst model = resolveProfileModel(profile, args.health);\n\tif (!model) return { outcome: \"deny\", decisions: [], reasonCodes: [\"profile_model_unavailable\"] };\n\tconst selectedResources = args.resources.filter((resource) => args.request.resourcePointerIds.includes(resource.id));\n\tconst manifestsByName = new Map(args.toolManifests.map((manifest) => [manifest.toolName, manifest]));\n\tconst requestedTools = profile.toolNames.filter((toolName) => {\n\t\tconst manifest = manifestsByName.get(toolName);\n\t\treturn manifest?.capabilities.every((capability) => args.task.requiredCapabilities.includes(capability)) === true;\n\t});\n\tconst policyInput: CompileExecutionGrantInput = {\n\t\tobjectiveId: args.task.objectiveId,\n\t\ttaskId: args.task.taskId,\n\t\tattemptId: args.attemptId,\n\t\tsubjectId: args.subjectId,\n\t\trole: profile.role,\n\t\trequiredCapabilities: args.task.requiredCapabilities,\n\t\trequestedCapabilities: args.task.requiredCapabilities,\n\t\tauthorityCapabilities: profile.capabilityCeiling,\n\t\trequestedTools,\n\t\ttoolManifests: args.toolManifests,\n\t\tresources: selectedResources,\n\t\treadPaths: args.readPaths,\n\t\twritePaths: args.writePaths,\n\t\tdeniedPaths: args.deniedPaths,\n\t\trequestedBudget: profile.budget,\n\t\tauthorityBudget: profile.budget,\n\t\tpolicyVersion: args.policyVersion,\n\t};\n\tconst compiled = args.policyCompiler.compile(policyInput);\n\tif (compiled.outcome !== \"allow\") return compiled;\n\treturn { outcome: \"allow\", plan: { profile, model, grant: compiled.grant, toolManifests: compiled.toolManifests } };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"profile-registry.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/profile-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,cAAc,EACd,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EAEf,YAAY,EACZ,sBAAsB,EACtB,MAAM,gBAAgB,CAAC;AAiBxB,OAAO,EAGN,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,MAAM,sBAAsB,CAAC;AAG9B,MAAM,WAAW,eAAe;IAC/B,SAAS,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC;CACvD;AAED,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,KAAK,EAAE,yBAAyB,CAAC;IACjC,KAAK,EAAE,cAAc,CAAC;IACtB,aAAa,EAAE,SAAS,sBAAsB,EAAE,CAAC;CACjD;AAED,MAAM,MAAM,yBAAyB,GAClC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,GAC/C,OAAO,CAAC,uBAAuB,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE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M,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;CACtB,GAAG,yBAAyB,CAoC5B"}
|
|
@@ -333,8 +333,8 @@ function freezeProfile(profile) {
|
|
|
333
333
|
return Object.freeze(clone);
|
|
334
334
|
}
|
|
335
335
|
export class OrchestrationProfileRegistry {
|
|
336
|
-
profiles = new Map();
|
|
337
336
|
constructor(profiles = []) {
|
|
337
|
+
this.profiles = new Map();
|
|
338
338
|
for (const profile of profiles)
|
|
339
339
|
this.register(profile);
|
|
340
340
|
for (const profile of this.profiles.values()) {
|