@cortexkit/opencode-magic-context 0.49.33 → 0.49.35
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 +11 -6
- package/dist/chunk-embedding-write-worker.js +16 -14
- package/dist/{compaction-marker-candidates-31h86ph0.js → compaction-marker-candidates-g0p67ced.js} +3 -2
- package/dist/compaction-marker-candidates-worker.js +1 -1
- package/dist/{compartment-chunk-embedding-5q5gj67r.js → compartment-chunk-embedding-y4136are.js} +8 -7
- package/dist/{conflict-warning-hook-xgskea1v.js → conflict-warning-hook-hhw8z5ak.js} +9 -8
- package/dist/{context-jyzkstnr.js → context-fk8e3h9p.js} +1400 -701
- package/dist/{derive-budgets-pqybnx09.js → derive-budgets-htj16n4x.js} +3 -2
- package/dist/embedding-backfill-q6n72sy0.js +27 -0
- package/dist/embedding-worker-process.js +2 -1
- package/dist/embedding-worker.js +5 -4
- 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.d.ts +22 -6
- 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/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 +7 -0
- package/dist/features/magic-context/storage-meta-persisted.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/{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 +5 -1
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +5 -5
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts +9 -0
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -0
- 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-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/inject-compartments.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/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-as2amvn3.js → index-0c7p8mq5.js} +6 -531
- package/dist/{index-51rdvtkz.js → index-1rhgxqs8.js} +2 -2
- 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-waktfbjy.js → index-2v6nvy3k.js} +4 -4
- package/dist/{index-dq5xzeb9.js → index-3d3872c6.js} +7 -5
- package/dist/{index-qr2mb02j.js → index-3j9t1v4n.js} +55 -21
- package/dist/{index-2xh37qn5.js → index-4bgk5ztz.js} +576 -5524
- package/dist/{index-b88dwwrh.js → index-4xyjr62e.js} +1 -1
- package/dist/index-66a50f3e.js +777 -0
- package/dist/{index-94ef0qe2.js → index-87ctnzz9.js} +33 -5
- package/dist/{index-xrnsygfq.js → index-9wnbnx8f.js} +1 -1
- package/dist/{index-3fkk2gwj.js → index-b6xz3qbe.js} +246 -420
- package/dist/{index-0fe4q77z.js → index-brg2w6qc.js} +146 -134
- package/dist/{index-spwjbkc7.js → index-dnqqqc5f.js} +1 -1
- package/dist/index-dy7w6wm4.js +194 -0
- package/dist/{index-3jmx3fae.js → index-ezv6dz3y.js} +37 -7
- package/dist/index-f297z1n8.js +4557 -0
- package/dist/{index-qgh1qwjj.js → index-f9b3vtt1.js} +1 -1
- package/dist/{index-v15ne3a3.js → index-faxb7mck.js} +2 -2
- 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-hbt0sbv2.js → index-gyaa159j.js} +18 -276
- package/dist/{index-4pnsgvfk.js → index-hacf2tyx.js} +1 -1
- package/dist/{index-s1n8dd2n.js → index-jkanybgq.js} +2 -2
- package/dist/{index-2743x98y.js → index-jn0ddrhp.js} +29 -138
- package/dist/{index-h7tgn49j.js → index-jrfre9ah.js} +5 -222
- package/dist/{index-kfyb3k6n.js → index-jz5bk7xd.js} +2 -2
- package/dist/{index-np3rgfw4.js → index-ksv0a31x.js} +3 -3
- package/dist/{index-7kkphb6c.js → index-nj360hcs.js} +4 -4
- package/dist/{index-gkee6p4g.js → index-p56dszfp.js} +3 -3
- package/dist/{index-4s4zq97n.js → index-pq0dpwrc.js} +4 -4
- package/dist/{index-rfxzazzy.js → index-pswsyf1w.js} +4 -4
- package/dist/{index-y1qwzvxn.js → index-pztqab6k.js} +2 -2
- package/dist/{index-rverk2vz.js → index-qncw9hey.js} +1 -1
- package/dist/index-qx8j6kds.js +270 -0
- package/dist/{index-kq5w68dp.js → index-txs8tce6.js} +1 -1
- package/dist/index-vzhhr1ht.js +532 -0
- package/dist/index-wh9fxds5.js +265 -0
- package/dist/{index-b7w46fp2.js → index-x2mrq5xv.js} +170 -48
- package/dist/{index-43vqx0za.js → index-xwwsbsd3.js} +15 -13
- package/dist/index-z4p0ry94.js +222 -0
- package/dist/index-z9zygwse.js +89 -0
- package/dist/{index-v7287tzq.js → index-zhqwda72.js} +19 -8
- package/dist/index.js +83 -72
- package/dist/{logger-94kew5wm.js → logger-qwnbcfj9.js} +2 -1
- package/dist/{message-fts-rowid-map-va36knh4.js → message-fts-rowid-map-xg7hr0mk.js} +5 -4
- package/dist/{message-index-bounded-zq7a5nm6.js → message-index-bounded-narw7bnz.js} +12 -11
- package/dist/{message-time-backfill-4qva0b4f.js → message-time-backfill-39bm498k.js} +3 -2
- package/dist/migration-worker.js +13 -11
- package/dist/{project-embedding-registry-6yex0r9f.js → project-embedding-registry-tdz7985n.js} +13 -11
- package/dist/raw-ordinal-warmup-worker.js +12 -7
- package/dist/{read-session-chunk-1ndphmb8.js → read-session-chunk-vmg1zjg0.js} +15 -10
- package/dist/{read-session-raw-b2sd67v4.js → read-session-raw-mncmzbm9.js} +3 -2
- package/dist/recomp-orchestrator-qyyhnc9b.js +68 -0
- package/dist/render-c5p0k846.js +43 -0
- package/dist/{safe-notification-target-mkr9yzvr.js → safe-notification-target-wztd7bgk.js} +3 -2
- package/dist/{search-archive-sr07c6aj.js → search-archive-0ny7p3bw.js} +13 -11
- package/dist/{search-040pac3a.js → search-f6hwvcxk.js} +26 -23
- package/dist/{send-session-notification-vz86nt79.js → send-session-notification-0gwcz3fw.js} +7 -6
- package/dist/{storage-tags-6hvkk01c.js → storage-tags-zx1023km.js} +5 -4
- package/dist/store-620rjzt9.js +21 -0
- package/dist/store-reader-yh19h38c.js +14 -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-zx1peqma.js → transform-postprocess-phase-807ff6t2.js} +36 -30
- package/dist/v2/auto-search-worker.js +11 -6
- package/dist/v2/chunk-embedding-write-worker.js +16 -14
- package/dist/v2/{compaction-marker-candidates-m4vmye3w.js → compaction-marker-candidates-t1aq6gsj.js} +3 -2
- package/dist/v2/compaction-marker-candidates-worker.js +1 -1
- package/dist/v2/{compartment-chunk-embedding-rc31e6md.js → compartment-chunk-embedding-ncsk0r9e.js} +8 -7
- package/dist/v2/{context-3c4z2wj5.js → context-znqfkap4.js} +1725 -1095
- package/dist/v2/{derive-budgets-knf763tt.js → derive-budgets-sa0v7bz0.js} +4 -3
- package/dist/v2/embedding-backfill-11j425e0.js +26 -0
- package/dist/v2/embedding-worker-process.js +2 -1
- package/dist/v2/embedding-worker.js +5 -4
- package/dist/v2/expand-attachments-h33jbgyz.js +21 -0
- package/dist/v2/fold/idle.d.ts +15 -0
- package/dist/v2/fold/idle.d.ts.map +1 -0
- package/dist/v2/fold/native-replay-v3.d.ts +68 -0
- package/dist/v2/fold/native-replay-v3.d.ts.map +1 -0
- package/dist/v2/fold/native-replay.d.ts +58 -2
- 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/{history-owner-ad0crnrn.js → history-owner-fpka43cn.js} +3 -2
- 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/store.d.ts +7 -2
- package/dist/v2/hooks/store.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-rmk571mb.js} +5 -4
- package/dist/v2/{message-index-bounded-jvgz7vk9.js → message-index-bounded-620bppw7.js} +12 -11
- package/dist/v2/{message-time-backfill-zvthw6xb.js → message-time-backfill-0c4h7sg6.js} +3 -2
- package/dist/v2/migration-worker.js +13 -11
- 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-bm5fe1a8.js} +13 -11
- package/dist/v2/raw-ordinal-warmup-worker.js +12 -7
- package/dist/v2/{read-session-chunk-djzgm4jg.js → read-session-chunk-qfwv1k71.js} +15 -10
- package/dist/v2/{read-session-raw-5x088amc.js → read-session-raw-q294t8xs.js} +3 -2
- package/dist/v2/recomp-orchestrator-fcnjref7.js +67 -0
- package/dist/v2/render-98a1qv0b.js +42 -0
- package/dist/v2/{safe-notification-target-khnzg57c.js → safe-notification-target-gphhast7.js} +3 -2
- package/dist/v2/{search-archive-n3dhns4r.js → search-archive-r0y1bafr.js} +13 -11
- package/dist/v2/{search-q3wkpe8t.js → search-z1zqzsmh.js} +25 -22
- package/dist/v2/{send-session-notification-x5nzy34v.js → send-session-notification-fst6hkg7.js} +7 -6
- package/dist/v2/{server-rb8m4vry.js → server-1xesqm5h.js} +146 -134
- 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-55v5hpth.js +270 -0
- package/dist/v2/server-5jp38p98.js +532 -0
- package/dist/v2/{server-qjvk4a9t.js → server-69m30b21.js} +1 -1
- package/dist/v2/{server-d01pe8q5.js → server-7ccxt4nq.js} +14 -216
- package/dist/v2/{server-3mz2qh5a.js → server-969cdpmg.js} +1 -1
- package/dist/v2/{server-835q39kd.js → server-9k0mjef7.js} +2 -2
- package/dist/v2/{server-qc915kw2.js → server-bez34e60.js} +4 -4
- package/dist/v2/{server-nxas8v1d.js → server-bpvsvtph.js} +3 -3
- package/dist/v2/{server-ab8017gw.js → server-bxpz2dcn.js} +29 -138
- package/dist/v2/{server-bsgd4dk1.js → server-dcws5831.js} +2 -2
- package/dist/v2/server-ef1mskas.js +777 -0
- package/dist/v2/{server-1bw1wcbp.js → server-f0j864ma.js} +1 -1
- package/dist/v2/{server-aqbm9c8d.js → server-fqj6ddpr.js} +632 -5540
- package/dist/v2/{server-rr4cbkr0.js → server-hnknwaz8.js} +37 -7
- package/dist/v2/{server-h1byrhwx.js → server-hsf0qsn5.js} +19 -8
- package/dist/v2/{server-6495nmn9.js → server-jb6tjyeb.js} +5 -222
- package/dist/v2/{server-2aasmpsp.js → server-kkxzwa6w.js} +4 -4
- package/dist/v2/{server-a7x00tw8.js → server-mfn1yf9d.js} +1 -1
- package/dist/v2/{server-tkdabx8q.js → server-q0z2q2dx.js} +5 -530
- package/dist/v2/{server-n14edf07.js → server-qa74bj91.js} +77 -17
- package/dist/v2/server-qf2kzsh2.js +4513 -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-hwag0khr.js → server-r3chnxs5.js} +4 -4
- package/dist/v2/{server-vr4szghm.js → server-rktnzs89.js} +2 -2
- package/dist/v2/{server-6vd2n183.js → server-s9xgyyj9.js} +1 -1
- 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-v77xa5wj.js → server-tpt7bwq8.js} +1 -1
- package/dist/v2/{server-awr8qa4c.js → server-ws5exe6q.js} +2 -2
- package/dist/v2/server-x4m6xcn4.js +194 -0
- package/dist/v2/{server-806rzhs6.js → server-xbtw0p9t.js} +1 -1
- 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 +6 -5
- package/dist/v2/{storage-tags-18nbaanf.js → storage-tags-19s0ebf0.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-vdm8v3jd.js +21 -0
- package/dist/v2/v2-archive-reader-t2c0eypn.js +11 -0
- package/dist/v2/{wrapup-orchestrator-ga5vfmwr.js → wrapup-orchestrator-aqpqsveg.js} +46 -39
- package/dist/v2-archive-reader-tm2eayp2.js +11 -0
- package/dist/wrapup-orchestrator-k5yp19a6.js +55 -0
- package/package.json +1 -1
- package/src/shared/sqlite-transaction-mode-guard.test.ts +4 -0
- package/dist/embedding-backfill-0jgtqxen.js +0 -25
- package/dist/recomp-orchestrator-skqzzvby.js +0 -62
- package/dist/v2/embedding-backfill-f43hd8y6.js +0 -24
- package/dist/v2/recomp-orchestrator-qfqdvbta.js +0 -61
- package/dist/wrapup-orchestrator-dy8r3gp8.js +0 -49
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./server-gzy5w8ya.js";
|
|
14
14
|
import {
|
|
15
15
|
scheduleAfterBootQuiet
|
|
16
|
-
} from "./server-
|
|
16
|
+
} from "./server-69m30b21.js";
|
|
17
17
|
import {
|
|
18
18
|
getHarness2,
|
|
19
19
|
harnessOwnsOpenCodeStore2
|
|
@@ -21,11 +21,10 @@ import {
|
|
|
21
21
|
import {
|
|
22
22
|
getMagicContextStorageDir,
|
|
23
23
|
getLegacyOpenCodeMagicContextStorageDir,
|
|
24
|
-
sanitizeDiagnosticText,
|
|
25
24
|
importPluginModule,
|
|
26
25
|
writeForwardedLogLine2,
|
|
27
26
|
log2
|
|
28
|
-
} from "./server-
|
|
27
|
+
} from "./server-jb6tjyeb.js";
|
|
29
28
|
import {
|
|
30
29
|
isOwnRpcServerRecord,
|
|
31
30
|
isPidAlive,
|
|
@@ -36,13 +35,16 @@ import {
|
|
|
36
35
|
parseRpcPortFile,
|
|
37
36
|
inspectProcessesAsync,
|
|
38
37
|
inspectWindowsProcessesSync
|
|
39
|
-
} from "./server-
|
|
38
|
+
} from "./server-sefxj8k1.js";
|
|
40
39
|
import {
|
|
41
40
|
configureContextDatabasePragmas2
|
|
42
41
|
} from "./server-fb3zxn06.js";
|
|
42
|
+
import {
|
|
43
|
+
attachFailClosedBlockingProcessEvidence
|
|
44
|
+
} from "./server-468mya5v.js";
|
|
43
45
|
import {
|
|
44
46
|
startMessageFtsRowidMapBackfill2
|
|
45
|
-
} from "./server-
|
|
47
|
+
} from "./server-ws5exe6q.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 "./server-
|
|
57
|
+
} from "./server-3schkz95.js";
|
|
56
58
|
import {
|
|
57
59
|
ensureColumn,
|
|
58
60
|
installV95PerfSchema,
|
|
59
61
|
installTagIdentityRevisionTrigger
|
|
60
|
-
} from "./server-
|
|
62
|
+
} from "./server-tpt7bwq8.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 "./server-
|
|
70
|
+
} from "./server-xy7w7hrd.js";
|
|
69
71
|
import {
|
|
70
72
|
getErrorMessage
|
|
71
73
|
} from "./server-y8v6yerm.js";
|
|
@@ -74,7 +76,7 @@ import {
|
|
|
74
76
|
} from "./server-8ajstryz.js";
|
|
75
77
|
import {
|
|
76
78
|
logSlowWriteTransaction
|
|
77
|
-
} from "./server-
|
|
79
|
+
} from "./server-qmmkhz2z.js";
|
|
78
80
|
import {
|
|
79
81
|
shouldEnforcePrivateStoragePermissions,
|
|
80
82
|
ensureStorageDirectorySync,
|
|
@@ -114,210 +116,6 @@ function ensureContextStoreUuid(db) {
|
|
|
114
116
|
return getContextStoreUuid(db) ?? minted;
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
// src/features/magic-context/fail-closed-block.ts
|
|
118
|
-
var FAIL_CLOSED_DOCTOR_COMMAND = "npx @cortexkit/magic-context@latest doctor";
|
|
119
|
-
function attachFailClosedBlockingProcessEvidence(process2, evidence) {
|
|
120
|
-
Object.defineProperties(process2, {
|
|
121
|
-
startTime: { configurable: true, value: evidence.startTime },
|
|
122
|
-
commandLine: { configurable: true, value: evidence.commandLine }
|
|
123
|
-
});
|
|
124
|
-
return process2;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
class FailClosedBlockingError extends Error {
|
|
128
|
-
code = "FAIL_CLOSED_BLOCKING";
|
|
129
|
-
reason;
|
|
130
|
-
constructor(message, reason, options) {
|
|
131
|
-
super(message, options);
|
|
132
|
-
this.name = "FailClosedBlockingError";
|
|
133
|
-
this.reason = reason;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
var OPENCODE_INTERNAL_AGENT_NAMES = new Set(["title", "summary", "compaction"]);
|
|
137
|
-
function isMagicContextHiddenAgentName(agent) {
|
|
138
|
-
if (agent === "smart-note-compiler" || agent.startsWith("smart-note-")) {
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
if (agent === "historian" || agent.startsWith("historian-"))
|
|
142
|
-
return true;
|
|
143
|
-
if (agent === "dreamer" || agent.startsWith("dreamer-"))
|
|
144
|
-
return true;
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
var MAX_FORMATTED_BLOCKING_PROCESSES = 8;
|
|
148
|
-
var MAX_FORMATTED_COMMAND_LINE_LENGTH = 80;
|
|
149
|
-
function normalizeFailClosedProcessKind(process2) {
|
|
150
|
-
switch (process2.kind) {
|
|
151
|
-
case "OpenCode server":
|
|
152
|
-
case "OpenCode instance (TUI/CLI)":
|
|
153
|
-
case "Pi":
|
|
154
|
-
case "process":
|
|
155
|
-
return process2.kind;
|
|
156
|
-
}
|
|
157
|
-
switch (process2.harness?.trim().toLowerCase()) {
|
|
158
|
-
case "opencode server":
|
|
159
|
-
return "OpenCode server";
|
|
160
|
-
case "opencode instance (tui/cli)":
|
|
161
|
-
case "opencode instance":
|
|
162
|
-
return "OpenCode instance (TUI/CLI)";
|
|
163
|
-
case "pi":
|
|
164
|
-
case "pi harness":
|
|
165
|
-
case "omp":
|
|
166
|
-
return "Pi";
|
|
167
|
-
default:
|
|
168
|
-
return "process";
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function formatFailClosedProcessStartTime(startTime) {
|
|
172
|
-
if (!Number.isFinite(startTime) || startTime <= 0)
|
|
173
|
-
return "unverified";
|
|
174
|
-
try {
|
|
175
|
-
const parts = new Intl.DateTimeFormat("en-US", {
|
|
176
|
-
day: "numeric",
|
|
177
|
-
hour: "2-digit",
|
|
178
|
-
minute: "2-digit",
|
|
179
|
-
month: "short",
|
|
180
|
-
hour12: false
|
|
181
|
-
}).formatToParts(new Date(startTime));
|
|
182
|
-
const values = Object.fromEntries(parts.map(({ type, value }) => [type, value]));
|
|
183
|
-
if (!values.month || !values.day || !values.hour || !values.minute)
|
|
184
|
-
return "unverified";
|
|
185
|
-
return `${values.month} ${values.day} ${values.hour}:${values.minute}`;
|
|
186
|
-
} catch {
|
|
187
|
-
return "unverified";
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
function formatFailClosedCommandLine(commandLine) {
|
|
191
|
-
if (typeof commandLine !== "string" || commandLine.trim().length === 0)
|
|
192
|
-
return "unverified";
|
|
193
|
-
try {
|
|
194
|
-
const normalized = commandLine.replaceAll("\x00", " ").replace(/\s+/g, " ").trim();
|
|
195
|
-
if (normalized.length === 0)
|
|
196
|
-
return "unverified";
|
|
197
|
-
const sanitized = sanitizeDiagnosticText(normalized).trim();
|
|
198
|
-
if (sanitized.length === 0)
|
|
199
|
-
return "unverified";
|
|
200
|
-
return sanitized.length > MAX_FORMATTED_COMMAND_LINE_LENGTH ? `${sanitized.slice(0, MAX_FORMATTED_COMMAND_LINE_LENGTH - 3)}...` : sanitized;
|
|
201
|
-
} catch {
|
|
202
|
-
return "unverified";
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function formatFailClosedBlockingProcesses(processes) {
|
|
206
|
-
const uniqueProcesses = new Map;
|
|
207
|
-
for (const process2 of processes) {
|
|
208
|
-
if (!Number.isInteger(process2.pid) || process2.pid <= 0)
|
|
209
|
-
continue;
|
|
210
|
-
const candidate = {
|
|
211
|
-
kind: normalizeFailClosedProcessKind(process2),
|
|
212
|
-
pid: process2.pid,
|
|
213
|
-
startTime: process2.startTime,
|
|
214
|
-
commandLine: process2.commandLine
|
|
215
|
-
};
|
|
216
|
-
const previous = uniqueProcesses.get(process2.pid);
|
|
217
|
-
if (!previous || previous.kind === "process" && candidate.kind !== "process") {
|
|
218
|
-
uniqueProcesses.set(process2.pid, candidate);
|
|
219
|
-
} else {
|
|
220
|
-
uniqueProcesses.set(process2.pid, {
|
|
221
|
-
...previous,
|
|
222
|
-
startTime: previous.startTime ?? candidate.startTime,
|
|
223
|
-
commandLine: previous.commandLine ?? candidate.commandLine
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
const entries = [...uniqueProcesses.values()];
|
|
228
|
-
const visible = entries.slice(0, MAX_FORMATTED_BLOCKING_PROCESSES);
|
|
229
|
-
const rendered = visible.map(({ kind, pid }) => `${kind} (PID ${pid})`);
|
|
230
|
-
const omitted = entries.length - visible.length;
|
|
231
|
-
if (omitted > 0)
|
|
232
|
-
rendered.push(`${omitted} more blocking process(es)`);
|
|
233
|
-
if (rendered.length === 0)
|
|
234
|
-
return "a live process";
|
|
235
|
-
const summary = rendered.length === 1 ? rendered[0] : `${rendered.slice(0, -1).join(", ")}, and ${rendered.at(-1)}`;
|
|
236
|
-
const evidence = entries.map(({ kind, pid, startTime, commandLine }) => `- PID ${pid}: ${kind}, started ${formatFailClosedProcessStartTime(startTime)}, cmd: ${formatFailClosedCommandLine(commandLine)}`).join(`
|
|
237
|
-
`);
|
|
238
|
-
return `${summary}
|
|
239
|
-
Blocking process evidence:
|
|
240
|
-
${evidence}`;
|
|
241
|
-
}
|
|
242
|
-
function formatFailClosedBlockingMessage(reason) {
|
|
243
|
-
if (reason.kind === "migration_guard") {
|
|
244
|
-
if (reason.unreadableFile) {
|
|
245
|
-
const arm = reason.unreadableArm ?? "io";
|
|
246
|
-
const recovery = arm === "io" ? `If none of these processes are running, it is safe to delete ${reason.unreadableFile} and retry.` : `The file may be a recent incomplete write; retry after the file is older than the ten-minute grace window, or stop the relevant process before deleting it.`;
|
|
247
|
-
return [
|
|
248
|
-
`Magic Context cannot migrate the shared database because RPC discovery file ${reason.unreadableFile} is uncertain (${arm} arm), so the absence of a live process cannot be proven.`,
|
|
249
|
-
recovery,
|
|
250
|
-
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
251
|
-
].join(" ");
|
|
252
|
-
}
|
|
253
|
-
return [
|
|
254
|
-
`Magic Context cannot migrate the shared database (one database serves every project on this machine) because ${formatFailClosedBlockingProcesses(reason.blockingProcesses)} may be running an older Magic Context build that would fail against the migrated database.`,
|
|
255
|
-
`The database is at upstream migration v${reason.persistedVersion}; this build needs v${reason.supportedVersion}.`,
|
|
256
|
-
"Restart the blocking process — even one from a different project — and it will pick up the new build and migrate on start; or shut it down and retry.",
|
|
257
|
-
"If that host loads a pinned or cached older Magic Context build, a restart alone is not enough: stop it or update its Magic Context build, then start this host once so it migrates the database with nothing older attached.",
|
|
258
|
-
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
259
|
-
].join(" ");
|
|
260
|
-
}
|
|
261
|
-
if (reason.kind === "schema_fence") {
|
|
262
|
-
return [
|
|
263
|
-
`Magic Context cannot operate: this Magic Context build is older than the database; upgrade/restart this harness (upstream migration lane v${reason.persistedVersion}, build supports through v${reason.supportedVersion}).`,
|
|
264
|
-
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
265
|
-
].join(" ");
|
|
266
|
-
}
|
|
267
|
-
const cause = reason.cause.trim().length > 0 ? reason.cause.trim() : "unknown storage error";
|
|
268
|
-
return [
|
|
269
|
-
`Magic Context cannot operate: persistent storage failed (${cause}).`,
|
|
270
|
-
"The plugin will not silently degrade to native compaction while enabled.",
|
|
271
|
-
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
272
|
-
].join(" ");
|
|
273
|
-
}
|
|
274
|
-
function formatFailClosedBlockingSummary(reason) {
|
|
275
|
-
if (reason.kind === "migration_guard") {
|
|
276
|
-
if (reason.unreadableFile) {
|
|
277
|
-
return `Magic Context cannot migrate the shared database from v${reason.persistedVersion} to v${reason.supportedVersion}: RPC discovery file ${reason.unreadableFile} could not be read, so an older host may still be attached.`;
|
|
278
|
-
}
|
|
279
|
-
const blockers = reason.blockingProcesses.filter((process2) => Number.isInteger(process2.pid) && process2.pid > 0).map((process2) => `${normalizeFailClosedProcessKind(process2)} (PID ${process2.pid})`);
|
|
280
|
-
const named = blockers.length > 0 ? blockers.join(", ") : "a live process";
|
|
281
|
-
return `Magic Context cannot migrate the shared database from v${reason.persistedVersion} to v${reason.supportedVersion} while ${named} may still run an older Magic Context build. Stop or update that host, then start this one once.`;
|
|
282
|
-
}
|
|
283
|
-
if (reason.kind === "schema_fence") {
|
|
284
|
-
return `Magic Context cannot operate: the shared database is at v${reason.persistedVersion}, newer than this build supports (v${reason.supportedVersion}). Update and restart this host.`;
|
|
285
|
-
}
|
|
286
|
-
const cause = reason.cause.trim().length > 0 ? reason.cause.trim() : "unknown storage error";
|
|
287
|
-
return `Magic Context cannot operate: persistent storage failed (${cause}).`;
|
|
288
|
-
}
|
|
289
|
-
function createFailClosedBlockingError(reason, options) {
|
|
290
|
-
return new FailClosedBlockingError(formatFailClosedBlockingMessage(reason), reason, options);
|
|
291
|
-
}
|
|
292
|
-
function isFailClosedBlockingError(error) {
|
|
293
|
-
return error instanceof FailClosedBlockingError || typeof error === "object" && error !== null && error.name === "FailClosedBlockingError" && error.code === "FAIL_CLOSED_BLOCKING";
|
|
294
|
-
}
|
|
295
|
-
function shouldBypassFailClosedBlock(input) {
|
|
296
|
-
if (input.isPiSubagentEnv === true)
|
|
297
|
-
return true;
|
|
298
|
-
if (input.isInternalChildSession === true)
|
|
299
|
-
return true;
|
|
300
|
-
const agent = typeof input.agent === "string" ? input.agent.trim() : "";
|
|
301
|
-
if (agent.length === 0)
|
|
302
|
-
return false;
|
|
303
|
-
if (OPENCODE_INTERNAL_AGENT_NAMES.has(agent))
|
|
304
|
-
return true;
|
|
305
|
-
if (isMagicContextHiddenAgentName(agent))
|
|
306
|
-
return true;
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
function resolveAgentNameFromMessages(messages) {
|
|
310
|
-
for (let i = messages.length - 1;i >= 0; i -= 1) {
|
|
311
|
-
const info = messages[i]?.info;
|
|
312
|
-
if (!info || typeof info !== "object")
|
|
313
|
-
continue;
|
|
314
|
-
const agent = info.agent;
|
|
315
|
-
if (typeof agent === "string" && agent.length > 0)
|
|
316
|
-
return agent;
|
|
317
|
-
}
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
119
|
// src/features/magic-context/migration-worker-client.ts
|
|
322
120
|
import { Worker } from "node:worker_threads";
|
|
323
121
|
|
|
@@ -1221,8 +1019,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1221
1019
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1222
1020
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1223
1021
|
return;
|
|
1224
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1225
|
-
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-
|
|
1022
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-qfwv1k71.js"));
|
|
1023
|
+
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-0c4h7sg6.js"));
|
|
1226
1024
|
if (signal.aborted)
|
|
1227
1025
|
return;
|
|
1228
1026
|
await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
|
|
@@ -2726,4 +2524,4 @@ function getDatabasePersistenceError(db) {
|
|
|
2726
2524
|
return persistenceErrorByDatabase.get(db) ?? null;
|
|
2727
2525
|
}
|
|
2728
2526
|
|
|
2729
|
-
export {
|
|
2527
|
+
export { startBootDeadline, getUnconfirmedMigrationHolders, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, BOOT_SQLITE_BUSY_TIMEOUT_MS, getDatabasePath, getPersistedSchemaVersion, enforceSchemaFence, setSqlitePragmaConfig, runSqliteOptimize, initializeDatabase, openDatabase, openCurrentDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError };
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
importPluginModule,
|
|
6
6
|
sessionLog2
|
|
7
|
-
} from "./server-
|
|
7
|
+
} from "./server-jb6tjyeb.js";
|
|
8
8
|
import {
|
|
9
9
|
isDefaultSessionTitle2
|
|
10
|
-
} from "./server-
|
|
10
|
+
} from "./server-f0j864ma.js";
|
|
11
11
|
import {
|
|
12
12
|
shouldHoldIgnoredNotification
|
|
13
|
-
} from "./server-
|
|
13
|
+
} from "./server-mfn1yf9d.js";
|
|
14
14
|
import {
|
|
15
15
|
getErrorMessage
|
|
16
16
|
} from "./server-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-gphhast7.js"));
|
|
146
146
|
if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
|
|
147
147
|
sessionLog2(sessionId, "notification skipped (session not titled yet)");
|
|
148
148
|
return "skipped";
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
} from "./server-1zx87sdm.js";
|
|
5
5
|
import {
|
|
6
6
|
estimateTokens
|
|
7
|
-
} from "./server-
|
|
7
|
+
} from "./server-969cdpmg.js";
|
|
8
8
|
import {
|
|
9
9
|
getHarness2
|
|
10
10
|
} from "./server-pavzsdc6.js";
|
|
11
11
|
import {
|
|
12
12
|
sessionLog2
|
|
13
|
-
} from "./server-
|
|
13
|
+
} from "./server-jb6tjyeb.js";
|
|
14
14
|
import {
|
|
15
15
|
getTagIdentityWriteGeneration2,
|
|
16
16
|
getSqliteDatabasePath2
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
stableStringifyHash,
|
|
21
21
|
tagOrderConstraintIndex,
|
|
22
22
|
tagIdentityRevisionKey
|
|
23
|
-
} from "./server-
|
|
23
|
+
} from "./server-tpt7bwq8.js";
|
|
24
24
|
import {
|
|
25
25
|
DEFAULT_PROTECTED_TOOLS,
|
|
26
26
|
normalizeProtectedToolName,
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
inRootAsyncContext2,
|
|
3
|
-
getSqliteDatabasePath2,
|
|
4
|
-
withSqliteBackgroundWriter2,
|
|
5
|
-
withoutSqliteTransformPass2,
|
|
6
|
-
isTransientSqliteError2
|
|
7
|
-
} from "./server-gzy5w8ya.js";
|
|
8
1
|
import {
|
|
9
2
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
10
3
|
} from "./server-24g8r2d0.js";
|
|
4
|
+
import {
|
|
5
|
+
embedPauseBySession,
|
|
6
|
+
activeEmbeddingSessions,
|
|
7
|
+
drainBackgroundBatches,
|
|
8
|
+
beginSynapseBatchLedger,
|
|
9
|
+
finishSynapseBatchLedger,
|
|
10
|
+
pruneSynapseBatchLedgerForProject
|
|
11
|
+
} from "./server-2amn2s73.js";
|
|
12
|
+
import {
|
|
13
|
+
inRootAsyncContext2,
|
|
14
|
+
getSqliteDatabasePath2
|
|
15
|
+
} from "./server-gzy5w8ya.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,9 +23,11 @@ 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";
|
|
24
31
|
import {
|
|
25
32
|
createWorkerShutdown
|
|
26
33
|
} from "./server-cpjk5jd2.js";
|
|
@@ -29,10 +36,10 @@ import {
|
|
|
29
36
|
isSynapseEmbeddingTruncated,
|
|
30
37
|
getSynapseBatchRequestKey,
|
|
31
38
|
SynapseEmbeddingProvider
|
|
32
|
-
} from "./server-
|
|
39
|
+
} from "./server-zzgtgqmd.js";
|
|
33
40
|
import {
|
|
34
41
|
estimateTokens
|
|
35
|
-
} from "./server-
|
|
42
|
+
} from "./server-969cdpmg.js";
|
|
36
43
|
import {
|
|
37
44
|
DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS2,
|
|
38
45
|
CHUNK_WINDOW_SAFETY_RATIO2,
|
|
@@ -50,7 +57,7 @@ import {
|
|
|
50
57
|
countSessionCompartmentEmbedCoverage2,
|
|
51
58
|
countSessionCompartmentEmbedCoveragePolite2,
|
|
52
59
|
countUnembeddedSessionCompartmentsPolite2
|
|
53
|
-
} from "./server-
|
|
60
|
+
} from "./server-hsf0qsn5.js";
|
|
54
61
|
import {
|
|
55
62
|
acquireGitSweepLease,
|
|
56
63
|
renewGitSweepLease,
|
|
@@ -58,7 +65,7 @@ import {
|
|
|
58
65
|
findMisScopedCompartmentChunkEmbeddingIdsForProject,
|
|
59
66
|
recordSessionProjectIdentity,
|
|
60
67
|
repairMisScopedCompartmentChunkEmbeddingsForProject
|
|
61
|
-
} from "./server-
|
|
68
|
+
} from "./server-dcws5831.js";
|
|
62
69
|
import {
|
|
63
70
|
saveEmbeddingIfHashMatches,
|
|
64
71
|
getMemoryEmbedCoverage,
|
|
@@ -73,132 +80,16 @@ import {
|
|
|
73
80
|
logLocalEmbeddingPoolingUnavailableOnce,
|
|
74
81
|
getEmbeddingProviderIdentity,
|
|
75
82
|
LocalEmbeddingProvider
|
|
76
|
-
} from "./server-
|
|
83
|
+
} from "./server-rktnzs89.js";
|
|
77
84
|
import {
|
|
78
85
|
isKnownAutocommit
|
|
79
86
|
} from "./server-8ajstryz.js";
|
|
80
87
|
import {
|
|
81
88
|
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
|
-
}
|
|
89
|
+
} from "./server-qmmkhz2z.js";
|
|
199
90
|
|
|
200
91
|
// src/features/magic-context/project-embedding-registry.ts
|
|
201
|
-
import { createHash as
|
|
92
|
+
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
202
93
|
|
|
203
94
|
// src/features/magic-context/chunk-embedding-writer.ts
|
|
204
95
|
import { Worker } from "node:worker_threads";
|
|
@@ -507,7 +398,7 @@ function enforceProjectCap(db, projectPath, maxCommits) {
|
|
|
507
398
|
}
|
|
508
399
|
|
|
509
400
|
// src/features/magic-context/memory/embedding-openai.ts
|
|
510
|
-
import { createHash
|
|
401
|
+
import { createHash } from "node:crypto";
|
|
511
402
|
|
|
512
403
|
// src/features/magic-context/memory/embedding-ssrf.ts
|
|
513
404
|
var METADATA_HOSTNAMES = new Set(["metadata.google.internal", "metadata.goog"]);
|
|
@@ -614,7 +505,7 @@ var RATE_LIMIT_BACKOFF_CAP_MS = 30000;
|
|
|
614
505
|
var RATE_LIMIT_BACKOFF_JITTER = 0.25;
|
|
615
506
|
var rateLimitStates = new Map;
|
|
616
507
|
function rateLimitStateKey(endpoint, apiKey) {
|
|
617
|
-
const keyHash = apiKey ?
|
|
508
|
+
const keyHash = apiKey ? createHash("sha256").update(apiKey).digest("hex").slice(0, 16) : "";
|
|
618
509
|
return `${endpoint}\x00${keyHash}`;
|
|
619
510
|
}
|
|
620
511
|
function parseRetryAfterMs(value, nowMs) {
|
|
@@ -1405,10 +1296,10 @@ function stableStringify(value) {
|
|
|
1405
1296
|
return JSON.stringify(value);
|
|
1406
1297
|
}
|
|
1407
1298
|
function sha256Prefix(value, length = 16) {
|
|
1408
|
-
return
|
|
1299
|
+
return createHash2("sha256").update(value).digest("hex").slice(0, length);
|
|
1409
1300
|
}
|
|
1410
1301
|
function contentSha2562(value) {
|
|
1411
|
-
return
|
|
1302
|
+
return createHash2("sha256").update(value).digest("hex");
|
|
1412
1303
|
}
|
|
1413
1304
|
function getRuntimeFingerprint(config) {
|
|
1414
1305
|
if (config.provider === "off") {
|
|
@@ -3209,4 +3100,4 @@ function _resetProjectEmbeddingRegistryForTests2() {
|
|
|
3209
3100
|
setBootQuietPeriodForTests(null);
|
|
3210
3101
|
}
|
|
3211
3102
|
|
|
3212
|
-
export {
|
|
3103
|
+
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 };
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./server-pavzsdc6.js";
|
|
4
4
|
import {
|
|
5
5
|
isUserHomeDirectory
|
|
6
|
-
} from "./server-
|
|
6
|
+
} from "./server-69m30b21.js";
|
|
7
7
|
import {
|
|
8
8
|
logSlowWriteTransaction
|
|
9
|
-
} from "./server-
|
|
9
|
+
} from "./server-qmmkhz2z.js";
|
|
10
10
|
|
|
11
11
|
// src/features/magic-context/git-commits/sweep-coordinator.ts
|
|
12
12
|
var GIT_SWEEP_COOLDOWN_MS = 10 * 60 * 1000;
|