open-multi-agent-kit 0.96.2 → 0.98.0
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 +51 -0
- package/README.md +43 -9
- package/dist/cli/args.d.ts +2 -3
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +13 -189
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/help.d.ts +3 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +194 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js +2 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/resource-paths.d.ts +4 -0
- package/dist/cli/resource-paths.d.ts.map +1 -0
- package/dist/cli/resource-paths.js +59 -0
- package/dist/cli/resource-paths.js.map +1 -0
- package/dist/commands/adaptorch-doctor-cli.d.ts +13 -0
- package/dist/commands/adaptorch-doctor-cli.d.ts.map +1 -0
- package/dist/commands/adaptorch-doctor-cli.js +115 -0
- package/dist/commands/adaptorch-doctor-cli.js.map +1 -0
- package/dist/commands/resource-doctor-cli.d.ts +4 -0
- package/dist/commands/resource-doctor-cli.d.ts.map +1 -1
- package/dist/commands/resource-doctor-cli.js +35 -5
- package/dist/commands/resource-doctor-cli.js.map +1 -1
- package/dist/core/adaptorch-bridge.d.ts +11 -13
- package/dist/core/adaptorch-bridge.d.ts.map +1 -1
- package/dist/core/adaptorch-bridge.js +11 -13
- package/dist/core/adaptorch-bridge.js.map +1 -1
- package/dist/core/agent-session-snapshot.d.ts +16 -0
- package/dist/core/agent-session-snapshot.d.ts.map +1 -0
- package/dist/core/agent-session-snapshot.js +111 -0
- package/dist/core/agent-session-snapshot.js.map +1 -0
- package/dist/core/agent-session.d.ts +14 -10
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +102 -217
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/agent-tool-settings.d.ts +10 -0
- package/dist/core/agent-tool-settings.d.ts.map +1 -1
- package/dist/core/agent-tool-settings.js +10 -1
- package/dist/core/agent-tool-settings.js.map +1 -1
- package/dist/core/attachment-store.d.ts +39 -0
- package/dist/core/attachment-store.d.ts.map +1 -0
- package/dist/core/attachment-store.js +81 -0
- package/dist/core/attachment-store.js.map +1 -0
- package/dist/core/command-safety.d.ts +8 -0
- package/dist/core/command-safety.d.ts.map +1 -1
- package/dist/core/command-safety.js +140 -14
- package/dist/core/command-safety.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +13 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +60 -62
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/knowledge-triage-format.d.ts +9 -0
- package/dist/core/compaction/knowledge-triage-format.d.ts.map +1 -0
- package/dist/core/compaction/knowledge-triage-format.js +71 -0
- package/dist/core/compaction/knowledge-triage-format.js.map +1 -0
- package/dist/core/compaction/knowledge-triage-types.d.ts +7 -0
- package/dist/core/compaction/knowledge-triage-types.d.ts.map +1 -0
- package/dist/core/compaction/knowledge-triage-types.js +2 -0
- package/dist/core/compaction/knowledge-triage-types.js.map +1 -0
- package/dist/core/compaction/knowledge-triage.d.ts +29 -0
- package/dist/core/compaction/knowledge-triage.d.ts.map +1 -0
- package/dist/core/compaction/knowledge-triage.js +189 -0
- package/dist/core/compaction/knowledge-triage.js.map +1 -0
- package/dist/core/compaction/transaction.d.ts.map +1 -1
- package/dist/core/compaction/transaction.js +1 -1
- package/dist/core/compaction/transaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +4 -0
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +37 -0
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/completion-sound-io.d.ts +14 -0
- package/dist/core/completion-sound-io.d.ts.map +1 -0
- package/dist/core/completion-sound-io.js +64 -0
- package/dist/core/completion-sound-io.js.map +1 -0
- package/dist/core/completion-sound.d.ts +4 -10
- package/dist/core/completion-sound.d.ts.map +1 -1
- package/dist/core/completion-sound.js +28 -58
- package/dist/core/completion-sound.js.map +1 -1
- package/dist/core/context-budget-governor-v2.d.ts +1 -1
- package/dist/core/context-budget-governor-v2.d.ts.map +1 -1
- package/dist/core/context-budget-governor-v2.js +1 -1
- package/dist/core/context-budget-governor-v2.js.map +1 -1
- package/dist/core/context-budget-relevance.d.ts +15 -2
- package/dist/core/context-budget-relevance.d.ts.map +1 -1
- package/dist/core/context-budget-relevance.js +21 -9
- package/dist/core/context-budget-relevance.js.map +1 -1
- package/dist/core/context-budget-system-prompt-items.d.ts +1 -1
- package/dist/core/context-budget-system-prompt-items.d.ts.map +1 -1
- package/dist/core/context-budget-system-prompt-items.js.map +1 -1
- package/dist/core/context-budget-system-prompt.d.ts +1 -1
- package/dist/core/context-budget-system-prompt.d.ts.map +1 -1
- package/dist/core/context-budget-system-prompt.js.map +1 -1
- package/dist/core/context-budget-v2-cache-keys.d.ts +3 -0
- package/dist/core/context-budget-v2-cache-keys.d.ts.map +1 -1
- package/dist/core/context-budget-v2-cache-keys.js +2 -0
- package/dist/core/context-budget-v2-cache-keys.js.map +1 -1
- package/dist/core/context-budget-v2-plan-cache-keys.d.ts.map +1 -1
- package/dist/core/context-budget-v2-plan-cache-keys.js +3 -0
- package/dist/core/context-budget-v2-plan-cache-keys.js.map +1 -1
- package/dist/core/context-budget-v2-planner.d.ts.map +1 -1
- package/dist/core/context-budget-v2-planner.js +2 -1
- package/dist/core/context-budget-v2-planner.js.map +1 -1
- package/dist/core/context-budget-v2-scoring.d.ts +17 -0
- package/dist/core/context-budget-v2-scoring.d.ts.map +1 -1
- package/dist/core/context-budget-v2-scoring.js +25 -8
- package/dist/core/context-budget-v2-scoring.js.map +1 -1
- package/dist/core/context-budget-v2-selection.d.ts +2 -2
- package/dist/core/context-budget-v2-selection.d.ts.map +1 -1
- package/dist/core/context-budget-v2-selection.js +18 -1
- package/dist/core/context-budget-v2-selection.js.map +1 -1
- package/dist/core/context-budget-v2-types.d.ts +17 -0
- package/dist/core/context-budget-v2-types.d.ts.map +1 -1
- package/dist/core/context-budget-v2-types.js +15 -0
- package/dist/core/context-budget-v2-types.js.map +1 -1
- package/dist/core/context-file.d.ts +23 -0
- package/dist/core/context-file.d.ts.map +1 -0
- package/dist/core/context-file.js +17 -0
- package/dist/core/context-file.js.map +1 -0
- package/dist/core/extensions/builtin/command-safety-gate.d.ts +3 -1
- package/dist/core/extensions/builtin/command-safety-gate.d.ts.map +1 -1
- package/dist/core/extensions/builtin/command-safety-gate.js +7 -0
- package/dist/core/extensions/builtin/command-safety-gate.js.map +1 -1
- package/dist/core/extensions/types.d.ts +12 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +6 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-prompt-policy.d.ts +1 -1
- package/dist/core/model-prompt-policy.d.ts.map +1 -1
- package/dist/core/model-prompt-policy.js.map +1 -1
- package/dist/core/model-registry.d.ts +8 -3
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +71 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/package-doctor-source-scan.d.ts +9 -0
- package/dist/core/package-doctor-source-scan.d.ts.map +1 -1
- package/dist/core/package-doctor-source-scan.js +77 -4
- package/dist/core/package-doctor-source-scan.js.map +1 -1
- package/dist/core/prompt-attachment.d.ts +51 -0
- package/dist/core/prompt-attachment.d.ts.map +1 -0
- package/dist/core/prompt-attachment.js +186 -0
- package/dist/core/prompt-attachment.js.map +1 -0
- package/dist/core/prompt-settlement.d.ts +6 -3
- package/dist/core/prompt-settlement.d.ts.map +1 -1
- package/dist/core/prompt-settlement.js +10 -14
- package/dist/core/prompt-settlement.js.map +1 -1
- package/dist/core/provider-resilience.d.ts +28 -0
- package/dist/core/provider-resilience.d.ts.map +1 -1
- package/dist/core/provider-resilience.js +50 -0
- package/dist/core/provider-resilience.js.map +1 -1
- package/dist/core/provider-retry.d.ts +1 -1
- package/dist/core/provider-retry.d.ts.map +1 -1
- package/dist/core/provider-retry.js +1 -1
- package/dist/core/provider-retry.js.map +1 -1
- package/dist/core/provider-usage.d.ts.map +1 -1
- package/dist/core/provider-usage.js +68 -2
- package/dist/core/provider-usage.js.map +1 -1
- package/dist/core/reasoning-router-promotion.d.ts +124 -0
- package/dist/core/reasoning-router-promotion.d.ts.map +1 -0
- package/dist/core/reasoning-router-promotion.js +121 -0
- package/dist/core/reasoning-router-promotion.js.map +1 -0
- package/dist/core/reasoning-router-replay-stability.d.ts +65 -0
- package/dist/core/reasoning-router-replay-stability.d.ts.map +1 -0
- package/dist/core/reasoning-router-replay-stability.js +67 -0
- package/dist/core/reasoning-router-replay-stability.js.map +1 -0
- package/dist/core/reasoning-router-v4-weights.d.ts +6 -6
- package/dist/core/reasoning-router-v4-weights.d.ts.map +1 -1
- package/dist/core/reasoning-router-v4-weights.js +3 -3
- package/dist/core/reasoning-router-v4-weights.js.map +1 -1
- package/dist/core/reasoning-router-v4.d.ts.map +1 -1
- package/dist/core/reasoning-router-v4.js +6 -6
- package/dist/core/reasoning-router-v4.js.map +1 -1
- package/dist/core/redaction.d.ts.map +1 -1
- package/dist/core/redaction.js +1 -1
- package/dist/core/redaction.js.map +1 -1
- package/dist/core/resource-admission.d.ts +2 -1
- package/dist/core/resource-admission.d.ts.map +1 -1
- package/dist/core/resource-admission.js +11 -0
- package/dist/core/resource-admission.js.map +1 -1
- package/dist/core/resource-governor-format.d.ts +1 -1
- package/dist/core/resource-governor-format.d.ts.map +1 -1
- package/dist/core/resource-governor-format.js.map +1 -1
- package/dist/core/resource-governor-settings.d.ts +6 -12
- package/dist/core/resource-governor-settings.d.ts.map +1 -1
- package/dist/core/resource-governor-settings.js.map +1 -1
- package/dist/core/resource-governor-types.d.ts +24 -0
- package/dist/core/resource-governor-types.d.ts.map +1 -0
- package/dist/core/resource-governor-types.js +15 -0
- package/dist/core/resource-governor-types.js.map +1 -0
- package/dist/core/resource-loader.d.ts +1 -7
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/resource-observation-journal.d.ts +2 -1
- package/dist/core/resource-observation-journal.d.ts.map +1 -1
- package/dist/core/resource-observation-journal.js +4 -3
- package/dist/core/resource-observation-journal.js.map +1 -1
- package/dist/core/resource-observation-report-reader.d.ts +7 -0
- package/dist/core/resource-observation-report-reader.d.ts.map +1 -0
- package/dist/core/resource-observation-report-reader.js +157 -0
- package/dist/core/resource-observation-report-reader.js.map +1 -0
- package/dist/core/resource-observation-report.d.ts +24 -0
- package/dist/core/resource-observation-report.d.ts.map +1 -0
- package/dist/core/resource-observation-report.js +101 -0
- package/dist/core/resource-observation-report.js.map +1 -0
- package/dist/core/router-feedback-collector.d.ts +1 -1
- package/dist/core/router-feedback-collector.d.ts.map +1 -1
- package/dist/core/router-feedback-collector.js.map +1 -1
- package/dist/core/session-bash-service.d.ts.map +1 -1
- package/dist/core/session-bash-service.js +4 -3
- package/dist/core/session-bash-service.js.map +1 -1
- package/dist/core/session-failure-cause.d.ts +33 -0
- package/dist/core/session-failure-cause.d.ts.map +1 -0
- package/dist/core/session-failure-cause.js +141 -0
- package/dist/core/session-failure-cause.js.map +1 -0
- package/dist/core/session-system-prompt.d.ts +1 -1
- package/dist/core/session-system-prompt.d.ts.map +1 -1
- package/dist/core/session-system-prompt.js.map +1 -1
- package/dist/core/session-termination.d.ts +1 -1
- package/dist/core/session-termination.d.ts.map +1 -1
- package/dist/core/session-termination.js +11 -2
- package/dist/core/session-termination.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +10 -14
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +13 -48
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -34
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/workload-classifier.d.ts +2 -10
- package/dist/core/workload-classifier.d.ts.map +1 -1
- package/dist/core/workload-classifier.js +17 -0
- package/dist/core/workload-classifier.js.map +1 -1
- package/dist/core/workload-family-matcher.d.ts +1 -1
- package/dist/core/workload-family-matcher.d.ts.map +1 -1
- package/dist/core/workload-family-matcher.js.map +1 -1
- package/dist/core/workload-shard-execution-types.d.ts +40 -0
- package/dist/core/workload-shard-execution-types.d.ts.map +1 -0
- package/dist/core/workload-shard-execution-types.js +14 -0
- package/dist/core/workload-shard-execution-types.js.map +1 -0
- package/dist/core/workload-shard-executor.d.ts +3 -27
- package/dist/core/workload-shard-executor.d.ts.map +1 -1
- package/dist/core/workload-shard-executor.js.map +1 -1
- package/dist/core/workload-shard-runner.d.ts +1 -1
- package/dist/core/workload-shard-runner.d.ts.map +1 -1
- package/dist/core/workload-shard-runner.js.map +1 -1
- package/dist/core/workload-types.d.ts +24 -0
- package/dist/core/workload-types.d.ts.map +1 -0
- package/dist/core/workload-types.js +15 -0
- package/dist/core/workload-types.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +27 -47
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/attachment-strip.d.ts +21 -0
- package/dist/modes/interactive/components/attachment-strip.d.ts.map +1 -0
- package/dist/modes/interactive/components/attachment-strip.js +136 -0
- package/dist/modes/interactive/components/attachment-strip.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +6 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +26 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/status-sidebar.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-sidebar.js +12 -1
- package/dist/modes/interactive/components/status-sidebar.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +23 -4
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +174 -53
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/omk-control-panel.json +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +42 -33
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +14 -2
- package/dist/utils/clipboard.js.map +1 -1
- package/docs/adaptorch-preview-spec.md +20 -18
- package/docs/adaptorch-preview.md +9 -9
- package/docs/compaction.md +25 -4
- package/docs/correctness-wall.md +10 -10
- package/docs/docs.json +12 -0
- package/docs/environment-variables.md +9 -2
- package/docs/extensions.md +12 -3
- package/docs/index.md +7 -1
- package/docs/metrics.md +74 -2
- package/docs/provider-resilience.md +11 -0
- package/docs/runtime-algorithms.md +359 -0
- package/docs/sdk.md +2 -2
- package/docs/settings.md +11 -10
- package/docs/usage.md +19 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +18 -18
- package/package.json +7 -7
- package/dist/core/context-budget-governor.d.ts +0 -67
- package/dist/core/context-budget-governor.d.ts.map +0 -1
- package/dist/core/context-budget-governor.js +0 -224
- package/dist/core/context-budget-governor.js.map +0 -1
- package/dist/core/lean-ctx.d.ts +0 -99
- package/dist/core/lean-ctx.d.ts.map +0 -1
- package/dist/core/lean-ctx.js +0 -225
- package/dist/core/lean-ctx.js.map +0 -1
- package/dist/core/read-anchors.d.ts +0 -110
- package/dist/core/read-anchors.d.ts.map +0 -1
- package/dist/core/read-anchors.js +0 -193
- package/dist/core/read-anchors.js.map +0 -1
- package/dist/core/recovery-checkpoint.d.ts +0 -196
- package/dist/core/recovery-checkpoint.d.ts.map +0 -1
- package/dist/core/recovery-checkpoint.js +0 -382
- package/dist/core/recovery-checkpoint.js.map +0 -1
- package/dist/core/sandbox-policy-v2.d.ts +0 -49
- package/dist/core/sandbox-policy-v2.d.ts.map +0 -1
- package/dist/core/sandbox-policy-v2.js +0 -368
- package/dist/core/sandbox-policy-v2.js.map +0 -1
- package/dist/core/tools/omp-pure-seams.d.ts +0 -41
- package/dist/core/tools/omp-pure-seams.d.ts.map +0 -1
- package/dist/core/tools/omp-pure-seams.js +0 -142
- package/dist/core/tools/omp-pure-seams.js.map +0 -1
- package/dist/core/tools/omp-seam-runtime.d.ts +0 -100
- package/dist/core/tools/omp-seam-runtime.d.ts.map +0 -1
- package/dist/core/tools/omp-seam-runtime.js +0 -40
- package/dist/core/tools/omp-seam-runtime.js.map +0 -1
- package/dist/guardrails/audit-logger.d.ts +0 -4
- package/dist/guardrails/audit-logger.d.ts.map +0 -1
- package/dist/guardrails/audit-logger.js +0 -28
- package/dist/guardrails/audit-logger.js.map +0 -1
- package/dist/guardrails/freedomd-adapter.d.ts +0 -16
- package/dist/guardrails/freedomd-adapter.d.ts.map +0 -1
- package/dist/guardrails/freedomd-adapter.js +0 -87
- package/dist/guardrails/freedomd-adapter.js.map +0 -1
- package/dist/orchestration/lane-grant-auditor.d.ts +0 -4
- package/dist/orchestration/lane-grant-auditor.d.ts.map +0 -1
- package/dist/orchestration/lane-grant-auditor.js +0 -87
- package/dist/orchestration/lane-grant-auditor.js.map +0 -1
- package/dist/types/guardrails.d.ts +0 -61
- package/dist/types/guardrails.d.ts.map +0 -1
- package/dist/types/guardrails.js +0 -9
- package/dist/types/guardrails.js.map +0 -1
- package/dist/types/lane-grant.d.ts +0 -58
- package/dist/types/lane-grant.d.ts.map +0 -1
- package/dist/types/lane-grant.js +0 -9
- package/dist/types/lane-grant.js.map +0 -1
package/docs/sdk.md
CHANGED
|
@@ -565,12 +565,12 @@ The `edit` tool returns `details.diff` for OMK's TUI display and `details.patch`
|
|
|
565
565
|
|
|
566
566
|
The `diagnostics` tool runs the project's own checkers and normalizes the result — `tsc --noEmit` for TypeScript, `pyright`/`ruff` for Python, `go vet` for Go, `cargo check` for Rust. Missing checkers or project markers are reported as `skipped` in the tool result instead of failing. Output is capped at 50 diagnostics and cached for 5 s.
|
|
567
567
|
|
|
568
|
-
|
|
568
|
+
Truncated `read` output may spill the selected window to a randomly named `omk-spill-*` directory under the OS temporary directory; `ReadToolDetails.fullOutputPath` reports the path when present. The directory is owner-only (`0700`) and the spill file is exclusive and owner-readable (`0600`) on POSIX. A first line that alone exceeds the byte cap is clipped without a spill. The exported `spillTruncatedOutput()` helper provides the same preview-plus-path contract for custom tools.
|
|
569
569
|
|
|
570
570
|
```typescript
|
|
571
571
|
import { createAgentSession } from "open-multi-agent-kit";
|
|
572
572
|
|
|
573
|
-
// Enable inspection tools;
|
|
573
|
+
// Enable inspection tools; a long read may create a private temp spill
|
|
574
574
|
const { session } = await createAgentSession({
|
|
575
575
|
tools: ["read", "grep", "find", "ls"],
|
|
576
576
|
});
|
package/docs/settings.md
CHANGED
|
@@ -138,7 +138,7 @@ All numeric token reserves must be non-negative safe integers. Ratios must be fi
|
|
|
138
138
|
|
|
139
139
|
| Setting | Type | Default | Description |
|
|
140
140
|
|---------|------|---------|-------------|
|
|
141
|
-
| `contextBudget.enabled` | boolean | `false` | Globally enable prompt resource budgeting
|
|
141
|
+
| `contextBudget.enabled` | boolean | `false` | Globally enable prompt resource budgeting; representation entries persist per workspace by default while plan entries stay in session memory |
|
|
142
142
|
|
|
143
143
|
```json
|
|
144
144
|
{
|
|
@@ -146,7 +146,7 @@ All numeric token reserves must be non-negative safe integers. Ratios must be fi
|
|
|
146
146
|
}
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
This setting is global-only: `.omk/settings.json` cannot enable or disable it. Use `OMK_CONTEXT_GOVERNOR=1` to force it on for one process or `OMK_CONTEXT_GOVERNOR=0` to force it off for a baseline run.
|
|
149
|
+
This setting is global-only: `.omk/settings.json` cannot enable or disable it. Use `OMK_CONTEXT_GOVERNOR=1` to force it on for one process or `OMK_CONTEXT_GOVERNOR=0` to force it off for a baseline run. When enabled, content-addressed representation and negative-result entries persist under `.omk/cache/context-budget-v2`; plan entries stay in session memory. Set `OMK_CONTEXT_GOVERNOR_CACHE=memory` to keep every entry in session memory or `OMK_CONTEXT_GOVERNOR_CACHE_DIR` to relocate the representation snapshot.
|
|
150
150
|
|
|
151
151
|
### Agent Tool Execution
|
|
152
152
|
|
|
@@ -182,7 +182,7 @@ The DAG preserves source-order result artifacts. `bash`, unknown tools, and exte
|
|
|
182
182
|
|
|
183
183
|
### Resource Governor
|
|
184
184
|
|
|
185
|
-
The governor probes host capacity (memory, workspace disk, V8 heap, system CPU) and evaluates a resource admission decision, surfaced through `/resource [probe|policy]` in the TUI and `omk doctor resources [--json]` headless. In `observe` mode (default) it records decisions without changing behavior; in `adaptive`/`strict` modes each top-level prompt runs a bounded preflight probe and throttles the effective tool concurrency for that run (never above `agent.maxToolConcurrency`), restoring it when the run settles. Heavy-process caps are enforced at the governed bash boundary; the internal subagent-lane launcher is not wired into live child dispatch. Absent settings keep prior behavior unchanged.
|
|
185
|
+
The governor probes host capacity (memory, workspace disk, V8 heap, system CPU) and evaluates a resource admission decision, surfaced through `/resource [probe|policy]` in the TUI and `omk doctor resources [--json]` headless. `omk doctor resources --report [--json]` aggregates bounded, identifier-free admission counts from local run journals without probing the current host. Only reason-qualified records count toward the 30-record floor; legacy/malformed reason coverage remains diagnostic. The floor is only a sample signal, always requires human review, and never promotes the mode. In `observe` mode (default) it records decisions without changing behavior; in `adaptive`/`strict` modes each top-level prompt runs a bounded preflight probe and throttles the effective tool concurrency for that run (never above `agent.maxToolConcurrency`), restoring it when the run settles. Heavy-process caps are enforced at the governed bash boundary; the internal subagent-lane launcher is not wired into live child dispatch. Absent settings keep prior behavior unchanged.
|
|
186
186
|
|
|
187
187
|
| Setting | Type | Default | Description |
|
|
188
188
|
| --------- | ------ | --------- | ------------- |
|
|
@@ -213,20 +213,21 @@ Validation is explicit and fail-closed: invalid values are reported (in `/resour
|
|
|
213
213
|
|
|
214
214
|
### Completion Sound
|
|
215
215
|
|
|
216
|
-
Plays a short system sound
|
|
216
|
+
Plays a short system sound only after the top-level prompt settles: retries, continuations, and tools must be drained first. Current subagent work is awaited inside its tool call, so that tool boundary also covers those children. The settlement contract reserves direct child/shard counters for future live wiring; those paths must connect the counters before activation. Sound is enabled by default only in the interactive TUI on a real TTY—never in RPC, JSON, print mode, or CI. Successful prompts honor `minDurationMs`; failed and aborted prompts notify immediately. Backends use fixed absolute executables and arguments (macOS `afplay`, Windows system PowerShell, Linux `canberra-gtk-play`/`paplay`/`aplay`), an allowlisted environment with no inherited `PATH` or credentials, and the OS temporary directory as cwd. WSL uses terminal BEL because Windows executable mounts have no fixed trusted path. Sound failures are diagnostics only and never affect the prompt outcome.
|
|
217
217
|
|
|
218
218
|
| Setting | Type | Default | Description |
|
|
219
219
|
| --------- | ------ | --------- | ------------- |
|
|
220
|
-
| `notifications.completionSound.enabled` | boolean | `
|
|
221
|
-
| `notifications.completionSound.minDurationMs` | number | `5000` |
|
|
222
|
-
| `notifications.completionSound.onSuccess` | boolean | `true` |
|
|
223
|
-
| `notifications.completionSound.onFailure` | boolean | `true` |
|
|
224
|
-
| `notifications.completionSound.
|
|
220
|
+
| `notifications.completionSound.enabled` | boolean | `true` | Master switch; `OMK_COMPLETION_SOUND=0` disables and `=1` enables it for one process |
|
|
221
|
+
| `notifications.completionSound.minDurationMs` | number | `5000` | Minimum duration for successful-completion sounds; failed/aborted outcomes bypass it |
|
|
222
|
+
| `notifications.completionSound.onSuccess` | boolean | `true` | Notify after a completed prompt that meets the duration floor |
|
|
223
|
+
| `notifications.completionSound.onFailure` | boolean | `true` | Notify immediately after a failed terminal outcome |
|
|
224
|
+
| `notifications.completionSound.onAbort` | boolean | `true` | Notify immediately after an aborted/stopped terminal outcome |
|
|
225
|
+
| `notifications.completionSound.terminalBellFallback` | boolean | `true` | Fall back to terminal BEL when no sound backend works |
|
|
225
226
|
|
|
226
227
|
```json
|
|
227
228
|
{
|
|
228
229
|
"notifications": {
|
|
229
|
-
"completionSound": { "
|
|
230
|
+
"completionSound": { "minDurationMs": 10000, "onAbort": false }
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
```
|
package/docs/usage.md
CHANGED
|
@@ -22,7 +22,7 @@ The editor can be replaced temporarily by built-in UI such as `/settings` or by
|
|
|
22
22
|
| File reference | Type `@` to fuzzy-search project files |
|
|
23
23
|
| Path completion | Press Tab to complete paths |
|
|
24
24
|
| Multi-line input | Shift+Enter, or Ctrl+Enter on Windows Terminal |
|
|
25
|
-
| Images | Paste with Ctrl+V
|
|
25
|
+
| Images | Paste with Ctrl+V (Alt+V on Windows) or drag into the terminal; pastes attach as preview chips above the editor and send with your next prompt |
|
|
26
26
|
| Skill/bash launcher | `!` opens skill completion; `!skill:name prompt` invokes a skill; `!omk <role-or-request>` routes through OMK role hubs |
|
|
27
27
|
| Shell command | `! command` runs and sends output to the model |
|
|
28
28
|
| Hidden shell command | `!! command` runs without sending output to the model |
|
|
@@ -45,6 +45,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
|
|
|
45
45
|
| `/new` | Start a new session |
|
|
46
46
|
| `/name <name>` | Set session display name |
|
|
47
47
|
| `/session` | Show session file, ID, messages, tokens, and cost |
|
|
48
|
+
| `/resource [probe\|policy]` | Show resource pressure and effective concurrency for this run |
|
|
48
49
|
| `/goal [objective]` | Show or set the durable goal for the current working directory |
|
|
49
50
|
| `/tree` | Jump to any point in the session and continue from there |
|
|
50
51
|
| `/fork` | Create a new session from a previous user message |
|
|
@@ -261,6 +262,21 @@ Diagnoses one provider and prints a single sanitized JSON document. Exit codes a
|
|
|
261
262
|
|
|
262
263
|
Config sources, highest precedence first: `models.json`, `KIMI_BASE_URL`/`KIMI_MODEL_NAME` env, `~/.kimi/config.toml` root keys, then `[providers.<name>]` TOML tables with `type = "openai_legacy"` — the last are classified `custom-openai-compatible`, so native-only checks (login, native config) are skipped and endpoint reachability is checked instead. Credentials, URL userinfo/query/fragment, request bodies, and response bodies never appear in the output; malformed TOML is reported by line number only.
|
|
263
264
|
|
|
265
|
+
### Resource Doctor
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
omk doctor resources [--json]
|
|
269
|
+
omk doctor resources --report [--json]
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
The first form probes current host pressure. `--report` does not probe the host;
|
|
273
|
+
it scans at most 500 bounded local resource-observation journals and emits only
|
|
274
|
+
aggregate pressure/action/probe-health counts. It opens bounded regular files
|
|
275
|
+
without following symlinks and never includes paths, prompt or decision IDs,
|
|
276
|
+
digests, a command field, or raw capacity. Only reason-qualified records count
|
|
277
|
+
toward the 30-record floor; the report always requires human false-positive
|
|
278
|
+
review and never promotes `adaptive`.
|
|
279
|
+
|
|
264
280
|
### Modes
|
|
265
281
|
|
|
266
282
|
| Flag | Description |
|
|
@@ -311,7 +327,7 @@ cat README.md | omk -p "Summarize this text"
|
|
|
311
327
|
|
|
312
328
|
Built-in tools: `read`, `bash`, `edit`, `write`, `grep`, `find`, `ls`.
|
|
313
329
|
|
|
314
|
-
|
|
330
|
+
A long text `read` returns a bounded window and continuation marker. Truncation may spill the selected window to a randomly named owner-only directory under the OS temporary directory and report that path; the directory uses mode `0700` and the file `0600` on POSIX. A first line that alone exceeds the byte cap is clipped without a spill. An inspection-only tool allowlist is therefore not a strict no-write filesystem boundary.
|
|
315
331
|
|
|
316
332
|
### Resource Options
|
|
317
333
|
|
|
@@ -380,7 +396,7 @@ omk --model sonnet:high "Solve this complex problem"
|
|
|
380
396
|
# Limit model cycling
|
|
381
397
|
omk --models "claude-*,gpt-4o"
|
|
382
398
|
|
|
383
|
-
# Inspection-only tool allowlist;
|
|
399
|
+
# Inspection-only tool allowlist; a long read may create a private temp spill
|
|
384
400
|
omk --tools read,grep,find,ls -p "Review the code"
|
|
385
401
|
|
|
386
402
|
# Disable one extension or built-in tool while keeping the rest available
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omk-extension-custom-provider-anthropic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omk-extension-custom-provider-anthropic",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.98.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "0.52.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omk-extension-gondolin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omk-extension-gondolin",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.98.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@earendil-works/gondolin": "0.12.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omk-extension-sandbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omk-extension-sandbox",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.98.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "0.0.26"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omk-extension-with-deps",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omk-extension-with-deps",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.98.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "2.1.3"
|
|
12
12
|
},
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-multi-agent-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "open-multi-agent-kit",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.98.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"omk-agent-core": "^0.
|
|
13
|
-
"omk-ai": "^0.
|
|
14
|
-
"omk-tui": "^0.
|
|
12
|
+
"omk-agent-core": "^0.98.0",
|
|
13
|
+
"omk-ai": "^0.98.0",
|
|
14
|
+
"omk-tui": "^0.98.0",
|
|
15
15
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
16
16
|
"canonicalize": "4.0.0",
|
|
17
17
|
"chalk": "5.6.2",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"typebox": "1.3.11",
|
|
28
28
|
"undici": "8.10.0",
|
|
29
29
|
"yaml": "2.9.0",
|
|
30
|
-
"omk-adaptorch-wpl": "^0.
|
|
31
|
-
"omk-protocol": "^0.
|
|
30
|
+
"omk-adaptorch-wpl": "^0.98.0",
|
|
31
|
+
"omk-protocol": "^0.98.0"
|
|
32
32
|
},
|
|
33
33
|
"optionalDependencies": {
|
|
34
34
|
"@mariozechner/clipboard": "0.3.9"
|
|
@@ -1285,19 +1285,19 @@
|
|
|
1285
1285
|
}
|
|
1286
1286
|
},
|
|
1287
1287
|
"node_modules/omk-adaptorch-wpl": {
|
|
1288
|
-
"version": "0.
|
|
1289
|
-
"resolved": "https://registry.npmjs.org/omk-adaptorch-wpl/-/omk-adaptorch-wpl-0.
|
|
1288
|
+
"version": "0.98.0",
|
|
1289
|
+
"resolved": "https://registry.npmjs.org/omk-adaptorch-wpl/-/omk-adaptorch-wpl-0.98.0.tgz",
|
|
1290
1290
|
"license": "MIT",
|
|
1291
1291
|
"engines": {
|
|
1292
1292
|
"node": ">=22.19.0"
|
|
1293
1293
|
}
|
|
1294
1294
|
},
|
|
1295
1295
|
"node_modules/omk-agent-core": {
|
|
1296
|
-
"version": "0.
|
|
1297
|
-
"resolved": "https://registry.npmjs.org/omk-agent-core/-/omk-agent-core-0.
|
|
1296
|
+
"version": "0.98.0",
|
|
1297
|
+
"resolved": "https://registry.npmjs.org/omk-agent-core/-/omk-agent-core-0.98.0.tgz",
|
|
1298
1298
|
"license": "MIT",
|
|
1299
1299
|
"dependencies": {
|
|
1300
|
-
"omk-ai": "^0.
|
|
1300
|
+
"omk-ai": "^0.98.0",
|
|
1301
1301
|
"ignore": "7.0.6",
|
|
1302
1302
|
"typebox": "1.3.11",
|
|
1303
1303
|
"yaml": "2.9.0"
|
|
@@ -1307,8 +1307,8 @@
|
|
|
1307
1307
|
}
|
|
1308
1308
|
},
|
|
1309
1309
|
"node_modules/omk-ai": {
|
|
1310
|
-
"version": "0.
|
|
1311
|
-
"resolved": "https://registry.npmjs.org/omk-ai/-/omk-ai-0.
|
|
1310
|
+
"version": "0.98.0",
|
|
1311
|
+
"resolved": "https://registry.npmjs.org/omk-ai/-/omk-ai-0.98.0.tgz",
|
|
1312
1312
|
"license": "MIT",
|
|
1313
1313
|
"dependencies": {
|
|
1314
1314
|
"@anthropic-ai/sdk": "0.91.1",
|
|
@@ -1330,16 +1330,16 @@
|
|
|
1330
1330
|
}
|
|
1331
1331
|
},
|
|
1332
1332
|
"node_modules/omk-protocol": {
|
|
1333
|
-
"version": "0.
|
|
1334
|
-
"resolved": "https://registry.npmjs.org/omk-protocol/-/omk-protocol-0.
|
|
1333
|
+
"version": "0.98.0",
|
|
1334
|
+
"resolved": "https://registry.npmjs.org/omk-protocol/-/omk-protocol-0.98.0.tgz",
|
|
1335
1335
|
"license": "MIT",
|
|
1336
1336
|
"engines": {
|
|
1337
1337
|
"node": ">=22.19.0"
|
|
1338
1338
|
}
|
|
1339
1339
|
},
|
|
1340
1340
|
"node_modules/omk-tui": {
|
|
1341
|
-
"version": "0.
|
|
1342
|
-
"resolved": "https://registry.npmjs.org/omk-tui/-/omk-tui-0.
|
|
1341
|
+
"version": "0.98.0",
|
|
1342
|
+
"resolved": "https://registry.npmjs.org/omk-tui/-/omk-tui-0.98.0.tgz",
|
|
1343
1343
|
"license": "MIT",
|
|
1344
1344
|
"dependencies": {
|
|
1345
1345
|
"get-east-asian-width": "1.6.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-multi-agent-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"description": "OMK (Open Multi-Agent Kit) coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"omkConfig": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"clean": "shx rm -rf dist",
|
|
35
|
-
"build": "node ./scripts/link-workspace-deps.mjs && tsgo -p tsconfig.build.json && shx chmod +x dist/cli.js && npm run copy-assets",
|
|
35
|
+
"build": "node ./scripts/link-workspace-deps.mjs && tsgo -p tsconfig.build.json && node ../../scripts/prune-dist-orphans.mjs . && shx chmod +x dist/cli.js && npm run copy-assets",
|
|
36
36
|
"build:binary": "npm --prefix ../tui run build && npm --prefix ../ai run build && npm --prefix ../agent run build && npm run build && bun build --compile ./dist/bun/cli.js ./src/utils/image-resize-worker.ts --outfile dist/omk && npm run copy-binary-assets",
|
|
37
37
|
"copy-assets": "shx mkdir -p dist/modes/interactive/theme && shx cp src/modes/interactive/theme/*.json dist/modes/interactive/theme/ && shx mkdir -p dist/modes/interactive/assets && shx cp src/modes/interactive/assets/*.png dist/modes/interactive/assets/ && shx mkdir -p dist/core/export-html/vendor && shx cp src/core/export-html/template.html src/core/export-html/template.css src/core/export-html/template.js dist/core/export-html/ && shx cp src/core/export-html/vendor/*.js dist/core/export-html/vendor/",
|
|
38
38
|
"copy-binary-assets": "shx cp package.json dist/ && shx cp README.md dist/ && shx cp CHANGELOG.md dist/ && shx mkdir -p dist/theme && shx cp src/modes/interactive/theme/*.json dist/theme/ && shx mkdir -p dist/assets && shx cp src/modes/interactive/assets/*.png dist/assets/ && shx mkdir -p dist/export-html/vendor && shx cp src/core/export-html/template.html dist/export-html/ && shx cp src/core/export-html/vendor/*.js dist/export-html/vendor/ && shx cp -r docs dist/ && shx cp -r examples dist/ && shx cp ../../node_modules/@silvia-odwyer/photon-node/photon_rs_bg.wasm dist/",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"link-workspace-deps": "node ./scripts/link-workspace-deps.mjs"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"omk-agent-core": "^0.
|
|
46
|
-
"omk-ai": "^0.
|
|
47
|
-
"omk-tui": "^0.
|
|
45
|
+
"omk-agent-core": "^0.98.0",
|
|
46
|
+
"omk-ai": "^0.98.0",
|
|
47
|
+
"omk-tui": "^0.98.0",
|
|
48
48
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
49
49
|
"canonicalize": "4.0.0",
|
|
50
50
|
"chalk": "5.6.2",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"typebox": "1.3.11",
|
|
61
61
|
"undici": "8.10.0",
|
|
62
62
|
"yaml": "2.9.0",
|
|
63
|
-
"omk-adaptorch-wpl": "^0.
|
|
64
|
-
"omk-protocol": "^0.
|
|
63
|
+
"omk-adaptorch-wpl": "^0.98.0",
|
|
64
|
+
"omk-protocol": "^0.98.0"
|
|
65
65
|
},
|
|
66
66
|
"overrides": {
|
|
67
67
|
"rimraf": "6.1.2",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { type TokenCounterAdapter } from "./context-budget-token-counter.ts";
|
|
2
|
-
export type ContextBudgetItemKind = "system" | "context-pointer" | "context-full" | "skill-header" | "skill" | "mcp" | "history" | "tool-result" | "subagent-evidence" | "budget-note";
|
|
3
|
-
export type ContextBudgetPriority = "hard" | "high" | "medium" | "low";
|
|
4
|
-
export type ContextBudgetDiagnosticReason = "hard_pin_over_capacity" | "item_omitted" | "invalid_budget";
|
|
5
|
-
export interface ContextBudgetItem {
|
|
6
|
-
readonly id: string;
|
|
7
|
-
readonly kind: ContextBudgetItemKind;
|
|
8
|
-
readonly text: string;
|
|
9
|
-
readonly priority: ContextBudgetPriority;
|
|
10
|
-
readonly tokenEstimate?: number;
|
|
11
|
-
readonly relevance?: number;
|
|
12
|
-
readonly recency?: number;
|
|
13
|
-
readonly evidenceValue?: number;
|
|
14
|
-
readonly redundancyKey?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface ContextBudgetGovernorInput {
|
|
17
|
-
readonly maxTokens: number;
|
|
18
|
-
readonly responseReserveTokens?: number;
|
|
19
|
-
readonly modelId?: string;
|
|
20
|
-
readonly policyVersion?: string;
|
|
21
|
-
readonly items: readonly ContextBudgetItem[];
|
|
22
|
-
readonly tokenCounter?: TokenCounterAdapter;
|
|
23
|
-
}
|
|
24
|
-
export interface ContextBudgetPlannedItem extends ContextBudgetItem {
|
|
25
|
-
readonly estimatedTokens: number;
|
|
26
|
-
readonly score: number;
|
|
27
|
-
}
|
|
28
|
-
export interface ContextBudgetDiagnostic {
|
|
29
|
-
readonly reason: ContextBudgetDiagnosticReason;
|
|
30
|
-
readonly itemId?: string;
|
|
31
|
-
readonly detail: string;
|
|
32
|
-
}
|
|
33
|
-
export interface ContextBudgetObservabilityCounts {
|
|
34
|
-
readonly selected: number;
|
|
35
|
-
readonly omitted: number;
|
|
36
|
-
}
|
|
37
|
-
export interface ContextBudgetObservabilityTokens {
|
|
38
|
-
readonly available: number;
|
|
39
|
-
readonly used: number;
|
|
40
|
-
readonly omitted: number;
|
|
41
|
-
readonly tokenSavings: number;
|
|
42
|
-
}
|
|
43
|
-
export interface ContextBudgetObservability {
|
|
44
|
-
readonly counts: ContextBudgetObservabilityCounts;
|
|
45
|
-
readonly diagnosticReasons: readonly ContextBudgetDiagnosticReason[];
|
|
46
|
-
readonly tokens: ContextBudgetObservabilityTokens;
|
|
47
|
-
readonly planHash: string;
|
|
48
|
-
}
|
|
49
|
-
export interface ContextBudgetPlan {
|
|
50
|
-
readonly policyVersion: string;
|
|
51
|
-
readonly maxTokens: number;
|
|
52
|
-
readonly responseReserveTokens: number;
|
|
53
|
-
readonly availableTokens: number;
|
|
54
|
-
readonly usedTokens: number;
|
|
55
|
-
readonly omittedTokens: number;
|
|
56
|
-
readonly emergency: boolean;
|
|
57
|
-
readonly omittedHighPriority: boolean;
|
|
58
|
-
readonly includedItems: readonly ContextBudgetPlannedItem[];
|
|
59
|
-
readonly omittedItems: readonly ContextBudgetPlannedItem[];
|
|
60
|
-
readonly diagnostics: readonly ContextBudgetDiagnostic[];
|
|
61
|
-
readonly planHash: string;
|
|
62
|
-
readonly observability: ContextBudgetObservability;
|
|
63
|
-
}
|
|
64
|
-
export declare const CONTEXT_BUDGET_POLICY_VERSION = "context-budget-v1";
|
|
65
|
-
export declare function planContextBudget(input: ContextBudgetGovernorInput): ContextBudgetPlan;
|
|
66
|
-
export declare function scoreContextBudgetItem(item: ContextBudgetItem, estimatedTokens: number): number;
|
|
67
|
-
//# sourceMappingURL=context-budget-governor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-budget-governor.d.ts","sourceRoot":"","sources":["../../src/core/context-budget-governor.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAEzG,MAAM,MAAM,qBAAqB,GAC9B,QAAQ,GACR,iBAAiB,GACjB,cAAc,GACd,cAAc,GACd,OAAO,GACP,KAAK,GACL,SAAS,GACT,aAAa,GACb,mBAAmB,GACnB,aAAa,CAAC;AAEjB,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AACvE,MAAM,MAAM,6BAA6B,GAAG,wBAAwB,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAEzG,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,mBAAmB,CAAC;CAC5C;AAED,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB;IAClE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,MAAM,EAAE,6BAA6B,CAAC;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,gCAAgC;IAChD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gCAAgC;IAChD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,MAAM,EAAE,gCAAgC,CAAC;IAClD,QAAQ,CAAC,iBAAiB,EAAE,SAAS,6BAA6B,EAAE,CAAC;IACrE,QAAQ,CAAC,MAAM,EAAE,gCAAgC,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,aAAa,EAAE,SAAS,wBAAwB,EAAE,CAAC;IAC5D,QAAQ,CAAC,YAAY,EAAE,SAAS,wBAAwB,EAAE,CAAC;IAC3D,QAAQ,CAAC,WAAW,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACzD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,0BAA0B,CAAC;CACnD;AAED,eAAO,MAAM,6BAA6B,sBAAsB,CAAC;AAEjE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,0BAA0B,GAAG,iBAAiB,CAqGtF;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAU/F","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { createFallbackTokenCounter, type TokenCounterAdapter } from \"./context-budget-token-counter.ts\";\n\nexport type ContextBudgetItemKind =\n\t| \"system\"\n\t| \"context-pointer\"\n\t| \"context-full\"\n\t| \"skill-header\"\n\t| \"skill\"\n\t| \"mcp\"\n\t| \"history\"\n\t| \"tool-result\"\n\t| \"subagent-evidence\"\n\t| \"budget-note\";\n\nexport type ContextBudgetPriority = \"hard\" | \"high\" | \"medium\" | \"low\";\nexport type ContextBudgetDiagnosticReason = \"hard_pin_over_capacity\" | \"item_omitted\" | \"invalid_budget\";\n\nexport interface ContextBudgetItem {\n\treadonly id: string;\n\treadonly kind: ContextBudgetItemKind;\n\treadonly text: string;\n\treadonly priority: ContextBudgetPriority;\n\treadonly tokenEstimate?: number;\n\treadonly relevance?: number;\n\treadonly recency?: number;\n\treadonly evidenceValue?: number;\n\treadonly redundancyKey?: string;\n}\n\nexport interface ContextBudgetGovernorInput {\n\treadonly maxTokens: number;\n\treadonly responseReserveTokens?: number;\n\treadonly modelId?: string;\n\treadonly policyVersion?: string;\n\treadonly items: readonly ContextBudgetItem[];\n\treadonly tokenCounter?: TokenCounterAdapter;\n}\n\nexport interface ContextBudgetPlannedItem extends ContextBudgetItem {\n\treadonly estimatedTokens: number;\n\treadonly score: number;\n}\n\nexport interface ContextBudgetDiagnostic {\n\treadonly reason: ContextBudgetDiagnosticReason;\n\treadonly itemId?: string;\n\treadonly detail: string;\n}\n\nexport interface ContextBudgetObservabilityCounts {\n\treadonly selected: number;\n\treadonly omitted: number;\n}\n\nexport interface ContextBudgetObservabilityTokens {\n\treadonly available: number;\n\treadonly used: number;\n\treadonly omitted: number;\n\treadonly tokenSavings: number;\n}\n\nexport interface ContextBudgetObservability {\n\treadonly counts: ContextBudgetObservabilityCounts;\n\treadonly diagnosticReasons: readonly ContextBudgetDiagnosticReason[];\n\treadonly tokens: ContextBudgetObservabilityTokens;\n\treadonly planHash: string;\n}\n\nexport interface ContextBudgetPlan {\n\treadonly policyVersion: string;\n\treadonly maxTokens: number;\n\treadonly responseReserveTokens: number;\n\treadonly availableTokens: number;\n\treadonly usedTokens: number;\n\treadonly omittedTokens: number;\n\treadonly emergency: boolean;\n\treadonly omittedHighPriority: boolean;\n\treadonly includedItems: readonly ContextBudgetPlannedItem[];\n\treadonly omittedItems: readonly ContextBudgetPlannedItem[];\n\treadonly diagnostics: readonly ContextBudgetDiagnostic[];\n\treadonly planHash: string;\n\treadonly observability: ContextBudgetObservability;\n}\n\nexport const CONTEXT_BUDGET_POLICY_VERSION = \"context-budget-v1\";\n\nexport function planContextBudget(input: ContextBudgetGovernorInput): ContextBudgetPlan {\n\tconst tokenCounter = input.tokenCounter ?? createFallbackTokenCounter();\n\tconst modelId = input.modelId ?? \"unknown\";\n\tconst diagnostics: ContextBudgetDiagnostic[] = [];\n\tconst maxTokens = normalizeBudgetTokens(\"maxTokens\", input.maxTokens, diagnostics);\n\tconst responseReserveTokens = normalizeBudgetTokens(\n\t\t\"responseReserveTokens\",\n\t\tinput.responseReserveTokens ?? 0,\n\t\tdiagnostics,\n\t);\n\tconst availableTokens = Math.max(0, maxTokens - responseReserveTokens);\n\tconst plannedItems = input.items.map((item) => planItem(item, tokenCounter, modelId, diagnostics));\n\tconst includedIds = new Set<string>();\n\tlet usedTokens = 0;\n\n\tfor (const item of plannedItems) {\n\t\tif (item.priority !== \"hard\") {\n\t\t\tcontinue;\n\t\t}\n\t\tincludedIds.add(item.id);\n\t\tusedTokens += item.estimatedTokens;\n\t}\n\n\tif (usedTokens > availableTokens) {\n\t\tdiagnostics.push({\n\t\t\treason: \"hard_pin_over_capacity\",\n\t\t\tdetail: `hard-pinned context uses ${usedTokens} tokens against ${availableTokens} available tokens`,\n\t\t});\n\t}\n\n\tconst selectedRedundancyKeys = new Set<string>();\n\tconst remainingOptionalItems = plannedItems.filter((item) => item.priority !== \"hard\");\n\n\twhile (remainingOptionalItems.length > 0) {\n\t\tconst rankedItems = remainingOptionalItems\n\t\t\t.map((item) => applyRedundancyPenalty(item, selectedRedundancyKeys))\n\t\t\t.sort(comparePlannedItemsForSelection);\n\t\tconst selected = rankedItems.find((item) => usedTokens + item.estimatedTokens <= availableTokens);\n\t\tif (!selected) {\n\t\t\tbreak;\n\t\t}\n\n\t\tincludedIds.add(selected.id);\n\t\tusedTokens += selected.estimatedTokens;\n\t\tif (selected.redundancyKey) {\n\t\t\tselectedRedundancyKeys.add(selected.redundancyKey);\n\t\t}\n\n\t\tconst selectedIndex = remainingOptionalItems.findIndex((item) => item.id === selected.id);\n\t\tremainingOptionalItems.splice(selectedIndex, 1);\n\t}\n\n\tconst includedItems = plannedItems.filter((item) => includedIds.has(item.id));\n\tconst omittedItems = plannedItems.filter((item) => !includedIds.has(item.id));\n\tfor (const item of omittedItems) {\n\t\tdiagnostics.push({ reason: \"item_omitted\", itemId: item.id, detail: `${item.kind} omitted from context budget` });\n\t}\n\tconst omittedTokens = omittedItems.reduce((sum, item) => sum + item.estimatedTokens, 0);\n\tconst omittedHighPriority = omittedItems.some((item) => item.priority === \"high\");\n\tconst emergency =\n\t\tusedTokens > availableTokens || diagnostics.some((diagnostic) => diagnostic.reason === \"invalid_budget\");\n\tconst policyVersion = input.policyVersion ?? CONTEXT_BUDGET_POLICY_VERSION;\n\n\tconst planWithoutHash = {\n\t\tpolicyVersion,\n\t\tmaxTokens,\n\t\tresponseReserveTokens,\n\t\tavailableTokens,\n\t\tusedTokens,\n\t\tomittedTokens,\n\t\temergency,\n\t\tomittedHighPriority,\n\t\tincluded: includedItems.map((item) => [item.id, item.estimatedTokens, item.score]),\n\t\tomitted: omittedItems.map((item) => [item.id, item.estimatedTokens, item.score]),\n\t};\n\tconst planHash = createHash(\"sha256\").update(JSON.stringify(planWithoutHash), \"utf8\").digest(\"hex\");\n\tconst observability = buildObservability({\n\t\tavailableTokens,\n\t\tdiagnostics,\n\t\tincludedItems,\n\t\tomittedItems,\n\t\tomittedTokens,\n\t\tplanHash,\n\t\tusedTokens,\n\t});\n\n\treturn {\n\t\tpolicyVersion,\n\t\tmaxTokens,\n\t\tresponseReserveTokens,\n\t\tavailableTokens,\n\t\tusedTokens,\n\t\tomittedTokens,\n\t\temergency,\n\t\tomittedHighPriority,\n\t\tincludedItems,\n\t\tomittedItems,\n\t\tdiagnostics,\n\t\tplanHash,\n\t\tobservability,\n\t};\n}\n\nexport function scoreContextBudgetItem(item: ContextBudgetItem, estimatedTokens: number): number {\n\tconst priorityScore = priorityWeight(item.priority);\n\tconst relevance = clampScore(item.relevance) * 20;\n\tconst recency = clampScore(item.recency) * 10;\n\tconst evidence = clampScore(item.evidenceValue) * 15;\n\t// G1: costPenalty 비례화 — sqrt 기반으로 대항목에 더 큰 불이익 부여.\n\t// log2(t)*2는 1000토큰에서 ~19.9점으로 relevance(20점)와 동급 → 대항목 생존.\n\t// sqrt(t)*0.5는 1000토큰 15.8점, 5000토큰 35.4점, 10000토큰 50점 → 비례적 증가.\n\tconst costPenalty = Math.sqrt(normalizeTokenCount(estimatedTokens)) * 0.5;\n\treturn priorityScore + relevance + recency + evidence - costPenalty;\n}\n\nfunction planItem(\n\titem: ContextBudgetItem,\n\ttokenCounter: TokenCounterAdapter,\n\tmodelId: string,\n\tdiagnostics: ContextBudgetDiagnostic[],\n): ContextBudgetPlannedItem {\n\tconst rawEstimate = item.tokenEstimate ?? tokenCounter.countText(item.text, modelId).tokens;\n\tconst estimatedTokens = normalizeItemTokenEstimate(item.id, rawEstimate, diagnostics);\n\treturn {\n\t\t...item,\n\t\testimatedTokens,\n\t\tscore: item.priority === \"hard\" ? Number.POSITIVE_INFINITY : scoreContextBudgetItem(item, estimatedTokens),\n\t};\n}\n\nconst REDUNDANCY_PENALTY_FLOOR = 10;\nconst REDUNDANCY_PENALTY_SCALE = 0.8;\n\n/**\n * W4: Adaptive redundancy penalty — proportional to token count.\n * Large duplicates waste more budget so deserve higher penalty.\n * Formula: max(floor, sqrt(tokens) * scale)\n * - 200 tokens → 11.3 (near floor — minimal waste)\n * - 1000 tokens → 25.3 (moderate waste)\n * - 5000 tokens → 56.6 (heavy waste — strongly penalized)\n * Floor ensures small duplicates are still penalized meaningfully.\n * Scale (0.8) tuned to score medium=50 so large duplicates go negative.\n */\nfunction redundancyPenalty(estimatedTokens: number): number {\n\treturn Math.max(REDUNDANCY_PENALTY_FLOOR, Math.sqrt(estimatedTokens) * REDUNDANCY_PENALTY_SCALE);\n}\n\nfunction applyRedundancyPenalty(\n\titem: ContextBudgetPlannedItem,\n\tselectedRedundancyKeys: Set<string>,\n): ContextBudgetPlannedItem {\n\tif (!item.redundancyKey || !selectedRedundancyKeys.has(item.redundancyKey)) {\n\t\treturn item;\n\t}\n\treturn { ...item, score: item.score - redundancyPenalty(item.estimatedTokens) };\n}\n\nfunction comparePlannedItemsForSelection(a: ContextBudgetPlannedItem, b: ContextBudgetPlannedItem): number {\n\t// G2: 우선순위 티어 내부에서 밀도(score/tokens) 기반 정렬.\n\t// 단위 토큰당 가치가 높은 항목을 우선 선택 → 예산 활용률 극대화.\n\tconst aTier = priorityTier(a.priority);\n\tconst bTier = priorityTier(b.priority);\n\tif (aTier !== bTier) {\n\t\treturn aTier - bTier;\n\t}\n\tconst aDensity = a.score > 0 ? a.score / Math.max(a.estimatedTokens, 1) : 0;\n\tconst bDensity = b.score > 0 ? b.score / Math.max(b.estimatedTokens, 1) : 0;\n\tif (aDensity !== bDensity) {\n\t\treturn bDensity - aDensity;\n\t}\n\tif (a.estimatedTokens !== b.estimatedTokens) {\n\t\treturn a.estimatedTokens - b.estimatedTokens;\n\t}\n\treturn a.id.localeCompare(b.id);\n}\n\nfunction priorityTier(priority: ContextBudgetPriority): number {\n\tswitch (priority) {\n\t\tcase \"hard\":\n\t\t\treturn 0;\n\t\tcase \"high\":\n\t\t\treturn 1;\n\t\tcase \"medium\":\n\t\t\treturn 2;\n\t\tcase \"low\":\n\t\t\treturn 3;\n\t}\n}\n\nfunction priorityWeight(priority: ContextBudgetPriority): number {\n\tswitch (priority) {\n\t\tcase \"hard\":\n\t\t\treturn 1_000_000;\n\t\tcase \"high\":\n\t\t\treturn 100;\n\t\tcase \"medium\":\n\t\t\treturn 50;\n\t\tcase \"low\":\n\t\t\treturn 10;\n\t}\n}\n\nfunction clampScore(value: number | undefined): number {\n\tif (value === undefined || !Number.isFinite(value)) {\n\t\treturn 0;\n\t}\n\treturn Math.max(0, Math.min(1, value));\n}\n\nfunction normalizeBudgetTokens(\n\tfield: \"maxTokens\" | \"responseReserveTokens\",\n\tvalue: number,\n\tdiagnostics: ContextBudgetDiagnostic[],\n): number {\n\tif (!Number.isFinite(value) || value < 0) {\n\t\tdiagnostics.push({\n\t\t\treason: \"invalid_budget\",\n\t\t\tdetail: `${field} must be a non-negative finite number, got ${value}`,\n\t\t});\n\t\treturn 0;\n\t}\n\treturn Math.floor(value);\n}\n\nfunction normalizeItemTokenEstimate(itemId: string, value: number, diagnostics: ContextBudgetDiagnostic[]): number {\n\tif (!Number.isFinite(value) || value < 0) {\n\t\tdiagnostics.push({\n\t\t\treason: \"invalid_budget\",\n\t\t\titemId,\n\t\t\tdetail: `tokenEstimate must be a non-negative finite number, got ${value}`,\n\t\t});\n\t\treturn 0;\n\t}\n\treturn Math.ceil(value);\n}\n\nfunction normalizeTokenCount(value: number): number {\n\tif (!Number.isFinite(value) || value < 0) {\n\t\treturn 0;\n\t}\n\treturn value;\n}\n\nfunction buildObservability(input: {\n\treadonly availableTokens: number;\n\treadonly diagnostics: readonly ContextBudgetDiagnostic[];\n\treadonly includedItems: readonly ContextBudgetPlannedItem[];\n\treadonly omittedItems: readonly ContextBudgetPlannedItem[];\n\treadonly omittedTokens: number;\n\treadonly planHash: string;\n\treadonly usedTokens: number;\n}): ContextBudgetObservability {\n\treturn {\n\t\tcounts: {\n\t\t\tselected: input.includedItems.length,\n\t\t\tomitted: input.omittedItems.length,\n\t\t},\n\t\tdiagnosticReasons: [...new Set(input.diagnostics.map((diagnostic) => diagnostic.reason))].sort(),\n\t\ttokens: {\n\t\t\tavailable: input.availableTokens,\n\t\t\tused: input.usedTokens,\n\t\t\tomitted: input.omittedTokens,\n\t\t\ttokenSavings: input.omittedTokens,\n\t\t},\n\t\tplanHash: input.planHash,\n\t};\n}\n"]}
|