@caupulican/pi-adaptative 0.85.4 → 0.86.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 +65 -0
- package/dist/bun/cli.d.ts +1 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +1 -0
- package/dist/bun/cli.js.map +1 -1
- package/dist/core/agent-paths.d.ts +3 -3
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +3 -3
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +1 -1
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +11 -5
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +14 -3
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -2
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +2 -2
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +19 -8
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts +11 -5
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +34 -8
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.d.ts +3 -3
- package/dist/core/autonomy/subagent-prompt.js +9 -9
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +10 -8
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +23 -13
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bash-execution-controller.d.ts +4 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +11 -4
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/bash-executor.d.ts +2 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +4 -3
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/billing-failover-controller.d.ts +2 -2
- package/dist/core/billing-failover-controller.d.ts.map +1 -1
- package/dist/core/billing-failover-controller.js +1 -1
- package/dist/core/billing-failover-controller.js.map +1 -1
- package/dist/core/capability-contract.d.ts +1 -1
- package/dist/core/capability-contract.d.ts.map +1 -1
- package/dist/core/capability-contract.js +0 -1
- package/dist/core/capability-contract.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +8 -2
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +73 -3
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +2 -2
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +9 -1
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/artifact-retrieval.d.ts +1 -1
- package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
- package/dist/core/context/artifact-retrieval.js +1 -1
- package/dist/core/context/artifact-retrieval.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts +6 -6
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +151 -63
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-composition.js +1 -1
- package/dist/core/context/context-composition.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js +5 -2
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/file-store-memory-provider.js +1 -1
- package/dist/core/context/file-store-memory-provider.js.map +1 -1
- package/dist/core/context/tool-output-packer.d.ts +1 -1
- package/dist/core/context/tool-output-packer.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.js +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 +7 -5
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +2 -2
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +8 -4
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js +1 -1
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js +2 -2
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/cost/session-usage.d.ts +1 -1
- package/dist/core/cost/session-usage.d.ts.map +1 -1
- package/dist/core/cost/session-usage.js +1 -1
- package/dist/core/cost/session-usage.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts +1 -0
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +3 -2
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/worker-actions.js +1 -1
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +27 -8
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +191 -33
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts +45 -6
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js +110 -13
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +180 -160
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts +23 -0
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-authority-resolver.js +128 -0
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -0
- package/dist/core/delegation/worker-conversation-store.d.ts +2 -1
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
- package/dist/core/delegation/worker-conversation-store.js +4 -3
- package/dist/core/delegation/worker-conversation-store.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +7 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +260 -87
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +25 -4
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js +90 -1
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts +2 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js +22 -12
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-lifecycle.d.ts +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +4 -2
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.d.ts +0 -2
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.js +8 -35
- 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 +1 -0
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +6 -1
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +20 -6
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +47 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.js +210 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -0
- package/dist/core/extensions/builtin.d.ts +2 -2
- package/dist/core/extensions/builtin.d.ts.map +1 -1
- package/dist/core/extensions/builtin.js +2 -2
- package/dist/core/extensions/builtin.js.map +1 -1
- package/dist/core/extensions/bundled-virtual-modules.d.ts +2 -0
- package/dist/core/extensions/bundled-virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/bundled-virtual-modules.js +129 -0
- package/dist/core/extensions/bundled-virtual-modules.js.map +1 -0
- package/dist/core/extensions/factory-runtime.d.ts +22 -0
- package/dist/core/extensions/factory-runtime.d.ts.map +1 -0
- package/dist/core/extensions/factory-runtime.js +334 -0
- package/dist/core/extensions/factory-runtime.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/lifecycle.d.ts +13 -0
- package/dist/core/extensions/lifecycle.d.ts.map +1 -0
- package/dist/core/extensions/lifecycle.js +52 -0
- package/dist/core/extensions/lifecycle.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +3 -24
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +21 -531
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +51 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +59 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/foreground-recovery-controller.d.ts +2 -1
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +3 -3
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/goal-loop-controller.js +1 -1
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts +1 -1
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
- package/dist/core/goals/compact-goal-context.js +1 -1
- package/dist/core/goals/compact-goal-context.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +1 -1
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +1 -1
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +1 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +1 -1
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory/providers/user-memory-archive.js +1 -1
- package/dist/core/memory/providers/user-memory-archive.js.map +1 -1
- package/dist/core/model-registry.d.ts +2 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +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-controller.js +1 -1
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.js +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +1 -1
- package/dist/core/model-tool-protocol.d.ts.map +1 -1
- package/dist/core/model-tool-protocol.js +1 -1
- package/dist/core/model-tool-protocol.js.map +1 -1
- package/dist/core/models/llamacpp-runtime.d.ts +7 -0
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
- package/dist/core/models/llamacpp-runtime.js +8 -3
- package/dist/core/models/llamacpp-runtime.js.map +1 -1
- package/dist/core/models/local-runtime.js +1 -1
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/runtime-process.d.ts.map +1 -1
- package/dist/core/models/runtime-process.js +5 -18
- package/dist/core/models/runtime-process.js.map +1 -1
- package/dist/core/orchestration/bounded-string-array.d.ts +11 -0
- package/dist/core/orchestration/bounded-string-array.d.ts.map +1 -0
- package/dist/core/orchestration/bounded-string-array.js +17 -0
- package/dist/core/orchestration/bounded-string-array.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +16 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +38 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +11 -3
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +0 -1
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +3 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/event-store.d.ts +12 -10
- package/dist/core/orchestration/event-store.d.ts.map +1 -1
- package/dist/core/orchestration/event-store.js +94 -104
- package/dist/core/orchestration/event-store.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js +4 -1
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/model-binding.d.ts +1 -1
- package/dist/core/orchestration/model-binding.d.ts.map +1 -1
- package/dist/core/orchestration/model-binding.js +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 +8 -9
- package/dist/core/orchestration/policy-compiler.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +4 -10
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/task-profile-writer.js +1 -1
- package/dist/core/orchestration/task-profile-writer.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 +58 -3
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js +10 -17
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/process-matrix/runtime.d.ts +15 -1
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js +55 -34
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +4 -3
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +2 -2
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/research/model-fitness-controller.js +1 -1
- package/dist/core/research/model-fitness-controller.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts +2 -2
- package/dist/core/research/research-lane-controller.d.ts.map +1 -1
- package/dist/core/research/research-lane-controller.js +1 -1
- package/dist/core/research/research-lane-controller.js.map +1 -1
- package/dist/core/resource-loader.d.ts +10 -19
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +8 -70
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.js +3 -3
- 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 +47 -18
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts +1 -1
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +1 -1
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/bitwarden-credential-storage.d.ts +51 -0
- package/dist/core/secrets/bitwarden-credential-storage.d.ts.map +1 -0
- package/dist/core/secrets/bitwarden-credential-storage.js +345 -0
- package/dist/core/secrets/bitwarden-credential-storage.js.map +1 -0
- package/dist/core/secrets/credential-exposure-guard.d.ts +8 -4
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +31 -29
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/secrets/credential-manager.d.ts +109 -0
- package/dist/core/secrets/credential-manager.d.ts.map +1 -0
- package/dist/core/secrets/credential-manager.js +384 -0
- package/dist/core/secrets/credential-manager.js.map +1 -0
- package/dist/core/secrets/credential-project.d.ts +4 -0
- package/dist/core/secrets/credential-project.d.ts.map +1 -0
- package/dist/core/secrets/credential-project.js +145 -0
- package/dist/core/secrets/credential-project.js.map +1 -0
- package/dist/core/secrets/secret-dotenv.d.ts +1 -1
- package/dist/core/secrets/secret-dotenv.js +1 -1
- package/dist/core/secrets/secret-dotenv.js.map +1 -1
- package/dist/core/security/context-threat-scanner.d.ts +14 -0
- package/dist/core/security/context-threat-scanner.d.ts.map +1 -0
- package/dist/core/security/context-threat-scanner.js +71 -0
- package/dist/core/security/context-threat-scanner.js.map +1 -0
- package/dist/core/session-supervision-runtime.d.ts +4 -1
- package/dist/core/session-supervision-runtime.d.ts.map +1 -1
- package/dist/core/session-supervision-runtime.js +49 -11
- package/dist/core/session-supervision-runtime.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +10 -6
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tool-capability-policy.js +2 -2
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tool-recovery-logger.js +1 -1
- package/dist/core/tool-recovery-logger.js.map +1 -1
- package/dist/core/tools/artifact-retrieve.js +1 -1
- package/dist/core/tools/artifact-retrieve.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +16 -4
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +29 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +179 -28
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/extensionify-runtime.d.ts +44 -0
- package/dist/core/tools/extensionify-runtime.d.ts.map +1 -0
- package/dist/core/tools/extensionify-runtime.js +115 -0
- package/dist/core/tools/extensionify-runtime.js.map +1 -0
- package/dist/core/tools/extensionify.d.ts +9 -30
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js +10 -140
- package/dist/core/tools/extensionify.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 +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts +1 -0
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +1 -1
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/index.d.ts +2 -4
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +7 -43
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +1 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/profile-writer.js +3 -3
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/core/tools/python.d.ts +2 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js +17 -12
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/render-utils.js +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/run-process.d.ts +2 -0
- package/dist/core/tools/run-process.d.ts.map +1 -1
- package/dist/core/tools/run-process.js +7 -3
- package/dist/core/tools/run-process.js.map +1 -1
- package/dist/core/tools/search-command-guard.d.ts +8 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -1
- package/dist/core/tools/search-command-guard.js +54 -0
- package/dist/core/tools/search-command-guard.js.map +1 -1
- package/dist/core/tools/secret-store.d.ts +8 -18
- package/dist/core/tools/secret-store.d.ts.map +1 -1
- package/dist/core/tools/secret-store.js +83 -348
- package/dist/core/tools/secret-store.js.map +1 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +9 -4
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-session.d.ts.map +1 -1
- package/dist/core/tools/shell-session.js +6 -4
- package/dist/core/tools/shell-session.js.map +1 -1
- package/dist/core/tools/tool-definition-factory.d.ts +32 -0
- package/dist/core/tools/tool-definition-factory.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-factory.js +55 -0
- package/dist/core/tools/tool-definition-factory.js.map +1 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +79 -32
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +24 -18
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +1 -1
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +35 -14
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +1 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.js +1 -1
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +27 -4
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/secret-menu-controller.d.ts +21 -0
- package/dist/modes/interactive/secret-menu-controller.d.ts.map +1 -0
- package/dist/modes/interactive/secret-menu-controller.js +276 -0
- package/dist/modes/interactive/secret-menu-controller.js.map +1 -0
- package/dist/utils/child-process.js +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +2 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +43 -48
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/zip-extractor.d.ts +8 -0
- package/dist/utils/zip-extractor.d.ts.map +1 -0
- package/dist/utils/zip-extractor.js +275 -0
- package/dist/utils/zip-extractor.js.map +1 -0
- package/docs/harness-architecture.md +34 -22
- package/docs/index.md +1 -1
- package/docs/resources.md +1 -1
- package/docs/settings.md +39 -103
- package/docs/usage.md +7 -5
- package/docs/worker-profiles.md +9 -7
- 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 +12 -12
- package/package.json +7 -5
- package/dist/core/secrets/secret-vault-format.d.ts +0 -112
- package/dist/core/secrets/secret-vault-format.d.ts.map +0 -1
- package/dist/core/secrets/secret-vault-format.js +0 -396
- package/dist/core/secrets/secret-vault-format.js.map +0 -1
- package/dist/core/secrets/secret-vault.d.ts +0 -72
- package/dist/core/secrets/secret-vault.d.ts.map +0 -1
- package/dist/core/secrets/secret-vault.js +0 -663
- package/dist/core/secrets/secret-vault.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegation-ledger.js","sourceRoot":"","sources":["../../../src/core/orchestration/delegation-ledger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAWxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAA4B,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AA8ClH,SAAS,aAAa,CAAC,OAA4B;IAClD,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,IAA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EAAE,CAAC;gBACxE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;gBACpE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;gBACtC,SAAS;YACV,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACvC,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,CAC7C,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,aAAa,KAAK,iBAAiB,CAChG,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { WorkerDelegationTaskContext } from \"../delegation/worker-delegation-request.ts\";\nimport { deriveWorkerTaskLabel } from \"../delegation/worker-task-label.ts\";\nimport { hasGoalAcceptanceOverride } from \"../goals/goal-acceptance.ts\";\nimport type { GoalState } from \"../goals/goal-state.ts\";\nimport type {\n\tAgentBindingContract,\n\tAttemptUsageSnapshot,\n\tHarnessCapability,\n\tOrchestrationDispatchRequest,\n\tRiskBudget,\n\tWorkerExecutionContract,\n\tWorkerRole,\n} from \"./contracts.ts\";\nimport { OrchestrationEventStore } from \"./event-store.ts\";\nimport { type AttemptRuntimeState, DurableTaskRuntime, DurableTaskRuntimeError } from \"./task-runtime.ts\";\nimport { goalObjectiveId, projectGoalAcceptanceEvidence, projectGoalObjective } from \"./work-state-projection.ts\";\n\nexport interface DelegationLedgerOptions {\n\tagentDir: string;\n\tsessionId: string;\n\tnow?: () => number;\n}\n\nexport interface PrepareDelegationInput {\n\tlaneId: string;\n\tinstructions: string;\n\texecutionContract: WorkerExecutionContract;\n\trequiredCapabilities: readonly HarnessCapability[];\n\tgoal?: GoalState;\n\tverificationOfTaskId?: string;\n\ttaskContext?: WorkerDelegationTaskContext;\n}\n\nexport interface PrepareManagedDelegationInput {\n\tlaneId: string;\n\tdispatchSequence: number;\n\tinstructions: string;\n\tprofileId: string;\n\tprovider: string;\n\tauthorizationId: string;\n\trole: WorkerRole;\n\triskBudget: RiskBudget;\n\tgoal?: GoalState;\n\tgoalId?: string;\n\tworktreeLaneKey?: string;\n}\n\nexport interface StartedDelegationAttempt {\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tleaseId: string;\n\tfencingToken: number;\n\texpiresAt: string;\n}\n\nexport interface PrepareAgentTurnInput {\n\tagentId: string;\n\tinstructions: string;\n}\n\nfunction activeAttempt(attempt: AttemptRuntimeState): boolean {\n\treturn attempt.status === \"queued\" || attempt.status === \"leased\" || attempt.status === \"running\";\n}\n\n/**\n * Durable adapter for in-process delegated completions. It records the dispatch before execution,\n * fences interrupted completions on restart, and returns queued work for event-driven re-dispatch.\n * It deliberately does not pretend an isolated completion has a resumable model transcript.\n */\nexport class DelegationOrchestrationLedger {\n\treadonly runtime: DurableTaskRuntime;\n\tprivate readonly sessionId: string;\n\n\tconstructor(options: DelegationLedgerOptions) {\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.runtime = new DurableTaskRuntime({\n\t\t\tstore: new OrchestrationEventStore({ agentDir: options.agentDir, sessionId: options.sessionId }),\n\t\t\tnow: options.now,\n\t\t});\n\t}\n\n\tprepare(input: PrepareDelegationInput): AttemptRuntimeState {\n\t\tconst profile = input.executionContract.worker.profile;\n\t\treturn this.prepareNormalized({\n\t\t\tlaneId: input.laneId,\n\t\t\tinstructions: input.instructions,\n\t\t\tprofileId: profile.profileId,\n\t\t\trole: profile.role,\n\t\t\trequiredCapabilities: input.requiredCapabilities,\n\t\t\triskBudget: profile.budget,\n\t\t\texecutionContract: input.executionContract,\n\t\t\t...(input.goal ? { goal: input.goal } : {}),\n\t\t\t...(input.verificationOfTaskId ? { verificationOfTaskId: input.verificationOfTaskId } : {}),\n\t\t\t...(input.taskContext ? { taskContext: input.taskContext } : {}),\n\t\t});\n\t}\n\n\tprepareManaged(input: PrepareManagedDelegationInput): AttemptRuntimeState {\n\t\tif (!Number.isSafeInteger(input.dispatchSequence) || input.dispatchSequence < 1) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Managed dispatch sequence must be a positive integer.\");\n\t\t}\n\t\tconst taskId = `${input.laneId}:turn:${input.dispatchSequence}`;\n\t\treturn this.prepareNormalized({\n\t\t\tlaneId: taskId,\n\t\t\tinstructions: input.instructions,\n\t\t\tprofileId: input.profileId,\n\t\t\trole: input.role,\n\t\t\trequiredCapabilities: [],\n\t\t\triskBudget: input.riskBudget,\n\t\t\t...(input.goal ? { goal: input.goal } : {}),\n\t\t\t...(input.goalId ? { goalId: input.goalId } : {}),\n\t\t\tdispatchMetadata: {\n\t\t\t\texecutionKind: \"managed-process\",\n\t\t\t\tlogicalLaneId: input.laneId,\n\t\t\t\tdispatchSequence: input.dispatchSequence,\n\t\t\t\tprovider: input.provider,\n\t\t\t\tauthorizationId: input.authorizationId,\n\t\t\t\t...(input.worktreeLaneKey ? { worktreeLaneKey: input.worktreeLaneKey } : {}),\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Queue one new turn for an existing logical agent. The agent identity and its immutable\n\t * execution contract are inherited from the last bound turn; the durable task and attempt ids\n\t * are intentionally new so retries, leases, and terminal evidence never collide across turns.\n\t */\n\tprepareAgentTurn(input: PrepareAgentTurnInput): AttemptRuntimeState {\n\t\tconst agentId = input.agentId.trim();\n\t\tconst instructions = input.instructions.trim();\n\t\tif (!agentId) throw new DurableTaskRuntimeError(\"Logical worker agent id is required.\");\n\t\tif (!instructions) throw new DurableTaskRuntimeError(\"Worker follow-up instructions are required.\");\n\t\tconst snapshot = this.runtime.getSnapshot();\n\t\tconst agent = snapshot.agents[agentId];\n\t\tif (!agent) throw new DurableTaskRuntimeError(`Unknown logical worker agent '${agentId}'.`);\n\t\tif (agent.status !== \"registered\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Logical worker agent '${agentId}' is not idle.`);\n\t\t}\n\t\tconst prior = this.latestAgentAttempt(snapshot, agent);\n\t\tconst contract = prior?.dispatch.executionContract;\n\t\tif (!prior || !contract) {\n\t\t\tthrow new DurableTaskRuntimeError(`Logical worker agent '${agentId}' has no immutable execution contract.`);\n\t\t}\n\t\tconst priorTask = snapshot.tasks[prior.taskId]?.task;\n\t\tif (!priorTask) throw new DurableTaskRuntimeError(`Logical worker agent '${agentId}' has no prior durable task.`);\n\t\tconst sequence = Object.values(snapshot.attempts).filter((attempt) => attempt.agentId === agentId).length + 1;\n\t\tconst taskId = `${agentId}:turn:${sequence}`;\n\t\tif (snapshot.tasks[taskId]) {\n\t\t\tthrow new DurableTaskRuntimeError(`Logical worker agent '${agentId}' already has turn ${sequence}.`);\n\t\t}\n\t\treturn this.prepareNormalized({\n\t\t\tlaneId: taskId,\n\t\t\tinstructions,\n\t\t\tprofileId: contract.worker.profile.profileId,\n\t\t\trole: agent.role,\n\t\t\trequiredCapabilities: contract.worker.authority.capabilities,\n\t\t\triskBudget: contract.worker.profile.budget,\n\t\t\ttaskContext: {\n\t\t\t\trequirementIds: prior.dispatch.requirementIds ?? [],\n\t\t\t\tdependsOnTaskIds: priorTask.dependsOn,\n\t\t\t\tacceptanceCriterionIds: priorTask.acceptanceCriterionIds,\n\t\t\t\tresourcePointerIds: prior.dispatch.resourcePointerIds,\n\t\t\t},\n\t\t\texecutionContract: contract,\n\t\t\tdispatchMetadata: {\n\t\t\t\tlogicalLaneId: agentId,\n\t\t\t\tdispatchSequence: sequence,\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate latestAgentAttempt(\n\t\tsnapshot: ReturnType<DurableTaskRuntime[\"getSnapshot\"]>,\n\t\tagent: AgentBindingContract,\n\t): AttemptRuntimeState | undefined {\n\t\treturn Object.values(snapshot.attempts)\n\t\t\t.filter((attempt) => attempt.agentId === agent.agentId)\n\t\t\t.sort((left, right) => left.createdAt.localeCompare(right.createdAt))\n\t\t\t.at(-1);\n\t}\n\n\tprivate prepareNormalized(input: {\n\t\tlaneId: string;\n\t\tinstructions: string;\n\t\tprofileId: string;\n\t\trole: WorkerRole;\n\t\trequiredCapabilities: readonly HarnessCapability[];\n\t\triskBudget: RiskBudget;\n\t\tgoal?: GoalState;\n\t\tgoalId?: string;\n\t\tverificationOfTaskId?: string;\n\t\ttaskContext?: WorkerDelegationTaskContext;\n\t\texecutionContract?: WorkerExecutionContract;\n\t\tdispatchMetadata?: Pick<\n\t\t\tOrchestrationDispatchRequest,\n\t\t\t\"executionKind\" | \"logicalLaneId\" | \"dispatchSequence\" | \"provider\" | \"authorizationId\" | \"worktreeLaneKey\"\n\t\t>;\n\t}): AttemptRuntimeState {\n\t\tlet snapshot = this.runtime.getSnapshot();\n\t\tconst existingVerificationSubject = input.verificationOfTaskId\n\t\t\t? snapshot.tasks[input.verificationOfTaskId]\n\t\t\t: undefined;\n\t\tif (input.verificationOfTaskId && !existingVerificationSubject) {\n\t\t\tthrow new DurableTaskRuntimeError(`Unknown verification subject '${input.verificationOfTaskId}'.`);\n\t\t}\n\t\tconst projectedGoal = input.goal ? projectGoalObjective(input.goal) : undefined;\n\t\tconst objectiveId =\n\t\t\texistingVerificationSubject?.task.objectiveId ??\n\t\t\tprojectedGoal?.objectiveId ??\n\t\t\t(input.goalId ? goalObjectiveId(input.goalId) : `session:${this.sessionId}`);\n\t\tif (input.goal && objectiveId === projectedGoal?.objectiveId) {\n\t\t\tthis.synchronizeGoalState(input.goal);\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t} else if (!snapshot.objectives[objectiveId]) {\n\t\t\tthis.runtime.createObjective({\n\t\t\t\tobjectiveId,\n\t\t\t\ttitle: input.goalId ? `Goal ${input.goalId}` : `Session ${this.sessionId}`,\n\t\t\t\tdescription: input.goalId ? \"Externally managed goal work\" : \"Session-scoped delegated work\",\n\t\t\t});\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\n\t\tif (!snapshot.tasks[input.laneId]) {\n\t\t\tconst verificationSubject = input.verificationOfTaskId\n\t\t\t\t? snapshot.tasks[input.verificationOfTaskId]\n\t\t\t\t: undefined;\n\t\t\tthis.runtime.createTask({\n\t\t\t\ttaskId: input.laneId,\n\t\t\t\tobjectiveId,\n\t\t\t\ttitle: deriveWorkerTaskLabel(input.instructions, `Delegated ${input.role} work`),\n\t\t\t\tdescription: input.instructions,\n\t\t\t\trole: input.role,\n\t\t\t\tdependsOn: input.taskContext?.dependsOnTaskIds ?? [],\n\t\t\t\trequiredCapabilities: input.requiredCapabilities,\n\t\t\t\tacceptanceCriterionIds: input.taskContext?.acceptanceCriterionIds ?? [],\n\t\t\t\triskBudget: input.riskBudget,\n\t\t\t\t...(input.verificationOfTaskId\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tverificationOfTaskId: input.verificationOfTaskId,\n\t\t\t\t\t\t\tacceptanceCriterionIds: verificationSubject?.task.acceptanceCriterionIds ?? [],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\n\t\tconst task = snapshot.tasks[input.laneId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Failed to create task '${input.laneId}'.`);\n\t\tconst existing = [...task.attemptIds]\n\t\t\t.reverse()\n\t\t\t.map((attemptId) => snapshot.attempts[attemptId])\n\t\t\t.find((attempt): attempt is AttemptRuntimeState => attempt !== undefined && activeAttempt(attempt));\n\t\tif (existing) return existing;\n\n\t\treturn this.runtime.queueAttempt(input.laneId, {\n\t\t\ttaskId: input.laneId,\n\t\t\tprofileId: input.profileId,\n\t\t\tinstructions: input.instructions,\n\t\t\tresourcePointerIds: input.taskContext?.resourcePointerIds ?? [],\n\t\t\trequirementIds: input.taskContext?.requirementIds ?? [],\n\t\t\t...(input.executionContract ? { executionContract: input.executionContract } : {}),\n\t\t\t...input.dispatchMetadata,\n\t\t});\n\t}\n\n\tsynchronizeGoalState(goal: GoalState): void {\n\t\tconst objective = projectGoalObjective(goal);\n\t\tthis.runtime.ensureObjective(objective);\n\t\tfor (const evidence of projectGoalAcceptanceEvidence(goal)) {\n\t\t\tthis.runtime.recordObjectiveEvidence(objective.objectiveId, evidence);\n\t\t}\n\t\tconst status = this.runtime.getSnapshot().objectives[goalObjectiveId(goal.goalId)]?.objective.status;\n\t\tswitch (goal.status) {\n\t\t\tcase \"active\":\n\t\t\t\tif (status === \"paused\") this.runtime.resumeObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"paused\":\n\t\t\tcase \"blocked\":\n\t\t\tcase \"usage_limited\":\n\t\t\tcase \"budget_limited\":\n\t\t\t\tif (status === \"active\") this.runtime.pauseObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"cancelled\":\n\t\t\t\tif (status !== \"cancelled\") this.runtime.cancelObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"completed\":\n\t\t\t\tif (status !== \"completed\") {\n\t\t\t\t\tthis.runtime.completeObjectiveFromOwner(objective.objectiveId, hasGoalAcceptanceOverride(goal));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tstart(\n\t\tattemptId: string,\n\t\tleaseTtlMs: number,\n\t\townerId = `in-process:${this.sessionId}`,\n\t\tagentId?: string,\n\t): StartedDelegationAttempt {\n\t\tconst snapshot = this.runtime.getSnapshot();\n\t\tconst attempt = snapshot.attempts[attemptId];\n\t\tif (!attempt) throw new DurableTaskRuntimeError(`Unknown attempt '${attemptId}'.`);\n\t\tconst task = snapshot.tasks[attempt.taskId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Unknown task '${attempt.taskId}'.`);\n\t\tconst lease = this.runtime.leaseAttempt(attemptId, ownerId, leaseTtlMs, agentId);\n\t\tthis.runtime.startAttempt(attemptId, lease.leaseId, lease.fencingToken);\n\t\treturn {\n\t\t\tobjectiveId: task.task.objectiveId,\n\t\t\ttaskId: task.task.taskId,\n\t\t\tattemptId,\n\t\t\tleaseId: lease.leaseId,\n\t\t\tfencingToken: lease.fencingToken,\n\t\t\texpiresAt: lease.expiresAt,\n\t\t};\n\t}\n\n\tcancel(attemptId: string, reasonCode: string): void {\n\t\tthis.runtime.cancelAttempt(attemptId, reasonCode);\n\t}\n\n\t/** Latest fenced cumulative usage, if this attempt has crossed a durable checkpoint boundary. */\n\tgetAttemptUsage(attemptId: string): AttemptUsageSnapshot | undefined {\n\t\tconst snapshot = this.runtime.getSnapshot();\n\t\tconst attempt = snapshot.attempts[attemptId];\n\t\tif (!attempt) throw new DurableTaskRuntimeError(`Unknown attempt '${attemptId}'.`);\n\t\tfor (const checkpointId of [...attempt.checkpointIds].reverse()) {\n\t\t\tconst usage = snapshot.checkpoints[checkpointId]?.usage;\n\t\t\tif (usage) return structuredClone(usage);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Fence interrupted isolated completions and queue one replacement attempt per task. */\n\trecoverQueuedDispatches(): AttemptRuntimeState[] {\n\t\tthis.runtime.recoverInterruptedUnboundAttempts((attempt) => attempt.dispatch.executionKind !== \"managed-process\");\n\t\tlet snapshot = this.runtime.getSnapshot();\n\t\tfor (const task of Object.values(snapshot.tasks)) {\n\t\t\tconst attempts = task.attemptIds.map((attemptId) => snapshot.attempts[attemptId]).filter(Boolean);\n\t\t\tif (attempts.some((attempt) => attempt && activeAttempt(attempt))) continue;\n\t\t\tconst interrupted = [...attempts].reverse().find((attempt) => attempt?.status === \"expired\");\n\t\t\tif (!interrupted || task.task.status !== \"ready\") continue;\n\t\t\tconst maxAttempts = task.task.riskBudget.maxAttempts;\n\t\t\tif (maxAttempts !== undefined && task.attemptIds.length >= maxAttempts) {\n\t\t\t\tthis.runtime.failTask(task.task.taskId, \"attempt_budget_exhausted\");\n\t\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.runtime.queueAttempt(task.task.taskId, interrupted.dispatch);\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\t\treturn Object.values(snapshot.attempts).filter(\n\t\t\t(attempt) => attempt.status === \"queued\" && attempt.dispatch.executionKind !== \"managed-process\",\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"delegation-ledger.js","sourceRoot":"","sources":["../../../src/core/orchestration/delegation-ledger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAWxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAA4B,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AA+ClH,SAAS,aAAa,CAAC,OAA4B;IAClD,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC;AACnG,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,6BAA6B;IAIzC,YAAY,OAAgC;QAC3C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAkB,CAAC;YACrC,KAAK,EAAE,IAAI,uBAAuB,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;YAChG,GAAG,EAAE,OAAO,CAAC,GAAG;SAChB,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,KAA6B;QACpC,MAAM,OAAO,GAAG,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC;QACv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Y,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACvC,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,CAC7C,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,aAAa,KAAK,iBAAiB,CAChG,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { WorkerDelegationTaskContext } from \"../delegation/worker-delegation-request.ts\";\nimport { deriveWorkerTaskLabel } from \"../delegation/worker-task-label.ts\";\nimport { hasGoalAcceptanceOverride } from \"../goals/goal-acceptance.ts\";\nimport type { GoalState } from \"../goals/goal-state.ts\";\nimport type {\n\tAgentBindingContract,\n\tAttemptUsageSnapshot,\n\tHarnessCapability,\n\tOrchestrationDispatchRequest,\n\tRiskBudget,\n\tWorkerExecutionContract,\n\tWorkerRole,\n} from \"./contracts.ts\";\nimport { OrchestrationEventStore } from \"./event-store.ts\";\nimport { type AttemptRuntimeState, DurableTaskRuntime, DurableTaskRuntimeError } from \"./task-runtime.ts\";\nimport { goalObjectiveId, projectGoalAcceptanceEvidence, projectGoalObjective } from \"./work-state-projection.ts\";\n\nexport interface DelegationLedgerOptions {\n\tagentDir: string;\n\tsessionId: string;\n\tnow?: () => number;\n}\n\nexport interface PrepareDelegationInput {\n\tlaneId: string;\n\tinstructions: string;\n\tparentAgentId?: string;\n\texecutionContract: WorkerExecutionContract;\n\trequiredCapabilities: readonly HarnessCapability[];\n\tgoal?: GoalState;\n\tverificationOfTaskId?: string;\n\ttaskContext?: WorkerDelegationTaskContext;\n}\n\nexport interface PrepareManagedDelegationInput {\n\tlaneId: string;\n\tdispatchSequence: number;\n\tinstructions: string;\n\tprofileId: string;\n\tprovider: string;\n\tauthorizationId: string;\n\trole: WorkerRole;\n\triskBudget: RiskBudget;\n\tgoal?: GoalState;\n\tgoalId?: string;\n\tworktreeLaneKey?: string;\n}\n\nexport interface StartedDelegationAttempt {\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tleaseId: string;\n\tfencingToken: number;\n\texpiresAt: string;\n}\n\nexport interface PrepareAgentTurnInput {\n\tagentId: string;\n\tinstructions: string;\n}\n\nfunction activeAttempt(attempt: AttemptRuntimeState): boolean {\n\treturn attempt.status === \"queued\" || attempt.status === \"leased\" || attempt.status === \"running\";\n}\n\n/**\n * Durable adapter for in-process delegated completions. It records the dispatch before execution,\n * fences interrupted completions on restart, and returns queued work for event-driven re-dispatch.\n * It deliberately does not pretend an isolated completion has a resumable model transcript.\n */\nexport class DelegationOrchestrationLedger {\n\treadonly runtime: DurableTaskRuntime;\n\tprivate readonly sessionId: string;\n\n\tconstructor(options: DelegationLedgerOptions) {\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.runtime = new DurableTaskRuntime({\n\t\t\tstore: new OrchestrationEventStore({ agentDir: options.agentDir, sessionId: options.sessionId }),\n\t\t\tnow: options.now,\n\t\t});\n\t}\n\n\tprepare(input: PrepareDelegationInput): AttemptRuntimeState {\n\t\tconst profile = input.executionContract.worker.profile;\n\t\treturn this.prepareNormalized({\n\t\t\tlaneId: input.laneId,\n\t\t\tinstructions: input.instructions,\n\t\t\tprofileId: profile.profileId,\n\t\t\trole: profile.role,\n\t\t\trequiredCapabilities: input.requiredCapabilities,\n\t\t\triskBudget: profile.budget,\n\t\t\t...(input.parentAgentId ? { parentAgentId: input.parentAgentId } : {}),\n\t\t\texecutionContract: input.executionContract,\n\t\t\t...(input.goal ? { goal: input.goal } : {}),\n\t\t\t...(input.verificationOfTaskId ? { verificationOfTaskId: input.verificationOfTaskId } : {}),\n\t\t\t...(input.taskContext ? { taskContext: input.taskContext } : {}),\n\t\t\tdispatchMetadata: { logicalLaneId: input.laneId },\n\t\t});\n\t}\n\n\tprepareManaged(input: PrepareManagedDelegationInput): AttemptRuntimeState {\n\t\tif (!Number.isSafeInteger(input.dispatchSequence) || input.dispatchSequence < 1) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Managed dispatch sequence must be a positive integer.\");\n\t\t}\n\t\tconst taskId = `${input.laneId}:turn:${input.dispatchSequence}`;\n\t\treturn this.prepareNormalized({\n\t\t\tlaneId: taskId,\n\t\t\tinstructions: input.instructions,\n\t\t\tprofileId: input.profileId,\n\t\t\trole: input.role,\n\t\t\trequiredCapabilities: [],\n\t\t\triskBudget: input.riskBudget,\n\t\t\t...(input.goal ? { goal: input.goal } : {}),\n\t\t\t...(input.goalId ? { goalId: input.goalId } : {}),\n\t\t\tdispatchMetadata: {\n\t\t\t\texecutionKind: \"managed-process\",\n\t\t\t\tlogicalLaneId: input.laneId,\n\t\t\t\tdispatchSequence: input.dispatchSequence,\n\t\t\t\tprovider: input.provider,\n\t\t\t\tauthorizationId: input.authorizationId,\n\t\t\t\t...(input.worktreeLaneKey ? { worktreeLaneKey: input.worktreeLaneKey } : {}),\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Queue one new turn for an existing logical agent. The agent identity and its immutable\n\t * execution contract are inherited from the last bound turn; the durable task and attempt ids\n\t * are intentionally new so retries, leases, and terminal evidence never collide across turns.\n\t */\n\tprepareAgentTurn(input: PrepareAgentTurnInput): AttemptRuntimeState {\n\t\tconst agentId = input.agentId.trim();\n\t\tconst instructions = input.instructions.trim();\n\t\tif (!agentId) throw new DurableTaskRuntimeError(\"Logical worker agent id is required.\");\n\t\tif (!instructions) throw new DurableTaskRuntimeError(\"Worker follow-up instructions are required.\");\n\t\tconst snapshot = this.runtime.getSnapshot();\n\t\tconst agent = snapshot.agents[agentId];\n\t\tif (!agent) throw new DurableTaskRuntimeError(`Unknown logical worker agent '${agentId}'.`);\n\t\tif (agent.status !== \"registered\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Logical worker agent '${agentId}' is not idle.`);\n\t\t}\n\t\tconst prior = this.latestAgentAttempt(snapshot, agent);\n\t\tconst contract = prior?.dispatch.executionContract;\n\t\tif (!prior || !contract) {\n\t\t\tthrow new DurableTaskRuntimeError(`Logical worker agent '${agentId}' has no immutable execution contract.`);\n\t\t}\n\t\tconst priorTask = snapshot.tasks[prior.taskId]?.task;\n\t\tif (!priorTask) throw new DurableTaskRuntimeError(`Logical worker agent '${agentId}' has no prior durable task.`);\n\t\tconst sequence = Object.values(snapshot.attempts).filter((attempt) => attempt.agentId === agentId).length + 1;\n\t\tconst taskId = `${agentId}:turn:${sequence}`;\n\t\tif (snapshot.tasks[taskId]) {\n\t\t\tthrow new DurableTaskRuntimeError(`Logical worker agent '${agentId}' already has turn ${sequence}.`);\n\t\t}\n\t\treturn this.prepareNormalized({\n\t\t\tlaneId: taskId,\n\t\t\tinstructions,\n\t\t\tprofileId: contract.worker.profile.profileId,\n\t\t\trole: agent.role,\n\t\t\trequiredCapabilities: contract.worker.authority.capabilities,\n\t\t\triskBudget: contract.worker.profile.budget,\n\t\t\ttaskContext: {\n\t\t\t\trequirementIds: prior.dispatch.requirementIds ?? [],\n\t\t\t\tdependsOnTaskIds: priorTask.dependsOn,\n\t\t\t\tacceptanceCriterionIds: priorTask.acceptanceCriterionIds,\n\t\t\t\tresourcePointerIds: prior.dispatch.resourcePointerIds,\n\t\t\t},\n\t\t\texecutionContract: contract,\n\t\t\tdispatchMetadata: {\n\t\t\t\tlogicalLaneId: agentId,\n\t\t\t\tdispatchSequence: sequence,\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate latestAgentAttempt(\n\t\tsnapshot: ReturnType<DurableTaskRuntime[\"getSnapshot\"]>,\n\t\tagent: AgentBindingContract,\n\t): AttemptRuntimeState | undefined {\n\t\treturn Object.values(snapshot.attempts)\n\t\t\t.filter((attempt) => attempt.agentId === agent.agentId)\n\t\t\t.sort((left, right) => left.createdAt.localeCompare(right.createdAt))\n\t\t\t.at(-1);\n\t}\n\n\tprivate prepareNormalized(input: {\n\t\tlaneId: string;\n\t\tinstructions: string;\n\t\tprofileId: string;\n\t\trole: WorkerRole;\n\t\trequiredCapabilities: readonly HarnessCapability[];\n\t\triskBudget: RiskBudget;\n\t\tparentAgentId?: string;\n\t\tgoal?: GoalState;\n\t\tgoalId?: string;\n\t\tverificationOfTaskId?: string;\n\t\ttaskContext?: WorkerDelegationTaskContext;\n\t\texecutionContract?: WorkerExecutionContract;\n\t\tdispatchMetadata?: Pick<\n\t\t\tOrchestrationDispatchRequest,\n\t\t\t\"executionKind\" | \"logicalLaneId\" | \"dispatchSequence\" | \"provider\" | \"authorizationId\" | \"worktreeLaneKey\"\n\t\t>;\n\t}): AttemptRuntimeState {\n\t\tlet snapshot = this.runtime.getSnapshot();\n\t\tconst existingVerificationSubject = input.verificationOfTaskId\n\t\t\t? snapshot.tasks[input.verificationOfTaskId]\n\t\t\t: undefined;\n\t\tif (input.verificationOfTaskId && !existingVerificationSubject) {\n\t\t\tthrow new DurableTaskRuntimeError(`Unknown verification subject '${input.verificationOfTaskId}'.`);\n\t\t}\n\t\tconst projectedGoal = input.goal ? projectGoalObjective(input.goal) : undefined;\n\t\tconst objectiveId =\n\t\t\texistingVerificationSubject?.task.objectiveId ??\n\t\t\tprojectedGoal?.objectiveId ??\n\t\t\t(input.goalId ? goalObjectiveId(input.goalId) : `session:${this.sessionId}`);\n\t\tif (input.goal && objectiveId === projectedGoal?.objectiveId) {\n\t\t\tthis.synchronizeGoalState(input.goal);\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t} else if (!snapshot.objectives[objectiveId]) {\n\t\t\tthis.runtime.createObjective({\n\t\t\t\tobjectiveId,\n\t\t\t\ttitle: input.goalId ? `Goal ${input.goalId}` : `Session ${this.sessionId}`,\n\t\t\t\tdescription: input.goalId ? \"Externally managed goal work\" : \"Session-scoped delegated work\",\n\t\t\t});\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\n\t\tif (!snapshot.tasks[input.laneId]) {\n\t\t\tconst verificationSubject = input.verificationOfTaskId\n\t\t\t\t? snapshot.tasks[input.verificationOfTaskId]\n\t\t\t\t: undefined;\n\t\t\tthis.runtime.createTask({\n\t\t\t\ttaskId: input.laneId,\n\t\t\t\tobjectiveId,\n\t\t\t\ttitle: deriveWorkerTaskLabel(input.instructions, `Delegated ${input.role} work`),\n\t\t\t\tdescription: input.instructions,\n\t\t\t\trole: input.role,\n\t\t\t\tdependsOn: input.taskContext?.dependsOnTaskIds ?? [],\n\t\t\t\trequiredCapabilities: input.requiredCapabilities,\n\t\t\t\tacceptanceCriterionIds: input.taskContext?.acceptanceCriterionIds ?? [],\n\t\t\t\triskBudget: input.riskBudget,\n\t\t\t\t...(input.verificationOfTaskId\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tverificationOfTaskId: input.verificationOfTaskId,\n\t\t\t\t\t\t\tacceptanceCriterionIds: verificationSubject?.task.acceptanceCriterionIds ?? [],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\n\t\tconst task = snapshot.tasks[input.laneId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Failed to create task '${input.laneId}'.`);\n\t\tconst existing = [...task.attemptIds]\n\t\t\t.reverse()\n\t\t\t.map((attemptId) => snapshot.attempts[attemptId])\n\t\t\t.find((attempt): attempt is AttemptRuntimeState => attempt !== undefined && activeAttempt(attempt));\n\t\tif (existing) return existing;\n\n\t\treturn this.runtime.queueAttempt(input.laneId, {\n\t\t\ttaskId: input.laneId,\n\t\t\tprofileId: input.profileId,\n\t\t\tinstructions: input.instructions,\n\t\t\tresourcePointerIds: input.taskContext?.resourcePointerIds ?? [],\n\t\t\t...(input.parentAgentId ? { parentAgentId: input.parentAgentId } : {}),\n\t\t\trequirementIds: input.taskContext?.requirementIds ?? [],\n\t\t\t...(input.executionContract ? { executionContract: input.executionContract } : {}),\n\t\t\t...input.dispatchMetadata,\n\t\t});\n\t}\n\n\tsynchronizeGoalState(goal: GoalState): void {\n\t\tconst objective = projectGoalObjective(goal);\n\t\tthis.runtime.ensureObjective(objective);\n\t\tfor (const evidence of projectGoalAcceptanceEvidence(goal)) {\n\t\t\tthis.runtime.recordObjectiveEvidence(objective.objectiveId, evidence);\n\t\t}\n\t\tconst status = this.runtime.getSnapshot().objectives[goalObjectiveId(goal.goalId)]?.objective.status;\n\t\tswitch (goal.status) {\n\t\t\tcase \"active\":\n\t\t\t\tif (status === \"paused\") this.runtime.resumeObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"paused\":\n\t\t\tcase \"blocked\":\n\t\t\tcase \"usage_limited\":\n\t\t\tcase \"budget_limited\":\n\t\t\t\tif (status === \"active\") this.runtime.pauseObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"cancelled\":\n\t\t\t\tif (status !== \"cancelled\") this.runtime.cancelObjective(objective.objectiveId);\n\t\t\t\tbreak;\n\t\t\tcase \"completed\":\n\t\t\t\tif (status !== \"completed\") {\n\t\t\t\t\tthis.runtime.completeObjectiveFromOwner(objective.objectiveId, hasGoalAcceptanceOverride(goal));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tstart(\n\t\tattemptId: string,\n\t\tleaseTtlMs: number,\n\t\townerId = `in-process:${this.sessionId}`,\n\t\tagentId?: string,\n\t): StartedDelegationAttempt {\n\t\tconst snapshot = this.runtime.getSnapshot();\n\t\tconst attempt = snapshot.attempts[attemptId];\n\t\tif (!attempt) throw new DurableTaskRuntimeError(`Unknown attempt '${attemptId}'.`);\n\t\tconst task = snapshot.tasks[attempt.taskId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Unknown task '${attempt.taskId}'.`);\n\t\tconst lease = this.runtime.leaseAttempt(attemptId, ownerId, leaseTtlMs, agentId);\n\t\tthis.runtime.startAttempt(attemptId, lease.leaseId, lease.fencingToken);\n\t\treturn {\n\t\t\tobjectiveId: task.task.objectiveId,\n\t\t\ttaskId: task.task.taskId,\n\t\t\tattemptId,\n\t\t\tleaseId: lease.leaseId,\n\t\t\tfencingToken: lease.fencingToken,\n\t\t\texpiresAt: lease.expiresAt,\n\t\t};\n\t}\n\n\tcancel(attemptId: string, reasonCode: string): void {\n\t\tthis.runtime.cancelAttempt(attemptId, reasonCode);\n\t}\n\n\t/** Latest fenced cumulative usage, if this attempt has crossed a durable checkpoint boundary. */\n\tgetAttemptUsage(attemptId: string): AttemptUsageSnapshot | undefined {\n\t\tconst snapshot = this.runtime.getSnapshot();\n\t\tconst attempt = snapshot.attempts[attemptId];\n\t\tif (!attempt) throw new DurableTaskRuntimeError(`Unknown attempt '${attemptId}'.`);\n\t\tfor (const checkpointId of [...attempt.checkpointIds].reverse()) {\n\t\t\tconst usage = snapshot.checkpoints[checkpointId]?.usage;\n\t\t\tif (usage) return structuredClone(usage);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Fence interrupted isolated completions and queue one replacement attempt per task. */\n\trecoverQueuedDispatches(): AttemptRuntimeState[] {\n\t\tthis.runtime.recoverInterruptedUnboundAttempts((attempt) => attempt.dispatch.executionKind !== \"managed-process\");\n\t\tlet snapshot = this.runtime.getSnapshot();\n\t\tfor (const task of Object.values(snapshot.tasks)) {\n\t\t\tconst attempts = task.attemptIds.map((attemptId) => snapshot.attempts[attemptId]).filter(Boolean);\n\t\t\tif (attempts.some((attempt) => attempt && activeAttempt(attempt))) continue;\n\t\t\tconst interrupted = [...attempts].reverse().find((attempt) => attempt?.status === \"expired\");\n\t\t\tif (!interrupted || task.task.status !== \"ready\") continue;\n\t\t\tconst maxAttempts = task.task.riskBudget.maxAttempts;\n\t\t\tif (maxAttempts !== undefined && task.attemptIds.length >= maxAttempts) {\n\t\t\t\tthis.runtime.failTask(task.task.taskId, \"attempt_budget_exhausted\");\n\t\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.runtime.queueAttempt(task.task.taskId, interrupted.dispatch);\n\t\t\tsnapshot = this.runtime.getSnapshot();\n\t\t}\n\t\treturn Object.values(snapshot.attempts).filter(\n\t\t\t(attempt) => attempt.status === \"queued\" && attempt.dispatch.executionKind !== \"managed-process\",\n\t\t);\n\t}\n}\n"]}
|
|
@@ -20,10 +20,13 @@ export declare class OrchestrationSnapshotRequiredError extends OrchestrationEve
|
|
|
20
20
|
constructor(throughOrdinal: number);
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* Append-only event tail with a replaceable full-state projection snapshot.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* Append-only event tail with a replaceable full-state projection snapshot. Each immutable event is
|
|
24
|
+
* its own commit record: idempotency data is derived directly from the bounded tail, while a small
|
|
25
|
+
* mutable cursor remains only as a corruption high-water mark. Atomic rename prevents torn event
|
|
26
|
+
* records without multiplying one transition into per-key marker files and atomic cursor rewrites.
|
|
27
|
+
* Snapshot publication is two-phase (payload, then small baseline pointer), after which covered event
|
|
28
|
+
* and legacy-index files are pruned. A crash at any point leaves either the old replay prefix or the
|
|
29
|
+
* new verified snapshot authoritative; ordinals never reset.
|
|
27
30
|
*/
|
|
28
31
|
export declare class OrchestrationEventStore {
|
|
29
32
|
readonly rootDir: string;
|
|
@@ -39,6 +42,7 @@ export declare class OrchestrationEventStore {
|
|
|
39
42
|
private readonly maxIdempotencyEvents;
|
|
40
43
|
private readonly listeners;
|
|
41
44
|
private verifiedSnapshotBaseline;
|
|
45
|
+
private synchronizedIndexes;
|
|
42
46
|
constructor(options: OrchestrationEventStoreOptions);
|
|
43
47
|
append(input: AppendOrchestrationEventInput, options?: {
|
|
44
48
|
expectedLastOrdinal?: number;
|
|
@@ -71,13 +75,11 @@ export declare class OrchestrationEventStore {
|
|
|
71
75
|
private snapshotFileSignatureUnlocked;
|
|
72
76
|
private unlinkManagedFile;
|
|
73
77
|
private readEventFileUnlocked;
|
|
74
|
-
private idempotencyPath;
|
|
75
|
-
private serializeIdempotencyMarker;
|
|
76
|
-
private writeIdempotencyMarkerUnlocked;
|
|
77
|
-
private readIdempotentEventUnlocked;
|
|
78
78
|
/**
|
|
79
|
-
* Reconcile
|
|
80
|
-
*
|
|
79
|
+
* Reconcile the bounded immutable tail into an in-memory index. Independent writers are detected
|
|
80
|
+
* from new ordinals while holding the shared lock, so normal same-process appends parse only events
|
|
81
|
+
* committed by other writers. A bounded mutable cursor remains derived corruption evidence; legacy
|
|
82
|
+
* per-key marker files are no longer needed or rewritten.
|
|
81
83
|
*/
|
|
82
84
|
private synchronizeIndexesUnlocked;
|
|
83
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-store.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/event-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,EACN,KAAK,6BAA6B,EAGlC,KAAK,kBAAkB,EACvB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"event-store.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/event-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,EACN,KAAK,6BAA6B,EAGlC,KAAK,kBAAkB,EACvB,MAAM,gBAAgB,CAAC;AAgExB,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,4BAA6B,SAAQ,KAAK;IACtD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AAED,qBAAa,6BAA8B,SAAQ,4BAA4B;IAC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AAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,GAAG,OAAO,CAiG7E;IAED,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAAG,MAAM,IAAI,CAGnE;IAED,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,4BAA4B;IAapC,OAAO,CAAC,yBAAyB;IAejC,kFAAkF;IAClF,OAAO,CAAC,oCAAoC;IAe5C,oGAAoG;IACpG,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,oBAAoB;IAoC5B,OAAO,CAAC,8BAA8B;IAwDtC;;;;OAIG;IACH,OAAO,CAAC,oCAAoC;IAuC5C,OAAO,CAAC,6BAA6B;IAcrC,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,qBAAqB;IAiB7B;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;CAuDlC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { existsSync, statSync, unlinkSync } from "node:fs";
|
|
2
|
+
import { existsSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { orchestrationEventStoreDir } from "../agent-paths.js";
|
|
5
5
|
import { withFileLockSync, writeFileAtomicSync } from "../util/atomic-file.js";
|
|
@@ -18,7 +18,6 @@ const MAX_IDEMPOTENCY_DIRECTORY_ENTRIES = 2_048;
|
|
|
18
18
|
const MAX_SNAPSHOT_DIRECTORY_ENTRIES = 8;
|
|
19
19
|
const MAX_CURSOR_BYTES = 64 * 1024;
|
|
20
20
|
const MAX_BASELINE_BYTES = 64 * 1024;
|
|
21
|
-
const MAX_IDEMPOTENCY_MARKER_BYTES = 64 * 1024;
|
|
22
21
|
/** Full current task state plus retained idempotency evidence; intentionally above the 16MiB tail cap. */
|
|
23
22
|
const MAX_PROJECTION_SNAPSHOT_BYTES = 32 * 1024 * 1024;
|
|
24
23
|
export class OrchestrationEventStoreError extends Error {
|
|
@@ -97,10 +96,13 @@ function positiveSafeInteger(value, fallback, maximum, label) {
|
|
|
97
96
|
return resolved;
|
|
98
97
|
}
|
|
99
98
|
/**
|
|
100
|
-
* Append-only event tail with a replaceable full-state projection snapshot.
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
99
|
+
* Append-only event tail with a replaceable full-state projection snapshot. Each immutable event is
|
|
100
|
+
* its own commit record: idempotency data is derived directly from the bounded tail, while a small
|
|
101
|
+
* mutable cursor remains only as a corruption high-water mark. Atomic rename prevents torn event
|
|
102
|
+
* records without multiplying one transition into per-key marker files and atomic cursor rewrites.
|
|
103
|
+
* Snapshot publication is two-phase (payload, then small baseline pointer), after which covered event
|
|
104
|
+
* and legacy-index files are pruned. A crash at any point leaves either the old replay prefix or the
|
|
105
|
+
* new verified snapshot authoritative; ordinals never reset.
|
|
104
106
|
*/
|
|
105
107
|
export class OrchestrationEventStore {
|
|
106
108
|
constructor(options) {
|
|
@@ -119,10 +121,10 @@ export class OrchestrationEventStore {
|
|
|
119
121
|
}
|
|
120
122
|
append(input, options = {}) {
|
|
121
123
|
const committed = withFileLockSync(this.cursorPath, () => {
|
|
122
|
-
const
|
|
123
|
-
const actual =
|
|
124
|
+
const indexes = this.synchronizeIndexesUnlocked();
|
|
125
|
+
const actual = indexes.lastOrdinal;
|
|
124
126
|
if (input.idempotencyKey) {
|
|
125
|
-
const existing =
|
|
127
|
+
const existing = indexes.idempotencyEvents.get(input.idempotencyKey);
|
|
126
128
|
if (existing)
|
|
127
129
|
return { event: existing, appended: false };
|
|
128
130
|
}
|
|
@@ -146,19 +148,17 @@ export class OrchestrationEventStore {
|
|
|
146
148
|
payload: structuredClone(input.payload),
|
|
147
149
|
};
|
|
148
150
|
const serializedEvent = serializeBounded(next, this.maxTailBytes, "Orchestration event", "Orchestration event exceeds its configured tail byte limit.");
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
: undefined;
|
|
152
|
-
const serializedCursor = serializeBounded({
|
|
153
|
-
version: 1,
|
|
154
|
-
lastOrdinal: ordinal,
|
|
155
|
-
tailBytes: cursor.tailBytes + Buffer.byteLength(serializedEvent),
|
|
156
|
-
}, MAX_CURSOR_BYTES, "Orchestration cursor");
|
|
151
|
+
const nextTailBytes = indexes.tailBytes + Buffer.byteLength(serializedEvent);
|
|
152
|
+
const serializedCursor = serializeBounded({ version: 1, lastOrdinal: ordinal, tailBytes: nextTailBytes }, MAX_CURSOR_BYTES, "Orchestration cursor");
|
|
157
153
|
writeFileAtomicSync(join(this.eventsDir, eventFileName(ordinal)), serializedEvent);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
154
|
+
indexes.lastOrdinal = ordinal;
|
|
155
|
+
indexes.tailBytes = nextTailBytes;
|
|
156
|
+
if (input.idempotencyKey)
|
|
157
|
+
indexes.idempotencyEvents.set(input.idempotencyKey, next);
|
|
158
|
+
// The immutable event is authoritative. The cursor is only a corruption high-water mark,
|
|
159
|
+
// so a lock-protected direct overwrite avoids another tmp-file creation and rename on the
|
|
160
|
+
// Windows scanner-sensitive path; a torn cursor is safely rebuilt from the event tail.
|
|
161
|
+
writeFileSync(this.cursorPath, serializedCursor, "utf-8");
|
|
162
162
|
return { event: next, appended: true };
|
|
163
163
|
});
|
|
164
164
|
if (committed.appended) {
|
|
@@ -203,11 +203,21 @@ export class OrchestrationEventStore {
|
|
|
203
203
|
}
|
|
204
204
|
/** Replace a large replay prefix with one verified current-state snapshot and a bounded tail. */
|
|
205
205
|
compactIfNeeded(throughOrdinal, projection) {
|
|
206
|
-
const baselineBeforeLock = this.readBaselineUnlocked()
|
|
206
|
+
const baselineBeforeLock = this.readBaselineUnlocked();
|
|
207
|
+
const baselineOrdinalBeforeLock = baselineBeforeLock?.throughOrdinal ?? 0;
|
|
208
|
+
const cachedIndexes = this.synchronizedIndexes;
|
|
209
|
+
if (cachedIndexes?.baselineOrdinal === baselineOrdinalBeforeLock &&
|
|
210
|
+
cachedIndexes.baselineDigest === baselineBeforeLock?.digest &&
|
|
211
|
+
cachedIndexes.lastOrdinal === throughOrdinal &&
|
|
212
|
+
throughOrdinal - baselineOrdinalBeforeLock < this.maxTailEvents &&
|
|
213
|
+
cachedIndexes.tailBytes < this.maxTailBytes) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
207
216
|
const cursorBeforeLock = parseCursor(this.cursorPath);
|
|
208
|
-
if (
|
|
217
|
+
if (!cachedIndexes &&
|
|
218
|
+
cursorBeforeLock?.lastOrdinal === throughOrdinal &&
|
|
209
219
|
cursorBeforeLock.tailBytes !== undefined &&
|
|
210
|
-
throughOrdinal -
|
|
220
|
+
throughOrdinal - baselineOrdinalBeforeLock < this.maxTailEvents &&
|
|
211
221
|
cursorBeforeLock.tailBytes < this.maxTailBytes) {
|
|
212
222
|
return false;
|
|
213
223
|
}
|
|
@@ -262,6 +272,14 @@ export class OrchestrationEventStore {
|
|
|
262
272
|
this.unlinkManagedFile(join(this.snapshotsDir, name));
|
|
263
273
|
}
|
|
264
274
|
writeFileAtomicSync(this.cursorPath, serializedCursor);
|
|
275
|
+
this.verifiedSnapshotBaseline = undefined;
|
|
276
|
+
this.synchronizedIndexes = {
|
|
277
|
+
baselineOrdinal: throughOrdinal,
|
|
278
|
+
baselineDigest: digest,
|
|
279
|
+
lastOrdinal: throughOrdinal,
|
|
280
|
+
tailBytes: 0,
|
|
281
|
+
idempotencyEvents: new Map(idempotencyEvents.map((event) => [event.idempotencyKey, structuredClone(event)])),
|
|
282
|
+
};
|
|
265
283
|
return true;
|
|
266
284
|
});
|
|
267
285
|
}
|
|
@@ -445,17 +463,24 @@ export class OrchestrationEventStore {
|
|
|
445
463
|
cached.signature.size === signature.size &&
|
|
446
464
|
cached.signature.mtimeMs === signature.mtimeMs &&
|
|
447
465
|
cached.signature.ctimeMs === signature.ctimeMs) {
|
|
448
|
-
return
|
|
466
|
+
return cached;
|
|
467
|
+
}
|
|
468
|
+
const snapshot = this.readProjectionSnapshotUnlocked();
|
|
469
|
+
if (!snapshot) {
|
|
470
|
+
throw new OrchestrationEventStoreError("Orchestration projection snapshot is unavailable.");
|
|
449
471
|
}
|
|
450
|
-
this.readProjectionSnapshotUnlocked();
|
|
451
472
|
const verifiedSignature = this.snapshotFileSignatureUnlocked(baseline);
|
|
452
473
|
if (verifiedSignature.size !== signature.size ||
|
|
453
474
|
verifiedSignature.mtimeMs !== signature.mtimeMs ||
|
|
454
475
|
verifiedSignature.ctimeMs !== signature.ctimeMs) {
|
|
455
476
|
throw new OrchestrationEventStoreError("Orchestration projection snapshot changed while being verified.");
|
|
456
477
|
}
|
|
457
|
-
this.verifiedSnapshotBaseline = {
|
|
458
|
-
|
|
478
|
+
this.verifiedSnapshotBaseline = {
|
|
479
|
+
baseline,
|
|
480
|
+
signature,
|
|
481
|
+
idempotencyEvents: snapshot.idempotencyEvents.map((event) => structuredClone(event)),
|
|
482
|
+
};
|
|
483
|
+
return this.verifiedSnapshotBaseline;
|
|
459
484
|
}
|
|
460
485
|
snapshotFileSignatureUnlocked(baseline) {
|
|
461
486
|
try {
|
|
@@ -492,96 +517,61 @@ export class OrchestrationEventStore {
|
|
|
492
517
|
}
|
|
493
518
|
return parsed;
|
|
494
519
|
}
|
|
495
|
-
idempotencyPath(key) {
|
|
496
|
-
return join(this.idempotencyDir, `${createHash("sha256").update(key).digest("hex")}.json`);
|
|
497
|
-
}
|
|
498
|
-
serializeIdempotencyMarker(key, ordinal) {
|
|
499
|
-
return serializeBounded({ version: 1, key, ordinal }, MAX_IDEMPOTENCY_MARKER_BYTES, "Orchestration idempotency marker");
|
|
500
|
-
}
|
|
501
|
-
writeIdempotencyMarkerUnlocked(key, serializedMarker) {
|
|
502
|
-
writeFileAtomicSync(this.idempotencyPath(key), serializedMarker);
|
|
503
|
-
}
|
|
504
|
-
readIdempotentEventUnlocked(key) {
|
|
505
|
-
const markerPath = this.idempotencyPath(key);
|
|
506
|
-
if (!existsSync(markerPath)) {
|
|
507
|
-
return this.readProjectionSnapshotUnlocked()?.idempotencyEvents.find((event) => event.idempotencyKey === key);
|
|
508
|
-
}
|
|
509
|
-
let parsed;
|
|
510
|
-
try {
|
|
511
|
-
parsed = JSON.parse(readBoundedTextFileSync(markerPath, MAX_IDEMPOTENCY_MARKER_BYTES, "Orchestration idempotency marker"));
|
|
512
|
-
}
|
|
513
|
-
catch (error) {
|
|
514
|
-
throw new OrchestrationEventStoreError(`Failed to parse orchestration idempotency marker: ${error instanceof Error ? error.message : String(error)}`);
|
|
515
|
-
}
|
|
516
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
517
|
-
throw new OrchestrationEventStoreError("Invalid orchestration idempotency marker.");
|
|
518
|
-
}
|
|
519
|
-
const marker = parsed;
|
|
520
|
-
if (marker.version !== 1 ||
|
|
521
|
-
marker.key !== key ||
|
|
522
|
-
!Number.isSafeInteger(marker.ordinal) ||
|
|
523
|
-
Number(marker.ordinal) < 1) {
|
|
524
|
-
throw new OrchestrationEventStoreError("Invalid orchestration idempotency marker.");
|
|
525
|
-
}
|
|
526
|
-
const ordinal = Number(marker.ordinal);
|
|
527
|
-
if (!existsSync(join(this.eventsDir, eventFileName(ordinal)))) {
|
|
528
|
-
const retained = this.readProjectionSnapshotUnlocked()?.idempotencyEvents.find((event) => event.idempotencyKey === key && event.ordinal === ordinal);
|
|
529
|
-
if (retained)
|
|
530
|
-
return retained;
|
|
531
|
-
}
|
|
532
|
-
const event = this.readEventFileUnlocked(eventFileName(ordinal));
|
|
533
|
-
if (event.ordinal !== ordinal || event.idempotencyKey !== key) {
|
|
534
|
-
throw new OrchestrationEventStoreError("Orchestration idempotency marker does not match its event.");
|
|
535
|
-
}
|
|
536
|
-
return event;
|
|
537
|
-
}
|
|
538
520
|
/**
|
|
539
|
-
* Reconcile
|
|
540
|
-
*
|
|
521
|
+
* Reconcile the bounded immutable tail into an in-memory index. Independent writers are detected
|
|
522
|
+
* from new ordinals while holding the shared lock, so normal same-process appends parse only events
|
|
523
|
+
* committed by other writers. A bounded mutable cursor remains derived corruption evidence; legacy
|
|
524
|
+
* per-key marker files are no longer needed or rewritten.
|
|
541
525
|
*/
|
|
542
526
|
synchronizeIndexesUnlocked() {
|
|
543
527
|
const names = this.eventFileNamesUnlocked();
|
|
544
|
-
const
|
|
528
|
+
const verifiedBaseline = this.readVerifiedSnapshotBaselineUnlocked();
|
|
529
|
+
const baselineOrdinal = verifiedBaseline?.baseline.throughOrdinal ?? 0;
|
|
530
|
+
const baselineDigest = verifiedBaseline?.baseline.digest;
|
|
545
531
|
this.assertReadableTailUnlocked(names, baselineOrdinal);
|
|
546
532
|
const highestEventOrdinal = names.length > 0 ? Number(EVENT_FILE_PATTERN.exec(names.at(-1))?.[1] ?? 0) : 0;
|
|
547
533
|
const highest = Math.max(baselineOrdinal, highestEventOrdinal);
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
534
|
+
if (this.synchronizedIndexes?.baselineOrdinal === baselineOrdinal &&
|
|
535
|
+
this.synchronizedIndexes.baselineDigest === baselineDigest &&
|
|
536
|
+
this.synchronizedIndexes.lastOrdinal > highest) {
|
|
537
|
+
throw new OrchestrationEventStoreError(`Orchestration cursor ${this.synchronizedIndexes.lastOrdinal} is ahead of the last committed event ${highest}.`);
|
|
538
|
+
}
|
|
539
|
+
const cached = this.synchronizedIndexes;
|
|
540
|
+
const canExtendCached = cached?.baselineOrdinal === baselineOrdinal &&
|
|
541
|
+
cached.baselineDigest === baselineDigest &&
|
|
542
|
+
cached.lastOrdinal >= baselineOrdinal &&
|
|
543
|
+
cached.lastOrdinal <= highest;
|
|
544
|
+
if (canExtendCached && cached.lastOrdinal === highest)
|
|
545
|
+
return cached;
|
|
546
|
+
const indexes = canExtendCached
|
|
547
|
+
? cached
|
|
548
|
+
: {
|
|
549
|
+
baselineOrdinal,
|
|
550
|
+
baselineDigest,
|
|
551
|
+
lastOrdinal: baselineOrdinal,
|
|
552
|
+
tailBytes: 0,
|
|
553
|
+
idempotencyEvents: new Map((verifiedBaseline?.idempotencyEvents ?? []).map((event) => [
|
|
554
|
+
event.idempotencyKey,
|
|
555
|
+
structuredClone(event),
|
|
556
|
+
])),
|
|
557
|
+
};
|
|
558
|
+
const scanFrom = indexes.lastOrdinal + 1;
|
|
560
559
|
for (const name of names) {
|
|
561
560
|
const ordinal = Number(EVENT_FILE_PATTERN.exec(name)?.[1] ?? 0);
|
|
562
|
-
if (ordinal <
|
|
561
|
+
if (ordinal < scanFrom || ordinal <= baselineOrdinal)
|
|
563
562
|
continue;
|
|
564
563
|
const event = this.readEventFileUnlocked(name);
|
|
565
564
|
if (event.ordinal !== ordinal) {
|
|
566
565
|
throw new OrchestrationEventStoreError(`Event ordinal does not match file name: ${name}`);
|
|
567
566
|
}
|
|
568
|
-
if (event.idempotencyKey)
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
try {
|
|
577
|
-
return total + statSync(join(this.eventsDir, name)).size;
|
|
578
|
-
}
|
|
579
|
-
catch {
|
|
580
|
-
return total;
|
|
581
|
-
}
|
|
582
|
-
}, 0);
|
|
583
|
-
writeFileAtomicSync(this.cursorPath, serializeBounded({ version: 1, lastOrdinal: highest, tailBytes }, MAX_CURSOR_BYTES, "Orchestration cursor"));
|
|
584
|
-
return { lastOrdinal: highest, tailBytes };
|
|
567
|
+
if (event.idempotencyKey)
|
|
568
|
+
indexes.idempotencyEvents.set(event.idempotencyKey, event);
|
|
569
|
+
indexes.tailBytes += statSync(join(this.eventsDir, name)).size;
|
|
570
|
+
indexes.lastOrdinal = ordinal;
|
|
571
|
+
}
|
|
572
|
+
indexes.lastOrdinal = highest;
|
|
573
|
+
this.synchronizedIndexes = indexes;
|
|
574
|
+
return indexes;
|
|
585
575
|
}
|
|
586
576
|
}
|
|
587
577
|
//# sourceMappingURL=event-store.js.map
|