@cortexkit/opencode-magic-context 0.44.3 → 0.45.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/dist/agents/hidden-agent-registrations.d.ts +3 -2
- package/dist/agents/hidden-agent-registrations.d.ts.map +1 -1
- package/dist/agents/magic-context-prompt.d.ts +1 -0
- package/dist/agents/magic-context-prompt.d.ts.map +1 -1
- package/dist/agents/permissions.d.ts +8 -28
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/{announcement-n8hs7kjw.js → announcement-f75t58v9.js} +4 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/project-security.d.ts +48 -0
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/raw-loader.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +10 -7
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-hmpzxep6.js → conflict-warning-hook-5yrz2r24.js} +10 -6
- package/dist/{derive-budgets-vjmvh6pz.js → derive-budgets-a63zsm5c.js} +4 -4
- package/dist/embedding-worker.js +49 -0
- package/dist/emscripten-module-0g8f45e6.js +602 -0
- package/dist/emscripten-module-0pekdjxz.js +1532 -0
- package/dist/emscripten-module-e67xwsp3.js +503 -0
- package/dist/emscripten-module-pj1vyb44.js +4559 -0
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +23 -3
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-storage.d.ts +14 -3
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/context-store-uuid.d.ts +7 -0
- package/dist/features/magic-context/context-store-uuid.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/classify.d.ts +1 -3
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/cron.d.ts +5 -4
- package/dist/features/magic-context/dreamer/cron.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/docs-proposals.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/expire-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/idle-schedule-prune.d.ts +24 -0
- package/dist/features/magic-context/dreamer/idle-schedule-prune.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/manual-summary.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts +5 -5
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/module-apply.d.ts +4 -25
- package/dist/features/magic-context/dreamer/module-apply.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-learnings.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +5 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts +12 -5
- package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts +6 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-gates.d.ts +34 -0
- package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts +7 -5
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +10 -3
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/token-budget.d.ts +3 -0
- package/dist/features/magic-context/dreamer/token-budget.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts +2 -2
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/git-log-reader.d.ts +11 -2
- package/dist/features/magic-context/git-commits/git-log-reader.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/indexer.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/git-commits/storage-git-commits.d.ts +2 -0
- package/dist/features/magic-context/git-commits/storage-git-commits.d.ts.map +1 -1
- package/dist/features/magic-context/legacy-authority-fixture.test-support.d.ts +6 -0
- package/dist/features/magic-context/legacy-authority-fixture.test-support.d.ts.map +1 -0
- package/dist/features/magic-context/lkg-prefix-chunks.d.ts +53 -0
- package/dist/features/magic-context/lkg-prefix-chunks.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +8 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts +1 -0
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts +27 -0
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-worker.d.ts +2 -0
- package/dist/features/magic-context/memory/embedding-worker.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-worker.fixture.d.ts +2 -0
- package/dist/features/magic-context/memory/embedding-worker.fixture.d.ts.map +1 -0
- package/dist/features/magic-context/memory/memory-selection.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity-cache.d.ts +4 -3
- package/dist/features/magic-context/memory/project-identity-cache.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity.d.ts +5 -4
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/visibility.d.ts +1 -1
- package/dist/features/magic-context/memory/visibility.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-rowid-map.d.ts +14 -1
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-session-filter.d.ts +14 -0
- package/dist/features/magic-context/message-fts-session-filter.d.ts.map +1 -0
- package/dist/features/magic-context/message-index.d.ts +1 -7
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/message-time-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/migration-v94-write-split.d.ts +62 -0
- package/dist/features/magic-context/migration-v94-write-split.d.ts.map +1 -0
- package/dist/features/magic-context/migration-worker-client.d.ts +23 -0
- package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -0
- package/dist/features/magic-context/migration-worker-protocol.d.ts +30 -0
- package/dist/features/magic-context/migration-worker-protocol.d.ts.map +1 -0
- package/dist/features/magic-context/migration-worker.d.ts +2 -0
- package/dist/features/magic-context/migration-worker.d.ts.map +1 -0
- package/dist/features/magic-context/migrations.d.ts +7 -0
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/mural/render-mural.d.ts +24 -2
- package/dist/features/magic-context/mural/render-mural.d.ts.map +1 -1
- package/dist/features/magic-context/mural/render-trigger.d.ts +1 -1
- package/dist/features/magic-context/mural/render-trigger.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +18 -7
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +2 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/range-parser.d.ts +2 -3
- package/dist/features/magic-context/range-parser.d.ts.map +1 -1
- package/dist/features/magic-context/resolve-subagent-fallback.d.ts +2 -0
- package/dist/features/magic-context/resolve-subagent-fallback.d.ts.map +1 -1
- package/dist/features/magic-context/scheduler.d.ts +2 -0
- package/dist/features/magic-context/scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +7 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/session-project-storage.d.ts +10 -1
- package/dist/features/magic-context/session-project-storage.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler-prompt.d.ts +1 -1
- package/dist/features/magic-context/smart-notes/compiler-prompt.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts +4 -0
- package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/runner.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts +2 -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 +10 -8
- package/dist/features/magic-context/smart-notes/ssrf-guard.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/storage.d.ts +2 -2
- package/dist/features/magic-context/smart-notes/storage.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/types.d.ts +7 -2
- package/dist/features/magic-context/smart-notes/types.d.ts.map +1 -1
- package/dist/features/magic-context/storage-caveman-rules.d.ts +21 -0
- package/dist/features/magic-context/storage-caveman-rules.d.ts.map +1 -0
- package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
- package/dist/features/magic-context/storage-compartment-history-version.d.ts +4 -0
- package/dist/features/magic-context/storage-compartment-history-version.d.ts.map +1 -0
- package/dist/features/magic-context/storage-db.d.ts +68 -3
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-identity-merge.d.ts +6 -0
- package/dist/features/magic-context/storage-identity-merge.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +15 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts +1 -1
- package/dist/features/magic-context/storage-meta-session.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-notes.d.ts +2 -2
- package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
- package/dist/features/magic-context/storage-reasoning-removal.d.ts +30 -0
- package/dist/features/magic-context/storage-reasoning-removal.d.ts.map +1 -0
- package/dist/features/magic-context/storage-replay-document.d.ts +42 -5
- package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +7 -1
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +1 -1
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
- package/dist/features/magic-context/tag-input.d.ts +4 -0
- package/dist/features/magic-context/tag-input.d.ts.map +1 -0
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
- package/dist/features/magic-context/v22-deferred-backfill.d.ts.map +1 -1
- package/dist/ffi-3cx1cxpk.js +78 -0
- package/dist/ffi-7bqqe4cd.js +91 -0
- package/dist/ffi-7e6gryj5.js +91 -0
- package/dist/ffi-bpvkebwr.js +78 -0
- package/dist/hooks/magic-context/apply-operations.d.ts +9 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-deadline.d.ts +10 -0
- package/dist/hooks/magic-context/auto-search-deadline.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-hint.d.ts +3 -0
- package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts +3 -0
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/caveman-cleanup.d.ts +8 -1
- package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/caveman.d.ts +56 -1
- package/dist/hooks/magic-context/caveman.d.ts.map +1 -1
- package/dist/hooks/magic-context/child-session-spawn.d.ts +2 -0
- package/dist/hooks/magic-context/child-session-spawn.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-parser.d.ts +3 -3
- package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts +12 -1
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +0 -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/compartment-runner-types.d.ts +3 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +6 -0
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/degraded-pass-refusal.d.ts +35 -0
- package/dist/hooks/magic-context/degraded-pass-refusal.d.ts.map +1 -0
- package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
- package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts.map +1 -1
- package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/embed-history-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts +15 -0
- 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-resolvers.d.ts +7 -0
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts +1 -0
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +17 -0
- 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-host-runner.d.ts +5 -0
- package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts +116 -0
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -0
- package/dist/hooks/magic-context/historian-prompt.generated.d.ts +1 -1
- package/dist/hooks/magic-context/historian-prompt.generated.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-repair.d.ts +44 -0
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook.d.ts +4 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +13 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts +12 -0
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay-fit.d.ts +104 -0
- package/dist/hooks/magic-context/lkg-replay-fit.d.ts.map +1 -0
- package/dist/hooks/magic-context/lkg-replay.d.ts +64 -0
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync-timing.d.ts +1 -1
- package/dist/hooks/magic-context/module-state-sync-timing.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts +6 -68
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-tool-backends.d.ts +1 -34
- package/dist/hooks/magic-context/module-tool-backends.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts +1 -55
- 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 +2 -0
- package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
- package/dist/hooks/magic-context/pass-outcome.d.ts +59 -2
- package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
- package/dist/hooks/magic-context/producer-window-guard.d.ts +6 -0
- package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +17 -4
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts +11 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +2 -2
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/reasoning-removal.d.ts +60 -0
- package/dist/hooks/magic-context/reasoning-removal.d.ts.map +1 -0
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +1 -0
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/reference-retrieval.d.ts +1 -1
- package/dist/hooks/magic-context/reference-retrieval.d.ts.map +1 -1
- package/dist/hooks/magic-context/reply-pages.d.ts +3 -0
- package/dist/hooks/magic-context/reply-pages.d.ts.map +1 -0
- package/dist/hooks/magic-context/rust-lkg-freeze-registry.d.ts +62 -0
- package/dist/hooks/magic-context/rust-lkg-freeze-registry.d.ts.map +1 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +17 -85
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
- package/dist/hooks/magic-context/sentinel.d.ts +35 -0
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/shared-compartment-boundaries.d.ts +28 -0
- package/dist/hooks/magic-context/shared-compartment-boundaries.d.ts.map +1 -0
- package/dist/hooks/magic-context/single-store-refusal.d.ts +14 -0
- package/dist/hooks/magic-context/single-store-refusal.d.ts.map +1 -0
- package/dist/hooks/magic-context/storage-busy-refusal.d.ts +7 -0
- package/dist/hooks/magic-context/storage-busy-refusal.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/stripped-command.d.ts +1 -1
- package/dist/hooks/magic-context/stripped-command.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-injection-stripper.d.ts +7 -0
- package/dist/hooks/magic-context/system-injection-stripper.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-id-fallback.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +18 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/tokenizer-calibration.d.ts +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +1 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +38 -4
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +12 -39
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/unmanaged-over-window.d.ts +36 -0
- package/dist/hooks/magic-context/unmanaged-over-window.d.ts.map +1 -0
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts +15 -0
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts.map +1 -0
- package/dist/hooks/magic-context/user-profile-render.d.ts +3 -0
- package/dist/hooks/magic-context/user-profile-render.d.ts.map +1 -0
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/{index-yhm60r53.js → index-16ny736w.js} +13622 -28584
- package/dist/{index-q5p1aqvv.js → index-2aq21j41.js} +1208 -429
- package/dist/{index-32b096cc.js → index-2ntg5sd4.js} +6 -2
- package/dist/index-4krbw8z9.js +6034 -0
- package/dist/{index-33q7s9y2.js → index-75zjgwga.js} +61 -85
- package/dist/{index-nf9sk8sh.js → index-8fgkmxmy.js} +28 -10
- package/dist/index-a4m2b1yv.js +530 -0
- package/dist/index-anq4nn6f.js +131 -0
- package/dist/index-avwt563y.js +62 -0
- package/dist/index-bmzf7zxv.js +445 -0
- package/dist/index-e44zzy84.js +10 -0
- package/dist/index-en1k8h8m.js +244 -0
- package/dist/{index-638hf49n.js → index-f85teqck.js} +15 -6
- package/dist/index-fr2z4qy8.js +7810 -0
- package/dist/{index-kwe03yde.js → index-fzbvakh0.js} +1 -1
- package/dist/{module-asyncify-2EFITU5U-rkqjhjxd.js → index-g20jdh0p.js} +114 -105
- package/dist/index-gd5qx1j9.js +398 -0
- package/dist/{index-3bygzk2d.js → index-hybnrwq0.js} +169 -4
- package/dist/{index-jqcbs2k1.js → index-mc22ayvf.js} +24 -5
- package/dist/{index-y5145x8k.js → index-n96ag4rk.js} +15 -1
- package/dist/index-q7yesyk9.js +9118 -0
- package/dist/index-remp7e2g.js +214 -0
- package/dist/{index-7k55qm8a.js → index-sfpzqvdz.js} +8 -8
- package/dist/{index-9y5p0d50.js → index-vvtfyw1z.js} +13 -76
- package/dist/index-w9jwmntv.js +202 -0
- package/dist/{index-kr5qehbd.js → index-x23gah8c.js} +1 -1
- package/dist/{index-jdxxq8cz.js → index-x8a7jmkh.js} +6 -1
- package/dist/{index-rdsaxnf2.js → index-xgt9k6c6.js} +23 -12
- package/dist/index-y8v6yerm.js +77 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7560 -8084
- package/dist/message-time-backfill-an311pmk.js +124 -0
- package/dist/migration-worker.js +53 -0
- package/dist/{model-resolution-dxatzjde.js → model-resolution-xhfmyyvy.js} +5 -1
- package/dist/module-ES6BEMUI-3cet1pyp.js +12 -0
- package/dist/module-asyncify-2EFITU5U-c2razzd9.js +6 -0
- package/dist/plugin/boot-deadline.d.ts.map +1 -1
- package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
- package/dist/plugin/dream-timer-module-client.d.ts +1 -11
- package/dist/plugin/dream-timer-module-client.d.ts.map +1 -1
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +8 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts +20 -13
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/stale-build-notice.d.ts +16 -0
- package/dist/plugin/stale-build-notice.d.ts.map +1 -0
- package/dist/read-session-chunk-8rxs0tc9.js +84 -0
- package/dist/recomp-orchestrator-nzamtw29.js +39 -0
- package/dist/{rpc-notifications-4amf6mf4.js → rpc-notifications-3hed126v.js} +3 -1
- package/dist/{safe-notification-target-50gm9c58.js → safe-notification-target-43r8jsxw.js} +3 -3
- package/dist/send-session-notification-nqpv7cne.js +28 -0
- package/dist/shared/assistant-message-extractor.d.ts +4 -0
- package/dist/shared/assistant-message-extractor.d.ts.map +1 -1
- package/dist/shared/background-batch-drain.d.ts +8 -0
- package/dist/shared/background-batch-drain.d.ts.map +1 -0
- package/dist/{features/builtin-commands/commands.d.ts → shared/builtin-commands.d.ts} +1 -1
- package/dist/shared/builtin-commands.d.ts.map +1 -0
- package/dist/shared/embedding-activity.d.ts +13 -0
- package/dist/shared/embedding-activity.d.ts.map +1 -0
- package/dist/shared/historian-tool-expansions.d.ts +5 -0
- package/dist/shared/historian-tool-expansions.d.ts.map +1 -0
- package/dist/shared/historian-tool-template.d.ts +5 -0
- package/dist/shared/historian-tool-template.d.ts.map +1 -0
- package/dist/shared/historian-transient-error.d.ts +2 -0
- package/dist/shared/historian-transient-error.d.ts.map +1 -0
- package/dist/shared/jsonc-edit.d.ts.map +1 -1
- package/dist/shared/logger.d.ts +7 -0
- package/dist/shared/logger.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts +2 -1
- 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/off-thread-migration-clock.d.ts +38 -0
- package/dist/shared/off-thread-migration-clock.d.ts.map +1 -0
- package/dist/shared/plugin-package-version.d.ts +14 -0
- package/dist/shared/plugin-package-version.d.ts.map +1 -0
- package/dist/shared/project-directory-key.d.ts +26 -0
- package/dist/shared/project-directory-key.d.ts.map +1 -0
- package/dist/shared/prompt-async-transport.d.ts +4 -0
- package/dist/shared/prompt-async-transport.d.ts.map +1 -1
- package/dist/shared/prompt-surface-runtime.d.ts +3 -3
- package/dist/shared/provider-response-completion.d.ts +12 -0
- package/dist/shared/provider-response-completion.d.ts.map +1 -0
- package/dist/shared/redaction.d.ts.map +1 -1
- package/dist/shared/rpc-client.d.ts +23 -2
- package/dist/shared/rpc-client.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +19 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/rpc-utils.d.ts +41 -0
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/sqlite.d.ts +13 -2
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/stale-plugin-build.d.ts +21 -0
- package/dist/shared/stale-plugin-build.d.ts.map +1 -0
- package/dist/shared/status-summary.d.ts +29 -0
- package/dist/shared/status-summary.d.ts.map +1 -1
- package/dist/shared/status-view-check.d.ts +124 -0
- package/dist/shared/status-view-check.d.ts.map +1 -0
- package/dist/shared/status-view.d.ts +38 -2
- package/dist/shared/status-view.d.ts.map +1 -1
- package/dist/shared/tag-owner-id.d.ts +19 -0
- package/dist/shared/tag-owner-id.d.ts.map +1 -0
- package/dist/shared/tag-transcript.d.ts +2 -1
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/test-temp-dir.d.ts +8 -2
- package/dist/shared/test-temp-dir.d.ts.map +1 -1
- package/dist/shared/transcript.d.ts +2 -0
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/shared/user-answer.d.ts +4 -0
- package/dist/shared/user-answer.d.ts.map +1 -0
- package/dist/shared/user-facing-codes.d.ts +41 -6
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/shared/xml-unescape.d.ts +9 -0
- package/dist/shared/xml-unescape.d.ts.map +1 -0
- package/dist/task-config-v81k8jvk.js +17 -0
- 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 +4 -0
- package/dist/tools/ctx-expand/mode.d.ts.map +1 -1
- package/dist/tools/ctx-expand/render.d.ts +5 -1
- package/dist/tools/ctx-expand/render.d.ts.map +1 -1
- package/dist/tools/ctx-expand/tools.d.ts +2 -0
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/tools/ctx-expand/types.d.ts +1 -0
- package/dist/tools/ctx-expand/types.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/render.d.ts +2 -0
- package/dist/tools/ctx-note/render.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.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/light-descriptions.d.ts +3 -3
- package/dist/tools/light-descriptions.d.ts.map +1 -1
- package/dist/tools/parameter-descriptions.d.ts +14 -14
- package/dist/transform-postprocess-phase-414phndq.js +61 -0
- package/dist/tui/data/context-db.d.ts +34 -10
- package/dist/tui/data/context-db.d.ts.map +1 -1
- package/dist/tui/data/notification-socket.d.ts +6 -0
- package/dist/tui/data/notification-socket.d.ts.map +1 -1
- package/dist/tui/data/session-directory.d.ts +16 -0
- package/dist/tui/data/session-directory.d.ts.map +1 -0
- package/dist/tui-compiled/data/context-db.d.ts +34 -10
- package/dist/tui-compiled/data/context-db.d.ts.map +1 -1
- package/dist/tui-compiled/data/notification-socket.d.ts +6 -0
- package/dist/tui-compiled/data/notification-socket.d.ts.map +1 -1
- package/dist/tui-compiled/data/session-directory.d.ts +16 -0
- package/dist/tui-compiled/data/session-directory.d.ts.map +1 -0
- package/dist/v2/derive-budgets-v0krf3t7.js +18 -0
- package/dist/v2/embedding-worker.js +47 -0
- package/dist/v2/emscripten-module-0g8f45e6.js +602 -0
- package/dist/v2/emscripten-module-0pekdjxz.js +1532 -0
- package/dist/v2/emscripten-module-e67xwsp3.js +503 -0
- package/dist/v2/emscripten-module-pj1vyb44.js +4559 -0
- package/dist/v2/ffi-3cx1cxpk.js +78 -0
- package/dist/v2/ffi-7bqqe4cd.js +91 -0
- package/dist/v2/ffi-7e6gryj5.js +91 -0
- package/dist/v2/ffi-bpvkebwr.js +78 -0
- package/dist/v2/fold/boundary.d.ts.map +1 -1
- package/dist/v2/fork-inheritance.d.ts +101 -0
- package/dist/v2/fork-inheritance.d.ts.map +1 -0
- package/dist/v2/hidden-child-cleanup.d.ts +11 -0
- package/dist/v2/hidden-child-cleanup.d.ts.map +1 -0
- package/dist/v2/hidden-child-native.d.ts +29 -0
- package/dist/v2/hidden-child-native.d.ts.map +1 -0
- package/dist/v2/hidden-child-record.d.ts +135 -0
- package/dist/v2/hidden-child-record.d.ts.map +1 -0
- package/dist/v2/hidden-completion.d.ts +12 -97
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +20 -8
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/dream-manual.d.ts.map +1 -1
- package/dist/v2/hooks/dream-trigger.d.ts +5 -0
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/generate.d.ts +10 -0
- package/dist/v2/hooks/generate.d.ts.map +1 -0
- package/dist/v2/hooks/hidden-child.d.ts +33 -2
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts +3 -0
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/session-api-gate.d.ts +4 -0
- package/dist/v2/hooks/session-api-gate.d.ts.map +1 -0
- package/dist/v2/hooks/storage-gate.d.ts +3 -1
- package/dist/v2/hooks/storage-gate.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts +1 -1
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/hooks/types.d.ts +10 -0
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/hooks/update-check.d.ts.map +1 -1
- package/dist/v2/hooks/usage-persist.d.ts.map +1 -1
- package/dist/v2/hooks/usage-reading.d.ts +4 -0
- package/dist/v2/hooks/usage-reading.d.ts.map +1 -1
- package/dist/v2/index-6e4mwffh.js +5662 -0
- package/dist/v2/index-en1k8h8m.js +244 -0
- package/dist/{message-time-backfill-q374fxc5.js → v2/message-time-backfill-0n93vrd7.js} +19 -5
- package/dist/v2/migration-worker.js +52 -0
- package/dist/v2/model-resolution-xhfmyyvy.js +16 -0
- package/dist/v2/module-ES6BEMUI-3cet1pyp.js +12 -0
- package/dist/v2/module-asyncify-2EFITU5U-c2razzd9.js +6 -0
- package/dist/v2/prompt-context-5y5ms8f9.js +6 -0
- package/dist/{read-session-chunk-n072mcq4.js → v2/read-session-chunk-hjza38hr.js} +24 -7
- package/dist/v2/recomp-orchestrator-1aq7h44c.js +36 -0
- package/dist/v2/retrospective-raw-provider.d.ts +21 -0
- package/dist/v2/retrospective-raw-provider.d.ts.map +1 -0
- package/dist/v2/rpc-notifications-3hed126v.js +16 -0
- package/dist/v2/safe-notification-target-wtj0bbc2.js +9 -0
- package/dist/{send-session-notification-04hvd54c.js → v2/send-session-notification-mq9frrtm.js} +10 -5
- package/dist/v2/server-0jqw05sa.js +803 -0
- package/dist/v2/server-5317ykaf.js +40 -0
- package/dist/v2/server-a4m2b1yv.js +530 -0
- package/dist/v2/server-avwt563y.js +62 -0
- package/dist/v2/server-c4g2y1z8.js +28824 -0
- package/dist/v2/server-ckpc8pxy.js +662 -0
- package/dist/v2/server-e36nf2p1.js +7702 -0
- package/dist/v2/server-e44zzy84.js +10 -0
- package/dist/v2/server-fgmxwrgy.js +16 -0
- package/dist/v2/server-fmsr7v69.js +75 -0
- package/dist/v2/server-g20jdh0p.js +1273 -0
- package/dist/{index-dgg5y7er.js → v2/server-hfjfbg59.js} +849 -747
- package/dist/v2/server-n96ag4rk.js +633 -0
- package/dist/v2/server-qdjnb2z1.js +181 -0
- package/dist/v2/server-qpg6wf72.js +187 -0
- package/dist/v2/server-r7cmye3k.js +131 -0
- package/dist/v2/server-remp7e2g.js +214 -0
- package/dist/v2/server-rhdgxp1t.js +398 -0
- package/dist/v2/server-sfpzqvdz.js +137 -0
- package/dist/v2/server-syahy8j8.js +50 -0
- package/dist/v2/server-v5xgft5v.js +9116 -0
- package/dist/v2/server-w99cyt6a.js +361 -0
- package/dist/v2/server-x8a7jmkh.js +104 -0
- package/dist/v2/server-y8v6yerm.js +77 -0
- package/dist/v2/server-z19x7eqz.js +423 -0
- package/dist/v2/server.d.ts.map +1 -1
- package/dist/v2/server.js +8868 -107184
- package/dist/v2/store-reader.d.ts +52 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/task-config-tbndqyny.js +17 -0
- package/dist/v2/transformers-node-wasm.js +26768 -0
- package/dist/v2/transformers-web.js +25670 -0
- package/dist/v2/transformers.node-hj754h7s.js +29997 -0
- package/dist/v2/tui/index.d.ts +10 -1
- package/dist/v2/tui/index.d.ts.map +1 -1
- package/dist/v2/tui/sidebar-mount.d.ts +6 -0
- package/dist/v2/tui/sidebar-mount.d.ts.map +1 -1
- package/dist/v2/tui/status-dialog-mount.d.ts +7 -4
- package/dist/v2/tui/status-dialog-mount.d.ts.map +1 -1
- package/dist/v2/tui/types.d.ts +12 -0
- package/dist/v2/tui/types.d.ts.map +1 -1
- package/dist/v2/wrapup-orchestrator-tbyx78dz.js +425 -0
- package/dist/wrapup-orchestrator-h28bqsy6.js +26 -0
- package/package.json +8 -8
- package/src/agents/hidden-agent-registrations.ts +24 -16
- package/src/agents/magic-context-prompt.test.ts +41 -0
- package/src/agents/magic-context-prompt.ts +8 -5
- package/src/agents/permissions.test.ts +31 -49
- package/src/agents/permissions.ts +8 -28
- package/src/config/index.test.ts +60 -20
- package/src/config/index.ts +53 -1
- package/src/config/live-run-config.test.ts +5 -5
- package/src/config/live-snapshot.test.ts +4 -4
- package/src/config/migrate-config-location.test.ts +3 -10
- package/src/config/project-config-trust-boundary.test.ts +207 -0
- package/src/config/project-security.hostile-matrix.test.ts +4 -4
- package/src/config/project-security.ts +218 -1
- package/src/config/protected-tokens.test.ts +14 -9
- package/src/config/raw-loader.test.ts +31 -3
- package/src/config/raw-loader.ts +8 -3
- package/src/config/schema/magic-context.ts +20 -3
- package/src/config/variable.test.ts +3 -2
- package/src/features/magic-context/dreamer/cron.ts +30 -9
- package/src/features/magic-context/dreamer/task-registry.ts +7 -5
- package/src/shared/announcement.test.ts +2 -1
- package/src/shared/assistant-message-extractor.test.ts +27 -1
- package/src/shared/assistant-message-extractor.ts +27 -0
- package/src/shared/background-batch-drain.test.ts +38 -0
- package/src/shared/background-batch-drain.ts +29 -0
- package/src/shared/builtin-commands.ts +50 -0
- package/src/shared/console-diagnostics-fence.test.ts +145 -0
- package/src/shared/data-path.test.ts +6 -5
- package/src/shared/embedding-activity.test.ts +21 -0
- package/src/shared/embedding-activity.ts +36 -0
- package/src/shared/historian-tool-defaults.json +13 -0
- package/src/shared/historian-tool-expansions.ts +18 -0
- package/src/shared/historian-tool-template.ts +248 -0
- package/src/shared/historian-transient-error.test.ts +36 -0
- package/src/shared/historian-transient-error.ts +22 -0
- package/src/shared/jsonc-edit.ts +20 -1
- package/src/shared/logger.test.ts +3 -2
- package/src/shared/logger.ts +40 -1
- package/src/shared/model-suggestion-retry.test.ts +46 -0
- package/src/shared/model-suggestion-retry.ts +16 -1
- package/src/shared/models-dev-cache.test.ts +74 -2
- package/src/shared/models-dev-cache.ts +5 -1
- package/src/shared/off-thread-migration-clock.test.ts +55 -0
- package/src/shared/off-thread-migration-clock.ts +124 -0
- package/src/shared/opencode-db-path.test.ts +3 -2
- package/src/shared/plugin-package-version.ts +52 -0
- package/src/shared/project-directory-key.test.ts +111 -0
- package/src/shared/project-directory-key.ts +54 -0
- package/src/shared/prompt-async-transport.test.ts +249 -72
- package/src/shared/prompt-async-transport.ts +131 -24
- package/src/shared/prompt-surface-a1-golden.md +41 -25
- package/src/shared/prompt-surface-runtime.test.ts +3 -3
- package/src/shared/provider-response-completion.ts +23 -0
- package/src/shared/redaction.test.ts +51 -1
- package/src/shared/redaction.ts +33 -0
- package/src/shared/rpc-async-probes.test.ts +32 -2
- package/src/shared/rpc-client.test.ts +3 -2
- package/src/shared/rpc-client.ts +76 -18
- package/src/shared/rpc-types.ts +15 -0
- package/src/shared/rpc-utils.test.ts +191 -12
- package/src/shared/rpc-utils.ts +184 -26
- package/src/shared/sqlite-acquisition-routing.test.ts +46 -3
- package/src/shared/sqlite-pass-scope.test.ts +3 -2
- package/src/shared/sqlite-transaction-mode-guard.test.ts +4 -0
- package/src/shared/sqlite-writer-diagnostics.test.ts +134 -0
- package/src/shared/sqlite.ts +225 -41
- package/src/shared/stale-plugin-build.test.ts +129 -0
- package/src/shared/stale-plugin-build.ts +151 -0
- package/src/shared/status-summary.ts +40 -13
- package/src/shared/status-view-check.test.ts +253 -0
- package/src/shared/status-view-check.ts +536 -0
- package/src/shared/status-view.test.ts +6 -1
- package/src/shared/status-view.ts +176 -4
- package/src/shared/storage-busy.test.ts +3 -2
- package/src/shared/tag-owner-id.test.ts +33 -0
- package/src/shared/tag-owner-id.ts +29 -0
- package/src/shared/tag-transcript.ts +17 -3
- package/src/shared/test-temp-dir-policy.test.ts +33 -0
- package/src/shared/test-temp-dir.test.ts +27 -0
- package/src/shared/test-temp-dir.ts +36 -12
- package/src/shared/transcript.ts +3 -0
- package/src/shared/tui-config.test.ts +6 -5
- package/src/shared/tui-preferences.test.ts +3 -2
- package/src/shared/user-answer.test.ts +40 -0
- package/src/shared/user-answer.ts +17 -0
- package/src/shared/user-facing-codes.ts +52 -6
- package/src/shared/window-geometry.test.ts +3 -2
- package/src/shared/write-transaction-attribution.test.ts +11 -7
- package/src/shared/write-transaction-hold-clock.test.ts +160 -0
- package/src/shared/xml-unescape.ts +19 -0
- package/src/tui/data/context-db.test.ts +92 -4
- package/src/tui/data/context-db.ts +184 -18
- package/src/tui/data/notification-socket.test.ts +49 -2
- package/src/tui/data/notification-socket.ts +47 -9
- package/src/tui/data/session-directory.ts +19 -0
- package/src/tui/dialogs/status-dialog-render.test.ts +284 -0
- package/src/tui/dialogs/status-dialog.tsx +41 -38
- package/src/tui/index.tsx +30 -18
- package/src/tui/slots/sidebar-content.tsx +9 -2
- package/src/tui-compiled/data/context-db.ts +184 -18
- package/src/tui-compiled/data/notification-socket.ts +47 -9
- package/src/tui-compiled/data/session-directory.ts +19 -0
- package/src/tui-compiled/dialogs/status-dialog.tsx +38 -29
- package/src/tui-compiled/index.tsx +29 -16
- package/src/tui-compiled/slots/sidebar-content.tsx +3 -2
- package/src/v2/tui/host-contract.test.ts +9 -10
- package/src/v2/tui/index.ts +78 -23
- package/src/v2/tui/load-compiled-sidebar.d.mts +5 -1
- package/src/v2/tui/load-compiled-status-dialog.d.mts +3 -2
- package/src/v2/tui/session-directory.test.ts +53 -0
- package/src/v2/tui/sidebar-mount.ts +19 -1
- package/src/v2/tui/status-dialog-mount.ts +10 -7
- package/src/v2/tui/types.ts +10 -0
- package/dist/features/builtin-commands/commands.d.ts.map +0 -1
- package/dist/features/builtin-commands/types.d.ts +0 -3
- package/dist/features/builtin-commands/types.d.ts.map +0 -1
- package/dist/features/magic-context/context-authority.d.ts +0 -272
- package/dist/features/magic-context/context-authority.d.ts.map +0 -1
- package/dist/features/magic-context/memory/mirror-reembed.d.ts +0 -22
- package/dist/features/magic-context/memory/mirror-reembed.d.ts.map +0 -1
- package/dist/hooks/magic-context/historian-state-file.d.ts +0 -43
- package/dist/hooks/magic-context/historian-state-file.d.ts.map +0 -1
- package/dist/index-4an2p8qa.js +0 -1056
- package/dist/index-rn7gafjr.js +0 -8
- package/dist/index-v6t0tg85.js +0 -13
- package/dist/plugin/memory-id-translation.d.ts +0 -109
- package/dist/plugin/memory-id-translation.d.ts.map +0 -1
- package/dist/plugin/rust-note-backend.d.ts +0 -84
- package/dist/plugin/rust-note-backend.d.ts.map +0 -1
- package/dist/recomp-orchestrator-19tr6zya.js +0 -22
- package/dist/task-config-2bm68628.js +0 -9
- package/dist/transform-postprocess-phase-z2mfc5w1.js +0 -36
- package/dist/v2/host-service.d.ts +0 -66
- package/dist/v2/host-service.d.ts.map +0 -1
- package/dist/wrapup-orchestrator-sy4m56a7.js +0 -19
- /package/dist/{index-s70wtd8k.js → index-q6hef7fh.js} +0 -0
|
@@ -1,17 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OMO_INTERNAL_INITIATOR_MARKER,
|
|
3
|
+
isSystemDirective,
|
|
4
|
+
hasMeaningfulUserText2,
|
|
5
|
+
extractTexts2,
|
|
6
|
+
extractToolResultBodyTokens,
|
|
7
|
+
extractToolCallSummaries,
|
|
8
|
+
estimateTokens,
|
|
9
|
+
normalizeText,
|
|
10
|
+
compactRole,
|
|
11
|
+
formatBlock,
|
|
12
|
+
compactTextForSummary,
|
|
13
|
+
mergeCommitHashes
|
|
14
|
+
} from "./server-rhdgxp1t.js";
|
|
1
15
|
import {
|
|
2
16
|
getHarness
|
|
3
|
-
} from "./
|
|
17
|
+
} from "./server-ckpc8pxy.js";
|
|
18
|
+
import {
|
|
19
|
+
renderToolTemplate
|
|
20
|
+
} from "./server-remp7e2g.js";
|
|
4
21
|
import {
|
|
5
22
|
openCodeDbExists,
|
|
6
23
|
withReadOnlySessionDb,
|
|
7
24
|
getRawSessionMessageCountFromDb,
|
|
8
25
|
getMessageTimesFromOpenCodeDb
|
|
9
|
-
} from "./
|
|
26
|
+
} from "./server-w99cyt6a.js";
|
|
27
|
+
import {
|
|
28
|
+
stableStringify,
|
|
29
|
+
getLargestMeasuredToolDefinitionTokens,
|
|
30
|
+
getMeasuredToolDefinitionTokens
|
|
31
|
+
} from "./server-r7cmye3k.js";
|
|
10
32
|
import {
|
|
11
33
|
UNKNOWN_FIT_RATIO,
|
|
12
34
|
resolveDecisionCalibration,
|
|
13
35
|
providerMass
|
|
14
|
-
} from "./
|
|
36
|
+
} from "./server-n96ag4rk.js";
|
|
37
|
+
import {
|
|
38
|
+
canonicalModelIdentity
|
|
39
|
+
} from "./server-avwt563y.js";
|
|
15
40
|
|
|
16
41
|
// src/features/magic-context/reclaim-protection.ts
|
|
17
42
|
var CTX_REDUCE_KEEP = 3;
|
|
@@ -19,411 +44,14 @@ function newestCtxReduceTagNumbers(tags) {
|
|
|
19
44
|
return new Set(tags.filter((tag) => tag.toolName === "ctx_reduce").sort((left, right) => right.tagNumber - left.tagNumber).slice(0, CTX_REDUCE_KEEP).map((tag) => tag.tagNumber));
|
|
20
45
|
}
|
|
21
46
|
|
|
22
|
-
// src/hooks/magic-context/read-session-formatting.ts
|
|
23
|
-
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
24
|
-
import { createRequire } from "node:module";
|
|
25
|
-
import { homedir } from "node:os";
|
|
26
|
-
import { dirname, join, resolve } from "node:path";
|
|
27
|
-
import { pathToFileURL } from "node:url";
|
|
28
|
-
|
|
29
|
-
// src/shared/commit-detection.ts
|
|
30
|
-
var HASH_HEX = "[0-9a-f]{7,12}";
|
|
31
|
-
var COMMIT_HASH_TEST_PATTERN = new RegExp(`\\b${HASH_HEX}\\b`, "i");
|
|
32
|
-
var COMMIT_VERB_PATTERN = /\b(?:commit(?:ted|ting|s)?|cherry-?pick(?:ed|ing|s)?|merge[ds]?|merging|rebas(?:e|ed|es|ing))\b/i;
|
|
33
|
-
function textMentionsRecentCommit(text) {
|
|
34
|
-
return COMMIT_HASH_TEST_PATTERN.test(text) && COMMIT_VERB_PATTERN.test(text);
|
|
35
|
-
}
|
|
36
|
-
function createCommitHashExtractPattern() {
|
|
37
|
-
return new RegExp(`\`?\\b(${HASH_HEX})\\b\`?`, "gi");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// src/shared/internal-initiator-marker.ts
|
|
41
|
-
var OMO_INTERNAL_INITIATOR_MARKER = "<!-- OMO_INTERNAL_INITIATOR -->";
|
|
42
|
-
|
|
43
|
-
// src/shared/system-directive.ts
|
|
44
|
-
var SYSTEM_DIRECTIVE_PREFIX = "[SYSTEM DIRECTIVE: MAGIC-CONTEXT";
|
|
45
|
-
function isSystemDirective(text) {
|
|
46
|
-
return text.trimStart().startsWith(SYSTEM_DIRECTIVE_PREFIX);
|
|
47
|
-
}
|
|
48
|
-
function removeSystemReminders(text) {
|
|
49
|
-
return text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/gi, "").trim();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/hooks/magic-context/read-session-formatting.ts
|
|
53
|
-
var MAX_COMMITS_PER_BLOCK = 5;
|
|
54
|
-
function hasMeaningfulUserText2(parts) {
|
|
55
|
-
for (const part of parts) {
|
|
56
|
-
if (part === null || typeof part !== "object")
|
|
57
|
-
continue;
|
|
58
|
-
const candidate = part;
|
|
59
|
-
if (candidate.type !== "text" || typeof candidate.text !== "string")
|
|
60
|
-
continue;
|
|
61
|
-
if (candidate.ignored === true)
|
|
62
|
-
continue;
|
|
63
|
-
const cleaned = removeSystemReminders(candidate.text).replace(OMO_INTERNAL_INITIATOR_MARKER, "").trim();
|
|
64
|
-
if (!cleaned)
|
|
65
|
-
continue;
|
|
66
|
-
if (isSystemDirective(cleaned))
|
|
67
|
-
continue;
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
function extractTexts2(parts) {
|
|
73
|
-
const texts = [];
|
|
74
|
-
for (const part of parts) {
|
|
75
|
-
if (part === null || typeof part !== "object")
|
|
76
|
-
continue;
|
|
77
|
-
const p = part;
|
|
78
|
-
if (p.type === "text" && typeof p.text === "string" && p.text.trim().length > 0) {
|
|
79
|
-
texts.push(p.text.trim());
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return texts;
|
|
83
|
-
}
|
|
84
|
-
function extractToolResultBodyTokens(parts) {
|
|
85
|
-
let tokens = 0;
|
|
86
|
-
for (const part of parts) {
|
|
87
|
-
if (part === null || typeof part !== "object")
|
|
88
|
-
continue;
|
|
89
|
-
const p = part;
|
|
90
|
-
if (p.type !== "tool")
|
|
91
|
-
continue;
|
|
92
|
-
const state = p.state;
|
|
93
|
-
if (!state || typeof state !== "object")
|
|
94
|
-
continue;
|
|
95
|
-
const body = state.output ?? state.error;
|
|
96
|
-
if (body === undefined)
|
|
97
|
-
continue;
|
|
98
|
-
const text = typeof body === "string" ? body : JSON.stringify(body);
|
|
99
|
-
tokens += Math.ceil(text.length / 4);
|
|
100
|
-
}
|
|
101
|
-
return tokens;
|
|
102
|
-
}
|
|
103
|
-
function extractToolCallSummaries(parts) {
|
|
104
|
-
const summaries = [];
|
|
105
|
-
for (const part of parts) {
|
|
106
|
-
if (part === null || typeof part !== "object")
|
|
107
|
-
continue;
|
|
108
|
-
const p = part;
|
|
109
|
-
if (p.type !== "tool" || typeof p.tool !== "string")
|
|
110
|
-
continue;
|
|
111
|
-
const state = p.state;
|
|
112
|
-
if (!state || typeof state !== "object")
|
|
113
|
-
continue;
|
|
114
|
-
const input = state.input;
|
|
115
|
-
const metadata = state.metadata;
|
|
116
|
-
const description = input && typeof input.description === "string" && input.description || metadata && typeof metadata.description === "string" && metadata.description;
|
|
117
|
-
if (description) {
|
|
118
|
-
summaries.push(`TC: ${description}`);
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
const toolName = p.tool;
|
|
122
|
-
const keyArg = extractKeyArg(toolName, input);
|
|
123
|
-
summaries.push(keyArg ? `TC: ${toolName}(${keyArg})` : `TC: ${toolName}`);
|
|
124
|
-
}
|
|
125
|
-
return summaries;
|
|
126
|
-
}
|
|
127
|
-
function extractKeyArg(_toolName, input) {
|
|
128
|
-
if (!input)
|
|
129
|
-
return null;
|
|
130
|
-
if (typeof input.filePath === "string")
|
|
131
|
-
return truncateArg(input.filePath);
|
|
132
|
-
if (typeof input.path === "string")
|
|
133
|
-
return truncateArg(input.path);
|
|
134
|
-
if (typeof input.pattern === "string")
|
|
135
|
-
return truncateArg(input.pattern);
|
|
136
|
-
if (typeof input.query === "string")
|
|
137
|
-
return truncateArg(input.query);
|
|
138
|
-
if (typeof input.symbol === "string")
|
|
139
|
-
return input.symbol;
|
|
140
|
-
if (typeof input.module === "string")
|
|
141
|
-
return input.module;
|
|
142
|
-
if (typeof input.action === "string")
|
|
143
|
-
return input.action;
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
function truncateArg(value, maxLen = 60) {
|
|
147
|
-
if (value.length <= maxLen)
|
|
148
|
-
return value;
|
|
149
|
-
return `${value.slice(0, maxLen)}…`;
|
|
150
|
-
}
|
|
151
|
-
var TOKENIZER_PACKAGE_DIRS = [
|
|
152
|
-
["@cortexkit", "opencode-magic-context"],
|
|
153
|
-
["@cortexkit", "pi-magic-context"]
|
|
154
|
-
];
|
|
155
|
-
var tokenizer;
|
|
156
|
-
var tokenizerLoadAttempted = false;
|
|
157
|
-
var tokenizerLoadPromise;
|
|
158
|
-
var tokenizerWarningSent = false;
|
|
159
|
-
var tokenizerEncodingPath;
|
|
160
|
-
var tokenizerSerializedTableBytes;
|
|
161
|
-
function tokenizerPackageRoots() {
|
|
162
|
-
const cwd = process.cwd();
|
|
163
|
-
const openCodeCache = join(process.env.XDG_CACHE_HOME ?? join(homedir(), ".cache"), "opencode");
|
|
164
|
-
const roots = [cwd, openCodeCache];
|
|
165
|
-
const candidates = [];
|
|
166
|
-
for (const root of roots) {
|
|
167
|
-
for (const packageDir of TOKENIZER_PACKAGE_DIRS) {
|
|
168
|
-
candidates.push(join(root, "node_modules", ...packageDir, "node_modules", "ai-tokenizer"));
|
|
169
|
-
}
|
|
170
|
-
candidates.push(join(root, "node_modules", "ai-tokenizer"));
|
|
171
|
-
}
|
|
172
|
-
let ancestor = process.argv[1] ? dirname(resolve(process.argv[1])) : cwd;
|
|
173
|
-
while (true) {
|
|
174
|
-
candidates.push(join(ancestor, "node_modules", "ai-tokenizer"));
|
|
175
|
-
const parent = dirname(ancestor);
|
|
176
|
-
if (parent === ancestor)
|
|
177
|
-
break;
|
|
178
|
-
ancestor = parent;
|
|
179
|
-
}
|
|
180
|
-
return [...new Set(candidates)];
|
|
181
|
-
}
|
|
182
|
-
function packageImportTarget(value) {
|
|
183
|
-
if (typeof value === "string")
|
|
184
|
-
return value;
|
|
185
|
-
if (!value || typeof value !== "object")
|
|
186
|
-
return;
|
|
187
|
-
const conditions = value;
|
|
188
|
-
return packageImportTarget(conditions.import) ?? packageImportTarget(conditions.default);
|
|
189
|
-
}
|
|
190
|
-
function findTokenizerImportPaths() {
|
|
191
|
-
for (const packageRoot of tokenizerPackageRoots()) {
|
|
192
|
-
const packageJsonPath = join(packageRoot, "package.json");
|
|
193
|
-
if (!existsSync(packageJsonPath))
|
|
194
|
-
continue;
|
|
195
|
-
try {
|
|
196
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
197
|
-
const tokenizerTarget = packageImportTarget(packageJson.exports?.["."]) ?? (typeof packageJson.module === "string" ? packageJson.module : undefined) ?? (typeof packageJson.main === "string" ? packageJson.main : undefined);
|
|
198
|
-
const encodingTarget = packageImportTarget(packageJson.exports?.["./encoding/claude"]);
|
|
199
|
-
if (!tokenizerTarget || !encodingTarget)
|
|
200
|
-
continue;
|
|
201
|
-
return {
|
|
202
|
-
tokenizerPath: realpathSync(join(packageRoot, tokenizerTarget)),
|
|
203
|
-
encodingPath: realpathSync(join(packageRoot, encodingTarget))
|
|
204
|
-
};
|
|
205
|
-
} catch {}
|
|
206
|
-
}
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
function constructTokenizer(tokenizerModule, claudeEncoding) {
|
|
210
|
-
const typedModule = tokenizerModule;
|
|
211
|
-
const Tokenizer = typedModule.default ?? typedModule.Tokenizer;
|
|
212
|
-
if (!Tokenizer) {
|
|
213
|
-
throw new Error("ai-tokenizer does not expose a Tokenizer constructor");
|
|
214
|
-
}
|
|
215
|
-
return new Tokenizer(claudeEncoding);
|
|
216
|
-
}
|
|
217
|
-
function loadTokenizer() {
|
|
218
|
-
const requireFromThisModule = createRequire(import.meta.url);
|
|
219
|
-
const encodingSpecifier = "ai-tokenizer/encoding/" + "claude";
|
|
220
|
-
tokenizerEncodingPath = requireFromThisModule.resolve(encodingSpecifier);
|
|
221
|
-
tokenizerSerializedTableBytes = undefined;
|
|
222
|
-
return constructTokenizer(requireFromThisModule("ai-" + "tokenizer"), requireFromThisModule(encodingSpecifier));
|
|
223
|
-
}
|
|
224
|
-
async function loadTokenizerFromInstalledPackage() {
|
|
225
|
-
const installedPaths = findTokenizerImportPaths();
|
|
226
|
-
if (!installedPaths) {
|
|
227
|
-
throw new Error("ai-tokenizer was not found under the project, runtime, or OpenCode cache node_modules roots");
|
|
228
|
-
}
|
|
229
|
-
const [tokenizerModule, claudeEncoding] = await Promise.all([
|
|
230
|
-
import(pathToFileURL(installedPaths.tokenizerPath).href),
|
|
231
|
-
import(pathToFileURL(installedPaths.encodingPath).href)
|
|
232
|
-
]);
|
|
233
|
-
tokenizerEncodingPath = installedPaths.encodingPath;
|
|
234
|
-
tokenizerSerializedTableBytes = undefined;
|
|
235
|
-
return constructTokenizer(tokenizerModule, claudeEncoding);
|
|
236
|
-
}
|
|
237
|
-
function serializedTokenizerTableBytes(entryPath) {
|
|
238
|
-
const root = dirname(entryPath);
|
|
239
|
-
const pending = [entryPath];
|
|
240
|
-
const visited = new Set;
|
|
241
|
-
let total = 0;
|
|
242
|
-
try {
|
|
243
|
-
while (pending.length > 0) {
|
|
244
|
-
const nextPath = pending.pop();
|
|
245
|
-
if (!nextPath)
|
|
246
|
-
break;
|
|
247
|
-
const path = realpathSync(nextPath);
|
|
248
|
-
if (visited.has(path))
|
|
249
|
-
continue;
|
|
250
|
-
visited.add(path);
|
|
251
|
-
total += statSync(path).size;
|
|
252
|
-
const source = readFileSync(path, "utf8");
|
|
253
|
-
const localImports = source.matchAll(/(?:require\(|\bfrom\s+|\bimport\()\s*["'](\.\.?\/[^"']+)["']/g);
|
|
254
|
-
for (const match of localImports) {
|
|
255
|
-
const specifier = match[1];
|
|
256
|
-
if (!specifier)
|
|
257
|
-
continue;
|
|
258
|
-
const dependency = resolve(dirname(path), specifier);
|
|
259
|
-
if (dependency.startsWith(root))
|
|
260
|
-
pending.push(dependency);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return total;
|
|
264
|
-
} catch {
|
|
265
|
-
return null;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
function getTokenizerNativeMemoryStats() {
|
|
269
|
-
if (tokenizerSerializedTableBytes === undefined) {
|
|
270
|
-
tokenizerSerializedTableBytes = tokenizerEncodingPath ? serializedTokenizerTableBytes(tokenizerEncodingPath) : null;
|
|
271
|
-
}
|
|
272
|
-
return {
|
|
273
|
-
loaded: tokenizer !== undefined,
|
|
274
|
-
loadAttempted: tokenizerLoadAttempted || tokenizerLoadPromise !== undefined,
|
|
275
|
-
tableBytes: tokenizerSerializedTableBytes,
|
|
276
|
-
tablePath: tokenizerEncodingPath ?? null
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
function warnTokenizerFallback(error) {
|
|
280
|
-
if (tokenizerWarningSent)
|
|
281
|
-
return;
|
|
282
|
-
tokenizerWarningSent = true;
|
|
283
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
284
|
-
console.warn("[magic-context] ai-tokenizer is unavailable; using approximate character-based token counts for this process. Token budgets, persisted per-message counts, and protected-tail/compartment boundaries may be less accurate until restart:", reason);
|
|
285
|
-
}
|
|
286
|
-
async function preloadTokenizer() {
|
|
287
|
-
if (tokenizer)
|
|
288
|
-
return true;
|
|
289
|
-
if (tokenizerLoadAttempted)
|
|
290
|
-
return false;
|
|
291
|
-
if (tokenizerLoadPromise)
|
|
292
|
-
return tokenizerLoadPromise;
|
|
293
|
-
tokenizerLoadPromise = (async () => {
|
|
294
|
-
try {
|
|
295
|
-
try {
|
|
296
|
-
tokenizer = loadTokenizer();
|
|
297
|
-
} catch {
|
|
298
|
-
tokenizer = await loadTokenizerFromInstalledPackage();
|
|
299
|
-
}
|
|
300
|
-
tokenizerLoadAttempted = true;
|
|
301
|
-
return true;
|
|
302
|
-
} catch (error) {
|
|
303
|
-
tokenizerLoadAttempted = true;
|
|
304
|
-
warnTokenizerFallback(error);
|
|
305
|
-
return false;
|
|
306
|
-
} finally {
|
|
307
|
-
tokenizerLoadPromise = undefined;
|
|
308
|
-
}
|
|
309
|
-
})();
|
|
310
|
-
return tokenizerLoadPromise;
|
|
311
|
-
}
|
|
312
|
-
function getTokenizer() {
|
|
313
|
-
if (tokenizer || tokenizerLoadAttempted)
|
|
314
|
-
return tokenizer;
|
|
315
|
-
tokenizerLoadAttempted = true;
|
|
316
|
-
try {
|
|
317
|
-
tokenizer = loadTokenizer();
|
|
318
|
-
} catch (error) {
|
|
319
|
-
warnTokenizerFallback(error);
|
|
320
|
-
}
|
|
321
|
-
return tokenizer;
|
|
322
|
-
}
|
|
323
|
-
function estimateTokensHeuristically(text) {
|
|
324
|
-
return Math.ceil(text.length / 3.5);
|
|
325
|
-
}
|
|
326
|
-
function estimateTokens(text) {
|
|
327
|
-
if (!text)
|
|
328
|
-
return 0;
|
|
329
|
-
const activeTokenizer = getTokenizer();
|
|
330
|
-
if (!activeTokenizer)
|
|
331
|
-
return estimateTokensHeuristically(text);
|
|
332
|
-
try {
|
|
333
|
-
return activeTokenizer.encode(text, "all").length;
|
|
334
|
-
} catch (error) {
|
|
335
|
-
tokenizer = undefined;
|
|
336
|
-
tokenizerLoadAttempted = true;
|
|
337
|
-
warnTokenizerFallback(error);
|
|
338
|
-
return estimateTokensHeuristically(text);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
function normalizeText(text) {
|
|
342
|
-
return text.replace(/\s+/g, " ").trim();
|
|
343
|
-
}
|
|
344
|
-
function compactRole(role) {
|
|
345
|
-
if (role === "assistant")
|
|
346
|
-
return "A";
|
|
347
|
-
if (role === "user")
|
|
348
|
-
return "U";
|
|
349
|
-
return role.slice(0, 1).toUpperCase() || "M";
|
|
350
|
-
}
|
|
351
|
-
function formatBlock(block) {
|
|
352
|
-
const range = block.startOrdinal === block.endOrdinal ? `[${block.startOrdinal}]` : `[${block.startOrdinal}-${block.endOrdinal}]`;
|
|
353
|
-
const commitSuffix = block.commitHashes.length > 0 ? ` commits: ${block.commitHashes.join(", ")}` : "";
|
|
354
|
-
return `${range} ${block.role}:${commitSuffix} ${block.parts.join(" / ")}`;
|
|
355
|
-
}
|
|
356
|
-
function extractCommitHashes(text) {
|
|
357
|
-
const hashes = [];
|
|
358
|
-
const seen = new Set;
|
|
359
|
-
for (const match of text.matchAll(createCommitHashExtractPattern())) {
|
|
360
|
-
const hash = match[1]?.toLowerCase();
|
|
361
|
-
if (!hash || seen.has(hash))
|
|
362
|
-
continue;
|
|
363
|
-
seen.add(hash);
|
|
364
|
-
hashes.push(hash);
|
|
365
|
-
if (hashes.length >= MAX_COMMITS_PER_BLOCK)
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
return hashes;
|
|
369
|
-
}
|
|
370
|
-
function compactTextForSummary(text, role) {
|
|
371
|
-
const commitHashes = role === "assistant" ? extractCommitHashes(text) : [];
|
|
372
|
-
if (commitHashes.length === 0 || !COMMIT_VERB_PATTERN.test(text)) {
|
|
373
|
-
return { text, commitHashes };
|
|
374
|
-
}
|
|
375
|
-
const withoutHashes = text.replace(createCommitHashExtractPattern(), "").replace(/\(\s*\)/g, "").replace(/\s+,/g, ",").replace(/,\s*,+/g, ", ").replace(/\s{2,}/g, " ").replace(/\s+([,.;:])/g, "$1").trim();
|
|
376
|
-
return {
|
|
377
|
-
text: withoutHashes.length > 0 ? withoutHashes : text,
|
|
378
|
-
commitHashes
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
function mergeCommitHashes(existing, next) {
|
|
382
|
-
if (next.length === 0)
|
|
383
|
-
return existing;
|
|
384
|
-
const merged = [...existing];
|
|
385
|
-
for (const hash of next) {
|
|
386
|
-
if (merged.includes(hash))
|
|
387
|
-
continue;
|
|
388
|
-
merged.push(hash);
|
|
389
|
-
if (merged.length >= MAX_COMMITS_PER_BLOCK)
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
return merged;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
47
|
// src/hooks/magic-context/tag-content-primitives.ts
|
|
396
48
|
var encoder = new TextEncoder;
|
|
397
49
|
var TAG_PREFIX_REGEX = /^(?:§\d+§\s*)+/;
|
|
398
50
|
var MALFORMED_TAG_PREFIX_REGEX = /^(?:§\d+">§(?:\d+§)?\s*)+/;
|
|
399
|
-
var DANGLING_TAG_GLOBAL_REGEX = /\u00a7\d+(?!\.\d)[^\s\u00a7\w.]?/g;
|
|
400
51
|
var DANGLING_TAG_PREFIX_REGEX = /^(?:\u00a7\d+(?!\.\d)[^\s\u00a7\w.]?\s*)+/;
|
|
401
|
-
var COMPLETE_TAG_PAIR_GLOBAL_REGEX = /\u00a7\d+\u00a7/g;
|
|
402
|
-
var MALFORMED_TAG_GLOBAL_REGEX = /\u00a7\d+">(?:\u00a7(?:\d+\u00a7)?)?/g;
|
|
403
|
-
var STRAY_SECTION_CHAR_REGEX = /\u00a7/g;
|
|
404
52
|
function stripWellFormedLeadingTagPrefix(value) {
|
|
405
53
|
return value.replace(/^(\u00a7\d+\u00a7\s*)+/, "");
|
|
406
54
|
}
|
|
407
|
-
function stripCompleteTagPairsGlobally(value) {
|
|
408
|
-
return value.replace(COMPLETE_TAG_PAIR_GLOBAL_REGEX, "");
|
|
409
|
-
}
|
|
410
|
-
function stripMalformedTagNotationGlobally(value) {
|
|
411
|
-
return value.replace(MALFORMED_TAG_GLOBAL_REGEX, "");
|
|
412
|
-
}
|
|
413
|
-
function stripDanglingTagNotationGlobally(value) {
|
|
414
|
-
return value.replace(DANGLING_TAG_GLOBAL_REGEX, "");
|
|
415
|
-
}
|
|
416
|
-
function stripTagSectionCharacters(value) {
|
|
417
|
-
return value.replace(STRAY_SECTION_CHAR_REGEX, "");
|
|
418
|
-
}
|
|
419
|
-
function stripPersistedAssistantText(value) {
|
|
420
|
-
let text = stripWellFormedLeadingTagPrefix(value);
|
|
421
|
-
text = stripCompleteTagPairsGlobally(text);
|
|
422
|
-
text = stripMalformedTagNotationGlobally(text);
|
|
423
|
-
text = stripDanglingTagNotationGlobally(text);
|
|
424
|
-
text = stripTagSectionCharacters(text);
|
|
425
|
-
return text.trim();
|
|
426
|
-
}
|
|
427
55
|
function byteSize(value) {
|
|
428
56
|
return encoder.encode(value).length;
|
|
429
57
|
}
|
|
@@ -461,26 +89,17 @@ function isRecord(value) {
|
|
|
461
89
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
462
90
|
}
|
|
463
91
|
|
|
464
|
-
// src/shared/
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
const entries = Object.entries(value).sort(([a], [b]) => {
|
|
477
|
-
if (a < b)
|
|
478
|
-
return -1;
|
|
479
|
-
if (a > b)
|
|
480
|
-
return 1;
|
|
481
|
-
return 0;
|
|
482
|
-
});
|
|
483
|
-
return `{${entries.map(([key, child]) => `${JSON.stringify(key)}:${stableStringify(child, seen)}`).join(",")}}`;
|
|
92
|
+
// src/shared/tag-owner-id.ts
|
|
93
|
+
var POSITIONAL_CONTENT_SUFFIX = /:(?:p|file)\d+$/;
|
|
94
|
+
var CONTENT_DERIVED_TEXT_SUFFIX = /:mc-text-v1:[0-9a-f]+:[0-9a-f]+:o\d+$/;
|
|
95
|
+
function contentTagOwnerMessageId(contentId) {
|
|
96
|
+
const positional = POSITIONAL_CONTENT_SUFFIX.exec(contentId);
|
|
97
|
+
if (positional)
|
|
98
|
+
return contentId.slice(0, positional.index);
|
|
99
|
+
const derived = CONTENT_DERIVED_TEXT_SUFFIX.exec(contentId);
|
|
100
|
+
if (derived)
|
|
101
|
+
return contentId.slice(0, derived.index);
|
|
102
|
+
return contentId;
|
|
484
103
|
}
|
|
485
104
|
|
|
486
105
|
// src/hooks/magic-context/image-token-estimate.ts
|
|
@@ -506,7 +125,7 @@ function estimateImageTokensFromDataUrl(url) {
|
|
|
506
125
|
if (dims)
|
|
507
126
|
return clampImageTokens(Math.ceil(dims.w * dims.h / IMAGE_TOKEN_DIVISOR));
|
|
508
127
|
} else if (header.includes("image/jpeg") || header.includes("image/jpg")) {
|
|
509
|
-
const dims = parseJpegDimensions(bytes);
|
|
128
|
+
const dims = parseJpegDimensions(createBase64ByteReader(payload, bytes));
|
|
510
129
|
if (dims)
|
|
511
130
|
return clampImageTokens(Math.ceil(dims.w * dims.h / IMAGE_TOKEN_DIVISOR));
|
|
512
131
|
} else if (header.includes("image/webp")) {
|
|
@@ -564,21 +183,46 @@ function parsePngDimensions(b) {
|
|
|
564
183
|
return null;
|
|
565
184
|
return { w, h };
|
|
566
185
|
}
|
|
567
|
-
|
|
568
|
-
|
|
186
|
+
var READER_PREVIEW_CHARS = 512;
|
|
187
|
+
var READER_PREVIEW_BYTES = 384;
|
|
188
|
+
var READER_WINDOW_CHARS = 4096;
|
|
189
|
+
var READER_WINDOW_BYTES = 3072;
|
|
190
|
+
function createBase64ByteReader(payload, preview) {
|
|
191
|
+
const windows = new Map;
|
|
192
|
+
return (offset) => {
|
|
193
|
+
if (offset < READER_PREVIEW_BYTES)
|
|
194
|
+
return preview[offset];
|
|
195
|
+
const index = Math.floor((offset - READER_PREVIEW_BYTES) / READER_WINDOW_BYTES);
|
|
196
|
+
let window = windows.get(index);
|
|
197
|
+
if (window === undefined) {
|
|
198
|
+
const start = READER_PREVIEW_CHARS + index * READER_WINDOW_CHARS;
|
|
199
|
+
const chars = payload.slice(start, start + READER_WINDOW_CHARS);
|
|
200
|
+
try {
|
|
201
|
+
window = chars.length > 0 ? base64Decode(chars) : null;
|
|
202
|
+
} catch {
|
|
203
|
+
window = null;
|
|
204
|
+
}
|
|
205
|
+
windows.set(index, window);
|
|
206
|
+
}
|
|
207
|
+
return window?.[offset - READER_PREVIEW_BYTES - index * READER_WINDOW_BYTES];
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
var JPEG_SCAN_LIMIT_BYTES = 256 * 1024;
|
|
211
|
+
function parseJpegDimensions(byteAt) {
|
|
212
|
+
if (byteAt(0) !== 255 || byteAt(1) !== 216 || byteAt(3) === undefined)
|
|
569
213
|
return null;
|
|
570
214
|
let i = 2;
|
|
571
|
-
while (i <
|
|
572
|
-
if (
|
|
215
|
+
while (i < JPEG_SCAN_LIMIT_BYTES && byteAt(i + 8) !== undefined) {
|
|
216
|
+
if (byteAt(i) !== 255) {
|
|
573
217
|
i++;
|
|
574
218
|
continue;
|
|
575
219
|
}
|
|
576
|
-
const marker =
|
|
220
|
+
const marker = byteAt(i + 1);
|
|
577
221
|
if (marker === undefined)
|
|
578
222
|
break;
|
|
579
223
|
if (isSofMarker(marker)) {
|
|
580
|
-
const h =
|
|
581
|
-
const w =
|
|
224
|
+
const h = byteAt(i + 5) << 8 | byteAt(i + 6);
|
|
225
|
+
const w = byteAt(i + 7) << 8 | byteAt(i + 8);
|
|
582
226
|
if (w && h)
|
|
583
227
|
return { w, h };
|
|
584
228
|
return null;
|
|
@@ -587,7 +231,7 @@ function parseJpegDimensions(b) {
|
|
|
587
231
|
i += 2;
|
|
588
232
|
continue;
|
|
589
233
|
}
|
|
590
|
-
const segLen =
|
|
234
|
+
const segLen = byteAt(i + 2) << 8 | byteAt(i + 3);
|
|
591
235
|
if (segLen < 2)
|
|
592
236
|
return null;
|
|
593
237
|
i += 2 + segLen;
|
|
@@ -978,7 +622,7 @@ function toolInputText(part) {
|
|
|
978
622
|
function messageIdForTag(tag) {
|
|
979
623
|
if (tag.type === "tool")
|
|
980
624
|
return tag.toolOwnerMessageId;
|
|
981
|
-
return tag.messageId
|
|
625
|
+
return contentTagOwnerMessageId(tag.messageId);
|
|
982
626
|
}
|
|
983
627
|
function resolveProtectedTagNumbers(tags, protectedTagNumbersInput) {
|
|
984
628
|
const protectedNumbers = new Set(protectedTagNumbersInput);
|
|
@@ -1868,6 +1512,7 @@ ${body}${hintText}
|
|
|
1868
1512
|
var TARGET_FRACTION = 0.3;
|
|
1869
1513
|
var TIER_RECENCY_RESERVE = 0.2;
|
|
1870
1514
|
var EMERGENCY_REARM_MIN_TOKENS = 2000;
|
|
1515
|
+
var EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS = EMERGENCY_REARM_MIN_TOKENS;
|
|
1871
1516
|
var T1_TOOLS = new Set(["read", "todowrite", "task", "aft_outline", "aft_zoom"]);
|
|
1872
1517
|
var T2_TOOLS = new Set(["edit", "write", "apply_patch", "grep", "glob", "aft_search"]);
|
|
1873
1518
|
function normalizeToolName(toolName) {
|
|
@@ -1929,8 +1574,9 @@ function planEmergencyDrop(input) {
|
|
|
1929
1574
|
const workingSpan = Math.max(ceilingTokens - fixedFloor, 0);
|
|
1930
1575
|
const target = fixedFloor + TARGET_FRACTION * workingSpan;
|
|
1931
1576
|
const reclaimTokens = Math.round(currentTotalInputTokens - target);
|
|
1577
|
+
const floorNote = fixedFloor > ceilingTokens ? `; fixed floor ≈${Math.round(fixedFloor)} already exceeds ceiling ${Math.round(ceilingTokens)}: tool drops cannot reach the target` : "";
|
|
1932
1578
|
if (reclaimTokens <= EMERGENCY_REARM_MIN_TOKENS) {
|
|
1933
|
-
return noop(`reclaim<=min (${reclaimTokens} <= ${EMERGENCY_REARM_MIN_TOKENS})`);
|
|
1579
|
+
return noop(`reclaim<=min (${reclaimTokens} <= ${EMERGENCY_REARM_MIN_TOKENS})${floorNote}`);
|
|
1934
1580
|
}
|
|
1935
1581
|
const cutoff = input.protectedCutoff;
|
|
1936
1582
|
const windowYields = absoluteEmergency;
|
|
@@ -1985,13 +1631,16 @@ function planEmergencyDrop(input) {
|
|
|
1985
1631
|
}
|
|
1986
1632
|
}
|
|
1987
1633
|
if (selected.length === 0) {
|
|
1988
|
-
return noop(
|
|
1634
|
+
return noop(`no-candidates${floorNote}`);
|
|
1635
|
+
}
|
|
1636
|
+
if (!input.passAlreadyPriced && reclaimed < EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS) {
|
|
1637
|
+
return noop(`achievable reclaim below minimum (${selected.length} tags, reclaim≈${Math.round(reclaimed)} < ${EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS} against gap ${reclaimTokens})${floorNote}`);
|
|
1989
1638
|
}
|
|
1990
1639
|
return {
|
|
1991
1640
|
shouldDrop: true,
|
|
1992
1641
|
tagNumbers: selected,
|
|
1993
1642
|
reclaimTokens,
|
|
1994
|
-
reason: `tiered drop: ${selected.length} tags, reclaim≈${reclaimed}/${reclaimTokens} tokens (floor≈${fixedFloor}, ceiling=${Math.round(ceilingTokens)})`
|
|
1643
|
+
reason: `tiered drop: ${selected.length} tags, reclaim≈${reclaimed}/${reclaimTokens} tokens (floor≈${fixedFloor}, ceiling=${Math.round(ceilingTokens)})${floorNote}`
|
|
1995
1644
|
};
|
|
1996
1645
|
}
|
|
1997
1646
|
function measureEmergencyTag(tag, target, calibration, skeleton) {
|
|
@@ -2045,14 +1694,13 @@ function getUpdateTagDropModeStatement(db) {
|
|
|
2045
1694
|
}
|
|
2046
1695
|
var updateTagByteSizeStatements = new WeakMap;
|
|
2047
1696
|
var updateTagInputByteSizeStatements = new WeakMap;
|
|
2048
|
-
var CONTENT_ID_SUFFIX = /:(?:p|file)\d+$/;
|
|
2049
1697
|
var RECENT_OWNER_SCAN_PAGE_SIZE = 128;
|
|
2050
1698
|
var recentTagOwnerStatements = new WeakMap;
|
|
2051
1699
|
function ownerMessageIdForTagRow(row) {
|
|
2052
1700
|
if (row.type === "tool") {
|
|
2053
1701
|
return row.tool_owner_message_id ?? row.message_id;
|
|
2054
1702
|
}
|
|
2055
|
-
return row.message_id
|
|
1703
|
+
return contentTagOwnerMessageId(row.message_id);
|
|
2056
1704
|
}
|
|
2057
1705
|
function getRecentTagOwnerStatement(db) {
|
|
2058
1706
|
let statement = recentTagOwnerStatements.get(db);
|
|
@@ -2077,7 +1725,7 @@ function getRecentTagOwnerMessageIds(db, sessionId, maxOwners) {
|
|
|
2077
1725
|
for (const row of rows) {
|
|
2078
1726
|
if (typeof row.type !== "string" || typeof row.message_id !== "string")
|
|
2079
1727
|
continue;
|
|
2080
|
-
const ownerId = row.type === "tool" ? typeof row.tool_owner_message_id === "string" ? row.tool_owner_message_id : null : row.message_id
|
|
1728
|
+
const ownerId = row.type === "tool" ? typeof row.tool_owner_message_id === "string" ? row.tool_owner_message_id : null : contentTagOwnerMessageId(row.message_id);
|
|
2081
1729
|
if (!ownerId || recent.has(ownerId))
|
|
2082
1730
|
continue;
|
|
2083
1731
|
recent.add(ownerId);
|
|
@@ -2243,22 +1891,6 @@ function getUpdateTagMessageIdStatement(db) {
|
|
|
2243
1891
|
}
|
|
2244
1892
|
return stmt;
|
|
2245
1893
|
}
|
|
2246
|
-
function getTagNumbersByMessageIdStatement(db) {
|
|
2247
|
-
let stmt = getTagNumbersByMessageIdStatements.get(db);
|
|
2248
|
-
if (!stmt) {
|
|
2249
|
-
stmt = db.prepare("SELECT tag_number FROM tags WHERE session_id = ? AND (message_id = ? OR message_id LIKE ? ESCAPE '\\' OR message_id LIKE ? ESCAPE '\\') ORDER BY tag_number ASC");
|
|
2250
|
-
getTagNumbersByMessageIdStatements.set(db, stmt);
|
|
2251
|
-
}
|
|
2252
|
-
return stmt;
|
|
2253
|
-
}
|
|
2254
|
-
function getDeleteTagsByMessageIdStatement(db) {
|
|
2255
|
-
let stmt = deleteTagsByMessageIdStatements.get(db);
|
|
2256
|
-
if (!stmt) {
|
|
2257
|
-
stmt = db.prepare("DELETE FROM tags WHERE session_id = ? AND (message_id = ? OR message_id LIKE ? ESCAPE '\\' OR message_id LIKE ? ESCAPE '\\')");
|
|
2258
|
-
deleteTagsByMessageIdStatements.set(db, stmt);
|
|
2259
|
-
}
|
|
2260
|
-
return stmt;
|
|
2261
|
-
}
|
|
2262
1894
|
function getMaxTagNumberBySessionStatement(db) {
|
|
2263
1895
|
let stmt = getMaxTagNumberBySessionStatements.get(db);
|
|
2264
1896
|
if (!stmt) {
|
|
@@ -2332,9 +1964,6 @@ function isMaxTagNumberRow(row) {
|
|
|
2332
1964
|
const r = row;
|
|
2333
1965
|
return typeof r.max_tag_number === "number";
|
|
2334
1966
|
}
|
|
2335
|
-
function escapeLikePattern(value) {
|
|
2336
|
-
return value.replaceAll("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_");
|
|
2337
|
-
}
|
|
2338
1967
|
function insertTag(db, sessionId, messageId, type, byteSize, tagNumber, reasoningByteSize = 0, toolName = null, inputByteSize = 0, toolOwnerMessageId = null, entryFingerprint = null, tokenCounts = null) {
|
|
2339
1968
|
getInsertTagStatement(db).run(sessionId, messageId, type, byteSize, reasoningByteSize, tagNumber, toolName, inputByteSize, getHarness(), toolOwnerMessageId, entryFingerprint, tokenCounts?.tokenCount ?? null, tokenCounts?.inputTokenCount ?? null, tokenCounts?.reasoningTokenCount ?? null);
|
|
2340
1969
|
return tagNumber;
|
|
@@ -2349,7 +1978,21 @@ function markWhitespaceAssistantTagInert(db, sessionId, tagNumber, contentId) {
|
|
|
2349
1978
|
entry_fingerprint = ?
|
|
2350
1979
|
WHERE session_id = ? AND tag_number = ? AND type = 'message'`).run(`${WHITESPACE_ASSISTANT_INERT_MESSAGE_PREFIX}${tagNumber}`, `${WHITESPACE_ASSISTANT_INERT_FINGERPRINT_PREFIX}${contentId}`, sessionId, tagNumber);
|
|
2351
1980
|
}
|
|
2352
|
-
function getInertWhitespaceAssistantTags(db, sessionId) {
|
|
1981
|
+
function getInertWhitespaceAssistantTags(db, sessionId, messageIds) {
|
|
1982
|
+
if (messageIds) {
|
|
1983
|
+
const statement = db.prepare(`SELECT tag_number AS tagNumber, entry_fingerprint AS entryFingerprint
|
|
1984
|
+
FROM tags
|
|
1985
|
+
WHERE session_id = ? AND type = 'message' AND status = 'compacted'
|
|
1986
|
+
AND entry_fingerprint >= ? AND entry_fingerprint < ?`);
|
|
1987
|
+
return [...new Set(messageIds)].flatMap((messageId) => {
|
|
1988
|
+
const prefix = `${WHITESPACE_ASSISTANT_INERT_FINGERPRINT_PREFIX}${messageId}:p`;
|
|
1989
|
+
const rows = statement.all(sessionId, prefix, `${prefix.slice(0, -1)}q`);
|
|
1990
|
+
return rows.map((row) => ({
|
|
1991
|
+
tagNumber: row.tagNumber,
|
|
1992
|
+
contentId: row.entryFingerprint.slice(WHITESPACE_ASSISTANT_INERT_FINGERPRINT_PREFIX.length)
|
|
1993
|
+
}));
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
2353
1996
|
const rows = db.prepare(`SELECT tag_number AS tagNumber, entry_fingerprint AS entryFingerprint
|
|
2354
1997
|
FROM tags
|
|
2355
1998
|
WHERE session_id = ?
|
|
@@ -2452,9 +2095,10 @@ function deleteFoldedDuplicateTag(db, sessionId, tagNumber) {
|
|
|
2452
2095
|
foldStatement(db, "DELETE FROM tags WHERE session_id = ? AND tag_number = ?").run(sessionId, tagNumber);
|
|
2453
2096
|
foldStatement(db, "DELETE FROM pending_ops WHERE session_id = ? AND tag_id = ?").run(sessionId, tagNumber);
|
|
2454
2097
|
}
|
|
2455
|
-
function foldDuplicateIntoSurvivor(db, sessionId, survivor, duplicate, duplicateMayHaveQueuedOps = true) {
|
|
2098
|
+
function foldDuplicateIntoSurvivor(db, sessionId, survivor, duplicate, duplicateMayHaveQueuedOps = true, propagateDroppedStatus = true) {
|
|
2456
2099
|
mergeSizeAndTokenColumnsIntoSurvivor(db, sessionId, survivor, duplicate);
|
|
2457
|
-
|
|
2100
|
+
if (propagateDroppedStatus)
|
|
2101
|
+
applyDroppedStatusIfNeeded(db, sessionId, survivor, duplicate);
|
|
2458
2102
|
if (duplicateMayHaveQueuedOps) {
|
|
2459
2103
|
retargetPendingOps(db, sessionId, duplicate.tagNumber, survivor.tagNumber);
|
|
2460
2104
|
}
|
|
@@ -2549,7 +2193,7 @@ function foldShrunkPartTags(db, sessionId, messages) {
|
|
|
2549
2193
|
for (const orphan of orphans) {
|
|
2550
2194
|
if (orphan.tagNumber === survivor.tagNumber)
|
|
2551
2195
|
continue;
|
|
2552
|
-
foldDuplicateIntoSurvivor(db, sessionId, survivor, orphan, queuedTags.any.has(orphan.tagNumber));
|
|
2196
|
+
foldDuplicateIntoSurvivor(db, sessionId, survivor, orphan, queuedTags.any.has(orphan.tagNumber), false);
|
|
2553
2197
|
result.foldedTagNumbers.push(orphan.tagNumber);
|
|
2554
2198
|
}
|
|
2555
2199
|
}
|
|
@@ -2558,56 +2202,69 @@ function foldShrunkPartTags(db, sessionId, messages) {
|
|
|
2558
2202
|
return result;
|
|
2559
2203
|
}
|
|
2560
2204
|
function markTagsCompactedByMessageIds(db, sessionId, messageIds) {
|
|
2561
|
-
const
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
const deleteTransaction = db.transaction(() => {
|
|
2583
|
-
const escapedMessageId = escapeLikePattern(messageId);
|
|
2584
|
-
const textPartPattern = `${escapedMessageId}:p%`;
|
|
2585
|
-
const filePartPattern = `${escapedMessageId}:file%`;
|
|
2586
|
-
const messageScopedTags = getTagNumbersByMessageIdStatement(db).all(sessionId, messageId, textPartPattern, filePartPattern).filter(isTagNumberRow).map((row) => row.tag_number);
|
|
2587
|
-
const ownerScopedTagNumbers = getOwnerScopedToolTagNumbers(db, sessionId, messageId);
|
|
2588
|
-
if (messageScopedTags.length === 0 && ownerScopedTagNumbers.length === 0) {
|
|
2589
|
-
return [];
|
|
2590
|
-
}
|
|
2591
|
-
if (messageScopedTags.length > 0) {
|
|
2592
|
-
getDeleteTagsByMessageIdStatement(db).run(sessionId, messageId, textPartPattern, filePartPattern);
|
|
2593
|
-
}
|
|
2594
|
-
if (ownerScopedTagNumbers.length > 0) {
|
|
2595
|
-
deleteToolTagsByOwner(db, sessionId, messageId);
|
|
2205
|
+
const ids = new Set(messageIds);
|
|
2206
|
+
if (ids.size === 0)
|
|
2207
|
+
return 0;
|
|
2208
|
+
const asciiLower = (value) => value.replace(/[A-Z]/g, (char) => char.toLowerCase());
|
|
2209
|
+
const foldedIds = new Set(Array.from(ids, asciiLower));
|
|
2210
|
+
const nulPrefixes = new Set(Array.from(ids).filter((id) => id.includes("\x00")).map((id) => asciiLower(id.split("\x00")[0])));
|
|
2211
|
+
const matches = (messageId, owner) => {
|
|
2212
|
+
if (messageId !== null && ids.has(messageId))
|
|
2213
|
+
return true;
|
|
2214
|
+
if (owner !== null && ids.has(owner))
|
|
2215
|
+
return true;
|
|
2216
|
+
if (messageId === null)
|
|
2217
|
+
return false;
|
|
2218
|
+
const nul = messageId.indexOf("\x00");
|
|
2219
|
+
const value = nul < 0 ? messageId : messageId.slice(0, nul);
|
|
2220
|
+
if (nulPrefixes.size > 0 && nulPrefixes.has(asciiLower(value)))
|
|
2221
|
+
return true;
|
|
2222
|
+
for (let colon = value.indexOf(":");colon >= 0; colon = value.indexOf(":", colon + 1)) {
|
|
2223
|
+
const suffix = value[colon + 1];
|
|
2224
|
+
if ((suffix === "p" || suffix === "P" || asciiLower(value.slice(colon + 1, colon + 5)) === "file") && foldedIds.has(asciiLower(value.slice(0, colon))))
|
|
2225
|
+
return true;
|
|
2596
2226
|
}
|
|
2597
|
-
|
|
2598
|
-
|
|
2227
|
+
return false;
|
|
2228
|
+
};
|
|
2229
|
+
const rows = db.prepare(`WITH ids AS MATERIALIZED (
|
|
2230
|
+
SELECT value AS source_id, lower(value) AS folded_id FROM json_each(?)
|
|
2231
|
+
)
|
|
2232
|
+
SELECT id, message_id, tool_owner_message_id FROM tags INDEXED BY idx_tags_session_tag_number
|
|
2233
|
+
WHERE session_id = ? AND status IN ('active', 'dropped') AND (
|
|
2234
|
+
message_id IN (SELECT source_id FROM ids)
|
|
2235
|
+
OR tool_owner_message_id IN (SELECT source_id FROM ids)
|
|
2236
|
+
OR (instr(lower(message_id), ':p') > 0 AND
|
|
2237
|
+
lower(substr(message_id, 1, instr(lower(message_id), ':p') - 1)) IN (SELECT folded_id FROM ids))
|
|
2238
|
+
OR (instr(lower(message_id), ':file') > 0 AND
|
|
2239
|
+
lower(substr(message_id, 1, instr(lower(message_id), ':file') - 1)) IN (SELECT folded_id FROM ids))
|
|
2240
|
+
OR (? AND instr(message_id, ':') > 0)
|
|
2241
|
+
OR ?
|
|
2242
|
+
)`).all(JSON.stringify(Array.from(ids)), sessionId, Array.from(ids).some((id) => id.includes(":")) ? 1 : 0, nulPrefixes.size > 0 ? 1 : 0);
|
|
2243
|
+
const candidates = rows.filter((row) => matches(row.message_id, row.tool_owner_message_id));
|
|
2244
|
+
if (candidates.length === 0)
|
|
2245
|
+
return 0;
|
|
2246
|
+
const update = db.prepare(`UPDATE tags SET status = 'compacted'
|
|
2247
|
+
WHERE id = ? AND session_id = ?
|
|
2248
|
+
AND status IN ('active', 'dropped')
|
|
2249
|
+
AND message_id IS ? AND tool_owner_message_id IS ?
|
|
2250
|
+
RETURNING id`);
|
|
2251
|
+
let cursor = 0;
|
|
2252
|
+
let changed = 0;
|
|
2253
|
+
const batch = db.transaction(() => {
|
|
2254
|
+
const start = performance.now();
|
|
2255
|
+
let processed = 0;
|
|
2256
|
+
do {
|
|
2257
|
+
const row = candidates[cursor++];
|
|
2258
|
+
if (update.get(row.id, sessionId, row.message_id, row.tool_owner_message_id))
|
|
2259
|
+
changed++;
|
|
2260
|
+
processed++;
|
|
2261
|
+
} while (cursor < candidates.length && processed < 128 && performance.now() - start < 8);
|
|
2599
2262
|
});
|
|
2600
|
-
|
|
2263
|
+
while (cursor < candidates.length)
|
|
2264
|
+
batch.immediate();
|
|
2265
|
+
return changed;
|
|
2601
2266
|
}
|
|
2602
2267
|
var getOwnerScopedToolTagNumbersStatements = new WeakMap;
|
|
2603
|
-
function getOwnerScopedToolTagNumbers(db, sessionId, ownerMsgId) {
|
|
2604
|
-
let stmt = getOwnerScopedToolTagNumbersStatements.get(db);
|
|
2605
|
-
if (!stmt) {
|
|
2606
|
-
stmt = db.prepare("SELECT tag_number FROM tags WHERE session_id = ? AND type = 'tool' AND tool_owner_message_id = ? ORDER BY tag_number ASC");
|
|
2607
|
-
getOwnerScopedToolTagNumbersStatements.set(db, stmt);
|
|
2608
|
-
}
|
|
2609
|
-
return stmt.all(sessionId, ownerMsgId).filter(isTagNumberRow).map((row) => row.tag_number);
|
|
2610
|
-
}
|
|
2611
2268
|
function getMaxTagNumberBySession(db, sessionId) {
|
|
2612
2269
|
const row = getMaxTagNumberBySessionStatement(db).get(sessionId);
|
|
2613
2270
|
return isMaxTagNumberRow(row) ? row.max_tag_number : 0;
|
|
@@ -2722,11 +2379,14 @@ function getTailHygieneTags(db, sessionId) {
|
|
|
2722
2379
|
return active;
|
|
2723
2380
|
}
|
|
2724
2381
|
function getDroppedTagsBySession(db, sessionId, scope) {
|
|
2725
|
-
const rows = (scope ? db.prepare(`SELECT ${TAG_SELECT_COLUMNS} FROM tags
|
|
2726
|
-
WHERE session_id = ? AND status = 'dropped'
|
|
2727
|
-
AND
|
|
2728
|
-
|
|
2729
|
-
|
|
2382
|
+
const rows = (scope ? db.prepare(`SELECT ${TAG_SELECT_COLUMNS} FROM tags INDEXED BY idx_tags_pi_fallback_tool_owner
|
|
2383
|
+
WHERE session_id = ? AND type = 'tool' AND +status = 'dropped'
|
|
2384
|
+
AND tool_owner_message_id IN (SELECT value FROM json_each(?))
|
|
2385
|
+
UNION ALL
|
|
2386
|
+
SELECT ${TAG_SELECT_COLUMNS} FROM tags INDEXED BY idx_tags_session_message_id
|
|
2387
|
+
WHERE session_id = ? AND type != 'tool' AND +status = 'dropped'
|
|
2388
|
+
AND message_id IN (SELECT value FROM json_each(?))
|
|
2389
|
+
ORDER BY tag_number ASC, id ASC`).all(sessionId, JSON.stringify(scope.ownerIds), sessionId, JSON.stringify(scope.messageAddresses)) : getDroppedTagsBySessionStatement(db).all(sessionId)).filter(isTagRow);
|
|
2730
2390
|
return rows.map(toTagEntry);
|
|
2731
2391
|
}
|
|
2732
2392
|
function getTagsByNumbers(db, sessionId, tagNumbers) {
|
|
@@ -2868,20 +2528,33 @@ function pickNearestPriorOwner(candidates, currentMessageId, times) {
|
|
|
2868
2528
|
}
|
|
2869
2529
|
return best?.id ?? null;
|
|
2870
2530
|
}
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
}
|
|
2881
|
-
|
|
2882
|
-
}
|
|
2883
|
-
|
|
2884
|
-
|
|
2531
|
+
// src/shared/historian-tool-defaults.json
|
|
2532
|
+
var historian_tool_defaults_default = {
|
|
2533
|
+
ctx_note: "Note ${input.action} ${input.note_ids}: ${input.content} → ${output.truncate(160)}",
|
|
2534
|
+
ctx_memory: "Memory ${input.action} ${input.category} ${input.ids}: ${input.content} → ${output.truncate(160)}",
|
|
2535
|
+
todowrite: 'Todos (${input.todos.count}): ${input.todos.each("${status}: ${content}")}',
|
|
2536
|
+
question: 'Asked user: ${input.questions[*].question.join(" / ")} → ${output}',
|
|
2537
|
+
task: "Task ${input.subagent_type}: ${input.prompt} → ${output.truncate(200)}",
|
|
2538
|
+
ask: 'Asked: ${input.question.truncate(250)} [options: ${input.options.join(" / ")}] ${input.resolution} → ${output.truncate(300)}',
|
|
2539
|
+
peer_send: "PM to ${input.agent}${input.agent_id}: ${input.message.truncate(400)}",
|
|
2540
|
+
board: 'Board ${input.verb}: ${input.ops.each("${op} ${item}${lane.title} ${state}${lane.status}${props.text} ${lane.items[*].text}")}',
|
|
2541
|
+
room: "Room ${input.action} ${input.room_id}: ${input.text.truncate(400)}",
|
|
2542
|
+
work: "Work ${input.action} ${input.id}: ${input.prompt_file}${input.prompt.truncate(200)}${input.notes.truncate(200)} → ${output.truncate(160)}",
|
|
2543
|
+
knowhow: "Looked up how-to: ${input.query}${input.id}"
|
|
2544
|
+
};
|
|
2545
|
+
|
|
2546
|
+
// src/shared/historian-tool-expansions.ts
|
|
2547
|
+
function expandToolPart(part, overrides) {
|
|
2548
|
+
if (!part || typeof part !== "object")
|
|
2549
|
+
return null;
|
|
2550
|
+
const p = part;
|
|
2551
|
+
if (p.type !== "tool" || typeof p.tool !== "string")
|
|
2552
|
+
return null;
|
|
2553
|
+
const template = overrides && Object.hasOwn(overrides, p.tool) ? overrides[p.tool] : Object.hasOwn(historian_tool_defaults_default, p.tool) ? historian_tool_defaults_default[p.tool] : undefined;
|
|
2554
|
+
if (typeof template !== "string")
|
|
2555
|
+
return null;
|
|
2556
|
+
const state = p.state;
|
|
2557
|
+
return renderToolTemplate(template, state?.input, state?.output ?? state?.error);
|
|
2885
2558
|
}
|
|
2886
2559
|
|
|
2887
2560
|
// src/hooks/magic-context/host-served-rows.ts
|
|
@@ -3050,8 +2723,8 @@ function readRawSessionMessagesFromDb(db, sessionId) {
|
|
|
3050
2723
|
};
|
|
3051
2724
|
});
|
|
3052
2725
|
}
|
|
3053
|
-
function readRawSessionMessagePageFromDb(db, sessionId, afterOrdinal, limit, finalWatermark = Number.MAX_SAFE_INTEGER) {
|
|
3054
|
-
const messageRows = readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWatermark);
|
|
2726
|
+
function readRawSessionMessagePageFromDb(db, sessionId, afterOrdinal, limit, finalWatermark = Number.MAX_SAFE_INTEGER, after) {
|
|
2727
|
+
const messageRows = readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWatermark, after);
|
|
3055
2728
|
if (messageRows.length === 0)
|
|
3056
2729
|
return [];
|
|
3057
2730
|
const placeholders = messageRows.map(() => "?").join(", ");
|
|
@@ -3062,15 +2735,22 @@ function readRawSessionMessagePageFromDb(db, sessionId, afterOrdinal, limit, fin
|
|
|
3062
2735
|
ORDER BY message_id ASC, time_created ASC, id ASC`).all(sessionId, ...messageRows.map((row) => row.id)).filter(isRawPartRow);
|
|
3063
2736
|
return assembleRawMessagePage(messageRows, partRows);
|
|
3064
2737
|
}
|
|
3065
|
-
function readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWatermark) {
|
|
2738
|
+
function readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWatermark, after) {
|
|
3066
2739
|
const remaining = Math.max(0, Math.floor(finalWatermark) - Math.floor(afterOrdinal));
|
|
3067
2740
|
const pageSize = Math.min(Math.max(1, Math.floor(limit)), remaining);
|
|
3068
2741
|
if (pageSize === 0)
|
|
3069
2742
|
return [];
|
|
2743
|
+
const parameters = [sessionId];
|
|
2744
|
+
if (after)
|
|
2745
|
+
parameters.push(after.timeCreated, after.timeCreated, after.timeCreated, after.id);
|
|
2746
|
+
parameters.push(pageSize);
|
|
2747
|
+
if (!after)
|
|
2748
|
+
parameters.push(Math.max(0, Math.floor(afterOrdinal)));
|
|
3070
2749
|
return db.prepare(`SELECT id, data, time_created, time_updated
|
|
3071
2750
|
FROM message
|
|
3072
2751
|
WHERE session_id = ?
|
|
3073
|
-
|
|
2752
|
+
${after ? "AND time_created >= ? AND (time_created > ? OR (time_created = ? AND id > ?))" : ""}
|
|
2753
|
+
AND NOT (
|
|
3074
2754
|
CASE WHEN json_valid(data) = 1
|
|
3075
2755
|
THEN COALESCE(json_extract(data, '$.summary'), 0)
|
|
3076
2756
|
ELSE 0 END = 1
|
|
@@ -3079,7 +2759,7 @@ function readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWaterma
|
|
|
3079
2759
|
ELSE '' END = 'stop'
|
|
3080
2760
|
)
|
|
3081
2761
|
ORDER BY time_created ASC, id ASC
|
|
3082
|
-
LIMIT ? OFFSET
|
|
2762
|
+
LIMIT ? ${after ? "" : "OFFSET ?"}`).all(...parameters).filter(isRawMessageRow).map((row, index) => ({
|
|
3083
2763
|
...row,
|
|
3084
2764
|
ordinal: Math.floor(afterOrdinal) + index + 1
|
|
3085
2765
|
}));
|
|
@@ -3132,8 +2812,8 @@ var RAW_SUMMARY_PART_DATA_SQL = `CASE
|
|
|
3132
2812
|
)
|
|
3133
2813
|
)
|
|
3134
2814
|
END`;
|
|
3135
|
-
function readRawSessionMessageSummaryPageFromDb(db, sessionId, afterOrdinal, limit, finalWatermark = Number.MAX_SAFE_INTEGER) {
|
|
3136
|
-
const messageRows = readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWatermark);
|
|
2815
|
+
function readRawSessionMessageSummaryPageFromDb(db, sessionId, afterOrdinal, limit, finalWatermark = Number.MAX_SAFE_INTEGER, after) {
|
|
2816
|
+
const messageRows = readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWatermark, after);
|
|
3137
2817
|
if (messageRows.length === 0)
|
|
3138
2818
|
return [];
|
|
3139
2819
|
const placeholders = messageRows.map(() => "?").join(", ");
|
|
@@ -3941,18 +3621,87 @@ function computeRawRangeFingerprint(messages, startInclusive, endExclusive) {
|
|
|
3941
3621
|
}
|
|
3942
3622
|
return pieces.join("|");
|
|
3943
3623
|
}
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3624
|
+
|
|
3625
|
+
// src/hooks/magic-context/system-injection-stripper.ts
|
|
3626
|
+
var SYSTEM_INJECTION_MARKERS = [
|
|
3627
|
+
"<!-- OMO_INTERNAL_INITIATOR -->",
|
|
3628
|
+
"[SYSTEM DIRECTIVE: MAGIC-CONTEXT",
|
|
3629
|
+
"[SYSTEM DIRECTIVE: OH-MY-OPENCODE",
|
|
3630
|
+
"[Category+Skill Reminder]",
|
|
3631
|
+
"[EDIT ERROR - IMMEDIATE ACTION REQUIRED]",
|
|
3632
|
+
"[task CALL FAILED - IMMEDIATE RETRY REQUIRED]",
|
|
3633
|
+
"[EMERGENCY CONTEXT WINDOW WARNING]",
|
|
3634
|
+
"Unstable background agent appears idle",
|
|
3635
|
+
"**THE SUBAGENT JUST CLAIMED THIS TASK IS DONE."
|
|
3636
|
+
];
|
|
3637
|
+
var SYSTEM_REMINDER_REGEX = /<system-reminder>[\s\S]*?<\/system-reminder>/gi;
|
|
3638
|
+
var OMO_MARKER_REGEX = /<!-- OMO_INTERNAL_INITIATOR -->/g;
|
|
3639
|
+
var STEERING_WRAPPER_REGEX = /<system-reminder>\nThe user sent the following message:\n[\s\S]*?\n\nPlease address this message and continue with your tasks\.\n<\/system-reminder>/g;
|
|
3640
|
+
function stripSystemInjection(text) {
|
|
3641
|
+
STEERING_WRAPPER_REGEX.lastIndex = 0;
|
|
3642
|
+
if (!STEERING_WRAPPER_REGEX.test(text))
|
|
3643
|
+
return stripInjectedRegions(text);
|
|
3644
|
+
STEERING_WRAPPER_REGEX.lastIndex = 0;
|
|
3645
|
+
let result = "";
|
|
3646
|
+
let changed = false;
|
|
3647
|
+
let cursor = 0;
|
|
3648
|
+
const keepOrStrip = (segment) => {
|
|
3649
|
+
const stripped = stripInjectedRegions(segment);
|
|
3650
|
+
if (stripped === null) {
|
|
3651
|
+
result += segment;
|
|
3652
|
+
} else {
|
|
3653
|
+
result += stripped;
|
|
3654
|
+
changed = true;
|
|
3655
|
+
}
|
|
3656
|
+
};
|
|
3657
|
+
for (const match of text.matchAll(STEERING_WRAPPER_REGEX)) {
|
|
3658
|
+
keepOrStrip(text.slice(cursor, match.index));
|
|
3659
|
+
result += match[0];
|
|
3660
|
+
cursor = match.index + match[0].length;
|
|
3661
|
+
}
|
|
3662
|
+
keepOrStrip(text.slice(cursor));
|
|
3663
|
+
return changed ? result.trim() : null;
|
|
3664
|
+
}
|
|
3665
|
+
function stripOutsideSteeringWrappers(text, strip) {
|
|
3666
|
+
STEERING_WRAPPER_REGEX.lastIndex = 0;
|
|
3667
|
+
let result = "";
|
|
3668
|
+
let cursor = 0;
|
|
3669
|
+
for (const match of text.matchAll(STEERING_WRAPPER_REGEX)) {
|
|
3670
|
+
result += strip(text.slice(cursor, match.index));
|
|
3671
|
+
result += match[0];
|
|
3672
|
+
cursor = match.index + match[0].length;
|
|
3673
|
+
}
|
|
3674
|
+
return result + strip(text.slice(cursor));
|
|
3675
|
+
}
|
|
3676
|
+
function stripInjectedRegions(text) {
|
|
3677
|
+
let hasInjection = false;
|
|
3678
|
+
for (const marker of SYSTEM_INJECTION_MARKERS) {
|
|
3679
|
+
if (text.includes(marker)) {
|
|
3680
|
+
hasInjection = true;
|
|
3681
|
+
break;
|
|
3953
3682
|
}
|
|
3954
3683
|
}
|
|
3955
|
-
|
|
3684
|
+
if (SYSTEM_REMINDER_REGEX.test(text))
|
|
3685
|
+
hasInjection = true;
|
|
3686
|
+
SYSTEM_REMINDER_REGEX.lastIndex = 0;
|
|
3687
|
+
if (!hasInjection)
|
|
3688
|
+
return null;
|
|
3689
|
+
let cleaned = text;
|
|
3690
|
+
cleaned = cleaned.replace(SYSTEM_REMINDER_REGEX, "");
|
|
3691
|
+
cleaned = cleaned.replace(OMO_MARKER_REGEX, "");
|
|
3692
|
+
cleaned = cleaned.replace(/\[SYSTEM DIRECTIVE: OH-MY-(?:OPENCODE|CLAUDE)[^\]]*\][\s\S]*?(?=\n\n(?!\s*[-*])|$)/g, "");
|
|
3693
|
+
for (const marker of SYSTEM_INJECTION_MARKERS) {
|
|
3694
|
+
if (marker.startsWith("<!-- ") || marker.startsWith("[SYSTEM DIRECTIVE"))
|
|
3695
|
+
continue;
|
|
3696
|
+
const idx = cleaned.indexOf(marker);
|
|
3697
|
+
if (idx === -1)
|
|
3698
|
+
continue;
|
|
3699
|
+
const blockEnd = cleaned.indexOf(`
|
|
3700
|
+
|
|
3701
|
+
`, idx + marker.length);
|
|
3702
|
+
cleaned = blockEnd !== -1 ? cleaned.slice(0, idx) + cleaned.slice(blockEnd) : cleaned.slice(0, idx);
|
|
3703
|
+
}
|
|
3704
|
+
return cleaned.trim();
|
|
3956
3705
|
}
|
|
3957
3706
|
|
|
3958
3707
|
// src/hooks/magic-context/tag-part-guards.ts
|
|
@@ -3984,6 +3733,27 @@ function buildFileSourceContent(parts) {
|
|
|
3984
3733
|
return content.length > 0 ? content : null;
|
|
3985
3734
|
}
|
|
3986
3735
|
|
|
3736
|
+
// src/shared/user-answer.ts
|
|
3737
|
+
function hasUserAnswerMetadata(value) {
|
|
3738
|
+
if (!isRecord(value))
|
|
3739
|
+
return false;
|
|
3740
|
+
if (value.userAnswer === true)
|
|
3741
|
+
return true;
|
|
3742
|
+
if (Array.isArray(value.answers))
|
|
3743
|
+
return true;
|
|
3744
|
+
if (typeof value.answer === "string")
|
|
3745
|
+
return true;
|
|
3746
|
+
if (Array.isArray(value.selectedOptions) || typeof value.customInput === "string")
|
|
3747
|
+
return true;
|
|
3748
|
+
return Array.isArray(value.results) && value.results.some(hasUserAnswerMetadata);
|
|
3749
|
+
}
|
|
3750
|
+
function toolPartHasUserAnswer(part) {
|
|
3751
|
+
if (!isRecord(part))
|
|
3752
|
+
return false;
|
|
3753
|
+
const state = isRecord(part.state) ? part.state : undefined;
|
|
3754
|
+
return hasUserAnswerMetadata(state?.metadata) || hasUserAnswerMetadata(part.details);
|
|
3755
|
+
}
|
|
3756
|
+
|
|
3987
3757
|
// src/features/magic-context/dreamer/token-budget.ts
|
|
3988
3758
|
class DreamTokenBudgetExceeded extends Error {
|
|
3989
3759
|
sessionId;
|
|
@@ -4004,9 +3774,6 @@ function registerBudgetFinalizeChild(sessionId, guard) {
|
|
|
4004
3774
|
function releaseBudgetFinalizeChild(sessionId) {
|
|
4005
3775
|
finalizingChildren.delete(sessionId);
|
|
4006
3776
|
}
|
|
4007
|
-
function refuseBudgetedToolCall(sessionId) {
|
|
4008
|
-
return finalizingChildren.get(sessionId)?.refuseTool() ?? null;
|
|
4009
|
-
}
|
|
4010
3777
|
function createDreamTokenBudget(budget) {
|
|
4011
3778
|
if (!Number.isSafeInteger(budget) || budget <= 0)
|
|
4012
3779
|
throw new Error("Invalid token budget");
|
|
@@ -4023,12 +3790,20 @@ function createDreamTokenBudget(budget) {
|
|
|
4023
3790
|
});
|
|
4024
3791
|
return {
|
|
4025
3792
|
snapshot,
|
|
3793
|
+
finalize() {
|
|
3794
|
+
if (finalizeFired)
|
|
3795
|
+
return "continue";
|
|
3796
|
+
finalizeFired = true;
|
|
3797
|
+
return "finalize";
|
|
3798
|
+
},
|
|
4026
3799
|
charge(input, cacheRead, cacheWrite, completed = false, canFinalize = true) {
|
|
4027
3800
|
for (const value of [input, cacheRead, cacheWrite]) {
|
|
4028
3801
|
if (!Number.isSafeInteger(value) || value < 0)
|
|
4029
3802
|
throw new Error("Invalid prompt usage");
|
|
4030
3803
|
}
|
|
4031
3804
|
spent += input + cacheRead + cacheWrite;
|
|
3805
|
+
if (completed)
|
|
3806
|
+
return "continue";
|
|
4032
3807
|
if (spent >= budget)
|
|
4033
3808
|
return "stop";
|
|
4034
3809
|
if (!completed && !finalizeFired && spent >= budget * 0.8) {
|
|
@@ -4042,7 +3817,7 @@ function createDreamTokenBudget(budget) {
|
|
|
4042
3817
|
return "continue";
|
|
4043
3818
|
},
|
|
4044
3819
|
refuseTool() {
|
|
4045
|
-
if (!finalizeFired)
|
|
3820
|
+
if (!finalizeFired && !snapshot().hardStopped)
|
|
4046
3821
|
return null;
|
|
4047
3822
|
refusedCalls += 1;
|
|
4048
3823
|
return { message: TOKEN_BUDGET_TOOL_REFUSAL, hardStopped: snapshot().hardStopped };
|
|
@@ -4211,23 +3986,6 @@ function assertExecutableToolInput(guard, call) {
|
|
|
4211
3986
|
if (refusal !== undefined)
|
|
4212
3987
|
throw new Error(refusal);
|
|
4213
3988
|
}
|
|
4214
|
-
function createDroppedInputToolExecuteBeforeHook() {
|
|
4215
|
-
const guard = createDroppedInputGuard();
|
|
4216
|
-
return async (input, output) => {
|
|
4217
|
-
const call = isRecord2(input) ? input : {};
|
|
4218
|
-
const args = isRecord2(output) ? output.args : undefined;
|
|
4219
|
-
if (typeof call.sessionID === "string") {
|
|
4220
|
-
const refusal = refuseBudgetedToolCall(call.sessionID);
|
|
4221
|
-
if (refusal)
|
|
4222
|
-
throw new Error(refusal.message);
|
|
4223
|
-
}
|
|
4224
|
-
assertExecutableToolInput(guard, {
|
|
4225
|
-
sessionID: typeof call.sessionID === "string" ? call.sessionID : undefined,
|
|
4226
|
-
toolName: typeof call.tool === "string" ? call.tool : undefined,
|
|
4227
|
-
input: args
|
|
4228
|
-
});
|
|
4229
|
-
};
|
|
4230
|
-
}
|
|
4231
3989
|
|
|
4232
3990
|
// src/hooks/magic-context/edit-marker.ts
|
|
4233
3991
|
var TRUNCATION_SENTINEL = "...[truncated]";
|
|
@@ -4259,110 +4017,6 @@ function applyEditMarkerToInput(input) {
|
|
|
4259
4017
|
}
|
|
4260
4018
|
}
|
|
4261
4019
|
|
|
4262
|
-
// src/features/magic-context/tool-definition-tokens.ts
|
|
4263
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
4264
|
-
var measurements = new Map;
|
|
4265
|
-
var fingerprints = new Map;
|
|
4266
|
-
var persistenceDb = null;
|
|
4267
|
-
var cachedInsertStmt = null;
|
|
4268
|
-
function keyFor(providerID, modelID, agentName) {
|
|
4269
|
-
const agent = agentName && agentName.length > 0 ? agentName : "default";
|
|
4270
|
-
return `${providerID}/${modelID}/${agent}`;
|
|
4271
|
-
}
|
|
4272
|
-
function fingerprintFor(description, parameters) {
|
|
4273
|
-
return createHash2("sha256").update(description).update("\x00").update(stableStringify(parameters)).digest("hex");
|
|
4274
|
-
}
|
|
4275
|
-
function getCurrentToolSetHash(providerID, modelID, agentName) {
|
|
4276
|
-
if (!providerID || !modelID)
|
|
4277
|
-
return "";
|
|
4278
|
-
const toolIds = measurements.get(keyFor(providerID, modelID, agentName));
|
|
4279
|
-
if (!toolIds || toolIds.size === 0)
|
|
4280
|
-
return "";
|
|
4281
|
-
return createHash2("sha256").update(Array.from(toolIds.keys()).sort().join("\x00")).digest("hex");
|
|
4282
|
-
}
|
|
4283
|
-
function setDatabase(db) {
|
|
4284
|
-
persistenceDb = db;
|
|
4285
|
-
cachedInsertStmt = null;
|
|
4286
|
-
}
|
|
4287
|
-
function loadToolDefinitionMeasurements(db) {
|
|
4288
|
-
let rows = [];
|
|
4289
|
-
try {
|
|
4290
|
-
rows = db.prepare("SELECT provider_id, model_id, agent_name, tool_id, token_count FROM tool_definition_measurements").all();
|
|
4291
|
-
} catch {
|
|
4292
|
-
return;
|
|
4293
|
-
}
|
|
4294
|
-
for (const row of rows) {
|
|
4295
|
-
const key = keyFor(row.provider_id, row.model_id, row.agent_name);
|
|
4296
|
-
let inner = measurements.get(key);
|
|
4297
|
-
if (!inner) {
|
|
4298
|
-
inner = new Map;
|
|
4299
|
-
measurements.set(key, inner);
|
|
4300
|
-
}
|
|
4301
|
-
inner.set(row.tool_id, row.token_count);
|
|
4302
|
-
}
|
|
4303
|
-
}
|
|
4304
|
-
function recordToolDefinition(providerID, modelID, agentName, toolID, description, parameters) {
|
|
4305
|
-
if (!providerID || !modelID || !toolID)
|
|
4306
|
-
return;
|
|
4307
|
-
const key = keyFor(providerID, modelID, agentName);
|
|
4308
|
-
const fp = fingerprintFor(description ?? "", parameters);
|
|
4309
|
-
let innerFp = fingerprints.get(key);
|
|
4310
|
-
if (innerFp && innerFp.get(toolID) === fp)
|
|
4311
|
-
return;
|
|
4312
|
-
let paramsText = "";
|
|
4313
|
-
try {
|
|
4314
|
-
paramsText = parameters === undefined ? "" : JSON.stringify(parameters);
|
|
4315
|
-
} catch {
|
|
4316
|
-
paramsText = "";
|
|
4317
|
-
}
|
|
4318
|
-
const tokens = estimateTokens(description ?? "") + estimateTokens(paramsText);
|
|
4319
|
-
let inner = measurements.get(key);
|
|
4320
|
-
if (!inner) {
|
|
4321
|
-
inner = new Map;
|
|
4322
|
-
measurements.set(key, inner);
|
|
4323
|
-
}
|
|
4324
|
-
inner.set(toolID, tokens);
|
|
4325
|
-
if (!innerFp) {
|
|
4326
|
-
innerFp = new Map;
|
|
4327
|
-
fingerprints.set(key, innerFp);
|
|
4328
|
-
}
|
|
4329
|
-
innerFp.set(toolID, fp);
|
|
4330
|
-
if (persistenceDb) {
|
|
4331
|
-
try {
|
|
4332
|
-
const agent = agentName && agentName.length > 0 ? agentName : "default";
|
|
4333
|
-
if (!cachedInsertStmt) {
|
|
4334
|
-
cachedInsertStmt = persistenceDb.prepare(`INSERT OR REPLACE INTO tool_definition_measurements
|
|
4335
|
-
(provider_id, model_id, agent_name, tool_id, token_count, recorded_at)
|
|
4336
|
-
VALUES (?, ?, ?, ?, ?, ?)`);
|
|
4337
|
-
}
|
|
4338
|
-
cachedInsertStmt.run(providerID, modelID, agent, toolID, tokens, Date.now());
|
|
4339
|
-
} catch {
|
|
4340
|
-
cachedInsertStmt = null;
|
|
4341
|
-
}
|
|
4342
|
-
}
|
|
4343
|
-
}
|
|
4344
|
-
function getLargestMeasuredToolDefinitionTokens() {
|
|
4345
|
-
let largest = 0;
|
|
4346
|
-
for (const tools of measurements.values()) {
|
|
4347
|
-
let total = 0;
|
|
4348
|
-
for (const tokens of tools.values())
|
|
4349
|
-
total += tokens;
|
|
4350
|
-
largest = Math.max(largest, total);
|
|
4351
|
-
}
|
|
4352
|
-
return largest > 0 ? largest : undefined;
|
|
4353
|
-
}
|
|
4354
|
-
function getMeasuredToolDefinitionTokens(providerID, modelID, agentName) {
|
|
4355
|
-
if (!providerID || !modelID)
|
|
4356
|
-
return;
|
|
4357
|
-
const inner = measurements.get(keyFor(providerID, modelID, agentName));
|
|
4358
|
-
if (!inner || inner.size === 0)
|
|
4359
|
-
return;
|
|
4360
|
-
let total = 0;
|
|
4361
|
-
for (const tokens of inner.values())
|
|
4362
|
-
total += tokens;
|
|
4363
|
-
return total;
|
|
4364
|
-
}
|
|
4365
|
-
|
|
4366
4020
|
// src/hooks/magic-context/final-wire-token-estimate.ts
|
|
4367
4021
|
function compactWireLabel(value, fallback) {
|
|
4368
4022
|
if (typeof value !== "string" || value.length === 0)
|
|
@@ -4387,75 +4041,104 @@ function describeFinalWireTail(messages) {
|
|
|
4387
4041
|
return `${role}:${kinds}`;
|
|
4388
4042
|
}).join(", ")}]`;
|
|
4389
4043
|
}
|
|
4390
|
-
function
|
|
4044
|
+
function serializedText(value) {
|
|
4391
4045
|
if (value === undefined)
|
|
4392
|
-
return
|
|
4393
|
-
|
|
4046
|
+
return "";
|
|
4047
|
+
return (typeof value === "string" ? value : JSON.stringify(value)) ?? "";
|
|
4048
|
+
}
|
|
4049
|
+
function serializedTokens(value) {
|
|
4050
|
+
const serialized = serializedText(value);
|
|
4394
4051
|
return serialized ? estimateTokens(serialized) : 0;
|
|
4395
4052
|
}
|
|
4396
|
-
function
|
|
4397
|
-
let conversation = 0;
|
|
4398
|
-
let toolCall = 0;
|
|
4053
|
+
function visitWireContent(message, visit) {
|
|
4399
4054
|
for (const part of message.parts) {
|
|
4400
4055
|
if (!part || typeof part !== "object")
|
|
4401
4056
|
continue;
|
|
4402
4057
|
const p = part;
|
|
4403
4058
|
if (p.ignored)
|
|
4404
4059
|
continue;
|
|
4060
|
+
const text = (value) => {
|
|
4061
|
+
if (typeof value === "string")
|
|
4062
|
+
visit.text("conversation", value);
|
|
4063
|
+
};
|
|
4064
|
+
const tool = (value) => visit.text("toolCall", value);
|
|
4405
4065
|
switch (p.type) {
|
|
4406
4066
|
case "text":
|
|
4407
|
-
|
|
4408
|
-
conversation += estimateTokens(p.text);
|
|
4067
|
+
text(p.text);
|
|
4409
4068
|
break;
|
|
4410
|
-
case "reasoning":
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
const signature = p.metadata?.anthropic?.signature;
|
|
4414
|
-
if (typeof signature === "string")
|
|
4415
|
-
conversation += estimateTokens(signature);
|
|
4069
|
+
case "reasoning":
|
|
4070
|
+
text(p.text);
|
|
4071
|
+
text(p.metadata?.anthropic?.signature);
|
|
4416
4072
|
break;
|
|
4417
|
-
}
|
|
4418
4073
|
case "thinking":
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
if (typeof p.signature === "string")
|
|
4422
|
-
conversation += estimateTokens(p.signature);
|
|
4074
|
+
text(p.thinking);
|
|
4075
|
+
text(p.signature);
|
|
4423
4076
|
break;
|
|
4424
4077
|
case "redacted_thinking":
|
|
4425
|
-
|
|
4426
|
-
conversation += estimateTokens(p.data);
|
|
4078
|
+
text(p.data);
|
|
4427
4079
|
break;
|
|
4428
4080
|
case "file":
|
|
4429
4081
|
if (typeof p.mime === "string" && p.mime.startsWith("image/")) {
|
|
4430
|
-
conversation
|
|
4082
|
+
visit.image("conversation", typeof p.url === "string" && p.url.startsWith("data:") ? estimateImageTokensFromDataUrl(p.url) : 1200);
|
|
4431
4083
|
}
|
|
4432
4084
|
break;
|
|
4433
4085
|
case "tool":
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
toolCall
|
|
4086
|
+
tool(p.state?.input ?? p.input ?? p.args);
|
|
4087
|
+
tool(p.state?.output ?? p.state?.content ?? p.output ?? p.result ?? p.content);
|
|
4088
|
+
tool(p.state?.error);
|
|
4089
|
+
visit.image("toolCall", estimateToolAttachmentImageTokens(p.state));
|
|
4438
4090
|
break;
|
|
4439
4091
|
case "tool-call":
|
|
4440
|
-
|
|
4092
|
+
tool(p.input ?? p.args);
|
|
4441
4093
|
break;
|
|
4442
4094
|
case "tool-invocation":
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4095
|
+
tool(p.args ?? p.input);
|
|
4096
|
+
tool(p.result ?? p.output ?? p.state?.output);
|
|
4097
|
+
tool(p.state?.error);
|
|
4446
4098
|
break;
|
|
4447
4099
|
case "tool-result":
|
|
4448
|
-
|
|
4100
|
+
tool(p.result ?? p.content ?? p.output);
|
|
4449
4101
|
break;
|
|
4450
4102
|
case "tool_use":
|
|
4451
|
-
|
|
4103
|
+
tool(p.input ?? p.args);
|
|
4452
4104
|
break;
|
|
4453
4105
|
case "tool_result":
|
|
4454
|
-
|
|
4106
|
+
tool(p.content ?? p.result ?? p.output);
|
|
4455
4107
|
break;
|
|
4456
4108
|
}
|
|
4457
4109
|
}
|
|
4458
|
-
|
|
4110
|
+
}
|
|
4111
|
+
function estimateMessageTokens(message) {
|
|
4112
|
+
const total = { conversation: 0, toolCall: 0 };
|
|
4113
|
+
visitWireContent(message, {
|
|
4114
|
+
text: (bucket, value) => {
|
|
4115
|
+
total[bucket] += serializedTokens(value);
|
|
4116
|
+
},
|
|
4117
|
+
image: (bucket, tokens) => {
|
|
4118
|
+
total[bucket] += tokens;
|
|
4119
|
+
}
|
|
4120
|
+
});
|
|
4121
|
+
return total;
|
|
4122
|
+
}
|
|
4123
|
+
function wireContentBytes(messages, abortAboveBytes, bytesPerToken) {
|
|
4124
|
+
let bytes = 0;
|
|
4125
|
+
try {
|
|
4126
|
+
for (const message of messages) {
|
|
4127
|
+
visitWireContent(message, {
|
|
4128
|
+
text: (_bucket, value) => {
|
|
4129
|
+
bytes += Buffer.byteLength(serializedText(value));
|
|
4130
|
+
},
|
|
4131
|
+
image: (_bucket, tokens) => {
|
|
4132
|
+
bytes += tokens * bytesPerToken;
|
|
4133
|
+
}
|
|
4134
|
+
});
|
|
4135
|
+
if (bytes > abortAboveBytes)
|
|
4136
|
+
return { bytes, aborted: true };
|
|
4137
|
+
}
|
|
4138
|
+
} catch {
|
|
4139
|
+
return null;
|
|
4140
|
+
}
|
|
4141
|
+
return { bytes, aborted: false };
|
|
4459
4142
|
}
|
|
4460
4143
|
function estimateFinalWireInputTokens(input) {
|
|
4461
4144
|
const messageTokens = input.messages.reduce((total, message) => {
|
|
@@ -4486,7 +4169,8 @@ function estimateFinalWireInputTokens(input) {
|
|
|
4486
4169
|
componentsComplete: toolDefinitions !== undefined && input.messages.every(hasCountableParts),
|
|
4487
4170
|
messageTokens,
|
|
4488
4171
|
systemTokens,
|
|
4489
|
-
toolDefinitionTokens
|
|
4172
|
+
toolDefinitionTokens,
|
|
4173
|
+
toolDefinitionsMeasured: measuredToolDefinitions !== undefined
|
|
4490
4174
|
};
|
|
4491
4175
|
}
|
|
4492
4176
|
function hasCountableParts(message) {
|
|
@@ -4531,6 +4215,310 @@ function hasCountableParts(message) {
|
|
|
4531
4215
|
});
|
|
4532
4216
|
}
|
|
4533
4217
|
|
|
4218
|
+
// src/features/magic-context/overflow-detection.ts
|
|
4219
|
+
var OVERFLOW_PATTERNS = [
|
|
4220
|
+
/prompt is too long/i,
|
|
4221
|
+
/input is too long for requested model/i,
|
|
4222
|
+
/exceeds the context window/i,
|
|
4223
|
+
/input token count.*exceeds the maximum/i,
|
|
4224
|
+
/maximum prompt length is \d+/i,
|
|
4225
|
+
/reduce the length of the messages/i,
|
|
4226
|
+
/maximum context length is \d+ tokens/i,
|
|
4227
|
+
/maximum model length is \d+/i,
|
|
4228
|
+
/exceeds the limit of \d+/i,
|
|
4229
|
+
/exceeds the available context size/i,
|
|
4230
|
+
/greater than the context length/i,
|
|
4231
|
+
/context window exceeds limit/i,
|
|
4232
|
+
/exceeded model token limit/i,
|
|
4233
|
+
/context[_ ]length[_ ]exceeded/i,
|
|
4234
|
+
/request entity too large/i,
|
|
4235
|
+
/context length is only \d+ tokens/i,
|
|
4236
|
+
/input length.*exceeds.*context length/i,
|
|
4237
|
+
/prompt too long; exceeded (?:max )?context length/i,
|
|
4238
|
+
/too large for model with \d+ maximum context length/i,
|
|
4239
|
+
/model_context_window_exceeded/i,
|
|
4240
|
+
/context size has been exceeded/i,
|
|
4241
|
+
/prepared prompt exceeds engine max_context/i,
|
|
4242
|
+
/prompt exceeds (?:the )?.{0,32}\bmax_context\b/i
|
|
4243
|
+
];
|
|
4244
|
+
var LIMIT_EXTRACTION_PATTERNS = [
|
|
4245
|
+
{ pattern: /maximum prompt length is (\d+)/i, provenance: "prompt_only" },
|
|
4246
|
+
{
|
|
4247
|
+
pattern: /maximum context length is (\d+) tokens?/i,
|
|
4248
|
+
provenance: "combined"
|
|
4249
|
+
},
|
|
4250
|
+
{ pattern: /maximum model length is (\d+)/i, provenance: "combined" },
|
|
4251
|
+
{ pattern: /context length is only (\d+) tokens?/i, provenance: "combined" },
|
|
4252
|
+
{ pattern: /exceeds the limit of (\d+)/i, provenance: "unknown" },
|
|
4253
|
+
{
|
|
4254
|
+
pattern: /too large for model with (\d+) maximum context length/i,
|
|
4255
|
+
provenance: "combined"
|
|
4256
|
+
},
|
|
4257
|
+
{ pattern: /context size[^0-9]{0,40}(\d{4,})\s*tokens?/i, provenance: "combined" },
|
|
4258
|
+
{ pattern: /exceeds? the context length of (\d+)/i, provenance: "combined" },
|
|
4259
|
+
{
|
|
4260
|
+
pattern: />\s*(\d+)\s*(?:tokens?\s*)?(?:maximum|max|limit)\b/i,
|
|
4261
|
+
provenance: "prompt_only"
|
|
4262
|
+
},
|
|
4263
|
+
{
|
|
4264
|
+
pattern: /maximum number of tokens allowed\s*\(?\s*(\d+)/i,
|
|
4265
|
+
provenance: "prompt_only"
|
|
4266
|
+
},
|
|
4267
|
+
{ pattern: /prepared prompt exceeds engine max_context\s+(\d+)/i, provenance: "unknown" },
|
|
4268
|
+
{ pattern: /prompt exceeds (?:the )?.{0,32}\bmax_context\s+(\d+)/i, provenance: "unknown" },
|
|
4269
|
+
{ pattern: /max(?:imum)?.*context.*?(\d+)/i, provenance: "unknown" }
|
|
4270
|
+
];
|
|
4271
|
+
var MIN_PLAUSIBLE_LIMIT = 1024;
|
|
4272
|
+
var MAX_PLAUSIBLE_LIMIT = 1e7;
|
|
4273
|
+
function extractErrorMessage(error) {
|
|
4274
|
+
if (!error)
|
|
4275
|
+
return "";
|
|
4276
|
+
if (typeof error === "string")
|
|
4277
|
+
return error;
|
|
4278
|
+
if (typeof error === "object") {
|
|
4279
|
+
const obj = error;
|
|
4280
|
+
const nested = obj.error;
|
|
4281
|
+
if (nested && typeof nested.message === "string" && nested.message.length > 0) {
|
|
4282
|
+
return nested.message;
|
|
4283
|
+
}
|
|
4284
|
+
}
|
|
4285
|
+
if (error instanceof Error)
|
|
4286
|
+
return error.message;
|
|
4287
|
+
if (typeof error === "object") {
|
|
4288
|
+
const obj = error;
|
|
4289
|
+
if (typeof obj.message === "string")
|
|
4290
|
+
return obj.message;
|
|
4291
|
+
if (typeof obj.responseBody === "string")
|
|
4292
|
+
return obj.responseBody;
|
|
4293
|
+
try {
|
|
4294
|
+
return JSON.stringify(error);
|
|
4295
|
+
} catch {
|
|
4296
|
+
return String(error);
|
|
4297
|
+
}
|
|
4298
|
+
}
|
|
4299
|
+
return String(error);
|
|
4300
|
+
}
|
|
4301
|
+
var PREFIX_BOUND_THINKING_MODELS = [
|
|
4302
|
+
["fable", 5, 1],
|
|
4303
|
+
["opus", 5, 5],
|
|
4304
|
+
["sonnet", 5, 5]
|
|
4305
|
+
];
|
|
4306
|
+
var PREFIX_BOUND_THINKING_PATTERN = new RegExp(`(?:^|[-_.:/])(?:${PREFIX_BOUND_THINKING_MODELS.map(([family, major, minor]) => `${family}[-_.]?${major}[-_.]${minor}`).join("|")})(?:$|[-_.:/@])`, "i");
|
|
4307
|
+
function isPrefixBoundThinkingModel(_providerID, modelID) {
|
|
4308
|
+
if (!modelID)
|
|
4309
|
+
return false;
|
|
4310
|
+
return PREFIX_BOUND_THINKING_PATTERN.test(modelID);
|
|
4311
|
+
}
|
|
4312
|
+
function isFable51ThinkingBindingModel(providerID, modelID) {
|
|
4313
|
+
if (providerID?.toLowerCase() !== "anthropic" || !modelID)
|
|
4314
|
+
return false;
|
|
4315
|
+
return /(?:^|[-_.])fable[-_.]?5[-_.]1(?:$|[-_.])/i.test(modelID);
|
|
4316
|
+
}
|
|
4317
|
+
function detectOverflow(error) {
|
|
4318
|
+
const message = extractErrorMessage(error);
|
|
4319
|
+
if (!message) {
|
|
4320
|
+
return { isOverflow: false };
|
|
4321
|
+
}
|
|
4322
|
+
const hasStatus413 = /\b413\b/.test(message) && /(entity|payload|context|prompt)/i.test(message);
|
|
4323
|
+
let matched;
|
|
4324
|
+
for (const pattern of OVERFLOW_PATTERNS) {
|
|
4325
|
+
if (pattern.test(message)) {
|
|
4326
|
+
matched = pattern;
|
|
4327
|
+
break;
|
|
4328
|
+
}
|
|
4329
|
+
}
|
|
4330
|
+
if (!matched && !hasStatus413) {
|
|
4331
|
+
return { isOverflow: false };
|
|
4332
|
+
}
|
|
4333
|
+
const reportedLimit = parseReportedLimit(message);
|
|
4334
|
+
const reportedInputTokens = parseReportedInputTokens(message);
|
|
4335
|
+
return {
|
|
4336
|
+
isOverflow: true,
|
|
4337
|
+
reportedInputTokens,
|
|
4338
|
+
reportedLimit: reportedLimit?.value,
|
|
4339
|
+
reportedLimitProvenance: reportedLimit?.provenance,
|
|
4340
|
+
matchedPattern: matched?.source
|
|
4341
|
+
};
|
|
4342
|
+
}
|
|
4343
|
+
function parseReportedInputTokens(message) {
|
|
4344
|
+
if (!message)
|
|
4345
|
+
return;
|
|
4346
|
+
const patterns = [
|
|
4347
|
+
/prompt is too long:\s*(\d+)/i,
|
|
4348
|
+
/input token count\s*\(?\s*(\d+)/i,
|
|
4349
|
+
/input length\s*(\d+)/i,
|
|
4350
|
+
/prompt was\s*(\d+)/i,
|
|
4351
|
+
/messages resulted in\s*(\d+)\s*tokens?/i
|
|
4352
|
+
];
|
|
4353
|
+
for (const pattern of patterns) {
|
|
4354
|
+
const raw = message.match(pattern)?.[1];
|
|
4355
|
+
if (!raw)
|
|
4356
|
+
continue;
|
|
4357
|
+
const value = Number.parseInt(raw, 10);
|
|
4358
|
+
if (Number.isFinite(value) && value > 0)
|
|
4359
|
+
return value;
|
|
4360
|
+
}
|
|
4361
|
+
return;
|
|
4362
|
+
}
|
|
4363
|
+
function parseReportedLimit(message) {
|
|
4364
|
+
if (!message)
|
|
4365
|
+
return;
|
|
4366
|
+
for (const { pattern, provenance } of LIMIT_EXTRACTION_PATTERNS) {
|
|
4367
|
+
const match = message.match(pattern);
|
|
4368
|
+
if (!match)
|
|
4369
|
+
continue;
|
|
4370
|
+
const raw = match[1];
|
|
4371
|
+
if (!raw)
|
|
4372
|
+
continue;
|
|
4373
|
+
const value = Number.parseInt(raw, 10);
|
|
4374
|
+
if (!Number.isFinite(value))
|
|
4375
|
+
continue;
|
|
4376
|
+
if (value < MIN_PLAUSIBLE_LIMIT || value > MAX_PLAUSIBLE_LIMIT)
|
|
4377
|
+
continue;
|
|
4378
|
+
return { value, provenance };
|
|
4379
|
+
}
|
|
4380
|
+
return;
|
|
4381
|
+
}
|
|
4382
|
+
|
|
4383
|
+
// src/hooks/magic-context/sentinel.ts
|
|
4384
|
+
var WHOLE_MESSAGE_PLACEHOLDER_TEXT = "[dropped]";
|
|
4385
|
+
function modelAcceptsEmptyContent(providerID) {
|
|
4386
|
+
return providerID === "anthropic";
|
|
4387
|
+
}
|
|
4388
|
+
function isAnthropicFamilyRoute(providerID, modelID) {
|
|
4389
|
+
const provider = (providerID ?? "").toLowerCase();
|
|
4390
|
+
const model = (modelID ?? "").toLowerCase();
|
|
4391
|
+
return provider.includes("anthropic") || model.includes("claude") || model.includes("anthropic");
|
|
4392
|
+
}
|
|
4393
|
+
var REMOVED_REASONING_MARK = Symbol.for("magic-context.removed-reasoning");
|
|
4394
|
+
var NEUTRALIZED_ORIGINALS = new WeakMap;
|
|
4395
|
+
function neutralizeDroppedReasoningPart(part) {
|
|
4396
|
+
if (!isRecord(part))
|
|
4397
|
+
return;
|
|
4398
|
+
if (part.thinking === undefined && part.text === undefined)
|
|
4399
|
+
return;
|
|
4400
|
+
if (part.type === "text")
|
|
4401
|
+
return;
|
|
4402
|
+
NEUTRALIZED_ORIGINALS.set(part, { ...part });
|
|
4403
|
+
const cacheControl = part.cache_control;
|
|
4404
|
+
const cacheControlCamel = part.cacheControl;
|
|
4405
|
+
for (const key of Object.keys(part))
|
|
4406
|
+
delete part[key];
|
|
4407
|
+
part.type = "text";
|
|
4408
|
+
part.text = "";
|
|
4409
|
+
if (cacheControl !== undefined)
|
|
4410
|
+
part.cache_control = cacheControl;
|
|
4411
|
+
if (cacheControlCamel !== undefined)
|
|
4412
|
+
part.cacheControl = cacheControlCamel;
|
|
4413
|
+
Object.defineProperty(part, REMOVED_REASONING_MARK, {
|
|
4414
|
+
value: true,
|
|
4415
|
+
enumerable: false,
|
|
4416
|
+
configurable: true
|
|
4417
|
+
});
|
|
4418
|
+
}
|
|
4419
|
+
function restoreNeutralizedReasoningPart(part, legacyCleared) {
|
|
4420
|
+
if (!isRecord(part))
|
|
4421
|
+
return false;
|
|
4422
|
+
const original = NEUTRALIZED_ORIGINALS.get(part);
|
|
4423
|
+
if (!original)
|
|
4424
|
+
return false;
|
|
4425
|
+
for (const key of Object.keys(part))
|
|
4426
|
+
delete part[key];
|
|
4427
|
+
Object.assign(part, original);
|
|
4428
|
+
if (legacyCleared) {
|
|
4429
|
+
if (part.thinking !== undefined)
|
|
4430
|
+
part.thinking = "[cleared]";
|
|
4431
|
+
if (part.text !== undefined)
|
|
4432
|
+
part.text = "[cleared]";
|
|
4433
|
+
}
|
|
4434
|
+
NEUTRALIZED_ORIGINALS.delete(part);
|
|
4435
|
+
delete part[REMOVED_REASONING_MARK];
|
|
4436
|
+
return true;
|
|
4437
|
+
}
|
|
4438
|
+
function isNeutralizedReasoningPart(part) {
|
|
4439
|
+
return isRecord(part) && part[REMOVED_REASONING_MARK] === true;
|
|
4440
|
+
}
|
|
4441
|
+
var VARIANT_CACHE_PRESERVING_MODELS = {
|
|
4442
|
+
"anthropic/claude-fable-5-1": "2026-09-02",
|
|
4443
|
+
"openai/gpt-6-astra": "2026-09-05",
|
|
4444
|
+
"anthropic/claude-opus-5-5": "2026-09-23"
|
|
4445
|
+
};
|
|
4446
|
+
function canonicalVariantModelIdentity(providerID, modelID) {
|
|
4447
|
+
const normalizedProviderID = providerID.toLowerCase();
|
|
4448
|
+
const isAnthropicFamily = normalizedProviderID === "anthropic" || normalizedProviderID === "google-vertex-anthropic" || normalizedProviderID.includes("bedrock");
|
|
4449
|
+
if (isAnthropicFamily && isFable51ThinkingBindingModel("anthropic", modelID)) {
|
|
4450
|
+
return "anthropic/claude-fable-5-1";
|
|
4451
|
+
}
|
|
4452
|
+
return canonicalModelIdentity(`${providerID}/${modelID}`).toLowerCase();
|
|
4453
|
+
}
|
|
4454
|
+
function variantChangeBustsProviderCache(providerID, modelID) {
|
|
4455
|
+
if (!providerID || !modelID)
|
|
4456
|
+
return false;
|
|
4457
|
+
const identity = canonicalVariantModelIdentity(providerID, modelID);
|
|
4458
|
+
if (Object.hasOwn(VARIANT_CACHE_PRESERVING_MODELS, identity))
|
|
4459
|
+
return false;
|
|
4460
|
+
const normalizedProviderID = providerID.toLowerCase();
|
|
4461
|
+
return normalizedProviderID === "anthropic" || normalizedProviderID === "google-vertex-anthropic" || normalizedProviderID.includes("bedrock");
|
|
4462
|
+
}
|
|
4463
|
+
function makeSentinel(originalPart) {
|
|
4464
|
+
const sentinel = {
|
|
4465
|
+
type: "text",
|
|
4466
|
+
text: ""
|
|
4467
|
+
};
|
|
4468
|
+
if (isRecord(originalPart)) {
|
|
4469
|
+
if (originalPart.cache_control !== undefined) {
|
|
4470
|
+
sentinel.cache_control = originalPart.cache_control;
|
|
4471
|
+
}
|
|
4472
|
+
if (originalPart.cacheControl !== undefined) {
|
|
4473
|
+
sentinel.cacheControl = originalPart.cacheControl;
|
|
4474
|
+
}
|
|
4475
|
+
}
|
|
4476
|
+
return sentinel;
|
|
4477
|
+
}
|
|
4478
|
+
function makeWholeMessageSentinel(providerID) {
|
|
4479
|
+
return {
|
|
4480
|
+
type: "text",
|
|
4481
|
+
text: modelAcceptsEmptyContent(providerID) ? "" : WHOLE_MESSAGE_PLACEHOLDER_TEXT
|
|
4482
|
+
};
|
|
4483
|
+
}
|
|
4484
|
+
function isSentinel(part) {
|
|
4485
|
+
if (!isRecord(part))
|
|
4486
|
+
return false;
|
|
4487
|
+
if (part.type !== "text")
|
|
4488
|
+
return false;
|
|
4489
|
+
if (typeof part.text !== "string")
|
|
4490
|
+
return false;
|
|
4491
|
+
return part.text === "" || part.text === WHOLE_MESSAGE_PLACEHOLDER_TEXT;
|
|
4492
|
+
}
|
|
4493
|
+
function replaySentinelByMessageIds(messages, ids, providerID, hiddenSeamIds = new Set) {
|
|
4494
|
+
if (ids.size === 0)
|
|
4495
|
+
return { replayed: 0, missingIds: [] };
|
|
4496
|
+
const seen = new Set;
|
|
4497
|
+
let replayed = 0;
|
|
4498
|
+
for (let index = messages.length - 1;index >= 0; index -= 1) {
|
|
4499
|
+
const msg = messages[index];
|
|
4500
|
+
const id = msg.info.id;
|
|
4501
|
+
if (!id || !ids.has(id))
|
|
4502
|
+
continue;
|
|
4503
|
+
seen.add(id);
|
|
4504
|
+
if (!modelAcceptsEmptyContent(providerID) && hiddenSeamIds.has(id)) {
|
|
4505
|
+
messages.splice(index, 1);
|
|
4506
|
+
replayed += 1;
|
|
4507
|
+
continue;
|
|
4508
|
+
}
|
|
4509
|
+
if (msg.parts.length === 1 && isSentinel(msg.parts[0]))
|
|
4510
|
+
continue;
|
|
4511
|
+
msg.parts.length = 0;
|
|
4512
|
+
msg.parts.push(makeWholeMessageSentinel(providerID));
|
|
4513
|
+
replayed += 1;
|
|
4514
|
+
}
|
|
4515
|
+
const missingIds = [];
|
|
4516
|
+
for (const id of ids)
|
|
4517
|
+
if (!seen.has(id))
|
|
4518
|
+
missingIds.push(id);
|
|
4519
|
+
return { replayed, missingIds };
|
|
4520
|
+
}
|
|
4521
|
+
|
|
4534
4522
|
// src/hooks/magic-context/tool-input-size.ts
|
|
4535
4523
|
var SKELETON_REAL_INPUT_MAX_BYTES = 1024;
|
|
4536
4524
|
var encoder2 = new TextEncoder;
|
|
@@ -4713,12 +4701,8 @@ function hasMeaningfulPart(part) {
|
|
|
4713
4701
|
return true;
|
|
4714
4702
|
}
|
|
4715
4703
|
function clearThinkingParts(thinkingParts) {
|
|
4716
|
-
for (const part of thinkingParts)
|
|
4717
|
-
|
|
4718
|
-
part.thinking = "[cleared]";
|
|
4719
|
-
if (part.text !== undefined)
|
|
4720
|
-
part.text = "[cleared]";
|
|
4721
|
-
}
|
|
4704
|
+
for (const part of thinkingParts)
|
|
4705
|
+
neutralizeDroppedReasoningPart(part);
|
|
4722
4706
|
}
|
|
4723
4707
|
function messageHasNativeReasoning(message) {
|
|
4724
4708
|
return message.parts.some((part) => {
|
|
@@ -4963,7 +4947,7 @@ function createToolDropTarget(compositeKey, thinkingParts, index, batch, tagId)
|
|
|
4963
4947
|
},
|
|
4964
4948
|
canDrop: () => {
|
|
4965
4949
|
const entry = index.get(compositeKey);
|
|
4966
|
-
return !!entry && entry.occurrences.length > 0 && entry.hasResult;
|
|
4950
|
+
return !!entry && entry.occurrences.length > 0 && entry.hasResult && !entry.occurrences.some((occurrence) => toolPartHasUserAnswer(occurrence.part));
|
|
4967
4951
|
},
|
|
4968
4952
|
requiresToolArcSkeleton: thinkingParts.length > 0 || (index.get(compositeKey)?.occurrences.some((occurrence) => messageHasNativeReasoning(occurrence.message)) ?? false),
|
|
4969
4953
|
readInput: () => {
|
|
@@ -5012,29 +4996,77 @@ var sessionProviders = new Map;
|
|
|
5012
4996
|
function resolveHostServedBoundaryId2(sessionId, messageId) {
|
|
5013
4997
|
if (messageId.length === 0)
|
|
5014
4998
|
return messageId;
|
|
5015
|
-
return sessionProviders.get(sessionId)?.readServedBoundaryId?.(messageId) ?? messageId;
|
|
4999
|
+
return sessionProviders.get(sessionId)?.provider.readServedBoundaryId?.(messageId) ?? messageId;
|
|
5016
5000
|
}
|
|
5017
5001
|
function hasRawMessageProvider2(sessionId) {
|
|
5018
5002
|
return sessionProviders.has(sessionId);
|
|
5019
5003
|
}
|
|
5020
5004
|
function setRawMessageProvider2(sessionId, provider) {
|
|
5021
|
-
sessionProviders.
|
|
5005
|
+
const current = sessionProviders.get(sessionId);
|
|
5006
|
+
const registration = current?.provider === provider ? current : { provider, scopes: 0 };
|
|
5007
|
+
registration.scopes += 1;
|
|
5008
|
+
sessionProviders.set(sessionId, registration);
|
|
5009
|
+
let active = true;
|
|
5022
5010
|
return () => {
|
|
5023
|
-
|
|
5024
|
-
|
|
5011
|
+
if (!active)
|
|
5012
|
+
return;
|
|
5013
|
+
active = false;
|
|
5014
|
+
registration.scopes -= 1;
|
|
5015
|
+
if (registration.scopes === 0 && sessionProviders.get(sessionId) === registration) {
|
|
5025
5016
|
sessionProviders.delete(sessionId);
|
|
5017
|
+
}
|
|
5026
5018
|
};
|
|
5027
5019
|
}
|
|
5020
|
+
var boundedProviderWrappers = new WeakMap;
|
|
5028
5021
|
function setBoundedRawMessageProvider2(sessionId, provider) {
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5022
|
+
let wrapper = boundedProviderWrappers.get(provider);
|
|
5023
|
+
if (!wrapper) {
|
|
5024
|
+
wrapper = {
|
|
5025
|
+
...provider,
|
|
5026
|
+
readMessages: () => {
|
|
5027
|
+
throw new Error("Bounded raw-message providers cannot read complete history; full reads are reserved for store-generation conversion");
|
|
5028
|
+
}
|
|
5029
|
+
};
|
|
5030
|
+
boundedProviderWrappers.set(provider, wrapper);
|
|
5031
|
+
}
|
|
5032
|
+
return setRawMessageProvider2(sessionId, wrapper);
|
|
5033
|
+
}
|
|
5034
|
+
function withRawMessageProvider2(sessionId, provider, fn) {
|
|
5035
|
+
const cleanup = setRawMessageProvider2(sessionId, provider);
|
|
5036
|
+
let result;
|
|
5037
|
+
try {
|
|
5038
|
+
result = fn();
|
|
5039
|
+
} catch (error) {
|
|
5040
|
+
cleanup();
|
|
5041
|
+
throw error;
|
|
5042
|
+
}
|
|
5043
|
+
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
|
5044
|
+
return result.finally(cleanup);
|
|
5045
|
+
}
|
|
5046
|
+
cleanup();
|
|
5047
|
+
return result;
|
|
5035
5048
|
}
|
|
5049
|
+
var SYSTEM_REMINDER_BLOCK_REGEX = /<system-reminder>[\s\S]*?<\/system-reminder>/gi;
|
|
5036
5050
|
function cleanUserText2(text) {
|
|
5037
|
-
return
|
|
5051
|
+
return stripOutsideSteeringWrappers(text, (segment) => segment.replace(SYSTEM_REMINDER_BLOCK_REGEX, "").replace(OMO_INTERNAL_INITIATOR_MARKER, "")).trim();
|
|
5052
|
+
}
|
|
5053
|
+
function hasMeaningfulChunkUserText(parts) {
|
|
5054
|
+
for (const part of parts) {
|
|
5055
|
+
if (part === null || typeof part !== "object")
|
|
5056
|
+
continue;
|
|
5057
|
+
const candidate = part;
|
|
5058
|
+
if (candidate.type !== "text" || typeof candidate.text !== "string")
|
|
5059
|
+
continue;
|
|
5060
|
+
if (candidate.ignored === true)
|
|
5061
|
+
continue;
|
|
5062
|
+
const cleaned = cleanUserText2(candidate.text);
|
|
5063
|
+
if (!cleaned)
|
|
5064
|
+
continue;
|
|
5065
|
+
if (isSystemDirective(cleaned))
|
|
5066
|
+
continue;
|
|
5067
|
+
return true;
|
|
5068
|
+
}
|
|
5069
|
+
return false;
|
|
5038
5070
|
}
|
|
5039
5071
|
function withRawSessionMessageCache2(fn) {
|
|
5040
5072
|
const outerCache = activeRawMessageCache;
|
|
@@ -5070,7 +5102,7 @@ function readRawSessionMessages2(sessionId) {
|
|
|
5070
5102
|
return readRawSessionMessagesFromSource(sessionId);
|
|
5071
5103
|
}
|
|
5072
5104
|
function readRawSessionMessagePage2(sessionId, afterOrdinal, limit, finalWatermark) {
|
|
5073
|
-
const provider = sessionProviders.get(sessionId);
|
|
5105
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5074
5106
|
if (provider?.readMessagePage) {
|
|
5075
5107
|
return provider.readMessagePage(afterOrdinal, limit, finalWatermark);
|
|
5076
5108
|
}
|
|
@@ -5082,7 +5114,7 @@ function readRawSessionMessagePage2(sessionId, afterOrdinal, limit, finalWaterma
|
|
|
5082
5114
|
return withReadOnlySessionDb((db) => readRawSessionMessagePageFromDb(db, sessionId, afterOrdinal, limit, finalWatermark));
|
|
5083
5115
|
}
|
|
5084
5116
|
function getRawSessionMessageOrdinalCount2(sessionId) {
|
|
5085
|
-
const provider = sessionProviders.get(sessionId);
|
|
5117
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5086
5118
|
if (provider) {
|
|
5087
5119
|
if (provider.getMessageCount)
|
|
5088
5120
|
return provider.getMessageCount();
|
|
@@ -5095,7 +5127,9 @@ function getRawSessionMessageOrdinalCount2(sessionId) {
|
|
|
5095
5127
|
}
|
|
5096
5128
|
var RAW_MESSAGE_RANGE_PAGE_SIZE = 100;
|
|
5097
5129
|
function readRawSessionMessageRangeFromSource(sessionId, fromOrdinal, toOrdinal) {
|
|
5098
|
-
const provider = sessionProviders.get(sessionId);
|
|
5130
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5131
|
+
if (provider?.iterateMessageRange)
|
|
5132
|
+
return [...provider.iterateMessageRange(fromOrdinal, toOrdinal)];
|
|
5099
5133
|
if (provider && !provider.readMessagePage) {
|
|
5100
5134
|
return provider.readMessages().filter((message) => message.ordinal >= fromOrdinal && message.ordinal <= toOrdinal);
|
|
5101
5135
|
}
|
|
@@ -5103,9 +5137,10 @@ function readRawSessionMessageRangeFromSource(sessionId, fromOrdinal, toOrdinal)
|
|
|
5103
5137
|
return [];
|
|
5104
5138
|
const messages = [];
|
|
5105
5139
|
let afterOrdinal = fromOrdinal - 1;
|
|
5140
|
+
let after;
|
|
5106
5141
|
while (afterOrdinal < toOrdinal) {
|
|
5107
5142
|
const limit = Math.min(RAW_MESSAGE_RANGE_PAGE_SIZE, toOrdinal - afterOrdinal);
|
|
5108
|
-
const page = provider?.readMessagePage ? provider.readMessagePage(afterOrdinal, limit, toOrdinal) : withReadOnlySessionDb((db) => readRawSessionMessagePageFromDb(db, sessionId, afterOrdinal, limit, toOrdinal));
|
|
5143
|
+
const page = provider?.readMessagePage ? provider.readMessagePage(afterOrdinal, limit, toOrdinal, after) : withReadOnlySessionDb((db) => readRawSessionMessagePageFromDb(db, sessionId, afterOrdinal, limit, toOrdinal, after));
|
|
5109
5144
|
if (page.length === 0)
|
|
5110
5145
|
break;
|
|
5111
5146
|
let nextOrdinal = afterOrdinal;
|
|
@@ -5118,16 +5153,25 @@ function readRawSessionMessageRangeFromSource(sessionId, fromOrdinal, toOrdinal)
|
|
|
5118
5153
|
if (nextOrdinal <= afterOrdinal)
|
|
5119
5154
|
break;
|
|
5120
5155
|
afterOrdinal = nextOrdinal;
|
|
5156
|
+
const last = page.at(-1);
|
|
5157
|
+
after = last ? { timeCreated: last.createdAt ?? 0, id: last.id } : undefined;
|
|
5121
5158
|
}
|
|
5122
5159
|
return messages;
|
|
5123
5160
|
}
|
|
5124
|
-
var
|
|
5161
|
+
var RAW_MESSAGE_VISIT_PAGE_SIZE2 = 50;
|
|
5125
5162
|
function visitRawSessionMessages2(sessionId, fromOrdinal, toOrdinal, visit, options = {}) {
|
|
5126
5163
|
const from = Math.max(1, Math.floor(fromOrdinal));
|
|
5127
5164
|
const to = Math.floor(toOrdinal);
|
|
5128
5165
|
if (to < from)
|
|
5129
5166
|
return;
|
|
5130
|
-
const provider = sessionProviders.get(sessionId);
|
|
5167
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5168
|
+
if (provider?.iterateMessageRange) {
|
|
5169
|
+
for (const message of provider.iterateMessageRange(from, to)) {
|
|
5170
|
+
if (!visit(message))
|
|
5171
|
+
return;
|
|
5172
|
+
}
|
|
5173
|
+
return;
|
|
5174
|
+
}
|
|
5131
5175
|
if (provider && !provider.readMessagePage) {
|
|
5132
5176
|
for (const message of provider.readMessages()) {
|
|
5133
5177
|
if (message.ordinal < from || message.ordinal > to)
|
|
@@ -5139,12 +5183,13 @@ function visitRawSessionMessages2(sessionId, fromOrdinal, toOrdinal, visit, opti
|
|
|
5139
5183
|
}
|
|
5140
5184
|
if (!provider && !openCodeDbExists())
|
|
5141
5185
|
return;
|
|
5142
|
-
const pageSize = Math.max(1, Math.floor(options.pageSize ??
|
|
5186
|
+
const pageSize = Math.max(1, Math.floor(options.pageSize ?? RAW_MESSAGE_VISIT_PAGE_SIZE2));
|
|
5143
5187
|
let afterOrdinal = from - 1;
|
|
5188
|
+
let after;
|
|
5144
5189
|
while (afterOrdinal < to) {
|
|
5145
5190
|
const limit = Math.min(pageSize, to - afterOrdinal);
|
|
5146
5191
|
const cursor = afterOrdinal;
|
|
5147
|
-
const page = provider?.readMessagePage ? provider.readMessagePage(cursor, limit, to) : withReadOnlySessionDb((db) => options.summary ? readRawSessionMessageSummaryPageFromDb(db, sessionId, cursor, limit, to) : readRawSessionMessagePageFromDb(db, sessionId, cursor, limit, to));
|
|
5192
|
+
const page = provider?.readMessagePage ? provider.readMessagePage(cursor, limit, to, after) : withReadOnlySessionDb((db) => options.summary ? readRawSessionMessageSummaryPageFromDb(db, sessionId, cursor, limit, to, after) : readRawSessionMessagePageFromDb(db, sessionId, cursor, limit, to, after));
|
|
5148
5193
|
if (page.length === 0)
|
|
5149
5194
|
return;
|
|
5150
5195
|
let nextOrdinal = afterOrdinal;
|
|
@@ -5158,6 +5203,8 @@ function visitRawSessionMessages2(sessionId, fromOrdinal, toOrdinal, visit, opti
|
|
|
5158
5203
|
if (nextOrdinal <= afterOrdinal)
|
|
5159
5204
|
return;
|
|
5160
5205
|
afterOrdinal = nextOrdinal;
|
|
5206
|
+
const last = page.at(-1);
|
|
5207
|
+
after = last ? { timeCreated: last.createdAt ?? 0, id: last.id } : undefined;
|
|
5161
5208
|
}
|
|
5162
5209
|
}
|
|
5163
5210
|
function readRawSessionMessageRange2(sessionId, fromOrdinal, toOrdinal) {
|
|
@@ -5194,7 +5241,7 @@ function primeTailRawMessageCache2(args) {
|
|
|
5194
5241
|
return false;
|
|
5195
5242
|
if (lastCompartmentEnd < 1 || !anchorMessageId)
|
|
5196
5243
|
return false;
|
|
5197
|
-
const provider = sessionProviders.get(sessionId);
|
|
5244
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5198
5245
|
if (provider) {
|
|
5199
5246
|
if (!provider.readMessagePage || !provider.getMessageCount)
|
|
5200
5247
|
return false;
|
|
@@ -5242,7 +5289,7 @@ function primeInMemoryTailRawMessageCache2(args) {
|
|
|
5242
5289
|
return true;
|
|
5243
5290
|
}
|
|
5244
5291
|
function readRawSessionMessageOrdinalPage2(sessionId, after, limit) {
|
|
5245
|
-
const provider = sessionProviders.get(sessionId);
|
|
5292
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5246
5293
|
if (provider?.readMessageOrdinalPage)
|
|
5247
5294
|
return provider.readMessageOrdinalPage(after, limit);
|
|
5248
5295
|
if (provider) {
|
|
@@ -5259,7 +5306,7 @@ function readRawSessionMessageOrdinalPage2(sessionId, after, limit) {
|
|
|
5259
5306
|
return withReadOnlySessionDb((db) => readRawSessionMessageOrdinalPageFromDb(db, sessionId, after, limit));
|
|
5260
5307
|
}
|
|
5261
5308
|
function getRawSessionStoredMessageCount2(sessionId) {
|
|
5262
|
-
const provider = sessionProviders.get(sessionId);
|
|
5309
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5263
5310
|
if (provider?.getStoredMessageCount)
|
|
5264
5311
|
return provider.getStoredMessageCount();
|
|
5265
5312
|
if (provider)
|
|
@@ -5273,15 +5320,19 @@ function readRawSessionMessageIdOrdinalsForRange2(sessionId, fromOrdinal, toOrdi
|
|
|
5273
5320
|
const to = Math.floor(toOrdinal);
|
|
5274
5321
|
if (to < from)
|
|
5275
5322
|
return new Map;
|
|
5276
|
-
const provider = sessionProviders.get(sessionId);
|
|
5323
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5277
5324
|
if (provider?.readMessageIdOrdinalsForRange) {
|
|
5278
5325
|
return provider.readMessageIdOrdinalsForRange(from, to);
|
|
5279
5326
|
}
|
|
5280
5327
|
const all = provider?.readMessageIdOrdinals ? provider.readMessageIdOrdinals() : provider ? new Map(provider.readMessages().map((message) => [message.id, message.ordinal])) : !openCodeDbExists() ? new Map : withReadOnlySessionDb((db) => readRawSessionMessageIdOrdinalsFromDb(db, sessionId));
|
|
5281
5328
|
return new Map([...all].filter(([, ordinal]) => ordinal >= from && ordinal <= to));
|
|
5282
5329
|
}
|
|
5330
|
+
function readRawSessionMessageIdOrdinals2(sessionId) {
|
|
5331
|
+
const count = getRawSessionMessageOrdinalCount2(sessionId);
|
|
5332
|
+
return readRawSessionMessageIdOrdinalsForRange2(sessionId, 1, count);
|
|
5333
|
+
}
|
|
5283
5334
|
function readRawSessionMessagePartsById2(sessionId, messageId, onQuery) {
|
|
5284
|
-
const provider = sessionProviders.get(sessionId);
|
|
5335
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5285
5336
|
if (provider?.readMessagePartsById)
|
|
5286
5337
|
return provider.readMessagePartsById(messageId);
|
|
5287
5338
|
if (provider?.readMessageById)
|
|
@@ -5294,13 +5345,13 @@ function readRawSessionMessagePartsById2(sessionId, messageId, onQuery) {
|
|
|
5294
5345
|
return withReadOnlySessionDb((db) => readRawSessionMessagePartsByIdFromDb(db, sessionId, messageId, onQuery));
|
|
5295
5346
|
}
|
|
5296
5347
|
function hasRawSessionMessageById2(sessionId, messageId) {
|
|
5297
|
-
const provider = sessionProviders.get(sessionId);
|
|
5348
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5298
5349
|
if (provider?.hasMessageById)
|
|
5299
5350
|
return provider.hasMessageById(messageId);
|
|
5300
5351
|
return readRawSessionMessageById2(sessionId, messageId) !== null;
|
|
5301
5352
|
}
|
|
5302
5353
|
function readRawSessionMessageOrdinalById2(sessionId, messageId) {
|
|
5303
|
-
const provider = sessionProviders.get(sessionId);
|
|
5354
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5304
5355
|
if (provider?.readMessageOrdinalById) {
|
|
5305
5356
|
return provider.readMessageOrdinalById(messageId);
|
|
5306
5357
|
}
|
|
@@ -5337,7 +5388,7 @@ function readRawSessionMessageOrdinalById2(sessionId, messageId) {
|
|
|
5337
5388
|
return withReadOnlySessionDb((db) => readRawSessionMessageOrdinalByIdFromDb(db, sessionId, messageId));
|
|
5338
5389
|
}
|
|
5339
5390
|
function compareRawSessionMessageOrder2(sessionId, leftId, rightId) {
|
|
5340
|
-
const provider = sessionProviders.get(sessionId);
|
|
5391
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5341
5392
|
if (provider) {
|
|
5342
5393
|
if (!provider.readMessageOrdinalById)
|
|
5343
5394
|
return null;
|
|
@@ -5361,7 +5412,7 @@ function compareRawSessionMessageOrder2(sessionId, leftId, rightId) {
|
|
|
5361
5412
|
});
|
|
5362
5413
|
}
|
|
5363
5414
|
function readRawSessionMessageById2(sessionId, messageId) {
|
|
5364
|
-
const provider = sessionProviders.get(sessionId);
|
|
5415
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5365
5416
|
if (provider?.readMessageById) {
|
|
5366
5417
|
return provider.readMessageById(messageId);
|
|
5367
5418
|
}
|
|
@@ -5373,7 +5424,7 @@ function readRawSessionMessageById2(sessionId, messageId) {
|
|
|
5373
5424
|
return withReadOnlySessionDb((db) => readRawSessionMessageByIdFromDb(db, sessionId, messageId));
|
|
5374
5425
|
}
|
|
5375
5426
|
function readRawSessionMessagesFromSource(sessionId) {
|
|
5376
|
-
const provider = sessionProviders.get(sessionId);
|
|
5427
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5377
5428
|
if (provider)
|
|
5378
5429
|
return provider.readMessages();
|
|
5379
5430
|
if (!openCodeDbExists())
|
|
@@ -5381,7 +5432,7 @@ function readRawSessionMessagesFromSource(sessionId) {
|
|
|
5381
5432
|
return withReadOnlySessionDb((db) => readRawSessionMessagesFromDb(db, sessionId));
|
|
5382
5433
|
}
|
|
5383
5434
|
function getRawSessionMessageCount2(sessionId) {
|
|
5384
|
-
const provider = sessionProviders.get(sessionId);
|
|
5435
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5385
5436
|
if (provider) {
|
|
5386
5437
|
if (provider.getMessageCount)
|
|
5387
5438
|
return provider.getMessageCount();
|
|
@@ -5392,7 +5443,7 @@ function getRawSessionMessageCount2(sessionId) {
|
|
|
5392
5443
|
return 0;
|
|
5393
5444
|
return withReadOnlySessionDb((db) => getRawSessionMessageCountFromDb(db, sessionId));
|
|
5394
5445
|
}
|
|
5395
|
-
var
|
|
5446
|
+
var RAW_SESSION_TAG_KEY_PAGE_SIZE2 = 32;
|
|
5396
5447
|
function yieldRawSessionTagKeyPage() {
|
|
5397
5448
|
return new Promise((resolve) => {
|
|
5398
5449
|
const immediate = globalThis.setImmediate;
|
|
@@ -5410,7 +5461,7 @@ async function getRawSessionTagKeysThrough2(sessionId, upToMessageIndex, options
|
|
|
5410
5461
|
const candidateOwnersByCallId = new Map;
|
|
5411
5462
|
const messageTimesById = new Map;
|
|
5412
5463
|
const finalWatermark = Number.isFinite(upToMessageIndex) ? Math.max(0, Math.floor(upToMessageIndex)) : getRawSessionMessageOrdinalCount2(sessionId);
|
|
5413
|
-
const pageSize = Number.isFinite(options.pageSize) ? Math.max(1, Math.floor(options.pageSize ??
|
|
5464
|
+
const pageSize = Number.isFinite(options.pageSize) ? Math.max(1, Math.floor(options.pageSize ?? RAW_SESSION_TAG_KEY_PAGE_SIZE2)) : RAW_SESSION_TAG_KEY_PAGE_SIZE2;
|
|
5414
5465
|
const yieldToEventLoop = options.yieldToEventLoop ?? yieldRawSessionTagKeyPage;
|
|
5415
5466
|
const nearestPersistedOwner = (callId, currentMessageId) => {
|
|
5416
5467
|
if (!options.db)
|
|
@@ -5508,11 +5559,42 @@ function getLegacyProtectedTailStartOrdinal2(sessionId) {
|
|
|
5508
5559
|
}
|
|
5509
5560
|
return userOrdinals.length < PROTECTED_TAIL_USER_TURNS ? 1 : userOrdinals[PROTECTED_TAIL_USER_TURNS - 1] ?? 1;
|
|
5510
5561
|
}
|
|
5511
|
-
function
|
|
5562
|
+
function getProtectedTailStartOrdinal2(sessionId) {
|
|
5563
|
+
return getLegacyProtectedTailStartOrdinal2(sessionId);
|
|
5564
|
+
}
|
|
5565
|
+
function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdinal, options = {}) {
|
|
5512
5566
|
const totalMessageCount = getCachedAbsoluteMessageCount2(sessionId) ?? getRawSessionMessageOrdinalCount2(sessionId);
|
|
5513
5567
|
const startOrdinal = Math.max(1, offset);
|
|
5514
5568
|
const finalOrdinal = eligibleEndOrdinal === undefined ? totalMessageCount : Math.min(totalMessageCount, eligibleEndOrdinal - 1);
|
|
5515
5569
|
const messages = readRawSessionMessageRange2(sessionId, Math.max(1, startOrdinal - 1), finalOrdinal);
|
|
5570
|
+
const expandedParts = new Map;
|
|
5571
|
+
const expandedResults = new Set;
|
|
5572
|
+
if (options.expand !== false) {
|
|
5573
|
+
const calls = new Map;
|
|
5574
|
+
for (const message of messages)
|
|
5575
|
+
for (const part of message.parts) {
|
|
5576
|
+
if (!part || typeof part !== "object")
|
|
5577
|
+
continue;
|
|
5578
|
+
const p = part;
|
|
5579
|
+
if (p.type !== "tool")
|
|
5580
|
+
continue;
|
|
5581
|
+
const state = p.state;
|
|
5582
|
+
if (state?.input !== undefined && typeof p.callID === "string")
|
|
5583
|
+
calls.set(p.callID, p);
|
|
5584
|
+
expandedParts.set(part, expandToolPart(part, options.expandTools));
|
|
5585
|
+
if (state?.input === undefined && state?.output !== undefined && typeof p.callID === "string") {
|
|
5586
|
+
const call = calls.get(p.callID);
|
|
5587
|
+
if (call) {
|
|
5588
|
+
const expansion = expandToolPart({ ...call, state: { ...call.state, output: state.output } }, options.expandTools);
|
|
5589
|
+
if (expansion !== null) {
|
|
5590
|
+
expandedParts.set(call, expansion);
|
|
5591
|
+
expandedResults.add(part);
|
|
5592
|
+
}
|
|
5593
|
+
calls.delete(p.callID);
|
|
5594
|
+
}
|
|
5595
|
+
}
|
|
5596
|
+
}
|
|
5597
|
+
}
|
|
5516
5598
|
const completedToolArcs = buildToolArcs(messages).flatMap((arc) => arc.resOrdinal === null ? [] : [{ start: arc.invOrdinal, end: arc.resOrdinal }]);
|
|
5517
5599
|
const completedToolComponents = [];
|
|
5518
5600
|
for (const arc of completedToolArcs) {
|
|
@@ -5620,8 +5702,13 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
5620
5702
|
const meta = { ordinal: msg.ordinal, messageId: msg.id };
|
|
5621
5703
|
if (isHostUnservedRow(msg))
|
|
5622
5704
|
markHostUnservedRow(meta);
|
|
5623
|
-
if (msg.role === "user" && !
|
|
5624
|
-
const tcSummaries =
|
|
5705
|
+
if (msg.role === "user" && !hasMeaningfulChunkUserText(msg.parts)) {
|
|
5706
|
+
const tcSummaries = msg.parts.flatMap((part) => {
|
|
5707
|
+
if (expandedResults.has(part))
|
|
5708
|
+
return [];
|
|
5709
|
+
const expansion = expandedParts.get(part) ?? null;
|
|
5710
|
+
return expansion === null ? extractToolCallSummaries([part]) : [`TC: ${expansion}`];
|
|
5711
|
+
});
|
|
5625
5712
|
if (tcSummaries.length === 0) {
|
|
5626
5713
|
recordFilteredNoise(meta);
|
|
5627
5714
|
continue;
|
|
@@ -5661,8 +5748,18 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
5661
5748
|
}
|
|
5662
5749
|
const role = compactRole(msg.role);
|
|
5663
5750
|
const textParts = extractTexts2(msg.parts).map((t) => msg.role === "user" ? cleanUserText2(t) : t).map(normalizeText).filter((value) => value.length > 0);
|
|
5664
|
-
const
|
|
5665
|
-
|
|
5751
|
+
const allParts = options.expand === false ? [
|
|
5752
|
+
...textParts,
|
|
5753
|
+
...textParts.length === 0 ? extractToolCallSummaries(msg.parts) : []
|
|
5754
|
+
] : msg.parts.flatMap((part) => {
|
|
5755
|
+
if (expandedResults.has(part))
|
|
5756
|
+
return [];
|
|
5757
|
+
const expansion = expandedParts.get(part) ?? null;
|
|
5758
|
+
if (expansion !== null)
|
|
5759
|
+
return [`TC: ${expansion}`];
|
|
5760
|
+
const texts = extractTexts2([part]).map((t) => msg.role === "user" ? cleanUserText2(t) : t).map(normalizeText).filter(Boolean);
|
|
5761
|
+
return texts.length ? texts : textParts.length === 0 ? extractToolCallSummaries([part]) : [];
|
|
5762
|
+
});
|
|
5666
5763
|
const compacted = compactTextForSummary(allParts.join(" / "), msg.role);
|
|
5667
5764
|
const text = compacted.text;
|
|
5668
5765
|
if (!text) {
|
|
@@ -5738,8 +5835,13 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
5738
5835
|
toolResultBoundaries
|
|
5739
5836
|
};
|
|
5740
5837
|
}
|
|
5838
|
+
function getRawSessionMessageIdsThrough2(sessionId, endOrdinal) {
|
|
5839
|
+
if (endOrdinal < 1)
|
|
5840
|
+
return [];
|
|
5841
|
+
return [...readRawSessionMessageIdOrdinalsForRange2(sessionId, 1, endOrdinal).entries()].sort((left, right) => left[1] - right[1]).map(([id]) => id);
|
|
5842
|
+
}
|
|
5741
5843
|
function readRawSessionSeedTail2(sessionId, boundaryId, onQuery) {
|
|
5742
|
-
const provider = sessionProviders.get(sessionId);
|
|
5844
|
+
const provider = sessionProviders.get(sessionId)?.provider;
|
|
5743
5845
|
if (provider) {
|
|
5744
5846
|
const boundaryOrdinal = boundaryId === null ? 1 : readRawSessionMessageOrdinalById2(sessionId, boundaryId);
|
|
5745
5847
|
if (boundaryOrdinal === null)
|
|
@@ -5758,4 +5860,4 @@ function readRawSessionSeedTail2(sessionId, boundaryId, onQuery) {
|
|
|
5758
5860
|
});
|
|
5759
5861
|
}
|
|
5760
5862
|
|
|
5761
|
-
export {
|
|
5863
|
+
export { isPrefixBoundThinkingModel, detectOverflow, CTX_REDUCE_KEEP, newestCtxReduceTagNumbers, stripWellFormedLeadingTagPrefix, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, isRecord, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchanged, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, getRecentTagOwnerMessageIds, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, getActiveTagTokenTotalsByMessage, getAllStatusTagTokenTotalsFlat, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, markWhitespaceAssistantTagInert, getInertWhitespaceAssistantTags, updateTagDropMode, updateCavemanDepth, updateTagMessageId, foldShrunkPartTags, markTagsCompactedByMessageIds, getMaxTagNumberBySession, getTagNumberByMessageId, getAssignableTagNumberByMessageId, deriveTagLoadFloor, TAG_SELECT_COLUMNS, getTagsBySession, getActiveTagsBySession, getTailHygieneTags, getDroppedTagsBySession, getTagsByNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getTagById, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, getCandidateToolOwners, pickNearestPriorOwner, expandToolPart, markHostUnservedRow, retreatPastHostUnservedRows, snapTerminalCompartmentToServedRow, isHostRenderedSystemMessage, isStrictGapHealingMessage, isRawCompactionSummaryInfo, extractInMemoryMessageViews, buildInMemoryTailRawMessages, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, stripSystemInjection, isTextPart, isToolPartWithOutput, isFilePart, buildFileSourceContent, toolPartHasUserAnswer, DreamTokenBudgetExceeded, TOKEN_BUDGET_FINALIZE_MESSAGE, registerBudgetFinalizeChild, releaseBudgetFinalizeChild, createDreamTokenBudget, recordToolParameters, createDroppedInputGuard, assertExecutableToolInput, isEditTool, describeFinalWireTail, estimateMessageTokens, wireContentBytes, estimateFinalWireInputTokens, modelAcceptsEmptyContent, isAnthropicFamilyRoute, neutralizeDroppedReasoningPart, restoreNeutralizedReasoningPart, isNeutralizedReasoningPart, variantChangeBustsProviderCache, makeSentinel, makeWholeMessageSentinel, isSentinel, replaySentinelByMessageIds, SKELETON_REAL_INPUT_MAX_BYTES, partHasCompletedResult, extractToolCallObservation, ToolMutationBatch, createToolDropTarget, resolveHostServedBoundaryId2, hasRawMessageProvider2, setRawMessageProvider2, setBoundedRawMessageProvider2, withRawMessageProvider2, cleanUserText2, withRawSessionMessageCache2, readRawSessionMessages2, readRawSessionMessagePage2, getRawSessionMessageOrdinalCount2, RAW_MESSAGE_VISIT_PAGE_SIZE2, visitRawSessionMessages2, readRawSessionMessageRange2, primeTailRawMessageCache2, getCachedAbsoluteMessageCount2, primeInMemoryTailRawMessageCache2, readRawSessionMessageOrdinalPage2, getRawSessionStoredMessageCount2, readRawSessionMessageIdOrdinalsForRange2, readRawSessionMessageIdOrdinals2, readRawSessionMessagePartsById2, hasRawSessionMessageById2, readRawSessionMessageOrdinalById2, compareRawSessionMessageOrder2, readRawSessionMessageById2, getRawSessionMessageCount2, RAW_SESSION_TAG_KEY_PAGE_SIZE2, getRawSessionTagKeysThrough2, getLegacyProtectedTailStartOrdinal2, getProtectedTailStartOrdinal2, readSessionChunk2, getRawSessionMessageIdsThrough2, readRawSessionSeedTail2 };
|