@cortexkit/opencode-magic-context 0.49.86 → 0.49.89

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 (182) hide show
  1. package/dist/{announcement-fnyxaahs.js → announcement-4ynkaf0d.js} +2 -2
  2. package/dist/auto-search-worker.js +13 -7
  3. package/dist/chunk-embedding-write-worker.js +7 -7
  4. package/dist/{compartment-chunk-embedding-ymc9mtwv.js → compartment-chunk-embedding-fey2bsyf.js} +3 -1
  5. package/dist/{conflict-warning-hook-a0wrnzch.js → conflict-warning-hook-kbq6ppjf.js} +2 -2
  6. package/dist/{context-xesm7rj3.js → context-grdg1k2k.js} +132 -52
  7. package/dist/{derive-budgets-90869322.js → derive-budgets-hzzq71rm.js} +2 -2
  8. package/dist/{embedding-backfill-v6sw58m8.js → embedding-backfill-qjkaee9s.js} +8 -8
  9. package/dist/{v2/embedding-cache-mgyr73ef.js → embedding-cache-zn4r1c31.js} +5 -1
  10. package/dist/embedding-worker.js +2 -2
  11. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -0
  12. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  13. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/token-budget.d.ts +8 -3
  15. package/dist/features/magic-context/dreamer/token-budget.d.ts.map +1 -1
  16. package/dist/features/magic-context/memory/embedding-cache.d.ts +7 -0
  17. package/dist/features/magic-context/memory/embedding-cache.d.ts.map +1 -1
  18. package/dist/features/magic-context/search.d.ts +6 -0
  19. package/dist/features/magic-context/search.d.ts.map +1 -1
  20. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  21. package/dist/features/magic-context/tool-definition-tokens.d.ts +2 -0
  22. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/auto-search-worker-probe.fixture.d.ts +2 -0
  25. package/dist/hooks/magic-context/auto-search-worker-probe.fixture.d.ts.map +1 -0
  26. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/compartment-runner-recomp-carry.d.ts +4 -0
  28. package/dist/hooks/magic-context/compartment-runner-recomp-carry.d.ts.map +1 -0
  29. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts +8 -2
  30. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/emergency-fail-closed.d.ts +2 -0
  33. package/dist/hooks/magic-context/emergency-fail-closed.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -5
  35. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/send-session-notification.d.ts +11 -1
  37. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/transform.d.ts +1 -0
  39. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  40. package/dist/{index-s8ks5nz4.js → index-2pdgy88n.js} +5 -5
  41. package/dist/{index-7j2zv9nm.js → index-2qsca7h7.js} +47 -11
  42. package/dist/{index-1bqkqde0.js → index-39rzef89.js} +9 -7
  43. package/dist/{index-snbpdpa3.js → index-3pdknr07.js} +4 -4
  44. package/dist/{index-c5tmzym6.js → index-5df2fw5b.js} +108 -13
  45. package/dist/{index-7svecf3m.js → index-5pgyqgmx.js} +1 -1
  46. package/dist/{index-xrnhxkz7.js → index-60wnwcwz.js} +1 -1
  47. package/dist/{index-k50xhjw1.js → index-60x5d68t.js} +1 -1
  48. package/dist/{index-4ntnt8ee.js → index-61knrt52.js} +1 -1
  49. package/dist/{index-g6hfh4h4.js → index-6zewd2n5.js} +14 -8
  50. package/dist/{index-70cv85b0.js → index-78t37mcq.js} +2 -2
  51. package/dist/{index-stx8zd81.js → index-83qd3n7s.js} +2 -2
  52. package/dist/{index-nny4gm06.js → index-9d3qgwq0.js} +2 -2
  53. package/dist/{index-jjvbk92s.js → index-9emdjcb5.js} +1 -1
  54. package/dist/{index-05bm2ndp.js → index-chpzb6xy.js} +1 -1
  55. package/dist/{index-2kf73btc.js → index-cr483vx6.js} +1 -1
  56. package/dist/{index-d0rtbv0f.js → index-dk3hy2a2.js} +21 -14
  57. package/dist/{index-gxdc95cp.js → index-g0mb2kb4.js} +585 -82
  58. package/dist/{index-w6v4dw5f.js → index-h9hybzr5.js} +5 -5
  59. package/dist/{index-1pf5qrx4.js → index-jzfsnbmm.js} +3 -3
  60. package/dist/{index-jrj95cce.js → index-m6dnydf8.js} +9 -2
  61. package/dist/{index-xccywqdj.js → index-mrjat4eq.js} +77 -14
  62. package/dist/{index-022w6314.js → index-n1ty0vd3.js} +116 -512
  63. package/dist/{index-ttk3trse.js → index-q7msfgwz.js} +311 -111
  64. package/dist/{index-e32b3x4n.js → index-qfcjrnpe.js} +7 -6
  65. package/dist/{v2/server-4dhv7mqz.js → index-qjwpqvnf.js} +48 -1
  66. package/dist/{index-3dtzyred.js → index-r4y0dczp.js} +1 -1
  67. package/dist/{index-4w5rx7de.js → index-tt0vs4x5.js} +2 -2
  68. package/dist/{index-k0tb2z28.js → index-w51n3576.js} +2 -2
  69. package/dist/{index-25nktq8n.js → index-wmb2mcdw.js} +7 -7
  70. package/dist/{index-zmqx48vt.js → index-xsqw8kbd.js} +1 -1
  71. package/dist/{index-fzgyvsb1.js → index-y14pawe1.js} +3 -0
  72. package/dist/{index-798s7c8s.js → index-zxhev8ze.js} +2 -2
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +68 -59
  75. package/dist/{message-index-bounded-6fr624zf.js → message-index-bounded-r1qys471.js} +4 -4
  76. package/dist/migration-worker.js +5 -5
  77. package/dist/plugin/messages-transform.d.ts +3 -4
  78. package/dist/plugin/messages-transform.d.ts.map +1 -1
  79. package/dist/plugin/refusal-notice.d.ts +3 -0
  80. package/dist/plugin/refusal-notice.d.ts.map +1 -0
  81. package/dist/{project-embedding-registry-q80scexh.js → project-embedding-registry-m3fp1pa4.js} +7 -7
  82. package/dist/raw-ordinal-warmup-worker.js +4 -4
  83. package/dist/{read-session-chunk-6wedfths.js → read-session-chunk-xv9f0wgb.js} +3 -3
  84. package/dist/{recomp-orchestrator-7ecg8ryx.js → recomp-orchestrator-dgyb394j.js} +23 -23
  85. package/dist/{render-yqp7q79f.js → render-d014e603.js} +12 -12
  86. package/dist/{rpc-notifications-t9q0ynq7.js → rpc-notifications-ta2zsxpq.js} +1 -1
  87. package/dist/{search-bw22d7zc.js → search-9gceftb9.js} +18 -18
  88. package/dist/{search-archive-r4h96j2z.js → search-archive-gybn6q7s.js} +5 -5
  89. package/dist/{send-session-notification-7x518gew.js → send-session-notification-gzxz88vq.js} +1 -1
  90. package/dist/shared/assistant-message-extractor.d.ts +2 -0
  91. package/dist/shared/assistant-message-extractor.d.ts.map +1 -1
  92. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  93. package/dist/shared/recomp-outcome.d.ts +4 -0
  94. package/dist/shared/recomp-outcome.d.ts.map +1 -0
  95. package/dist/shared/rpc-notifications.d.ts +1 -1
  96. package/dist/shared/rpc-notifications.d.ts.map +1 -1
  97. package/dist/shared/storage-permissions.d.ts +16 -2
  98. package/dist/shared/storage-permissions.d.ts.map +1 -1
  99. package/dist/shared/user-facing-codes.d.ts +4 -1
  100. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  101. package/dist/{storage-memory-e6a7mb0k.js → storage-memory-hhrvfw0x.js} +2 -2
  102. package/dist/{storage-tags-y2mrb8e6.js → storage-tags-f1ftvjpw.js} +2 -2
  103. package/dist/{transform-postprocess-phase-t99yj9vt.js → transform-postprocess-phase-34k1zwsy.js} +24 -24
  104. package/dist/v2/auto-search-worker.js +13 -7
  105. package/dist/v2/chunk-embedding-write-worker.js +7 -7
  106. package/dist/v2/{compartment-chunk-embedding-x6qw6mjk.js → compartment-chunk-embedding-knt2468v.js} +3 -1
  107. package/dist/v2/{context-k8sx1nyy.js → context-8bzydxfy.js} +227 -70
  108. package/dist/v2/{derive-budgets-ecjy1aqh.js → derive-budgets-hr4qqrnv.js} +3 -3
  109. package/dist/v2/{embedding-backfill-k8kqnwfq.js → embedding-backfill-0ar1bm97.js} +8 -8
  110. package/dist/{embedding-cache-mgyr73ef.js → v2/embedding-cache-zn4r1c31.js} +5 -1
  111. package/dist/v2/embedding-worker.js +2 -2
  112. package/dist/v2/fold/native-replay.d.ts +3 -1
  113. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  114. package/dist/v2/hidden-child-record.d.ts +1 -0
  115. package/dist/v2/hidden-child-record.d.ts.map +1 -1
  116. package/dist/v2/hidden-completion.d.ts.map +1 -1
  117. package/dist/v2/hooks/context.d.ts.map +1 -1
  118. package/dist/v2/{message-index-bounded-jqy7283g.js → message-index-bounded-b07r9cjv.js} +4 -4
  119. package/dist/v2/migration-worker.js +5 -5
  120. package/dist/v2/{project-embedding-registry-2jp1antr.js → project-embedding-registry-gx2waee8.js} +7 -7
  121. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  122. package/dist/v2/{read-session-chunk-n3nhfvd7.js → read-session-chunk-38wdy8nd.js} +3 -3
  123. package/dist/v2/{recomp-orchestrator-ssde9ft1.js → recomp-orchestrator-wq7gbkqa.js} +24 -24
  124. package/dist/v2/{render-fezgh7pa.js → render-2dan17xc.js} +12 -12
  125. package/dist/v2/{rpc-notifications-t9q0ynq7.js → rpc-notifications-ta2zsxpq.js} +1 -1
  126. package/dist/v2/{search-archive-zz1kza50.js → search-archive-89hdy0a2.js} +5 -5
  127. package/dist/v2/{search-m251amra.js → search-nyqykx7q.js} +17 -17
  128. package/dist/v2/{send-session-notification-p52rhjzy.js → send-session-notification-zazaxxpf.js} +1 -1
  129. package/dist/v2/{server-4wwwm2ya.js → server-09h2vyvs.js} +5 -5
  130. package/dist/v2/{server-r2es6zt7.js → server-0tv6kytx.js} +108 -13
  131. package/dist/v2/{server-rz4snd3x.js → server-1rrmxhd1.js} +1 -1
  132. package/dist/v2/{server-wdq85mxj.js → server-6250cxzs.js} +14 -8
  133. package/dist/v2/{server-xa8fefhw.js → server-96nm9vk4.js} +1 -1
  134. package/dist/v2/{server-jjvbk92s.js → server-9emdjcb5.js} +1 -1
  135. package/dist/v2/{server-ap81bk3c.js → server-9n2qgk29.js} +1 -1
  136. package/dist/v2/{server-ps6rz88g.js → server-a85j3kam.js} +2 -2
  137. package/dist/v2/{server-y31y6gws.js → server-add0j5n3.js} +9 -7
  138. package/dist/v2/{server-97w51d8n.js → server-b0a9h3ds.js} +3 -3
  139. package/dist/v2/{server-2k8tkbhz.js → server-c7awk5s2.js} +10 -4
  140. package/dist/v2/{server-hn8b7sfe.js → server-dgjqvpgd.js} +5 -5
  141. package/dist/v2/{server-fsw8kbng.js → server-dtcwkdqj.js} +314 -114
  142. package/dist/v2/{server-mbkwcwgw.js → server-f7tzvmzs.js} +2 -2
  143. package/dist/v2/{server-n5zr7190.js → server-fb5hvvfc.js} +77 -14
  144. package/dist/v2/{server-w7mpvkpj.js → server-fn4ky6mn.js} +1 -1
  145. package/dist/v2/{server-3p6b0qya.js → server-gqkdfdvw.js} +1 -1
  146. package/dist/v2/{server-cwtehwbb.js → server-j4jjtdc5.js} +1 -1
  147. package/dist/v2/{server-b93f0bqh.js → server-pjk9spbf.js} +1 -1
  148. package/dist/v2/{server-s15knz0w.js → server-pmws7we9.js} +1 -1
  149. package/dist/{index-4dhv7mqz.js → v2/server-qjwpqvnf.js} +48 -1
  150. package/dist/v2/{server-a2f1bhyj.js → server-stjy5dxv.js} +9 -2
  151. package/dist/v2/{server-ssg29wjg.js → server-ta4h0fch.js} +21 -14
  152. package/dist/v2/{server-e2k9mt86.js → server-tj65pgvg.js} +1 -1
  153. package/dist/v2/{server-brgandk4.js → server-vy0beygw.js} +2 -2
  154. package/dist/v2/{server-fzgyvsb1.js → server-y14pawe1.js} +3 -0
  155. package/dist/v2/{server-8pdfmc27.js → server-y17r5ryz.js} +4 -4
  156. package/dist/v2/{server-sxfbjdye.js → server-yx0nyj1q.js} +2 -2
  157. package/dist/v2/server.js +6 -6
  158. package/dist/v2/{storage-memory-e6a7mb0k.js → storage-memory-hhrvfw0x.js} +2 -2
  159. package/dist/v2/{storage-tags-xq81zgt2.js → storage-tags-pmw33chf.js} +2 -2
  160. package/dist/v2/{v2-archive-reader-e2w39c3p.js → v2-archive-reader-gh1jghf7.js} +1 -1
  161. package/dist/v2/{wrapup-orchestrator-eg5b1p89.js → wrapup-orchestrator-2h7ayss9.js} +24 -24
  162. package/dist/{v2-archive-reader-8dsngf2j.js → v2-archive-reader-8158kyfd.js} +1 -1
  163. package/dist/{wrapup-orchestrator-nmk6yf7f.js → wrapup-orchestrator-ct59br0c.js} +24 -24
  164. package/package.json +1 -1
  165. package/src/shared/assistant-message-extractor.test.ts +22 -0
  166. package/src/shared/assistant-message-extractor.ts +13 -0
  167. package/src/shared/model-suggestion-retry.test.ts +43 -12
  168. package/src/shared/prompt-async-transport.test.ts +275 -8
  169. package/src/shared/prompt-async-transport.ts +41 -2
  170. package/src/shared/recomp-outcome.ts +8 -0
  171. package/src/shared/reusable-worker.fixture.ts +15 -3
  172. package/src/shared/reusable-worker.test.ts +20 -10
  173. package/src/shared/rpc-notifications.ts +4 -1
  174. package/src/shared/sqlite-foreground-wait.test.ts +2 -2
  175. package/src/shared/startup-maintenance-policy.test.ts +4 -2
  176. package/src/shared/storage-permissions-startup.test.ts +296 -6
  177. package/src/shared/storage-permissions.ts +143 -18
  178. package/src/shared/user-facing-codes.ts +5 -2
  179. package/src/tui/dialogs/status-dialog.tsx +3 -0
  180. package/src/tui/slots/sidebar-content.tsx +6 -2
  181. package/src/tui-compiled/dialogs/status-dialog.tsx +12 -0
  182. package/src/tui-compiled/slots/sidebar-content.tsx +7 -2
@@ -5,8 +5,8 @@ import {
5
5
  readLastAnnouncedVersion2,
6
6
  markAnnouncementSeen2,
7
7
  shouldShowAnnouncement2
8
- } from "./index-2kf73btc.js";
9
- import"./index-c5tmzym6.js";
8
+ } from "./index-cr483vx6.js";
9
+ import"./index-5df2fw5b.js";
10
10
  import"./index-gqf8r04r.js";
11
11
  import"./index-ywrz4wy2.js";
12
12
  import"./index-pavzsdc6.js";
@@ -17,7 +17,7 @@ serveWorkerJobs(async (initial, port) => {
17
17
  }
18
18
  const [
19
19
  { ensureMemoryEmbeddings },
20
- { getProjectEmbeddings },
20
+ { getProjectEmbeddings, keepWorkerMemoryEmbeddings, maintainKeptWorkerMemoryEmbeddings },
21
21
  { getMemoriesByProject },
22
22
  { installProjectEmbeddingSearchBridge },
23
23
  { searchMessageHistory, unifiedSearch },
@@ -27,12 +27,12 @@ serveWorkerJobs(async (initial, port) => {
27
27
  { Database, registerSqliteDiagnosticSink },
28
28
  { log }
29
29
  ] = await Promise.all([
30
- import("./embedding-backfill-v6sw58m8.js"),
31
- import("./embedding-cache-mgyr73ef.js"),
32
- import("./storage-memory-e6a7mb0k.js"),
33
- import("./project-embedding-registry-q80scexh.js"),
34
- import("./search-bw22d7zc.js"),
35
- import("./compartment-chunk-embedding-ymc9mtwv.js"),
30
+ import("./embedding-backfill-qjkaee9s.js"),
31
+ import("./embedding-cache-zn4r1c31.js"),
32
+ import("./storage-memory-hhrvfw0x.js"),
33
+ import("./project-embedding-registry-m3fp1pa4.js"),
34
+ import("./search-9gceftb9.js"),
35
+ import("./compartment-chunk-embedding-fey2bsyf.js"),
36
36
  import("./embedding-activity-g1dhes6g.js"),
37
37
  import("./harness-e4avh192.js"),
38
38
  import("./sqlite-zdgm52sv.js"),
@@ -64,6 +64,8 @@ serveWorkerJobs(async (initial, port) => {
64
64
  }
65
65
  db = new Database(input.path, input.job === "backfill" ? undefined : { readonly: true });
66
66
  db.exec("PRAGMA busy_timeout = 250");
67
+ if (persistent && input.job === "search")
68
+ keepWorkerMemoryEmbeddings(db);
67
69
  const { closePort } = exitOnWorkerClose(port, () => db.close());
68
70
  const CHUNK_POOL_MAINTENANCE_INTERVAL_MS = 5000;
69
71
  let maintenanceTimer;
@@ -72,6 +74,9 @@ serveWorkerJobs(async (initial, port) => {
72
74
  if (maintaining)
73
75
  return;
74
76
  maintaining = true;
77
+ try {
78
+ maintainKeptWorkerMemoryEmbeddings(db);
79
+ } catch {}
75
80
  maintainCompartmentChunkSearchPools(db).catch(() => {}).finally(() => {
76
81
  maintaining = false;
77
82
  });
@@ -135,6 +140,7 @@ serveWorkerJobs(async (initial, port) => {
135
140
  const diagnostics = input.options.autoSearchDiagnostics;
136
141
  const results = await unifiedSearch(db, input.sessionId, input.projectPath, input.query, {
137
142
  ...input.options,
143
+ deferChunkPoolWarmup: persistent,
138
144
  backfillMemoryEmbeddings: false,
139
145
  countRetrievals: false,
140
146
  measurementDisabled: true,
@@ -24,23 +24,23 @@ import {
24
24
  recordChunkEmbedBackoff2,
25
25
  loadUnembeddedSessionChunkCandidates2,
26
26
  countUnembeddedSessionCompartments2
27
- } from "./index-snbpdpa3.js";
27
+ } from "./index-3pdknr07.js";
28
28
  import {
29
29
  recordSessionProjectIdentity,
30
30
  acquireGitSweepLease,
31
31
  renewGitSweepLease,
32
32
  releaseGitSweepLease
33
- } from "./index-3dtzyred.js";
33
+ } from "./index-r4y0dczp.js";
34
34
  import"./index-gqf8r04r.js";
35
- import"./index-c5tmzym6.js";
36
- import"./index-7svecf3m.js";
35
+ import"./index-5df2fw5b.js";
36
+ import"./index-5pgyqgmx.js";
37
37
  import {
38
38
  LATEST_SUPPORTED_VERSION,
39
39
  enforceSchemaFence
40
- } from "./index-xccywqdj.js";
40
+ } from "./index-mrjat4eq.js";
41
41
  import"./index-wh9fxds5.js";
42
- import"./index-4w5rx7de.js";
43
- import"./index-jrj95cce.js";
42
+ import"./index-tt0vs4x5.js";
43
+ import"./index-m6dnydf8.js";
44
44
  import"./index-fr0wbhdn.js";
45
45
  import"./index-58e3y90n.js";
46
46
  import"./index-m0pwswv9.js";
@@ -9,6 +9,7 @@ import {
9
9
  chunkEmbeddingWindowsAreCurrent2,
10
10
  replaceCompartmentChunkEmbeddings2,
11
11
  loadCompartmentChunkEmbeddingsForSearch2,
12
+ trackCompartmentChunkSearchPool2,
12
13
  getLastCompartmentChunkPoolWarm2,
13
14
  peekCompartmentChunkSearchPool2,
14
15
  warmCompartmentChunkSearchPool2,
@@ -24,7 +25,7 @@ import {
24
25
  countSessionCompartmentEmbedCoverage2,
25
26
  countSessionCompartmentEmbedCoveragePolite2,
26
27
  countUnembeddedSessionCompartmentsPolite2
27
- } from "./index-snbpdpa3.js";
28
+ } from "./index-3pdknr07.js";
28
29
  import"./index-pxnzyvjc.js";
29
30
  import"./index-s32f8y67.js";
30
31
  import"./index-q7q6qp1f.js";
@@ -62,5 +63,6 @@ export {
62
63
  peekCompartmentChunkSearchPool2 as peekCompartmentChunkSearchPool,
63
64
  recordChunkEmbedBackoff2 as recordChunkEmbedBackoff,
64
65
  replaceCompartmentChunkEmbeddings2 as replaceCompartmentChunkEmbeddings,
66
+ trackCompartmentChunkSearchPool2 as trackCompartmentChunkSearchPool,
65
67
  warmCompartmentChunkSearchPool2 as warmCompartmentChunkSearchPool
66
68
  };
@@ -4,10 +4,10 @@ import {
4
4
  cleanupConflictWarnings2,
5
5
  sendSchemaFenceWarning2,
6
6
  sendStartupAnnouncement2
7
- } from "./index-stx8zd81.js";
7
+ } from "./index-83qd3n7s.js";
8
8
  import"./index-nxxzeq4y.js";
9
9
  import"./index-sd3egckz.js";
10
- import"./index-g6hfh4h4.js";
10
+ import"./index-6zewd2n5.js";
11
11
  import"./index-qt1qqasc.js";
12
12
  import"./index-x40zr813.js";
13
13
  import"./index-e6ncz7a6.js";
@@ -44,7 +44,7 @@ import {
44
44
  resolveOpenCodeProtectedTailBoundary,
45
45
  nonNarrativeStoredGapRanges,
46
46
  getActiveCompartmentRun
47
- } from "./index-ttk3trse.js";
47
+ } from "./index-q7msfgwz.js";
48
48
  import"./index-sd3egckz.js";
49
49
  import {
50
50
  getHarness2
@@ -57,7 +57,7 @@ import {
57
57
  } from "./index-ywrz4wy2.js";
58
58
  import"./index-z4p0ry94.js";
59
59
  import"./index-gqf8r04r.js";
60
- import"./index-c5tmzym6.js";
60
+ import"./index-5df2fw5b.js";
61
61
  import {
62
62
  isSaneLimit,
63
63
  setOutputReserveConfig,
@@ -68,7 +68,7 @@ import {
68
68
  deriveHistorianChunkTokens2,
69
69
  resolveKnownHistorianContextLimit2,
70
70
  resolveHistorianContextLimit2
71
- } from "./index-zmqx48vt.js";
71
+ } from "./index-xsqw8kbd.js";
72
72
  import"./index-6nqz8hsz.js";
73
73
  import {
74
74
  CANONICAL_DREAM_TASKS,
@@ -91,11 +91,6 @@ import {
91
91
  startDreamScheduleTimer,
92
92
  createDreamTimerModuleClient,
93
93
  ensureProjectRegisteredFromOpenCodeDirectory,
94
- resolveContextLimit,
95
- resolveModelKey,
96
- parseCacheTtl,
97
- createScheduler,
98
- computeHardCacheExpired,
99
94
  describeStorageUnavailability,
100
95
  getSessionErrorInfo,
101
96
  summarizeManualDream,
@@ -118,6 +113,7 @@ import {
118
113
  isClearlyOverWindow,
119
114
  UnmanagedOverWindowError,
120
115
  UnresolvedHistoryBoundaryError,
116
+ rendersCompartmentHistory,
121
117
  createTransform,
122
118
  createSubcModuleClient,
123
119
  createModuleToolBackends,
@@ -140,7 +136,7 @@ import {
140
136
  applyJsonSchemaParameterDescriptions,
141
137
  MagicContextRpcServer,
142
138
  subagentTemperature
143
- } from "./index-022w6314.js";
139
+ } from "./index-n1ty0vd3.js";
144
140
  import {
145
141
  invalidateAutoEmbedSession,
146
142
  clearEmbedSessionState
@@ -165,7 +161,7 @@ import"./index-q7q6qp1f.js";
165
161
  import"./index-s32f8y67.js";
166
162
  import {
167
163
  deleteChunkEmbedBackoffForSession2
168
- } from "./index-snbpdpa3.js";
164
+ } from "./index-3pdknr07.js";
169
165
  import {
170
166
  advanceSessionActivity,
171
167
  backfillSessionActivity,
@@ -202,8 +198,8 @@ import {
202
198
  getSlot,
203
199
  dropSlot,
204
200
  copySessionStateForClone
205
- } from "./index-w6v4dw5f.js";
206
- import"./index-05bm2ndp.js";
201
+ } from "./index-h9hybzr5.js";
202
+ import"./index-chpzb6xy.js";
207
203
  import {
208
204
  stripPersistedAssistantText,
209
205
  currentReclaimableToolOutputCount,
@@ -245,13 +241,13 @@ import {
245
241
  estimateFinalWireInputTokens,
246
242
  getMaxTagNumberBySession2,
247
243
  getTagsBySession2
248
- } from "./index-xrnhxkz7.js";
244
+ } from "./index-60wnwcwz.js";
249
245
  import {
250
246
  BoundedSessionMap,
251
247
  getTableColumnNames,
252
248
  recordToolDefinitionSet,
253
249
  getCurrentToolSetHash
254
- } from "./index-jrj95cce.js";
250
+ } from "./index-m6dnydf8.js";
255
251
  import {
256
252
  resolveHistorianModel2
257
253
  } from "./index-5kym00ag.js";
@@ -267,7 +263,7 @@ import {
267
263
  setHomeProjectPermission,
268
264
  resolveProjectIdentityForSession,
269
265
  scheduleAfterBootQuiet
270
- } from "./index-7svecf3m.js";
266
+ } from "./index-5pgyqgmx.js";
271
267
  import"./index-1zx87sdm.js";
272
268
  import"./index-58e3y90n.js";
273
269
  import"./index-x40zr813.js";
@@ -283,10 +279,10 @@ import {
283
279
  cleanUserText2,
284
280
  readRawSessionMessageIdOrdinalsForRange2,
285
281
  readRawSessionMessageOrdinalById2
286
- } from "./index-7j2zv9nm.js";
282
+ } from "./index-2qsca7h7.js";
287
283
  import {
288
284
  scheduleClearAndReindex
289
- } from "./index-798s7c8s.js";
285
+ } from "./index-zxhev8ze.js";
290
286
  import {
291
287
  startBootDeadline,
292
288
  getSchemaFenceRejection,
@@ -296,9 +292,9 @@ import {
296
292
  openDatabaseAsync,
297
293
  isDatabasePersisted,
298
294
  getDatabasePersistenceError
299
- } from "./index-xccywqdj.js";
295
+ } from "./index-mrjat4eq.js";
300
296
  import"./index-fr0wbhdn.js";
301
- import"./index-4w5rx7de.js";
297
+ import"./index-tt0vs4x5.js";
302
298
  import {
303
299
  gaDatabasePath2,
304
300
  RAW_MESSAGE_TYPES2,
@@ -306,8 +302,13 @@ import {
306
302
  V2StoreReader2
307
303
  } from "./index-1y4y98r1.js";
308
304
  import"./index-fb3zxn06.js";
309
- import"./index-4ntnt8ee.js";
305
+ import"./index-61knrt52.js";
310
306
  import {
307
+ resolveContextLimit,
308
+ resolveModelKey,
309
+ parseCacheTtl,
310
+ createScheduler,
311
+ computeHardCacheExpired,
311
312
  createTagger,
312
313
  cavemanWordRulesForLanguage,
313
314
  setCtxReduceRegisteredGlobally,
@@ -319,31 +320,31 @@ import {
319
320
  servedHeadChanged,
320
321
  noteHostCheckpointCommit,
321
322
  isSyntheticHeadMessage2
322
- } from "./index-gxdc95cp.js";
323
+ } from "./index-g0mb2kb4.js";
323
324
  import"./index-832w615x.js";
324
325
  import"./index-qt1qqasc.js";
325
326
  import {
326
327
  retainProjectEmbedding2
327
- } from "./index-s8ks5nz4.js";
328
- import"./index-3dtzyred.js";
329
- import"./index-4dhv7mqz.js";
330
- import"./index-k50xhjw1.js";
328
+ } from "./index-2pdgy88n.js";
329
+ import"./index-r4y0dczp.js";
330
+ import"./index-qjwpqvnf.js";
331
+ import"./index-60x5d68t.js";
331
332
  import {
332
333
  renderUserFacingFailure,
333
334
  userFacingFailureCode
334
- } from "./index-1bqkqde0.js";
335
- import"./index-k0tb2z28.js";
336
- import"./index-jjvbk92s.js";
335
+ } from "./index-39rzef89.js";
336
+ import"./index-w51n3576.js";
337
+ import"./index-9emdjcb5.js";
337
338
  import {
338
339
  pushLiveNotification2,
339
340
  pushNotification2,
340
341
  isTuiConnected2
341
- } from "./index-fzgyvsb1.js";
342
+ } from "./index-y14pawe1.js";
342
343
  import"./index-e6ncz7a6.js";
343
- import"./index-g6hfh4h4.js";
344
- import"./index-d0rtbv0f.js";
345
- import"./index-e32b3x4n.js";
346
- import"./index-2kf73btc.js";
344
+ import"./index-6zewd2n5.js";
345
+ import"./index-dk3hy2a2.js";
346
+ import"./index-qfcjrnpe.js";
347
+ import"./index-cr483vx6.js";
347
348
  import {
348
349
  detectConflicts
349
350
  } from "./index-nxxzeq4y.js";
@@ -374,10 +375,10 @@ import {
374
375
  createV2RawMessageProvider2
375
376
  } from "./index-08jfpny9.js";
376
377
  import"./index-fmsr7v69.js";
377
- import"./index-70cv85b0.js";
378
+ import"./index-78t37mcq.js";
378
379
  import"./index-52x68mj4.js";
379
- import"./index-1pf5qrx4.js";
380
- import"./index-nny4gm06.js";
380
+ import"./index-jzfsnbmm.js";
381
+ import"./index-9d3qgwq0.js";
381
382
  import {
382
383
  isDreamerRunnable,
383
384
  isSmartNoteSurfaceAvailable,
@@ -386,6 +387,7 @@ import {
386
387
  import {
387
388
  markHostInstructionRow,
388
389
  hostInstructionRow,
390
+ hostInstructionRowID,
389
391
  markRetiredInstructionRow,
390
392
  markCoveredInstructionRow,
391
393
  isCoveredInstructionRow
@@ -2527,12 +2529,14 @@ ${cached}
2527
2529
  }
2528
2530
  return true;
2529
2531
  }
2530
- async restorationFloor(sessionID, _cut, reader) {
2532
+ async restorationFloor(sessionID, _cut, reader, options) {
2531
2533
  if (this.options.protocol !== 3)
2532
2534
  return;
2533
2535
  const replay = await this.floorState(sessionID, reader);
2534
2536
  if (replay)
2535
2537
  return replay.floor.after;
2538
+ if (options?.allowMissingFloor)
2539
+ return;
2536
2540
  const current = await this.admissions?.get(this.admissionKey(sessionID));
2537
2541
  const legacy = await this.admissions?.get(admissionKey(sessionID));
2538
2542
  if (current || legacy?.payload) {
@@ -4192,6 +4196,22 @@ function sumRowUsage(rows) {
4192
4196
  ...total.reasoning !== undefined || row.data.tokens?.reasoning !== undefined ? { reasoning: (total.reasoning ?? 0) + count(row.data.tokens?.reasoning) } : {}
4193
4197
  }), { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
4194
4198
  }
4199
+ function isLengthCapped(row) {
4200
+ return row.data.finish === "length" || row.data.finish === "max_tokens";
4201
+ }
4202
+ var OUTPUT_LIMIT_CONTINUATION_TEXT = "Your last response hit the output token limit (stop reason: length). Do not apologize, recap, or repeat yourself. Break the remaining work into smaller pieces.";
4203
+ function outputLimitChainStart(rows, finalSeq) {
4204
+ let firstSeq = finalSeq;
4205
+ for (let i = rows.findIndex((row) => row.seq === finalSeq);i >= 2; i -= 2) {
4206
+ const instruction = rows[i - 1];
4207
+ const prior = rows[i - 2];
4208
+ if (instruction?.type !== "synthetic" || instruction.data.text !== OUTPUT_LIMIT_CONTINUATION_TEXT || prior?.type !== "assistant" || !isLengthCapped(prior) || prior.data.content?.some((part) => part.type === "tool" || part.type === "tool-call" || part.type === "tool-result")) {
4209
+ break;
4210
+ }
4211
+ firstSeq = prior.seq;
4212
+ }
4213
+ return firstSeq;
4214
+ }
4195
4215
  function toolLoopMessages(attempt, rows) {
4196
4216
  const messages = attempt.observedMessages ?? [];
4197
4217
  const results = new Map;
@@ -4324,6 +4344,10 @@ async function awaitAssistantRow(openReader, readSessionError, localFailure, chi
4324
4344
  throw refused;
4325
4345
  if (newIdle && (!newAssistant || newIdle.seq > newAssistant.seq)) {
4326
4346
  const outcome = newIdle.data.outcome;
4347
+ const error = newIdle.data.error;
4348
+ if (outcome === "failed" && newAssistant && isLengthCapped(newAssistant) && error && typeof error === "object" && "type" in error && error.type === "output-limit") {
4349
+ return { row: newAssistant, outputLimit: true };
4350
+ }
4327
4351
  if (outcome === "failed" || outcome === "interrupted") {
4328
4352
  const sessionError = await readSessionError() ?? newAssistant?.data.error;
4329
4353
  const details = [
@@ -4336,7 +4360,7 @@ async function awaitAssistantRow(openReader, readSessionError, localFailure, chi
4336
4360
  }) : new HiddenProviderError(details.join("; "), { hostError: sessionError });
4337
4361
  }
4338
4362
  if (outcome === "succeeded" && newAssistant)
4339
- return newAssistant;
4363
+ return { row: newAssistant };
4340
4364
  }
4341
4365
  if (newAssistant) {
4342
4366
  const outcome = assistantOutcome(newAssistant);
@@ -4358,7 +4382,7 @@ async function awaitAssistantRow(openReader, readSessionError, localFailure, chi
4358
4382
  });
4359
4383
  }
4360
4384
  if (typeof newAssistant.data.finish === "string" || outcome === "succeeded") {
4361
- return newAssistant;
4385
+ return { row: newAssistant };
4362
4386
  }
4363
4387
  }
4364
4388
  if (Date.now() >= deadline) {
@@ -4754,7 +4778,7 @@ async function createV2HiddenCompletionExecutor(host, options) {
4754
4778
  aborted,
4755
4779
  ...budget ? [budgetStopped] : []
4756
4780
  ]);
4757
- const row = await Promise.race([
4781
+ const { row, outputLimit } = await Promise.race([
4758
4782
  awaitAssistantRow(options.openReader, async () => {
4759
4783
  try {
4760
4784
  const eventError = await host.terminalError?.({
@@ -4778,14 +4802,17 @@ async function createV2HiddenCompletionExecutor(host, options) {
4778
4802
  const system = typeof request.body.system === "string" ? request.body.system : run.identity.system;
4779
4803
  const tokens = row.data.tokens;
4780
4804
  const tokenNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
4781
- const steps = withReader(options.openReader, (reader) => reader.assistantSince?.(run.child.id, baseline) ?? [row]).filter((step) => step.seq > baseline && step.seq <= row.seq);
4805
+ const attemptRows = withReader(options.openReader, (reader) => (outputLimit ? reader.range?.(run.child.id, baseline, row.seq) : undefined) ?? reader.assistantSince?.(run.child.id, baseline) ?? [row]);
4806
+ const steps = attemptRows.filter((step) => step.type === "assistant" && step.seq > baseline && step.seq <= row.seq);
4782
4807
  const exceeded = chargeBudgetRows(steps);
4783
4808
  if (exceeded) {
4784
4809
  await interruptAndRetire(run, "token-budget");
4785
4810
  throw exceeded;
4786
4811
  }
4787
- const reportedUsage = steps.some((step) => tokenNumber(step.data.tokens?.input) !== undefined || tokenNumber(step.data.tokens?.output) !== undefined);
4788
- const usage = sumRowUsage(steps);
4812
+ const cappedChainStart = outputLimit ? outputLimitChainStart(attemptRows, row.seq) : row.seq;
4813
+ const usageRows = cappedChainStart < row.seq ? steps.filter((step) => step.seq < cappedChainStart || step.seq === row.seq) : steps;
4814
+ const reportedUsage = usageRows.some((step) => tokenNumber(step.data.tokens?.input) !== undefined || tokenNumber(step.data.tokens?.output) !== undefined);
4815
+ const usage = sumRowUsage(usageRows);
4789
4816
  if (request.signal?.aborted || run.retired || Date.now() >= deadline) {
4790
4817
  await interruptAndRetire(run, "prompt-aborted-or-timeout");
4791
4818
  throw new Error(request.signal?.aborted ? "Hidden completion prompt aborted" : "Hidden completion prompt timed out");
@@ -4796,7 +4823,7 @@ async function createV2HiddenCompletionExecutor(host, options) {
4796
4823
  ...hiddenToolLoop(run.identity) ? { messages: toolLoopMessages(attempt, steps) } : {},
4797
4824
  reasoning: text ? null : assistantReasoning(row),
4798
4825
  usage: reportedUsage ? usage : meter(system, promptText(request), text ?? ""),
4799
- lengthCapped: ["length", "max_tokens"].includes(row.data.finish ?? ""),
4826
+ lengthCapped: outputLimit || isLengthCapped(row),
4800
4827
  providerId: row.data.model?.providerID ?? requested.providerID,
4801
4828
  modelId: row.data.model?.id ?? requested.modelID,
4802
4829
  attemptedModel: requestedRef,
@@ -6937,6 +6964,17 @@ function checkHistoryBoundary(db, reader, sessionID) {
6937
6964
  return;
6938
6965
  }
6939
6966
  }
6967
+ function newBaselineStartAfter(db, reader, sessionID, cached, compactionOff) {
6968
+ if (cached?.id != null || cached?.hasBytes)
6969
+ return;
6970
+ const isSubagent = storedSubagentMode(db, sessionID);
6971
+ if (isSubagent === undefined || !rendersCompartmentHistory(isSubagent, compactionOff))
6972
+ return;
6973
+ const newest = db.prepare("SELECT end_message_id AS id, rebase_status AS status FROM compartments WHERE session_id = ? ORDER BY sequence DESC LIMIT 1").get(sessionID);
6974
+ if (newest?.id && newest.status !== "unresolved" && reader.sequenceForId(sessionID, newest.id) !== undefined)
6975
+ return newest.id;
6976
+ return;
6977
+ }
6940
6978
  async function cacheV2SessionDirectory(session, sessionID, directories) {
6941
6979
  if (directories.has(sessionID))
6942
6980
  return;
@@ -7178,6 +7216,7 @@ async function registerContext(context) {
7178
7216
  const liveModels = new Map;
7179
7217
  const toolDefinitionsHashes = new BoundedSessionMap(1000);
7180
7218
  const requestToolsFingerprints = new BoundedSessionMap(1000);
7219
+ const recoveredInstructions = new BoundedSessionMap(1000);
7181
7220
  const promptSurfaceRuntime = createPromptSurfaceRuntime({
7182
7221
  harness: "opencode2",
7183
7222
  directory,
@@ -7821,6 +7860,7 @@ async function registerContext(context) {
7821
7860
  continue;
7822
7861
  }
7823
7862
  if (event.type === "session.deleted") {
7863
+ recoveredInstructions.delete(sessionID);
7824
7864
  overflowRecovery.forget(sessionID);
7825
7865
  hostFoldIdle?.active(sessionID);
7826
7866
  clearLkgMeasuredRequest(sessionID);
@@ -8073,12 +8113,21 @@ async function registerContext(context) {
8073
8113
  return ids;
8074
8114
  };
8075
8115
  const restoreAfterCheckpoint = async (args) => {
8076
- const { db, reader, draft, cut, boundaryRepair } = args;
8116
+ const { db, reader, draft, cut } = args;
8077
8117
  const moduleBoundaryID = rustModeModuleClient ? getPersistedCompactionMarkerState(db, draft.sessionID)?.boundaryMessageId ?? null : null;
8078
8118
  const moduleBoundarySeq = moduleBoundaryID ? reader.sequenceForId(draft.sessionID, moduleBoundaryID) : undefined;
8079
- const boundaryID = db.prepare("SELECT cached_m0_last_baseline_end_message_id AS id FROM session_meta WHERE session_id = ?").get(draft.sessionID)?.id ?? (boundaryRepair?.kind === "repaired" || boundaryRepair?.kind === "baseline-reset" ? boundaryRepair.anchorEndMessageId : null);
8119
+ const cached = db.prepare("SELECT cached_m0_last_baseline_end_message_id AS id, cached_m0_bytes IS NOT NULL AS hasBytes FROM session_meta WHERE session_id = ?").get(draft.sessionID);
8120
+ const newStart = args.canRebuild && !rustModeModuleClient ? newBaselineStartAfter(db, reader, draft.sessionID, cached, compactionOff) : undefined;
8121
+ const nativeFloor = await nativeFoldReplay?.restorationFloor(draft.sessionID, cut, reader, {
8122
+ allowMissingFloor: newStart !== undefined
8123
+ });
8124
+ if (newStart && nativeFloor === undefined) {
8125
+ const pass = contextPass.getStore();
8126
+ if (pass)
8127
+ pass.recoveredCheckpointID = cut.id;
8128
+ }
8129
+ const boundaryID = cached?.id ?? (nativeFloor === undefined ? newStart : undefined) ?? null;
8080
8130
  const servedBoundary = boundaryID ? servedBoundaryRow2(reader, draft.sessionID, boundaryID) : null;
8081
- const nativeFloor = await nativeFoldReplay?.restorationFloor(draft.sessionID, cut, reader);
8082
8131
  const retiredInstructions = await nativeFoldReplay?.instructionRetirement(draft.sessionID, reader) ?? (() => false);
8083
8132
  const floor = Math.max(nativeFloor ?? -Infinity, (nativeFoldReplay?.sourceChanged(draft.sessionID) && !rustModeModuleClient ? (reader.earliestSequence(draft.sessionID) ?? 0) - 1 : undefined) ?? (moduleBoundarySeq !== undefined ? moduleBoundarySeq - 1 : undefined) ?? servedBoundary?.seq ?? reader.sequenceForId(draft.sessionID, boundaryID) ?? (reader.earliestSequence(draft.sessionID) ?? 0) - 1);
8084
8133
  const floorRow = !rustModeModuleClient && Number.isFinite(floor) ? reader.range(draft.sessionID, floor - 1, floor).find((row) => row.seq === floor) : undefined;
@@ -8191,7 +8240,7 @@ async function registerContext(context) {
8191
8240
  onRustEngineReconnectRefusal: (refusal) => rustRefusalRecovery?.arm(refusal),
8192
8241
  ...createHostSeams(context, readAllForConversion, pagedRead, liveModels)
8193
8242
  });
8194
- const runManagedContext = async (draft, pass) => {
8243
+ const runManagedContext = async (draft, pass, previousRecovery) => {
8195
8244
  rememberHostMedia(draft.messages);
8196
8245
  if (hiddenChildHook.apply(draft))
8197
8246
  return "skipped";
@@ -8341,8 +8390,7 @@ async function registerContext(context) {
8341
8390
  draft,
8342
8391
  messages,
8343
8392
  cut: localCut,
8344
- incoming,
8345
- boundaryRepair: undefined
8393
+ incoming
8346
8394
  });
8347
8395
  }
8348
8396
  } else if (localCut)
@@ -8557,6 +8605,8 @@ async function registerContext(context) {
8557
8605
  sessionLog2(draft.sessionID, "v2 host fold: cache unavailable; restoring host rows", error);
8558
8606
  nativeRestored = await nativeFoldReplay.restoreRead(draft.sessionID, cut, draft.model);
8559
8607
  }
8608
+ if (nativeRestored)
8609
+ pass.nativeReplayCheckpointID = cut.id;
8560
8610
  }
8561
8611
  if (cut && nativeFoldReplay?.sourceChanged(draft.sessionID)) {
8562
8612
  if (db && !rustModeModuleClient && nativeFoldReplay.needsHeadRebuild(draft.sessionID))
@@ -8597,7 +8647,7 @@ async function registerContext(context) {
8597
8647
  messages: draft.messages,
8598
8648
  cut: localCut,
8599
8649
  incoming,
8600
- boundaryRepair
8650
+ canRebuild: true
8601
8651
  }));
8602
8652
  }
8603
8653
  instructionRows = new Map(bindKeptInstructionCoordinates(draft.messages, incoming || undefined, reader, draft.sessionID).map((row) => [row.id, row]));
@@ -8650,6 +8700,17 @@ async function registerContext(context) {
8650
8700
  rustReplayParticipant: () => transform?.getRustReplayParticipant() ?? null
8651
8701
  })({}, mapped);
8652
8702
  mapped.commit();
8703
+ if (replayHead === undefined && (pass.recoveredCheckpointID || previousRecovery && pass.nativeReplayCheckpointID === previousRecovery.checkpointID)) {
8704
+ pass.servedInstructionIDs = new Set(mapped.messages.flatMap(({ info, parts }) => {
8705
+ if (info.role !== "system" || pass.recoveredCheckpointID && !isCoveredInstructionRow(info) || !parts.some((value) => {
8706
+ const part = value;
8707
+ return part?.type === "text" && typeof part.text === "string" && part.text.length > 0;
8708
+ }))
8709
+ return [];
8710
+ const id = hostInstructionRowID(info);
8711
+ return id ? [id] : [];
8712
+ }));
8713
+ }
8653
8714
  const checkpointPermission = checkpointPassPermissions.get(draft.sessionID);
8654
8715
  checkpointPassPermissions.delete(draft.sessionID);
8655
8716
  checkpointInputEstimates.delete(draft.sessionID);
@@ -8815,13 +8876,15 @@ async function registerContext(context) {
8815
8876
  };
8816
8877
  await context.session.hook("context", (draft) => withV2ContextPass(draft.sessionID, async (pass) => {
8817
8878
  hostFoldIdle?.active(draft.sessionID);
8879
+ const previousRecovery = recoveredInstructions.peek(draft.sessionID);
8880
+ recoveredInstructions.delete(draft.sessionID);
8818
8881
  const hiddenChild = hiddenChildHook.owns(draft.sessionID);
8819
8882
  const anchor = compactionOff || hiddenChild ? undefined : generateReplayAnchor(draft.messages);
8820
8883
  beginServedRequest(draft.sessionID);
8821
8884
  let returned = false;
8822
8885
  let outcome;
8823
8886
  try {
8824
- outcome = await runManagedContext(draft, pass);
8887
+ outcome = await runManagedContext(draft, pass, previousRecovery);
8825
8888
  if (!pass.refused && pass.storageNoticeWake && draft.messages.at(-1)?.role === "assistant") {
8826
8889
  await refuseBeforeProvider(context.session, draft.sessionID, "storage-notice-turn", "request ends with the previous reply");
8827
8890
  }
@@ -8850,6 +8913,22 @@ async function registerContext(context) {
8850
8913
  foldedInstructionIDs.delete(draft.sessionID);
8851
8914
  finishServedRequest(draft, returned);
8852
8915
  }
8916
+ if (pass.servedInstructionIDs && !deletedSessions.has(draft.sessionID)) {
8917
+ const served = pass.servedInstructionIDs;
8918
+ if (previousRecovery && previousRecovery.checkpointID === pass.nativeReplayCheckpointID) {
8919
+ const left = [...previousRecovery.coveredInstructionIDs].filter((id) => !served.has(id)).length;
8920
+ if (left > 0) {
8921
+ try {
8922
+ sessionLog2(draft.sessionID, `v2 host fold: after history recovery, the native record for checkpoint ${previousRecovery.checkpointID} was re-admitted; ${left} covered instruction ${left === 1 ? "row is" : "rows are"} no longer sent, changing the cached prefix once`);
8923
+ } catch {}
8924
+ }
8925
+ }
8926
+ if (pass.recoveredCheckpointID && served.size > 0)
8927
+ recoveredInstructions.set(draft.sessionID, {
8928
+ checkpointID: pass.recoveredCheckpointID,
8929
+ coveredInstructionIDs: served
8930
+ });
8931
+ }
8853
8932
  if (compactionOff)
8854
8933
  sessionLog2(draft.sessionID, "generate replay capture skipped: compaction-disabled");
8855
8934
  else if (!pass.refused && outcome === "managed" && !hiddenChild && !deletedSessions.has(draft.sessionID))
@@ -8993,6 +9072,7 @@ async function registerContext(context) {
8993
9072
  clearInterval(hiddenChildSweepTimer);
8994
9073
  await hiddenChildSweep.dispose();
8995
9074
  messageTimesCache.clear();
9075
+ recoveredInstructions.clear();
8996
9076
  hostFoldIdle?.dispose();
8997
9077
  usageController.abort();
8998
9078
  await hiddenCompletionExecutor?.dispose();
@@ -5,9 +5,9 @@ import {
5
5
  resolveHistorianProducerLimits2,
6
6
  resolveHistorianContextLimit2,
7
7
  producerSourceLocalBudget2
8
- } from "./index-zmqx48vt.js";
8
+ } from "./index-xsqw8kbd.js";
9
9
  import"./index-1zx87sdm.js";
10
- import"./index-c5tmzym6.js";
10
+ import"./index-5df2fw5b.js";
11
11
  import"./index-gqf8r04r.js";
12
12
  import"./index-ywrz4wy2.js";
13
13
  import"./index-pavzsdc6.js";
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  ensureMemoryEmbeddings2
3
- } from "./index-k0tb2z28.js";
4
- import"./index-s8ks5nz4.js";
5
- import"./index-4dhv7mqz.js";
3
+ } from "./index-w51n3576.js";
4
+ import"./index-2pdgy88n.js";
5
+ import"./index-qjwpqvnf.js";
6
6
  import"./index-2amn2s73.js";
7
7
  import"./index-qt1qqasc.js";
8
- import"./index-k50xhjw1.js";
8
+ import"./index-60x5d68t.js";
9
9
  import"./index-6nqz8hsz.js";
10
- import"./index-3dtzyred.js";
11
- import"./index-snbpdpa3.js";
10
+ import"./index-r4y0dczp.js";
11
+ import"./index-3pdknr07.js";
12
12
  import"./index-pxnzyvjc.js";
13
- import"./index-7svecf3m.js";
13
+ import"./index-5pgyqgmx.js";
14
14
  import"./index-s32f8y67.js";
15
15
  import"./index-q7q6qp1f.js";
16
16
  import"./index-96ztjvkn.js";
17
17
  import"./index-v0p37hm2.js";
18
18
  import"./index-m0pwswv9.js";
19
- import"./index-c5tmzym6.js";
19
+ import"./index-5df2fw5b.js";
20
20
  import"./index-gqf8r04r.js";
21
21
  import"./index-5vsk2cpp.js";
22
22
  import"./index-gzy5w8ya.js";
@@ -1,15 +1,19 @@
1
1
  import {
2
+ keepWorkerMemoryEmbeddings2,
3
+ maintainKeptWorkerMemoryEmbeddings2,
2
4
  getProjectEmbeddings2,
3
5
  peekProjectEmbeddings2,
4
6
  invalidateProject2,
5
7
  invalidateMemory2,
6
8
  resetEmbeddingCacheForTests2,
7
9
  setEmbeddingCacheTtlForTests2
8
- } from "./server-4dhv7mqz.js";
10
+ } from "./index-qjwpqvnf.js";
9
11
  export {
10
12
  getProjectEmbeddings2 as getProjectEmbeddings,
11
13
  invalidateMemory2 as invalidateMemory,
12
14
  invalidateProject2 as invalidateProject,
15
+ keepWorkerMemoryEmbeddings2 as keepWorkerMemoryEmbeddings,
16
+ maintainKeptWorkerMemoryEmbeddings2 as maintainKeptWorkerMemoryEmbeddings,
13
17
  peekProjectEmbeddings2 as peekProjectEmbeddings,
14
18
  resetEmbeddingCacheForTests2 as resetEmbeddingCacheForTests,
15
19
  setEmbeddingCacheTtlForTests2 as setEmbeddingCacheTtlForTests