open-multi-agent-kit 0.99.0 → 1.2.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 +30 -1
- package/README.md +3 -3
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +1 -0
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/register-bundled-coding-agent.d.ts +10 -0
- package/dist/bun/register-bundled-coding-agent.d.ts.map +1 -0
- package/dist/bun/register-bundled-coding-agent.js +12 -0
- package/dist/bun/register-bundled-coding-agent.js.map +1 -0
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +2 -1
- package/dist/cli/help.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +14 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/neo-cli.d.ts +9 -0
- package/dist/commands/neo-cli.d.ts.map +1 -0
- package/dist/commands/neo-cli.js +61 -0
- package/dist/commands/neo-cli.js.map +1 -0
- package/dist/coordination/awareness.d.ts +32 -0
- package/dist/coordination/awareness.d.ts.map +1 -0
- package/dist/coordination/awareness.js +55 -0
- package/dist/coordination/awareness.js.map +1 -0
- package/dist/coordination/broker.d.ts +79 -0
- package/dist/coordination/broker.d.ts.map +1 -0
- package/dist/coordination/broker.js +195 -0
- package/dist/coordination/broker.js.map +1 -0
- package/dist/coordination/index.d.ts +16 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +16 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/coordination/integration.d.ts +59 -0
- package/dist/coordination/integration.d.ts.map +1 -0
- package/dist/coordination/integration.js +126 -0
- package/dist/coordination/integration.js.map +1 -0
- package/dist/coordination/operation.d.ts +106 -0
- package/dist/coordination/operation.d.ts.map +1 -0
- package/dist/coordination/operation.js +179 -0
- package/dist/coordination/operation.js.map +1 -0
- package/dist/coordination/resource.d.ts +33 -0
- package/dist/coordination/resource.d.ts.map +1 -0
- package/dist/coordination/resource.js +89 -0
- package/dist/coordination/resource.js.map +1 -0
- package/dist/coordination/session.d.ts +74 -0
- package/dist/coordination/session.d.ts.map +1 -0
- package/dist/coordination/session.js +143 -0
- package/dist/coordination/session.js.map +1 -0
- package/dist/coordination/types.d.ts +68 -0
- package/dist/coordination/types.d.ts.map +1 -0
- package/dist/coordination/types.js +26 -0
- package/dist/coordination/types.js.map +1 -0
- package/dist/core/agent-session.d.ts +29 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +135 -37
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bundled-skills.d.ts +4 -0
- package/dist/core/bundled-skills.d.ts.map +1 -0
- package/dist/core/bundled-skills.js +32 -0
- package/dist/core/bundled-skills.js.map +1 -0
- package/dist/core/cli-diagnostics.d.ts +6 -0
- package/dist/core/cli-diagnostics.d.ts.map +1 -0
- package/dist/core/cli-diagnostics.js +20 -0
- package/dist/core/cli-diagnostics.js.map +1 -0
- package/dist/core/compaction/control-state.d.ts +41 -0
- package/dist/core/compaction/control-state.d.ts.map +1 -0
- package/dist/core/compaction/control-state.js +85 -0
- package/dist/core/compaction/control-state.js.map +1 -0
- package/dist/core/compaction/fallback.d.ts +60 -0
- package/dist/core/compaction/fallback.d.ts.map +1 -0
- package/dist/core/compaction/fallback.js +117 -0
- package/dist/core/compaction/fallback.js.map +1 -0
- package/dist/core/compaction/index.d.ts +2 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +2 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/context-budget-headroom-candidates.d.ts +16 -1
- package/dist/core/context-budget-headroom-candidates.d.ts.map +1 -1
- package/dist/core/context-budget-headroom-candidates.js +31 -13
- package/dist/core/context-budget-headroom-candidates.js.map +1 -1
- package/dist/core/context-budget-headroom-types.d.ts +7 -1
- package/dist/core/context-budget-headroom-types.d.ts.map +1 -1
- package/dist/core/context-budget-headroom-types.js +0 -1
- package/dist/core/context-budget-headroom-types.js.map +1 -1
- package/dist/core/context-budget-headroom.d.ts +22 -0
- package/dist/core/context-budget-headroom.d.ts.map +1 -1
- package/dist/core/context-budget-headroom.js +46 -2
- package/dist/core/context-budget-headroom.js.map +1 -1
- package/dist/core/context-budget-v2-global-pass.d.ts +21 -0
- package/dist/core/context-budget-v2-global-pass.d.ts.map +1 -0
- package/dist/core/context-budget-v2-global-pass.js +203 -0
- package/dist/core/context-budget-v2-global-pass.js.map +1 -0
- package/dist/core/context-budget-v2-input-validation.d.ts +4 -0
- package/dist/core/context-budget-v2-input-validation.d.ts.map +1 -0
- package/dist/core/context-budget-v2-input-validation.js +79 -0
- package/dist/core/context-budget-v2-input-validation.js.map +1 -0
- package/dist/core/context-budget-v2-observability.d.ts +15 -0
- package/dist/core/context-budget-v2-observability.d.ts.map +1 -0
- package/dist/core/context-budget-v2-observability.js +35 -0
- package/dist/core/context-budget-v2-observability.js.map +1 -0
- package/dist/core/context-budget-v2-planned-items.d.ts +17 -0
- package/dist/core/context-budget-v2-planned-items.d.ts.map +1 -0
- package/dist/core/context-budget-v2-planned-items.js +59 -0
- package/dist/core/context-budget-v2-planned-items.js.map +1 -0
- package/dist/core/context-budget-v2-planner.d.ts.map +1 -1
- package/dist/core/context-budget-v2-planner.js +69 -51
- package/dist/core/context-budget-v2-planner.js.map +1 -1
- package/dist/core/context-budget-v2-scoring.d.ts +7 -1
- package/dist/core/context-budget-v2-scoring.d.ts.map +1 -1
- package/dist/core/context-budget-v2-scoring.js.map +1 -1
- package/dist/core/context-budget-v2-selection.d.ts +22 -3
- package/dist/core/context-budget-v2-selection.d.ts.map +1 -1
- package/dist/core/context-budget-v2-selection.js +41 -59
- package/dist/core/context-budget-v2-selection.js.map +1 -1
- package/dist/core/context-budget-v2-tiers.d.ts.map +1 -1
- package/dist/core/context-budget-v2-tiers.js +9 -42
- package/dist/core/context-budget-v2-tiers.js.map +1 -1
- package/dist/core/context-budget-v2-types.d.ts +14 -2
- package/dist/core/context-budget-v2-types.d.ts.map +1 -1
- package/dist/core/context-budget-v2-types.js +6 -1
- package/dist/core/context-budget-v2-types.js.map +1 -1
- package/dist/core/extensions/bundled-virtual-modules.d.ts +15 -0
- package/dist/core/extensions/bundled-virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/bundled-virtual-modules.js +63 -0
- package/dist/core/extensions/bundled-virtual-modules.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +2 -42
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +6 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +10 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/loadout-runtime.d.ts +2 -8
- package/dist/core/loadout-runtime.d.ts.map +1 -1
- package/dist/core/loadout-runtime.js.map +1 -1
- package/dist/core/mcp/client.d.ts +27 -6
- package/dist/core/mcp/client.d.ts.map +1 -1
- package/dist/core/mcp/client.js +80 -20
- package/dist/core/mcp/client.js.map +1 -1
- package/dist/core/mcp/manager.d.ts +10 -1
- package/dist/core/mcp/manager.d.ts.map +1 -1
- package/dist/core/mcp/manager.js +68 -9
- package/dist/core/mcp/manager.js.map +1 -1
- package/dist/core/mcp/protocol.d.ts +9 -3
- package/dist/core/mcp/protocol.d.ts.map +1 -1
- package/dist/core/mcp/protocol.js +61 -15
- package/dist/core/mcp/protocol.js.map +1 -1
- package/dist/core/mcp/stdio-transport.d.ts +12 -1
- package/dist/core/mcp/stdio-transport.d.ts.map +1 -1
- package/dist/core/mcp/stdio-transport.js +30 -2
- package/dist/core/mcp/stdio-transport.js.map +1 -1
- package/dist/core/mcp-descriptor-injection.d.ts +26 -0
- package/dist/core/mcp-descriptor-injection.d.ts.map +1 -0
- package/dist/core/mcp-descriptor-injection.js +25 -0
- package/dist/core/mcp-descriptor-injection.js.map +1 -0
- package/dist/core/mcp-public-presets.d.ts +1 -3
- package/dist/core/mcp-public-presets.d.ts.map +1 -1
- package/dist/core/mcp-public-presets.js +3 -15
- package/dist/core/mcp-public-presets.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +24 -3
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/neo/catalog.d.ts +20 -0
- package/dist/core/neo/catalog.d.ts.map +1 -0
- package/dist/core/neo/catalog.js +50 -0
- package/dist/core/neo/catalog.js.map +1 -0
- package/dist/core/neo/setup.d.ts +3 -0
- package/dist/core/neo/setup.d.ts.map +1 -0
- package/dist/core/neo/setup.js +47 -0
- package/dist/core/neo/setup.js.map +1 -0
- package/dist/core/provider-default-models.d.ts +2 -0
- package/dist/core/provider-default-models.d.ts.map +1 -1
- package/dist/core/provider-default-models.js +2 -0
- package/dist/core/provider-default-models.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +2 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/provider-error-classification.d.ts +57 -0
- package/dist/core/provider-error-classification.d.ts.map +1 -0
- package/dist/core/provider-error-classification.js +103 -0
- package/dist/core/provider-error-classification.js.map +1 -0
- package/dist/core/provider-resilience.d.ts +10 -0
- package/dist/core/provider-resilience.d.ts.map +1 -1
- package/dist/core/provider-resilience.js +36 -3
- package/dist/core/provider-resilience.js.map +1 -1
- package/dist/core/provider-usage-commandcode.d.ts +9 -0
- package/dist/core/provider-usage-commandcode.d.ts.map +1 -0
- package/dist/core/provider-usage-commandcode.js +198 -0
- package/dist/core/provider-usage-commandcode.js.map +1 -0
- package/dist/core/provider-usage-devin.d.ts +5 -3
- package/dist/core/provider-usage-devin.d.ts.map +1 -1
- package/dist/core/provider-usage-devin.js +15 -5
- package/dist/core/provider-usage-devin.js.map +1 -1
- package/dist/core/provider-usage-types.d.ts +1 -1
- package/dist/core/provider-usage-types.d.ts.map +1 -1
- package/dist/core/provider-usage-types.js.map +1 -1
- package/dist/core/provider-usage.d.ts.map +1 -1
- package/dist/core/provider-usage.js +6 -0
- package/dist/core/provider-usage.js.map +1 -1
- package/dist/core/reasoning-router-resolver.d.ts +7 -0
- package/dist/core/reasoning-router-resolver.d.ts.map +1 -1
- package/dist/core/reasoning-router-resolver.js +21 -3
- package/dist/core/reasoning-router-resolver.js.map +1 -1
- package/dist/core/reasoning-router-v4.d.ts +8 -5
- package/dist/core/reasoning-router-v4.d.ts.map +1 -1
- package/dist/core/reasoning-router-v4.js +8 -5
- package/dist/core/reasoning-router-v4.js.map +1 -1
- package/dist/core/resource-admission.d.ts +36 -0
- package/dist/core/resource-admission.d.ts.map +1 -1
- package/dist/core/resource-admission.js +59 -0
- package/dist/core/resource-admission.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +2 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/run-usage-ledger.d.ts +47 -0
- package/dist/core/run-usage-ledger.d.ts.map +1 -0
- package/dist/core/run-usage-ledger.js +162 -0
- package/dist/core/run-usage-ledger.js.map +1 -0
- package/dist/core/run-usage-operation.d.ts +8 -0
- package/dist/core/run-usage-operation.d.ts.map +1 -0
- package/dist/core/run-usage-operation.js +12 -0
- package/dist/core/run-usage-operation.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-compaction-service.d.ts +15 -0
- package/dist/core/session-compaction-service.d.ts.map +1 -1
- package/dist/core/session-compaction-service.js +17 -4
- package/dist/core/session-compaction-service.js.map +1 -1
- package/dist/core/session-failure-cause.d.ts.map +1 -1
- package/dist/core/session-failure-cause.js +14 -5
- package/dist/core/session-failure-cause.js.map +1 -1
- package/dist/core/session-prompt-lifecycle.d.ts +6 -0
- package/dist/core/session-prompt-lifecycle.d.ts.map +1 -1
- package/dist/core/session-prompt-lifecycle.js +47 -2
- package/dist/core/session-prompt-lifecycle.js.map +1 -1
- package/dist/core/session-termination.d.ts.map +1 -1
- package/dist/core/session-termination.js +4 -2
- package/dist/core/session-termination.js.map +1 -1
- package/dist/core/subagent-lane-authority.d.ts +28 -0
- package/dist/core/subagent-lane-authority.d.ts.map +1 -0
- package/dist/core/subagent-lane-authority.js +119 -0
- package/dist/core/subagent-lane-authority.js.map +1 -0
- package/dist/core/subagent-lane-contract.d.ts +114 -0
- package/dist/core/subagent-lane-contract.d.ts.map +1 -0
- package/dist/core/subagent-lane-contract.js +18 -0
- package/dist/core/subagent-lane-contract.js.map +1 -0
- package/dist/core/subagent-lane-launcher.d.ts +3 -6
- package/dist/core/subagent-lane-launcher.d.ts.map +1 -1
- package/dist/core/subagent-lane-launcher.js +53 -12
- package/dist/core/subagent-lane-launcher.js.map +1 -1
- package/dist/core/subagent-orchestration.d.ts +4 -17
- package/dist/core/subagent-orchestration.d.ts.map +1 -1
- package/dist/core/subagent-orchestration.js.map +1 -1
- package/dist/core/todo-runtime-state.d.ts +12 -0
- package/dist/core/todo-runtime-state.d.ts.map +1 -1
- package/dist/core/todo-runtime-state.js +23 -0
- package/dist/core/todo-runtime-state.js.map +1 -1
- package/dist/core/verified-run/broker.d.ts.map +1 -1
- package/dist/core/verified-run/broker.js +4 -1
- package/dist/core/verified-run/broker.js.map +1 -1
- package/dist/core/workload-permit-pool.d.ts +1 -1
- package/dist/core/workload-permit-pool.d.ts.map +1 -1
- package/dist/core/workload-permit-pool.js +3 -0
- package/dist/core/workload-permit-pool.js.map +1 -1
- package/dist/guardrails/strict-evidence-approval-adapter.d.ts +34 -0
- package/dist/guardrails/strict-evidence-approval-adapter.d.ts.map +1 -0
- package/dist/guardrails/strict-evidence-approval-adapter.js +70 -0
- package/dist/guardrails/strict-evidence-approval-adapter.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +11 -18
- package/dist/main.js.map +1 -1
- package/dist/metacognition/calibration-selective.d.ts +78 -0
- package/dist/metacognition/calibration-selective.d.ts.map +1 -0
- package/dist/metacognition/calibration-selective.js +161 -0
- package/dist/metacognition/calibration-selective.js.map +1 -0
- package/dist/metacognition/calibration.d.ts +62 -0
- package/dist/metacognition/calibration.d.ts.map +1 -0
- package/dist/metacognition/calibration.js +122 -0
- package/dist/metacognition/calibration.js.map +1 -0
- package/dist/metacognition/checkpoint.d.ts +60 -0
- package/dist/metacognition/checkpoint.d.ts.map +1 -0
- package/dist/metacognition/checkpoint.js +57 -0
- package/dist/metacognition/checkpoint.js.map +1 -0
- package/dist/metacognition/context7.d.ts +48 -0
- package/dist/metacognition/context7.d.ts.map +1 -0
- package/dist/metacognition/context7.js +154 -0
- package/dist/metacognition/context7.js.map +1 -0
- package/dist/metacognition/decision.d.ts +44 -0
- package/dist/metacognition/decision.d.ts.map +1 -0
- package/dist/metacognition/decision.js +111 -0
- package/dist/metacognition/decision.js.map +1 -0
- package/dist/metacognition/evaluation.d.ts +73 -0
- package/dist/metacognition/evaluation.d.ts.map +1 -0
- package/dist/metacognition/evaluation.js +97 -0
- package/dist/metacognition/evaluation.js.map +1 -0
- package/dist/metacognition/index.d.ts +31 -0
- package/dist/metacognition/index.d.ts.map +1 -0
- package/dist/metacognition/index.js +31 -0
- package/dist/metacognition/index.js.map +1 -0
- package/dist/metacognition/knowledge-action.d.ts +43 -0
- package/dist/metacognition/knowledge-action.d.ts.map +1 -0
- package/dist/metacognition/knowledge-action.js +60 -0
- package/dist/metacognition/knowledge-action.js.map +1 -0
- package/dist/metacognition/knowledge.d.ts +84 -0
- package/dist/metacognition/knowledge.d.ts.map +1 -0
- package/dist/metacognition/knowledge.js +165 -0
- package/dist/metacognition/knowledge.js.map +1 -0
- package/dist/metacognition/obligations.d.ts +82 -0
- package/dist/metacognition/obligations.d.ts.map +1 -0
- package/dist/metacognition/obligations.js +139 -0
- package/dist/metacognition/obligations.js.map +1 -0
- package/dist/metacognition/observation-validity.d.ts +83 -0
- package/dist/metacognition/observation-validity.d.ts.map +1 -0
- package/dist/metacognition/observation-validity.js +118 -0
- package/dist/metacognition/observation-validity.js.map +1 -0
- package/dist/metacognition/observe.d.ts +45 -0
- package/dist/metacognition/observe.d.ts.map +1 -0
- package/dist/metacognition/observe.js +59 -0
- package/dist/metacognition/observe.js.map +1 -0
- package/dist/metacognition/policy.d.ts +53 -0
- package/dist/metacognition/policy.d.ts.map +1 -0
- package/dist/metacognition/policy.js +155 -0
- package/dist/metacognition/policy.js.map +1 -0
- package/dist/metacognition/predictions.d.ts +78 -0
- package/dist/metacognition/predictions.d.ts.map +1 -0
- package/dist/metacognition/predictions.js +181 -0
- package/dist/metacognition/predictions.js.map +1 -0
- package/dist/metacognition/retrieval.d.ts +53 -0
- package/dist/metacognition/retrieval.d.ts.map +1 -0
- package/dist/metacognition/retrieval.js +170 -0
- package/dist/metacognition/retrieval.js.map +1 -0
- package/dist/metacognition/risk.d.ts +48 -0
- package/dist/metacognition/risk.d.ts.map +1 -0
- package/dist/metacognition/risk.js +165 -0
- package/dist/metacognition/risk.js.map +1 -0
- package/dist/metacognition/route-economics.d.ts +95 -0
- package/dist/metacognition/route-economics.d.ts.map +1 -0
- package/dist/metacognition/route-economics.js +110 -0
- package/dist/metacognition/route-economics.js.map +1 -0
- package/dist/metacognition/runtime-bridge.d.ts +54 -0
- package/dist/metacognition/runtime-bridge.d.ts.map +1 -0
- package/dist/metacognition/runtime-bridge.js +140 -0
- package/dist/metacognition/runtime-bridge.js.map +1 -0
- package/dist/metacognition/skills.d.ts +42 -0
- package/dist/metacognition/skills.d.ts.map +1 -0
- package/dist/metacognition/skills.js +220 -0
- package/dist/metacognition/skills.js.map +1 -0
- package/dist/metacognition/state.d.ts +110 -0
- package/dist/metacognition/state.d.ts.map +1 -0
- package/dist/metacognition/state.js +52 -0
- package/dist/metacognition/state.js.map +1 -0
- package/dist/metacognition/validation.d.ts +19 -0
- package/dist/metacognition/validation.d.ts.map +1 -0
- package/dist/metacognition/validation.js +58 -0
- package/dist/metacognition/validation.js.map +1 -0
- package/dist/metacognition/verification.d.ts +93 -0
- package/dist/metacognition/verification.d.ts.map +1 -0
- package/dist/metacognition/verification.js +132 -0
- package/dist/metacognition/verification.js.map +1 -0
- package/dist/metacognition/verifier.d.ts +49 -0
- package/dist/metacognition/verifier.d.ts.map +1 -0
- package/dist/metacognition/verifier.js +88 -0
- package/dist/metacognition/verifier.js.map +1 -0
- package/dist/modes/acp/acp-agent.d.ts +24 -0
- package/dist/modes/acp/acp-agent.d.ts.map +1 -0
- package/dist/modes/acp/acp-agent.js +133 -0
- package/dist/modes/acp/acp-agent.js.map +1 -0
- package/dist/modes/acp/acp-mode.d.ts +4 -0
- package/dist/modes/acp/acp-mode.d.ts.map +1 -0
- package/dist/modes/acp/acp-mode.js +34 -0
- package/dist/modes/acp/acp-mode.js.map +1 -0
- package/dist/modes/acp/acp-session.d.ts +4 -0
- package/dist/modes/acp/acp-session.d.ts.map +1 -0
- package/dist/modes/acp/acp-session.js +76 -0
- package/dist/modes/acp/acp-session.js.map +1 -0
- package/dist/modes/acp/acp-transport.d.ts +5 -0
- package/dist/modes/acp/acp-transport.d.ts.map +1 -0
- package/dist/modes/acp/acp-transport.js +90 -0
- package/dist/modes/acp/acp-transport.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/observation/identity.d.ts +14 -0
- package/dist/observation/identity.d.ts.map +1 -0
- package/dist/observation/identity.js +29 -0
- package/dist/observation/identity.js.map +1 -0
- package/dist/observation/index.d.ts +13 -0
- package/dist/observation/index.d.ts.map +1 -0
- package/dist/observation/index.js +13 -0
- package/dist/observation/index.js.map +1 -0
- package/dist/observation/observe-mode.d.ts +46 -0
- package/dist/observation/observe-mode.d.ts.map +1 -0
- package/dist/observation/observe-mode.js +83 -0
- package/dist/observation/observe-mode.js.map +1 -0
- package/dist/observation/store.d.ts +53 -0
- package/dist/observation/store.d.ts.map +1 -0
- package/dist/observation/store.js +126 -0
- package/dist/observation/store.js.map +1 -0
- package/dist/observation/types.d.ts +72 -0
- package/dist/observation/types.d.ts.map +1 -0
- package/dist/observation/types.js +9 -0
- package/dist/observation/types.js.map +1 -0
- package/dist/observation/view.d.ts +39 -0
- package/dist/observation/view.d.ts.map +1 -0
- package/dist/observation/view.js +173 -0
- package/dist/observation/view.js.map +1 -0
- package/docs/audit-revalidation-2026-09-17.md +77 -0
- package/docs/devin-harness.md +33 -4
- package/docs/ecraf-normalization.md +83 -0
- package/docs/metacognition.md +51 -0
- package/docs/model-catalog-refresh.md +110 -1
- package/docs/models.md +1 -1
- package/docs/neo.md +134 -0
- package/docs/providers.md +125 -6
- package/docs/run-usage-ledger.md +56 -0
- package/docs/runtime-algorithms.md +151 -3
- package/docs/skills.md +1 -1
- package/docs/usage.md +2 -1
- 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/subagent/adaptive-agent-runtime.ts +14 -1
- package/examples/extensions/subagent/graph-result.ts +48 -0
- package/examples/extensions/subagent/index.ts +246 -111
- package/examples/extensions/subagent/managed-process-tree.ts +42 -0
- package/examples/extensions/subagent/managed-process.test.ts +24 -0
- package/examples/extensions/subagent/managed-process.ts +93 -112
- package/examples/extensions/subagent/subagent-runtime-types.ts +17 -1
- package/examples/extensions/subagent/subagent-stream.ts +161 -0
- package/examples/extensions/terminal-browser/README.md +54 -0
- package/examples/extensions/terminal-browser/bridge-protocol.ts +29 -0
- package/examples/extensions/terminal-browser/bridge.ts +219 -0
- package/examples/extensions/terminal-browser/browser-surface.ts +288 -0
- package/examples/extensions/terminal-browser/index.ts +215 -0
- package/examples/extensions/terminal-browser/placeholders.ts +49 -0
- 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 +8 -7
- package/resources/neo/skills/omk-browser/SKILL.md +32 -0
- package/resources/neo/skills/omk-code-review/SKILL.md +24 -0
- package/resources/neo/skills/omk-computeruse/SKILL.md +34 -0
- package/resources/neo/skills/omk-mcp-setup/SKILL.md +48 -0
- package/resources/neo/skills/omk-research/SKILL.md +24 -0
- package/resources/neo/skills/omk-site/SKILL.md +28 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/observation/view.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAA6B,eAAe,EAAuB,cAAc,EAAE,MAAM,YAAY,CAAC;AAOlH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,6EAA6E;AAC7E,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AASD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,QAAQ,EAAE,CAyB7F;AAwDD;;;;GAIG;AACH,wBAAgB,SAAS,CACxB,WAAW,EAAE,cAAc,EAC3B,eAAe,GAAE,SAAS,MAAM,EAAO,GACrC,SAAS,eAAe,EAAE,CAkC5B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,SAAS,eAAe,EAAE,EACjC,YAAY,EAAE,MAAM,EACpB,eAAe,GAAE,SAAS,MAAM,EAAO,GACrC,eAAe,GAAG,IAAI,CAqBxB","sourcesContent":["/**\n * Deterministic observation views with a coverage gate — U1/U3.\n *\n * A view is a projection of a stored raw observation, never a rewrite of it.\n * `chooseView` refuses any candidate that drops a required fact atom: a cheap\n * representation is admissible only if it preserves the decision-relevant\n * facts the current obligations need. `coverageStatus` is `unknown` when the\n * input carries no required fact set — never silently \"covered\".\n */\n\nimport { ensure, integer, text } from \"../metacognition/validation.ts\";\nimport { viewDigestOf } from \"./identity.ts\";\nimport type { ObservationCoverageStatus, ObservationView, ObservationViewKind, RawObservation } from \"./types.ts\";\n\nconst CHARS_PER_TOKEN = 4;\n/** Per-atom-class occurrence cap. Four classes stay well under any global bound. */\nconst MAX_FACTS_PER_ID = 32;\nconst MAX_VIEW_TEXT = 32_768;\n\nexport function estimateViewTokens(text: string): number {\n\treturn Math.max(1, Math.ceil(text.length / CHARS_PER_TOKEN));\n}\n\n/** A host-verifiable fact atom extracted from raw bytes, e.g. exitCode=1. */\nexport interface FactAtom {\n\treadonly id: string;\n\t/** The verbatim text that must appear in a view for the atom to count as covered. */\n\treadonly evidence: string;\n\treadonly byteOffset: number;\n\treadonly byteLength: number;\n}\n\nconst FACT_PATTERNS: readonly { readonly id: string; readonly re: RegExp }[] = [\n\t{ id: \"exit-code\", re: /exit code[:\\s]+(-?\\d+)|exitCode\\s*[=:]\\s*(-?\\d+)/i },\n\t{ id: \"test-failure\", re: /FAIL[:\\s]+([A-Za-z0-9_.\\-/]+)|✗\\s*([A-Za-z0-9_.\\-/]+)/ },\n\t{ id: \"permission-denied\", re: /permission[ _-]?denied|EACCES/i },\n\t{ id: \"error-marker\", re: /(?:error|errno|exception|traceback)[:\\s]/i },\n];\n\n/**\n * Extract host-verifiable fact atoms from raw bytes. `requiredFactIds` limits\n * extraction to the caller's obligation set; when omitted, all recognized\n * atoms are returned so a view can advertise what it preserves.\n */\nexport function extractFacts(raw: Uint8Array, requiredFactIds?: readonly string[]): FactAtom[] {\n\tconst decoded = new TextDecoder(\"utf-8\", { fatal: false }).decode(raw);\n\tconst encoder = new TextEncoder();\n\tconst wanted = requiredFactIds === undefined ? undefined : new Set(requiredFactIds);\n\tconst facts: FactAtom[] = [];\n\tfor (const { id, re } of FACT_PATTERNS) {\n\t\tif (wanted !== undefined && !wanted.has(id)) continue;\n\t\t// Per-id cap, not a shared running total: a log that repeats one atom\n\t\t// thousands of times must not starve a later pattern out of extraction\n\t\t// entirely, or a required atom silently disappears from every view.\n\t\tlet perId = 0;\n\t\tfor (const match of decoded.matchAll(new RegExp(re.source, re.flags.includes(\"g\") ? re.flags : `${re.flags}g`))) {\n\t\t\tif (perId >= MAX_FACTS_PER_ID) break;\n\t\t\tconst evidence = match[0];\n\t\t\tconst byteOffset = encoder.encode(decoded.slice(0, match.index ?? 0)).length;\n\t\t\tfacts.push({\n\t\t\t\tid,\n\t\t\t\tevidence,\n\t\t\t\tbyteOffset,\n\t\t\t\tbyteLength: encoder.encode(evidence).length,\n\t\t\t});\n\t\t\tperId += 1;\n\t\t}\n\t}\n\treturn facts;\n}\n\n/**\n * Collapse repeated identical atoms into one line that keeps the occurrence\n * count. Without this the evidence view of a log that repeats one failure is\n * larger than the raw text it was supposed to shrink, and the selector\n * correctly but uselessly falls back to full text.\n */\nfunction dedupeFacts(facts: readonly FactAtom[]): readonly { readonly fact: FactAtom; readonly count: number }[] {\n\tconst byKey = new Map<string, { fact: FactAtom; count: number }>();\n\tfor (const fact of facts) {\n\t\tconst key = `${fact.id}\\u0000${fact.evidence}`;\n\t\tconst existing = byKey.get(key);\n\t\tif (existing === undefined) byKey.set(key, { fact, count: 1 });\n\t\telse existing.count += 1;\n\t}\n\treturn [...byKey.values()];\n}\n\nfunction viewText(raw: Uint8Array, facts: readonly FactAtom[], kind: ObservationViewKind): string {\n\tconst decoded = new TextDecoder(\"utf-8\", { fatal: false }).decode(raw);\n\tswitch (kind) {\n\t\tcase \"full\":\n\t\t\treturn decoded;\n\t\tcase \"excerpt\": {\n\t\t\tif (decoded.length <= MAX_VIEW_TEXT) return decoded;\n\t\t\tconst head = decoded.slice(0, Math.floor(MAX_VIEW_TEXT / 2));\n\t\t\tconst tail = decoded.slice(-Math.floor(MAX_VIEW_TEXT / 2));\n\t\t\treturn `${head}\\n…[omitted ${decoded.length - MAX_VIEW_TEXT} chars]…\\n${tail}`;\n\t\t}\n\t\tcase \"evidence\":\n\t\t\treturn facts.length === 0\n\t\t\t\t? \"\"\n\t\t\t\t: dedupeFacts(facts)\n\t\t\t\t\t\t.map(({ fact, count }) =>\n\t\t\t\t\t\t\tcount === 1\n\t\t\t\t\t\t\t\t? `${fact.id} @${fact.byteOffset}: ${fact.evidence}`\n\t\t\t\t\t\t\t\t: `${fact.id} @${fact.byteOffset} \\u00d7${count}: ${fact.evidence}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join(\"\\n\")\n\t\t\t\t\t\t.slice(0, MAX_VIEW_TEXT);\n\t\tcase \"pointer\":\n\t\t\treturn `[observation ${raw.length} bytes; digest-bound; read via handle]`;\n\t}\n}\n\nfunction coverageFor(\n\tcovered: readonly string[],\n\trequired: readonly string[],\n): { status: ObservationCoverageStatus; missing: readonly string[] } {\n\tif (required.length === 0) return { status: \"unknown\", missing: [] };\n\tconst coveredSet = new Set(covered);\n\tconst missing = required.filter((id) => !coveredSet.has(id));\n\treturn { status: missing.length === 0 ? \"complete\" : \"partial\", missing };\n}\n\n/**\n * Build the candidate views for one observation. Every view records which\n * fact atoms it preserves and which required atoms it would drop, so the\n * selector can gate on coverage rather than token density alone.\n */\nexport function makeViews(\n\tobservation: RawObservation,\n\trequiredFactIds: readonly string[] = [],\n): readonly ObservationView[] {\n\ttext(observation.observationId, \"observationId\", 128);\n\tfor (const id of requiredFactIds) text(id, \"requiredFactId\", 256);\n\tconst facts = extractFacts(observation.bytes);\n\tconst coveredByKind: Record<ObservationViewKind, readonly string[]> = {\n\t\tfull: facts.map((f) => f.id),\n\t\texcerpt: facts.map((f) => f.id), // excerpt keeps head+tail; see note\n\t\tevidence: facts.map((f) => f.id),\n\t\tpointer: [],\n\t};\n\tconst kinds: readonly ObservationViewKind[] = [\"full\", \"excerpt\", \"evidence\", \"pointer\"];\n\treturn kinds.map((kind) => {\n\t\tconst body = viewText(observation.bytes, facts, kind);\n\t\tconst covered = coveredByKind[kind].filter(\n\t\t\t(id) => body.includes(id) || kind !== \"evidence\" || facts.some((f) => f.id === id),\n\t\t);\n\t\tconst { status, missing } = coverageFor(covered, requiredFactIds);\n\t\treturn Object.freeze({\n\t\t\tviewKind: kind,\n\t\t\tobservationId: observation.observationId,\n\t\t\tparentDigest: observation.rawDigest,\n\t\t\ttransformationDigest: viewDigestOf({\n\t\t\t\tobservationId: observation.observationId,\n\t\t\t\tviewKind: kind,\n\t\t\t\tparams: `req:${[...requiredFactIds].sort().join(\",\")}`,\n\t\t\t}),\n\t\t\ttext: body,\n\t\t\testimatedTokens: estimateViewTokens(body),\n\t\t\tcoveredFactIds: covered,\n\t\t\tmissingRequiredFactIds: missing,\n\t\t\tcoverageStatus: status,\n\t\t\ttaskVerdict: \"not-assessed\" as const,\n\t\t});\n\t});\n}\n\n/**\n * Coverage-gated deterministic selection: the smallest view that preserves\n * every required fact within budget. Returns null (infeasible) rather than\n * silently dropping a required atom — the caller must widen the budget or keep\n * the raw observation.\n */\nexport function chooseView(\n\tviews: readonly ObservationView[],\n\tbudgetTokens: number,\n\trequiredFactIds: readonly string[] = [],\n): ObservationView | null {\n\tinteger(budgetTokens, \"budgetTokens\");\n\tensure(views.length > 0, \"views must be nonempty\");\n\tfor (const id of requiredFactIds) text(id, \"requiredFactId\", 256);\n\tconst admissible = views.filter(\n\t\t(v) => v.estimatedTokens <= budgetTokens && requiredFactIds.every((id) => v.coveredFactIds.includes(id)),\n\t);\n\tif (admissible.length === 0) return null;\n\t// Smallest tokens wins; break ties toward the higher-fidelity kind.\n\tconst rank: Record<ObservationViewKind, number> = { full: 0, excerpt: 1, evidence: 2, pointer: 3 };\n\tlet best: ObservationView | undefined;\n\tfor (const view of admissible) {\n\t\tif (\n\t\t\tbest === undefined ||\n\t\t\tview.estimatedTokens < best.estimatedTokens ||\n\t\t\t(view.estimatedTokens === best.estimatedTokens && rank[view.viewKind] < rank[best.viewKind])\n\t\t) {\n\t\t\tbest = view;\n\t\t}\n\t}\n\treturn best ?? null;\n}\n"]}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic observation views with a coverage gate — U1/U3.
|
|
3
|
+
*
|
|
4
|
+
* A view is a projection of a stored raw observation, never a rewrite of it.
|
|
5
|
+
* `chooseView` refuses any candidate that drops a required fact atom: a cheap
|
|
6
|
+
* representation is admissible only if it preserves the decision-relevant
|
|
7
|
+
* facts the current obligations need. `coverageStatus` is `unknown` when the
|
|
8
|
+
* input carries no required fact set — never silently "covered".
|
|
9
|
+
*/
|
|
10
|
+
import { ensure, integer, text } from "../metacognition/validation.js";
|
|
11
|
+
import { viewDigestOf } from "./identity.js";
|
|
12
|
+
const CHARS_PER_TOKEN = 4;
|
|
13
|
+
/** Per-atom-class occurrence cap. Four classes stay well under any global bound. */
|
|
14
|
+
const MAX_FACTS_PER_ID = 32;
|
|
15
|
+
const MAX_VIEW_TEXT = 32_768;
|
|
16
|
+
export function estimateViewTokens(text) {
|
|
17
|
+
return Math.max(1, Math.ceil(text.length / CHARS_PER_TOKEN));
|
|
18
|
+
}
|
|
19
|
+
const FACT_PATTERNS = [
|
|
20
|
+
{ id: "exit-code", re: /exit code[:\s]+(-?\d+)|exitCode\s*[=:]\s*(-?\d+)/i },
|
|
21
|
+
{ id: "test-failure", re: /FAIL[:\s]+([A-Za-z0-9_.\-/]+)|✗\s*([A-Za-z0-9_.\-/]+)/ },
|
|
22
|
+
{ id: "permission-denied", re: /permission[ _-]?denied|EACCES/i },
|
|
23
|
+
{ id: "error-marker", re: /(?:error|errno|exception|traceback)[:\s]/i },
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Extract host-verifiable fact atoms from raw bytes. `requiredFactIds` limits
|
|
27
|
+
* extraction to the caller's obligation set; when omitted, all recognized
|
|
28
|
+
* atoms are returned so a view can advertise what it preserves.
|
|
29
|
+
*/
|
|
30
|
+
export function extractFacts(raw, requiredFactIds) {
|
|
31
|
+
const decoded = new TextDecoder("utf-8", { fatal: false }).decode(raw);
|
|
32
|
+
const encoder = new TextEncoder();
|
|
33
|
+
const wanted = requiredFactIds === undefined ? undefined : new Set(requiredFactIds);
|
|
34
|
+
const facts = [];
|
|
35
|
+
for (const { id, re } of FACT_PATTERNS) {
|
|
36
|
+
if (wanted !== undefined && !wanted.has(id))
|
|
37
|
+
continue;
|
|
38
|
+
// Per-id cap, not a shared running total: a log that repeats one atom
|
|
39
|
+
// thousands of times must not starve a later pattern out of extraction
|
|
40
|
+
// entirely, or a required atom silently disappears from every view.
|
|
41
|
+
let perId = 0;
|
|
42
|
+
for (const match of decoded.matchAll(new RegExp(re.source, re.flags.includes("g") ? re.flags : `${re.flags}g`))) {
|
|
43
|
+
if (perId >= MAX_FACTS_PER_ID)
|
|
44
|
+
break;
|
|
45
|
+
const evidence = match[0];
|
|
46
|
+
const byteOffset = encoder.encode(decoded.slice(0, match.index ?? 0)).length;
|
|
47
|
+
facts.push({
|
|
48
|
+
id,
|
|
49
|
+
evidence,
|
|
50
|
+
byteOffset,
|
|
51
|
+
byteLength: encoder.encode(evidence).length,
|
|
52
|
+
});
|
|
53
|
+
perId += 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return facts;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Collapse repeated identical atoms into one line that keeps the occurrence
|
|
60
|
+
* count. Without this the evidence view of a log that repeats one failure is
|
|
61
|
+
* larger than the raw text it was supposed to shrink, and the selector
|
|
62
|
+
* correctly but uselessly falls back to full text.
|
|
63
|
+
*/
|
|
64
|
+
function dedupeFacts(facts) {
|
|
65
|
+
const byKey = new Map();
|
|
66
|
+
for (const fact of facts) {
|
|
67
|
+
const key = `${fact.id}\u0000${fact.evidence}`;
|
|
68
|
+
const existing = byKey.get(key);
|
|
69
|
+
if (existing === undefined)
|
|
70
|
+
byKey.set(key, { fact, count: 1 });
|
|
71
|
+
else
|
|
72
|
+
existing.count += 1;
|
|
73
|
+
}
|
|
74
|
+
return [...byKey.values()];
|
|
75
|
+
}
|
|
76
|
+
function viewText(raw, facts, kind) {
|
|
77
|
+
const decoded = new TextDecoder("utf-8", { fatal: false }).decode(raw);
|
|
78
|
+
switch (kind) {
|
|
79
|
+
case "full":
|
|
80
|
+
return decoded;
|
|
81
|
+
case "excerpt": {
|
|
82
|
+
if (decoded.length <= MAX_VIEW_TEXT)
|
|
83
|
+
return decoded;
|
|
84
|
+
const head = decoded.slice(0, Math.floor(MAX_VIEW_TEXT / 2));
|
|
85
|
+
const tail = decoded.slice(-Math.floor(MAX_VIEW_TEXT / 2));
|
|
86
|
+
return `${head}\n…[omitted ${decoded.length - MAX_VIEW_TEXT} chars]…\n${tail}`;
|
|
87
|
+
}
|
|
88
|
+
case "evidence":
|
|
89
|
+
return facts.length === 0
|
|
90
|
+
? ""
|
|
91
|
+
: dedupeFacts(facts)
|
|
92
|
+
.map(({ fact, count }) => count === 1
|
|
93
|
+
? `${fact.id} @${fact.byteOffset}: ${fact.evidence}`
|
|
94
|
+
: `${fact.id} @${fact.byteOffset} \u00d7${count}: ${fact.evidence}`)
|
|
95
|
+
.join("\n")
|
|
96
|
+
.slice(0, MAX_VIEW_TEXT);
|
|
97
|
+
case "pointer":
|
|
98
|
+
return `[observation ${raw.length} bytes; digest-bound; read via handle]`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function coverageFor(covered, required) {
|
|
102
|
+
if (required.length === 0)
|
|
103
|
+
return { status: "unknown", missing: [] };
|
|
104
|
+
const coveredSet = new Set(covered);
|
|
105
|
+
const missing = required.filter((id) => !coveredSet.has(id));
|
|
106
|
+
return { status: missing.length === 0 ? "complete" : "partial", missing };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Build the candidate views for one observation. Every view records which
|
|
110
|
+
* fact atoms it preserves and which required atoms it would drop, so the
|
|
111
|
+
* selector can gate on coverage rather than token density alone.
|
|
112
|
+
*/
|
|
113
|
+
export function makeViews(observation, requiredFactIds = []) {
|
|
114
|
+
text(observation.observationId, "observationId", 128);
|
|
115
|
+
for (const id of requiredFactIds)
|
|
116
|
+
text(id, "requiredFactId", 256);
|
|
117
|
+
const facts = extractFacts(observation.bytes);
|
|
118
|
+
const coveredByKind = {
|
|
119
|
+
full: facts.map((f) => f.id),
|
|
120
|
+
excerpt: facts.map((f) => f.id), // excerpt keeps head+tail; see note
|
|
121
|
+
evidence: facts.map((f) => f.id),
|
|
122
|
+
pointer: [],
|
|
123
|
+
};
|
|
124
|
+
const kinds = ["full", "excerpt", "evidence", "pointer"];
|
|
125
|
+
return kinds.map((kind) => {
|
|
126
|
+
const body = viewText(observation.bytes, facts, kind);
|
|
127
|
+
const covered = coveredByKind[kind].filter((id) => body.includes(id) || kind !== "evidence" || facts.some((f) => f.id === id));
|
|
128
|
+
const { status, missing } = coverageFor(covered, requiredFactIds);
|
|
129
|
+
return Object.freeze({
|
|
130
|
+
viewKind: kind,
|
|
131
|
+
observationId: observation.observationId,
|
|
132
|
+
parentDigest: observation.rawDigest,
|
|
133
|
+
transformationDigest: viewDigestOf({
|
|
134
|
+
observationId: observation.observationId,
|
|
135
|
+
viewKind: kind,
|
|
136
|
+
params: `req:${[...requiredFactIds].sort().join(",")}`,
|
|
137
|
+
}),
|
|
138
|
+
text: body,
|
|
139
|
+
estimatedTokens: estimateViewTokens(body),
|
|
140
|
+
coveredFactIds: covered,
|
|
141
|
+
missingRequiredFactIds: missing,
|
|
142
|
+
coverageStatus: status,
|
|
143
|
+
taskVerdict: "not-assessed",
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Coverage-gated deterministic selection: the smallest view that preserves
|
|
149
|
+
* every required fact within budget. Returns null (infeasible) rather than
|
|
150
|
+
* silently dropping a required atom — the caller must widen the budget or keep
|
|
151
|
+
* the raw observation.
|
|
152
|
+
*/
|
|
153
|
+
export function chooseView(views, budgetTokens, requiredFactIds = []) {
|
|
154
|
+
integer(budgetTokens, "budgetTokens");
|
|
155
|
+
ensure(views.length > 0, "views must be nonempty");
|
|
156
|
+
for (const id of requiredFactIds)
|
|
157
|
+
text(id, "requiredFactId", 256);
|
|
158
|
+
const admissible = views.filter((v) => v.estimatedTokens <= budgetTokens && requiredFactIds.every((id) => v.coveredFactIds.includes(id)));
|
|
159
|
+
if (admissible.length === 0)
|
|
160
|
+
return null;
|
|
161
|
+
// Smallest tokens wins; break ties toward the higher-fidelity kind.
|
|
162
|
+
const rank = { full: 0, excerpt: 1, evidence: 2, pointer: 3 };
|
|
163
|
+
let best;
|
|
164
|
+
for (const view of admissible) {
|
|
165
|
+
if (best === undefined ||
|
|
166
|
+
view.estimatedTokens < best.estimatedTokens ||
|
|
167
|
+
(view.estimatedTokens === best.estimatedTokens && rank[view.viewKind] < rank[best.viewKind])) {
|
|
168
|
+
best = view;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return best ?? null;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/observation/view.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAA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IACF,CAAC;IACD,OAAO,IAAI,IAAI,IAAI,CAAC;AAAA,CACpB","sourcesContent":["/**\n * Deterministic observation views with a coverage gate — U1/U3.\n *\n * A view is a projection of a stored raw observation, never a rewrite of it.\n * `chooseView` refuses any candidate that drops a required fact atom: a cheap\n * representation is admissible only if it preserves the decision-relevant\n * facts the current obligations need. `coverageStatus` is `unknown` when the\n * input carries no required fact set — never silently \"covered\".\n */\n\nimport { ensure, integer, text } from \"../metacognition/validation.ts\";\nimport { viewDigestOf } from \"./identity.ts\";\nimport type { ObservationCoverageStatus, ObservationView, ObservationViewKind, RawObservation } from \"./types.ts\";\n\nconst CHARS_PER_TOKEN = 4;\n/** Per-atom-class occurrence cap. Four classes stay well under any global bound. */\nconst MAX_FACTS_PER_ID = 32;\nconst MAX_VIEW_TEXT = 32_768;\n\nexport function estimateViewTokens(text: string): number {\n\treturn Math.max(1, Math.ceil(text.length / CHARS_PER_TOKEN));\n}\n\n/** A host-verifiable fact atom extracted from raw bytes, e.g. exitCode=1. */\nexport interface FactAtom {\n\treadonly id: string;\n\t/** The verbatim text that must appear in a view for the atom to count as covered. */\n\treadonly evidence: string;\n\treadonly byteOffset: number;\n\treadonly byteLength: number;\n}\n\nconst FACT_PATTERNS: readonly { readonly id: string; readonly re: RegExp }[] = [\n\t{ id: \"exit-code\", re: /exit code[:\\s]+(-?\\d+)|exitCode\\s*[=:]\\s*(-?\\d+)/i },\n\t{ id: \"test-failure\", re: /FAIL[:\\s]+([A-Za-z0-9_.\\-/]+)|✗\\s*([A-Za-z0-9_.\\-/]+)/ },\n\t{ id: \"permission-denied\", re: /permission[ _-]?denied|EACCES/i },\n\t{ id: \"error-marker\", re: /(?:error|errno|exception|traceback)[:\\s]/i },\n];\n\n/**\n * Extract host-verifiable fact atoms from raw bytes. `requiredFactIds` limits\n * extraction to the caller's obligation set; when omitted, all recognized\n * atoms are returned so a view can advertise what it preserves.\n */\nexport function extractFacts(raw: Uint8Array, requiredFactIds?: readonly string[]): FactAtom[] {\n\tconst decoded = new TextDecoder(\"utf-8\", { fatal: false }).decode(raw);\n\tconst encoder = new TextEncoder();\n\tconst wanted = requiredFactIds === undefined ? undefined : new Set(requiredFactIds);\n\tconst facts: FactAtom[] = [];\n\tfor (const { id, re } of FACT_PATTERNS) {\n\t\tif (wanted !== undefined && !wanted.has(id)) continue;\n\t\t// Per-id cap, not a shared running total: a log that repeats one atom\n\t\t// thousands of times must not starve a later pattern out of extraction\n\t\t// entirely, or a required atom silently disappears from every view.\n\t\tlet perId = 0;\n\t\tfor (const match of decoded.matchAll(new RegExp(re.source, re.flags.includes(\"g\") ? re.flags : `${re.flags}g`))) {\n\t\t\tif (perId >= MAX_FACTS_PER_ID) break;\n\t\t\tconst evidence = match[0];\n\t\t\tconst byteOffset = encoder.encode(decoded.slice(0, match.index ?? 0)).length;\n\t\t\tfacts.push({\n\t\t\t\tid,\n\t\t\t\tevidence,\n\t\t\t\tbyteOffset,\n\t\t\t\tbyteLength: encoder.encode(evidence).length,\n\t\t\t});\n\t\t\tperId += 1;\n\t\t}\n\t}\n\treturn facts;\n}\n\n/**\n * Collapse repeated identical atoms into one line that keeps the occurrence\n * count. Without this the evidence view of a log that repeats one failure is\n * larger than the raw text it was supposed to shrink, and the selector\n * correctly but uselessly falls back to full text.\n */\nfunction dedupeFacts(facts: readonly FactAtom[]): readonly { readonly fact: FactAtom; readonly count: number }[] {\n\tconst byKey = new Map<string, { fact: FactAtom; count: number }>();\n\tfor (const fact of facts) {\n\t\tconst key = `${fact.id}\\u0000${fact.evidence}`;\n\t\tconst existing = byKey.get(key);\n\t\tif (existing === undefined) byKey.set(key, { fact, count: 1 });\n\t\telse existing.count += 1;\n\t}\n\treturn [...byKey.values()];\n}\n\nfunction viewText(raw: Uint8Array, facts: readonly FactAtom[], kind: ObservationViewKind): string {\n\tconst decoded = new TextDecoder(\"utf-8\", { fatal: false }).decode(raw);\n\tswitch (kind) {\n\t\tcase \"full\":\n\t\t\treturn decoded;\n\t\tcase \"excerpt\": {\n\t\t\tif (decoded.length <= MAX_VIEW_TEXT) return decoded;\n\t\t\tconst head = decoded.slice(0, Math.floor(MAX_VIEW_TEXT / 2));\n\t\t\tconst tail = decoded.slice(-Math.floor(MAX_VIEW_TEXT / 2));\n\t\t\treturn `${head}\\n…[omitted ${decoded.length - MAX_VIEW_TEXT} chars]…\\n${tail}`;\n\t\t}\n\t\tcase \"evidence\":\n\t\t\treturn facts.length === 0\n\t\t\t\t? \"\"\n\t\t\t\t: dedupeFacts(facts)\n\t\t\t\t\t\t.map(({ fact, count }) =>\n\t\t\t\t\t\t\tcount === 1\n\t\t\t\t\t\t\t\t? `${fact.id} @${fact.byteOffset}: ${fact.evidence}`\n\t\t\t\t\t\t\t\t: `${fact.id} @${fact.byteOffset} \\u00d7${count}: ${fact.evidence}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join(\"\\n\")\n\t\t\t\t\t\t.slice(0, MAX_VIEW_TEXT);\n\t\tcase \"pointer\":\n\t\t\treturn `[observation ${raw.length} bytes; digest-bound; read via handle]`;\n\t}\n}\n\nfunction coverageFor(\n\tcovered: readonly string[],\n\trequired: readonly string[],\n): { status: ObservationCoverageStatus; missing: readonly string[] } {\n\tif (required.length === 0) return { status: \"unknown\", missing: [] };\n\tconst coveredSet = new Set(covered);\n\tconst missing = required.filter((id) => !coveredSet.has(id));\n\treturn { status: missing.length === 0 ? \"complete\" : \"partial\", missing };\n}\n\n/**\n * Build the candidate views for one observation. Every view records which\n * fact atoms it preserves and which required atoms it would drop, so the\n * selector can gate on coverage rather than token density alone.\n */\nexport function makeViews(\n\tobservation: RawObservation,\n\trequiredFactIds: readonly string[] = [],\n): readonly ObservationView[] {\n\ttext(observation.observationId, \"observationId\", 128);\n\tfor (const id of requiredFactIds) text(id, \"requiredFactId\", 256);\n\tconst facts = extractFacts(observation.bytes);\n\tconst coveredByKind: Record<ObservationViewKind, readonly string[]> = {\n\t\tfull: facts.map((f) => f.id),\n\t\texcerpt: facts.map((f) => f.id), // excerpt keeps head+tail; see note\n\t\tevidence: facts.map((f) => f.id),\n\t\tpointer: [],\n\t};\n\tconst kinds: readonly ObservationViewKind[] = [\"full\", \"excerpt\", \"evidence\", \"pointer\"];\n\treturn kinds.map((kind) => {\n\t\tconst body = viewText(observation.bytes, facts, kind);\n\t\tconst covered = coveredByKind[kind].filter(\n\t\t\t(id) => body.includes(id) || kind !== \"evidence\" || facts.some((f) => f.id === id),\n\t\t);\n\t\tconst { status, missing } = coverageFor(covered, requiredFactIds);\n\t\treturn Object.freeze({\n\t\t\tviewKind: kind,\n\t\t\tobservationId: observation.observationId,\n\t\t\tparentDigest: observation.rawDigest,\n\t\t\ttransformationDigest: viewDigestOf({\n\t\t\t\tobservationId: observation.observationId,\n\t\t\t\tviewKind: kind,\n\t\t\t\tparams: `req:${[...requiredFactIds].sort().join(\",\")}`,\n\t\t\t}),\n\t\t\ttext: body,\n\t\t\testimatedTokens: estimateViewTokens(body),\n\t\t\tcoveredFactIds: covered,\n\t\t\tmissingRequiredFactIds: missing,\n\t\t\tcoverageStatus: status,\n\t\t\ttaskVerdict: \"not-assessed\" as const,\n\t\t});\n\t});\n}\n\n/**\n * Coverage-gated deterministic selection: the smallest view that preserves\n * every required fact within budget. Returns null (infeasible) rather than\n * silently dropping a required atom — the caller must widen the budget or keep\n * the raw observation.\n */\nexport function chooseView(\n\tviews: readonly ObservationView[],\n\tbudgetTokens: number,\n\trequiredFactIds: readonly string[] = [],\n): ObservationView | null {\n\tinteger(budgetTokens, \"budgetTokens\");\n\tensure(views.length > 0, \"views must be nonempty\");\n\tfor (const id of requiredFactIds) text(id, \"requiredFactId\", 256);\n\tconst admissible = views.filter(\n\t\t(v) => v.estimatedTokens <= budgetTokens && requiredFactIds.every((id) => v.coveredFactIds.includes(id)),\n\t);\n\tif (admissible.length === 0) return null;\n\t// Smallest tokens wins; break ties toward the higher-fidelity kind.\n\tconst rank: Record<ObservationViewKind, number> = { full: 0, excerpt: 1, evidence: 2, pointer: 3 };\n\tlet best: ObservationView | undefined;\n\tfor (const view of admissible) {\n\t\tif (\n\t\t\tbest === undefined ||\n\t\t\tview.estimatedTokens < best.estimatedTokens ||\n\t\t\t(view.estimatedTokens === best.estimatedTokens && rank[view.viewKind] < rank[best.viewKind])\n\t\t) {\n\t\t\tbest = view;\n\t\t}\n\t}\n\treturn best ?? null;\n}\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Audit revalidation — 2026-09-17
|
|
2
|
+
|
|
3
|
+
Baseline: `1e58611d0c28775c8a066b6e913ea6710ccea396`, with unrelated local
|
|
4
|
+
provider/model changes present. This is a scoped local revalidation, not a release
|
|
5
|
+
approval, full security audit, or competitor benchmark.
|
|
6
|
+
|
|
7
|
+
## Inputs and scope
|
|
8
|
+
|
|
9
|
+
The local September 14 reproduction ZIP targets
|
|
10
|
+
`69e0637d8fddd26eb40a7ec3f8ebfb65b500de5b`. All 25 entries listed in its
|
|
11
|
+
SHA256SUMS matched. Its recorded six expected failures describe that historical
|
|
12
|
+
snapshot, not the current checkout. The archived runner was not executed or
|
|
13
|
+
substituted for current repository tests.
|
|
14
|
+
|
|
15
|
+
The September 15 strategy report combines historical findings with proposed
|
|
16
|
+
resource-aware scheduling, recovery, and comparative evaluation. These proposals
|
|
17
|
+
are not measured product benefits. The September 16 GitHub audit targets
|
|
18
|
+
`739bc6f3b6fe1c89bfe058aad7ec17ad252fb10e`; its missing DAG contract is no longer
|
|
19
|
+
present in this baseline. The documents were used to select the checks below;
|
|
20
|
+
not every proposed acceptance criterion was executed.
|
|
21
|
+
|
|
22
|
+
## Executed regression groups
|
|
23
|
+
|
|
24
|
+
Commands use `node ../../node_modules/vitest/dist/cli.js --run` from the named
|
|
25
|
+
workspace. No external provider requests were needed.
|
|
26
|
+
|
|
27
|
+
| Workspace | Test files | Result |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| agent | `test/tool-dag-*.test.ts` | 83 passed, including 10,000 seeded bounded schedules |
|
|
30
|
+
| coding-agent | `test/mcp/{protocol,protocol-required,manager-lifecycle,manager-health,client,tools}.test.ts` | 61 passed; client tests include a local stdio fixture |
|
|
31
|
+
| protocol | `test/{protocol,evaluation-candidate-binding,validation,run-dag-contract,run-dag-properties}.test.ts` | 44 passed |
|
|
32
|
+
| coding-agent | `test/{context-budget-v2-validation-cache,context-budget-cache,context-budget-cache-policy,context-budget-v2-tier-floor,context-budget-v2-eligibility,context-budget-v2-nonfinite-tokens,context-budget-governor-v2}.test.ts` | 46 passed after the fix below |
|
|
33
|
+
|
|
34
|
+
These are 234 distinct passing test cases, not 234 independent production tasks.
|
|
35
|
+
An initial command included nonexistent `test/mcp/manager.test.ts`; Vitest ran
|
|
36
|
+
other matching files successfully. Manager coverage above comes from the actual
|
|
37
|
+
`manager-lifecycle`, `manager-health`, and `client` files, not that missing path.
|
|
38
|
+
|
|
39
|
+
## Fixed: input diagnostics leaked across plan-cache reuse
|
|
40
|
+
|
|
41
|
+
`planPromptContextBudgetV2()` originally decided cache eligibility before
|
|
42
|
+
`validateBudgetItems()`. Duplicate IDs are dropped and invalid token estimates are
|
|
43
|
+
recomputed. Their sanitized items can produce exactly the same plan key as valid
|
|
44
|
+
input, but their input diagnostics are different.
|
|
45
|
+
|
|
46
|
+
Three regressions failed before the fix:
|
|
47
|
+
|
|
48
|
+
1. A cached valid plan hid a duplicate-ID diagnostic on a later call.
|
|
49
|
+
2. A plan produced from duplicate IDs carried its diagnostic into a later valid call.
|
|
50
|
+
3. A cached plan hid the diagnostic for a recomputed non-finite token estimate.
|
|
51
|
+
|
|
52
|
+
Cache eligibility is now decided after input validation. Calls with input or
|
|
53
|
+
budget diagnostics neither read nor write the plan cache. Representation-cache
|
|
54
|
+
validation and normal valid-input plan reuse remain unchanged. The regression
|
|
55
|
+
uses a required item to isolate plan reuse from the existing
|
|
56
|
+
`cache_dependency_unsafe` rejection for plans containing representation-cache hits.
|
|
57
|
+
|
|
58
|
+
Changed implementation: `src/core/context-budget-v2-planner.ts`.
|
|
59
|
+
Regression: `test/context-budget-v2-validation-cache.test.ts` (3 passed).
|
|
60
|
+
This preserves diagnostics; it does not redesign duplicate-item handling or tier
|
|
61
|
+
allocation policy.
|
|
62
|
+
|
|
63
|
+
## Remaining boundaries
|
|
64
|
+
|
|
65
|
+
- Full `npm run check` has been blocked by unrelated local module-size growth in
|
|
66
|
+
`agent-session.ts` and `model-registry.ts`; those files and the ratchet baseline
|
|
67
|
+
are not changed by this fix. A passing focused compiler/test run does not close
|
|
68
|
+
the full repository gate.
|
|
69
|
+
- General observation evaluation still has existential semantics. Passing
|
|
70
|
+
candidate-binding tests does not establish latest-result or complete-coverage
|
|
71
|
+
semantics, or independently authenticate a verifier.
|
|
72
|
+
- ECRAF remains an internal planner. Resource normalization, fairness, live
|
|
73
|
+
admission integration, and equal-budget performance comparisons were not added.
|
|
74
|
+
- This pass does not validate the complete timeout/ownership fault matrix,
|
|
75
|
+
verified-run crash recovery, all MCP authorization boundaries, remote CI,
|
|
76
|
+
branch protection, published artifacts, or router calibration.
|
|
77
|
+
- No release, commit, push, paid benchmark, or new runtime default is implied.
|
package/docs/devin-harness.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Devin SWE-2 harness
|
|
2
2
|
|
|
3
|
-
This page is the canonical operator guide for the built-in `devin` provider
|
|
3
|
+
This page is the canonical operator guide for the built-in `devin` provider, centered on the logical `swe-2` model. Use `/login devin` for the Devin CLI subscription PKCE flow or `DEVIN_API_KEY` for an already-owned CLI session token. A user-local `~/.omk/agent/devin.md` may add operator notes, but it is not the portable product contract.
|
|
4
4
|
|
|
5
5
|
Authentication, transport, and verification limits are owned by [Providers](providers.md#devin-cli); this page covers how OMK drives SWE-2 as a harness.
|
|
6
6
|
|
|
@@ -44,12 +44,12 @@ Guidance from the [SWE-2 announcement](https://cognition.com/blog/swe-2): `mediu
|
|
|
44
44
|
|
|
45
45
|
## Context budget: 1,000,000 tokens
|
|
46
46
|
|
|
47
|
-
`devin/swe-2` ships with `contextWindow: 1000000` and `maxTokens: 16384`. These are local budgets that drive OMK's context budgeting and compaction, **not published SWE-2 limits**; Cognition has not published a context window for SWE-2. The budget also selects the catalog lane:
|
|
47
|
+
`devin/swe-2` ships with `contextWindow: 1000000` and `maxTokens: 16384`. These are local budgets that drive OMK's context budgeting and compaction, **not published SWE-2 limits**; Cognition has not published a context window for SWE-2. Chat completion settings follow the captured native Devin CLI 3000.6.2 defaults (`maxNewlines` 400, empty stop list). `topP=0.95` is protobuf field 8; field 6 is `firstTemperature` and is omitted. This removes the old 200-newline cap and synthetic stops, but does not prove that every interrupted reply had that cause. The budget also selects the catalog lane:
|
|
48
48
|
|
|
49
49
|
1. Before each turn OMK reads `GetCliModelConfigs`. SWE-2 family entries may carry a `1M Context` axis (order `1`) beside the effort axis. A local budget of 1,000,000 or more asks for that 1M-context lane; below it, the standard lane is used and 1M entries are ignored.
|
|
50
50
|
2. A catalog with no 1M-context lane keeps the standard lane for the selected effort.
|
|
51
51
|
3. If the chosen lane declares a context window smaller than the local budget, the request fails with `... declares a N-token context window; lower the models.json contextWindow before retrying`. OMK never shrinks the budget silently, never invents a wire UID, and never downgrades to another effort.
|
|
52
|
-
4. Fast-lane (`Fast Mode`) entries are
|
|
52
|
+
4. Fast-lane (`Fast Mode`) entries are excluded from effort routing and are reachable only through their own UID models (ids ending in `-fast` or `-priority`). Output is capped against the authenticated catalog's declared maximum.
|
|
53
53
|
|
|
54
54
|
To lower the budget (for example if your account only serves the standard lane at 262,144 tokens), override the built-in model in `~/.omk/agent/models.json`:
|
|
55
55
|
|
|
@@ -87,7 +87,7 @@ General prompt-based domain routing is separate and opt-in through `OMK_DOMAIN_R
|
|
|
87
87
|
|
|
88
88
|
## Model selection
|
|
89
89
|
|
|
90
|
-
The `devin` catalog
|
|
90
|
+
The `devin` catalog leads with the logical `swe-2` model; the server's SWE-2 family metadata supplies each effort's wire UID at request time. Every other lane the account catalog advertises is its own logical model whose id is the wire UID — for example `devin/claude-opus-5-high`, `devin/gpt-5-6-sol-xhigh`, `devin/gemini-3-8-flash-medium`, `devin/kimi-k3-max`, `devin/glm-5-3-high`, `devin/grok-4-6-xhigh`, `devin/deepseek-v4-pro-max`, `devin/swe-1-7`, or `devin/inkling-max`. Flat models pin their declared effort lane, so `/think` levels are fixed per model and `No Thinking`/`None` lanes report `reasoning: false`. Availability is account- and plan-dependent: a lane absent from your catalog fails loudly instead of being remapped. Use `/model` or `omk --list-models devin` for the current list. Image input is unsupported; provide text.
|
|
91
91
|
|
|
92
92
|
## Skill and MCP matrix summary
|
|
93
93
|
|
|
@@ -116,6 +116,35 @@ Relevant evidence hooks for SWE-2 lanes are `pre-shell-guard`, `protect-secrets`
|
|
|
116
116
|
4. If a turn fails with an "unavailable or ambiguous" route or a smaller declared context window, treat it as a configuration signal: check `devin models list`, or lower `contextWindow` as shown above. Do not retry with a guessed wire UID.
|
|
117
117
|
5. Keep credentials out of preset JSON, prompts, and logs: the session token, the exchanged user JWT, and `auth.json` contents are secrets under `protect-secrets`.
|
|
118
118
|
|
|
119
|
+
## Troubleshooting `does not provide an export named`
|
|
120
|
+
|
|
121
|
+
If Devin fails with `The requested module './devin-connect.js' does not provide an export named 'MAX_FRAME_BYTES'`, the loaded stream module is mixed with an older unary module. That is a client load error, not an orphan tool call or a remote protocol trailer.
|
|
122
|
+
|
|
123
|
+
- Current OMK keeps the 16 MiB Connect frame cap inside `devin-connect-stream.ts`, so a stale `devin-connect.js` cannot fail that named import.
|
|
124
|
+
- `/new` does not reload already-imported provider modules. Quit and restart OMK after a rebuild.
|
|
125
|
+
- The failure banner should say to restart OMK, not to sanitize a sticky transcript.
|
|
126
|
+
|
|
127
|
+
## Troubleshooting `invalid_argument`
|
|
128
|
+
|
|
129
|
+
A Connect `invalid_argument` trailer is a provider/request failure, not evidence of
|
|
130
|
+
an orphan tool call or a safety refusal. Keep any reported trace ID for support;
|
|
131
|
+
OMK includes only a bounded hexadecimal trace ID, never the remote error body.
|
|
132
|
+
|
|
133
|
+
- The SWE-2 adapter rejects zero, negative, and non-finite `temperature` values
|
|
134
|
+
before sending credentials. A controlled high-effort probe returned
|
|
135
|
+
`invalid_argument` at `temperature: 0`, while the default temperature completed
|
|
136
|
+
the same prompt. Omit the option to use the native default of `1`; OMK does not
|
|
137
|
+
silently replace an explicit zero.
|
|
138
|
+
- Check model, effort, context budget, and request settings with `/debug`. Repair
|
|
139
|
+
tool history only when a tool/message mismatch is actually identified.
|
|
140
|
+
- After updating or rebuilding the adapter, quit and restart the OMK process.
|
|
141
|
+
`/new` replaces conversation state; it does not reload an imported provider
|
|
142
|
+
module. This is an update-application step, not a guaranteed fix for every
|
|
143
|
+
provider error.
|
|
144
|
+
- If a minimal tool-free request still fails at the default temperature, preserve
|
|
145
|
+
the trace ID and investigate provider compatibility or availability rather than
|
|
146
|
+
repeatedly sanitizing the same transcript.
|
|
147
|
+
|
|
119
148
|
## Local overlay
|
|
120
149
|
|
|
121
150
|
When the `devin` provider is active, OMK appends `~/.omk/agent/devin.md` (capped at 24,000 characters) to the system prompt, mirroring the Grok `grok.md` overlay. Treat that file as optional host configuration for effort defaults, compaction notes, or team conventions; this page and the current provider documentation remain authoritative and it cannot override higher-priority instructions.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# ECRAF dimensionless normalization (R11)
|
|
2
|
+
|
|
3
|
+
Status: **pure planner, opt-in, not wired** — the same gate vocabulary as
|
|
4
|
+
[runtime-algorithms](./runtime-algorithms.md) applies. This page documents what is
|
|
5
|
+
implemented and verified, and states explicitly what remains unproven.
|
|
6
|
+
|
|
7
|
+
## Versions
|
|
8
|
+
|
|
9
|
+
`planEcrafAdmissions()` accepts an explicit `algorithmVersion`:
|
|
10
|
+
|
|
11
|
+
| Version | Density formula | When selected |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| `legacy-v1` (default when omitted) | `P_i / (epsilon + Σ_r weight_r · a_ir)` | No normalization options supplied. |
|
|
14
|
+
| `normalized-v2` | `P_i / (epsilon + slotCost + Σ_r weight_r · a_ir / s_r)` | `algorithmVersion: "normalized-v2"` **or** `referenceScales` supplied without a version (compatibility with the earlier scales-only opt-in). |
|
|
15
|
+
|
|
16
|
+
Compatibility policy:
|
|
17
|
+
|
|
18
|
+
- Omitting `algorithmVersion` and every normalization option reproduces the
|
|
19
|
+
byte-for-byte legacy plan. Legacy regression and property tests are unchanged.
|
|
20
|
+
- Supplying `referenceScales` (or `slotCost`) with `legacy-v1` is rejected with
|
|
21
|
+
`RangeError`; the scales-only shape silently choosing a different algorithm was
|
|
22
|
+
the ambiguity this version policy closes.
|
|
23
|
+
- Unknown versions and unknown future options are rejected, not coerced.
|
|
24
|
+
|
|
25
|
+
## normalized-v2 semantics (spec §13.2)
|
|
26
|
+
|
|
27
|
+
- Every resource with a nonzero demand needs a positive finite reference scale
|
|
28
|
+
`s_r`. In `normalized-v2` omitted entries default to the resource's **positive
|
|
29
|
+
total capacity** — never remaining headroom — so the caller cannot implicitly
|
|
30
|
+
re-scale ranking by scheduling pressure. Unbounded resources (capacity omitted)
|
|
31
|
+
cannot fall back to a scale and require an explicit one.
|
|
32
|
+
- Zero capacity is a **feasibility gate**, not a scale: a positive demand on a
|
|
33
|
+
zero-capacity resource is deferred before scoring; a zero demand still uses the
|
|
34
|
+
resource in the legacy sense (admission fails on held usage), so the documented
|
|
35
|
+
"missing capacity = unbounded" and `capacity: 0` meanings are preserved.
|
|
36
|
+
- `slotCost` (λ_slot) is finite and **positive**; the slot term charges every
|
|
37
|
+
running candidate one execution slot even when its resource vector is empty or
|
|
38
|
+
all-zero, so an empty node cannot dominate on `epsilon` alone.
|
|
39
|
+
- Infinite capacities are rejected in v2 (`RangeError`); the legacy finite-input
|
|
40
|
+
contract is unchanged. Finite inputs can still overflow the denominator,
|
|
41
|
+
density, or reserved usage, and those derived values are rejected with
|
|
42
|
+
`RangeError` as before.
|
|
43
|
+
|
|
44
|
+
## Verified properties (unit invariance, spec §13.3)
|
|
45
|
+
|
|
46
|
+
`a'_ir = c_r·a_ir` with `s'_r = c_r·s_r` (`c_r > 0`) produces the identical plan.
|
|
47
|
+
The seeded property test (`tool-dag-ecraf-normalization.test.ts`) replays the same
|
|
48
|
+
batch under independent power-of-two memory/CPU rescaling, both bounded and
|
|
49
|
+
unbounded, with conflicts, held usage, and slot caps, and additionally asserts
|
|
50
|
+
partition completeness, slot bounds, feasibility, conflict invariants, and input
|
|
51
|
+
immutability. The spec's worked example holds: memory scale 4 GiB / CPU scale 8
|
|
52
|
+
gives A = 0.625 < B = 0.75 in both GiB and byte units.
|
|
53
|
+
|
|
54
|
+
Unit normalization is **not** a fairness guarantee or an optimality proof, and it
|
|
55
|
+
is not equivalent to DRF.
|
|
56
|
+
|
|
57
|
+
## What this is not
|
|
58
|
+
|
|
59
|
+
- **No live path calls the planner.** `runDagFrontier()` in
|
|
60
|
+
`packages/agent/src/agent-loop.ts` admits ready calls by source order and
|
|
61
|
+
settled-claim conflicts; it does not import `tool-dag-ecraf`. There is no
|
|
62
|
+
shadow recording, feature flag, or default change, and **no measured benefit**
|
|
63
|
+
is claimed anywhere.
|
|
64
|
+
- **The conflict predicate covers only this pass.** A live caller must re-check
|
|
65
|
+
unsettled claims, re-validate post-hook arguments, and refuse stale plans
|
|
66
|
+
before granting (spec §13.4). None of that wiring exists.
|
|
67
|
+
- Starvation/fairness accounting (spec §13.5) and same-budget comparisons
|
|
68
|
+
(§13.6 steps 4–6) are separate, unstarted work.
|
|
69
|
+
|
|
70
|
+
## Tests
|
|
71
|
+
|
|
72
|
+
- `packages/agent/test/tool-dag-ecraf-normalization.test.ts` — version policy,
|
|
73
|
+
scale derivation, zero-capacity gating, slot cost, overflow/validation
|
|
74
|
+
boundaries, unit-invariance property test (seed 110917, 300 runs).
|
|
75
|
+
- `packages/agent/test/tool-dag-ecraf.test.ts` — legacy behavior, input
|
|
76
|
+
rejection, admission invariants, and the §13.3 GiB/bytes ranking-flip example.
|
|
77
|
+
- `packages/agent/test/tool-dag-ecraf-arithmetic.test.ts` — finite-arithmetic
|
|
78
|
+
overflow rejection, unchanged.
|
|
79
|
+
|
|
80
|
+
Mutation/negative-control evidence: removing the demand/scale division, weakening
|
|
81
|
+
slot-cost positivity to `< 0`, removing the zero-capacity gate, or removing the
|
|
82
|
+
version whitelist each makes the assertion harness fail (run from a /tmp mutant
|
|
83
|
+
copy; the working tree was not modified during the check).
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Metacognitive Control Kernel
|
|
2
|
+
|
|
3
|
+
`src/metacognition/` implements the observation / control / evaluation loop from
|
|
4
|
+
`docs/OMK_metacognitive_control_algorithms_2026-09-19.md`, on top of the
|
|
5
|
+
skill-and-knowledge control kernel from `docs/OMK_skill_knowledge_control_2026-09-19.zip`.
|
|
6
|
+
|
|
7
|
+
This is a decision-rules library, not a performance claim. It manages what the
|
|
8
|
+
agent *expects*, which *obligations* remain, whether *checks* can actually
|
|
9
|
+
detect the defects they cover, and when a *strategy* should switch — all as
|
|
10
|
+
host-owned structured state, never as model self-report.
|
|
11
|
+
|
|
12
|
+
## Modules
|
|
13
|
+
|
|
14
|
+
| Module | Spec | Purpose |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| `knowledge.ts` | §13 core | Claim/evidence gap inspection (`inspectKnowledge`) |
|
|
17
|
+
| `knowledge-action.ts` | §13 core | Bounded next action (`nextKnowledgeAction`) |
|
|
18
|
+
| `skills.ts` | §13 core | Capability-coverage skill planning (`planSkills`) |
|
|
19
|
+
| `retrieval.ts` | §13 core | Local BM25 (`searchCorpus`), owned-promise `AcquisitionPool` |
|
|
20
|
+
| `context7.ts` | §13 core | Approved-egress Context7 GET adapter (`Context7Client`) |
|
|
21
|
+
| `runtime-bridge.ts` | §13 attach | ClaimGraph/ObservationNode → kernel inputs (`toMetaState`) |
|
|
22
|
+
| `evaluation.ts` | §11, §15 | DR offline estimator, experience records, completion metrics |
|
|
23
|
+
| `observe.ts` | §13 observe | Observation-mode diagnostics (`attachMetaDiagnostics`) |
|
|
24
|
+
| `obligations.ts` | A / §4 | Change-atom rules → candidate vs required obligations |
|
|
25
|
+
| `predictions.ts` | B / §5 | Pre-registered prediction ledger, Brier/surprise scoring |
|
|
26
|
+
| `decision.ts` | C / §6 | Finite Bayes risk + one-step VOI (`experimentValue`) |
|
|
27
|
+
| `verifier.ts` | D / §7 | Obligation-scoped negative-control evaluation (`evaluateVerifier`) |
|
|
28
|
+
| `calibration.ts` | E+G / §8, §10 | Condition-bucket Beta records + drift demotion |
|
|
29
|
+
| `state.ts` | §3, §9.5 | `MetaState` tuple and the three finish states |
|
|
30
|
+
| `policy.ts` | F / §9, §14 | Feasibility gating + priority-table action selection |
|
|
31
|
+
| `checkpoint.ts` | §9.4 | One ordered checkpoint evaluation (`checkpoint`) |
|
|
32
|
+
|
|
33
|
+
## Invariants enforced
|
|
34
|
+
|
|
35
|
+
- Required approvals and required checks are hard constraints, not optimization
|
|
36
|
+
inputs.
|
|
37
|
+
- Predictions are registered before outcomes and never overwritten; edits append.
|
|
38
|
+
- Model-produced obligations stay candidates until host facts promote them.
|
|
39
|
+
- Mutant counts exclude compile-broken, environment-failed, and equivalent
|
|
40
|
+
mutants; an empty denominator reports `unknown`, never a score.
|
|
41
|
+
- `max VOI <= 0` never implies verified completion; receipts must bind to the
|
|
42
|
+
current candidate hash.
|
|
43
|
+
- Environment failures are recorded separately from code failures — neither
|
|
44
|
+
inflates nor silently discards the other.
|
|
45
|
+
|
|
46
|
+
## Tests
|
|
47
|
+
|
|
48
|
+
`test/metacognition-*.test.ts` — 94 tests, including the 13 numerical checks
|
|
49
|
+
ported from `check_examples.py` (Brier 0.9025 at p=0.95 failure, VOI 0.84,
|
|
50
|
+
XOR two-bit synergy 0.40, probability-vector rejection) and the reference
|
|
51
|
+
kernel's contract tests.
|