@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
|
@@ -15,6 +15,9 @@ function resolveHarnessBlock(container, harness) {
|
|
|
15
15
|
const selected = harness === "omp" ? container?.omp ?? container?.pi : container?.[harness];
|
|
16
16
|
return asRecord(selected);
|
|
17
17
|
}
|
|
18
|
+
function sourceHarness(container, harness) {
|
|
19
|
+
return harness === "omp" && container?.omp == null ? "pi" : harness;
|
|
20
|
+
}
|
|
18
21
|
function normalizeModelEntry2(entry, harness) {
|
|
19
22
|
if (typeof entry === "string") {
|
|
20
23
|
const model = readString(entry);
|
|
@@ -61,13 +64,19 @@ function resolveHistorianModel2(config, harness) {
|
|
|
61
64
|
const block = resolveHarnessBlock(historian, harness);
|
|
62
65
|
if (!block)
|
|
63
66
|
return { fallbacks: [] };
|
|
67
|
+
const source = `historian.${sourceHarness(historian, harness)}`;
|
|
68
|
+
const primary = resolvePrimaryEntry({
|
|
69
|
+
entry: block.model,
|
|
70
|
+
defaultQualifier: block[harness === "opencode" ? "variant" : "thinking_level"],
|
|
71
|
+
harness
|
|
72
|
+
});
|
|
73
|
+
const fallbacks = resolveFallbackEntries2(block.fallback_models, harness);
|
|
64
74
|
return {
|
|
65
|
-
primary:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})
|
|
70
|
-
fallbacks: resolveFallbackEntries2(block.fallback_models, harness)
|
|
75
|
+
primary: primary ? { ...primary, sourceConfigKey: `${source}.model` } : undefined,
|
|
76
|
+
fallbacks: fallbacks.map((entry) => ({
|
|
77
|
+
...entry,
|
|
78
|
+
sourceConfigKey: `${source}.fallback_models`
|
|
79
|
+
}))
|
|
71
80
|
};
|
|
72
81
|
}
|
|
73
82
|
function resolveDreamerTaskModel2(args) {
|
|
@@ -86,15 +95,25 @@ function resolveDreamerTaskModel2(args) {
|
|
|
86
95
|
const taskQualifier = taskBlock?.[args.harness === "opencode" ? "variant" : "thinking_level"];
|
|
87
96
|
const harnessQualifier = harnessBlock[args.harness === "opencode" ? "variant" : "thinking_level"] ?? normalizeModelEntry2(harnessBlock.model, args.harness)?.qualifier;
|
|
88
97
|
const taskHasModel = taskBlock !== undefined && hasOwn(taskBlock, "model");
|
|
98
|
+
const taskHasFallbacks = taskBlock !== undefined && hasOwn(taskBlock, "fallback_models");
|
|
89
99
|
const primarySource = taskHasModel ? taskBlock?.model : harnessBlock.model;
|
|
90
|
-
const fallbackSource =
|
|
100
|
+
const fallbackSource = taskHasFallbacks ? taskBlock?.fallback_models : harnessBlock.fallback_models;
|
|
101
|
+
const source = `dreamer.${sourceHarness(dreamer, args.harness)}`;
|
|
102
|
+
const primary = resolvePrimaryEntry({
|
|
103
|
+
entry: primarySource,
|
|
104
|
+
defaultQualifier: taskQualifier ?? harnessQualifier,
|
|
105
|
+
harness: args.harness
|
|
106
|
+
});
|
|
107
|
+
const fallbacks = resolveFallbackEntries2(fallbackSource, args.harness);
|
|
91
108
|
return {
|
|
92
|
-
primary:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
primary: primary ? {
|
|
110
|
+
...primary,
|
|
111
|
+
sourceConfigKey: taskHasModel ? `${source}.tasks.${args.task}.model` : `${source}.model`
|
|
112
|
+
} : undefined,
|
|
113
|
+
fallbacks: fallbacks.map((entry) => ({
|
|
114
|
+
...entry,
|
|
115
|
+
sourceConfigKey: taskHasFallbacks ? `${source}.tasks.${args.task}.fallback_models` : `${source}.fallback_models`
|
|
116
|
+
})),
|
|
98
117
|
schedule: readString(schedulingTask?.schedule),
|
|
99
118
|
timeoutMinutes: typeof taskBlock?.timeout_minutes === "number" ? taskBlock.timeout_minutes : undefined,
|
|
100
119
|
promotionThreshold: typeof schedulingTask?.promotion_threshold === "number" ? schedulingTask.promotion_threshold : undefined
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
importPluginModule,
|
|
6
6
|
sessionLog2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-h7tgn49j.js";
|
|
8
8
|
import {
|
|
9
9
|
isDefaultSessionTitle2
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-rrv26qjz.js";
|
|
11
11
|
import {
|
|
12
12
|
shouldHoldIgnoredNotification
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-ksq50rg0.js";
|
|
14
14
|
import {
|
|
15
15
|
getErrorMessage
|
|
16
16
|
} from "./index-y8v6yerm.js";
|
|
@@ -142,7 +142,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
|
|
|
142
142
|
holdIgnoredNotification({ client, sessionId, text, params, forcePersist }, "during target checks");
|
|
143
143
|
return "queued";
|
|
144
144
|
}
|
|
145
|
-
const { waitForSafeNotificationTarget } = await importPluginModule(() => import("./safe-notification-target-
|
|
145
|
+
const { waitForSafeNotificationTarget } = await importPluginModule(() => import("./safe-notification-target-mkr9yzvr.js"));
|
|
146
146
|
if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
|
|
147
147
|
sessionLog2(sessionId, "notification skipped (session not titled yet)");
|
|
148
148
|
return "skipped";
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
} from "./index-fr0wbhdn.js";
|
|
4
4
|
import {
|
|
5
5
|
log2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-h7tgn49j.js";
|
|
7
7
|
import {
|
|
8
8
|
ensureColumn,
|
|
9
9
|
healAllNullColumns,
|
|
10
10
|
installV95PerfSchema
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-x9k3mqrf.js";
|
|
12
12
|
import {
|
|
13
13
|
resolveOpenCodeDbPath,
|
|
14
14
|
openCodeDbPathExists,
|
|
@@ -16,14 +16,14 @@ import {
|
|
|
16
16
|
} from "./index-58e3y90n.js";
|
|
17
17
|
import {
|
|
18
18
|
Database2
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-gzy5w8ya.js";
|
|
20
20
|
import {
|
|
21
21
|
normalizeStoredProjectPath,
|
|
22
22
|
storedPathBelongsToIdentity
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-kq5w68dp.js";
|
|
24
24
|
import {
|
|
25
25
|
logSlowWriteTransaction
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-t5pck3ss.js";
|
|
27
27
|
|
|
28
28
|
// src/features/magic-context/lkg-prefix-chunks.ts
|
|
29
29
|
import { createHash } from "node:crypto";
|
|
@@ -3,21 +3,23 @@ import {
|
|
|
3
3
|
importPluginModule,
|
|
4
4
|
writeForwardedLogLine2,
|
|
5
5
|
log2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-h7tgn49j.js";
|
|
7
7
|
import {
|
|
8
8
|
inRootAsyncContext2,
|
|
9
9
|
registerSlowWriteReporter2,
|
|
10
10
|
registerSqliteDiagnosticSink2,
|
|
11
11
|
detectSqliteRuntime2,
|
|
12
12
|
Database2,
|
|
13
|
+
createSqliteTurnDatabase2,
|
|
14
|
+
hasSqliteTurnDeadlineRouting2,
|
|
13
15
|
withSqliteBackgroundWriter2,
|
|
14
16
|
withoutSqliteTransformPass2,
|
|
15
17
|
isTransientSqliteError2,
|
|
16
18
|
withPrivilegedWriter2
|
|
17
|
-
} from "./index-
|
|
19
|
+
} from "./index-gzy5w8ya.js";
|
|
18
20
|
import {
|
|
19
21
|
scheduleAfterBootQuiet
|
|
20
|
-
} from "./index-
|
|
22
|
+
} from "./index-kq5w68dp.js";
|
|
21
23
|
import {
|
|
22
24
|
getHarness2,
|
|
23
25
|
harnessOwnsOpenCodeStore2
|
|
@@ -36,13 +38,13 @@ import {
|
|
|
36
38
|
parseRpcPortFile,
|
|
37
39
|
inspectProcessesAsync,
|
|
38
40
|
inspectWindowsProcessesSync
|
|
39
|
-
} from "./index-
|
|
41
|
+
} from "./index-c7phnbvk.js";
|
|
40
42
|
import {
|
|
41
43
|
configureContextDatabasePragmas2
|
|
42
44
|
} from "./index-fb3zxn06.js";
|
|
43
45
|
import {
|
|
44
46
|
startMessageFtsRowidMapBackfill2
|
|
45
|
-
} from "./index-
|
|
47
|
+
} from "./index-x6cbrv9h.js";
|
|
46
48
|
import {
|
|
47
49
|
LKG_SLOT_CHUNKS_DDL,
|
|
48
50
|
SESSION_REPLAY_DECISIONS_DDL,
|
|
@@ -52,12 +54,12 @@ import {
|
|
|
52
54
|
hasPendingMigrations,
|
|
53
55
|
getMainThreadMigrationBodyCount,
|
|
54
56
|
runMigrations
|
|
55
|
-
} from "./index-
|
|
57
|
+
} from "./index-9q1g3c5q.js";
|
|
56
58
|
import {
|
|
57
59
|
installTagIdentityRevisionTrigger,
|
|
58
60
|
ensureColumn,
|
|
59
61
|
installV95PerfSchema
|
|
60
|
-
} from "./index-
|
|
62
|
+
} from "./index-x9k3mqrf.js";
|
|
61
63
|
import {
|
|
62
64
|
resolveOpenCodeDbPath,
|
|
63
65
|
hasV1MessageTables
|
|
@@ -65,7 +67,7 @@ import {
|
|
|
65
67
|
import {
|
|
66
68
|
setDatabase,
|
|
67
69
|
loadToolDefinitionMeasurements
|
|
68
|
-
} from "./index-
|
|
70
|
+
} from "./index-j76ah6d7.js";
|
|
69
71
|
import {
|
|
70
72
|
getErrorMessage
|
|
71
73
|
} from "./index-y8v6yerm.js";
|
|
@@ -74,7 +76,7 @@ import {
|
|
|
74
76
|
} from "./index-8ajstryz.js";
|
|
75
77
|
import {
|
|
76
78
|
logSlowWriteTransaction
|
|
77
|
-
} from "./index-
|
|
79
|
+
} from "./index-t5pck3ss.js";
|
|
78
80
|
import {
|
|
79
81
|
shouldEnforcePrivateStoragePermissions,
|
|
80
82
|
ensureStorageDirectorySync,
|
|
@@ -1277,8 +1279,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1277
1279
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1278
1280
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1279
1281
|
return;
|
|
1280
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1281
|
-
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-
|
|
1282
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-t039f0m5.js"));
|
|
1283
|
+
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-4qva0b4f.js"));
|
|
1282
1284
|
if (signal.aborted)
|
|
1283
1285
|
return;
|
|
1284
1286
|
await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
|
|
@@ -2583,6 +2585,10 @@ function openDatabase(dbPathOrOptions) {
|
|
|
2583
2585
|
return null;
|
|
2584
2586
|
}
|
|
2585
2587
|
if (existing) {
|
|
2588
|
+
if (options?.nativeTurnDeadlines && !hasSqliteTurnDeadlineRouting2(existing)) {
|
|
2589
|
+
log2("[magic-context] storage unavailable: native turn deadlines must be selected on the first open; restart the host");
|
|
2590
|
+
return null;
|
|
2591
|
+
}
|
|
2586
2592
|
if (!enforceSchemaFence(existing, dbPath, latestSupportedVersion)) {
|
|
2587
2593
|
return null;
|
|
2588
2594
|
}
|
|
@@ -2607,7 +2613,7 @@ function openDatabase(dbPathOrOptions) {
|
|
|
2607
2613
|
throw error;
|
|
2608
2614
|
}
|
|
2609
2615
|
}
|
|
2610
|
-
db = new Database2(dbPath);
|
|
2616
|
+
db = options?.nativeTurnDeadlines ? createSqliteTurnDatabase2(dbPath) : new Database2(dbPath);
|
|
2611
2617
|
installBootBusyTimeout(db, dbPath, busyTimeoutMs, options?.onBootBusyTimeout);
|
|
2612
2618
|
if (!enforceSchemaFence(db, dbPath, latestSupportedVersion)) {
|
|
2613
2619
|
closeQuietly(db);
|
|
@@ -2654,6 +2660,10 @@ async function openDatabaseAsync(dbPathOrOptions) {
|
|
|
2654
2660
|
lastMigrationOnOpenRefusal = null;
|
|
2655
2661
|
const existing = databases.get(dbPath);
|
|
2656
2662
|
if (existing) {
|
|
2663
|
+
if (options?.nativeTurnDeadlines && !hasSqliteTurnDeadlineRouting2(existing)) {
|
|
2664
|
+
log2("[magic-context] storage unavailable: native turn deadlines must be selected on the first open; restart the host");
|
|
2665
|
+
return null;
|
|
2666
|
+
}
|
|
2657
2667
|
const startedAt = performance.now();
|
|
2658
2668
|
const accepted = enforceSchemaFence(existing, dbPath, latestSupportedVersion);
|
|
2659
2669
|
if (accepted) {
|
|
@@ -2669,8 +2679,12 @@ async function openDatabaseAsync(dbPathOrOptions) {
|
|
|
2669
2679
|
return accepted ? existing : null;
|
|
2670
2680
|
}
|
|
2671
2681
|
const pending = pendingAsyncOpens.get(dbPath);
|
|
2672
|
-
if (pending)
|
|
2673
|
-
|
|
2682
|
+
if (pending) {
|
|
2683
|
+
if (!options?.nativeTurnDeadlines)
|
|
2684
|
+
return pending;
|
|
2685
|
+
const opened = await pending;
|
|
2686
|
+
return opened && hasSqliteTurnDeadlineRouting2(opened) ? opened : null;
|
|
2687
|
+
}
|
|
2674
2688
|
if (!isFileBackedPath(dbPath)) {
|
|
2675
2689
|
throw new Error("async migration requires a file-backed database; use the explicit synchronous opener for in-memory or URI test databases");
|
|
2676
2690
|
}
|
|
@@ -2696,7 +2710,7 @@ async function openDatabaseAsync(dbPathOrOptions) {
|
|
|
2696
2710
|
throw error;
|
|
2697
2711
|
}
|
|
2698
2712
|
}
|
|
2699
|
-
db = new Database2(dbPath);
|
|
2713
|
+
db = options?.nativeTurnDeadlines ? createSqliteTurnDatabase2(dbPath) : new Database2(dbPath);
|
|
2700
2714
|
installBootBusyTimeout(db, dbPath, busyTimeoutMs, options?.onBootBusyTimeout);
|
|
2701
2715
|
openMs = performance.now() - openStartedAt;
|
|
2702
2716
|
guardStartedAt = performance.now();
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/shared/worker-shutdown.ts
|
|
2
|
+
var WORKER_CLOSE_MESSAGE = { kind: "close" };
|
|
3
|
+
function isWorkerCloseMessage(message) {
|
|
4
|
+
return typeof message === "object" && message !== null && message.kind === WORKER_CLOSE_MESSAGE.kind;
|
|
5
|
+
}
|
|
6
|
+
function exitOnWorkerClose(port, closeConnections) {
|
|
7
|
+
const listener = (message) => {
|
|
8
|
+
if (!isWorkerCloseMessage(message))
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
closeConnections();
|
|
12
|
+
} finally {
|
|
13
|
+
process.exit(0);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
if (!port)
|
|
17
|
+
return { closePort() {} };
|
|
18
|
+
port.on("message", listener);
|
|
19
|
+
let closed = false;
|
|
20
|
+
return {
|
|
21
|
+
closePort() {
|
|
22
|
+
if (closed)
|
|
23
|
+
return;
|
|
24
|
+
closed = true;
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
port.off("message", listener);
|
|
27
|
+
port.close();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
var outcomes = new Map;
|
|
33
|
+
function createWorkerShutdown(worker, site, deadlineMs) {
|
|
34
|
+
let exited = false;
|
|
35
|
+
let forced = false;
|
|
36
|
+
let closing;
|
|
37
|
+
const exit = new Promise((resolve) => {
|
|
38
|
+
worker.once("exit", () => {
|
|
39
|
+
exited = true;
|
|
40
|
+
resolve();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
const record = () => {
|
|
44
|
+
const counts = outcomes.get(site) ?? { graceful: 0, forced: 0 };
|
|
45
|
+
if (forced)
|
|
46
|
+
counts.forced += 1;
|
|
47
|
+
else
|
|
48
|
+
counts.graceful += 1;
|
|
49
|
+
outcomes.set(site, counts);
|
|
50
|
+
};
|
|
51
|
+
const terminate = () => {
|
|
52
|
+
forced = true;
|
|
53
|
+
worker.terminate().catch(() => {});
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
close() {
|
|
57
|
+
if (closing)
|
|
58
|
+
return closing;
|
|
59
|
+
if (exited) {
|
|
60
|
+
closing = Promise.resolve();
|
|
61
|
+
return closing;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
worker.postMessage(WORKER_CLOSE_MESSAGE);
|
|
65
|
+
} catch {
|
|
66
|
+
terminate();
|
|
67
|
+
}
|
|
68
|
+
const fallback = setTimeout(() => {
|
|
69
|
+
if (!exited)
|
|
70
|
+
terminate();
|
|
71
|
+
}, deadlineMs);
|
|
72
|
+
fallback.unref?.();
|
|
73
|
+
closing = exit.then(() => {
|
|
74
|
+
clearTimeout(fallback);
|
|
75
|
+
record();
|
|
76
|
+
});
|
|
77
|
+
return closing;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { isWorkerCloseMessage, exitOnWorkerClose, createWorkerShutdown };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sessionLog2
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-h7tgn49j.js";
|
|
4
4
|
import {
|
|
5
5
|
clearEmergencyRecovery
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-mnhcdfxg.js";
|
|
7
7
|
import {
|
|
8
8
|
requestPendingMaterialization,
|
|
9
9
|
dropSlot,
|
|
10
10
|
executeContextRecomp
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-y76rhsnr.js";
|
|
12
12
|
import {
|
|
13
13
|
renderUserFacingFailure,
|
|
14
14
|
userFacingFailureCode
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-3svaejkh.js";
|
|
16
16
|
|
|
17
17
|
// src/hooks/magic-context/recomp-orchestrator.ts
|
|
18
18
|
function resolveLiveModelKey(liveSessionState, sessionId) {
|
|
@@ -175,6 +175,177 @@ function topLevelCommaSegments(text) {
|
|
|
175
175
|
function getTagIdentityWriteGeneration2() {
|
|
176
176
|
return tagIdentityWriteGeneration;
|
|
177
177
|
}
|
|
178
|
+
var busyTimeoutStates = new WeakMap;
|
|
179
|
+
var BUSY_TIMEOUT_QUERY = /^\s*PRAGMA\s+(?:(?:\w+|"[^"]+"|`[^`]+`|\[[^\]]+\])\s*\.\s*)?(?:busy_timeout|"busy_timeout"|`busy_timeout`|\[busy_timeout\])\s*;?\s*$/i;
|
|
180
|
+
var BUSY_TIMEOUT_SETTER = /^\s*PRAGMA\s+(?:(?:\w+|"[^"]+"|`[^`]+`|\[[^\]]+\])\s*\.\s*)?(?:busy_timeout|"busy_timeout"|`busy_timeout`|\[busy_timeout\])\s*(?==|\()/i;
|
|
181
|
+
function literalBusyTimeout(sql) {
|
|
182
|
+
const head = BUSY_TIMEOUT_SETTER.exec(sql);
|
|
183
|
+
if (!head)
|
|
184
|
+
return;
|
|
185
|
+
const match = /^(?:=\s*|\(\s*)(?:'(-?\d+)'|"(-?\d+)"|(-?\d+))\s*\)?\s*;?\s*$/.exec(sql.slice(head[0].length));
|
|
186
|
+
if (!match)
|
|
187
|
+
return;
|
|
188
|
+
const value = Number(match[1] ?? match[2] ?? match[3]);
|
|
189
|
+
return value < 0 ? 0 : value <= 2147483647 ? value : undefined;
|
|
190
|
+
}
|
|
191
|
+
function busyTimeoutStatements(sql) {
|
|
192
|
+
const statements = [];
|
|
193
|
+
let statement = "";
|
|
194
|
+
let quote = "";
|
|
195
|
+
for (let i = 0;i < sql.length; i++) {
|
|
196
|
+
const char = sql[i];
|
|
197
|
+
if (quote) {
|
|
198
|
+
statement += char;
|
|
199
|
+
if (char === quote) {
|
|
200
|
+
if (sql[i + 1] === quote)
|
|
201
|
+
statement += sql[++i];
|
|
202
|
+
else
|
|
203
|
+
quote = "";
|
|
204
|
+
}
|
|
205
|
+
} else if (char === "'" || char === '"' || char === "`" || char === "[") {
|
|
206
|
+
quote = char === "[" ? "]" : char;
|
|
207
|
+
statement += char;
|
|
208
|
+
} else if (char === "-" && sql[i + 1] === "-") {
|
|
209
|
+
while (i + 1 < sql.length && sql[i + 1] !== `
|
|
210
|
+
`)
|
|
211
|
+
i++;
|
|
212
|
+
statement += " ";
|
|
213
|
+
} else if (char === "/" && sql[i + 1] === "*") {
|
|
214
|
+
i += 2;
|
|
215
|
+
while (i < sql.length && !(sql[i] === "*" && sql[i + 1] === "/"))
|
|
216
|
+
i++;
|
|
217
|
+
i++;
|
|
218
|
+
statement += " ";
|
|
219
|
+
} else if (char === ";") {
|
|
220
|
+
statements.push(statement);
|
|
221
|
+
statement = "";
|
|
222
|
+
} else
|
|
223
|
+
statement += char;
|
|
224
|
+
}
|
|
225
|
+
statements.push(statement);
|
|
226
|
+
return statements.filter((part) => part.trim().length > 0);
|
|
227
|
+
}
|
|
228
|
+
function installNativeDeadlineRouting(db) {
|
|
229
|
+
const rawExec = db.exec.bind(db);
|
|
230
|
+
const rawPrepare = db.prepare.bind(db);
|
|
231
|
+
const readTimeout = () => {
|
|
232
|
+
const statement = rawPrepare("PRAGMA busy_timeout");
|
|
233
|
+
try {
|
|
234
|
+
return Object.values(statement.get())[0];
|
|
235
|
+
} finally {
|
|
236
|
+
statement.finalize?.();
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const timeoutState = { current: readTimeout() };
|
|
240
|
+
busyTimeoutStates.set(db, timeoutState);
|
|
241
|
+
const setBusyTimeout = (timeout) => {
|
|
242
|
+
rawExec(`PRAGMA busy_timeout=${timeout}`);
|
|
243
|
+
timeoutState.current = timeout;
|
|
244
|
+
};
|
|
245
|
+
const withinDeadline = (operation) => {
|
|
246
|
+
const deadline = nativeWaitScope?.getStore();
|
|
247
|
+
if (!deadline?.active || !deadline.remainingMs)
|
|
248
|
+
return operation();
|
|
249
|
+
const remaining = deadline.remainingMs();
|
|
250
|
+
if (remaining === Infinity)
|
|
251
|
+
return operation();
|
|
252
|
+
const previous = timeoutState.current;
|
|
253
|
+
const timeout = Math.min(previous, Math.max(0, Math.floor(remaining)));
|
|
254
|
+
if (timeout === previous)
|
|
255
|
+
return operation();
|
|
256
|
+
setBusyTimeout(timeout);
|
|
257
|
+
try {
|
|
258
|
+
return operation();
|
|
259
|
+
} finally {
|
|
260
|
+
setBusyTimeout(previous);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
Object.defineProperty(db, "exec", {
|
|
264
|
+
configurable: true,
|
|
265
|
+
writable: true,
|
|
266
|
+
value: (sql) => {
|
|
267
|
+
const parts = /\bbusy_timeout\b/i.test(sql) ? busyTimeoutStatements(sql) : [];
|
|
268
|
+
if (parts.length === 1 && BUSY_TIMEOUT_QUERY.test(parts[0]))
|
|
269
|
+
return rawExec(sql);
|
|
270
|
+
const singleSetter = parts.length === 1 && BUSY_TIMEOUT_SETTER.test(parts[0]);
|
|
271
|
+
const setting = singleSetter ? literalBusyTimeout(parts[0]) : undefined;
|
|
272
|
+
if (singleSetter) {
|
|
273
|
+
const result = rawExec(sql);
|
|
274
|
+
timeoutState.current = setting ?? readTimeout();
|
|
275
|
+
return result;
|
|
276
|
+
}
|
|
277
|
+
if (!/\bbusy_timeout\b/i.test(sql))
|
|
278
|
+
return withinDeadline(() => rawExec(sql));
|
|
279
|
+
const setters = parts.filter((part) => BUSY_TIMEOUT_SETTER.test(part));
|
|
280
|
+
return withinDeadline(() => {
|
|
281
|
+
try {
|
|
282
|
+
const result = rawExec(sql);
|
|
283
|
+
if (setters.length)
|
|
284
|
+
timeoutState.current = literalBusyTimeout(setters[setters.length - 1]) ?? readTimeout();
|
|
285
|
+
return result;
|
|
286
|
+
} catch (error) {
|
|
287
|
+
if (setters.length)
|
|
288
|
+
timeoutState.current = readTimeout();
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
const nativePrepare = (sql) => BUSY_TIMEOUT_QUERY.test(sql) || BUSY_TIMEOUT_SETTER.test(sql) ? rawPrepare(sql) : withinDeadline(() => rawPrepare(sql));
|
|
295
|
+
Object.defineProperty(db, "prepare", {
|
|
296
|
+
configurable: true,
|
|
297
|
+
writable: true,
|
|
298
|
+
value: (sql) => {
|
|
299
|
+
const statement = nativePrepare(sql);
|
|
300
|
+
const normalized = /\bbusy_timeout\b/i.test(sql) ? busyTimeoutStatements(sql)[0] ?? sql : sql;
|
|
301
|
+
const setting = literalBusyTimeout(normalized);
|
|
302
|
+
const timeoutSetter = BUSY_TIMEOUT_SETTER.test(normalized);
|
|
303
|
+
const timeoutQuery = BUSY_TIMEOUT_QUERY.test(normalized);
|
|
304
|
+
if (timeoutSetter)
|
|
305
|
+
timeoutState.current = setting ?? readTimeout();
|
|
306
|
+
for (const method of ["run", "get", "all", "values"]) {
|
|
307
|
+
const execute = statement[method]?.bind(statement);
|
|
308
|
+
if (!execute)
|
|
309
|
+
continue;
|
|
310
|
+
Object.defineProperty(statement, method, {
|
|
311
|
+
configurable: true,
|
|
312
|
+
value: (...args) => {
|
|
313
|
+
if (timeoutQuery)
|
|
314
|
+
return execute(...args);
|
|
315
|
+
if (!timeoutSetter)
|
|
316
|
+
return withinDeadline(() => execute(...args));
|
|
317
|
+
const result = execute(...args);
|
|
318
|
+
timeoutState.current = readTimeout();
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
if (typeof statement.iterate === "function") {
|
|
324
|
+
const iterate = statement.iterate.bind(statement);
|
|
325
|
+
Object.defineProperty(statement, "iterate", {
|
|
326
|
+
configurable: true,
|
|
327
|
+
value: (...args) => {
|
|
328
|
+
const iterator = !timeoutSetter && !timeoutQuery ? withinDeadline(() => iterate(...args)) : iterate(...args);
|
|
329
|
+
const next = iterator.next.bind(iterator);
|
|
330
|
+
if (timeoutSetter)
|
|
331
|
+
timeoutState.current = readTimeout();
|
|
332
|
+
iterator.next = () => {
|
|
333
|
+
if (timeoutQuery)
|
|
334
|
+
return next();
|
|
335
|
+
if (!timeoutSetter)
|
|
336
|
+
return withinDeadline(next);
|
|
337
|
+
const result = next();
|
|
338
|
+
timeoutState.current = readTimeout();
|
|
339
|
+
return result;
|
|
340
|
+
};
|
|
341
|
+
return iterator;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
return statement;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
178
349
|
function installTransactionRouting(db, readonly) {
|
|
179
350
|
const nativeExec = db.exec.bind(db);
|
|
180
351
|
Object.defineProperty(db, "exec", {
|
|
@@ -312,7 +483,7 @@ function wrapRemainingTagWriteForms(statement) {
|
|
|
312
483
|
});
|
|
313
484
|
}
|
|
314
485
|
}
|
|
315
|
-
function trackSqliteConnection(db, filename, options) {
|
|
486
|
+
function trackSqliteConnection(db, filename, options, turnDeadlines = false) {
|
|
316
487
|
const originalClose = db.close.bind(db);
|
|
317
488
|
const sequence = nextSqliteConnectionSequence++;
|
|
318
489
|
const metadata = {
|
|
@@ -320,6 +491,8 @@ function trackSqliteConnection(db, filename, options) {
|
|
|
320
491
|
filename: typeof filename === "string" ? filename : Buffer.isBuffer(filename) ? "<buffer>" : ":memory:",
|
|
321
492
|
readonly: Boolean(options) && typeof options === "object" && (options.readonly === true || options.readOnly === true)
|
|
322
493
|
};
|
|
494
|
+
if (turnDeadlines)
|
|
495
|
+
installNativeDeadlineRouting(db);
|
|
323
496
|
installTransactionRouting(db, metadata.readonly);
|
|
324
497
|
Object.defineProperty(db, "close", {
|
|
325
498
|
configurable: true,
|
|
@@ -372,6 +545,12 @@ function buildNodeSqliteDatabaseClass(DatabaseSync) {
|
|
|
372
545
|
return NodeSqliteDatabase;
|
|
373
546
|
}
|
|
374
547
|
var Database2 = TrackedDatabase;
|
|
548
|
+
function createSqliteTurnDatabase2(filename, options) {
|
|
549
|
+
return trackSqliteConnection(new DatabaseImpl(filename, options), filename, options, true);
|
|
550
|
+
}
|
|
551
|
+
function hasSqliteTurnDeadlineRouting2(db) {
|
|
552
|
+
return busyTimeoutStates.has(db);
|
|
553
|
+
}
|
|
375
554
|
function getSqliteDatabasePath2(db) {
|
|
376
555
|
for (const connection of trackedSqliteConnections.values()) {
|
|
377
556
|
if (connection.reference.deref() === db) {
|
|
@@ -391,6 +570,11 @@ function pragmaValue(db, name) {
|
|
|
391
570
|
return row[name] ?? Object.values(row)[0];
|
|
392
571
|
}
|
|
393
572
|
function pragmaNumber(db, name) {
|
|
573
|
+
if (name === "busy_timeout") {
|
|
574
|
+
const state = busyTimeoutStates.get(db);
|
|
575
|
+
if (state)
|
|
576
|
+
return state.current;
|
|
577
|
+
}
|
|
394
578
|
try {
|
|
395
579
|
const value = pragmaValue(db, name);
|
|
396
580
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
@@ -521,11 +705,14 @@ function prepareCachedStatement2(db, sql) {
|
|
|
521
705
|
return ownPreparedStatement(db, db.prepare(sql));
|
|
522
706
|
}
|
|
523
707
|
var privilegeDepth = new WeakMap;
|
|
708
|
+
var nativeWaitScope;
|
|
524
709
|
var transformPassScope = new AsyncLocalStorage;
|
|
525
710
|
var admissionScope = new AsyncLocalStorage;
|
|
526
711
|
var backgroundWriterScope = new AsyncLocalStorage;
|
|
527
712
|
function withSqliteBackgroundWriter2(operation) {
|
|
528
|
-
|
|
713
|
+
if (!nativeWaitScope?.getStore())
|
|
714
|
+
return backgroundWriterScope.run(true, operation);
|
|
715
|
+
return nativeWaitScope.run(undefined, () => backgroundWriterScope.run(true, operation));
|
|
529
716
|
}
|
|
530
717
|
function withSqliteTransformPass2(operation) {
|
|
531
718
|
const existing = transformPassScope.getStore();
|
|
@@ -556,7 +743,9 @@ function withSqliteTransformPass2(operation) {
|
|
|
556
743
|
return typeof reservation === "function" ? run(reservation) : reservation.then(run);
|
|
557
744
|
}
|
|
558
745
|
function withoutSqliteTransformPass2(operation) {
|
|
559
|
-
|
|
746
|
+
if (!nativeWaitScope?.getStore())
|
|
747
|
+
return transformPassScope.run(undefined, operation);
|
|
748
|
+
return nativeWaitScope.run(undefined, () => transformPassScope.run(undefined, operation));
|
|
560
749
|
}
|
|
561
750
|
function assertTransformWrite2() {
|
|
562
751
|
if (!backgroundWriterScope.getStore())
|
|
@@ -752,7 +941,7 @@ async function withAsyncPrivilegedWriter2(db, operation, options = {}) {
|
|
|
752
941
|
} catch (error) {
|
|
753
942
|
if (entered || !(error instanceof SqliteAcquisitionBusyError2))
|
|
754
943
|
throw error;
|
|
755
|
-
options.beforeRetry?.(error);
|
|
944
|
+
await options.beforeRetry?.(error);
|
|
756
945
|
const elapsed = performance.now() - started;
|
|
757
946
|
if (elapsed >= budgetMs) {
|
|
758
947
|
reportSqliteDiagnostic(`sqlite writer site=privileged_writer lane=foreground acquire_ms=${Math.round(elapsed)} attempts=${attempts} outcome=busy`);
|
|
@@ -890,4 +1079,4 @@ async function yieldIndexChunk2() {
|
|
|
890
1079
|
await yieldIndexTurn();
|
|
891
1080
|
}
|
|
892
1081
|
|
|
893
|
-
export { inRootAsyncContext2, registerSlowWriteReporter2, registerSqliteDiagnosticSink2, detectSqliteRuntime2, getTagIdentityWriteGeneration2, Database2, getSqliteDatabasePath2, getSqliteMemoryStats2, prepareCachedStatement2, withSqliteBackgroundWriter2, withSqliteTransformPass2, withoutSqliteTransformPass2, assertTransformWrite2, isTransientSqliteError2, SqliteAcquisitionBusyError2, beginSqliteWriterAsync2, withAsyncPrivilegedWriter2, withPrivilegedWriter2, indexCoordinationInput2, releaseIndexOwner2, withIndexChunk2, yieldIndexChunk2 };
|
|
1082
|
+
export { inRootAsyncContext2, registerSlowWriteReporter2, registerSqliteDiagnosticSink2, detectSqliteRuntime2, getTagIdentityWriteGeneration2, Database2, createSqliteTurnDatabase2, hasSqliteTurnDeadlineRouting2, getSqliteDatabasePath2, getSqliteMemoryStats2, prepareCachedStatement2, withSqliteBackgroundWriter2, withSqliteTransformPass2, withoutSqliteTransformPass2, assertTransformWrite2, isTransientSqliteError2, SqliteAcquisitionBusyError2, beginSqliteWriterAsync2, withAsyncPrivilegedWriter2, withPrivilegedWriter2, indexCoordinationInput2, releaseIndexOwner2, withIndexChunk2, yieldIndexChunk2 };
|