@cortexkit/opencode-magic-context 0.42.5 → 0.43.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/README.md +6 -7
- package/dist/agents/dreamer.d.ts +7 -9
- package/dist/agents/dreamer.d.ts.map +1 -1
- package/dist/agents/hidden-agent-registrations.d.ts.map +1 -1
- package/dist/agents/magic-context-prompt.d.ts.map +1 -1
- package/dist/config/index.d.ts +10 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/live-run-config.d.ts +12 -0
- package/dist/config/live-run-config.d.ts.map +1 -0
- package/dist/config/live-snapshot.d.ts +32 -0
- package/dist/config/live-snapshot.d.ts.map +1 -0
- package/dist/config/schema/magic-context.d.ts +13 -2
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-jyj54gbe.js → conflict-warning-hook-t2vb0wnx.js} +3 -3
- package/dist/{derive-budgets-v1fkhjjr.js → derive-budgets-0sg5vp61.js} +5 -2
- package/dist/features/builtin-commands/commands.d.ts +0 -4
- package/dist/features/builtin-commands/commands.d.ts.map +1 -1
- package/dist/features/magic-context/compaction-marker.d.ts +6 -0
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +4 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-lease.d.ts +8 -0
- package/dist/features/magic-context/compartment-lease.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-storage.d.ts +21 -0
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/context-authority.d.ts +37 -3
- package/dist/features/magic-context/context-authority.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts +23 -0
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts +5 -1
- package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +48 -0
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/manual-summary.d.ts +7 -0
- package/dist/features/magic-context/dreamer/manual-summary.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/open-opencode-db.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/promote-primers.d.ts +8 -1
- package/dist/features/magic-context/dreamer/promote-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts +5 -2
- package/dist/features/magic-context/dreamer/retrospective-orphan-sweep.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +22 -13
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts +9 -0
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +3 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +7 -4
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts +53 -2
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +3 -0
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/tick-failure.d.ts +38 -0
- package/dist/features/magic-context/dreamer/tick-failure.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts +2 -0
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-identity.d.ts +1 -0
- package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +1 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding.d.ts +1 -1
- package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
- package/dist/features/magic-context/memory/memory-diagnostics.d.ts +6 -0
- package/dist/features/magic-context/memory/memory-diagnostics.d.ts.map +1 -0
- package/dist/features/magic-context/memory/memory-selection.d.ts +12 -0
- package/dist/features/magic-context/memory/memory-selection.d.ts.map +1 -0
- package/dist/features/magic-context/memory/memory-visibility.d.ts +46 -0
- package/dist/features/magic-context/memory/memory-visibility.d.ts.map +1 -0
- package/dist/features/magic-context/memory/mirror-reembed.d.ts +22 -0
- package/dist/features/magic-context/memory/mirror-reembed.d.ts.map +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts +9 -0
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts +6 -2
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
- package/dist/features/magic-context/memory/transformers-remote-host.d.ts +6 -0
- package/dist/features/magic-context/memory/transformers-remote-host.d.ts.map +1 -0
- package/dist/features/magic-context/memory/transformers-web-entry.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-rowid-map.d.ts +3 -1
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +8 -3
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +7 -1
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/message-time-backfill.d.ts +19 -0
- package/dist/features/magic-context/message-time-backfill.d.ts.map +1 -0
- package/dist/features/magic-context/migrations.d.ts +16 -0
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
- package/dist/features/magic-context/mural/storage-mural.d.ts +5 -0
- package/dist/features/magic-context/mural/storage-mural.d.ts.map +1 -1
- package/dist/features/magic-context/opencode2-relabel.d.ts +132 -0
- package/dist/features/magic-context/opencode2-relabel.d.ts.map +1 -0
- package/dist/features/magic-context/overflow-detection.d.ts +3 -0
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +1 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/protection-window.d.ts +1 -1
- package/dist/features/magic-context/protection-window.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +6 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/session-decision-calibration.d.ts +31 -0
- package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -0
- package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/shadow-backfill-state.d.ts +1 -1
- package/dist/features/magic-context/shadow-backfill-state.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts +5 -1
- package/dist/features/magic-context/smart-notes/compiler.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 +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-historian-runs.d.ts +4 -2
- package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +16 -2
- package/dist/features/magic-context/storage-meta-persisted.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-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-notes.d.ts +1 -0
- package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
- package/dist/features/magic-context/storage-replay-document.d.ts +2 -0
- package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
- package/dist/features/magic-context/storage-subagent-invocations.d.ts +1 -1
- package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +42 -4
- 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/store-generation-rebase.d.ts +95 -0
- package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -0
- package/dist/features/magic-context/subagent-token-capture.d.ts +1 -0
- package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
- package/dist/features/magic-context/tagger.d.ts +2 -0
- package/dist/features/magic-context/tagger.d.ts.map +1 -1
- package/dist/features/magic-context/tool-definition-tokens.d.ts +1 -0
- package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
- package/dist/features/magic-context/tool-owner-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts +5 -1
- package/dist/features/magic-context/user-memory/review-user-memories.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 +10 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +19 -4
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/channel2-delivery.d.ts +8 -0
- package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts +5 -4
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-off-transition.d.ts +1 -0
- package/dist/hooks/magic-context/compaction-off-transition.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-prompt.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts +3 -1
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +1 -0
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +19 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +19 -11
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +4 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/decay-render.d.ts +1 -0
- package/dist/hooks/magic-context/decay-render.d.ts.map +1 -1
- package/dist/hooks/magic-context/decision-calibration.d.ts +24 -0
- package/dist/hooks/magic-context/decision-calibration.d.ts.map +1 -0
- package/dist/hooks/magic-context/derive-budgets.d.ts +2 -0
- package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
- package/dist/hooks/magic-context/dropped-input-guard.d.ts +50 -4
- package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/embed-history-runner.d.ts +30 -0
- package/dist/hooks/magic-context/embed-history-runner.d.ts.map +1 -0
- package/dist/hooks/magic-context/emergency-drop.d.ts +13 -8
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-payloads.d.ts +2 -1
- package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts +2 -1
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +12 -4
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-no-fire-cause.d.ts +5 -0
- package/dist/hooks/magic-context/historian-no-fire-cause.d.ts.map +1 -0
- package/dist/hooks/magic-context/historian-publish-stage-logger.d.ts +3 -0
- package/dist/hooks/magic-context/historian-publish-stage-logger.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts +0 -3
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +4 -4
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/host-served-rows.d.ts +58 -0
- package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts +38 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/legacy-compartments.d.ts +20 -0
- package/dist/hooks/magic-context/legacy-compartments.d.ts.map +1 -0
- package/dist/hooks/magic-context/live-session-state.d.ts +7 -7
- package/dist/hooks/magic-context/m0-token-breakdown.d.ts +6 -0
- package/dist/hooks/magic-context/m0-token-breakdown.d.ts.map +1 -1
- package/dist/hooks/magic-context/maintenance-authority.d.ts +0 -1
- package/dist/hooks/magic-context/maintenance-authority.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts +4 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts +24 -2
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts +43 -1
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
- package/dist/hooks/magic-context/postprocess-read-cache.d.ts +8 -0
- package/dist/hooks/magic-context/postprocess-read-cache.d.ts.map +1 -0
- package/dist/hooks/magic-context/producer-window-guard.d.ts +47 -1
- package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/producer-window-test-support.d.ts +14 -0
- package/dist/hooks/magic-context/producer-window-test-support.d.ts.map +1 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +2 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +51 -10
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +8 -0
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts +6 -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 +6 -0
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +17 -39
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +51 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-refusal-recovery.d.ts +28 -0
- package/dist/hooks/magic-context/rust-refusal-recovery.d.ts.map +1 -0
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +6 -7
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +21 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +63 -0
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/tokenizer-calibration.d.ts +19 -12
- package/dist/hooks/magic-context/tokenizer-calibration.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts +52 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-sweep-policy.d.ts +50 -0
- package/dist/hooks/magic-context/tool-sweep-policy.d.ts.map +1 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +20 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts +9 -0
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +5 -3
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +44 -4
- 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-f9gem5cr.js → index-8w1skpnm.js} +85 -5
- package/dist/index-99sfbrrf.js +170 -0
- package/dist/index-9skq8m9y.js +16 -0
- package/dist/{index-3wbd8sdq.js → index-d0dh7v0f.js} +28107 -29850
- package/dist/{index-d8mgqezq.js → index-rpz2me0v.js} +133 -78
- package/dist/{index-p474rw9p.js → index-rvwvdq59.js} +1 -1
- package/dist/index-w2ety11c.js +393 -0
- package/dist/index-y5145x8k.js +619 -0
- package/dist/index-ygwdyntq.js +5407 -0
- package/dist/{index-jkrqhc7y.js → index-ykg9sdzz.js} +147 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7065 -3197
- package/dist/message-time-backfill-gzjer78y.js +108 -0
- package/dist/plugin/dream-timer.d.ts +13 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +5 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/memory-id-translation.d.ts +109 -0
- package/dist/plugin/memory-id-translation.d.ts.map +1 -0
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +10 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/rust-note-backend.d.ts +84 -0
- package/dist/plugin/rust-note-backend.d.ts.map +1 -0
- package/dist/plugin/rust-tool-backends.d.ts +1 -1
- package/dist/plugin/rust-tool-backends.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts +1 -0
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/read-session-chunk-ec3jkvhg.js +61 -0
- package/dist/{recomp-orchestrator-k20sfpm2.js → recomp-orchestrator-6akjp11f.js} +8 -8
- package/dist/{send-session-notification-xnypkxpx.js → send-session-notification-f6gwkesy.js} +2 -2
- package/dist/shared/assistant-message-extractor.d.ts +6 -0
- package/dist/shared/assistant-message-extractor.d.ts.map +1 -1
- package/dist/shared/auto-update-provenance.d.ts +9 -0
- package/dist/shared/auto-update-provenance.d.ts.map +1 -0
- package/dist/shared/conflict-detector.d.ts +14 -5
- package/dist/shared/conflict-detector.d.ts.map +1 -1
- package/dist/shared/hidden-variant-warnings.d.ts +5 -0
- package/dist/shared/hidden-variant-warnings.d.ts.map +1 -0
- package/dist/shared/host-limitations.d.ts +14 -0
- package/dist/shared/host-limitations.d.ts.map +1 -0
- package/dist/shared/keep-subagents.d.ts +1 -1
- package/dist/shared/keep-subagents.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/models-dev-cache.d.ts +1 -0
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/shared/opencode-config-dir.d.ts +52 -0
- package/dist/shared/opencode-config-dir.d.ts.map +1 -1
- package/dist/shared/opencode-db-path.d.ts +46 -2
- package/dist/shared/opencode-db-path.d.ts.map +1 -1
- package/dist/shared/prompt-surface-runtime.d.ts +6 -6
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/shared/rpc-server.d.ts +10 -0
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +64 -5
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/status-detail-text.d.ts +1 -3
- package/dist/shared/status-detail-text.d.ts.map +1 -1
- package/dist/shared/status-summary.d.ts +7 -0
- package/dist/shared/status-summary.d.ts.map +1 -1
- package/dist/shared/status-view.d.ts +229 -0
- package/dist/shared/status-view.d.ts.map +1 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/tail-hygiene-status.d.ts +8 -0
- package/dist/shared/tail-hygiene-status.d.ts.map +1 -1
- package/dist/shared/user-facing-codes.d.ts +32 -7
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/shared/window-geometry.d.ts +3 -0
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/{task-config-cv8k9y8r.js → task-config-ex4nt0q0.js} +1 -1
- package/dist/tools/ctx-expand/constants.d.ts +1 -1
- package/dist/tools/ctx-expand/constants.d.ts.map +1 -1
- package/dist/tools/ctx-expand/mode.d.ts +31 -0
- package/dist/tools/ctx-expand/mode.d.ts.map +1 -0
- package/dist/tools/ctx-expand/render.d.ts.map +1 -1
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/constants.d.ts +3 -1
- package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts +1 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/types.d.ts +2 -2
- package/dist/tools/ctx-note/constants.d.ts +1 -1
- package/dist/tools/ctx-note/constants.d.ts.map +1 -1
- package/dist/tools/ctx-note/render.d.ts +88 -0
- package/dist/tools/ctx-note/render.d.ts.map +1 -0
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/types.d.ts +1 -1
- package/dist/tools/ctx-note/types.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/constants.d.ts +1 -1
- package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
- package/dist/tools/ctx-search/constants.d.ts +1 -1
- package/dist/tools/ctx-search/constants.d.ts.map +1 -1
- package/dist/tools/ctx-search/date-range.d.ts +9 -0
- package/dist/tools/ctx-search/date-range.d.ts.map +1 -0
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/types.d.ts +3 -1
- package/dist/tools/ctx-search/types.d.ts.map +1 -1
- package/dist/tools/light-descriptions.d.ts +5 -5
- package/dist/tools/light-descriptions.d.ts.map +1 -1
- package/dist/tools/parameter-descriptions.d.ts +75 -0
- package/dist/tools/parameter-descriptions.d.ts.map +1 -0
- package/dist/transformers-node-wasm.js +1918 -826
- package/dist/transformers-web.js +1736 -636
- package/dist/{transformers.node-dpmf3wpx.js → transformers.node-3zqr6k1w.js} +4087 -2898
- package/dist/tui/data/context-db.d.ts +19 -7
- package/dist/tui/data/context-db.d.ts.map +1 -1
- package/dist/tui-compiled/data/context-db.d.ts +19 -7
- package/dist/tui-compiled/data/context-db.d.ts.map +1 -1
- package/dist/v2/fold/host-media.d.ts +36 -0
- package/dist/v2/fold/host-media.d.ts.map +1 -0
- package/dist/v2/fold/restore.d.ts +21 -1
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/hidden-completion.d.ts +114 -14
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/commands.d.ts +29 -0
- package/dist/v2/hooks/commands.d.ts.map +1 -0
- package/dist/v2/hooks/context.d.ts +58 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/deleted-session-tombstones.d.ts +10 -0
- package/dist/v2/hooks/deleted-session-tombstones.d.ts.map +1 -0
- package/dist/v2/hooks/dream-manual.d.ts +43 -0
- package/dist/v2/hooks/dream-manual.d.ts.map +1 -0
- package/dist/v2/hooks/dream-trigger.d.ts +7 -0
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +32 -0
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -0
- package/dist/v2/hooks/model-limit-cache.d.ts +19 -0
- package/dist/v2/hooks/model-limit-cache.d.ts.map +1 -0
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/provider-admission.d.ts +22 -0
- package/dist/v2/hooks/provider-admission.d.ts.map +1 -0
- package/dist/v2/hooks/rpc-live-state.d.ts +9 -0
- package/dist/v2/hooks/rpc-live-state.d.ts.map +1 -0
- package/dist/v2/hooks/store.d.ts +38 -2
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts +8 -0
- package/dist/v2/hooks/tools.d.ts.map +1 -0
- package/dist/v2/hooks/types.d.ts +157 -19
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/hooks/usage-reading.d.ts +42 -0
- package/dist/v2/hooks/usage-reading.d.ts.map +1 -0
- package/dist/v2/host-service.d.ts +65 -0
- package/dist/v2/host-service.d.ts.map +1 -0
- package/dist/v2/server.d.ts +19 -0
- package/dist/v2/server.d.ts.map +1 -1
- package/dist/v2/server.js +141849 -110533
- package/dist/v2/store-reader.d.ts +78 -6
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/tui/events.d.ts +7 -0
- package/dist/v2/tui/events.d.ts.map +1 -0
- package/dist/v2/tui/index.d.ts +33 -0
- package/dist/v2/tui/index.d.ts.map +1 -0
- package/dist/v2/tui/sidebar-mount.d.ts +40 -0
- package/dist/v2/tui/sidebar-mount.d.ts.map +1 -0
- package/dist/v2/tui/status-dialog-mount.d.ts +29 -0
- package/dist/v2/tui/status-dialog-mount.d.ts.map +1 -0
- package/dist/v2/tui/types.d.ts +148 -0
- package/dist/v2/tui/types.d.ts.map +1 -0
- package/dist/wrapup-orchestrator-5akc87gr.js +16 -0
- package/package.json +9 -7
- package/src/agents/dreamer.ts +7 -16
- package/src/agents/hidden-agent-registrations.ts +10 -22
- package/src/agents/magic-context-prompt.test.ts +29 -39
- package/src/agents/magic-context-prompt.ts +99 -122
- package/src/agents/permissions.test.ts +17 -21
- package/src/config/index.ts +39 -4
- package/src/config/live-run-config.test.ts +237 -0
- package/src/config/live-run-config.ts +80 -0
- package/src/config/live-schema-drift.test.ts +67 -0
- package/src/config/live-snapshot.test.ts +85 -0
- package/src/config/live-snapshot.ts +191 -0
- package/src/config/protected-tokens.test.ts +40 -0
- package/src/config/raw-loader.test.ts +1 -0
- package/src/config/schema/magic-context.test.ts +13 -5
- package/src/config/schema/magic-context.ts +109 -13
- package/src/features/magic-context/dreamer/task-registry.ts +137 -13
- package/src/shared/assistant-message-extractor.test.ts +21 -0
- package/src/shared/assistant-message-extractor.ts +43 -8
- package/src/shared/auto-update-provenance.ts +42 -0
- package/src/shared/child-session-teardown.test.ts +38 -3
- package/src/shared/child-session-teardown.ts +3 -3
- package/src/shared/conflict-detector.test.ts +277 -7
- package/src/shared/conflict-detector.ts +221 -80
- package/src/shared/hidden-variant-warnings.ts +21 -0
- package/src/shared/host-limitations.ts +43 -0
- package/src/shared/keep-subagents.ts +6 -6
- package/src/shared/model-suggestion-retry.test.ts +43 -0
- package/src/shared/model-suggestion-retry.ts +12 -0
- package/src/shared/models-dev-cache.test.ts +25 -0
- package/src/shared/models-dev-cache.ts +5 -0
- package/src/shared/opencode-config-dir.ts +80 -7
- package/src/shared/opencode-db-path.test.ts +174 -0
- package/src/shared/opencode-db-path.ts +193 -15
- package/src/shared/opencode-host-generation.test.ts +29 -0
- package/src/shared/prompt-surface-a1-golden.md +142 -215
- package/src/shared/prompt-surface-runtime.test.ts +20 -0
- package/src/shared/prompt-surface-runtime.ts +7 -5
- package/src/shared/rpc-server.ts +18 -0
- package/src/shared/rpc-types.ts +63 -4
- package/src/shared/status-detail-text.test.ts +52 -18
- package/src/shared/status-detail-text.ts +1 -90
- package/src/shared/status-summary.ts +37 -2
- package/src/shared/status-view.test.ts +441 -0
- package/src/shared/status-view.ts +707 -0
- package/src/shared/tag-transcript.ts +115 -16
- package/src/shared/tail-hygiene-status.ts +9 -1
- package/src/shared/user-facing-codes.test.ts +3 -4
- package/src/shared/user-facing-codes.ts +33 -8
- package/src/shared/window-geometry.test.ts +23 -5
- package/src/shared/window-geometry.ts +13 -3
- package/src/tui/data/context-db.ts +50 -15
- package/src/tui/dialogs/status-dialog-colors.test.ts +58 -0
- package/src/tui/dialogs/status-dialog.tsx +288 -0
- package/src/tui/entry.mjs +11 -1
- package/src/tui/index.tsx +7 -464
- package/src/tui/slots/sidebar-content.tsx +21 -5
- package/src/tui-compiled/data/context-db.ts +50 -15
- package/src/tui-compiled/dialogs/status-dialog.tsx +552 -0
- package/src/tui-compiled/index.tsx +43 -1025
- package/src/tui-compiled/slots/sidebar-content.tsx +173 -152
- package/src/v2/tui/__fixtures__/ga-host-theme.json +160 -0
- package/src/v2/tui/events.ts +23 -0
- package/src/v2/tui/host-contract.test.ts +251 -0
- package/src/v2/tui/index.ts +526 -0
- package/src/v2/tui/load-compiled-sidebar.d.mts +59 -0
- package/src/v2/tui/load-compiled-sidebar.mjs +24 -0
- package/src/v2/tui/load-compiled-status-dialog.d.mts +17 -0
- package/src/v2/tui/load-compiled-status-dialog.mjs +16 -0
- package/src/v2/tui/sidebar-fallback.test.ts +100 -0
- package/src/v2/tui/sidebar-mount.ts +164 -0
- package/src/v2/tui/sidebar-text.test.ts +70 -0
- package/src/v2/tui/status-dialog-fallback.test.ts +97 -0
- package/src/v2/tui/status-dialog-mount.ts +76 -0
- package/src/v2/tui/theme-mapping.test.ts +57 -0
- package/src/v2/tui/types.ts +132 -0
- package/tui.js +1 -0
- package/dist/features/magic-context/memory/memory-migration.d.ts +0 -129
- package/dist/features/magic-context/memory/memory-migration.d.ts.map +0 -1
- package/dist/hooks/magic-context/upgrade-reminder.d.ts +0 -76
- package/dist/hooks/magic-context/upgrade-reminder.d.ts.map +0 -1
- package/dist/index-1ar7b3e9.js +0 -637
- package/dist/index-4wwr6cz0.js +0 -112
- package/dist/index-avwt563y.js +0 -62
- package/dist/storage-meta-session-x3j0q9qy.js +0 -20
package/dist/index-1ar7b3e9.js
DELETED
|
@@ -1,637 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
log
|
|
3
|
-
} from "./index-qp20p2py.js";
|
|
4
|
-
import {
|
|
5
|
-
withReadOnlySessionDb
|
|
6
|
-
} from "./index-jkrqhc7y.js";
|
|
7
|
-
import {
|
|
8
|
-
piModelRefToCanonical
|
|
9
|
-
} from "./index-avwt563y.js";
|
|
10
|
-
import {
|
|
11
|
-
getHarness
|
|
12
|
-
} from "./index-4ftb5hcq.js";
|
|
13
|
-
|
|
14
|
-
// src/features/magic-context/storage-meta-session.ts
|
|
15
|
-
import { Buffer as Buffer2 } from "node:buffer";
|
|
16
|
-
|
|
17
|
-
// src/shared/write-transaction-timing.ts
|
|
18
|
-
var SLOW_WRITE_TRANSACTION_THRESHOLD_MS = 1000;
|
|
19
|
-
function logSlowWriteTransaction(site, startedAt, thresholdMs = SLOW_WRITE_TRANSACTION_THRESHOLD_MS, completedAtMs = performance.now()) {
|
|
20
|
-
try {
|
|
21
|
-
const durationMs = completedAtMs - startedAt;
|
|
22
|
-
if (durationMs < thresholdMs)
|
|
23
|
-
return;
|
|
24
|
-
log(`[magic-context] slow write transaction: site=${site} held=${durationMs.toFixed(1)}ms`);
|
|
25
|
-
} catch {}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/features/magic-context/resolve-subagent-fallback.ts
|
|
29
|
-
function resolveIsSubagentFromOpenCodeDb(sessionId) {
|
|
30
|
-
try {
|
|
31
|
-
return withReadOnlySessionDb((openCodeDb) => {
|
|
32
|
-
const row = openCodeDb.prepare("SELECT parent_id FROM session WHERE id = ?").get(sessionId);
|
|
33
|
-
if (!row)
|
|
34
|
-
return null;
|
|
35
|
-
return typeof row.parent_id === "string" && row.parent_id.length > 0;
|
|
36
|
-
});
|
|
37
|
-
} catch (error) {
|
|
38
|
-
log(`[magic-context] resolveIsSubagentFromOpenCodeDb failed for ${sessionId}:`, error);
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// src/features/magic-context/storage-meta-shared.ts
|
|
44
|
-
import { Buffer } from "node:buffer";
|
|
45
|
-
var SESSION_META_SELECT_COLUMNS = [
|
|
46
|
-
"session_id",
|
|
47
|
-
"last_response_time",
|
|
48
|
-
"cache_ttl",
|
|
49
|
-
"counter",
|
|
50
|
-
"last_nudge_tokens",
|
|
51
|
-
"last_nudge_band",
|
|
52
|
-
"last_transform_error",
|
|
53
|
-
"is_subagent",
|
|
54
|
-
"last_context_percentage",
|
|
55
|
-
"last_input_tokens",
|
|
56
|
-
"observed_safe_input_tokens",
|
|
57
|
-
"cache_alert_sent",
|
|
58
|
-
"times_execute_threshold_reached",
|
|
59
|
-
"compartment_in_progress",
|
|
60
|
-
"system_prompt_hash",
|
|
61
|
-
"system_prompt_tokens",
|
|
62
|
-
"conversation_tokens",
|
|
63
|
-
"tool_call_tokens",
|
|
64
|
-
"cleared_reasoning_through_tag",
|
|
65
|
-
"tool_reclaim_watermark",
|
|
66
|
-
"last_todo_state",
|
|
67
|
-
"cached_m0_bytes",
|
|
68
|
-
"cached_m0_mural_data_url",
|
|
69
|
-
"cached_m0_mural_hash",
|
|
70
|
-
"cached_m1_bytes",
|
|
71
|
-
"cached_m0_project_memory_epoch",
|
|
72
|
-
"cached_m0_workspace_fingerprint",
|
|
73
|
-
"cached_m0_project_user_profile_version",
|
|
74
|
-
"cached_m0_max_compartment_seq",
|
|
75
|
-
"cached_m0_max_memory_id",
|
|
76
|
-
"cached_m0_max_mutation_id",
|
|
77
|
-
"cached_m0_max_memory_mutation_id",
|
|
78
|
-
"cached_m0_project_docs_hash",
|
|
79
|
-
"cached_m0_materialized_at",
|
|
80
|
-
"cached_m0_session_facts_version",
|
|
81
|
-
"cached_m0_upgrade_state",
|
|
82
|
-
"cached_m0_system_hash",
|
|
83
|
-
"cached_m0_tool_set_hash",
|
|
84
|
-
"cached_m0_model_key",
|
|
85
|
-
"cached_m0_project_identity",
|
|
86
|
-
"last_observed_model_key",
|
|
87
|
-
"last_usage_context_limit",
|
|
88
|
-
"prior_boundary_ordinal",
|
|
89
|
-
"protected_tail_policy_version",
|
|
90
|
-
"protected_tail_drain_window_started_at",
|
|
91
|
-
"protected_tail_drain_tokens",
|
|
92
|
-
"recovery_no_eligible_head_count",
|
|
93
|
-
"force_emergency_bypass_window_start",
|
|
94
|
-
"force_emergency_bypass_used",
|
|
95
|
-
"emergency_drain_active",
|
|
96
|
-
"historian_drain_failure_at",
|
|
97
|
-
"upgrade_reminded_at",
|
|
98
|
-
"upgrade_reminder_last_sent_at",
|
|
99
|
-
"upgrade_reminder_count",
|
|
100
|
-
"pi_stable_id_scheme"
|
|
101
|
-
];
|
|
102
|
-
var META_COLUMNS = {
|
|
103
|
-
lastResponseTime: "last_response_time",
|
|
104
|
-
cacheTtl: "cache_ttl",
|
|
105
|
-
counter: "counter",
|
|
106
|
-
lastNudgeTokens: "last_nudge_tokens",
|
|
107
|
-
lastNudgeBand: "last_nudge_band",
|
|
108
|
-
lastTransformError: "last_transform_error",
|
|
109
|
-
isSubagent: "is_subagent",
|
|
110
|
-
lastContextPercentage: "last_context_percentage",
|
|
111
|
-
lastInputTokens: "last_input_tokens",
|
|
112
|
-
observedSafeInputTokens: "observed_safe_input_tokens",
|
|
113
|
-
cacheAlertSent: "cache_alert_sent",
|
|
114
|
-
timesExecuteThresholdReached: "times_execute_threshold_reached",
|
|
115
|
-
compartmentInProgress: "compartment_in_progress",
|
|
116
|
-
systemPromptHash: "system_prompt_hash",
|
|
117
|
-
systemPromptTokens: "system_prompt_tokens",
|
|
118
|
-
conversationTokens: "conversation_tokens",
|
|
119
|
-
toolCallTokens: "tool_call_tokens",
|
|
120
|
-
clearedReasoningThroughTag: "cleared_reasoning_through_tag",
|
|
121
|
-
toolReclaimWatermark: "tool_reclaim_watermark",
|
|
122
|
-
lastTodoState: "last_todo_state",
|
|
123
|
-
cachedM0Bytes: "cached_m0_bytes",
|
|
124
|
-
cachedM0MuralDataUrl: "cached_m0_mural_data_url",
|
|
125
|
-
cachedM0MuralHash: "cached_m0_mural_hash",
|
|
126
|
-
cachedM1Bytes: "cached_m1_bytes",
|
|
127
|
-
cachedM0ProjectMemoryEpoch: "cached_m0_project_memory_epoch",
|
|
128
|
-
cachedM0WorkspaceFingerprint: "cached_m0_workspace_fingerprint",
|
|
129
|
-
cachedM0ProjectUserProfileVersion: "cached_m0_project_user_profile_version",
|
|
130
|
-
cachedM0MaxCompartmentSeq: "cached_m0_max_compartment_seq",
|
|
131
|
-
cachedM0MaxMemoryId: "cached_m0_max_memory_id",
|
|
132
|
-
cachedM0MaxMutationId: "cached_m0_max_mutation_id",
|
|
133
|
-
cachedM0MaxMemoryMutationId: "cached_m0_max_memory_mutation_id",
|
|
134
|
-
cachedM0ProjectDocsHash: "cached_m0_project_docs_hash",
|
|
135
|
-
cachedM0MaterializedAt: "cached_m0_materialized_at",
|
|
136
|
-
cachedM0SessionFactsVersion: "cached_m0_session_facts_version",
|
|
137
|
-
cachedM0UpgradeState: "cached_m0_upgrade_state",
|
|
138
|
-
cachedM0SystemHash: "cached_m0_system_hash",
|
|
139
|
-
cachedM0ToolSetHash: "cached_m0_tool_set_hash",
|
|
140
|
-
cachedM0ModelKey: "cached_m0_model_key",
|
|
141
|
-
cachedM0ProjectIdentity: "cached_m0_project_identity",
|
|
142
|
-
lastObservedModelKey: "last_observed_model_key",
|
|
143
|
-
lastUsageContextLimit: "last_usage_context_limit",
|
|
144
|
-
priorBoundaryOrdinal: "prior_boundary_ordinal",
|
|
145
|
-
protectedTailPolicyVersion: "protected_tail_policy_version",
|
|
146
|
-
protectedTailDrainWindowStartedAt: "protected_tail_drain_window_started_at",
|
|
147
|
-
protectedTailDrainTokens: "protected_tail_drain_tokens",
|
|
148
|
-
recoveryNoEligibleHeadCount: "recovery_no_eligible_head_count",
|
|
149
|
-
forceEmergencyBypassWindowStart: "force_emergency_bypass_window_start",
|
|
150
|
-
forceEmergencyBypassUsed: "force_emergency_bypass_used",
|
|
151
|
-
emergencyDrainActive: "emergency_drain_active",
|
|
152
|
-
historianDrainFailureAt: "historian_drain_failure_at",
|
|
153
|
-
upgradeRemindedAt: "upgrade_reminded_at",
|
|
154
|
-
upgradeReminderLastSentAt: "upgrade_reminder_last_sent_at",
|
|
155
|
-
upgradeReminderCount: "upgrade_reminder_count",
|
|
156
|
-
piStableIdScheme: "pi_stable_id_scheme"
|
|
157
|
-
};
|
|
158
|
-
var BOOLEAN_META_KEYS = new Set(["isSubagent", "compartmentInProgress", "cacheAlertSent"]);
|
|
159
|
-
var NULL_BIND_META_KEYS = new Set([
|
|
160
|
-
"cachedM0Bytes",
|
|
161
|
-
"cachedM0MuralDataUrl",
|
|
162
|
-
"cachedM0MuralHash",
|
|
163
|
-
"cachedM1Bytes",
|
|
164
|
-
"cachedM0ProjectMemoryEpoch",
|
|
165
|
-
"cachedM0WorkspaceFingerprint",
|
|
166
|
-
"cachedM0ProjectUserProfileVersion",
|
|
167
|
-
"cachedM0MaxCompartmentSeq",
|
|
168
|
-
"cachedM0MaxMemoryId",
|
|
169
|
-
"cachedM0MaxMutationId",
|
|
170
|
-
"cachedM0MaxMemoryMutationId",
|
|
171
|
-
"cachedM0ProjectDocsHash",
|
|
172
|
-
"cachedM0MaterializedAt",
|
|
173
|
-
"cachedM0SessionFactsVersion",
|
|
174
|
-
"cachedM0UpgradeState",
|
|
175
|
-
"cachedM0ProjectIdentity",
|
|
176
|
-
"lastObservedModelKey",
|
|
177
|
-
"upgradeRemindedAt",
|
|
178
|
-
"upgradeReminderLastSentAt",
|
|
179
|
-
"piStableIdScheme"
|
|
180
|
-
]);
|
|
181
|
-
function isStringOrNull(value) {
|
|
182
|
-
return value === null || typeof value === "string";
|
|
183
|
-
}
|
|
184
|
-
function isNumberOrNull(value) {
|
|
185
|
-
return value === null || typeof value === "number";
|
|
186
|
-
}
|
|
187
|
-
function isBlobOrNull(value) {
|
|
188
|
-
return value === null || Buffer.isBuffer(value) || value instanceof Uint8Array;
|
|
189
|
-
}
|
|
190
|
-
function toBufferOrNull(value) {
|
|
191
|
-
if (value === null)
|
|
192
|
-
return null;
|
|
193
|
-
if (Buffer.isBuffer(value))
|
|
194
|
-
return value;
|
|
195
|
-
return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
196
|
-
}
|
|
197
|
-
function isSessionMetaRow(row) {
|
|
198
|
-
if (row === null || typeof row !== "object")
|
|
199
|
-
return false;
|
|
200
|
-
const r = row;
|
|
201
|
-
return typeof r.session_id === "string" && typeof r.last_response_time === "number" && isStringOrNull(r.cache_ttl) && typeof r.counter === "number" && typeof r.last_nudge_tokens === "number" && isStringOrNull(r.last_nudge_band) && isStringOrNull(r.last_transform_error) && typeof r.is_subagent === "number" && typeof r.last_context_percentage === "number" && typeof r.last_input_tokens === "number" && isNumberOrNull(r.observed_safe_input_tokens) && isNumberOrNull(r.cache_alert_sent) && isNumberOrNull(r.times_execute_threshold_reached) && isNumberOrNull(r.compartment_in_progress) && (r.system_prompt_hash === null || typeof r.system_prompt_hash === "string" || typeof r.system_prompt_hash === "number") && isNumberOrNull(r.system_prompt_tokens) && isNumberOrNull(r.conversation_tokens) && isNumberOrNull(r.tool_call_tokens) && isNumberOrNull(r.cleared_reasoning_through_tag) && isStringOrNull(r.last_todo_state) && isBlobOrNull(r.cached_m0_bytes) && isStringOrNull(r.cached_m0_mural_data_url) && isStringOrNull(r.cached_m0_mural_hash) && isBlobOrNull(r.cached_m1_bytes) && isNumberOrNull(r.cached_m0_project_memory_epoch) && isStringOrNull(r.cached_m0_workspace_fingerprint) && isNumberOrNull(r.cached_m0_project_user_profile_version) && isNumberOrNull(r.cached_m0_max_compartment_seq) && isNumberOrNull(r.cached_m0_max_memory_id) && isNumberOrNull(r.cached_m0_max_mutation_id) && isNumberOrNull(r.cached_m0_max_memory_mutation_id) && isStringOrNull(r.cached_m0_project_docs_hash) && isNumberOrNull(r.cached_m0_materialized_at) && isNumberOrNull(r.cached_m0_session_facts_version) && isStringOrNull(r.cached_m0_upgrade_state) && isStringOrNull(r.cached_m0_system_hash) && isStringOrNull(r.cached_m0_tool_set_hash) && isStringOrNull(r.cached_m0_model_key) && isStringOrNull(r.cached_m0_project_identity) && isStringOrNull(r.last_observed_model_key) && isNumberOrNull(r.last_usage_context_limit) && isNumberOrNull(r.prior_boundary_ordinal) && isNumberOrNull(r.protected_tail_policy_version) && isNumberOrNull(r.protected_tail_drain_window_started_at) && isNumberOrNull(r.protected_tail_drain_tokens) && isNumberOrNull(r.recovery_no_eligible_head_count) && isNumberOrNull(r.force_emergency_bypass_window_start) && isNumberOrNull(r.force_emergency_bypass_used) && isNumberOrNull(r.upgrade_reminded_at) && isNumberOrNull(r.upgrade_reminder_last_sent_at) && isNumberOrNull(r.upgrade_reminder_count) && isNumberOrNull(r.pi_stable_id_scheme) && isNumberOrNull(r.tool_reclaim_watermark);
|
|
202
|
-
}
|
|
203
|
-
function getDefaultSessionMeta(sessionId) {
|
|
204
|
-
return {
|
|
205
|
-
sessionId,
|
|
206
|
-
lastResponseTime: 0,
|
|
207
|
-
cacheTtl: "5m",
|
|
208
|
-
counter: 0,
|
|
209
|
-
lastNudgeTokens: 0,
|
|
210
|
-
lastNudgeBand: null,
|
|
211
|
-
lastTransformError: null,
|
|
212
|
-
isSubagent: false,
|
|
213
|
-
lastContextPercentage: 0,
|
|
214
|
-
lastInputTokens: 0,
|
|
215
|
-
observedSafeInputTokens: 0,
|
|
216
|
-
cacheAlertSent: false,
|
|
217
|
-
timesExecuteThresholdReached: 0,
|
|
218
|
-
compartmentInProgress: false,
|
|
219
|
-
systemPromptHash: "",
|
|
220
|
-
systemPromptTokens: 0,
|
|
221
|
-
conversationTokens: 0,
|
|
222
|
-
toolCallTokens: 0,
|
|
223
|
-
clearedReasoningThroughTag: 0,
|
|
224
|
-
toolReclaimWatermark: 0,
|
|
225
|
-
lastTodoState: "",
|
|
226
|
-
cachedM0Bytes: null,
|
|
227
|
-
cachedM0MuralDataUrl: null,
|
|
228
|
-
cachedM0MuralHash: null,
|
|
229
|
-
cachedM1Bytes: null,
|
|
230
|
-
cachedM0ProjectMemoryEpoch: null,
|
|
231
|
-
cachedM0WorkspaceFingerprint: null,
|
|
232
|
-
cachedM0ProjectUserProfileVersion: null,
|
|
233
|
-
cachedM0MaxCompartmentSeq: null,
|
|
234
|
-
cachedM0MaxMemoryId: null,
|
|
235
|
-
cachedM0MaxMutationId: null,
|
|
236
|
-
cachedM0MaxMemoryMutationId: null,
|
|
237
|
-
cachedM0ProjectDocsHash: null,
|
|
238
|
-
cachedM0MaterializedAt: null,
|
|
239
|
-
cachedM0SessionFactsVersion: null,
|
|
240
|
-
cachedM0UpgradeState: null,
|
|
241
|
-
cachedM0SystemHash: null,
|
|
242
|
-
cachedM0ToolSetHash: null,
|
|
243
|
-
cachedM0ModelKey: null,
|
|
244
|
-
cachedM0ProjectIdentity: null,
|
|
245
|
-
lastObservedModelKey: null,
|
|
246
|
-
lastUsageContextLimit: 0,
|
|
247
|
-
priorBoundaryOrdinal: 1,
|
|
248
|
-
protectedTailPolicyVersion: 0,
|
|
249
|
-
protectedTailDrainWindowStartedAt: 0,
|
|
250
|
-
protectedTailDrainTokens: 0,
|
|
251
|
-
recoveryNoEligibleHeadCount: 0,
|
|
252
|
-
forceEmergencyBypassWindowStart: 0,
|
|
253
|
-
forceEmergencyBypassUsed: 0,
|
|
254
|
-
upgradeRemindedAt: null,
|
|
255
|
-
upgradeReminderLastSentAt: null,
|
|
256
|
-
upgradeReminderCount: 0,
|
|
257
|
-
piStableIdScheme: null
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
function ensureSessionMetaRow(db, sessionId) {
|
|
261
|
-
const defaults = getDefaultSessionMeta(sessionId);
|
|
262
|
-
db.prepare("INSERT OR IGNORE INTO session_meta (session_id, harness, last_response_time, cache_ttl, counter, last_nudge_tokens, last_nudge_band, last_transform_error, is_subagent, last_context_percentage, last_input_tokens, observed_safe_input_tokens, cache_alert_sent, times_execute_threshold_reached, compartment_in_progress, system_prompt_hash, cleared_reasoning_through_tag) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)").run(sessionId, getHarness(), defaults.lastResponseTime, defaults.cacheTtl, defaults.counter, defaults.lastNudgeTokens, defaults.lastNudgeBand ?? "", defaults.lastTransformError ?? "", defaults.isSubagent ? 1 : 0, defaults.lastContextPercentage, defaults.lastInputTokens, defaults.observedSafeInputTokens, defaults.cacheAlertSent ? 1 : 0, defaults.timesExecuteThresholdReached, defaults.compartmentInProgress ? 1 : 0, defaults.systemPromptHash ?? "", defaults.clearedReasoningThroughTag);
|
|
263
|
-
}
|
|
264
|
-
function toSessionMeta(row) {
|
|
265
|
-
const nudgeBandRaw = typeof row.last_nudge_band === "string" ? row.last_nudge_band : "";
|
|
266
|
-
const transformErrorRaw = typeof row.last_transform_error === "string" ? row.last_transform_error : "";
|
|
267
|
-
const cacheTtlRaw = typeof row.cache_ttl === "string" && row.cache_ttl.length > 0 ? row.cache_ttl : "5m";
|
|
268
|
-
const systemPromptHashRaw = row.system_prompt_hash == null ? "" : row.system_prompt_hash;
|
|
269
|
-
const lastTodoStateRaw = typeof row.last_todo_state === "string" ? row.last_todo_state : "";
|
|
270
|
-
const numOrZero = (value) => typeof value === "number" ? value : 0;
|
|
271
|
-
const numOrNull = (value) => typeof value === "number" ? value : null;
|
|
272
|
-
const stringOrNull = (value) => typeof value === "string" ? value : null;
|
|
273
|
-
return {
|
|
274
|
-
sessionId: row.session_id,
|
|
275
|
-
lastResponseTime: row.last_response_time,
|
|
276
|
-
cacheTtl: cacheTtlRaw,
|
|
277
|
-
counter: row.counter,
|
|
278
|
-
lastNudgeTokens: row.last_nudge_tokens,
|
|
279
|
-
lastNudgeBand: nudgeBandRaw.length > 0 ? nudgeBandRaw : null,
|
|
280
|
-
lastTransformError: transformErrorRaw.length > 0 ? transformErrorRaw : null,
|
|
281
|
-
isSubagent: row.is_subagent === 1,
|
|
282
|
-
lastContextPercentage: row.last_context_percentage,
|
|
283
|
-
lastInputTokens: row.last_input_tokens,
|
|
284
|
-
observedSafeInputTokens: numOrZero(row.observed_safe_input_tokens),
|
|
285
|
-
cacheAlertSent: numOrZero(row.cache_alert_sent) === 1,
|
|
286
|
-
timesExecuteThresholdReached: numOrZero(row.times_execute_threshold_reached),
|
|
287
|
-
compartmentInProgress: row.compartment_in_progress === 1,
|
|
288
|
-
systemPromptHash: String(systemPromptHashRaw),
|
|
289
|
-
systemPromptTokens: numOrZero(row.system_prompt_tokens),
|
|
290
|
-
conversationTokens: numOrZero(row.conversation_tokens),
|
|
291
|
-
toolCallTokens: numOrZero(row.tool_call_tokens),
|
|
292
|
-
clearedReasoningThroughTag: numOrZero(row.cleared_reasoning_through_tag),
|
|
293
|
-
toolReclaimWatermark: numOrZero(row.tool_reclaim_watermark),
|
|
294
|
-
lastTodoState: lastTodoStateRaw,
|
|
295
|
-
cachedM0Bytes: toBufferOrNull(row.cached_m0_bytes),
|
|
296
|
-
cachedM0MuralDataUrl: stringOrNull(row.cached_m0_mural_data_url),
|
|
297
|
-
cachedM0MuralHash: stringOrNull(row.cached_m0_mural_hash),
|
|
298
|
-
cachedM1Bytes: toBufferOrNull(row.cached_m1_bytes),
|
|
299
|
-
cachedM0ProjectMemoryEpoch: numOrNull(row.cached_m0_project_memory_epoch),
|
|
300
|
-
cachedM0WorkspaceFingerprint: stringOrNull(row.cached_m0_workspace_fingerprint),
|
|
301
|
-
cachedM0ProjectUserProfileVersion: numOrNull(row.cached_m0_project_user_profile_version),
|
|
302
|
-
cachedM0MaxCompartmentSeq: numOrNull(row.cached_m0_max_compartment_seq),
|
|
303
|
-
cachedM0MaxMemoryId: numOrNull(row.cached_m0_max_memory_id),
|
|
304
|
-
cachedM0MaxMutationId: numOrNull(row.cached_m0_max_mutation_id),
|
|
305
|
-
cachedM0MaxMemoryMutationId: numOrNull(row.cached_m0_max_memory_mutation_id),
|
|
306
|
-
cachedM0ProjectDocsHash: stringOrNull(row.cached_m0_project_docs_hash),
|
|
307
|
-
cachedM0MaterializedAt: numOrNull(row.cached_m0_materialized_at),
|
|
308
|
-
cachedM0SessionFactsVersion: numOrNull(row.cached_m0_session_facts_version),
|
|
309
|
-
cachedM0UpgradeState: stringOrNull(row.cached_m0_upgrade_state),
|
|
310
|
-
cachedM0SystemHash: stringOrNull(row.cached_m0_system_hash),
|
|
311
|
-
cachedM0ToolSetHash: stringOrNull(row.cached_m0_tool_set_hash),
|
|
312
|
-
cachedM0ModelKey: stringOrNull(row.cached_m0_model_key),
|
|
313
|
-
cachedM0ProjectIdentity: stringOrNull(row.cached_m0_project_identity),
|
|
314
|
-
lastObservedModelKey: stringOrNull(row.last_observed_model_key),
|
|
315
|
-
lastUsageContextLimit: numOrZero(row.last_usage_context_limit),
|
|
316
|
-
priorBoundaryOrdinal: Math.max(1, numOrZero(row.prior_boundary_ordinal) || 1),
|
|
317
|
-
protectedTailPolicyVersion: numOrZero(row.protected_tail_policy_version),
|
|
318
|
-
protectedTailDrainWindowStartedAt: numOrZero(row.protected_tail_drain_window_started_at),
|
|
319
|
-
protectedTailDrainTokens: numOrZero(row.protected_tail_drain_tokens),
|
|
320
|
-
recoveryNoEligibleHeadCount: numOrZero(row.recovery_no_eligible_head_count),
|
|
321
|
-
forceEmergencyBypassWindowStart: numOrZero(row.force_emergency_bypass_window_start),
|
|
322
|
-
forceEmergencyBypassUsed: numOrZero(row.force_emergency_bypass_used),
|
|
323
|
-
upgradeRemindedAt: numOrNull(row.upgrade_reminded_at),
|
|
324
|
-
upgradeReminderLastSentAt: numOrNull(row.upgrade_reminder_last_sent_at),
|
|
325
|
-
upgradeReminderCount: numOrZero(row.upgrade_reminder_count),
|
|
326
|
-
piStableIdScheme: numOrNull(row.pi_stable_id_scheme)
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
function persistCachedM0(db, sessionId, payload) {
|
|
330
|
-
ensureSessionMetaRow(db, sessionId);
|
|
331
|
-
db.prepare(`UPDATE session_meta SET
|
|
332
|
-
cached_m0_bytes = ?,
|
|
333
|
-
cached_m0_mural_data_url = ?,
|
|
334
|
-
cached_m0_mural_hash = ?,
|
|
335
|
-
cached_m0_project_memory_epoch = ?,
|
|
336
|
-
cached_m0_workspace_fingerprint = ?,
|
|
337
|
-
cached_m0_project_user_profile_version = ?,
|
|
338
|
-
cached_m0_max_compartment_seq = ?,
|
|
339
|
-
cached_m0_max_memory_id = ?,
|
|
340
|
-
cached_m0_max_mutation_id = ?,
|
|
341
|
-
cached_m0_max_memory_mutation_id = ?,
|
|
342
|
-
cached_m1_bytes = ?,
|
|
343
|
-
cached_m0_project_docs_hash = ?,
|
|
344
|
-
cached_m0_materialized_at = ?,
|
|
345
|
-
cached_m0_session_facts_version = ?,
|
|
346
|
-
cached_m0_upgrade_state = ?,
|
|
347
|
-
cached_m0_system_hash = ?,
|
|
348
|
-
cached_m0_tool_set_hash = ?,
|
|
349
|
-
cached_m0_model_key = ?,
|
|
350
|
-
cached_m0_project_identity = ?
|
|
351
|
-
WHERE session_id = ?`).run(Buffer.from(payload.m0Bytes), payload.muralDataUrl ?? null, payload.muralHash ?? null, payload.projectMemoryEpoch, payload.workspaceFingerprint ?? null, payload.projectUserProfileVersion, payload.maxCompartmentSeq, payload.maxMemoryId, payload.maxMutationId, payload.maxMemoryMutationId ?? null, payload.m1Bytes ? Buffer.from(payload.m1Bytes) : null, payload.projectDocsHash, payload.materializedAt, payload.sessionFactsVersion, payload.upgradeState, payload.systemHash ?? "", payload.toolSetHash ?? "", payload.modelKey ? piModelRefToCanonical(payload.modelKey) : "", payload.projectIdentity ?? null, sessionId);
|
|
352
|
-
}
|
|
353
|
-
function clearCachedM0M1(db, sessionId) {
|
|
354
|
-
ensureSessionMetaRow(db, sessionId);
|
|
355
|
-
const existingColumns = new Set(db.prepare("PRAGMA table_info(session_meta)").all().map((column) => column.name));
|
|
356
|
-
const clears = [
|
|
357
|
-
["cached_m0_bytes", null],
|
|
358
|
-
["cached_m0_mural_data_url", null],
|
|
359
|
-
["cached_m0_mural_hash", null],
|
|
360
|
-
["cached_m1_bytes", null],
|
|
361
|
-
["cached_m0_project_memory_epoch", null],
|
|
362
|
-
["cached_m0_workspace_fingerprint", null],
|
|
363
|
-
["cached_m0_project_user_profile_version", null],
|
|
364
|
-
["cached_m0_max_compartment_seq", null],
|
|
365
|
-
["cached_m0_max_memory_id", null],
|
|
366
|
-
["cached_m0_max_mutation_id", null],
|
|
367
|
-
["cached_m0_max_memory_mutation_id", null],
|
|
368
|
-
["cached_m0_project_docs_hash", null],
|
|
369
|
-
["cached_m0_materialized_at", null],
|
|
370
|
-
["cached_m0_session_facts_version", null],
|
|
371
|
-
["cached_m0_upgrade_state", null],
|
|
372
|
-
["cached_m0_system_hash", null],
|
|
373
|
-
["cached_m0_tool_set_hash", null],
|
|
374
|
-
["cached_m0_model_key", null],
|
|
375
|
-
["cached_m0_project_identity", null],
|
|
376
|
-
["cached_m0_last_baseline_end_message_id", null],
|
|
377
|
-
["memory_block_cache", ""],
|
|
378
|
-
["memory_block_count", 0],
|
|
379
|
-
["memory_block_ids", ""]
|
|
380
|
-
];
|
|
381
|
-
const setClauses = [];
|
|
382
|
-
const values = [];
|
|
383
|
-
for (const [column, value] of clears) {
|
|
384
|
-
if (!existingColumns.has(column))
|
|
385
|
-
continue;
|
|
386
|
-
setClauses.push(`${column} = ?`);
|
|
387
|
-
values.push(value);
|
|
388
|
-
}
|
|
389
|
-
if (setClauses.length === 0)
|
|
390
|
-
return;
|
|
391
|
-
db.prepare(`UPDATE session_meta SET ${setClauses.join(", ")} WHERE session_id = ?`).run(...values, sessionId);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// src/features/magic-context/storage-session-tables.ts
|
|
395
|
-
var SESSION_SCOPED_TABLES = [
|
|
396
|
-
{ table: "pending_ops", harnessScoped: true },
|
|
397
|
-
{ table: "source_contents", harnessScoped: true },
|
|
398
|
-
{ table: "tool_owner_backfill_state" },
|
|
399
|
-
{ table: "tags", harnessScoped: true },
|
|
400
|
-
{ table: "session_meta", harnessScoped: true },
|
|
401
|
-
{ table: "session_projects", harnessScoped: true },
|
|
402
|
-
{ table: "compartment_chunk_embeddings", harnessScoped: true },
|
|
403
|
-
{ table: "compartments", harnessScoped: true },
|
|
404
|
-
{ table: "compression_depth", harnessScoped: true },
|
|
405
|
-
{ table: "session_facts", harnessScoped: true },
|
|
406
|
-
{ table: "compartment_state_lease" },
|
|
407
|
-
{ table: "notes", harnessScoped: true, extraPredicate: "type = 'session'" },
|
|
408
|
-
{ table: "recomp_compartments", harnessScoped: true },
|
|
409
|
-
{ table: "recomp_facts", harnessScoped: true },
|
|
410
|
-
{ table: "user_memory_candidates" },
|
|
411
|
-
{ table: "primer_candidates", harnessScoped: true },
|
|
412
|
-
{ table: "m0_mutation_log" },
|
|
413
|
-
{ table: "compartment_events", harnessScoped: true },
|
|
414
|
-
{ table: "subagent_invocations", harnessScoped: true },
|
|
415
|
-
{ table: "historian_runs", harnessScoped: true },
|
|
416
|
-
{ table: "plugin_messages" },
|
|
417
|
-
{ table: "transform_decisions", harnessScoped: true },
|
|
418
|
-
{ table: "synapse_batch_ledger" },
|
|
419
|
-
{ table: "embedding_measurement_corpus" },
|
|
420
|
-
{ table: "pending_session_cleanup", harnessScoped: true },
|
|
421
|
-
{ table: "message_history_fts" },
|
|
422
|
-
{ table: "message_fts_rowid_map" },
|
|
423
|
-
{ table: "message_history_source", harnessScoped: true },
|
|
424
|
-
{ table: "message_history_index", harnessScoped: true },
|
|
425
|
-
{ table: "lkg_slots" }
|
|
426
|
-
];
|
|
427
|
-
function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
|
|
428
|
-
if (sessionIds.length === 0)
|
|
429
|
-
return 0;
|
|
430
|
-
let deletableSessionIds = [...sessionIds];
|
|
431
|
-
if (options.rustModuleCleanupAcknowledged !== true) {
|
|
432
|
-
const placeholders = sessionIds.map(() => "?").join(", ");
|
|
433
|
-
const harnessPredicate = harness === undefined ? "" : " AND harness = ?";
|
|
434
|
-
const protectedRows = db.prepare(`SELECT session_id
|
|
435
|
-
FROM pending_session_cleanup
|
|
436
|
-
WHERE session_id IN (${placeholders})
|
|
437
|
-
AND harness LIKE '%:rust'${harnessPredicate}`).all(...sessionIds, ...harness === undefined ? [] : [`${harness}:rust`]);
|
|
438
|
-
const protectedSessionIds = new Set(protectedRows.map((row) => row.session_id));
|
|
439
|
-
deletableSessionIds = sessionIds.filter((sessionId) => !protectedSessionIds.has(sessionId));
|
|
440
|
-
}
|
|
441
|
-
if (deletableSessionIds.length === 0)
|
|
442
|
-
return 0;
|
|
443
|
-
const placeholders = deletableSessionIds.map(() => "?").join(", ");
|
|
444
|
-
for (const definition of SESSION_SCOPED_TABLES) {
|
|
445
|
-
if (definition.table === "message_history_fts") {
|
|
446
|
-
db.prepare(`DELETE FROM message_history_fts
|
|
447
|
-
WHERE rowid IN (
|
|
448
|
-
SELECT fts_rowid
|
|
449
|
-
FROM message_fts_rowid_map
|
|
450
|
-
WHERE session_id IN (${placeholders})
|
|
451
|
-
)`).run(...deletableSessionIds);
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
const predicates = [`session_id IN (${placeholders})`];
|
|
455
|
-
if (definition.extraPredicate)
|
|
456
|
-
predicates.push(definition.extraPredicate);
|
|
457
|
-
const bindHarness = harness !== undefined && definition.harnessScoped === true;
|
|
458
|
-
if (bindHarness)
|
|
459
|
-
predicates.push("harness = ?");
|
|
460
|
-
const statement = db.prepare(`DELETE FROM ${definition.table} WHERE ${predicates.join(" AND ")}`);
|
|
461
|
-
if (bindHarness)
|
|
462
|
-
statement.run(...deletableSessionIds, harness);
|
|
463
|
-
else
|
|
464
|
-
statement.run(...deletableSessionIds);
|
|
465
|
-
}
|
|
466
|
-
return deletableSessionIds.length;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// src/features/magic-context/storage-meta-session.ts
|
|
470
|
-
var SESSION_META_FALLBACK_SELECTS = {
|
|
471
|
-
cache_ttl: "'5m' AS cache_ttl",
|
|
472
|
-
last_nudge_band: "'' AS last_nudge_band",
|
|
473
|
-
last_transform_error: "'' AS last_transform_error",
|
|
474
|
-
system_prompt_hash: "'' AS system_prompt_hash",
|
|
475
|
-
last_todo_state: "'' AS last_todo_state",
|
|
476
|
-
tool_reclaim_watermark: "0 AS tool_reclaim_watermark",
|
|
477
|
-
cached_m0_bytes: "NULL AS cached_m0_bytes",
|
|
478
|
-
cached_m0_mural_data_url: "NULL AS cached_m0_mural_data_url",
|
|
479
|
-
cached_m0_mural_hash: "NULL AS cached_m0_mural_hash",
|
|
480
|
-
cached_m1_bytes: "NULL AS cached_m1_bytes",
|
|
481
|
-
cached_m0_project_memory_epoch: "NULL AS cached_m0_project_memory_epoch",
|
|
482
|
-
cached_m0_project_user_profile_version: "NULL AS cached_m0_project_user_profile_version",
|
|
483
|
-
cached_m0_max_compartment_seq: "NULL AS cached_m0_max_compartment_seq",
|
|
484
|
-
cached_m0_max_memory_id: "NULL AS cached_m0_max_memory_id",
|
|
485
|
-
cached_m0_max_mutation_id: "NULL AS cached_m0_max_mutation_id",
|
|
486
|
-
cached_m0_max_memory_mutation_id: "NULL AS cached_m0_max_memory_mutation_id",
|
|
487
|
-
cached_m0_project_docs_hash: "NULL AS cached_m0_project_docs_hash",
|
|
488
|
-
cached_m0_materialized_at: "NULL AS cached_m0_materialized_at",
|
|
489
|
-
cached_m0_session_facts_version: "NULL AS cached_m0_session_facts_version",
|
|
490
|
-
cached_m0_upgrade_state: "NULL AS cached_m0_upgrade_state",
|
|
491
|
-
cached_m0_system_hash: "NULL AS cached_m0_system_hash",
|
|
492
|
-
cached_m0_tool_set_hash: "NULL AS cached_m0_tool_set_hash",
|
|
493
|
-
cached_m0_model_key: "NULL AS cached_m0_model_key",
|
|
494
|
-
cached_m0_project_identity: "NULL AS cached_m0_project_identity",
|
|
495
|
-
last_observed_model_key: "NULL AS last_observed_model_key",
|
|
496
|
-
upgrade_reminded_at: "NULL AS upgrade_reminded_at",
|
|
497
|
-
upgrade_reminder_last_sent_at: "NULL AS upgrade_reminder_last_sent_at",
|
|
498
|
-
upgrade_reminder_count: "0 AS upgrade_reminder_count"
|
|
499
|
-
};
|
|
500
|
-
var sessionMetaSelectColumnsCache = new WeakMap;
|
|
501
|
-
function getSessionMetaSelectColumns(db) {
|
|
502
|
-
const cached = sessionMetaSelectColumnsCache.get(db);
|
|
503
|
-
if (cached !== undefined)
|
|
504
|
-
return cached;
|
|
505
|
-
const existingColumns = new Set(db.prepare("PRAGMA table_info(session_meta)").all().map((column) => column.name));
|
|
506
|
-
const projection = SESSION_META_SELECT_COLUMNS.map((column) => {
|
|
507
|
-
if (existingColumns.has(column))
|
|
508
|
-
return column;
|
|
509
|
-
return SESSION_META_FALLBACK_SELECTS[column] ?? `0 AS ${column}`;
|
|
510
|
-
}).join(", ");
|
|
511
|
-
sessionMetaSelectColumnsCache.set(db, projection);
|
|
512
|
-
return projection;
|
|
513
|
-
}
|
|
514
|
-
function getOrCreateSessionMeta2(db, sessionId) {
|
|
515
|
-
const result = db.prepare(`SELECT ${getSessionMetaSelectColumns(db)} FROM session_meta WHERE session_id = ?`).get(sessionId);
|
|
516
|
-
if (isSessionMetaRow(result)) {
|
|
517
|
-
return toSessionMeta(result);
|
|
518
|
-
}
|
|
519
|
-
const defaults = getDefaultSessionMeta(sessionId);
|
|
520
|
-
const fallbackSubagent = getHarness() === "opencode" ? resolveIsSubagentFromOpenCodeDb(sessionId) : null;
|
|
521
|
-
if (fallbackSubagent === true) {
|
|
522
|
-
defaults.isSubagent = true;
|
|
523
|
-
}
|
|
524
|
-
ensureSessionMetaRow(db, sessionId);
|
|
525
|
-
if (fallbackSubagent === true) {
|
|
526
|
-
db.prepare("UPDATE session_meta SET is_subagent = 1 WHERE session_id = ?").run(sessionId);
|
|
527
|
-
}
|
|
528
|
-
return defaults;
|
|
529
|
-
}
|
|
530
|
-
function updateSessionMeta2(db, sessionId, updates) {
|
|
531
|
-
const setClauses = [];
|
|
532
|
-
const values = [];
|
|
533
|
-
for (const [key, column] of Object.entries(META_COLUMNS)) {
|
|
534
|
-
const value = updates[key];
|
|
535
|
-
if (value === undefined)
|
|
536
|
-
continue;
|
|
537
|
-
if (value === null) {
|
|
538
|
-
setClauses.push(`${column} = ?`);
|
|
539
|
-
values.push(NULL_BIND_META_KEYS.has(key) ? null : "");
|
|
540
|
-
} else if ((key === "cachedM0Bytes" || key === "cachedM1Bytes") && value instanceof Uint8Array) {
|
|
541
|
-
setClauses.push(`${column} = ?`);
|
|
542
|
-
values.push(Buffer2.from(value.buffer, value.byteOffset, value.byteLength));
|
|
543
|
-
} else if (BOOLEAN_META_KEYS.has(key)) {
|
|
544
|
-
setClauses.push(`${column} = ?`);
|
|
545
|
-
values.push(value ? 1 : 0);
|
|
546
|
-
} else if (typeof value === "string" || typeof value === "number") {
|
|
547
|
-
setClauses.push(`${column} = ?`);
|
|
548
|
-
values.push(key === "lastObservedModelKey" && typeof value === "string" ? piModelRefToCanonical(value) : value);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
if (setClauses.length === 0) {
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
db.transaction(() => {
|
|
555
|
-
ensureSessionMetaRow(db, sessionId);
|
|
556
|
-
db.prepare(`UPDATE session_meta SET ${setClauses.join(", ")} WHERE session_id = ?`).run(...values, sessionId);
|
|
557
|
-
})();
|
|
558
|
-
}
|
|
559
|
-
function advanceToolReclaimWatermark2(db, sessionId, maxTagNumber) {
|
|
560
|
-
if (maxTagNumber <= 0)
|
|
561
|
-
return;
|
|
562
|
-
db.transaction(() => {
|
|
563
|
-
ensureSessionMetaRow(db, sessionId);
|
|
564
|
-
db.prepare("UPDATE session_meta SET tool_reclaim_watermark = MAX(COALESCE(tool_reclaim_watermark, 0), ?) WHERE session_id = ?").run(maxTagNumber, sessionId);
|
|
565
|
-
})();
|
|
566
|
-
}
|
|
567
|
-
function rustCleanupHarness() {
|
|
568
|
-
return `${getHarness()}:rust`;
|
|
569
|
-
}
|
|
570
|
-
function markSessionCleanupPending2(db, sessionId, rustModuleCleanupRequired = false) {
|
|
571
|
-
const row = db.prepare(`INSERT INTO pending_session_cleanup (session_id, harness, requested_at, last_attempt_at)
|
|
572
|
-
VALUES (?, ?, ?, NULL)
|
|
573
|
-
ON CONFLICT(session_id) DO UPDATE SET
|
|
574
|
-
harness = CASE
|
|
575
|
-
WHEN pending_session_cleanup.harness LIKE '%:rust'
|
|
576
|
-
THEN pending_session_cleanup.harness
|
|
577
|
-
ELSE excluded.harness
|
|
578
|
-
END,
|
|
579
|
-
requested_at = MIN(pending_session_cleanup.requested_at, excluded.requested_at)
|
|
580
|
-
RETURNING harness`).get(sessionId, rustModuleCleanupRequired ? rustCleanupHarness() : getHarness(), Date.now());
|
|
581
|
-
return row.harness.endsWith(":rust");
|
|
582
|
-
}
|
|
583
|
-
function retryPendingSessionCleanups2(db, limit = 200) {
|
|
584
|
-
const rows = db.prepare(`SELECT session_id
|
|
585
|
-
FROM pending_session_cleanup
|
|
586
|
-
WHERE harness NOT LIKE '%:rust'
|
|
587
|
-
ORDER BY requested_at ASC, session_id ASC
|
|
588
|
-
LIMIT ?`).all(Math.max(1, Math.floor(limit)));
|
|
589
|
-
const failedSessionIds = [];
|
|
590
|
-
let cleared = 0;
|
|
591
|
-
for (const row of rows) {
|
|
592
|
-
try {
|
|
593
|
-
db.prepare("UPDATE pending_session_cleanup SET last_attempt_at = ? WHERE session_id = ?").run(Date.now(), row.session_id);
|
|
594
|
-
clearSession2(db, row.session_id);
|
|
595
|
-
cleared += 1;
|
|
596
|
-
} catch {
|
|
597
|
-
failedSessionIds.push(row.session_id);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
return { attempted: rows.length, cleared, failedSessionIds };
|
|
601
|
-
}
|
|
602
|
-
async function retryPendingRustSessionCleanupsForProject2(db, projectPath, deleteSession, limit = 200) {
|
|
603
|
-
const harness = getHarness();
|
|
604
|
-
const rows = db.prepare(`SELECT pending.session_id
|
|
605
|
-
FROM pending_session_cleanup pending
|
|
606
|
-
JOIN session_projects projects
|
|
607
|
-
ON projects.session_id = pending.session_id
|
|
608
|
-
AND projects.harness = ?
|
|
609
|
-
WHERE pending.harness = ?
|
|
610
|
-
AND projects.project_path = ?
|
|
611
|
-
ORDER BY pending.requested_at ASC, pending.session_id ASC
|
|
612
|
-
LIMIT ?`).all(harness, rustCleanupHarness(), projectPath, Math.max(1, Math.floor(limit)));
|
|
613
|
-
const failedSessionIds = [];
|
|
614
|
-
let cleared = 0;
|
|
615
|
-
for (const row of rows) {
|
|
616
|
-
try {
|
|
617
|
-
db.prepare("UPDATE pending_session_cleanup SET last_attempt_at = ? WHERE session_id = ?").run(Date.now(), row.session_id);
|
|
618
|
-
await deleteSession(row.session_id);
|
|
619
|
-
clearSession2(db, row.session_id, true);
|
|
620
|
-
cleared += 1;
|
|
621
|
-
} catch {
|
|
622
|
-
failedSessionIds.push(row.session_id);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
return { attempted: rows.length, cleared, failedSessionIds };
|
|
626
|
-
}
|
|
627
|
-
function clearSession2(db, sessionId, rustModuleCleanupAcknowledged = false) {
|
|
628
|
-
const transactionStartedAt = performance.now();
|
|
629
|
-
db.transaction(() => {
|
|
630
|
-
deleteSessionScopedRows(db, [sessionId], undefined, {
|
|
631
|
-
rustModuleCleanupAcknowledged
|
|
632
|
-
});
|
|
633
|
-
})();
|
|
634
|
-
logSlowWriteTransaction("clear-session", transactionStartedAt);
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
export { logSlowWriteTransaction, ensureSessionMetaRow, persistCachedM0, clearCachedM0M1, SESSION_SCOPED_TABLES, deleteSessionScopedRows, getOrCreateSessionMeta2, updateSessionMeta2, advanceToolReclaimWatermark2, markSessionCleanupPending2, retryPendingSessionCleanups2, retryPendingRustSessionCleanupsForProject2, clearSession2 };
|