@cortexkit/opencode-magic-context 0.49.80 → 0.49.82

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 (168) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +4 -4
  3. package/dist/{conflict-warning-hook-m8yezwdj.js → conflict-warning-hook-a0wrnzch.js} +3 -3
  4. package/dist/{context-7rkrv5q8.js → context-00f1hdz2.js} +278 -43
  5. package/dist/{embedding-backfill-0tvprmrn.js → embedding-backfill-k994xdas.js} +4 -4
  6. package/dist/features/magic-context/memory/identity-merge-command.d.ts +4 -0
  7. package/dist/features/magic-context/memory/identity-merge-command.d.ts.map +1 -0
  8. package/dist/features/magic-context/memory/project-binding-notice.d.ts +5 -0
  9. package/dist/features/magic-context/memory/project-binding-notice.d.ts.map +1 -0
  10. package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
  11. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  12. package/dist/features/magic-context/storage-clone.d.ts +17 -0
  13. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  14. package/dist/features/magic-context/store-generation-rebase.d.ts +13 -0
  15. package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
  16. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +1 -7
  17. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  18. package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/inject-compartments.d.ts +16 -0
  20. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  21. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  22. package/dist/hooks/magic-context/stored-compartment-gaps.d.ts +16 -0
  23. package/dist/hooks/magic-context/stored-compartment-gaps.d.ts.map +1 -0
  24. package/dist/hooks/magic-context/transform.d.ts +1 -0
  25. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  26. package/dist/{index-m4q6ptgz.js → index-2xhzmwf6.js} +4 -4
  27. package/dist/{index-jhhkb4jv.js → index-2ygw6q5s.js} +1 -1
  28. package/dist/{index-v0epndb8.js → index-93rezfvc.js} +22 -2
  29. package/dist/{index-exvsw656.js → index-b2787fk6.js} +116 -42
  30. package/dist/{index-tebcx987.js → index-bd34njzg.js} +1 -1
  31. package/dist/{index-zpd4pxnp.js → index-dg5jvh9r.js} +6 -6
  32. package/dist/{index-6athgjba.js → index-e21n48yd.js} +34 -2
  33. package/dist/{index-ezgeq2z7.js → index-eptthgkw.js} +5 -5
  34. package/dist/{index-9554nr2q.js → index-fgy6hnr3.js} +6 -1
  35. package/dist/{index-tzy5h4x6.js → index-fpqdbb67.js} +1 -1
  36. package/dist/{v2/server-x8a7jmkh.js → index-fzgyvsb1.js} +15 -4
  37. package/dist/{index-1sq1krqw.js → index-g6hfh4h4.js} +4 -4
  38. package/dist/{index-hpmx99e9.js → index-hz1xdb15.js} +3 -3
  39. package/dist/{index-xjpemea9.js → index-jvr9ba9y.js} +151 -37
  40. package/dist/{index-esqcwes7.js → index-nxxzeq4y.js} +4 -2
  41. package/dist/{index-m6rkq3t4.js → index-rnyaa7cj.js} +1 -1
  42. package/dist/{index-yfn52pb6.js → index-shpyv8gq.js} +2 -2
  43. package/dist/{index-pzvdf7sr.js → index-stx8zd81.js} +3 -3
  44. package/dist/{index-jg7sbt3v.js → index-vpw46557.js} +1 -1
  45. package/dist/{index-xx05vta0.js → index-w2wpx7t5.js} +1 -1
  46. package/dist/{index-177yv84k.js → index-w8dcjt7f.js} +1 -1
  47. package/dist/{index-mgvj4vkb.js → index-wxxcfpxh.js} +5 -5
  48. package/dist/{index-xsdaz3mq.js → index-x8qgqnym.js} +30 -11
  49. package/dist/{index-aawwdt26.js → index-zvane1rq.js} +2 -2
  50. package/dist/index.js +32 -32
  51. package/dist/migration-worker.js +3 -3
  52. package/dist/plugin/rpc-handlers.d.ts +2 -0
  53. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  54. package/dist/{project-embedding-registry-sw4z2ptg.js → project-embedding-registry-y3z36mjy.js} +3 -3
  55. package/dist/raw-ordinal-warmup-worker.js +2 -2
  56. package/dist/{recomp-orchestrator-n7h0a0tn.js → recomp-orchestrator-fjdp3t1d.js} +14 -14
  57. package/dist/{render-bjxgkrk6.js → render-c9fjwrad.js} +6 -6
  58. package/dist/{rpc-notifications-3hed126v.js → rpc-notifications-t9q0ynq7.js} +3 -1
  59. package/dist/{search-z56487n8.js → search-1jejx5cx.js} +9 -9
  60. package/dist/{search-archive-p3jhx9wc.js → search-archive-s2jas2jb.js} +2 -2
  61. package/dist/{send-session-notification-ykvt5k2s.js → send-session-notification-7x518gew.js} +1 -1
  62. package/dist/shared/conflict-detector.d.ts +6 -0
  63. package/dist/shared/conflict-detector.d.ts.map +1 -1
  64. package/dist/shared/conflict-fixer.d.ts +1 -0
  65. package/dist/shared/conflict-fixer.d.ts.map +1 -1
  66. package/dist/shared/prompt-surface-runtime.d.ts +1 -1
  67. package/dist/shared/rpc-notifications.d.ts +8 -3
  68. package/dist/shared/rpc-notifications.d.ts.map +1 -1
  69. package/dist/shared/rpc-types.d.ts +4 -0
  70. package/dist/shared/rpc-types.d.ts.map +1 -1
  71. package/dist/shared/status-summary.d.ts +2 -0
  72. package/dist/shared/status-summary.d.ts.map +1 -1
  73. package/dist/shared/status-view-check.d.ts.map +1 -1
  74. package/dist/shared/status-view.d.ts +1 -0
  75. package/dist/shared/status-view.d.ts.map +1 -1
  76. package/dist/shared/user-facing-codes.d.ts +5 -0
  77. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  78. package/dist/{store-8trkpmtx.js → store-ggrq9e14.js} +6 -2
  79. package/dist/{store-reader-3eh1s1m8.js → store-reader-tr64nxyy.js} +1 -1
  80. package/dist/tools/ctx-memory/constants.d.ts +1 -1
  81. package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
  82. package/dist/tools/light-descriptions.d.ts +1 -1
  83. package/dist/tools/light-descriptions.d.ts.map +1 -1
  84. package/dist/tools/parameter-descriptions.d.ts +6 -6
  85. package/dist/tools/parameter-descriptions.d.ts.map +1 -1
  86. package/dist/{transform-postprocess-phase-f0wssyce.js → transform-postprocess-phase-p2egg02g.js} +15 -15
  87. package/dist/v2/auto-search-worker.js +3 -3
  88. package/dist/v2/chunk-embedding-write-worker.js +4 -4
  89. package/dist/v2/{context-r1swhysg.js → context-gwkgh0wd.js} +398 -58
  90. package/dist/v2/{embedding-backfill-qnaswpmb.js → embedding-backfill-hjvjxp7d.js} +4 -4
  91. package/dist/v2/fold/owner.d.ts +8 -0
  92. package/dist/v2/fold/owner.d.ts.map +1 -1
  93. package/dist/v2/fork-inheritance.d.ts +25 -17
  94. package/dist/v2/fork-inheritance.d.ts.map +1 -1
  95. package/dist/v2/hidden-child-native.d.ts +6 -6
  96. package/dist/v2/hidden-child-native.d.ts.map +1 -1
  97. package/dist/v2/hidden-child-record.d.ts +21 -3
  98. package/dist/v2/hidden-child-record.d.ts.map +1 -1
  99. package/dist/v2/hidden-child-sweep.d.ts +1 -1
  100. package/dist/v2/hidden-child-sweep.d.ts.map +1 -1
  101. package/dist/v2/hidden-completion.d.ts +1 -0
  102. package/dist/v2/hidden-completion.d.ts.map +1 -1
  103. package/dist/v2/hidden-run-holder.d.ts +16 -0
  104. package/dist/v2/hidden-run-holder.d.ts.map +1 -0
  105. package/dist/v2/hooks/context.d.ts.map +1 -1
  106. package/dist/v2/hooks/dream-timer.d.ts +5 -7
  107. package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
  108. package/dist/v2/hooks/fork-history-status.d.ts +10 -0
  109. package/dist/v2/hooks/fork-history-status.d.ts.map +1 -0
  110. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  111. package/dist/v2/hooks/store.d.ts +4 -0
  112. package/dist/v2/hooks/store.d.ts.map +1 -1
  113. package/dist/v2/hooks/types.d.ts +5 -26
  114. package/dist/v2/hooks/types.d.ts.map +1 -1
  115. package/dist/v2/migration-worker.js +3 -3
  116. package/dist/v2/{project-embedding-registry-52f2jept.js → project-embedding-registry-mzsvyads.js} +3 -3
  117. package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
  118. package/dist/v2/{recomp-orchestrator-4w2w4kd4.js → recomp-orchestrator-jn39mxh0.js} +13 -13
  119. package/dist/v2/{render-hwqk0d8t.js → render-q2aj9bgy.js} +6 -6
  120. package/dist/v2/{rpc-notifications-3hed126v.js → rpc-notifications-t9q0ynq7.js} +3 -1
  121. package/dist/v2/{search-eftsvbg7.js → search-9xn6ds9x.js} +8 -8
  122. package/dist/v2/{search-archive-mdxzvgpm.js → search-archive-fj59gjv1.js} +2 -2
  123. package/dist/v2/{send-session-notification-8g4r97bp.js → send-session-notification-p52rhjzy.js} +1 -1
  124. package/dist/v2/{server-ma9jwnas.js → server-1cn3kryt.js} +4 -4
  125. package/dist/v2/{server-34pvhvxt.js → server-1efjj215.js} +22 -2
  126. package/dist/v2/{server-jn4pktdk.js → server-2ktxmtbd.js} +1 -1
  127. package/dist/v2/{server-zw1e3wq5.js → server-2w1rdttn.js} +1 -1
  128. package/dist/v2/{server-jtq03rkb.js → server-4z964n1c.js} +1 -1
  129. package/dist/v2/{server-pxdpwycq.js → server-53n8hv5q.js} +6 -6
  130. package/dist/v2/{server-rbtx6q5v.js → server-569he5mh.js} +1 -1
  131. package/dist/v2/{server-rthnpmbp.js → server-5yfq912a.js} +34 -2
  132. package/dist/v2/{server-mhrgymcs.js → server-68q80y27.js} +2 -2
  133. package/dist/v2/{server-afsz3cmx.js → server-bt546axy.js} +1 -1
  134. package/dist/v2/{server-dhdn8mwq.js → server-c8mqs0v5.js} +30 -11
  135. package/dist/{index-x8a7jmkh.js → v2/server-fzgyvsb1.js} +15 -4
  136. package/dist/v2/{server-76v5y7zm.js → server-g1a0nhtk.js} +2 -2
  137. package/dist/v2/{server-25qtxt4d.js → server-gx1s06dx.js} +6 -1
  138. package/dist/v2/{server-x8ksqcw7.js → server-pejjj0nv.js} +1 -1
  139. package/dist/v2/{server-fqnty3nk.js → server-vt6nj2hn.js} +111 -37
  140. package/dist/v2/{server-qjff96a6.js → server-wdq85mxj.js} +4 -4
  141. package/dist/v2/server.js +3 -3
  142. package/dist/v2/{store-m3zny7q2.js → store-qdgzd38f.js} +6 -2
  143. package/dist/v2/{store-reader-yaxtdy6f.js → store-reader-83tka051.js} +1 -1
  144. package/dist/v2/store-reader.d.ts +15 -8
  145. package/dist/v2/store-reader.d.ts.map +1 -1
  146. package/dist/v2/tui/index.d.ts +1 -1
  147. package/dist/v2/tui/index.d.ts.map +1 -1
  148. package/dist/v2/{v2-archive-reader-p89x05hj.js → v2-archive-reader-9z8z97db.js} +1 -1
  149. package/dist/v2/{wrapup-orchestrator-0f4nwpbv.js → wrapup-orchestrator-vd5zfp3v.js} +13 -13
  150. package/dist/{v2-archive-reader-vzmzb245.js → v2-archive-reader-r0xpxsb1.js} +1 -1
  151. package/dist/{wrapup-orchestrator-5k9hgb3t.js → wrapup-orchestrator-k29zqfp9.js} +15 -15
  152. package/package.json +1 -1
  153. package/src/agents/smart-notes-dreamer-gate.golden.json +169 -169
  154. package/src/shared/conflict-detector.ts +35 -2
  155. package/src/shared/conflict-fixer.ts +10 -6
  156. package/src/shared/fold-render-lock-fence.test.ts +2 -0
  157. package/src/shared/prompt-surface-a1-golden.md +8 -7
  158. package/src/shared/rpc-notifications.test.ts +29 -0
  159. package/src/shared/rpc-notifications.ts +24 -5
  160. package/src/shared/rpc-types.ts +4 -0
  161. package/src/shared/status-summary.ts +9 -1
  162. package/src/shared/status-view-check.ts +2 -0
  163. package/src/shared/status-view.test.ts +9 -0
  164. package/src/shared/status-view.ts +4 -0
  165. package/src/shared/user-facing-codes.ts +5 -0
  166. package/src/tui/slots/sidebar-content.tsx +11 -5
  167. package/src/tui-compiled/slots/sidebar-content.tsx +191 -176
  168. package/src/v2/tui/index.ts +7 -2
@@ -107,13 +107,13 @@ import {
107
107
  import {
108
108
  shouldSkipHomeProjectMemory,
109
109
  resolveProjectIdentity
110
- } from "./index-tzy5h4x6.js";
110
+ } from "./index-fpqdbb67.js";
111
111
  import {
112
112
  getSchemaFenceRejection,
113
113
  LATEST_SUPPORTED_VERSION,
114
114
  getPersistedSchemaVersion,
115
115
  openDatabase
116
- } from "./index-aawwdt26.js";
116
+ } from "./index-zvane1rq.js";
117
117
  import {
118
118
  areRustHistorianSyntheticParts2,
119
119
  isStrictGapHealingMessage2,
@@ -130,7 +130,7 @@ import {
130
130
  resolveStoredPathWorkspaceIdentity,
131
131
  sourceNameForMemory,
132
132
  computeWorkspaceEpochFingerprint
133
- } from "./index-xx05vta0.js";
133
+ } from "./index-w2wpx7t5.js";
134
134
  import {
135
135
  BoundedSessionMap
136
136
  } from "./index-jrj95cce.js";
@@ -202,7 +202,7 @@ import {
202
202
  getProjectState,
203
203
  recordSubagentInvocation,
204
204
  getLatestHistorianInvocationId
205
- } from "./index-xsdaz3mq.js";
205
+ } from "./index-x8qgqnym.js";
206
206
  import {
207
207
  clearCompressionDepth,
208
208
  clearCompressionDepthRange,
@@ -269,10 +269,10 @@ import {
269
269
  getSessionNotes,
270
270
  getReadySmartNotes,
271
271
  insertPrimerCandidates
272
- } from "./index-tebcx987.js";
272
+ } from "./index-bd34njzg.js";
273
273
  import {
274
274
  pushNotification2
275
- } from "./index-x8a7jmkh.js";
275
+ } from "./index-fzgyvsb1.js";
276
276
  import {
277
277
  computeCueContentHash,
278
278
  getMuralCueState,
@@ -287,13 +287,13 @@ import {
287
287
  getProjectChunkEmbeddingModelId2,
288
288
  getProjectEmbeddingMaxInputTokens2,
289
289
  embedItemsWindowBounded2
290
- } from "./index-yfn52pb6.js";
290
+ } from "./index-shpyv8gq.js";
291
291
  import {
292
292
  renderUserFacingFailure,
293
293
  userFacingFailureCode,
294
294
  promoteSessionFactsDurable,
295
295
  embedPromotedFacts
296
- } from "./index-9554nr2q.js";
296
+ } from "./index-fgy6hnr3.js";
297
297
  import {
298
298
  isMarkerCandidateBasisCurrent2,
299
299
  invalidateMarkerCandidateBasis2,
@@ -307,7 +307,7 @@ import {
307
307
  } from "./index-832w615x.js";
308
308
  import {
309
309
  sendStatusNotification2
310
- } from "./index-1sq1krqw.js";
310
+ } from "./index-g6hfh4h4.js";
311
311
  import {
312
312
  isCompactionEnabled,
313
313
  migrateLegacyAgentEnabledInMemory
@@ -321,6 +321,9 @@ import {
321
321
  import {
322
322
  piModelRefToCanonical
323
323
  } from "./index-avwt563y.js";
324
+ import {
325
+ sameProjectDirectory
326
+ } from "./index-knvkbfvh.js";
324
327
  import {
325
328
  getErrorMessage,
326
329
  describeError
@@ -4675,7 +4678,7 @@ function providerOutputFailureFromInvalidManifest(messages, responseText) {
4675
4678
  }
4676
4679
 
4677
4680
  // src/v2/hooks/hidden-child.ts
4678
- import { createHash as createHash3 } from "node:crypto";
4681
+ import { createHash as createHash4 } from "node:crypto";
4679
4682
 
4680
4683
  // src/shared/historian-cache.ts
4681
4684
  function withoutHistorianTailCache(body) {
@@ -4708,6 +4711,43 @@ function withoutHistorianTailCache(body) {
4708
4711
  return body;
4709
4712
  }
4710
4713
 
4714
+ // src/v2/hidden-run-holder.ts
4715
+ import { createHash as createHash3, randomUUID } from "node:crypto";
4716
+ import { stat } from "node:fs/promises";
4717
+ var HOLDER_PREFIX = "ses_mc_bg_";
4718
+ var HOLDER_CANDIDATES = 3;
4719
+ function isHiddenRunHolder(id) {
4720
+ return id.startsWith(HOLDER_PREFIX);
4721
+ }
4722
+ function supportsQuietHiddenChildren(version) {
4723
+ return typeof version === "string" && /^\d+\.\d+\.\d+$/.test(version) && version !== "2.3.0";
4724
+ }
4725
+ function matchesHiddenRunLocation(wanted, returned) {
4726
+ return sameProjectDirectory(wanted, returned ?? "");
4727
+ }
4728
+ async function hiddenRunPlacement(createHolder, directory) {
4729
+ if (!(await stat(directory)).isDirectory())
4730
+ throw new Error(`Not a run directory: ${directory}`);
4731
+ const base = HOLDER_PREFIX + createHash3("sha256").update(directory).digest("hex").slice(0, 32);
4732
+ const displaced = [];
4733
+ for (let index = 0;index < HOLDER_CANDIDATES; index++) {
4734
+ const id = index === 0 ? base : `${base}_${index + 1}`;
4735
+ const holder = await createHolder({
4736
+ id,
4737
+ title: "Magic Context background runs",
4738
+ location: { directory },
4739
+ metadata: { magic_context: "background-holder" }
4740
+ });
4741
+ if (holder.id !== id || holder.parentID)
4742
+ throw new Error(`OpenCode did not return the expected background holder ${id}`);
4743
+ if (holder.metadata?.magic_context === "background-holder" && matchesHiddenRunLocation(directory, holder.location?.directory)) {
4744
+ return { id: `ses_aut_${randomUUID()}`, parentID: id };
4745
+ }
4746
+ displaced.push(id);
4747
+ }
4748
+ throw new Error(`No background holder at ${directory}; displaced holders: ${displaced.join(", ")}`);
4749
+ }
4750
+
4711
4751
  // src/v2/hooks/claude-agent-instructions.ts
4712
4752
  var CLAUDE_AGENT_PROVIDER_ID = "claude-agent";
4713
4753
  function deliversInstructionsInUserMessage(providerID) {
@@ -4725,6 +4765,7 @@ ${system}
4725
4765
  var HIDDEN_HISTORIAN_AGENT = "historian";
4726
4766
  var HIDDEN_DREAMER_AGENT = "dreamer-classifier";
4727
4767
  var HIDDEN_CURATE_AGENT = DREAMER_AGENT;
4768
+ var HOLDER_CHAT_REFUSAL = "This session holds Magic Context's background runs and can't be used for chat.";
4728
4769
  var AGENT_TOOLS = {
4729
4770
  [HIDDEN_HISTORIAN_AGENT]: [],
4730
4771
  [HIDDEN_DREAMER_AGENT]: [],
@@ -4912,7 +4953,7 @@ var REFUSAL_PART_DIGESTS = 8;
4912
4953
  function textDigest(text) {
4913
4954
  return {
4914
4955
  length: text.length,
4915
- sha256: createHash3("sha256").update(text).digest("hex").slice(0, 16)
4956
+ sha256: createHash4("sha256").update(text).digest("hex").slice(0, 16)
4916
4957
  };
4917
4958
  }
4918
4959
  function firstDifference(a, b) {
@@ -4957,7 +4998,7 @@ class HiddenChildHook {
4957
4998
  }
4958
4999
  }
4959
5000
  owns(sessionID) {
4960
- return this.childIDs.has(sessionID);
5001
+ return this.childIDs.has(sessionID) || isHiddenRunHolder(sessionID);
4961
5002
  }
4962
5003
  async cacheRequest(draft) {
4963
5004
  const attempt = this.active.get(draft.sessionID);
@@ -5048,6 +5089,10 @@ class HiddenChildHook {
5048
5089
  }
5049
5090
  return false;
5050
5091
  }
5092
+ if (isHiddenRunHolder(draft.sessionID)) {
5093
+ this.note(`[magic-context] hidden child refused: ${HOLDER_CHAT_REFUSAL} session=${draft.sessionID}`);
5094
+ throw new HiddenCompletionRefusal("hidden_prompt_unrecognized", HOLDER_CHAT_REFUSAL, true);
5095
+ }
5051
5096
  const texts = userTexts(draft.messages.at(-1));
5052
5097
  const named = new Set;
5053
5098
  for (const text of texts) {
@@ -6496,7 +6541,7 @@ async function promptAsyncAndWaitForIdle(client, request, options = {}) {
6496
6541
  }
6497
6542
  }
6498
6543
  // src/shared/prompt-surface-runtime.ts
6499
- import { createHash as createHash4 } from "node:crypto";
6544
+ import { createHash as createHash5 } from "node:crypto";
6500
6545
  import { existsSync as existsSync5, readFileSync as readFileSync5, statSync as statSync4 } from "node:fs";
6501
6546
  import { dirname as dirname4, isAbsolute as isAbsolute3, resolve as resolve2 } from "node:path";
6502
6547
 
@@ -6504,7 +6549,7 @@ import { dirname as dirname4, isAbsolute as isAbsolute3, resolve as resolve2 } f
6504
6549
  var CTX_REDUCE_LIGHT_DESCRIPTION = `Stamp an item as no longer needed for the work ahead. Not a delete: stamping QUEUES it, the item stays readable until Magic Context clears stamped items in one sweep, newest tags are protected, and a cleared item goes to the archive (recent: a [dropped §N§] placeholder; older: removed) recoverable via ctx_expand(tag=N). The question is "does this need to stay on my desk for what comes next?" — a file you keep editing stays, the grep that found it goes. Stamp used reads/searches/outputs, acted-on build/test output, redundant dumps, extracted pasted payloads; keep user messages, your own text, unresolved errors, raw evidence, exact wording that may matter. Look at each tag; never blanket-stamp "1-50". Grammar: "3-5", "1,2,9", "1-5,8,12-15".`;
6505
6550
  var CTX_EXPAND_LIGHT_DESCRIPTION = "Recover one item with tag=N (a §N§ or dropped placeholder number), not a message ordinal; text or one tool call with full input/output. message=N and start/end are whole-message ordinals from history/search, never tag numbers. Recover raw conversation behind a <session-history> heading or around a ctx_search hit: ctx_expand(start, end) returns [N] U:/A: lines (~15K-token cap; oversized ranges return the head and where to continue). verbose=true lists messages with per-part previews to pick one; message=N returns that message in full, including a tool output released with ctx_reduce. Ranges after the last compartment are your live tail, not expandable.";
6506
6551
  var CTX_NOTE_LIGHT_DESCRIPTION = 'Session notes are pending intentions: work you intend to return to, with findings attached ("take a note" always qualifies). Not active steps, an executing plan, or restart insurance; a record of how things stand (world-state, a design at a point in time) with nothing you intend to do about it — that goes stale silently; a fact worth keeping is memory, the rest is nothing. First line = title (<80 chars). write saves; read lists rows (note_ids for bodies); update changes one; dismiss retires 1–50. Dismiss a note when its work lands or is abandoned; a queue you never dismiss from stops being read. surface_condition parks it until an outside check against repo files, git, GitHub or the web holds.';
6507
- var CTX_MEMORY_LIGHT_DESCRIPTION = "Durable facts about this project, shared with every agent on it and kept for the months this work lasts; active ones are already in <project-memory> as `#id: fact`. Write one standalone fact when it must not have to be found again — a rule, an architecture fact, a constraint, a config value, a naming convention — especially what cost you turns. A pending intention with evidence is ctx_note, not memory. write (content + category); update one id (content; category optional); archive one or more ids (reason optional); merge two or more ids (content); get 1–20 ids in any status.";
6552
+ var CTX_MEMORY_LIGHT_DESCRIPTION = "Durable facts about this project, shared with every agent and kept for the months this work lasts; active ones are already in <project-memory> as `#id: fact`. Write one standalone fact you must not have to find again — a rule, an architecture fact, a constraint, a config value, a naming convention — especially what cost you turns. A pending intention with evidence is ctx_note, not memory. write (content + category); update one id (content + category); archive one or more ids (reason optional); merge 2+ distinct same-category ids (content); get 1–20 ids in any status.";
6508
6553
  var CTX_SEARCH_LIGHT_DESCRIPTION = 'Search the archive — everything that ever happened here that is not on your desk: memories not in <project-memory>, compacted conversation, commits, notes. Phrase query as a natural-language question carrying the exact terms you expect ("where is the opencode source code path?", "why did we choose SQLite over postgres?", "how does the dreamer lease work?") — a keyword stack finds less. Sources (omit for all): memory (rules, conventions), message (compacted conversation; hits carry ordinals for ctx_expand), git_commit (when did this change), primer (reusable project Q&A the dreamer distils from recurring questions), note (parked follow-ups). Memory ids alone (`#7234`) resolve directly. from/to restrict every source to an inclusive UTC date range.';
6509
6554
 
6510
6555
  // src/shared/prompt-surface-runtime.ts
@@ -6529,7 +6574,7 @@ function promptSurfaceHashMaterial(systemContent, preset = "full") {
6529
6574
  \x00magic-context-prompt-surface:${preset}`;
6530
6575
  }
6531
6576
  function systemPromptFingerprint(systemContent, preset = "full") {
6532
- return createHash4("md5").update(promptSurfaceHashMaterial(systemContent, preset)).digest("hex");
6577
+ return createHash5("md5").update(promptSurfaceHashMaterial(systemContent, preset)).digest("hex");
6533
6578
  }
6534
6579
  var PROMPT_SURFACE_TOOL_ID_SET = new Set(ACTIVE_TOOL_IDS);
6535
6580
  function resolveUserConfigDirectory(options) {
@@ -7224,7 +7269,7 @@ function compareMemorySelectionPriority(left, right) {
7224
7269
  }
7225
7270
 
7226
7271
  // src/features/magic-context/mural/render-trigger.ts
7227
- import { createHash as createHash5 } from "node:crypto";
7272
+ import { createHash as createHash6 } from "node:crypto";
7228
7273
 
7229
7274
  // src/features/magic-context/mural/mural-selection.ts
7230
7275
  var DEFAULT_MURAL_MEMORY_BUDGET = 8000;
@@ -8000,7 +8045,7 @@ function ensureMuralRendered(db, projectIdentity, budgetTokens = DEFAULT_MURAL_M
8000
8045
  log2(`[mural] skipped for ${projectIdentity}: ${skipReason}`);
8001
8046
  return { hasMural: false, rerendered: false, skipReason };
8002
8047
  }
8003
- const textHash = createHash5("sha256").update(plan.layout.text).digest("hex");
8048
+ const textHash = createHash6("sha256").update(plan.layout.text).digest("hex");
8004
8049
  if (existing && existing.contentHash === textHash && existing.width === plan.width && existing.height === plan.height) {
8005
8050
  return rememberRender(db, projectIdentity, key, existing.image, {
8006
8051
  hasMural: true,
@@ -8059,9 +8104,9 @@ function resolveMuralWire(db, projectIdentity, modelKey, enabled, budgetTokens =
8059
8104
  }
8060
8105
 
8061
8106
  // src/features/magic-context/request-tool-definitions.ts
8062
- import { createHash as createHash6 } from "node:crypto";
8107
+ import { createHash as createHash7 } from "node:crypto";
8063
8108
  var IDENTITY_SCOPE = "names-descriptions-v1";
8064
- var sha = (value) => createHash6("sha256").update(JSON.stringify(value)).digest("hex");
8109
+ var sha = (value) => createHash7("sha256").update(JSON.stringify(value)).digest("hex");
8065
8110
  function v2ToolDefinitionsHash(tools) {
8066
8111
  const pairs = Object.entries(tools).map(([name, tool]) => [name, tool.description]).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
8067
8112
  return JSON.stringify({
@@ -8175,7 +8220,7 @@ function classifyRequestToolsChange(previous, current) {
8175
8220
  function requestToolSchemaDigest(schema) {
8176
8221
  const pieces = [];
8177
8222
  writeCanonicalJson(toJsonValue(schema, ""), [], pieces);
8178
- return createHash6("sha256").update(pieces.join("")).digest("hex");
8223
+ return createHash7("sha256").update(pieces.join("")).digest("hex");
8179
8224
  }
8180
8225
  function isJsonValue(value) {
8181
8226
  return value !== undefined && typeof value !== "function" && typeof value !== "symbol";
@@ -8374,14 +8419,14 @@ function parseUserMemoryRow(row) {
8374
8419
  }
8375
8420
 
8376
8421
  // src/features/magic-context/compaction-marker.ts
8377
- import { createHash as createHash7 } from "node:crypto";
8422
+ import { createHash as createHash8 } from "node:crypto";
8378
8423
  import { existsSync as existsSync6, statSync as statSync5 } from "node:fs";
8379
8424
  var BASE62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
8380
8425
  var ID_PREFIX_HEX_LENGTH = 12;
8381
8426
  var ID_SUFFIX_LENGTH = 14;
8382
8427
  var ID_PREFIX_MASK = (1n << BigInt(ID_PREFIX_HEX_LENGTH * 4)) - 1n;
8383
8428
  function deterministicBase62(seed, length) {
8384
- let value = BigInt(`0x${createHash7("sha256").update(seed).digest("hex")}`);
8429
+ let value = BigInt(`0x${createHash8("sha256").update(seed).digest("hex")}`);
8385
8430
  const chars = Array(length);
8386
8431
  for (let index = length - 1;index >= 0; index -= 1) {
8387
8432
  chars[index] = BASE62_CHARS[Number(value % 62n)];
@@ -11433,7 +11478,8 @@ function resolveMuralForM0(options, projectPath, modelKey, budgetTokens, mode =
11433
11478
  return;
11434
11479
  return resolveMuralWire(options.db, projectPath, modelKey, true, budgetTokens, mode);
11435
11480
  }
11436
- function materializeM0(options) {
11481
+ function materializeM0(options, render) {
11482
+ const persist = render?.persist !== false;
11437
11483
  const projectPath = options.projectPath;
11438
11484
  const projectDirectory = options.projectDirectory ?? projectPath ?? "";
11439
11485
  let snapshotMarkers;
@@ -11498,7 +11544,7 @@ function materializeM0(options) {
11498
11544
  })
11499
11545
  };
11500
11546
  const trimmed = workspace.isWorkspaced ? trimWorkspaceMemoriesToBudgetV2(options.sessionId, memories, memoryBudget, workspace, memoryRenderOptions) : trimMemoriesToBudgetV2(options.sessionId, memories, memoryBudget);
11501
- const mural = options.memoryEnabled === false ? undefined : options.mural ?? resolveMuralForM0(options, projectPath, snapshotMarkers.modelKey, memoryBudget);
11547
+ const mural = options.memoryEnabled === false ? undefined : options.mural ?? resolveMuralForM0(options, projectPath, snapshotMarkers.modelKey, memoryBudget, persist ? "persist" : "read-only");
11502
11548
  let decayPressureMultiplier = 1;
11503
11549
  let m0Text = renderM0({
11504
11550
  projectDocs: docs.renderedBlock,
@@ -11539,6 +11585,8 @@ function materializeM0(options) {
11539
11585
  snapshotMarkers.muralHash = frozenMuralHash;
11540
11586
  snapshotMarkers.materializedAt = foldMaterializedAt;
11541
11587
  const renderedMemoryIds = trimmed.renderOrder.map((m) => m.id);
11588
+ if (!persist)
11589
+ return { m0Bytes, m0Text, snapshotMarkers, renderedMemoryIds };
11542
11590
  options.beforePhase3ForTest?.();
11543
11591
  const steps = new WriteTransactionSteps;
11544
11592
  const upgradeIdentity = withCachedM0ToolDefinitionsHash(withCachedM0MemoryIds(encodeCachedM0UpgradeIdentity(snapshotMarkers.upgradeState, snapshotMarkers.compartmentRenderEpoch, snapshotMarkers.muralEnabled, snapshotMarkers.renderBudgetIdentity, snapshotMarkers.memoryRenderEpoch, snapshotMarkers.renderedBudgets ?? null), renderedMemoryIds), snapshotMarkers.toolDefinitionsHash ?? null);
@@ -15482,6 +15530,9 @@ function readCoordinateRebaseNotice(db, sessionId) {
15482
15530
  }) : [];
15483
15531
  return {
15484
15532
  generation: record.generation,
15533
+ ...Object.hasOwn(record, "inheritedGaps") ? {
15534
+ inheritedGaps: Array.isArray(record.inheritedGaps) ? record.inheritedGaps.flatMap((gap) => gap && typeof gap === "object" && Number.isSafeInteger(gap.start) && Number.isSafeInteger(gap.end) && gap.start >= 1 && gap.end >= gap.start ? [{ start: gap.start, end: gap.end }] : []) : []
15535
+ } : {},
15485
15536
  previousGeneration: record.previousGeneration === "v1" || record.previousGeneration === "v2" ? record.previousGeneration : null,
15486
15537
  at: count(record.at),
15487
15538
  unresolvedCompartments: count(record.unresolvedCompartments),
@@ -16015,8 +16066,9 @@ function recoverUnresolvedCompartments(args) {
16015
16066
  const derivedSequences = new Set(result.derived.map((note) => note.sequence));
16016
16067
  const notice = {
16017
16068
  generation,
16069
+ ...previous?.inheritedGaps !== undefined ? { inheritedGaps: previous.inheritedGaps } : {},
16018
16070
  previousGeneration: previous?.previousGeneration ?? null,
16019
- at: previous?.at ?? now,
16071
+ at: previous?.at || now,
16020
16072
  unresolvedCompartments: result.unresolved.length,
16021
16073
  discardedReductions: previous?.discardedReductions ?? 0,
16022
16074
  droppedDepthRows: previous?.droppedDepthRows ?? 0,
@@ -17574,17 +17626,9 @@ async function validateBoundarySnapshotOffThread(args, options = {}) {
17574
17626
  };
17575
17627
  }
17576
17628
 
17577
- // src/hooks/magic-context/compartment-runner-incremental.ts
17578
- var inconsistentProducerWindows = new Set;
17579
- function logInconsistentProducerWindowOnce(sessionId, model, window, reserve) {
17580
- if (inconsistentProducerWindows.has(model))
17581
- return;
17582
- inconsistentProducerWindows.add(model);
17583
- sessionLog2(sessionId, `producer window inconsistent for ${model}: window=${window} reserve=${reserve}; sending unguarded`);
17584
- }
17585
- var HISTORIAN_ALERT_COOLDOWN_MS = 60 * 1000;
17586
- function nonNarrativeStoredGapRanges(db, sessionId, compartments) {
17587
- const rebasedToV2 = readCoordinateRebaseNotice(db, sessionId)?.generation === "v2";
17629
+ // src/hooks/magic-context/stored-compartment-gaps.ts
17630
+ function nonNarrativeStoredGapRanges(db, sessionId, compartments, readRange = (start, end) => readRawSessionMessageRange2(sessionId, start, end), onConversionGap) {
17631
+ const notice = readCoordinateRebaseNotice(db, sessionId);
17588
17632
  const safeRanges = [];
17589
17633
  for (let index = 0;index < compartments.length; index += 1) {
17590
17634
  const previous = compartments[index - 1];
@@ -17595,14 +17639,44 @@ function nonNarrativeStoredGapRanges(db, sessionId, compartments) {
17595
17639
  const end = current.startMessage - 1;
17596
17640
  if (end < start)
17597
17641
  continue;
17598
- const messages = readRawSessionMessageRange2(sessionId, start, end);
17599
- const ordinals = new Set(messages.map((message) => message.ordinal));
17600
- const complete = ordinals.size === end - start + 1 && messages.every((message) => message.ordinal >= start && message.ordinal <= end && (areRustHistorianSyntheticParts2(message.parts) || index > 0 && rebasedToV2 && isStrictGapHealingMessage2(message)));
17601
- if (complete)
17602
- safeRanges.push({ start, end });
17642
+ const ordinals = new Set;
17643
+ let valid = true;
17644
+ let needsConversion = false;
17645
+ for (const message of readRange(start, end)) {
17646
+ const { ordinal } = message;
17647
+ if (ordinal < start || ordinal > end) {
17648
+ valid = false;
17649
+ break;
17650
+ }
17651
+ if (!areRustHistorianSyntheticParts2(message.parts)) {
17652
+ const insideInheritedGap = notice?.inheritedGaps?.some((gap) => gap.start <= ordinal && ordinal <= gap.end);
17653
+ if (index === 0 || notice?.generation !== "v2" || insideInheritedGap === false || !isStrictGapHealingMessage2(message)) {
17654
+ valid = false;
17655
+ break;
17656
+ }
17657
+ needsConversion = true;
17658
+ }
17659
+ ordinals.add(ordinal);
17660
+ }
17661
+ if (valid && ordinals.size === end - start + 1) {
17662
+ const gap = { start, end };
17663
+ safeRanges.push(gap);
17664
+ if (needsConversion)
17665
+ onConversionGap?.(gap);
17666
+ }
17603
17667
  }
17604
17668
  return safeRanges;
17605
17669
  }
17670
+
17671
+ // src/hooks/magic-context/compartment-runner-incremental.ts
17672
+ var inconsistentProducerWindows = new Set;
17673
+ function logInconsistentProducerWindowOnce(sessionId, model, window, reserve) {
17674
+ if (inconsistentProducerWindows.has(model))
17675
+ return;
17676
+ inconsistentProducerWindows.add(model);
17677
+ sessionLog2(sessionId, `producer window inconsistent for ${model}: window=${window} reserve=${reserve}; sending unguarded`);
17678
+ }
17679
+ var HISTORIAN_ALERT_COOLDOWN_MS = 60 * 1000;
17606
17680
  var lastHistorianAlertBySession = new Map;
17607
17681
  var loggedStoredValidationFailures = new Map;
17608
17682
  function logStoredValidationFailureOnce(sessionId, error) {
@@ -19416,4 +19490,4 @@ async function executeContextRecomp(deps, options = {}) {
19416
19490
  return (await executeContextRecompWithResult(deps, options)).message;
19417
19491
  }
19418
19492
 
19419
- export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, isCommitRetentionPaused, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, createChildSessionWithFence, HiddenCompletionRefusal, DreamerProviderOutputFailureError, providerOutputFailureFromInvalidManifest, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, HIDDEN_RUN_DISPOSED_REASON, noteChildOfDisposedInstance, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, hiddenModelCooldowns, ModelProducedNoOutputError, noteModelActivityMonitored, noteModelOutputReceived, isPromptTimeoutError, getPromptFailureDetail, raceWithSignal, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, annotateSubagentInvocationError, failedInvocationStatus, emptyTokenTotals, sumTokensFromChildMessages, recordChildInvocation, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, setKeepSubagents, teardownChildSession, getCompartmentEvents, runTokenLog, formatRunTokenLog, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, v2ToolDefinitionsHash, v2RequestToolsFingerprint, classifyRequestToolsChange, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, startCompactionMarkerCandidatePreparation, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, stripMemoryMuralBlock, servedHeadTexts, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, headMessagesForSizing, rawTailAfterNewestCompartment, hasCompleteCachedM0M1, injectM0M1, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readCoordinateGeneration, readCoordinateRebaseNotice, formatCoordinateRebaseNotice, rebaseSessionCoordinatesAsync, readHistorianFailureStreak, describeHistorianJoinRefusal, shouldWaitForNewHistorianHistory, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, omitIncompleteFileTokenTotals, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
19493
+ export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, isCommitRetentionPaused, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, createChildSessionWithFence, HiddenCompletionRefusal, DreamerProviderOutputFailureError, providerOutputFailureFromInvalidManifest, supportsQuietHiddenChildren, matchesHiddenRunLocation, hiddenRunPlacement, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, HIDDEN_RUN_DISPOSED_REASON, noteChildOfDisposedInstance, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, hiddenModelCooldowns, ModelProducedNoOutputError, noteModelActivityMonitored, noteModelOutputReceived, isPromptTimeoutError, getPromptFailureDetail, raceWithSignal, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, annotateSubagentInvocationError, failedInvocationStatus, emptyTokenTotals, sumTokensFromChildMessages, recordChildInvocation, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, setKeepSubagents, teardownChildSession, getCompartmentEvents, runTokenLog, formatRunTokenLog, validateStoredCompartments, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, v2ToolDefinitionsHash, v2RequestToolsFingerprint, classifyRequestToolsChange, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, startCompactionMarkerCandidatePreparation, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, stripMemoryMuralBlock, servedHeadTexts, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, headMessagesForSizing, rawTailAfterNewestCompartment, hasCompleteCachedM0M1, injectM0M1, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readCoordinateGeneration, readCoordinateRebaseNotice, formatCoordinateRebaseNotice, rebaseSessionCoordinatesAsync, readHistorianFailureStreak, describeHistorianJoinRefusal, shouldWaitForNewHistorianHistory, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, omitIncompleteFileTokenTotals, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, nonNarrativeStoredGapRanges, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
@@ -6,7 +6,7 @@ import {
6
6
  } from "./index-gzy5w8ya.js";
7
7
  import {
8
8
  managedAuthorityNoteRow
9
- } from "./index-xx05vta0.js";
9
+ } from "./index-w2wpx7t5.js";
10
10
 
11
11
  // src/features/magic-context/storage-notes.ts
12
12
  var NOTE_TYPES = new Set(["session", "smart"]);
@@ -38,7 +38,7 @@ import {
38
38
  enqueueShadowEmbeddingItems2,
39
39
  getProjectEmbeddingSnapshot2,
40
40
  embedItemsForProject2
41
- } from "./index-yfn52pb6.js";
41
+ } from "./index-shpyv8gq.js";
42
42
  import {
43
43
  recordEmbeddingMeasurement
44
44
  } from "./index-2amn2s73.js";
@@ -54,7 +54,7 @@ import {
54
54
  sanitizeFtsQuery,
55
55
  searchMemoriesFTS,
56
56
  searchMemoriesFTSUnion
57
- } from "./index-9554nr2q.js";
57
+ } from "./index-fgy6hnr3.js";
58
58
  import {
59
59
  ModuleMemoryAuthorityError2,
60
60
  getMemoriesByProject2,
@@ -71,10 +71,10 @@ import {
71
71
  withMemoryHintContent,
72
72
  autoSearchRelevance,
73
73
  recordAutoSearchLane
74
- } from "./index-m6rkq3t4.js";
74
+ } from "./index-rnyaa7cj.js";
75
75
  import {
76
76
  ensureMemoryEmbeddings2
77
- } from "./index-177yv84k.js";
77
+ } from "./index-w8dcjt7f.js";
78
78
  import {
79
79
  MESSAGE_FTS_SESSION_FILTER_SQL,
80
80
  withMessageFtsSessionFilter
@@ -88,11 +88,11 @@ import {
88
88
  expandWorkspaceIdentitySetWithAliases,
89
89
  resolveStoredPathWorkspaceIdentity,
90
90
  sourceNameForMemory
91
- } from "./index-xx05vta0.js";
91
+ } from "./index-w2wpx7t5.js";
92
92
  import {
93
93
  getNotes,
94
94
  getActivePrimers
95
- } from "./index-tebcx987.js";
95
+ } from "./index-bd34njzg.js";
96
96
  import {
97
97
  isKnownAutocommit
98
98
  } from "./index-8ajstryz.js";
@@ -439,7 +439,7 @@ class V2StoreReader2 {
439
439
  const order = columns.has("time_updated") ? "time_updated DESC, id DESC" : "id DESC";
440
440
  const page = this.prepare(`SELECT id, COALESCE(directory, '') AS directory FROM session_v2
441
441
  WHERE parent_id IS NULL${archived}
442
- AND COALESCE(json_extract(metadata, '$.magic_context'), '') <> 'hidden-run'
442
+ AND COALESCE(json_extract(metadata, '$.magic_context'), '') NOT IN ('hidden-run', 'background-holder')
443
443
  ORDER BY ${order} LIMIT ? OFFSET ?`);
444
444
  const pageSize = 500;
445
445
  for (let offset = 0;; offset += pageSize) {
@@ -460,7 +460,7 @@ class V2StoreReader2 {
460
460
  WHERE session_id = session_v2.id AND type = 'user'
461
461
  ) AS time FROM session_v2
462
462
  WHERE parent_id IS NULL
463
- AND COALESCE(json_extract(metadata, '$.magic_context'), '') <> 'hidden-run'
463
+ AND COALESCE(json_extract(metadata, '$.magic_context'), '') NOT IN ('hidden-run', 'background-holder')
464
464
  AND id IN (${chunk.map(() => "?").join(",")})`).all(...chunk);
465
465
  for (const row of rows)
466
466
  if (row.time !== null)
@@ -746,6 +746,38 @@ class V2StoreReader2 {
746
746
  return this.prepare(`SELECT id, type, seq, time_created FROM session_message
747
747
  WHERE session_id = ? AND seq <= ? ORDER BY seq ASC`).all(sessionID, throughSeq);
748
748
  }
749
+ matchingForkBodies(parentID, forkID, throughSeq) {
750
+ const matchParts = this.hasPartTable() ? `
751
+ AND NOT EXISTS (
752
+ SELECT ordinal, type, call_id, data FROM session_part WHERE message_id = p.id
753
+ EXCEPT SELECT ordinal, type, call_id, data FROM session_part WHERE message_id = f.id
754
+ ) AND NOT EXISTS (
755
+ SELECT ordinal, type, call_id, data FROM session_part WHERE message_id = f.id
756
+ EXCEPT SELECT ordinal, type, call_id, data FROM session_part WHERE message_id = p.id
757
+ )` : "";
758
+ const rows = this.prepare(`SELECT p.id AS parentId, f.id AS forkId FROM session_message p JOIN session_message f ON f.seq = p.seq
759
+ WHERE p.session_id = ? AND f.session_id = ? AND p.seq <= ?
760
+ AND p.type = f.type AND p.time_created = f.time_created AND p.data = f.data${matchParts}`).all(parentID, forkID, throughSeq);
761
+ return new Map(rows.map(({ parentId, forkId }) => [parentId, forkId]));
762
+ }
763
+ *iterateRawMessageRange(sessionID, from, to) {
764
+ if (!Number.isSafeInteger(from) || !Number.isSafeInteger(to) || from < 1 || to < from)
765
+ return;
766
+ let anchor;
767
+ for (let after = from - 1;after < to; after += 1) {
768
+ const [row] = this.messagePage(sessionID, after, 1, to, anchor);
769
+ if (!row)
770
+ return;
771
+ anchor = { id: row.id, timeCreated: row.time_created ?? 0 };
772
+ yield row;
773
+ }
774
+ }
775
+ messageCountAndNewestId(sessionID) {
776
+ const row = this.prepare(`SELECT COUNT(*) AS count, (
777
+ SELECT id FROM session_message WHERE session_id = ? ORDER BY seq DESC LIMIT 1
778
+ ) AS newestId FROM session_message WHERE session_id = ?`).get(sessionID, sessionID);
779
+ return [row.count, row.newestId];
780
+ }
749
781
  latestSequenceForIds(sessionID, ids) {
750
782
  let latest = -1;
751
783
  for (let offset = 0;offset < ids.length; offset += 500) {
@@ -9,7 +9,7 @@ import {
9
9
  getCompartments,
10
10
  getLastCompartmentEndMessage,
11
11
  requestPendingMaterialization
12
- } from "./index-xsdaz3mq.js";
12
+ } from "./index-x8qgqnym.js";
13
13
  import {
14
14
  inRootAsyncContext2
15
15
  } from "./index-gzy5w8ya.js";
@@ -26,7 +26,7 @@ import {
26
26
  } from "./index-2q0t43fy.js";
27
27
  import {
28
28
  pushNotification2
29
- } from "./index-x8a7jmkh.js";
29
+ } from "./index-fzgyvsb1.js";
30
30
  import {
31
31
  describeBoundaryDiagnostics,
32
32
  resolveWrapupProtectedTailBoundary,
@@ -35,14 +35,14 @@ import {
35
35
  getActiveCompartmentRun,
36
36
  markActiveCompartmentRunPublished,
37
37
  registerActiveCompartmentRun
38
- } from "./index-exvsw656.js";
38
+ } from "./index-b2787fk6.js";
39
39
  import {
40
40
  sendStatusNotification2
41
- } from "./index-1sq1krqw.js";
41
+ } from "./index-g6hfh4h4.js";
42
42
  import {
43
43
  setRecompStarting2,
44
44
  setRecompTerminal2
45
- } from "./index-hpmx99e9.js";
45
+ } from "./index-hz1xdb15.js";
46
46
 
47
47
  // src/hooks/magic-context/wrapup-orchestrator.ts
48
48
  import * as crypto from "node:crypto";
@@ -21,7 +21,7 @@ import {
21
21
  import {
22
22
  OpenAICompatibleEmbeddingProvider,
23
23
  embedTextForProject2
24
- } from "./index-yfn52pb6.js";
24
+ } from "./index-shpyv8gq.js";
25
25
  import {
26
26
  saveEmbeddingIfHashMatches
27
27
  } from "./index-4dhv7mqz.js";
@@ -51,6 +51,11 @@ var USER_FACING_FAILURES = {
51
51
  sentence: "History compression is paused because this session's saved summaries no longer line up with its messages.",
52
52
  action: "Run /ctx-recomp to rebuild them."
53
53
  },
54
+ fork_history_gap: {
55
+ code: "MC-H09",
56
+ sentence: "This fork's saved history has a gap.",
57
+ action: "Run /ctx-recomp to rebuild its history."
58
+ },
54
59
  history_boundary_unresolved: {
55
60
  code: "MC-H04",
56
61
  sentence: "This request was not sent: it is larger than the model's context window, and Magic Context could not cut the already-summarized history out of it.",
@@ -737,4 +737,4 @@ function setBootQuietPeriodForTests(startAtMs) {
737
737
  bootQuietUntilMs = startAtMs === null ? 0 : startAtMs + BOOT_QUIET_MS;
738
738
  }
739
739
 
740
- export { pruneMissingProjectIdentities, setHomeProjectPermission, shouldSkipHomeProjectMemory, ProjectIdentityError, resolveProjectIdentityStrict, takeDubiousOwnershipProjectIdentityWarning, isUserHomeDirectory, resolveProjectIdentity, directoryHasGitMetadata, describeUnresolvedProjectIdentity, isUsableProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, beginBootQuietPeriod, bootQuietRemainingMs, scheduleAfterBootQuiet, setBootQuietPeriodForTests };
740
+ export { pruneMissingProjectIdentities, setHomeProjectPermission, shouldSkipHomeProjectMemory, ProjectIdentityError, directoryFallback, resolveProjectIdentityStrict, takeDubiousOwnershipProjectIdentityWarning, isUserHomeDirectory, resolveProjectIdentity, directoryHasGitMetadata, describeUnresolvedProjectIdentity, isUsableProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, beginBootQuietPeriod, bootQuietRemainingMs, scheduleAfterBootQuiet, setBootQuietPeriodForTests };
@@ -15,9 +15,20 @@ function notificationMatchesSink(notification, sink) {
15
15
  return notification.sessionId === sink.sessionId;
16
16
  return sink.protocol !== 2;
17
17
  }
18
- function pushNotification2(type, payload, sessionId) {
18
+ function pushLiveNotification2(type, payload, sessionId) {
19
19
  const notification = { id: nextNotificationId++, type, payload, sessionId };
20
- queue.push(notification);
20
+ for (const sink of sinks) {
21
+ if (sink.sessionId !== sessionId)
22
+ continue;
23
+ try {
24
+ sink.send(notification);
25
+ } catch {}
26
+ }
27
+ }
28
+ function pushNotification2(type, payload, sessionId, options) {
29
+ const notification = { id: nextNotificationId++, type, payload, sessionId };
30
+ if (!options?.liveOnly)
31
+ queue.push(notification);
21
32
  for (const sink of sinks) {
22
33
  if (!notificationMatchesSink(notification, sink))
23
34
  continue;
@@ -25,7 +36,7 @@ function pushNotification2(type, payload, sessionId) {
25
36
  sink.send(notification);
26
37
  } catch {}
27
38
  }
28
- if (queue.length > 100) {
39
+ if (!options?.liveOnly && queue.length > 100) {
29
40
  const reservedIds = new Set;
30
41
  const reservedScopes = new Set;
31
42
  for (let i = queue.length - 1;i >= 0 && reservedScopes.size < 25; i -= 1) {
@@ -101,4 +112,4 @@ function isTuiConnected2(sessionId) {
101
112
  return false;
102
113
  }
103
114
 
104
- export { registerNotificationSink2, pushNotification2, acknowledgeNotifications2, __resetNotificationStateForTests2, drainNotifications2, isTuiConnected2 };
115
+ export { registerNotificationSink2, pushLiveNotification2, pushNotification2, acknowledgeNotifications2, __resetNotificationStateForTests2, drainNotifications2, isTuiConnected2 };
@@ -53,11 +53,11 @@ async function trySendTuiToast(sessionId, text, params, forcePersist) {
53
53
  const message = text.length > 200 ? `${text.slice(0, 200)}…` : text;
54
54
  const toastVariant = inferToastVariant(text);
55
55
  const duration = params.toastDurationMs ?? 5000;
56
- const { isTuiConnected: checkTui } = await importPluginModule(() => import("./rpc-notifications-3hed126v.js"));
56
+ const { isTuiConnected: checkTui } = await importPluginModule(() => import("./rpc-notifications-t9q0ynq7.js"));
57
57
  if (!checkTui(sessionId))
58
58
  return false;
59
59
  try {
60
- const { pushNotification } = await importPluginModule(() => import("./rpc-notifications-3hed126v.js"));
60
+ const { pushNotification } = await importPluginModule(() => import("./rpc-notifications-t9q0ynq7.js"));
61
61
  pushNotification("toast", {
62
62
  title,
63
63
  message,
@@ -286,7 +286,7 @@ async function sendCommandResult2(client, sessionId, text, params) {
286
286
  if (shouldHoldIgnoredNotification(sessionId)) {
287
287
  return sendIgnoredMessage2(client, sessionId, text, params);
288
288
  }
289
- const { isTuiConnected } = await importPluginModule(() => import("./rpc-notifications-3hed126v.js"));
289
+ const { isTuiConnected } = await importPluginModule(() => import("./rpc-notifications-t9q0ynq7.js"));
290
290
  if (isTuiConnected(sessionId))
291
291
  return sendIgnoredMessage2(client, sessionId, text, params);
292
292
  const session = client?.session;
@@ -386,7 +386,7 @@ function observeIgnoredNotificationEvent2(event) {
386
386
  }
387
387
  async function sendStatusNotification2(_client, sessionId, text, params) {
388
388
  try {
389
- const { pushNotification } = await importPluginModule(() => import("./rpc-notifications-3hed126v.js"));
389
+ const { pushNotification } = await importPluginModule(() => import("./rpc-notifications-t9q0ynq7.js"));
390
390
  pushNotification("toast", {
391
391
  title: extractToastTitle(text),
392
392
  message: text,