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,108 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
const CHARS_PER_TOKEN_ESTIMATE = 4;
|
|
3
|
+
const TRACKING_KEY_SEPARATOR = "\u0000";
|
|
4
|
+
export const LEAN_CONTEXT_DEFAULT_MIN_STUB_TOKENS = 256;
|
|
5
|
+
export const LEAN_CONTEXT_NEVER_STUB_FILENAMES = ["AGENTS.md", "CLAUDE.md", "SYSTEM.md"];
|
|
6
|
+
const DEFAULT_SECRET_PATTERNS = [
|
|
7
|
+
/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/i,
|
|
8
|
+
/\b(?:api[_-]?key|access[_-]?token|auth[_-]?token|refresh[_-]?token|client[_-]?secret|password|passwd|pwd)\b\s*[:=]\s*["']?[^\s"']{8,}/i,
|
|
9
|
+
/\bauthorization\s*:\s*bearer\s+[A-Za-z0-9._~+/=-]{10,}/i,
|
|
10
|
+
/\b(?:gh[pousr]_|sk-|xox[baprs]-)[A-Za-z0-9_=-]{10,}/i,
|
|
11
|
+
];
|
|
12
|
+
export function createLeanContextPolicyState(hashesByToolKey = {}) {
|
|
13
|
+
return { hashesByToolKey: { ...hashesByToolKey } };
|
|
14
|
+
}
|
|
15
|
+
export function decideLeanContextEmission(input) {
|
|
16
|
+
const contentSha256 = sha256Text(input.content);
|
|
17
|
+
const trackingKey = createLeanContextTrackingKey(input.tool, input.key);
|
|
18
|
+
const previousSha256 = input.state.hashesByToolKey[trackingKey];
|
|
19
|
+
const estimatedTokens = estimateLeanContextTokens(input.content);
|
|
20
|
+
const nextState = updateTrackedHash(input.state, trackingKey, contentSha256);
|
|
21
|
+
const baseDecision = {
|
|
22
|
+
contentSha256,
|
|
23
|
+
previousSha256,
|
|
24
|
+
estimatedTokens,
|
|
25
|
+
nextState,
|
|
26
|
+
};
|
|
27
|
+
if (previousSha256 === undefined) {
|
|
28
|
+
return { ...baseDecision, emit: "full", reason: "first-pass" };
|
|
29
|
+
}
|
|
30
|
+
if (previousSha256 !== contentSha256) {
|
|
31
|
+
return { ...baseDecision, emit: "full", reason: "changed" };
|
|
32
|
+
}
|
|
33
|
+
if (isNeverStubParentInstruction(input.path ?? input.key, input.neverStubFilenames)) {
|
|
34
|
+
return { ...baseDecision, emit: "full", reason: "never-stub-parent-instruction" };
|
|
35
|
+
}
|
|
36
|
+
if (containsSecretPattern(input.content, input.secretPatterns)) {
|
|
37
|
+
return { ...baseDecision, emit: "full", reason: "secret-pattern" };
|
|
38
|
+
}
|
|
39
|
+
const minStubTokens = normalizeMinStubTokens(input.minStubTokens);
|
|
40
|
+
if (estimatedTokens < minStubTokens) {
|
|
41
|
+
return { ...baseDecision, emit: "full", reason: "below-min-token-threshold" };
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
...baseDecision,
|
|
45
|
+
emit: "stub",
|
|
46
|
+
reason: "unchanged",
|
|
47
|
+
stub: formatLeanContextUnchangedStub({
|
|
48
|
+
tool: input.tool,
|
|
49
|
+
key: input.key,
|
|
50
|
+
contentSha256,
|
|
51
|
+
estimatedTokens,
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function getLeanContextTrackingHash(state, tool, key) {
|
|
56
|
+
return state.hashesByToolKey[createLeanContextTrackingKey(tool, key)];
|
|
57
|
+
}
|
|
58
|
+
export function createLeanContextTrackingKey(tool, key) {
|
|
59
|
+
return `${tool}${TRACKING_KEY_SEPARATOR}${key}`;
|
|
60
|
+
}
|
|
61
|
+
export function estimateLeanContextTokens(content) {
|
|
62
|
+
if (content.length === 0)
|
|
63
|
+
return 0;
|
|
64
|
+
return Math.ceil(content.length / CHARS_PER_TOKEN_ESTIMATE);
|
|
65
|
+
}
|
|
66
|
+
export function formatLeanContextUnchangedStub(input) {
|
|
67
|
+
return `[lean-context] ${input.tool} result for ${input.key} unchanged; omitted ${input.estimatedTokens} estimated tokens (sha256:${input.contentSha256.slice(0, 12)}).`;
|
|
68
|
+
}
|
|
69
|
+
function updateTrackedHash(state, trackingKey, contentSha256) {
|
|
70
|
+
if (state.hashesByToolKey[trackingKey] === contentSha256) {
|
|
71
|
+
return state;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
hashesByToolKey: {
|
|
75
|
+
...state.hashesByToolKey,
|
|
76
|
+
[trackingKey]: contentSha256,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function sha256Text(content) {
|
|
81
|
+
return createHash("sha256").update(content, "utf8").digest("hex");
|
|
82
|
+
}
|
|
83
|
+
function isNeverStubParentInstruction(pathOrKey, filenames) {
|
|
84
|
+
const allowedNames = filenames ?? LEAN_CONTEXT_NEVER_STUB_FILENAMES;
|
|
85
|
+
const basename = getBasename(pathOrKey).toUpperCase();
|
|
86
|
+
return allowedNames.some((name) => name.toUpperCase() === basename);
|
|
87
|
+
}
|
|
88
|
+
function getBasename(pathOrKey) {
|
|
89
|
+
const normalized = pathOrKey.replaceAll("\\", "/");
|
|
90
|
+
const parts = normalized.split("/");
|
|
91
|
+
return parts.at(-1) ?? normalized;
|
|
92
|
+
}
|
|
93
|
+
function containsSecretPattern(content, patterns) {
|
|
94
|
+
const activePatterns = patterns ?? DEFAULT_SECRET_PATTERNS;
|
|
95
|
+
return activePatterns.some((pattern) => regexTestStateless(pattern, content));
|
|
96
|
+
}
|
|
97
|
+
function regexTestStateless(pattern, content) {
|
|
98
|
+
const flags = pattern.flags.replace(/[gy]/g, "");
|
|
99
|
+
return new RegExp(pattern.source, flags).test(content);
|
|
100
|
+
}
|
|
101
|
+
function normalizeMinStubTokens(value) {
|
|
102
|
+
if (value === undefined)
|
|
103
|
+
return LEAN_CONTEXT_DEFAULT_MIN_STUB_TOKENS;
|
|
104
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
105
|
+
return 0;
|
|
106
|
+
return Math.ceil(value);
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=lean-context-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lean-context-policy.js","sourceRoot":"","sources":["../../src/core/lean-context-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,sBAAsB,GAAG,QAAQ,CAAC;AAExC,MAAM,CAAC,MAAM,oCAAoC,GAAG,GAAG,CAAC;AACxD,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,CAAU,CAAC;AAElG,MAAM,uBAAuB,GAAsB;IAClD,wCAAwC;IACxC,wIAAwI;IACxI,yDAAyD;IACzD,sDAAsD;CACtD,CAAC;AA6CF,MAAM,UAAU,4BAA4B,CAC3C,eAAe,GAAqC,EAAE,EAC7B;I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,OAAO,CAAC,CAAC,CAAC;AAAA,CAC9E;AAED,SAAS,kBAAkB,CAAC,OAAe,EAAE,OAAe,EAAW;IACtE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACjD,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAAA,CACvD;AAED,SAAS,sBAAsB,CAAC,KAAyB,EAAU;IAClE,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,oCAAoC,CAAC;IACrE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACpD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAAA,CACxB","sourcesContent":["import { createHash } from \"node:crypto\";\n\nconst CHARS_PER_TOKEN_ESTIMATE = 4;\nconst TRACKING_KEY_SEPARATOR = \"\\u0000\";\n\nexport const LEAN_CONTEXT_DEFAULT_MIN_STUB_TOKENS = 256;\nexport const LEAN_CONTEXT_NEVER_STUB_FILENAMES = [\"AGENTS.md\", \"CLAUDE.md\", \"SYSTEM.md\"] as const;\n\nconst DEFAULT_SECRET_PATTERNS: readonly RegExp[] = [\n\t/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/i,\n\t/\\b(?:api[_-]?key|access[_-]?token|auth[_-]?token|refresh[_-]?token|client[_-]?secret|password|passwd|pwd)\\b\\s*[:=]\\s*[\"']?[^\\s\"']{8,}/i,\n\t/\\bauthorization\\s*:\\s*bearer\\s+[A-Za-z0-9._~+/=-]{10,}/i,\n\t/\\b(?:gh[pousr]_|sk-|xox[baprs]-)[A-Za-z0-9_=-]{10,}/i,\n];\n\nexport type LeanContextEmission = \"full\" | \"stub\";\n\nexport type LeanContextDecisionReason =\n\t| \"first-pass\"\n\t| \"changed\"\n\t| \"unchanged\"\n\t| \"never-stub-parent-instruction\"\n\t| \"secret-pattern\"\n\t| \"below-min-token-threshold\";\n\nexport interface LeanContextPolicyState {\n\treadonly hashesByToolKey: Readonly<Record<string, string>>;\n}\n\nexport interface LeanContextPolicyOptions {\n\t/** Repeated unchanged outputs below this token estimate stay full. */\n\treadonly minStubTokens?: number;\n\t/** Basenames that must never be replaced with an unchanged stub. */\n\treadonly neverStubFilenames?: readonly string[];\n\t/** Patterns that force full output when matched. */\n\treadonly secretPatterns?: readonly RegExp[];\n}\n\nexport interface LeanContextPolicyInput extends LeanContextPolicyOptions {\n\treadonly state: LeanContextPolicyState;\n\treadonly tool: string;\n\t/** Stable caller-defined identity inside the tool, such as path or request key. */\n\treadonly key: string;\n\treadonly content: string;\n\t/** Optional path used for parent-instruction filename checks. Defaults to key. */\n\treadonly path?: string;\n}\n\nexport interface LeanContextPolicyDecision {\n\treadonly emit: LeanContextEmission;\n\treadonly reason: LeanContextDecisionReason;\n\treadonly contentSha256: string;\n\treadonly previousSha256?: string;\n\treadonly estimatedTokens: number;\n\treadonly nextState: LeanContextPolicyState;\n\treadonly stub?: string;\n}\n\nexport function createLeanContextPolicyState(\n\thashesByToolKey: Readonly<Record<string, string>> = {},\n): LeanContextPolicyState {\n\treturn { hashesByToolKey: { ...hashesByToolKey } };\n}\n\nexport function decideLeanContextEmission(input: LeanContextPolicyInput): LeanContextPolicyDecision {\n\tconst contentSha256 = sha256Text(input.content);\n\tconst trackingKey = createLeanContextTrackingKey(input.tool, input.key);\n\tconst previousSha256 = input.state.hashesByToolKey[trackingKey];\n\tconst estimatedTokens = estimateLeanContextTokens(input.content);\n\tconst nextState = updateTrackedHash(input.state, trackingKey, contentSha256);\n\tconst baseDecision = {\n\t\tcontentSha256,\n\t\tpreviousSha256,\n\t\testimatedTokens,\n\t\tnextState,\n\t};\n\n\tif (previousSha256 === undefined) {\n\t\treturn { ...baseDecision, emit: \"full\", reason: \"first-pass\" };\n\t}\n\n\tif (previousSha256 !== contentSha256) {\n\t\treturn { ...baseDecision, emit: \"full\", reason: \"changed\" };\n\t}\n\n\tif (isNeverStubParentInstruction(input.path ?? input.key, input.neverStubFilenames)) {\n\t\treturn { ...baseDecision, emit: \"full\", reason: \"never-stub-parent-instruction\" };\n\t}\n\n\tif (containsSecretPattern(input.content, input.secretPatterns)) {\n\t\treturn { ...baseDecision, emit: \"full\", reason: \"secret-pattern\" };\n\t}\n\n\tconst minStubTokens = normalizeMinStubTokens(input.minStubTokens);\n\tif (estimatedTokens < minStubTokens) {\n\t\treturn { ...baseDecision, emit: \"full\", reason: \"below-min-token-threshold\" };\n\t}\n\n\treturn {\n\t\t...baseDecision,\n\t\temit: \"stub\",\n\t\treason: \"unchanged\",\n\t\tstub: formatLeanContextUnchangedStub({\n\t\t\ttool: input.tool,\n\t\t\tkey: input.key,\n\t\t\tcontentSha256,\n\t\t\testimatedTokens,\n\t\t}),\n\t};\n}\n\nexport function getLeanContextTrackingHash(\n\tstate: LeanContextPolicyState,\n\ttool: string,\n\tkey: string,\n): string | undefined {\n\treturn state.hashesByToolKey[createLeanContextTrackingKey(tool, key)];\n}\n\nexport function createLeanContextTrackingKey(tool: string, key: string): string {\n\treturn `${tool}${TRACKING_KEY_SEPARATOR}${key}`;\n}\n\nexport function estimateLeanContextTokens(content: string): number {\n\tif (content.length === 0) return 0;\n\treturn Math.ceil(content.length / CHARS_PER_TOKEN_ESTIMATE);\n}\n\nexport function formatLeanContextUnchangedStub(input: {\n\treadonly tool: string;\n\treadonly key: string;\n\treadonly contentSha256: string;\n\treadonly estimatedTokens: number;\n}): string {\n\treturn `[lean-context] ${input.tool} result for ${input.key} unchanged; omitted ${input.estimatedTokens} estimated tokens (sha256:${input.contentSha256.slice(0, 12)}).`;\n}\n\nfunction updateTrackedHash(\n\tstate: LeanContextPolicyState,\n\ttrackingKey: string,\n\tcontentSha256: string,\n): LeanContextPolicyState {\n\tif (state.hashesByToolKey[trackingKey] === contentSha256) {\n\t\treturn state;\n\t}\n\treturn {\n\t\thashesByToolKey: {\n\t\t\t...state.hashesByToolKey,\n\t\t\t[trackingKey]: contentSha256,\n\t\t},\n\t};\n}\n\nfunction sha256Text(content: string): string {\n\treturn createHash(\"sha256\").update(content, \"utf8\").digest(\"hex\");\n}\n\nfunction isNeverStubParentInstruction(pathOrKey: string, filenames?: readonly string[]): boolean {\n\tconst allowedNames = filenames ?? LEAN_CONTEXT_NEVER_STUB_FILENAMES;\n\tconst basename = getBasename(pathOrKey).toUpperCase();\n\treturn allowedNames.some((name) => name.toUpperCase() === basename);\n}\n\nfunction getBasename(pathOrKey: string): string {\n\tconst normalized = pathOrKey.replaceAll(\"\\\\\", \"/\");\n\tconst parts = normalized.split(\"/\");\n\treturn parts.at(-1) ?? normalized;\n}\n\nfunction containsSecretPattern(content: string, patterns?: readonly RegExp[]): boolean {\n\tconst activePatterns = patterns ?? DEFAULT_SECRET_PATTERNS;\n\treturn activePatterns.some((pattern) => regexTestStateless(pattern, content));\n}\n\nfunction regexTestStateless(pattern: RegExp, content: string): boolean {\n\tconst flags = pattern.flags.replace(/[gy]/g, \"\");\n\treturn new RegExp(pattern.source, flags).test(content);\n}\n\nfunction normalizeMinStubTokens(value: number | undefined): number {\n\tif (value === undefined) return LEAN_CONTEXT_DEFAULT_MIN_STUB_TOKENS;\n\tif (!Number.isFinite(value) || value <= 0) return 0;\n\treturn Math.ceil(value);\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { LoadoutAccessEntry, LoadoutCommands } from "./loadouts.ts";
|
|
2
|
+
export type LoadoutAccessOperation = "read" | "write" | "execute";
|
|
3
|
+
export interface CreateLoadoutAccessPolicyOptions {
|
|
4
|
+
cwd: string;
|
|
5
|
+
activeTools: readonly string[];
|
|
6
|
+
readSet?: readonly LoadoutAccessEntry[];
|
|
7
|
+
writeSet?: readonly LoadoutAccessEntry[];
|
|
8
|
+
blockedPaths?: readonly string[];
|
|
9
|
+
commands?: LoadoutCommands;
|
|
10
|
+
}
|
|
11
|
+
export interface LoadoutAccessPolicy {
|
|
12
|
+
cwd: string;
|
|
13
|
+
activeTools: readonly string[];
|
|
14
|
+
readRoots: readonly string[];
|
|
15
|
+
writeRoots: readonly string[];
|
|
16
|
+
blockedPaths: readonly string[];
|
|
17
|
+
commands: LoadoutCommands;
|
|
18
|
+
}
|
|
19
|
+
export interface LoadoutPathAccessRequest {
|
|
20
|
+
operation: "read" | "write";
|
|
21
|
+
toolName: string;
|
|
22
|
+
path: string;
|
|
23
|
+
}
|
|
24
|
+
export interface LoadoutCommandAccessRequest {
|
|
25
|
+
operation: "execute";
|
|
26
|
+
toolName: string;
|
|
27
|
+
command: string;
|
|
28
|
+
}
|
|
29
|
+
export type LoadoutAccessRequest = LoadoutPathAccessRequest | LoadoutCommandAccessRequest;
|
|
30
|
+
export interface LoadoutAccessDecision {
|
|
31
|
+
allowed: boolean;
|
|
32
|
+
reason: string;
|
|
33
|
+
normalizedPath?: string;
|
|
34
|
+
normalizedCommand?: string;
|
|
35
|
+
}
|
|
36
|
+
export type LoadoutAccessGuard = (request: LoadoutAccessRequest) => LoadoutAccessDecision;
|
|
37
|
+
export declare function assertLoadoutAccess(guard: LoadoutAccessGuard | undefined, request: LoadoutAccessRequest): void;
|
|
38
|
+
export declare function createLoadoutAccessPolicy(options: CreateLoadoutAccessPolicyOptions): LoadoutAccessPolicy;
|
|
39
|
+
export declare function isActiveLoadoutTool(policy: Pick<LoadoutAccessPolicy, "activeTools">, toolName: string): boolean;
|
|
40
|
+
export declare function decideLoadoutAccess(policy: LoadoutAccessPolicy, request: LoadoutAccessRequest): LoadoutAccessDecision;
|
|
41
|
+
//# sourceMappingURL=loadout-access-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadout-access-policy.d.ts","sourceRoot":"","sources":["../../src/core/loadout-access-policy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;A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AAE,kBAAkB,GAAG,SAAS,EAAE,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAM9G;AAID,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,gCAAgC,GAAG,mBAAmB,CAYxG;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,mBAAmB,EAAE,aAAa,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE/G;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,oBAAoB,GAAG,qBAAqB,CAMrH","sourcesContent":["import { existsSync, realpathSync } from \"node:fs\";\nimport { basename, dirname, isAbsolute, relative, resolve } from \"node:path\";\nimport type { LoadoutAccessEntry, LoadoutCommands } from \"./loadouts.ts\";\n\nexport type LoadoutAccessOperation = \"read\" | \"write\" | \"execute\";\n\nexport interface CreateLoadoutAccessPolicyOptions {\n\tcwd: string;\n\tactiveTools: readonly string[];\n\treadSet?: readonly LoadoutAccessEntry[];\n\twriteSet?: readonly LoadoutAccessEntry[];\n\tblockedPaths?: readonly string[];\n\tcommands?: LoadoutCommands;\n}\n\nexport interface LoadoutAccessPolicy {\n\tcwd: string;\n\tactiveTools: readonly string[];\n\treadRoots: readonly string[];\n\twriteRoots: readonly string[];\n\tblockedPaths: readonly string[];\n\tcommands: LoadoutCommands;\n}\n\nexport interface LoadoutPathAccessRequest {\n\toperation: \"read\" | \"write\";\n\ttoolName: string;\n\tpath: string;\n}\n\nexport interface LoadoutCommandAccessRequest {\n\toperation: \"execute\";\n\ttoolName: string;\n\tcommand: string;\n}\n\nexport type LoadoutAccessRequest = LoadoutPathAccessRequest | LoadoutCommandAccessRequest;\n\nexport interface LoadoutAccessDecision {\n\tallowed: boolean;\n\treason: string;\n\tnormalizedPath?: string;\n\tnormalizedCommand?: string;\n}\n\nexport type LoadoutAccessGuard = (request: LoadoutAccessRequest) => LoadoutAccessDecision;\n\nexport function assertLoadoutAccess(guard: LoadoutAccessGuard | undefined, request: LoadoutAccessRequest): void {\n\tif (!guard) return;\n\tconst decision = guard(request);\n\tif (!decision.allowed) {\n\t\tthrow new Error(`loadout: ${decision.reason}`);\n\t}\n}\n\nconst DEFAULT_BLOCKED_PATHS = [\"**/.env*\", \"**/*secret*\", \"**/*key*\", \"**/.git\", \"**/.git/*\"] as const;\n\nexport function createLoadoutAccessPolicy(options: CreateLoadoutAccessPolicyOptions): LoadoutAccessPolicy {\n\tconst cwd = normalizeRootPath(options.cwd);\n\treturn {\n\t\tcwd,\n\t\tactiveTools: uniqueSorted(\n\t\t\toptions.activeTools.map((toolName) => toolName.trim()).filter((toolName) => toolName !== \"\"),\n\t\t),\n\t\treadRoots: normalizeAccessSet(cwd, options.readSet),\n\t\twriteRoots: normalizeAccessSet(cwd, options.writeSet),\n\t\tblockedPaths: uniqueSorted(options.blockedPaths ?? DEFAULT_BLOCKED_PATHS),\n\t\tcommands: options.commands ?? { mode: \"none\" },\n\t};\n}\n\nexport function isActiveLoadoutTool(policy: Pick<LoadoutAccessPolicy, \"activeTools\">, toolName: string): boolean {\n\treturn policy.activeTools.includes(toolName.trim());\n}\n\nexport function decideLoadoutAccess(policy: LoadoutAccessPolicy, request: LoadoutAccessRequest): LoadoutAccessDecision {\n\tif (!isActiveLoadoutTool(policy, request.toolName)) {\n\t\treturn deny(`inactive tool: ${request.toolName}`);\n\t}\n\tif (request.operation === \"execute\") return decideCommandAccess(policy, request);\n\treturn decidePathAccess(policy, request);\n}\n\nfunction decidePathAccess(policy: LoadoutAccessPolicy, request: LoadoutPathAccessRequest): LoadoutAccessDecision {\n\tconst normalizedPath = normalizeRequestPath(policy.cwd, request.path);\n\tif (!normalizedPath) return deny(\"invalid path\");\n\tif (isBlockedPath(policy, normalizedPath)) return deny(\"blocked path\", normalizedPath);\n\n\tif (request.operation === \"read\") {\n\t\tconst roots = uniqueSorted([...policy.readRoots, ...policy.writeRoots]);\n\t\tif (roots.length === 0) return deny(\"outside read scope: empty read/write set\", normalizedPath);\n\t\tif (roots.some((root) => containsPath(root, normalizedPath))) return allow(normalizedPath);\n\t\treturn deny(\"outside read scope\", normalizedPath);\n\t}\n\n\tif (policy.writeRoots.length === 0) return deny(\"outside write scope: empty write set\", normalizedPath);\n\tif (policy.writeRoots.some((root) => containsPath(root, normalizedPath))) return allow(normalizedPath);\n\treturn deny(\"outside write scope\", normalizedPath);\n}\n\nfunction decideCommandAccess(policy: LoadoutAccessPolicy, request: LoadoutCommandAccessRequest): LoadoutAccessDecision {\n\tconst normalizedCommand = request.command.trim();\n\tif (normalizedCommand === \"\" || normalizedCommand.includes(\"\\0\")) return denyCommand(\"invalid command\");\n\tif (policy.commands.mode === \"none\") return denyCommand(\"command mode none\");\n\tif (policy.commands.blockPatterns?.some((pattern) => commandMatchesPattern(pattern, normalizedCommand))) {\n\t\treturn denyCommand(\"blocked command pattern\");\n\t}\n\tif (policy.commands.allowPatterns?.some((pattern) => commandMatchesPattern(pattern, normalizedCommand))) {\n\t\treturn { allowed: true, reason: \"allowed\", normalizedCommand };\n\t}\n\treturn denyCommand(`command mode ${policy.commands.mode} requires an explicit allow pattern`);\n}\n\nfunction allow(normalizedPath: string): LoadoutAccessDecision {\n\treturn { allowed: true, reason: \"allowed\", normalizedPath };\n}\n\nfunction deny(reason: string, normalizedPath?: string): LoadoutAccessDecision {\n\treturn { allowed: false, reason, normalizedPath };\n}\n\nfunction denyCommand(reason: string): LoadoutAccessDecision {\n\treturn { allowed: false, reason };\n}\n\nfunction normalizeRootPath(path: string): string {\n\tconst normalized = normalizePathSeparators(path);\n\tif (normalized.trim() === \"\" || normalized.includes(\"\\0\")) {\n\t\tthrow new Error(\"loadout access policy cwd must be a non-empty path\");\n\t}\n\treturn stripTrailingSeparator(canonicalizeExistingPrefix(resolve(normalized)));\n}\n\nfunction normalizeRequestPath(cwd: string, requestedPath: string): string | undefined {\n\tconst normalized = normalizePathSeparators(requestedPath);\n\tif (normalized.trim() === \"\" || normalized.includes(\"\\0\")) return undefined;\n\treturn stripTrailingSeparator(canonicalizeExistingPrefix(resolve(cwd, normalized)));\n}\n\nfunction normalizeAccessSet(cwd: string, accessSet: readonly LoadoutAccessEntry[] | undefined): string[] {\n\tif (!accessSet) return [];\n\tconst roots: string[] = [];\n\tfor (const entry of accessSet) {\n\t\tif (entry.symbols && entry.symbols.length > 0) continue;\n\t\tconst normalized = normalizePathSeparators(entry.path);\n\t\tif (normalized.trim() === \"\" || normalized.includes(\"\\0\")) continue;\n\t\troots.push(stripTrailingSeparator(canonicalizeExistingPrefix(resolve(cwd, normalized))));\n\t}\n\treturn uniqueSorted(roots);\n}\n\nfunction canonicalizeExistingPrefix(path: string): string {\n\ttry {\n\t\treturn realpathSync.native(path);\n\t} catch {\n\t\tif (existsSync(path)) return resolve(path);\n\t\tconst parent = dirname(path);\n\t\tif (parent === path) return resolve(path);\n\t\treturn resolve(canonicalizeExistingPrefix(parent), basename(path));\n\t}\n}\n\nfunction containsPath(root: string, candidate: string): boolean {\n\tif (candidate === root) return true;\n\tconst relativePath = relative(root, candidate);\n\treturn relativePath !== \"\" && !relativePath.startsWith(\"..\") && !isAbsolute(relativePath);\n}\n\nfunction isBlockedPath(policy: LoadoutAccessPolicy, normalizedPath: string): boolean {\n\tconst relativeCandidate = toForwardSlashes(relative(policy.cwd, normalizedPath));\n\tconst candidates = uniqueSorted([toForwardSlashes(normalizedPath), relativeCandidate]);\n\treturn policy.blockedPaths.some((pattern) => candidates.some((candidate) => globMatch(pattern, candidate)));\n}\n\nfunction commandMatchesPattern(pattern: string, command: string): boolean {\n\treturn pattern === command || globMatch(pattern, command);\n}\n\nfunction normalizePathSeparators(path: string): string {\n\treturn path.replaceAll(\"\\\\\", \"/\");\n}\n\nfunction stripTrailingSeparator(path: string): string {\n\tif (path === \"/\") return path;\n\treturn path.endsWith(\"/\") ? path.slice(0, -1) : path;\n}\n\nfunction toForwardSlashes(path: string): string {\n\treturn path.replaceAll(\"\\\\\", \"/\");\n}\n\nfunction globMatch(glob: string, value: string): boolean {\n\treturn globToRegExp(normalizePathSeparators(glob)).test(toForwardSlashes(value));\n}\n\nfunction globToRegExp(glob: string): RegExp {\n\tlet pattern = \"\";\n\tfor (let index = 0; index < glob.length; index++) {\n\t\tconst char = glob[index];\n\t\tif (char === \"*\") {\n\t\t\tif (glob[index + 1] === \"*\") {\n\t\t\t\tif (glob[index + 2] === \"/\") {\n\t\t\t\t\tpattern += \"(?:.*/)?\";\n\t\t\t\t\tindex += 2;\n\t\t\t\t} else {\n\t\t\t\t\tpattern += \".*\";\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpattern += \"[^/]*\";\n\t\t\t}\n\t\t} else if (char === \"?\") {\n\t\t\tpattern += \"[^/]\";\n\t\t} else {\n\t\t\tpattern += char.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\t}\n\t}\n\treturn new RegExp(`^${pattern}$`);\n}\n\nfunction uniqueSorted(values: readonly string[]): string[] {\n\treturn [...new Set(values)].sort((a, b) => {\n\t\tif (a < b) return -1;\n\t\tif (a > b) return 1;\n\t\treturn 0;\n\t});\n}\n"]}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, isAbsolute, relative, resolve } from "node:path";
|
|
3
|
+
export function assertLoadoutAccess(guard, request) {
|
|
4
|
+
if (!guard)
|
|
5
|
+
return;
|
|
6
|
+
const decision = guard(request);
|
|
7
|
+
if (!decision.allowed) {
|
|
8
|
+
throw new Error(`loadout: ${decision.reason}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const DEFAULT_BLOCKED_PATHS = ["**/.env*", "**/*secret*", "**/*key*", "**/.git", "**/.git/*"];
|
|
12
|
+
export function createLoadoutAccessPolicy(options) {
|
|
13
|
+
const cwd = normalizeRootPath(options.cwd);
|
|
14
|
+
return {
|
|
15
|
+
cwd,
|
|
16
|
+
activeTools: uniqueSorted(options.activeTools.map((toolName) => toolName.trim()).filter((toolName) => toolName !== "")),
|
|
17
|
+
readRoots: normalizeAccessSet(cwd, options.readSet),
|
|
18
|
+
writeRoots: normalizeAccessSet(cwd, options.writeSet),
|
|
19
|
+
blockedPaths: uniqueSorted(options.blockedPaths ?? DEFAULT_BLOCKED_PATHS),
|
|
20
|
+
commands: options.commands ?? { mode: "none" },
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function isActiveLoadoutTool(policy, toolName) {
|
|
24
|
+
return policy.activeTools.includes(toolName.trim());
|
|
25
|
+
}
|
|
26
|
+
export function decideLoadoutAccess(policy, request) {
|
|
27
|
+
if (!isActiveLoadoutTool(policy, request.toolName)) {
|
|
28
|
+
return deny(`inactive tool: ${request.toolName}`);
|
|
29
|
+
}
|
|
30
|
+
if (request.operation === "execute")
|
|
31
|
+
return decideCommandAccess(policy, request);
|
|
32
|
+
return decidePathAccess(policy, request);
|
|
33
|
+
}
|
|
34
|
+
function decidePathAccess(policy, request) {
|
|
35
|
+
const normalizedPath = normalizeRequestPath(policy.cwd, request.path);
|
|
36
|
+
if (!normalizedPath)
|
|
37
|
+
return deny("invalid path");
|
|
38
|
+
if (isBlockedPath(policy, normalizedPath))
|
|
39
|
+
return deny("blocked path", normalizedPath);
|
|
40
|
+
if (request.operation === "read") {
|
|
41
|
+
const roots = uniqueSorted([...policy.readRoots, ...policy.writeRoots]);
|
|
42
|
+
if (roots.length === 0)
|
|
43
|
+
return deny("outside read scope: empty read/write set", normalizedPath);
|
|
44
|
+
if (roots.some((root) => containsPath(root, normalizedPath)))
|
|
45
|
+
return allow(normalizedPath);
|
|
46
|
+
return deny("outside read scope", normalizedPath);
|
|
47
|
+
}
|
|
48
|
+
if (policy.writeRoots.length === 0)
|
|
49
|
+
return deny("outside write scope: empty write set", normalizedPath);
|
|
50
|
+
if (policy.writeRoots.some((root) => containsPath(root, normalizedPath)))
|
|
51
|
+
return allow(normalizedPath);
|
|
52
|
+
return deny("outside write scope", normalizedPath);
|
|
53
|
+
}
|
|
54
|
+
function decideCommandAccess(policy, request) {
|
|
55
|
+
const normalizedCommand = request.command.trim();
|
|
56
|
+
if (normalizedCommand === "" || normalizedCommand.includes("\0"))
|
|
57
|
+
return denyCommand("invalid command");
|
|
58
|
+
if (policy.commands.mode === "none")
|
|
59
|
+
return denyCommand("command mode none");
|
|
60
|
+
if (policy.commands.blockPatterns?.some((pattern) => commandMatchesPattern(pattern, normalizedCommand))) {
|
|
61
|
+
return denyCommand("blocked command pattern");
|
|
62
|
+
}
|
|
63
|
+
if (policy.commands.allowPatterns?.some((pattern) => commandMatchesPattern(pattern, normalizedCommand))) {
|
|
64
|
+
return { allowed: true, reason: "allowed", normalizedCommand };
|
|
65
|
+
}
|
|
66
|
+
return denyCommand(`command mode ${policy.commands.mode} requires an explicit allow pattern`);
|
|
67
|
+
}
|
|
68
|
+
function allow(normalizedPath) {
|
|
69
|
+
return { allowed: true, reason: "allowed", normalizedPath };
|
|
70
|
+
}
|
|
71
|
+
function deny(reason, normalizedPath) {
|
|
72
|
+
return { allowed: false, reason, normalizedPath };
|
|
73
|
+
}
|
|
74
|
+
function denyCommand(reason) {
|
|
75
|
+
return { allowed: false, reason };
|
|
76
|
+
}
|
|
77
|
+
function normalizeRootPath(path) {
|
|
78
|
+
const normalized = normalizePathSeparators(path);
|
|
79
|
+
if (normalized.trim() === "" || normalized.includes("\0")) {
|
|
80
|
+
throw new Error("loadout access policy cwd must be a non-empty path");
|
|
81
|
+
}
|
|
82
|
+
return stripTrailingSeparator(canonicalizeExistingPrefix(resolve(normalized)));
|
|
83
|
+
}
|
|
84
|
+
function normalizeRequestPath(cwd, requestedPath) {
|
|
85
|
+
const normalized = normalizePathSeparators(requestedPath);
|
|
86
|
+
if (normalized.trim() === "" || normalized.includes("\0"))
|
|
87
|
+
return undefined;
|
|
88
|
+
return stripTrailingSeparator(canonicalizeExistingPrefix(resolve(cwd, normalized)));
|
|
89
|
+
}
|
|
90
|
+
function normalizeAccessSet(cwd, accessSet) {
|
|
91
|
+
if (!accessSet)
|
|
92
|
+
return [];
|
|
93
|
+
const roots = [];
|
|
94
|
+
for (const entry of accessSet) {
|
|
95
|
+
if (entry.symbols && entry.symbols.length > 0)
|
|
96
|
+
continue;
|
|
97
|
+
const normalized = normalizePathSeparators(entry.path);
|
|
98
|
+
if (normalized.trim() === "" || normalized.includes("\0"))
|
|
99
|
+
continue;
|
|
100
|
+
roots.push(stripTrailingSeparator(canonicalizeExistingPrefix(resolve(cwd, normalized))));
|
|
101
|
+
}
|
|
102
|
+
return uniqueSorted(roots);
|
|
103
|
+
}
|
|
104
|
+
function canonicalizeExistingPrefix(path) {
|
|
105
|
+
try {
|
|
106
|
+
return realpathSync.native(path);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
if (existsSync(path))
|
|
110
|
+
return resolve(path);
|
|
111
|
+
const parent = dirname(path);
|
|
112
|
+
if (parent === path)
|
|
113
|
+
return resolve(path);
|
|
114
|
+
return resolve(canonicalizeExistingPrefix(parent), basename(path));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function containsPath(root, candidate) {
|
|
118
|
+
if (candidate === root)
|
|
119
|
+
return true;
|
|
120
|
+
const relativePath = relative(root, candidate);
|
|
121
|
+
return relativePath !== "" && !relativePath.startsWith("..") && !isAbsolute(relativePath);
|
|
122
|
+
}
|
|
123
|
+
function isBlockedPath(policy, normalizedPath) {
|
|
124
|
+
const relativeCandidate = toForwardSlashes(relative(policy.cwd, normalizedPath));
|
|
125
|
+
const candidates = uniqueSorted([toForwardSlashes(normalizedPath), relativeCandidate]);
|
|
126
|
+
return policy.blockedPaths.some((pattern) => candidates.some((candidate) => globMatch(pattern, candidate)));
|
|
127
|
+
}
|
|
128
|
+
function commandMatchesPattern(pattern, command) {
|
|
129
|
+
return pattern === command || globMatch(pattern, command);
|
|
130
|
+
}
|
|
131
|
+
function normalizePathSeparators(path) {
|
|
132
|
+
return path.replaceAll("\\", "/");
|
|
133
|
+
}
|
|
134
|
+
function stripTrailingSeparator(path) {
|
|
135
|
+
if (path === "/")
|
|
136
|
+
return path;
|
|
137
|
+
return path.endsWith("/") ? path.slice(0, -1) : path;
|
|
138
|
+
}
|
|
139
|
+
function toForwardSlashes(path) {
|
|
140
|
+
return path.replaceAll("\\", "/");
|
|
141
|
+
}
|
|
142
|
+
function globMatch(glob, value) {
|
|
143
|
+
return globToRegExp(normalizePathSeparators(glob)).test(toForwardSlashes(value));
|
|
144
|
+
}
|
|
145
|
+
function globToRegExp(glob) {
|
|
146
|
+
let pattern = "";
|
|
147
|
+
for (let index = 0; index < glob.length; index++) {
|
|
148
|
+
const char = glob[index];
|
|
149
|
+
if (char === "*") {
|
|
150
|
+
if (glob[index + 1] === "*") {
|
|
151
|
+
if (glob[index + 2] === "/") {
|
|
152
|
+
pattern += "(?:.*/)?";
|
|
153
|
+
index += 2;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
pattern += ".*";
|
|
157
|
+
index++;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
pattern += "[^/]*";
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else if (char === "?") {
|
|
165
|
+
pattern += "[^/]";
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
pattern += char.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return new RegExp(`^${pattern}$`);
|
|
172
|
+
}
|
|
173
|
+
function uniqueSorted(values) {
|
|
174
|
+
return [...new Set(values)].sort((a, b) => {
|
|
175
|
+
if (a < b)
|
|
176
|
+
return -1;
|
|
177
|
+
if (a > b)
|
|
178
|
+
return 1;
|
|
179
|
+
return 0;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=loadout-access-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadout-access-policy.js","sourceRoot":"","sources":["../../src/core/loadout-access-policy.ts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I,CAAC,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC;QACpB,OAAO,CAAC,CAAC;IAAA,CACT,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { existsSync, realpathSync } from \"node:fs\";\nimport { basename, dirname, isAbsolute, relative, resolve } from \"node:path\";\nimport type { LoadoutAccessEntry, LoadoutCommands } from \"./loadouts.ts\";\n\nexport type LoadoutAccessOperation = \"read\" | \"write\" | \"execute\";\n\nexport interface CreateLoadoutAccessPolicyOptions {\n\tcwd: string;\n\tactiveTools: readonly string[];\n\treadSet?: readonly LoadoutAccessEntry[];\n\twriteSet?: readonly LoadoutAccessEntry[];\n\tblockedPaths?: readonly string[];\n\tcommands?: LoadoutCommands;\n}\n\nexport interface LoadoutAccessPolicy {\n\tcwd: string;\n\tactiveTools: readonly string[];\n\treadRoots: readonly string[];\n\twriteRoots: readonly string[];\n\tblockedPaths: readonly string[];\n\tcommands: LoadoutCommands;\n}\n\nexport interface LoadoutPathAccessRequest {\n\toperation: \"read\" | \"write\";\n\ttoolName: string;\n\tpath: string;\n}\n\nexport interface LoadoutCommandAccessRequest {\n\toperation: \"execute\";\n\ttoolName: string;\n\tcommand: string;\n}\n\nexport type LoadoutAccessRequest = LoadoutPathAccessRequest | LoadoutCommandAccessRequest;\n\nexport interface LoadoutAccessDecision {\n\tallowed: boolean;\n\treason: string;\n\tnormalizedPath?: string;\n\tnormalizedCommand?: string;\n}\n\nexport type LoadoutAccessGuard = (request: LoadoutAccessRequest) => LoadoutAccessDecision;\n\nexport function assertLoadoutAccess(guard: LoadoutAccessGuard | undefined, request: LoadoutAccessRequest): void {\n\tif (!guard) return;\n\tconst decision = guard(request);\n\tif (!decision.allowed) {\n\t\tthrow new Error(`loadout: ${decision.reason}`);\n\t}\n}\n\nconst DEFAULT_BLOCKED_PATHS = [\"**/.env*\", \"**/*secret*\", \"**/*key*\", \"**/.git\", \"**/.git/*\"] as const;\n\nexport function createLoadoutAccessPolicy(options: CreateLoadoutAccessPolicyOptions): LoadoutAccessPolicy {\n\tconst cwd = normalizeRootPath(options.cwd);\n\treturn {\n\t\tcwd,\n\t\tactiveTools: uniqueSorted(\n\t\t\toptions.activeTools.map((toolName) => toolName.trim()).filter((toolName) => toolName !== \"\"),\n\t\t),\n\t\treadRoots: normalizeAccessSet(cwd, options.readSet),\n\t\twriteRoots: normalizeAccessSet(cwd, options.writeSet),\n\t\tblockedPaths: uniqueSorted(options.blockedPaths ?? DEFAULT_BLOCKED_PATHS),\n\t\tcommands: options.commands ?? { mode: \"none\" },\n\t};\n}\n\nexport function isActiveLoadoutTool(policy: Pick<LoadoutAccessPolicy, \"activeTools\">, toolName: string): boolean {\n\treturn policy.activeTools.includes(toolName.trim());\n}\n\nexport function decideLoadoutAccess(policy: LoadoutAccessPolicy, request: LoadoutAccessRequest): LoadoutAccessDecision {\n\tif (!isActiveLoadoutTool(policy, request.toolName)) {\n\t\treturn deny(`inactive tool: ${request.toolName}`);\n\t}\n\tif (request.operation === \"execute\") return decideCommandAccess(policy, request);\n\treturn decidePathAccess(policy, request);\n}\n\nfunction decidePathAccess(policy: LoadoutAccessPolicy, request: LoadoutPathAccessRequest): LoadoutAccessDecision {\n\tconst normalizedPath = normalizeRequestPath(policy.cwd, request.path);\n\tif (!normalizedPath) return deny(\"invalid path\");\n\tif (isBlockedPath(policy, normalizedPath)) return deny(\"blocked path\", normalizedPath);\n\n\tif (request.operation === \"read\") {\n\t\tconst roots = uniqueSorted([...policy.readRoots, ...policy.writeRoots]);\n\t\tif (roots.length === 0) return deny(\"outside read scope: empty read/write set\", normalizedPath);\n\t\tif (roots.some((root) => containsPath(root, normalizedPath))) return allow(normalizedPath);\n\t\treturn deny(\"outside read scope\", normalizedPath);\n\t}\n\n\tif (policy.writeRoots.length === 0) return deny(\"outside write scope: empty write set\", normalizedPath);\n\tif (policy.writeRoots.some((root) => containsPath(root, normalizedPath))) return allow(normalizedPath);\n\treturn deny(\"outside write scope\", normalizedPath);\n}\n\nfunction decideCommandAccess(policy: LoadoutAccessPolicy, request: LoadoutCommandAccessRequest): LoadoutAccessDecision {\n\tconst normalizedCommand = request.command.trim();\n\tif (normalizedCommand === \"\" || normalizedCommand.includes(\"\\0\")) return denyCommand(\"invalid command\");\n\tif (policy.commands.mode === \"none\") return denyCommand(\"command mode none\");\n\tif (policy.commands.blockPatterns?.some((pattern) => commandMatchesPattern(pattern, normalizedCommand))) {\n\t\treturn denyCommand(\"blocked command pattern\");\n\t}\n\tif (policy.commands.allowPatterns?.some((pattern) => commandMatchesPattern(pattern, normalizedCommand))) {\n\t\treturn { allowed: true, reason: \"allowed\", normalizedCommand };\n\t}\n\treturn denyCommand(`command mode ${policy.commands.mode} requires an explicit allow pattern`);\n}\n\nfunction allow(normalizedPath: string): LoadoutAccessDecision {\n\treturn { allowed: true, reason: \"allowed\", normalizedPath };\n}\n\nfunction deny(reason: string, normalizedPath?: string): LoadoutAccessDecision {\n\treturn { allowed: false, reason, normalizedPath };\n}\n\nfunction denyCommand(reason: string): LoadoutAccessDecision {\n\treturn { allowed: false, reason };\n}\n\nfunction normalizeRootPath(path: string): string {\n\tconst normalized = normalizePathSeparators(path);\n\tif (normalized.trim() === \"\" || normalized.includes(\"\\0\")) {\n\t\tthrow new Error(\"loadout access policy cwd must be a non-empty path\");\n\t}\n\treturn stripTrailingSeparator(canonicalizeExistingPrefix(resolve(normalized)));\n}\n\nfunction normalizeRequestPath(cwd: string, requestedPath: string): string | undefined {\n\tconst normalized = normalizePathSeparators(requestedPath);\n\tif (normalized.trim() === \"\" || normalized.includes(\"\\0\")) return undefined;\n\treturn stripTrailingSeparator(canonicalizeExistingPrefix(resolve(cwd, normalized)));\n}\n\nfunction normalizeAccessSet(cwd: string, accessSet: readonly LoadoutAccessEntry[] | undefined): string[] {\n\tif (!accessSet) return [];\n\tconst roots: string[] = [];\n\tfor (const entry of accessSet) {\n\t\tif (entry.symbols && entry.symbols.length > 0) continue;\n\t\tconst normalized = normalizePathSeparators(entry.path);\n\t\tif (normalized.trim() === \"\" || normalized.includes(\"\\0\")) continue;\n\t\troots.push(stripTrailingSeparator(canonicalizeExistingPrefix(resolve(cwd, normalized))));\n\t}\n\treturn uniqueSorted(roots);\n}\n\nfunction canonicalizeExistingPrefix(path: string): string {\n\ttry {\n\t\treturn realpathSync.native(path);\n\t} catch {\n\t\tif (existsSync(path)) return resolve(path);\n\t\tconst parent = dirname(path);\n\t\tif (parent === path) return resolve(path);\n\t\treturn resolve(canonicalizeExistingPrefix(parent), basename(path));\n\t}\n}\n\nfunction containsPath(root: string, candidate: string): boolean {\n\tif (candidate === root) return true;\n\tconst relativePath = relative(root, candidate);\n\treturn relativePath !== \"\" && !relativePath.startsWith(\"..\") && !isAbsolute(relativePath);\n}\n\nfunction isBlockedPath(policy: LoadoutAccessPolicy, normalizedPath: string): boolean {\n\tconst relativeCandidate = toForwardSlashes(relative(policy.cwd, normalizedPath));\n\tconst candidates = uniqueSorted([toForwardSlashes(normalizedPath), relativeCandidate]);\n\treturn policy.blockedPaths.some((pattern) => candidates.some((candidate) => globMatch(pattern, candidate)));\n}\n\nfunction commandMatchesPattern(pattern: string, command: string): boolean {\n\treturn pattern === command || globMatch(pattern, command);\n}\n\nfunction normalizePathSeparators(path: string): string {\n\treturn path.replaceAll(\"\\\\\", \"/\");\n}\n\nfunction stripTrailingSeparator(path: string): string {\n\tif (path === \"/\") return path;\n\treturn path.endsWith(\"/\") ? path.slice(0, -1) : path;\n}\n\nfunction toForwardSlashes(path: string): string {\n\treturn path.replaceAll(\"\\\\\", \"/\");\n}\n\nfunction globMatch(glob: string, value: string): boolean {\n\treturn globToRegExp(normalizePathSeparators(glob)).test(toForwardSlashes(value));\n}\n\nfunction globToRegExp(glob: string): RegExp {\n\tlet pattern = \"\";\n\tfor (let index = 0; index < glob.length; index++) {\n\t\tconst char = glob[index];\n\t\tif (char === \"*\") {\n\t\t\tif (glob[index + 1] === \"*\") {\n\t\t\t\tif (glob[index + 2] === \"/\") {\n\t\t\t\t\tpattern += \"(?:.*/)?\";\n\t\t\t\t\tindex += 2;\n\t\t\t\t} else {\n\t\t\t\t\tpattern += \".*\";\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpattern += \"[^/]*\";\n\t\t\t}\n\t\t} else if (char === \"?\") {\n\t\t\tpattern += \"[^/]\";\n\t\t} else {\n\t\t\tpattern += char.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\t}\n\t}\n\treturn new RegExp(`^${pattern}$`);\n}\n\nfunction uniqueSorted(values: readonly string[]): string[] {\n\treturn [...new Set(values)].sort((a, b) => {\n\t\tif (a < b) return -1;\n\t\tif (a > b) return 1;\n\t\treturn 0;\n\t});\n}\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loadout runtime wiring — pure algorithms.
|
|
3
|
+
*
|
|
4
|
+
* Converts the pure loadout decisions in `loadouts.ts` into runtime-ready
|
|
5
|
+
* capability inventories, lane grants, and scheduler fields without mutating
|
|
6
|
+
* `AgentSession`.
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolDefinition } from "./extensions/types.ts";
|
|
9
|
+
import { type HookInventory } from "./hook-inventory.ts";
|
|
10
|
+
import { type LoadoutAccessPolicy } from "./loadout-access-policy.ts";
|
|
11
|
+
import { type AppliedLoadout, type CapabilityInventory, type LoadoutAuthority, type LoadoutCommands, type LoadoutProfile, type LoadoutRole, type SchedulerFields } from "./loadouts.ts";
|
|
12
|
+
import type { ResourceLoader } from "./resource-loader.ts";
|
|
13
|
+
import type { SourceInfo } from "./source-info.ts";
|
|
14
|
+
interface ExtensionRunnerLike {
|
|
15
|
+
getAllRegisteredTools(): Array<{
|
|
16
|
+
definition: {
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
sourceInfo: SourceInfo;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Subset of `AgentSession` fields needed to build a capability inventory.
|
|
24
|
+
* Callers (including `AgentSession` itself) can cast the session to this
|
|
25
|
+
* interface because the fields are read-only for inventory construction.
|
|
26
|
+
*/
|
|
27
|
+
export interface LoadoutRuntimeSession {
|
|
28
|
+
_baseToolDefinitions: Map<string, ToolDefinition>;
|
|
29
|
+
_extensionRunner: ExtensionRunnerLike;
|
|
30
|
+
_customTools: ToolDefinition[];
|
|
31
|
+
}
|
|
32
|
+
export interface LoadoutRuntimeState {
|
|
33
|
+
profileName: string;
|
|
34
|
+
authority: LoadoutAuthority;
|
|
35
|
+
activeTools: string[];
|
|
36
|
+
activeSkills: string[];
|
|
37
|
+
activeMcp: string[];
|
|
38
|
+
activeHooks: string[];
|
|
39
|
+
schedulerFields: SchedulerFields;
|
|
40
|
+
blockers: string[];
|
|
41
|
+
warnings: string[];
|
|
42
|
+
}
|
|
43
|
+
export interface BuildLoadoutAccessPolicyOptions {
|
|
44
|
+
cwd: string;
|
|
45
|
+
blockedPaths?: readonly string[];
|
|
46
|
+
commands?: LoadoutCommands;
|
|
47
|
+
}
|
|
48
|
+
export declare function buildLoadoutAccessPolicy(state: LoadoutRuntimeState, options: BuildLoadoutAccessPolicyOptions): LoadoutAccessPolicy;
|
|
49
|
+
export interface SubagentLaneGrant {
|
|
50
|
+
laneId: string;
|
|
51
|
+
agent: string;
|
|
52
|
+
task: string;
|
|
53
|
+
scope: string;
|
|
54
|
+
authority: LoadoutAuthority;
|
|
55
|
+
allowedPaths: string[];
|
|
56
|
+
blockedPaths: string[];
|
|
57
|
+
skills: string[];
|
|
58
|
+
mcp: string[];
|
|
59
|
+
hooks: string[];
|
|
60
|
+
commands: LoadoutCommands;
|
|
61
|
+
evidenceOutput?: string;
|
|
62
|
+
scheduler: SchedulerFields;
|
|
63
|
+
}
|
|
64
|
+
export declare function buildCapabilityInventory(session: LoadoutRuntimeSession, resourceLoader: ResourceLoader, cwd: string, hookInventory: HookInventory): CapabilityInventory;
|
|
65
|
+
export interface ApplyLoadoutToRuntimeRequest {
|
|
66
|
+
profile: LoadoutProfile;
|
|
67
|
+
role: LoadoutRole;
|
|
68
|
+
grantAuthority?: LoadoutAuthority;
|
|
69
|
+
assignedReadPaths?: readonly string[];
|
|
70
|
+
assignedWritePaths?: readonly string[];
|
|
71
|
+
}
|
|
72
|
+
export declare function applyLoadoutToRuntime(session: LoadoutRuntimeSession, resourceLoader: ResourceLoader, cwd: string, agentDir: string, request: ApplyLoadoutToRuntimeRequest): LoadoutRuntimeState;
|
|
73
|
+
export interface BuildSubagentLaneGrantOptions {
|
|
74
|
+
allowedReadPaths?: readonly string[];
|
|
75
|
+
allowedWritePaths?: readonly string[];
|
|
76
|
+
evidenceOutputPattern?: string;
|
|
77
|
+
runId?: string;
|
|
78
|
+
profile?: {
|
|
79
|
+
commands?: LoadoutCommands;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export declare function buildSubagentLaneGrant(nodeId: string, role: LoadoutRole, task: string, applied: AppliedLoadout, schedulerFields: SchedulerFields, options?: BuildSubagentLaneGrantOptions): SubagentLaneGrant;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=loadout-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadout-runtime.d.ts","sourceRoot":"","sources":["../../src/core/loadout-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,KAAK,aAAa,EAAqB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,EACN,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EAExB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,WAAW,EAEhB,KAAK,eAAe,EAEpB,MAAM,eAAe,CAAC;AAEv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eAAe,EAAE,eAAe,EAChC,OAAO,GAAE,6BAAkC,GACzC,iBAAiB,CA4BnB","sourcesContent":["/**\n * Loadout runtime wiring — pure algorithms.\n *\n * Converts the pure loadout decisions in `loadouts.ts` into runtime-ready\n * capability inventories, lane grants, and scheduler fields without mutating\n * `AgentSession`.\n */\n\nimport type { ToolDefinition } from \"./extensions/types.ts\";\nimport { type HookInventory, loadHookInventory } from \"./hook-inventory.ts\";\nimport { createLoadoutAccessPolicy, type LoadoutAccessPolicy } from \"./loadout-access-policy.ts\";\nimport {\n\ttype AppliedLoadout,\n\tapplyLoadoutProfile,\n\ttype CapabilityInventory,\n\tderiveSchedulerFields,\n\ttype LoadoutAuthority,\n\ttype LoadoutCommands,\n\ttype LoadoutProfile,\n\ttype LoadoutRole,\n\ttype NamedResource,\n\ttype SchedulerFields,\n\tvalidateLoadoutProfile,\n} from \"./loadouts.ts\";\nimport { loadMcpInventory } from \"./mcp-inventory.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\n\ninterface ExtensionRunnerLike {\n\tgetAllRegisteredTools(): Array<{ definition: { name: string }; sourceInfo: SourceInfo }>;\n}\n\n/**\n * Subset of `AgentSession` fields needed to build a capability inventory.\n * Callers (including `AgentSession` itself) can cast the session to this\n * interface because the fields are read-only for inventory construction.\n */\nexport interface LoadoutRuntimeSession {\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_extensionRunner: ExtensionRunnerLike;\n\t_customTools: ToolDefinition[];\n}\n\nexport interface LoadoutRuntimeState {\n\tprofileName: string;\n\tauthority: LoadoutAuthority;\n\tactiveTools: string[];\n\tactiveSkills: string[];\n\tactiveMcp: string[];\n\tactiveHooks: string[];\n\tschedulerFields: SchedulerFields;\n\tblockers: string[];\n\twarnings: string[];\n}\n\nexport interface BuildLoadoutAccessPolicyOptions {\n\tcwd: string;\n\tblockedPaths?: readonly string[];\n\tcommands?: LoadoutCommands;\n}\n\nexport function buildLoadoutAccessPolicy(\n\tstate: LoadoutRuntimeState,\n\toptions: BuildLoadoutAccessPolicyOptions,\n): LoadoutAccessPolicy {\n\treturn createLoadoutAccessPolicy({\n\t\tcwd: options.cwd,\n\t\tactiveTools: state.activeTools,\n\t\treadSet: state.schedulerFields.readSet,\n\t\twriteSet: state.schedulerFields.writeSet,\n\t\tblockedPaths: options.blockedPaths,\n\t\tcommands: options.commands,\n\t});\n}\n\nexport interface SubagentLaneGrant {\n\tlaneId: string;\n\tagent: string;\n\ttask: string;\n\tscope: string;\n\tauthority: LoadoutAuthority;\n\tallowedPaths: string[];\n\tblockedPaths: string[];\n\tskills: string[];\n\tmcp: string[];\n\thooks: string[];\n\tcommands: LoadoutCommands;\n\tevidenceOutput?: string;\n\tscheduler: SchedulerFields;\n}\n\nexport function buildCapabilityInventory(\n\tsession: LoadoutRuntimeSession,\n\tresourceLoader: ResourceLoader,\n\tcwd: string,\n\thookInventory: HookInventory,\n): CapabilityInventory {\n\tconst tools: NamedResource[] = [];\n\n\tfor (const [name] of session._baseToolDefinitions) {\n\t\ttools.push({\n\t\t\tkind: \"tool\",\n\t\t\tname,\n\t\t\tsource: \"builtin\",\n\t\t\tscope: \"temporary\",\n\t\t\torigin: \"top-level\",\n\t\t});\n\t}\n\n\tfor (const registered of session._extensionRunner.getAllRegisteredTools()) {\n\t\tconst { sourceInfo } = registered;\n\t\ttools.push({\n\t\t\tkind: \"tool\",\n\t\t\tname: registered.definition.name,\n\t\t\tsource: sourceInfo.source,\n\t\t\tscope: sourceInfo.scope,\n\t\t\torigin: sourceInfo.origin,\n\t\t\tpath: sourceInfo.path,\n\t\t});\n\t}\n\n\tfor (const definition of session._customTools) {\n\t\ttools.push({\n\t\t\tkind: \"tool\",\n\t\t\tname: definition.name,\n\t\t\tsource: \"sdk\",\n\t\t\tscope: \"temporary\",\n\t\t\torigin: \"top-level\",\n\t\t});\n\t}\n\n\tconst skills: NamedResource[] = resourceLoader.getSkills().skills.map((skill) => ({\n\t\tkind: \"skill\",\n\t\tname: skill.name,\n\t\tsource: skill.sourceInfo.source,\n\t\tscope: skill.sourceInfo.scope,\n\t\torigin: skill.sourceInfo.origin,\n\t\tpath: skill.filePath,\n\t}));\n\n\tconst mcp: NamedResource[] = loadMcpInventory(cwd).entries.map((entry) => ({\n\t\tkind: \"mcp\",\n\t\tname: entry.name,\n\t\tsource: entry.source,\n\t\tscope: \"project\",\n\t\torigin: \"top-level\",\n\t}));\n\n\tconst hooks: NamedResource[] = hookInventory.hooks.map((descriptor) => ({\n\t\tkind: \"hook\",\n\t\tname: descriptor.name,\n\t\tsource: descriptor.scriptPath ?? \"builtin\",\n\t\tscope: \"builtin\",\n\t\torigin: \"top-level\",\n\t}));\n\n\treturn { tools, skills, mcp, hooks };\n}\n\nexport interface ApplyLoadoutToRuntimeRequest {\n\tprofile: LoadoutProfile;\n\trole: LoadoutRole;\n\tgrantAuthority?: LoadoutAuthority;\n\tassignedReadPaths?: readonly string[];\n\tassignedWritePaths?: readonly string[];\n}\n\nexport function applyLoadoutToRuntime(\n\tsession: LoadoutRuntimeSession,\n\tresourceLoader: ResourceLoader,\n\tcwd: string,\n\tagentDir: string,\n\trequest: ApplyLoadoutToRuntimeRequest,\n): LoadoutRuntimeState {\n\tconst validation = validateLoadoutProfile(request.profile);\n\tif (!validation.valid) {\n\t\treturn {\n\t\t\tprofileName: request.profile.name,\n\t\t\tauthority: request.profile.authority,\n\t\t\tactiveTools: [],\n\t\t\tactiveSkills: [],\n\t\t\tactiveMcp: [],\n\t\t\tactiveHooks: [],\n\t\t\tschedulerFields: { readSet: [], writeSet: [], parallelizable: true },\n\t\t\tblockers: validation.errors,\n\t\t\twarnings: [],\n\t\t};\n\t}\n\n\tconst hookInventory = loadHookInventory(agentDir);\n\tconst inventory = buildCapabilityInventory(session, resourceLoader, cwd, hookInventory);\n\tconst applied = applyLoadoutProfile(request.profile, inventory, { grantAuthority: request.grantAuthority });\n\tif (applied.blockers.length > 0) {\n\t\treturn {\n\t\t\tprofileName: applied.profileName,\n\t\t\tauthority: applied.authority,\n\t\t\tactiveTools: applied.activeTools,\n\t\t\tactiveSkills: applied.activeSkills,\n\t\t\tactiveMcp: applied.activeMcp,\n\t\t\tactiveHooks: applied.activeHooks,\n\t\t\tschedulerFields: { readSet: [], writeSet: [], parallelizable: true },\n\t\t\tblockers: applied.blockers,\n\t\t\twarnings: applied.warnings,\n\t\t};\n\t}\n\n\tconst schedulerFields = deriveSchedulerFields({\n\t\trole: request.role,\n\t\tassignedReadPaths: request.assignedReadPaths,\n\t\tassignedWritePaths: request.assignedWritePaths,\n\t});\n\n\treturn {\n\t\tprofileName: applied.profileName,\n\t\tauthority: applied.authority,\n\t\tactiveTools: applied.activeTools,\n\t\tactiveSkills: applied.activeSkills,\n\t\tactiveMcp: applied.activeMcp,\n\t\tactiveHooks: applied.activeHooks,\n\t\tschedulerFields,\n\t\tblockers: applied.blockers,\n\t\twarnings: applied.warnings,\n\t};\n}\n\nexport interface BuildSubagentLaneGrantOptions {\n\tallowedReadPaths?: readonly string[];\n\tallowedWritePaths?: readonly string[];\n\tevidenceOutputPattern?: string;\n\trunId?: string;\n\tprofile?: { commands?: LoadoutCommands };\n}\n\nexport function buildSubagentLaneGrant(\n\tnodeId: string,\n\trole: LoadoutRole,\n\ttask: string,\n\tapplied: AppliedLoadout,\n\tschedulerFields: SchedulerFields,\n\toptions: BuildSubagentLaneGrantOptions = {},\n): SubagentLaneGrant {\n\tconst allowedPaths = uniqueSorted([...(options.allowedReadPaths ?? []), ...(options.allowedWritePaths ?? [])]);\n\tconst blockedPaths = [\"**/.env*\", \"**/*secret*\", \"**/*key*\", \"**/.git/*\"];\n\n\tlet evidenceOutput: string | undefined;\n\tif (options.evidenceOutputPattern) {\n\t\tevidenceOutput = options.runId\n\t\t\t? options.evidenceOutputPattern.replace(\"<goal>\", options.runId)\n\t\t\t: options.evidenceOutputPattern;\n\t}\n\n\tconst commands = options.profile?.commands ?? { mode: \"none\" };\n\n\treturn {\n\t\tlaneId: nodeId,\n\t\tagent: `omk-${role}`,\n\t\ttask,\n\t\tscope: \"loadout-derived lane grant\",\n\t\tauthority: applied.authority,\n\t\tallowedPaths,\n\t\tblockedPaths,\n\t\tskills: applied.activeSkills,\n\t\tmcp: applied.activeMcp,\n\t\thooks: applied.activeHooks,\n\t\tcommands,\n\t\tevidenceOutput,\n\t\tscheduler: schedulerFields,\n\t};\n}\n\nfunction uniqueSorted(values: readonly string[]): string[] {\n\treturn [...new Set(values)]\n\t\t.map((value) => value.trim())\n\t\t.filter((value) => value !== \"\")\n\t\t.sort();\n}\n"]}
|