@cortexkit/opencode-magic-context 0.49.19 → 0.49.21
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/auto-search-worker.js +48 -9
- package/dist/chunk-embedding-write-worker.js +30 -23
- package/dist/{compaction-marker-candidates-n4krhat4.js → compaction-marker-candidates-31h86ph0.js} +3 -3
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/compartment-chunk-embedding-he60aaa2.js +65 -0
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +43 -9
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-4pmz879v.js → conflict-warning-hook-2r32hyx6.js} +9 -8
- package/dist/{context-j31m2dv7.js → context-j7hp43a0.js} +576 -185
- package/dist/{derive-budgets-zn7yzd2d.js → derive-budgets-pqybnx09.js} +2 -2
- package/dist/embedding-backfill-dtke6tck.js +25 -0
- package/dist/embedding-worker-process.js +2 -2
- package/dist/embedding-worker.js +6 -6
- package/dist/features/magic-context/chunk-embedding-writer.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +44 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts +1 -0
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +2 -0
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +1 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts +7 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/memory/local-embedding-pooling.d.ts +22 -0
- package/dist/features/magic-context/memory/local-embedding-pooling.d.ts.map +1 -0
- package/dist/features/magic-context/message-index-async.d.ts +7 -2
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +2 -0
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/mural/compress-cues.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/search-rerank.d.ts +9 -2
- package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +29 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -0
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +2 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/subagent-token-capture.d.ts +20 -0
- package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
- package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
- package/dist/{history-owner-xp3pngv7.js → history-owner-36wp3mkb.js} +2 -2
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-embed-session.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-hint.d.ts +7 -1
- package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts +33 -6
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +6 -2
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/channel2-delivery.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-types.d.ts +5 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/diagnostic-log-state.d.ts +4 -0
- package/dist/hooks/magic-context/diagnostic-log-state.d.ts.map +1 -0
- package/dist/hooks/magic-context/execute-reclaim.d.ts +35 -0
- package/dist/hooks/magic-context/execute-reclaim.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +1 -3
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/latest-assistant-turn.d.ts +8 -0
- package/dist/hooks/magic-context/latest-assistant-turn.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +5 -0
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/nudge-evaluation-log.d.ts +3 -0
- package/dist/hooks/magic-context/nudge-evaluation-log.d.ts.map +1 -0
- package/dist/hooks/magic-context/pending-drop-eligibility.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +4 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/served-shape-repair.d.ts +19 -0
- package/dist/hooks/magic-context/served-shape-repair.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts +4 -2
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-date-refresh.d.ts +5 -5
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts +10 -0
- package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts.map +1 -0
- package/dist/hooks/magic-context/tag-content-primitives.d.ts +1 -1
- package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +4 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/text-complete.d.ts +1 -1
- package/dist/hooks/magic-context/text-complete.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +21 -6
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +2 -2
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-3esx8tkf.js → index-11gzxvf4.js} +394 -125
- package/dist/{index-jn12fvvh.js → index-1gtfne2c.js} +3 -3
- package/dist/{index-jhghdnsm.js → index-1kbznkft.js} +521 -214
- package/dist/{index-3h4dp9wb.js → index-3svaejkh.js} +5 -5
- package/dist/{index-kee4kn5j.js → index-4pnsgvfk.js} +1 -1
- package/dist/{index-bjcnntmz.js → index-51rdvtkz.js} +501 -20
- package/dist/{v2/server-8cd2j99z.js → index-5kym00ag.js} +32 -13
- package/dist/{index-s74zqahq.js → index-66eby7hx.js} +4 -4
- package/dist/{index-63k48rv9.js → index-9q1g3c5q.js} +5 -5
- package/dist/{index-jrr131e0.js → index-a9zvn5fe.js} +29 -15
- package/dist/{index-c5pytzne.js → index-b88dwwrh.js} +1 -1
- package/dist/{index-nj7yykkx.js → index-c7phnbvk.js} +1 -1
- package/dist/index-cpjk5jd2.js +82 -0
- package/dist/{index-c1p88z1y.js → index-ffzhwfzy.js} +4 -4
- package/dist/{v2/server-beht37jy.js → index-gzy5w8ya.js} +194 -5
- package/dist/{index-j75v2476.js → index-h7tgn49j.js} +12 -15
- package/dist/{index-edmpdxcw.js → index-j32jj2t8.js} +5 -5
- package/dist/{index-ke416mdc.js → index-j76ah6d7.js} +2 -2
- package/dist/{index-s734jcsr.js → index-jfem3dgz.js} +9 -3
- package/dist/{index-n37sebck.js → index-jjvbk92s.js} +1 -1
- package/dist/{index-4911rn0b.js → index-jmq8kfe7.js} +6 -6
- package/dist/{index-rr2bb45z.js → index-kfyb3k6n.js} +2 -2
- package/dist/{index-2vxtcb95.js → index-kq5w68dp.js} +2 -2
- package/dist/{index-kq82mtg0.js → index-ksq50rg0.js} +3 -3
- package/dist/{index-b5vqckbw.js → index-m32esgmj.js} +314 -127
- package/dist/{index-9zcsy3hh.js → index-mnhcdfxg.js} +161 -13
- package/dist/{index-se4m2g6w.js → index-mnnkgq0q.js} +111 -19
- package/dist/{index-p5y3k4g7.js → index-nda0zgna.js} +2 -1
- package/dist/{index-wgypt3cs.js → index-nxrsns5x.js} +2466 -1290
- package/dist/{index-4s3t0nd0.js → index-qgh1qwjj.js} +2 -2
- package/dist/{index-y9f76s3f.js → index-rrv26qjz.js} +1 -1
- package/dist/{index-24fezq97.js → index-rxqr723x.js} +5 -5
- package/dist/{index-v10f1rjv.js → index-spwjbkc7.js} +1 -1
- package/dist/{index-dxmq29t1.js → index-syaazvy2.js} +182 -47
- package/dist/{index-k29z4aqh.js → index-t5pck3ss.js} +1 -1
- package/dist/{index-6x57ar45.js → index-wfybj1dw.js} +4 -6
- package/dist/{index-cf74k5ak.js → index-whcgcfrv.js} +9 -6
- package/dist/{index-a6mc0v4d.js → index-x6cbrv9h.js} +3 -3
- package/dist/{index-bp5083x2.js → index-x9k3mqrf.js} +1 -1
- package/dist/{index-rpxdjkm0.js → index-y76rhsnr.js} +319 -61
- package/dist/{index-ze7mvk54.js → index-zy67whjr.js} +95 -59
- package/dist/index.js +58 -54
- package/dist/{logger-jm3sqqzr.js → logger-94kew5wm.js} +1 -1
- package/dist/{message-fts-rowid-map-17s0dfn4.js → message-fts-rowid-map-e79b7b6x.js} +6 -5
- package/dist/{message-index-gtpqnj8w.js → message-index-4q8ek2fc.js} +17 -16
- package/dist/{message-index-bounded-zyc8h32y.js → message-index-bounded-rydsg9r5.js} +17 -16
- package/dist/{message-time-backfill-73mmm76q.js → message-time-backfill-4qva0b4f.js} +3 -3
- package/dist/migration-worker.js +13 -12
- package/dist/{model-resolution-nx97z3x7.js → model-resolution-280gmqvd.js} +1 -1
- package/dist/plugin/embedding-bootstrap.d.ts +4 -1
- package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +1 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +8 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/subagent-tool-policy.d.ts +9 -0
- package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/{project-embedding-registry-z74mhqkf.js → project-embedding-registry-hn529988.js} +16 -13
- package/dist/raw-ordinal-warmup-worker.js +136 -101
- package/dist/{read-session-chunk-jjb48bt9.js → read-session-chunk-t039f0m5.js} +12 -11
- package/dist/{read-session-raw-rsc8c7qy.js → read-session-raw-aw6jgvwg.js} +4 -3
- package/dist/recomp-orchestrator-hbm53jj5.js +62 -0
- package/dist/{safe-notification-target-1szv1k5k.js → safe-notification-target-mkr9yzvr.js} +2 -2
- package/dist/search-archive-weh164mh.js +26 -0
- package/dist/search-hea079d7.js +50 -0
- package/dist/{send-session-notification-6ve0e8p4.js → send-session-notification-gqzkz7da.js} +7 -6
- package/dist/shared/logger.d.ts.map +1 -1
- package/dist/shared/model-resolution.d.ts +2 -0
- package/dist/shared/model-resolution.d.ts.map +1 -1
- package/dist/shared/prompt-async-transport.d.ts +3 -0
- package/dist/shared/prompt-async-transport.d.ts.map +1 -1
- package/dist/shared/rpc-types.d.ts +7 -0
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/sqlite.d.ts +6 -1
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/subagent-runner.d.ts +2 -0
- package/dist/shared/subagent-runner.d.ts.map +1 -1
- package/dist/shared/tag-transcript.d.ts +2 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/worker-shutdown.d.ts +68 -0
- package/dist/shared/worker-shutdown.d.ts.map +1 -0
- package/dist/shared/worker-shutdown.fixture.d.ts +2 -0
- package/dist/shared/worker-shutdown.fixture.d.ts.map +1 -0
- package/dist/{sqlite-zf72c52d.js → sqlite-zdgm52sv.js} +5 -1
- package/dist/{storage-memory-y3qmy00r.js → storage-memory-e6a7mb0k.js} +2 -2
- package/dist/{storage-tags-r7k9tjcv.js → storage-tags-a77q4v77.js} +5 -5
- package/dist/{task-config-x3qmayd2.js → task-config-t6bpyka7.js} +2 -2
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/types.d.ts +1 -0
- package/dist/tools/ctx-search/types.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-jj99r7z2.js → transform-postprocess-phase-0b04tm1p.js} +35 -32
- package/dist/v2/auto-search-worker.js +48 -9
- package/dist/v2/chunk-embedding-write-worker.js +30 -23
- package/dist/v2/{compaction-marker-candidates-ebx3388k.js → compaction-marker-candidates-m4vmye3w.js} +3 -3
- package/dist/v2/compaction-marker-candidates-worker.js +2 -2
- package/dist/v2/compartment-chunk-embedding-8jjmcgeg.js +64 -0
- package/dist/v2/{context-y5yamxak.js → context-ea3x7smm.js} +1797 -810
- package/dist/v2/{derive-budgets-2zh4gm2c.js → derive-budgets-knf763tt.js} +3 -3
- package/dist/v2/embedding-backfill-5e74ae0m.js +24 -0
- package/dist/v2/embedding-worker-process.js +2 -2
- package/dist/v2/embedding-worker.js +6 -6
- package/dist/v2/hidden-child-record.d.ts +2 -0
- package/dist/v2/hidden-child-record.d.ts.map +1 -1
- package/dist/v2/hidden-completion.d.ts +2 -0
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hidden-model-activity.d.ts +7 -0
- package/dist/v2/hidden-model-activity.d.ts.map +1 -0
- package/dist/v2/{history-owner-42e16w0n.js → history-owner-ad0crnrn.js} +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/copied-tag-notation.d.ts +1 -1
- package/dist/v2/hooks/copied-tag-notation.d.ts.map +1 -1
- package/dist/v2/hooks/dream-timer.d.ts +2 -0
- package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
- package/dist/v2/hooks/embedding-lifecycle.d.ts +7 -0
- package/dist/v2/hooks/embedding-lifecycle.d.ts.map +1 -0
- package/dist/v2/hooks/generate.d.ts +36 -1
- package/dist/v2/hooks/generate.d.ts.map +1 -1
- package/dist/v2/hooks/lkg-system.d.ts +35 -4
- package/dist/v2/hooks/lkg-system.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts +16 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts +2 -0
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts +2 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/hooks/transform-features.d.ts +2 -2
- package/dist/v2/hooks/transform-features.d.ts.map +1 -1
- package/dist/v2/{logger-7qt02bnb.js → logger-p34mjtja.js} +1 -1
- package/dist/v2/{message-fts-rowid-map-wfx67gfd.js → message-fts-rowid-map-n8fdg2ja.js} +6 -5
- package/dist/v2/{message-index-bounded-spd8r7pj.js → message-index-bounded-8rcd7qq9.js} +17 -16
- package/dist/v2/{message-index-8vz2pq76.js → message-index-qz9wdp82.js} +17 -16
- package/dist/v2/{message-time-backfill-04t0km1z.js → message-time-backfill-zvthw6xb.js} +3 -3
- package/dist/v2/migration-worker.js +13 -12
- package/dist/v2/{model-resolution-nx97z3x7.js → model-resolution-280gmqvd.js} +1 -1
- package/dist/v2/{project-embedding-registry-gnkj56xp.js → project-embedding-registry-v38q4xd5.js} +16 -13
- package/dist/v2/raw-ordinal-warmup-worker.js +136 -101
- package/dist/v2/{read-session-chunk-cwkxrmns.js → read-session-chunk-wazfyxcg.js} +12 -11
- package/dist/v2/{read-session-raw-yaegtjzh.js → read-session-raw-b70cpwzj.js} +4 -3
- package/dist/v2/recomp-orchestrator-b12zaptj.js +61 -0
- package/dist/v2/{safe-notification-target-qg7n2s77.js → safe-notification-target-khnzg57c.js} +2 -2
- package/dist/v2/search-archive-x64rtz1z.js +25 -0
- package/dist/v2/search-hza9x72a.js +49 -0
- package/dist/v2/{send-session-notification-3pxn658x.js → send-session-notification-8eqe259v.js} +7 -6
- package/dist/v2/{server-45q69hkq.js → server-132h8twc.js} +5 -5
- package/dist/v2/{server-h0410h0v.js → server-1bw1wcbp.js} +1 -1
- package/dist/v2/{server-271qxsf5.js → server-24g8r2d0.js} +2466 -1290
- package/dist/v2/{server-tbe1femw.js → server-29qp8nz4.js} +1 -1
- package/dist/v2/{server-gsxjv2q2.js → server-33nqbqkw.js} +182 -47
- package/dist/v2/{server-tgnbmwah.js → server-3mz2qh5a.js} +1 -1
- package/dist/v2/{server-n1prf1g6.js → server-3vhxy2k5.js} +2 -2
- package/dist/v2/{server-xj136kt8.js → server-4kjmrjn4.js} +9 -3
- package/dist/v2/{server-34kwfsr4.js → server-53eh1r8r.js} +2 -2
- package/dist/{index-8cd2j99z.js → v2/server-5kym00ag.js} +32 -13
- package/dist/v2/{server-46neh5fa.js → server-62g58aaz.js} +314 -127
- package/dist/v2/{server-f2xf5gcb.js → server-6495nmn9.js} +12 -15
- package/dist/v2/{server-a9xqj88f.js → server-6v3cdzsx.js} +4 -4
- package/dist/v2/{server-d04vrx0j.js → server-806rzhs6.js} +2 -2
- package/dist/v2/{server-qd11g795.js → server-92g7d776.js} +2 -1
- package/dist/v2/{server-nj659894.js → server-94wk1ey3.js} +14 -3
- package/dist/v2/{server-6tmj0s7j.js → server-ab1g0wn9.js} +4 -6
- package/dist/v2/{server-8by8qfec.js → server-ad18djzs.js} +95 -59
- package/dist/v2/{server-hy3d3vsx.js → server-bsgd4dk1.js} +2 -2
- package/dist/v2/server-cpjk5jd2.js +82 -0
- package/dist/v2/{server-g3qma5c0.js → server-d1dzgvwd.js} +2 -2
- package/dist/v2/{server-hm38q7r0.js → server-d48x3m4x.js} +5 -5
- package/dist/v2/{server-1wy7b9de.js → server-dtp8hcjh.js} +3 -3
- package/dist/v2/{server-27gq4mfz.js → server-fa7vtp40.js} +9 -6
- package/dist/v2/{server-6pmqg9m4.js → server-gyy4k6mf.js} +1 -1
- package/dist/{index-beht37jy.js → v2/server-gzy5w8ya.js} +194 -5
- package/dist/v2/{server-bmymkx73.js → server-j8h7bsca.js} +29 -15
- package/dist/v2/{server-n37sebck.js → server-jjvbk92s.js} +1 -1
- package/dist/v2/{server-da07v4xp.js → server-k3t06fxr.js} +1 -1
- package/dist/v2/{server-9hx7g5jp.js → server-m4bfaevz.js} +1197 -1049
- package/dist/v2/{server-2ar62dyx.js → server-ppcd1qxh.js} +191 -99
- package/dist/v2/{server-rmygf5pn.js → server-qjvk4a9t.js} +2 -2
- package/dist/v2/{server-zzkj2fch.js → server-qteg2kt9.js} +5 -5
- package/dist/v2/{server-pwv4ezb0.js → server-rqebawx1.js} +2 -2
- package/dist/v2/{server-h1v0pyxb.js → server-vr4szghm.js} +501 -20
- package/dist/v2/{server-xq7dfjke.js → server-wwaw5npa.js} +5 -5
- package/dist/v2/{server-6vdzn1td.js → server-zg5y109h.js} +323 -76
- package/dist/v2/server.js +8 -8
- package/dist/v2/{sqlite-zf72c52d.js → sqlite-zdgm52sv.js} +5 -1
- package/dist/v2/{storage-memory-y3qmy00r.js → storage-memory-e6a7mb0k.js} +2 -2
- package/dist/v2/{storage-tags-3wdb8zph.js → storage-tags-q71rnr9f.js} +5 -5
- package/dist/v2/store-reader.d.ts +10 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{task-config-nvz8mapa.js → task-config-7md27rx8.js} +2 -2
- package/dist/v2/{wrapup-orchestrator-embdz8gj.js → wrapup-orchestrator-3ssd5yy1.js} +33 -32
- package/dist/wrapup-orchestrator-5vpcd1zx.js +49 -0
- package/package.json +2 -2
- package/src/config/index.test.ts +72 -6
- package/src/config/project-security.ts +15 -0
- package/src/config/rerank.test.ts +60 -0
- package/src/config/schema/magic-context.ts +57 -0
- package/src/shared/logger.test.ts +42 -1
- package/src/shared/logger.ts +11 -13
- package/src/shared/model-resolution.test.ts +67 -12
- package/src/shared/model-resolution.ts +43 -16
- package/src/shared/model-suggestion-retry.ts +2 -2
- package/src/shared/prompt-async-transport.ts +47 -3
- package/src/shared/rpc-types.ts +7 -0
- package/src/shared/sqlite-busy-budget-review.test.ts +6 -1
- package/src/shared/sqlite-turn-deadline.test.ts +270 -0
- package/src/shared/sqlite.ts +239 -9
- package/src/shared/subagent-runner.ts +2 -0
- package/src/shared/tag-transcript.ts +9 -1
- package/src/shared/worker-shutdown-fence.test.ts +87 -0
- package/src/shared/worker-shutdown.fixture.ts +25 -0
- package/src/shared/worker-shutdown.test.ts +127 -0
- package/src/shared/worker-shutdown.ts +160 -0
- package/dist/embedding-backfill-fmz50tsy.js +0 -24
- package/dist/recomp-orchestrator-999jj4bc.js +0 -61
- package/dist/search-archive-6vm0e2f5.js +0 -25
- package/dist/search-xsqk1bj4.js +0 -49
- package/dist/v2/embedding-backfill-7c7yr69y.js +0 -23
- package/dist/v2/recomp-orchestrator-f6m9jr7p.js +0 -60
- package/dist/v2/search-archive-wve3tq1k.js +0 -24
- package/dist/v2/search-hwg7jfbj.js +0 -48
- package/dist/wrapup-orchestrator-whhbjmaz.js +0 -48
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./index-pavzsdc6.js";
|
|
4
4
|
import {
|
|
5
5
|
sessionLog2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-h7tgn49j.js";
|
|
7
7
|
import {
|
|
8
8
|
UNKNOWN_FIT_RATIO,
|
|
9
9
|
resolveDecisionCalibration,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "./index-1zx87sdm.js";
|
|
14
14
|
import {
|
|
15
15
|
stripWellFormedLeadingTagPrefix,
|
|
16
|
+
stripPersistedAssistantText,
|
|
16
17
|
stripTagPrefix,
|
|
17
18
|
isRecord,
|
|
18
19
|
estimateImageTokensFromDataUrl,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
TAG_SELECT_COLUMNS2,
|
|
24
25
|
getCandidateToolOwners2,
|
|
25
26
|
pickNearestPriorOwner2
|
|
26
|
-
} from "./index-
|
|
27
|
+
} from "./index-whcgcfrv.js";
|
|
27
28
|
import {
|
|
28
29
|
OMO_INTERNAL_INITIATOR_MARKER,
|
|
29
30
|
isSystemDirective,
|
|
@@ -41,18 +42,18 @@ import {
|
|
|
41
42
|
formatBlock,
|
|
42
43
|
compactTextForSummary,
|
|
43
44
|
mergeCommitHashes
|
|
44
|
-
} from "./index-
|
|
45
|
+
} from "./index-b88dwwrh.js";
|
|
45
46
|
import {
|
|
46
47
|
prepareCachedStatement2
|
|
47
|
-
} from "./index-
|
|
48
|
+
} from "./index-gzy5w8ya.js";
|
|
48
49
|
import {
|
|
49
50
|
stableStringify
|
|
50
|
-
} from "./index-
|
|
51
|
+
} from "./index-x9k3mqrf.js";
|
|
51
52
|
import {
|
|
52
53
|
renderToolTemplate,
|
|
53
54
|
resolveModelConfigValue,
|
|
54
55
|
deriveDefaultProtectedTokens
|
|
55
|
-
} from "./index-
|
|
56
|
+
} from "./index-nxrsns5x.js";
|
|
56
57
|
import {
|
|
57
58
|
readRawSessionMessagesFromDb2,
|
|
58
59
|
readRawSessionMessagePageFromDb2,
|
|
@@ -69,25 +70,25 @@ import {
|
|
|
69
70
|
readRawSeedTailFromDb2,
|
|
70
71
|
readRawSessionBoundaryEndpointsFromDb2,
|
|
71
72
|
prewarmRawSessionOrdinalsForDb
|
|
72
|
-
} from "./index-
|
|
73
|
+
} from "./index-jfem3dgz.js";
|
|
73
74
|
import {
|
|
74
75
|
openCodeDbExists,
|
|
75
76
|
withReadOnlySessionDb,
|
|
76
77
|
getRawSessionMessageCountFromDb,
|
|
77
78
|
getMessageTimesFromOpenCodeDb
|
|
78
|
-
} from "./index-
|
|
79
|
+
} from "./index-ksq50rg0.js";
|
|
79
80
|
import {
|
|
80
81
|
getToolDefinitionMeasurementSignature,
|
|
81
82
|
getLargestMeasuredToolDefinitionTokens,
|
|
82
83
|
getMeasuredToolDefinitionTokens
|
|
83
|
-
} from "./index-
|
|
84
|
+
} from "./index-j76ah6d7.js";
|
|
84
85
|
import {
|
|
85
86
|
canonicalModelIdentity,
|
|
86
87
|
piModelRefToCanonical
|
|
87
88
|
} from "./index-avwt563y.js";
|
|
88
89
|
import {
|
|
89
90
|
logSlowWriteTransaction
|
|
90
|
-
} from "./index-
|
|
91
|
+
} from "./index-t5pck3ss.js";
|
|
91
92
|
|
|
92
93
|
// src/shared/hidden-zen-read.ts
|
|
93
94
|
function isToolFreeHiddenAgent(agent) {
|
|
@@ -3944,6 +3945,13 @@ function getCompactionMarkerHealth(db, sessionId, now = Date.now()) {
|
|
|
3944
3945
|
pendingSinceMs: firstFailedAt
|
|
3945
3946
|
};
|
|
3946
3947
|
}
|
|
3948
|
+
function executeReclaimFromReplay(raw) {
|
|
3949
|
+
try {
|
|
3950
|
+
return parseReplayDocument(raw).executeReclaim;
|
|
3951
|
+
} catch {
|
|
3952
|
+
return;
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3947
3955
|
function loadPostprocessReplaySnapshot(db, sessionId) {
|
|
3948
3956
|
const row = db.prepare(`SELECT stale_reduce_stripped_ids, processed_image_stripped_ids,
|
|
3949
3957
|
stripped_placeholder_ids, note_nudge_anchors,
|
|
@@ -3958,6 +3966,14 @@ function loadPostprocessReplaySnapshot(db, sessionId) {
|
|
|
3958
3966
|
const todoPermissionDenied = row?.todo_permission_denied === 1 ? true : row?.todo_permission_denied === 0 ? false : null;
|
|
3959
3967
|
const thinkingBindingRecoveryTarget = row?.thinking_binding_recovery_target;
|
|
3960
3968
|
return {
|
|
3969
|
+
servedShapeRepair: (() => {
|
|
3970
|
+
try {
|
|
3971
|
+
return parseReplayDocument(row?.trailing_blank_decisions).servedShapeRepair;
|
|
3972
|
+
} catch {
|
|
3973
|
+
return;
|
|
3974
|
+
}
|
|
3975
|
+
})(),
|
|
3976
|
+
executeReclaim: executeReclaimFromReplay(row?.trailing_blank_decisions),
|
|
3961
3977
|
staleReduceStrippedIds: new Set(parseStrippedBlob(row?.stale_reduce_stripped_ids)),
|
|
3962
3978
|
processedImageStrippedIds: new Set(parseProcessedImageMarkers(row?.processed_image_stripped_ids).keys()),
|
|
3963
3979
|
processedImageMarkers: parseProcessedImageMarkers(row?.processed_image_stripped_ids),
|
|
@@ -4645,6 +4661,120 @@ function createProcessedImageEligibility(messages, messageTagNumbers, options) {
|
|
|
4645
4661
|
};
|
|
4646
4662
|
}
|
|
4647
4663
|
|
|
4664
|
+
// src/hooks/magic-context/served-shape-repair.ts
|
|
4665
|
+
var sources = new WeakMap;
|
|
4666
|
+
function markServedShapeRepair(info, parts, requiresPermission = false) {
|
|
4667
|
+
const merged = new Map((sources.get(info) ?? []).map((part) => [part.index, part]));
|
|
4668
|
+
for (const part of parts)
|
|
4669
|
+
merged.set(part.index, { ...part, requiresPermission });
|
|
4670
|
+
if (merged.size)
|
|
4671
|
+
sources.set(info, [...merged.values()]);
|
|
4672
|
+
}
|
|
4673
|
+
function parseDecisions(value) {
|
|
4674
|
+
if (value === undefined)
|
|
4675
|
+
return {};
|
|
4676
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
4677
|
+
throw new Error("Invalid served-shape replay decisions");
|
|
4678
|
+
for (const entries of Object.values(value)) {
|
|
4679
|
+
if (!Array.isArray(entries) || entries.some((entry) => !entry || !Number.isSafeInteger(entry.index) || entry.index < 0 || typeof entry.text !== "string" || !entry.text.trim()))
|
|
4680
|
+
throw new Error("Invalid served-shape text decision");
|
|
4681
|
+
}
|
|
4682
|
+
return value;
|
|
4683
|
+
}
|
|
4684
|
+
function readDecisions(db, sessionID) {
|
|
4685
|
+
return parseDecisions(readReplayEnvelope(db, sessionID).servedShapeRepair);
|
|
4686
|
+
}
|
|
4687
|
+
function prepareServedShapeRepair(db, sessionID, messages, readPreviouslyServed, snapshot) {
|
|
4688
|
+
let decisions = snapshot ? parseDecisions(snapshot.servedShapeRepair) : readDecisions(db, sessionID);
|
|
4689
|
+
const collectPending = () => {
|
|
4690
|
+
const pending = {};
|
|
4691
|
+
for (const message of messages) {
|
|
4692
|
+
const id = message.info.id;
|
|
4693
|
+
if (typeof id !== "string")
|
|
4694
|
+
continue;
|
|
4695
|
+
const candidates = (sources.get(message.info) ?? []).filter(({ index }) => !decisions[id]?.some((part) => part.index === index));
|
|
4696
|
+
if (candidates.length)
|
|
4697
|
+
pending[id] = candidates;
|
|
4698
|
+
}
|
|
4699
|
+
return pending;
|
|
4700
|
+
};
|
|
4701
|
+
const pending = collectPending();
|
|
4702
|
+
let previouslyServed = null;
|
|
4703
|
+
try {
|
|
4704
|
+
const evidence = Object.keys(pending).length ? readPreviouslyServed?.() : null;
|
|
4705
|
+
if (Array.isArray(evidence))
|
|
4706
|
+
previouslyServed = evidence;
|
|
4707
|
+
} catch {}
|
|
4708
|
+
const provenUnserved = new Set;
|
|
4709
|
+
let needsRebuild = false;
|
|
4710
|
+
for (const id of Object.keys(pending)) {
|
|
4711
|
+
if (!previouslyServed)
|
|
4712
|
+
continue;
|
|
4713
|
+
const matches = previouslyServed.filter((value) => {
|
|
4714
|
+
if (!value || typeof value !== "object")
|
|
4715
|
+
return false;
|
|
4716
|
+
const message = value;
|
|
4717
|
+
return message.info?.id === id;
|
|
4718
|
+
});
|
|
4719
|
+
if (!matches.length)
|
|
4720
|
+
provenUnserved.add(id);
|
|
4721
|
+
const previous = matches.length === 1 ? matches[0] : undefined;
|
|
4722
|
+
needsRebuild ||= previous !== undefined && Array.isArray(previous.parts) && pending[id].some(({ index }) => {
|
|
4723
|
+
const part = previous.parts[index];
|
|
4724
|
+
return part?.type === "text" && part.text === "";
|
|
4725
|
+
});
|
|
4726
|
+
}
|
|
4727
|
+
return {
|
|
4728
|
+
pending: Object.keys(pending).length > 0,
|
|
4729
|
+
needsRebuild,
|
|
4730
|
+
get messageIDs() {
|
|
4731
|
+
return new Set(Object.keys(decisions));
|
|
4732
|
+
},
|
|
4733
|
+
apply(allowed) {
|
|
4734
|
+
const eligible = {};
|
|
4735
|
+
for (const [id, candidates] of Object.entries(collectPending())) {
|
|
4736
|
+
const parts = candidates.filter(({ requiresPermission }) => allowed || !requiresPermission && !needsRebuild && provenUnserved.has(id)).map(({ index, text }) => ({ index, text }));
|
|
4737
|
+
if (parts.length)
|
|
4738
|
+
eligible[id] = parts;
|
|
4739
|
+
}
|
|
4740
|
+
if (Object.keys(eligible).length) {
|
|
4741
|
+
if (!updateReplayDocument(db, sessionID, (doc) => {
|
|
4742
|
+
doc.version = 2;
|
|
4743
|
+
const current = parseDecisions(doc.servedShapeRepair);
|
|
4744
|
+
for (const [id, parts] of Object.entries(eligible)) {
|
|
4745
|
+
current[id] = [
|
|
4746
|
+
...current[id] ?? [],
|
|
4747
|
+
...parts.filter(({ index }) => !current[id]?.some((part) => part.index === index))
|
|
4748
|
+
];
|
|
4749
|
+
}
|
|
4750
|
+
doc.servedShapeRepair = current;
|
|
4751
|
+
return true;
|
|
4752
|
+
}))
|
|
4753
|
+
throw new Error("Could not persist served-shape repair");
|
|
4754
|
+
decisions = readDecisions(db, sessionID);
|
|
4755
|
+
}
|
|
4756
|
+
let changed = 0;
|
|
4757
|
+
for (const message of messages) {
|
|
4758
|
+
const id = message.info.id;
|
|
4759
|
+
if (typeof id !== "string")
|
|
4760
|
+
continue;
|
|
4761
|
+
for (const decision of decisions[id] ?? []) {
|
|
4762
|
+
const part = message.parts[decision.index];
|
|
4763
|
+
if (part?.type !== "text")
|
|
4764
|
+
continue;
|
|
4765
|
+
if (typeof part.text !== "string" || stripPersistedAssistantText(part.text).trim())
|
|
4766
|
+
continue;
|
|
4767
|
+
if (part.text !== decision.text) {
|
|
4768
|
+
part.text = decision.text;
|
|
4769
|
+
changed++;
|
|
4770
|
+
}
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
return changed;
|
|
4774
|
+
}
|
|
4775
|
+
};
|
|
4776
|
+
}
|
|
4777
|
+
|
|
4648
4778
|
// src/hooks/magic-context/strip-content.ts
|
|
4649
4779
|
var MARKER_ONLY_PATTERN = /^(?:(?:§\d+§|\[dropped(?: §\d+§)?\]|\[cleared\])\s*)+$/;
|
|
4650
4780
|
function isMarkerOnlyText(text) {
|
|
@@ -4799,9 +4929,11 @@ function replayClearedReasoning(messages, reasoningByMessage, messageTagNumbers,
|
|
|
4799
4929
|
}
|
|
4800
4930
|
return cleared;
|
|
4801
4931
|
}
|
|
4802
|
-
function replayStrippedInlineThinking(messages, messageTagNumbers, persistedWatermark) {
|
|
4932
|
+
function replayStrippedInlineThinking(messages, messageTagNumbers, persistedWatermark, captureRepair = false) {
|
|
4803
4933
|
if (persistedWatermark <= 0)
|
|
4804
4934
|
return 0;
|
|
4935
|
+
if (captureRepair)
|
|
4936
|
+
captureInlineThinkingRepairs(messages, messageTagNumbers, persistedWatermark);
|
|
4805
4937
|
let stripped = 0;
|
|
4806
4938
|
for (const message of messages) {
|
|
4807
4939
|
if (message.info.role !== "assistant")
|
|
@@ -4875,8 +5007,24 @@ function stripClearedReasoning(messages) {
|
|
|
4875
5007
|
return stripped;
|
|
4876
5008
|
}
|
|
4877
5009
|
var INLINE_THINKING_PATTERN = /<(?:thinking|think)>[\s\S]*?<\/(?:thinking|think)>\s*/g;
|
|
4878
|
-
function
|
|
5010
|
+
function captureInlineThinkingRepairs(messages, messageTagNumbers, watermark) {
|
|
5011
|
+
for (const message of messages) {
|
|
5012
|
+
const tag = messageTagNumbers.get(message) ?? 0;
|
|
5013
|
+
if (message.info.role !== "assistant" || tag <= 0 || tag > watermark)
|
|
5014
|
+
continue;
|
|
5015
|
+
for (const [index, part] of message.parts.entries()) {
|
|
5016
|
+
if (!isRecord(part) || part.type !== "text" || typeof part.text !== "string")
|
|
5017
|
+
continue;
|
|
5018
|
+
const cleaned = part.text.replace(INLINE_THINKING_PATTERN, "");
|
|
5019
|
+
if (cleaned !== part.text && !cleaned.trim())
|
|
5020
|
+
markServedShapeRepair(message.info, [{ index, text: "[cleared]" }], true);
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5023
|
+
}
|
|
5024
|
+
function stripInlineThinking(messages, messageTagNumbers, cutoff, captureRepair = false) {
|
|
4879
5025
|
const ageCutoff = cutoff;
|
|
5026
|
+
if (captureRepair)
|
|
5027
|
+
captureInlineThinkingRepairs(messages, messageTagNumbers, cutoff);
|
|
4880
5028
|
let stripped = 0;
|
|
4881
5029
|
for (const message of messages) {
|
|
4882
5030
|
if (message.info.role !== "assistant")
|
|
@@ -7346,4 +7494,4 @@ function readRawSessionSeedTail2(sessionId, boundaryId, onQuery) {
|
|
|
7346
7494
|
});
|
|
7347
7495
|
}
|
|
7348
7496
|
|
|
7349
|
-
export { isToolFreeHiddenAgent, TOOL_USE_DISABLED, ZEN_READ_AGENT_SUFFIX, needsBlockedRead, withBlockedReadInstruction, rememberV1HiddenRun, shapeV1HiddenMessage, expandToolPart, markHostUnservedRow, retreatPastHostUnservedRows, snapTerminalCompartmentToServedRow, isHostRenderedSystemMessage, markCoveredInstructionRow, isCoveredInstructionRow, takeCoveredInstructionRows, cloneKeepingCoveredInstructionMarks, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, invalidateTrueRawTokenCache, stripSystemInjection, isTextPart, isToolPartWithOutput, isFilePart, toolPartHasUserAnswer, DreamTokenBudgetExceeded, TOKEN_BUDGET_FINALIZE_MESSAGE, registerBudgetFinalizeChild, releaseBudgetFinalizeChild, createDreamTokenBudget, recordToolParameters, createDroppedInputGuard, assertExecutableToolInput, createDroppedInputToolExecuteBeforeHook, isEditTool, MERGED_REASONING_PARTS_PREFIX, decodeMergedReasoningParts, MAX_EXECUTE_THRESHOLD, escalationBands, HYGIENE_PROVIDER_UNITS_VERSION, sessionDecisionCalibration, transitionSessionHygieneUnits, readEpochFloorSnapshot, getProtectionWindowForSession, SESSION_META_SELECT_COLUMNS, META_COLUMNS, BOOLEAN_META_KEYS, NULL_BIND_META_KEYS, isSessionMetaRow, getDefaultSessionMeta, ensureSessionMetaRow, toSessionMeta, persistCachedM0, clearCachedM0M1, clearCachedM0, withReplayEnvelopeSnapshot, invalidateReplayEnvelopeSnapshot, isRustMarkerAdmissionFenced, setRustMarkerAdmissionFence, ReplayDocumentError, readReplayEnvelope, readReplayDocument, updateReplayDocument, writeReplayDocument, isEmergencyRecoveryArmed, isProviderOverflowReconfirmed, isProviderOverflowFailClosedProven, getEmergencyRecoveryArmedAt, describeProtectedTailDrainBudgetSkip, loadPersistedUsage, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, resetProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, getProtectedTailDrainBudgetSkip, reserveProtectedTailDrainTokens, clearEmergencyDrainLatch, recordHistorianDrainFailure, clearHistorianDrainFailure, rollbackProtectedTailDrainReservation, getPersistedReasoningWatermark, setPersistedReasoningWatermark, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, setPersistedNoteNudgeTrigger, setPersistedNoteNudgeTriggerMessageId, getNoteNudgeAnchors, getAutoSearchHintDecisions, deliverNoteNudgeAtomic, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, removeNoteNudgeAnchorByMessageId, queueAutoSearchHintDecisionRetirement, flushAutoSearchHintDecisionRetirement, removeAutoSearchHintDecisionByMessageId, getPersistedTodoPermissionDenied, setPersistedTodoPermissionDenied, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, setNoteLastReadAt, getHistorianFailureState, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, loadTransformPassStateSnapshot, recordOverflowDetected, recordDetectedContextLimit, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, setPersistedCompactionMarkerState, getDeferredClearedCompactionMarkerState, retireDeferredClearedCompactionMarkerState, parseStrippedPlaceholderState, serializeStrippedPlaceholderState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, removeStrippedPlaceholderId, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, THINKING_BINDING_STRIP_ORDER_END_MARKER, thinkingBindingRecoveryFrozenId, COMPACTION_OFF_THINKING_FROZEN_PREFIX, compactionOffThinkingFrozenId, compactionOffFrozenThinkingIds, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getTrailingBlankDecisions, addTrailingBlankDecisions, demoteTrailingBlankKeepDecisions, getStaleReduceStrippedIds, addStaleReduceStrippedIds, getProcessedImageStrippedIds, parseProcessedImageMarkers, serializeProcessedImageMarkers, getProcessedImageMarkers, addProcessedImageStrippedIds, getPendingCompactionMarkerState, getCompactionMarkerHealth, loadPostprocessReplaySnapshot, setPendingCompactionMarkerState, replacePendingCompactionMarkerStateIf, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, logPiCompactionMarkerClear, getSessionsWithPendingMarker, setSessionWorkMetrics, getObservedEpochFloor, resolveEpochFloorForPass, getReasoningRemovalState, addRemovedReasoningIds, markDropLeavesReasoning, detectThinkingBindingMismatch, detectLatestTurnThinkingMismatch, isPrefixBoundThinkingModel, detectOverflow, modelAcceptsEmptyContent, isAnthropicFamilyRoute, neutralizeDroppedReasoningPart, restoreNeutralizedReasoningPart, isNeutralizedReasoningPart, variantChangeBustsProviderCache, makeSentinel, makeWholeMessageSentinel, isSentinel, replaySentinelByMessageIds, isInActiveAnthropicTurn, activeAnthropicTurnStart, hasAnthropicReasoning, stripSystemInjectedMessages, stripDroppedPlaceholderMessages, replayClearedReasoning, replayStrippedInlineThinking, clearOldReasoning, stripClearedReasoning, stripInlineThinking, findReasoningBearingAssistantIds, findLatestAssistantReasoningMutationExemptMessage, snapshotTrailingBlankSourceDecisions, findTrailingBlankDecisionCandidates, applyFrozenTrailingBlankDecisions, stripReasoningFromAssistantIds, findMergedReasoningStripDecisions, stripReasoningFromMergedAssistants, getEmptyImageParts, stripProcessedImages, projectOpencodeReasoningBudgetCutoff, DEFAULT_KEEP_REASONING_TOKENS, resolveKeepReasoningTokens, reasoningStepCost, reasoningBudgetCutoff, reasoningTextAndOpaque, opencodeReasoningBudgetCutoff, describeFinalWireTail, estimatePartImageTokens, estimateMessageTokens, wireContentBytes, createFinalWireUsageTracker, estimateFinalWireInputTokens, estimateAppendedWireTokens, 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, visitRawSessionMessagesAsync2, readRawSessionMessageRange2, prepareRawSessionOrdinals2, primeTailRawMessageCache2, getCachedAbsoluteMessageCount2, primeInMemoryTailRawMessageCache2, readRawSessionMessageOrdinalPage2, getRawSessionStoredMessageCount2, readRawSessionMessageIdOrdinalsForRange2, readRawSessionMessageIdOrdinals2, readRawSessionMessagePartsById2, readRawSessionBoundaryEndpoints2, hasRawSessionMessageById2, readRawSessionMessageOrdinalById2, compareRawSessionMessageOrder2, readRawSessionMessageById2, getRawSessionMessageCount2, RAW_SESSION_TAG_KEY_PAGE_SIZE2, getRawSessionTagKeysThrough2, getLegacyProtectedTailStartOrdinal2, getProtectedTailStartOrdinal2, readSessionChunk2, getRawSessionMessageIdsThrough2, readRawSessionSeedTail2 };
|
|
7497
|
+
export { isToolFreeHiddenAgent, TOOL_USE_DISABLED, ZEN_READ_AGENT_SUFFIX, needsBlockedRead, withBlockedReadInstruction, rememberV1HiddenRun, shapeV1HiddenMessage, expandToolPart, markHostUnservedRow, retreatPastHostUnservedRows, snapTerminalCompartmentToServedRow, isHostRenderedSystemMessage, markCoveredInstructionRow, isCoveredInstructionRow, takeCoveredInstructionRows, cloneKeepingCoveredInstructionMarks, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, invalidateTrueRawTokenCache, stripSystemInjection, isTextPart, isToolPartWithOutput, isFilePart, toolPartHasUserAnswer, DreamTokenBudgetExceeded, TOKEN_BUDGET_FINALIZE_MESSAGE, registerBudgetFinalizeChild, releaseBudgetFinalizeChild, createDreamTokenBudget, recordToolParameters, createDroppedInputGuard, assertExecutableToolInput, createDroppedInputToolExecuteBeforeHook, isEditTool, MERGED_REASONING_PARTS_PREFIX, decodeMergedReasoningParts, MAX_EXECUTE_THRESHOLD, escalationBands, HYGIENE_PROVIDER_UNITS_VERSION, sessionDecisionCalibration, transitionSessionHygieneUnits, readEpochFloorSnapshot, getProtectionWindowForSession, SESSION_META_SELECT_COLUMNS, META_COLUMNS, BOOLEAN_META_KEYS, NULL_BIND_META_KEYS, isSessionMetaRow, getDefaultSessionMeta, ensureSessionMetaRow, toSessionMeta, persistCachedM0, clearCachedM0M1, clearCachedM0, withReplayEnvelopeSnapshot, invalidateReplayEnvelopeSnapshot, isRustMarkerAdmissionFenced, setRustMarkerAdmissionFence, ReplayDocumentError, readReplayEnvelope, readReplayDocument, updateReplayDocument, writeReplayDocument, isEmergencyRecoveryArmed, isProviderOverflowReconfirmed, isProviderOverflowFailClosedProven, getEmergencyRecoveryArmedAt, describeProtectedTailDrainBudgetSkip, loadPersistedUsage, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, resetProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, getProtectedTailDrainBudgetSkip, reserveProtectedTailDrainTokens, clearEmergencyDrainLatch, recordHistorianDrainFailure, clearHistorianDrainFailure, rollbackProtectedTailDrainReservation, getPersistedReasoningWatermark, setPersistedReasoningWatermark, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, setPersistedNoteNudgeTrigger, setPersistedNoteNudgeTriggerMessageId, getNoteNudgeAnchors, getAutoSearchHintDecisions, deliverNoteNudgeAtomic, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, removeNoteNudgeAnchorByMessageId, queueAutoSearchHintDecisionRetirement, flushAutoSearchHintDecisionRetirement, removeAutoSearchHintDecisionByMessageId, getPersistedTodoPermissionDenied, setPersistedTodoPermissionDenied, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, setNoteLastReadAt, getHistorianFailureState, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, loadTransformPassStateSnapshot, recordOverflowDetected, recordDetectedContextLimit, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, setPersistedCompactionMarkerState, getDeferredClearedCompactionMarkerState, retireDeferredClearedCompactionMarkerState, parseStrippedPlaceholderState, serializeStrippedPlaceholderState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, removeStrippedPlaceholderId, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, THINKING_BINDING_STRIP_ORDER_END_MARKER, thinkingBindingRecoveryFrozenId, COMPACTION_OFF_THINKING_FROZEN_PREFIX, compactionOffThinkingFrozenId, compactionOffFrozenThinkingIds, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getTrailingBlankDecisions, addTrailingBlankDecisions, demoteTrailingBlankKeepDecisions, getStaleReduceStrippedIds, addStaleReduceStrippedIds, getProcessedImageStrippedIds, parseProcessedImageMarkers, serializeProcessedImageMarkers, getProcessedImageMarkers, addProcessedImageStrippedIds, getPendingCompactionMarkerState, getCompactionMarkerHealth, loadPostprocessReplaySnapshot, setPendingCompactionMarkerState, replacePendingCompactionMarkerStateIf, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, logPiCompactionMarkerClear, getSessionsWithPendingMarker, setSessionWorkMetrics, getObservedEpochFloor, resolveEpochFloorForPass, getReasoningRemovalState, addRemovedReasoningIds, markDropLeavesReasoning, detectThinkingBindingMismatch, detectLatestTurnThinkingMismatch, isPrefixBoundThinkingModel, detectOverflow, modelAcceptsEmptyContent, isAnthropicFamilyRoute, neutralizeDroppedReasoningPart, restoreNeutralizedReasoningPart, isNeutralizedReasoningPart, variantChangeBustsProviderCache, makeSentinel, makeWholeMessageSentinel, isSentinel, replaySentinelByMessageIds, isInActiveAnthropicTurn, activeAnthropicTurnStart, hasAnthropicReasoning, markServedShapeRepair, prepareServedShapeRepair, stripSystemInjectedMessages, stripDroppedPlaceholderMessages, replayClearedReasoning, replayStrippedInlineThinking, clearOldReasoning, stripClearedReasoning, captureInlineThinkingRepairs, stripInlineThinking, findReasoningBearingAssistantIds, findLatestAssistantReasoningMutationExemptMessage, snapshotTrailingBlankSourceDecisions, findTrailingBlankDecisionCandidates, applyFrozenTrailingBlankDecisions, stripReasoningFromAssistantIds, findMergedReasoningStripDecisions, stripReasoningFromMergedAssistants, getEmptyImageParts, stripProcessedImages, projectOpencodeReasoningBudgetCutoff, DEFAULT_KEEP_REASONING_TOKENS, resolveKeepReasoningTokens, reasoningStepCost, reasoningBudgetCutoff, reasoningTextAndOpaque, opencodeReasoningBudgetCutoff, describeFinalWireTail, estimatePartImageTokens, estimateMessageTokens, wireContentBytes, createFinalWireUsageTracker, estimateFinalWireInputTokens, estimateAppendedWireTokens, 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, visitRawSessionMessagesAsync2, readRawSessionMessageRange2, prepareRawSessionOrdinals2, primeTailRawMessageCache2, getCachedAbsoluteMessageCount2, primeInMemoryTailRawMessageCache2, readRawSessionMessageOrdinalPage2, getRawSessionStoredMessageCount2, readRawSessionMessageIdOrdinalsForRange2, readRawSessionMessageIdOrdinals2, readRawSessionMessagePartsById2, readRawSessionBoundaryEndpoints2, hasRawSessionMessageById2, readRawSessionMessageOrdinalById2, compareRawSessionMessageOrder2, readRawSessionMessageById2, getRawSessionMessageCount2, RAW_SESSION_TAG_KEY_PAGE_SIZE2, getRawSessionTagKeysThrough2, getLegacyProtectedTailStartOrdinal2, getProtectedTailStartOrdinal2, readSessionChunk2, getRawSessionMessageIdsThrough2, readRawSessionSeedTail2 };
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
tagRevisionKey,
|
|
6
6
|
tagIdentityRevisionKey,
|
|
7
7
|
deleteTagIdentityRevisions
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-x9k3mqrf.js";
|
|
9
9
|
import {
|
|
10
10
|
getHarness2
|
|
11
11
|
} from "./index-pavzsdc6.js";
|
|
@@ -15,37 +15,37 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
isPidAlive,
|
|
17
17
|
readProcessStartTime
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-c7phnbvk.js";
|
|
19
19
|
import {
|
|
20
20
|
removeSystemReminders,
|
|
21
21
|
removeNestedBlocks,
|
|
22
22
|
hasMeaningfulUserText2,
|
|
23
23
|
extractTexts2
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-b88dwwrh.js";
|
|
25
25
|
import {
|
|
26
26
|
Database2,
|
|
27
27
|
getSqliteDatabasePath2,
|
|
28
28
|
prepareCachedStatement2,
|
|
29
29
|
withSqliteBackgroundWriter2,
|
|
30
30
|
withoutSqliteTransformPass2
|
|
31
|
-
} from "./index-
|
|
31
|
+
} from "./index-gzy5w8ya.js";
|
|
32
32
|
import {
|
|
33
33
|
resolveOpenCodeDbPath,
|
|
34
34
|
assertOpenCodeStoreGeneration
|
|
35
35
|
} from "./index-58e3y90n.js";
|
|
36
36
|
import {
|
|
37
37
|
cleanUserText2
|
|
38
|
-
} from "./index-
|
|
38
|
+
} from "./index-mnhcdfxg.js";
|
|
39
39
|
import {
|
|
40
40
|
recordMessageFtsRowid2,
|
|
41
41
|
recordIndexedMessageTime2,
|
|
42
42
|
messageFtsOrdinalRangeIsMapped2,
|
|
43
43
|
getMessageFtsRowidMapBackfillProgress2,
|
|
44
44
|
deleteUnmappedMessageFtsRows2
|
|
45
|
-
} from "./index-
|
|
45
|
+
} from "./index-x6cbrv9h.js";
|
|
46
46
|
import {
|
|
47
|
-
|
|
48
|
-
} from "./index-
|
|
47
|
+
deleteChunkEmbedBackoffForSession2
|
|
48
|
+
} from "./index-m32esgmj.js";
|
|
49
49
|
import {
|
|
50
50
|
sameProjectDirectory
|
|
51
51
|
} from "./index-knvkbfvh.js";
|
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
} from "./index-8ajstryz.js";
|
|
55
55
|
import {
|
|
56
56
|
logSlowWriteTransaction
|
|
57
|
-
} from "./index-
|
|
57
|
+
} from "./index-t5pck3ss.js";
|
|
58
58
|
import {
|
|
59
59
|
ensurePrivateStorageDirectorySync,
|
|
60
60
|
writeStorageFileSync,
|
|
@@ -214,7 +214,14 @@ import { createHash as createHash4 } from "node:crypto";
|
|
|
214
214
|
|
|
215
215
|
// src/hooks/magic-context/lkg-recovery-fence.ts
|
|
216
216
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
217
|
-
import {
|
|
217
|
+
import {
|
|
218
|
+
lstatSync,
|
|
219
|
+
opendirSync,
|
|
220
|
+
readdirSync as readdirSync2,
|
|
221
|
+
readFileSync as readFileSync2,
|
|
222
|
+
rmdirSync,
|
|
223
|
+
rmSync as rmSync2
|
|
224
|
+
} from "node:fs";
|
|
218
225
|
import { basename, dirname, join as join2 } from "node:path";
|
|
219
226
|
|
|
220
227
|
// src/shared/storage-file-mutex.ts
|
|
@@ -357,6 +364,58 @@ var lkgServedArrayDigest = hash;
|
|
|
357
364
|
function lkgRecoveryFencePath(sessionId) {
|
|
358
365
|
return join2(getMagicContextStorageDir(), "lkg-recovery-fences", `${hash(sessionId)}.json`);
|
|
359
366
|
}
|
|
367
|
+
var lockSweepDirectory;
|
|
368
|
+
function closeLkgLockSweepDirectory() {
|
|
369
|
+
lockSweepDirectory?.dir.closeSync();
|
|
370
|
+
lockSweepDirectory = undefined;
|
|
371
|
+
}
|
|
372
|
+
function takeLkgRecoveryLockSweepPage(maxEntries = 200) {
|
|
373
|
+
const path = join2(getMagicContextStorageDir(), "lkg-recovery-fences");
|
|
374
|
+
if (lockSweepDirectory?.path !== path)
|
|
375
|
+
closeLkgLockSweepDirectory();
|
|
376
|
+
const names = [];
|
|
377
|
+
try {
|
|
378
|
+
lockSweepDirectory ??= { path, dir: opendirSync(path) };
|
|
379
|
+
for (let i = 0;i < Math.min(200, Math.max(1, maxEntries)); i++) {
|
|
380
|
+
const entry = lockSweepDirectory.dir.readSync();
|
|
381
|
+
if (!entry) {
|
|
382
|
+
closeLkgLockSweepDirectory();
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
if (entry.isDirectory() && /^[a-f0-9]{64}\.json\.locks$/.test(entry.name))
|
|
386
|
+
names.push(entry.name);
|
|
387
|
+
}
|
|
388
|
+
} catch {
|
|
389
|
+
closeLkgLockSweepDirectory();
|
|
390
|
+
}
|
|
391
|
+
return names;
|
|
392
|
+
}
|
|
393
|
+
function sweepEmptyLkgRecoveryLockDirectories(names, retainedSessionIds) {
|
|
394
|
+
if (!durableFencesSupported())
|
|
395
|
+
return 0;
|
|
396
|
+
const retainedHashes = new Set(Array.from(retainedSessionIds, hash));
|
|
397
|
+
const root = join2(getMagicContextStorageDir(), "lkg-recovery-fences");
|
|
398
|
+
let removed = 0;
|
|
399
|
+
for (const name of names.slice(0, 200)) {
|
|
400
|
+
if (!/^[a-f0-9]{64}\.json\.locks$/.test(name) || retainedHashes.has(name.slice(0, 64)))
|
|
401
|
+
continue;
|
|
402
|
+
const path = join2(root, name);
|
|
403
|
+
try {
|
|
404
|
+
try {
|
|
405
|
+
lstatSync(path.slice(0, -".locks".length));
|
|
406
|
+
continue;
|
|
407
|
+
} catch (error) {
|
|
408
|
+
if (error.code !== "ENOENT")
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
if (!lstatSync(path).isDirectory())
|
|
412
|
+
continue;
|
|
413
|
+
rmdirSync(path);
|
|
414
|
+
removed++;
|
|
415
|
+
} catch {}
|
|
416
|
+
}
|
|
417
|
+
return removed;
|
|
418
|
+
}
|
|
360
419
|
function metadata(slot) {
|
|
361
420
|
return [
|
|
362
421
|
slot.inputIdSeq,
|
|
@@ -934,6 +993,11 @@ class V2StoreReaderPool {
|
|
|
934
993
|
this.idleWaiters.clear();
|
|
935
994
|
}
|
|
936
995
|
}
|
|
996
|
+
function messageTimesQuery(count) {
|
|
997
|
+
return `SELECT id, COALESCE(time_created, json_extract(data, '$.time.created')) AS created,
|
|
998
|
+
json_extract(data, '$.time.completed') AS completed
|
|
999
|
+
FROM session_message WHERE +session_id = ? AND id IN (${Array.from({ length: count }, () => "?").join(",")})`;
|
|
1000
|
+
}
|
|
937
1001
|
|
|
938
1002
|
class V2StoreReader {
|
|
939
1003
|
path;
|
|
@@ -1030,6 +1094,12 @@ class V2StoreReader {
|
|
|
1030
1094
|
return typeof row?.count === "number" ? row.count : 0;
|
|
1031
1095
|
});
|
|
1032
1096
|
}
|
|
1097
|
+
messageCountAfterSequence(sessionID, after, through) {
|
|
1098
|
+
const rawTypes = RAW_MESSAGE_TYPES.map(() => "?").join(", ");
|
|
1099
|
+
const row = this.prepare(`SELECT COUNT(*) AS count FROM session_message
|
|
1100
|
+
WHERE session_id = ? AND seq > ? AND seq <= ? AND type IN (${rawTypes})`).get(sessionID, after, through, ...RAW_MESSAGE_TYPES);
|
|
1101
|
+
return typeof row?.count === "number" ? row.count : 0;
|
|
1102
|
+
}
|
|
1033
1103
|
sessionDirectoryPage(afterSessionID, limit) {
|
|
1034
1104
|
const rows = this.prepare(`SELECT id, COALESCE(directory, '') AS directory FROM session_v2
|
|
1035
1105
|
WHERE id > ? ORDER BY id ASC LIMIT ?`).all(afterSessionID ?? "", limit);
|
|
@@ -1157,9 +1227,7 @@ class V2StoreReader {
|
|
|
1157
1227
|
const times = new Map;
|
|
1158
1228
|
for (let offset = 0;offset < ids.length; offset += 500) {
|
|
1159
1229
|
const batch = ids.slice(offset, offset + 500);
|
|
1160
|
-
const rows = this.prepare(
|
|
1161
|
-
json_extract(data, '$.time.completed') AS completed
|
|
1162
|
-
FROM session_message WHERE session_id = ? AND id IN (${batch.map(() => "?").join(",")})`).all(sessionID, ...batch);
|
|
1230
|
+
const rows = this.prepare(messageTimesQuery(batch.length)).all(sessionID, ...batch);
|
|
1163
1231
|
for (const row of rows)
|
|
1164
1232
|
times.set(row.id, {
|
|
1165
1233
|
created: typeof row.created === "number" ? row.created : undefined,
|
|
@@ -1469,7 +1537,7 @@ function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
|
|
|
1469
1537
|
fallback.run(tagTombstoneOwnerKey(id, getHarness2()), getHarness2(), ...tagTombstoneOwnerRange(id));
|
|
1470
1538
|
}
|
|
1471
1539
|
for (const sessionId of deletableSessionIds)
|
|
1472
|
-
|
|
1540
|
+
deleteChunkEmbedBackoffForSession2(db, sessionId);
|
|
1473
1541
|
for (const definition of SESSION_SCOPED_TABLES) {
|
|
1474
1542
|
if (definition.table === "message_history_fts") {
|
|
1475
1543
|
cleanupStatement(db, `DELETE FROM message_history_fts
|
|
@@ -1520,7 +1588,7 @@ function deleteSessionScopedRowsSlice(db, sessionId, harness) {
|
|
|
1520
1588
|
cleanupStatement(db, "INSERT OR IGNORE INTO schema_migrations_meta(key,value) VALUES (?,?)").run(tagTombstoneOwnerKey(sessionId, harness), harness);
|
|
1521
1589
|
let remaining = SESSION_CLEANUP_SLICE_ROWS;
|
|
1522
1590
|
const started = performance.now();
|
|
1523
|
-
remaining -=
|
|
1591
|
+
remaining -= deleteChunkEmbedBackoffForSession2(db, sessionId, remaining);
|
|
1524
1592
|
if (remaining <= 0)
|
|
1525
1593
|
return { complete: false, deleted: 0 };
|
|
1526
1594
|
for (const definition of SESSION_SCOPED_TABLES) {
|
|
@@ -2034,14 +2102,20 @@ function harnessSupportsOpenCodeOrphanSweep(harness) {
|
|
|
2034
2102
|
return harness === "opencode" || harness === "opencode2";
|
|
2035
2103
|
}
|
|
2036
2104
|
function getMessageHistoryOrphanSweepState(db, harness) {
|
|
2037
|
-
|
|
2105
|
+
const state = db.prepare("SELECT cursor_session_id, last_swept_at FROM message_history_orphan_sweep WHERE harness = ?").get(harness) ?? {};
|
|
2106
|
+
if (harness === "opencode2") {
|
|
2107
|
+
if (!state.cursor_session_id?.startsWith("session_v2:"))
|
|
2108
|
+
return {};
|
|
2109
|
+
return { ...state, cursor_session_id: state.cursor_session_id.slice("session_v2:".length) };
|
|
2110
|
+
}
|
|
2111
|
+
return state;
|
|
2038
2112
|
}
|
|
2039
2113
|
function persistMessageHistoryOrphanSweepState(db, cursor, lastSweptAt, harness) {
|
|
2040
2114
|
db.prepare(`INSERT INTO message_history_orphan_sweep (harness, cursor_session_id, last_swept_at)
|
|
2041
2115
|
VALUES (?, ?, ?)
|
|
2042
2116
|
ON CONFLICT(harness) DO UPDATE SET
|
|
2043
2117
|
cursor_session_id = excluded.cursor_session_id,
|
|
2044
|
-
last_swept_at = excluded.last_swept_at`).run(harness, cursor, lastSweptAt);
|
|
2118
|
+
last_swept_at = excluded.last_swept_at`).run(harness, harness === "opencode2" ? `session_v2:${cursor}` : cursor, lastSweptAt);
|
|
2045
2119
|
}
|
|
2046
2120
|
function getOpenCodeSessionScopedCandidateSourceSql(harness) {
|
|
2047
2121
|
const sources = SESSION_SCOPED_TABLES.filter((definition) => definition.harnessScoped === true).map((definition) => {
|
|
@@ -2089,13 +2163,14 @@ function* sweepOrphanedOpenCodeMessageIndexesInBackground(db, openReadableOpenCo
|
|
|
2089
2163
|
let v2Reader;
|
|
2090
2164
|
try {
|
|
2091
2165
|
let sessionExists;
|
|
2166
|
+
let liveIds;
|
|
2092
2167
|
if (harness === "opencode2") {
|
|
2093
2168
|
try {
|
|
2094
2169
|
const path = getSqliteDatabasePath2(openCodeDb);
|
|
2095
2170
|
if (!path)
|
|
2096
2171
|
throw new Error("OpenCode 2 source has no durable path");
|
|
2097
2172
|
v2Reader = new V2StoreReader(path);
|
|
2098
|
-
|
|
2173
|
+
liveIds = new Set(v2Reader.sessionIds());
|
|
2099
2174
|
if (liveIds.size === 0)
|
|
2100
2175
|
throw new Error("OpenCode 2 source has no sessions");
|
|
2101
2176
|
sessionExists = (id) => liveIds.has(id);
|
|
@@ -2104,9 +2179,26 @@ function* sweepOrphanedOpenCodeMessageIndexesInBackground(db, openReadableOpenCo
|
|
|
2104
2179
|
return { status: "source_unavailable", scanned: 0, deleted: 0, cursor };
|
|
2105
2180
|
}
|
|
2106
2181
|
} else {
|
|
2182
|
+
liveIds = new Set(openCodeDb.prepare("SELECT id FROM session").all().map((row) => row.id));
|
|
2107
2183
|
const query = openCodeDb.prepare("SELECT 1 FROM session WHERE id = ? LIMIT 1");
|
|
2108
2184
|
sessionExists = (id) => !!query.get(id);
|
|
2109
2185
|
}
|
|
2186
|
+
if (options.fenceLockNames?.length) {
|
|
2187
|
+
const retainedIds = new Set(liveIds);
|
|
2188
|
+
const sources = SESSION_SCOPED_TABLES.map((def) => `SELECT session_id FROM ${def.table}${def.extraPredicate ? ` WHERE ${def.extraPredicate}` : ""}`);
|
|
2189
|
+
for (const row of db.prepare(sources.join(" UNION ")).all()) {
|
|
2190
|
+
if (typeof row.session_id === "string")
|
|
2191
|
+
retainedIds.add(row.session_id);
|
|
2192
|
+
}
|
|
2193
|
+
for (const row of db.prepare("SELECT key FROM schema_migrations_meta WHERE key >= ? AND key < ?").all(TAG_TOMBSTONE_OWNER_PREFIX, "tag_revision_owner;")) {
|
|
2194
|
+
try {
|
|
2195
|
+
const id = JSON.parse(row.key.slice(TAG_TOMBSTONE_OWNER_PREFIX.length, row.key.lastIndexOf(":")));
|
|
2196
|
+
if (typeof id === "string")
|
|
2197
|
+
retainedIds.add(id);
|
|
2198
|
+
} catch {}
|
|
2199
|
+
}
|
|
2200
|
+
sweepEmptyLkgRecoveryLockDirectories(options.fenceLockNames, retainedIds);
|
|
2201
|
+
}
|
|
2110
2202
|
const cutoff = now - safetyAgeMs;
|
|
2111
2203
|
const candidateSourceSql = getOpenCodeSessionScopedCandidateSourceSql(harness);
|
|
2112
2204
|
const candidates = db.prepare(`SELECT session_id
|
|
@@ -2198,4 +2290,4 @@ async function sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, openSource,
|
|
|
2198
2290
|
}));
|
|
2199
2291
|
}
|
|
2200
2292
|
|
|
2201
|
-
export { BoundedSessionMap, advanceSessionActivity, observeSessionActivity, backfillSessionActivity, clearCompressionDepth, clearCompressionDepthRange, LkgRecoveryFenceError, clearLkgFenceProcessState, lkgServedArrayDigest, hasCleanLkgRecoveryFence, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, commitLkgWithRecoveryFence, clearLkgRecoveryFence, cleanSearchText, keywordRelevance, matchedSearchSnippet, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, deleteSessionScopedRows, MESSAGE_INDEX_MAX_FTS_BYTES2, messageIndexSkipKey2, toMessageIndexSource2, getMessageIndexSourceIdentity2, isMessageIndexSourceCurrent2, getLastIndexedOrdinal2, getIndexedMessageCorpusSize2, markMessageIndexDirty2, getMessageIndexReconciliationStartOrdinal2, isMessageIndexReconciledThrough2, deleteIndexedMessage2, clearIndexedMessagesInTransaction2, clearIndexedMessages2, getIndexableContent2, indexSingleMessage2, indexMessagesAfterOrdinal2, indexSourcesAfterOrdinal2, sweepOrphanedOpenCodeMessageIndexesCooperatively2 };
|
|
2293
|
+
export { BoundedSessionMap, advanceSessionActivity, observeSessionActivity, backfillSessionActivity, clearCompressionDepth, clearCompressionDepthRange, LkgRecoveryFenceError, clearLkgFenceProcessState, lkgServedArrayDigest, takeLkgRecoveryLockSweepPage, hasCleanLkgRecoveryFence, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, commitLkgWithRecoveryFence, clearLkgRecoveryFence, cleanSearchText, keywordRelevance, matchedSearchSnippet, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, deleteSessionScopedRows, MESSAGE_INDEX_MAX_FTS_BYTES2, messageIndexSkipKey2, toMessageIndexSource2, getMessageIndexSourceIdentity2, isMessageIndexSourceCurrent2, getLastIndexedOrdinal2, getIndexedMessageCorpusSize2, markMessageIndexDirty2, getMessageIndexReconciliationStartOrdinal2, isMessageIndexReconciledThrough2, deleteIndexedMessage2, clearIndexedMessagesInTransaction2, clearIndexedMessages2, getIndexableContent2, indexSingleMessage2, indexMessagesAfterOrdinal2, indexSourcesAfterOrdinal2, sweepOrphanedOpenCodeMessageIndexesCooperatively2 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveDreamerTaskModel2
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-5kym00ag.js";
|
|
4
4
|
import {
|
|
5
5
|
isDreamerRunnable
|
|
6
6
|
} from "./index-ksdyrrav.js";
|
|
@@ -187,6 +187,7 @@ function buildDreamTaskRuntimeConfigs2(dreamer, harness, language, smartNotesEna
|
|
|
187
187
|
schedule: resolved.schedule ?? "",
|
|
188
188
|
model: resolved.primary,
|
|
189
189
|
fallbackModels: resolved.fallbacks,
|
|
190
|
+
modelConfigKey: resolved.primary?.sourceConfigKey ?? resolved.fallbacks[0]?.sourceConfigKey,
|
|
190
191
|
thinkingLevel: harness === "pi" ? resolved.primary?.qualifier : undefined,
|
|
191
192
|
language,
|
|
192
193
|
timeoutMinutes: resolved.timeoutMinutes ?? 20,
|