@cortexkit/opencode-magic-context 0.49.56 → 0.49.59

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 (177) hide show
  1. package/dist/{announcement-9pr71hd5.js → announcement-p41dde4h.js} +2 -2
  2. package/dist/auto-search-worker.js +5 -5
  3. package/dist/chunk-embedding-write-worker.js +13 -13
  4. package/dist/{compaction-marker-candidates-8hazqfvj.js → compaction-marker-candidates-1ndjqh9k.js} +2 -2
  5. package/dist/compaction-marker-candidates-worker.js +1 -1
  6. package/dist/{compartment-chunk-embedding-gfd093f8.js → compartment-chunk-embedding-ymc9mtwv.js} +7 -7
  7. package/dist/{conflict-warning-hook-56qpq7ws.js → conflict-warning-hook-m8yezwdj.js} +7 -7
  8. package/dist/{context-bejy30t5.js → context-aexc6pbs.js} +69 -44
  9. package/dist/{derive-budgets-z53424qx.js → derive-budgets-heypxqdz.js} +2 -2
  10. package/dist/{embedding-backfill-2dvf3rcn.js → embedding-backfill-sk7agn5v.js} +12 -12
  11. package/dist/embedding-worker-process.js +1 -1
  12. package/dist/embedding-worker.js +4 -4
  13. package/dist/features/magic-context/mural/render-mural.d.ts +17 -0
  14. package/dist/features/magic-context/mural/render-mural.d.ts.map +1 -1
  15. package/dist/features/magic-context/mural/render-trigger.d.ts +2 -1
  16. package/dist/features/magic-context/mural/render-trigger.d.ts.map +1 -1
  17. package/dist/features/magic-context/mural/resolve-mural.d.ts +8 -2
  18. package/dist/features/magic-context/mural/resolve-mural.d.ts.map +1 -1
  19. package/dist/features/magic-context/storage-historian-runs.d.ts +7 -0
  20. package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
  21. package/dist/{history-owner-n50e0e8y.js → history-owner-xqfsvf9k.js} +2 -2
  22. package/dist/hooks/magic-context/command-handler.d.ts +2 -0
  23. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/compartment-runner-types.d.ts +9 -0
  27. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/compartment-runner.d.ts +7 -1
  29. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/historian-failure-report.d.ts +112 -0
  31. package/dist/hooks/magic-context/historian-failure-report.d.ts.map +1 -0
  32. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +11 -1
  35. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  37. package/dist/{index-5ptp2de1.js → index-0cz8bsyx.js} +9 -9
  38. package/dist/{index-r9agn061.js → index-1sq1krqw.js} +4 -4
  39. package/dist/{index-b6rdv8re.js → index-3hk445am.js} +4 -4
  40. package/dist/{index-by14cr73.js → index-3yyfftqq.js} +11 -11
  41. package/dist/{index-ffab4edg.js → index-575njz7q.js} +74 -50
  42. package/dist/{index-gapnh6tk.js → index-5ps3axh5.js} +1 -1
  43. package/dist/{index-0tz2fzpq.js → index-5vsk2cpp.js} +1 -1
  44. package/dist/{index-90z05d0p.js → index-832w615x.js} +1 -1
  45. package/dist/{index-sk6p6esd.js → index-8sc7vqt7.js} +4 -4
  46. package/dist/{index-cd3vp8xa.js → index-98qy103c.js} +1 -1
  47. package/dist/{index-3jeq08jv.js → index-a09sw9fx.js} +380 -93
  48. package/dist/{index-29ff546v.js → index-d0feqcs5.js} +6 -6
  49. package/dist/{index-gz001bx7.js → index-e6ncz7a6.js} +1 -1
  50. package/dist/{index-reyws9fy.js → index-esqcwes7.js} +1 -1
  51. package/dist/{index-h62j8z2r.js → index-ev2rrjfc.js} +4 -4
  52. package/dist/{index-sx1sppd6.js → index-gq1g9a3a.js} +8 -8
  53. package/dist/{index-ga5q492k.js → index-gqf8r04r.js} +1 -1
  54. package/dist/{index-5483ntzh.js → index-gth4t4ar.js} +5 -5
  55. package/dist/{index-pxfb7pp8.js → index-j4aeh6tx.js} +14 -14
  56. package/dist/{index-qperbvjn.js → index-jg7sbt3v.js} +2 -2
  57. package/dist/{index-9mggb1nv.js → index-jrj95cce.js} +2 -2
  58. package/dist/{index-12p4j9wa.js → index-kv4ntrr6.js} +5 -5
  59. package/dist/{index-tad3can2.js → index-m0pwswv9.js} +1 -1
  60. package/dist/{index-pdh4tdcq.js → index-n6aye6ny.js} +2 -2
  61. package/dist/{index-hsyczpn7.js → index-pxnzyvjc.js} +2 -2
  62. package/dist/{index-kn1bx21r.js → index-pzvdf7sr.js} +3 -3
  63. package/dist/{index-36wseasx.js → index-q7q6qp1f.js} +1 -1
  64. package/dist/{index-qfc1kjh4.js → index-s2jdky2x.js} +3 -3
  65. package/dist/{index-2ny9xwdn.js → index-s32f8y67.js} +2 -2
  66. package/dist/{index-3wmp1nb7.js → index-s3t4vk21.js} +7 -7
  67. package/dist/{index-hexdee98.js → index-snbpdpa3.js} +4 -4
  68. package/dist/{index-dhdv88e5.js → index-tebcx987.js} +1 -1
  69. package/dist/{index-5gqszjq9.js → index-tq20edcs.js} +3 -3
  70. package/dist/{index-0k283v27.js → index-tzy5h4x6.js} +1 -1
  71. package/dist/{index-em92bp7f.js → index-x40zr813.js} +2 -2
  72. package/dist/{index-sv5tn72j.js → index-xx05vta0.js} +4 -4
  73. package/dist/{index-82dfe8en.js → index-ywrz4wy2.js} +9 -4
  74. package/dist/{index-wgbp5zch.js → index-ywxvdwmj.js} +25 -10
  75. package/dist/{index-xstbytjn.js → index-zb4h9nrk.js} +2 -2
  76. package/dist/{index-2vsd5064.js → index-zxj39ba2.js} +4 -4
  77. package/dist/index.js +51 -50
  78. package/dist/{logger-sw7z6sjz.js → logger-d7c8akh9.js} +1 -1
  79. package/dist/{message-fts-rowid-map-kx1bsdyg.js → message-fts-rowid-map-0xx8ge09.js} +4 -4
  80. package/dist/{message-index-bounded-xav3h8qe.js → message-index-bounded-f6yz4xq8.js} +10 -10
  81. package/dist/{message-time-backfill-hp2jgn49.js → message-time-backfill-pz5981mf.js} +2 -2
  82. package/dist/migration-worker.js +10 -10
  83. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  84. package/dist/{project-embedding-registry-f2azrq24.js → project-embedding-registry-c2sfnamh.js} +11 -11
  85. package/dist/raw-ordinal-warmup-worker.js +8 -8
  86. package/dist/{read-session-chunk-70aam2c1.js → read-session-chunk-8b1g06nz.js} +8 -8
  87. package/dist/{read-session-raw-04ger9zt.js → read-session-raw-3sc9231y.js} +2 -2
  88. package/dist/{recomp-orchestrator-2tsjqbrm.js → recomp-orchestrator-zqn9zwxn.js} +29 -29
  89. package/dist/{render-fgxbcmnh.js → render-nrfbtkkw.js} +19 -19
  90. package/dist/{safe-notification-target-mx5khyxf.js → safe-notification-target-d21swr3n.js} +2 -2
  91. package/dist/{search-archive-0mz3p1g1.js → search-archive-1ppdjfm9.js} +10 -10
  92. package/dist/{search-jfwb4ms3.js → search-xha0r30f.js} +22 -22
  93. package/dist/{send-session-notification-gamjee2f.js → send-session-notification-ykvt5k2s.js} +5 -5
  94. package/dist/shared/data-path.d.ts +31 -36
  95. package/dist/shared/data-path.d.ts.map +1 -1
  96. package/dist/shared/test-temp-dir.d.ts +28 -0
  97. package/dist/shared/test-temp-dir.d.ts.map +1 -1
  98. package/dist/{storage-tags-arnkn5t1.js → storage-tags-spet01yb.js} +5 -5
  99. package/dist/{transform-postprocess-phase-64xtx439.js → transform-postprocess-phase-gxb3sp91.js} +30 -30
  100. package/dist/v2/auto-search-worker.js +5 -5
  101. package/dist/v2/chunk-embedding-write-worker.js +13 -13
  102. package/dist/v2/{compaction-marker-candidates-re14353a.js → compaction-marker-candidates-bp1bn579.js} +2 -2
  103. package/dist/v2/compaction-marker-candidates-worker.js +1 -1
  104. package/dist/v2/{compartment-chunk-embedding-0pxsrzrt.js → compartment-chunk-embedding-x6qw6mjk.js} +7 -7
  105. package/dist/v2/{context-5hhm89jw.js → context-wszt0gbq.js} +102 -57
  106. package/dist/v2/{derive-budgets-w0815q82.js → derive-budgets-gw030jzt.js} +3 -3
  107. package/dist/v2/{embedding-backfill-48qbnh7p.js → embedding-backfill-j2xj86zn.js} +12 -12
  108. package/dist/v2/embedding-worker-process.js +1 -1
  109. package/dist/v2/embedding-worker.js +4 -4
  110. package/dist/v2/{history-owner-ep91wgqj.js → history-owner-260djmv5.js} +2 -2
  111. package/dist/v2/hooks/claude-agent-instructions.d.ts +27 -0
  112. package/dist/v2/hooks/claude-agent-instructions.d.ts.map +1 -0
  113. package/dist/v2/hooks/context.d.ts.map +1 -1
  114. package/dist/v2/hooks/hidden-child.d.ts +15 -2
  115. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  116. package/dist/v2/hooks/usage-persist.d.ts +7 -1
  117. package/dist/v2/hooks/usage-persist.d.ts.map +1 -1
  118. package/dist/v2/{logger-xnscpj6w.js → logger-zyf43np1.js} +1 -1
  119. package/dist/v2/{message-fts-rowid-map-57jh6xpb.js → message-fts-rowid-map-n8mcvcpz.js} +4 -4
  120. package/dist/v2/{message-index-bounded-sw8hyqw1.js → message-index-bounded-0w8eh8fc.js} +10 -10
  121. package/dist/v2/{message-time-backfill-baxebka0.js → message-time-backfill-ynb3vg6r.js} +2 -2
  122. package/dist/v2/migration-worker.js +10 -10
  123. package/dist/v2/{project-embedding-registry-kwahtjgg.js → project-embedding-registry-k0hjqt11.js} +11 -11
  124. package/dist/v2/raw-ordinal-warmup-worker.js +8 -8
  125. package/dist/v2/{read-session-chunk-nqkn0yb4.js → read-session-chunk-dxs1tgt9.js} +8 -8
  126. package/dist/v2/{read-session-raw-3e482h3c.js → read-session-raw-wg5zc29f.js} +2 -2
  127. package/dist/v2/{recomp-orchestrator-dzdxrgdt.js → recomp-orchestrator-76rv3b89.js} +30 -30
  128. package/dist/v2/{render-jfa3hj8z.js → render-9knrdrjs.js} +19 -19
  129. package/dist/v2/{safe-notification-target-9r79xnbt.js → safe-notification-target-y55z2zat.js} +2 -2
  130. package/dist/v2/{search-8dc9ex0a.js → search-a2a0qs3t.js} +21 -21
  131. package/dist/v2/{search-archive-p4s9q7a3.js → search-archive-2jmyvj69.js} +10 -10
  132. package/dist/v2/{send-session-notification-95p89k7q.js → send-session-notification-8g4r97bp.js} +5 -5
  133. package/dist/v2/{server-7vrtk78d.js → server-3ap5dmhc.js} +1 -1
  134. package/dist/v2/{server-avfc9ezb.js → server-4r86tcs2.js} +3 -3
  135. package/dist/v2/{server-np27dgyt.js → server-5sbsnpkn.js} +1 -1
  136. package/dist/v2/{server-rz5jnhnv.js → server-6ash6z8z.js} +1 -1
  137. package/dist/v2/{server-beydmd68.js → server-88n85n60.js} +4 -4
  138. package/dist/v2/{server-g61hgy1y.js → server-8pdfmc27.js} +4 -4
  139. package/dist/v2/{server-gge95a03.js → server-8ycacd59.js} +6 -6
  140. package/dist/v2/{server-8e5m2gre.js → server-9ab9jnpq.js} +3 -3
  141. package/dist/v2/{server-z6sxv6n3.js → server-9emfsa60.js} +382 -95
  142. package/dist/v2/{server-kyfj1090.js → server-9m5r04ws.js} +5 -5
  143. package/dist/v2/{server-3yk44ddz.js → server-afsz3cmx.js} +1 -1
  144. package/dist/v2/{server-c8z2grq0.js → server-at0v0z4t.js} +1 -1
  145. package/dist/v2/{server-v817sf79.js → server-d07yxksx.js} +2 -2
  146. package/dist/v2/{server-kwtnrhv3.js → server-d706s5xn.js} +2 -2
  147. package/dist/v2/{server-ycvqg2s3.js → server-d9aayyxk.js} +4 -4
  148. package/dist/v2/{server-966dq3pd.js → server-ds8vpfkr.js} +2 -2
  149. package/dist/v2/{server-bb6kf05j.js → server-j8376q08.js} +9 -4
  150. package/dist/v2/{server-7waad75d.js → server-ja6swvmb.js} +11 -11
  151. package/dist/v2/{server-tmf0ayqp.js → server-jdfe07mp.js} +1 -1
  152. package/dist/v2/{server-6k0rnwbd.js → server-jn4pktdk.js} +4 -4
  153. package/dist/v2/{server-qp5sj6n5.js → server-jtq03rkb.js} +2 -2
  154. package/dist/v2/{server-sa1fdt41.js → server-kc5kb9ya.js} +1 -1
  155. package/dist/v2/{server-91gb0vh8.js → server-npdey91q.js} +1 -1
  156. package/dist/v2/{server-vqq3g1t7.js → server-qjff96a6.js} +4 -4
  157. package/dist/v2/{server-4x0xq8a1.js → server-rbtx6q5v.js} +1 -1
  158. package/dist/v2/{server-jwydbwcx.js → server-svx20ra2.js} +4 -4
  159. package/dist/v2/{server-q02z0jq7.js → server-t8tmrtcg.js} +25 -10
  160. package/dist/v2/{server-0ayyh3mx.js → server-tzh55x6d.js} +9 -9
  161. package/dist/v2/{server-5p0bjk3y.js → server-v1s0cb4v.js} +2 -2
  162. package/dist/v2/{server-mxsy9h1d.js → server-x6fn9x8q.js} +2 -2
  163. package/dist/v2/{server-b0357as4.js → server-xepx8t43.js} +2 -2
  164. package/dist/v2/{server-3jc6qmdz.js → server-y8xjr8rx.js} +1 -1
  165. package/dist/v2/{server-5kgesxck.js → server-ypaat9rj.js} +2 -2
  166. package/dist/v2/{server-rpmkz5ta.js → server-z5255w05.js} +8 -8
  167. package/dist/v2/server.js +5 -5
  168. package/dist/v2/{storage-tags-19da4c0m.js → storage-tags-50wsqg3t.js} +5 -5
  169. package/dist/v2/{v2-archive-reader-jpdh0ktt.js → v2-archive-reader-ycjh6a2d.js} +1 -1
  170. package/dist/v2/{wrapup-orchestrator-5dfj2mcs.js → wrapup-orchestrator-ejcx02g2.js} +30 -30
  171. package/dist/{v2-archive-reader-557b5dn3.js → v2-archive-reader-wec0a8fx.js} +1 -1
  172. package/dist/wrapup-orchestrator-e7mczz6e.js +54 -0
  173. package/package.json +1 -1
  174. package/src/shared/data-path.test.ts +27 -10
  175. package/src/shared/data-path.ts +39 -39
  176. package/src/shared/test-temp-dir.ts +59 -0
  177. package/dist/wrapup-orchestrator-21hgybdk.js +0 -54
@@ -3,11 +3,10 @@ import {
3
3
  harnessOwnsOpenCodeStore2
4
4
  } from "./server-pavzsdc6.js";
5
5
  import {
6
- ensureCortexKitArtifactGitignore,
7
- getProjectMagicContextHistorianDir,
6
+ getMagicContextHistorianSessionDir,
8
7
  log2,
9
8
  sessionLog2
10
- } from "./server-bb6kf05j.js";
9
+ } from "./server-j8376q08.js";
11
10
  import {
12
11
  sanitizeDiagnosticText
13
12
  } from "./server-z4p0ry94.js";
@@ -20,13 +19,13 @@ import {
20
19
  cortexKitProjectConfigBasePath,
21
20
  resolveLegacyConfigSourcesForHarness,
22
21
  loadPluginConfigDetailed
23
- } from "./server-5p0bjk3y.js";
22
+ } from "./server-v1s0cb4v.js";
24
23
  import {
25
24
  catalogOutputReserve,
26
25
  getSdkContextLimit,
27
26
  modelSupportsVision,
28
27
  getSdkOutputLimit
29
- } from "./server-sa1fdt41.js";
28
+ } from "./server-kc5kb9ya.js";
30
29
  import {
31
30
  withContentLanguageDirective,
32
31
  buildPrimaryLanguageDirective,
@@ -48,7 +47,7 @@ import {
48
47
  RawOrdinalsNotReady2,
49
48
  dropRawSessionOrdinalCheckpoints2,
50
49
  runSessionWarmupWorker
51
- } from "./server-rz5jnhnv.js";
50
+ } from "./server-6ash6z8z.js";
52
51
  import {
53
52
  providerMass,
54
53
  calibrationForModelKey,
@@ -64,6 +63,7 @@ import {
64
63
  persistCachedM0,
65
64
  clearCachedM0M1,
66
65
  describeProtectedTailDrainBudgetSkip,
66
+ loadPersistedUsage,
67
67
  loadProtectedTailMeta,
68
68
  markProtectedTailPolicyV3Seeded,
69
69
  recordProtectedTailPublicationFloor,
@@ -100,15 +100,15 @@ import {
100
100
  foldShrunkPartTags2,
101
101
  getTagNumberByMessageId2,
102
102
  getActiveTagsBySession2
103
- } from "./server-beydmd68.js";
103
+ } from "./server-88n85n60.js";
104
104
  import {
105
105
  hasMeaningfulUserText2,
106
106
  estimateTokens,
107
107
  estimateFixedPromptTokens
108
- } from "./server-3jc6qmdz.js";
108
+ } from "./server-y8xjr8rx.js";
109
109
  import {
110
110
  BoundedSessionMap
111
- } from "./server-b0357as4.js";
111
+ } from "./server-xepx8t43.js";
112
112
  import {
113
113
  resolveOpenCodeDbPath,
114
114
  assertOpenCodeStoreGeneration,
@@ -119,7 +119,7 @@ import {
119
119
  openCodeDbExists,
120
120
  withReadOnlySessionDb,
121
121
  getMessageTimesFromOpenCodeDb
122
- } from "./server-7vrtk78d.js";
122
+ } from "./server-3ap5dmhc.js";
123
123
  import {
124
124
  removeUnsupportedCommitHashes,
125
125
  completedToolArcCrossesBoundary,
@@ -155,14 +155,14 @@ import {
155
155
  getRawSessionTagKeysThrough2,
156
156
  getLegacyProtectedTailStartOrdinal2,
157
157
  readSessionChunk2
158
- } from "./server-gge95a03.js";
158
+ } from "./server-8ycacd59.js";
159
159
  import {
160
160
  clearCompressionDepth,
161
161
  clearCompressionDepthRange,
162
162
  toMessageIndexSource,
163
163
  clearIndexedMessagesInTransaction,
164
164
  indexSourcesAfterOrdinal
165
- } from "./server-jwydbwcx.js";
165
+ } from "./server-svx20ra2.js";
166
166
  import {
167
167
  COMPARTMENT_LEASE_RENEWAL_MS,
168
168
  getCompartmentLeaseBlocker,
@@ -194,6 +194,7 @@ import {
194
194
  requestPendingMaterialization,
195
195
  dropSlot,
196
196
  externalHistorianFailureReason,
197
+ getRecentFailedHistorianRunTimes,
197
198
  recordHistorianRun,
198
199
  summarizeImportance,
199
200
  tallyFactsByCategory,
@@ -206,7 +207,7 @@ import {
206
207
  getProjectState,
207
208
  recordSubagentInvocation,
208
209
  getLatestHistorianInvocationId
209
- } from "./server-q02z0jq7.js";
210
+ } from "./server-t8tmrtcg.js";
210
211
  import {
211
212
  invalidateAutoEmbedSession
212
213
  } from "./server-2amn2s73.js";
@@ -219,7 +220,7 @@ import {
219
220
  replaceCompartmentChunkEmbeddings2,
220
221
  deleteChunkEmbedBackoffForSession2,
221
222
  chunkWindowSourceKey2
222
- } from "./server-g61hgy1y.js";
223
+ } from "./server-8pdfmc27.js";
223
224
  import {
224
225
  isMarkerCandidateBasisCurrent2,
225
226
  invalidateMarkerCandidateBasis2,
@@ -230,18 +231,18 @@ import {
230
231
  certifiedMarkerReferenceFloor2,
231
232
  readMarkerReferenceRows2,
232
233
  readKnownMarkerReferenceRows2
233
- } from "./server-c8z2grq0.js";
234
+ } from "./server-at0v0z4t.js";
234
235
  import {
235
236
  shouldSkipHomeProjectMemory,
236
237
  resolveProjectIdentity
237
- } from "./server-3yk44ddz.js";
238
+ } from "./server-afsz3cmx.js";
238
239
  import {
239
240
  contentSha2562,
240
241
  enqueueShadowEmbeddingItems2,
241
242
  getProjectChunkEmbeddingModelId2,
242
243
  getProjectEmbeddingMaxInputTokens2,
243
244
  embedItemsWindowBounded2
244
- } from "./server-rpmkz5ta.js";
245
+ } from "./server-z5255w05.js";
245
246
  import {
246
247
  V2_MEMORY_CATEGORIES,
247
248
  CATEGORY_PRIORITY,
@@ -260,13 +261,13 @@ import {
260
261
  userFacingFailureCode,
261
262
  promoteSessionFactsDurable,
262
263
  embedPromotedFacts
263
- } from "./server-v817sf79.js";
264
+ } from "./server-d07yxksx.js";
264
265
  import {
265
266
  getSchemaFenceRejection,
266
267
  LATEST_SUPPORTED_VERSION,
267
268
  getPersistedSchemaVersion,
268
269
  openDatabase
269
- } from "./server-0ayyh3mx.js";
270
+ } from "./server-tzh55x6d.js";
270
271
  import {
271
272
  parseCompartmentOutput,
272
273
  resolveWorkspaceShareCategories,
@@ -275,7 +276,7 @@ import {
275
276
  resolveStoredPathWorkspaceIdentity,
276
277
  sourceNameForMemory,
277
278
  computeWorkspaceEpochFingerprint
278
- } from "./server-6k0rnwbd.js";
279
+ } from "./server-jn4pktdk.js";
279
280
  import {
280
281
  FAIL_CLOSED_DOCTOR_COMMAND
281
282
  } from "./server-468mya5v.js";
@@ -283,7 +284,7 @@ import {
283
284
  getSessionNotes,
284
285
  getReadySmartNotes,
285
286
  insertPrimerCandidates
286
- } from "./server-4x0xq8a1.js";
287
+ } from "./server-rbtx6q5v.js";
287
288
  import {
288
289
  pushNotification2
289
290
  } from "./server-x8a7jmkh.js";
@@ -291,10 +292,10 @@ import {
291
292
  deriveTriggerBudget2,
292
293
  resolveHistorianProducerLimits2,
293
294
  producerSourceLocalBudget2
294
- } from "./server-5kgesxck.js";
295
+ } from "./server-ypaat9rj.js";
295
296
  import {
296
297
  sendStatusNotification2
297
- } from "./server-vqq3g1t7.js";
298
+ } from "./server-qjff96a6.js";
298
299
  import {
299
300
  retreatPastHostUnservedRows,
300
301
  snapTerminalCompartmentToServedRow,
@@ -314,7 +315,7 @@ import {
314
315
  import {
315
316
  logSlowWriteTransaction,
316
317
  WriteTransactionSteps
317
- } from "./server-np27dgyt.js";
318
+ } from "./server-5sbsnpkn.js";
318
319
 
319
320
  // src/config/live-snapshot.ts
320
321
  import { createHash } from "node:crypto";
@@ -2726,6 +2727,19 @@ function withoutHistorianTailCache(body) {
2726
2727
  return body;
2727
2728
  }
2728
2729
 
2730
+ // src/v2/hooks/claude-agent-instructions.ts
2731
+ var CLAUDE_AGENT_PROVIDER_ID = "claude-agent";
2732
+ function deliversInstructionsInUserMessage(providerID) {
2733
+ return providerID === CLAUDE_AGENT_PROVIDER_ID;
2734
+ }
2735
+ function claudeAgentInstructionsText(system) {
2736
+ return `Instructions for this task:
2737
+
2738
+ <instructions>
2739
+ ${system}
2740
+ </instructions>`;
2741
+ }
2742
+
2729
2743
  // src/v2/hooks/hidden-child.ts
2730
2744
  var HIDDEN_HISTORIAN_AGENT = "historian";
2731
2745
  var HIDDEN_DREAMER_AGENT = "dreamer-classifier";
@@ -2833,14 +2847,14 @@ class HiddenAgentStepLimit extends Error {
2833
2847
  this.cap = cap;
2834
2848
  }
2835
2849
  }
2836
- function newestUserText(draft) {
2837
- const message = draft.messages.at(-1);
2850
+ function userTexts(message) {
2838
2851
  if (!message || message.role !== undefined && message.role !== "user")
2839
- return;
2852
+ return [];
2840
2853
  const content = message.content;
2841
2854
  if (typeof content === "string" && content.length > 0)
2842
- return content;
2855
+ return [content];
2843
2856
  const parts = Array.isArray(content) ? content : Array.isArray(message.parts) ? message.parts : [];
2857
+ const texts = [];
2844
2858
  for (const part of parts) {
2845
2859
  if (!part || typeof part !== "object")
2846
2860
  continue;
@@ -2848,10 +2862,10 @@ function newestUserText(draft) {
2848
2862
  if (typeof record.text !== "string" || record.text.length === 0)
2849
2863
  continue;
2850
2864
  if (record.type === undefined || record.type === "text" || record.type === "input_text") {
2851
- return record.text;
2865
+ texts.push(record.text);
2852
2866
  }
2853
2867
  }
2854
- return;
2868
+ return texts;
2855
2869
  }
2856
2870
  function authoredOptions(attempt) {
2857
2871
  const cap = attempt.identity.maxOutputTokens;
@@ -2887,6 +2901,33 @@ function markerCandidates(text) {
2887
2901
  const summary = hostCheckpointSummary(text);
2888
2902
  return [text, stripped, ...summary === undefined ? [] : [summary]];
2889
2903
  }
2904
+ function carriesMarker(texts, marker) {
2905
+ return texts.some((text) => markerCandidates(text).includes(marker));
2906
+ }
2907
+ function sharedPrefixBytes(a, b) {
2908
+ let offset = 0;
2909
+ while (offset < a.length && offset < b.length && a[offset] === b[offset])
2910
+ offset++;
2911
+ return offset;
2912
+ }
2913
+ function closestText(texts, markers) {
2914
+ let closest = texts[0];
2915
+ let best = 0;
2916
+ for (const text of texts) {
2917
+ for (const candidate of markerCandidates(text)) {
2918
+ const bytes = Buffer.from(candidate, "utf8");
2919
+ for (const marker of markers) {
2920
+ const shared = sharedPrefixBytes(bytes, Buffer.from(marker, "utf8"));
2921
+ if (shared > best) {
2922
+ best = shared;
2923
+ closest = text;
2924
+ }
2925
+ }
2926
+ }
2927
+ }
2928
+ return closest;
2929
+ }
2930
+ var REFUSAL_PART_DIGESTS = 8;
2890
2931
  function textDigest(text) {
2891
2932
  return {
2892
2933
  length: text.length,
@@ -2896,9 +2937,7 @@ function textDigest(text) {
2896
2937
  function firstDifference(a, b) {
2897
2938
  const left = Buffer.from(a, "utf8");
2898
2939
  const right = Buffer.from(b, "utf8");
2899
- let offset = 0;
2900
- while (offset < left.length && offset < right.length && left[offset] === right[offset])
2901
- offset++;
2940
+ const offset = sharedPrefixBytes(left, right);
2902
2941
  if (offset === left.length && offset === right.length)
2903
2942
  return;
2904
2943
  return {
@@ -2982,15 +3021,14 @@ class HiddenChildHook {
2982
3021
  }
2983
3022
  return marker;
2984
3023
  }
2985
- refuse(reason, draft, raw, inFlight, code = "hidden_prompt_unrecognized") {
2986
- const registered = [...this.attempts.values()].filter((attempt) => attempt.childSessionId === draft.sessionID && attempt.marker).map((attempt) => {
2987
- const marker = attempt.marker;
2988
- return {
2989
- ...textDigest(marker),
2990
- shaped: attempt.shaped,
2991
- ...raw === undefined ? {} : { first_difference: firstDifference(raw, marker) }
2992
- };
2993
- });
3024
+ refuse(reason, draft, texts, inFlight, code = "hidden_prompt_unrecognized") {
3025
+ const markers = [...this.attempts.values()].filter((attempt) => attempt.childSessionId === draft.sessionID && attempt.marker).map((attempt) => ({ attempt, marker: attempt.marker }));
3026
+ const raw = texts === undefined ? undefined : closestText(texts, markers.map(({ marker }) => marker));
3027
+ const registered = markers.map(({ attempt, marker }) => ({
3028
+ ...textDigest(marker),
3029
+ shaped: attempt.shaped,
3030
+ ...raw === undefined ? {} : { first_difference: firstDifference(raw, marker) }
3031
+ }));
2994
3032
  const newest = draft.messages.at(-1);
2995
3033
  const summary = raw === undefined ? undefined : hostCheckpointSummary(raw);
2996
3034
  this.note(`[magic-context] hidden child refused: ${reason} ${JSON.stringify({
@@ -2998,6 +3036,7 @@ class HiddenChildHook {
2998
3036
  messages: draft.messages.length,
2999
3037
  newest_role: newest?.role ?? null,
3000
3038
  received: raw === undefined ? null : textDigest(raw),
3039
+ ...texts !== undefined && texts.length > 1 ? { received_parts: texts.slice(0, REFUSAL_PART_DIGESTS).map(textDigest) } : {},
3001
3040
  checkpoint_summary: summary === undefined ? null : textDigest(summary),
3002
3041
  registered,
3003
3042
  active: this.active.has(draft.sessionID),
@@ -3010,40 +3049,50 @@ class HiddenChildHook {
3010
3049
  }
3011
3050
  throw refusal;
3012
3051
  }
3013
- calibratedParts(attempt, draft, raw) {
3052
+ firstMessageParts(attempt, draft, texts, system) {
3014
3053
  const parts = calibratedParts(attempt);
3015
3054
  if (!parts)
3016
- this.refuse("Hidden completion accepts text-only calibrated prompts", draft, raw);
3017
- return parts;
3055
+ this.refuse("Hidden completion accepts text-only calibrated prompts", draft, texts);
3056
+ if (!deliversInstructionsInUserMessage(draft.model.providerID))
3057
+ return parts;
3058
+ return [{ type: "text", text: claudeAgentInstructionsText(system) }, ...parts];
3018
3059
  }
3019
3060
  apply(draft) {
3020
3061
  if (!this.owns(draft.sessionID)) {
3021
3062
  if (isChildOfDisposedInstance(draft.sessionID)) {
3022
- this.refuse(`Refusing a turn of a Magic Context hidden child of a disposed plugin instance: ${HIDDEN_RUN_DISPOSED_REASON}`, draft, newestUserText(draft), undefined, "hidden_instance_disposed");
3063
+ this.refuse(`Refusing a turn of a Magic Context hidden child of a disposed plugin instance: ${HIDDEN_RUN_DISPOSED_REASON}`, draft, userTexts(draft.messages.at(-1)), undefined, "hidden_instance_disposed");
3023
3064
  }
3024
3065
  if (hiddenAgentAllowedTools(draft.agent) !== undefined) {
3025
- this.refuse("Refusing a Magic Context hidden-agent turn this instance did not register", draft, newestUserText(draft));
3066
+ this.refuse("Refusing a Magic Context hidden-agent turn this instance did not register", draft, userTexts(draft.messages.at(-1)));
3026
3067
  }
3027
3068
  return false;
3028
3069
  }
3029
- const raw = newestUserText(draft);
3030
- let attempt;
3031
- for (const candidate of raw === undefined ? [] : markerCandidates(raw)) {
3032
- attempt = this.attempts.get(candidate);
3033
- if (attempt)
3034
- break;
3070
+ const texts = userTexts(draft.messages.at(-1));
3071
+ const named = new Set;
3072
+ for (const text of texts) {
3073
+ for (const candidate of markerCandidates(text)) {
3074
+ const registered = this.attempts.get(candidate);
3075
+ if (registered) {
3076
+ named.add(registered);
3077
+ break;
3078
+ }
3079
+ }
3080
+ }
3081
+ if (named.size > 1) {
3082
+ this.refuse("Refusing a prompt that names more than one Magic Context hidden run", draft, texts);
3035
3083
  }
3084
+ const attempt = [...named][0];
3036
3085
  const current = this.active.get(draft.sessionID);
3037
3086
  const selected = attempt ?? current;
3038
3087
  if (!selected || selected.childSessionId !== draft.sessionID || attempt && current && current !== attempt) {
3039
- this.refuse("Refusing an unregistered prompt on a Magic Context hidden-run session", draft, raw);
3088
+ this.refuse("Refusing an unregistered prompt on a Magic Context hidden-run session", draft, texts);
3040
3089
  }
3041
3090
  if (selected.request.signal?.aborted) {
3042
3091
  throw new Error("Hidden completion prompt aborted");
3043
3092
  }
3044
3093
  if (!selected.shaped) {
3045
3094
  if (!attempt)
3046
- this.refuse("Hidden child first step requires a registered marker", draft, raw);
3095
+ this.refuse("Hidden child first step requires a registered marker", draft, texts);
3047
3096
  this.active.set(draft.sessionID, selected);
3048
3097
  }
3049
3098
  const steps = (selected.steps ?? 0) + 1;
@@ -3055,29 +3104,27 @@ class HiddenChildHook {
3055
3104
  selected.steps = steps;
3056
3105
  const system = typeof selected.request.body.system === "string" ? selected.request.body.system : selected.identity.system;
3057
3106
  const blockedRead = needsBlockedRead(selected.identity.agent, draft.model.providerID) && draft.tools.read !== undefined;
3058
- draft.system = [
3059
- {
3060
- type: "text",
3061
- text: blockedRead ? withBlockedReadInstruction(system, selected.identity) : system
3062
- }
3063
- ];
3107
+ const systemText = blockedRead ? withBlockedReadInstruction(system, selected.identity) : system;
3108
+ draft.system = [{ type: "text", text: systemText }];
3064
3109
  if (!selected.shaped) {
3065
3110
  draft.messages = [
3066
- { role: "user", content: this.calibratedParts(selected, draft, raw) }
3111
+ {
3112
+ role: "user",
3113
+ content: this.firstMessageParts(selected, draft, texts, systemText)
3114
+ }
3067
3115
  ];
3068
3116
  } else {
3069
3117
  let start = -1;
3070
3118
  draft.messages.forEach((message, index) => {
3071
- const text = newestUserText({ ...draft, messages: [message] });
3072
- if (text !== undefined && selected.marker !== undefined && markerCandidates(text).includes(selected.marker))
3119
+ if (selected.marker !== undefined && carriesMarker(userTexts(message), selected.marker))
3073
3120
  start = index;
3074
3121
  });
3075
3122
  const first = draft.messages[start];
3076
3123
  if (!first) {
3077
- this.refuse("Hidden child history does not contain this run's registered marker", draft, raw);
3124
+ this.refuse("Hidden child history does not contain this run's registered marker", draft, texts);
3078
3125
  }
3079
3126
  draft.messages = [
3080
- { ...first, content: this.calibratedParts(selected, draft, raw) },
3127
+ { ...first, content: this.firstMessageParts(selected, draft, texts, systemText) },
3081
3128
  ...draft.messages.slice(start + 1)
3082
3129
  ];
3083
3130
  }
@@ -6826,6 +6873,60 @@ function codepoints(value) {
6826
6873
  function escapeText(value) {
6827
6874
  return value.replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").trim();
6828
6875
  }
6876
+ var PUNCTUATION_FALLBACKS = {
6877
+ "‘": "'",
6878
+ "’": "'",
6879
+ "‚": "'",
6880
+ "‛": "'",
6881
+ "“": '"',
6882
+ "”": '"',
6883
+ "„": '"',
6884
+ "‟": '"',
6885
+ "–": "-",
6886
+ "—": "-",
6887
+ "…": "...",
6888
+ " ": " ",
6889
+ " ": " ",
6890
+ " ": " "
6891
+ };
6892
+ var REMOVABLE_COMBINING_MARK = /(?![\u0334-\u0338])\p{M}/gu;
6893
+ function hasGlyph(character) {
6894
+ return MURAL_FONT_GLYPHS[character] !== undefined;
6895
+ }
6896
+ function drawableMuralCue(cue) {
6897
+ const text = escapeText(cue);
6898
+ let normalized = "";
6899
+ let changed = false;
6900
+ for (const character of text) {
6901
+ if (hasGlyph(character)) {
6902
+ normalized += character;
6903
+ continue;
6904
+ }
6905
+ changed = true;
6906
+ const replacement = PUNCTUATION_FALLBACKS[character] ?? character.normalize("NFKD").replace(REMOVABLE_COMBINING_MARK, "");
6907
+ for (const part of replacement) {
6908
+ if (!hasGlyph(part))
6909
+ return null;
6910
+ }
6911
+ normalized += replacement;
6912
+ }
6913
+ if (!changed)
6914
+ return cue;
6915
+ const result = escapeText(normalized);
6916
+ return result.length > 0 ? result : null;
6917
+ }
6918
+ function partitionDrawableEntries(entries) {
6919
+ const drawable = [];
6920
+ const undrawableIds = [];
6921
+ for (const entry of entries) {
6922
+ const cue = drawableMuralCue(entry.cue);
6923
+ if (cue === null)
6924
+ undrawableIds.push(entry.id);
6925
+ else
6926
+ drawable.push(cue === entry.cue ? entry : { ...entry, cue });
6927
+ }
6928
+ return { drawable, undrawableIds };
6929
+ }
6829
6930
  function banner(category, roomWidth) {
6830
6931
  const label = ` <${category}> `;
6831
6932
  if (codepoints(label) > roomWidth) {
@@ -7131,11 +7232,12 @@ function snapDimensionToVisionTile(contentPixels, maximum) {
7131
7232
  return Math.min(maximum, Math.max(MURAL_VISION_TILE, Math.ceil(contentPixels / MURAL_VISION_TILE) * MURAL_VISION_TILE));
7132
7233
  }
7133
7234
  function planMuralRender(entries) {
7134
- const roomWidth = chooseRoomWidth(entries);
7135
- const plan = planLines(entries, roomWidth);
7235
+ const { drawable, undrawableIds } = partitionDrawableEntries(entries);
7236
+ const roomWidth = chooseRoomWidth(drawable);
7237
+ const plan = planLines(drawable, roomWidth);
7136
7238
  const candidates = Array.from({ length: MURAL_COLUMNS }, (_, index) => {
7137
7239
  const requestedColumnCount = index + 1;
7138
- const layout = renderLayout(entries, plan, roomWidth, requestedColumnCount);
7240
+ const layout = renderLayout(drawable, plan, roomWidth, requestedColumnCount);
7139
7241
  const contentWidth = layout.columnCount === 0 ? 0 : layout.columnCount * roomWidth * MURAL_CELL_WIDTH + MURAL_COLUMN_GAP * (layout.columnCount - 1) * MURAL_CELL_WIDTH;
7140
7242
  const contentHeight = layout.rowCount * MURAL_LINE_PITCH;
7141
7243
  const width = snapDimensionToVisionTile(contentWidth, MURAL_WIDTH);
@@ -7164,7 +7266,13 @@ function planMuralRender(entries) {
7164
7266
  }
7165
7267
  return candidate.requestedColumnCount < best.requestedColumnCount ? candidate : best;
7166
7268
  }, firstCandidate);
7167
- return { roomWidth, layout: selected.layout, width: selected.width, height: selected.height };
7269
+ return {
7270
+ roomWidth,
7271
+ layout: selected.layout,
7272
+ width: selected.width,
7273
+ height: selected.height,
7274
+ undrawableIds
7275
+ };
7168
7276
  }
7169
7277
  function rasterMural(plan) {
7170
7278
  const { roomWidth, layout, width, height } = plan;
@@ -7200,6 +7308,7 @@ function renderPlannedMural(plan) {
7200
7308
  layoutItems: layout.layoutItems,
7201
7309
  renderedIds: layout.renderedIds,
7202
7310
  droppedIds: layout.droppedIds,
7311
+ undrawableIds: plan.undrawableIds,
7203
7312
  categoryLineUsage: layout.usage,
7204
7313
  filledLineCount: layout.filledLineCount,
7205
7314
  width,
@@ -7231,13 +7340,17 @@ function poolContentHash(pool, memory) {
7231
7340
  function getMuralCoverage(db, projectIdentity, pool) {
7232
7341
  const { memories, cueState } = pool ?? readMuralPool(db, projectIdentity);
7233
7342
  let cuedMemoryCount = 0;
7343
+ let undrawableCueCount = 0;
7234
7344
  for (const memory of memories) {
7235
7345
  const state = cueState.get(memory.id);
7236
7346
  if (state && typeof state.cue === "string" && state.cue.trim() !== "" && state.hash !== null && state.hash === poolContentHash(pool, memory)) {
7237
- cuedMemoryCount += 1;
7347
+ if (drawableMuralCue(state.cue) === null)
7348
+ undrawableCueCount += 1;
7349
+ else
7350
+ cuedMemoryCount += 1;
7238
7351
  }
7239
7352
  }
7240
- return { activeMemoryCount: memories.length, cuedMemoryCount };
7353
+ return { activeMemoryCount: memories.length, cuedMemoryCount, undrawableCueCount };
7241
7354
  }
7242
7355
  function resolveMural(db, projectIdentity, budgetTokens = DEFAULT_MURAL_MEMORY_BUDGET, pool) {
7243
7356
  const memories = pool?.memories ?? getMemoriesByProject2(db, projectIdentity, ["active", "permanent"]);
@@ -7355,7 +7468,8 @@ function ensureMuralRendered(db, projectIdentity, budgetTokens = DEFAULT_MURAL_M
7355
7468
  const pool = readMuralPool(db, projectIdentity);
7356
7469
  const coverage = getMuralCoverage(db, projectIdentity, pool);
7357
7470
  if (coverage.activeMemoryCount === 0 || !muralCoverageGate(coverage.cuedMemoryCount, coverage.activeMemoryCount)) {
7358
- const skipReason = coverage.activeMemoryCount === 0 ? "no active memories" : `only ${coverage.cuedMemoryCount}/${coverage.activeMemoryCount} active memories have current cues (requires ${MIN_MURAL_CUED_MEMORIES} cues or ${MIN_MURAL_COVERAGE * 100}% coverage)`;
7471
+ const undrawable = coverage.undrawableCueCount > 0 ? ` the mural font can draw (${coverage.undrawableCueCount} more use characters it has no glyph for)` : "";
7472
+ const skipReason = coverage.activeMemoryCount === 0 ? "no active memories" : `only ${coverage.cuedMemoryCount}/${coverage.activeMemoryCount} active memories have current cues${undrawable} (requires ${MIN_MURAL_CUED_MEMORIES} cues or ${MIN_MURAL_COVERAGE * 100}% coverage)`;
7359
7473
  log2(`[mural] skipped for ${projectIdentity}: ${skipReason}`);
7360
7474
  return { hasMural: false, rerendered: false, skipReason };
7361
7475
  }
@@ -7370,6 +7484,11 @@ function ensureMuralRendered(db, projectIdentity, budgetTokens = DEFAULT_MURAL_M
7370
7484
  return { ...cached.result };
7371
7485
  }
7372
7486
  const plan = planMuralRender(entries);
7487
+ if (plan.layout.renderedIds.length === 0) {
7488
+ const skipReason = `none of the ${entries.length} overflow cues can be drawn (${plan.undrawableIds.length} use characters the mural font has no glyph for)`;
7489
+ log2(`[mural] skipped for ${projectIdentity}: ${skipReason}`);
7490
+ return { hasMural: false, rerendered: false, skipReason };
7491
+ }
7373
7492
  const textHash = createHash7("sha256").update(plan.layout.text).digest("hex");
7374
7493
  if (existing && existing.contentHash === textHash && existing.width === plan.width && existing.height === plan.height) {
7375
7494
  return rememberRender(db, projectIdentity, key, existing.image, {
@@ -7382,6 +7501,8 @@ function ensureMuralRendered(db, projectIdentity, budgetTokens = DEFAULT_MURAL_M
7382
7501
  });
7383
7502
  }
7384
7503
  const rendered = renderPlannedMural(plan);
7504
+ if (rendered.undrawableIds.length > 0)
7505
+ log2(`[mural] rendered for ${projectIdentity}: ${rendered.renderedIds.length} cues drawn, ${rendered.droppedIds.length} left out for space, ${rendered.undrawableIds.length} left out because the mural font has no glyph for their characters`);
7385
7506
  if (mode === "persist")
7386
7507
  upsertMural(db, {
7387
7508
  projectPath: projectIdentity,
@@ -12429,9 +12550,6 @@ function fitHistorianPrompt(args) {
12429
12550
  }
12430
12551
 
12431
12552
  // src/hooks/magic-context/compartment-runner-historian.ts
12432
- function historianResponseDumpDir(directory) {
12433
- return getProjectMagicContextHistorianDir(directory);
12434
- }
12435
12553
  var MAX_HISTORIAN_RETRIES = 2;
12436
12554
  var unknownProducerWindows = new Set;
12437
12555
  var HISTORIAN_REASONING_PART_TYPES = new Set(["reasoning", "thinking", "redacted_thinking"]);
@@ -12905,7 +13023,7 @@ async function runHistorianPrompt(args) {
12905
13023
  invocationId: invocationId ?? undefined
12906
13024
  };
12907
13025
  }
12908
- const dumpPath = dumpHistorianResponse(parentSessionId, sessionDirectory, dumpLabel ?? "historian-response", result);
13026
+ const dumpPath = dumpHistorianResponse(parentSessionId, dumpLabel ?? "historian-response", result);
12909
13027
  return { ok: true, result, dumpPath, invocationId: invocationId ?? undefined };
12910
13028
  } catch (modelError) {
12911
13029
  hiddenModelCooldowns.record(handle?.attemptedModel ?? toModelEntry(modelOverride)?.model, modelError);
@@ -13059,14 +13177,12 @@ function cleanupHistorianDump(sessionId, dumpPath) {
13059
13177
  });
13060
13178
  }
13061
13179
  }
13062
- function dumpHistorianResponse(sessionId, directory, label, text) {
13180
+ function dumpHistorianResponse(sessionId, label, text) {
13063
13181
  try {
13064
- const dumpDir = historianResponseDumpDir(directory);
13182
+ const dumpDir = getMagicContextHistorianSessionDir(sessionId);
13065
13183
  mkdirSync(dumpDir, { recursive: true });
13066
- ensureCortexKitArtifactGitignore(directory);
13067
- const safeSessionId = sanitizeDumpName(sessionId);
13068
13184
  const safeLabel = sanitizeDumpName(label);
13069
- const dumpPath = join(dumpDir, `${safeSessionId}-${safeLabel}-${Date.now()}.xml`);
13185
+ const dumpPath = join(dumpDir, `${safeLabel}-${Date.now()}.xml`);
13070
13186
  writeFileSync(dumpPath, text, "utf8");
13071
13187
  sessionLog2(sessionId, "compartment agent: historian response dumped", {
13072
13188
  label,
@@ -13085,6 +13201,140 @@ function sanitizeDumpName(value) {
13085
13201
  return value.replace(/[^a-zA-Z0-9._-]/g, "-");
13086
13202
  }
13087
13203
 
13204
+ // src/hooks/magic-context/historian-failure-report.ts
13205
+ var REPEATED_HISTORIAN_FAILURE_WARNING_STEP = 3;
13206
+ var REPEATED_HISTORIAN_FAILURE_WARNING_INTERVAL_MS = 30 * 60 * 1000;
13207
+ var ACTIONS = "What to do: run /ctx-status for detail; change the historian model or its fallback models in magic-context.jsonc (user or project config); or run /ctx-recomp to rebuild the history.";
13208
+ var REFUSAL_ERROR_MAX_CHARS = 500;
13209
+ var WARNING_ERROR_MAX_CHARS = 200;
13210
+ function readHistorianFailureStreak(db, sessionId, options = {}) {
13211
+ const state = getHistorianFailureState(db, sessionId);
13212
+ const count = state.failureCount;
13213
+ let since = null;
13214
+ if (count > 0) {
13215
+ const recorded = count - Math.max(0, options.unrecordedFailures ?? 0);
13216
+ if (recorded <= 0) {
13217
+ since = state.lastFailureAt;
13218
+ } else {
13219
+ const times = getRecentFailedHistorianRunTimes(db, sessionId, recorded);
13220
+ since = times.length === recorded ? times[recorded - 1] ?? null : null;
13221
+ }
13222
+ }
13223
+ return { count, lastError: state.lastError, lastFailureAt: state.lastFailureAt, since };
13224
+ }
13225
+ function formatHistorianClockTime(at, now = Date.now()) {
13226
+ const date = new Date(at);
13227
+ const pad = (value) => String(value).padStart(2, "0");
13228
+ const clock = `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
13229
+ const today = new Date(now);
13230
+ const sameDay = date.getFullYear() === today.getFullYear() && date.getMonth() === today.getMonth() && date.getDate() === today.getDate();
13231
+ return sameDay ? clock : `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${clock}`;
13232
+ }
13233
+ function formatHistorianSeconds(ms) {
13234
+ const seconds = Math.max(0, ms) / 1000;
13235
+ return String(Number(seconds.toFixed(seconds >= 10 ? 0 : 3)));
13236
+ }
13237
+ function singleLine(text) {
13238
+ return text.replace(/\s+/g, " ").trim();
13239
+ }
13240
+ function quoteError(error, maxChars) {
13241
+ const text = sanitizeDiagnosticText(singleLine(error));
13242
+ return text.length > maxChars ? `${text.slice(0, maxChars - 1).trimEnd()}…` : text;
13243
+ }
13244
+ function endSentence(text) {
13245
+ return /[.!?]$/.test(text) ? text : `${text}.`;
13246
+ }
13247
+ function usageClause(usagePercentage) {
13248
+ return typeof usagePercentage === "number" && Number.isFinite(usagePercentage) ? `context is at ${Math.round(usagePercentage)}% of the window` : "context is nearly full";
13249
+ }
13250
+ function capitalize(text) {
13251
+ return text.charAt(0).toUpperCase() + text.slice(1);
13252
+ }
13253
+ function chunkLabel(chunk) {
13254
+ return chunk ? `messages ${chunk.start}-${chunk.end}` : "";
13255
+ }
13256
+ function streakSentence(failures, now) {
13257
+ if (failures.count <= 0)
13258
+ return null;
13259
+ const since = failures.since !== null ? `, since ${formatHistorianClockTime(failures.since, now)}` : "";
13260
+ return `Summary runs failed in a row: ${failures.count}${since}.`;
13261
+ }
13262
+ function failureBelongsToRun(failures, run) {
13263
+ return failures.count > 0 && failures.lastFailureAt !== null && run?.startedAt !== undefined && failures.lastFailureAt >= run.startedAt;
13264
+ }
13265
+ function describeHistorianJoinRefusal(input) {
13266
+ const now = input.now ?? Date.now();
13267
+ const { run, failures } = input;
13268
+ const sentences = [
13269
+ `This turn was not sent: ${usageClause(input.usagePercentage)}, and Magic Context waited ${formatHistorianSeconds(input.waitedMs)} s for a history summary that did not finish in time.`
13270
+ ];
13271
+ const subject = run?.chunk ? `The summary of ${chunkLabel(run.chunk)}` : "The summary run";
13272
+ const ownFailure = failureBelongsToRun(failures, run);
13273
+ const lastError = failures.lastError ? quoteError(failures.lastError, REFUSAL_ERROR_MAX_CHARS) : "";
13274
+ if (ownFailure) {
13275
+ sentences.push(endSentence(`${subject} failed: ${lastError || "no reason recorded"}`));
13276
+ } else if (run && run.endedAt === undefined) {
13277
+ sentences.push(run.startedAt !== undefined ? `${subject} is still running after ${formatHistorianSeconds(now - run.startedAt)} s.` : `${subject} is still running.`);
13278
+ } else if (run) {
13279
+ sentences.push(`${subject} finished after the wait ended.`);
13280
+ }
13281
+ if (!ownFailure && failures.count > 0 && lastError && failures.lastFailureAt !== null) {
13282
+ sentences.push(endSentence(`The previous run failed at ${formatHistorianClockTime(failures.lastFailureAt, now)}: ${lastError}`));
13283
+ }
13284
+ const streak = streakSentence(failures, now);
13285
+ if (streak)
13286
+ sentences.push(streak);
13287
+ sentences.push(ACTIONS);
13288
+ return sentences.join(" ");
13289
+ }
13290
+ function describeRepeatedHistorianFailures(input) {
13291
+ const now = input.now ?? Date.now();
13292
+ const { failures } = input;
13293
+ const facts = [
13294
+ streakSentence(failures, now) ?? "Summary runs are failing.",
13295
+ ...input.chunk ? [`Last chunk: ${chunkLabel(input.chunk)}.`] : [],
13296
+ ...failures.lastError ? [
13297
+ endSentence(`Last error: ${quoteError(failures.lastError, WARNING_ERROR_MAX_CHARS)}`)
13298
+ ] : [],
13299
+ `${capitalize(usageClause(input.usagePercentage))}; at 95% a turn can be refused if no summary finishes in time.`
13300
+ ];
13301
+ return [
13302
+ "## Magic Context — History summaries keep failing",
13303
+ "",
13304
+ facts.join(" "),
13305
+ "",
13306
+ ACTIONS
13307
+ ].join(`
13308
+ `);
13309
+ }
13310
+ var repeatedFailureWarnings = new Map;
13311
+ function shouldWarnRepeatedHistorianFailures(sessionId, failureCount, now = Date.now()) {
13312
+ const step = REPEATED_HISTORIAN_FAILURE_WARNING_STEP;
13313
+ if (failureCount < step || failureCount % step !== 0)
13314
+ return false;
13315
+ const last = repeatedFailureWarnings.get(sessionId);
13316
+ if (last && failureCount > last.count && now - last.at < REPEATED_HISTORIAN_FAILURE_WARNING_INTERVAL_MS) {
13317
+ return false;
13318
+ }
13319
+ repeatedFailureWarnings.set(sessionId, { count: failureCount, at: now });
13320
+ return true;
13321
+ }
13322
+ function takeRepeatedHistorianFailureWarning(input) {
13323
+ const now = input.now ?? Date.now();
13324
+ if (!shouldWarnRepeatedHistorianFailures(input.sessionId, input.failureCount, now)) {
13325
+ return null;
13326
+ }
13327
+ const failures = readHistorianFailureStreak(input.db, input.sessionId, {
13328
+ unrecordedFailures: input.unrecordedFailures
13329
+ });
13330
+ return describeRepeatedHistorianFailures({
13331
+ chunk: input.chunk,
13332
+ failures: { ...failures, count: input.failureCount },
13333
+ usagePercentage: loadPersistedUsage(input.db, input.sessionId)?.usage.percentage,
13334
+ now
13335
+ });
13336
+ }
13337
+
13088
13338
  // src/hooks/magic-context/historian-history-wait.ts
13089
13339
  var historyWaits = new Map;
13090
13340
  function newestMessageId(snapshot) {
@@ -14510,6 +14760,28 @@ async function runCompartmentAgent(deps) {
14510
14760
  }
14511
14761
  await sendStatusNotification2(client, sessionId, message, getNotificationParams?.() ?? {});
14512
14762
  };
14763
+ const notifyCountedFailure = async (failureCount, notice) => {
14764
+ let warning = null;
14765
+ try {
14766
+ warning = takeRepeatedHistorianFailureWarning({
14767
+ db,
14768
+ sessionId,
14769
+ failureCount,
14770
+ chunk: telemetry.chunkStartOrdinal != null && telemetry.chunkEndOrdinal != null ? { start: telemetry.chunkStartOrdinal, end: telemetry.chunkEndOrdinal } : undefined,
14771
+ unrecordedFailures: 1
14772
+ });
14773
+ } catch (error) {
14774
+ sessionLog2(sessionId, "historian repeated-failure warning failed:", error);
14775
+ }
14776
+ if (!warning) {
14777
+ await notifyHistorianIssue(notice);
14778
+ return;
14779
+ }
14780
+ issueNotified = true;
14781
+ lastHistorianAlertBySession.set(sessionId, Date.now());
14782
+ sessionLog2(sessionId, `historian repeated-failure warning sent: count=${failureCount}`);
14783
+ await sendStatusNotification2(client, sessionId, warning, getNotificationParams?.() ?? {});
14784
+ };
14513
14785
  const truncateHistorianInputIfNeeded = (text, budget) => {
14514
14786
  if (estimateTokens(text) <= budget)
14515
14787
  return text;
@@ -14590,9 +14862,9 @@ async function runCompartmentAgent(deps) {
14590
14862
  telemetry.failureReason = `existing-validation: ${existingValidationError}`;
14591
14863
  retainDrainReservationForRetryThrottle = true;
14592
14864
  if (unresolvedInvolved) {
14593
- await notifyHistorianIssue(buildStoredCompartmentsInvalidNotice());
14865
+ await notifyCountedFailure(failCount, buildStoredCompartmentsInvalidNotice());
14594
14866
  } else {
14595
- await notifyHistorianIssue(buildHistorianFailureNotice(failCount, existingValidationError));
14867
+ await notifyCountedFailure(failCount, buildHistorianFailureNotice(failCount, existingValidationError));
14596
14868
  }
14597
14869
  return;
14598
14870
  }
@@ -14723,9 +14995,9 @@ async function runCompartmentAgent(deps) {
14723
14995
  return;
14724
14996
  }
14725
14997
  sessionLog2(sessionId, `historian failure: source=prompt-fit reason="${promptFit.reason}"`);
14726
- incrementHistorianFailure(db, sessionId, promptFit.reason);
14998
+ const failCount = incrementHistorianFailure(db, sessionId, promptFit.reason);
14727
14999
  retainDrainReservationForRetryThrottle = true;
14728
- await notifyHistorianIssue(buildHistorianWindowTooSmallNotice());
15000
+ await notifyCountedFailure(failCount, buildHistorianWindowTooSmallNotice());
14729
15001
  return;
14730
15002
  }
14731
15003
  const chunkTokens = promptFit.chunkTokens;
@@ -14765,6 +15037,7 @@ async function runCompartmentAgent(deps) {
14765
15037
  const forceKeepLastCompartmentForChunk = deps.forceKeepLastCompartment === true && !chunk.hasMore;
14766
15038
  telemetry.chunkStartOrdinal = chunk.startIndex;
14767
15039
  telemetry.chunkEndOrdinal = chunk.endIndex;
15040
+ deps.onChunkSelected?.({ start: chunk.startIndex, end: chunk.endIndex });
14768
15041
  if (!chunk.text || chunk.messageCount === 0) {
14769
15042
  if (persistFilteredNoise(db, sessionId, chunk, eligibleEndOrdinal)) {
14770
15043
  telemetry.status = "noop";
@@ -14825,7 +15098,7 @@ async function runCompartmentAgent(deps) {
14825
15098
  telemetry.failureReason = `chunk-coverage: ${chunkCoverageError}`;
14826
15099
  sessionLog2(sessionId, `historian failure: source=chunk-coverage reason="${chunkCoverageError}" chunkRange=${chunk.startIndex}-${chunk.endIndex}`);
14827
15100
  const failCount = incrementHistorianFailure(db, sessionId, chunkCoverageError);
14828
- await notifyHistorianIssue(buildHistorianFailureNotice(failCount, chunkCoverageError));
15101
+ await notifyCountedFailure(failCount, buildHistorianFailureNotice(failCount, chunkCoverageError));
14829
15102
  rollbackDrainReservation();
14830
15103
  return;
14831
15104
  }
@@ -14876,7 +15149,7 @@ ${chunkText}`,
14876
15149
  sessionLog2(sessionId, `historian failure: source=validation reason="${validatedPass.error}" chunkRange=${chunk.startIndex}-${chunk.endIndex} fallbackModel=${deps.fallbackModelId ?? "<none>"} twoPass=${deps.historianTwoPass ? "true" : "false"}`);
14877
15150
  const failCount = incrementHistorianFailure(db, sessionId, validatedPass.error);
14878
15151
  telemetry.failureReason = validatedPass.failureReason ?? validatedPass.error;
14879
- await notifyHistorianIssue(buildHistorianFailureNotice(failCount, validatedPass.error));
15152
+ await notifyCountedFailure(failCount, buildHistorianFailureNotice(failCount, validatedPass.error));
14880
15153
  return;
14881
15154
  }
14882
15155
  retainDrainReservationForRetryThrottle = false;
@@ -14905,7 +15178,7 @@ ${chunkText}`,
14905
15178
  sessionLog2(sessionId, "historian output discarded: reason=no_forward_progress");
14906
15179
  const failCount = incrementHistorianFailure(db, sessionId, `no forward progress beyond raw message ${offset - 1}`);
14907
15180
  try {
14908
- await notifyHistorianIssue(buildHistorianFailureNotice(failCount, `historian made no forward progress beyond raw message ${offset - 1}`));
15181
+ await notifyCountedFailure(failCount, buildHistorianFailureNotice(failCount, `historian made no forward progress beyond raw message ${offset - 1}`));
14909
15182
  } finally {
14910
15183
  recordHistorianNoProgress(boundarySnapshot, inEmergency);
14911
15184
  }
@@ -14956,7 +15229,7 @@ ${chunkText}`,
14956
15229
  sessionLog2(sessionId, `historian publish refused: sequence=${danglingBoundary.sequence} side=${danglingBoundary.side} missing_id=${danglingBoundary.messageId}; raw snapshot changed during the historian run`);
14957
15230
  sessionLog2(sessionId, "historian output discarded: reason=dangling_boundary");
14958
15231
  const failCount = incrementHistorianFailure(db, sessionId, reason);
14959
- await notifyHistorianIssue(buildHistorianFailureNotice(failCount, reason));
15232
+ await notifyCountedFailure(failCount, buildHistorianFailureNotice(failCount, reason));
14960
15233
  rollbackDrainReservation();
14961
15234
  return;
14962
15235
  }
@@ -15164,7 +15437,7 @@ ${chunkText}`,
15164
15437
  sessionLog2(sessionId, `historian failure: source=exception ${desc.brief}${desc.stackHead ? ` stackHead="${desc.stackHead}"` : ""}`);
15165
15438
  if (!issueNotified) {
15166
15439
  const failCount = incrementHistorianFailure(db, sessionId, desc.brief);
15167
- await notifyHistorianIssue(buildHistorianFailureNotice(failCount, desc.brief));
15440
+ await notifyCountedFailure(failCount, buildHistorianFailureNotice(failCount, desc.brief));
15168
15441
  }
15169
15442
  } finally {
15170
15443
  if (!completedSuccessfully) {
@@ -15988,10 +16261,12 @@ function registerActiveCompartmentRun(sessionId, promise, kind = "other") {
15988
16261
  const activeRun = {
15989
16262
  promise: Promise.resolve(),
15990
16263
  published: false,
15991
- kind
16264
+ kind,
16265
+ startedAt: Date.now()
15992
16266
  };
15993
16267
  const wrapped = promise.finally(() => {
15994
16268
  activeRun.settled = true;
16269
+ activeRun.endedAt = Date.now();
15995
16270
  if (activeRuns.get(sessionId)?.promise === wrapped) {
15996
16271
  activeRuns.delete(sessionId);
15997
16272
  }
@@ -16048,9 +16323,19 @@ function startBackgroundCompartmentAgent(deps, runAgent, prepareBoundary) {
16048
16323
  return;
16049
16324
  }
16050
16325
  const renewal = startLeaseRenewal(deps, holderId);
16326
+ const activeRun = {
16327
+ promise: Promise.resolve(),
16328
+ published: false,
16329
+ kind: "incremental",
16330
+ startedAt: Date.now()
16331
+ };
16051
16332
  const runnerDeps = withPublishedCallback({
16052
16333
  ...deps,
16053
- compartmentLeaseHolderId: holderId
16334
+ compartmentLeaseHolderId: holderId,
16335
+ onChunkSelected: (chunk) => {
16336
+ activeRun.chunk = chunk;
16337
+ deps.onChunkSelected?.(chunk);
16338
+ }
16054
16339
  });
16055
16340
  const promise = new Promise((resolve) => setTimeout(resolve, 0)).then(() => withRawSessionMessageCache2(() => {
16056
16341
  const snapshot = deps.boundarySnapshot;
@@ -16080,6 +16365,7 @@ function startBackgroundCompartmentAgent(deps, runAgent, prepareBoundary) {
16080
16365
  updateSessionMeta(deps.db, deps.sessionId, { compartmentInProgress: false });
16081
16366
  } catch {}
16082
16367
  }).finally(() => {
16368
+ activeRun.endedAt = Date.now();
16083
16369
  try {
16084
16370
  clearInterval(renewal);
16085
16371
  releaseCompartmentLeaseBestEffort(deps.db, deps.sessionId, holderId, sessionLog2);
@@ -16090,7 +16376,8 @@ function startBackgroundCompartmentAgent(deps, runAgent, prepareBoundary) {
16090
16376
  sessionLog2(deps.sessionId, "compartment agent: finalizer failed:", err);
16091
16377
  }
16092
16378
  });
16093
- activeRuns.set(deps.sessionId, { promise, published: false, kind: "incremental" });
16379
+ activeRun.promise = promise;
16380
+ activeRuns.set(deps.sessionId, activeRun);
16094
16381
  }
16095
16382
  async function executeContextRecompWithResult(deps, options = {}) {
16096
16383
  const { sessionId } = deps;
@@ -16279,4 +16566,4 @@ ${failure}`;
16279
16566
  }
16280
16567
  }
16281
16568
 
16282
- export { historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, v2ToolDefinitionsHash, v2RequestToolsFingerprint, classifyRequestToolsChange, readCoordinateGeneration, rebaseSessionCoordinatesAsync, HiddenCompletionRefusal, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, startCompactionMarkerCandidatePreparation, removeMcOwnedCompactionMarkers, getCompartmentEvents, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, DreamerProviderOutputFailureError, providerOutputFailureFromInvalidManifest, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, 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, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, teardownChildSession, runTokenLog, formatRunTokenLog, createChildSessionWithFence, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, 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, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, shouldWaitForNewHistorianHistory, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, omitIncompleteFileTokenTotals, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, isRecompFailure2, isRecompSkip2, extractRecompReason2, setRecompStarting2, setRecompNote2, setRecompTerminal2, buildRecompDeps2, runManagedRecomp2 };
16569
+ export { historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, v2ToolDefinitionsHash, v2RequestToolsFingerprint, classifyRequestToolsChange, readCoordinateGeneration, rebaseSessionCoordinatesAsync, HiddenCompletionRefusal, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, startCompactionMarkerCandidatePreparation, removeMcOwnedCompactionMarkers, getCompartmentEvents, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, DreamerProviderOutputFailureError, providerOutputFailureFromInvalidManifest, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, 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, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, teardownChildSession, runTokenLog, formatRunTokenLog, createChildSessionWithFence, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, 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, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readHistorianFailureStreak, describeHistorianJoinRefusal, shouldWaitForNewHistorianHistory, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, omitIncompleteFileTokenTotals, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, isRecompFailure2, isRecompSkip2, extractRecompReason2, setRecompStarting2, setRecompNote2, setRecompTerminal2, buildRecompDeps2, runManagedRecomp2 };