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,14 @@
|
|
|
1
|
+
export declare function sha256Hex(data: Uint8Array | string): string;
|
|
2
|
+
export declare function observationId(input: {
|
|
3
|
+
readonly runId: string;
|
|
4
|
+
readonly operationId: string;
|
|
5
|
+
readonly sequence: number;
|
|
6
|
+
readonly rawDigest: string;
|
|
7
|
+
}): string;
|
|
8
|
+
/** Deterministic digest of a derived view's transform + source + params. */
|
|
9
|
+
export declare function viewDigestOf(input: {
|
|
10
|
+
readonly observationId: string;
|
|
11
|
+
readonly viewKind: string;
|
|
12
|
+
readonly params: string;
|
|
13
|
+
}): string;
|
|
14
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/observation/identity.ts"],"names":[],"mappings":"AAWA,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAI3D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B,GAAG,MAAM,CAMT;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,KAAK,EAAE;IACnC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB,GAAG,MAAM,CAIT","sourcesContent":["/**\n * Observation identity and digests — U1.\n *\n * `observationId` binds an execution event (run, operation, sequence) to its\n * content digest. It is intentionally not a bare content hash: identical bytes\n * from two different executions are different events and must not collapse into\n * one record. Digests here are integrity checks, not provenance authentication.\n */\nimport { createHash } from \"node:crypto\";\nimport { integer, text } from \"../metacognition/validation.ts\";\n\nexport function sha256Hex(data: Uint8Array | string): string {\n\treturn createHash(\"sha256\")\n\t\t.update(data as Uint8Array)\n\t\t.digest(\"hex\");\n}\n\nexport function observationId(input: {\n\treadonly runId: string;\n\treadonly operationId: string;\n\treadonly sequence: number;\n\treadonly rawDigest: string;\n}): string {\n\ttext(input.runId, \"runId\", 256);\n\ttext(input.operationId, \"operationId\", 256);\n\tinteger(input.sequence, \"sequence\");\n\ttext(input.rawDigest, \"rawDigest\", 128);\n\treturn sha256Hex(`${input.runId}${input.operationId}${input.sequence}${input.rawDigest}`);\n}\n\n/** Deterministic digest of a derived view's transform + source + params. */\nexport function viewDigestOf(input: {\n\treadonly observationId: string;\n\treadonly viewKind: string;\n\treadonly params: string;\n}): string {\n\ttext(input.observationId, \"observationId\", 128);\n\ttext(input.viewKind, \"viewKind\", 32);\n\treturn sha256Hex(`${input.observationId}${input.viewKind}${input.params}`);\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observation identity and digests — U1.
|
|
3
|
+
*
|
|
4
|
+
* `observationId` binds an execution event (run, operation, sequence) to its
|
|
5
|
+
* content digest. It is intentionally not a bare content hash: identical bytes
|
|
6
|
+
* from two different executions are different events and must not collapse into
|
|
7
|
+
* one record. Digests here are integrity checks, not provenance authentication.
|
|
8
|
+
*/
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
import { integer, text } from "../metacognition/validation.js";
|
|
11
|
+
export function sha256Hex(data) {
|
|
12
|
+
return createHash("sha256")
|
|
13
|
+
.update(data)
|
|
14
|
+
.digest("hex");
|
|
15
|
+
}
|
|
16
|
+
export function observationId(input) {
|
|
17
|
+
text(input.runId, "runId", 256);
|
|
18
|
+
text(input.operationId, "operationId", 256);
|
|
19
|
+
integer(input.sequence, "sequence");
|
|
20
|
+
text(input.rawDigest, "rawDigest", 128);
|
|
21
|
+
return sha256Hex(`${input.runId}${input.operationId}${input.sequence}${input.rawDigest}`);
|
|
22
|
+
}
|
|
23
|
+
/** Deterministic digest of a derived view's transform + source + params. */
|
|
24
|
+
export function viewDigestOf(input) {
|
|
25
|
+
text(input.observationId, "observationId", 128);
|
|
26
|
+
text(input.viewKind, "viewKind", 32);
|
|
27
|
+
return sha256Hex(`${input.observationId}${input.viewKind}${input.params}`);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/observation/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAE/D,MAAM,UAAU,SAAS,CAAC,IAAyB,EAAU;IAC5D,OAAO,UAAU,CAAC,QAAQ,CAAC;SACzB,MAAM,CAAC,IAAkB,CAAC;SAC1B,MAAM,CAAC,KAAK,CAAC,CAAC;AAAA,CAChB;AAED,MAAM,UAAU,aAAa,CAAC,KAK7B,EAAU;IACV,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;IAC5C,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;IACxC,OAAO,SAAS,CAAC,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;AAAA,CAC1F;AAED,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAAC,KAI5B,EAAU;IACV,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,eAAe,EAAE,GAAG,CAAC,CAAC;IAChD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;IACrC,OAAO,SAAS,CAAC,GAAG,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;AAAA,CAC3E","sourcesContent":["/**\n * Observation identity and digests — U1.\n *\n * `observationId` binds an execution event (run, operation, sequence) to its\n * content digest. It is intentionally not a bare content hash: identical bytes\n * from two different executions are different events and must not collapse into\n * one record. Digests here are integrity checks, not provenance authentication.\n */\nimport { createHash } from \"node:crypto\";\nimport { integer, text } from \"../metacognition/validation.ts\";\n\nexport function sha256Hex(data: Uint8Array | string): string {\n\treturn createHash(\"sha256\")\n\t\t.update(data as Uint8Array)\n\t\t.digest(\"hex\");\n}\n\nexport function observationId(input: {\n\treadonly runId: string;\n\treadonly operationId: string;\n\treadonly sequence: number;\n\treadonly rawDigest: string;\n}): string {\n\ttext(input.runId, \"runId\", 256);\n\ttext(input.operationId, \"operationId\", 256);\n\tinteger(input.sequence, \"sequence\");\n\ttext(input.rawDigest, \"rawDigest\", 128);\n\treturn sha256Hex(`${input.runId}${input.operationId}${input.sequence}${input.rawDigest}`);\n}\n\n/** Deterministic digest of a derived view's transform + source + params. */\nexport function viewDigestOf(input: {\n\treadonly observationId: string;\n\treadonly viewKind: string;\n\treadonly params: string;\n}): string {\n\ttext(input.observationId, \"observationId\", 128);\n\ttext(input.viewKind, \"viewKind\", 32);\n\treturn sha256Hex(`${input.observationId}${input.viewKind}${input.params}`);\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observation kernel — U1/U2/U3 substrate of the upgraded SoL-Pi design.
|
|
3
|
+
*
|
|
4
|
+
* Pure, deterministic, bounded modules: raw-observation storage with byte-
|
|
5
|
+
* scoped reads, deterministic views with a coverage gate, and a shadow
|
|
6
|
+
* observation-mode recorder. No model calls, no I/O, no completion authority.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./identity.ts";
|
|
9
|
+
export * from "./observe-mode.ts";
|
|
10
|
+
export * from "./store.ts";
|
|
11
|
+
export * from "./types.ts";
|
|
12
|
+
export * from "./view.ts";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observation/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC","sourcesContent":["/**\n * Observation kernel — U1/U2/U3 substrate of the upgraded SoL-Pi design.\n *\n * Pure, deterministic, bounded modules: raw-observation storage with byte-\n * scoped reads, deterministic views with a coverage gate, and a shadow\n * observation-mode recorder. No model calls, no I/O, no completion authority.\n */\nexport * from \"./identity.ts\";\nexport * from \"./observe-mode.ts\";\nexport * from \"./store.ts\";\nexport * from \"./types.ts\";\nexport * from \"./view.ts\";\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observation kernel — U1/U2/U3 substrate of the upgraded SoL-Pi design.
|
|
3
|
+
*
|
|
4
|
+
* Pure, deterministic, bounded modules: raw-observation storage with byte-
|
|
5
|
+
* scoped reads, deterministic views with a coverage gate, and a shadow
|
|
6
|
+
* observation-mode recorder. No model calls, no I/O, no completion authority.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./identity.js";
|
|
9
|
+
export * from "./observe-mode.js";
|
|
10
|
+
export * from "./store.js";
|
|
11
|
+
export * from "./types.js";
|
|
12
|
+
export * from "./view.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/observation/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC","sourcesContent":["/**\n * Observation kernel — U1/U2/U3 substrate of the upgraded SoL-Pi design.\n *\n * Pure, deterministic, bounded modules: raw-observation storage with byte-\n * scoped reads, deterministic views with a coverage gate, and a shadow\n * observation-mode recorder. No model calls, no I/O, no completion authority.\n */\nexport * from \"./identity.ts\";\nexport * from \"./observe-mode.ts\";\nexport * from \"./store.ts\";\nexport * from \"./types.ts\";\nexport * from \"./view.ts\";\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observation-mode recorder — U1 shadow evaluation.
|
|
3
|
+
*
|
|
4
|
+
* Records what the coverage-gated deterministic view would have chosen and the
|
|
5
|
+
* upper-bound token saving, without changing what the model actually receives.
|
|
6
|
+
* A projected saving is an estimate, never an achieved saving — promotion out
|
|
7
|
+
* of observation mode requires a real comparison on the same budget.
|
|
8
|
+
*/
|
|
9
|
+
import type { ObservationView } from "./types.ts";
|
|
10
|
+
export interface ObservationChoiceRecord {
|
|
11
|
+
readonly observationId: string;
|
|
12
|
+
readonly observedTokens: number;
|
|
13
|
+
readonly chosenTokens: number;
|
|
14
|
+
readonly chosenViewKind: string;
|
|
15
|
+
readonly savedTokensUpperBound: number;
|
|
16
|
+
readonly coverageStatus: string;
|
|
17
|
+
readonly infeasible: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ObservationModeSummary {
|
|
20
|
+
readonly observations: number;
|
|
21
|
+
readonly observedTokens: number;
|
|
22
|
+
readonly chosenTokens: number;
|
|
23
|
+
readonly savedTokensUpperBound: number;
|
|
24
|
+
readonly infeasible: number;
|
|
25
|
+
readonly coverageComplete: number;
|
|
26
|
+
readonly coveragePartial: number;
|
|
27
|
+
readonly coverageUnknown: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ObservationModeRecorder {
|
|
30
|
+
record(choice: {
|
|
31
|
+
readonly observationId: string;
|
|
32
|
+
readonly observedTokens: number;
|
|
33
|
+
readonly chosenView: ObservationView | null;
|
|
34
|
+
readonly requiredFactIds?: readonly string[];
|
|
35
|
+
}): ObservationChoiceRecord;
|
|
36
|
+
readonly records: readonly ObservationChoiceRecord[];
|
|
37
|
+
summary(): ObservationModeSummary;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Pure recorder: given what the model actually saw (`observedTokens`) and what
|
|
41
|
+
* the gated selector would have chosen, emit one decision record. A null
|
|
42
|
+
* `chosenView` means the candidate set was infeasible under the required
|
|
43
|
+
* coverage — recorded as such, never converted into an implicit success.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createObservationModeRecorder(): ObservationModeRecorder;
|
|
46
|
+
//# sourceMappingURL=observe-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-mode.d.ts","sourceRoot":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;;;;GAKG;AACH,wBAAgB,6BAA6B,IAAI,uBAAuB,CA+DvE","sourcesContent":["/**\n * Observation-mode recorder — U1 shadow evaluation.\n *\n * Records what the coverage-gated deterministic view would have chosen and the\n * upper-bound token saving, without changing what the model actually receives.\n * A projected saving is an estimate, never an achieved saving — promotion out\n * of observation mode requires a real comparison on the same budget.\n */\n\nimport { ensure, integer, text } from \"../metacognition/validation.ts\";\nimport type { ObservationView } from \"./types.ts\";\n\nexport interface ObservationChoiceRecord {\n\treadonly observationId: string;\n\treadonly observedTokens: number;\n\treadonly chosenTokens: number;\n\treadonly chosenViewKind: string;\n\treadonly savedTokensUpperBound: number;\n\treadonly coverageStatus: string;\n\treadonly infeasible: boolean;\n}\n\nexport interface ObservationModeSummary {\n\treadonly observations: number;\n\treadonly observedTokens: number;\n\treadonly chosenTokens: number;\n\treadonly savedTokensUpperBound: number;\n\treadonly infeasible: number;\n\treadonly coverageComplete: number;\n\treadonly coveragePartial: number;\n\treadonly coverageUnknown: number;\n}\n\nexport interface ObservationModeRecorder {\n\trecord(choice: {\n\t\treadonly observationId: string;\n\t\treadonly observedTokens: number;\n\t\treadonly chosenView: ObservationView | null;\n\t\treadonly requiredFactIds?: readonly string[];\n\t}): ObservationChoiceRecord;\n\treadonly records: readonly ObservationChoiceRecord[];\n\tsummary(): ObservationModeSummary;\n}\n\n/**\n * Pure recorder: given what the model actually saw (`observedTokens`) and what\n * the gated selector would have chosen, emit one decision record. A null\n * `chosenView` means the candidate set was infeasible under the required\n * coverage — recorded as such, never converted into an implicit success.\n */\nexport function createObservationModeRecorder(): ObservationModeRecorder {\n\tconst records: ObservationChoiceRecord[] = [];\n\treturn {\n\t\trecord(choice) {\n\t\t\ttext(choice.observationId, \"observationId\", 128);\n\t\t\tinteger(choice.observedTokens, \"observedTokens\");\n\t\t\tconst chosen = choice.chosenView;\n\t\t\tconst record: ObservationChoiceRecord =\n\t\t\t\tchosen === null\n\t\t\t\t\t? Object.freeze({\n\t\t\t\t\t\t\tobservationId: choice.observationId,\n\t\t\t\t\t\t\tobservedTokens: choice.observedTokens,\n\t\t\t\t\t\t\tchosenTokens: choice.observedTokens,\n\t\t\t\t\t\t\tchosenViewKind: \"infeasible\",\n\t\t\t\t\t\t\tsavedTokensUpperBound: 0,\n\t\t\t\t\t\t\tcoverageStatus: \"unknown\",\n\t\t\t\t\t\t\tinfeasible: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t: Object.freeze({\n\t\t\t\t\t\t\tobservationId: choice.observationId,\n\t\t\t\t\t\t\tobservedTokens: choice.observedTokens,\n\t\t\t\t\t\t\tchosenTokens: chosen.estimatedTokens,\n\t\t\t\t\t\t\tchosenViewKind: chosen.viewKind,\n\t\t\t\t\t\t\tsavedTokensUpperBound: Math.max(0, choice.observedTokens - chosen.estimatedTokens),\n\t\t\t\t\t\t\tcoverageStatus: chosen.coverageStatus,\n\t\t\t\t\t\t\tinfeasible: false,\n\t\t\t\t\t\t});\n\t\t\tensure(Number.isFinite(record.savedTokensUpperBound), \"savedTokensUpperBound must be finite\");\n\t\t\trecords.push(record);\n\t\t\treturn record;\n\t\t},\n\t\tget records() {\n\t\t\treturn records;\n\t\t},\n\t\tsummary() {\n\t\t\tlet observedTokens = 0;\n\t\t\tlet chosenTokens = 0;\n\t\t\tlet savedTokensUpperBound = 0;\n\t\t\tlet infeasible = 0;\n\t\t\tlet coverageComplete = 0;\n\t\t\tlet coveragePartial = 0;\n\t\t\tlet coverageUnknown = 0;\n\t\t\tfor (const r of records) {\n\t\t\t\tobservedTokens += r.observedTokens;\n\t\t\t\tchosenTokens += r.chosenTokens;\n\t\t\t\tsavedTokensUpperBound += r.savedTokensUpperBound;\n\t\t\t\tif (r.infeasible) infeasible += 1;\n\t\t\t\tif (r.coverageStatus === \"complete\") coverageComplete += 1;\n\t\t\t\telse if (r.coverageStatus === \"partial\") coveragePartial += 1;\n\t\t\t\telse coverageUnknown += 1;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tobservations: records.length,\n\t\t\t\tobservedTokens,\n\t\t\t\tchosenTokens,\n\t\t\t\tsavedTokensUpperBound,\n\t\t\t\tinfeasible,\n\t\t\t\tcoverageComplete,\n\t\t\t\tcoveragePartial,\n\t\t\t\tcoverageUnknown,\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observation-mode recorder — U1 shadow evaluation.
|
|
3
|
+
*
|
|
4
|
+
* Records what the coverage-gated deterministic view would have chosen and the
|
|
5
|
+
* upper-bound token saving, without changing what the model actually receives.
|
|
6
|
+
* A projected saving is an estimate, never an achieved saving — promotion out
|
|
7
|
+
* of observation mode requires a real comparison on the same budget.
|
|
8
|
+
*/
|
|
9
|
+
import { ensure, integer, text } from "../metacognition/validation.js";
|
|
10
|
+
/**
|
|
11
|
+
* Pure recorder: given what the model actually saw (`observedTokens`) and what
|
|
12
|
+
* the gated selector would have chosen, emit one decision record. A null
|
|
13
|
+
* `chosenView` means the candidate set was infeasible under the required
|
|
14
|
+
* coverage — recorded as such, never converted into an implicit success.
|
|
15
|
+
*/
|
|
16
|
+
export function createObservationModeRecorder() {
|
|
17
|
+
const records = [];
|
|
18
|
+
return {
|
|
19
|
+
record(choice) {
|
|
20
|
+
text(choice.observationId, "observationId", 128);
|
|
21
|
+
integer(choice.observedTokens, "observedTokens");
|
|
22
|
+
const chosen = choice.chosenView;
|
|
23
|
+
const record = chosen === null
|
|
24
|
+
? Object.freeze({
|
|
25
|
+
observationId: choice.observationId,
|
|
26
|
+
observedTokens: choice.observedTokens,
|
|
27
|
+
chosenTokens: choice.observedTokens,
|
|
28
|
+
chosenViewKind: "infeasible",
|
|
29
|
+
savedTokensUpperBound: 0,
|
|
30
|
+
coverageStatus: "unknown",
|
|
31
|
+
infeasible: true,
|
|
32
|
+
})
|
|
33
|
+
: Object.freeze({
|
|
34
|
+
observationId: choice.observationId,
|
|
35
|
+
observedTokens: choice.observedTokens,
|
|
36
|
+
chosenTokens: chosen.estimatedTokens,
|
|
37
|
+
chosenViewKind: chosen.viewKind,
|
|
38
|
+
savedTokensUpperBound: Math.max(0, choice.observedTokens - chosen.estimatedTokens),
|
|
39
|
+
coverageStatus: chosen.coverageStatus,
|
|
40
|
+
infeasible: false,
|
|
41
|
+
});
|
|
42
|
+
ensure(Number.isFinite(record.savedTokensUpperBound), "savedTokensUpperBound must be finite");
|
|
43
|
+
records.push(record);
|
|
44
|
+
return record;
|
|
45
|
+
},
|
|
46
|
+
get records() {
|
|
47
|
+
return records;
|
|
48
|
+
},
|
|
49
|
+
summary() {
|
|
50
|
+
let observedTokens = 0;
|
|
51
|
+
let chosenTokens = 0;
|
|
52
|
+
let savedTokensUpperBound = 0;
|
|
53
|
+
let infeasible = 0;
|
|
54
|
+
let coverageComplete = 0;
|
|
55
|
+
let coveragePartial = 0;
|
|
56
|
+
let coverageUnknown = 0;
|
|
57
|
+
for (const r of records) {
|
|
58
|
+
observedTokens += r.observedTokens;
|
|
59
|
+
chosenTokens += r.chosenTokens;
|
|
60
|
+
savedTokensUpperBound += r.savedTokensUpperBound;
|
|
61
|
+
if (r.infeasible)
|
|
62
|
+
infeasible += 1;
|
|
63
|
+
if (r.coverageStatus === "complete")
|
|
64
|
+
coverageComplete += 1;
|
|
65
|
+
else if (r.coverageStatus === "partial")
|
|
66
|
+
coveragePartial += 1;
|
|
67
|
+
else
|
|
68
|
+
coverageUnknown += 1;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
observations: records.length,
|
|
72
|
+
observedTokens,
|
|
73
|
+
chosenTokens,
|
|
74
|
+
savedTokensUpperBound,
|
|
75
|
+
infeasible,
|
|
76
|
+
coverageComplete,
|
|
77
|
+
coveragePartial,
|
|
78
|
+
coverageUnknown,
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=observe-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe-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AsC,CAAC,CAAC;YAC9F,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO,MAAM,CAAC;QAAA,CACd;QACD,IAAI,OAAO,GAAG;YACb,OAAO,OAAO,CAAC;QAAA,CACf;QACD,OAAO,GAAG;YACT,IAAI,cAAc,GAAG,CAAC,CAAC;YACvB,IAAI,YAAY,GAAG,CAAC,CAAC;YACrB,IAAI,qBAAqB,GAAG,CAAC,CAAC;YAC9B,IAAI,UAAU,GAAG,CAAC,CAAC;YACnB,IAAI,gBAAgB,GAAG,CAAC,CAAC;YACzB,IAAI,eAAe,GAAG,CAAC,CAAC;YACxB,IAAI,eAAe,GAAG,CAAC,CAAC;YACxB,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;gBACzB,cAAc,IAAI,CAAC,CAAC,cAAc,CAAC;gBACnC,YAAY,IAAI,CAAC,CAAC,YAAY,CAAC;gBAC/B,qBAAqB,IAAI,CAAC,CAAC,qBAAqB,CAAC;gBACjD,IAAI,CAAC,CAAC,UAAU;oBAAE,UAAU,IAAI,CAAC,CAAC;gBAClC,IAAI,CAAC,CAAC,cAAc,KAAK,UAAU;oBAAE,gBAAgB,IAAI,CAAC,CAAC;qBACtD,IAAI,CAAC,CAAC,cAAc,KAAK,SAAS;oBAAE,eAAe,IAAI,CAAC,CAAC;;oBACzD,eAAe,IAAI,CAAC,CAAC;YAC3B,CAAC;YACD,OAAO;gBACN,YAAY,EAAE,OAAO,CAAC,MAAM;gBAC5B,cAAc;gBACd,YAAY;gBACZ,qBAAqB;gBACrB,UAAU;gBACV,gBAAgB;gBAChB,eAAe;gBACf,eAAe;aACf,CAAC;QAAA,CACF;KACD,CAAC;AAAA,CACF","sourcesContent":["/**\n * Observation-mode recorder — U1 shadow evaluation.\n *\n * Records what the coverage-gated deterministic view would have chosen and the\n * upper-bound token saving, without changing what the model actually receives.\n * A projected saving is an estimate, never an achieved saving — promotion out\n * of observation mode requires a real comparison on the same budget.\n */\n\nimport { ensure, integer, text } from \"../metacognition/validation.ts\";\nimport type { ObservationView } from \"./types.ts\";\n\nexport interface ObservationChoiceRecord {\n\treadonly observationId: string;\n\treadonly observedTokens: number;\n\treadonly chosenTokens: number;\n\treadonly chosenViewKind: string;\n\treadonly savedTokensUpperBound: number;\n\treadonly coverageStatus: string;\n\treadonly infeasible: boolean;\n}\n\nexport interface ObservationModeSummary {\n\treadonly observations: number;\n\treadonly observedTokens: number;\n\treadonly chosenTokens: number;\n\treadonly savedTokensUpperBound: number;\n\treadonly infeasible: number;\n\treadonly coverageComplete: number;\n\treadonly coveragePartial: number;\n\treadonly coverageUnknown: number;\n}\n\nexport interface ObservationModeRecorder {\n\trecord(choice: {\n\t\treadonly observationId: string;\n\t\treadonly observedTokens: number;\n\t\treadonly chosenView: ObservationView | null;\n\t\treadonly requiredFactIds?: readonly string[];\n\t}): ObservationChoiceRecord;\n\treadonly records: readonly ObservationChoiceRecord[];\n\tsummary(): ObservationModeSummary;\n}\n\n/**\n * Pure recorder: given what the model actually saw (`observedTokens`) and what\n * the gated selector would have chosen, emit one decision record. A null\n * `chosenView` means the candidate set was infeasible under the required\n * coverage — recorded as such, never converted into an implicit success.\n */\nexport function createObservationModeRecorder(): ObservationModeRecorder {\n\tconst records: ObservationChoiceRecord[] = [];\n\treturn {\n\t\trecord(choice) {\n\t\t\ttext(choice.observationId, \"observationId\", 128);\n\t\t\tinteger(choice.observedTokens, \"observedTokens\");\n\t\t\tconst chosen = choice.chosenView;\n\t\t\tconst record: ObservationChoiceRecord =\n\t\t\t\tchosen === null\n\t\t\t\t\t? Object.freeze({\n\t\t\t\t\t\t\tobservationId: choice.observationId,\n\t\t\t\t\t\t\tobservedTokens: choice.observedTokens,\n\t\t\t\t\t\t\tchosenTokens: choice.observedTokens,\n\t\t\t\t\t\t\tchosenViewKind: \"infeasible\",\n\t\t\t\t\t\t\tsavedTokensUpperBound: 0,\n\t\t\t\t\t\t\tcoverageStatus: \"unknown\",\n\t\t\t\t\t\t\tinfeasible: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t: Object.freeze({\n\t\t\t\t\t\t\tobservationId: choice.observationId,\n\t\t\t\t\t\t\tobservedTokens: choice.observedTokens,\n\t\t\t\t\t\t\tchosenTokens: chosen.estimatedTokens,\n\t\t\t\t\t\t\tchosenViewKind: chosen.viewKind,\n\t\t\t\t\t\t\tsavedTokensUpperBound: Math.max(0, choice.observedTokens - chosen.estimatedTokens),\n\t\t\t\t\t\t\tcoverageStatus: chosen.coverageStatus,\n\t\t\t\t\t\t\tinfeasible: false,\n\t\t\t\t\t\t});\n\t\t\tensure(Number.isFinite(record.savedTokensUpperBound), \"savedTokensUpperBound must be finite\");\n\t\t\trecords.push(record);\n\t\t\treturn record;\n\t\t},\n\t\tget records() {\n\t\t\treturn records;\n\t\t},\n\t\tsummary() {\n\t\t\tlet observedTokens = 0;\n\t\t\tlet chosenTokens = 0;\n\t\t\tlet savedTokensUpperBound = 0;\n\t\t\tlet infeasible = 0;\n\t\t\tlet coverageComplete = 0;\n\t\t\tlet coveragePartial = 0;\n\t\t\tlet coverageUnknown = 0;\n\t\t\tfor (const r of records) {\n\t\t\t\tobservedTokens += r.observedTokens;\n\t\t\t\tchosenTokens += r.chosenTokens;\n\t\t\t\tsavedTokensUpperBound += r.savedTokensUpperBound;\n\t\t\t\tif (r.infeasible) infeasible += 1;\n\t\t\t\tif (r.coverageStatus === \"complete\") coverageComplete += 1;\n\t\t\t\telse if (r.coverageStatus === \"partial\") coveragePartial += 1;\n\t\t\t\telse coverageUnknown += 1;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tobservations: records.length,\n\t\t\t\tobservedTokens,\n\t\t\t\tchosenTokens,\n\t\t\t\tsavedTokensUpperBound,\n\t\t\t\tinfeasible,\n\t\t\t\tcoverageComplete,\n\t\t\t\tcoveragePartial,\n\t\t\t\tcoverageUnknown,\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded raw-observation store — U1.
|
|
3
|
+
*
|
|
4
|
+
* Session-scoped, in-memory, deterministic. Stores exact bytes with their
|
|
5
|
+
* execution identity, and serves byte-range reads that snap to UTF-8 code-point
|
|
6
|
+
* boundaries rather than emitting silently-corrupted text. Over-capacity puts
|
|
7
|
+
* fail closed with `archive-unavailable` instead of silently evicting evidence.
|
|
8
|
+
*/
|
|
9
|
+
import type { ObservationKind, ObservationPrivacy, ObservationReadResult, ObservationStatus, RawObservation } from "./types.ts";
|
|
10
|
+
export interface ObservationStoreOptions {
|
|
11
|
+
readonly maxObservations?: number;
|
|
12
|
+
readonly maxTotalBytes?: number;
|
|
13
|
+
readonly maxObservationBytes?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class ObservationStore {
|
|
16
|
+
private readonly maxObservations;
|
|
17
|
+
private readonly maxTotalBytes;
|
|
18
|
+
private readonly maxObservationBytes;
|
|
19
|
+
private readonly byId;
|
|
20
|
+
private totalBytes;
|
|
21
|
+
constructor(options?: ObservationStoreOptions);
|
|
22
|
+
/** Store one raw observation. Throws (fails closed) on malformed input or capacity. */
|
|
23
|
+
put(input: {
|
|
24
|
+
readonly sessionId: string;
|
|
25
|
+
readonly runId: string;
|
|
26
|
+
readonly operationId: string;
|
|
27
|
+
readonly sequence: number;
|
|
28
|
+
readonly bytes: Uint8Array;
|
|
29
|
+
readonly status: ObservationStatus;
|
|
30
|
+
readonly kind?: ObservationKind;
|
|
31
|
+
readonly privacy?: ObservationPrivacy;
|
|
32
|
+
readonly sourceComplete?: boolean;
|
|
33
|
+
readonly toolCallId?: string;
|
|
34
|
+
}): RawObservation;
|
|
35
|
+
get(observationId: string): RawObservation | undefined;
|
|
36
|
+
has(observationId: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Scoped byte-range read. `scopeSessionId` must equal the observation's own
|
|
39
|
+
* session — a handle never crosses a session boundary. Byte offsets snap to
|
|
40
|
+
* UTF-8 boundaries; a `strict` range that lands mid-codepoint returns
|
|
41
|
+
* `utf8-boundary` instead of emitting corrupted text.
|
|
42
|
+
*/
|
|
43
|
+
read(input: {
|
|
44
|
+
readonly observationId: string;
|
|
45
|
+
readonly scopeSessionId: string;
|
|
46
|
+
readonly byteOffset: number;
|
|
47
|
+
readonly maxBytes: number;
|
|
48
|
+
readonly strict?: boolean;
|
|
49
|
+
}): ObservationReadResult;
|
|
50
|
+
get size(): number;
|
|
51
|
+
get bytes(): number;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/observation/store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EACX,eAAe,EACf,kBAAkB,EAElB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACtC;AAkBD,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqC;IAC1D,OAAO,CAAC,UAAU,CAAK;IAEvB,YAAY,OAAO,GAAE,uBAA4B,EAIhD;IAED,uFAAuF;IACvF,GAAG,CAAC,KAAK,EAAE;QACV,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;QAC3B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;QACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC;QAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC;QACtC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;QAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;KAC7B,GAAG,cAAc,CAmCjB;IAED,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAErD;IAED,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAElC;IAED;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE;QACX,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;QAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;KAC1B,GAAG,qBAAqB,CA+BxB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;CACD","sourcesContent":["/**\n * Bounded raw-observation store — U1.\n *\n * Session-scoped, in-memory, deterministic. Stores exact bytes with their\n * execution identity, and serves byte-range reads that snap to UTF-8 code-point\n * boundaries rather than emitting silently-corrupted text. Over-capacity puts\n * fail closed with `archive-unavailable` instead of silently evicting evidence.\n */\n\nimport { ensure, integer, text } from \"../metacognition/validation.ts\";\nimport { observationId as makeObservationId, sha256Hex } from \"./identity.ts\";\nimport type {\n\tObservationKind,\n\tObservationPrivacy,\n\tObservationRead,\n\tObservationReadResult,\n\tObservationStatus,\n\tRawObservation,\n} from \"./types.ts\";\n\nexport interface ObservationStoreOptions {\n\treadonly maxObservations?: number;\n\treadonly maxTotalBytes?: number;\n\treadonly maxObservationBytes?: number;\n}\n\nconst DEFAULT_MAX_OBSERVATIONS = 512;\nconst DEFAULT_MAX_TOTAL_BYTES = 64 * 1024 * 1024;\nconst DEFAULT_MAX_OBSERVATION_BYTES = 8 * 1024 * 1024;\n\nconst UTF8_DECODER = new TextDecoder(\"utf-8\", { fatal: false });\n\n/** Snap a byte offset down to the nearest UTF-8 code-point boundary. */\nfunction snapUtf8Boundary(bytes: Uint8Array, offset: number): { offset: number; normalized: boolean } {\n\tif (offset <= 0 || offset >= bytes.length)\n\t\treturn { offset: Math.max(0, Math.min(offset, bytes.length)), normalized: false };\n\t// A continuation byte is 0b10xxxxxx; walk back to a lead byte or ASCII.\n\tlet i = offset;\n\twhile (i > 0 && (bytes[i]! & 0xc0) === 0x80) i -= 1;\n\treturn { offset: i, normalized: i !== offset };\n}\n\nexport class ObservationStore {\n\tprivate readonly maxObservations: number;\n\tprivate readonly maxTotalBytes: number;\n\tprivate readonly maxObservationBytes: number;\n\tprivate readonly byId = new Map<string, RawObservation>();\n\tprivate totalBytes = 0;\n\n\tconstructor(options: ObservationStoreOptions = {}) {\n\t\tthis.maxObservations = options.maxObservations ?? DEFAULT_MAX_OBSERVATIONS;\n\t\tthis.maxTotalBytes = options.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;\n\t\tthis.maxObservationBytes = options.maxObservationBytes ?? DEFAULT_MAX_OBSERVATION_BYTES;\n\t}\n\n\t/** Store one raw observation. Throws (fails closed) on malformed input or capacity. */\n\tput(input: {\n\t\treadonly sessionId: string;\n\t\treadonly runId: string;\n\t\treadonly operationId: string;\n\t\treadonly sequence: number;\n\t\treadonly bytes: Uint8Array;\n\t\treadonly status: ObservationStatus;\n\t\treadonly kind?: ObservationKind;\n\t\treadonly privacy?: ObservationPrivacy;\n\t\treadonly sourceComplete?: boolean;\n\t\treadonly toolCallId?: string;\n\t}): RawObservation {\n\t\ttext(input.sessionId, \"sessionId\", 256);\n\t\ttext(input.runId, \"runId\", 256);\n\t\ttext(input.operationId, \"operationId\", 256);\n\t\tinteger(input.sequence, \"sequence\");\n\t\tensure(input.bytes instanceof Uint8Array, \"bytes must be a Uint8Array\");\n\t\tensure(input.bytes.length <= this.maxObservationBytes, \"observation exceeds per-item cap\");\n\t\tif (this.byId.size >= this.maxObservations || this.totalBytes + input.bytes.length > this.maxTotalBytes) {\n\t\t\tthrow new Error(\"archive-unavailable: observation store capacity exceeded\");\n\t\t}\n\t\tconst rawDigest = sha256Hex(input.bytes);\n\t\tconst id = makeObservationId({\n\t\t\trunId: input.runId,\n\t\t\toperationId: input.operationId,\n\t\t\tsequence: input.sequence,\n\t\t\trawDigest,\n\t\t});\n\t\tconst observation: RawObservation = Object.freeze({\n\t\t\tobservationId: id,\n\t\t\tsessionId: input.sessionId,\n\t\t\trunId: input.runId,\n\t\t\toperationId: input.operationId,\n\t\t\tsequence: input.sequence,\n\t\t\trawDigest,\n\t\t\tbyteLength: input.bytes.length,\n\t\t\tbytes: input.bytes,\n\t\t\tstatus: input.status,\n\t\t\tkind: input.kind ?? \"generic\",\n\t\t\tprivacy: input.privacy ?? \"raw-private\",\n\t\t\tsourceComplete: input.sourceComplete ?? true,\n\t\t\t...(input.toolCallId === undefined ? {} : { toolCallId: input.toolCallId }),\n\t\t});\n\t\tthis.byId.set(id, observation);\n\t\tthis.totalBytes += input.bytes.length;\n\t\treturn observation;\n\t}\n\n\tget(observationId: string): RawObservation | undefined {\n\t\treturn this.byId.get(observationId);\n\t}\n\n\thas(observationId: string): boolean {\n\t\treturn this.byId.has(observationId);\n\t}\n\n\t/**\n\t * Scoped byte-range read. `scopeSessionId` must equal the observation's own\n\t * session — a handle never crosses a session boundary. Byte offsets snap to\n\t * UTF-8 boundaries; a `strict` range that lands mid-codepoint returns\n\t * `utf8-boundary` instead of emitting corrupted text.\n\t */\n\tread(input: {\n\t\treadonly observationId: string;\n\t\treadonly scopeSessionId: string;\n\t\treadonly byteOffset: number;\n\t\treadonly maxBytes: number;\n\t\treadonly strict?: boolean;\n\t}): ObservationReadResult {\n\t\ttext(input.observationId, \"observationId\", 128);\n\t\ttext(input.scopeSessionId, \"scopeSessionId\", 256);\n\t\tinteger(input.byteOffset, \"byteOffset\");\n\t\tinteger(input.maxBytes, \"maxBytes\");\n\t\tensure(input.maxBytes > 0, \"maxBytes must be positive\");\n\t\tconst observation = this.byId.get(input.observationId);\n\t\tif (!observation) return { ok: false, error: \"observation-not-found\" };\n\t\tif (observation.sessionId !== input.scopeSessionId) {\n\t\t\treturn { ok: false, error: \"scope-mismatch\" };\n\t\t}\n\t\tif (input.byteOffset > observation.byteLength) {\n\t\t\treturn { ok: false, error: \"invalid-range\" };\n\t\t}\n\t\tconst snapped = snapUtf8Boundary(observation.bytes, input.byteOffset);\n\t\tif (input.strict && snapped.normalized) return { ok: false, error: \"utf8-boundary\" };\n\t\tconst start = snapped.offset;\n\t\tconst end = Math.min(observation.byteLength, start + input.maxBytes);\n\t\tconst chunk = observation.bytes.slice(start, end);\n\t\tconst read: ObservationRead = {\n\t\t\tobservationId: observation.observationId,\n\t\t\ttext: UTF8_DECODER.decode(chunk),\n\t\t\tbyteOffset: start,\n\t\t\tbyteLength: chunk.length,\n\t\t\tnextOffset: end,\n\t\t\teof: end >= observation.byteLength,\n\t\t\ttruncated: end < observation.byteLength,\n\t\t\tsourceComplete: observation.sourceComplete,\n\t\t\tnormalized: snapped.normalized,\n\t\t};\n\t\treturn { ok: true, read };\n\t}\n\n\tget size(): number {\n\t\treturn this.byId.size;\n\t}\n\n\tget bytes(): number {\n\t\treturn this.totalBytes;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded raw-observation store — U1.
|
|
3
|
+
*
|
|
4
|
+
* Session-scoped, in-memory, deterministic. Stores exact bytes with their
|
|
5
|
+
* execution identity, and serves byte-range reads that snap to UTF-8 code-point
|
|
6
|
+
* boundaries rather than emitting silently-corrupted text. Over-capacity puts
|
|
7
|
+
* fail closed with `archive-unavailable` instead of silently evicting evidence.
|
|
8
|
+
*/
|
|
9
|
+
import { ensure, integer, text } from "../metacognition/validation.js";
|
|
10
|
+
import { observationId as makeObservationId, sha256Hex } from "./identity.js";
|
|
11
|
+
const DEFAULT_MAX_OBSERVATIONS = 512;
|
|
12
|
+
const DEFAULT_MAX_TOTAL_BYTES = 64 * 1024 * 1024;
|
|
13
|
+
const DEFAULT_MAX_OBSERVATION_BYTES = 8 * 1024 * 1024;
|
|
14
|
+
const UTF8_DECODER = new TextDecoder("utf-8", { fatal: false });
|
|
15
|
+
/** Snap a byte offset down to the nearest UTF-8 code-point boundary. */
|
|
16
|
+
function snapUtf8Boundary(bytes, offset) {
|
|
17
|
+
if (offset <= 0 || offset >= bytes.length)
|
|
18
|
+
return { offset: Math.max(0, Math.min(offset, bytes.length)), normalized: false };
|
|
19
|
+
// A continuation byte is 0b10xxxxxx; walk back to a lead byte or ASCII.
|
|
20
|
+
let i = offset;
|
|
21
|
+
while (i > 0 && (bytes[i] & 0xc0) === 0x80)
|
|
22
|
+
i -= 1;
|
|
23
|
+
return { offset: i, normalized: i !== offset };
|
|
24
|
+
}
|
|
25
|
+
export class ObservationStore {
|
|
26
|
+
maxObservations;
|
|
27
|
+
maxTotalBytes;
|
|
28
|
+
maxObservationBytes;
|
|
29
|
+
byId = new Map();
|
|
30
|
+
totalBytes = 0;
|
|
31
|
+
constructor(options = {}) {
|
|
32
|
+
this.maxObservations = options.maxObservations ?? DEFAULT_MAX_OBSERVATIONS;
|
|
33
|
+
this.maxTotalBytes = options.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;
|
|
34
|
+
this.maxObservationBytes = options.maxObservationBytes ?? DEFAULT_MAX_OBSERVATION_BYTES;
|
|
35
|
+
}
|
|
36
|
+
/** Store one raw observation. Throws (fails closed) on malformed input or capacity. */
|
|
37
|
+
put(input) {
|
|
38
|
+
text(input.sessionId, "sessionId", 256);
|
|
39
|
+
text(input.runId, "runId", 256);
|
|
40
|
+
text(input.operationId, "operationId", 256);
|
|
41
|
+
integer(input.sequence, "sequence");
|
|
42
|
+
ensure(input.bytes instanceof Uint8Array, "bytes must be a Uint8Array");
|
|
43
|
+
ensure(input.bytes.length <= this.maxObservationBytes, "observation exceeds per-item cap");
|
|
44
|
+
if (this.byId.size >= this.maxObservations || this.totalBytes + input.bytes.length > this.maxTotalBytes) {
|
|
45
|
+
throw new Error("archive-unavailable: observation store capacity exceeded");
|
|
46
|
+
}
|
|
47
|
+
const rawDigest = sha256Hex(input.bytes);
|
|
48
|
+
const id = makeObservationId({
|
|
49
|
+
runId: input.runId,
|
|
50
|
+
operationId: input.operationId,
|
|
51
|
+
sequence: input.sequence,
|
|
52
|
+
rawDigest,
|
|
53
|
+
});
|
|
54
|
+
const observation = Object.freeze({
|
|
55
|
+
observationId: id,
|
|
56
|
+
sessionId: input.sessionId,
|
|
57
|
+
runId: input.runId,
|
|
58
|
+
operationId: input.operationId,
|
|
59
|
+
sequence: input.sequence,
|
|
60
|
+
rawDigest,
|
|
61
|
+
byteLength: input.bytes.length,
|
|
62
|
+
bytes: input.bytes,
|
|
63
|
+
status: input.status,
|
|
64
|
+
kind: input.kind ?? "generic",
|
|
65
|
+
privacy: input.privacy ?? "raw-private",
|
|
66
|
+
sourceComplete: input.sourceComplete ?? true,
|
|
67
|
+
...(input.toolCallId === undefined ? {} : { toolCallId: input.toolCallId }),
|
|
68
|
+
});
|
|
69
|
+
this.byId.set(id, observation);
|
|
70
|
+
this.totalBytes += input.bytes.length;
|
|
71
|
+
return observation;
|
|
72
|
+
}
|
|
73
|
+
get(observationId) {
|
|
74
|
+
return this.byId.get(observationId);
|
|
75
|
+
}
|
|
76
|
+
has(observationId) {
|
|
77
|
+
return this.byId.has(observationId);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Scoped byte-range read. `scopeSessionId` must equal the observation's own
|
|
81
|
+
* session — a handle never crosses a session boundary. Byte offsets snap to
|
|
82
|
+
* UTF-8 boundaries; a `strict` range that lands mid-codepoint returns
|
|
83
|
+
* `utf8-boundary` instead of emitting corrupted text.
|
|
84
|
+
*/
|
|
85
|
+
read(input) {
|
|
86
|
+
text(input.observationId, "observationId", 128);
|
|
87
|
+
text(input.scopeSessionId, "scopeSessionId", 256);
|
|
88
|
+
integer(input.byteOffset, "byteOffset");
|
|
89
|
+
integer(input.maxBytes, "maxBytes");
|
|
90
|
+
ensure(input.maxBytes > 0, "maxBytes must be positive");
|
|
91
|
+
const observation = this.byId.get(input.observationId);
|
|
92
|
+
if (!observation)
|
|
93
|
+
return { ok: false, error: "observation-not-found" };
|
|
94
|
+
if (observation.sessionId !== input.scopeSessionId) {
|
|
95
|
+
return { ok: false, error: "scope-mismatch" };
|
|
96
|
+
}
|
|
97
|
+
if (input.byteOffset > observation.byteLength) {
|
|
98
|
+
return { ok: false, error: "invalid-range" };
|
|
99
|
+
}
|
|
100
|
+
const snapped = snapUtf8Boundary(observation.bytes, input.byteOffset);
|
|
101
|
+
if (input.strict && snapped.normalized)
|
|
102
|
+
return { ok: false, error: "utf8-boundary" };
|
|
103
|
+
const start = snapped.offset;
|
|
104
|
+
const end = Math.min(observation.byteLength, start + input.maxBytes);
|
|
105
|
+
const chunk = observation.bytes.slice(start, end);
|
|
106
|
+
const read = {
|
|
107
|
+
observationId: observation.observationId,
|
|
108
|
+
text: UTF8_DECODER.decode(chunk),
|
|
109
|
+
byteOffset: start,
|
|
110
|
+
byteLength: chunk.length,
|
|
111
|
+
nextOffset: end,
|
|
112
|
+
eof: end >= observation.byteLength,
|
|
113
|
+
truncated: end < observation.byteLength,
|
|
114
|
+
sourceComplete: observation.sourceComplete,
|
|
115
|
+
normalized: snapped.normalized,
|
|
116
|
+
};
|
|
117
|
+
return { ok: true, read };
|
|
118
|
+
}
|
|
119
|
+
get size() {
|
|
120
|
+
return this.byId.size;
|
|
121
|
+
}
|
|
122
|
+
get bytes() {
|
|
123
|
+
return this.totalBytes;
|
|
124
|
+
}
|
|
125
|
+
}
|
|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AAC;QAClD,MAAM,IAAI,GAAoB;YAC7B,aAAa,EAAE,WAAW,CAAC,aAAa;YACxC,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;YAChC,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,KAAK,CAAC,MAAM;YACxB,UAAU,EAAE,GAAG;YACf,GAAG,EAAE,GAAG,IAAI,WAAW,CAAC,UAAU;YAClC,SAAS,EAAE,GAAG,GAAG,WAAW,CAAC,UAAU;YACvC,cAAc,EAAE,WAAW,CAAC,cAAc;YAC1C,UAAU,EAAE,OAAO,CAAC,UAAU;SAC9B,CAAC;QACF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAAA,CAC1B;IAED,IAAI,IAAI,GAAW;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAAA,CACtB;IAED,IAAI,KAAK,GAAW;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IAAA,CACvB;CACD","sourcesContent":["/**\n * Bounded raw-observation store — U1.\n *\n * Session-scoped, in-memory, deterministic. Stores exact bytes with their\n * execution identity, and serves byte-range reads that snap to UTF-8 code-point\n * boundaries rather than emitting silently-corrupted text. Over-capacity puts\n * fail closed with `archive-unavailable` instead of silently evicting evidence.\n */\n\nimport { ensure, integer, text } from \"../metacognition/validation.ts\";\nimport { observationId as makeObservationId, sha256Hex } from \"./identity.ts\";\nimport type {\n\tObservationKind,\n\tObservationPrivacy,\n\tObservationRead,\n\tObservationReadResult,\n\tObservationStatus,\n\tRawObservation,\n} from \"./types.ts\";\n\nexport interface ObservationStoreOptions {\n\treadonly maxObservations?: number;\n\treadonly maxTotalBytes?: number;\n\treadonly maxObservationBytes?: number;\n}\n\nconst DEFAULT_MAX_OBSERVATIONS = 512;\nconst DEFAULT_MAX_TOTAL_BYTES = 64 * 1024 * 1024;\nconst DEFAULT_MAX_OBSERVATION_BYTES = 8 * 1024 * 1024;\n\nconst UTF8_DECODER = new TextDecoder(\"utf-8\", { fatal: false });\n\n/** Snap a byte offset down to the nearest UTF-8 code-point boundary. */\nfunction snapUtf8Boundary(bytes: Uint8Array, offset: number): { offset: number; normalized: boolean } {\n\tif (offset <= 0 || offset >= bytes.length)\n\t\treturn { offset: Math.max(0, Math.min(offset, bytes.length)), normalized: false };\n\t// A continuation byte is 0b10xxxxxx; walk back to a lead byte or ASCII.\n\tlet i = offset;\n\twhile (i > 0 && (bytes[i]! & 0xc0) === 0x80) i -= 1;\n\treturn { offset: i, normalized: i !== offset };\n}\n\nexport class ObservationStore {\n\tprivate readonly maxObservations: number;\n\tprivate readonly maxTotalBytes: number;\n\tprivate readonly maxObservationBytes: number;\n\tprivate readonly byId = new Map<string, RawObservation>();\n\tprivate totalBytes = 0;\n\n\tconstructor(options: ObservationStoreOptions = {}) {\n\t\tthis.maxObservations = options.maxObservations ?? DEFAULT_MAX_OBSERVATIONS;\n\t\tthis.maxTotalBytes = options.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;\n\t\tthis.maxObservationBytes = options.maxObservationBytes ?? DEFAULT_MAX_OBSERVATION_BYTES;\n\t}\n\n\t/** Store one raw observation. Throws (fails closed) on malformed input or capacity. */\n\tput(input: {\n\t\treadonly sessionId: string;\n\t\treadonly runId: string;\n\t\treadonly operationId: string;\n\t\treadonly sequence: number;\n\t\treadonly bytes: Uint8Array;\n\t\treadonly status: ObservationStatus;\n\t\treadonly kind?: ObservationKind;\n\t\treadonly privacy?: ObservationPrivacy;\n\t\treadonly sourceComplete?: boolean;\n\t\treadonly toolCallId?: string;\n\t}): RawObservation {\n\t\ttext(input.sessionId, \"sessionId\", 256);\n\t\ttext(input.runId, \"runId\", 256);\n\t\ttext(input.operationId, \"operationId\", 256);\n\t\tinteger(input.sequence, \"sequence\");\n\t\tensure(input.bytes instanceof Uint8Array, \"bytes must be a Uint8Array\");\n\t\tensure(input.bytes.length <= this.maxObservationBytes, \"observation exceeds per-item cap\");\n\t\tif (this.byId.size >= this.maxObservations || this.totalBytes + input.bytes.length > this.maxTotalBytes) {\n\t\t\tthrow new Error(\"archive-unavailable: observation store capacity exceeded\");\n\t\t}\n\t\tconst rawDigest = sha256Hex(input.bytes);\n\t\tconst id = makeObservationId({\n\t\t\trunId: input.runId,\n\t\t\toperationId: input.operationId,\n\t\t\tsequence: input.sequence,\n\t\t\trawDigest,\n\t\t});\n\t\tconst observation: RawObservation = Object.freeze({\n\t\t\tobservationId: id,\n\t\t\tsessionId: input.sessionId,\n\t\t\trunId: input.runId,\n\t\t\toperationId: input.operationId,\n\t\t\tsequence: input.sequence,\n\t\t\trawDigest,\n\t\t\tbyteLength: input.bytes.length,\n\t\t\tbytes: input.bytes,\n\t\t\tstatus: input.status,\n\t\t\tkind: input.kind ?? \"generic\",\n\t\t\tprivacy: input.privacy ?? \"raw-private\",\n\t\t\tsourceComplete: input.sourceComplete ?? true,\n\t\t\t...(input.toolCallId === undefined ? {} : { toolCallId: input.toolCallId }),\n\t\t});\n\t\tthis.byId.set(id, observation);\n\t\tthis.totalBytes += input.bytes.length;\n\t\treturn observation;\n\t}\n\n\tget(observationId: string): RawObservation | undefined {\n\t\treturn this.byId.get(observationId);\n\t}\n\n\thas(observationId: string): boolean {\n\t\treturn this.byId.has(observationId);\n\t}\n\n\t/**\n\t * Scoped byte-range read. `scopeSessionId` must equal the observation's own\n\t * session — a handle never crosses a session boundary. Byte offsets snap to\n\t * UTF-8 boundaries; a `strict` range that lands mid-codepoint returns\n\t * `utf8-boundary` instead of emitting corrupted text.\n\t */\n\tread(input: {\n\t\treadonly observationId: string;\n\t\treadonly scopeSessionId: string;\n\t\treadonly byteOffset: number;\n\t\treadonly maxBytes: number;\n\t\treadonly strict?: boolean;\n\t}): ObservationReadResult {\n\t\ttext(input.observationId, \"observationId\", 128);\n\t\ttext(input.scopeSessionId, \"scopeSessionId\", 256);\n\t\tinteger(input.byteOffset, \"byteOffset\");\n\t\tinteger(input.maxBytes, \"maxBytes\");\n\t\tensure(input.maxBytes > 0, \"maxBytes must be positive\");\n\t\tconst observation = this.byId.get(input.observationId);\n\t\tif (!observation) return { ok: false, error: \"observation-not-found\" };\n\t\tif (observation.sessionId !== input.scopeSessionId) {\n\t\t\treturn { ok: false, error: \"scope-mismatch\" };\n\t\t}\n\t\tif (input.byteOffset > observation.byteLength) {\n\t\t\treturn { ok: false, error: \"invalid-range\" };\n\t\t}\n\t\tconst snapped = snapUtf8Boundary(observation.bytes, input.byteOffset);\n\t\tif (input.strict && snapped.normalized) return { ok: false, error: \"utf8-boundary\" };\n\t\tconst start = snapped.offset;\n\t\tconst end = Math.min(observation.byteLength, start + input.maxBytes);\n\t\tconst chunk = observation.bytes.slice(start, end);\n\t\tconst read: ObservationRead = {\n\t\t\tobservationId: observation.observationId,\n\t\t\ttext: UTF8_DECODER.decode(chunk),\n\t\t\tbyteOffset: start,\n\t\t\tbyteLength: chunk.length,\n\t\t\tnextOffset: end,\n\t\t\teof: end >= observation.byteLength,\n\t\t\ttruncated: end < observation.byteLength,\n\t\t\tsourceComplete: observation.sourceComplete,\n\t\t\tnormalized: snapped.normalized,\n\t\t};\n\t\treturn { ok: true, read };\n\t}\n\n\tget size(): number {\n\t\treturn this.byId.size;\n\t}\n\n\tget bytes(): number {\n\t\treturn this.totalBytes;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observation kernel types — U1/U2 of the upgraded SoL-Pi design.
|
|
3
|
+
*
|
|
4
|
+
* Raw observations are host-owned execution artifacts. Model-facing views are
|
|
5
|
+
* derived projections and never replace the raw authority: `taskVerdict` is
|
|
6
|
+
* always `not-assessed` here because a view cannot prove completion.
|
|
7
|
+
*/
|
|
8
|
+
export type ObservationStatus = "exit" | "signal" | "partial" | "unavailable";
|
|
9
|
+
export type ObservationPrivacy = "raw-private" | "approved-sanitized";
|
|
10
|
+
export type ObservationKind = "log" | "test" | "command" | "file" | "dom" | "network" | "generic";
|
|
11
|
+
/**
|
|
12
|
+
* A stored execution artifact. `observationId` binds the run, operation and
|
|
13
|
+
* sequence to the content digest, so two identical byte outputs from different
|
|
14
|
+
* executions remain distinct events (never content-hash deduped into one).
|
|
15
|
+
*/
|
|
16
|
+
export interface RawObservation {
|
|
17
|
+
readonly observationId: string;
|
|
18
|
+
readonly sessionId: string;
|
|
19
|
+
readonly runId: string;
|
|
20
|
+
readonly operationId: string;
|
|
21
|
+
readonly sequence: number;
|
|
22
|
+
readonly rawDigest: string;
|
|
23
|
+
readonly byteLength: number;
|
|
24
|
+
readonly bytes: Uint8Array;
|
|
25
|
+
readonly status: ObservationStatus;
|
|
26
|
+
readonly kind: ObservationKind;
|
|
27
|
+
readonly privacy: ObservationPrivacy;
|
|
28
|
+
/** False when the capture itself was truncated upstream — never claim "full raw". */
|
|
29
|
+
readonly sourceComplete: boolean;
|
|
30
|
+
readonly toolCallId?: string;
|
|
31
|
+
}
|
|
32
|
+
export type ObservationViewKind = "full" | "excerpt" | "evidence" | "pointer";
|
|
33
|
+
export type ObservationCoverageStatus = "complete" | "partial" | "unknown";
|
|
34
|
+
/**
|
|
35
|
+
* A model-facing projection of a stored observation. `transformationDigest`
|
|
36
|
+
* binds the view to the deterministic transform that produced it, and
|
|
37
|
+
* `coverageStatus` records whether the view preserves the required fact atoms.
|
|
38
|
+
*/
|
|
39
|
+
export interface ObservationView {
|
|
40
|
+
readonly viewKind: ObservationViewKind;
|
|
41
|
+
readonly observationId: string;
|
|
42
|
+
readonly parentDigest: string;
|
|
43
|
+
readonly transformationDigest: string;
|
|
44
|
+
readonly text: string;
|
|
45
|
+
readonly estimatedTokens: number;
|
|
46
|
+
readonly coveredFactIds: readonly string[];
|
|
47
|
+
readonly missingRequiredFactIds: readonly string[];
|
|
48
|
+
readonly coverageStatus: ObservationCoverageStatus;
|
|
49
|
+
readonly taskVerdict: "not-assessed";
|
|
50
|
+
}
|
|
51
|
+
/** Result of a scoped, byte-bounded read against a stored observation. */
|
|
52
|
+
export interface ObservationRead {
|
|
53
|
+
readonly observationId: string;
|
|
54
|
+
readonly text: string;
|
|
55
|
+
readonly byteOffset: number;
|
|
56
|
+
readonly byteLength: number;
|
|
57
|
+
readonly nextOffset: number;
|
|
58
|
+
readonly eof: boolean;
|
|
59
|
+
readonly truncated: boolean;
|
|
60
|
+
readonly sourceComplete: boolean;
|
|
61
|
+
/** True when the requested byte range was snapped to UTF-8 boundaries. */
|
|
62
|
+
readonly normalized: boolean;
|
|
63
|
+
}
|
|
64
|
+
export type ObservationReadError = "observation-not-found" | "scope-mismatch" | "invalid-range" | "utf8-boundary" | "archive-unavailable";
|
|
65
|
+
export type ObservationReadResult = {
|
|
66
|
+
readonly ok: true;
|
|
67
|
+
readonly read: ObservationRead;
|
|
68
|
+
} | {
|
|
69
|
+
readonly ok: false;
|
|
70
|
+
readonly error: ObservationReadError;
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/observation/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa,CAAC;AAC9E,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,oBAAoB,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,CAAC;AAElG;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CA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B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,oBAAoB,GAC7B,uBAAuB,GACvB,gBAAgB,GAChB,eAAe,GACf,eAAe,GACf,qBAAqB,CAAC;AAEzB,MAAM,MAAM,qBAAqB,GAC9B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAA;CAAE,CAAC","sourcesContent":["/**\n * Observation kernel types — U1/U2 of the upgraded SoL-Pi design.\n *\n * Raw observations are host-owned execution artifacts. Model-facing views are\n * derived projections and never replace the raw authority: `taskVerdict` is\n * always `not-assessed` here because a view cannot prove completion.\n */\n\nexport type ObservationStatus = \"exit\" | \"signal\" | \"partial\" | \"unavailable\";\nexport type ObservationPrivacy = \"raw-private\" | \"approved-sanitized\";\nexport type ObservationKind = \"log\" | \"test\" | \"command\" | \"file\" | \"dom\" | \"network\" | \"generic\";\n\n/**\n * A stored execution artifact. `observationId` binds the run, operation and\n * sequence to the content digest, so two identical byte outputs from different\n * executions remain distinct events (never content-hash deduped into one).\n */\nexport interface RawObservation {\n\treadonly observationId: string;\n\treadonly sessionId: string;\n\treadonly runId: string;\n\treadonly operationId: string;\n\treadonly sequence: number;\n\treadonly rawDigest: string;\n\treadonly byteLength: number;\n\treadonly bytes: Uint8Array;\n\treadonly status: ObservationStatus;\n\treadonly kind: ObservationKind;\n\treadonly privacy: ObservationPrivacy;\n\t/** False when the capture itself was truncated upstream — never claim \"full raw\". */\n\treadonly sourceComplete: boolean;\n\treadonly toolCallId?: string;\n}\n\nexport type ObservationViewKind = \"full\" | \"excerpt\" | \"evidence\" | \"pointer\";\nexport type ObservationCoverageStatus = \"complete\" | \"partial\" | \"unknown\";\n\n/**\n * A model-facing projection of a stored observation. `transformationDigest`\n * binds the view to the deterministic transform that produced it, and\n * `coverageStatus` records whether the view preserves the required fact atoms.\n */\nexport interface ObservationView {\n\treadonly viewKind: ObservationViewKind;\n\treadonly observationId: string;\n\treadonly parentDigest: string;\n\treadonly transformationDigest: string;\n\treadonly text: string;\n\treadonly estimatedTokens: number;\n\treadonly coveredFactIds: readonly string[];\n\treadonly missingRequiredFactIds: readonly string[];\n\treadonly coverageStatus: ObservationCoverageStatus;\n\treadonly taskVerdict: \"not-assessed\";\n}\n\n/** Result of a scoped, byte-bounded read against a stored observation. */\nexport interface ObservationRead {\n\treadonly observationId: string;\n\treadonly text: string;\n\treadonly byteOffset: number;\n\treadonly byteLength: number;\n\treadonly nextOffset: number;\n\treadonly eof: boolean;\n\treadonly truncated: boolean;\n\treadonly sourceComplete: boolean;\n\t/** True when the requested byte range was snapped to UTF-8 boundaries. */\n\treadonly normalized: boolean;\n}\n\nexport type ObservationReadError =\n\t| \"observation-not-found\"\n\t| \"scope-mismatch\"\n\t| \"invalid-range\"\n\t| \"utf8-boundary\"\n\t| \"archive-unavailable\";\n\nexport type ObservationReadResult =\n\t| { readonly ok: true; readonly read: ObservationRead }\n\t| { readonly ok: false; readonly error: ObservationReadError };\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observation kernel types — U1/U2 of the upgraded SoL-Pi design.
|
|
3
|
+
*
|
|
4
|
+
* Raw observations are host-owned execution artifacts. Model-facing views are
|
|
5
|
+
* derived projections and never replace the raw authority: `taskVerdict` is
|
|
6
|
+
* always `not-assessed` here because a view cannot prove completion.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/observation/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Observation kernel types — U1/U2 of the upgraded SoL-Pi design.\n *\n * Raw observations are host-owned execution artifacts. Model-facing views are\n * derived projections and never replace the raw authority: `taskVerdict` is\n * always `not-assessed` here because a view cannot prove completion.\n */\n\nexport type ObservationStatus = \"exit\" | \"signal\" | \"partial\" | \"unavailable\";\nexport type ObservationPrivacy = \"raw-private\" | \"approved-sanitized\";\nexport type ObservationKind = \"log\" | \"test\" | \"command\" | \"file\" | \"dom\" | \"network\" | \"generic\";\n\n/**\n * A stored execution artifact. `observationId` binds the run, operation and\n * sequence to the content digest, so two identical byte outputs from different\n * executions remain distinct events (never content-hash deduped into one).\n */\nexport interface RawObservation {\n\treadonly observationId: string;\n\treadonly sessionId: string;\n\treadonly runId: string;\n\treadonly operationId: string;\n\treadonly sequence: number;\n\treadonly rawDigest: string;\n\treadonly byteLength: number;\n\treadonly bytes: Uint8Array;\n\treadonly status: ObservationStatus;\n\treadonly kind: ObservationKind;\n\treadonly privacy: ObservationPrivacy;\n\t/** False when the capture itself was truncated upstream — never claim \"full raw\". */\n\treadonly sourceComplete: boolean;\n\treadonly toolCallId?: string;\n}\n\nexport type ObservationViewKind = \"full\" | \"excerpt\" | \"evidence\" | \"pointer\";\nexport type ObservationCoverageStatus = \"complete\" | \"partial\" | \"unknown\";\n\n/**\n * A model-facing projection of a stored observation. `transformationDigest`\n * binds the view to the deterministic transform that produced it, and\n * `coverageStatus` records whether the view preserves the required fact atoms.\n */\nexport interface ObservationView {\n\treadonly viewKind: ObservationViewKind;\n\treadonly observationId: string;\n\treadonly parentDigest: string;\n\treadonly transformationDigest: string;\n\treadonly text: string;\n\treadonly estimatedTokens: number;\n\treadonly coveredFactIds: readonly string[];\n\treadonly missingRequiredFactIds: readonly string[];\n\treadonly coverageStatus: ObservationCoverageStatus;\n\treadonly taskVerdict: \"not-assessed\";\n}\n\n/** Result of a scoped, byte-bounded read against a stored observation. */\nexport interface ObservationRead {\n\treadonly observationId: string;\n\treadonly text: string;\n\treadonly byteOffset: number;\n\treadonly byteLength: number;\n\treadonly nextOffset: number;\n\treadonly eof: boolean;\n\treadonly truncated: boolean;\n\treadonly sourceComplete: boolean;\n\t/** True when the requested byte range was snapped to UTF-8 boundaries. */\n\treadonly normalized: boolean;\n}\n\nexport type ObservationReadError =\n\t| \"observation-not-found\"\n\t| \"scope-mismatch\"\n\t| \"invalid-range\"\n\t| \"utf8-boundary\"\n\t| \"archive-unavailable\";\n\nexport type ObservationReadResult =\n\t| { readonly ok: true; readonly read: ObservationRead }\n\t| { readonly ok: false; readonly error: ObservationReadError };\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 type { ObservationView, RawObservation } from "./types.ts";
|
|
11
|
+
export declare function estimateViewTokens(text: string): number;
|
|
12
|
+
/** A host-verifiable fact atom extracted from raw bytes, e.g. exitCode=1. */
|
|
13
|
+
export interface FactAtom {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
/** The verbatim text that must appear in a view for the atom to count as covered. */
|
|
16
|
+
readonly evidence: string;
|
|
17
|
+
readonly byteOffset: number;
|
|
18
|
+
readonly byteLength: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Extract host-verifiable fact atoms from raw bytes. `requiredFactIds` limits
|
|
22
|
+
* extraction to the caller's obligation set; when omitted, all recognized
|
|
23
|
+
* atoms are returned so a view can advertise what it preserves.
|
|
24
|
+
*/
|
|
25
|
+
export declare function extractFacts(raw: Uint8Array, requiredFactIds?: readonly string[]): FactAtom[];
|
|
26
|
+
/**
|
|
27
|
+
* Build the candidate views for one observation. Every view records which
|
|
28
|
+
* fact atoms it preserves and which required atoms it would drop, so the
|
|
29
|
+
* selector can gate on coverage rather than token density alone.
|
|
30
|
+
*/
|
|
31
|
+
export declare function makeViews(observation: RawObservation, requiredFactIds?: readonly string[]): readonly ObservationView[];
|
|
32
|
+
/**
|
|
33
|
+
* Coverage-gated deterministic selection: the smallest view that preserves
|
|
34
|
+
* every required fact within budget. Returns null (infeasible) rather than
|
|
35
|
+
* silently dropping a required atom — the caller must widen the budget or keep
|
|
36
|
+
* the raw observation.
|
|
37
|
+
*/
|
|
38
|
+
export declare function chooseView(views: readonly ObservationView[], budgetTokens: number, requiredFactIds?: readonly string[]): ObservationView | null;
|
|
39
|
+
//# sourceMappingURL=view.d.ts.map
|