@namzu/sdk 38.2.1 → 40.0.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 +851 -0
- package/dist/advisory/executor.d.ts +10 -1
- package/dist/advisory/executor.d.ts.map +1 -1
- package/dist/advisory/executor.js +5 -26
- package/dist/advisory/executor.js.map +1 -1
- package/dist/advisory/history.d.ts +9 -0
- package/dist/advisory/history.d.ts.map +1 -0
- package/dist/advisory/history.js +120 -0
- package/dist/advisory/history.js.map +1 -0
- package/dist/advisory/index.d.ts +1 -1
- package/dist/advisory/index.d.ts.map +1 -1
- package/dist/advisory/index.js.map +1 -1
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +3 -0
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/runAgent.d.ts +10 -0
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +3 -0
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/compaction/manual.d.ts +6 -0
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +21 -2
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/summary.d.ts.map +1 -1
- package/dist/compaction/summary.js +4 -1
- package/dist/compaction/summary.js.map +1 -1
- package/dist/config/runtime.js +2 -2
- package/dist/config/runtime.js.map +1 -1
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +20 -6
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/contracts/schemas.js +1 -1
- package/dist/contracts/schemas.js.map +1 -1
- package/dist/eval/harness-protection.d.ts +18 -0
- package/dist/eval/harness-protection.d.ts.map +1 -0
- package/dist/eval/harness-protection.js +58 -0
- package/dist/eval/harness-protection.js.map +1 -0
- package/dist/eval/harness-verification.d.ts +6 -1
- package/dist/eval/harness-verification.d.ts.map +1 -1
- package/dist/eval/harness-verification.js +19 -2
- package/dist/eval/harness-verification.js.map +1 -1
- package/dist/eval/index.d.ts +1 -0
- package/dist/eval/index.d.ts.map +1 -1
- package/dist/eval/index.js.map +1 -1
- package/dist/manager/resident/activity.d.ts +50 -0
- package/dist/manager/resident/activity.d.ts.map +1 -0
- package/dist/manager/resident/activity.js +125 -0
- package/dist/manager/resident/activity.js.map +1 -0
- package/dist/manager/resident/agenda.d.ts +13 -1
- package/dist/manager/resident/agenda.d.ts.map +1 -1
- package/dist/manager/resident/agenda.js +40 -5
- package/dist/manager/resident/agenda.js.map +1 -1
- package/dist/manager/resident/consumption.d.ts +104 -0
- package/dist/manager/resident/consumption.d.ts.map +1 -0
- package/dist/manager/resident/consumption.js +233 -0
- package/dist/manager/resident/consumption.js.map +1 -0
- package/dist/manager/resident/evidence-recall.d.ts +24 -0
- package/dist/manager/resident/evidence-recall.d.ts.map +1 -0
- package/dist/manager/resident/evidence-recall.js +295 -0
- package/dist/manager/resident/evidence-recall.js.map +1 -0
- package/dist/manager/resident/history-disk.d.ts +10 -0
- package/dist/manager/resident/history-disk.d.ts.map +1 -0
- package/dist/manager/resident/history-disk.js +50 -0
- package/dist/manager/resident/history-disk.js.map +1 -0
- package/dist/manager/resident/history.d.ts +79 -0
- package/dist/manager/resident/history.d.ts.map +1 -0
- package/dist/manager/resident/history.js +203 -0
- package/dist/manager/resident/history.js.map +1 -0
- package/dist/manager/resident/initiative.d.ts.map +1 -1
- package/dist/manager/resident/initiative.js +11 -3
- package/dist/manager/resident/initiative.js.map +1 -1
- package/dist/manager/resident/learning-cycle.d.ts +131 -0
- package/dist/manager/resident/learning-cycle.d.ts.map +1 -0
- package/dist/manager/resident/learning-cycle.js +306 -0
- package/dist/manager/resident/learning-cycle.js.map +1 -0
- package/dist/manager/resident/learning-observation.d.ts +80 -0
- package/dist/manager/resident/learning-observation.d.ts.map +1 -0
- package/dist/manager/resident/learning-observation.js +22 -0
- package/dist/manager/resident/learning-observation.js.map +1 -0
- package/dist/manager/resident/learning-store.d.ts +106 -0
- package/dist/manager/resident/learning-store.d.ts.map +1 -0
- package/dist/manager/resident/learning-store.js +598 -0
- package/dist/manager/resident/learning-store.js.map +1 -0
- package/dist/manager/resident/learning.d.ts +246 -3
- package/dist/manager/resident/learning.d.ts.map +1 -1
- package/dist/manager/resident/learning.js +96 -6
- package/dist/manager/resident/learning.js.map +1 -1
- package/dist/manager/resident/outbox.d.ts +4 -4
- package/dist/manager/resident/store.d.ts +37 -4
- package/dist/manager/resident/store.d.ts.map +1 -1
- package/dist/manager/resident/store.js +27 -3
- package/dist/manager/resident/store.js.map +1 -1
- package/dist/manager/resident/tool-evidence.d.ts +71 -0
- package/dist/manager/resident/tool-evidence.d.ts.map +1 -0
- package/dist/manager/resident/tool-evidence.js +285 -0
- package/dist/manager/resident/tool-evidence.js.map +1 -0
- package/dist/manager/run/persistence.d.ts +8 -0
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +18 -0
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +5 -3
- package/dist/plugin/loader.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +2 -0
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/prompt/index.d.ts +2 -0
- package/dist/prompt/index.d.ts.map +1 -1
- package/dist/prompt/index.js +1 -0
- package/dist/prompt/index.js.map +1 -1
- package/dist/prompt/resident-learning.d.ts +19 -0
- package/dist/prompt/resident-learning.d.ts.map +1 -0
- package/dist/prompt/resident-learning.js +125 -0
- package/dist/prompt/resident-learning.js.map +1 -0
- package/dist/prompt/resident-step.d.ts +8 -1
- package/dist/prompt/resident-step.d.ts.map +1 -1
- package/dist/prompt/resident-step.js +65 -4
- package/dist/prompt/resident-step.js.map +1 -1
- package/dist/provider/collect-chat-completion.d.ts +2 -1
- package/dist/provider/collect-chat-completion.d.ts.map +1 -1
- package/dist/provider/collect-chat-completion.js +7 -6
- package/dist/provider/collect-chat-completion.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +2 -1
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/stream-text.d.ts +16 -0
- package/dist/provider/stream-text.d.ts.map +1 -0
- package/dist/provider/stream-text.js +51 -0
- package/dist/provider/stream-text.js.map +1 -0
- package/dist/public-runtime.d.ts +16 -4
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +17 -4
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +13 -0
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +16 -0
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +15 -3
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +2 -3
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/registry/tool/portable.d.ts +65 -0
- package/dist/registry/tool/portable.d.ts.map +1 -0
- package/dist/registry/tool/portable.js +244 -0
- package/dist/registry/tool/portable.js.map +1 -0
- package/dist/registry/tool/schema.d.ts +32 -5
- package/dist/registry/tool/schema.d.ts.map +1 -1
- package/dist/registry/tool/schema.js +35 -9
- package/dist/registry/tool/schema.js.map +1 -1
- package/dist/registry/toolset/catalog.js +8 -8
- package/dist/registry/toolset/catalog.js.map +1 -1
- package/dist/run/LimitChecker.js +3 -3
- package/dist/run/LimitChecker.js.map +1 -1
- package/dist/run/evidence-query.d.ts +41 -0
- package/dist/run/evidence-query.d.ts.map +1 -0
- package/dist/run/evidence-query.js +270 -0
- package/dist/run/evidence-query.js.map +1 -0
- package/dist/run/evidence-recall.d.ts +99 -0
- package/dist/run/evidence-recall.d.ts.map +1 -0
- package/dist/run/evidence-recall.js +633 -0
- package/dist/run/evidence-recall.js.map +1 -0
- package/dist/run/index.d.ts +2 -0
- package/dist/run/index.d.ts.map +1 -1
- package/dist/run/index.js +1 -0
- package/dist/run/index.js.map +1 -1
- package/dist/run/json-claim-verifier.d.ts +83 -0
- package/dist/run/json-claim-verifier.d.ts.map +1 -0
- package/dist/run/json-claim-verifier.js +200 -0
- package/dist/run/json-claim-verifier.js.map +1 -0
- package/dist/run/preparation-context-error.d.ts +10 -0
- package/dist/run/preparation-context-error.d.ts.map +1 -0
- package/dist/run/preparation-context-error.js +15 -0
- package/dist/run/preparation-context-error.js.map +1 -0
- package/dist/run-query/index.d.ts +3 -1
- package/dist/run-query/index.d.ts.map +1 -1
- package/dist/runtime/jobs/awaited-jobs.d.ts +215 -0
- package/dist/runtime/jobs/awaited-jobs.d.ts.map +1 -0
- package/dist/runtime/jobs/awaited-jobs.js +259 -0
- package/dist/runtime/jobs/awaited-jobs.js.map +1 -0
- package/dist/runtime/jobs/registry.d.ts +33 -2
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +37 -0
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/callback-inference.d.ts +8 -0
- package/dist/runtime/query/callback-inference.d.ts.map +1 -0
- package/dist/runtime/query/callback-inference.js +89 -0
- package/dist/runtime/query/callback-inference.js.map +1 -0
- package/dist/runtime/query/checkpoint.d.ts +4 -0
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +13 -0
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/events.d.ts +1 -0
- package/dist/runtime/query/events.d.ts.map +1 -1
- package/dist/runtime/query/events.js +18 -0
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +35 -1
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +77 -8
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/file-evidence-context.d.ts +5 -0
- package/dist/runtime/query/file-evidence-context.d.ts.map +1 -0
- package/dist/runtime/query/file-evidence-context.js +180 -0
- package/dist/runtime/query/file-evidence-context.js.map +1 -0
- package/dist/runtime/query/file-evidence-replay.d.ts +260 -0
- package/dist/runtime/query/file-evidence-replay.d.ts.map +1 -0
- package/dist/runtime/query/file-evidence-replay.js +647 -0
- package/dist/runtime/query/file-evidence-replay.js.map +1 -0
- package/dist/runtime/query/file-evidence-seed.d.ts +50 -0
- package/dist/runtime/query/file-evidence-seed.d.ts.map +1 -0
- package/dist/runtime/query/file-evidence-seed.js +100 -0
- package/dist/runtime/query/file-evidence-seed.js.map +1 -0
- package/dist/runtime/query/guard.d.ts.map +1 -1
- package/dist/runtime/query/guard.js +4 -0
- package/dist/runtime/query/guard.js.map +1 -1
- package/dist/runtime/query/index.d.ts +10 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +133 -26
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +92 -36
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +420 -117
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.d.ts +2 -1
- package/dist/runtime/query/iteration/phases/advisory.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.js +2 -1
- package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +12 -1
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +8 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/provider-rejected-image.d.ts +2 -1
- package/dist/runtime/query/iteration/provider-rejected-image.d.ts.map +1 -1
- package/dist/runtime/query/iteration/provider-rejected-image.js +5 -2
- package/dist/runtime/query/iteration/provider-rejected-image.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts +4 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +22 -8
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/plugin-hooks.d.ts +14 -0
- package/dist/runtime/query/plugin-hooks.d.ts.map +1 -1
- package/dist/runtime/query/plugin-hooks.js +18 -0
- package/dist/runtime/query/plugin-hooks.js.map +1 -1
- package/dist/runtime/query/repeat-call.d.ts +17 -4
- package/dist/runtime/query/repeat-call.d.ts.map +1 -1
- package/dist/runtime/query/repeat-call.js +26 -19
- package/dist/runtime/query/repeat-call.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts +18 -33
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +59 -42
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +4 -4
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +10 -9
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/sandbox-lifecycle.d.ts.map +1 -1
- package/dist/runtime/query/sandbox-lifecycle.js +4 -0
- package/dist/runtime/query/sandbox-lifecycle.js.map +1 -1
- package/dist/runtime/query/steering.d.ts +11 -1
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js +12 -1
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/runtime/query/tool-output-budget.d.ts +10 -6
- package/dist/runtime/query/tool-output-budget.d.ts.map +1 -1
- package/dist/runtime/query/tool-output-budget.js +54 -12
- package/dist/runtime/query/tool-output-budget.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +5 -1
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +5 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/scheduler/completion-inbox.d.ts +49 -0
- package/dist/scheduler/completion-inbox.d.ts.map +1 -1
- package/dist/scheduler/completion-inbox.js +122 -2
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/store/evidence/compaction-archive.d.ts +109 -0
- package/dist/store/evidence/compaction-archive.d.ts.map +1 -0
- package/dist/store/evidence/compaction-archive.js +125 -0
- package/dist/store/evidence/compaction-archive.js.map +1 -0
- package/dist/store/evidence/compaction-provenance.d.ts +7 -0
- package/dist/store/evidence/compaction-provenance.d.ts.map +1 -0
- package/dist/store/evidence/compaction-provenance.js +49 -0
- package/dist/store/evidence/compaction-provenance.js.map +1 -0
- package/dist/store/evidence/compaction-text.d.ts +16 -0
- package/dist/store/evidence/compaction-text.d.ts.map +1 -0
- package/dist/store/evidence/compaction-text.js +51 -0
- package/dist/store/evidence/compaction-text.js.map +1 -0
- package/dist/store/evidence/disk.d.ts +11 -0
- package/dist/store/evidence/disk.d.ts.map +1 -0
- package/dist/store/evidence/disk.js +367 -0
- package/dist/store/evidence/disk.js.map +1 -0
- package/dist/store/evidence/format.d.ts +25 -0
- package/dist/store/evidence/format.d.ts.map +1 -0
- package/dist/store/evidence/format.js +115 -0
- package/dist/store/evidence/format.js.map +1 -0
- package/dist/store/evidence/index-page.d.ts +208 -0
- package/dist/store/evidence/index-page.d.ts.map +1 -0
- package/dist/store/evidence/index-page.js +262 -0
- package/dist/store/evidence/index-page.js.map +1 -0
- package/dist/store/evidence/io.d.ts +24 -0
- package/dist/store/evidence/io.d.ts.map +1 -0
- package/dist/store/evidence/io.js +69 -0
- package/dist/store/evidence/io.js.map +1 -0
- package/dist/store/evidence/linked.d.ts +9 -0
- package/dist/store/evidence/linked.d.ts.map +1 -0
- package/dist/store/evidence/linked.js +314 -0
- package/dist/store/evidence/linked.js.map +1 -0
- package/dist/store/evidence/passages.d.ts +15 -0
- package/dist/store/evidence/passages.d.ts.map +1 -0
- package/dist/store/evidence/passages.js +72 -0
- package/dist/store/evidence/passages.js.map +1 -0
- package/dist/store/evidence/record-chain.d.ts +42 -0
- package/dist/store/evidence/record-chain.d.ts.map +1 -0
- package/dist/store/evidence/record-chain.js +111 -0
- package/dist/store/evidence/record-chain.js.map +1 -0
- package/dist/store/evidence/search-input.d.ts +21 -0
- package/dist/store/evidence/search-input.d.ts.map +1 -0
- package/dist/store/evidence/search-input.js +44 -0
- package/dist/store/evidence/search-input.js.map +1 -0
- package/dist/store/evidence/selection.d.ts +9 -0
- package/dist/store/evidence/selection.d.ts.map +1 -0
- package/dist/store/evidence/selection.js +17 -0
- package/dist/store/evidence/selection.js.map +1 -0
- package/dist/store/evidence/source-kind.d.ts +11 -0
- package/dist/store/evidence/source-kind.d.ts.map +1 -0
- package/dist/store/evidence/source-kind.js +26 -0
- package/dist/store/evidence/source-kind.js.map +1 -0
- package/dist/store/evidence/source-text.d.ts +51 -0
- package/dist/store/evidence/source-text.d.ts.map +1 -0
- package/dist/store/evidence/source-text.js +213 -0
- package/dist/store/evidence/source-text.js.map +1 -0
- package/dist/store/evidence/types.d.ts +162 -0
- package/dist/store/evidence/types.d.ts.map +1 -0
- package/dist/store/evidence/types.js +2 -0
- package/dist/store/evidence/types.js.map +1 -0
- package/dist/store/memory/disk.d.ts +2 -0
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +2 -1
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/run/disk.d.ts +10 -0
- package/dist/store/run/disk.d.ts.map +1 -1
- package/dist/store/run/disk.js +87 -7
- package/dist/store/run/disk.js.map +1 -1
- package/dist/store/run/memory.d.ts +1 -0
- package/dist/store/run/memory.d.ts.map +1 -1
- package/dist/store/run/memory.js +10 -0
- package/dist/store/run/memory.js.map +1 -1
- package/dist/store/run/tool-executions.d.ts +13 -0
- package/dist/store/run/tool-executions.d.ts.map +1 -0
- package/dist/store/run/tool-executions.js +99 -0
- package/dist/store/run/tool-executions.js.map +1 -0
- package/dist/store/session/index.d.ts +2 -0
- package/dist/store/session/index.d.ts.map +1 -1
- package/dist/store/session/index.js +1 -0
- package/dist/store/session/index.js.map +1 -1
- package/dist/store/session/sqlite.d.ts +57 -0
- package/dist/store/session/sqlite.d.ts.map +1 -0
- package/dist/store/session/sqlite.js +430 -0
- package/dist/store/session/sqlite.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +4 -10
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/edit-apply.d.ts +126 -0
- package/dist/tools/builtins/edit-apply.d.ts.map +1 -0
- package/dist/tools/builtins/edit-apply.js +360 -0
- package/dist/tools/builtins/edit-apply.js.map +1 -0
- package/dist/tools/builtins/edit.d.ts +143 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +37 -219
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/index.d.ts +1 -0
- package/dist/tools/builtins/index.d.ts.map +1 -1
- package/dist/tools/builtins/index.js +9 -3
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +5 -6
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/read-file.d.ts +2 -2
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +50 -65
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/read-render.d.ts +56 -0
- package/dist/tools/builtins/read-render.d.ts.map +1 -0
- package/dist/tools/builtins/read-render.js +73 -0
- package/dist/tools/builtins/read-render.js.map +1 -0
- package/dist/tools/builtins/wait-for-job-bounds.d.ts +67 -0
- package/dist/tools/builtins/wait-for-job-bounds.d.ts.map +1 -0
- package/dist/tools/builtins/wait-for-job-bounds.js +108 -0
- package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -0
- package/dist/tools/builtins/wait-for-job.d.ts +6 -0
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -0
- package/dist/tools/builtins/wait-for-job.js +162 -0
- package/dist/tools/builtins/wait-for-job.js.map +1 -0
- package/dist/tools/builtins/write-file.js +7 -2
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +1 -7
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/defineTool.d.ts +2 -1
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +1 -1
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/file-read-tracker.d.ts.map +1 -1
- package/dist/tools/file-read-tracker.js +90 -3
- package/dist/tools/file-read-tracker.js.map +1 -1
- package/dist/tools/resident-history.d.ts +10 -0
- package/dist/tools/resident-history.d.ts.map +1 -0
- package/dist/tools/resident-history.js +80 -0
- package/dist/tools/resident-history.js.map +1 -0
- package/dist/tools/resident-tool-evidence.d.ts +5 -0
- package/dist/tools/resident-tool-evidence.d.ts.map +1 -0
- package/dist/tools/resident-tool-evidence.js +57 -0
- package/dist/tools/resident-tool-evidence.js.map +1 -0
- package/dist/types/advisory/config.d.ts +7 -0
- package/dist/types/advisory/config.d.ts.map +1 -1
- package/dist/types/agent/reactive.d.ts +1 -0
- package/dist/types/agent/reactive.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +9 -9
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +1 -1
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/hitl/index.d.ts +4 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +16 -2
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +10 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +2 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +4 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/run/answer-review.d.ts +34 -3
- package/dist/types/run/answer-review.d.ts.map +1 -1
- package/dist/types/run/config.d.ts +3 -0
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/entity.d.ts +20 -0
- package/dist/types/run/entity.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +31 -8
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/run/prepare-step.d.ts +53 -8
- package/dist/types/run/prepare-step.d.ts.map +1 -1
- package/dist/types/run/store.d.ts +29 -4
- package/dist/types/run/store.d.ts.map +1 -1
- package/dist/types/run/store.js +0 -28
- package/dist/types/run/store.js.map +1 -1
- package/dist/types/sandbox/index.d.ts +15 -14
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/tool/index.d.ts +124 -1
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/utils/await-with-abort.d.ts +8 -0
- package/dist/utils/await-with-abort.d.ts.map +1 -0
- package/dist/utils/await-with-abort.js +28 -0
- package/dist/utils/await-with-abort.js.map +1 -0
- package/dist/utils/env.d.ts +19 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +25 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/evidence-time.d.ts +3 -0
- package/dist/utils/evidence-time.d.ts.map +1 -0
- package/dist/utils/evidence-time.js +10 -0
- package/dist/utils/evidence-time.js.map +1 -0
- package/dist/utils/evidence-tokens.d.ts +13 -0
- package/dist/utils/evidence-tokens.d.ts.map +1 -0
- package/dist/utils/evidence-tokens.js +29 -0
- package/dist/utils/evidence-tokens.js.map +1 -0
- package/package.json +1 -1
- package/src/advisory/executor.ts +15 -30
- package/src/advisory/history.ts +126 -0
- package/src/advisory/index.ts +5 -1
- package/src/agents/ReactiveAgent.ts +3 -0
- package/src/agents/runAgent.ts +14 -1
- package/src/compaction/manual.ts +30 -2
- package/src/compaction/summary.ts +4 -1
- package/src/config/runtime.ts +2 -2
- package/src/connector/mcp/adapter.ts +20 -6
- package/src/contracts/schemas.ts +1 -1
- package/src/eval/harness-protection.ts +79 -0
- package/src/eval/harness-verification.ts +31 -1
- package/src/eval/index.ts +1 -0
- package/src/manager/resident/activity.ts +187 -0
- package/src/manager/resident/agenda.ts +59 -5
- package/src/manager/resident/consumption.ts +311 -0
- package/src/manager/resident/evidence-recall.ts +363 -0
- package/src/manager/resident/history-disk.ts +63 -0
- package/src/manager/resident/history.ts +312 -0
- package/src/manager/resident/initiative.ts +13 -3
- package/src/manager/resident/learning-cycle.ts +499 -0
- package/src/manager/resident/learning-observation.ts +39 -0
- package/src/manager/resident/learning-store.ts +813 -0
- package/src/manager/resident/learning.ts +132 -8
- package/src/manager/resident/store.ts +31 -3
- package/src/manager/resident/tool-evidence.ts +412 -0
- package/src/manager/run/persistence.ts +18 -0
- package/src/plugin/loader.ts +8 -3
- package/src/prompt/coding-agent-doctrine.ts +2 -0
- package/src/prompt/index.ts +2 -0
- package/src/prompt/resident-learning.ts +143 -0
- package/src/prompt/resident-step.ts +83 -3
- package/src/provider/collect-chat-completion.ts +7 -6
- package/src/provider/fallback.ts +2 -1
- package/src/provider/stream-text.ts +56 -0
- package/src/public-runtime.ts +39 -1
- package/src/public-tools.ts +21 -0
- package/src/public-types.ts +98 -0
- package/src/registry/tool/execute.ts +2 -4
- package/src/registry/tool/portable.ts +264 -0
- package/src/registry/tool/schema.ts +38 -8
- package/src/registry/toolset/catalog.ts +8 -9
- package/src/run/LimitChecker.ts +3 -3
- package/src/run/evidence-query.ts +333 -0
- package/src/run/evidence-recall.ts +854 -0
- package/src/run/index.ts +11 -0
- package/src/run/json-claim-verifier.ts +298 -0
- package/src/run/preparation-context-error.ts +16 -0
- package/src/run-query/index.ts +1 -1
- package/src/runtime/jobs/awaited-jobs.ts +271 -0
- package/src/runtime/jobs/registry.ts +50 -0
- package/src/runtime/query/callback-inference.ts +94 -0
- package/src/runtime/query/checkpoint.ts +14 -0
- package/src/runtime/query/events.ts +22 -0
- package/src/runtime/query/executor.ts +100 -10
- package/src/runtime/query/file-evidence-context.ts +209 -0
- package/src/runtime/query/file-evidence-replay.ts +776 -0
- package/src/runtime/query/file-evidence-seed.ts +126 -0
- package/src/runtime/query/guard.ts +2 -0
- package/src/runtime/query/index.ts +153 -27
- package/src/runtime/query/iteration/index.ts +467 -110
- package/src/runtime/query/iteration/phases/advisory.ts +3 -0
- package/src/runtime/query/iteration/phases/context.ts +12 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +7 -0
- package/src/runtime/query/iteration/provider-rejected-image.ts +6 -1
- package/src/runtime/query/iteration/stream-turn.ts +35 -8
- package/src/runtime/query/plugin-hooks.ts +20 -0
- package/src/runtime/query/repeat-call.ts +28 -18
- package/src/runtime/query/resume-pending.ts +65 -40
- package/src/runtime/query/review-policy.ts +13 -9
- package/src/runtime/query/sandbox-lifecycle.ts +3 -0
- package/src/runtime/query/steering.ts +11 -0
- package/src/runtime/query/tool-output-budget.ts +65 -13
- package/src/runtime/query/tooling.ts +10 -1
- package/src/scheduler/completion-inbox.ts +124 -2
- package/src/store/evidence/compaction-archive.ts +139 -0
- package/src/store/evidence/compaction-provenance.ts +52 -0
- package/src/store/evidence/compaction-text.ts +61 -0
- package/src/store/evidence/disk.ts +461 -0
- package/src/store/evidence/format.ts +126 -0
- package/src/store/evidence/index-page.ts +292 -0
- package/src/store/evidence/io.ts +95 -0
- package/src/store/evidence/linked.ts +365 -0
- package/src/store/evidence/passages.ts +88 -0
- package/src/store/evidence/record-chain.ts +108 -0
- package/src/store/evidence/search-input.ts +62 -0
- package/src/store/evidence/selection.ts +25 -0
- package/src/store/evidence/source-kind.ts +36 -0
- package/src/store/evidence/source-text.ts +285 -0
- package/src/store/evidence/types.ts +177 -0
- package/src/store/memory/disk.ts +4 -1
- package/src/store/run/disk.ts +110 -8
- package/src/store/run/memory.ts +10 -0
- package/src/store/run/tool-executions.ts +112 -0
- package/src/store/session/index.ts +2 -0
- package/src/store/session/sqlite.ts +584 -0
- package/src/tools/builtins/bash.ts +4 -10
- package/src/tools/builtins/edit-apply.ts +456 -0
- package/src/tools/builtins/edit.ts +39 -270
- package/src/tools/builtins/index.ts +9 -3
- package/src/tools/builtins/job.ts +5 -6
- package/src/tools/builtins/read-file.ts +56 -77
- package/src/tools/builtins/read-render.ts +104 -0
- package/src/tools/builtins/wait-for-job-bounds.ts +179 -0
- package/src/tools/builtins/wait-for-job.ts +184 -0
- package/src/tools/builtins/write-file.ts +7 -2
- package/src/tools/coordinator/index.ts +1 -7
- package/src/tools/defineTool.ts +4 -2
- package/src/tools/file-read-tracker.ts +86 -2
- package/src/tools/resident-history.ts +86 -0
- package/src/tools/resident-tool-evidence.ts +68 -0
- package/src/types/advisory/config.ts +7 -0
- package/src/types/agent/reactive.ts +1 -0
- package/src/types/authorization/index.ts +2 -2
- package/src/types/hitl/index.ts +4 -0
- package/src/types/message/index.ts +22 -0
- package/src/types/provider/chat.ts +2 -0
- package/src/types/provider/stream.ts +4 -0
- package/src/types/run/answer-review.ts +34 -3
- package/src/types/run/config.ts +3 -0
- package/src/types/run/entity.ts +21 -0
- package/src/types/run/events.ts +31 -8
- package/src/types/run/prepare-step.ts +59 -8
- package/src/types/run/store.ts +35 -4
- package/src/types/sandbox/index.ts +15 -14
- package/src/types/tool/index.ts +123 -1
- package/src/utils/await-with-abort.ts +26 -0
- package/src/utils/env.ts +23 -0
- package/src/utils/evidence-time.ts +9 -0
- package/src/utils/evidence-tokens.ts +32 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { fingerprintContent } from '../../tools/builtins/content-fingerprint.js';
|
|
2
|
+
import { ReadFileTool } from '../../tools/builtins/read-file.js';
|
|
3
|
+
import { MAX_EDIT_CALLS, MAX_PATH_UNITS, MAX_WITNESSED_PATHS, createReplayBudget, indexVisibleHistory, knownStale, lexicalFileKeys, replayHop, spend, visibleCall, visibleEdit, visibleWrite, } from './file-evidence-replay.js';
|
|
4
|
+
/**
|
|
5
|
+
* Receipt text a read entry may point at.
|
|
6
|
+
*
|
|
7
|
+
* The same class of bound as the one on a write call's arguments, and set to
|
|
8
|
+
* the same number for the same reason: past it the text is not read at all. A
|
|
9
|
+
* bigger file is simply not admitted this way — the model re-reads it, which is
|
|
10
|
+
* what it does today.
|
|
11
|
+
*/
|
|
12
|
+
const MAX_RECEIPT_UNITS = 32_000;
|
|
13
|
+
/** Join visible call bodies, successful receipts and this executor's observation ledger. */
|
|
14
|
+
export function describeVisibleFileEvidence(messages, tracker, workingDirectory, sandboxed) {
|
|
15
|
+
// Execution-owned witnesses survive transparent wrappers; a name alone proves nothing.
|
|
16
|
+
if (!tracker.writeCallId || !tracker.fingerprint)
|
|
17
|
+
return;
|
|
18
|
+
// Lexical, as this projection has always looked entries up: a spelling that
|
|
19
|
+
// does not resolve to the tool's canonical key finds nothing and the path is
|
|
20
|
+
// simply not admitted. Writing the ledger is the side that has to key the
|
|
21
|
+
// way the tools do — see `file-evidence-seed.ts`.
|
|
22
|
+
const history = indexVisibleHistory(messages, lexicalFileKeys(workingDirectory, sandboxed));
|
|
23
|
+
const budget = createReplayBudget();
|
|
24
|
+
const files = new Map();
|
|
25
|
+
for (const [id, call] of history.calls) {
|
|
26
|
+
const name = call?.function.name;
|
|
27
|
+
if (name !== 'write' && name !== 'edit' && name !== 'read')
|
|
28
|
+
continue;
|
|
29
|
+
try {
|
|
30
|
+
const admitted = name === 'write'
|
|
31
|
+
? writeEvidence(id, tracker, history)
|
|
32
|
+
: name === 'edit'
|
|
33
|
+
? chainEvidence(id, tracker, history, budget)
|
|
34
|
+
: readEvidence(id, tracker, history);
|
|
35
|
+
if (!admitted)
|
|
36
|
+
continue;
|
|
37
|
+
// A write-rooted entry outranks a read of the same file: it names a
|
|
38
|
+
// body the model composed itself, and edits can be replayed onto it.
|
|
39
|
+
// The ledger already withholds a read witness where one survives; this
|
|
40
|
+
// keeps a read that ran BEFORE the write from taking the path back.
|
|
41
|
+
const held = files.get(admitted.key);
|
|
42
|
+
if (admitted.evidence.kind === 'read' && held && held.kind !== 'read')
|
|
43
|
+
continue;
|
|
44
|
+
files.delete(admitted.key);
|
|
45
|
+
files.set(admitted.key, admitted.evidence);
|
|
46
|
+
if (files.size > MAX_WITNESSED_PATHS)
|
|
47
|
+
files.delete(files.keys().next().value);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Malformed retained inputs or a custom tracker cannot establish evidence.
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (files.size === 0)
|
|
54
|
+
return;
|
|
55
|
+
return `Visible file evidence (this request only): each entry's current body is the complete body in the named successful write call, with the edit calls in editsInCalls — when present — applied in that order. An entry marked kind:"read" instead names a successful read call whose own receipt shows the file WHOLE, rendered with every line behind its own N<tab> prefix; that receipt is the body, and such an entry never carries editsInCalls. This runtime performed that reconstruction and checked it against its own file observation; it is not a derivation left to you. Reuse the body for a targeted edit; a read solely to recall it is unnecessary. This is NOT a fresh disk check, and after a resume the observation behind an entry may itself have been rebuilt from this conversation's own earlier calls rather than made while this process ran. Built-in edit/write still compare the disk body at mutation admission and refuse observed drift; on refusal inspect the current file and replan. Missing entries establish nothing.\n${JSON.stringify([...files.values()])}`;
|
|
56
|
+
}
|
|
57
|
+
/** A full body that arrived whole in one call and is still the file's body. */
|
|
58
|
+
function writeEvidence(id, tracker, history) {
|
|
59
|
+
const written = visibleWrite(history, id);
|
|
60
|
+
if (!written || knownStale(tracker, written.key))
|
|
61
|
+
return;
|
|
62
|
+
const fingerprint = fingerprintContent(written.body);
|
|
63
|
+
if (tracker.writeCallId?.(written.key) !== id ||
|
|
64
|
+
tracker.fingerprint?.(written.key) !== fingerprint)
|
|
65
|
+
return;
|
|
66
|
+
return {
|
|
67
|
+
key: written.key,
|
|
68
|
+
evidence: {
|
|
69
|
+
path: written.path,
|
|
70
|
+
bodyInCall: id,
|
|
71
|
+
observedFingerprint: fingerprint,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A full body plus the visible edits since, replayed and then checked.
|
|
77
|
+
*
|
|
78
|
+
* Only the chain's TIP establishes the path: a middle hop is validated as part
|
|
79
|
+
* of the walk below, and admitting one on its own would claim the file stops
|
|
80
|
+
* at an edit later calls have already moved past. The replay runs the same
|
|
81
|
+
* apply core the tool ran at mutation time, over call arguments that are
|
|
82
|
+
* already in the conversation — no filesystem read, and the result is compared
|
|
83
|
+
* to the ledger's disk-derived fingerprint, never written into it.
|
|
84
|
+
*/
|
|
85
|
+
function chainEvidence(id, tracker, history, budget) {
|
|
86
|
+
const tip = visibleEdit(history, id);
|
|
87
|
+
if (!tip || knownStale(tracker, tip.key))
|
|
88
|
+
return;
|
|
89
|
+
const key = tip.key;
|
|
90
|
+
const chain = tracker.editChain?.(key);
|
|
91
|
+
const observed = tracker.fingerprint?.(key);
|
|
92
|
+
if (!chain || observed === undefined || chain.editCallIds.at(-1) !== id)
|
|
93
|
+
return;
|
|
94
|
+
// The call bound before the walk, the unit bound before each operation it
|
|
95
|
+
// pays for. Neither is measured by doing the work it exists to refuse.
|
|
96
|
+
if (chain.editCallIds.length > MAX_EDIT_CALLS)
|
|
97
|
+
return;
|
|
98
|
+
const rootId = chain.rootWriteCallId;
|
|
99
|
+
const root = visibleWrite(history, rootId);
|
|
100
|
+
// A root naming a different file is an ambiguity, not a base: the ledger
|
|
101
|
+
// and the visible call disagree about what was written where.
|
|
102
|
+
if (!root || root.key !== key)
|
|
103
|
+
return;
|
|
104
|
+
let content = root.body;
|
|
105
|
+
if (!spend(budget, content.length))
|
|
106
|
+
return;
|
|
107
|
+
for (const editId of chain.editCallIds) {
|
|
108
|
+
const hop = editId === id ? tip : visibleEdit(history, editId);
|
|
109
|
+
if (!hop || hop.key !== key)
|
|
110
|
+
return;
|
|
111
|
+
// Each of this hop's operations is measured against the body it is about
|
|
112
|
+
// to be applied to, charged, and only then applied — so a hop over the
|
|
113
|
+
// ceiling is refused before it is built rather than after, and one that
|
|
114
|
+
// fits is never turned away for a ceiling that guessed high. A hop the
|
|
115
|
+
// budget refuses, or one whose anchors no longer match, reconstructs
|
|
116
|
+
// nothing and withholds the whole path.
|
|
117
|
+
const replayed = replayHop(content, hop.input, budget);
|
|
118
|
+
if (replayed === undefined)
|
|
119
|
+
return;
|
|
120
|
+
content = replayed;
|
|
121
|
+
}
|
|
122
|
+
if (fingerprintContent(content) !== observed)
|
|
123
|
+
return;
|
|
124
|
+
return {
|
|
125
|
+
key,
|
|
126
|
+
evidence: {
|
|
127
|
+
path: root.path,
|
|
128
|
+
bodyInCall: rootId,
|
|
129
|
+
editsInCalls: [...chain.editCallIds],
|
|
130
|
+
observedFingerprint: observed,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* A body the model can still see because a read of the whole file put it there.
|
|
136
|
+
*
|
|
137
|
+
* Structurally unlike the two above, and deliberately so. They name a body the
|
|
138
|
+
* model itself composed, in arguments this projection can parse and replay; this
|
|
139
|
+
* names a RESULT, and the only thing anyone is allowed to do with it is compare
|
|
140
|
+
* it. The tool fingerprinted the exact string it emitted, and the entry is
|
|
141
|
+
* admitted only while the receipt still fingerprints to that — so a receipt the
|
|
142
|
+
* output budget elided or spilled, one compaction cleared, or one changed in any
|
|
143
|
+
* other way withholds the path rather than pointing the model at a body that is
|
|
144
|
+
* no longer in front of it. Nothing here undoes the line numbering to recover
|
|
145
|
+
* text: the numbering is what makes the comparison conclusive, not an encoding
|
|
146
|
+
* to be reversed.
|
|
147
|
+
*
|
|
148
|
+
* No chain, ever. A read roots nothing, so an entry here is the file as that one
|
|
149
|
+
* call showed it, and the ledger drops the witness the moment an edit lands.
|
|
150
|
+
*/
|
|
151
|
+
function readEvidence(id, tracker, history) {
|
|
152
|
+
if (!tracker.readWitness)
|
|
153
|
+
return;
|
|
154
|
+
const call = visibleCall(history, id, 'read');
|
|
155
|
+
const shown = history.results.get(id)?.content;
|
|
156
|
+
if (!call || typeof shown !== 'string' || shown.length > MAX_RECEIPT_UNITS)
|
|
157
|
+
return;
|
|
158
|
+
const input = ReadFileTool.inputSchema.safeParse(JSON.parse(call.function.arguments));
|
|
159
|
+
if (!input.success || input.data.path.length > MAX_PATH_UNITS)
|
|
160
|
+
return;
|
|
161
|
+
const key = history.keyOf(input.data.path);
|
|
162
|
+
if (key === undefined || knownStale(tracker, key))
|
|
163
|
+
return;
|
|
164
|
+
const witness = tracker.readWitness(key);
|
|
165
|
+
const observed = tracker.fingerprint?.(key);
|
|
166
|
+
if (!witness || witness.callId !== id || observed === undefined)
|
|
167
|
+
return;
|
|
168
|
+
if (fingerprintContent(shown) !== witness.renderedFingerprint)
|
|
169
|
+
return;
|
|
170
|
+
return {
|
|
171
|
+
key,
|
|
172
|
+
evidence: {
|
|
173
|
+
path: input.data.path,
|
|
174
|
+
kind: 'read',
|
|
175
|
+
bodyInCall: id,
|
|
176
|
+
observedFingerprint: observed,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=file-evidence-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-evidence-context.js","sourceRoot":"","sources":["../../../src/runtime/query/file-evidence-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAGhE,OAAO,EACN,cAAc,EACd,cAAc,EACd,mBAAmB,EAGnB,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,SAAS,EACT,KAAK,EACL,WAAW,EACX,WAAW,EACX,YAAY,GACZ,MAAM,2BAA2B,CAAA;AAElC;;;;;;;GAOG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAWhC,4FAA4F;AAC5F,MAAM,UAAU,2BAA2B,CAC1C,QAA4B,EAC5B,OAAwB,EACxB,gBAAwB,EACxB,SAAkB;IAElB,uFAAuF;IACvF,IAAI,CAA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S,IAAI,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC;QAAE,OAAM;IACzD,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAA;IAC3C,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,EAAE,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAM;IACvE,IAAI,kBAAkB,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,mBAAmB;QAAE,OAAM;IACrE,OAAO;QACN,GAAG;QACH,QAAQ,EAAE;YACT,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI;YACrB,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,EAAE;YACd,mBAAmB,EAAE,QAAQ;SAC7B;KACD,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import type { Message, ToolCall } from '../../types/message/index.js';
|
|
2
|
+
import type { FileReadTracker } from '../../types/tool/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reconstructing a file's body from calls the conversation can still see.
|
|
5
|
+
*
|
|
6
|
+
* One module because two callers need the same answer and must not each have
|
|
7
|
+
* their own idea of it: the derived work context asks "is this ledger entry's
|
|
8
|
+
* body one the model can rebuild from what is in front of it?", and the resume
|
|
9
|
+
* seed asks "which of these ledger entries can be rebuilt at all?". A
|
|
10
|
+
* predicate that admitted a hop in one and refused it in the other would mean
|
|
11
|
+
* a path referenced as evidence that the ledger never witnessed, or the
|
|
12
|
+
* reverse. Everything below is a function of the messages, the ledger and the
|
|
13
|
+
* bounds — there is no filesystem access anywhere in this file.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Edit CALLS one chain may carry before the path is withheld.
|
|
17
|
+
*
|
|
18
|
+
* On calls rather than replacements because the bound is on replay work, and
|
|
19
|
+
* an `edits: [...]` batch is one pass over the content however many hunks it
|
|
20
|
+
* holds. Eight is generous for the shape this exists for — a file written and
|
|
21
|
+
* then refined within a turn — and short enough that the whole request's
|
|
22
|
+
* replay stays a rounding error beside the model call it rides on.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MAX_EDIT_CALLS = 8;
|
|
25
|
+
/**
|
|
26
|
+
* Content a replay may materialise across every path in one pass.
|
|
27
|
+
*
|
|
28
|
+
* Counted cumulatively in UTF-16 units — the measure the caps below and the
|
|
29
|
+
* step-context budget already use — and charged for the write body each chain
|
|
30
|
+
* starts from as well as every body an edit builds on top of it, because those
|
|
31
|
+
* are the strings actually built. Each operation is measured exactly against
|
|
32
|
+
* the content it is about to be applied to and refused before it is built, so
|
|
33
|
+
* a pass whose history is full of long chains it is going to refuse anyway
|
|
34
|
+
* cannot make itself slow proving that. A refusal is charged nothing: the body
|
|
35
|
+
* was never built, and the paths after it keep their room.
|
|
36
|
+
*/
|
|
37
|
+
export declare const MAX_REPLAYED_UNITS: number;
|
|
38
|
+
/**
|
|
39
|
+
* Path lengths a `write` entry may go out with.
|
|
40
|
+
*
|
|
41
|
+
* Exported because `file-evidence-context.ts` puts the same bound on the
|
|
42
|
+
* spelling a `read` entry emits — a read is the other thing that puts a path
|
|
43
|
+
* in the work-context message, and the constant belongs to this module.
|
|
44
|
+
*/
|
|
45
|
+
export declare const MAX_PATH_UNITS = 512;
|
|
46
|
+
/**
|
|
47
|
+
* One pass's answer to "which file did this call touch", memoised.
|
|
48
|
+
*
|
|
49
|
+
* Keyed on the call OBJECT rather than on its id: an id claimed by two calls
|
|
50
|
+
* is an ambiguity this module refuses to settle by position, and settling it
|
|
51
|
+
* by cache hit instead would be the same mistake wearing a different hat. A
|
|
52
|
+
* `WeakMap` because the entries are worth exactly as long as the transcript
|
|
53
|
+
* they describe, and the value is the declared path or `null` for a call that
|
|
54
|
+
* declares none — `undefined` means only "not asked yet".
|
|
55
|
+
*/
|
|
56
|
+
export type PathAttributions = WeakMap<ToolCall, string | null>;
|
|
57
|
+
export declare function createPathAttributions(): PathAttributions;
|
|
58
|
+
/**
|
|
59
|
+
* The ledger key a tool-call path belongs to, or `undefined` for a path this
|
|
60
|
+
* pass may not key at all.
|
|
61
|
+
*
|
|
62
|
+
* A resolver rather than a working directory, because the two callers do not
|
|
63
|
+
* key alike and must not be made to. The projection READS a ledger the tools
|
|
64
|
+
* wrote and looks entries up lexically, as it always has: a spelling that does
|
|
65
|
+
* not match the tool's canonical key simply finds nothing. A seed WRITES that
|
|
66
|
+
* ledger, so its keys have to be the ones the tools will come looking for —
|
|
67
|
+
* which means resolving a path the way `write` and `edit` resolve it, through
|
|
68
|
+
* every symlink, and that is filesystem work nothing in this module is allowed
|
|
69
|
+
* to do. So the caller resolves first and hands the answers in.
|
|
70
|
+
*/
|
|
71
|
+
export type FileKeyResolver = (path: string) => string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The lexical key space: the path resolved against the working directory, or
|
|
74
|
+
* the path as written when the tools address a sandbox.
|
|
75
|
+
*
|
|
76
|
+
* What a reader of the ledger uses. Not what a writer of it may use: see
|
|
77
|
+
* {@link FileKeyResolver}.
|
|
78
|
+
*/
|
|
79
|
+
export declare function lexicalFileKeys(workingDirectory: string, sandboxed: boolean): FileKeyResolver;
|
|
80
|
+
/** The calls and receipts of one conversation, indexed by call id. */
|
|
81
|
+
export interface VisibleHistory {
|
|
82
|
+
/** `null` where an id was claimed by more than one assistant call. */
|
|
83
|
+
readonly calls: ReadonlyMap<string, ToolCall | null>;
|
|
84
|
+
/** `null` where an id was answered more than once. */
|
|
85
|
+
readonly results: ReadonlyMap<string, Message | null>;
|
|
86
|
+
/** The ledger key a tool-call path resolves to. */
|
|
87
|
+
readonly keyOf: FileKeyResolver;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Index a transcript once, so every lookup below is a map hit.
|
|
91
|
+
*
|
|
92
|
+
* An id claimed twice, or answered twice, indexes to `null` rather than to
|
|
93
|
+
* whichever message came last: two calls wearing one id is an ambiguity, and
|
|
94
|
+
* resolving it by position would let the second silently vouch for the first.
|
|
95
|
+
*/
|
|
96
|
+
export declare function indexVisibleHistory(messages: readonly Message[], keyOf: FileKeyResolver): VisibleHistory;
|
|
97
|
+
/**
|
|
98
|
+
* Every path a replay of this history might have to key, in the order the
|
|
99
|
+
* calls arrived.
|
|
100
|
+
*
|
|
101
|
+
* For a caller that has to resolve them before the replay can run, and only
|
|
102
|
+
* for that: nothing here decides anything about a path. Empty when the history
|
|
103
|
+
* holds no `write` and no `edit` call at all, because a claim is only ever made
|
|
104
|
+
* by a mutation — a conversation that only read files reconstructs nothing, and
|
|
105
|
+
* resolving its reads would be filesystem work with no possible result.
|
|
106
|
+
*
|
|
107
|
+
* Every mutation the walk can ATTRIBUTE has to appear here, the ones it will
|
|
108
|
+
* refuse to reconstruct included. This used to drop a call whose arguments ran
|
|
109
|
+
* past the evidence bound, so the walk reached it holding no key for its path,
|
|
110
|
+
* read that as a mutation it could not attribute, and abandoned the seeding
|
|
111
|
+
* entirely: one thirty-kilobyte `write` anywhere in a conversation erased every
|
|
112
|
+
* witness in it. The bounds belong to what may be believed; the path is read
|
|
113
|
+
* here out of the same field the walk reads it from, under no bound at all.
|
|
114
|
+
*/
|
|
115
|
+
export declare function collectObservedPaths(messages: readonly Message[], attributions?: PathAttributions): readonly string[];
|
|
116
|
+
/**
|
|
117
|
+
* The visibility every hop must pass, write or edit, root or tip.
|
|
118
|
+
*
|
|
119
|
+
* One function because a middle hop is not a lesser claim than the last one.
|
|
120
|
+
* A chain whose second edit was cleared by compaction, or came back an error,
|
|
121
|
+
* or arrived truncated, reconstructs nothing at all — so the whole path is
|
|
122
|
+
* withheld rather than emitted as the part still visible, which would name a
|
|
123
|
+
* body the model cannot rebuild.
|
|
124
|
+
*
|
|
125
|
+
* A call a `pre_tool_use` hook SKIPPED is the one refusal that does not arrive
|
|
126
|
+
* as an error. The hook declined the call; nothing failed, so the receipt is a
|
|
127
|
+
* plain success carrying the sentence `plugin-hooks.ts` writes for it, and
|
|
128
|
+
* reading that as a `write` would hand back a body the tool was never allowed
|
|
129
|
+
* to put on disk — a fingerprint for a file that still holds whatever it held
|
|
130
|
+
* before, and a spurious drift refusal on the next edit. Recognised through
|
|
131
|
+
* the same function that writes the sentence, so the two cannot drift apart.
|
|
132
|
+
*/
|
|
133
|
+
export declare function visibleCall(history: VisibleHistory, id: string, name: 'write' | 'edit' | 'read'): ToolCall | undefined;
|
|
134
|
+
/** A full body that arrived whole in one visible call. */
|
|
135
|
+
export declare function visibleWrite(history: VisibleHistory, id: string): {
|
|
136
|
+
readonly path: string;
|
|
137
|
+
readonly key: string;
|
|
138
|
+
readonly body: string;
|
|
139
|
+
} | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* One visible edit call's arguments, ready to replay.
|
|
142
|
+
*
|
|
143
|
+
* No length bound on the path here, unlike the write above. A write's path is
|
|
144
|
+
* the spelling an entry goes out with; an edit is held to the KEY it resolves
|
|
145
|
+
* to, which its chain's root has already been bounded on.
|
|
146
|
+
*/
|
|
147
|
+
export declare function visibleEdit(history: VisibleHistory, id: string): {
|
|
148
|
+
readonly key: string;
|
|
149
|
+
readonly input: unknown;
|
|
150
|
+
} | undefined;
|
|
151
|
+
/** Room left for content this pass may still materialise. */
|
|
152
|
+
export interface ReplayBudget {
|
|
153
|
+
remaining: number;
|
|
154
|
+
}
|
|
155
|
+
export declare function createReplayBudget(units?: number): ReplayBudget;
|
|
156
|
+
/**
|
|
157
|
+
* Charge one body against the pass's replay allowance.
|
|
158
|
+
*
|
|
159
|
+
* Checked before it is taken, so a refusal costs nothing. Deducting first and
|
|
160
|
+
* reporting afterwards left the allowance negative, and one oversized path
|
|
161
|
+
* then refused every admissible path behind it in the same pass.
|
|
162
|
+
*/
|
|
163
|
+
export declare function spend(budget: ReplayBudget, units: number): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Replay one edit call onto the body in hand, within what the budget has left.
|
|
166
|
+
*
|
|
167
|
+
* `undefined` for a hop the budget turns away and for one that no longer
|
|
168
|
+
* applies, because both mean the same thing to every caller here: this path
|
|
169
|
+
* reconstructs nothing. The charge is settled either way — what the attempt
|
|
170
|
+
* built, it built — and for a hop refused at its first operation that charge
|
|
171
|
+
* is zero.
|
|
172
|
+
*/
|
|
173
|
+
export declare function replayHop(content: string, input: unknown, budget: ReplayBudget): string | undefined;
|
|
174
|
+
/**
|
|
175
|
+
* Whether a refused mutation has reported this path stale since the ledger
|
|
176
|
+
* last observed it.
|
|
177
|
+
*
|
|
178
|
+
* That refusal read the real file to make its comparison, so the ledger knows
|
|
179
|
+
* its body is behind disk without a consumer here touching the filesystem.
|
|
180
|
+
* The reconstruction would still be a body the model can rebuild — but not the
|
|
181
|
+
* FILE's body, which is what an entry claims. Withheld until a real
|
|
182
|
+
* observation re-baselines the ledger, which is also what clears the flag.
|
|
183
|
+
*/
|
|
184
|
+
export declare function knownStale(tracker: FileReadTracker, key: string): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Paths one pass may hold a reconstructed body for at a time.
|
|
187
|
+
*
|
|
188
|
+
* The projection emits at most this many entries and keeps the most recent, so
|
|
189
|
+
* a pass that tracked more would be doing work whose result is discarded.
|
|
190
|
+
*/
|
|
191
|
+
export declare const MAX_WITNESSED_PATHS = 6;
|
|
192
|
+
/** What one pass of {@link replayObservationLedger} established. */
|
|
193
|
+
export interface LedgerReplayReport {
|
|
194
|
+
/** Paths whose body was reconstructed exactly, with a fingerprint and a witness. */
|
|
195
|
+
readonly pathsWitnessed: number;
|
|
196
|
+
/**
|
|
197
|
+
* Paths the conversation demonstrably mutated but whose body could not be
|
|
198
|
+
* rebuilt. Nothing is written to the ledger for these; see {@link commit}.
|
|
199
|
+
*/
|
|
200
|
+
readonly pathsSeen: number;
|
|
201
|
+
/**
|
|
202
|
+
* Content materialised, in UTF-16 units. Never above
|
|
203
|
+
* {@link MAX_REPLAYED_UNITS}, and non-zero even for a pass that established
|
|
204
|
+
* nothing: it reports the work done, not the work kept.
|
|
205
|
+
*/
|
|
206
|
+
readonly unitsReplayed: number;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Rebuild an observation ledger from a conversation's own history.
|
|
210
|
+
*
|
|
211
|
+
* The ledger is process state. A resumed conversation gets a fresh empty one,
|
|
212
|
+
* and until something reads a file again the runtime knows nothing about files
|
|
213
|
+
* this conversation wrote in full — so the projection admits nothing and the
|
|
214
|
+
* model re-reads a body already in front of it, every time a session is picked
|
|
215
|
+
* back up.
|
|
216
|
+
*
|
|
217
|
+
* What is reconstructable here is exactly what the projection would admit, by
|
|
218
|
+
* the same predicates and the same bounded replay, because both go through the
|
|
219
|
+
* functions above. A `write` whose call and successful receipt are both intact
|
|
220
|
+
* hands back its body and its witness; the edits on top of it are replayed
|
|
221
|
+
* hop by hop and extend the chain. Anything else about a path the conversation
|
|
222
|
+
* mutated — a receipt compaction cleared, a call the transcript never answered,
|
|
223
|
+
* a mutation it refused, one a `pre_tool_use` hook skipped before it ever ran,
|
|
224
|
+
* a hop that no longer applies, a body past the bounds, a call too long to
|
|
225
|
+
* quote back — withdraws whatever this pass was holding for that path and
|
|
226
|
+
* writes NOTHING for it.
|
|
227
|
+
*
|
|
228
|
+
* Content-backed observations only, and that is the whole of what a resume
|
|
229
|
+
* restores. A path in the ledger with no fingerprint is a path `write` lets
|
|
230
|
+
* through unread: the read-before-overwrite refusal is `hasRead`, and the drift
|
|
231
|
+
* comparison it guards needs a body to compare. Seeding membership alone would
|
|
232
|
+
* therefore admit a full overwrite of a file that changed while the session was
|
|
233
|
+
* closed, with nothing checked — weaker than the empty ledger a resume used to
|
|
234
|
+
* start from, which refuses that overwrite outright. So a path this pass cannot
|
|
235
|
+
* rebuild is left exactly as that empty ledger leaves it, and the first real
|
|
236
|
+
* read re-establishes it.
|
|
237
|
+
*
|
|
238
|
+
* Two things this deliberately does not do. It never reads the filesystem: a
|
|
239
|
+
* fingerprint restored here is a claim derived from history, and the built-in
|
|
240
|
+
* mutation checks still compare it against the real file before anything is
|
|
241
|
+
* written — so a file changed while the session was closed is refused exactly
|
|
242
|
+
* as it is today, and the refusal's drift flag withdraws the entry. And it
|
|
243
|
+
* never recovers a body from a `read` receipt by undoing the line numbering: a
|
|
244
|
+
* read's rendering is compared, whole, against a body this pass already holds,
|
|
245
|
+
* and a read that cannot be matched that way withdraws the body rather than
|
|
246
|
+
* supplying one.
|
|
247
|
+
*
|
|
248
|
+
* That first guarantee is the reason `keyOf` is a parameter. Everything written
|
|
249
|
+
* here has to land on the key the mutation tools will look it up under, and on
|
|
250
|
+
* a host those keys are canonical — `write` and `edit` follow every symlink
|
|
251
|
+
* before they touch the ledger. Keying a seed lexically instead writes entries
|
|
252
|
+
* into a key space the tools never read: the projection would then match a
|
|
253
|
+
* fingerprint this pass had just written to it, and the drift refusal that is
|
|
254
|
+
* supposed to withdraw the claim would land somewhere else and never reach it.
|
|
255
|
+
* So the caller resolves the paths the way the tools do — see
|
|
256
|
+
* `file-evidence-seed.ts` — and a path it could not resolve gets no key, which
|
|
257
|
+
* makes the mutation that named it unattributable and stops the pass.
|
|
258
|
+
*/
|
|
259
|
+
export declare function replayObservationLedger(messages: readonly Message[], tracker: FileReadTracker, keyOf: FileKeyResolver, attributions?: PathAttributions): LedgerReplayReport;
|
|
260
|
+
//# sourceMappingURL=file-evidence-replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-evidence-replay.d.ts","sourceRoot":"","sources":["../../../src/runtime/query/file-evidence-replay.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAGhE;;;;;;;;;;;GAWG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,IAAI,CAAA;AAE/B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAa,CAAA;AAiB5C;;;;;;GAMG;AACH,eAAO,MAAM,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