@sema-ai/core 1.275.1
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 +5433 -0
- package/LICENSE +27 -0
- package/NOTICE.md +30 -0
- package/README.md +1040 -0
- package/dist/agents/agent-definition.d.ts +10 -0
- package/dist/agents/agent-definition.d.ts.map +1 -0
- package/dist/agents/agent-definition.js +18 -0
- package/dist/agents/agent-definition.js.map +1 -0
- package/dist/agents/builtin-agents.d.ts +69 -0
- package/dist/agents/builtin-agents.d.ts.map +1 -0
- package/dist/agents/builtin-agents.js +177 -0
- package/dist/agents/builtin-agents.js.map +1 -0
- package/dist/agents/cascade.d.ts +101 -0
- package/dist/agents/cascade.d.ts.map +1 -0
- package/dist/agents/cascade.js +189 -0
- package/dist/agents/cascade.js.map +1 -0
- package/dist/agents/observer.d.ts +209 -0
- package/dist/agents/observer.d.ts.map +1 -0
- package/dist/agents/observer.js +495 -0
- package/dist/agents/observer.js.map +1 -0
- package/dist/agents/repair-loop.d.ts +236 -0
- package/dist/agents/repair-loop.d.ts.map +1 -0
- package/dist/agents/repair-loop.js +293 -0
- package/dist/agents/repair-loop.js.map +1 -0
- package/dist/agents/session-util.d.ts +8 -0
- package/dist/agents/session-util.d.ts.map +1 -0
- package/dist/agents/session-util.js +9 -0
- package/dist/agents/session-util.js.map +1 -0
- package/dist/agents/subagent-steps.d.ts +93 -0
- package/dist/agents/subagent-steps.d.ts.map +1 -0
- package/dist/agents/subagent-steps.js +206 -0
- package/dist/agents/subagent-steps.js.map +1 -0
- package/dist/agents/subagent.d.ts +441 -0
- package/dist/agents/subagent.d.ts.map +1 -0
- package/dist/agents/subagent.js +2492 -0
- package/dist/agents/subagent.js.map +1 -0
- package/dist/agents/suspend-guard.d.ts +35 -0
- package/dist/agents/suspend-guard.d.ts.map +1 -0
- package/dist/agents/suspend-guard.js +48 -0
- package/dist/agents/suspend-guard.js.map +1 -0
- package/dist/agents/teacher.d.ts +137 -0
- package/dist/agents/teacher.d.ts.map +1 -0
- package/dist/agents/teacher.js +575 -0
- package/dist/agents/teacher.js.map +1 -0
- package/dist/agents/team.d.ts +211 -0
- package/dist/agents/team.d.ts.map +1 -0
- package/dist/agents/team.js +293 -0
- package/dist/agents/team.js.map +1 -0
- package/dist/agents/tool-filter.d.ts +29 -0
- package/dist/agents/tool-filter.d.ts.map +1 -0
- package/dist/agents/tool-filter.js +50 -0
- package/dist/agents/tool-filter.js.map +1 -0
- package/dist/agents/verify.d.ts +177 -0
- package/dist/agents/verify.d.ts.map +1 -0
- package/dist/agents/verify.js +305 -0
- package/dist/agents/verify.js.map +1 -0
- package/dist/bench/metrics.d.ts +714 -0
- package/dist/bench/metrics.d.ts.map +1 -0
- package/dist/bench/metrics.js +618 -0
- package/dist/bench/metrics.js.map +1 -0
- package/dist/bin/sema-tb.d.ts +3 -0
- package/dist/bin/sema-tb.d.ts.map +1 -0
- package/dist/bin/sema-tb.js +516 -0
- package/dist/bin/sema-tb.js.map +1 -0
- package/dist/bin/tb-env.d.ts +13 -0
- package/dist/bin/tb-env.d.ts.map +1 -0
- package/dist/bin/tb-env.js +26 -0
- package/dist/bin/tb-env.js.map +1 -0
- package/dist/brain/anthropic.d.ts +46 -0
- package/dist/brain/anthropic.d.ts.map +1 -0
- package/dist/brain/anthropic.js +830 -0
- package/dist/brain/anthropic.js.map +1 -0
- package/dist/brain/circuit-breaker.d.ts +46 -0
- package/dist/brain/circuit-breaker.d.ts.map +1 -0
- package/dist/brain/circuit-breaker.js +173 -0
- package/dist/brain/circuit-breaker.js.map +1 -0
- package/dist/brain/degrading.d.ts +98 -0
- package/dist/brain/degrading.d.ts.map +1 -0
- package/dist/brain/degrading.js +249 -0
- package/dist/brain/degrading.js.map +1 -0
- package/dist/brain/errors.d.ts +31 -0
- package/dist/brain/errors.d.ts.map +1 -0
- package/dist/brain/errors.js +58 -0
- package/dist/brain/errors.js.map +1 -0
- package/dist/brain/failover.d.ts +18 -0
- package/dist/brain/failover.d.ts.map +1 -0
- package/dist/brain/failover.js +118 -0
- package/dist/brain/failover.js.map +1 -0
- package/dist/brain/model-presets.d.ts +36 -0
- package/dist/brain/model-presets.d.ts.map +1 -0
- package/dist/brain/model-presets.js +54 -0
- package/dist/brain/model-presets.js.map +1 -0
- package/dist/brain/openai.d.ts +43 -0
- package/dist/brain/openai.d.ts.map +1 -0
- package/dist/brain/openai.js +784 -0
- package/dist/brain/openai.js.map +1 -0
- package/dist/brain/reasoning.d.ts +138 -0
- package/dist/brain/reasoning.d.ts.map +1 -0
- package/dist/brain/reasoning.js +146 -0
- package/dist/brain/reasoning.js.map +1 -0
- package/dist/brain/repetition.d.ts +60 -0
- package/dist/brain/repetition.d.ts.map +1 -0
- package/dist/brain/repetition.js +121 -0
- package/dist/brain/repetition.js.map +1 -0
- package/dist/brain/request-params.d.ts +29 -0
- package/dist/brain/request-params.d.ts.map +1 -0
- package/dist/brain/request-params.js +78 -0
- package/dist/brain/request-params.js.map +1 -0
- package/dist/brain/retry.d.ts +18 -0
- package/dist/brain/retry.d.ts.map +1 -0
- package/dist/brain/retry.js +42 -0
- package/dist/brain/retry.js.map +1 -0
- package/dist/brain/routing.d.ts +19 -0
- package/dist/brain/routing.d.ts.map +1 -0
- package/dist/brain/routing.js +44 -0
- package/dist/brain/routing.js.map +1 -0
- package/dist/brain/status-sink.d.ts +46 -0
- package/dist/brain/status-sink.d.ts.map +1 -0
- package/dist/brain/status-sink.js +36 -0
- package/dist/brain/status-sink.js.map +1 -0
- package/dist/brain/stream-engine.d.ts +85 -0
- package/dist/brain/stream-engine.d.ts.map +1 -0
- package/dist/brain/stream-engine.js +391 -0
- package/dist/brain/stream-engine.js.map +1 -0
- package/dist/brain/timeout.d.ts +44 -0
- package/dist/brain/timeout.d.ts.map +1 -0
- package/dist/brain/timeout.js +41 -0
- package/dist/brain/timeout.js.map +1 -0
- package/dist/brain/tool-call-repair.d.ts +15 -0
- package/dist/brain/tool-call-repair.d.ts.map +1 -0
- package/dist/brain/tool-call-repair.js +67 -0
- package/dist/brain/tool-call-repair.js.map +1 -0
- package/dist/brain/walltime.d.ts +14 -0
- package/dist/brain/walltime.d.ts.map +1 -0
- package/dist/brain/walltime.js +14 -0
- package/dist/brain/walltime.js.map +1 -0
- package/dist/core/arg-summary.d.ts +19 -0
- package/dist/core/arg-summary.d.ts.map +1 -0
- package/dist/core/arg-summary.js +96 -0
- package/dist/core/arg-summary.js.map +1 -0
- package/dist/core/ask-question.d.ts +113 -0
- package/dist/core/ask-question.d.ts.map +1 -0
- package/dist/core/ask-question.js +246 -0
- package/dist/core/ask-question.js.map +1 -0
- package/dist/core/auto-compaction.d.ts +341 -0
- package/dist/core/auto-compaction.d.ts.map +1 -0
- package/dist/core/auto-compaction.js +495 -0
- package/dist/core/auto-compaction.js.map +1 -0
- package/dist/core/auto-promote.d.ts +126 -0
- package/dist/core/auto-promote.d.ts.map +1 -0
- package/dist/core/auto-promote.js +171 -0
- package/dist/core/auto-promote.js.map +1 -0
- package/dist/core/background-shell.d.ts +128 -0
- package/dist/core/background-shell.d.ts.map +1 -0
- package/dist/core/background-shell.js +42 -0
- package/dist/core/background-shell.js.map +1 -0
- package/dist/core/cache-break-detector.d.ts +63 -0
- package/dist/core/cache-break-detector.d.ts.map +1 -0
- package/dist/core/cache-break-detector.js +0 -0
- package/dist/core/cache-break-detector.js.map +1 -0
- package/dist/core/canonical-json.d.ts +45 -0
- package/dist/core/canonical-json.d.ts.map +1 -0
- package/dist/core/canonical-json.js +132 -0
- package/dist/core/canonical-json.js.map +1 -0
- package/dist/core/checkpoint-store.d.ts +1101 -0
- package/dist/core/checkpoint-store.d.ts.map +1 -0
- package/dist/core/checkpoint-store.js +514 -0
- package/dist/core/checkpoint-store.js.map +1 -0
- package/dist/core/consolidate-scope.d.ts +94 -0
- package/dist/core/consolidate-scope.d.ts.map +1 -0
- package/dist/core/consolidate-scope.js +158 -0
- package/dist/core/consolidate-scope.js.map +1 -0
- package/dist/core/context-edit.d.ts +82 -0
- package/dist/core/context-edit.d.ts.map +1 -0
- package/dist/core/context-edit.js +149 -0
- package/dist/core/context-edit.js.map +1 -0
- package/dist/core/context-guard.d.ts +43 -0
- package/dist/core/context-guard.d.ts.map +1 -0
- package/dist/core/context-guard.js +171 -0
- package/dist/core/context-guard.js.map +1 -0
- package/dist/core/dynamic-recall.d.ts +100 -0
- package/dist/core/dynamic-recall.d.ts.map +1 -0
- package/dist/core/dynamic-recall.js +108 -0
- package/dist/core/dynamic-recall.js.map +1 -0
- package/dist/core/exec-gate.d.ts +74 -0
- package/dist/core/exec-gate.d.ts.map +1 -0
- package/dist/core/exec-gate.js +143 -0
- package/dist/core/exec-gate.js.map +1 -0
- package/dist/core/exec-output-tail.d.ts +37 -0
- package/dist/core/exec-output-tail.d.ts.map +1 -0
- package/dist/core/exec-output-tail.js +63 -0
- package/dist/core/exec-output-tail.js.map +1 -0
- package/dist/core/file-snapshot-store.d.ts +137 -0
- package/dist/core/file-snapshot-store.d.ts.map +1 -0
- package/dist/core/file-snapshot-store.js +319 -0
- package/dist/core/file-snapshot-store.js.map +1 -0
- package/dist/core/git-worktree-env.d.ts +41 -0
- package/dist/core/git-worktree-env.d.ts.map +1 -0
- package/dist/core/git-worktree-env.js +64 -0
- package/dist/core/git-worktree-env.js.map +1 -0
- package/dist/core/hooks.d.ts +372 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +269 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/lsp-diagnostics.d.ts +74 -0
- package/dist/core/lsp-diagnostics.d.ts.map +1 -0
- package/dist/core/lsp-diagnostics.js +125 -0
- package/dist/core/lsp-diagnostics.js.map +1 -0
- package/dist/core/lsp-protocol.d.ts +28 -0
- package/dist/core/lsp-protocol.d.ts.map +1 -0
- package/dist/core/lsp-protocol.js +179 -0
- package/dist/core/lsp-protocol.js.map +1 -0
- package/dist/core/lsp-session.d.ts +56 -0
- package/dist/core/lsp-session.d.ts.map +1 -0
- package/dist/core/lsp-session.js +185 -0
- package/dist/core/lsp-session.js.map +1 -0
- package/dist/core/lsp.d.ts +132 -0
- package/dist/core/lsp.d.ts.map +1 -0
- package/dist/core/lsp.js +147 -0
- package/dist/core/lsp.js.map +1 -0
- package/dist/core/mcp.d.ts +294 -0
- package/dist/core/mcp.d.ts.map +1 -0
- package/dist/core/mcp.js +992 -0
- package/dist/core/mcp.js.map +1 -0
- package/dist/core/media-byte-cap.d.ts +34 -0
- package/dist/core/media-byte-cap.d.ts.map +1 -0
- package/dist/core/media-byte-cap.js +76 -0
- package/dist/core/media-byte-cap.js.map +1 -0
- package/dist/core/memory-engine/data-plane.d.ts +103 -0
- package/dist/core/memory-engine/data-plane.d.ts.map +1 -0
- package/dist/core/memory-engine/data-plane.js +272 -0
- package/dist/core/memory-engine/data-plane.js.map +1 -0
- package/dist/core/memory-engine/dual-root.d.ts +40 -0
- package/dist/core/memory-engine/dual-root.d.ts.map +1 -0
- package/dist/core/memory-engine/dual-root.js +95 -0
- package/dist/core/memory-engine/dual-root.js.map +1 -0
- package/dist/core/memory-engine/engine.d.ts +161 -0
- package/dist/core/memory-engine/engine.d.ts.map +1 -0
- package/dist/core/memory-engine/engine.js +1110 -0
- package/dist/core/memory-engine/engine.js.map +1 -0
- package/dist/core/memory-engine/file-backend.d.ts +162 -0
- package/dist/core/memory-engine/file-backend.d.ts.map +1 -0
- package/dist/core/memory-engine/file-backend.js +948 -0
- package/dist/core/memory-engine/file-backend.js.map +1 -0
- package/dist/core/memory-engine/frontmatter.d.ts +24 -0
- package/dist/core/memory-engine/frontmatter.d.ts.map +1 -0
- package/dist/core/memory-engine/frontmatter.js +135 -0
- package/dist/core/memory-engine/frontmatter.js.map +1 -0
- package/dist/core/memory-engine/index.d.ts +13 -0
- package/dist/core/memory-engine/index.d.ts.map +1 -0
- package/dist/core/memory-engine/index.js +28 -0
- package/dist/core/memory-engine/index.js.map +1 -0
- package/dist/core/memory-engine/layout.d.ts +123 -0
- package/dist/core/memory-engine/layout.d.ts.map +1 -0
- package/dist/core/memory-engine/layout.js +643 -0
- package/dist/core/memory-engine/layout.js.map +1 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts +22 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts.map +1 -0
- package/dist/core/memory-engine/memory-backend-contract.js +271 -0
- package/dist/core/memory-engine/memory-backend-contract.js.map +1 -0
- package/dist/core/memory-engine/migrate.d.ts +17 -0
- package/dist/core/memory-engine/migrate.d.ts.map +1 -0
- package/dist/core/memory-engine/migrate.js +35 -0
- package/dist/core/memory-engine/migrate.js.map +1 -0
- package/dist/core/memory-engine/scan.d.ts +20 -0
- package/dist/core/memory-engine/scan.d.ts.map +1 -0
- package/dist/core/memory-engine/scan.js +84 -0
- package/dist/core/memory-engine/scan.js.map +1 -0
- package/dist/core/memory-engine/scope-contract.d.ts +104 -0
- package/dist/core/memory-engine/scope-contract.d.ts.map +1 -0
- package/dist/core/memory-engine/scope-contract.js +288 -0
- package/dist/core/memory-engine/scope-contract.js.map +1 -0
- package/dist/core/memory-engine/sync-client.d.ts +100 -0
- package/dist/core/memory-engine/sync-client.d.ts.map +1 -0
- package/dist/core/memory-engine/sync-client.js +328 -0
- package/dist/core/memory-engine/sync-client.js.map +1 -0
- package/dist/core/memory-engine/sync.d.ts +97 -0
- package/dist/core/memory-engine/sync.d.ts.map +1 -0
- package/dist/core/memory-engine/sync.js +91 -0
- package/dist/core/memory-engine/sync.js.map +1 -0
- package/dist/core/memory-engine/types.d.ts +279 -0
- package/dist/core/memory-engine/types.d.ts.map +1 -0
- package/dist/core/memory-engine/types.js +9 -0
- package/dist/core/memory-engine/types.js.map +1 -0
- package/dist/core/memory-recall.d.ts +261 -0
- package/dist/core/memory-recall.d.ts.map +1 -0
- package/dist/core/memory-recall.js +600 -0
- package/dist/core/memory-recall.js.map +1 -0
- package/dist/core/memory-vector.d.ts +24 -0
- package/dist/core/memory-vector.d.ts.map +1 -0
- package/dist/core/memory-vector.js +51 -0
- package/dist/core/memory-vector.js.map +1 -0
- package/dist/core/memory.d.ts +502 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +881 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/message-utils.d.ts +7 -0
- package/dist/core/message-utils.d.ts.map +1 -0
- package/dist/core/message-utils.js +10 -0
- package/dist/core/message-utils.js.map +1 -0
- package/dist/core/oracle-isolation.d.ts +85 -0
- package/dist/core/oracle-isolation.d.ts.map +1 -0
- package/dist/core/oracle-isolation.js +121 -0
- package/dist/core/oracle-isolation.js.map +1 -0
- package/dist/core/permission-rules.d.ts +102 -0
- package/dist/core/permission-rules.d.ts.map +1 -0
- package/dist/core/permission-rules.js +357 -0
- package/dist/core/permission-rules.js.map +1 -0
- package/dist/core/present-plan-tool.d.ts +28 -0
- package/dist/core/present-plan-tool.d.ts.map +1 -0
- package/dist/core/present-plan-tool.js +119 -0
- package/dist/core/present-plan-tool.js.map +1 -0
- package/dist/core/pricing.d.ts +48 -0
- package/dist/core/pricing.d.ts.map +1 -0
- package/dist/core/pricing.js +46 -0
- package/dist/core/pricing.js.map +1 -0
- package/dist/core/property-harness.d.ts +126 -0
- package/dist/core/property-harness.d.ts.map +1 -0
- package/dist/core/property-harness.js +192 -0
- package/dist/core/property-harness.js.map +1 -0
- package/dist/core/push-queue.d.ts +10 -0
- package/dist/core/push-queue.d.ts.map +1 -0
- package/dist/core/push-queue.js +42 -0
- package/dist/core/push-queue.js.map +1 -0
- package/dist/core/remote-env.d.ts +432 -0
- package/dist/core/remote-env.d.ts.map +1 -0
- package/dist/core/remote-env.js +77 -0
- package/dist/core/remote-env.js.map +1 -0
- package/dist/core/roles.d.ts +74 -0
- package/dist/core/roles.d.ts.map +1 -0
- package/dist/core/roles.js +272 -0
- package/dist/core/roles.js.map +1 -0
- package/dist/core/runner/active-skill-scope.d.ts +64 -0
- package/dist/core/runner/active-skill-scope.d.ts.map +1 -0
- package/dist/core/runner/active-skill-scope.js +197 -0
- package/dist/core/runner/active-skill-scope.js.map +1 -0
- package/dist/core/runner/assemble-result.d.ts +191 -0
- package/dist/core/runner/assemble-result.d.ts.map +1 -0
- package/dist/core/runner/assemble-result.js +250 -0
- package/dist/core/runner/assemble-result.js.map +1 -0
- package/dist/core/runner/call-cap.d.ts +130 -0
- package/dist/core/runner/call-cap.d.ts.map +1 -0
- package/dist/core/runner/call-cap.js +151 -0
- package/dist/core/runner/call-cap.js.map +1 -0
- package/dist/core/runner/grounding-signal.d.ts +12 -0
- package/dist/core/runner/grounding-signal.d.ts.map +1 -0
- package/dist/core/runner/grounding-signal.js +94 -0
- package/dist/core/runner/grounding-signal.js.map +1 -0
- package/dist/core/runner/image.d.ts +23 -0
- package/dist/core/runner/image.d.ts.map +1 -0
- package/dist/core/runner/image.js +151 -0
- package/dist/core/runner/image.js.map +1 -0
- package/dist/core/runner/memory-consolidation.d.ts +112 -0
- package/dist/core/runner/memory-consolidation.d.ts.map +1 -0
- package/dist/core/runner/memory-consolidation.js +372 -0
- package/dist/core/runner/memory-consolidation.js.map +1 -0
- package/dist/core/runner/prepare-task.d.ts +583 -0
- package/dist/core/runner/prepare-task.d.ts.map +1 -0
- package/dist/core/runner/prepare-task.js +3612 -0
- package/dist/core/runner/prepare-task.js.map +1 -0
- package/dist/core/runner/prompt-suggestions.d.ts +33 -0
- package/dist/core/runner/prompt-suggestions.d.ts.map +1 -0
- package/dist/core/runner/prompt-suggestions.js +116 -0
- package/dist/core/runner/prompt-suggestions.js.map +1 -0
- package/dist/core/runner/runtask.d.ts +274 -0
- package/dist/core/runner/runtask.d.ts.map +1 -0
- package/dist/core/runner/runtask.js +4606 -0
- package/dist/core/runner/runtask.js.map +1 -0
- package/dist/core/runner/session-rule-policy.d.ts +28 -0
- package/dist/core/runner/session-rule-policy.d.ts.map +1 -0
- package/dist/core/runner/session-rule-policy.js +110 -0
- package/dist/core/runner/session-rule-policy.js.map +1 -0
- package/dist/core/runner/strict-output-schema.d.ts +36 -0
- package/dist/core/runner/strict-output-schema.d.ts.map +1 -0
- package/dist/core/runner/strict-output-schema.js +365 -0
- package/dist/core/runner/strict-output-schema.js.map +1 -0
- package/dist/core/runner/synthetic-tools.d.ts +72 -0
- package/dist/core/runner/synthetic-tools.d.ts.map +1 -0
- package/dist/core/runner/synthetic-tools.js +203 -0
- package/dist/core/runner/synthetic-tools.js.map +1 -0
- package/dist/core/runner/tool-disclosure.d.ts +117 -0
- package/dist/core/runner/tool-disclosure.d.ts.map +1 -0
- package/dist/core/runner/tool-disclosure.js +0 -0
- package/dist/core/runner/tool-disclosure.js.map +1 -0
- package/dist/core/runner/turn-attachments.d.ts +381 -0
- package/dist/core/runner/turn-attachments.d.ts.map +1 -0
- package/dist/core/runner/turn-attachments.js +596 -0
- package/dist/core/runner/turn-attachments.js.map +1 -0
- package/dist/core/runner/usage-accounting.d.ts +35 -0
- package/dist/core/runner/usage-accounting.d.ts.map +1 -0
- package/dist/core/runner/usage-accounting.js +45 -0
- package/dist/core/runner/usage-accounting.js.map +1 -0
- package/dist/core/runtime.d.ts +9 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js +17 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/core/safety-axis-vocab.d.ts +33 -0
- package/dist/core/safety-axis-vocab.d.ts.map +1 -0
- package/dist/core/safety-axis-vocab.js +35 -0
- package/dist/core/safety-axis-vocab.js.map +1 -0
- package/dist/core/safety-merge-corpus.d.ts +48 -0
- package/dist/core/safety-merge-corpus.d.ts.map +1 -0
- package/dist/core/safety-merge-corpus.js +203 -0
- package/dist/core/safety-merge-corpus.js.map +1 -0
- package/dist/core/scheduler.d.ts +126 -0
- package/dist/core/scheduler.d.ts.map +1 -0
- package/dist/core/scheduler.js +54 -0
- package/dist/core/scheduler.js.map +1 -0
- package/dist/core/secret-env.d.ts +23 -0
- package/dist/core/secret-env.d.ts.map +1 -0
- package/dist/core/secret-env.js +35 -0
- package/dist/core/secret-env.js.map +1 -0
- package/dist/core/select-model.d.ts +26 -0
- package/dist/core/select-model.d.ts.map +1 -0
- package/dist/core/select-model.js +58 -0
- package/dist/core/select-model.js.map +1 -0
- package/dist/core/sensitive-path-policy.d.ts +24 -0
- package/dist/core/sensitive-path-policy.d.ts.map +1 -0
- package/dist/core/sensitive-path-policy.js +96 -0
- package/dist/core/sensitive-path-policy.js.map +1 -0
- package/dist/core/session-policy-store.d.ts +102 -0
- package/dist/core/session-policy-store.d.ts.map +1 -0
- package/dist/core/session-policy-store.js +177 -0
- package/dist/core/session-policy-store.js.map +1 -0
- package/dist/core/session-reconcile.d.ts +63 -0
- package/dist/core/session-reconcile.d.ts.map +1 -0
- package/dist/core/session-reconcile.js +71 -0
- package/dist/core/session-reconcile.js.map +1 -0
- package/dist/core/session-store.d.ts +99 -0
- package/dist/core/session-store.d.ts.map +1 -0
- package/dist/core/session-store.js +298 -0
- package/dist/core/session-store.js.map +1 -0
- package/dist/core/session.d.ts +144 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +56 -0
- package/dist/core/session.js.map +1 -0
- package/dist/core/spec-contract.d.ts +147 -0
- package/dist/core/spec-contract.d.ts.map +1 -0
- package/dist/core/spec-contract.js +340 -0
- package/dist/core/spec-contract.js.map +1 -0
- package/dist/core/strategy-store.d.ts +50 -0
- package/dist/core/strategy-store.d.ts.map +1 -0
- package/dist/core/strategy-store.js +100 -0
- package/dist/core/strategy-store.js.map +1 -0
- package/dist/core/stub-env.d.ts +35 -0
- package/dist/core/stub-env.d.ts.map +1 -0
- package/dist/core/stub-env.js +69 -0
- package/dist/core/stub-env.js.map +1 -0
- package/dist/core/task-notification.d.ts +115 -0
- package/dist/core/task-notification.d.ts.map +1 -0
- package/dist/core/task-notification.js +247 -0
- package/dist/core/task-notification.js.map +1 -0
- package/dist/core/task-outcome.d.ts +80 -0
- package/dist/core/task-outcome.d.ts.map +1 -0
- package/dist/core/task-outcome.js +40 -0
- package/dist/core/task-outcome.js.map +1 -0
- package/dist/core/task-registry.d.ts +349 -0
- package/dist/core/task-registry.d.ts.map +1 -0
- package/dist/core/task-registry.js +1751 -0
- package/dist/core/task-registry.js.map +1 -0
- package/dist/core/tighten-task-spec.d.ts +27 -0
- package/dist/core/tighten-task-spec.d.ts.map +1 -0
- package/dist/core/tighten-task-spec.js +95 -0
- package/dist/core/tighten-task-spec.js.map +1 -0
- package/dist/core/tool-detach.d.ts +31 -0
- package/dist/core/tool-detach.d.ts.map +1 -0
- package/dist/core/tool-detach.js +62 -0
- package/dist/core/tool-detach.js.map +1 -0
- package/dist/core/tool-errors.d.ts +72 -0
- package/dist/core/tool-errors.d.ts.map +1 -0
- package/dist/core/tool-errors.js +194 -0
- package/dist/core/tool-errors.js.map +1 -0
- package/dist/core/tool-name-aliases.d.ts +5 -0
- package/dist/core/tool-name-aliases.d.ts.map +1 -0
- package/dist/core/tool-name-aliases.js +130 -0
- package/dist/core/tool-name-aliases.js.map +1 -0
- package/dist/core/tool-policy.d.ts +295 -0
- package/dist/core/tool-policy.d.ts.map +1 -0
- package/dist/core/tool-policy.js +567 -0
- package/dist/core/tool-policy.js.map +1 -0
- package/dist/core/tool-result-budget.d.ts +44 -0
- package/dist/core/tool-result-budget.d.ts.map +1 -0
- package/dist/core/tool-result-budget.js +140 -0
- package/dist/core/tool-result-budget.js.map +1 -0
- package/dist/core/tool-result-store.d.ts +136 -0
- package/dist/core/tool-result-store.d.ts.map +1 -0
- package/dist/core/tool-result-store.js +219 -0
- package/dist/core/tool-result-store.js.map +1 -0
- package/dist/core/tools.d.ts +14 -0
- package/dist/core/tools.d.ts.map +1 -0
- package/dist/core/tools.js +98 -0
- package/dist/core/tools.js.map +1 -0
- package/dist/core/trace.d.ts +340 -0
- package/dist/core/trace.d.ts.map +1 -0
- package/dist/core/trace.js +12 -0
- package/dist/core/trace.js.map +1 -0
- package/dist/core/types.d.ts +2828 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/untrusted-egress.d.ts +32 -0
- package/dist/core/untrusted-egress.d.ts.map +1 -0
- package/dist/core/untrusted-egress.js +49 -0
- package/dist/core/untrusted-egress.js.map +1 -0
- package/dist/core/untrusted-text.d.ts +64 -0
- package/dist/core/untrusted-text.d.ts.map +1 -0
- package/dist/core/untrusted-text.js +119 -0
- package/dist/core/untrusted-text.js.map +1 -0
- package/dist/core/warm-resume.d.ts +23 -0
- package/dist/core/warm-resume.d.ts.map +1 -0
- package/dist/core/warm-resume.js +28 -0
- package/dist/core/warm-resume.js.map +1 -0
- package/dist/core/with-retry.d.ts +43 -0
- package/dist/core/with-retry.d.ts.map +1 -0
- package/dist/core/with-retry.js +59 -0
- package/dist/core/with-retry.js.map +1 -0
- package/dist/core/workflow-journal-store.d.ts +44 -0
- package/dist/core/workflow-journal-store.d.ts.map +1 -0
- package/dist/core/workflow-journal-store.js +47 -0
- package/dist/core/workflow-journal-store.js.map +1 -0
- package/dist/core/workflow-run-store-contract.d.ts +31 -0
- package/dist/core/workflow-run-store-contract.d.ts.map +1 -0
- package/dist/core/workflow-run-store-contract.js +191 -0
- package/dist/core/workflow-run-store-contract.js.map +1 -0
- package/dist/core/workflow-run-store.d.ts +149 -0
- package/dist/core/workflow-run-store.d.ts.map +1 -0
- package/dist/core/workflow-run-store.js +110 -0
- package/dist/core/workflow-run-store.js.map +1 -0
- package/dist/engine/compaction/compaction.d.ts +139 -0
- package/dist/engine/compaction/compaction.d.ts.map +1 -0
- package/dist/engine/compaction/compaction.js +1030 -0
- package/dist/engine/compaction/compaction.js.map +1 -0
- package/dist/engine/compaction/utils.d.ts +45 -0
- package/dist/engine/compaction/utils.d.ts.map +1 -0
- package/dist/engine/compaction/utils.js +203 -0
- package/dist/engine/compaction/utils.js.map +1 -0
- package/dist/engine/execution-env/kill-tree.d.ts +20 -0
- package/dist/engine/execution-env/kill-tree.d.ts.map +1 -0
- package/dist/engine/execution-env/kill-tree.js +183 -0
- package/dist/engine/execution-env/kill-tree.js.map +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +133 -0
- package/dist/engine/execution-env/node-execution-env.d.ts.map +1 -0
- package/dist/engine/execution-env/node-execution-env.js +1031 -0
- package/dist/engine/execution-env/node-execution-env.js.map +1 -0
- package/dist/engine/harness/agent-harness.d.ts +174 -0
- package/dist/engine/harness/agent-harness.d.ts.map +1 -0
- package/dist/engine/harness/agent-harness.js +1053 -0
- package/dist/engine/harness/agent-harness.js.map +1 -0
- package/dist/engine/harness/messages.d.ts +17 -0
- package/dist/engine/harness/messages.d.ts.map +1 -0
- package/dist/engine/harness/messages.js +122 -0
- package/dist/engine/harness/messages.js.map +1 -0
- package/dist/engine/harness/types.d.ts +713 -0
- package/dist/engine/harness/types.d.ts.map +1 -0
- package/dist/engine/harness/types.js +100 -0
- package/dist/engine/harness/types.js.map +1 -0
- package/dist/engine/llm/diagnostics.d.ts +23 -0
- package/dist/engine/llm/diagnostics.d.ts.map +1 -0
- package/dist/engine/llm/diagnostics.js +32 -0
- package/dist/engine/llm/diagnostics.js.map +1 -0
- package/dist/engine/llm/event-stream.d.ts +25 -0
- package/dist/engine/llm/event-stream.d.ts.map +1 -0
- package/dist/engine/llm/event-stream.js +103 -0
- package/dist/engine/llm/event-stream.js.map +1 -0
- package/dist/engine/llm/index.d.ts +12 -0
- package/dist/engine/llm/index.d.ts.map +1 -0
- package/dist/engine/llm/index.js +12 -0
- package/dist/engine/llm/index.js.map +1 -0
- package/dist/engine/llm/types.d.ts +753 -0
- package/dist/engine/llm/types.d.ts.map +1 -0
- package/dist/engine/llm/types.js +2 -0
- package/dist/engine/llm/types.js.map +1 -0
- package/dist/engine/llm/validation.d.ts +8 -0
- package/dist/engine/llm/validation.d.ts.map +1 -0
- package/dist/engine/llm/validation.js +318 -0
- package/dist/engine/llm/validation.js.map +1 -0
- package/dist/engine/loop/agent-loop.d.ts +74 -0
- package/dist/engine/loop/agent-loop.d.ts.map +1 -0
- package/dist/engine/loop/agent-loop.js +1490 -0
- package/dist/engine/loop/agent-loop.js.map +1 -0
- package/dist/engine/loop/runtime-deps.d.ts +17 -0
- package/dist/engine/loop/runtime-deps.d.ts.map +1 -0
- package/dist/engine/loop/runtime-deps.js +21 -0
- package/dist/engine/loop/runtime-deps.js.map +1 -0
- package/dist/engine/loop/types.d.ts +609 -0
- package/dist/engine/loop/types.d.ts.map +1 -0
- package/dist/engine/loop/types.js +2 -0
- package/dist/engine/loop/types.js.map +1 -0
- package/dist/engine/lsp/frame-decoder.d.ts +16 -0
- package/dist/engine/lsp/frame-decoder.d.ts.map +1 -0
- package/dist/engine/lsp/frame-decoder.js +53 -0
- package/dist/engine/lsp/frame-decoder.js.map +1 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts +105 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts.map +1 -0
- package/dist/engine/lsp/node-lsp-manager.js +343 -0
- package/dist/engine/lsp/node-lsp-manager.js.map +1 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts +37 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts.map +1 -0
- package/dist/engine/lsp/stdio-lsp-transport.js +185 -0
- package/dist/engine/lsp/stdio-lsp-transport.js.map +1 -0
- package/dist/engine/session/import-validate.d.ts +44 -0
- package/dist/engine/session/import-validate.d.ts.map +1 -0
- package/dist/engine/session/import-validate.js +92 -0
- package/dist/engine/session/import-validate.js.map +1 -0
- package/dist/engine/session/memory-repo.d.ts +25 -0
- package/dist/engine/session/memory-repo.d.ts.map +1 -0
- package/dist/engine/session/memory-repo.js +59 -0
- package/dist/engine/session/memory-repo.js.map +1 -0
- package/dist/engine/session/memory-storage.d.ts +14 -0
- package/dist/engine/session/memory-storage.d.ts.map +1 -0
- package/dist/engine/session/memory-storage.js +17 -0
- package/dist/engine/session/memory-storage.js.map +1 -0
- package/dist/engine/session/repo-utils.d.ts +11 -0
- package/dist/engine/session/repo-utils.d.ts.map +1 -0
- package/dist/engine/session/repo-utils.js +40 -0
- package/dist/engine/session/repo-utils.js.map +1 -0
- package/dist/engine/session/session.d.ts +34 -0
- package/dist/engine/session/session.d.ts.map +1 -0
- package/dist/engine/session/session.js +227 -0
- package/dist/engine/session/session.js.map +1 -0
- package/dist/engine/session/storage-base.d.ts +38 -0
- package/dist/engine/session/storage-base.d.ts.map +1 -0
- package/dist/engine/session/storage-base.js +157 -0
- package/dist/engine/session/storage-base.js.map +1 -0
- package/dist/engine/session/timestamps.d.ts +3 -0
- package/dist/engine/session/timestamps.d.ts.map +1 -0
- package/dist/engine/session/timestamps.js +15 -0
- package/dist/engine/session/timestamps.js.map +1 -0
- package/dist/engine/session/uuid.d.ts +2 -0
- package/dist/engine/session/uuid.d.ts.map +1 -0
- package/dist/engine/session/uuid.js +50 -0
- package/dist/engine/session/uuid.js.map +1 -0
- package/dist/index.d.ts +160 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +374 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/harness.d.ts +26 -0
- package/dist/internal/harness.d.ts.map +1 -0
- package/dist/internal/harness.js +24 -0
- package/dist/internal/harness.js.map +1 -0
- package/dist/internal/llm.d.ts +9 -0
- package/dist/internal/llm.d.ts.map +1 -0
- package/dist/internal/llm.js +8 -0
- package/dist/internal/llm.js.map +1 -0
- package/dist/orchestration/builtin-workflows.d.ts +44 -0
- package/dist/orchestration/builtin-workflows.d.ts.map +1 -0
- package/dist/orchestration/builtin-workflows.js +165 -0
- package/dist/orchestration/builtin-workflows.js.map +1 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts +24 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts.map +1 -0
- package/dist/orchestration/dev-vm-script-runner.js +106 -0
- package/dist/orchestration/dev-vm-script-runner.js.map +1 -0
- package/dist/orchestration/goal.d.ts +97 -0
- package/dist/orchestration/goal.d.ts.map +1 -0
- package/dist/orchestration/goal.js +248 -0
- package/dist/orchestration/goal.js.map +1 -0
- package/dist/orchestration/run-spec.d.ts +63 -0
- package/dist/orchestration/run-spec.d.ts.map +1 -0
- package/dist/orchestration/run-spec.js +274 -0
- package/dist/orchestration/run-spec.js.map +1 -0
- package/dist/orchestration/run-workflow-tool.d.ts +187 -0
- package/dist/orchestration/run-workflow-tool.d.ts.map +1 -0
- package/dist/orchestration/run-workflow-tool.js +612 -0
- package/dist/orchestration/run-workflow-tool.js.map +1 -0
- package/dist/orchestration/workflow-governance.d.ts +70 -0
- package/dist/orchestration/workflow-governance.d.ts.map +1 -0
- package/dist/orchestration/workflow-governance.js +176 -0
- package/dist/orchestration/workflow-governance.js.map +1 -0
- package/dist/orchestration/workflow-meta.d.ts +41 -0
- package/dist/orchestration/workflow-meta.d.ts.map +1 -0
- package/dist/orchestration/workflow-meta.js +426 -0
- package/dist/orchestration/workflow-meta.js.map +1 -0
- package/dist/orchestration/workflow-observe.d.ts +77 -0
- package/dist/orchestration/workflow-observe.d.ts.map +1 -0
- package/dist/orchestration/workflow-observe.js +177 -0
- package/dist/orchestration/workflow-observe.js.map +1 -0
- package/dist/orchestration/workflow-primitives.d.ts +31 -0
- package/dist/orchestration/workflow-primitives.d.ts.map +1 -0
- package/dist/orchestration/workflow-primitives.js +104 -0
- package/dist/orchestration/workflow-primitives.js.map +1 -0
- package/dist/orchestration/workflow-sandbox-conformance.d.ts +34 -0
- package/dist/orchestration/workflow-sandbox-conformance.d.ts.map +1 -0
- package/dist/orchestration/workflow-sandbox-conformance.js +301 -0
- package/dist/orchestration/workflow-sandbox-conformance.js.map +1 -0
- package/dist/orchestration/workflow-script-runner.d.ts +127 -0
- package/dist/orchestration/workflow-script-runner.d.ts.map +1 -0
- package/dist/orchestration/workflow-script-runner.js +48 -0
- package/dist/orchestration/workflow-script-runner.js.map +1 -0
- package/dist/orchestration/workflow-script-store.d.ts +99 -0
- package/dist/orchestration/workflow-script-store.d.ts.map +1 -0
- package/dist/orchestration/workflow-script-store.js +133 -0
- package/dist/orchestration/workflow-script-store.js.map +1 -0
- package/dist/orchestration/workflow-size-guideline.d.ts +50 -0
- package/dist/orchestration/workflow-size-guideline.d.ts.map +1 -0
- package/dist/orchestration/workflow-size-guideline.js +78 -0
- package/dist/orchestration/workflow-size-guideline.js.map +1 -0
- package/dist/orchestration/workflow.d.ts +624 -0
- package/dist/orchestration/workflow.d.ts.map +1 -0
- package/dist/orchestration/workflow.js +1596 -0
- package/dist/orchestration/workflow.js.map +1 -0
- package/dist/prompts/default.d.ts +474 -0
- package/dist/prompts/default.d.ts.map +1 -0
- package/dist/prompts/default.js +676 -0
- package/dist/prompts/default.js.map +1 -0
- package/dist/prompts/supervisor.d.ts +60 -0
- package/dist/prompts/supervisor.d.ts.map +1 -0
- package/dist/prompts/supervisor.js +162 -0
- package/dist/prompts/supervisor.js.map +1 -0
- package/dist/scenarios/env.d.ts +41 -0
- package/dist/scenarios/env.d.ts.map +1 -0
- package/dist/scenarios/env.js +65 -0
- package/dist/scenarios/env.js.map +1 -0
- package/dist/scenarios/full-body.d.ts +47 -0
- package/dist/scenarios/full-body.d.ts.map +1 -0
- package/dist/scenarios/full-body.js +36 -0
- package/dist/scenarios/full-body.js.map +1 -0
- package/dist/scenarios/scenario-registry.d.ts +107 -0
- package/dist/scenarios/scenario-registry.d.ts.map +1 -0
- package/dist/scenarios/scenario-registry.js +192 -0
- package/dist/scenarios/scenario-registry.js.map +1 -0
- package/dist/scenarios/teacher-quickstart.d.ts +41 -0
- package/dist/scenarios/teacher-quickstart.d.ts.map +1 -0
- package/dist/scenarios/teacher-quickstart.js +32 -0
- package/dist/scenarios/teacher-quickstart.js.map +1 -0
- package/dist/server/http.d.ts +36 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +144 -0
- package/dist/server/http.js.map +1 -0
- package/dist/stores/file/checkpoint-store.d.ts +62 -0
- package/dist/stores/file/checkpoint-store.d.ts.map +1 -0
- package/dist/stores/file/checkpoint-store.js +250 -0
- package/dist/stores/file/checkpoint-store.js.map +1 -0
- package/dist/stores/file/file-snapshot-store.d.ts +43 -0
- package/dist/stores/file/file-snapshot-store.d.ts.map +1 -0
- package/dist/stores/file/file-snapshot-store.js +374 -0
- package/dist/stores/file/file-snapshot-store.js.map +1 -0
- package/dist/stores/file/fs-atomic.d.ts +95 -0
- package/dist/stores/file/fs-atomic.d.ts.map +1 -0
- package/dist/stores/file/fs-atomic.js +415 -0
- package/dist/stores/file/fs-atomic.js.map +1 -0
- package/dist/stores/file/index.d.ts +98 -0
- package/dist/stores/file/index.d.ts.map +1 -0
- package/dist/stores/file/index.js +109 -0
- package/dist/stores/file/index.js.map +1 -0
- package/dist/stores/file/memory-store.d.ts +95 -0
- package/dist/stores/file/memory-store.d.ts.map +1 -0
- package/dist/stores/file/memory-store.js +393 -0
- package/dist/stores/file/memory-store.js.map +1 -0
- package/dist/stores/file/session-policy-store.d.ts +24 -0
- package/dist/stores/file/session-policy-store.d.ts.map +1 -0
- package/dist/stores/file/session-policy-store.js +123 -0
- package/dist/stores/file/session-policy-store.js.map +1 -0
- package/dist/stores/file/session-store.d.ts +34 -0
- package/dist/stores/file/session-store.d.ts.map +1 -0
- package/dist/stores/file/session-store.js +175 -0
- package/dist/stores/file/session-store.js.map +1 -0
- package/dist/stores/file/tool-result-store.d.ts +23 -0
- package/dist/stores/file/tool-result-store.d.ts.map +1 -0
- package/dist/stores/file/tool-result-store.js +61 -0
- package/dist/stores/file/tool-result-store.js.map +1 -0
- package/dist/stores/file/workflow-journal-store.d.ts +36 -0
- package/dist/stores/file/workflow-journal-store.d.ts.map +1 -0
- package/dist/stores/file/workflow-journal-store.js +157 -0
- package/dist/stores/file/workflow-journal-store.js.map +1 -0
- package/dist/stores/file/workflow-run-store.d.ts +58 -0
- package/dist/stores/file/workflow-run-store.d.ts.map +1 -0
- package/dist/stores/file/workflow-run-store.js +178 -0
- package/dist/stores/file/workflow-run-store.js.map +1 -0
- package/dist/stores/pg.d.ts +210 -0
- package/dist/stores/pg.d.ts.map +1 -0
- package/dist/stores/pg.js +652 -0
- package/dist/stores/pg.js.map +1 -0
- package/dist/tools/fs/encoding.d.ts +51 -0
- package/dist/tools/fs/encoding.d.ts.map +1 -0
- package/dist/tools/fs/encoding.js +74 -0
- package/dist/tools/fs/encoding.js.map +1 -0
- package/dist/tools/fs/gh-rate-limit.d.ts +19 -0
- package/dist/tools/fs/gh-rate-limit.d.ts.map +1 -0
- package/dist/tools/fs/gh-rate-limit.js +35 -0
- package/dist/tools/fs/gh-rate-limit.js.map +1 -0
- package/dist/tools/fs/index.d.ts +246 -0
- package/dist/tools/fs/index.d.ts.map +1 -0
- package/dist/tools/fs/index.js +2130 -0
- package/dist/tools/fs/index.js.map +1 -0
- package/dist/tools/fs/pdf.d.ts +106 -0
- package/dist/tools/fs/pdf.d.ts.map +1 -0
- package/dist/tools/fs/pdf.js +178 -0
- package/dist/tools/fs/pdf.js.map +1 -0
- package/dist/tools/fs/repo-map.d.ts +15 -0
- package/dist/tools/fs/repo-map.d.ts.map +1 -0
- package/dist/tools/fs/repo-map.js +251 -0
- package/dist/tools/fs/repo-map.js.map +1 -0
- package/dist/tools/fs/safety.d.ts +168 -0
- package/dist/tools/fs/safety.d.ts.map +1 -0
- package/dist/tools/fs/safety.js +479 -0
- package/dist/tools/fs/safety.js.map +1 -0
- package/dist/tools/fs/search.d.ts +118 -0
- package/dist/tools/fs/search.d.ts.map +1 -0
- package/dist/tools/fs/search.js +650 -0
- package/dist/tools/fs/search.js.map +1 -0
- package/dist/tools/gitea-issue.d.ts +39 -0
- package/dist/tools/gitea-issue.d.ts.map +1 -0
- package/dist/tools/gitea-issue.js +91 -0
- package/dist/tools/gitea-issue.js.map +1 -0
- package/dist/tools/monitor.d.ts +64 -0
- package/dist/tools/monitor.d.ts.map +1 -0
- package/dist/tools/monitor.js +135 -0
- package/dist/tools/monitor.js.map +1 -0
- package/dist/tools/scheduler-tools.d.ts +48 -0
- package/dist/tools/scheduler-tools.d.ts.map +1 -0
- package/dist/tools/scheduler-tools.js +449 -0
- package/dist/tools/scheduler-tools.js.map +1 -0
- package/dist/tools/sql-adapters.d.ts +32 -0
- package/dist/tools/sql-adapters.d.ts.map +1 -0
- package/dist/tools/sql-adapters.js +31 -0
- package/dist/tools/sql-adapters.js.map +1 -0
- package/dist/tools/sql.d.ts +36 -0
- package/dist/tools/sql.d.ts.map +1 -0
- package/dist/tools/sql.js +131 -0
- package/dist/tools/sql.js.map +1 -0
- package/dist/tools/task-list.d.ts +26 -0
- package/dist/tools/task-list.d.ts.map +1 -0
- package/dist/tools/task-list.js +352 -0
- package/dist/tools/task-list.js.map +1 -0
- package/dist/tools/todo.d.ts +11 -0
- package/dist/tools/todo.d.ts.map +1 -0
- package/dist/tools/todo.js +126 -0
- package/dist/tools/todo.js.map +1 -0
- package/dist/tools/web.d.ts +59 -0
- package/dist/tools/web.d.ts.map +1 -0
- package/dist/tools/web.js +607 -0
- package/dist/tools/web.js.map +1 -0
- package/dist/tools/worktree.d.ts +88 -0
- package/dist/tools/worktree.d.ts.map +1 -0
- package/dist/tools/worktree.js +434 -0
- package/dist/tools/worktree.js.map +1 -0
- package/docs/A1-ATTRIBUTION-ROUND1-2026-07-09.md +181 -0
- package/docs/AB-ORACLE-GATE-VERDICT-2026-07-10.md +100 -0
- package/docs/ANCHOR-GAP-INVENTORY-2026-07-09.md +143 -0
- package/docs/ARCHITECTURE.md +125 -0
- package/docs/BUGHUNT-2026-07-05-NIGHT.md +98 -0
- package/docs/BUILD.md +63 -0
- package/docs/CANCEL-ASYNC-ATTRIBUTION-2026-07-09.md +98 -0
- package/docs/CC-198-VS-201-DRIFT-2026-07-09.md +70 -0
- package/docs/CC-BASELINE-FAKE-ZERO-AUDIT-2026-07-09.md +51 -0
- package/docs/CC-DRIFT-198-206-AGENT-TYPES-2026-07-10.md +82 -0
- package/docs/CC-DRIFT-198-206-CHANGELOG-2026-07-10.md +82 -0
- package/docs/CC-DRIFT-198-206-REMINDERS-2026-07-10.md +96 -0
- package/docs/CC-DRIFT-198-206-ROADMAP-2026-07-10.md +110 -0
- package/docs/CC-DRIFT-198-206-TOOL-INVENTORY-2026-07-10.md +53 -0
- package/docs/CC-DRIFT-198-206-USAGE-CONSTANTS-2026-07-10.md +64 -0
- package/docs/CC-DRIFT-198-206-WORKFLOW-2026-07-10.md +83 -0
- package/docs/CC-PARITY-CHECKLIST.md +220 -0
- package/docs/CC-PARITY-DEEP-SWEEP-2026-07-07.md +149 -0
- package/docs/CC-SUBAGENT-PROMPT-STUDY-2026-07-09.md +219 -0
- package/docs/CC-TASK-REMINDER-CADENCE-STUDY-2026-07-09.md +396 -0
- package/docs/CC-TOOL-PARITY-SWEEP-2026-07.md +56 -0
- package/docs/CC-TOOL-PROMPT-DEEP-DIFF-2026-07-08.md +274 -0
- package/docs/CC-TOOLSURFACE-DEEP-DIVE-2026-07-07.md +197 -0
- package/docs/CC206-OBSERVER-ANCHORS-2026-07-11.md +463 -0
- package/docs/CC207-CORE-SWEEP-BACKLOG-2026-07-12.md +155 -0
- package/docs/CENTER-CONTROL-PLANE-SEAM.md +86 -0
- package/docs/CLEANUP-CONTRACT-ANCHOR-2026-07-09.md +83 -0
- package/docs/COLD-START-RSI-2026-07-09.md +72 -0
- package/docs/COMPACTION-LIVE-AUDIT-2026-07-09.md +114 -0
- package/docs/CONTEXT-lifecycle-extension-points-and-stop-attribution.md +71 -0
- package/docs/COREWARS-POLYGLOT-TRIAGE-2026-07-09.md +85 -0
- package/docs/DEADTARGET-OVERFULL-HBOX-2026-07-10.md +92 -0
- package/docs/DEADTARGET-PATH-TRACING-REVERSE-2026-07-10.md +87 -0
- package/docs/DEADTARGET-WINNING-AVG-COREWARS-2026-07-10.md +96 -0
- package/docs/DEEPSEEK-API-LIMITS-PROBE-2026-07-09.md +118 -0
- package/docs/DESIGN-140-MOCK-VERIFY-2026-07-11.md +79 -0
- package/docs/DESIGN-140-VERIFICATION-2026-07-11.md +43 -0
- package/docs/DESIGN-DRAFT-workflow-collab-2026-07-11.md +56 -0
- package/docs/DESIGN-ORACLE-GROUNDING-GATE-2026-07-10.md +167 -0
- package/docs/DESIGN-TFRAG-RECONCILE-SCAFFOLD-2026-07-09.md +102 -0
- package/docs/EXP-PA2-PE-DESIGN-2026-07-11.md +220 -0
- package/docs/EXT-DOGFOOD-2026-07-12.md +50 -0
- package/docs/FINAL-VERIFY-SURFACE-AUDIT-2026-07-09.md +44 -0
- package/docs/FRAG-RECON-INVESTIGATION-2026-07-09.md +183 -0
- package/docs/HANDOFF.md +121 -0
- package/docs/KNOWN-ISSUES.md +96 -0
- package/docs/LEGW-WINDOW-TAX-2026-07-10.md +82 -0
- package/docs/LIVE-PROBE-BATCH-2026-07-11.md +207 -0
- package/docs/M2-CERT-ATTRIBUTION-2026-07-10.md +61 -0
- package/docs/M25-LEG-VARIANCE-ATTRIBUTION-2026-07-10.md +81 -0
- package/docs/MAILMAN-TIMEOUT-ATTRIBUTION-2026-07-10.md +88 -0
- package/docs/MEMORY-BACKEND-DIALECT-NOTES.md +69 -0
- package/docs/MTEB-ESCAPE-HATCH-ATTRIBUTION-2026-07-09.md +57 -0
- package/docs/MTEB-LEADERBOARD-ATTRIBUTION-2026-07-10.md +134 -0
- package/docs/ORACLE-GATE-NEGATIVE-SAMPLE-2026-07-11.md +28 -0
- package/docs/PARITY-CONTEXT-TRANSACTIONS-2026-07-10.md +67 -0
- package/docs/PARITY-PROGRESS-MATRIX-2026-07-10.md +37 -0
- package/docs/PARITY-SPOT-AGENT-TYPES-2026-07-10.md +70 -0
- package/docs/PARITY-SPOT-REMINDERS-2026-07-10.md +144 -0
- package/docs/PARITY-SPOT-TOOL-INVENTORY-2026-07-10.md +61 -0
- package/docs/PARITY-SPOT-USAGE-CONSTANTS-2026-07-10.md +95 -0
- package/docs/PARITY-SPOT-WORKFLOW-2026-07-10.md +93 -0
- package/docs/PASSWORD-RECOVERY-PANEL-VERDICT-2026-07-10.md +62 -0
- package/docs/R8-R9-FINALIZE-COORDINATION-2026-07-09.md +124 -0
- package/docs/REPL-CODE-MODE-EVALUATION-2026-07-10.md +187 -0
- package/docs/REPORT-1249-TARGETED.md +48 -0
- package/docs/RESEARCH-3P-MEMORY-SWAP-2026-07-12.md +273 -0
- package/docs/ROADMAP.md +111 -0
- package/docs/RSI-CLOUD-DEPLOY-2026-07-06.md +289 -0
- package/docs/RSI-PROCESS-AI-COLDSTART-2026-07-11.md +68 -0
- package/docs/S18-THOROUGHNESS-AUDIT-2026-07-09.md +113 -0
- package/docs/SERVICE-INTEGRATION-GUIDE.md +298 -0
- package/docs/SUBAGENT-STREAM-RESILIENCE-PARITY-2026-07-10.md +118 -0
- package/docs/SWEBENCH-PRO-RECON-2026-07-11.md +31 -0
- package/docs/TB-EFFICIENCY-TELEMETRY-2026-07-08.md +114 -0
- package/docs/TB-FAILURE-AUTOPSY-2026-07-05-RERUN.md +67 -0
- package/docs/TB-FAIRNESS-AUDIT-2026-07-08.md +141 -0
- package/docs/TB-FULL-1257-2026-07-08.md +77 -0
- package/docs/TB-LEG-GAP-ATTRIBUTION-1261-1263-2026-07-11.md +154 -0
- package/docs/TB-REGRESSION-DAEMON-KILL-2026-07-08.md +58 -0
- package/docs/TB-RSI-CROSSCHECK-2026-07-06.md +68 -0
- package/docs/TB-RSI-LEDGER.md +30 -0
- package/docs/TB-STABLE-SET-2026-07-08.md +127 -0
- package/docs/TB21-RECON-2026-07-11.md +28 -0
- package/docs/TEST-DESIGN-BATCH-1-2-3.md +97 -0
- package/docs/THIRD-PARTY-INTEGRATION.md +45 -0
- package/docs/TOKEN-ESTIMATE-CALIBRATION-LIVE-2026-07-09.md +102 -0
- package/docs/audit-2026-06-10-/347/254/254/344/272/214/350/275/256-/347/251/272/347/231/275/345/214/272/344/270/216/345/277/230/346/216/245/347/272/277.md +147 -0
- package/docs/audit-2026-06-10-/350/256/241/347/256/227bug/346/211/253/346/217/217.md +163 -0
- package/docs/audit-2026-06-11-/344/277/256/345/244/215/345/244/215/345/256/241/344/270/216/345/233/236/345/275/222/344/270/223/346/211/253.md +95 -0
- package/docs/audit-2026-06-12-design71-P1/346/275/234/344/274/217/351/235/242/350/243/201/345/206/263/344/270/216/345/220/236/351/224/231/345/256/241/350/256/241.md +45 -0
- package/docs/audit-2026-06-12-/345/205/254/345/274/200/346/227/213/351/222/256/346/264/273/346/200/247/344/270/216vendored/346/255/273/350/267/257.md +63 -0
- package/docs/audit-2026-06-15/ADDENDUM-second-pass.md +88 -0
- package/docs/audit-2026-06-15/ARCHITECTURE-AND-ROADMAP.md +187 -0
- package/docs/audit-2026-06-15/DOC-CORRECTIONS.md +105 -0
- package/docs/audit-2026-06-15/INDEX.md +49 -0
- package/docs/audit-2026-06-15/ORCHESTRATION-STATUS.md +98 -0
- package/docs/audit-2026-06-15/PRODUCTION-ISSUES.md +189 -0
- package/docs/audit-2026-06-15/REFERENCES-literature.md +139 -0
- package/docs/audit-2026-06-15/VENDOR-REFACTOR-PLAN.md +96 -0
- package/docs/cc-probe-198/README.md +72 -0
- package/docs/cc-probe-198/STABILITY-AUDIT.md +118 -0
- package/docs/cc-probe-198/live-schema-monitor-worktree-2026-07-09.json +56 -0
- package/docs/cc-probe-198/mount-variants.json +536 -0
- package/docs/cc-probe-198/plan-mode-run.json +1 -0
- package/docs/cc-probe-198/probe-bash-bg.json +224 -0
- package/docs/cc-probe-198/probe-edit-mismatch.json +120 -0
- package/docs/cc-probe-198/probe-read-missing.json +62 -0
- package/docs/cc-probe-198/probe-search-empty.json +127 -0
- package/docs/cc-probe-198/probe-task-family.json +227 -0
- package/docs/cc-probe-198/probes.status +6 -0
- package/docs/cc-probe-198/raw-capture-interactive.json +948 -0
- package/docs/cc-probe-198/raw-capture-print.json +787 -0
- package/docs/cc-probe-198/raw-capture2-interactive.json +948 -0
- package/docs/cc-probe-198/raw-capture2-print.json +787 -0
- package/docs/cc-probe-198/system-prompt.txt +135 -0
- package/docs/cc-probe-198/tools-array.json +962 -0
- package/docs/durability-boundary.md +63 -0
- package/docs/fix-2026-06-10-/350/256/241/347/256/227bug/344/277/256/345/244/215-search/346/211/271.md +75 -0
- package/docs/fix-2026-06-11-/347/254/254/344/272/214/350/275/256-/344/277/256/345/244/215-search/346/211/271.md +62 -0
- package/docs/parity-sweep/REPORT-DYNAMIC.md +97 -0
- package/docs/parity-sweep/REPORT-STATIC-GGB.md +127 -0
- package/docs/parity-sweep/REPORT-STATIC-RWE.md +133 -0
- package/docs/vendor-history.md +385 -0
- package/docs/vendored-upstream-diff-2026-07.md +83 -0
- package/package.json +70 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { MemoryStore } from "./memory.js";
|
|
2
|
+
import { type ConsolidationLLM, type ConsolidationStats } from "./runner/memory-consolidation.js";
|
|
3
|
+
/**
|
|
4
|
+
* design/84 Seam B (M6+M10) — **cursor-incremental scope consolidation**. A thin function over the pure
|
|
5
|
+
* {@link runMemoryConsolidation}: it reads the scope's persisted cursor, feeds ONLY the notes appended
|
|
6
|
+
* AFTER it (the incremental batch) into one reconcile pass, then — IFF the whole pass succeeds — advances
|
|
7
|
+
* the cursor to the high-water mark it observed. This is the externally-triggerable periodic path (a
|
|
8
|
+
* deployment's timer / N-session gate fires it); the TRIGGER and any cross-process LOCK live OUTSIDE this
|
|
9
|
+
* function (the deployment shell's exec/persist axes — see {@link ConsolidateScopeOptions.acquire}).
|
|
10
|
+
*
|
|
11
|
+
* **Cursor marker semantics (no-miss / no-dup):** the cursor is an OPAQUE ordering marker the STORE defines
|
|
12
|
+
* (this core never parses it). In the three reference stores it is a note **id** — `uuidv7`, which is
|
|
13
|
+
* lexicographically time-sortable, so "after the cursor" is a string `>` comparison and the high-water mark
|
|
14
|
+
* is the lexicographic MAX. Each pass:
|
|
15
|
+
* - reads `cursor = getConsolidationCursor(scope)` (undefined ⇒ whole scope pending),
|
|
16
|
+
* - lists the scope's note headers (stable store ordering) and keeps those with `id > cursor` AND not
|
|
17
|
+
* already `consolidationGenerated` (a prior pass's own output — excluded so it is never re-merged),
|
|
18
|
+
* - reconciles that incremental batch via `runMemoryConsolidation` (which itself re-excludes
|
|
19
|
+
* `consolidationGenerated` + this-batch ids from each note's candidate set),
|
|
20
|
+
* - advances the cursor to the high-water mark of the fed batch ∪ `stats.addedIds`, but capped STRICTLY
|
|
21
|
+
* BELOW the smallest note this pass FAILED to process (`stats.failedIds`) — a contiguous successful-prefix
|
|
22
|
+
* marker, not the plain max (the MAJOR1 BLOCKER: a single max marker cannot keep a sub-max failed note
|
|
23
|
+
* pending; see {@link cappedHighWater}).
|
|
24
|
+
* No-dup: a note with `id <= cursor` is never re-fed. No-miss: a note appended after the advance, or one at/
|
|
25
|
+
* above a failure floor this pass, keeps `id > cursor` (uuidv7 monotonic) and is picked up by a later pass. A
|
|
26
|
+
* pass's own ADDs carry `consolidationGenerated:true` AND (when below the failure floor) are folded into the
|
|
27
|
+
* high-water mark, so they are excluded twice over.
|
|
28
|
+
*
|
|
29
|
+
* **Whole-pass advance (decision 3):** the cursor advances (up to the success boundary) ONLY when the pass
|
|
30
|
+
* returns (no throw). A pass that THROWS (LLM hard failure) does NOT advance at all — the batch is fully
|
|
31
|
+
* retried next time. A pass that returns with per-note failures advances only past the contiguous successful
|
|
32
|
+
* prefix below the smallest failure (fail-open: at worst a near-duplicate survives an extra pass, never data
|
|
33
|
+
* loss; consistent with the memory-store contract).
|
|
34
|
+
*
|
|
35
|
+
* **No-op safety (the BLOCKER §2 closes):** when the store lacks the cursor pair
|
|
36
|
+
* ({@link supportsPeriodicConsolidation} false) this is a NO-OP that calls `onWarn` — it NEVER degrades into a
|
|
37
|
+
* full re-consolidation of the whole scope (which would re-merge already-consolidated notes forever). It is
|
|
38
|
+
* also a no-op when the store can't consolidate at all ({@link supportsConsolidation} false) or the manifest
|
|
39
|
+
* surface ({@link MemoryStore.listStructuredNotes}) is absent.
|
|
40
|
+
*/
|
|
41
|
+
export interface ConsolidateScopeDeps {
|
|
42
|
+
store: MemoryStore;
|
|
43
|
+
llm: ConsolidationLLM;
|
|
44
|
+
/** Routes diagnostics (skipped decisions, no-op-because-unsupported, lock-busy) — same sink as the Runner's
|
|
45
|
+
* `onError(phase:"memory")`. Never throws back into this function. */
|
|
46
|
+
onWarn?: (err: unknown) => void;
|
|
47
|
+
/**
|
|
48
|
+
* design/84 Seam B (TOC profile) — OPTIONAL cross-process consolidation lock. When provided,
|
|
49
|
+
* {@link consolidateScope} acquires it for `scope` before the pass and releases it after; a `release` of
|
|
50
|
+
* `undefined` (lock busy) makes the pass a NO-OP (another process is already consolidating this scope).
|
|
51
|
+
* The implementation (writeThenLink + stale-PID prune) lives in the deployment shell (`stores/file`), NOT
|
|
52
|
+
* core — core only DEFINES the injection point (the constitutional persist/exec-axis split).
|
|
53
|
+
*/
|
|
54
|
+
acquire?: (scope: string) => Promise<(() => void) | undefined> | (() => void) | undefined;
|
|
55
|
+
}
|
|
56
|
+
/** Tuning for one {@link consolidateScope} pass (mirrors the inline consolidation settings; all optional). */
|
|
57
|
+
export interface ConsolidateScopeOptions {
|
|
58
|
+
band?: {
|
|
59
|
+
lo: number;
|
|
60
|
+
hi: number;
|
|
61
|
+
};
|
|
62
|
+
searchLimit?: number;
|
|
63
|
+
/** Cap on notes fed into ONE pass (token bound). The cursor advances only past the contiguous SUCCESSFUL
|
|
64
|
+
* prefix of the FED batch (the first `maxNotes` pending) — never past the un-fed tail beyond the cap, and
|
|
65
|
+
* never past a note this pass FAILED to process — so a backlog larger than `maxNotes`, and any failed note,
|
|
66
|
+
* keep `id > cursor` and drain over successive passes without ever re-feeding the notes already handled. */
|
|
67
|
+
maxNotes?: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Run ONE cursor-incremental consolidation pass for `scope` (design/84 Seam B). Returns the pass stats
|
|
71
|
+
* (or `undefined` when it was a no-op: unsupported store, empty incremental batch, or lock busy). Never
|
|
72
|
+
* throws for a no-op reason; a hard LLM failure inside `runMemoryConsolidation` propagates (the caller's
|
|
73
|
+
* fire-and-forget envelope catches it) and the cursor is left UN-advanced (the batch retries next pass).
|
|
74
|
+
*/
|
|
75
|
+
export declare function consolidateScope(scope: string, deps: ConsolidateScopeDeps, opts?: ConsolidateScopeOptions): Promise<ConsolidationStats | undefined>;
|
|
76
|
+
/**
|
|
77
|
+
* design/84 Seam B (切片 4) — advance ONLY the cursor after an INLINE (task-end) consolidation pass has
|
|
78
|
+
* already run, so a later periodic {@link consolidateScope} starts from the inline-processed high-water mark
|
|
79
|
+
* (it does NOT re-consolidate the notes the inline pass just handled). The inline path consolidates the
|
|
80
|
+
* notes the model saved THIS task (the newest, highest-id notes); advancing the cursor over the PROCESSED
|
|
81
|
+
* ids ∪ addedIds makes inline and periodic share ONE cursor.
|
|
82
|
+
*
|
|
83
|
+
* **MAJOR1 BLOCKER:** the advance caps STRICTLY BELOW the smallest FAILED note (`failedIds`). A single
|
|
84
|
+
* max-marker cursor cannot keep a sub-max failed note pending, so a low-id note whose handling failed must
|
|
85
|
+
* stop the cursor below it even when a higher-id sibling succeeded — otherwise the failed note (id <= the
|
|
86
|
+
* plain max) would lose `id > cursor` and be exiled from consolidation forever. Pass the pass's
|
|
87
|
+
* `stats.consolidatedIds` (processed), `stats.addedIds`, and `stats.failedIds`.
|
|
88
|
+
*
|
|
89
|
+
* No-op when the store lacks the cursor pair (back-compat: an old store keeps the pure-inline behavior).
|
|
90
|
+
* Never throws — a cursor-advance failure routes to `onWarn` (the inline notes are already durable; the
|
|
91
|
+
* worst case is the next periodic pass re-sees them, which `runMemoryConsolidation` handles idempotently).
|
|
92
|
+
*/
|
|
93
|
+
export declare function advanceCursorAfterInline(store: MemoryStore, scope: string, seenNoteIds: ReadonlyArray<string | undefined>, addedIds: ReadonlyArray<string>, failedIds?: ReadonlyArray<string>, onWarn?: (err: unknown) => void): Promise<void>;
|
|
94
|
+
//# sourceMappingURL=consolidate-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consolidate-scope.d.ts","sourceRoot":"","sources":["../../src/core/consolidate-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,aAAa,CAAC;AAEjE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAIxB,MAAM,kCAAkC,CA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js";
|
|
2
|
+
import { runMemoryConsolidation, DEFAULT_CONSOLIDATION_BAND, DEFAULT_CONSOLIDATION_SEARCH_LIMIT, DEFAULT_CONSOLIDATION_MAX_NOTES, } from "./runner/memory-consolidation.js";
|
|
3
|
+
/** Lexicographic max of two opaque markers (uuidv7 ids sort by time). `undefined` < any string. */
|
|
4
|
+
function maxMarker(a, b) {
|
|
5
|
+
return a === undefined || b > a ? b : a;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* design/84 Seam B (MAJOR1 BLOCKER) — the cursor's new high-water mark = the largest `seen` id that is
|
|
9
|
+
* still SAFE to advance past, i.e. STRICTLY BELOW the smallest FAILED id. A single max-marker cursor cannot
|
|
10
|
+
* express "skip the middle, keep a low one pending", so when a low-id note fails while a higher-id note
|
|
11
|
+
* succeeds, advancing to the plain max would exile the low note from consolidation forever (it'd no longer
|
|
12
|
+
* satisfy `id > cursor`). Capping below the smallest failure keeps the failed note — and every id at/above
|
|
13
|
+
* it — pending for the next pass (retried), while still advancing the contiguous successful prefix.
|
|
14
|
+
*
|
|
15
|
+
* `seen` = every id this pass observed that is eligible to move the cursor (the fed batch ∪ this pass's own
|
|
16
|
+
* ADD ids). `failed` = the ids this pass did NOT process to completion. No failure ⇒ the plain max of seen
|
|
17
|
+
* (existing behavior). Returns `undefined` only when there is nothing below the floor to advance to (the
|
|
18
|
+
* caller then leaves the cursor untouched).
|
|
19
|
+
*/
|
|
20
|
+
function cappedHighWater(seen, failed) {
|
|
21
|
+
let floor; // smallest failed id (exclusive upper bound for the cursor)
|
|
22
|
+
for (const id of failed)
|
|
23
|
+
if (floor === undefined || id < floor)
|
|
24
|
+
floor = id;
|
|
25
|
+
let hw;
|
|
26
|
+
for (const id of seen) {
|
|
27
|
+
if (floor !== undefined && id >= floor)
|
|
28
|
+
continue; // at/above a failure ⇒ keep pending, do not advance past
|
|
29
|
+
hw = maxMarker(hw, id);
|
|
30
|
+
}
|
|
31
|
+
return hw;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Run ONE cursor-incremental consolidation pass for `scope` (design/84 Seam B). Returns the pass stats
|
|
35
|
+
* (or `undefined` when it was a no-op: unsupported store, empty incremental batch, or lock busy). Never
|
|
36
|
+
* throws for a no-op reason; a hard LLM failure inside `runMemoryConsolidation` propagates (the caller's
|
|
37
|
+
* fire-and-forget envelope catches it) and the cursor is left UN-advanced (the batch retries next pass).
|
|
38
|
+
*/
|
|
39
|
+
export async function consolidateScope(scope, deps, opts = {}) {
|
|
40
|
+
const { store, onWarn } = deps;
|
|
41
|
+
// Gate 1 — the cursor pair. Missing ⇒ NO-OP (never a silent full re-consolidation; the §2 BLOCKER).
|
|
42
|
+
if (!supportsPeriodicConsolidation(store)) {
|
|
43
|
+
onWarn?.(new Error("consolidateScope: store does not implement the consolidation cursor pair " +
|
|
44
|
+
"(getConsolidationCursor/setConsolidationCursor) — skipped (no-op), NOT degraded to a full re-consolidation"));
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
// Gate 2 — the id-addressable trio + the manifest. Without them there is nothing to incrementally read/merge.
|
|
48
|
+
if (!supportsConsolidation(store) || typeof store.listStructuredNotes !== "function") {
|
|
49
|
+
onWarn?.(new Error("consolidateScope: store is not id-addressable / has no manifest — skipped (no-op)"));
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
// Optional cross-process lock (TOC). A busy lock ⇒ another process owns this scope's pass ⇒ no-op.
|
|
53
|
+
const release = deps.acquire ? await deps.acquire(scope) : () => { };
|
|
54
|
+
if (release === undefined) {
|
|
55
|
+
onWarn?.(new Error(`consolidateScope: scope "${scope}" is locked by another consolidation — skipped (no-op)`));
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const cursor = await store.getConsolidationCursor(scope);
|
|
60
|
+
const headers = await store.listStructuredNotes(scope);
|
|
61
|
+
// Incremental batch: notes appended AFTER the cursor (id > cursor by string order), excluding a prior
|
|
62
|
+
// pass's own output (consolidationGenerated) so it is never re-merged. The cursor advance still observes
|
|
63
|
+
// those excluded ids (below), so they don't reopen the window.
|
|
64
|
+
// Sort the pending headers by their opaque ordering marker (id) so "the first maxNotes" is the OLDEST
|
|
65
|
+
// post-cursor notes — capping then advances the cursor only past those, and the NEXT pass picks up the
|
|
66
|
+
// tail (no-miss). listStructuredNotes is documented to use the store's stable ordering, but sort here so
|
|
67
|
+
// the cap is deterministic across stores regardless of their list order.
|
|
68
|
+
const pending = headers
|
|
69
|
+
.filter((h) => !h.consolidationGenerated && (cursor === undefined || h.id > cursor))
|
|
70
|
+
.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
71
|
+
if (pending.length === 0) {
|
|
72
|
+
return undefined; // nothing new since the last pass — no-op (do NOT touch the cursor)
|
|
73
|
+
}
|
|
74
|
+
// Fetch the bodies for the incremental batch (capped) and feed them as the "new facts" to reconcile
|
|
75
|
+
// against the rest of the scope. `runMemoryConsolidation` excludes these ids + consolidationGenerated
|
|
76
|
+
// from each note's candidate set, so an incremental note never reconciles against itself.
|
|
77
|
+
const maxNotes = opts.maxNotes ?? DEFAULT_CONSOLIDATION_MAX_NOTES;
|
|
78
|
+
const batch = pending.slice(0, maxNotes);
|
|
79
|
+
const batchIds = batch.map((h) => h.id);
|
|
80
|
+
const records = await store.getByIds(scope, batchIds);
|
|
81
|
+
const byId = new Map(records.map((r) => [r.id, r]));
|
|
82
|
+
// Preserve store ordering; drop any id the store no longer returns (raced delete) — fail-open.
|
|
83
|
+
const notes = batchIds
|
|
84
|
+
.map((id) => byId.get(id))
|
|
85
|
+
.filter((r) => r !== undefined)
|
|
86
|
+
.map((r) => ({ id: r.id, text: r.text }));
|
|
87
|
+
let stats;
|
|
88
|
+
if (notes.length > 0) {
|
|
89
|
+
stats = await runMemoryConsolidation({
|
|
90
|
+
store,
|
|
91
|
+
scope,
|
|
92
|
+
notes,
|
|
93
|
+
band: opts.band ?? { lo: DEFAULT_CONSOLIDATION_BAND.lo, hi: DEFAULT_CONSOLIDATION_BAND.hi },
|
|
94
|
+
searchLimit: opts.searchLimit ?? DEFAULT_CONSOLIDATION_SEARCH_LIMIT,
|
|
95
|
+
maxNotes,
|
|
96
|
+
llm: deps.llm,
|
|
97
|
+
onWarn,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// The new high-water mark caps STRICTLY BELOW the smallest FAILED note (MAJOR1 BLOCKER): a low-id note
|
|
101
|
+
// whose handling failed inside `runMemoryConsolidation` must stay `id > cursor` so the next pass retries
|
|
102
|
+
// it, even when a higher-id sibling succeeded. `seen` = the FED batch ids ∪ this pass's own ADD ids (the
|
|
103
|
+
// ADDs carry `consolidationGenerated`, so they're excluded as candidates anyway, but advancing past them
|
|
104
|
+
// — when below the failure floor — keeps the window from reopening). `failed` = stats.failedIds. A
|
|
105
|
+
// raced-delete note (in batchIds but dropped from the fed `notes`) is neither failed nor pending (it no
|
|
106
|
+
// longer exists), so it doesn't block the cursor. No failure ⇒ the plain max over the fed batch (the
|
|
107
|
+
// no-miss guarantee: a > maxNotes backlog tail keeps id > cursor and drains over successive passes).
|
|
108
|
+
const seen = [...batchIds, ...(stats?.addedIds ?? [])];
|
|
109
|
+
const highWater = cappedHighWater(seen, stats?.failedIds ?? []);
|
|
110
|
+
// Whole-pass success boundary ⇒ advance the cursor (decision 3). A throw above skips this (batch retried
|
|
111
|
+
// next pass). highWater is undefined only when EVERY fed note failed (nothing safe to advance past).
|
|
112
|
+
if (highWater !== undefined && highWater !== cursor && (cursor === undefined || highWater > cursor)) {
|
|
113
|
+
await store.setConsolidationCursor(scope, highWater);
|
|
114
|
+
}
|
|
115
|
+
return stats ?? { tokens: 0, costMicroUsd: 0, applied: 0, addedIds: [], consolidatedIds: [], failedIds: [] };
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
release();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* design/84 Seam B (切片 4) — advance ONLY the cursor after an INLINE (task-end) consolidation pass has
|
|
123
|
+
* already run, so a later periodic {@link consolidateScope} starts from the inline-processed high-water mark
|
|
124
|
+
* (it does NOT re-consolidate the notes the inline pass just handled). The inline path consolidates the
|
|
125
|
+
* notes the model saved THIS task (the newest, highest-id notes); advancing the cursor over the PROCESSED
|
|
126
|
+
* ids ∪ addedIds makes inline and periodic share ONE cursor.
|
|
127
|
+
*
|
|
128
|
+
* **MAJOR1 BLOCKER:** the advance caps STRICTLY BELOW the smallest FAILED note (`failedIds`). A single
|
|
129
|
+
* max-marker cursor cannot keep a sub-max failed note pending, so a low-id note whose handling failed must
|
|
130
|
+
* stop the cursor below it even when a higher-id sibling succeeded — otherwise the failed note (id <= the
|
|
131
|
+
* plain max) would lose `id > cursor` and be exiled from consolidation forever. Pass the pass's
|
|
132
|
+
* `stats.consolidatedIds` (processed), `stats.addedIds`, and `stats.failedIds`.
|
|
133
|
+
*
|
|
134
|
+
* No-op when the store lacks the cursor pair (back-compat: an old store keeps the pure-inline behavior).
|
|
135
|
+
* Never throws — a cursor-advance failure routes to `onWarn` (the inline notes are already durable; the
|
|
136
|
+
* worst case is the next periodic pass re-sees them, which `runMemoryConsolidation` handles idempotently).
|
|
137
|
+
*/
|
|
138
|
+
export async function advanceCursorAfterInline(store, scope, seenNoteIds, addedIds, failedIds = [], onWarn) {
|
|
139
|
+
if (!supportsPeriodicConsolidation(store))
|
|
140
|
+
return; // pure-inline back-compat path
|
|
141
|
+
try {
|
|
142
|
+
const cursor = await store.getConsolidationCursor(scope);
|
|
143
|
+
const seen = [
|
|
144
|
+
...seenNoteIds.filter((id) => typeof id === "string" && Boolean(id)),
|
|
145
|
+
...addedIds,
|
|
146
|
+
];
|
|
147
|
+
// Cap below the smallest failed id; never move the cursor backward (seen ids may straddle the cursor).
|
|
148
|
+
const capped = cappedHighWater(seen, failedIds);
|
|
149
|
+
const highWater = cursor === undefined ? capped : maxMarker(cursor, capped ?? cursor);
|
|
150
|
+
if (highWater !== undefined && highWater !== cursor) {
|
|
151
|
+
await store.setConsolidationCursor(scope, highWater);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
onWarn?.(err);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=consolidate-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consolidate-scope.js","sourceRoot":"","sources":["../../src/core/consolidate-scope.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,EACL,sBAAsB,EAGtB,0BAA0B,EAC1B,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,kCAAkC,CAAC;AAmE1C,mGAAmG;AACnG,SAAS,SAAS,CAAC,CAAqB,EAAE,CAAS;IACjD,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,eAAe,CACtB,IAAsB,EACtB,MAAwB;IAExB,IAAI,KAAyB,CAAC,CAAC,4DAA4D;IAC3F,KAAK,MAAM,EAAE,IAAI,MAAM;QAAE,IAAI,KAAK,KAAK,SAAS,IAAI,EAAE,GAAG,KAAK;YAAE,KAAK,GAAG,EAAE,CAAC;IAC3E,IAAI,EAAsB,CAAC;IAC3B,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACtB,IAAI,KAAK,KAAK,SAAS,IAAI,EAAE,IAAI,KAAK;YAAE,SAAS,CAAC,yDAAyD;QAC3G,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAa,EACb,IAA0B,EAC1B,OAAgC,EAA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;YAAS,CAAC;QACT,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,KAAkB,EAClB,KAAa,EACb,WAA8C,EAC9C,QAA+B,EAC/B,YAAmC,EAAE,EACrC,MAA+B;IAE/B,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,+BAA+B;IAClF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,sBAAuB,CAAC,KAAK,CAAC,CAAC;QAC1D,MAAM,IAAI,GAAG;YACX,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,EAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC;YAClF,GAAG,QAAQ;SACZ,CAAC;QACF,uGAAuG;QACvG,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,IAAI,MAAM,CAAC,CAAC;QACtF,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;YACpD,MAAM,KAAK,CAAC,sBAAuB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { AgentMessage } from "../internal/harness.js";
|
|
2
|
+
import type { Model } from "../internal/llm.js";
|
|
3
|
+
/**
|
|
4
|
+
* Fraction of the window at which we start clearing stale tool results (lighter than the guard trim).
|
|
5
|
+
* Exported as the single source for the compaction-threshold clamp (design/64 §26.4 fix 2): compaction
|
|
6
|
+
* must trigger AT OR BELOW this point, or every request inside the clearStale band breaks the prefix
|
|
7
|
+
* cache at the clearing frontier (~0.7W re-prefilled per request — the "death band").
|
|
8
|
+
*/
|
|
9
|
+
export declare const EDIT_FRACTION = 0.7;
|
|
10
|
+
/**
|
|
11
|
+
* checklist #54 (CC microCompact.ts:41-50 `COMPACTABLE_TOOLS` parity): the INCLUSION whitelist of
|
|
12
|
+
* tools whose results may be content-cleared by the stale-result pass. CC's set is exactly
|
|
13
|
+
* { Read, Bash, PowerShell (SHELL_TOOL_NAMES), Grep, Glob, WebSearch, WebFetch, Edit, Write } —
|
|
14
|
+
* cheap-to-regenerate I/O. Everything else is PRESERVED: expensive/decision-bearing results
|
|
15
|
+
* (Agent subagent reports, Task* registry state, TodoWrite acks, Monitor, MCP tools, custom
|
|
16
|
+
* ToolSpecs) survive to the harder defenses (compaction summarizes them instead of blanking them).
|
|
17
|
+
* PowerShell is kept for CC fidelity even though sema does not mount it. Overridable per call via
|
|
18
|
+
* {@link ContextEditOptions.compactableTools} for custom-tool-heavy embedders.
|
|
19
|
+
*/
|
|
20
|
+
export declare const COMPACTABLE_TOOLS: ReadonlySet<string>;
|
|
21
|
+
export interface ContextEditOptions {
|
|
22
|
+
/** Start clearing once estimated context tokens exceed this. */
|
|
23
|
+
budgetTokens: number;
|
|
24
|
+
/** Always keep the content of this many most-recent tool results. Default 3. */
|
|
25
|
+
keepRecentToolResults?: number;
|
|
26
|
+
/**
|
|
27
|
+
* roadmap #6② (CC contentReplacementState parity): when set, a result's FULL TEXT is offloaded to
|
|
28
|
+
* the store before its content is cleared, and the marker carries the ReadToolResult ref — a
|
|
29
|
+
* cleared result becomes pageable instead of gone-from-view. `persist` must be idempotent per ref
|
|
30
|
+
* (the store's write-once put) because clearing re-runs on every request build. Absent ⇒ the bare
|
|
31
|
+
* marker (pre-#6 behavior; the durable session still holds the full result either way).
|
|
32
|
+
*/
|
|
33
|
+
offload?: {
|
|
34
|
+
/** Write-once persist; the returned ref goes into the marker. Sync (in-memory) or async stores both fit. */
|
|
35
|
+
persist: (toolCallId: string, fullText: string) => string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* design/123 D3 (codex-B1 = fable-M5) — ANCHORED accounting start: `estimateContextTokens(messages,
|
|
39
|
+
* charsPerToken).tokens` for the SAME message array. When set, the trigger gate AND the internal
|
|
40
|
+
* bookkeeping start from this usage-anchored value instead of the pure structural sum (which
|
|
41
|
+
* underestimates code by ~25% and CJK by 60–75% — the defense would self-certify and pass
|
|
42
|
+
* over-window requests). Bookkeeping semantics (pinned): clearing a message AFTER the usage anchor
|
|
43
|
+
* decrements by its structural delta; clearing a message AT/BEFORE the anchor decrements ZERO —
|
|
44
|
+
* the anchor usage was billed with that content included and does not shrink on a request-view
|
|
45
|
+
* edit (the clear only pays off on the NEXT request, after a fresh anchor lands), so the defense
|
|
46
|
+
* keeps clearing deeper until the anchored total is met or nothing clearable remains.
|
|
47
|
+
* Absent ⇒ legacy structural gate + accounting (byte-identical behavior).
|
|
48
|
+
*/
|
|
49
|
+
anchoredTotalTokens?: number;
|
|
50
|
+
/** design/123 D2 — structural coefficient (`Model.charsPerToken`); default 4. */
|
|
51
|
+
charsPerToken?: number;
|
|
52
|
+
/**
|
|
53
|
+
* checklist #54 — which tools' results are clearable. Defaults to {@link COMPACTABLE_TOOLS}
|
|
54
|
+
* (CC microCompact.ts:41-50). A result whose `toolName` is not in the set is NEVER cleared by
|
|
55
|
+
* this pass, no matter how far over budget the request is — expensive subagent reports and
|
|
56
|
+
* registry state are compaction's job, not a blanking marker's.
|
|
57
|
+
*/
|
|
58
|
+
compactableTools?: ReadonlySet<string>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Context-editing (the lightest, safest compaction; Anthropic reports ~29% improvement alone):
|
|
62
|
+
* when context exceeds the budget, replace the CONTENT of older tool-result messages with a short
|
|
63
|
+
* marker, keeping the turn structure (tool_call/tool_result pairing) intact. The most recent
|
|
64
|
+
* `keepRecentToolResults` results are preserved.
|
|
65
|
+
*
|
|
66
|
+
* Request-only and non-destructive: returns a new array; the durable session keeps the full results.
|
|
67
|
+
* Older results are cleared first, stopping as soon as the budget is met.
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* audit A-1 (view-level heal for HISTORICAL pollution): drop synthetic EMPTY failure assistants —
|
|
71
|
+
* stopReason aborted/error with no tool calls and no non-whitespace text/thinking. Sessions persisted
|
|
72
|
+
* before 1.92.0 may carry one parked between an interrupted tool batch and its reconcile tool_results
|
|
73
|
+
* (`A(tu×3), TR1, TR2, A(aborted,""), TR3`) — an API-invalid sequence on strict providers, and
|
|
74
|
+
* append-only sessions cannot be rewritten. Dropping the junk from the REQUEST VIEW restores a legal
|
|
75
|
+
* transcript (TR3 rejoins its batch). Deterministic ⇒ byte-stable per request ⇒ prefix-cache safe.
|
|
76
|
+
* New sessions never contain these (the loop exits cleanly on abort; the harness skips persisting them).
|
|
77
|
+
*/
|
|
78
|
+
export declare function dropEmptyFailureAssistants(messages: AgentMessage[]): AgentMessage[];
|
|
79
|
+
export declare function clearStaleToolResults(messages: AgentMessage[], opts: ContextEditOptions): AgentMessage[];
|
|
80
|
+
/** The token budget at which context-editing begins for a model (below the harder guard trim). */
|
|
81
|
+
export declare function editBudget(model: Model): number;
|
|
82
|
+
//# sourceMappingURL=context-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-edit.d.ts","sourceRoot":"","sources":["../../src/core/context-edit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAUhD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAUhD,CAAC;AAEH,MAAM,WAAW,kBAAkB;IACjC,gEAAgE;IAChE,YAAY,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE;QACR,4GAA4G;QAC5G,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;KAC3D,CAAC;IACF;;;;;;;;;;;OAWG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACxC;AAUD;;;;;;;;GAQG;AACH;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAUnF;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,YAAY,EAAE,EACxB,IAAI,EAAE,kBAAkB,GACvB,YAAY,EAAE,CAwEhB;AAED,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAG/C"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { DEFAULT_CHARS_PER_TOKEN, estimateContextTokens, estimateTokens } from "../internal/harness.js";
|
|
2
|
+
import { isToolResult } from "./message-utils.js";
|
|
3
|
+
const CLEARED_MARKER = "[tool result cleared to save context]";
|
|
4
|
+
/** roadmap #6②: the recoverable variant — the full content was offloaded first, so the marker
|
|
5
|
+
* carries the ref the model can page back via ReadToolResult. Kept deterministic (the ref derives
|
|
6
|
+
* from sessionId+toolCallId), so the per-request re-clear is byte-stable = prefix-cache safe. */
|
|
7
|
+
const clearedWithRef = (ref) => `[tool result cleared to save context — full content persisted; call ReadToolResult with ref "${ref}" to read it back]`;
|
|
8
|
+
/**
|
|
9
|
+
* Fraction of the window at which we start clearing stale tool results (lighter than the guard trim).
|
|
10
|
+
* Exported as the single source for the compaction-threshold clamp (design/64 §26.4 fix 2): compaction
|
|
11
|
+
* must trigger AT OR BELOW this point, or every request inside the clearStale band breaks the prefix
|
|
12
|
+
* cache at the clearing frontier (~0.7W re-prefilled per request — the "death band").
|
|
13
|
+
*/
|
|
14
|
+
export const EDIT_FRACTION = 0.7;
|
|
15
|
+
/**
|
|
16
|
+
* checklist #54 (CC microCompact.ts:41-50 `COMPACTABLE_TOOLS` parity): the INCLUSION whitelist of
|
|
17
|
+
* tools whose results may be content-cleared by the stale-result pass. CC's set is exactly
|
|
18
|
+
* { Read, Bash, PowerShell (SHELL_TOOL_NAMES), Grep, Glob, WebSearch, WebFetch, Edit, Write } —
|
|
19
|
+
* cheap-to-regenerate I/O. Everything else is PRESERVED: expensive/decision-bearing results
|
|
20
|
+
* (Agent subagent reports, Task* registry state, TodoWrite acks, Monitor, MCP tools, custom
|
|
21
|
+
* ToolSpecs) survive to the harder defenses (compaction summarizes them instead of blanking them).
|
|
22
|
+
* PowerShell is kept for CC fidelity even though sema does not mount it. Overridable per call via
|
|
23
|
+
* {@link ContextEditOptions.compactableTools} for custom-tool-heavy embedders.
|
|
24
|
+
*/
|
|
25
|
+
export const COMPACTABLE_TOOLS = new Set([
|
|
26
|
+
"Read",
|
|
27
|
+
"Bash",
|
|
28
|
+
"PowerShell",
|
|
29
|
+
"Grep",
|
|
30
|
+
"Glob",
|
|
31
|
+
"WebSearch",
|
|
32
|
+
"WebFetch",
|
|
33
|
+
"Edit",
|
|
34
|
+
"Write",
|
|
35
|
+
]);
|
|
36
|
+
function isCleared(m) {
|
|
37
|
+
const content = m.content;
|
|
38
|
+
if (!Array.isArray(content) || content.length !== 1)
|
|
39
|
+
return false;
|
|
40
|
+
const text = content[0].text;
|
|
41
|
+
// Both marker variants count as already-cleared (re-clearing a ref marker would drop its ref).
|
|
42
|
+
return text === CLEARED_MARKER || (typeof text === "string" && text.startsWith("[tool result cleared to save context —"));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Context-editing (the lightest, safest compaction; Anthropic reports ~29% improvement alone):
|
|
46
|
+
* when context exceeds the budget, replace the CONTENT of older tool-result messages with a short
|
|
47
|
+
* marker, keeping the turn structure (tool_call/tool_result pairing) intact. The most recent
|
|
48
|
+
* `keepRecentToolResults` results are preserved.
|
|
49
|
+
*
|
|
50
|
+
* Request-only and non-destructive: returns a new array; the durable session keeps the full results.
|
|
51
|
+
* Older results are cleared first, stopping as soon as the budget is met.
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* audit A-1 (view-level heal for HISTORICAL pollution): drop synthetic EMPTY failure assistants —
|
|
55
|
+
* stopReason aborted/error with no tool calls and no non-whitespace text/thinking. Sessions persisted
|
|
56
|
+
* before 1.92.0 may carry one parked between an interrupted tool batch and its reconcile tool_results
|
|
57
|
+
* (`A(tu×3), TR1, TR2, A(aborted,""), TR3`) — an API-invalid sequence on strict providers, and
|
|
58
|
+
* append-only sessions cannot be rewritten. Dropping the junk from the REQUEST VIEW restores a legal
|
|
59
|
+
* transcript (TR3 rejoins its batch). Deterministic ⇒ byte-stable per request ⇒ prefix-cache safe.
|
|
60
|
+
* New sessions never contain these (the loop exits cleanly on abort; the harness skips persisting them).
|
|
61
|
+
*/
|
|
62
|
+
export function dropEmptyFailureAssistants(messages) {
|
|
63
|
+
const isJunk = (m) => {
|
|
64
|
+
if (m.role !== "assistant")
|
|
65
|
+
return false;
|
|
66
|
+
const a = m;
|
|
67
|
+
if (a.stopReason !== "aborted" && a.stopReason !== "error")
|
|
68
|
+
return false;
|
|
69
|
+
return a.content.every((c) => c.type === "text" ? (c.text ?? "").trim() === "" : c.type === "thinking" ? (c.thinking ?? "").trim() === "" : false);
|
|
70
|
+
};
|
|
71
|
+
return messages.some(isJunk) ? messages.filter((m) => !isJunk(m)) : messages;
|
|
72
|
+
}
|
|
73
|
+
export function clearStaleToolResults(messages, opts) {
|
|
74
|
+
const cpt = opts.charsPerToken ?? DEFAULT_CHARS_PER_TOKEN;
|
|
75
|
+
// design/123 D3: trigger + internal accounting start from the ANCHORED estimate when provided
|
|
76
|
+
// (billed truth), else the legacy structural sum. `anchorIdx` marks the usage-anchor message:
|
|
77
|
+
// clearing at/before it decrements 0 (see ContextEditOptions.anchoredTotalTokens).
|
|
78
|
+
const anchored = opts.anchoredTotalTokens !== undefined;
|
|
79
|
+
let total;
|
|
80
|
+
let anchorIdx = -1;
|
|
81
|
+
if (anchored) {
|
|
82
|
+
total = opts.anchoredTotalTokens;
|
|
83
|
+
anchorIdx = estimateContextTokens(messages, cpt).lastUsageIndex ?? -1;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
total = 0;
|
|
87
|
+
for (const m of messages) {
|
|
88
|
+
total += estimateTokens(m, cpt);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (total <= opts.budgetTokens) {
|
|
92
|
+
return messages;
|
|
93
|
+
}
|
|
94
|
+
const keep = opts.keepRecentToolResults ?? 3;
|
|
95
|
+
// checklist #54 (CC microCompact.ts:226-241 `collectCompactableToolIds`): only results from
|
|
96
|
+
// whitelisted tools are candidates. The keep-recent window is computed over the CANDIDATES
|
|
97
|
+
// (CC microCompact.ts:461-463: `keepSet = compactableIds.slice(-keepRecent)`) — a
|
|
98
|
+
// non-compactable result neither clears nor consumes a keep slot.
|
|
99
|
+
const compactable = opts.compactableTools ?? COMPACTABLE_TOOLS;
|
|
100
|
+
const toolResultIdx = messages.flatMap((m, i) => isToolResult(m) && !isCleared(m) && compactable.has(m.toolName ?? "") ? [i] : []);
|
|
101
|
+
const clearable = toolResultIdx.slice(0, Math.max(0, toolResultIdx.length - keep)); // all but the last `keep`
|
|
102
|
+
if (clearable.length === 0) {
|
|
103
|
+
return messages;
|
|
104
|
+
}
|
|
105
|
+
const out = messages.slice();
|
|
106
|
+
let current = total;
|
|
107
|
+
for (const idx of clearable) {
|
|
108
|
+
if (current <= opts.budgetTokens) {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
const before = estimateTokens(out[idx], cpt);
|
|
112
|
+
// roadmap #6②: offload-then-clear — the marker becomes pageable (ReadToolResult ref) instead of
|
|
113
|
+
// a dead end. Best-effort: a throwing persist falls back to the bare marker, never fails the
|
|
114
|
+
// request build. Only text is offloaded (images have their own aggregate media cap).
|
|
115
|
+
let marker = CLEARED_MARKER;
|
|
116
|
+
if (opts.offload) {
|
|
117
|
+
const msg = out[idx];
|
|
118
|
+
const fullText = Array.isArray(msg.content)
|
|
119
|
+
? msg.content
|
|
120
|
+
.filter((c) => c?.type === "text" && typeof c.text === "string")
|
|
121
|
+
.map((c) => c.text)
|
|
122
|
+
.join("\n")
|
|
123
|
+
: "";
|
|
124
|
+
if (msg.toolCallId && fullText.trim().length > 0) {
|
|
125
|
+
try {
|
|
126
|
+
marker = clearedWithRef(opts.offload.persist(msg.toolCallId, fullText));
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
marker = CLEARED_MARKER;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const cleared = {
|
|
134
|
+
...out[idx],
|
|
135
|
+
content: [{ type: "text", text: marker }],
|
|
136
|
+
};
|
|
137
|
+
out[idx] = cleared;
|
|
138
|
+
// Anchored coordinate (design/123 D3): a pre-anchor clear does NOT reduce the anchored total —
|
|
139
|
+
// decrement 0 and keep clearing deeper; only post-anchor content decrements structurally.
|
|
140
|
+
current -= idx > anchorIdx ? before - estimateTokens(cleared, cpt) : 0;
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
/** The token budget at which context-editing begins for a model (below the harder guard trim). */
|
|
145
|
+
export function editBudget(model) {
|
|
146
|
+
const window = model.contextTokens ?? model.contextWindow;
|
|
147
|
+
return Math.floor(window * EDIT_FRACTION);
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=context-edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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E,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,UAAU,CAAC,KAAY;IACrC,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC;IAC1D,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AgentMessage } from "../internal/harness.js";
|
|
2
|
+
import type { Model } from "../internal/llm.js";
|
|
3
|
+
/**
|
|
4
|
+
* Last-resort, in-task context trim. Proper compaction (LLM summary) runs *between* tasks;
|
|
5
|
+
* this prevents a single task whose internal tool-loop balloons from overflowing the window.
|
|
6
|
+
*
|
|
7
|
+
* Keeps all summary messages (compaction/branch) and the most recent messages that fit the
|
|
8
|
+
* budget, dropping older regular messages at a safe boundary (never starting on an orphan
|
|
9
|
+
* toolResult). Returns the original array when already within budget.
|
|
10
|
+
*
|
|
11
|
+
* design/123 D3 (codex-B1 = fable-M5) — anchored accounting: when `anchoredTotalTokens`
|
|
12
|
+
* (= `estimateContextTokens(messages, charsPerToken).tokens` for the SAME array) is provided, the
|
|
13
|
+
* trigger gate and the internal bookkeeping start from the usage-anchored value instead of the
|
|
14
|
+
* structural sum (which underestimates code/CJK and lets over-window requests through). Dropping a
|
|
15
|
+
* message AFTER the usage anchor reduces the accounted total by its structural estimate; dropping a
|
|
16
|
+
* message AT/BEFORE the anchor reduces it by ZERO (the anchor usage was billed with that content —
|
|
17
|
+
* a request-view drop only pays off on the NEXT request), so the trim keeps cutting deeper until
|
|
18
|
+
* the anchored total meets the budget or only the minimal tail is left. Absent ⇒ legacy structural
|
|
19
|
+
* behavior, byte-identical. `charsPerToken` (design/123 D2): structural coefficient, default 4.
|
|
20
|
+
*/
|
|
21
|
+
export declare function trimToBudget(messages: AgentMessage[], budgetTokens: number, anchoredTotalTokens?: number, charsPerToken?: number): AgentMessage[];
|
|
22
|
+
/**
|
|
23
|
+
* design/123 D3 belt (invariant-level, live-caught 16k 400s): the FINAL request view must never
|
|
24
|
+
* contain a toolResult whose tool-call assistant is absent — strict gateways hard-400 on it
|
|
25
|
+
* ("Messages with role 'tool' must be a response to a preceding message with 'tool_calls'"). Every
|
|
26
|
+
* individual producer is turn-aligned (findCutPoint never cuts on a toolResult; trimToBudget
|
|
27
|
+
* turn-aligns its floor), but NO pipeline combination may ship an orphan, so the prepare-task
|
|
28
|
+
* context hook sweeps its output through this last. Deterministic ⇒ byte-stable per request ⇒
|
|
29
|
+
* prefix-cache safe. Returns the SAME array when clean (zero-cost fast path); `dropped` carries a
|
|
30
|
+
* diagnostic per removed orphan (toolCallId + neighbor roles) for onError attribution.
|
|
31
|
+
*/
|
|
32
|
+
export declare function dropOrphanToolResults(messages: AgentMessage[]): {
|
|
33
|
+
messages: AgentMessage[];
|
|
34
|
+
dropped: Array<{
|
|
35
|
+
toolCallId: string;
|
|
36
|
+
index: number;
|
|
37
|
+
prevRole: string;
|
|
38
|
+
nextRole: string;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
/** Budget the in-task guard targets for a model. */
|
|
42
|
+
export declare function guardBudget(model: Model): number;
|
|
43
|
+
//# sourceMappingURL=context-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-guard.d.ts","sourceRoot":"","sources":["../../src/core/context-guard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAYhD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,YAAY,EAAE,EACxB,YAAY,EAAE,MAAM,EACpB,mBAAmB,CAAC,EAAE,MAAM,EAC5B,aAAa,CAAC,EAAE,MAAM,GACrB,YAAY,EAAE,CA4FhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG;IAC/D,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,OAAO,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3F,CAkCA;AAED,oDAAoD;AACpD,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAGhD"}
|