@cortexkit/opencode-magic-context 0.49.7 → 0.49.8

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.
Files changed (200) hide show
  1. package/dist/auto-search-worker.js +6 -6
  2. package/dist/compaction-marker-candidates-worker.js +2 -2
  3. package/dist/{compaction-marker-candidates-a0edbqrr.js → compaction-marker-candidates-xxz35vwp.js} +3 -3
  4. package/dist/{conflict-warning-hook-myk5hbt9.js → conflict-warning-hook-w3crzrar.js} +8 -8
  5. package/dist/{context-ffr7e0g7.js → context-x0ccfv0f.js} +65 -42
  6. package/dist/{derive-budgets-j4ry8j8n.js → derive-budgets-3nbxsyss.js} +2 -2
  7. package/dist/embedding-backfill-3h2m5n0q.js +21 -0
  8. package/dist/embedding-worker-process.js +6 -2
  9. package/dist/embedding-worker.js +6 -5
  10. package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
  11. package/dist/features/magic-context/dreamer/cron.d.ts +2 -0
  12. package/dist/features/magic-context/dreamer/cron.d.ts.map +1 -1
  13. package/dist/features/magic-context/dreamer/provider-output-failure.d.ts +1 -0
  14. package/dist/features/magic-context/dreamer/provider-output-failure.d.ts.map +1 -1
  15. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  16. package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
  17. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  18. package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
  19. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  20. package/dist/features/magic-context/smart-notes/wake-plane.d.ts.map +1 -1
  21. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  22. package/dist/history-owner-ty29fz0f.js +244 -0
  23. package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/edit-marker.d.ts +2 -0
  28. package/dist/hooks/magic-context/edit-marker.d.ts.map +1 -1
  29. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/module-transport.d.ts +1 -0
  31. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/read-session-chunk.d.ts +8 -4
  34. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  35. package/dist/hooks/magic-context/rust-mode-transform.d.ts +1 -0
  36. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  40. package/dist/hooks/magic-context/unresolved-history-boundary.d.ts +5 -1
  41. package/dist/hooks/magic-context/unresolved-history-boundary.d.ts.map +1 -1
  42. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  43. package/dist/{index-g8qbdb03.js → index-0jz47061.js} +6 -3
  44. package/dist/{index-4mjhqadz.js → index-150zz6fh.js} +1 -1
  45. package/dist/{index-j58gqrn2.js → index-2rw244rh.js} +31 -24
  46. package/dist/{index-0gyq3djm.js → index-4hb8nt93.js} +3 -3
  47. package/dist/{index-ax2jhztn.js → index-7bjgyaj1.js} +4 -4
  48. package/dist/{index-h2wc01qk.js → index-8kk7yh6m.js} +2 -2
  49. package/dist/{index-n5a170gs.js → index-9g1c4bt9.js} +81 -58
  50. package/dist/{index-w6bd03dc.js → index-a43xq1pg.js} +5 -5
  51. package/dist/{index-tqf7yg27.js → index-a4b0gbyg.js} +1 -1
  52. package/dist/{index-37q80veb.js → index-angx1s0k.js} +4 -3
  53. package/dist/{index-wq16ahsn.js → index-b4gcb3rk.js} +8 -8
  54. package/dist/{index-z1tjp257.js → index-b64n4d0h.js} +1 -1
  55. package/dist/{index-1bt88epp.js → index-bd9cjab3.js} +1 -1
  56. package/dist/{index-gbmqa9x9.js → index-bmwfzz28.js} +9 -6
  57. package/dist/{index-qx53vezw.js → index-gjvjh960.js} +1 -1
  58. package/dist/{index-ebnngykq.js → index-gzg9ekc1.js} +19 -18
  59. package/dist/{index-5tbvdff4.js → index-hxrvx6cy.js} +79 -40
  60. package/dist/{index-w23dh319.js → index-jw4gbfkv.js} +1 -1
  61. package/dist/index-knvkbfvh.js +25 -0
  62. package/dist/{index-vkbqdnkj.js → index-kvw6xew3.js} +6 -3
  63. package/dist/{index-rzmjkdd6.js → index-mp2kghkv.js} +3 -27
  64. package/dist/{index-nsjyysj0.js → index-mvvephtj.js} +5 -1
  65. package/dist/{index-9yyqq3mm.js → index-n78avt2p.js} +1 -1
  66. package/dist/{index-vt4sf4ep.js → index-pgy3h49n.js} +4 -4
  67. package/dist/{index-w6vr754t.js → index-pjgzdezw.js} +13 -9
  68. package/dist/{v2/server-1rfgbjfn.js → index-q28hsbpg.js} +15 -3
  69. package/dist/{index-a8acx4gc.js → index-q76br5zn.js} +3 -3
  70. package/dist/{index-j5hce1ab.js → index-qgp5vnt4.js} +5 -5
  71. package/dist/{index-sf94at64.js → index-rg1cezmj.js} +22 -22
  72. package/dist/{index-sh91t19a.js → index-s178h9z8.js} +4 -3
  73. package/dist/{index-tagss15p.js → index-w1ejb9qr.js} +105 -58
  74. package/dist/{index-k6xvbj2e.js → index-w28y7d0z.js} +2 -0
  75. package/dist/{index-j8epsc0g.js → index-wafzvyhg.js} +33 -10
  76. package/dist/{index-rwmpkss5.js → index-xf6k8szp.js} +4 -4
  77. package/dist/{index-tmtty2x5.js → index-xpn05jxq.js} +4 -4
  78. package/dist/{index-n7kwfw2r.js → index-ydjgz36f.js} +7 -7
  79. package/dist/{index-4btknbqh.js → index-zf9nydbd.js} +48 -38
  80. package/dist/index.js +51 -50
  81. package/dist/{logger-ewak5q1s.js → logger-wn328tfg.js} +1 -1
  82. package/dist/{message-index-bounded-04rycpx4.js → message-index-bounded-hxjp56qk.js} +16 -16
  83. package/dist/{message-index-rqtse28y.js → message-index-zs882h8e.js} +16 -16
  84. package/dist/{message-time-backfill-a5ytnp53.js → message-time-backfill-nb5hhnrt.js} +3 -3
  85. package/dist/migration-worker.js +11 -11
  86. package/dist/plugin/boot-quiet.d.ts.map +1 -1
  87. package/dist/plugin/dream-timer.d.ts.map +1 -1
  88. package/dist/plugin/rpc-handlers.d.ts +2 -0
  89. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  90. package/dist/{project-embedding-registry-k0sd9k7v.js → project-embedding-registry-vy7sv9jt.js} +11 -11
  91. package/dist/raw-ordinal-warmup-worker.js +6 -6
  92. package/dist/{read-session-chunk-h1btx938.js → read-session-chunk-t9r7r0sg.js} +11 -11
  93. package/dist/{read-session-raw-vdf4wh78.js → read-session-raw-gm6xj30v.js} +3 -3
  94. package/dist/recomp-orchestrator-gr36zvd2.js +60 -0
  95. package/dist/{safe-notification-target-q0cyrx3x.js → safe-notification-target-jdynm677.js} +2 -2
  96. package/dist/{search-3rbdx6hw.js → search-qjen1pmz.js} +24 -24
  97. package/dist/{send-session-notification-2tp44tfa.js → send-session-notification-q8ngbap3.js} +6 -6
  98. package/dist/shared/history-owner.d.ts +12 -0
  99. package/dist/shared/history-owner.d.ts.map +1 -0
  100. package/dist/shared/off-thread-migration-clock.d.ts +8 -1
  101. package/dist/shared/off-thread-migration-clock.d.ts.map +1 -1
  102. package/dist/shared/redaction.d.ts.map +1 -1
  103. package/dist/shared/rpc-server.d.ts.map +1 -1
  104. package/dist/shared/sqlite.d.ts +2 -0
  105. package/dist/shared/sqlite.d.ts.map +1 -1
  106. package/dist/shared/user-facing-codes.d.ts +2 -2
  107. package/dist/{sqlite-j3tvg8r0.js → sqlite-4pqyynrs.js} +3 -1
  108. package/dist/{storage-memory-8168bgef.js → storage-memory-j3v3hc83.js} +2 -2
  109. package/dist/{storage-tags-61z5j2f9.js → storage-tags-a513rkj3.js} +5 -5
  110. package/dist/{transform-postprocess-phase-7qts7h54.js → transform-postprocess-phase-yv463b7y.js} +30 -30
  111. package/dist/v2/auto-search-worker.js +6 -6
  112. package/dist/v2/{compaction-marker-candidates-6nypjkpf.js → compaction-marker-candidates-a15w3mqh.js} +3 -3
  113. package/dist/v2/compaction-marker-candidates-worker.js +2 -2
  114. package/dist/v2/{context-xq4rtywr.js → context-wd82v9z6.js} +137 -68
  115. package/dist/v2/{derive-budgets-enckmg7y.js → derive-budgets-0rmpmxjw.js} +3 -3
  116. package/dist/v2/embedding-backfill-vr7wdtrf.js +20 -0
  117. package/dist/v2/embedding-worker-process.js +6 -2
  118. package/dist/v2/embedding-worker.js +6 -5
  119. package/dist/v2/hidden-completion.d.ts.map +1 -1
  120. package/dist/v2/history-owner-2cr9py37.js +243 -0
  121. package/dist/v2/hooks/context.d.ts.map +1 -1
  122. package/dist/v2/hooks/store.d.ts +1 -0
  123. package/dist/v2/hooks/store.d.ts.map +1 -1
  124. package/dist/v2/{logger-pj02s7sr.js → logger-te6e1j72.js} +1 -1
  125. package/dist/v2/{message-index-bounded-5vh1h2g7.js → message-index-bounded-madg2kfr.js} +16 -16
  126. package/dist/v2/{message-index-8e5z2xx8.js → message-index-yd94vt9n.js} +16 -16
  127. package/dist/v2/{message-time-backfill-2z365239.js → message-time-backfill-rz1pnpaj.js} +3 -3
  128. package/dist/v2/migration-worker.js +11 -11
  129. package/dist/v2/{project-embedding-registry-b77awytr.js → project-embedding-registry-ja23aygk.js} +11 -11
  130. package/dist/v2/raw-ordinal-warmup-worker.js +6 -6
  131. package/dist/v2/{read-session-chunk-4sat83cx.js → read-session-chunk-7qs791f3.js} +11 -11
  132. package/dist/v2/{read-session-raw-a3hw9jsp.js → read-session-raw-h4azh85b.js} +3 -3
  133. package/dist/v2/recomp-orchestrator-ee91r9s6.js +59 -0
  134. package/dist/v2/{safe-notification-target-y3p1hce9.js → safe-notification-target-936374xx.js} +2 -2
  135. package/dist/v2/search-pn15rr52.js +46 -0
  136. package/dist/v2/{send-session-notification-ppgc8qdz.js → send-session-notification-6n7chhyp.js} +6 -6
  137. package/dist/v2/{server-v4fwha43.js → server-08k4zkfk.js} +48 -38
  138. package/dist/v2/{server-ras2sxnc.js → server-44ryn9rb.js} +9 -6
  139. package/dist/v2/{server-fw31krgq.js → server-4easnf78.js} +19 -19
  140. package/dist/v2/{server-hcvcxzx7.js → server-4gz0xkrc.js} +5 -5
  141. package/dist/v2/{server-d6g4whc2.js → server-4qr18rfg.js} +3 -3
  142. package/dist/v2/{server-sy4b1sra.js → server-4rs8sm06.js} +5 -5
  143. package/dist/v2/{server-brhj8qtd.js → server-63ha7f0f.js} +3 -27
  144. package/dist/v2/{server-3t0q2cqx.js → server-7dv9wt9r.js} +1 -1
  145. package/dist/v2/{server-cw6521wn.js → server-7e087rvk.js} +2 -0
  146. package/dist/v2/{server-hb6xhh9q.js → server-988cqjme.js} +6 -3
  147. package/dist/v2/{server-fpqe39as.js → server-9a6bwc12.js} +4 -4
  148. package/dist/v2/{server-t4k4qexw.js → server-9e5r8y60.js} +5 -1
  149. package/dist/v2/{server-7ekna9zs.js → server-adfte03x.js} +2 -2
  150. package/dist/v2/{server-qcw43339.js → server-ak7w74j9.js} +4 -4
  151. package/dist/v2/{server-dd0nja67.js → server-bx59ezg6.js} +4 -3
  152. package/dist/v2/{server-676xw7at.js → server-ckrb5rm8.js} +1 -1
  153. package/dist/{index-w4mw92w3.js → v2/server-cxsr0ng6.js} +15 -3
  154. package/dist/v2/{server-t528t8qm.js → server-hn9fb3v0.js} +2 -2
  155. package/dist/v2/{server-7srtwsa4.js → server-j3dm74ey.js} +9 -9
  156. package/dist/v2/{server-w3zeywp1.js → server-jjsf29aq.js} +4 -4
  157. package/dist/v2/server-knvkbfvh.js +25 -0
  158. package/dist/v2/{server-9yyqq3mm.js → server-n78avt2p.js} +1 -1
  159. package/dist/v2/{server-kdrezdy0.js → server-njnx39q2.js} +6 -3
  160. package/dist/v2/{server-x08d1xf3.js → server-npm52h2q.js} +4 -3
  161. package/dist/v2/{server-vb7pbd9p.js → server-nveratm5.js} +1 -1
  162. package/dist/v2/{server-mv1w7t6z.js → server-q360kdb8.js} +77 -38
  163. package/dist/v2/{server-kzns2hbz.js → server-s6jqh8bj.js} +1 -1
  164. package/dist/v2/{server-6byqfbqf.js → server-shme41gj.js} +1 -1
  165. package/dist/v2/{server-j8epsc0g.js → server-wafzvyhg.js} +33 -10
  166. package/dist/v2/{server-gtv9wbhq.js → server-xj4mewze.js} +81 -58
  167. package/dist/v2/{server-nfan6zb6.js → server-y5g32dhq.js} +31 -24
  168. package/dist/v2/{server-jdwd03ep.js → server-yak3sxya.js} +7 -7
  169. package/dist/v2/{server-wkdgjjch.js → server-zrwaj29a.js} +2 -2
  170. package/dist/v2/server.js +7 -6
  171. package/dist/v2/{sqlite-j3tvg8r0.js → sqlite-4pqyynrs.js} +3 -1
  172. package/dist/v2/{storage-memory-8168bgef.js → storage-memory-j3v3hc83.js} +2 -2
  173. package/dist/v2/{storage-tags-j2fzq3sw.js → storage-tags-spa92sgj.js} +5 -5
  174. package/dist/v2/store-reader.d.ts.map +1 -1
  175. package/dist/v2/{wrapup-orchestrator-s92ebfzv.js → wrapup-orchestrator-5wxy1ggv.js} +38 -35
  176. package/dist/wrapup-orchestrator-gv08c6f9.js +47 -0
  177. package/package.json +1 -1
  178. package/src/config/compaction-accessor-guard.test.ts +3 -0
  179. package/src/features/magic-context/dreamer/cron.ts +8 -0
  180. package/src/shared/history-owner.test.ts +60 -0
  181. package/src/shared/history-owner.ts +43 -0
  182. package/src/shared/host-stall-profiler-node.ts +3 -1
  183. package/src/shared/host-stall-profiler.ts +3 -1
  184. package/src/shared/off-thread-migration-clock.test.ts +80 -10
  185. package/src/shared/off-thread-migration-clock.ts +37 -13
  186. package/src/shared/redaction.test.ts +16 -0
  187. package/src/shared/redaction.ts +8 -1
  188. package/src/shared/root-async-context.probe.mjs +36 -0
  189. package/src/shared/root-async-context.test.ts +49 -0
  190. package/src/shared/rpc-server.ts +27 -23
  191. package/src/shared/sqlite-busy-budget-review.test.ts +291 -0
  192. package/src/shared/sqlite-foreground-wait.test.ts +253 -1
  193. package/src/shared/sqlite.ts +55 -14
  194. package/src/shared/user-facing-codes.ts +2 -2
  195. package/dist/embedding-backfill-re16xncd.js +0 -21
  196. package/dist/recomp-orchestrator-trcgmm23.js +0 -60
  197. package/dist/v2/embedding-backfill-xd9ygzgd.js +0 -20
  198. package/dist/v2/recomp-orchestrator-n11zv1f1.js +0 -59
  199. package/dist/v2/search-mvgqtkkz.js +0 -46
  200. package/dist/wrapup-orchestrator-df61jmz9.js +0 -47
@@ -9,7 +9,7 @@ import {
9
9
  sanitizeDiagnosticText,
10
10
  log2,
11
11
  sessionLog2
12
- } from "./server-t4k4qexw.js";
12
+ } from "./server-9e5r8y60.js";
13
13
  import {
14
14
  parseJsoncRecovering,
15
15
  detectConfigFile,
@@ -17,34 +17,32 @@ import {
17
17
  cortexKitProjectConfigBasePath,
18
18
  resolveLegacyConfigSourcesForHarness,
19
19
  loadPluginConfigDetailed
20
- } from "./server-d6g4whc2.js";
20
+ } from "./server-4qr18rfg.js";
21
21
  import {
22
22
  catalogOutputReserve,
23
23
  getSdkContextLimit,
24
24
  modelSupportsVision,
25
25
  getSdkOutputLimit
26
- } from "./server-vb7pbd9p.js";
26
+ } from "./server-nveratm5.js";
27
27
  import {
28
28
  withContentLanguageDirective,
29
29
  buildPrimaryLanguageDirective,
30
30
  resolvePromptSurface,
31
31
  DEFAULT_HISTORIAN_TIMEOUT_MS,
32
32
  LIVE_RELOAD_CONFIG_PATHS
33
- } from "./server-cw6521wn.js";
33
+ } from "./server-7e087rvk.js";
34
34
  import {
35
35
  hasMeaningfulUserText2,
36
36
  estimateTokens,
37
37
  estimateFixedPromptTokens
38
- } from "./server-kzns2hbz.js";
38
+ } from "./server-s6jqh8bj.js";
39
39
  import {
40
+ inRootAsyncContext2,
40
41
  Database2,
41
42
  withSqliteBackgroundWriter2,
42
43
  withoutSqliteTransformPass2,
43
44
  beginSqliteWriterAsync2
44
- } from "./server-j8epsc0g.js";
45
- import {
46
- sameProjectDirectory
47
- } from "./server-brhj8qtd.js";
45
+ } from "./server-wafzvyhg.js";
48
46
  import {
49
47
  buildCanonicalChunkTextFromFts,
50
48
  buildCompartmentSummaryFallbackText,
@@ -54,10 +52,10 @@ import {
54
52
  replaceCompartmentChunkEmbeddings,
55
53
  deleteChunkEmbedBackoffForSession,
56
54
  chunkWindowSourceKey
57
- } from "./server-fpqe39as.js";
55
+ } from "./server-9a6bwc12.js";
58
56
  import {
59
57
  isPidAlive
60
- } from "./server-1rfgbjfn.js";
58
+ } from "./server-cxsr0ng6.js";
61
59
  import {
62
60
  BoundedSessionMap,
63
61
  clearCompressionDepth,
@@ -72,7 +70,7 @@ import {
72
70
  toMessageIndexSource2,
73
71
  clearIndexedMessagesInTransaction2,
74
72
  indexSourcesAfterOrdinal2
75
- } from "./server-7srtwsa4.js";
73
+ } from "./server-j3dm74ey.js";
76
74
  import {
77
75
  detectOverflow,
78
76
  SESSION_META_SELECT_COLUMNS,
@@ -161,17 +159,17 @@ import {
161
159
  getRawSessionTagKeysThrough2,
162
160
  getLegacyProtectedTailStartOrdinal2,
163
161
  readSessionChunk2
164
- } from "./server-gtv9wbhq.js";
162
+ } from "./server-xj4mewze.js";
165
163
  import {
166
164
  getTableColumnNames
167
- } from "./server-6byqfbqf.js";
165
+ } from "./server-shme41gj.js";
168
166
  import {
169
167
  FAIL_CLOSED_DOCTOR_COMMAND,
170
168
  getSchemaFenceRejection,
171
169
  LATEST_SUPPORTED_VERSION,
172
170
  getPersistedSchemaVersion,
173
171
  openDatabase
174
- } from "./server-v4fwha43.js";
172
+ } from "./server-08k4zkfk.js";
175
173
  import {
176
174
  providerMass,
177
175
  calibrationForModelKey,
@@ -189,11 +187,11 @@ import {
189
187
  foldShrunkPartTags2,
190
188
  getTagNumberByMessageId2,
191
189
  getActiveTagsBySession2
192
- } from "./server-w3zeywp1.js";
190
+ } from "./server-jjsf29aq.js";
193
191
  import {
194
192
  isStrictGapHealingMessage2,
195
193
  noteRawSessionSummaryRowWritten2
196
- } from "./server-dd0nja67.js";
194
+ } from "./server-bx59ezg6.js";
197
195
  import {
198
196
  resolveOpenCodeDbPath,
199
197
  assertOpenCodeStoreGeneration,
@@ -203,10 +201,10 @@ import {
203
201
  import {
204
202
  withReadOnlySessionDb,
205
203
  getMessageTimesFromOpenCodeDb
206
- } from "./server-wkdgjjch.js";
204
+ } from "./server-zrwaj29a.js";
207
205
  import {
208
206
  getMeasuredToolDefinitionTokens
209
- } from "./server-7ekna9zs.js";
207
+ } from "./server-adfte03x.js";
210
208
  import {
211
209
  V2_MEMORY_CATEGORIES,
212
210
  CATEGORY_PRIORITY,
@@ -222,11 +220,11 @@ import {
222
220
  resolveStoredPathWorkspaceIdentity,
223
221
  sourceNameForMemory,
224
222
  computeWorkspaceEpochFingerprint
225
- } from "./server-hcvcxzx7.js";
223
+ } from "./server-4gz0xkrc.js";
226
224
  import {
227
225
  shouldSkipHomeProjectMemory,
228
226
  resolveProjectIdentity
229
- } from "./server-kdrezdy0.js";
227
+ } from "./server-njnx39q2.js";
230
228
  import {
231
229
  drainBackgroundBatches,
232
230
  contentSha2562,
@@ -234,7 +232,7 @@ import {
234
232
  getProjectChunkEmbeddingModelId2,
235
233
  getProjectEmbeddingMaxInputTokens2,
236
234
  embedItemsForProject2
237
- } from "./server-fw31krgq.js";
235
+ } from "./server-4easnf78.js";
238
236
  import {
239
237
  getSessionNotes,
240
238
  getReadySmartNotes,
@@ -243,13 +241,13 @@ import {
243
241
  userFacingFailureCode,
244
242
  promoteSessionFactsDurable,
245
243
  embedPromotedFacts
246
- } from "./server-jdwd03ep.js";
244
+ } from "./server-yak3sxya.js";
247
245
  import {
248
246
  isMarkerCandidateBasisCurrent2,
249
247
  invalidateMarkerCandidateBasis2,
250
248
  readMarkerCandidateBasis2,
251
249
  prepareMarkerCandidateBasis2
252
- } from "./server-x08d1xf3.js";
250
+ } from "./server-npm52h2q.js";
253
251
  import {
254
252
  computeCueContentHash,
255
253
  getMuralCueState,
@@ -257,7 +255,7 @@ import {
257
255
  getMemoriesByProject2,
258
256
  getMemoriesByProjects2,
259
257
  getMaxMemoryIdForProjects2
260
- } from "./server-9yyqq3mm.js";
258
+ } from "./server-n78avt2p.js";
261
259
  import {
262
260
  pushNotification2
263
261
  } from "./server-x8a7jmkh.js";
@@ -265,10 +263,13 @@ import {
265
263
  deriveTriggerBudget2,
266
264
  resolveHistorianProducerLimits2,
267
265
  producerSourceLocalBudget2
268
- } from "./server-t528t8qm.js";
266
+ } from "./server-hn9fb3v0.js";
269
267
  import {
270
268
  sendStatusNotification2
271
- } from "./server-qcw43339.js";
269
+ } from "./server-ak7w74j9.js";
270
+ import {
271
+ sameProjectDirectory
272
+ } from "./server-knvkbfvh.js";
272
273
  import {
273
274
  getErrorMessage,
274
275
  describeError
@@ -282,7 +283,7 @@ import {
282
283
  import {
283
284
  logSlowWriteTransaction,
284
285
  WriteTransactionSteps
285
- } from "./server-3t0q2cqx.js";
286
+ } from "./server-7dv9wt9r.js";
286
287
 
287
288
  // src/config/live-snapshot.ts
288
289
  import { createHash } from "node:crypto";
@@ -1111,7 +1112,7 @@ var V2_MESSAGE_PAGE_SQL = `WITH bounds AS (
1111
1112
  SELECT seq FROM session_message
1112
1113
  WHERE session_id = ? AND type IN (${RAW_MESSAGE_TYPE_PARAMETERS})
1113
1114
  ORDER BY seq ASC LIMIT 1 OFFSET ?
1114
- ), -1) END AS after_seq,
1115
+ ), (SELECT MAX(seq) FROM session_message WHERE session_id = ?), -1) END AS after_seq,
1115
1116
  COALESCE((
1116
1117
  SELECT seq FROM session_message
1117
1118
  WHERE session_id = ? AND type IN (${RAW_MESSAGE_TYPE_PARAMETERS})
@@ -1372,7 +1373,7 @@ class V2StoreReader {
1372
1373
  }
1373
1374
  }
1374
1375
  const maximumSeq = Number.MAX_SAFE_INTEGER;
1375
- const rows = this.prepare(V2_MESSAGE_PAGE_SQL).all(afterOrdinal, sessionID, ...RAW_MESSAGE_TYPES, Math.max(0, afterOrdinal - 1), sessionID, ...RAW_MESSAGE_TYPES, finalWatermark - 1, maximumSeq, sessionID, ...RAW_MESSAGE_TYPES, pageSize);
1376
+ const rows = this.prepare(V2_MESSAGE_PAGE_SQL).all(afterOrdinal, sessionID, ...RAW_MESSAGE_TYPES, Math.max(0, afterOrdinal - 1), sessionID, sessionID, ...RAW_MESSAGE_TYPES, finalWatermark - 1, maximumSeq, sessionID, ...RAW_MESSAGE_TYPES, pageSize);
1376
1377
  return rows.map(decode);
1377
1378
  });
1378
1379
  }
@@ -12991,6 +12992,37 @@ function capturePrefixTrimSourceOrder(messages) {
12991
12992
  invalidReason
12992
12993
  });
12993
12994
  }
12995
+ function reanchorStoredBoundary(options, boundary) {
12996
+ if (!options.messages)
12997
+ return;
12998
+ const source = options.prefixTrimSourceOrder ?? capturePrefixTrimSourceOrder(options.messages);
12999
+ if (source.invalidReason)
13000
+ return;
13001
+ try {
13002
+ if (compareRawSessionMessageOrder2(options.sessionId, boundary, boundary) !== 0)
13003
+ return;
13004
+ const messageIds = [...source.messageIds];
13005
+ let previous;
13006
+ let insertion = messageIds.length;
13007
+ for (const [index, id] of messageIds.entries()) {
13008
+ if (previous) {
13009
+ const increasing = compareRawSessionMessageOrder2(options.sessionId, previous, id);
13010
+ if (increasing === null || !Number.isFinite(increasing) || increasing >= 0)
13011
+ return;
13012
+ }
13013
+ const order = compareRawSessionMessageOrder2(options.sessionId, boundary, id);
13014
+ if (order === null || !Number.isFinite(order) || order === 0)
13015
+ return;
13016
+ if (order < 0 && insertion === messageIds.length)
13017
+ insertion = index;
13018
+ previous = id;
13019
+ }
13020
+ messageIds.splice(insertion, 0, boundary);
13021
+ return { ...source, messageIds };
13022
+ } catch {
13023
+ return;
13024
+ }
13025
+ }
12994
13026
  function trimToPreparedPrefix(options, prepared) {
12995
13027
  if (options.compactionOff || !options.messages)
12996
13028
  return "not-attempted";
@@ -13015,7 +13047,8 @@ function trimToPreparedPrefix(options, prepared) {
13015
13047
  });
13016
13048
  const boundaryPosition = sourcePosition.get(boundary) ?? sourcePosition.get(resolveHostServedBoundaryId2(options.sessionId, boundary));
13017
13049
  if (boundaryPosition === undefined) {
13018
- status = refuse("boundary absent from immutable source order");
13050
+ const reanchored = reanchorStoredBoundary(options, boundary);
13051
+ status = reanchored ? trimToPreparedPrefix({ ...options, prefixTrimSourceOrder: reanchored }, prepared) : refuse("boundary absent from immutable source order");
13019
13052
  } else {
13020
13053
  let lastSourcePosition = -1;
13021
13054
  let sawPersistedRow = false;
@@ -13026,8 +13059,7 @@ function trimToPreparedPrefix(options, prepared) {
13026
13059
  for (const [index, message] of options.messages.entries()) {
13027
13060
  const id = message.info.id;
13028
13061
  if (isHostRenderedSystemMessage(message)) {
13029
- if (lastSourcePosition >= boundaryPosition)
13030
- retained.push(message);
13062
+ retained.push(message);
13031
13063
  continue;
13032
13064
  }
13033
13065
  if (typeof id !== "string" || id.length === 0) {
@@ -13070,12 +13102,19 @@ function trimToPreparedPrefix(options, prepared) {
13070
13102
  } else {
13071
13103
  const index = findBoundaryIndex(options.sessionId, options.messages, boundary);
13072
13104
  if (index >= 0) {
13073
- const removed = options.messages.splice(0, index + (isPartialCompartmentEnd(options.db, options.sessionId, boundary) ? 0 : 1));
13105
+ const cut = index + (isPartialCompartmentEnd(options.db, options.sessionId, boundary) ? 0 : 1);
13106
+ const unplaced = options.messages.slice(0, cut).filter(isHostRenderedSystemMessage);
13107
+ const removed = options.messages.splice(0, cut, ...unplaced);
13074
13108
  retireDecisions(removed.map((message) => message.info.id).filter((id) => typeof id === "string"));
13075
13109
  resetPrefixTrimFallbackState(options.sessionId);
13076
13110
  status = "applied";
13077
13111
  } else {
13078
- status = classifyAbsentBoundary(options, options.messages, boundary);
13112
+ const reanchored = reanchorStoredBoundary(options, boundary);
13113
+ if (reanchored && reanchored.messageIds[0] !== boundary) {
13114
+ status = trimToPreparedPrefix({ ...options, prefixTrimSourceOrder: reanchored }, prepared);
13115
+ } else {
13116
+ status = classifyAbsentBoundary(options, options.messages, boundary);
13117
+ }
13079
13118
  }
13080
13119
  }
13081
13120
  }
@@ -18010,6 +18049,7 @@ Historian pass ${passCount + 1}, attempt ${passAttempt} started for messages ${c
18010
18049
  sequenceOffset: candidateCompartments.length,
18011
18050
  dumpLabelBase: `recomp-${sessionId}-${chunk.startIndex}-${chunk.endIndex}-pass-${passCount + 1}`,
18012
18051
  timeoutMs: historianTimeoutMs,
18052
+ maxOutputTokens: deps.historianMaxOutputTokens,
18013
18053
  model: deps.model,
18014
18054
  fallbackModelId: deps.fallbackModelId,
18015
18055
  fallbackModels: deps.fallbackModels,
@@ -18524,7 +18564,6 @@ ${renderUserFacingFailure("recomp_unavailable")}`;
18524
18564
  }
18525
18565
  }
18526
18566
  }
18527
-
18528
18567
  // src/hooks/magic-context/compartment-runner.ts
18529
18568
  var activeRuns = new Map;
18530
18569
  function getActiveCompartmentRun(sessionId) {
@@ -18560,7 +18599,7 @@ function withPublishedCallback(deps) {
18560
18599
  };
18561
18600
  }
18562
18601
  function startLeaseRenewal(deps, holderId) {
18563
- return setInterval(() => {
18602
+ return inRootAsyncContext2(() => setInterval(() => {
18564
18603
  try {
18565
18604
  if (!renewCompartmentLease(deps.db, deps.sessionId, holderId)) {
18566
18605
  sessionLog2(deps.sessionId, "compartment lease renewal failed; publish will be skipped if holder is stale");
@@ -18568,7 +18607,7 @@ function startLeaseRenewal(deps, holderId) {
18568
18607
  } catch (err) {
18569
18608
  sessionLog2(deps.sessionId, `compartment lease renewal threw; publish will be skipped if holder is stale (${err instanceof Error ? err.message : String(err)})`);
18570
18609
  }
18571
- }, COMPARTMENT_LEASE_RENEWAL_MS);
18610
+ }, COMPARTMENT_LEASE_RENEWAL_MS));
18572
18611
  }
18573
18612
  function startCompartmentAgent(deps, runAgent = runCompartmentAgent, prepareBoundary) {
18574
18613
  withoutSqliteTransformPass2(() => startBackgroundCompartmentAgent(deps, runAgent, prepareBoundary));
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./server-t4k4qexw.js";
3
+ } from "./server-9e5r8y60.js";
4
4
 
5
5
  // src/hooks/magic-context/read-session-formatting.ts
6
6
  import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sessionLog2
3
- } from "./server-t4k4qexw.js";
3
+ } from "./server-9e5r8y60.js";
4
4
  import {
5
5
  isKnownAutocommit
6
6
  } from "./server-8ajstryz.js";
@@ -1,6 +1,10 @@
1
1
  // src/shared/sqlite.ts
2
- import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
3
3
  import { statSync } from "node:fs";
4
+ var resourceRoot = new AsyncResource("magic-context:root");
5
+ function inRootAsyncContext2(operation) {
6
+ return resourceRoot.runInAsyncScope(operation);
7
+ }
4
8
  var reportSlowPrivilegedWrite;
5
9
  function registerSlowWriteReporter2(reporter) {
6
10
  reportSlowPrivilegedWrite = reporter;
@@ -191,7 +195,7 @@ function installTransactionRouting(db, readonly) {
191
195
  return endWriterTransaction(db, () => nativeExec(sql), sql);
192
196
  if (!/^\s*(?:SELECT|EXPLAIN|PRAGMA|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\b/i.test(sql)) {
193
197
  try {
194
- return withAutocommitTimeout(db, () => nativeExec(sql));
198
+ return withAutocommitTimeout(db, () => nativeExec(sql), false);
195
199
  } finally {
196
200
  if (mayChangeTagIdentity(sql))
197
201
  tagIdentityWriteGeneration += 1;
@@ -333,7 +337,7 @@ function trackSqliteConnection(db, filename, options) {
333
337
  }
334
338
  var TrackedDatabase = new Proxy(DatabaseImpl, {
335
339
  construct(target, args) {
336
- const db = Reflect.construct(target, args, target);
340
+ const db = inRootAsyncContext2(() => Reflect.construct(target, args, target));
337
341
  return trackSqliteConnection(db, args[0], args[1]);
338
342
  }
339
343
  });
@@ -577,29 +581,48 @@ function foregroundWaitLease() {
577
581
  const lease = transformPassScope.getStore();
578
582
  return lease?.active && !admissionScope.getStore() && !backgroundWriterScope.getStore() ? lease : undefined;
579
583
  }
580
- function withAutocommitTimeout(db, operation) {
584
+ function withAutocommitTimeout(db, operation, singleStatement = true) {
581
585
  assertTransformWrite2();
582
586
  const lease = foregroundWaitLease();
583
587
  if (isInTransaction(db))
584
588
  return operation();
585
589
  const scoped = lease || backgroundWriterScope.getStore();
586
590
  const previous = scoped ? pragmaNumber(db, "busy_timeout") : null;
587
- if (scoped)
588
- db.exec(`PRAGMA busy_timeout=${lease ? Math.floor(Math.min(lease.remainingWaitMs, lease.guard?.remainingMs() ?? Infinity)) : SHORT_BUSY_TIMEOUT_MS}`);
589
591
  const started = performance.now();
590
592
  let completed = false;
591
- try {
593
+ const execute = () => {
592
594
  const result = operation();
593
595
  completed = true;
594
596
  return result;
597
+ };
598
+ try {
599
+ if (!scoped)
600
+ return execute();
601
+ if (singleStatement) {
602
+ db.exec("PRAGMA busy_timeout=0");
603
+ try {
604
+ return execute();
605
+ } catch (error) {
606
+ if (!isTransientSqliteError2(error) || isInTransaction(db))
607
+ throw error;
608
+ }
609
+ assertTransformWrite2();
610
+ }
611
+ const timeout = Math.floor(Math.min(lease?.remainingWaitMs ?? SHORT_BUSY_TIMEOUT_MS, lease?.guard?.remainingMs() ?? Infinity));
612
+ db.exec(`PRAGMA busy_timeout=${timeout}`);
613
+ const waitStarted = performance.now();
614
+ try {
615
+ return execute();
616
+ } finally {
617
+ if (lease)
618
+ lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - (performance.now() - waitStarted));
619
+ }
595
620
  } catch (error) {
596
621
  if (lease && isTransientSqliteError2(error))
597
622
  throw new SqliteAcquisitionBusyError2(error, "autocommit");
598
623
  throw error;
599
624
  } finally {
600
625
  const elapsed = performance.now() - started;
601
- if (lease)
602
- lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - elapsed);
603
626
  if (previous !== null)
604
627
  db.exec(`PRAGMA busy_timeout=${previous}`);
605
628
  if (elapsed >= SLOW_WRITER_LOG_MS)
@@ -859,4 +882,4 @@ async function yieldIndexChunk2() {
859
882
  await yieldIndexTurn();
860
883
  }
861
884
 
862
- export { registerSlowWriteReporter2, registerSqliteDiagnosticSink2, detectSqliteRuntime2, getTagIdentityWriteGeneration2, Database2, getSqliteDatabasePath2, getSqliteMemoryStats2, prepareCachedStatement2, withSqliteBackgroundWriter2, withSqliteTransformPass2, withoutSqliteTransformPass2, assertTransformWrite2, isTransientSqliteError2, SqliteAcquisitionBusyError2, beginSqliteWriterAsync2, withAsyncPrivilegedWriter2, withPrivilegedWriter2, indexCoordinationInput2, releaseIndexOwner2, withIndexChunk2, yieldIndexChunk2 };
885
+ export { inRootAsyncContext2, registerSlowWriteReporter2, registerSqliteDiagnosticSink2, detectSqliteRuntime2, getTagIdentityWriteGeneration2, Database2, getSqliteDatabasePath2, getSqliteMemoryStats2, prepareCachedStatement2, withSqliteBackgroundWriter2, withSqliteTransformPass2, withoutSqliteTransformPass2, assertTransformWrite2, isTransientSqliteError2, SqliteAcquisitionBusyError2, beginSqliteWriterAsync2, withAsyncPrivilegedWriter2, withPrivilegedWriter2, indexCoordinationInput2, releaseIndexOwner2, withIndexChunk2, yieldIndexChunk2 };