@cortexkit/opencode-magic-context 0.49.34 → 0.49.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/auto-search-worker.js +163 -155
- package/dist/chunk-embedding-write-worker.js +70 -66
- package/dist/{compaction-marker-candidates-31h86ph0.js → compaction-marker-candidates-5p1qkve9.js} +5 -2
- package/dist/compaction-marker-candidates-worker.js +24 -23
- package/dist/{compartment-chunk-embedding-5q5gj67r.js → compartment-chunk-embedding-ypktm0tk.js} +10 -8
- package/dist/{conflict-warning-hook-xgskea1v.js → conflict-warning-hook-b75jn458.js} +11 -9
- package/dist/{context-p3xrarzt.js → context-969z683s.js} +1839 -746
- package/dist/{derive-budgets-pqybnx09.js → derive-budgets-htj16n4x.js} +3 -2
- package/dist/embedding-backfill-rma0v2ct.js +28 -0
- package/dist/embedding-worker-process.js +2 -1
- package/dist/embedding-worker.js +6 -5
- package/dist/expand-attachments-h33jbgyz.js +21 -0
- package/dist/features/magic-context/auto-search-diagnostics.d.ts +21 -0
- package/dist/features/magic-context/auto-search-diagnostics.d.ts.map +1 -0
- package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
- package/dist/features/magic-context/compaction-marker.d.ts +5 -3
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-gate.d.ts +2 -0
- package/dist/features/magic-context/dreamer/verify-gate.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-state.d.ts +9 -0
- package/dist/features/magic-context/dreamer/verify-state.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/verify.d.ts +2 -1
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/migration-worker-client.d.ts +3 -0
- package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/migration-worker.d.ts +15 -0
- package/dist/features/magic-context/migration-worker.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +2 -2
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +4 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +1 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +4 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/store-generation-rebase-labels.d.ts +6 -0
- package/dist/features/magic-context/store-generation-rebase-labels.d.ts.map +1 -0
- package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
- package/dist/features/magic-context/work-metrics-carry-storage.d.ts +10 -0
- package/dist/features/magic-context/work-metrics-carry-storage.d.ts.map +1 -0
- package/dist/{history-owner-36wp3mkb.js → history-owner-0z620wgz.js} +3 -2
- package/dist/hooks/magic-context/apply-operations.d.ts +20 -3
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-observation.d.ts +13 -0
- package/dist/hooks/magic-context/auto-search-observation.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts +10 -2
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-commit-hashes.d.ts +4 -0
- package/dist/hooks/magic-context/compartment-commit-hashes.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +1 -0
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-completeness.d.ts +15 -0
- package/dist/hooks/magic-context/final-wire-completeness.d.ts.map +1 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/issue-423-fixture.d.ts +1 -1
- package/dist/hooks/magic-context/issue-423-fixture.d.ts.map +1 -1
- package/dist/hooks/magic-context/issue-424-fixture.d.ts +1 -1
- package/dist/hooks/magic-context/issue-424-fixture.d.ts.map +1 -1
- package/dist/hooks/magic-context/project-structural-sentinels.d.ts +25 -0
- package/dist/hooks/magic-context/project-structural-sentinels.d.ts.map +1 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +8 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +1 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +11 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts +2 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +2 -0
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/release-recovery-prefix.d.ts +9 -0
- package/dist/hooks/magic-context/release-recovery-prefix.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-structural-noise.d.ts +6 -3
- package/dist/hooks/magic-context/strip-structural-noise.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts +3 -0
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +3 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-cpjk5jd2.js → index-1d042x6w.js} +16 -14
- package/dist/{index-2743x98y.js → index-21fgrfrf.js} +35 -142
- package/dist/index-2amn2s73.js +123 -0
- package/dist/{index-c7phnbvk.js → index-2p37txes.js} +1 -1
- package/dist/index-2qbtqg1w.js +529 -0
- package/dist/{index-9gpw8hrm.js → index-2rs7912w.js} +4 -4
- package/dist/{index-m1x9ghk5.js → index-4ks89h5a.js} +37 -7
- package/dist/{index-b88dwwrh.js → index-4xyjr62e.js} +1 -1
- package/dist/index-4y35msh5.js +531 -0
- package/dist/index-66a50f3e.js +777 -0
- package/dist/index-72czy45z.js +4557 -0
- package/dist/index-7v05d9b7.js +58 -0
- package/dist/{index-qgh1qwjj.js → index-850vthn3.js} +9 -3
- package/dist/{index-np3rgfw4.js → index-8jjjmhab.js} +15 -4
- package/dist/index-96ztjvkn.js +204 -0
- package/dist/{index-fm36bjv4.js → index-9fgmkfaf.js} +22 -277
- package/dist/{index-atekmqef.js → index-9tdvbdv1.js} +508 -5547
- package/dist/{index-xrnsygfq.js → index-9wnbnx8f.js} +1 -1
- package/dist/{index-waktfbjy.js → index-ae1ar4v1.js} +4 -4
- package/dist/{index-v15ne3a3.js → index-b1ydbp95.js} +2 -2
- package/dist/{index-nxrsns5x.js → index-c5dzns43.js} +75 -75
- package/dist/{index-v7287tzq.js → index-dcjkw41m.js} +19 -8
- package/dist/{index-hbx7m8he.js → index-dfdg2cgg.js} +338 -86
- package/dist/{index-spwjbkc7.js → index-dnqqqc5f.js} +1 -1
- package/dist/{index-04z754rd.js → index-dz48h1wx.js} +33 -5
- package/dist/{index-rrv26qjz.js → index-fw42ms3m.js} +1 -1
- package/dist/{index-t5pck3ss.js → index-fxbk7gk3.js} +1 -1
- package/dist/{index-wfybj1dw.js → index-g4t7850m.js} +2 -2
- package/dist/{index-97spytxq.js → index-gnmhbyyc.js} +583 -474
- package/dist/{index-4pnsgvfk.js → index-hacf2tyx.js} +1 -1
- package/dist/index-j105mf16.js +270 -0
- package/dist/{index-gkee6p4g.js → index-jggt5gf2.js} +3 -3
- package/dist/{index-s1n8dd2n.js → index-jkanybgq.js} +2 -2
- package/dist/{index-h7tgn49j.js → index-jrfre9ah.js} +5 -222
- package/dist/{index-kfyb3k6n.js → index-jz5bk7xd.js} +2 -2
- package/dist/{index-7kkphb6c.js → index-nj360hcs.js} +4 -4
- package/dist/{index-07vskjn8.js → index-pp8vdn01.js} +15 -13
- package/dist/index-prw8apnc.js +194 -0
- package/dist/{index-rverk2vz.js → index-r2epb000.js} +34 -4
- package/dist/{index-7g9dr8gy.js → index-tn9drm1a.js} +125 -143
- package/dist/{index-kq5w68dp.js → index-txs8tce6.js} +1 -1
- package/dist/{index-rfxzazzy.js → index-ty4vhe4n.js} +5 -5
- package/dist/{index-y1qwzvxn.js → index-vd2ywmfe.js} +2 -2
- package/dist/{index-0677w9sd.js → index-wcwhhtdh.js} +58 -23
- package/dist/index-wh9fxds5.js +265 -0
- package/dist/{index-51rdvtkz.js → index-xd2p95m7.js} +3 -3
- package/dist/{index-as2amvn3.js → index-xnm0wq1r.js} +6 -531
- package/dist/{index-ftr84kkv.js → index-ys7j6679.js} +7 -5
- package/dist/index-z4p0ry94.js +222 -0
- package/dist/index-z9zygwse.js +89 -0
- package/dist/index.js +86 -74
- package/dist/{logger-94kew5wm.js → logger-qwnbcfj9.js} +2 -1
- package/dist/{message-fts-rowid-map-va36knh4.js → message-fts-rowid-map-t6qsyg9s.js} +7 -5
- package/dist/{message-index-bounded-qh91fdr3.js → message-index-bounded-wfk6aqxk.js} +15 -13
- package/dist/{message-time-backfill-4qva0b4f.js → message-time-backfill-39bm498k.js} +3 -2
- package/dist/migration-worker.js +55 -48
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{project-embedding-registry-6yex0r9f.js → project-embedding-registry-3yyegjma.js} +16 -13
- package/dist/raw-ordinal-warmup-worker.js +114 -113
- package/dist/{read-session-chunk-kaghtr75.js → read-session-chunk-26yrrhyz.js} +18 -12
- package/dist/{read-session-raw-b2sd67v4.js → read-session-raw-j7c9w57v.js} +5 -3
- package/dist/recomp-orchestrator-wk509qkp.js +69 -0
- package/dist/render-h1qarr8a.js +44 -0
- package/dist/{safe-notification-target-mkr9yzvr.js → safe-notification-target-wztd7bgk.js} +3 -2
- package/dist/search-5h9fydyq.js +54 -0
- package/dist/search-archive-q79hyqxs.js +29 -0
- package/dist/{send-session-notification-vz86nt79.js → send-session-notification-14p3yje4.js} +9 -7
- package/dist/shared/model-suggestion-retry.d.ts +7 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/prompt-async-transport.d.ts.map +1 -1
- package/dist/shared/reusable-worker-entry.d.ts +4 -0
- package/dist/shared/reusable-worker-entry.d.ts.map +1 -0
- package/dist/shared/reusable-worker.d.ts +6 -0
- package/dist/shared/reusable-worker.d.ts.map +1 -0
- package/dist/shared/reusable-worker.fixture.d.ts +2 -0
- package/dist/shared/reusable-worker.fixture.d.ts.map +1 -0
- package/dist/shared/worker-shutdown.d.ts +1 -1
- package/dist/shared/worker-shutdown.d.ts.map +1 -1
- package/dist/{storage-tags-6hvkk01c.js → storage-tags-vj0yj7ed.js} +5 -4
- package/dist/store-reader-yh19h38c.js +14 -0
- package/dist/store-s3eykdjt.js +21 -0
- package/dist/tools/ctx-expand/render.d.ts +5 -3
- package/dist/tools/ctx-expand/render.d.ts.map +1 -1
- package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
- package/dist/tools/ctx-expand/tools.d.ts +2 -0
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/tools/ctx-expand/v2-archive-reader.d.ts +33 -0
- package/dist/tools/ctx-expand/v2-archive-reader.d.ts.map +1 -0
- package/dist/{transform-postprocess-phase-ph38mhrs.js → transform-postprocess-phase-4gj0mtcg.js} +39 -32
- package/dist/v2/auto-search-worker.js +163 -155
- package/dist/v2/chunk-embedding-write-worker.js +71 -67
- package/dist/v2/compaction-marker-candidates-worker.js +24 -23
- package/dist/v2/{compaction-marker-candidates-m4vmye3w.js → compaction-marker-candidates-yeb2ky46.js} +6 -3
- package/dist/v2/{compartment-chunk-embedding-rc31e6md.js → compartment-chunk-embedding-qfk791bd.js} +11 -9
- package/dist/v2/{context-s60hcatx.js → context-bxr039be.js} +2678 -1246
- package/dist/v2/{derive-budgets-knf763tt.js → derive-budgets-sa0v7bz0.js} +4 -3
- package/dist/v2/embedding-backfill-00tw59rx.js +27 -0
- package/dist/v2/embedding-worker-process.js +2 -1
- package/dist/v2/embedding-worker.js +6 -5
- package/dist/v2/expand-attachments-h33jbgyz.js +21 -0
- package/dist/v2/fold/code-mode-catalog.d.ts +3 -0
- package/dist/v2/fold/code-mode-catalog.d.ts.map +1 -0
- package/dist/v2/fold/idle.d.ts +16 -0
- package/dist/v2/fold/idle.d.ts.map +1 -0
- package/dist/v2/fold/manual-baseline.d.ts +8 -0
- package/dist/v2/fold/manual-baseline.d.ts.map +1 -0
- package/dist/v2/fold/native-replay-v3.d.ts +75 -0
- package/dist/v2/fold/native-replay-v3.d.ts.map +1 -0
- package/dist/v2/fold/native-replay.d.ts +81 -8
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/fold/policy.d.ts +2 -1
- package/dist/v2/fold/policy.d.ts.map +1 -1
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/fold/summary.d.ts +4 -0
- package/dist/v2/fold/summary.d.ts.map +1 -0
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/{history-owner-ad0crnrn.js → history-owner-fpka43cn.js} +3 -2
- package/dist/v2/hooks/channel2.d.ts +6 -0
- package/dist/v2/hooks/channel2.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/expand-attachments.d.ts +8 -0
- package/dist/v2/hooks/expand-attachments.d.ts.map +1 -0
- package/dist/v2/hooks/overflow-recovery.d.ts +45 -0
- package/dist/v2/hooks/overflow-recovery.d.ts.map +1 -0
- package/dist/v2/hooks/restore-rows.d.ts +12 -2
- package/dist/v2/hooks/restore-rows.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts +7 -2
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/synthetic-admission.d.ts +7 -0
- package/dist/v2/hooks/synthetic-admission.d.ts.map +1 -0
- package/dist/v2/hooks/usage-persist.d.ts.map +1 -1
- package/dist/v2/{logger-p34mjtja.js → logger-4cj6d03m.js} +2 -1
- package/dist/v2/{message-fts-rowid-map-78awh03v.js → message-fts-rowid-map-z86avy0n.js} +8 -6
- package/dist/v2/{message-index-bounded-4htdr1j6.js → message-index-bounded-w14496s9.js} +16 -14
- package/dist/v2/{message-time-backfill-zvthw6xb.js → message-time-backfill-0c4h7sg6.js} +3 -2
- package/dist/v2/migration-worker.js +56 -49
- package/dist/v2/ordinal-range.fixture.d.ts +7 -0
- package/dist/v2/ordinal-range.fixture.d.ts.map +1 -0
- package/dist/v2/{project-embedding-registry-1x5qe2fy.js → project-embedding-registry-jqq2qeqb.js} +17 -14
- package/dist/v2/raw-ordinal-warmup-worker.js +114 -113
- package/dist/v2/{read-session-chunk-1fa9qzwb.js → read-session-chunk-tqnh1ret.js} +18 -12
- package/dist/v2/{read-session-raw-5x088amc.js → read-session-raw-qpp6x9kg.js} +6 -4
- package/dist/v2/recomp-orchestrator-9cjk6aej.js +68 -0
- package/dist/v2/render-5dz1knf2.js +43 -0
- package/dist/v2/{safe-notification-target-khnzg57c.js → safe-notification-target-gphhast7.js} +3 -2
- package/dist/v2/search-8yfet25y.js +52 -0
- package/dist/v2/search-archive-z6z9jqwf.js +28 -0
- package/dist/v2/{send-session-notification-x5nzy34v.js → send-session-notification-kxp47tsw.js} +9 -7
- package/dist/v2/{server-cpjk5jd2.js → server-1d042x6w.js} +16 -14
- package/dist/v2/server-2amn2s73.js +123 -0
- package/dist/v2/{server-6g98c227.js → server-3schkz95.js} +4 -4
- package/dist/v2/server-468mya5v.js +209 -0
- package/dist/v2/{server-z2wft9zv.js → server-5by3vdzs.js} +562 -5560
- package/dist/v2/{server-qjvk4a9t.js → server-69m30b21.js} +1 -1
- package/dist/v2/server-6emy0v9a.js +531 -0
- package/dist/v2/{server-vr4szghm.js → server-6vzh6wej.js} +3 -3
- package/dist/v2/{server-ajxhrgjv.js → server-7094pk3w.js} +80 -19
- package/dist/v2/{server-ab8017gw.js → server-7acq7815.js} +34 -141
- package/dist/v2/server-7v05d9b7.js +58 -0
- package/dist/v2/{server-24g8r2d0.js → server-7zacmty5.js} +75 -75
- package/dist/v2/{server-3mz2qh5a.js → server-969cdpmg.js} +1 -1
- package/dist/v2/server-96ztjvkn.js +204 -0
- package/dist/v2/{server-grakwy1v.js → server-a9w5f0yw.js} +37 -7
- package/dist/v2/{server-835q39kd.js → server-avdveykk.js} +3 -3
- package/dist/v2/{server-qc915kw2.js → server-bez34e60.js} +4 -4
- package/dist/v2/{server-h1byrhwx.js → server-cp1a03vc.js} +19 -8
- package/dist/v2/{server-bsgd4dk1.js → server-dcws5831.js} +2 -2
- package/dist/v2/{server-m1pfg2d4.js → server-dfq5vb8j.js} +4 -4
- package/dist/v2/server-e51xmr4d.js +194 -0
- package/dist/v2/server-ef1mskas.js +777 -0
- package/dist/v2/{server-1bw1wcbp.js → server-f0j864ma.js} +1 -1
- package/dist/v2/{server-jw5qe9y8.js → server-g3gqq4ac.js} +18 -217
- package/dist/v2/{server-2aasmpsp.js → server-gkse1wyz.js} +5 -5
- package/dist/v2/{server-6495nmn9.js → server-jb6tjyeb.js} +5 -222
- package/dist/v2/{server-qvy4qavp.js → server-jd7vzwn4.js} +125 -143
- package/dist/v2/{server-a7x00tw8.js → server-mfn1yf9d.js} +1 -1
- package/dist/v2/{server-awr8qa4c.js → server-nmyganc8.js} +2 -2
- package/dist/v2/{server-tkdabx8q.js → server-nq3cb7be.js} +5 -530
- package/dist/v2/server-qjyp27vf.js +270 -0
- package/dist/v2/{server-gyy4k6mf.js → server-qmmkhz2z.js} +1 -1
- package/dist/v2/{server-29qp8nz4.js → server-qxzbmtqt.js} +1 -1
- package/dist/v2/{server-806rzhs6.js → server-r4430x9m.js} +10 -4
- package/dist/v2/{server-53eh1r8r.js → server-sd8hvzte.js} +2 -2
- package/dist/v2/{server-k3t06fxr.js → server-sefxj8k1.js} +1 -1
- package/dist/v2/server-t8y64xj7.js +4513 -0
- package/dist/v2/{server-6vd2n183.js → server-tnzbk64q.js} +35 -5
- package/dist/v2/{server-v77xa5wj.js → server-tpt7bwq8.js} +1 -1
- package/dist/v2/{server-51779zs2.js → server-v0p37hm2.js} +4 -1
- package/dist/v2/{server-nxas8v1d.js → server-xfjjbrkt.js} +15 -4
- package/dist/v2/{server-cqjvxyrp.js → server-xy7w7hrd.js} +2 -2
- package/dist/v2/server-ypf1ap0v.js +529 -0
- package/dist/v2/server-z4p0ry94.js +222 -0
- package/dist/v2/server-z9zygwse.js +89 -0
- package/dist/v2/{server-ab1g0wn9.js → server-zzgtgqmd.js} +2 -2
- package/dist/v2/server.js +7 -6
- package/dist/v2/{storage-tags-18nbaanf.js → storage-tags-cw07ky67.js} +5 -4
- package/dist/v2/store-reader-cgx47zkp.js +14 -0
- package/dist/v2/store-reader.d.ts +9 -2
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/store-z3qe67cg.js +21 -0
- package/dist/v2/v2-archive-reader-z7wr42ry.js +11 -0
- package/dist/v2/{wrapup-orchestrator-wxf7n5k6.js → wrapup-orchestrator-j1v62bkj.js} +50 -42
- package/dist/v2-archive-reader-028z6kck.js +11 -0
- package/dist/wrapup-orchestrator-xg9avt2p.js +56 -0
- package/package.json +1 -1
- package/src/shared/model-suggestion-retry.ts +1 -1
- package/src/shared/prompt-async-transport.test.ts +64 -3
- package/src/shared/prompt-async-transport.ts +61 -16
- package/src/shared/reusable-worker-entry.ts +58 -0
- package/src/shared/reusable-worker-reset.test.ts +108 -0
- package/src/shared/reusable-worker.fixture.ts +35 -0
- package/src/shared/reusable-worker.test.ts +253 -0
- package/src/shared/reusable-worker.ts +240 -0
- package/src/shared/sqlite-transaction-mode-guard.test.ts +2 -0
- package/src/shared/worker-shutdown.ts +21 -17
- package/dist/embedding-backfill-0jgtqxen.js +0 -25
- package/dist/recomp-orchestrator-0y983w7h.js +0 -62
- package/dist/search-archive-1kw2rp19.js +0 -26
- package/dist/search-p684j8ww.js +0 -50
- package/dist/v2/embedding-backfill-f43hd8y6.js +0 -24
- package/dist/v2/recomp-orchestrator-7q9nvxte.js +0 -61
- package/dist/v2/search-archive-xfp51s0g.js +0 -25
- package/dist/v2/search-wf8rqxhm.js +0 -48
- package/dist/wrapup-orchestrator-ys2nrkkb.js +0 -49
|
@@ -5,17 +5,17 @@ import {
|
|
|
5
5
|
getDataDir,
|
|
6
6
|
log2,
|
|
7
7
|
sessionLog2
|
|
8
|
-
} from "./server-
|
|
8
|
+
} from "./server-jb6tjyeb.js";
|
|
9
9
|
import {
|
|
10
10
|
inRootAsyncContext2,
|
|
11
11
|
withSqliteBackgroundWriter2
|
|
12
12
|
} from "./server-gzy5w8ya.js";
|
|
13
13
|
import {
|
|
14
14
|
scheduleAfterBootQuiet
|
|
15
|
-
} from "./server-
|
|
15
|
+
} from "./server-69m30b21.js";
|
|
16
16
|
import {
|
|
17
17
|
isRecord
|
|
18
|
-
} from "./server-
|
|
18
|
+
} from "./server-xfjjbrkt.js";
|
|
19
19
|
import {
|
|
20
20
|
cleanSearchText,
|
|
21
21
|
keywordRelevance,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
isMessageIndexReconciledThrough,
|
|
26
26
|
clearIndexedMessages,
|
|
27
27
|
indexMessagesAfterOrdinal
|
|
28
|
-
} from "./server-
|
|
28
|
+
} from "./server-dfq5vb8j.js";
|
|
29
29
|
import {
|
|
30
30
|
Priority,
|
|
31
31
|
AdmissionClass,
|
|
@@ -34,15 +34,14 @@ import {
|
|
|
34
34
|
StaleRouteHandleError,
|
|
35
35
|
SubcClient,
|
|
36
36
|
isConsumerReconnectTransient
|
|
37
|
-
} from "./server-
|
|
37
|
+
} from "./server-zzgtgqmd.js";
|
|
38
38
|
import {
|
|
39
39
|
buildCanonicalChunkTextFromFts2,
|
|
40
40
|
loadCompartmentChunkEmbeddingsForSearch2,
|
|
41
41
|
peekCompartmentChunkSearchPool2,
|
|
42
42
|
warmCompartmentChunkSearchPool2
|
|
43
|
-
} from "./server-
|
|
43
|
+
} from "./server-cp1a03vc.js";
|
|
44
44
|
import {
|
|
45
|
-
recordEmbeddingMeasurement,
|
|
46
45
|
saveCommitEmbedding,
|
|
47
46
|
loadProjectCommitEmbeddings,
|
|
48
47
|
loadUnembeddedCommits,
|
|
@@ -57,7 +56,10 @@ import {
|
|
|
57
56
|
enqueueShadowEmbeddingItems2,
|
|
58
57
|
getProjectEmbeddingSnapshot2,
|
|
59
58
|
embedItemsForProject2
|
|
60
|
-
} from "./server-
|
|
59
|
+
} from "./server-7acq7815.js";
|
|
60
|
+
import {
|
|
61
|
+
recordEmbeddingMeasurement
|
|
62
|
+
} from "./server-2amn2s73.js";
|
|
61
63
|
import {
|
|
62
64
|
getProjectEmbeddings2
|
|
63
65
|
} from "./server-4dhv7mqz.js";
|
|
@@ -66,7 +68,7 @@ import {
|
|
|
66
68
|
isEmbeddingEnabled,
|
|
67
69
|
embedText,
|
|
68
70
|
ensureMemoryEmbeddings2
|
|
69
|
-
} from "./server-
|
|
71
|
+
} from "./server-gkse1wyz.js";
|
|
70
72
|
import {
|
|
71
73
|
ModuleMemoryAuthorityError2,
|
|
72
74
|
getMemoriesByProject2,
|
|
@@ -74,14 +76,12 @@ import {
|
|
|
74
76
|
updateMemoryRetrievalCount2
|
|
75
77
|
} from "./server-jjvbk92s.js";
|
|
76
78
|
import {
|
|
77
|
-
getNotes,
|
|
78
|
-
getActivePrimers,
|
|
79
79
|
USER_FACING_FAILURES,
|
|
80
80
|
relaxedFtsQuery,
|
|
81
81
|
sanitizeFtsQuery,
|
|
82
82
|
searchMemoriesFTS,
|
|
83
83
|
searchMemoriesFTSUnion
|
|
84
|
-
} from "./server-
|
|
84
|
+
} from "./server-nq3cb7be.js";
|
|
85
85
|
import {
|
|
86
86
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
87
87
|
withMessageFtsSessionFilter
|
|
@@ -92,7 +92,11 @@ import {
|
|
|
92
92
|
expandWorkspaceIdentitySetWithAliases,
|
|
93
93
|
resolveStoredPathWorkspaceIdentity,
|
|
94
94
|
sourceNameForMemory
|
|
95
|
-
} from "./server-
|
|
95
|
+
} from "./server-3schkz95.js";
|
|
96
|
+
import {
|
|
97
|
+
getNotes,
|
|
98
|
+
getActivePrimers
|
|
99
|
+
} from "./server-ypf1ap0v.js";
|
|
96
100
|
import {
|
|
97
101
|
isKnownAutocommit
|
|
98
102
|
} from "./server-8ajstryz.js";
|
|
@@ -392,6 +396,32 @@ function invalidateIncrementalWork(sessionId) {
|
|
|
392
396
|
}
|
|
393
397
|
}
|
|
394
398
|
|
|
399
|
+
// src/features/magic-context/auto-search-diagnostics.ts
|
|
400
|
+
function createAutoSearchDiagnostics(threshold) {
|
|
401
|
+
return {
|
|
402
|
+
threshold,
|
|
403
|
+
lanes: {},
|
|
404
|
+
pool: "unknown",
|
|
405
|
+
poolRows: null,
|
|
406
|
+
peek: "not-run",
|
|
407
|
+
workerStarted: false
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function autoSearchRelevance(query, result) {
|
|
411
|
+
if (cleanSearchText(result.source === "compartment" ? result.title : result.content).length === 0)
|
|
412
|
+
return 0;
|
|
413
|
+
return result.source === "message" || "matchType" in result && result.source !== "compartment" && result.matchType !== "semantic" ? keywordRelevance(query, result.content) : result.score;
|
|
414
|
+
}
|
|
415
|
+
function recordAutoSearchLane(diagnostics, lane, query, results) {
|
|
416
|
+
if (!diagnostics)
|
|
417
|
+
return;
|
|
418
|
+
const scores = results.map((result) => result.relevanceScore ?? autoSearchRelevance(query, result));
|
|
419
|
+
diagnostics.lanes[lane] = {
|
|
420
|
+
top: scores.length ? Math.max(...scores) : null,
|
|
421
|
+
nearMisses: scores.filter((score) => score >= 0.5 && score < diagnostics.threshold).length
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
395
425
|
// src/hooks/magic-context/module-transport.ts
|
|
396
426
|
import { realpathSync } from "node:fs";
|
|
397
427
|
import { join } from "node:path";
|
|
@@ -1736,6 +1766,7 @@ var RERANK_MODEL = "gte-reranker-modernbert-base-f32";
|
|
|
1736
1766
|
var RERANK_LANE_LIMIT = 25;
|
|
1737
1767
|
var DEADLINE_MS = 1500;
|
|
1738
1768
|
var DOCUMENT_BYTES = 1024;
|
|
1769
|
+
var proseWordSegmenter = new Intl.Segmenter(undefined, { granularity: "word" });
|
|
1739
1770
|
function isProseQuery(query) {
|
|
1740
1771
|
const text = query.trim();
|
|
1741
1772
|
if (!text || /[\n;]|^["'`]|["'`]$/.test(text))
|
|
@@ -1744,10 +1775,10 @@ function isProseQuery(query) {
|
|
|
1744
1775
|
return false;
|
|
1745
1776
|
if (/\b(?:[A-Z][A-Z_]+:|\w*(?:Error|Exception):)|\bat\s+\S+\s*\(/.test(text))
|
|
1746
1777
|
return false;
|
|
1747
|
-
const words = text.replace(/[?!.]$/, "").split(/\s+/);
|
|
1778
|
+
const words = /(?![a-zA-Z])\p{L}/u.test(text) ? [...proseWordSegmenter.segment(text)].filter((word) => word.isWordLike).map((word) => word.segment) : text.replace(/[?!.]$/, "").split(/\s+/);
|
|
1748
1779
|
if (words.length < 3)
|
|
1749
1780
|
return false;
|
|
1750
|
-
const plain = words.filter((word) => /^[
|
|
1781
|
+
const plain = words.filter((word) => /^[\p{L}\p{M}]+(?:['’-][\p{L}\p{M}]+)*$/u.test(word));
|
|
1751
1782
|
if (/^(?:how|why|what|where|when|which|who)\b/i.test(text))
|
|
1752
1783
|
return plain.length >= 3;
|
|
1753
1784
|
return words.length >= 4 && plain.length >= 3 && !/[\\/]|::|=/.test(text);
|
|
@@ -3009,11 +3040,17 @@ async function searchCompartmentChunks(args) {
|
|
|
3009
3040
|
if (args.limit <= 0 || !args.modelId || args.modelId === "off") {
|
|
3010
3041
|
if (args.timings)
|
|
3011
3042
|
args.timings.chunkPool = "off";
|
|
3043
|
+
if (args.diagnostics)
|
|
3044
|
+
args.diagnostics.pool = "off";
|
|
3045
|
+
args.reportDiagnostics?.();
|
|
3012
3046
|
return [];
|
|
3013
3047
|
}
|
|
3014
3048
|
if (!args.queryEmbedding) {
|
|
3015
3049
|
if (args.timings)
|
|
3016
3050
|
args.timings.chunkPool = "no-vector";
|
|
3051
|
+
if (args.diagnostics)
|
|
3052
|
+
args.diagnostics.pool = "no-vector";
|
|
3053
|
+
args.reportDiagnostics?.();
|
|
3017
3054
|
if (args.warmOnly)
|
|
3018
3055
|
warmCompartmentChunkSearchPool2(args.db, args.sessionId, args.projectPath, args.modelId);
|
|
3019
3056
|
return [];
|
|
@@ -3021,15 +3058,25 @@ async function searchCompartmentChunks(args) {
|
|
|
3021
3058
|
const cutoff = args.maxOrdinal != null && args.maxOrdinal >= 0 ? args.maxOrdinal : null;
|
|
3022
3059
|
let rows;
|
|
3023
3060
|
if (args.warmOnly) {
|
|
3024
|
-
const warm = peekCompartmentChunkSearchPool2(args.db, args.sessionId, args.projectPath, args.modelId, args.dateRange);
|
|
3061
|
+
const warm = peekCompartmentChunkSearchPool2(args.db, args.sessionId, args.projectPath, args.modelId, args.dateRange, args.diagnostics);
|
|
3025
3062
|
if (warm === null) {
|
|
3026
3063
|
if (args.timings)
|
|
3027
3064
|
args.timings.chunkPool = "cold";
|
|
3065
|
+
if (args.diagnostics) {
|
|
3066
|
+
args.diagnostics.pool = "cold";
|
|
3067
|
+
args.diagnostics.poolRows = 0;
|
|
3068
|
+
}
|
|
3069
|
+
args.reportDiagnostics?.();
|
|
3028
3070
|
warmCompartmentChunkSearchPool2(args.db, args.sessionId, args.projectPath, args.modelId);
|
|
3029
3071
|
return [];
|
|
3030
3072
|
}
|
|
3031
3073
|
if (args.timings)
|
|
3032
3074
|
args.timings.chunkPool = "warm";
|
|
3075
|
+
if (args.diagnostics) {
|
|
3076
|
+
args.diagnostics.pool = "warm";
|
|
3077
|
+
args.diagnostics.poolRows = warm.length;
|
|
3078
|
+
}
|
|
3079
|
+
args.reportDiagnostics?.();
|
|
3033
3080
|
rows = warm;
|
|
3034
3081
|
} else {
|
|
3035
3082
|
try {
|
|
@@ -3399,6 +3446,8 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3399
3446
|
lanes.message_fts = (outcome.laneResults ?? outcome.results).slice(0, 25);
|
|
3400
3447
|
if (timings)
|
|
3401
3448
|
timings.messageMs = performance.now() - stepStartedAt;
|
|
3449
|
+
recordAutoSearchLane(options.autoSearchDiagnostics, "messages", trimmedQuery, messageResults);
|
|
3450
|
+
options.onAutoSearchDiagnostics?.();
|
|
3402
3451
|
}
|
|
3403
3452
|
stepStartedAt = performance.now();
|
|
3404
3453
|
const capturedQuery = await queryEmbeddingPromise;
|
|
@@ -3416,6 +3465,8 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3416
3465
|
stepStartedAt = performance.now();
|
|
3417
3466
|
if (timings)
|
|
3418
3467
|
timings.chunkPool = "off";
|
|
3468
|
+
if (options.autoSearchDiagnostics && !runCompartmentChunks)
|
|
3469
|
+
options.autoSearchDiagnostics.pool = "off";
|
|
3419
3470
|
const compartmentResults = runCompartmentChunks ? await searchCompartmentChunks({
|
|
3420
3471
|
db,
|
|
3421
3472
|
sessionId,
|
|
@@ -3427,8 +3478,13 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3427
3478
|
dateRange,
|
|
3428
3479
|
warmOnly: options.chunkPoolWarmOnly,
|
|
3429
3480
|
signal: options.signal,
|
|
3430
|
-
timings
|
|
3481
|
+
timings,
|
|
3482
|
+
diagnostics: options.autoSearchDiagnostics,
|
|
3483
|
+
reportDiagnostics: options.onAutoSearchDiagnostics
|
|
3431
3484
|
}) : [];
|
|
3485
|
+
if (runCompartmentChunks)
|
|
3486
|
+
recordAutoSearchLane(options.autoSearchDiagnostics, "summaries", trimmedQuery, compartmentResults);
|
|
3487
|
+
options.onAutoSearchDiagnostics?.();
|
|
3432
3488
|
if (timings && runCompartmentChunks)
|
|
3433
3489
|
timings.chunkMs = performance.now() - stepStartedAt;
|
|
3434
3490
|
stepStartedAt = performance.now();
|
|
@@ -3489,6 +3545,11 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3489
3545
|
]);
|
|
3490
3546
|
if (timings)
|
|
3491
3547
|
timings.otherLanesMs = performance.now() - stepStartedAt;
|
|
3548
|
+
if (runMemory)
|
|
3549
|
+
recordAutoSearchLane(options.autoSearchDiagnostics, "memory", trimmedQuery, memoryOutcome.results);
|
|
3550
|
+
if (runGitCommits)
|
|
3551
|
+
recordAutoSearchLane(options.autoSearchDiagnostics, "git", trimmedQuery, gitCommitResults);
|
|
3552
|
+
options.onAutoSearchDiagnostics?.();
|
|
3492
3553
|
if (options.diagnostics) {
|
|
3493
3554
|
options.diagnostics.suppressedVisibleMemoryIds = memoryOutcome.suppressedVisibleIds;
|
|
3494
3555
|
}
|
|
@@ -3551,7 +3612,7 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3551
3612
|
if (options.autoHint) {
|
|
3552
3613
|
return results.map((result) => ({
|
|
3553
3614
|
...result,
|
|
3554
|
-
relevanceScore:
|
|
3615
|
+
relevanceScore: autoSearchRelevance(trimmedQuery, result)
|
|
3555
3616
|
}));
|
|
3556
3617
|
}
|
|
3557
3618
|
return results;
|
|
@@ -3674,4 +3735,4 @@ ${bodyParts.join(`
|
|
|
3674
3735
|
`)}`;
|
|
3675
3736
|
}
|
|
3676
3737
|
|
|
3677
|
-
export { getMessageIndexEpoch, isMessageIndexSearchable, scheduleReconciliation, scheduleClearAndReindex, getMessageIndexQueueHeapStats, renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, singleStoreMigrationRequiredFailure, projectNeedsSingleStoreMigration, STORE_AHEAD_OF_BINARY_CODE, storeAheadOfBinaryFailure, TRANSFORM_PAGE_UPLOAD_TIMEOUT_MS, transformColdStartExecuteTimeoutMs, getDefaultSubcConnectionFile, isModuleTransportGenerationChangedResult, SubcModuleTransport, indexCommitsForProject, embedUnembeddedCommits, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
|
|
3738
|
+
export { getMessageIndexEpoch, isMessageIndexSearchable, scheduleReconciliation, scheduleClearAndReindex, getMessageIndexQueueHeapStats, createAutoSearchDiagnostics, renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, singleStoreMigrationRequiredFailure, projectNeedsSingleStoreMigration, STORE_AHEAD_OF_BINARY_CODE, storeAheadOfBinaryFailure, TRANSFORM_PAGE_UPLOAD_TIMEOUT_MS, transformColdStartExecuteTimeoutMs, getDefaultSubcConnectionFile, isModuleTransportGenerationChangedResult, SubcModuleTransport, indexCommitsForProject, embedUnembeddedCommits, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
3
|
+
} from "./server-7zacmty5.js";
|
|
4
|
+
import {
|
|
5
|
+
embedPauseBySession,
|
|
6
|
+
activeEmbeddingSessions,
|
|
7
|
+
drainBackgroundBatches,
|
|
8
|
+
beginSynapseBatchLedger,
|
|
9
|
+
finishSynapseBatchLedger,
|
|
10
|
+
pruneSynapseBatchLedgerForProject
|
|
11
|
+
} from "./server-2amn2s73.js";
|
|
1
12
|
import {
|
|
2
13
|
inRootAsyncContext2,
|
|
3
|
-
getSqliteDatabasePath2
|
|
4
|
-
withSqliteBackgroundWriter2,
|
|
5
|
-
withoutSqliteTransformPass2,
|
|
6
|
-
isTransientSqliteError2
|
|
14
|
+
getSqliteDatabasePath2
|
|
7
15
|
} from "./server-gzy5w8ya.js";
|
|
8
|
-
import {
|
|
9
|
-
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
10
|
-
} from "./server-24g8r2d0.js";
|
|
11
16
|
import {
|
|
12
17
|
setBootQuietPeriodForTests
|
|
13
|
-
} from "./server-
|
|
18
|
+
} from "./server-69m30b21.js";
|
|
14
19
|
import {
|
|
15
20
|
isEmbeddingHostBusy2
|
|
16
21
|
} from "./server-qt1qqasc.js";
|
|
@@ -18,21 +23,26 @@ import {
|
|
|
18
23
|
getHarness2
|
|
19
24
|
} from "./server-pavzsdc6.js";
|
|
20
25
|
import {
|
|
21
|
-
sanitizeDiagnosticText,
|
|
22
26
|
log2
|
|
23
|
-
} from "./server-
|
|
27
|
+
} from "./server-jb6tjyeb.js";
|
|
28
|
+
import {
|
|
29
|
+
sanitizeDiagnosticText
|
|
30
|
+
} from "./server-z4p0ry94.js";
|
|
31
|
+
import {
|
|
32
|
+
reuseWorker
|
|
33
|
+
} from "./server-96ztjvkn.js";
|
|
24
34
|
import {
|
|
25
35
|
createWorkerShutdown
|
|
26
|
-
} from "./server-
|
|
36
|
+
} from "./server-1d042x6w.js";
|
|
27
37
|
import {
|
|
28
38
|
SYNAPSE_DEFAULT_MODEL,
|
|
29
39
|
isSynapseEmbeddingTruncated,
|
|
30
40
|
getSynapseBatchRequestKey,
|
|
31
41
|
SynapseEmbeddingProvider
|
|
32
|
-
} from "./server-
|
|
42
|
+
} from "./server-zzgtgqmd.js";
|
|
33
43
|
import {
|
|
34
44
|
estimateTokens
|
|
35
|
-
} from "./server-
|
|
45
|
+
} from "./server-969cdpmg.js";
|
|
36
46
|
import {
|
|
37
47
|
DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS2,
|
|
38
48
|
CHUNK_WINDOW_SAFETY_RATIO2,
|
|
@@ -50,7 +60,7 @@ import {
|
|
|
50
60
|
countSessionCompartmentEmbedCoverage2,
|
|
51
61
|
countSessionCompartmentEmbedCoveragePolite2,
|
|
52
62
|
countUnembeddedSessionCompartmentsPolite2
|
|
53
|
-
} from "./server-
|
|
63
|
+
} from "./server-cp1a03vc.js";
|
|
54
64
|
import {
|
|
55
65
|
acquireGitSweepLease,
|
|
56
66
|
renewGitSweepLease,
|
|
@@ -58,7 +68,7 @@ import {
|
|
|
58
68
|
findMisScopedCompartmentChunkEmbeddingIdsForProject,
|
|
59
69
|
recordSessionProjectIdentity,
|
|
60
70
|
repairMisScopedCompartmentChunkEmbeddingsForProject
|
|
61
|
-
} from "./server-
|
|
71
|
+
} from "./server-dcws5831.js";
|
|
62
72
|
import {
|
|
63
73
|
saveEmbeddingIfHashMatches,
|
|
64
74
|
getMemoryEmbedCoverage,
|
|
@@ -73,135 +83,18 @@ import {
|
|
|
73
83
|
logLocalEmbeddingPoolingUnavailableOnce,
|
|
74
84
|
getEmbeddingProviderIdentity,
|
|
75
85
|
LocalEmbeddingProvider
|
|
76
|
-
} from "./server-
|
|
86
|
+
} from "./server-6vzh6wej.js";
|
|
77
87
|
import {
|
|
78
88
|
isKnownAutocommit
|
|
79
89
|
} from "./server-8ajstryz.js";
|
|
80
90
|
import {
|
|
81
91
|
logSlowWriteTransaction
|
|
82
|
-
} from "./server-
|
|
83
|
-
|
|
84
|
-
// src/hooks/magic-context/embed-session-state.ts
|
|
85
|
-
var embedPauseBySession = new Set;
|
|
86
|
-
var embedRunStateBySession = new Map;
|
|
87
|
-
var activeEmbeddingSessions = new Map;
|
|
88
|
-
var autoEmbedAttemptedBySession = new Set;
|
|
89
|
-
var autoEmbedIdentityBySession = new Map;
|
|
90
|
-
var autoEmbedRetryAfterBySession = new Map;
|
|
91
|
-
function invalidateAutoEmbedSession(sessionId) {
|
|
92
|
-
autoEmbedAttemptedBySession.delete(sessionId);
|
|
93
|
-
autoEmbedIdentityBySession.delete(sessionId);
|
|
94
|
-
autoEmbedRetryAfterBySession.delete(sessionId);
|
|
95
|
-
}
|
|
96
|
-
function getEmbedDrainUiStatus(sessionId, progress) {
|
|
97
|
-
if (embedPauseBySession.has(sessionId)) {
|
|
98
|
-
return { status: "paused" };
|
|
99
|
-
}
|
|
100
|
-
const activeRun = embedRunStateBySession.get(sessionId);
|
|
101
|
-
if (activeRun && !activeRun.signal.aborted || progress?.kind === "embed" && progress.phase === "recomp") {
|
|
102
|
-
return { status: "running" };
|
|
103
|
-
}
|
|
104
|
-
if (progress?.kind === "embed" && (progress.phase === "failed" || progress.phase === "skipped") && progress.message) {
|
|
105
|
-
if (/provider/i.test(progress.message)) {
|
|
106
|
-
return { status: "stopped", detail: progress.message };
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return { status: "idle" };
|
|
110
|
-
}
|
|
111
|
-
function clearEmbedSessionState(sessionId) {
|
|
112
|
-
activeEmbeddingSessions.delete(sessionId);
|
|
113
|
-
embedPauseBySession.delete(sessionId);
|
|
114
|
-
const ctrl = embedRunStateBySession.get(sessionId);
|
|
115
|
-
if (ctrl) {
|
|
116
|
-
ctrl.abort();
|
|
117
|
-
embedRunStateBySession.delete(sessionId);
|
|
118
|
-
}
|
|
119
|
-
invalidateAutoEmbedSession(sessionId);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// src/shared/background-batch-drain.ts
|
|
123
|
-
async function drainBackgroundBatches(step, options = {}) {
|
|
124
|
-
const now = options.now ?? (() => performance.now());
|
|
125
|
-
const deadline = now() + (options.budgetMs ?? 2000);
|
|
126
|
-
const yieldFn = options.yieldFn ?? (() => new Promise((resolve) => setTimeout(resolve, 0)));
|
|
127
|
-
let batches = 0;
|
|
128
|
-
while (now() < deadline) {
|
|
129
|
-
try {
|
|
130
|
-
if (!withoutSqliteTransformPass2(() => withSqliteBackgroundWriter2(step)))
|
|
131
|
-
break;
|
|
132
|
-
} catch (error) {
|
|
133
|
-
if (isTransientSqliteError2(error))
|
|
134
|
-
break;
|
|
135
|
-
throw error;
|
|
136
|
-
}
|
|
137
|
-
batches++;
|
|
138
|
-
await yieldFn();
|
|
139
|
-
}
|
|
140
|
-
return batches;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// src/features/magic-context/storage-embedding-measurements.ts
|
|
144
|
-
import { createHash } from "node:crypto";
|
|
145
|
-
function normalizedQueryHash(query) {
|
|
146
|
-
const normalized = query.trim().replace(/\s+/g, " ").toLowerCase();
|
|
147
|
-
return createHash("sha256").update(normalized).digest("hex");
|
|
148
|
-
}
|
|
149
|
-
var MEASUREMENT_CORPUS_SESSION_ROW_CAP = 2000;
|
|
150
|
-
function recordEmbeddingMeasurement(db, input, cap = MEASUREMENT_CORPUS_SESSION_ROW_CAP) {
|
|
151
|
-
const queryTextHash = normalizedQueryHash(input.queryText);
|
|
152
|
-
const dedupKey = queryTextHash;
|
|
153
|
-
const result = db.prepare(`INSERT OR IGNORE INTO embedding_measurement_corpus
|
|
154
|
-
(session_id, project_path, dedup_key, cohort_key, query_text_hash,
|
|
155
|
-
primary_result_ids_json, shadow_result_ids_json, primary_latency_ms, shadow_latency_ms,
|
|
156
|
-
primary_failed, shadow_failed, primary_model_id, shadow_model_id,
|
|
157
|
-
primary_fingerprint, shadow_fingerprint, primary_epoch, shadow_epoch,
|
|
158
|
-
corpus_hash, coverage_json, created_at)
|
|
159
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(input.sessionId, input.projectPath, dedupKey, input.cohortKey, queryTextHash, JSON.stringify(input.primaryResultIds.slice(0, 10)), JSON.stringify(input.shadowResultIds.slice(0, 10)), input.primaryLatencyMs, input.shadowLatencyMs, input.primaryFailed ? 1 : 0, input.shadowFailed ? 1 : 0, input.primaryModelId, input.shadowModelId, input.primaryFingerprint, input.shadowFingerprint, input.primaryEpoch, input.shadowEpoch, input.corpusHash, JSON.stringify(input.coverage), Date.now());
|
|
160
|
-
if (result.changes > 0) {
|
|
161
|
-
const rowCount = db.prepare("SELECT COUNT(*) AS count FROM embedding_measurement_corpus WHERE session_id = ?").get(input.sessionId).count;
|
|
162
|
-
const overflow = rowCount - cap;
|
|
163
|
-
if (overflow > 0) {
|
|
164
|
-
db.prepare(`DELETE FROM embedding_measurement_corpus
|
|
165
|
-
WHERE session_id = ?
|
|
166
|
-
AND id IN (
|
|
167
|
-
SELECT id FROM embedding_measurement_corpus
|
|
168
|
-
WHERE session_id = ?
|
|
169
|
-
ORDER BY id ASC
|
|
170
|
-
LIMIT ?
|
|
171
|
-
)`).run(input.sessionId, input.sessionId, overflow);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return result.changes > 0;
|
|
175
|
-
}
|
|
176
|
-
function beginSynapseBatchLedger(db, input, now = Date.now()) {
|
|
177
|
-
db.prepare(`INSERT INTO synapse_batch_ledger
|
|
178
|
-
(session_id, project_path, scope, manifest_json, request_key, status, created_at, updated_at)
|
|
179
|
-
VALUES (?, ?, ?, ?, ?, 'pending', ?, ?)
|
|
180
|
-
ON CONFLICT(session_id, request_key) DO UPDATE SET
|
|
181
|
-
manifest_json = excluded.manifest_json,
|
|
182
|
-
updated_at = excluded.updated_at`).run(input.sessionId, input.projectPath, input.scope, JSON.stringify(input.manifest), input.requestKey, now, now);
|
|
183
|
-
}
|
|
184
|
-
function finishSynapseBatchLedger(db, sessionId, requestKey, status, now = Date.now()) {
|
|
185
|
-
db.prepare("UPDATE synapse_batch_ledger SET status = ?, updated_at = ? WHERE session_id = ? AND request_key = ?").run(status, now, sessionId, requestKey);
|
|
186
|
-
}
|
|
187
|
-
var SYNAPSE_BATCH_LEDGER_TTL_MS = 14 * 24 * 60 * 60 * 1000;
|
|
188
|
-
function pruneSynapseBatchLedgerForProject(db, projectIdentity, ttlMs = SYNAPSE_BATCH_LEDGER_TTL_MS) {
|
|
189
|
-
const ledgerTable = db.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'synapse_batch_ledger'").get();
|
|
190
|
-
if (!ledgerTable)
|
|
191
|
-
return 0;
|
|
192
|
-
const shadow = `shadow:${projectIdentity}`;
|
|
193
|
-
const cutoff = Date.now() - ttlMs;
|
|
194
|
-
const predicate = "session_id IN (?, ?) AND updated_at < ?";
|
|
195
|
-
if (!db.prepare(`SELECT 1 FROM synapse_batch_ledger WHERE ${predicate} LIMIT 1`).get(projectIdentity, shadow, cutoff))
|
|
196
|
-
return 0;
|
|
197
|
-
return db.prepare(`DELETE FROM synapse_batch_ledger WHERE ${predicate}`).run(projectIdentity, shadow, cutoff).changes;
|
|
198
|
-
}
|
|
92
|
+
} from "./server-qmmkhz2z.js";
|
|
199
93
|
|
|
200
94
|
// src/features/magic-context/project-embedding-registry.ts
|
|
201
|
-
import { createHash as
|
|
95
|
+
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
202
96
|
|
|
203
97
|
// src/features/magic-context/chunk-embedding-writer.ts
|
|
204
|
-
import { Worker } from "node:worker_threads";
|
|
205
98
|
function createChunkEmbeddingWriter(db) {
|
|
206
99
|
const path = getSqliteDatabasePath2(db);
|
|
207
100
|
if (!path)
|
|
@@ -210,7 +103,7 @@ function createChunkEmbeddingWriter(db) {
|
|
|
210
103
|
throw new Error("chunk embedding writer requires a filesystem path");
|
|
211
104
|
const entry = new URL(import.meta.url.endsWith(".ts") ? "./chunk-embedding-write-worker.ts" : "./chunk-embedding-write-worker.js", import.meta.url);
|
|
212
105
|
const timeout = db.prepare("PRAGMA busy_timeout").get().timeout;
|
|
213
|
-
const worker = inRootAsyncContext2(() =>
|
|
106
|
+
const worker = inRootAsyncContext2(() => reuseWorker(entry, { workerData: { path, harness: getHarness2(), timeout } }));
|
|
214
107
|
const shutdown = createWorkerShutdown(worker, "chunk-embedding-writer", timeout + 2000);
|
|
215
108
|
let pending;
|
|
216
109
|
let failure;
|
|
@@ -507,7 +400,7 @@ function enforceProjectCap(db, projectPath, maxCommits) {
|
|
|
507
400
|
}
|
|
508
401
|
|
|
509
402
|
// src/features/magic-context/memory/embedding-openai.ts
|
|
510
|
-
import { createHash
|
|
403
|
+
import { createHash } from "node:crypto";
|
|
511
404
|
|
|
512
405
|
// src/features/magic-context/memory/embedding-ssrf.ts
|
|
513
406
|
var METADATA_HOSTNAMES = new Set(["metadata.google.internal", "metadata.goog"]);
|
|
@@ -614,7 +507,7 @@ var RATE_LIMIT_BACKOFF_CAP_MS = 30000;
|
|
|
614
507
|
var RATE_LIMIT_BACKOFF_JITTER = 0.25;
|
|
615
508
|
var rateLimitStates = new Map;
|
|
616
509
|
function rateLimitStateKey(endpoint, apiKey) {
|
|
617
|
-
const keyHash = apiKey ?
|
|
510
|
+
const keyHash = apiKey ? createHash("sha256").update(apiKey).digest("hex").slice(0, 16) : "";
|
|
618
511
|
return `${endpoint}\x00${keyHash}`;
|
|
619
512
|
}
|
|
620
513
|
function parseRetryAfterMs(value, nowMs) {
|
|
@@ -1405,10 +1298,10 @@ function stableStringify(value) {
|
|
|
1405
1298
|
return JSON.stringify(value);
|
|
1406
1299
|
}
|
|
1407
1300
|
function sha256Prefix(value, length = 16) {
|
|
1408
|
-
return
|
|
1301
|
+
return createHash2("sha256").update(value).digest("hex").slice(0, length);
|
|
1409
1302
|
}
|
|
1410
1303
|
function contentSha2562(value) {
|
|
1411
|
-
return
|
|
1304
|
+
return createHash2("sha256").update(value).digest("hex");
|
|
1412
1305
|
}
|
|
1413
1306
|
function getRuntimeFingerprint(config) {
|
|
1414
1307
|
if (config.provider === "off") {
|
|
@@ -3209,4 +3102,4 @@ function _resetProjectEmbeddingRegistryForTests2() {
|
|
|
3209
3102
|
setBootQuietPeriodForTests(null);
|
|
3210
3103
|
}
|
|
3211
3104
|
|
|
3212
|
-
export {
|
|
3105
|
+
export { saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitSha, enforceProjectCap, OpenAICompatibleEmbeddingProvider, describeShadowBackfillWriteRefusal2, listShadowBackfillStalls2, retainProjectEmbedding2, getShadowBackfillStopReason2, markProjectLoadUntrusted2, contentSha2562, drainProjectEmbeddingIdentityMaintenance2, drainStaleEmbeddingIdentitiesForProject2, registerProjectEmbedding2, registerProjectShadowEmbedding2, getShadowEmbeddingMeasurementCohort2, getPrimaryEmbeddingMeasurementCohort2, embedShadowTextForProject2, enqueueShadowEmbeddingItems2, getShadowBackfillRemaining2, flushShadowEmbeddingBacklog2, registerProjectInObservationMode2, unregisterProjectShadowEmbedding2, unregisterProjectEmbedding2, getProjectEmbeddingSnapshot2, installProjectEmbeddingSearchBridge2, getProjectChunkEmbeddingModelId2, getProjectEmbeddingMaxInputTokens2, embedTextForProject2, embedBatchForProject2, embedItemsForProject2, embedUnembeddedMemoriesForProject2, embedUnembeddedMemoriesForProjectOutcome2, drainCommitBacklogForProject2, embedUnembeddedCompartmentChunksForProject2, embedSessionCompartmentChunks2, getEmbeddingCoverageStatus2, getAutoEmbeddingSessionCoverage2, sweepAllRegisteredProjects2, _setTestProviderFactoryForProject2, _resetProjectEmbeddingRegistryForTests2 };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/shared/reusable-worker-entry.ts
|
|
2
|
+
import { EventEmitter } from "node:events";
|
|
3
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
4
|
+
function serveWorkerJobs(run, autoClose = true) {
|
|
5
|
+
if (!parentPort)
|
|
6
|
+
throw new Error("worker requires a parent port");
|
|
7
|
+
const parent = parentPort;
|
|
8
|
+
if (!workerData?.reusableWorker) {
|
|
9
|
+
Promise.resolve(run(workerData, parent)).catch(rethrow);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
let active;
|
|
13
|
+
parent.on("message", (message) => {
|
|
14
|
+
if (!("start" in message)) {
|
|
15
|
+
if (active?.id === message.jobId)
|
|
16
|
+
active.port.emit("message", message.value);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (active)
|
|
20
|
+
throw new Error("reusable worker received overlapping jobs");
|
|
21
|
+
const id = message.jobId;
|
|
22
|
+
let closed = false;
|
|
23
|
+
const port = Object.assign(new EventEmitter, {
|
|
24
|
+
postMessage(value, transferList) {
|
|
25
|
+
if (!closed)
|
|
26
|
+
parent.postMessage({ jobId: id, value }, transferList);
|
|
27
|
+
},
|
|
28
|
+
close() {
|
|
29
|
+
if (closed)
|
|
30
|
+
return;
|
|
31
|
+
closed = true;
|
|
32
|
+
port.removeAllListeners();
|
|
33
|
+
active = undefined;
|
|
34
|
+
parent.postMessage({
|
|
35
|
+
jobId: id,
|
|
36
|
+
finished: true,
|
|
37
|
+
code: Number(process.exitCode) || 0
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
active = { id, port };
|
|
42
|
+
try {
|
|
43
|
+
Promise.resolve(run(message.start, port)).then(() => {
|
|
44
|
+
if (autoClose)
|
|
45
|
+
port.close();
|
|
46
|
+
}).catch(rethrow);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
rethrow(error);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function rethrow(error) {
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
throw error;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { serveWorkerJobs };
|