@cortexkit/opencode-magic-context 0.49.93 → 0.49.96
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/{announcement-4ynkaf0d.js → announcement-8nj2jd87.js} +5 -5
- package/dist/auto-search-worker.js +5 -5
- package/dist/chunk-embedding-write-worker.js +16 -16
- package/dist/{compaction-marker-candidates-1ndjqh9k.js → compaction-marker-candidates-a4b0anvv.js} +3 -3
- package/dist/compaction-marker-candidates-worker.js +1 -1
- package/dist/{compartment-chunk-embedding-rp4asvk0.js → compartment-chunk-embedding-re2cw7y3.js} +8 -8
- package/dist/config/removed-agent-config.d.ts +1 -1
- package/dist/config/removed-agent-config.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +0 -75
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-exf96bpt.js → conflict-warning-hook-wcq55y61.js} +8 -8
- package/dist/{context-jpxthqxg.js → context-gtjdrp8f.js} +237 -140
- package/dist/{derive-budgets-hzzq71rm.js → derive-budgets-g1sy72e8.js} +5 -5
- package/dist/embedding-backfill-pdymqbnh.js +29 -0
- package/dist/embedding-worker-process.js +2 -2
- package/dist/embedding-worker.js +8 -8
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts +5 -2
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/token-budget.d.ts +2 -2
- package/dist/features/magic-context/dreamer/token-budget.d.ts.map +1 -1
- package/dist/features/magic-context/history-gap-recovery.d.ts +42 -0
- package/dist/features/magic-context/history-gap-recovery.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-synapse.d.ts +18 -5
- package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
- package/dist/features/magic-context/message-visibility.d.ts +10 -0
- package/dist/features/magic-context/message-visibility.d.ts.map +1 -0
- package/dist/features/magic-context/search-rerank.d.ts +2 -2
- 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/session-decision-calibration.d.ts.map +1 -1
- package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
- package/dist/{history-owner-xqfsvf9k.js → history-owner-74826t4n.js} +3 -3
- package/dist/hooks/magic-context/compartment-runner-recomp.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/history-boundary-repair.d.ts +2 -2
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +6 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts +3 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +1 -0
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts +3 -0
- package/dist/hooks/magic-context/lkg-replay.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/tail-hygiene-output-count.d.ts +4 -0
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +2 -0
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +2 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-stage-logger.d.ts +6 -0
- package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +2 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-5zrzg8r1.js → index-0bjj9yf3.js} +2 -2
- package/dist/{index-g9qtxv87.js → index-0sqhg9nf.js} +132 -64
- package/dist/{index-nxxzeq4y.js → index-0ve29s6f.js} +1 -1
- package/dist/{index-g6y2wk32.js → index-2afrmgy3.js} +6 -6
- package/dist/{index-ywrz4wy2.js → index-3fhb0j32.js} +1 -1
- package/dist/{index-gqf8r04r.js → index-3n4j5rqc.js} +1 -1
- package/dist/{index-xsqw8kbd.js → index-45qgkg8j.js} +2 -2
- package/dist/{index-5df2fw5b.js → index-6mryx739.js} +1 -1
- package/dist/{index-n9kd68vc.js → index-7m2tnk8q.js} +10 -10
- package/dist/{index-r4y0dczp.js → index-7sdns2ww.js} +2 -2
- package/dist/{index-mjy2k9jr.js → index-880a24vd.js} +1 -1
- package/dist/{index-pnawfv4e.js → index-89bkkgcn.js} +4 -4
- package/dist/{index-s32f8y67.js → index-89xg64wb.js} +2 -2
- package/dist/{index-hee64h6k.js → index-8sgv96kq.js} +7 -7
- package/dist/{index-ttdk2w0z.js → index-910gahfb.js} +6 -6
- package/dist/{index-kty5k23y.js → index-9jvxq5rt.js} +4 -4
- package/dist/{index-832w615x.js → index-azkfw78y.js} +1 -1
- package/dist/{index-wh9fxds5.js → index-c205x7xd.js} +1 -1
- package/dist/{index-mg9s2rc3.js → index-cpbr0xvk.js} +2 -2
- package/dist/{index-g5c67kay.js → index-cq8znmyw.js} +17 -17
- package/dist/{index-cr483vx6.js → index-dj64gzg5.js} +2 -2
- package/dist/{index-jba6ny4m.js → index-dnpcv1rg.js} +4 -4
- package/dist/{index-z4p0ry94.js → index-dt7cyqfe.js} +2 -1
- package/dist/{index-j2w79s9r.js → index-e6ay1gez.js} +2 -2
- package/dist/{index-y2vshk67.js → index-f154w8m4.js} +229 -84
- package/dist/{index-6r99v53h.js → index-fgw241hh.js} +164 -62
- package/dist/{index-rz47hf2m.js → index-fvfnq8n6.js} +30 -14
- package/dist/{index-yqha238s.js → index-gnrwgvn7.js} +127 -17
- package/dist/{index-fpjnjxyx.js → index-h7kta6cn.js} +3 -3
- package/dist/{index-q7q6qp1f.js → index-hedgz8an.js} +1 -1
- package/dist/{index-5pgyqgmx.js → index-hj78hvhm.js} +2 -2
- package/dist/{index-dr6bd4c8.js → index-hp46xe93.js} +7 -7
- package/dist/{index-0twg41mh.js → index-j4dcjb8t.js} +4 -4
- package/dist/{index-e6ncz7a6.js → index-jzrvdqb8.js} +1 -1
- package/dist/{index-sp5pvs95.js → index-k34hc455.js} +2 -2
- package/dist/{index-9ffntwyr.js → index-kj4bprep.js} +4 -4
- package/dist/index-mgy7g740.js +119 -0
- package/dist/{index-za1yx1m4.js → index-nqdwpdje.js} +154 -32
- package/dist/{index-hes3k87g.js → index-r1d45dsr.js} +4 -4
- package/dist/{index-y915t3ey.js → index-r3f85n7y.js} +5 -1
- package/dist/{index-1kem0xxx.js → index-t2e10rag.js} +5 -5
- package/dist/{index-m0pwswv9.js → index-tqtpgnhr.js} +1 -1
- package/dist/{index-01h7tqe3.js → index-tr4ep2ej.js} +21 -6
- package/dist/{index-xr1t0fxb.js → index-w7n7qkpf.js} +49 -13
- package/dist/{index-s7460efs.js → index-zfx7mtqa.js} +1 -1
- package/dist/{index-gqfy38m9.js → index-zkjx8gq3.js} +11 -11
- package/dist/{index-et39x9k3.js → index-zmgp0tr6.js} +3 -3
- package/dist/index.js +59 -56
- package/dist/{logger-d7c8akh9.js → logger-nmb2508f.js} +2 -2
- package/dist/{message-fts-rowid-map-0xx8ge09.js → message-fts-rowid-map-vcatdan0.js} +5 -5
- package/dist/{message-index-bounded-vjrnptar.js → message-index-bounded-abhwe610.js} +12 -12
- package/dist/{message-time-backfill-pz5981mf.js → message-time-backfill-zc5rsvhv.js} +3 -3
- package/dist/migration-worker.js +13 -13
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{project-embedding-registry-m8zcmrsg.js → project-embedding-registry-e566q4bg.js} +15 -15
- package/dist/raw-ordinal-warmup-worker.js +9 -9
- package/dist/{read-session-chunk-zkzdc0e5.js → read-session-chunk-sde0wym3.js} +10 -10
- package/dist/{read-session-raw-3sc9231y.js → read-session-raw-trhdgc9z.js} +3 -3
- package/dist/recomp-orchestrator-d3rbpa59.js +69 -0
- package/dist/render-6cf1dgc4.js +43 -0
- package/dist/{safe-notification-target-d21swr3n.js → safe-notification-target-54ns7dv9.js} +3 -3
- package/dist/{search-e9bb9hpx.js → search-11aw8wpq.js} +27 -27
- package/dist/search-archive-s9m5szf0.js +29 -0
- package/dist/{send-session-notification-0779tyd9.js → send-session-notification-gxrj4w1r.js} +6 -6
- package/dist/shared/host-sqlite-runtime.d.ts +3 -0
- package/dist/shared/host-sqlite-runtime.d.ts.map +1 -0
- package/dist/shared/redaction.d.ts.map +1 -1
- package/dist/shared/storage-file-mutex.d.ts.map +1 -1
- package/dist/{storage-tags-gk7gjkqt.js → storage-tags-jq0c0zsn.js} +7 -7
- package/dist/{store-yr443ye8.js → store-29ksp6vy.js} +4 -4
- package/dist/{store-reader-qbq6q4v0.js → store-reader-dgh3ssxx.js} +1 -1
- package/dist/tools/ctx-expand/search-archive.d.ts +3 -2
- package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/tools/ctx-expand/v2-archive-reader.d.ts +2 -0
- package/dist/tools/ctx-expand/v2-archive-reader.d.ts.map +1 -1
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-neds90e3.js → transform-postprocess-phase-376xn40x.js} +35 -35
- package/dist/v2/auto-search-worker.js +5 -5
- package/dist/v2/chunk-embedding-write-worker.js +16 -16
- package/dist/v2/{compaction-marker-candidates-bp1bn579.js → compaction-marker-candidates-6nypmsr3.js} +3 -3
- package/dist/v2/compaction-marker-candidates-worker.js +1 -1
- package/dist/v2/{compartment-chunk-embedding-w7ht0t9v.js → compartment-chunk-embedding-jthtfhcd.js} +8 -8
- package/dist/v2/{context-ctsd80vc.js → context-vm09agrs.js} +426 -185
- package/dist/v2/{derive-budgets-hr4qqrnv.js → derive-budgets-wj0q7s7d.js} +6 -6
- package/dist/v2/embedding-backfill-16b16m38.js +29 -0
- package/dist/v2/embedding-worker-process.js +2 -2
- package/dist/v2/embedding-worker.js +8 -8
- package/dist/v2/fold/memory-cache.d.ts +2 -0
- package/dist/v2/fold/memory-cache.d.ts.map +1 -1
- package/dist/v2/fold/native-replay.d.ts +23 -5
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/hidden-child-native.d.ts.map +1 -1
- package/dist/v2/hidden-child-record.d.ts +8 -0
- package/dist/v2/hidden-child-record.d.ts.map +1 -1
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hidden-run-holder.d.ts +8 -2
- package/dist/v2/hidden-run-holder.d.ts.map +1 -1
- package/dist/v2/{history-owner-260djmv5.js → history-owner-8pd5ax3n.js} +3 -3
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +3 -0
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/revert-message-state.d.ts.map +1 -1
- package/dist/v2/hooks/session-project-backfill.d.ts +2 -1
- package/dist/v2/hooks/session-project-backfill.d.ts.map +1 -1
- package/dist/v2/{logger-zyf43np1.js → logger-58jfese9.js} +2 -2
- package/dist/v2/{message-fts-rowid-map-n8mcvcpz.js → message-fts-rowid-map-ax4vk78j.js} +5 -5
- package/dist/v2/{message-index-bounded-1vew9c37.js → message-index-bounded-qh794qxx.js} +12 -12
- package/dist/v2/{message-time-backfill-ynb3vg6r.js → message-time-backfill-yj773saf.js} +3 -3
- package/dist/v2/migration-worker.js +13 -13
- package/dist/v2/{project-embedding-registry-je5jam7y.js → project-embedding-registry-z05xvckg.js} +15 -15
- package/dist/v2/raw-ordinal-warmup-worker.js +9 -9
- package/dist/v2/{read-session-chunk-09sre4xv.js → read-session-chunk-8tn2dbn1.js} +10 -10
- package/dist/v2/{read-session-raw-wg5zc29f.js → read-session-raw-ywebck9q.js} +3 -3
- package/dist/v2/recomp-orchestrator-pfjpzdrb.js +69 -0
- package/dist/v2/render-7t5d7hkv.js +43 -0
- package/dist/v2/{safe-notification-target-y55z2zat.js → safe-notification-target-zrwbh6k7.js} +3 -3
- package/dist/v2/{search-gmye6n25.js → search-35cz80x0.js} +26 -26
- package/dist/v2/search-archive-5dpxv0ck.js +29 -0
- package/dist/v2/{send-session-notification-v69y04f5.js → send-session-notification-8x146x5y.js} +6 -6
- package/dist/v2/{server-z9czv2vb.js → server-11ra1pmx.js} +49 -13
- package/dist/v2/{server-gs2251jr.js → server-2cq3e1c1.js} +4 -4
- package/dist/v2/{server-39bcszk4.js → server-2qvnr3t7.js} +1 -1
- package/dist/v2/{server-jkj1dq6j.js → server-2sare4qg.js} +4 -4
- package/dist/v2/{server-jdfe07mp.js → server-2wz6y46g.js} +1 -1
- package/dist/v2/{server-at0v0z4t.js → server-379fd3n7.js} +1 -1
- package/dist/v2/{server-ds8vpfkr.js → server-40vdz8sf.js} +2 -2
- package/dist/v2/{server-qntmqaca.js → server-4yrvbnnm.js} +2 -2
- package/dist/v2/{server-x69fqsvz.js → server-5t4nzfpt.js} +1 -1
- package/dist/v2/{server-npdey91q.js → server-63ree5ns.js} +1 -1
- package/dist/v2/{server-gqkdfdvw.js → server-6qax5pds.js} +2 -2
- package/dist/v2/{server-qb3s0mnc.js → server-73bqw5c0.js} +1 -1
- package/dist/v2/{server-6chcnnhq.js → server-7h4gwphm.js} +4 -4
- package/dist/v2/{server-rkj44mez.js → server-7tj8yzrv.js} +2 -2
- package/dist/v2/{server-e6xneh68.js → server-arfzfxe8.js} +5 -1
- package/dist/v2/{server-6ash6z8z.js → server-av3p9c8k.js} +1 -1
- package/dist/v2/{server-5hwf5c7r.js → server-bx5k66qc.js} +1 -1
- package/dist/v2/{server-dgsjamm4.js → server-db91dxwc.js} +7 -7
- package/dist/v2/{server-z4p0ry94.js → server-dt7cyqfe.js} +2 -1
- package/dist/v2/{server-k1xc2bw1.js → server-ganavh75.js} +2 -2
- package/dist/v2/{server-6x40bnb7.js → server-gh2w75fn.js} +3 -3
- package/dist/v2/server-j1gxs1gj.js +119 -0
- package/dist/v2/{server-ps6zrzwj.js → server-k3ntgf6n.js} +164 -62
- package/dist/v2/{server-j8376q08.js → server-kzrrdjp5.js} +1 -1
- package/dist/v2/{server-1rrmxhd1.js → server-n33hyq9t.js} +2 -2
- package/dist/v2/{server-0tv6kytx.js → server-n34vzyfm.js} +1 -1
- package/dist/v2/{server-vc5fta6s.js → server-nnh81jqy.js} +6 -6
- package/dist/v2/{server-g53asaqt.js → server-pcq2d1wh.js} +30 -14
- package/dist/v2/{server-bnkc9kph.js → server-ppy2dj7g.js} +6 -6
- package/dist/v2/{server-96nm9vk4.js → server-rr5c0xcg.js} +2 -2
- package/dist/v2/{server-j4jjtdc5.js → server-rt8t6s2a.js} +2 -2
- package/dist/v2/{server-2xm0gxke.js → server-svccj9rd.js} +4 -4
- package/dist/v2/{server-5sbsnpkn.js → server-tq523gj6.js} +1 -1
- package/dist/v2/{server-00adcfjd.js → server-vj0xbbrc.js} +17 -3
- package/dist/v2/{server-4ecpanyn.js → server-vntc961c.js} +127 -17
- package/dist/v2/{server-btgnkr9z.js → server-vsx9tsks.js} +11 -11
- package/dist/v2/{server-vtgeyhq6.js → server-vtkbxzw1.js} +21 -6
- package/dist/v2/{server-cvp9w5gs.js → server-w35ep6wn.js} +192 -84
- package/dist/v2/{server-myp4pc6x.js → server-z2nv8jdv.js} +132 -64
- package/dist/v2/{server-pcarsvj2.js → server-z5cv5wm5.js} +10 -10
- package/dist/v2/{server-barj0mjz.js → server-zemnpv92.js} +4 -4
- package/dist/v2/server.js +9 -9
- package/dist/v2/{storage-tags-nccqr0kr.js → storage-tags-pcenytad.js} +7 -7
- package/dist/v2/{store-enef5jcn.js → store-gx19qc3a.js} +4 -4
- package/dist/v2/{store-reader-jbaqv1yp.js → store-reader-qt2msa8z.js} +1 -1
- package/dist/v2/store-reader.d.ts +1 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{v2-archive-reader-7vmng8q7.js → v2-archive-reader-jqrwz7b8.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-7r4y0bf6.js → wrapup-orchestrator-kcq3cv7y.js} +35 -35
- package/dist/{v2-archive-reader-7s90gfax.js → v2-archive-reader-64h2gtam.js} +1 -1
- package/dist/wrapup-orchestrator-knyac7jp.js +56 -0
- package/package.json +1 -1
- package/src/config/index.test.ts +23 -5
- package/src/config/live-run-config.test.ts +7 -7
- package/src/config/removed-agent-config.ts +14 -1
- package/src/config/schema/magic-context.ts +5 -1
- package/src/shared/host-sqlite-runtime.test.ts +21 -0
- package/src/shared/host-sqlite-runtime.ts +32 -0
- package/src/shared/redaction.test.ts +11 -8
- package/src/shared/redaction.ts +5 -1
- package/src/shared/storage-file-mutex-review.test.ts +110 -0
- package/src/shared/storage-file-mutex.ts +12 -0
- package/dist/embedding-backfill-6wzc4p2n.js +0 -29
- package/dist/index-52x68mj4.js +0 -58
- package/dist/recomp-orchestrator-qb2hymj5.js +0 -69
- package/dist/render-34p0kek8.js +0 -43
- package/dist/search-archive-08ppk0q5.js +0 -27
- package/dist/v2/embedding-backfill-40g0anxh.js +0 -29
- package/dist/v2/recomp-orchestrator-mgcty3we.js +0 -69
- package/dist/v2/render-ygcmyn9x.js +0 -43
- package/dist/v2/search-archive-nrsqqmk5.js +0 -27
- package/dist/v2/server-52x68mj4.js +0 -58
- package/dist/wrapup-orchestrator-m2p89973.js +0 -56
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
estimateTokens
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-zfx7mtqa.js";
|
|
4
4
|
import {
|
|
5
5
|
getHarness2
|
|
6
6
|
} from "./index-pavzsdc6.js";
|
|
7
7
|
import {
|
|
8
8
|
log2
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-3fhb0j32.js";
|
|
10
10
|
import {
|
|
11
11
|
inRootAsyncContext2
|
|
12
12
|
} from "./index-gzy5w8ya.js";
|
|
@@ -1600,9 +1600,13 @@ function pendingKey(handle, corr) {
|
|
|
1600
1600
|
}
|
|
1601
1601
|
// src/features/magic-context/memory/embedding-synapse.ts
|
|
1602
1602
|
import { createHash } from "node:crypto";
|
|
1603
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
1603
1604
|
var SYNAPSE_DEFAULT_MODEL = "gte-modernbert-base-f16";
|
|
1604
1605
|
var SYNAPSE_DEFAULT_QUERY_TIMEOUT_MS = 3000;
|
|
1605
1606
|
var SYNAPSE_DEFAULT_BATCH_TIMEOUT_MS = 120000;
|
|
1607
|
+
var SYNAPSE_DEFAULT_POLL_TIMEOUT_MS = 5 * 60000;
|
|
1608
|
+
var SYNAPSE_INITIAL_POLL_DELAY_MS = 250;
|
|
1609
|
+
var SYNAPSE_MAX_POLL_DELAY_MS = 2000;
|
|
1606
1610
|
var SYNAPSE_CERTIFICATION_REFUSAL_REASONS = new Set([
|
|
1607
1611
|
"not_certified",
|
|
1608
1612
|
"probe_required",
|
|
@@ -1637,6 +1641,9 @@ function formatSynapseLaneDescriptor(descriptor) {
|
|
|
1637
1641
|
const certified = descriptor.certified === undefined ? "unknown" : String(descriptor.certified);
|
|
1638
1642
|
return `lane=${descriptor.lane}; device_class=${descriptor.device_class ?? "unknown"}; ` + `max_tokens=${descriptor.max_tokens} (${descriptor.max_tokens_source}); ` + `certified=${certified}; warm=${descriptor.warm ? "yes" : "no"}; ` + `warm_load_cost_hint_ms=${descriptor.warm_load_cost_hint_ms ?? "unknown"}`;
|
|
1639
1643
|
}
|
|
1644
|
+
function isPollState(state) {
|
|
1645
|
+
return state === "queued" || state === "running" || state === "done" || state === "failed_transient" || state === "failed_permanent";
|
|
1646
|
+
}
|
|
1640
1647
|
|
|
1641
1648
|
class SynapseEmbeddingError extends Error {
|
|
1642
1649
|
code;
|
|
@@ -1765,6 +1772,21 @@ function embeddingFailureFor(error) {
|
|
|
1765
1772
|
function wait(ms) {
|
|
1766
1773
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1767
1774
|
}
|
|
1775
|
+
async function untilAborted(request, signal) {
|
|
1776
|
+
let onAbort = () => {};
|
|
1777
|
+
const aborted = new Promise((_, reject) => {
|
|
1778
|
+
onAbort = () => reject(signal.reason);
|
|
1779
|
+
if (signal.aborted)
|
|
1780
|
+
onAbort();
|
|
1781
|
+
else
|
|
1782
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1783
|
+
});
|
|
1784
|
+
try {
|
|
1785
|
+
return await Promise.race([request, aborted]);
|
|
1786
|
+
} finally {
|
|
1787
|
+
signal.removeEventListener("abort", onAbort);
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1768
1790
|
function sha256(value) {
|
|
1769
1791
|
return createHash("sha256").update(value).digest("hex");
|
|
1770
1792
|
}
|
|
@@ -2102,43 +2124,42 @@ class SynapseEmbeddingProvider {
|
|
|
2102
2124
|
break;
|
|
2103
2125
|
const page = this.nextPage(eligibleItems, start);
|
|
2104
2126
|
start += page.length;
|
|
2127
|
+
let job;
|
|
2105
2128
|
try {
|
|
2106
2129
|
const requestKey = this.requestKey(page, purpose);
|
|
2107
|
-
let body = {};
|
|
2108
2130
|
let restarted = false;
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
+
try {
|
|
2132
|
+
for (;; ) {
|
|
2133
|
+
try {
|
|
2134
|
+
const body = await this.callWithRetry("embed.batch", this.batchRequest(page, requestKey, purpose), this.options.batchTimeoutMs ?? SYNAPSE_DEFAULT_BATCH_TIMEOUT_MS, true, signal, job);
|
|
2135
|
+
const first = responseBody(body);
|
|
2136
|
+
if (typeof first.job_id === "string" && first.job_id) {
|
|
2137
|
+
job ??= this.startPoll(first.job_id, first.state, signal);
|
|
2138
|
+
job.id = first.job_id;
|
|
2139
|
+
await this.pollBatch(job, page);
|
|
2140
|
+
} else {
|
|
2141
|
+
this.acceptBatchRows(body, page, output);
|
|
2142
|
+
}
|
|
2143
|
+
break;
|
|
2144
|
+
} catch (error) {
|
|
2145
|
+
if (job && (signal?.aborted || this.pollRemainingMs(job) <= 0)) {
|
|
2146
|
+
if (!signal?.aborted) {
|
|
2147
|
+
log2(`[magic-context] Synapse embed.result polling limit reached: job_id=${job.id} state=${job.state} pages_read=${job.pagesRead.size}`);
|
|
2148
|
+
}
|
|
2149
|
+
break;
|
|
2150
|
+
}
|
|
2151
|
+
const classified = classifyError(error);
|
|
2152
|
+
if (classified.code !== "module_restarted" || restarted)
|
|
2153
|
+
throw classified;
|
|
2154
|
+
restarted = true;
|
|
2155
|
+
}
|
|
2131
2156
|
}
|
|
2132
|
-
|
|
2133
|
-
if (!
|
|
2134
|
-
|
|
2157
|
+
} finally {
|
|
2158
|
+
if (!signal?.aborted && job?.rows.size) {
|
|
2159
|
+
for (const [id, vector] of job.rows)
|
|
2160
|
+
output.set(id, vector);
|
|
2161
|
+
this.recordSuccess();
|
|
2135
2162
|
}
|
|
2136
|
-
const rowMetadata = validateWireRow(item, disclosures[index] ?? null, expected);
|
|
2137
|
-
const vectorArray = Float32Array.from(vector);
|
|
2138
|
-
this.validateResponse({ ...batchEnvelope, ...item }, vectorArray.length);
|
|
2139
|
-
embeddingRowMetadata.set(vectorArray, rowMetadata);
|
|
2140
|
-
output.set(id, vectorArray);
|
|
2141
|
-
this.recordSuccess();
|
|
2142
2163
|
}
|
|
2143
2164
|
} catch (error) {
|
|
2144
2165
|
const classified = classifyError(error);
|
|
@@ -2155,6 +2176,30 @@ class SynapseEmbeddingProvider {
|
|
|
2155
2176
|
}
|
|
2156
2177
|
return output;
|
|
2157
2178
|
}
|
|
2179
|
+
acceptBatchRows(body, requested, output, polling = false) {
|
|
2180
|
+
const batchEnvelope = responseBody(body);
|
|
2181
|
+
const disclosures = extractTruncationDisclosures(body);
|
|
2182
|
+
for (const [index, item] of extractBatchItems(body).entries()) {
|
|
2183
|
+
const id = typeof item.id === "string" ? item.id : "";
|
|
2184
|
+
const vector = item.vector ?? item.embedding;
|
|
2185
|
+
if (!id || !Array.isArray(vector) || vector.some((component) => typeof component !== "number" || !Number.isFinite(component))) {
|
|
2186
|
+
throw new SynapseEmbeddingError("schema_violation", "Synapse batch item is malformed");
|
|
2187
|
+
}
|
|
2188
|
+
const expected = requested.find((candidate) => candidate.id === id);
|
|
2189
|
+
if (!expected) {
|
|
2190
|
+
throw new SynapseEmbeddingError("schema_violation", `Synapse returned unknown item ${id}`);
|
|
2191
|
+
}
|
|
2192
|
+
const rowMetadata = validateWireRow(item, disclosures[index] ?? null, expected);
|
|
2193
|
+
this.validateResponse(polling ? batchEnvelope : { ...batchEnvelope, ...item }, vector.length);
|
|
2194
|
+
if (polling && output.has(id))
|
|
2195
|
+
continue;
|
|
2196
|
+
const vectorArray = Float32Array.from(vector);
|
|
2197
|
+
embeddingRowMetadata.set(vectorArray, rowMetadata);
|
|
2198
|
+
output.set(id, vectorArray);
|
|
2199
|
+
if (!polling)
|
|
2200
|
+
this.recordSuccess();
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2158
2203
|
async dispose() {
|
|
2159
2204
|
this.initialized = false;
|
|
2160
2205
|
this.client = null;
|
|
@@ -2199,45 +2244,91 @@ class SynapseEmbeddingProvider {
|
|
|
2199
2244
|
purpose
|
|
2200
2245
|
});
|
|
2201
2246
|
}
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
const
|
|
2205
|
-
|
|
2247
|
+
startPoll(id, state, signal) {
|
|
2248
|
+
const timeoutMs = this.options.pollTimeoutMs ?? SYNAPSE_DEFAULT_POLL_TIMEOUT_MS;
|
|
2249
|
+
const timeout = this.options.pollClock?.timeoutSignal(timeoutMs) ?? AbortSignal.timeout(timeoutMs);
|
|
2250
|
+
return {
|
|
2251
|
+
id,
|
|
2252
|
+
state: isPollState(state) ? state : "unknown",
|
|
2253
|
+
deadline: this.pollNow() + timeoutMs,
|
|
2254
|
+
signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
|
|
2255
|
+
delayMs: SYNAPSE_INITIAL_POLL_DELAY_MS,
|
|
2256
|
+
pagesRead: new Set,
|
|
2257
|
+
rows: new Map
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
pollNow() {
|
|
2261
|
+
return this.options.pollClock?.now() ?? performance.now();
|
|
2262
|
+
}
|
|
2263
|
+
pollRemainingMs(job) {
|
|
2264
|
+
return job.signal.aborted ? 0 : Math.ceil(job.deadline - this.pollNow());
|
|
2265
|
+
}
|
|
2266
|
+
async pollWait(ms, signal) {
|
|
2267
|
+
const clock = this.options.pollClock;
|
|
2268
|
+
if (clock)
|
|
2269
|
+
await clock.sleep(ms, signal);
|
|
2270
|
+
else
|
|
2271
|
+
await sleep(ms, undefined, { signal });
|
|
2272
|
+
}
|
|
2273
|
+
async pollBatch(job, requested) {
|
|
2274
|
+
let page = 0;
|
|
2206
2275
|
for (;; ) {
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2276
|
+
let body;
|
|
2277
|
+
try {
|
|
2278
|
+
body = await this.callWithRetry("embed.result", { job_id: job.id, page }, this.options.batchTimeoutMs ?? SYNAPSE_DEFAULT_BATCH_TIMEOUT_MS, true, job.signal, job);
|
|
2279
|
+
} catch (error) {
|
|
2280
|
+
if (readErrorCode(error) !== "invalid_request")
|
|
2281
|
+
throw error;
|
|
2282
|
+
log2(`[magic-context] Synapse embed.result stopped: job_id=${job.id} page=${page} code=invalid_request`);
|
|
2283
|
+
return;
|
|
2284
|
+
}
|
|
2214
2285
|
const parsed = responseBody(body);
|
|
2215
|
-
const
|
|
2216
|
-
const
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2286
|
+
const state = parsed.state;
|
|
2287
|
+
const malformed = () => new SynapseEmbeddingError("schema_violation", "Synapse embed.result returned a malformed page or status");
|
|
2288
|
+
if (!isPollState(state) || parsed.job_id !== job.id || typeof parsed.pages_available !== "number" || !Number.isInteger(parsed.pages_available) || parsed.pages_available < 0)
|
|
2289
|
+
throw malformed();
|
|
2290
|
+
job.state = state;
|
|
2291
|
+
if (Array.isArray(parsed.vectors)) {
|
|
2292
|
+
const pageCount = parsed.page_count;
|
|
2293
|
+
if (parsed.page !== page || typeof pageCount !== "number" || !Number.isInteger(pageCount) || pageCount <= page || parsed.pages_available <= page || parsed.vectors.length === 0 || parsed.vectors.some((row) => !asRecord(row)))
|
|
2294
|
+
throw malformed();
|
|
2295
|
+
this.acceptBatchRows(body, requested, job.rows, true);
|
|
2296
|
+
job.pagesRead.add(page);
|
|
2297
|
+
page += 1;
|
|
2298
|
+
if (state === "done" && page === pageCount)
|
|
2299
|
+
return;
|
|
2300
|
+
continue;
|
|
2301
|
+
}
|
|
2302
|
+
if (parsed.vectors !== undefined || parsed.page !== undefined || parsed.page_count !== undefined || typeof parsed.request_key !== "string")
|
|
2303
|
+
throw malformed();
|
|
2304
|
+
if (state === "failed_transient" || state === "failed_permanent") {
|
|
2305
|
+
const error = asRecord(parsed.error);
|
|
2306
|
+
if (typeof error?.code !== "string" || typeof error.message !== "string") {
|
|
2307
|
+
throw malformed();
|
|
2308
|
+
}
|
|
2309
|
+
throw Object.assign(new Error(error.message), { code: error.code });
|
|
2227
2310
|
}
|
|
2228
|
-
|
|
2311
|
+
if (state !== "queued" && state !== "running")
|
|
2312
|
+
throw malformed();
|
|
2313
|
+
const delay = Math.min(job.delayMs, this.pollRemainingMs(job));
|
|
2314
|
+
if (delay > 0)
|
|
2315
|
+
await this.pollWait(delay, job.signal);
|
|
2316
|
+
job.delayMs = Math.min(job.delayMs * 2, SYNAPSE_MAX_POLL_DELAY_MS);
|
|
2229
2317
|
}
|
|
2230
2318
|
}
|
|
2231
|
-
async callWithRetry(method, params, timeoutMs, retryEmbeddings, signal) {
|
|
2319
|
+
async callWithRetry(method, params, timeoutMs, retryEmbeddings, signal, job) {
|
|
2232
2320
|
let attempt = 0;
|
|
2233
2321
|
for (;; ) {
|
|
2234
2322
|
if (signal?.aborted)
|
|
2235
2323
|
throw new SynapseEmbeddingError("transport", "Synapse request aborted");
|
|
2324
|
+
const remainingMs = job ? this.pollRemainingMs(job) : timeoutMs;
|
|
2325
|
+
if (job && remainingMs <= 0)
|
|
2326
|
+
throw new SynapseEmbeddingError("timeout", "Synapse polling limit reached");
|
|
2236
2327
|
try {
|
|
2237
2328
|
if (!this.client)
|
|
2238
2329
|
throw new SynapseEmbeddingError("transport", "Synapse client is unavailable");
|
|
2239
|
-
|
|
2240
|
-
timeoutMs,
|
|
2330
|
+
const request = this.client.call(this.options.moduleId ?? "synapse", method, params, {
|
|
2331
|
+
timeoutMs: Math.min(timeoutMs, remainingMs),
|
|
2241
2332
|
targetKind: "management_surface",
|
|
2242
2333
|
identity: {
|
|
2243
2334
|
project_root: this.options.projectRoot,
|
|
@@ -2245,8 +2336,16 @@ class SynapseEmbeddingProvider {
|
|
|
2245
2336
|
session: this.options.session
|
|
2246
2337
|
}
|
|
2247
2338
|
});
|
|
2339
|
+
if (!job)
|
|
2340
|
+
return await request;
|
|
2341
|
+
const reply = await untilAborted(request, job.signal);
|
|
2342
|
+
if (this.pollRemainingMs(job) <= 0)
|
|
2343
|
+
throw new SynapseEmbeddingError("timeout", "Synapse polling limit reached");
|
|
2344
|
+
return reply;
|
|
2248
2345
|
} catch (error) {
|
|
2249
2346
|
const classified = classifyError(error);
|
|
2347
|
+
if (job && (this.pollRemainingMs(job) <= 0 || classified.code === "module_restarted" || method === "embed.result" && readErrorCode(error) === "invalid_request"))
|
|
2348
|
+
throw error;
|
|
2250
2349
|
if (classified.code === "idempotency_conflict")
|
|
2251
2350
|
throw classified;
|
|
2252
2351
|
const outcomeUnknown = error instanceof SubcCallError && error.kind === "outcome_unknown";
|
|
@@ -2255,7 +2354,10 @@ class SynapseEmbeddingProvider {
|
|
|
2255
2354
|
throw classified;
|
|
2256
2355
|
const delay = classified.retryAfterMs ?? Math.min(2000, 100 * 2 ** attempt);
|
|
2257
2356
|
attempt += 1;
|
|
2258
|
-
|
|
2357
|
+
if (job)
|
|
2358
|
+
await this.pollWait(Math.min(delay, this.pollRemainingMs(job)), job.signal);
|
|
2359
|
+
else
|
|
2360
|
+
await wait(delay);
|
|
2259
2361
|
}
|
|
2260
2362
|
}
|
|
2261
2363
|
}
|
|
@@ -1,35 +1,49 @@
|
|
|
1
1
|
import {
|
|
2
|
-
withMessageFtsSessionFilter
|
|
3
|
-
|
|
2
|
+
withMessageFtsSessionFilter,
|
|
3
|
+
liveTailRangeTouchesUnresolvedCoverage,
|
|
4
|
+
rangeHasHiddenMessages
|
|
5
|
+
} from "./index-mgy7g740.js";
|
|
4
6
|
import {
|
|
5
7
|
getSqliteDatabasePath2
|
|
6
8
|
} from "./index-gzy5w8ya.js";
|
|
7
9
|
import {
|
|
8
10
|
runSessionWarmupWorker
|
|
9
|
-
} from "./index-
|
|
11
|
+
} from "./index-hedgz8an.js";
|
|
10
12
|
import {
|
|
11
13
|
estimateTokens
|
|
12
|
-
} from "./index-
|
|
14
|
+
} from "./index-zfx7mtqa.js";
|
|
13
15
|
import {
|
|
14
16
|
openCodeDbExists,
|
|
15
17
|
withReadOnlySessionDb
|
|
16
|
-
} from "./index-
|
|
18
|
+
} from "./index-k34hc455.js";
|
|
17
19
|
import {
|
|
18
20
|
hasRawMessageProvider2,
|
|
19
21
|
rawMessageWorkerSource2,
|
|
20
22
|
rawMessageOffThreadRangeReader2,
|
|
21
23
|
readRawSessionMessageIdOrdinalsForRange2
|
|
22
|
-
} from "./index-
|
|
24
|
+
} from "./index-hp46xe93.js";
|
|
23
25
|
import {
|
|
24
26
|
readV2ArchiveOffThread2
|
|
25
|
-
} from "./index-
|
|
27
|
+
} from "./index-2afrmgy3.js";
|
|
26
28
|
|
|
27
29
|
// src/tools/ctx-expand/search-archive.ts
|
|
28
30
|
var archiveReadsOnThisThread = 0;
|
|
29
|
-
function
|
|
31
|
+
function liveTailRefusal(start, end, lastCompartmentEnd) {
|
|
32
|
+
return `Range ${start}-${end} is entirely within the live tail (after the last compacted message ${lastCompartmentEnd}); those messages are already visible in context.`;
|
|
33
|
+
}
|
|
34
|
+
function unresolvedLiveTailRefusal2(db, sessionId, start, end, lastCompartmentEnd) {
|
|
35
|
+
return liveTailRangeTouchesUnresolvedCoverage(db, sessionId, start, end, lastCompartmentEnd) ? liveTailRefusal(start, end, lastCompartmentEnd) : null;
|
|
36
|
+
}
|
|
37
|
+
function renderSearchArchive2(db, sessionId, start, end, tokenBudget, archiveOnly = false, readRawIds = () => readRawSessionMessageIdOrdinalsForRange2(sessionId, start, end), liveTailAfter) {
|
|
30
38
|
archiveReadsOnThisThread += 1;
|
|
39
|
+
let rawIds;
|
|
40
|
+
if (liveTailAfter !== undefined) {
|
|
41
|
+
rawIds = readRawIds();
|
|
42
|
+
if (!rangeHasHiddenMessages(db, sessionId, rawIds, liveTailAfter, start, end)) {
|
|
43
|
+
return liveTailRefusal(start, end, liveTailAfter);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
31
46
|
return withMessageFtsSessionFilter(db, sessionId, (sessionFirst) => {
|
|
32
|
-
let rawIds;
|
|
33
47
|
const rows = db.prepare(sessionFirst ? `SELECT f.message_ordinal AS ordinal, f.message_id AS id, f.role, f.content
|
|
34
48
|
FROM message_fts_rowid_map AS m
|
|
35
49
|
JOIN message_history_fts AS f ON f.rowid = m.fts_rowid
|
|
@@ -76,7 +90,7 @@ function renderSearchArchive2(db, sessionId, start, end, tokenBudget, archiveOnl
|
|
|
76
90
|
`);
|
|
77
91
|
});
|
|
78
92
|
}
|
|
79
|
-
async function renderSearchArchiveOffThread2(db, sessionId, start, end, tokenBudget, archiveOnly = false) {
|
|
93
|
+
async function renderSearchArchiveOffThread2(db, sessionId, start, end, tokenBudget, archiveOnly = false, liveTailAfter) {
|
|
80
94
|
const path = getSqliteDatabasePath2(db);
|
|
81
95
|
const provider = hasRawMessageProvider2(sessionId);
|
|
82
96
|
const source = rawMessageWorkerSource2(sessionId);
|
|
@@ -92,7 +106,7 @@ async function renderSearchArchiveOffThread2(db, sessionId, start, end, tokenBud
|
|
|
92
106
|
if (!path) {
|
|
93
107
|
return renderSearchArchive2(db, sessionId, start, end, tokenBudget, archiveOnly, rawIds ? () => rawIds : provider ? () => {
|
|
94
108
|
throw new Error("Search archive worker unavailable: private archive has no off-thread source");
|
|
95
|
-
} : undefined);
|
|
109
|
+
} : undefined, liveTailAfter);
|
|
96
110
|
}
|
|
97
111
|
if (!archiveOnly && source) {
|
|
98
112
|
return readV2ArchiveOffThread2(path, source.path, sessionId, {
|
|
@@ -100,7 +114,8 @@ async function renderSearchArchiveOffThread2(db, sessionId, start, end, tokenBud
|
|
|
100
114
|
start,
|
|
101
115
|
end,
|
|
102
116
|
tokenBudget,
|
|
103
|
-
archiveOnly
|
|
117
|
+
archiveOnly,
|
|
118
|
+
liveTailAfter
|
|
104
119
|
});
|
|
105
120
|
}
|
|
106
121
|
if (!archiveOnly && provider && !rawIds) {
|
|
@@ -116,7 +131,8 @@ async function renderSearchArchiveOffThread2(db, sessionId, start, end, tokenBud
|
|
|
116
131
|
tokenBudget,
|
|
117
132
|
archiveOnly,
|
|
118
133
|
rawPath,
|
|
119
|
-
rawIds: rawIds ? [...rawIds] : undefined
|
|
134
|
+
rawIds: rawIds ? [...rawIds] : undefined,
|
|
135
|
+
liveTailAfter
|
|
120
136
|
}
|
|
121
137
|
}, {});
|
|
122
138
|
if ("searchArchive" in result)
|
|
@@ -124,4 +140,4 @@ async function renderSearchArchiveOffThread2(db, sessionId, start, end, tokenBud
|
|
|
124
140
|
throw new Error(`Search archive worker unavailable: ${"failure" in result ? `${result.failure}: ${result.detail}` : "unexpected reply"}`);
|
|
125
141
|
}
|
|
126
142
|
|
|
127
|
-
export { renderSearchArchive2, renderSearchArchiveOffThread2 };
|
|
143
|
+
export { unresolvedLiveTailRefusal2, renderSearchArchive2, renderSearchArchiveOffThread2 };
|