@cortexkit/opencode-magic-context 0.45.0 → 0.46.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/README.md +26 -0
- package/dist/{announcement-f75t58v9.js → announcement-y35wzg2r.js} +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/live-run-config.d.ts.map +1 -1
- package/dist/config/migrate-config-location.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +13 -7
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-5yrz2r24.js → conflict-warning-hook-7fj2b9jw.js} +6 -5
- package/dist/context-sh2m2vde.js +4525 -0
- package/dist/{derive-budgets-a63zsm5c.js → derive-budgets-7nj7r1rv.js} +2 -2
- package/dist/embedding-worker.js +4 -4
- package/dist/features/magic-context/checkout-claim-fake-subc.test-support.d.ts +45 -0
- package/dist/features/magic-context/checkout-claim-fake-subc.test-support.d.ts.map +1 -0
- package/dist/features/magic-context/checkout-claim.d.ts +155 -0
- package/dist/features/magic-context/checkout-claim.d.ts.map +1 -0
- package/dist/features/magic-context/compaction-marker.d.ts +20 -3
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-storage.d.ts +23 -2
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/provider-output-failure.d.ts +6 -2
- package/dist/features/magic-context/dreamer/provider-output-failure.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/provider-output-failure.test-support.d.ts +30 -0
- package/dist/features/magic-context/dreamer/provider-output-failure.test-support.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +9 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-diff.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-gate.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity-cache.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-verifications.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory.d.ts +3 -0
- package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
- package/dist/features/magic-context/memory/verification-paths.d.ts +2 -2
- package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
- package/dist/features/magic-context/merged-reasoning-decisions.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +3 -3
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +2 -0
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/migration-v95-perf-indexes.d.ts +12 -0
- package/dist/features/magic-context/migration-v95-perf-indexes.d.ts.map +1 -0
- package/dist/features/magic-context/migration-worker-client.d.ts +4 -4
- package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts +1 -0
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/mural/render-trigger.d.ts.map +1 -1
- package/dist/features/magic-context/mural/resolve-mural.d.ts +15 -4
- package/dist/features/magic-context/mural/resolve-mural.d.ts.map +1 -1
- package/dist/features/magic-context/mural/source-revision.d.ts +7 -0
- package/dist/features/magic-context/mural/source-revision.d.ts.map +1 -0
- package/dist/features/magic-context/mural/storage-mural-cues.d.ts.map +1 -1
- package/dist/features/magic-context/reclaim-protection.d.ts +15 -10
- package/dist/features/magic-context/reclaim-protection.d.ts.map +1 -1
- package/dist/features/magic-context/session-cache-ttl.d.ts +4 -2
- package/dist/features/magic-context/session-cache-ttl.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/capabilities.d.ts +3 -0
- package/dist/features/magic-context/smart-notes/capabilities.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/github-token.d.ts +5 -0
- package/dist/features/magic-context/smart-notes/github-token.d.ts.map +1 -0
- package/dist/features/magic-context/smart-notes/runner.d.ts +1 -0
- package/dist/features/magic-context/smart-notes/runner.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts +12 -0
- package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/ssrf-guard.d.ts +6 -0
- package/dist/features/magic-context/smart-notes/ssrf-guard.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/storage.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/types.d.ts +2 -0
- package/dist/features/magic-context/smart-notes/types.d.ts.map +1 -1
- package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +6 -9
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-shared.d.ts +1 -1
- package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
- package/dist/features/magic-context/storage-ops.d.ts +8 -1
- package/dist/features/magic-context/storage-ops.d.ts.map +1 -1
- package/dist/features/magic-context/storage-replay-document.d.ts +7 -0
- package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
- package/dist/features/magic-context/storage-schema-helpers.d.ts +2 -0
- package/dist/features/magic-context/storage-schema-helpers.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/features/magic-context/storage-source.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +11 -3
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +2 -2
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/temporal-decisions.d.ts +10 -0
- package/dist/features/magic-context/temporal-decisions.d.ts.map +1 -0
- package/dist/features/magic-context/tool-definition-tokens.d.ts +2 -0
- package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/features/magic-context/types.d.ts +7 -6
- package/dist/features/magic-context/types.d.ts.map +1 -1
- package/dist/features/magic-context/window-report-ledger.d.ts.map +1 -1
- package/dist/hooks/auto-update-checker/index.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +8 -0
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +6 -3
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/channel2-cycle.d.ts +2 -0
- package/dist/hooks/magic-context/channel2-cycle.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +7 -0
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-prompt.d.ts +2 -2
- package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts +8 -0
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +18 -4
- package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/ctx-reduce-availability.d.ts +12 -0
- package/dist/hooks/magic-context/ctx-reduce-availability.d.ts.map +1 -1
- package/dist/hooks/magic-context/decision-calibration.d.ts +3 -0
- package/dist/hooks/magic-context/decision-calibration.d.ts.map +1 -1
- package/dist/hooks/magic-context/default-protection-pressure.test-support.d.ts +37 -0
- package/dist/hooks/magic-context/default-protection-pressure.test-support.d.ts.map +1 -0
- package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts +4 -0
- package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts.map +1 -1
- package/dist/hooks/magic-context/edit-marker.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts +2 -0
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-fail-closed.d.ts +21 -1
- package/dist/hooks/magic-context/emergency-fail-closed.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +5 -0
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +30 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts +2 -0
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts +4 -2
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +2 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +9 -10
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-measured-request.d.ts +69 -0
- package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -0
- package/dist/hooks/magic-context/lkg-persist.d.ts +2 -0
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay-fit.d.ts +14 -0
- package/dist/hooks/magic-context/lkg-replay-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts +10 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +4 -0
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts +2 -0
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/note-nudger.d.ts +17 -5
- package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +1 -0
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts +7 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +4 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +2 -0
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/reference-retrieval.d.ts +27 -17
- package/dist/hooks/magic-context/reference-retrieval.d.ts.map +1 -1
- package/dist/hooks/magic-context/request-hook-order.d.ts +56 -0
- package/dist/hooks/magic-context/request-hook-order.d.ts.map +1 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +22 -3
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +4 -2
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/supersession-reclaim.d.ts +4 -0
- package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +7 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +12 -3
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/temporal-awareness.d.ts +6 -3
- package/dist/hooks/magic-context/temporal-awareness.d.ts.map +1 -1
- package/dist/hooks/magic-context/temporal-served-projection.d.ts +4 -0
- package/dist/hooks/magic-context/temporal-served-projection.d.ts.map +1 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-reclaim.d.ts +2 -0
- package/dist/hooks/magic-context/tool-reclaim.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-message-helpers.d.ts +5 -0
- package/dist/hooks/magic-context/transform-message-helpers.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +41 -17
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +12 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/{index-vvtfyw1z.js → index-0d3g3461.js} +5 -13
- package/dist/index-1bc61ans.js +154 -0
- package/dist/{index-n96ag4rk.js → index-1zx87sdm.js} +5 -1
- package/dist/{index-4krbw8z9.js → index-3h0ybwah.js} +608 -102
- package/dist/{index-gd5qx1j9.js → index-5eqk6z3s.js} +62 -1
- package/dist/index-5gq3b2ya.js +494 -0
- package/dist/{index-8fgkmxmy.js → index-5p8jdswx.js} +4 -3
- package/dist/{index-75zjgwga.js → index-7qw742ev.js} +1 -1
- package/dist/{index-f85teqck.js → index-8da2zjhz.js} +3 -256
- package/dist/{index-q7yesyk9.js → index-8x2v7gg9.js} +25 -24
- package/dist/{index-w9jwmntv.js → index-b35pxds2.js} +9 -1
- package/dist/{v2/server-a4m2b1yv.js → index-fg34g6a5.js} +55 -1
- package/dist/index-hpecdzec.js +28506 -0
- package/dist/{index-2ntg5sd4.js → index-k5bdx1bx.js} +9 -5
- package/dist/{index-bmzf7zxv.js → index-majxda46.js} +23 -5
- package/dist/{index-2aq21j41.js → index-pkbcrdqs.js} +418 -127
- package/dist/{index-remp7e2g.js → index-q4yp4b52.js} +16 -1
- package/dist/{index-fr2z4qy8.js → index-r5hmbx3t.js} +132 -169
- package/dist/index-sfnj6h8h.js +259 -0
- package/dist/{index-xgt9k6c6.js → index-sgthv3f7.js} +2 -1
- package/dist/index-sj29b3z2.js +30 -0
- package/dist/{index-16ny736w.js → index-sjthx78w.js} +20526 -19817
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1983 -33118
- package/dist/{message-time-backfill-an311pmk.js → message-time-backfill-68gj6t3e.js} +2 -2
- package/dist/migration-worker.js +12 -7
- package/dist/plugin/dream-timer.d.ts +25 -1
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +2 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts +13 -0
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +4 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/subagent-tool-policy.d.ts +14 -0
- package/dist/plugin/subagent-tool-policy.d.ts.map +1 -0
- package/dist/plugin/tool-registry.d.ts +1 -0
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/{read-session-chunk-8rxs0tc9.js → read-session-chunk-egz7r68d.js} +8 -8
- package/dist/{recomp-orchestrator-nzamtw29.js → recomp-orchestrator-y15j0rb9.js} +15 -15
- package/dist/{send-session-notification-nqpv7cne.js → send-session-notification-dyw42dtr.js} +4 -4
- package/dist/shared/announcement.d.ts.map +1 -1
- package/dist/shared/cache-ttl-display.d.ts +6 -4
- package/dist/shared/cache-ttl-display.d.ts.map +1 -1
- package/dist/shared/model-cache-ttl.d.ts +1 -1
- package/dist/shared/model-cache-ttl.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts +2 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/shared/protected-tools-policy.d.ts +6 -0
- package/dist/shared/protected-tools-policy.d.ts.map +1 -0
- package/dist/shared/quota-diagnostic.d.ts +4 -0
- package/dist/shared/quota-diagnostic.d.ts.map +1 -0
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/sqlite-context-pragmas.d.ts +12 -0
- package/dist/shared/sqlite-context-pragmas.d.ts.map +1 -0
- package/dist/shared/sqlite-helpers.d.ts +9 -0
- package/dist/shared/sqlite-helpers.d.ts.map +1 -1
- package/dist/shared/sqlite.d.ts +10 -0
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/status-summary.d.ts +1 -0
- package/dist/shared/status-summary.d.ts.map +1 -1
- package/dist/shared/status-view-check.d.ts.map +1 -1
- package/dist/shared/status-view.d.ts +4 -0
- package/dist/shared/status-view.d.ts.map +1 -1
- package/dist/shared/storage-permissions.d.ts +24 -0
- package/dist/shared/storage-permissions.d.ts.map +1 -1
- package/dist/shared/temporal-upgrade-fixture.d.ts +19 -0
- package/dist/shared/temporal-upgrade-fixture.d.ts.map +1 -0
- package/dist/shared/user-facing-codes.d.ts +5 -0
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/shared/write-transaction-timing.d.ts +8 -1
- package/dist/shared/write-transaction-timing.d.ts.map +1 -1
- package/dist/tools/ctx-expand/render.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/constants.d.ts +2 -0
- package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/tools.d.ts +4 -4
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-414phndq.js → transform-postprocess-phase-bqhz6vdr.js} +15 -15
- package/dist/v2/context-zecmzk5s.js +52209 -0
- package/dist/v2/{derive-budgets-v0krf3t7.js → derive-budgets-kdgp4s3r.js} +4 -3
- package/dist/v2/embedding-worker.js +6 -5
- package/dist/v2/fold/boundary.d.ts +2 -0
- package/dist/v2/fold/boundary.d.ts.map +1 -1
- package/dist/v2/fold/owner.d.ts.map +1 -1
- package/dist/v2/hidden-child-native.d.ts +7 -0
- package/dist/v2/hidden-child-native.d.ts.map +1 -1
- package/dist/v2/hidden-child-record.d.ts +8 -0
- package/dist/v2/hidden-child-record.d.ts.map +1 -1
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/channel2.d.ts +2 -0
- package/dist/v2/hooks/channel2.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/dream-timer.d.ts +39 -0
- package/dist/v2/hooks/dream-timer.d.ts.map +1 -0
- package/dist/v2/hooks/dream-trigger.d.ts +15 -1
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +54 -3
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts +1 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/hooks/types.d.ts +12 -1
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/hooks/update-check.d.ts.map +1 -1
- package/dist/v2/{message-time-backfill-0n93vrd7.js → message-time-backfill-r6qkem1x.js} +3 -3
- package/dist/v2/migration-worker.js +13 -8
- package/dist/v2/{read-session-chunk-hjza38hr.js → read-session-chunk-8vjp6581.js} +9 -9
- package/dist/v2/recomp-orchestrator-8ejxvrzz.js +39 -0
- package/dist/v2/{safe-notification-target-wtj0bbc2.js → safe-notification-target-eb1n1vfb.js} +2 -2
- package/dist/v2/{send-session-notification-mq9frrtm.js → send-session-notification-qs0j78v6.js} +6 -6
- package/dist/v2/server-14vq4kpm.js +30 -0
- package/dist/v2/server-1bc61ans.js +154 -0
- package/dist/v2/{server-n96ag4rk.js → server-1zx87sdm.js} +5 -1
- package/dist/v2/server-3n4q9xme.js +79 -0
- package/dist/v2/{server-rhdgxp1t.js → server-51dv1pr5.js} +63 -2
- package/dist/v2/{server-5317ykaf.js → server-6r257mf5.js} +1 -1
- package/dist/v2/server-84w6rvvf.js +14 -0
- package/dist/v2/{server-qpg6wf72.js → server-ajzeteqw.js} +9 -1
- package/dist/v2/server-c5gz8wph.js +3892 -0
- package/dist/v2/{server-v5xgft5v.js → server-e29d7p7c.js} +188 -3533
- package/dist/{index-a4m2b1yv.js → v2/server-fg34g6a5.js} +55 -1
- package/dist/v2/{server-e36nf2p1.js → server-frbm99q5.js} +1595 -1599
- package/dist/v2/{server-remp7e2g.js → server-g0fjrkta.js} +16 -1
- package/dist/v2/{server-c4g2y1z8.js → server-jc7y02q0.js} +2816 -5392
- package/dist/v2/{server-z19x7eqz.js → server-mcfawjgc.js} +4 -4
- package/dist/v2/{server-hfjfbg59.js → server-qp5hx1ad.js} +608 -105
- package/dist/v2/server-vs5gpnd4.js +493 -0
- package/dist/v2/{server-w99cyt6a.js → server-wvjvfhck.js} +14 -6
- package/dist/v2/server-xa4xe3rv.js +3351 -0
- package/dist/v2/{server-0jqw05sa.js → server-y8maxeft.js} +6 -84
- package/dist/v2/server.d.ts.map +1 -1
- package/dist/v2/server.js +104 -49288
- package/dist/v2/store-reader.d.ts +39 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/tool-result.d.ts +8 -0
- package/dist/v2/tool-result.d.ts.map +1 -0
- package/dist/v2/tui/index.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-tbyx78dz.js → wrapup-orchestrator-0snhvwcv.js} +20 -16
- package/dist/wrapup-orchestrator-39amhv9s.js +26 -0
- package/package.json +26 -10
- package/src/config/index.ts +21 -4
- package/src/config/latch-permanence-guard.test.ts +6 -1
- package/src/config/live-run-config.ts +1 -0
- package/src/config/migrate-config-location.test.ts +31 -1
- package/src/config/migrate-config-location.ts +8 -41
- package/src/config/protected-tools.test.ts +70 -0
- package/src/config/raw-loader.test.ts +15 -0
- package/src/config/raw-loader.ts +1 -1
- package/src/config/removed-agent-source-fence.test.ts +10 -1
- package/src/config/schema/magic-context.test.ts +20 -1
- package/src/config/schema/magic-context.ts +26 -7
- package/src/shared/announcement.ts +6 -5
- package/src/shared/cache-ttl-display.test.ts +1 -1
- package/src/shared/cache-ttl-display.ts +17 -16
- package/src/shared/fold-render-lock-fence.test.ts +84 -0
- package/src/shared/fold-render-lock-fixtures.test.ts +276 -0
- package/src/shared/model-cache-ttl.test.ts +2 -2
- package/src/shared/model-cache-ttl.ts +8 -4
- package/src/shared/model-suggestion-retry.test.ts +104 -1
- package/src/shared/model-suggestion-retry.ts +63 -6
- package/src/shared/models-dev-cache.ts +3 -11
- package/src/shared/protected-tools-policy.ts +23 -0
- package/src/shared/quota-diagnostic.ts +9 -0
- package/src/shared/rpc-server.ts +6 -54
- package/src/shared/sqlite-context-pragmas.test.ts +105 -0
- package/src/shared/sqlite-context-pragmas.ts +24 -0
- package/src/shared/sqlite-helpers.ts +17 -0
- package/src/shared/sqlite.ts +75 -0
- package/src/shared/status-detail-text.test.ts +18 -1
- package/src/shared/status-summary.ts +11 -0
- package/src/shared/status-view-check.ts +5 -0
- package/src/shared/status-view.test.ts +11 -2
- package/src/shared/status-view.ts +12 -1
- package/src/shared/storage-permissions.test.ts +204 -0
- package/src/shared/storage-permissions.ts +192 -0
- package/src/shared/temporal-upgrade-fixture.ts +50 -0
- package/src/shared/user-facing-codes.ts +6 -0
- package/src/shared/write-transaction-timing.test.ts +39 -0
- package/src/shared/write-transaction-timing.ts +25 -1
- package/src/tui/dialogs/status-dialog-render.test.ts +1 -1
- package/src/tui/index.tsx +3 -1
- package/src/tui/startup-order.test.ts +16 -0
- package/src/tui-compiled/index.tsx +3 -1
- package/src/v2/tui/index.ts +9 -2
- package/dist/index-anq4nn6f.js +0 -131
- package/dist/index-e44zzy84.js +0 -10
- package/dist/index-x23gah8c.js +0 -16
- package/dist/v2/recomp-orchestrator-1aq7h44c.js +0 -36
- package/dist/v2/server-e44zzy84.js +0 -10
- package/dist/v2/server-fgmxwrgy.js +0 -16
- package/dist/v2/server-r7cmye3k.js +0 -131
- package/dist/wrapup-orchestrator-h28bqsy6.js +0 -26
- package/dist/v2/{server-ckpc8pxy.js → server-1qbnzc80.js} +8 -8
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import {
|
|
2
|
+
estimateTokens
|
|
3
|
+
} from "./server-51dv1pr5.js";
|
|
4
|
+
import {
|
|
5
|
+
sessionLog
|
|
6
|
+
} from "./server-1qbnzc80.js";
|
|
7
|
+
import {
|
|
8
|
+
isKnownAutocommit
|
|
9
|
+
} from "./server-ajzeteqw.js";
|
|
10
|
+
|
|
11
|
+
// src/features/magic-context/tool-definition-tokens.ts
|
|
12
|
+
import { createHash } from "node:crypto";
|
|
13
|
+
|
|
14
|
+
// src/shared/stable-json.ts
|
|
15
|
+
function stableStringify(value, seen = new WeakSet) {
|
|
16
|
+
if (value === undefined)
|
|
17
|
+
return "undefined";
|
|
18
|
+
if (value === null || typeof value !== "object")
|
|
19
|
+
return JSON.stringify(value) ?? String(value);
|
|
20
|
+
if (seen.has(value))
|
|
21
|
+
return '"[Circular]"';
|
|
22
|
+
seen.add(value);
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
return `[${value.map((item) => stableStringify(item, seen)).join(",")}]`;
|
|
25
|
+
}
|
|
26
|
+
const entries = Object.entries(value).sort(([a], [b]) => {
|
|
27
|
+
if (a < b)
|
|
28
|
+
return -1;
|
|
29
|
+
if (a > b)
|
|
30
|
+
return 1;
|
|
31
|
+
return 0;
|
|
32
|
+
});
|
|
33
|
+
return `{${entries.map(([key, child]) => `${JSON.stringify(key)}:${stableStringify(child, seen)}`).join(",")}}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/features/magic-context/tool-definition-tokens.ts
|
|
37
|
+
var measurements = new Map;
|
|
38
|
+
var fingerprints = new Map;
|
|
39
|
+
var persistenceDb = null;
|
|
40
|
+
var cachedInsertStmt = null;
|
|
41
|
+
function keyFor(providerID, modelID, agentName) {
|
|
42
|
+
const agent = agentName && agentName.length > 0 ? agentName : "default";
|
|
43
|
+
return `${providerID}/${modelID}/${agent}`;
|
|
44
|
+
}
|
|
45
|
+
function fingerprintFor(description, parameters) {
|
|
46
|
+
return createHash("sha256").update(description).update("\x00").update(stableStringify(parameters)).digest("hex");
|
|
47
|
+
}
|
|
48
|
+
function getCurrentToolSetHash(providerID, modelID, agentName) {
|
|
49
|
+
if (!providerID || !modelID)
|
|
50
|
+
return "";
|
|
51
|
+
const toolIds = measurements.get(keyFor(providerID, modelID, agentName));
|
|
52
|
+
if (!toolIds || toolIds.size === 0)
|
|
53
|
+
return "";
|
|
54
|
+
return createHash("sha256").update(Array.from(toolIds.keys()).sort().join("\x00")).digest("hex");
|
|
55
|
+
}
|
|
56
|
+
function getToolDefinitionMeasurementSignature(providerID, modelID, agentName) {
|
|
57
|
+
const key = keyFor(providerID, modelID, agentName);
|
|
58
|
+
const measured = measurements.get(key);
|
|
59
|
+
const observed = fingerprints.get(key);
|
|
60
|
+
if (!measured || !observed || [...measured.keys()].some((id) => !observed.has(id)))
|
|
61
|
+
return;
|
|
62
|
+
return createHash("sha256").update(JSON.stringify([...measured.keys()].sort().map((id) => [id, observed.get(id)]))).digest("hex");
|
|
63
|
+
}
|
|
64
|
+
function setDatabase(db) {
|
|
65
|
+
persistenceDb = db;
|
|
66
|
+
cachedInsertStmt = null;
|
|
67
|
+
}
|
|
68
|
+
function loadToolDefinitionMeasurements(db) {
|
|
69
|
+
let rows = [];
|
|
70
|
+
try {
|
|
71
|
+
rows = db.prepare("SELECT provider_id, model_id, agent_name, tool_id, token_count FROM tool_definition_measurements").all();
|
|
72
|
+
} catch {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
for (const row of rows) {
|
|
76
|
+
const key = keyFor(row.provider_id, row.model_id, row.agent_name);
|
|
77
|
+
let inner = measurements.get(key);
|
|
78
|
+
if (!inner) {
|
|
79
|
+
inner = new Map;
|
|
80
|
+
measurements.set(key, inner);
|
|
81
|
+
}
|
|
82
|
+
inner.set(row.tool_id, row.token_count);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function recordToolDefinition(providerID, modelID, agentName, toolID, description, parameters) {
|
|
86
|
+
if (!providerID || !modelID || !toolID)
|
|
87
|
+
return;
|
|
88
|
+
const key = keyFor(providerID, modelID, agentName);
|
|
89
|
+
const fp = fingerprintFor(description ?? "", parameters);
|
|
90
|
+
let innerFp = fingerprints.get(key);
|
|
91
|
+
if (innerFp && innerFp.get(toolID) === fp)
|
|
92
|
+
return;
|
|
93
|
+
let paramsText = "";
|
|
94
|
+
try {
|
|
95
|
+
paramsText = parameters === undefined ? "" : JSON.stringify(parameters);
|
|
96
|
+
} catch {
|
|
97
|
+
paramsText = "";
|
|
98
|
+
}
|
|
99
|
+
const tokens = estimateTokens(description ?? "") + estimateTokens(paramsText);
|
|
100
|
+
let inner = measurements.get(key);
|
|
101
|
+
if (!inner) {
|
|
102
|
+
inner = new Map;
|
|
103
|
+
measurements.set(key, inner);
|
|
104
|
+
}
|
|
105
|
+
inner.set(toolID, tokens);
|
|
106
|
+
if (!innerFp) {
|
|
107
|
+
innerFp = new Map;
|
|
108
|
+
fingerprints.set(key, innerFp);
|
|
109
|
+
}
|
|
110
|
+
innerFp.set(toolID, fp);
|
|
111
|
+
if (persistenceDb) {
|
|
112
|
+
try {
|
|
113
|
+
const agent = agentName && agentName.length > 0 ? agentName : "default";
|
|
114
|
+
if (!cachedInsertStmt) {
|
|
115
|
+
cachedInsertStmt = persistenceDb.prepare(`INSERT OR REPLACE INTO tool_definition_measurements
|
|
116
|
+
(provider_id, model_id, agent_name, tool_id, token_count, recorded_at)
|
|
117
|
+
VALUES (?, ?, ?, ?, ?, ?)`);
|
|
118
|
+
}
|
|
119
|
+
cachedInsertStmt.run(providerID, modelID, agent, toolID, tokens, Date.now());
|
|
120
|
+
} catch {
|
|
121
|
+
cachedInsertStmt = null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function getLargestMeasuredToolDefinitionTokens() {
|
|
126
|
+
let largest = 0;
|
|
127
|
+
for (const tools of measurements.values()) {
|
|
128
|
+
let total = 0;
|
|
129
|
+
for (const tokens of tools.values())
|
|
130
|
+
total += tokens;
|
|
131
|
+
largest = Math.max(largest, total);
|
|
132
|
+
}
|
|
133
|
+
return largest > 0 ? largest : undefined;
|
|
134
|
+
}
|
|
135
|
+
function getMeasuredToolDefinitionTokens(providerID, modelID, agentName) {
|
|
136
|
+
if (!providerID || !modelID)
|
|
137
|
+
return;
|
|
138
|
+
const inner = measurements.get(keyFor(providerID, modelID, agentName));
|
|
139
|
+
if (!inner || inner.size === 0)
|
|
140
|
+
return;
|
|
141
|
+
let total = 0;
|
|
142
|
+
for (const tokens of inner.values())
|
|
143
|
+
total += tokens;
|
|
144
|
+
return total;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/features/magic-context/storage-schema-helpers.ts
|
|
148
|
+
var columnCaches = new WeakMap;
|
|
149
|
+
function readColumnNames(db, table) {
|
|
150
|
+
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
151
|
+
return new Set(rows.flatMap((row) => typeof row.name === "string" ? [row.name] : []));
|
|
152
|
+
}
|
|
153
|
+
function columnNames(db, table) {
|
|
154
|
+
if (!isKnownAutocommit(db)) {
|
|
155
|
+
columnCaches.delete(db);
|
|
156
|
+
return readColumnNames(db, table);
|
|
157
|
+
}
|
|
158
|
+
let cache = columnCaches.get(db);
|
|
159
|
+
if (!cache) {
|
|
160
|
+
cache = { version: -1, stamp: db.prepare("PRAGMA schema_version"), tables: new Map };
|
|
161
|
+
columnCaches.set(db, cache);
|
|
162
|
+
}
|
|
163
|
+
const [{ schema_version: version }] = cache.stamp.all();
|
|
164
|
+
if (version !== cache.version) {
|
|
165
|
+
cache.tables.clear();
|
|
166
|
+
cache.version = version;
|
|
167
|
+
}
|
|
168
|
+
let columns = cache.tables.get(table);
|
|
169
|
+
if (!columns) {
|
|
170
|
+
columns = readColumnNames(db, table);
|
|
171
|
+
cache.tables.set(table, columns);
|
|
172
|
+
}
|
|
173
|
+
return columns;
|
|
174
|
+
}
|
|
175
|
+
function getTableColumnNames(db, table) {
|
|
176
|
+
if (!/^[a-z][a-z0-9_]*$/.test(table))
|
|
177
|
+
throw new Error(`Unsafe schema identifier: ${table}`);
|
|
178
|
+
return columnNames(db, table);
|
|
179
|
+
}
|
|
180
|
+
function ensureColumn(db, table, column, definition) {
|
|
181
|
+
if (!/^[a-z][a-z0-9_]*$/.test(table) || !/^[a-z][a-z0-9_]*$/.test(column) || !/^[A-Z0-9_"'(),[\]\s]+$/i.test(definition)) {
|
|
182
|
+
throw new Error(`Unsafe schema identifier: ${table}.${column} ${definition}`);
|
|
183
|
+
}
|
|
184
|
+
if (columnNames(db, table).has(column)) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
189
|
+
} catch (err) {
|
|
190
|
+
columnCaches.delete(db);
|
|
191
|
+
const recheck = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
192
|
+
if (recheck.some((row) => row.name === column)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
throw err;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function healAllNullColumns(db) {
|
|
199
|
+
const existingColumns = getSessionMetaColumns(db);
|
|
200
|
+
const fallbacks = [
|
|
201
|
+
["cache_ttl", ""],
|
|
202
|
+
["last_nudge_band", ""],
|
|
203
|
+
["last_nudge_level", ""],
|
|
204
|
+
["channel2_nudge_claim_token", ""],
|
|
205
|
+
["last_transform_error", ""],
|
|
206
|
+
["nudge_anchor_message_id", ""],
|
|
207
|
+
["nudge_anchor_text", ""],
|
|
208
|
+
["sticky_turn_reminder_text", ""],
|
|
209
|
+
["sticky_turn_reminder_message_id", ""],
|
|
210
|
+
["note_nudge_trigger_message_id", ""],
|
|
211
|
+
["note_nudge_sticky_text", ""],
|
|
212
|
+
["note_nudge_sticky_message_id", ""],
|
|
213
|
+
["last_todo_state", ""],
|
|
214
|
+
["todo_synthetic_call_id", ""],
|
|
215
|
+
["todo_synthetic_anchor_message_id", ""],
|
|
216
|
+
["todo_synthetic_state_json", ""],
|
|
217
|
+
["system_prompt_hash", ""],
|
|
218
|
+
["stripped_placeholder_ids", ""],
|
|
219
|
+
["stale_reduce_stripped_ids", ""],
|
|
220
|
+
["processed_image_stripped_ids", ""],
|
|
221
|
+
["merged_reasoning_stripped_ids", ""],
|
|
222
|
+
["thinking_binding_recovery_target", ""],
|
|
223
|
+
["trailing_blank_decisions", ""],
|
|
224
|
+
["memory_block_cache", ""],
|
|
225
|
+
["memory_block_ids", ""],
|
|
226
|
+
["compaction_marker_state", ""],
|
|
227
|
+
["key_files", ""],
|
|
228
|
+
["times_execute_threshold_reached", 0],
|
|
229
|
+
["compartment_in_progress", 0],
|
|
230
|
+
["historian_failure_count", 0],
|
|
231
|
+
["cleared_reasoning_through_tag", 0],
|
|
232
|
+
["memory_block_count", 0],
|
|
233
|
+
["system_prompt_tokens", 0],
|
|
234
|
+
["conversation_tokens", 0],
|
|
235
|
+
["tool_call_tokens", 0],
|
|
236
|
+
["note_nudge_trigger_pending", 0],
|
|
237
|
+
["observed_safe_input_tokens", 0],
|
|
238
|
+
["cache_alert_sent", 0],
|
|
239
|
+
["new_work_tokens", 0],
|
|
240
|
+
["total_input_tokens", 0],
|
|
241
|
+
["last_emergency_input_sample", 0],
|
|
242
|
+
["channel2_nudge_claimed_at", 0],
|
|
243
|
+
["last_usage_context_limit", 0],
|
|
244
|
+
["prior_boundary_ordinal", 1],
|
|
245
|
+
["protected_tail_policy_version", 0],
|
|
246
|
+
["protected_tail_drain_window_started_at", 0],
|
|
247
|
+
["protected_tail_drain_tokens", 0],
|
|
248
|
+
["recovery_no_eligible_head_count", 0],
|
|
249
|
+
["force_emergency_bypass_window_start", 0],
|
|
250
|
+
["force_emergency_bypass_used", 0],
|
|
251
|
+
["emergency_drain_active", 0],
|
|
252
|
+
["historian_drain_failure_at", 0]
|
|
253
|
+
];
|
|
254
|
+
const presentFallbacks = fallbacks.filter(([column]) => existingColumns.has(column));
|
|
255
|
+
if (presentFallbacks.length > 0) {
|
|
256
|
+
const assignments = presentFallbacks.map(([column]) => `${column} = COALESCE(${column}, ?)`).join(", ");
|
|
257
|
+
const nullPredicate = presentFallbacks.map(([column]) => `${column} IS NULL`).join(" OR ");
|
|
258
|
+
db.prepare(`UPDATE session_meta SET ${assignments} WHERE ${nullPredicate}`).run(...presentFallbacks.map(([, fallback]) => fallback));
|
|
259
|
+
}
|
|
260
|
+
healMissingMemoryBlockIds(db, existingColumns);
|
|
261
|
+
}
|
|
262
|
+
function getSessionMetaColumns(db) {
|
|
263
|
+
const rows = db.prepare("PRAGMA table_info(session_meta)").all();
|
|
264
|
+
return new Set(rows.flatMap((row) => typeof row.name === "string" ? [row.name] : []));
|
|
265
|
+
}
|
|
266
|
+
function healMissingMemoryBlockIds(db, columns) {
|
|
267
|
+
if (!columns.has("memory_block_cache") || !columns.has("memory_block_ids") || !columns.has("memory_block_count")) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
db.prepare("UPDATE session_meta SET memory_block_cache = '' WHERE memory_block_cache != '' AND (memory_block_ids IS NULL OR memory_block_ids = '') AND memory_block_count > 0").run();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// src/features/magic-context/temporal-decisions.ts
|
|
274
|
+
var PREFIX = "temporal-message-v1:";
|
|
275
|
+
function decodeTemporalDecision(entry) {
|
|
276
|
+
if (!entry.startsWith(PREFIX))
|
|
277
|
+
return null;
|
|
278
|
+
try {
|
|
279
|
+
const pair = JSON.parse(entry.slice(PREFIX.length));
|
|
280
|
+
if (Array.isArray(pair) && pair.length === 2 && typeof pair[0] === "string" && pair[0] && typeof pair[1] === "string")
|
|
281
|
+
return [pair[0], pair[1]];
|
|
282
|
+
} catch {}
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
function readRows(db, sessionId, messageIds) {
|
|
286
|
+
if (!messageIds)
|
|
287
|
+
return db.prepare("SELECT message_id,marker FROM temporal_decisions WHERE session_id=?").all(sessionId);
|
|
288
|
+
const ids = [...messageIds];
|
|
289
|
+
const result = [];
|
|
290
|
+
for (let offset = 0;offset < ids.length; offset += 400) {
|
|
291
|
+
const chunk = ids.slice(offset, offset + 400);
|
|
292
|
+
result.push(...db.prepare(`SELECT message_id,marker FROM temporal_decisions WHERE session_id=? AND message_id IN (${chunk.map(() => "?").join(",")})`).all(sessionId, ...chunk));
|
|
293
|
+
}
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
function getTemporalDecisions(db, sessionId, messageIds) {
|
|
297
|
+
return new Map(readRows(db, sessionId, messageIds).flatMap((row) => row.marker === null ? [] : [[row.message_id, row.marker]]));
|
|
298
|
+
}
|
|
299
|
+
function observeTemporalDecisions(db, sessionId, candidates, previouslyServed, messageIds) {
|
|
300
|
+
const ids = new Set([...candidates.keys(), ...messageIds ?? []]);
|
|
301
|
+
const rows = readRows(db, sessionId, ids);
|
|
302
|
+
const known = new Set(rows.map((row) => row.message_id));
|
|
303
|
+
const missing = [...candidates].filter(([id]) => !known.has(id));
|
|
304
|
+
if (!missing.length)
|
|
305
|
+
return new Map(rows.flatMap((row) => row.marker === null ? [] : [[row.message_id, row.marker]]));
|
|
306
|
+
const transient = new Map;
|
|
307
|
+
db.transaction(() => {
|
|
308
|
+
const insert = db.prepare("INSERT OR IGNORE INTO temporal_decisions(session_id,message_id,marker) VALUES (?,?,?)");
|
|
309
|
+
const servedTag = db.prepare("SELECT 1 FROM tags WHERE session_id=? AND message_id=? UNION ALL SELECT 1 FROM tags WHERE session_id=? AND message_id>=? AND message_id<? LIMIT 1");
|
|
310
|
+
let served;
|
|
311
|
+
for (const [id, candidate] of missing) {
|
|
312
|
+
const historical = servedTag.get(sessionId, id, sessionId, `${id}:p`, `${id}:q`);
|
|
313
|
+
if (historical) {
|
|
314
|
+
served ??= previouslyServed?.(missing.map(([missingId]) => missingId)) ?? new Map;
|
|
315
|
+
const previous = served.get(id);
|
|
316
|
+
if (previous === undefined) {
|
|
317
|
+
transient.set(id, candidate);
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
insert.run(sessionId, id, previous === "" && candidate !== "" ? null : previous);
|
|
321
|
+
} else {
|
|
322
|
+
insert.run(sessionId, id, null);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}).immediate();
|
|
326
|
+
return new Map([...transient, ...getTemporalDecisions(db, sessionId, ids)]);
|
|
327
|
+
}
|
|
328
|
+
function freezeTemporalDecisions(db, sessionId, candidates) {
|
|
329
|
+
if (candidates.size === 0)
|
|
330
|
+
return new Map;
|
|
331
|
+
return db.transaction(() => {
|
|
332
|
+
const insert = db.prepare("INSERT INTO temporal_decisions(session_id,message_id,marker) VALUES (?,?,?) ON CONFLICT(session_id,message_id) DO UPDATE SET marker=excluded.marker WHERE temporal_decisions.marker IS NULL");
|
|
333
|
+
for (const [id, marker] of candidates) {
|
|
334
|
+
insert.run(sessionId, id, marker);
|
|
335
|
+
}
|
|
336
|
+
return getTemporalDecisions(db, sessionId, candidates.keys());
|
|
337
|
+
}).immediate();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/features/magic-context/migration-v95-perf-indexes.ts
|
|
341
|
+
var TEMPORAL_DECISIONS_DDL = `CREATE TABLE temporal_decisions (
|
|
342
|
+
session_id TEXT NOT NULL,
|
|
343
|
+
message_id TEXT NOT NULL,
|
|
344
|
+
marker TEXT,
|
|
345
|
+
PRIMARY KEY (session_id, message_id)
|
|
346
|
+
) WITHOUT ROWID`;
|
|
347
|
+
var indexes = [
|
|
348
|
+
["message_fts_rowid_map", "idx_message_fts_rowid_map_session_rowid", "session_id, fts_rowid"],
|
|
349
|
+
["transform_decisions", "idx_transform_decisions_retention", "session_id, harness, ts_ms"],
|
|
350
|
+
["plugin_messages", "idx_plugin_messages_session", "session_id"],
|
|
351
|
+
["user_memory_candidates", "idx_user_memory_candidates_session", "session_id"]
|
|
352
|
+
];
|
|
353
|
+
var V95_REDUNDANT_INDEXES = [
|
|
354
|
+
"idx_tags_session_tag_number",
|
|
355
|
+
"idx_compartments_session",
|
|
356
|
+
"idx_pending_ops_session",
|
|
357
|
+
"idx_source_contents_session",
|
|
358
|
+
"idx_compression_depth_session",
|
|
359
|
+
"idx_transform_decisions_session_harness",
|
|
360
|
+
"idx_project_key_files_project"
|
|
361
|
+
];
|
|
362
|
+
var GIT_COMMIT_FTS_ROWID_MAP_DDL = `CREATE TABLE git_commit_fts_rowid_map (
|
|
363
|
+
fts_rowid INTEGER PRIMARY KEY,
|
|
364
|
+
sha BLOB
|
|
365
|
+
)`;
|
|
366
|
+
var GIT_FTS_MAP_REPAIR_COMMAND = "magic-context doctor git-fts-map --repair";
|
|
367
|
+
var GIT_FTS_MAP_DISAGREEMENT_SQL = `
|
|
368
|
+
SELECT 1 FROM git_commits_fts AS f
|
|
369
|
+
LEFT JOIN git_commit_fts_rowid_map AS m ON m.fts_rowid = f.rowid
|
|
370
|
+
WHERE m.fts_rowid IS NULL OR m.sha IS NOT f.sha OR typeof(m.sha) IS NOT typeof(f.sha)
|
|
371
|
+
UNION ALL
|
|
372
|
+
SELECT 1 FROM git_commit_fts_rowid_map AS m
|
|
373
|
+
WHERE NOT EXISTS (SELECT 1 FROM git_commits_fts AS f WHERE f.rowid = m.fts_rowid)
|
|
374
|
+
LIMIT 1`;
|
|
375
|
+
function gitFtsMapRepairMessage(detail) {
|
|
376
|
+
return `${detail}; stop all hosts, then run \`${GIT_FTS_MAP_REPAIR_COMMAND}\` to back up both stores and rebuild only the map`;
|
|
377
|
+
}
|
|
378
|
+
var mapIndex = "CREATE INDEX idx_git_commit_fts_rowid_map_sha ON git_commit_fts_rowid_map(sha)";
|
|
379
|
+
var remove = (row) => `
|
|
380
|
+
DELETE FROM git_commits_fts WHERE rowid IN (
|
|
381
|
+
SELECT fts_rowid FROM git_commit_fts_rowid_map WHERE sha = ${row}.sha
|
|
382
|
+
);
|
|
383
|
+
DELETE FROM git_commit_fts_rowid_map WHERE sha = ${row}.sha;`;
|
|
384
|
+
var insert = `
|
|
385
|
+
INSERT INTO git_commits_fts(sha, project_path, message)
|
|
386
|
+
VALUES (NEW.sha, NEW.project_path, NEW.message);
|
|
387
|
+
INSERT INTO git_commit_fts_rowid_map(fts_rowid, sha)
|
|
388
|
+
VALUES (last_insert_rowid(), NEW.sha);`;
|
|
389
|
+
var triggers = [
|
|
390
|
+
[
|
|
391
|
+
"git_commits_fts_insert",
|
|
392
|
+
`CREATE TRIGGER git_commits_fts_insert AFTER INSERT ON git_commits BEGIN${remove("NEW")}${insert}
|
|
393
|
+
END`
|
|
394
|
+
],
|
|
395
|
+
[
|
|
396
|
+
"git_commits_fts_delete",
|
|
397
|
+
`CREATE TRIGGER git_commits_fts_delete AFTER DELETE ON git_commits BEGIN${remove("OLD")}
|
|
398
|
+
END`
|
|
399
|
+
],
|
|
400
|
+
[
|
|
401
|
+
"git_commits_fts_update",
|
|
402
|
+
`CREATE TRIGGER git_commits_fts_update AFTER UPDATE OF message, project_path ON git_commits BEGIN${remove("OLD")}${insert}
|
|
403
|
+
END`
|
|
404
|
+
]
|
|
405
|
+
];
|
|
406
|
+
function installV95PerfSchema(db, verifyExistingMap = false, allowCreateMap = true) {
|
|
407
|
+
const schema = new Map(db.prepare("SELECT name, sql FROM sqlite_master").all().map((row) => [row.name, row.sql]));
|
|
408
|
+
if (!schema.has("temporal_decisions")) {
|
|
409
|
+
db.exec(TEMPORAL_DECISIONS_DDL);
|
|
410
|
+
if (schema.has("session_meta")) {
|
|
411
|
+
ensureColumn(db, "session_meta", "merged_reasoning_stripped_ids", "TEXT DEFAULT ''");
|
|
412
|
+
const rows = db.prepare("SELECT session_id, merged_reasoning_stripped_ids AS entries FROM session_meta WHERE merged_reasoning_stripped_ids LIKE '%temporal-message-v1:%'").all();
|
|
413
|
+
const insert = db.prepare("INSERT OR IGNORE INTO temporal_decisions(session_id,message_id,marker) VALUES (?,?,?)");
|
|
414
|
+
for (const row of rows) {
|
|
415
|
+
let entries;
|
|
416
|
+
try {
|
|
417
|
+
entries = JSON.parse(row.entries);
|
|
418
|
+
} catch {
|
|
419
|
+
sessionLog(row.session_id, "v95 temporal metadata: malformed JSON skipped; original blob retained");
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
if (!Array.isArray(entries)) {
|
|
423
|
+
sessionLog(row.session_id, "v95 temporal metadata: non-array JSON skipped; original blob retained");
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
const kept = [];
|
|
427
|
+
for (const entry of entries) {
|
|
428
|
+
const decision = typeof entry === "string" ? decodeTemporalDecision(entry) : null;
|
|
429
|
+
if (decision)
|
|
430
|
+
insert.run(row.session_id, ...decision);
|
|
431
|
+
else
|
|
432
|
+
kept.push(entry);
|
|
433
|
+
}
|
|
434
|
+
db.prepare("UPDATE session_meta SET merged_reasoning_stripped_ids=? WHERE session_id=?").run(JSON.stringify(kept), row.session_id);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
for (const [table, name, columns] of indexes) {
|
|
439
|
+
if (schema.has(table) && !schema.has(name))
|
|
440
|
+
db.exec(`CREATE INDEX ${name} ON ${table}(${columns})`);
|
|
441
|
+
}
|
|
442
|
+
for (const name of V95_REDUNDANT_INDEXES) {
|
|
443
|
+
if (schema.has(name))
|
|
444
|
+
db.exec(`DROP INDEX ${name}`);
|
|
445
|
+
}
|
|
446
|
+
if (!schema.has("git_commits") || !schema.has("git_commits_fts"))
|
|
447
|
+
return;
|
|
448
|
+
const installed = schema.get("git_commit_fts_rowid_map");
|
|
449
|
+
if (installed === undefined) {
|
|
450
|
+
if (!allowCreateMap)
|
|
451
|
+
throw new Error(gitFtsMapRepairMessage("git FTS rowid map is missing"));
|
|
452
|
+
db.exec(GIT_COMMIT_FTS_ROWID_MAP_DDL);
|
|
453
|
+
db.exec("INSERT INTO git_commit_fts_rowid_map(fts_rowid, sha) SELECT rowid, sha FROM git_commits_fts");
|
|
454
|
+
} else if (installed !== GIT_COMMIT_FTS_ROWID_MAP_DDL) {
|
|
455
|
+
throw new Error(gitFtsMapRepairMessage("git_commit_fts_rowid_map schema differs; refusing to replace rowid data"));
|
|
456
|
+
}
|
|
457
|
+
if (verifyExistingMap && installed !== undefined && db.prepare(GIT_FTS_MAP_DISAGREEMENT_SQL).get()) {
|
|
458
|
+
throw new Error(gitFtsMapRepairMessage("git FTS rowid inventory differs; refusing migration replay"));
|
|
459
|
+
}
|
|
460
|
+
if (!schema.has("idx_git_commit_fts_rowid_map_sha"))
|
|
461
|
+
db.exec(mapIndex);
|
|
462
|
+
for (const [name, ddl] of triggers) {
|
|
463
|
+
if (schema.get(name) === ddl)
|
|
464
|
+
continue;
|
|
465
|
+
db.exec(`DROP TRIGGER IF EXISTS ${name}`);
|
|
466
|
+
db.exec(ddl);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
var tagOrderIndexes = new WeakMap;
|
|
470
|
+
function tagOrderConstraintIndex(db) {
|
|
471
|
+
const version = db.prepare("PRAGMA schema_version").get().schema_version;
|
|
472
|
+
const cacheable = isKnownAutocommit(db);
|
|
473
|
+
if (!cacheable)
|
|
474
|
+
tagOrderIndexes.delete(db);
|
|
475
|
+
const cached = tagOrderIndexes.get(db);
|
|
476
|
+
if (cached?.schemaVersion === version)
|
|
477
|
+
return cached.name;
|
|
478
|
+
const candidates = db.prepare("PRAGMA index_list(tags)").all();
|
|
479
|
+
for (const candidate of candidates) {
|
|
480
|
+
if (!candidate.unique || candidate.origin !== "u")
|
|
481
|
+
continue;
|
|
482
|
+
const quoted = `"${candidate.name.replaceAll('"', '""')}"`;
|
|
483
|
+
const columns = db.prepare(`PRAGMA index_info(${quoted})`).all();
|
|
484
|
+
if (columns.length !== 2 || columns[0]?.name !== "session_id" || columns[1]?.name !== "tag_number")
|
|
485
|
+
continue;
|
|
486
|
+
if (cacheable)
|
|
487
|
+
tagOrderIndexes.set(db, { schemaVersion: version, name: quoted });
|
|
488
|
+
return quoted;
|
|
489
|
+
}
|
|
490
|
+
throw new Error("tags lacks its UNIQUE(session_id, tag_number) ordering constraint");
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export { getTableColumnNames, ensureColumn, healAllNullColumns, stableStringify, getTemporalDecisions, observeTemporalDecisions, freezeTemporalDecisions, installV95PerfSchema, tagOrderConstraintIndex, getCurrentToolSetHash, getToolDefinitionMeasurementSignature, setDatabase, loadToolDefinitionMeasurements, recordToolDefinition, getLargestMeasuredToolDefinitionTokens, getMeasuredToolDefinitionTokens };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
harnessOwnsOpenCodeStore,
|
|
3
3
|
log
|
|
4
|
-
} from "./server-
|
|
4
|
+
} from "./server-1qbnzc80.js";
|
|
5
5
|
import {
|
|
6
|
+
closeQuietly,
|
|
6
7
|
resolveOpenCodeDbPath,
|
|
7
8
|
assertOpenCodeStoreGeneration,
|
|
8
9
|
openCodeDbPathExists,
|
|
9
10
|
recordOpenCodeDbReadFailure,
|
|
10
11
|
clearOpenCodeDbReadFailure,
|
|
11
|
-
claimOpenCodeDbDiagnosticOnce
|
|
12
|
-
|
|
13
|
-
} from "./server-qpg6wf72.js";
|
|
12
|
+
claimOpenCodeDbDiagnosticOnce
|
|
13
|
+
} from "./server-ajzeteqw.js";
|
|
14
14
|
import {
|
|
15
15
|
Database
|
|
16
|
-
} from "./server-
|
|
16
|
+
} from "./server-fg34g6a5.js";
|
|
17
17
|
|
|
18
18
|
// src/hooks/magic-context/read-session-db.ts
|
|
19
19
|
function openCodeDbExists() {
|
|
@@ -133,7 +133,15 @@ function shouldHoldIgnoredNotificationFromMessages(messages) {
|
|
|
133
133
|
return latestRealUser !== null && latestRealUser.timeCreated > (latestAssistant?.timeCreated ?? -1);
|
|
134
134
|
}
|
|
135
135
|
function trackedMessages(session) {
|
|
136
|
-
|
|
136
|
+
let assistant;
|
|
137
|
+
let user;
|
|
138
|
+
for (const message of session.messages.values()) {
|
|
139
|
+
if (message.role === "assistant" && (!assistant || message.timeCreated >= assistant.timeCreated))
|
|
140
|
+
assistant = message;
|
|
141
|
+
if (message.role === "user" && (!user || message.timeCreated >= user.timeCreated) && (message.parts.size === 0 || ![...message.parts.values()].every(isMachineGeneratedPart)))
|
|
142
|
+
user = message;
|
|
143
|
+
}
|
|
144
|
+
return [user, assistant].filter((message) => !!message).map((message) => ({
|
|
137
145
|
info: {
|
|
138
146
|
id: message.id,
|
|
139
147
|
role: message.role,
|