open-multi-agent-kit 0.80.5 → 0.80.7
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 +31 -0
- package/README.md +22 -14
- package/dist/cli/config-selector.d.ts +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/config.d.ts +5 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +55 -23
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +45 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +197 -13
- package/dist/core/agent-session.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 +5 -5
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/command-safety.d.ts +11 -0
- package/dist/core/command-safety.d.ts.map +1 -0
- package/dist/core/command-safety.js +528 -0
- package/dist/core/command-safety.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +20 -5
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +99 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +655 -21
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/pruner-policy.d.ts +84 -0
- package/dist/core/compaction/pruner-policy.d.ts.map +1 -0
- package/dist/core/compaction/pruner-policy.js +273 -0
- package/dist/core/compaction/pruner-policy.js.map +1 -0
- package/dist/core/context-graph-identity-resolution.d.ts +114 -0
- package/dist/core/context-graph-identity-resolution.d.ts.map +1 -0
- package/dist/core/context-graph-identity-resolution.js +127 -0
- package/dist/core/context-graph-identity-resolution.js.map +1 -0
- package/dist/core/context-graph-memory-store.d.ts +153 -0
- package/dist/core/context-graph-memory-store.d.ts.map +1 -0
- package/dist/core/context-graph-memory-store.js +377 -0
- package/dist/core/context-graph-memory-store.js.map +1 -0
- package/dist/core/context-graph-ontology-generation.d.ts +104 -0
- package/dist/core/context-graph-ontology-generation.d.ts.map +1 -0
- package/dist/core/context-graph-ontology-generation.js +135 -0
- package/dist/core/context-graph-ontology-generation.js.map +1 -0
- package/dist/core/context-graph-ontology-registry.d.ts +766 -0
- package/dist/core/context-graph-ontology-registry.d.ts.map +1 -0
- package/dist/core/context-graph-ontology-registry.js +1133 -0
- package/dist/core/context-graph-ontology-registry.js.map +1 -0
- package/dist/core/context-graph-policy.d.ts +68 -0
- package/dist/core/context-graph-policy.d.ts.map +1 -0
- package/dist/core/context-graph-policy.js +221 -0
- package/dist/core/context-graph-policy.js.map +1 -0
- package/dist/core/context-graph-reasoning.d.ts +130 -0
- package/dist/core/context-graph-reasoning.d.ts.map +1 -0
- package/dist/core/context-graph-reasoning.js +442 -0
- package/dist/core/context-graph-reasoning.js.map +1 -0
- package/dist/core/context-graph-retrieval.d.ts +120 -0
- package/dist/core/context-graph-retrieval.d.ts.map +1 -0
- package/dist/core/context-graph-retrieval.js +288 -0
- package/dist/core/context-graph-retrieval.js.map +1 -0
- package/dist/core/contract-verification.d.ts +78 -0
- package/dist/core/contract-verification.d.ts.map +1 -0
- package/dist/core/contract-verification.js +110 -0
- package/dist/core/contract-verification.js.map +1 -0
- package/dist/core/exact-cache-policy.d.ts +100 -0
- package/dist/core/exact-cache-policy.d.ts.map +1 -0
- package/dist/core/exact-cache-policy.js +175 -0
- package/dist/core/exact-cache-policy.js.map +1 -0
- package/dist/core/exec.d.ts +2 -0
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +1 -0
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/template.js +2 -2
- package/dist/core/extensions/builtin/command-safety-gate.d.ts +77 -0
- package/dist/core/extensions/builtin/command-safety-gate.d.ts.map +1 -0
- package/dist/core/extensions/builtin/command-safety-gate.js +147 -0
- package/dist/core/extensions/builtin/command-safety-gate.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +4 -4
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +94 -56
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +38 -10
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/freedom/banner.d.ts +14 -0
- package/dist/core/freedom/banner.d.ts.map +1 -0
- package/dist/core/freedom/banner.js +22 -0
- package/dist/core/freedom/banner.js.map +1 -0
- package/dist/core/freedom/config.d.ts +27 -0
- package/dist/core/freedom/config.d.ts.map +1 -0
- package/dist/core/freedom/config.js +216 -0
- package/dist/core/freedom/config.js.map +1 -0
- package/dist/core/freedom/index.d.ts +23 -0
- package/dist/core/freedom/index.d.ts.map +1 -0
- package/dist/core/freedom/index.js +19 -0
- package/dist/core/freedom/index.js.map +1 -0
- package/dist/core/freedom/policy.d.ts +42 -0
- package/dist/core/freedom/policy.d.ts.map +1 -0
- package/dist/core/freedom/policy.js +47 -0
- package/dist/core/freedom/policy.js.map +1 -0
- package/dist/core/freedom/safety-floor.d.ts +73 -0
- package/dist/core/freedom/safety-floor.d.ts.map +1 -0
- package/dist/core/freedom/safety-floor.js +275 -0
- package/dist/core/freedom/safety-floor.js.map +1 -0
- package/dist/core/harness-control-events.d.ts +91 -0
- package/dist/core/harness-control-events.d.ts.map +1 -0
- package/dist/core/harness-control-events.js +514 -0
- package/dist/core/harness-control-events.js.map +1 -0
- package/dist/core/harness-control-replay.d.ts +31 -0
- package/dist/core/harness-control-replay.d.ts.map +1 -0
- package/dist/core/harness-control-replay.js +187 -0
- package/dist/core/harness-control-replay.js.map +1 -0
- package/dist/core/headroom-middleware.d.ts +35 -0
- package/dist/core/headroom-middleware.d.ts.map +1 -0
- package/dist/core/headroom-middleware.js +166 -0
- package/dist/core/headroom-middleware.js.map +1 -0
- package/dist/core/hook-inventory.d.ts +23 -0
- package/dist/core/hook-inventory.d.ts.map +1 -0
- package/dist/core/hook-inventory.js +50 -0
- package/dist/core/hook-inventory.js.map +1 -0
- package/dist/core/keybindings.d.ts +12 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +31 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/lean-context-middleware.d.ts +12 -0
- package/dist/core/lean-context-middleware.d.ts.map +1 -0
- package/dist/core/lean-context-middleware.js +87 -0
- package/dist/core/lean-context-middleware.js.map +1 -0
- package/dist/core/lean-context-policy.d.ts +45 -0
- package/dist/core/lean-context-policy.d.ts.map +1 -0
- package/dist/core/lean-context-policy.js +108 -0
- package/dist/core/lean-context-policy.js.map +1 -0
- package/dist/core/loadout-access-policy.d.ts +41 -0
- package/dist/core/loadout-access-policy.d.ts.map +1 -0
- package/dist/core/loadout-access-policy.js +182 -0
- package/dist/core/loadout-access-policy.js.map +1 -0
- package/dist/core/loadout-runtime.d.ts +84 -0
- package/dist/core/loadout-runtime.d.ts.map +1 -0
- package/dist/core/loadout-runtime.js +157 -0
- package/dist/core/loadout-runtime.js.map +1 -0
- package/dist/core/loadouts.d.ts +147 -0
- package/dist/core/loadouts.d.ts.map +1 -0
- package/dist/core/loadouts.js +442 -0
- package/dist/core/loadouts.js.map +1 -0
- package/dist/core/mcp-inventory.d.ts +74 -0
- package/dist/core/mcp-inventory.d.ts.map +1 -0
- package/dist/core/mcp-inventory.js +156 -0
- package/dist/core/mcp-inventory.js.map +1 -0
- package/dist/core/mcp-presets.d.ts +57 -0
- package/dist/core/mcp-presets.d.ts.map +1 -0
- package/dist/core/mcp-presets.js +81 -0
- package/dist/core/mcp-presets.js.map +1 -0
- package/dist/core/model-registry.d.ts +1 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +40 -17
- 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 -0
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/native-adoption-benchmark.d.ts +166 -0
- package/dist/core/native-adoption-benchmark.d.ts.map +1 -0
- package/dist/core/native-adoption-benchmark.js +624 -0
- package/dist/core/native-adoption-benchmark.js.map +1 -0
- package/dist/core/observability-trace.d.ts +80 -0
- package/dist/core/observability-trace.d.ts.map +1 -0
- package/dist/core/observability-trace.js +140 -0
- package/dist/core/observability-trace.js.map +1 -0
- package/dist/core/orchestration/checkpoint.d.ts +83 -0
- package/dist/core/orchestration/checkpoint.d.ts.map +1 -0
- package/dist/core/orchestration/checkpoint.js +152 -0
- package/dist/core/orchestration/checkpoint.js.map +1 -0
- package/dist/core/orchestration/errors.d.ts +74 -0
- package/dist/core/orchestration/errors.d.ts.map +1 -0
- package/dist/core/orchestration/errors.js +52 -0
- package/dist/core/orchestration/errors.js.map +1 -0
- package/dist/core/orchestration/merge-queue.d.ts +121 -0
- package/dist/core/orchestration/merge-queue.d.ts.map +1 -0
- package/dist/core/orchestration/merge-queue.js +149 -0
- package/dist/core/orchestration/merge-queue.js.map +1 -0
- package/dist/core/orchestration/recovery.d.ts +106 -0
- package/dist/core/orchestration/recovery.d.ts.map +1 -0
- package/dist/core/orchestration/recovery.js +110 -0
- package/dist/core/orchestration/recovery.js.map +1 -0
- package/dist/core/orchestration/replay-ledger.d.ts +76 -0
- package/dist/core/orchestration/replay-ledger.d.ts.map +1 -0
- package/dist/core/orchestration/replay-ledger.js +395 -0
- package/dist/core/orchestration/replay-ledger.js.map +1 -0
- package/dist/core/orchestration/scheduler-state.d.ts +78 -0
- package/dist/core/orchestration/scheduler-state.d.ts.map +1 -0
- package/dist/core/orchestration/scheduler-state.js +185 -0
- package/dist/core/orchestration/scheduler-state.js.map +1 -0
- package/dist/core/orchestration/scheduler-store.d.ts +309 -0
- package/dist/core/orchestration/scheduler-store.d.ts.map +1 -0
- package/dist/core/orchestration/scheduler-store.js +368 -0
- package/dist/core/orchestration/scheduler-store.js.map +1 -0
- package/dist/core/orchestration/sqlite-scheduler-store.d.ts +57 -0
- package/dist/core/orchestration/sqlite-scheduler-store.d.ts.map +1 -0
- package/dist/core/orchestration/sqlite-scheduler-store.js +528 -0
- package/dist/core/orchestration/sqlite-scheduler-store.js.map +1 -0
- package/dist/core/orchestration/transaction-coordinator.d.ts +217 -0
- package/dist/core/orchestration/transaction-coordinator.d.ts.map +1 -0
- package/dist/core/orchestration/transaction-coordinator.js +281 -0
- package/dist/core/orchestration/transaction-coordinator.js.map +1 -0
- package/dist/core/orchestration/verification-contract.d.ts +197 -0
- package/dist/core/orchestration/verification-contract.d.ts.map +1 -0
- package/dist/core/orchestration/verification-contract.js +145 -0
- package/dist/core/orchestration/verification-contract.js.map +1 -0
- package/dist/core/package-composition.d.ts +68 -0
- package/dist/core/package-composition.d.ts.map +1 -0
- package/dist/core/package-composition.js +304 -0
- package/dist/core/package-composition.js.map +1 -0
- package/dist/core/package-gallery.d.ts +124 -0
- package/dist/core/package-gallery.d.ts.map +1 -0
- package/dist/core/package-gallery.js +392 -0
- package/dist/core/package-gallery.js.map +1 -0
- package/dist/core/package-manager.d.ts +69 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +367 -69
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/package-procurement.d.ts +268 -0
- package/dist/core/package-procurement.d.ts.map +1 -0
- package/dist/core/package-procurement.js +697 -0
- package/dist/core/package-procurement.js.map +1 -0
- package/dist/core/package-trial-runtime.d.ts +75 -0
- package/dist/core/package-trial-runtime.d.ts.map +1 -0
- package/dist/core/package-trial-runtime.js +73 -0
- package/dist/core/package-trial-runtime.js.map +1 -0
- package/dist/core/package-trial-sandbox.d.ts +27 -0
- package/dist/core/package-trial-sandbox.d.ts.map +1 -0
- package/dist/core/package-trial-sandbox.js +102 -0
- package/dist/core/package-trial-sandbox.js.map +1 -0
- package/dist/core/policy-overlays-runtime.d.ts +141 -0
- package/dist/core/policy-overlays-runtime.d.ts.map +1 -0
- package/dist/core/policy-overlays-runtime.js +720 -0
- package/dist/core/policy-overlays-runtime.js.map +1 -0
- package/dist/core/read-anchor-registry.d.ts +27 -0
- package/dist/core/read-anchor-registry.d.ts.map +1 -0
- package/dist/core/read-anchor-registry.js +103 -0
- package/dist/core/read-anchor-registry.js.map +1 -0
- package/dist/core/read-anchors.d.ts +110 -0
- package/dist/core/read-anchors.d.ts.map +1 -0
- package/dist/core/read-anchors.js +193 -0
- package/dist/core/read-anchors.js.map +1 -0
- package/dist/core/read-content-cache.d.ts +22 -0
- package/dist/core/read-content-cache.d.ts.map +1 -0
- package/dist/core/read-content-cache.js +79 -0
- package/dist/core/read-content-cache.js.map +1 -0
- package/dist/core/recovery-checkpoint.d.ts +196 -0
- package/dist/core/recovery-checkpoint.d.ts.map +1 -0
- package/dist/core/recovery-checkpoint.js +382 -0
- package/dist/core/recovery-checkpoint.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +30 -2
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts +23 -21
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +93 -15
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sandbox/backend.d.ts +25 -0
- package/dist/core/sandbox/backend.d.ts.map +1 -0
- package/dist/core/sandbox/backend.js +150 -0
- package/dist/core/sandbox/backend.js.map +1 -0
- package/dist/core/sandbox/env.d.ts +6 -0
- package/dist/core/sandbox/env.d.ts.map +1 -0
- package/dist/core/sandbox/env.js +46 -0
- package/dist/core/sandbox/env.js.map +1 -0
- package/dist/core/sandbox/path-resolver.d.ts +4 -0
- package/dist/core/sandbox/path-resolver.d.ts.map +1 -0
- package/dist/core/sandbox/path-resolver.js +44 -0
- package/dist/core/sandbox/path-resolver.js.map +1 -0
- package/dist/core/sandbox/policy.d.ts +87 -0
- package/dist/core/sandbox/policy.d.ts.map +1 -0
- package/dist/core/sandbox/policy.js +280 -0
- package/dist/core/sandbox/policy.js.map +1 -0
- package/dist/core/sandbox/spawn.d.ts +20 -0
- package/dist/core/sandbox/spawn.d.ts.map +1 -0
- package/dist/core/sandbox/spawn.js +80 -0
- package/dist/core/sandbox/spawn.js.map +1 -0
- package/dist/core/sdk.d.ts +83 -4
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +143 -55
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/semantic-cache-policy.d.ts +45 -0
- package/dist/core/semantic-cache-policy.d.ts.map +1 -0
- package/dist/core/semantic-cache-policy.js +220 -0
- package/dist/core/semantic-cache-policy.js.map +1 -0
- package/dist/core/session-digest.d.ts +57 -0
- package/dist/core/session-digest.d.ts.map +1 -0
- package/dist/core/session-digest.js +193 -0
- package/dist/core/session-digest.js.map +1 -0
- package/dist/core/session-manager.d.ts +2 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +5 -4
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +17 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +47 -2
- 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 +4 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/spec-kit/compiler.d.ts +67 -0
- package/dist/core/spec-kit/compiler.d.ts.map +1 -0
- package/dist/core/spec-kit/compiler.js +268 -0
- package/dist/core/spec-kit/compiler.js.map +1 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +25 -7
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/telemetry.d.ts.map +1 -1
- package/dist/core/telemetry.js +1 -1
- package/dist/core/telemetry.js.map +1 -1
- package/dist/core/timings.d.ts +1 -1
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +2 -2
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts +28 -3
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +53 -10
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +12 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +24 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +3 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +3 -0
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +3 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +4 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +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 +3 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +3 -0
- package/dist/core/tools/ls.js.map +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/read.d.ts +13 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +29 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts +3 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +3 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/transaction-coordinator.d.ts +30 -0
- package/dist/core/transaction-coordinator.d.ts.map +1 -0
- package/dist/core/transaction-coordinator.js +173 -0
- package/dist/core/transaction-coordinator.js.map +1 -0
- package/dist/index.d.ts +19 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +4 -6
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +35 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +410 -4
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-gradient-motion.d.ts +28 -0
- package/dist/modes/interactive/components/control-panel-gradient-motion.d.ts.map +1 -0
- package/dist/modes/interactive/components/control-panel-gradient-motion.js +146 -0
- package/dist/modes/interactive/components/control-panel-gradient-motion.js.map +1 -0
- package/dist/modes/interactive/components/control-panel-gradient.d.ts +27 -0
- package/dist/modes/interactive/components/control-panel-gradient.d.ts.map +1 -0
- package/dist/modes/interactive/components/control-panel-gradient.js +127 -0
- package/dist/modes/interactive/components/control-panel-gradient.js.map +1 -0
- package/dist/modes/interactive/components/control-panel.d.ts +56 -0
- package/dist/modes/interactive/components/control-panel.d.ts.map +1 -0
- package/dist/modes/interactive/components/control-panel.js +240 -0
- package/dist/modes/interactive/components/control-panel.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +21 -13
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js +1 -1
- package/dist/modes/interactive/components/earendil-announcement.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 -1
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +8 -0
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +3 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +3 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/mcp-selector.d.ts +30 -0
- package/dist/modes/interactive/components/mcp-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/mcp-selector.js +155 -0
- package/dist/modes/interactive/components/mcp-selector.js.map +1 -0
- package/dist/modes/interactive/components/model-selector-state.d.ts +101 -0
- package/dist/modes/interactive/components/model-selector-state.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector-state.js +261 -0
- package/dist/modes/interactive/components/model-selector-state.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +52 -9
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +212 -66
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +19 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +21 -8
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skills-selector.d.ts +32 -0
- package/dist/modes/interactive/components/skills-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/skills-selector.js +130 -0
- package/dist/modes/interactive/components/skills-selector.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +10 -1
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +7 -8
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +7 -48
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +13 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +399 -108
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/catppuccin-mocha.json +86 -0
- package/dist/modes/interactive/theme/dracula.json +86 -0
- package/dist/modes/interactive/theme/gruvbox-dark.json +86 -0
- package/dist/modes/interactive/theme/kanagawa-dragon.json +86 -0
- package/dist/modes/interactive/theme/omk-blackboard.json +91 -0
- package/dist/modes/interactive/theme/omk-control-panel.json +91 -0
- package/dist/modes/interactive/theme/omk-freedom-grid.json +91 -0
- package/dist/modes/interactive/theme/omk-neon-ops.json +90 -0
- package/dist/modes/interactive/theme/omk-slate-light.json +91 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +55 -16
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/theme/tokyo-night-storm.json +86 -0
- package/dist/modes/print-mode.d.ts +2 -2
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +2 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +4 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +114 -49
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/omk-user-agent.d.ts +2 -0
- package/dist/utils/omk-user-agent.d.ts.map +1 -0
- package/dist/utils/{pi-user-agent.js → omk-user-agent.js} +2 -2
- package/dist/utils/omk-user-agent.js.map +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +1 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +5 -5
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +8 -11
- 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 +1 -1
- package/dist/utils/windows-self-update.js.map +1 -1
- package/docs/compaction.md +21 -8
- package/docs/packages.md +47 -6
- package/docs/prompt-templates.md +2 -0
- package/docs/quickstart.md +1 -1
- package/docs/themes.md +10 -2
- package/docs/usage.md +18 -7
- package/examples/README.md +1 -1
- package/examples/extensions/README.md +11 -11
- package/examples/extensions/auto-commit-on-exit.ts +6 -6
- package/examples/extensions/bash-spawn-hook.ts +4 -4
- package/examples/extensions/bookmark.ts +5 -5
- package/examples/extensions/border-status-editor.ts +7 -7
- package/examples/extensions/built-in-tool-renderer.ts +6 -6
- package/examples/extensions/claude-rules.ts +4 -4
- package/examples/extensions/commands.ts +5 -5
- package/examples/extensions/confirm-destructive.ts +3 -3
- package/examples/extensions/custom-compaction.ts +3 -3
- package/examples/extensions/custom-footer.ts +2 -2
- package/examples/extensions/custom-header.ts +5 -5
- package/examples/extensions/custom-provider-anthropic/index.ts +4 -4
- 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/index.ts +3 -3
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/dirty-repo-guard.ts +7 -7
- package/examples/extensions/doom-overlay/README.md +3 -3
- package/examples/extensions/doom-overlay/doom/build.sh +2 -2
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +1 -1
- package/examples/extensions/doom-overlay/index.ts +3 -3
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/dynamic-resources/index.ts +2 -2
- package/examples/extensions/dynamic-tools.ts +4 -4
- package/examples/extensions/event-bus.ts +8 -8
- package/examples/extensions/file-trigger.ts +3 -3
- package/examples/extensions/git-checkpoint.ts +7 -7
- package/examples/extensions/git-merge-and-resolve.ts +14 -14
- package/examples/extensions/github-issue-autocomplete.ts +6 -6
- package/examples/extensions/gondolin/index.ts +16 -16
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/handoff.ts +2 -2
- package/examples/extensions/hello.ts +2 -2
- package/examples/extensions/hidden-thinking-label.ts +4 -4
- package/examples/extensions/inline-bash.ts +5 -5
- package/examples/extensions/input-transform-streaming.ts +5 -5
- package/examples/extensions/input-transform.ts +5 -5
- package/examples/extensions/interactive-shell.ts +3 -3
- package/examples/extensions/mac-system-theme.ts +5 -5
- package/examples/extensions/message-renderer.ts +4 -4
- package/examples/extensions/minimal-mode.ts +9 -9
- package/examples/extensions/modal-editor.ts +3 -3
- package/examples/extensions/model-status.ts +3 -3
- package/examples/extensions/notify.ts +5 -5
- package/examples/extensions/overlay-qa-tests.ts +20 -20
- package/examples/extensions/overlay-test.ts +3 -3
- package/examples/extensions/permission-gate.ts +2 -2
- package/examples/extensions/pirate.ts +4 -4
- package/examples/extensions/plan-mode/index.ts +22 -22
- package/examples/extensions/preset.ts +30 -30
- package/examples/extensions/prompt-customizer.ts +3 -3
- package/examples/extensions/protected-paths.ts +2 -2
- package/examples/extensions/provider-payload.ts +5 -5
- package/examples/extensions/qna.ts +2 -2
- package/examples/extensions/question.ts +2 -2
- package/examples/extensions/questionnaire.ts +2 -2
- package/examples/extensions/rainbow-editor.ts +3 -3
- package/examples/extensions/reload-runtime.ts +4 -4
- package/examples/extensions/rpc-demo.ts +10 -10
- package/examples/extensions/sandbox/index.ts +17 -17
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/send-user-message.ts +13 -13
- package/examples/extensions/session-name.ts +4 -4
- package/examples/extensions/shutdown-command.ts +10 -10
- package/examples/extensions/snake.ts +3 -3
- package/examples/extensions/space-invaders.ts +3 -3
- package/examples/extensions/ssh.ts +12 -12
- package/examples/extensions/status-line.ts +4 -4
- package/examples/extensions/structured-output.ts +2 -2
- package/examples/extensions/subagent/README.md +13 -13
- package/examples/extensions/subagent/agents.ts +2 -2
- package/examples/extensions/subagent/index.ts +53 -21
- package/examples/extensions/summarize.ts +2 -2
- package/examples/extensions/system-prompt-header.ts +3 -3
- package/examples/extensions/tic-tac-toe.ts +15 -15
- package/examples/extensions/timed-confirm.ts +4 -4
- package/examples/extensions/titlebar-spinner.ts +9 -9
- package/examples/extensions/todo.ts +5 -5
- package/examples/extensions/tool-override.ts +5 -5
- package/examples/extensions/tools.ts +10 -10
- package/examples/extensions/trigger-compact.ts +3 -3
- package/examples/extensions/truncated-tool.ts +3 -3
- package/examples/extensions/widget-placement.ts +2 -2
- package/examples/extensions/with-deps/index.ts +2 -2
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/extensions/working-indicator.ts +7 -7
- package/examples/extensions/working-message-test.ts +3 -3
- package/examples/sdk/01-minimal.ts +1 -1
- package/examples/sdk/03-custom-prompt.ts +1 -1
- package/examples/sdk/04-skills.ts +1 -1
- package/examples/sdk/05-tools.ts +1 -1
- package/examples/sdk/06-extensions.ts +11 -11
- package/examples/sdk/07-context-files.ts +2 -0
- package/examples/sdk/08-prompt-templates.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +2 -2
- package/examples/sdk/README.md +2 -2
- package/node_modules/@earendil-works/omk-agent-core/README.md +488 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/agent-loop.d.ts +24 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/agent-loop.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/agent-loop.js +553 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/agent-loop.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/agent.d.ts +118 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/agent.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/agent.js +402 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/agent.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/agent-harness.d.ts +95 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/agent-harness.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/agent-harness.js +996 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/agent-harness.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/branch-summarization.d.ts +53 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/branch-summarization.js +175 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/compaction.d.ts +117 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/compaction.js +568 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/compaction.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/utils.d.ts +25 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/utils.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/utils.js +131 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/compaction/utils.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/env/nodejs.d.ts +51 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/env/nodejs.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/env/nodejs.js +510 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/env/nodejs.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/messages.d.ts +51 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/messages.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/messages.js +102 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/messages.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/prompt-templates.d.ts +48 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/prompt-templates.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/prompt-templates.js +230 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/prompt-templates.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-repo.d.ts +26 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-repo.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-repo.js +101 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-repo.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-storage.d.ts +36 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-storage.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-storage.js +273 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/jsonl-storage.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-repo.d.ts +18 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-repo.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-repo.js +42 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-repo.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-storage.d.ts +25 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-storage.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-storage.js +114 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/memory-storage.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/repo-utils.d.ts +11 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/repo-utils.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/repo-utils.js +39 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/repo-utils.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/session.d.ts +33 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/session.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/session.js +210 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/session.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/uuid.d.ts +2 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/uuid.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/uuid.js +50 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/session/uuid.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/skills.d.ts +44 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/skills.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/skills.js +311 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/skills.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/system-prompt.d.ts +3 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/system-prompt.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/system-prompt.js +30 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/system-prompt.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/types.d.ts +616 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/types.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/types.js +94 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/types.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/shell-output.d.ts +14 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/shell-output.js +126 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/shell-output.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/truncate.d.ts +70 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/truncate.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/truncate.js +297 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/harness/utils/truncate.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/index.d.ts +20 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/index.js +25 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/index.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/node.d.ts +3 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/node.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/node.js +3 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/node.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/proxy.d.ts +69 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/proxy.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/proxy.js +278 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/proxy.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/types.d.ts +393 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/types.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/types.js +2 -0
- package/node_modules/@earendil-works/omk-agent-core/dist/types.js.map +1 -0
- package/node_modules/@earendil-works/omk-agent-core/package.json +60 -0
- package/node_modules/@earendil-works/omk-ai/README.md +1389 -0
- package/node_modules/@earendil-works/omk-ai/dist/api-registry.d.ts +20 -0
- package/node_modules/@earendil-works/omk-ai/dist/api-registry.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/api-registry.js +44 -0
- package/node_modules/@earendil-works/omk-ai/dist/api-registry.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/bedrock-provider.d.ts +5 -0
- package/node_modules/@earendil-works/omk-ai/dist/bedrock-provider.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/bedrock-provider.js +6 -0
- package/node_modules/@earendil-works/omk-ai/dist/bedrock-provider.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/cli.d.ts +3 -0
- package/node_modules/@earendil-works/omk-ai/dist/cli.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/cli.js +130 -0
- package/node_modules/@earendil-works/omk-ai/dist/cli.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/env-api-keys.d.ts +20 -0
- package/node_modules/@earendil-works/omk-ai/dist/env-api-keys.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/env-api-keys.js +199 -0
- package/node_modules/@earendil-works/omk-ai/dist/env-api-keys.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/image-models.d.ts +10 -0
- package/node_modules/@earendil-works/omk-ai/dist/image-models.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/image-models.generated.d.ts +515 -0
- package/node_modules/@earendil-works/omk-ai/dist/image-models.generated.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/image-models.generated.js +517 -0
- package/node_modules/@earendil-works/omk-ai/dist/image-models.generated.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/image-models.js +23 -0
- package/node_modules/@earendil-works/omk-ai/dist/image-models.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/images-api-registry.d.ts +14 -0
- package/node_modules/@earendil-works/omk-ai/dist/images-api-registry.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/images-api-registry.js +22 -0
- package/node_modules/@earendil-works/omk-ai/dist/images-api-registry.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/images.d.ts +4 -0
- package/node_modules/@earendil-works/omk-ai/dist/images.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/images.js +16 -0
- package/node_modules/@earendil-works/omk-ai/dist/images.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/index.d.ts +33 -0
- package/node_modules/@earendil-works/omk-ai/dist/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/index.js +21 -0
- package/node_modules/@earendil-works/omk-ai/dist/index.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/models.d.ts +18 -0
- package/node_modules/@earendil-works/omk-ai/dist/models.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/models.generated.d.ts +18762 -0
- package/node_modules/@earendil-works/omk-ai/dist/models.generated.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/models.generated.js +17197 -0
- package/node_modules/@earendil-works/omk-ai/dist/models.generated.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/models.js +78 -0
- package/node_modules/@earendil-works/omk-ai/dist/models.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/oauth.d.ts +2 -0
- package/node_modules/@earendil-works/omk-ai/dist/oauth.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/oauth.js +2 -0
- package/node_modules/@earendil-works/omk-ai/dist/oauth.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/provider-network.d.ts +39 -0
- package/node_modules/@earendil-works/omk-ai/dist/provider-network.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/provider-network.js +170 -0
- package/node_modules/@earendil-works/omk-ai/dist/provider-network.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/amazon-bedrock.d.ts +38 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/amazon-bedrock.js +826 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/amazon-bedrock.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/anthropic.d.ts +77 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/anthropic.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/anthropic.js +1123 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/anthropic.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/azure-openai-responses.d.ts +15 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/azure-openai-responses.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/azure-openai-responses.js +221 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/azure-openai-responses.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/cloudflare.d.ts +13 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/cloudflare.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/cloudflare.js +26 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/cloudflare.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/faux.d.ts +56 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/faux.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/faux.js +368 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/faux.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/github-copilot-headers.d.ts +8 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/github-copilot-headers.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/github-copilot-headers.js +29 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/github-copilot-headers.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google-shared.d.ts +70 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google-shared.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google-shared.js +331 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google-shared.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google-vertex.d.ts +15 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google-vertex.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google-vertex.js +442 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google-vertex.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google.d.ts +13 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google.js +402 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/google.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/images/openrouter.d.ts +3 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/images/openrouter.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/images/openrouter.js +128 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/images/openrouter.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/images/register-builtins.d.ts +4 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/images/register-builtins.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/images/register-builtins.js +34 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/images/register-builtins.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/mistral.d.ts +25 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/mistral.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/mistral.js +534 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/mistral.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-codex-responses.d.ts +30 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-codex-responses.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-codex-responses.js +1171 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-codex-responses.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-completions.d.ts +19 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-completions.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-completions.js +977 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-completions.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-prompt-cache.d.ts +11 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-prompt-cache.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-prompt-cache.js +22 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-prompt-cache.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses-shared.d.ts +18 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses-shared.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses-shared.js +496 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses-shared.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses.d.ts +13 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses.js +233 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/openai-responses.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/register-builtins.d.ts +35 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/register-builtins.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/register-builtins.js +254 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/register-builtins.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/simple-options.d.ts +8 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/simple-options.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/simple-options.js +42 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/simple-options.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/tool-schema.d.ts +13 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/tool-schema.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/tool-schema.js +82 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/tool-schema.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/transform-messages.d.ts +8 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/transform-messages.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/transform-messages.js +184 -0
- package/node_modules/@earendil-works/omk-ai/dist/providers/transform-messages.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/session-resources.d.ts +4 -0
- package/node_modules/@earendil-works/omk-ai/dist/session-resources.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/session-resources.js +22 -0
- package/node_modules/@earendil-works/omk-ai/dist/session-resources.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/stream.d.ts +8 -0
- package/node_modules/@earendil-works/omk-ai/dist/stream.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/stream.js +77 -0
- package/node_modules/@earendil-works/omk-ai/dist/stream.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/types.d.ts +570 -0
- package/node_modules/@earendil-works/omk-ai/dist/types.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/types.js +2 -0
- package/node_modules/@earendil-works/omk-ai/dist/types.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/abort-signals.d.ts +6 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/abort-signals.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/abort-signals.js +34 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/abort-signals.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/diagnostics.d.ts +19 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/diagnostics.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/diagnostics.js +25 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/diagnostics.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/event-stream.d.ts +21 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/event-stream.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/event-stream.js +81 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/event-stream.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/hash.d.ts +3 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/hash.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/hash.js +14 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/hash.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/headers.d.ts +2 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/headers.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/headers.js +8 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/headers.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/json-parse.d.ts +16 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/json-parse.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/json-parse.js +113 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/json-parse.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/node-http-proxy.d.ts +10 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/node-http-proxy.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/node-http-proxy.js +97 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/node-http-proxy.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/anthropic.d.ts +25 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/anthropic.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/anthropic.js +335 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/anthropic.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/device-code.d.ts +21 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/device-code.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/device-code.js +56 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/device-code.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/github-copilot.d.ts +30 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/github-copilot.js +280 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/github-copilot.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/index.d.ts +58 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/index.js +122 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/index.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/oauth-page.d.ts +3 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/oauth-page.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/oauth-page.js +105 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/oauth-page.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/openai-codex.d.ts +43 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/openai-codex.js +487 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/openai-codex.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/pkce.d.ts +13 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/pkce.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/pkce.js +31 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/pkce.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/types.d.ts +64 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/types.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/types.js +2 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/oauth/types.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/overflow.d.ts +57 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/overflow.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/overflow.js +154 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/overflow.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/sanitize-unicode.d.ts +22 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/sanitize-unicode.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/sanitize-unicode.js +26 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/sanitize-unicode.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/typebox-helpers.d.ts +17 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/typebox-helpers.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/typebox-helpers.js +21 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/typebox-helpers.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/validation.d.ts +18 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/validation.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/validation.js +281 -0
- package/node_modules/@earendil-works/omk-ai/dist/utils/validation.js.map +1 -0
- package/node_modules/@earendil-works/omk-ai/package.json +106 -0
- package/node_modules/@earendil-works/omk-tui/README.md +791 -0
- package/node_modules/@earendil-works/omk-tui/dist/autocomplete.d.ts +54 -0
- package/node_modules/@earendil-works/omk-tui/dist/autocomplete.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/autocomplete.js +632 -0
- package/node_modules/@earendil-works/omk-tui/dist/autocomplete.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/box.d.ts +22 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/box.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/box.js +104 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/box.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/cancellable-loader.d.ts +22 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/cancellable-loader.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/cancellable-loader.js +35 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/cancellable-loader.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/editor.d.ts +249 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/editor.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/editor.js +1857 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/editor.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/image.d.ts +28 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/image.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/image.js +89 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/image.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/input.d.ts +37 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/input.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/input.js +378 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/input.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/loader.d.ts +31 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/loader.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/loader.js +69 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/loader.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/markdown.d.ts +96 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/markdown.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/markdown.js +644 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/markdown.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/select-list.d.ts +50 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/select-list.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/select-list.js +159 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/select-list.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/settings-list.d.ts +50 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/settings-list.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/settings-list.js +185 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/settings-list.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/spacer.d.ts +12 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/spacer.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/spacer.js +23 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/spacer.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/text.d.ts +19 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/text.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/text.js +89 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/text.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/truncated-text.d.ts +13 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/truncated-text.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/truncated-text.js +51 -0
- package/node_modules/@earendil-works/omk-tui/dist/components/truncated-text.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/editor-component.d.ts +39 -0
- package/node_modules/@earendil-works/omk-tui/dist/editor-component.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/editor-component.js +2 -0
- package/node_modules/@earendil-works/omk-tui/dist/editor-component.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/fuzzy.d.ts +16 -0
- package/node_modules/@earendil-works/omk-tui/dist/fuzzy.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/fuzzy.js +110 -0
- package/node_modules/@earendil-works/omk-tui/dist/fuzzy.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/index.d.ts +23 -0
- package/node_modules/@earendil-works/omk-tui/dist/index.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/index.js +32 -0
- package/node_modules/@earendil-works/omk-tui/dist/index.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/keybindings.d.ts +212 -0
- package/node_modules/@earendil-works/omk-tui/dist/keybindings.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/keybindings.js +252 -0
- package/node_modules/@earendil-works/omk-tui/dist/keybindings.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/keys.d.ts +184 -0
- package/node_modules/@earendil-works/omk-tui/dist/keys.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/keys.js +1173 -0
- package/node_modules/@earendil-works/omk-tui/dist/keys.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/kill-ring.d.ts +28 -0
- package/node_modules/@earendil-works/omk-tui/dist/kill-ring.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/kill-ring.js +44 -0
- package/node_modules/@earendil-works/omk-tui/dist/kill-ring.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/native-modifiers.d.ts +3 -0
- package/node_modules/@earendil-works/omk-tui/dist/native-modifiers.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/native-modifiers.js +53 -0
- package/node_modules/@earendil-works/omk-tui/dist/native-modifiers.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/stdin-buffer.d.ts +50 -0
- package/node_modules/@earendil-works/omk-tui/dist/stdin-buffer.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/stdin-buffer.js +361 -0
- package/node_modules/@earendil-works/omk-tui/dist/stdin-buffer.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/terminal-image.d.ts +90 -0
- package/node_modules/@earendil-works/omk-tui/dist/terminal-image.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/terminal-image.js +366 -0
- package/node_modules/@earendil-works/omk-tui/dist/terminal-image.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/terminal.d.ts +113 -0
- package/node_modules/@earendil-works/omk-tui/dist/terminal.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/terminal.js +472 -0
- package/node_modules/@earendil-works/omk-tui/dist/terminal.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/tui.d.ts +242 -0
- package/node_modules/@earendil-works/omk-tui/dist/tui.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/tui.js +1221 -0
- package/node_modules/@earendil-works/omk-tui/dist/tui.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/undo-stack.d.ts +17 -0
- package/node_modules/@earendil-works/omk-tui/dist/undo-stack.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/undo-stack.js +25 -0
- package/node_modules/@earendil-works/omk-tui/dist/undo-stack.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/utils.d.ts +84 -0
- package/node_modules/@earendil-works/omk-tui/dist/utils.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/utils.js +1032 -0
- package/node_modules/@earendil-works/omk-tui/dist/utils.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/word-navigation.d.ts +25 -0
- package/node_modules/@earendil-works/omk-tui/dist/word-navigation.d.ts.map +1 -0
- package/node_modules/@earendil-works/omk-tui/dist/word-navigation.js +96 -0
- package/node_modules/@earendil-works/omk-tui/dist/word-navigation.js.map +1 -0
- package/node_modules/@earendil-works/omk-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
- package/node_modules/@earendil-works/omk-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/node_modules/@earendil-works/omk-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/node_modules/@earendil-works/omk-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/node_modules/@earendil-works/omk-tui/package.json +47 -0
- package/package.json +22 -6
- package/dist/utils/pi-user-agent.d.ts +0 -2
- package/dist/utils/pi-user-agent.d.ts.map +0 -1
- package/dist/utils/pi-user-agent.js.map +0 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 1: fail-closed, ledger-gated transaction coordinator (pure algorithms).
|
|
3
|
+
*
|
|
4
|
+
* These functions are deterministic and side-effect free except through the
|
|
5
|
+
* injected in-memory transaction/store callbacks. No SQLite or filesystem is
|
|
6
|
+
* wired here; the real durable store is injected later. The invariant enforced
|
|
7
|
+
* is: no state-changing mutation commits unless its required ledger event was
|
|
8
|
+
* durably appended (JSONL fsync) and mirrored, in that order.
|
|
9
|
+
*
|
|
10
|
+
* Reference: .omk/runs/omk-autonomous-harness-remediation-plan/algorithm-plan.md
|
|
11
|
+
* (Phase 1) and audit-transaction.md.
|
|
12
|
+
*/
|
|
13
|
+
import { type TransactionPhase } from "./errors.ts";
|
|
14
|
+
/**
|
|
15
|
+
* A canonical, content-addressed ledger event record. `eventHash` is derived
|
|
16
|
+
* deterministically from the identity + state hashes, which is what makes
|
|
17
|
+
* idempotency detection (same key + same hash => no-op) reliable.
|
|
18
|
+
*/
|
|
19
|
+
export interface LedgerRecord {
|
|
20
|
+
operationId: string;
|
|
21
|
+
runId: string;
|
|
22
|
+
nodeId: string;
|
|
23
|
+
eventType: string;
|
|
24
|
+
phase: TransactionPhase;
|
|
25
|
+
idempotencyKey: string;
|
|
26
|
+
beforeStateHash: string;
|
|
27
|
+
afterStateHash: string;
|
|
28
|
+
eventHash: string;
|
|
29
|
+
attemptId?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Identity + intent for a single ledger-gated mutation. `mutate` is pure: it
|
|
33
|
+
* receives the snapshot and returns the staged next state without committing.
|
|
34
|
+
*/
|
|
35
|
+
export interface LedgerGatedTransactionRequest<S> {
|
|
36
|
+
runId: string;
|
|
37
|
+
nodeId: string;
|
|
38
|
+
operationId: string;
|
|
39
|
+
eventType: string;
|
|
40
|
+
phase: TransactionPhase;
|
|
41
|
+
idempotencyKey: string;
|
|
42
|
+
mutate: (before: S) => S;
|
|
43
|
+
attemptId?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Injected transaction handle (a single `BEGIN IMMEDIATE` scope). The fake used
|
|
47
|
+
* in tests and the real SQLite-backed handle implement this surface.
|
|
48
|
+
*
|
|
49
|
+
* Contract:
|
|
50
|
+
* - `appendRequiredEvent` simulates the durable JSONL append + fsync. It escapes
|
|
51
|
+
* transactional rollback (an appended event stays on disk).
|
|
52
|
+
* - `mirrorEvent` stages the SQLite mirror insert inside the open transaction.
|
|
53
|
+
* - `commit` applies the staged mirror + state; `rollback` discards them.
|
|
54
|
+
*/
|
|
55
|
+
export interface LedgerGatedTransactionHandle<S> {
|
|
56
|
+
snapshot: () => S;
|
|
57
|
+
findByIdempotencyKey: (key: string) => LedgerRecord | undefined;
|
|
58
|
+
appendRequiredEvent: (record: LedgerRecord) => void;
|
|
59
|
+
mirrorEvent: (record: LedgerRecord) => void;
|
|
60
|
+
commit: (state: S) => void;
|
|
61
|
+
rollback: () => void;
|
|
62
|
+
}
|
|
63
|
+
export interface LedgerGatedTransactionDeps<S> {
|
|
64
|
+
begin: () => LedgerGatedTransactionHandle<S>;
|
|
65
|
+
hashState?: (state: S) => string;
|
|
66
|
+
}
|
|
67
|
+
export type LedgerGatedTransactionStatus = "committed" | "noop";
|
|
68
|
+
export interface LedgerGatedTransactionResult<S> {
|
|
69
|
+
status: LedgerGatedTransactionStatus;
|
|
70
|
+
applied: boolean;
|
|
71
|
+
record: LedgerRecord;
|
|
72
|
+
state: S;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Default state hash. Callers with non-JSON state must inject `hashState`.
|
|
76
|
+
*/
|
|
77
|
+
export declare function coordinatorStateHash(state: unknown): string;
|
|
78
|
+
/**
|
|
79
|
+
* Deterministically derive a content hash for a ledger event from its identity
|
|
80
|
+
* and state transition. Volatile fields are excluded so replays are stable.
|
|
81
|
+
*/
|
|
82
|
+
export declare function computeCoordinatorEventHash(input: {
|
|
83
|
+
operationId: string;
|
|
84
|
+
runId: string;
|
|
85
|
+
nodeId: string;
|
|
86
|
+
eventType: string;
|
|
87
|
+
phase: TransactionPhase;
|
|
88
|
+
idempotencyKey: string;
|
|
89
|
+
beforeStateHash: string;
|
|
90
|
+
afterStateHash: string;
|
|
91
|
+
attemptId?: string;
|
|
92
|
+
}): string;
|
|
93
|
+
/**
|
|
94
|
+
* Build a complete ledger record (including `eventHash`) from a request and the
|
|
95
|
+
* computed before/after state hashes.
|
|
96
|
+
*/
|
|
97
|
+
export declare function buildLedgerRecord(request: {
|
|
98
|
+
operationId: string;
|
|
99
|
+
runId: string;
|
|
100
|
+
nodeId: string;
|
|
101
|
+
eventType: string;
|
|
102
|
+
phase: TransactionPhase;
|
|
103
|
+
idempotencyKey: string;
|
|
104
|
+
attemptId?: string;
|
|
105
|
+
}, beforeStateHash: string, afterStateHash: string): LedgerRecord;
|
|
106
|
+
/**
|
|
107
|
+
* Run one fail-closed, ledger-gated state-changing transaction.
|
|
108
|
+
*
|
|
109
|
+
* ```text
|
|
110
|
+
* BEGIN IMMEDIATE
|
|
111
|
+
* before = snapshot()
|
|
112
|
+
* staged = mutate(before) # no commit yet
|
|
113
|
+
* record = ledger event with before/after state hashes
|
|
114
|
+
* idempotency:
|
|
115
|
+
* same key + same eventHash -> rollback, no-op
|
|
116
|
+
* same key + different hash -> rollback, IDEMPOTENCY_CONFLICT
|
|
117
|
+
* appendRequiredEvent(record) # durable JSONL append + fsync
|
|
118
|
+
* fail -> rollback, LEDGER_APPEND_REQUIRED_FAILED
|
|
119
|
+
* mirrorEvent(record) # same transaction
|
|
120
|
+
* fail -> rollback, SQLITE_MIRROR_FAILED (ledger durable; replay repairs)
|
|
121
|
+
* commit(staged)
|
|
122
|
+
* fail -> rollback, SQLITE_COMMIT_AFTER_LEDGER_FAILED (ledger durable)
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* Any failure leaves the injected store unmutated (transaction rolled back);
|
|
126
|
+
* only the durable ledger append can survive, which recovery/replay reconciles.
|
|
127
|
+
*/
|
|
128
|
+
export declare function runLedgerGatedTransaction<S>(deps: LedgerGatedTransactionDeps<S>, request: LedgerGatedTransactionRequest<S>): LedgerGatedTransactionResult<S>;
|
|
129
|
+
/**
|
|
130
|
+
* A single side-effecting step that must record a receipt after its side effect.
|
|
131
|
+
* Each step declares a stable `receiptId` so a durable receipt can short-circuit
|
|
132
|
+
* re-execution on replay.
|
|
133
|
+
*/
|
|
134
|
+
export interface ReceiptedStep {
|
|
135
|
+
id: string;
|
|
136
|
+
receiptId: string;
|
|
137
|
+
sequence: number;
|
|
138
|
+
idempotent: boolean;
|
|
139
|
+
beforeStateHash: string;
|
|
140
|
+
afterStateHash: string;
|
|
141
|
+
run: () => void;
|
|
142
|
+
}
|
|
143
|
+
export interface ReceiptHandle {
|
|
144
|
+
findReceipt: (receiptId: string) => LedgerRecord | undefined;
|
|
145
|
+
appendReceiptEvent: (record: LedgerRecord) => void;
|
|
146
|
+
}
|
|
147
|
+
export interface ReceiptApplyRequest {
|
|
148
|
+
runId: string;
|
|
149
|
+
nodeId: string;
|
|
150
|
+
operationId: string;
|
|
151
|
+
attemptId?: string;
|
|
152
|
+
eventType?: string;
|
|
153
|
+
steps: readonly ReceiptedStep[];
|
|
154
|
+
}
|
|
155
|
+
export type ReceiptApplyStatus = "completed" | "in_doubt";
|
|
156
|
+
export interface ReceiptApplyResult {
|
|
157
|
+
status: ReceiptApplyStatus;
|
|
158
|
+
executedStepIds: string[];
|
|
159
|
+
skippedStepIds: string[];
|
|
160
|
+
appliedReceipts: LedgerRecord[];
|
|
161
|
+
stoppedAtStepId?: string;
|
|
162
|
+
reason?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Apply side-effecting steps in deterministic sequence order, recording a
|
|
166
|
+
* required receipt after each side effect.
|
|
167
|
+
*
|
|
168
|
+
* Fail-closed rule (algorithm-plan Phase 1, test 3): if a receipt append fails
|
|
169
|
+
* after its side effect ran, stop executing further side effects and return
|
|
170
|
+
* `in_doubt` — UNLESS a durable idempotent receipt for that step exists, in
|
|
171
|
+
* which case the side effect is provably recorded and execution continues.
|
|
172
|
+
*
|
|
173
|
+
* Steps whose receipt is already durably recorded are skipped (idempotent
|
|
174
|
+
* replay) and never re-run.
|
|
175
|
+
*/
|
|
176
|
+
export declare function applyReceiptedSteps(handle: ReceiptHandle, request: ReceiptApplyRequest): ReceiptApplyResult;
|
|
177
|
+
/**
|
|
178
|
+
* A registered compensator and its forward-execution status.
|
|
179
|
+
*/
|
|
180
|
+
export interface CompensatorExecutionStep {
|
|
181
|
+
id: string;
|
|
182
|
+
sequence: number;
|
|
183
|
+
idempotent: boolean;
|
|
184
|
+
applied: boolean;
|
|
185
|
+
run: () => void;
|
|
186
|
+
}
|
|
187
|
+
export interface CompensationHandle {
|
|
188
|
+
appendCompensationStart: (record: LedgerRecord) => void;
|
|
189
|
+
appendCompensationReceipt: (record: LedgerRecord) => void;
|
|
190
|
+
}
|
|
191
|
+
export interface GatedCompensationRequest {
|
|
192
|
+
runId: string;
|
|
193
|
+
nodeId: string;
|
|
194
|
+
operationId: string;
|
|
195
|
+
idempotencyKey: string;
|
|
196
|
+
beforeStateHash: string;
|
|
197
|
+
afterStateHash: string;
|
|
198
|
+
attemptId?: string;
|
|
199
|
+
steps: readonly CompensatorExecutionStep[];
|
|
200
|
+
}
|
|
201
|
+
export interface GatedCompensationResult {
|
|
202
|
+
status: "rolled_back";
|
|
203
|
+
executedStepIds: string[];
|
|
204
|
+
receipts: LedgerRecord[];
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Run compensation fail-closed (algorithm-plan Phase 1, test 4 + invariant I7).
|
|
208
|
+
*
|
|
209
|
+
* 1. Refuse to auto-compensate if any NON-idempotent step was already applied
|
|
210
|
+
* (state is ambiguous): throw COMPENSATION_FAILED before anything runs.
|
|
211
|
+
* 2. The compensation start is itself ledger-gated: if its required event cannot
|
|
212
|
+
* be appended, throw RequiredAuditWriteError and run NO compensators.
|
|
213
|
+
* 3. Only idempotent compensators run, in reverse execution order, each
|
|
214
|
+
* recording a compensation receipt.
|
|
215
|
+
*/
|
|
216
|
+
export declare function runGatedCompensation(handle: CompensationHandle, request: GatedCompensationRequest): GatedCompensationResult;
|
|
217
|
+
//# sourceMappingURL=transaction-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-coordinator.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/transaction-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,aAAa,CAAC;AAGrB;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,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AY,KAAK,IAAI,CAAC;IACxD,yBAAyB,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAC1D;AAED,MAAM,WAAW,wBAAwB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,SAAS,wBAAwB,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACvC,MAAM,EAAE,aAAa,CAAC;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,EAAE,YAAY,EAAE,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,wBAAwB,GAC/B,uBAAuB,CAyEzB","sourcesContent":["/**\n * Phase 1: fail-closed, ledger-gated transaction coordinator (pure algorithms).\n *\n * These functions are deterministic and side-effect free except through the\n * injected in-memory transaction/store callbacks. No SQLite or filesystem is\n * wired here; the real durable store is injected later. The invariant enforced\n * is: no state-changing mutation commits unless its required ledger event was\n * durably appended (JSONL fsync) and mirrored, in that order.\n *\n * Reference: .omk/runs/omk-autonomous-harness-remediation-plan/algorithm-plan.md\n * (Phase 1) and audit-transaction.md.\n */\n\nimport {\n\tCoordinatorError,\n\ttype CoordinatorRecoverability,\n\tRequiredAuditWriteError,\n\ttype TransactionPhase,\n} from \"./errors.ts\";\nimport { type JsonValue, sha256Hex, stableStringify } from \"./replay-ledger.ts\";\n\n/**\n * A canonical, content-addressed ledger event record. `eventHash` is derived\n * deterministically from the identity + state hashes, which is what makes\n * idempotency detection (same key + same hash => no-op) reliable.\n */\nexport interface LedgerRecord {\n\toperationId: string;\n\trunId: string;\n\tnodeId: string;\n\teventType: string;\n\tphase: TransactionPhase;\n\tidempotencyKey: string;\n\tbeforeStateHash: string;\n\tafterStateHash: string;\n\teventHash: string;\n\tattemptId?: string;\n}\n\n/**\n * Identity + intent for a single ledger-gated mutation. `mutate` is pure: it\n * receives the snapshot and returns the staged next state without committing.\n */\nexport interface LedgerGatedTransactionRequest<S> {\n\trunId: string;\n\tnodeId: string;\n\toperationId: string;\n\teventType: string;\n\tphase: TransactionPhase;\n\tidempotencyKey: string;\n\tmutate: (before: S) => S;\n\tattemptId?: string;\n}\n\n/**\n * Injected transaction handle (a single `BEGIN IMMEDIATE` scope). The fake used\n * in tests and the real SQLite-backed handle implement this surface.\n *\n * Contract:\n * - `appendRequiredEvent` simulates the durable JSONL append + fsync. It escapes\n * transactional rollback (an appended event stays on disk).\n * - `mirrorEvent` stages the SQLite mirror insert inside the open transaction.\n * - `commit` applies the staged mirror + state; `rollback` discards them.\n */\nexport interface LedgerGatedTransactionHandle<S> {\n\tsnapshot: () => S;\n\tfindByIdempotencyKey: (key: string) => LedgerRecord | undefined;\n\tappendRequiredEvent: (record: LedgerRecord) => void;\n\tmirrorEvent: (record: LedgerRecord) => void;\n\tcommit: (state: S) => void;\n\trollback: () => void;\n}\n\nexport interface LedgerGatedTransactionDeps<S> {\n\tbegin: () => LedgerGatedTransactionHandle<S>;\n\thashState?: (state: S) => string;\n}\n\nexport type LedgerGatedTransactionStatus = \"committed\" | \"noop\";\n\nexport interface LedgerGatedTransactionResult<S> {\n\tstatus: LedgerGatedTransactionStatus;\n\tapplied: boolean;\n\trecord: LedgerRecord;\n\tstate: S;\n}\n\n/**\n * Default state hash. Callers with non-JSON state must inject `hashState`.\n */\nexport function coordinatorStateHash(state: unknown): string {\n\treturn sha256Hex(stableStringify(state as JsonValue));\n}\n\n/**\n * Deterministically derive a content hash for a ledger event from its identity\n * and state transition. Volatile fields are excluded so replays are stable.\n */\nexport function computeCoordinatorEventHash(input: {\n\toperationId: string;\n\trunId: string;\n\tnodeId: string;\n\teventType: string;\n\tphase: TransactionPhase;\n\tidempotencyKey: string;\n\tbeforeStateHash: string;\n\tafterStateHash: string;\n\tattemptId?: string;\n}): string {\n\tconst canonical: { readonly [key: string]: JsonValue } = {\n\t\toperationId: input.operationId,\n\t\trunId: input.runId,\n\t\tnodeId: input.nodeId,\n\t\teventType: input.eventType,\n\t\tphase: input.phase,\n\t\tidempotencyKey: input.idempotencyKey,\n\t\tbeforeStateHash: input.beforeStateHash,\n\t\tafterStateHash: input.afterStateHash,\n\t\tattemptId: input.attemptId ?? null,\n\t};\n\treturn sha256Hex(stableStringify(canonical));\n}\n\n/**\n * Build a complete ledger record (including `eventHash`) from a request and the\n * computed before/after state hashes.\n */\nexport function buildLedgerRecord(\n\trequest: {\n\t\toperationId: string;\n\t\trunId: string;\n\t\tnodeId: string;\n\t\teventType: string;\n\t\tphase: TransactionPhase;\n\t\tidempotencyKey: string;\n\t\tattemptId?: string;\n\t},\n\tbeforeStateHash: string,\n\tafterStateHash: string,\n): LedgerRecord {\n\tconst eventHash = computeCoordinatorEventHash({\n\t\toperationId: request.operationId,\n\t\trunId: request.runId,\n\t\tnodeId: request.nodeId,\n\t\teventType: request.eventType,\n\t\tphase: request.phase,\n\t\tidempotencyKey: request.idempotencyKey,\n\t\tbeforeStateHash,\n\t\tafterStateHash,\n\t\tattemptId: request.attemptId,\n\t});\n\treturn {\n\t\toperationId: request.operationId,\n\t\trunId: request.runId,\n\t\tnodeId: request.nodeId,\n\t\teventType: request.eventType,\n\t\tphase: request.phase,\n\t\tidempotencyKey: request.idempotencyKey,\n\t\tbeforeStateHash,\n\t\tafterStateHash,\n\t\teventHash,\n\t\t...(request.attemptId === undefined ? {} : { attemptId: request.attemptId }),\n\t};\n}\n\nfunction errorContext(\n\trequest: {\n\t\trunId: string;\n\t\tnodeId: string;\n\t\toperationId: string;\n\t\tphase: TransactionPhase;\n\t\teventType: string;\n\t\tattemptId?: string;\n\t},\n\trecoverability: CoordinatorRecoverability,\n\tcause?: unknown,\n): {\n\trunId: string;\n\tnodeId: string;\n\toperationId: string;\n\tphase: TransactionPhase;\n\teventType: string;\n\trecoverability: CoordinatorRecoverability;\n\tattemptId?: string;\n\tcause?: unknown;\n} {\n\treturn {\n\t\trunId: request.runId,\n\t\tnodeId: request.nodeId,\n\t\toperationId: request.operationId,\n\t\tphase: request.phase,\n\t\teventType: request.eventType,\n\t\trecoverability,\n\t\tattemptId: request.attemptId,\n\t\tcause,\n\t};\n}\n\n/**\n * Run one fail-closed, ledger-gated state-changing transaction.\n *\n * ```text\n * BEGIN IMMEDIATE\n * before = snapshot()\n * staged = mutate(before) # no commit yet\n * record = ledger event with before/after state hashes\n * idempotency:\n * same key + same eventHash -> rollback, no-op\n * same key + different hash -> rollback, IDEMPOTENCY_CONFLICT\n * appendRequiredEvent(record) # durable JSONL append + fsync\n * fail -> rollback, LEDGER_APPEND_REQUIRED_FAILED\n * mirrorEvent(record) # same transaction\n * fail -> rollback, SQLITE_MIRROR_FAILED (ledger durable; replay repairs)\n * commit(staged)\n * fail -> rollback, SQLITE_COMMIT_AFTER_LEDGER_FAILED (ledger durable)\n * ```\n *\n * Any failure leaves the injected store unmutated (transaction rolled back);\n * only the durable ledger append can survive, which recovery/replay reconciles.\n */\nexport function runLedgerGatedTransaction<S>(\n\tdeps: LedgerGatedTransactionDeps<S>,\n\trequest: LedgerGatedTransactionRequest<S>,\n): LedgerGatedTransactionResult<S> {\n\tconst hashState = deps.hashState ?? coordinatorStateHash;\n\tconst handle = deps.begin();\n\tlet settled = false;\n\tconst rollbackOnce = (): void => {\n\t\tif (!settled) {\n\t\t\tsettled = true;\n\t\t\thandle.rollback();\n\t\t}\n\t};\n\n\ttry {\n\t\tconst before = handle.snapshot();\n\t\tconst staged = request.mutate(before);\n\t\tconst record = buildLedgerRecord(request, hashState(before), hashState(staged));\n\n\t\tconst existing = handle.findByIdempotencyKey(request.idempotencyKey);\n\t\tif (existing !== undefined) {\n\t\t\trollbackOnce();\n\t\t\tif (existing.eventHash === record.eventHash) {\n\t\t\t\treturn { status: \"noop\", applied: false, record: existing, state: before };\n\t\t\t}\n\t\t\tthrow new CoordinatorError(\n\t\t\t\t\"IDEMPOTENCY_CONFLICT\",\n\t\t\t\t`idempotency key \"${request.idempotencyKey}\" already recorded with a different event hash`,\n\t\t\t\terrorContext(request, \"operator\"),\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\thandle.appendRequiredEvent(record);\n\t\t} catch (cause) {\n\t\t\trollbackOnce();\n\t\t\tthrow new RequiredAuditWriteError(\n\t\t\t\t`required ledger append failed for \"${request.eventType}\"`,\n\t\t\t\terrorContext(request, \"rollback\", cause),\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\thandle.mirrorEvent(record);\n\t\t} catch (cause) {\n\t\t\trollbackOnce();\n\t\t\tthrow new CoordinatorError(\n\t\t\t\t\"SQLITE_MIRROR_FAILED\",\n\t\t\t\t`sqlite mirror failed after ledger append for \"${request.eventType}\"`,\n\t\t\t\terrorContext(request, \"in_doubt\", cause),\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\thandle.commit(staged);\n\t\t\tsettled = true;\n\t\t} catch (cause) {\n\t\t\trollbackOnce();\n\t\t\tthrow new CoordinatorError(\n\t\t\t\t\"SQLITE_COMMIT_AFTER_LEDGER_FAILED\",\n\t\t\t\t`sqlite commit failed after ledger append for \"${request.eventType}\"`,\n\t\t\t\terrorContext(request, \"in_doubt\", cause),\n\t\t\t);\n\t\t}\n\n\t\treturn { status: \"committed\", applied: true, record, state: staged };\n\t} catch (error) {\n\t\trollbackOnce();\n\t\tthrow error;\n\t}\n}\n\n/**\n * A single side-effecting step that must record a receipt after its side effect.\n * Each step declares a stable `receiptId` so a durable receipt can short-circuit\n * re-execution on replay.\n */\nexport interface ReceiptedStep {\n\tid: string;\n\treceiptId: string;\n\tsequence: number;\n\tidempotent: boolean;\n\tbeforeStateHash: string;\n\tafterStateHash: string;\n\trun: () => void;\n}\n\nexport interface ReceiptHandle {\n\tfindReceipt: (receiptId: string) => LedgerRecord | undefined;\n\tappendReceiptEvent: (record: LedgerRecord) => void;\n}\n\nexport interface ReceiptApplyRequest {\n\trunId: string;\n\tnodeId: string;\n\toperationId: string;\n\tattemptId?: string;\n\teventType?: string;\n\tsteps: readonly ReceiptedStep[];\n}\n\nexport type ReceiptApplyStatus = \"completed\" | \"in_doubt\";\n\nexport interface ReceiptApplyResult {\n\tstatus: ReceiptApplyStatus;\n\texecutedStepIds: string[];\n\tskippedStepIds: string[];\n\tappliedReceipts: LedgerRecord[];\n\tstoppedAtStepId?: string;\n\treason?: string;\n}\n\n/**\n * Apply side-effecting steps in deterministic sequence order, recording a\n * required receipt after each side effect.\n *\n * Fail-closed rule (algorithm-plan Phase 1, test 3): if a receipt append fails\n * after its side effect ran, stop executing further side effects and return\n * `in_doubt` — UNLESS a durable idempotent receipt for that step exists, in\n * which case the side effect is provably recorded and execution continues.\n *\n * Steps whose receipt is already durably recorded are skipped (idempotent\n * replay) and never re-run.\n */\nexport function applyReceiptedSteps(handle: ReceiptHandle, request: ReceiptApplyRequest): ReceiptApplyResult {\n\tconst eventType = request.eventType ?? \"scheduler.node.receipt\";\n\tconst ordered = [...request.steps].sort((a, b) => a.sequence - b.sequence);\n\tconst executedStepIds: string[] = [];\n\tconst skippedStepIds: string[] = [];\n\tconst appliedReceipts: LedgerRecord[] = [];\n\n\tfor (const step of ordered) {\n\t\tconst pre = handle.findReceipt(step.receiptId);\n\t\tif (pre !== undefined) {\n\t\t\t// Receipt already durable: idempotent replay, do not re-run the side effect.\n\t\t\tskippedStepIds.push(step.id);\n\t\t\tappliedReceipts.push(pre);\n\t\t\tcontinue;\n\t\t}\n\n\t\tstep.run();\n\t\texecutedStepIds.push(step.id);\n\n\t\tconst record = buildLedgerRecord(\n\t\t\t{\n\t\t\t\toperationId: request.operationId,\n\t\t\t\trunId: request.runId,\n\t\t\t\tnodeId: request.nodeId,\n\t\t\t\teventType,\n\t\t\t\tphase: \"receipt\",\n\t\t\t\tidempotencyKey: step.receiptId,\n\t\t\t\tattemptId: request.attemptId,\n\t\t\t},\n\t\t\tstep.beforeStateHash,\n\t\t\tstep.afterStateHash,\n\t\t);\n\n\t\ttry {\n\t\t\thandle.appendReceiptEvent(record);\n\t\t\tappliedReceipts.push(record);\n\t\t} catch {\n\t\t\tconst post = handle.findReceipt(step.receiptId);\n\t\t\tif (post !== undefined) {\n\t\t\t\t// Receipt persisted despite the append error: recoverable, keep going.\n\t\t\t\tappliedReceipts.push(post);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstatus: \"in_doubt\",\n\t\t\t\texecutedStepIds,\n\t\t\t\tskippedStepIds,\n\t\t\t\tappliedReceipts,\n\t\t\t\tstoppedAtStepId: step.id,\n\t\t\t\treason: `receipt append failed after side effect for step \"${step.id}\" with no durable receipt`,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn { status: \"completed\", executedStepIds, skippedStepIds, appliedReceipts };\n}\n\n/**\n * A registered compensator and its forward-execution status.\n */\nexport interface CompensatorExecutionStep {\n\tid: string;\n\tsequence: number;\n\tidempotent: boolean;\n\tapplied: boolean;\n\trun: () => void;\n}\n\nexport interface CompensationHandle {\n\tappendCompensationStart: (record: LedgerRecord) => void;\n\tappendCompensationReceipt: (record: LedgerRecord) => void;\n}\n\nexport interface GatedCompensationRequest {\n\trunId: string;\n\tnodeId: string;\n\toperationId: string;\n\tidempotencyKey: string;\n\tbeforeStateHash: string;\n\tafterStateHash: string;\n\tattemptId?: string;\n\tsteps: readonly CompensatorExecutionStep[];\n}\n\nexport interface GatedCompensationResult {\n\tstatus: \"rolled_back\";\n\texecutedStepIds: string[];\n\treceipts: LedgerRecord[];\n}\n\n/**\n * Run compensation fail-closed (algorithm-plan Phase 1, test 4 + invariant I7).\n *\n * 1. Refuse to auto-compensate if any NON-idempotent step was already applied\n * (state is ambiguous): throw COMPENSATION_FAILED before anything runs.\n * 2. The compensation start is itself ledger-gated: if its required event cannot\n * be appended, throw RequiredAuditWriteError and run NO compensators.\n * 3. Only idempotent compensators run, in reverse execution order, each\n * recording a compensation receipt.\n */\nexport function runGatedCompensation(\n\thandle: CompensationHandle,\n\trequest: GatedCompensationRequest,\n): GatedCompensationResult {\n\tconst baseContext = {\n\t\trunId: request.runId,\n\t\tnodeId: request.nodeId,\n\t\toperationId: request.operationId,\n\t\tphase: \"compensate\" as TransactionPhase,\n\t\teventType: \"scheduler.node.compensating\",\n\t\tattemptId: request.attemptId,\n\t};\n\n\tfor (const step of request.steps) {\n\t\tif (!step.idempotent && step.applied) {\n\t\t\tthrow new CoordinatorError(\n\t\t\t\t\"COMPENSATION_FAILED\",\n\t\t\t\t`cannot auto-compensate non-idempotent step \"${step.id}\" that was already applied`,\n\t\t\t\t{ ...baseContext, recoverability: \"in_doubt\" },\n\t\t\t);\n\t\t}\n\t}\n\n\tconst startRecord = buildLedgerRecord(\n\t\t{\n\t\t\toperationId: request.operationId,\n\t\t\trunId: request.runId,\n\t\t\tnodeId: request.nodeId,\n\t\t\teventType: \"scheduler.node.compensating\",\n\t\t\tphase: \"compensate\",\n\t\t\tidempotencyKey: request.idempotencyKey,\n\t\t\tattemptId: request.attemptId,\n\t\t},\n\t\trequest.beforeStateHash,\n\t\trequest.afterStateHash,\n\t);\n\n\ttry {\n\t\thandle.appendCompensationStart(startRecord);\n\t} catch (cause) {\n\t\tthrow new RequiredAuditWriteError(\"required compensation-start ledger append failed\", { ...baseContext, cause });\n\t}\n\n\tconst reversed = request.steps.filter((step) => step.idempotent).sort((a, b) => b.sequence - a.sequence);\n\tconst executedStepIds: string[] = [];\n\tconst receipts: LedgerRecord[] = [];\n\n\tfor (const step of reversed) {\n\t\ttry {\n\t\t\tstep.run();\n\t\t} catch (cause) {\n\t\t\tthrow new CoordinatorError(\"COMPENSATION_FAILED\", `compensator \"${step.id}\" failed`, {\n\t\t\t\t...baseContext,\n\t\t\t\trecoverability: \"in_doubt\",\n\t\t\t\tcause,\n\t\t\t});\n\t\t}\n\t\texecutedStepIds.push(step.id);\n\t\tconst receipt = buildLedgerRecord(\n\t\t\t{\n\t\t\t\toperationId: request.operationId,\n\t\t\t\trunId: request.runId,\n\t\t\t\tnodeId: request.nodeId,\n\t\t\t\teventType: \"scheduler.node.compensation.receipt\",\n\t\t\t\tphase: \"compensate\",\n\t\t\t\tidempotencyKey: `${request.idempotencyKey}:${step.id}`,\n\t\t\t\tattemptId: request.attemptId,\n\t\t\t},\n\t\t\trequest.beforeStateHash,\n\t\t\trequest.afterStateHash,\n\t\t);\n\t\thandle.appendCompensationReceipt(receipt);\n\t\treceipts.push(receipt);\n\t}\n\n\treturn { status: \"rolled_back\", executedStepIds, receipts };\n}\n"]}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 1: fail-closed, ledger-gated transaction coordinator (pure algorithms).
|
|
3
|
+
*
|
|
4
|
+
* These functions are deterministic and side-effect free except through the
|
|
5
|
+
* injected in-memory transaction/store callbacks. No SQLite or filesystem is
|
|
6
|
+
* wired here; the real durable store is injected later. The invariant enforced
|
|
7
|
+
* is: no state-changing mutation commits unless its required ledger event was
|
|
8
|
+
* durably appended (JSONL fsync) and mirrored, in that order.
|
|
9
|
+
*
|
|
10
|
+
* Reference: .omk/runs/omk-autonomous-harness-remediation-plan/algorithm-plan.md
|
|
11
|
+
* (Phase 1) and audit-transaction.md.
|
|
12
|
+
*/
|
|
13
|
+
import { CoordinatorError, RequiredAuditWriteError, } from "./errors.js";
|
|
14
|
+
import { sha256Hex, stableStringify } from "./replay-ledger.js";
|
|
15
|
+
/**
|
|
16
|
+
* Default state hash. Callers with non-JSON state must inject `hashState`.
|
|
17
|
+
*/
|
|
18
|
+
export function coordinatorStateHash(state) {
|
|
19
|
+
return sha256Hex(stableStringify(state));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Deterministically derive a content hash for a ledger event from its identity
|
|
23
|
+
* and state transition. Volatile fields are excluded so replays are stable.
|
|
24
|
+
*/
|
|
25
|
+
export function computeCoordinatorEventHash(input) {
|
|
26
|
+
const canonical = {
|
|
27
|
+
operationId: input.operationId,
|
|
28
|
+
runId: input.runId,
|
|
29
|
+
nodeId: input.nodeId,
|
|
30
|
+
eventType: input.eventType,
|
|
31
|
+
phase: input.phase,
|
|
32
|
+
idempotencyKey: input.idempotencyKey,
|
|
33
|
+
beforeStateHash: input.beforeStateHash,
|
|
34
|
+
afterStateHash: input.afterStateHash,
|
|
35
|
+
attemptId: input.attemptId ?? null,
|
|
36
|
+
};
|
|
37
|
+
return sha256Hex(stableStringify(canonical));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build a complete ledger record (including `eventHash`) from a request and the
|
|
41
|
+
* computed before/after state hashes.
|
|
42
|
+
*/
|
|
43
|
+
export function buildLedgerRecord(request, beforeStateHash, afterStateHash) {
|
|
44
|
+
const eventHash = computeCoordinatorEventHash({
|
|
45
|
+
operationId: request.operationId,
|
|
46
|
+
runId: request.runId,
|
|
47
|
+
nodeId: request.nodeId,
|
|
48
|
+
eventType: request.eventType,
|
|
49
|
+
phase: request.phase,
|
|
50
|
+
idempotencyKey: request.idempotencyKey,
|
|
51
|
+
beforeStateHash,
|
|
52
|
+
afterStateHash,
|
|
53
|
+
attemptId: request.attemptId,
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
operationId: request.operationId,
|
|
57
|
+
runId: request.runId,
|
|
58
|
+
nodeId: request.nodeId,
|
|
59
|
+
eventType: request.eventType,
|
|
60
|
+
phase: request.phase,
|
|
61
|
+
idempotencyKey: request.idempotencyKey,
|
|
62
|
+
beforeStateHash,
|
|
63
|
+
afterStateHash,
|
|
64
|
+
eventHash,
|
|
65
|
+
...(request.attemptId === undefined ? {} : { attemptId: request.attemptId }),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function errorContext(request, recoverability, cause) {
|
|
69
|
+
return {
|
|
70
|
+
runId: request.runId,
|
|
71
|
+
nodeId: request.nodeId,
|
|
72
|
+
operationId: request.operationId,
|
|
73
|
+
phase: request.phase,
|
|
74
|
+
eventType: request.eventType,
|
|
75
|
+
recoverability,
|
|
76
|
+
attemptId: request.attemptId,
|
|
77
|
+
cause,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Run one fail-closed, ledger-gated state-changing transaction.
|
|
82
|
+
*
|
|
83
|
+
* ```text
|
|
84
|
+
* BEGIN IMMEDIATE
|
|
85
|
+
* before = snapshot()
|
|
86
|
+
* staged = mutate(before) # no commit yet
|
|
87
|
+
* record = ledger event with before/after state hashes
|
|
88
|
+
* idempotency:
|
|
89
|
+
* same key + same eventHash -> rollback, no-op
|
|
90
|
+
* same key + different hash -> rollback, IDEMPOTENCY_CONFLICT
|
|
91
|
+
* appendRequiredEvent(record) # durable JSONL append + fsync
|
|
92
|
+
* fail -> rollback, LEDGER_APPEND_REQUIRED_FAILED
|
|
93
|
+
* mirrorEvent(record) # same transaction
|
|
94
|
+
* fail -> rollback, SQLITE_MIRROR_FAILED (ledger durable; replay repairs)
|
|
95
|
+
* commit(staged)
|
|
96
|
+
* fail -> rollback, SQLITE_COMMIT_AFTER_LEDGER_FAILED (ledger durable)
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* Any failure leaves the injected store unmutated (transaction rolled back);
|
|
100
|
+
* only the durable ledger append can survive, which recovery/replay reconciles.
|
|
101
|
+
*/
|
|
102
|
+
export function runLedgerGatedTransaction(deps, request) {
|
|
103
|
+
const hashState = deps.hashState ?? coordinatorStateHash;
|
|
104
|
+
const handle = deps.begin();
|
|
105
|
+
let settled = false;
|
|
106
|
+
const rollbackOnce = () => {
|
|
107
|
+
if (!settled) {
|
|
108
|
+
settled = true;
|
|
109
|
+
handle.rollback();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
try {
|
|
113
|
+
const before = handle.snapshot();
|
|
114
|
+
const staged = request.mutate(before);
|
|
115
|
+
const record = buildLedgerRecord(request, hashState(before), hashState(staged));
|
|
116
|
+
const existing = handle.findByIdempotencyKey(request.idempotencyKey);
|
|
117
|
+
if (existing !== undefined) {
|
|
118
|
+
rollbackOnce();
|
|
119
|
+
if (existing.eventHash === record.eventHash) {
|
|
120
|
+
return { status: "noop", applied: false, record: existing, state: before };
|
|
121
|
+
}
|
|
122
|
+
throw new CoordinatorError("IDEMPOTENCY_CONFLICT", `idempotency key "${request.idempotencyKey}" already recorded with a different event hash`, errorContext(request, "operator"));
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
handle.appendRequiredEvent(record);
|
|
126
|
+
}
|
|
127
|
+
catch (cause) {
|
|
128
|
+
rollbackOnce();
|
|
129
|
+
throw new RequiredAuditWriteError(`required ledger append failed for "${request.eventType}"`, errorContext(request, "rollback", cause));
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
handle.mirrorEvent(record);
|
|
133
|
+
}
|
|
134
|
+
catch (cause) {
|
|
135
|
+
rollbackOnce();
|
|
136
|
+
throw new CoordinatorError("SQLITE_MIRROR_FAILED", `sqlite mirror failed after ledger append for "${request.eventType}"`, errorContext(request, "in_doubt", cause));
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
handle.commit(staged);
|
|
140
|
+
settled = true;
|
|
141
|
+
}
|
|
142
|
+
catch (cause) {
|
|
143
|
+
rollbackOnce();
|
|
144
|
+
throw new CoordinatorError("SQLITE_COMMIT_AFTER_LEDGER_FAILED", `sqlite commit failed after ledger append for "${request.eventType}"`, errorContext(request, "in_doubt", cause));
|
|
145
|
+
}
|
|
146
|
+
return { status: "committed", applied: true, record, state: staged };
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
rollbackOnce();
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Apply side-effecting steps in deterministic sequence order, recording a
|
|
155
|
+
* required receipt after each side effect.
|
|
156
|
+
*
|
|
157
|
+
* Fail-closed rule (algorithm-plan Phase 1, test 3): if a receipt append fails
|
|
158
|
+
* after its side effect ran, stop executing further side effects and return
|
|
159
|
+
* `in_doubt` — UNLESS a durable idempotent receipt for that step exists, in
|
|
160
|
+
* which case the side effect is provably recorded and execution continues.
|
|
161
|
+
*
|
|
162
|
+
* Steps whose receipt is already durably recorded are skipped (idempotent
|
|
163
|
+
* replay) and never re-run.
|
|
164
|
+
*/
|
|
165
|
+
export function applyReceiptedSteps(handle, request) {
|
|
166
|
+
const eventType = request.eventType ?? "scheduler.node.receipt";
|
|
167
|
+
const ordered = [...request.steps].sort((a, b) => a.sequence - b.sequence);
|
|
168
|
+
const executedStepIds = [];
|
|
169
|
+
const skippedStepIds = [];
|
|
170
|
+
const appliedReceipts = [];
|
|
171
|
+
for (const step of ordered) {
|
|
172
|
+
const pre = handle.findReceipt(step.receiptId);
|
|
173
|
+
if (pre !== undefined) {
|
|
174
|
+
// Receipt already durable: idempotent replay, do not re-run the side effect.
|
|
175
|
+
skippedStepIds.push(step.id);
|
|
176
|
+
appliedReceipts.push(pre);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
step.run();
|
|
180
|
+
executedStepIds.push(step.id);
|
|
181
|
+
const record = buildLedgerRecord({
|
|
182
|
+
operationId: request.operationId,
|
|
183
|
+
runId: request.runId,
|
|
184
|
+
nodeId: request.nodeId,
|
|
185
|
+
eventType,
|
|
186
|
+
phase: "receipt",
|
|
187
|
+
idempotencyKey: step.receiptId,
|
|
188
|
+
attemptId: request.attemptId,
|
|
189
|
+
}, step.beforeStateHash, step.afterStateHash);
|
|
190
|
+
try {
|
|
191
|
+
handle.appendReceiptEvent(record);
|
|
192
|
+
appliedReceipts.push(record);
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
const post = handle.findReceipt(step.receiptId);
|
|
196
|
+
if (post !== undefined) {
|
|
197
|
+
// Receipt persisted despite the append error: recoverable, keep going.
|
|
198
|
+
appliedReceipts.push(post);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
status: "in_doubt",
|
|
203
|
+
executedStepIds,
|
|
204
|
+
skippedStepIds,
|
|
205
|
+
appliedReceipts,
|
|
206
|
+
stoppedAtStepId: step.id,
|
|
207
|
+
reason: `receipt append failed after side effect for step "${step.id}" with no durable receipt`,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return { status: "completed", executedStepIds, skippedStepIds, appliedReceipts };
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Run compensation fail-closed (algorithm-plan Phase 1, test 4 + invariant I7).
|
|
215
|
+
*
|
|
216
|
+
* 1. Refuse to auto-compensate if any NON-idempotent step was already applied
|
|
217
|
+
* (state is ambiguous): throw COMPENSATION_FAILED before anything runs.
|
|
218
|
+
* 2. The compensation start is itself ledger-gated: if its required event cannot
|
|
219
|
+
* be appended, throw RequiredAuditWriteError and run NO compensators.
|
|
220
|
+
* 3. Only idempotent compensators run, in reverse execution order, each
|
|
221
|
+
* recording a compensation receipt.
|
|
222
|
+
*/
|
|
223
|
+
export function runGatedCompensation(handle, request) {
|
|
224
|
+
const baseContext = {
|
|
225
|
+
runId: request.runId,
|
|
226
|
+
nodeId: request.nodeId,
|
|
227
|
+
operationId: request.operationId,
|
|
228
|
+
phase: "compensate",
|
|
229
|
+
eventType: "scheduler.node.compensating",
|
|
230
|
+
attemptId: request.attemptId,
|
|
231
|
+
};
|
|
232
|
+
for (const step of request.steps) {
|
|
233
|
+
if (!step.idempotent && step.applied) {
|
|
234
|
+
throw new CoordinatorError("COMPENSATION_FAILED", `cannot auto-compensate non-idempotent step "${step.id}" that was already applied`, { ...baseContext, recoverability: "in_doubt" });
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const startRecord = buildLedgerRecord({
|
|
238
|
+
operationId: request.operationId,
|
|
239
|
+
runId: request.runId,
|
|
240
|
+
nodeId: request.nodeId,
|
|
241
|
+
eventType: "scheduler.node.compensating",
|
|
242
|
+
phase: "compensate",
|
|
243
|
+
idempotencyKey: request.idempotencyKey,
|
|
244
|
+
attemptId: request.attemptId,
|
|
245
|
+
}, request.beforeStateHash, request.afterStateHash);
|
|
246
|
+
try {
|
|
247
|
+
handle.appendCompensationStart(startRecord);
|
|
248
|
+
}
|
|
249
|
+
catch (cause) {
|
|
250
|
+
throw new RequiredAuditWriteError("required compensation-start ledger append failed", { ...baseContext, cause });
|
|
251
|
+
}
|
|
252
|
+
const reversed = request.steps.filter((step) => step.idempotent).sort((a, b) => b.sequence - a.sequence);
|
|
253
|
+
const executedStepIds = [];
|
|
254
|
+
const receipts = [];
|
|
255
|
+
for (const step of reversed) {
|
|
256
|
+
try {
|
|
257
|
+
step.run();
|
|
258
|
+
}
|
|
259
|
+
catch (cause) {
|
|
260
|
+
throw new CoordinatorError("COMPENSATION_FAILED", `compensator "${step.id}" failed`, {
|
|
261
|
+
...baseContext,
|
|
262
|
+
recoverability: "in_doubt",
|
|
263
|
+
cause,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
executedStepIds.push(step.id);
|
|
267
|
+
const receipt = buildLedgerRecord({
|
|
268
|
+
operationId: request.operationId,
|
|
269
|
+
runId: request.runId,
|
|
270
|
+
nodeId: request.nodeId,
|
|
271
|
+
eventType: "scheduler.node.compensation.receipt",
|
|
272
|
+
phase: "compensate",
|
|
273
|
+
idempotencyKey: `${request.idempotencyKey}:${step.id}`,
|
|
274
|
+
attemptId: request.attemptId,
|
|
275
|
+
}, request.beforeStateHash, request.afterStateHash);
|
|
276
|
+
handle.appendCompensationReceipt(receipt);
|
|
277
|
+
receipts.push(receipt);
|
|
278
|
+
}
|
|
279
|
+
return { status: "rolled_back", executedStepIds, receipts };
|
|
280
|
+
}
|
|
281
|
+
//# sourceMappingURL=transaction-coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-coordinator.js","sourceRoot":"","sources":["../../../src/core/orchestration/transaction-coordinator.ts"],"names":[],"mappings":"AAAA;;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C,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IACzG,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAmB,EAAE,CAAC;IAEpC,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC;YACJ,IAAI,CAAC,GAAG,EAAE,CAAC;QACZ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,gBAAgB,CAAC,qBAAqB,EAAE,gBAAgB,IAAI,CAAC,EAAE,UAAU,EAAE;gBACpF,GAAG,WAAW;gBACd,cAAc,EAAE,UAAU;gBAC1B,KAAK;aACL,CAAC,CAAC;QACJ,CAAC;QACD,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,OAAO,GAAG,iBAAiB,CAChC;YACC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,qCAAqC;YAChD,KAAK,EAAE,YAAY;YACnB,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC,EAAE,EAAE;YACtD,SAAS,EAAE,OAAO,CAAC,SAAS;SAC5B,EACD,OAAO,CAAC,eAAe,EACvB,OAAO,CAAC,cAAc,CACtB,CAAC;QACF,MAAM,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC1C,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC;AAAA,CAC5D","sourcesContent":["/**\n * Phase 1: fail-closed, ledger-gated transaction coordinator (pure algorithms).\n *\n * These functions are deterministic and side-effect free except through the\n * injected in-memory transaction/store callbacks. No SQLite or filesystem is\n * wired here; the real durable store is injected later. The invariant enforced\n * is: no state-changing mutation commits unless its required ledger event was\n * durably appended (JSONL fsync) and mirrored, in that order.\n *\n * Reference: .omk/runs/omk-autonomous-harness-remediation-plan/algorithm-plan.md\n * (Phase 1) and audit-transaction.md.\n */\n\nimport {\n\tCoordinatorError,\n\ttype CoordinatorRecoverability,\n\tRequiredAuditWriteError,\n\ttype TransactionPhase,\n} from \"./errors.ts\";\nimport { type JsonValue, sha256Hex, stableStringify } from \"./replay-ledger.ts\";\n\n/**\n * A canonical, content-addressed ledger event record. `eventHash` is derived\n * deterministically from the identity + state hashes, which is what makes\n * idempotency detection (same key + same hash => no-op) reliable.\n */\nexport interface LedgerRecord {\n\toperationId: string;\n\trunId: string;\n\tnodeId: string;\n\teventType: string;\n\tphase: TransactionPhase;\n\tidempotencyKey: string;\n\tbeforeStateHash: string;\n\tafterStateHash: string;\n\teventHash: string;\n\tattemptId?: string;\n}\n\n/**\n * Identity + intent for a single ledger-gated mutation. `mutate` is pure: it\n * receives the snapshot and returns the staged next state without committing.\n */\nexport interface LedgerGatedTransactionRequest<S> {\n\trunId: string;\n\tnodeId: string;\n\toperationId: string;\n\teventType: string;\n\tphase: TransactionPhase;\n\tidempotencyKey: string;\n\tmutate: (before: S) => S;\n\tattemptId?: string;\n}\n\n/**\n * Injected transaction handle (a single `BEGIN IMMEDIATE` scope). The fake used\n * in tests and the real SQLite-backed handle implement this surface.\n *\n * Contract:\n * - `appendRequiredEvent` simulates the durable JSONL append + fsync. It escapes\n * transactional rollback (an appended event stays on disk).\n * - `mirrorEvent` stages the SQLite mirror insert inside the open transaction.\n * - `commit` applies the staged mirror + state; `rollback` discards them.\n */\nexport interface LedgerGatedTransactionHandle<S> {\n\tsnapshot: () => S;\n\tfindByIdempotencyKey: (key: string) => LedgerRecord | undefined;\n\tappendRequiredEvent: (record: LedgerRecord) => void;\n\tmirrorEvent: (record: LedgerRecord) => void;\n\tcommit: (state: S) => void;\n\trollback: () => void;\n}\n\nexport interface LedgerGatedTransactionDeps<S> {\n\tbegin: () => LedgerGatedTransactionHandle<S>;\n\thashState?: (state: S) => string;\n}\n\nexport type LedgerGatedTransactionStatus = \"committed\" | \"noop\";\n\nexport interface LedgerGatedTransactionResult<S> {\n\tstatus: LedgerGatedTransactionStatus;\n\tapplied: boolean;\n\trecord: LedgerRecord;\n\tstate: S;\n}\n\n/**\n * Default state hash. Callers with non-JSON state must inject `hashState`.\n */\nexport function coordinatorStateHash(state: unknown): string {\n\treturn sha256Hex(stableStringify(state as JsonValue));\n}\n\n/**\n * Deterministically derive a content hash for a ledger event from its identity\n * and state transition. Volatile fields are excluded so replays are stable.\n */\nexport function computeCoordinatorEventHash(input: {\n\toperationId: string;\n\trunId: string;\n\tnodeId: string;\n\teventType: string;\n\tphase: TransactionPhase;\n\tidempotencyKey: string;\n\tbeforeStateHash: string;\n\tafterStateHash: string;\n\tattemptId?: string;\n}): string {\n\tconst canonical: { readonly [key: string]: JsonValue } = {\n\t\toperationId: input.operationId,\n\t\trunId: input.runId,\n\t\tnodeId: input.nodeId,\n\t\teventType: input.eventType,\n\t\tphase: input.phase,\n\t\tidempotencyKey: input.idempotencyKey,\n\t\tbeforeStateHash: input.beforeStateHash,\n\t\tafterStateHash: input.afterStateHash,\n\t\tattemptId: input.attemptId ?? null,\n\t};\n\treturn sha256Hex(stableStringify(canonical));\n}\n\n/**\n * Build a complete ledger record (including `eventHash`) from a request and the\n * computed before/after state hashes.\n */\nexport function buildLedgerRecord(\n\trequest: {\n\t\toperationId: string;\n\t\trunId: string;\n\t\tnodeId: string;\n\t\teventType: string;\n\t\tphase: TransactionPhase;\n\t\tidempotencyKey: string;\n\t\tattemptId?: string;\n\t},\n\tbeforeStateHash: string,\n\tafterStateHash: string,\n): LedgerRecord {\n\tconst eventHash = computeCoordinatorEventHash({\n\t\toperationId: request.operationId,\n\t\trunId: request.runId,\n\t\tnodeId: request.nodeId,\n\t\teventType: request.eventType,\n\t\tphase: request.phase,\n\t\tidempotencyKey: request.idempotencyKey,\n\t\tbeforeStateHash,\n\t\tafterStateHash,\n\t\tattemptId: request.attemptId,\n\t});\n\treturn {\n\t\toperationId: request.operationId,\n\t\trunId: request.runId,\n\t\tnodeId: request.nodeId,\n\t\teventType: request.eventType,\n\t\tphase: request.phase,\n\t\tidempotencyKey: request.idempotencyKey,\n\t\tbeforeStateHash,\n\t\tafterStateHash,\n\t\teventHash,\n\t\t...(request.attemptId === undefined ? {} : { attemptId: request.attemptId }),\n\t};\n}\n\nfunction errorContext(\n\trequest: {\n\t\trunId: string;\n\t\tnodeId: string;\n\t\toperationId: string;\n\t\tphase: TransactionPhase;\n\t\teventType: string;\n\t\tattemptId?: string;\n\t},\n\trecoverability: CoordinatorRecoverability,\n\tcause?: unknown,\n): {\n\trunId: string;\n\tnodeId: string;\n\toperationId: string;\n\tphase: TransactionPhase;\n\teventType: string;\n\trecoverability: CoordinatorRecoverability;\n\tattemptId?: string;\n\tcause?: unknown;\n} {\n\treturn {\n\t\trunId: request.runId,\n\t\tnodeId: request.nodeId,\n\t\toperationId: request.operationId,\n\t\tphase: request.phase,\n\t\teventType: request.eventType,\n\t\trecoverability,\n\t\tattemptId: request.attemptId,\n\t\tcause,\n\t};\n}\n\n/**\n * Run one fail-closed, ledger-gated state-changing transaction.\n *\n * ```text\n * BEGIN IMMEDIATE\n * before = snapshot()\n * staged = mutate(before) # no commit yet\n * record = ledger event with before/after state hashes\n * idempotency:\n * same key + same eventHash -> rollback, no-op\n * same key + different hash -> rollback, IDEMPOTENCY_CONFLICT\n * appendRequiredEvent(record) # durable JSONL append + fsync\n * fail -> rollback, LEDGER_APPEND_REQUIRED_FAILED\n * mirrorEvent(record) # same transaction\n * fail -> rollback, SQLITE_MIRROR_FAILED (ledger durable; replay repairs)\n * commit(staged)\n * fail -> rollback, SQLITE_COMMIT_AFTER_LEDGER_FAILED (ledger durable)\n * ```\n *\n * Any failure leaves the injected store unmutated (transaction rolled back);\n * only the durable ledger append can survive, which recovery/replay reconciles.\n */\nexport function runLedgerGatedTransaction<S>(\n\tdeps: LedgerGatedTransactionDeps<S>,\n\trequest: LedgerGatedTransactionRequest<S>,\n): LedgerGatedTransactionResult<S> {\n\tconst hashState = deps.hashState ?? coordinatorStateHash;\n\tconst handle = deps.begin();\n\tlet settled = false;\n\tconst rollbackOnce = (): void => {\n\t\tif (!settled) {\n\t\t\tsettled = true;\n\t\t\thandle.rollback();\n\t\t}\n\t};\n\n\ttry {\n\t\tconst before = handle.snapshot();\n\t\tconst staged = request.mutate(before);\n\t\tconst record = buildLedgerRecord(request, hashState(before), hashState(staged));\n\n\t\tconst existing = handle.findByIdempotencyKey(request.idempotencyKey);\n\t\tif (existing !== undefined) {\n\t\t\trollbackOnce();\n\t\t\tif (existing.eventHash === record.eventHash) {\n\t\t\t\treturn { status: \"noop\", applied: false, record: existing, state: before };\n\t\t\t}\n\t\t\tthrow new CoordinatorError(\n\t\t\t\t\"IDEMPOTENCY_CONFLICT\",\n\t\t\t\t`idempotency key \"${request.idempotencyKey}\" already recorded with a different event hash`,\n\t\t\t\terrorContext(request, \"operator\"),\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\thandle.appendRequiredEvent(record);\n\t\t} catch (cause) {\n\t\t\trollbackOnce();\n\t\t\tthrow new RequiredAuditWriteError(\n\t\t\t\t`required ledger append failed for \"${request.eventType}\"`,\n\t\t\t\terrorContext(request, \"rollback\", cause),\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\thandle.mirrorEvent(record);\n\t\t} catch (cause) {\n\t\t\trollbackOnce();\n\t\t\tthrow new CoordinatorError(\n\t\t\t\t\"SQLITE_MIRROR_FAILED\",\n\t\t\t\t`sqlite mirror failed after ledger append for \"${request.eventType}\"`,\n\t\t\t\terrorContext(request, \"in_doubt\", cause),\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\thandle.commit(staged);\n\t\t\tsettled = true;\n\t\t} catch (cause) {\n\t\t\trollbackOnce();\n\t\t\tthrow new CoordinatorError(\n\t\t\t\t\"SQLITE_COMMIT_AFTER_LEDGER_FAILED\",\n\t\t\t\t`sqlite commit failed after ledger append for \"${request.eventType}\"`,\n\t\t\t\terrorContext(request, \"in_doubt\", cause),\n\t\t\t);\n\t\t}\n\n\t\treturn { status: \"committed\", applied: true, record, state: staged };\n\t} catch (error) {\n\t\trollbackOnce();\n\t\tthrow error;\n\t}\n}\n\n/**\n * A single side-effecting step that must record a receipt after its side effect.\n * Each step declares a stable `receiptId` so a durable receipt can short-circuit\n * re-execution on replay.\n */\nexport interface ReceiptedStep {\n\tid: string;\n\treceiptId: string;\n\tsequence: number;\n\tidempotent: boolean;\n\tbeforeStateHash: string;\n\tafterStateHash: string;\n\trun: () => void;\n}\n\nexport interface ReceiptHandle {\n\tfindReceipt: (receiptId: string) => LedgerRecord | undefined;\n\tappendReceiptEvent: (record: LedgerRecord) => void;\n}\n\nexport interface ReceiptApplyRequest {\n\trunId: string;\n\tnodeId: string;\n\toperationId: string;\n\tattemptId?: string;\n\teventType?: string;\n\tsteps: readonly ReceiptedStep[];\n}\n\nexport type ReceiptApplyStatus = \"completed\" | \"in_doubt\";\n\nexport interface ReceiptApplyResult {\n\tstatus: ReceiptApplyStatus;\n\texecutedStepIds: string[];\n\tskippedStepIds: string[];\n\tappliedReceipts: LedgerRecord[];\n\tstoppedAtStepId?: string;\n\treason?: string;\n}\n\n/**\n * Apply side-effecting steps in deterministic sequence order, recording a\n * required receipt after each side effect.\n *\n * Fail-closed rule (algorithm-plan Phase 1, test 3): if a receipt append fails\n * after its side effect ran, stop executing further side effects and return\n * `in_doubt` — UNLESS a durable idempotent receipt for that step exists, in\n * which case the side effect is provably recorded and execution continues.\n *\n * Steps whose receipt is already durably recorded are skipped (idempotent\n * replay) and never re-run.\n */\nexport function applyReceiptedSteps(handle: ReceiptHandle, request: ReceiptApplyRequest): ReceiptApplyResult {\n\tconst eventType = request.eventType ?? \"scheduler.node.receipt\";\n\tconst ordered = [...request.steps].sort((a, b) => a.sequence - b.sequence);\n\tconst executedStepIds: string[] = [];\n\tconst skippedStepIds: string[] = [];\n\tconst appliedReceipts: LedgerRecord[] = [];\n\n\tfor (const step of ordered) {\n\t\tconst pre = handle.findReceipt(step.receiptId);\n\t\tif (pre !== undefined) {\n\t\t\t// Receipt already durable: idempotent replay, do not re-run the side effect.\n\t\t\tskippedStepIds.push(step.id);\n\t\t\tappliedReceipts.push(pre);\n\t\t\tcontinue;\n\t\t}\n\n\t\tstep.run();\n\t\texecutedStepIds.push(step.id);\n\n\t\tconst record = buildLedgerRecord(\n\t\t\t{\n\t\t\t\toperationId: request.operationId,\n\t\t\t\trunId: request.runId,\n\t\t\t\tnodeId: request.nodeId,\n\t\t\t\teventType,\n\t\t\t\tphase: \"receipt\",\n\t\t\t\tidempotencyKey: step.receiptId,\n\t\t\t\tattemptId: request.attemptId,\n\t\t\t},\n\t\t\tstep.beforeStateHash,\n\t\t\tstep.afterStateHash,\n\t\t);\n\n\t\ttry {\n\t\t\thandle.appendReceiptEvent(record);\n\t\t\tappliedReceipts.push(record);\n\t\t} catch {\n\t\t\tconst post = handle.findReceipt(step.receiptId);\n\t\t\tif (post !== undefined) {\n\t\t\t\t// Receipt persisted despite the append error: recoverable, keep going.\n\t\t\t\tappliedReceipts.push(post);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstatus: \"in_doubt\",\n\t\t\t\texecutedStepIds,\n\t\t\t\tskippedStepIds,\n\t\t\t\tappliedReceipts,\n\t\t\t\tstoppedAtStepId: step.id,\n\t\t\t\treason: `receipt append failed after side effect for step \"${step.id}\" with no durable receipt`,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn { status: \"completed\", executedStepIds, skippedStepIds, appliedReceipts };\n}\n\n/**\n * A registered compensator and its forward-execution status.\n */\nexport interface CompensatorExecutionStep {\n\tid: string;\n\tsequence: number;\n\tidempotent: boolean;\n\tapplied: boolean;\n\trun: () => void;\n}\n\nexport interface CompensationHandle {\n\tappendCompensationStart: (record: LedgerRecord) => void;\n\tappendCompensationReceipt: (record: LedgerRecord) => void;\n}\n\nexport interface GatedCompensationRequest {\n\trunId: string;\n\tnodeId: string;\n\toperationId: string;\n\tidempotencyKey: string;\n\tbeforeStateHash: string;\n\tafterStateHash: string;\n\tattemptId?: string;\n\tsteps: readonly CompensatorExecutionStep[];\n}\n\nexport interface GatedCompensationResult {\n\tstatus: \"rolled_back\";\n\texecutedStepIds: string[];\n\treceipts: LedgerRecord[];\n}\n\n/**\n * Run compensation fail-closed (algorithm-plan Phase 1, test 4 + invariant I7).\n *\n * 1. Refuse to auto-compensate if any NON-idempotent step was already applied\n * (state is ambiguous): throw COMPENSATION_FAILED before anything runs.\n * 2. The compensation start is itself ledger-gated: if its required event cannot\n * be appended, throw RequiredAuditWriteError and run NO compensators.\n * 3. Only idempotent compensators run, in reverse execution order, each\n * recording a compensation receipt.\n */\nexport function runGatedCompensation(\n\thandle: CompensationHandle,\n\trequest: GatedCompensationRequest,\n): GatedCompensationResult {\n\tconst baseContext = {\n\t\trunId: request.runId,\n\t\tnodeId: request.nodeId,\n\t\toperationId: request.operationId,\n\t\tphase: \"compensate\" as TransactionPhase,\n\t\teventType: \"scheduler.node.compensating\",\n\t\tattemptId: request.attemptId,\n\t};\n\n\tfor (const step of request.steps) {\n\t\tif (!step.idempotent && step.applied) {\n\t\t\tthrow new CoordinatorError(\n\t\t\t\t\"COMPENSATION_FAILED\",\n\t\t\t\t`cannot auto-compensate non-idempotent step \"${step.id}\" that was already applied`,\n\t\t\t\t{ ...baseContext, recoverability: \"in_doubt\" },\n\t\t\t);\n\t\t}\n\t}\n\n\tconst startRecord = buildLedgerRecord(\n\t\t{\n\t\t\toperationId: request.operationId,\n\t\t\trunId: request.runId,\n\t\t\tnodeId: request.nodeId,\n\t\t\teventType: \"scheduler.node.compensating\",\n\t\t\tphase: \"compensate\",\n\t\t\tidempotencyKey: request.idempotencyKey,\n\t\t\tattemptId: request.attemptId,\n\t\t},\n\t\trequest.beforeStateHash,\n\t\trequest.afterStateHash,\n\t);\n\n\ttry {\n\t\thandle.appendCompensationStart(startRecord);\n\t} catch (cause) {\n\t\tthrow new RequiredAuditWriteError(\"required compensation-start ledger append failed\", { ...baseContext, cause });\n\t}\n\n\tconst reversed = request.steps.filter((step) => step.idempotent).sort((a, b) => b.sequence - a.sequence);\n\tconst executedStepIds: string[] = [];\n\tconst receipts: LedgerRecord[] = [];\n\n\tfor (const step of reversed) {\n\t\ttry {\n\t\t\tstep.run();\n\t\t} catch (cause) {\n\t\t\tthrow new CoordinatorError(\"COMPENSATION_FAILED\", `compensator \"${step.id}\" failed`, {\n\t\t\t\t...baseContext,\n\t\t\t\trecoverability: \"in_doubt\",\n\t\t\t\tcause,\n\t\t\t});\n\t\t}\n\t\texecutedStepIds.push(step.id);\n\t\tconst receipt = buildLedgerRecord(\n\t\t\t{\n\t\t\t\toperationId: request.operationId,\n\t\t\t\trunId: request.runId,\n\t\t\t\tnodeId: request.nodeId,\n\t\t\t\teventType: \"scheduler.node.compensation.receipt\",\n\t\t\t\tphase: \"compensate\",\n\t\t\t\tidempotencyKey: `${request.idempotencyKey}:${step.id}`,\n\t\t\t\tattemptId: request.attemptId,\n\t\t\t},\n\t\t\trequest.beforeStateHash,\n\t\t\trequest.afterStateHash,\n\t\t);\n\t\thandle.appendCompensationReceipt(receipt);\n\t\treceipts.push(receipt);\n\t}\n\n\treturn { status: \"rolled_back\", executedStepIds, receipts };\n}\n"]}
|