@cortexkit/opencode-magic-context 0.43.2 → 0.44.0

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 (252) hide show
  1. package/README.md +18 -2
  2. package/dist/config/index.d.ts +13 -0
  3. package/dist/config/index.d.ts.map +1 -1
  4. package/dist/config/project-security.d.ts +6 -3
  5. package/dist/config/project-security.d.ts.map +1 -1
  6. package/dist/config/schema/magic-context.d.ts +27 -0
  7. package/dist/config/schema/magic-context.d.ts.map +1 -1
  8. package/dist/{conflict-warning-hook-hyk9y29x.js → conflict-warning-hook-48f7np9d.js} +5 -5
  9. package/dist/{derive-budgets-b8ybssh9.js → derive-budgets-8kgevxmx.js} +2 -2
  10. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  11. package/dist/features/magic-context/compartment-embedding.d.ts +3 -2
  12. package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
  13. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  15. package/dist/features/magic-context/dreamer/curate-category-rotation.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/failed-invocation-evidence.d.ts +13 -0
  18. package/dist/features/magic-context/dreamer/failed-invocation-evidence.d.ts.map +1 -0
  19. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/lease.d.ts +5 -2
  21. package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  23. package/dist/features/magic-context/dreamer/memory-claim-safety.d.ts.map +1 -1
  24. package/dist/features/magic-context/dreamer/module-apply.d.ts +1 -0
  25. package/dist/features/magic-context/dreamer/module-apply.d.ts.map +1 -1
  26. package/dist/features/magic-context/dreamer/retrospective-learnings.d.ts.map +1 -1
  27. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +1 -1
  28. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
  29. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  30. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +2 -0
  31. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  32. package/dist/features/magic-context/dreamer/verify.d.ts +19 -0
  33. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  34. package/dist/features/magic-context/fail-closed-block.d.ts +7 -0
  35. package/dist/features/magic-context/fail-closed-block.d.ts.map +1 -1
  36. package/dist/features/magic-context/index.d.ts +1 -0
  37. package/dist/features/magic-context/index.d.ts.map +1 -1
  38. package/dist/features/magic-context/install-instance-id.d.ts +33 -0
  39. package/dist/features/magic-context/install-instance-id.d.ts.map +1 -0
  40. package/dist/features/magic-context/memory/constants.d.ts.map +1 -1
  41. package/dist/features/magic-context/memory/embedding-backfill.d.ts.map +1 -1
  42. package/dist/features/magic-context/memory/single-store-embedding-drain.d.ts +35 -0
  43. package/dist/features/magic-context/memory/single-store-embedding-drain.d.ts.map +1 -0
  44. package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
  45. package/dist/features/magic-context/message-index.d.ts +23 -0
  46. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  47. package/dist/features/magic-context/migrations.d.ts +7 -0
  48. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  49. package/dist/features/magic-context/overflow-detection.d.ts +31 -8
  50. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  51. package/dist/features/magic-context/project-embedding-registry.d.ts +40 -1
  52. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  53. package/dist/features/magic-context/search.d.ts.map +1 -1
  54. package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -1
  55. package/dist/features/magic-context/storage-db.d.ts +1 -1
  56. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  57. package/dist/features/magic-context/storage-meta-persisted.d.ts +20 -5
  58. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  59. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  60. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  61. package/dist/features/magic-context/storage-notes.d.ts +1 -0
  62. package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
  63. package/dist/features/magic-context/storage-primers.d.ts.map +1 -1
  64. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  65. package/dist/features/magic-context/storage-unavailable-reason.d.ts +17 -0
  66. package/dist/features/magic-context/storage-unavailable-reason.d.ts.map +1 -0
  67. package/dist/features/magic-context/storage.d.ts +1 -1
  68. package/dist/features/magic-context/storage.d.ts.map +1 -1
  69. package/dist/features/magic-context/store-generation-rebase.d.ts +33 -1
  70. package/dist/features/magic-context/store-generation-rebase.d.ts.map +1 -1
  71. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  72. package/dist/features/magic-context/transform-decision-log.d.ts +1 -1
  73. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  74. package/dist/features/magic-context/types.d.ts +8 -3
  75. package/dist/features/magic-context/types.d.ts.map +1 -1
  76. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
  77. package/dist/hooks/magic-context/apply-operations.d.ts +105 -9
  78. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  79. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  80. package/dist/hooks/magic-context/compartment-parser.d.ts +2 -0
  81. package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -1
  82. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +1 -0
  83. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  84. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  85. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  86. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  87. package/dist/hooks/magic-context/compartment-runner-types.d.ts +2 -0
  88. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  89. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  90. package/dist/hooks/magic-context/context-limit-resolution.d.ts +31 -0
  91. package/dist/hooks/magic-context/context-limit-resolution.d.ts.map +1 -0
  92. package/dist/hooks/magic-context/embed-history-runner.d.ts +0 -1
  93. package/dist/hooks/magic-context/embed-history-runner.d.ts.map +1 -1
  94. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  95. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  96. package/dist/hooks/magic-context/format-embed-status.d.ts.map +1 -1
  97. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  98. package/dist/hooks/magic-context/historian-host-runner.d.ts +233 -0
  99. package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -0
  100. package/dist/hooks/magic-context/hook.d.ts +1 -3
  101. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  102. package/dist/hooks/magic-context/image-token-estimate.d.ts +9 -0
  103. package/dist/hooks/magic-context/image-token-estimate.d.ts.map +1 -1
  104. package/dist/hooks/magic-context/inject-compartments.d.ts +60 -1
  105. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  106. package/dist/hooks/magic-context/lkg-slot.d.ts +6 -0
  107. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  108. package/dist/hooks/magic-context/module-client.d.ts +21 -0
  109. package/dist/hooks/magic-context/module-client.d.ts.map +1 -0
  110. package/dist/hooks/magic-context/module-state-sync.d.ts +6 -2
  111. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  112. package/dist/hooks/magic-context/module-tool-backends.d.ts +47 -0
  113. package/dist/hooks/magic-context/module-tool-backends.d.ts.map +1 -0
  114. package/dist/hooks/magic-context/module-transport.d.ts +1 -1
  115. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  116. package/dist/hooks/magic-context/persist-filtered-noise.d.ts.map +1 -1
  117. package/dist/hooks/magic-context/read-session-chunk.d.ts +12 -0
  118. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  119. package/dist/hooks/magic-context/rust-mode-transform.d.ts +35 -0
  120. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  121. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts +18 -0
  122. package/dist/hooks/magic-context/rust-refusal-recovery.d.ts.map +1 -1
  123. package/dist/hooks/magic-context/rust-served-m0.d.ts +20 -0
  124. package/dist/hooks/magic-context/rust-served-m0.d.ts.map +1 -0
  125. package/dist/hooks/magic-context/store-ahead-refusal.d.ts +40 -0
  126. package/dist/hooks/magic-context/store-ahead-refusal.d.ts.map +1 -0
  127. package/dist/hooks/magic-context/strip-content.d.ts +5 -5
  128. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  129. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  130. package/dist/hooks/magic-context/tag-messages.d.ts +19 -0
  131. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  132. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
  133. package/dist/hooks/magic-context/tool-drop-target.d.ts +14 -0
  134. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  135. package/dist/hooks/magic-context/tool-input-size.d.ts +21 -0
  136. package/dist/hooks/magic-context/tool-input-size.d.ts.map +1 -0
  137. package/dist/hooks/magic-context/tool-sweep-policy.d.ts.map +1 -1
  138. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +124 -11
  139. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  140. package/dist/hooks/magic-context/transform.d.ts +13 -0
  141. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  142. package/dist/{index-0ccmyzbj.js → index-01ft0h3p.js} +1 -1
  143. package/dist/{index-tdrv6nd0.js → index-2zf5fv89.js} +254 -61
  144. package/dist/{index-6j8th2hd.js → index-5f4qsnaq.js} +2 -2
  145. package/dist/{index-jgnag7sa.js → index-c906f3ff.js} +4 -4
  146. package/dist/{index-pa67brzn.js → index-cj5qe2nw.js} +3 -3
  147. package/dist/{index-febg06dy.js → index-dx0xnd4q.js} +1 -1
  148. package/dist/{index-bmzt6xgy.js → index-pye48m79.js} +1 -1
  149. package/dist/{index-g6hpfkqa.js → index-rdey8znw.js} +932 -261
  150. package/dist/{index-wgzyeyf5.js → index-tjq5jztd.js} +22 -6
  151. package/dist/{index-9r1cbh9e.js → index-v6wsttqt.js} +1 -1
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +3323 -1629
  154. package/dist/{message-time-backfill-0ccvyk9n.js → message-time-backfill-rm9wmcem.js} +3 -3
  155. package/dist/plugin/dream-timer.d.ts +2 -0
  156. package/dist/plugin/dream-timer.d.ts.map +1 -1
  157. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  158. package/dist/plugin/messages-transform.d.ts.map +1 -1
  159. package/dist/plugin/native-compaction-guard.d.ts +22 -0
  160. package/dist/plugin/native-compaction-guard.d.ts.map +1 -0
  161. package/dist/plugin/rpc-handlers.d.ts +11 -0
  162. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  163. package/dist/{read-session-chunk-53a7qbrh.js → read-session-chunk-ktz5zt70.js} +5 -3
  164. package/dist/{recomp-orchestrator-adsgqgse.js → recomp-orchestrator-ahekzt0s.js} +8 -8
  165. package/dist/{safe-notification-target-vrkjrbgb.js → safe-notification-target-6w0esgd6.js} +2 -2
  166. package/dist/{send-session-notification-e28r4xx2.js → send-session-notification-w7xbnrsm.js} +4 -4
  167. package/dist/shared/index.d.ts +1 -0
  168. package/dist/shared/index.d.ts.map +1 -1
  169. package/dist/shared/logger.d.ts.map +1 -1
  170. package/dist/shared/model-suggestion-retry.d.ts +13 -1
  171. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  172. package/dist/shared/prompt-async-transport.d.ts +25 -0
  173. package/dist/shared/prompt-async-transport.d.ts.map +1 -0
  174. package/dist/shared/rpc-server.d.ts +1 -0
  175. package/dist/shared/rpc-server.d.ts.map +1 -1
  176. package/dist/shared/rpc-types.d.ts +16 -0
  177. package/dist/shared/rpc-types.d.ts.map +1 -1
  178. package/dist/shared/rpc-utils.d.ts +3 -0
  179. package/dist/shared/rpc-utils.d.ts.map +1 -1
  180. package/dist/shared/sqlite-write-locker-test-support.d.ts +7 -0
  181. package/dist/shared/sqlite-write-locker-test-support.d.ts.map +1 -0
  182. package/dist/shared/status-summary.d.ts +9 -1
  183. package/dist/shared/status-summary.d.ts.map +1 -1
  184. package/dist/shared/tag-transcript.d.ts.map +1 -1
  185. package/dist/shared/user-facing-codes.d.ts +10 -5
  186. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  187. package/dist/shared/window-geometry.d.ts +6 -3
  188. package/dist/shared/window-geometry.d.ts.map +1 -1
  189. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  190. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  191. package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
  192. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  193. package/dist/v2/fold/boundary.d.ts +61 -0
  194. package/dist/v2/fold/boundary.d.ts.map +1 -0
  195. package/dist/v2/fold/restore.d.ts.map +1 -1
  196. package/dist/v2/hidden-completion.d.ts +16 -3
  197. package/dist/v2/hidden-completion.d.ts.map +1 -1
  198. package/dist/v2/hooks/context.d.ts +45 -14
  199. package/dist/v2/hooks/context.d.ts.map +1 -1
  200. package/dist/v2/hooks/hidden-child.d.ts +6 -0
  201. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  202. package/dist/v2/hooks/payload.d.ts.map +1 -1
  203. package/dist/v2/hooks/rpc-live-state.d.ts +1 -1
  204. package/dist/v2/hooks/rpc-live-state.d.ts.map +1 -1
  205. package/dist/v2/hooks/rust-mode.d.ts +47 -0
  206. package/dist/v2/hooks/rust-mode.d.ts.map +1 -0
  207. package/dist/v2/hooks/session-project-backfill.d.ts +15 -0
  208. package/dist/v2/hooks/session-project-backfill.d.ts.map +1 -0
  209. package/dist/v2/hooks/storage-gate.d.ts +42 -0
  210. package/dist/v2/hooks/storage-gate.d.ts.map +1 -0
  211. package/dist/v2/hooks/storage-notice.d.ts +29 -0
  212. package/dist/v2/hooks/storage-notice.d.ts.map +1 -0
  213. package/dist/v2/hooks/store.d.ts +16 -0
  214. package/dist/v2/hooks/store.d.ts.map +1 -1
  215. package/dist/v2/hooks/tools.d.ts +11 -2
  216. package/dist/v2/hooks/tools.d.ts.map +1 -1
  217. package/dist/v2/hooks/types.d.ts +4 -0
  218. package/dist/v2/hooks/types.d.ts.map +1 -1
  219. package/dist/v2/hooks/usage-persist.d.ts +31 -0
  220. package/dist/v2/hooks/usage-persist.d.ts.map +1 -0
  221. package/dist/v2/server.js +12216 -7963
  222. package/dist/v2/store-reader.d.ts +9 -0
  223. package/dist/v2/store-reader.d.ts.map +1 -1
  224. package/dist/wrapup-orchestrator-9srk0kjf.js +18 -0
  225. package/package.json +1 -1
  226. package/src/agents/magic-context-prompt.ts +3 -3
  227. package/src/config/index.ts +40 -0
  228. package/src/config/misplaced-agent-model.test.ts +61 -0
  229. package/src/config/project-security.test.ts +17 -0
  230. package/src/config/project-security.ts +28 -4
  231. package/src/config/schema/magic-context.ts +29 -2
  232. package/src/shared/index.ts +1 -0
  233. package/src/shared/logger.test.ts +63 -2
  234. package/src/shared/logger.ts +23 -5
  235. package/src/shared/model-suggestion-retry.test.ts +115 -4
  236. package/src/shared/model-suggestion-retry.ts +57 -12
  237. package/src/shared/prompt-async-transport.test.ts +217 -0
  238. package/src/shared/prompt-async-transport.ts +242 -0
  239. package/src/shared/prompt-surface-a1-golden.md +8 -8
  240. package/src/shared/rpc-server.ts +13 -1
  241. package/src/shared/rpc-types.ts +17 -0
  242. package/src/shared/rpc-utils.ts +28 -0
  243. package/src/shared/sqlite-transaction-mode-guard.test.ts +198 -0
  244. package/src/shared/sqlite-write-locker-test-support.ts +62 -0
  245. package/src/shared/status-detail-text.test.ts +23 -0
  246. package/src/shared/status-summary.ts +25 -1
  247. package/src/shared/tag-transcript.ts +82 -19
  248. package/src/shared/user-facing-codes.ts +12 -5
  249. package/src/shared/window-geometry.ts +6 -3
  250. package/dist/v2/hooks/provider-admission.d.ts +0 -22
  251. package/dist/v2/hooks/provider-admission.d.ts.map +0 -1
  252. package/dist/wrapup-orchestrator-8xzbpvm8.js +0 -18
@@ -105,6 +105,15 @@ export declare class V2StoreReader {
105
105
  */
106
106
  messagePage(sessionID: string, afterOrdinal: number, limit: number, finalWatermark: number): StoreRow[];
107
107
  messageCount(sessionID: string): number;
108
+ /**
109
+ * One page of host sessions with the directory each was created in, in
110
+ * ascending id order after `afterSessionID` (exclusive; null starts at the
111
+ * beginning). Feeds the session-to-project backfill.
112
+ */
113
+ sessionDirectoryPage(afterSessionID: string | null, limit: number): Array<{
114
+ sessionId: string;
115
+ directory: string;
116
+ }>;
108
117
  storedMessageCount(sessionID: string): number;
109
118
  messageById(sessionID: string, id: string): StoreRow | null;
110
119
  messageExistsById(sessionID: string, id: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"store-reader.d.ts","sourceRoot":"","sources":["../../src/v2/store-reader.ts"],"names":[],"mappings":"AAOA,yFAAyF;AACzF,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,MAAM,CAER;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,SAAW,EAClB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,MAAM,CAER;AAGD,MAAM,MAAM,WAAW,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,mBAAmB,GACnB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,OAAO,GACP,OAAO,GACP,WAAW,GACX,YAAY,GACZ,MAAM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M,EAAE,GAAG,MAAM;IAevE,OAAO,CAAC,kBAAkB;IAe1B,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,GAAG,SAAS;IAMvE,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,GAAG,SAAS;IAM9E,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,EAAE;IAO3D,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOvD,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAOzC,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,SAAS;IAWrE,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS;IAW3D,8EAA8E;IAC9E,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE;IASrC;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE;IAItC,OAAO,CAAC,GAAG;CAcd"}
@@ -0,0 +1,18 @@
1
+ import {
2
+ runManagedWrapup2
3
+ } from "./index-cj5qe2nw.js";
4
+ import"./index-rdey8znw.js";
5
+ import"./index-sd3egckz.js";
6
+ import"./index-01ft0h3p.js";
7
+ import"./index-c906f3ff.js";
8
+ import"./index-2zf5fv89.js";
9
+ import"./index-y5145x8k.js";
10
+ import"./index-pye48m79.js";
11
+ import"./index-v6wsttqt.js";
12
+ import"./index-jdxxq8cz.js";
13
+ import"./index-dx0xnd4q.js";
14
+ import"./index-tjq5jztd.js";
15
+ import"./index-6z9g64js.js";
16
+ export {
17
+ runManagedWrapup2 as runManagedWrapup
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.43.2",
3
+ "version": "0.44.0",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -55,9 +55,9 @@ const BASE_INTRO = (
55
55
 
56
56
  Think of your context as a desk. Every message and every tool output lands on it, and each item arrives with a §N§ tag (§1§, §42§) — the tag is the item's handle.
57
57
 
58
- When an item no longer needs to stay on the desk for the work ahead, stamp it: \`ctx_reduce\` with its tag. Stamping does not remove anything — the item stays on the desk, fully readable. From time to time, when stamped items have piled up and the desk needs room, Magic Context clears them all in one sweep; you don't pick the moment, you only stamp. Stamp as soon as an item has served its purpose, not at the end of the turn, and do it silently: nobody wants to read "I'll drop these outputs". Never stamp a user message for what it asks of you; a large paste inside one is fine once you have used it.
58
+ When an item no longer needs to stay on the desk for the work ahead, stamp it: \`ctx_reduce\` with its tag. Stamping does not remove anything — the item stays on the desk, fully readable. From time to time, when stamped items have piled up and the desk needs room, Magic Context clears them all in one sweep; you don't pick the moment, you only stamp. Stamp as soon as an item has served its purpose, not at the end of the turn, and do it silently: nobody wants to read "I'll drop these outputs". An output is used once you've taken what you need from it into your reasoning or your answer. Never stamp a user message for what it asks of you; a large paste inside one is fine once you have used it.
59
59
 
60
- Nothing stamped is ever lost. A cleared item goes to the archive — a recent one leaves a \`[dropped §N§]\` placeholder on the desk, an older one leaves nothing — and \`ctx_expand(message=N)\` brings it back whole: text, tool input, tool output. Now and then Magic Context leaves a short reminder on the desk saying how much unstamped material is lying around; that is housekeeping, not a warning, and the desk never gets smaller for it.
60
+ Nothing stamped is ever lost. A cleared item goes to the archive — a recent one leaves a \`[dropped §N§]\` placeholder on the desk, an older one leaves nothing — and \`ctx_expand(message=N)\` brings it back whole: text, tool input, tool output. Now and then Magic Context leaves a short reminder on the desk saying how much unstamped material is lying around. A reminder means stamping is overdue: act on it in your next step. It isn't a warning about the desk's size. The desk never gets smaller for it.
61
61
 
62
62
  ${TOOL_HISTORY_GUIDANCE}
63
63
 
@@ -106,7 +106,7 @@ const BASE_INTRO_LIGHT = (
106
106
  temporalAwarenessEnabled: boolean,
107
107
  ): string => `### Your desk
108
108
 
109
- Your context is a desk. Every message and tool output lands on it with a §N§ tag as its handle. When an item no longer needs to stay for the work ahead, stamp it: \`ctx_reduce\` with its tag. Stamping removes nothing — the item stays readable; from time to time, when stamped items have piled up and the desk needs room, Magic Context clears them in one sweep (you only stamp, you don't pick the moment). Stamp as soon as an item has served its purpose, silently; never stamp a user message for what it asks (a used paste inside one is fine). Nothing is lost: a cleared item goes to the archive (a recent one leaves \`[dropped §N§]\`, an older one nothing) and \`ctx_expand(message=N)\` brings it back whole. Occasional reminders about unstamped material are housekeeping, not warnings; the desk never gets smaller.
109
+ Your context is a desk. Every message and tool output lands on it with a §N§ tag as its handle. When an item no longer needs to stay for the work ahead, stamp it: \`ctx_reduce\` with its tag. Stamping removes nothing — the item stays readable; from time to time, when stamped items have piled up and the desk needs room, Magic Context clears them in one sweep (you only stamp, you don't pick the moment). Stamp as soon as an item has served its purpose, silently; never stamp a user message for what it asks (a used paste inside one is fine). An output is used once you've taken what you need from it into your reasoning or your answer. Nothing is lost: a cleared item goes to the archive (a recent one leaves \`[dropped §N§]\`, an older one nothing) and \`ctx_expand(message=N)\` brings it back whole. Occasional reminders about unstamped material may appear. A reminder means stamping is overdue: act on it in your next step. It isn't a warning about the desk's size. The desk never gets smaller.
110
110
 
111
111
  ${TOOL_HISTORY_GUIDANCE_LIGHT}
112
112
 
@@ -339,6 +339,45 @@ export function formatProtectedTokensBelowMinWarning(value: number): string {
339
339
  return `protected_tokens is a token floor (minimum ${PROTECTED_TOKENS_MIN}, default derived from the context window); ${value} looks like the old protected_tags count. Remove the key to use the default, or set a token count such as 16000.`;
340
340
  }
341
341
 
342
+ /** The blocks `resolveHistorianModel` and `resolveDreamerTaskModel` actually read. */
343
+ const MODEL_HARNESS_BLOCKS = ["opencode", "pi", "omp"] as const;
344
+
345
+ /**
346
+ * Warn when an agent's model is configured somewhere the resolver never looks.
347
+ *
348
+ * Agent models are resolved per harness: `historian.opencode.model`,
349
+ * `historian.pi.model`, `historian.omp.model`. A bare `historian.model` is
350
+ * schema-valid and reads naturally, but nothing consumes it —
351
+ * `resolveHistorianModel({historian:{model}}, "opencode")` returns no models at
352
+ * all, and the only outward sign is a historian that silently never runs (the
353
+ * Rust module reports it as `historian_no_fire=no_models`). Saying so at load
354
+ * time is the difference between a five-minute fix and a subsystem that looks
355
+ * configured and is not.
356
+ */
357
+ export function misplacedAgentModelWarnings(rawConfig: Record<string, unknown>): string[] {
358
+ const warnings: string[] = [];
359
+ for (const agent of ["historian", "dreamer"]) {
360
+ const block = rawConfig[agent];
361
+ if (!block || typeof block !== "object" || Array.isArray(block)) continue;
362
+ const record = block as Record<string, unknown>;
363
+ if (!Object.hasOwn(record, "model")) continue;
364
+ const harnessWithModel = MODEL_HARNESS_BLOCKS.find((harness) => {
365
+ const sub = record[harness];
366
+ return (
367
+ sub !== null &&
368
+ typeof sub === "object" &&
369
+ !Array.isArray(sub) &&
370
+ Object.hasOwn(sub as Record<string, unknown>, "model")
371
+ );
372
+ });
373
+ if (harnessWithModel) continue;
374
+ warnings.push(
375
+ `${agent}.model is not read: the ${agent} model is resolved per harness, so it has to be ${agent}.opencode.model (OpenCode 1 and 2), ${agent}.pi.model, or ${agent}.omp.model. As written the ${agent} resolves to no models and never runs.`,
376
+ );
377
+ }
378
+ return warnings;
379
+ }
380
+
342
381
  export function resetProtectedTagsDeprecationWarningForTest(): void {
343
382
  warnedProtectedTagsDeprecation = false;
344
383
  }
@@ -366,6 +405,7 @@ export function parsePluginConfig(
366
405
  "protected_tags is deprecated and ignored; use protected_tokens instead.",
367
406
  );
368
407
  }
408
+ preMigrationWarnings.push(...misplacedAgentModelWarnings(rawConfig));
369
409
  const migratedExperimental = migrateLegacyExperimental(
370
410
  configWithoutRemovedAgent,
371
411
  preMigrationWarnings,
@@ -0,0 +1,61 @@
1
+ /// <reference types="bun-types" />
2
+
3
+ import { describe, expect, it } from "bun:test";
4
+ import { resolveHistorianModel } from "../shared/model-resolution";
5
+ import { misplacedAgentModelWarnings, parsePluginConfig } from "./index";
6
+
7
+ /**
8
+ * A bare `historian.model` is schema-valid, reads naturally, and resolves to
9
+ * nothing. These tests pin both halves: that the resolver really does ignore it,
10
+ * and that the loader now says so instead of leaving the user with a subsystem
11
+ * that looks configured and never runs.
12
+ */
13
+ describe("misplaced agent model warning", () => {
14
+ it("is what a top-level historian.model actually resolves to", () => {
15
+ // The premise, asserted rather than assumed: if this ever starts
16
+ // resolving, the warning below becomes wrong and should be deleted.
17
+ expect(resolveHistorianModel({ historian: { model: "openai/gpt-5" } }, "opencode")).toEqual(
18
+ {
19
+ primary: undefined,
20
+ fallbacks: [],
21
+ },
22
+ );
23
+ });
24
+
25
+ it("warns when the model sits outside every harness block", () => {
26
+ const warnings = misplacedAgentModelWarnings({ historian: { model: "openai/gpt-5" } });
27
+ expect(warnings).toHaveLength(1);
28
+ expect(warnings[0]).toContain("historian.model is not read");
29
+ expect(warnings[0]).toContain("historian.opencode.model");
30
+ });
31
+
32
+ it("stays quiet when a harness block carries the model", () => {
33
+ expect(
34
+ misplacedAgentModelWarnings({
35
+ historian: { model: "openai/gpt-5", opencode: { model: "openai/gpt-5" } },
36
+ }),
37
+ ).toEqual([]);
38
+ expect(
39
+ misplacedAgentModelWarnings({ historian: { opencode: { model: "openai/gpt-5" } } }),
40
+ ).toEqual([]);
41
+ expect(misplacedAgentModelWarnings({})).toEqual([]);
42
+ expect(misplacedAgentModelWarnings({ historian: { disable: true } })).toEqual([]);
43
+ });
44
+
45
+ it("covers the dreamer on the same rule", () => {
46
+ const warnings = misplacedAgentModelWarnings({ dreamer: { model: "openai/gpt-5" } });
47
+ expect(warnings).toHaveLength(1);
48
+ expect(warnings[0]).toContain("dreamer.model is not read");
49
+ });
50
+
51
+ it("reaches the pinned config-warning channel", () => {
52
+ // configWarnings is what /ctx-status, the Pi session-start notice and
53
+ // doctor read, so landing here is what makes the warning visible.
54
+ const parsed = parsePluginConfig({ historian: { model: "openai/gpt-5" } });
55
+ expect(
56
+ (parsed.configWarnings ?? []).some((warning) =>
57
+ warning.includes("historian.model is not read"),
58
+ ),
59
+ ).toBe(true);
60
+ });
61
+ });
@@ -225,6 +225,23 @@ describe("stripUnsafeProjectConfigFields", () => {
225
225
  expect(warning).toContain("historian.pi.thinking_level");
226
226
  });
227
227
 
228
+ it("strips the historian runner from project config so a repo cannot redirect the completion", () => {
229
+ const raw: Record<string, unknown> = {
230
+ historian: {
231
+ runner: "host",
232
+ opencode: { runner: "host" },
233
+ temperature: 0.2,
234
+ },
235
+ };
236
+
237
+ const warnings = stripUnsafeProjectConfigFields(raw);
238
+
239
+ expect(raw.historian).toEqual({ opencode: {}, temperature: 0.2 });
240
+ const warning = warnings.join("\n");
241
+ expect(warning).toContain("historian.runner");
242
+ expect(warning).toContain("historian.opencode.runner");
243
+ });
244
+
228
245
  it("strips mural.model from project config but keeps the feature switch", () => {
229
246
  const raw: Record<string, unknown> = {
230
247
  mural: { enabled: true, model: "repo-controlled-model" },
@@ -23,7 +23,17 @@ const HARNESS_KEYS = PER_HARNESS_MODEL_KEYS;
23
23
  /** Every historian model-resolution field, including per-harness qualifiers.
24
24
  * Variant and thinking_level merge onto the user's historian model at resolve
25
25
  * time, so leaving them would let a cloned repo force extra spend. */
26
- const HISTORIAN_USER_ONLY_FIELDS = PER_HARNESS_MIGRATION_INVENTORY.historian.migrated_execution;
26
+ const HISTORIAN_USER_ONLY_FIELDS = [
27
+ ...PER_HARNESS_MIGRATION_INVENTORY.historian.migrated_execution,
28
+ // `runner` chooses which process and which provider account runs the hidden
29
+ // historian completion. A cloned repo redirecting it would move that spend and
30
+ // that prompt text somewhere the user never agreed to.
31
+ "runner",
32
+ // `host_runner` turns this machine's pull loop on and off. A cloned repo
33
+ // turning it ON would start spending the user's provider account on folds for
34
+ // every project this process serves, not just its own.
35
+ "host_runner",
36
+ ] as const;
27
37
  const PROMPT_SURFACE_USER_ONLY_FIELDS = ["guidance_override_path", "tool_descriptions"] as const;
28
38
 
29
39
  /**
@@ -348,10 +358,13 @@ function makeProjectThresholdWarning(field: string, reason: string): string {
348
358
  * can opt its own runtime into the experimental Rust pipeline. The resolver
349
359
  * requires trusted user-level `subc` configuration before Rust can activate.
350
360
  * - historian model-resolution fields (model, fallback_models, variant,
351
- * thinking_level), including both per-harness blocks — historian model
352
- * spend is user-level only. Qualifiers merge onto the user's historian
361
+ * thinking_level) and `runner`, including both per-harness blocks — historian
362
+ * model spend is user-level only. Qualifiers merge onto the user's historian
353
363
  * model at resolve time, so a cloned repo cannot force extra thinking or
354
- * variant cost.
364
+ * variant cost, and cannot move the completion to a different process or
365
+ * provider account. `host_runner` is stripped for the same reason in the other
366
+ * direction: a repo must not switch this machine's pull loop on and start
367
+ * spending the user's provider account on folds.
355
368
  * - `mural.model` at the top-level block, the legacy experimental spelling,
356
369
  * and any nested `mural.model` under hidden agents — a cloned repo cannot
357
370
  * choose where project memory is sent.
@@ -579,6 +592,17 @@ export function stripUnsafeProjectConfigFields(projectRaw: Record<string, unknow
579
592
  }
580
593
  }
581
594
 
595
+ // `dreamer.runner` chooses which process and which provider account runs the
596
+ // module-routed dreamer completions, for the same reason `historian.runner`
597
+ // is user-level only.
598
+ const dreamer = projectRaw.dreamer;
599
+ if (isPlainObject(dreamer) && "runner" in dreamer) {
600
+ delete dreamer.runner;
601
+ warnings.push(
602
+ "Ignoring dreamer.runner from project config (security: which process and provider account run dreamer completions is a user-level setting).",
603
+ );
604
+ }
605
+
582
606
  const mural = projectRaw.mural;
583
607
  if (isPlainObject(mural) && "model" in mural) {
584
608
  delete mural.model;
@@ -624,6 +624,12 @@ const AgentMetadataSchema = AgentOverrideConfigSchema.pick({
624
624
 
625
625
  /** Combined dreamer metadata plus independent strict execution blocks. */
626
626
  export const DreamerConfigSchema = AgentMetadataSchema.extend({
627
+ runner: z
628
+ .enum(["broca", "host"])
629
+ .optional()
630
+ .describe(
631
+ 'Which side runs the dreamer completions the Rust module routes (classify-memories) in Rust transform mode: "host" runs them on this process\'s carrier, "broca" routes them to the Broca module. When unset, historian.runner applies, and when that is unset too the harness decides the same way it does for the historian. User-level config only.',
632
+ ),
627
633
  opencode: DreamerOpenCodeHarnessBlockSchema.optional(),
628
634
  pi: DreamerPiHarnessBlockSchema.optional(),
629
635
  omp: DreamerOmpHarnessBlockSchema.optional(),
@@ -645,6 +651,25 @@ export const HistorianConfigSchema = AgentMetadataSchema.extend({
645
651
  opencode: OpenCodeHarnessBlockSchema.optional(),
646
652
  pi: PiHarnessBlockSchema.optional(),
647
653
  omp: OmpHarnessBlockSchema.optional(),
654
+ runner: z
655
+ .enum(["broca", "host"])
656
+ .optional()
657
+ .describe(
658
+ 'Which side runs the historian completion in Rust transform mode: "host" queues it for this process to run on the configured historian model, "broca" routes it to the Broca module. When unset the harness decides: OpenCode 1 and OpenCode 2 use "host", Claude Code (through the Thalamus gateway, which has no host to run a completion) uses "broca". User-level config only — it decides whose provider account pays for the call.',
659
+ ),
660
+ host_runner: z
661
+ .object({
662
+ enabled: z
663
+ .boolean()
664
+ .optional()
665
+ .describe(
666
+ "Whether this process answers historian runs queued for a claimant (default true). Setting it to false stops the pull loop without changing historian.runner, so an operator can take one machine out of the lane and leave the queued runs for another claimant or for the runner setting to be changed deliberately.",
667
+ ),
668
+ })
669
+ .optional()
670
+ .describe(
671
+ "Controls for this process's historian pull loop, which answers runs the Rust module queues for the host runner (`historian.runner: \"host\"`, or unset on OpenCode 1 and OpenCode 2). User-level config only — it decides whether this machine's provider account is spent on folds.",
672
+ ),
648
673
  two_pass: z
649
674
  .boolean()
650
675
  .default(false)
@@ -675,7 +700,7 @@ const BaseEmbeddingConfigSchema = z
675
700
  .enum(["local", "openai-compatible", "off", "synapse"])
676
701
  .default("local")
677
702
  .describe(
678
- "Embedding provider. 'local' uses Xenova/all-MiniLM-L6-v2, 'openai-compatible' requires endpoint and model, 'synapse' uses the certified local Synapse lane with an explicit fallback provider, and 'off' disables embeddings.",
703
+ "Embedding provider. 'local' uses Xenova/all-MiniLM-L6-v2, 'openai-compatible' requires endpoint and model, 'synapse' uses the certified local Synapse lane with an explicit fallback provider, and 'off' disables embeddings. Session history is embedded for semantic ctx_search whenever the provider is not 'off', regardless of memory.enabled; memories are embedded only while memory.enabled is true.",
679
704
  ),
680
705
  fallback_provider: EmbeddingFallbackProviderSchema.optional().describe(
681
706
  "Fallback provider for the Synapse lane. Required when provider is 'synapse'; local, openai-compatible, and off are valid.",
@@ -1413,7 +1438,9 @@ export const MagicContextConfigSchema = z
1413
1438
  enabled: z
1414
1439
  .boolean()
1415
1440
  .default(true)
1416
- .describe("Enable cross-session memory (default: true)"),
1441
+ .describe(
1442
+ "Enable cross-session memory (default: true). Does not affect history embedding or semantic ctx_search over session history; set embedding.provider to 'off' to stop all embedding.",
1443
+ ),
1417
1444
  injection_budget_tokens: z
1418
1445
  .number()
1419
1446
  .min(500)
@@ -1,6 +1,7 @@
1
1
  export * from "./logger";
2
2
  export * from "./model-suggestion-retry";
3
3
  export * from "./normalize-sdk-response";
4
+ export * from "./prompt-async-transport";
4
5
  export * from "./prompt-surface";
5
6
  export * from "./prompt-surface-runtime";
6
7
  export * from "./resolve-fallbacks";
@@ -30,6 +30,8 @@ type RotationScenarioResult = {
30
30
  files: string[];
31
31
  };
32
32
 
33
+ type RetryScenarioResult = { content: string; failed: number };
34
+
33
35
  type HotPathScenarioResult = {
34
36
  statCalls: number;
35
37
  };
@@ -49,6 +51,16 @@ if (!root || !loggerModuleUrl || !scenario) {
49
51
  const logPath = path.join(root, "nested", "magic-context.log");
50
52
  process.env.MAGIC_CONTEXT_LOG_PATH = logPath;
51
53
  let statCalls = 0;
54
+ if (scenario === "retry") {
55
+ let attempts = 0;
56
+ mock.module("node:fs", () => ({
57
+ ...fs,
58
+ appendFileSync: (...args) => {
59
+ if (attempts++ === 0) throw new Error("injected transient write failure");
60
+ return fs.appendFileSync(...args);
61
+ },
62
+ }));
63
+ }
52
64
  if (scenario === "hot-path") {
53
65
  mock.module("node:fs", () => ({
54
66
  ...fs,
@@ -61,7 +73,28 @@ if (scenario === "hot-path") {
61
73
 
62
74
  const logger = await import(loggerModuleUrl);
63
75
 
64
- if (scenario === "rotation") {
76
+ if (scenario === "retry") {
77
+ logger.log("first buffered line");
78
+ logger.log("second buffered line");
79
+ logger.flushLogger();
80
+ const failed = logger.getLoggerDiagnostics().swallowedWriteCount;
81
+ logger.log("third buffered line");
82
+ logger.flushLogger();
83
+ console.log(JSON.stringify({ content: fs.readFileSync(logPath, "utf8"), failed }));
84
+ } else if (scenario === "oversized") {
85
+ logger.log("x".repeat(2_000_000));
86
+ logger.flushLogger();
87
+ console.log(JSON.stringify({ content: fs.readFileSync(logPath, "utf8"), failed: logger.getLoggerDiagnostics().swallowedWriteCount }));
88
+ } else if (scenario === "bounded") {
89
+ const failedPath = path.join(root, "unwritable-target");
90
+ fs.mkdirSync(failedPath);
91
+ process.env.MAGIC_CONTEXT_LOG_PATH = failedPath;
92
+ for (let i = 0; i < 100; i++) logger.log("line-" + i + "-" + "x".repeat(20_000));
93
+ logger.flushLogger();
94
+ process.env.MAGIC_CONTEXT_LOG_PATH = logPath;
95
+ logger.flushLogger();
96
+ console.log(JSON.stringify({ content: fs.readFileSync(logPath, "utf8"), failed: logger.getLoggerDiagnostics().swallowedWriteCount }));
97
+ } else if (scenario === "rotation") {
65
98
  const maxLogBytes = 32 * 1024 * 1024;
66
99
  fs.mkdirSync(path.dirname(logPath), { recursive: true });
67
100
  fs.writeFileSync(logPath, Buffer.alloc(maxLogBytes, "o"));
@@ -144,7 +177,14 @@ afterEach(() => {
144
177
  });
145
178
 
146
179
  async function runLoggerScenario<T>(
147
- scenario: "recovery" | "diagnostics" | "rotation" | "hot-path",
180
+ scenario:
181
+ | "recovery"
182
+ | "diagnostics"
183
+ | "rotation"
184
+ | "hot-path"
185
+ | "retry"
186
+ | "bounded"
187
+ | "oversized",
148
188
  ): Promise<T> {
149
189
  const root = mkdtempSync(path.join(os.tmpdir(), "magic-context-logger-test-"));
150
190
  scenarioRoots.push(root);
@@ -171,6 +211,27 @@ async function runLoggerScenario<T>(
171
211
  }
172
212
 
173
213
  describe("logger", () => {
214
+ test("retries the whole buffered batch after a transient append failure", async () => {
215
+ const result = await runLoggerScenario<RetryScenarioResult>("retry");
216
+ expect(result.failed).toBe(1);
217
+ expect(result.content).toContain("first buffered line");
218
+ expect(result.content).toContain("second buffered line");
219
+ expect(result.content).toContain("third buffered line");
220
+ });
221
+ test("reports a single oversized line even if no payload remains buffered", async () => {
222
+ const result = await runLoggerScenario<RetryScenarioResult>("oversized");
223
+ expect(result.content).toMatch(/logger dropped 1 line: buffer exceeded/);
224
+ expect(Buffer.byteLength(result.content)).toBeLessThan(1000);
225
+ });
226
+
227
+ test("bounds failed batches and reports the number of discarded lines", async () => {
228
+ const result = await runLoggerScenario<RetryScenarioResult>("bounded");
229
+ expect(result.failed).toBeGreaterThan(0);
230
+ expect(Buffer.byteLength(result.content)).toBeLessThan(1_100_000);
231
+ expect(result.content).toMatch(/logger dropped \d+ lines: buffer exceeded/);
232
+ expect(result.content).toContain("line-99-");
233
+ });
234
+
174
235
  test("recreates a log directory removed while the process is running", async () => {
175
236
  const result = await runLoggerScenario<LoggerScenarioResult>("recovery");
176
237
 
@@ -9,6 +9,16 @@ let buffer: string[] = [];
9
9
  let flushTimer: ReturnType<typeof setTimeout> | null = null;
10
10
  const FLUSH_INTERVAL_MS = 500;
11
11
  const BUFFER_SIZE_LIMIT = 50;
12
+ const MAX_BUFFERED_BYTES = 1024 * 1024;
13
+ let bufferedBytes = 0;
14
+ let droppedLines = 0;
15
+
16
+ function boundBuffer(): void {
17
+ while (bufferedBytes > MAX_BUFFERED_BYTES && buffer.length > 0) {
18
+ bufferedBytes -= Buffer.byteLength(buffer.shift() ?? "");
19
+ droppedLines++;
20
+ }
21
+ }
12
22
  const MAX_LOG_FILE_BYTES = 32 * 1024 * 1024;
13
23
  const SIZE_CHECK_INTERVAL_FLUSHES = 64;
14
24
 
@@ -141,11 +151,12 @@ function flush(): void {
141
151
  clearTimeout(flushTimer);
142
152
  flushTimer = null;
143
153
  }
144
- if (buffer.length === 0) return;
145
- const bufferedData = buffer.join("");
146
- buffer = [];
154
+ if (buffer.length === 0 && droppedLines === 0) return;
155
+ const notice = droppedLines
156
+ ? `[${new Date().toISOString()}] [magic-context][global] logger dropped ${droppedLines} ${droppedLines === 1 ? "line" : "lines"}: buffer exceeded ${MAX_BUFFERED_BYTES} bytes while writes were pending\n`
157
+ : "";
147
158
  try {
148
- const data = capLogData(bufferedData);
159
+ const data = capLogData(notice + buffer.join(""));
149
160
  const logFile = getMagicContextLogPath();
150
161
  ensureDir(logFile);
151
162
  let currentSize = getCurrentLogSize(logFile);
@@ -155,6 +166,9 @@ function flush(): void {
155
166
  currentSize = 0;
156
167
  }
157
168
  fs.appendFileSync(logFile, data, { encoding: "utf8", mode: 0o600 });
169
+ buffer = [];
170
+ bufferedBytes = 0;
171
+ droppedLines = 0;
158
172
  activeLogFile = logFile;
159
173
  activeLogSize = currentSize + dataSize;
160
174
  flushesSinceSizeCheck++;
@@ -163,6 +177,7 @@ function flush(): void {
163
177
  activeLogSize = null;
164
178
  flushesSinceSizeCheck = 0;
165
179
  recordSwallowedWrite(error);
180
+ boundBuffer();
166
181
  }
167
182
  }
168
183
 
@@ -186,7 +201,10 @@ export function log(message: string, data?: unknown): void {
186
201
  `${data.message}${data.stack ? `\n${data.stack}` : ""}`,
187
202
  )}`
188
203
  : ` ${JSON.stringify(sanitizeConfigValue(data))}`;
189
- buffer.push(`[${timestamp}] ${sanitizeDiagnosticText(message)}${serialized}\n`);
204
+ const line = `[${timestamp}] ${sanitizeDiagnosticText(message)}${serialized}\n`;
205
+ buffer.push(line);
206
+ bufferedBytes += Buffer.byteLength(line);
207
+ boundBuffer();
190
208
  if (buffer.length >= BUFFER_SIZE_LIMIT) {
191
209
  flush();
192
210
  } else {