@cortexkit/opencode-magic-context 0.45.0 → 0.46.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 (385) hide show
  1. package/README.md +26 -0
  2. package/dist/{announcement-f75t58v9.js → announcement-y35wzg2r.js} +1 -1
  3. package/dist/config/index.d.ts.map +1 -1
  4. package/dist/config/live-run-config.d.ts.map +1 -1
  5. package/dist/config/migrate-config-location.d.ts.map +1 -1
  6. package/dist/config/schema/magic-context.d.ts +10 -4
  7. package/dist/config/schema/magic-context.d.ts.map +1 -1
  8. package/dist/{conflict-warning-hook-5yrz2r24.js → conflict-warning-hook-7fj2b9jw.js} +6 -5
  9. package/dist/context-8dkpszy5.js +4483 -0
  10. package/dist/{derive-budgets-a63zsm5c.js → derive-budgets-7nj7r1rv.js} +2 -2
  11. package/dist/embedding-worker.js +4 -4
  12. package/dist/features/magic-context/checkout-claim-fake-subc.test-support.d.ts +45 -0
  13. package/dist/features/magic-context/checkout-claim-fake-subc.test-support.d.ts.map +1 -0
  14. package/dist/features/magic-context/checkout-claim.d.ts +155 -0
  15. package/dist/features/magic-context/checkout-claim.d.ts.map +1 -0
  16. package/dist/features/magic-context/compaction-marker.d.ts +20 -3
  17. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  18. package/dist/features/magic-context/compartment-storage.d.ts +23 -2
  19. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  21. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/provider-output-failure.d.ts +6 -2
  23. package/dist/features/magic-context/dreamer/provider-output-failure.d.ts.map +1 -1
  24. package/dist/features/magic-context/dreamer/provider-output-failure.test-support.d.ts +30 -0
  25. package/dist/features/magic-context/dreamer/provider-output-failure.test-support.d.ts.map +1 -0
  26. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
  27. package/dist/features/magic-context/dreamer/task-executor.d.ts +9 -0
  28. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  29. package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
  30. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  31. package/dist/features/magic-context/dreamer/verify-diff.d.ts.map +1 -1
  32. package/dist/features/magic-context/dreamer/verify-gate.d.ts.map +1 -1
  33. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  34. package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -1
  35. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  36. package/dist/features/magic-context/memory/project-identity-cache.d.ts.map +1 -1
  37. package/dist/features/magic-context/memory/storage-memory-verifications.d.ts.map +1 -1
  38. package/dist/features/magic-context/memory/storage-memory.d.ts +3 -0
  39. package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -1
  40. package/dist/features/magic-context/memory/verification-paths.d.ts +2 -2
  41. package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
  42. package/dist/features/magic-context/merged-reasoning-decisions.d.ts.map +1 -1
  43. package/dist/features/magic-context/message-index-async.d.ts +3 -3
  44. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  45. package/dist/features/magic-context/message-index.d.ts +2 -0
  46. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  47. package/dist/features/magic-context/migration-v95-perf-indexes.d.ts +12 -0
  48. package/dist/features/magic-context/migration-v95-perf-indexes.d.ts.map +1 -0
  49. package/dist/features/magic-context/migration-worker-client.d.ts +4 -4
  50. package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
  51. package/dist/features/magic-context/migrations.d.ts +1 -0
  52. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  53. package/dist/features/magic-context/mural/render-trigger.d.ts.map +1 -1
  54. package/dist/features/magic-context/mural/resolve-mural.d.ts +15 -4
  55. package/dist/features/magic-context/mural/resolve-mural.d.ts.map +1 -1
  56. package/dist/features/magic-context/mural/source-revision.d.ts +7 -0
  57. package/dist/features/magic-context/mural/source-revision.d.ts.map +1 -0
  58. package/dist/features/magic-context/mural/storage-mural-cues.d.ts.map +1 -1
  59. package/dist/features/magic-context/reclaim-protection.d.ts +15 -10
  60. package/dist/features/magic-context/reclaim-protection.d.ts.map +1 -1
  61. package/dist/features/magic-context/session-cache-ttl.d.ts +4 -2
  62. package/dist/features/magic-context/session-cache-ttl.d.ts.map +1 -1
  63. package/dist/features/magic-context/smart-notes/capabilities.d.ts +3 -0
  64. package/dist/features/magic-context/smart-notes/capabilities.d.ts.map +1 -1
  65. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  66. package/dist/features/magic-context/smart-notes/github-token.d.ts +5 -0
  67. package/dist/features/magic-context/smart-notes/github-token.d.ts.map +1 -0
  68. package/dist/features/magic-context/smart-notes/runner.d.ts +1 -0
  69. package/dist/features/magic-context/smart-notes/runner.d.ts.map +1 -1
  70. package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts +12 -0
  71. package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts.map +1 -1
  72. package/dist/features/magic-context/smart-notes/ssrf-guard.d.ts +6 -0
  73. package/dist/features/magic-context/smart-notes/ssrf-guard.d.ts.map +1 -1
  74. package/dist/features/magic-context/smart-notes/storage.d.ts.map +1 -1
  75. package/dist/features/magic-context/smart-notes/types.d.ts +2 -0
  76. package/dist/features/magic-context/smart-notes/types.d.ts.map +1 -1
  77. package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
  78. package/dist/features/magic-context/storage-db.d.ts +6 -9
  79. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  80. package/dist/features/magic-context/storage-meta-shared.d.ts +1 -1
  81. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  82. package/dist/features/magic-context/storage-ops.d.ts +8 -1
  83. package/dist/features/magic-context/storage-ops.d.ts.map +1 -1
  84. package/dist/features/magic-context/storage-replay-document.d.ts +7 -0
  85. package/dist/features/magic-context/storage-replay-document.d.ts.map +1 -1
  86. package/dist/features/magic-context/storage-schema-helpers.d.ts +2 -0
  87. package/dist/features/magic-context/storage-schema-helpers.d.ts.map +1 -1
  88. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  89. package/dist/features/magic-context/storage-source.d.ts.map +1 -1
  90. package/dist/features/magic-context/storage-tags.d.ts +11 -3
  91. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  92. package/dist/features/magic-context/storage.d.ts +2 -2
  93. package/dist/features/magic-context/storage.d.ts.map +1 -1
  94. package/dist/features/magic-context/temporal-decisions.d.ts +10 -0
  95. package/dist/features/magic-context/temporal-decisions.d.ts.map +1 -0
  96. package/dist/features/magic-context/tool-definition-tokens.d.ts +2 -0
  97. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
  98. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  99. package/dist/features/magic-context/types.d.ts +7 -6
  100. package/dist/features/magic-context/types.d.ts.map +1 -1
  101. package/dist/features/magic-context/window-report-ledger.d.ts.map +1 -1
  102. package/dist/hooks/auto-update-checker/index.d.ts.map +1 -1
  103. package/dist/hooks/magic-context/apply-operations.d.ts +8 -0
  104. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  105. package/dist/hooks/magic-context/cache-busting-signals.d.ts +6 -3
  106. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  107. package/dist/hooks/magic-context/channel2-cycle.d.ts +2 -0
  108. package/dist/hooks/magic-context/channel2-cycle.d.ts.map +1 -1
  109. package/dist/hooks/magic-context/compaction-marker-manager.d.ts +7 -0
  110. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  111. package/dist/hooks/magic-context/compartment-prompt.d.ts +2 -2
  112. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  113. package/dist/hooks/magic-context/compartment-render-epoch.d.ts +8 -0
  114. package/dist/hooks/magic-context/compartment-render-epoch.d.ts.map +1 -1
  115. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +18 -4
  116. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -1
  117. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  118. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
  119. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  120. package/dist/hooks/magic-context/ctx-reduce-availability.d.ts +12 -0
  121. package/dist/hooks/magic-context/ctx-reduce-availability.d.ts.map +1 -1
  122. package/dist/hooks/magic-context/decision-calibration.d.ts +3 -0
  123. package/dist/hooks/magic-context/decision-calibration.d.ts.map +1 -1
  124. package/dist/hooks/magic-context/default-protection-pressure.test-support.d.ts +37 -0
  125. package/dist/hooks/magic-context/default-protection-pressure.test-support.d.ts.map +1 -0
  126. package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts +4 -0
  127. package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts.map +1 -1
  128. package/dist/hooks/magic-context/edit-marker.d.ts.map +1 -1
  129. package/dist/hooks/magic-context/emergency-drop.d.ts +2 -0
  130. package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
  131. package/dist/hooks/magic-context/emergency-fail-closed.d.ts +21 -1
  132. package/dist/hooks/magic-context/emergency-fail-closed.d.ts.map +1 -1
  133. package/dist/hooks/magic-context/event-handler.d.ts +5 -0
  134. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  135. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +30 -1
  136. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  137. package/dist/hooks/magic-context/heuristic-cleanup.d.ts +2 -0
  138. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  139. package/dist/hooks/magic-context/historian-prompt-fit.d.ts +4 -2
  140. package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
  141. package/dist/hooks/magic-context/hook.d.ts +2 -1
  142. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  143. package/dist/hooks/magic-context/inject-compartments.d.ts +9 -10
  144. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  145. package/dist/hooks/magic-context/lkg-measured-request.d.ts +69 -0
  146. package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -0
  147. package/dist/hooks/magic-context/lkg-persist.d.ts +2 -0
  148. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
  149. package/dist/hooks/magic-context/lkg-replay-fit.d.ts +14 -0
  150. package/dist/hooks/magic-context/lkg-replay-fit.d.ts.map +1 -1
  151. package/dist/hooks/magic-context/lkg-replay.d.ts +10 -1
  152. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  153. package/dist/hooks/magic-context/lkg-slot.d.ts +4 -0
  154. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  155. package/dist/hooks/magic-context/module-state-sync.d.ts +2 -0
  156. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  157. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  158. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  159. package/dist/hooks/magic-context/note-nudger.d.ts +17 -5
  160. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
  161. package/dist/hooks/magic-context/read-session-chunk.d.ts +1 -1
  162. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  163. package/dist/hooks/magic-context/read-session-db.d.ts +1 -0
  164. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  165. package/dist/hooks/magic-context/read-session-formatting.d.ts +7 -0
  166. package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
  167. package/dist/hooks/magic-context/read-session-raw.d.ts +4 -0
  168. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  169. package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
  170. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +2 -0
  171. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  172. package/dist/hooks/magic-context/reference-retrieval.d.ts +27 -17
  173. package/dist/hooks/magic-context/reference-retrieval.d.ts.map +1 -1
  174. package/dist/hooks/magic-context/request-hook-order.d.ts +56 -0
  175. package/dist/hooks/magic-context/request-hook-order.d.ts.map +1 -0
  176. package/dist/hooks/magic-context/rust-mode-transform.d.ts +22 -3
  177. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  178. package/dist/hooks/magic-context/strip-content.d.ts +4 -2
  179. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  180. package/dist/hooks/magic-context/supersession-reclaim.d.ts +4 -0
  181. package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
  182. package/dist/hooks/magic-context/system-prompt-hash.d.ts +7 -0
  183. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  184. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +12 -3
  185. package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
  186. package/dist/hooks/magic-context/temporal-awareness.d.ts +6 -3
  187. package/dist/hooks/magic-context/temporal-awareness.d.ts.map +1 -1
  188. package/dist/hooks/magic-context/temporal-served-projection.d.ts +4 -0
  189. package/dist/hooks/magic-context/temporal-served-projection.d.ts.map +1 -0
  190. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  191. package/dist/hooks/magic-context/tool-reclaim.d.ts +2 -0
  192. package/dist/hooks/magic-context/tool-reclaim.d.ts.map +1 -1
  193. package/dist/hooks/magic-context/transform-message-helpers.d.ts +5 -0
  194. package/dist/hooks/magic-context/transform-message-helpers.d.ts.map +1 -1
  195. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +41 -17
  196. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  197. package/dist/hooks/magic-context/transform.d.ts +12 -0
  198. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  199. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  200. package/dist/{index-vvtfyw1z.js → index-0d3g3461.js} +5 -13
  201. package/dist/index-1bc61ans.js +154 -0
  202. package/dist/{index-n96ag4rk.js → index-1zx87sdm.js} +5 -1
  203. package/dist/{index-4krbw8z9.js → index-3h0ybwah.js} +608 -102
  204. package/dist/{index-gd5qx1j9.js → index-5eqk6z3s.js} +62 -1
  205. package/dist/index-5gq3b2ya.js +494 -0
  206. package/dist/{index-75zjgwga.js → index-7qw742ev.js} +1 -1
  207. package/dist/{index-f85teqck.js → index-8da2zjhz.js} +3 -256
  208. package/dist/{index-w9jwmntv.js → index-b35pxds2.js} +9 -1
  209. package/dist/{index-8fgkmxmy.js → index-e2dtv0ra.js} +4 -3
  210. package/dist/{v2/server-a4m2b1yv.js → index-fg34g6a5.js} +55 -1
  211. package/dist/{index-xgt9k6c6.js → index-j7fvnjye.js} +2 -1
  212. package/dist/{index-2aq21j41.js → index-k4404na5.js} +418 -127
  213. package/dist/{index-2ntg5sd4.js → index-k5bdx1bx.js} +9 -5
  214. package/dist/{index-bmzf7zxv.js → index-majxda46.js} +23 -5
  215. package/dist/{index-16ny736w.js → index-p821bjdb.js} +14406 -13726
  216. package/dist/{index-remp7e2g.js → index-q4yp4b52.js} +16 -1
  217. package/dist/index-qr6r7akd.js +28505 -0
  218. package/dist/{index-fr2z4qy8.js → index-r5hmbx3t.js} +132 -169
  219. package/dist/index-sfnj6h8h.js +259 -0
  220. package/dist/index-sj29b3z2.js +30 -0
  221. package/dist/{index-q7yesyk9.js → index-yasgb8ej.js} +23 -24
  222. package/dist/index.d.ts.map +1 -1
  223. package/dist/index.js +1983 -33118
  224. package/dist/{message-time-backfill-an311pmk.js → message-time-backfill-68gj6t3e.js} +2 -2
  225. package/dist/migration-worker.js +12 -7
  226. package/dist/plugin/dream-timer.d.ts +25 -1
  227. package/dist/plugin/dream-timer.d.ts.map +1 -1
  228. package/dist/plugin/hooks/create-session-hooks.d.ts +2 -1
  229. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  230. package/dist/plugin/messages-transform.d.ts +13 -0
  231. package/dist/plugin/messages-transform.d.ts.map +1 -1
  232. package/dist/plugin/rpc-handlers.d.ts +4 -0
  233. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  234. package/dist/plugin/subagent-tool-policy.d.ts +14 -0
  235. package/dist/plugin/subagent-tool-policy.d.ts.map +1 -0
  236. package/dist/plugin/tool-registry.d.ts +1 -0
  237. package/dist/plugin/tool-registry.d.ts.map +1 -1
  238. package/dist/{read-session-chunk-8rxs0tc9.js → read-session-chunk-egz7r68d.js} +8 -8
  239. package/dist/{recomp-orchestrator-nzamtw29.js → recomp-orchestrator-ejq7ex5d.js} +15 -15
  240. package/dist/{send-session-notification-nqpv7cne.js → send-session-notification-dyw42dtr.js} +4 -4
  241. package/dist/shared/announcement.d.ts.map +1 -1
  242. package/dist/shared/cache-ttl-display.d.ts +6 -4
  243. package/dist/shared/cache-ttl-display.d.ts.map +1 -1
  244. package/dist/shared/model-cache-ttl.d.ts +1 -1
  245. package/dist/shared/model-cache-ttl.d.ts.map +1 -1
  246. package/dist/shared/model-suggestion-retry.d.ts +2 -0
  247. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  248. package/dist/shared/models-dev-cache.d.ts.map +1 -1
  249. package/dist/shared/protected-tools-policy.d.ts +6 -0
  250. package/dist/shared/protected-tools-policy.d.ts.map +1 -0
  251. package/dist/shared/quota-diagnostic.d.ts +4 -0
  252. package/dist/shared/quota-diagnostic.d.ts.map +1 -0
  253. package/dist/shared/rpc-server.d.ts.map +1 -1
  254. package/dist/shared/sqlite-context-pragmas.d.ts +12 -0
  255. package/dist/shared/sqlite-context-pragmas.d.ts.map +1 -0
  256. package/dist/shared/sqlite-helpers.d.ts +9 -0
  257. package/dist/shared/sqlite-helpers.d.ts.map +1 -1
  258. package/dist/shared/sqlite.d.ts +10 -0
  259. package/dist/shared/sqlite.d.ts.map +1 -1
  260. package/dist/shared/status-summary.d.ts +1 -0
  261. package/dist/shared/status-summary.d.ts.map +1 -1
  262. package/dist/shared/status-view-check.d.ts.map +1 -1
  263. package/dist/shared/status-view.d.ts +4 -0
  264. package/dist/shared/status-view.d.ts.map +1 -1
  265. package/dist/shared/storage-permissions.d.ts +24 -0
  266. package/dist/shared/storage-permissions.d.ts.map +1 -1
  267. package/dist/shared/temporal-upgrade-fixture.d.ts +19 -0
  268. package/dist/shared/temporal-upgrade-fixture.d.ts.map +1 -0
  269. package/dist/shared/user-facing-codes.d.ts +5 -0
  270. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  271. package/dist/shared/write-transaction-timing.d.ts +8 -1
  272. package/dist/shared/write-transaction-timing.d.ts.map +1 -1
  273. package/dist/tools/ctx-expand/render.d.ts.map +1 -1
  274. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  275. package/dist/tools/ctx-reduce/constants.d.ts +2 -0
  276. package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
  277. package/dist/tools/ctx-reduce/tools.d.ts +4 -4
  278. package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
  279. package/dist/{transform-postprocess-phase-414phndq.js → transform-postprocess-phase-tz3pat2p.js} +15 -15
  280. package/dist/v2/context-8vgtb6sz.js +52166 -0
  281. package/dist/v2/{derive-budgets-v0krf3t7.js → derive-budgets-kdgp4s3r.js} +4 -3
  282. package/dist/v2/embedding-worker.js +6 -5
  283. package/dist/v2/fold/boundary.d.ts +2 -0
  284. package/dist/v2/fold/boundary.d.ts.map +1 -1
  285. package/dist/v2/fold/owner.d.ts.map +1 -1
  286. package/dist/v2/hooks/channel2.d.ts +2 -0
  287. package/dist/v2/hooks/channel2.d.ts.map +1 -1
  288. package/dist/v2/hooks/context.d.ts +2 -2
  289. package/dist/v2/hooks/context.d.ts.map +1 -1
  290. package/dist/v2/hooks/dream-timer.d.ts +39 -0
  291. package/dist/v2/hooks/dream-timer.d.ts.map +1 -0
  292. package/dist/v2/hooks/payload.d.ts.map +1 -1
  293. package/dist/v2/hooks/store.d.ts.map +1 -1
  294. package/dist/v2/hooks/tools.d.ts +1 -1
  295. package/dist/v2/hooks/tools.d.ts.map +1 -1
  296. package/dist/v2/hooks/update-check.d.ts.map +1 -1
  297. package/dist/v2/{message-time-backfill-0n93vrd7.js → message-time-backfill-r6qkem1x.js} +3 -3
  298. package/dist/v2/migration-worker.js +13 -8
  299. package/dist/v2/{read-session-chunk-hjza38hr.js → read-session-chunk-8vjp6581.js} +9 -9
  300. package/dist/v2/recomp-orchestrator-5xj0yzyk.js +39 -0
  301. package/dist/v2/{safe-notification-target-wtj0bbc2.js → safe-notification-target-eb1n1vfb.js} +2 -2
  302. package/dist/v2/{send-session-notification-mq9frrtm.js → send-session-notification-qs0j78v6.js} +6 -6
  303. package/dist/v2/server-14vq4kpm.js +30 -0
  304. package/dist/v2/server-1bc61ans.js +154 -0
  305. package/dist/v2/{server-n96ag4rk.js → server-1zx87sdm.js} +5 -1
  306. package/dist/v2/server-3n4q9xme.js +79 -0
  307. package/dist/v2/server-4663ejam.js +3351 -0
  308. package/dist/v2/{server-rhdgxp1t.js → server-51dv1pr5.js} +63 -2
  309. package/dist/v2/{server-5317ykaf.js → server-6r257mf5.js} +1 -1
  310. package/dist/v2/server-84w6rvvf.js +14 -0
  311. package/dist/v2/{server-qpg6wf72.js → server-ajzeteqw.js} +9 -1
  312. package/dist/{index-a4m2b1yv.js → v2/server-fg34g6a5.js} +55 -1
  313. package/dist/v2/{server-e36nf2p1.js → server-frbm99q5.js} +1595 -1599
  314. package/dist/v2/{server-remp7e2g.js → server-g0fjrkta.js} +16 -1
  315. package/dist/v2/{server-z19x7eqz.js → server-mcfawjgc.js} +4 -4
  316. package/dist/v2/server-p2en78c8.js +3892 -0
  317. package/dist/v2/{server-hfjfbg59.js → server-qp5hx1ad.js} +608 -105
  318. package/dist/v2/{server-c4g2y1z8.js → server-vnh7r35f.js} +2778 -5383
  319. package/dist/v2/server-vs5gpnd4.js +493 -0
  320. package/dist/v2/{server-w99cyt6a.js → server-wvjvfhck.js} +14 -6
  321. package/dist/v2/{server-v5xgft5v.js → server-xtp687da.js} +186 -3533
  322. package/dist/v2/{server-0jqw05sa.js → server-y8maxeft.js} +6 -84
  323. package/dist/v2/server.d.ts.map +1 -1
  324. package/dist/v2/server.js +104 -49288
  325. package/dist/v2/store-reader.d.ts +39 -1
  326. package/dist/v2/store-reader.d.ts.map +1 -1
  327. package/dist/v2/tool-result.d.ts +8 -0
  328. package/dist/v2/tool-result.d.ts.map +1 -0
  329. package/dist/v2/tui/index.d.ts.map +1 -1
  330. package/dist/v2/{wrapup-orchestrator-tbyx78dz.js → wrapup-orchestrator-r5t1pyj8.js} +20 -16
  331. package/dist/wrapup-orchestrator-kw3x3myw.js +26 -0
  332. package/package.json +22 -7
  333. package/src/config/index.ts +21 -4
  334. package/src/config/latch-permanence-guard.test.ts +6 -1
  335. package/src/config/live-run-config.ts +1 -0
  336. package/src/config/migrate-config-location.test.ts +31 -1
  337. package/src/config/migrate-config-location.ts +8 -41
  338. package/src/config/protected-tools.test.ts +70 -0
  339. package/src/config/raw-loader.test.ts +15 -0
  340. package/src/config/raw-loader.ts +1 -1
  341. package/src/config/removed-agent-source-fence.test.ts +10 -1
  342. package/src/config/schema/magic-context.test.ts +20 -1
  343. package/src/config/schema/magic-context.ts +21 -7
  344. package/src/shared/announcement.ts +6 -5
  345. package/src/shared/cache-ttl-display.test.ts +1 -1
  346. package/src/shared/cache-ttl-display.ts +17 -16
  347. package/src/shared/fold-render-lock-fence.test.ts +84 -0
  348. package/src/shared/fold-render-lock-fixtures.test.ts +276 -0
  349. package/src/shared/model-cache-ttl.test.ts +2 -2
  350. package/src/shared/model-cache-ttl.ts +8 -4
  351. package/src/shared/model-suggestion-retry.test.ts +104 -1
  352. package/src/shared/model-suggestion-retry.ts +63 -6
  353. package/src/shared/models-dev-cache.ts +3 -11
  354. package/src/shared/protected-tools-policy.ts +23 -0
  355. package/src/shared/quota-diagnostic.ts +9 -0
  356. package/src/shared/rpc-server.ts +6 -54
  357. package/src/shared/sqlite-context-pragmas.test.ts +105 -0
  358. package/src/shared/sqlite-context-pragmas.ts +24 -0
  359. package/src/shared/sqlite-helpers.ts +17 -0
  360. package/src/shared/sqlite.ts +75 -0
  361. package/src/shared/status-detail-text.test.ts +18 -1
  362. package/src/shared/status-summary.ts +11 -0
  363. package/src/shared/status-view-check.ts +5 -0
  364. package/src/shared/status-view.test.ts +11 -2
  365. package/src/shared/status-view.ts +12 -1
  366. package/src/shared/storage-permissions.test.ts +204 -0
  367. package/src/shared/storage-permissions.ts +192 -0
  368. package/src/shared/temporal-upgrade-fixture.ts +50 -0
  369. package/src/shared/user-facing-codes.ts +6 -0
  370. package/src/shared/write-transaction-timing.test.ts +39 -0
  371. package/src/shared/write-transaction-timing.ts +25 -1
  372. package/src/tui/dialogs/status-dialog-render.test.ts +1 -1
  373. package/src/tui/index.tsx +3 -1
  374. package/src/tui/startup-order.test.ts +16 -0
  375. package/src/tui-compiled/index.tsx +3 -1
  376. package/src/v2/tui/index.ts +9 -2
  377. package/dist/index-anq4nn6f.js +0 -131
  378. package/dist/index-e44zzy84.js +0 -10
  379. package/dist/index-x23gah8c.js +0 -16
  380. package/dist/v2/recomp-orchestrator-1aq7h44c.js +0 -36
  381. package/dist/v2/server-e44zzy84.js +0 -10
  382. package/dist/v2/server-fgmxwrgy.js +0 -16
  383. package/dist/v2/server-r7cmye3k.js +0 -131
  384. package/dist/wrapup-orchestrator-h28bqsy6.js +0 -26
  385. package/dist/v2/{server-ckpc8pxy.js → server-1qbnzc80.js} +8 -8
@@ -0,0 +1,259 @@
1
+ import {
2
+ sendStatusNotification2
3
+ } from "./index-7qw742ev.js";
4
+ import {
5
+ importPluginModule,
6
+ log
7
+ } from "./index-hybnrwq0.js";
8
+ import {
9
+ formatConflictShort
10
+ } from "./index-8da2zjhz.js";
11
+
12
+ // src/plugin/conflict-warning-hook.ts
13
+ import { existsSync, readFileSync } from "node:fs";
14
+ import { homedir, platform } from "node:os";
15
+ import { join } from "node:path";
16
+ var CONFLICT_WARNING_MARKER = "⚠️ Magic Context is disabled due to conflicting configuration:";
17
+ var SCHEMA_FENCE_MARKER = "⚠️ Magic Context is disabled — database is newer than this version";
18
+ var ENABLED_MARKER = "✨ Magic Context is now enabled";
19
+ var ANNOUNCEMENT_MARKER = "✨ Magic Context — what's new in";
20
+ function getDesktopStatePath() {
21
+ const os = platform();
22
+ const home = homedir();
23
+ if (os === "darwin") {
24
+ return join(home, "Library", "Application Support", "ai.opencode.desktop", "opencode.global.dat");
25
+ }
26
+ if (os === "linux") {
27
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join(home, ".config");
28
+ return join(xdgConfig, "ai.opencode.desktop", "opencode.global.dat");
29
+ }
30
+ if (os === "win32") {
31
+ const appData = process.env.APPDATA || join(home, "AppData", "Roaming");
32
+ return join(appData, "ai.opencode.desktop", "opencode.global.dat");
33
+ }
34
+ return null;
35
+ }
36
+ function readDesktopState(directory) {
37
+ const statePath = getDesktopStatePath();
38
+ if (!statePath || !existsSync(statePath)) {
39
+ log(`[magic-context] conflict-warning: Desktop state file not found at ${statePath}`);
40
+ return { sessionId: null, sidecarUrl: null };
41
+ }
42
+ try {
43
+ const raw = readFileSync(statePath, "utf-8");
44
+ const state = JSON.parse(raw);
45
+ let sidecarUrl = null;
46
+ const serverStr = state.server;
47
+ if (typeof serverStr === "string") {
48
+ try {
49
+ const serverState = JSON.parse(serverStr);
50
+ if (typeof serverState.currentSidecarUrl === "string") {
51
+ sidecarUrl = serverState.currentSidecarUrl;
52
+ }
53
+ } catch {}
54
+ }
55
+ let sessionId = null;
56
+ const layoutPage = state["layout.page"];
57
+ if (typeof layoutPage === "string") {
58
+ const parsed = JSON.parse(layoutPage);
59
+ const lastProjectSession = parsed.lastProjectSession;
60
+ if (lastProjectSession) {
61
+ const entry = lastProjectSession[directory];
62
+ sessionId = entry?.id ?? null;
63
+ }
64
+ }
65
+ return { sessionId, sidecarUrl };
66
+ } catch (error) {
67
+ log(`[magic-context] conflict-warning: failed to read Desktop state: ${error instanceof Error ? error.message : String(error)}`);
68
+ return { sessionId: null, sidecarUrl: null };
69
+ }
70
+ }
71
+ var cachedDesktopStateByDir = new Map;
72
+ var __conflictWarningTest2 = {
73
+ setDesktopState(directory, state) {
74
+ cachedDesktopStateByDir.set(directory, state);
75
+ },
76
+ reset() {
77
+ cachedDesktopStateByDir.clear();
78
+ }
79
+ };
80
+ function getDesktopState(directory) {
81
+ let cached = cachedDesktopStateByDir.get(directory);
82
+ if (!cached) {
83
+ cached = readDesktopState(directory);
84
+ cachedDesktopStateByDir.set(directory, cached);
85
+ }
86
+ return cached;
87
+ }
88
+ async function deleteMessage(serverUrl, sessionId, messageId) {
89
+ const auth = getServerAuth();
90
+ const url = `${serverUrl}/session/${encodeURIComponent(sessionId)}/message/${encodeURIComponent(messageId)}`;
91
+ try {
92
+ const response = await fetch(url, {
93
+ method: "DELETE",
94
+ headers: auth ? { Authorization: auth } : {},
95
+ signal: AbortSignal.timeout(1e4)
96
+ });
97
+ if (!response.ok) {
98
+ log(`[magic-context] conflict-warning: DELETE failed status=${response.status} url=${url}`);
99
+ return false;
100
+ }
101
+ return true;
102
+ } catch (error) {
103
+ log(`[magic-context] conflict-warning: DELETE error (url=${serverUrl}): ${error instanceof Error ? error.message : String(error)}`);
104
+ return false;
105
+ }
106
+ }
107
+ function getServerAuth() {
108
+ const password = process.env.OPENCODE_SERVER_PASSWORD;
109
+ if (!password)
110
+ return;
111
+ const username = process.env.OPENCODE_SERVER_USERNAME ?? "opencode";
112
+ return `Basic ${Buffer.from(`${username}:${password}`, "utf8").toString("base64")}`;
113
+ }
114
+ async function getSessionMessages(client, sessionId) {
115
+ try {
116
+ const c = client;
117
+ if (typeof c.session?.messages === "function") {
118
+ const result = await c.session.messages({
119
+ path: { id: sessionId },
120
+ query: { limit: 50 }
121
+ });
122
+ return result?.data ?? [];
123
+ }
124
+ } catch (error) {
125
+ log(`[magic-context] conflict-warning: failed to read messages: ${error instanceof Error ? error.message : String(error)}`);
126
+ }
127
+ return [];
128
+ }
129
+ async function sendConflictWarning2(client, directory, conflictResult) {
130
+ const { sessionId } = getDesktopState(directory);
131
+ if (!sessionId) {
132
+ log("[magic-context] conflict-warning: could not find active session for Desktop warning");
133
+ return;
134
+ }
135
+ const warningText = formatConflictShort(conflictResult);
136
+ log(`[magic-context] sending conflict warning to session ${sessionId}: ${conflictResult.reasons.join(", ")}`);
137
+ try {
138
+ await sendStatusNotification2(client, sessionId, warningText, {});
139
+ } catch (error) {
140
+ log(`[magic-context] conflict-warning: failed to send: ${error instanceof Error ? error.message : String(error)}`);
141
+ }
142
+ }
143
+ async function cleanupConflictWarnings2(client, directory, serverUrl) {
144
+ const { sessionId } = getDesktopState(directory);
145
+ if (!sessionId) {
146
+ log("[magic-context] cleanup: no active Desktop session found");
147
+ return;
148
+ }
149
+ const messages = await getSessionMessages(client, sessionId);
150
+ if (messages.length === 0)
151
+ return;
152
+ const warningMessageIds = [];
153
+ for (let i = messages.length - 1;i >= 0; i--) {
154
+ const msg = messages[i];
155
+ const msgId = msg.info?.id;
156
+ const msgRole = msg.info?.role;
157
+ if (!msgId || msgRole !== "user")
158
+ break;
159
+ const parts = msg.parts ?? [];
160
+ const isWarning = parts.length > 0 && parts.every((p) => p.ignored === true && p.type === "text" && typeof p.text === "string" && p.text.startsWith(CONFLICT_WARNING_MARKER));
161
+ if (isWarning) {
162
+ warningMessageIds.push(msgId);
163
+ } else {
164
+ break;
165
+ }
166
+ }
167
+ if (warningMessageIds.length === 0) {
168
+ await cleanupEnabledMessages(messages, serverUrl, sessionId);
169
+ return;
170
+ }
171
+ if (!serverUrl) {
172
+ log("[magic-context] cleanup: no serverUrl provided, cannot delete messages");
173
+ return;
174
+ }
175
+ log(`[magic-context] cleaning up ${warningMessageIds.length} conflict warning message(s) from session ${sessionId}`);
176
+ for (const messageId of warningMessageIds) {
177
+ const ok = await deleteMessage(serverUrl, sessionId, messageId);
178
+ if (ok) {
179
+ log(`[magic-context] deleted conflict warning message ${messageId}`);
180
+ }
181
+ }
182
+ const enabledText = `${ENABLED_MARKER}. Enjoy! ✨`;
183
+ try {
184
+ await sendStatusNotification2(client, sessionId, enabledText, {});
185
+ } catch {}
186
+ }
187
+ async function cleanupEnabledMessages(messages, serverUrl, sessionId) {
188
+ if (!serverUrl)
189
+ return;
190
+ for (let i = messages.length - 1;i >= 0; i--) {
191
+ const msg = messages[i];
192
+ const msgId = msg.info?.id;
193
+ const msgRole = msg.info?.role;
194
+ if (!msgId || msgRole !== "user")
195
+ break;
196
+ const parts = msg.parts ?? [];
197
+ const isEnabled = parts.length > 0 && parts.every((p) => p.ignored === true && p.type === "text" && typeof p.text === "string" && p.text.startsWith(ENABLED_MARKER));
198
+ if (isEnabled) {
199
+ await deleteMessage(serverUrl, sessionId, msgId);
200
+ } else {
201
+ break;
202
+ }
203
+ }
204
+ }
205
+ async function sendSchemaFenceWarning2(client, directory, detail) {
206
+ const { sessionId } = getDesktopState(directory);
207
+ if (!sessionId)
208
+ return;
209
+ const text = [
210
+ `${SCHEMA_FENCE_MARKER}`,
211
+ "",
212
+ `The shared Magic Context database was upgraded to schema v${detail.persistedVersion} by a`,
213
+ `newer build (OpenCode and Pi share one database). This build only supports`,
214
+ `up to v${detail.supportedVersion}, so it has fail-closed to avoid corrupting the cache.`,
215
+ "",
216
+ "This usually means a pinned or stale plugin is sharing the database with a",
217
+ "newer instance. Update or unpin Magic Context on this harness (or update",
218
+ "OpenCode/Pi) to the latest version, then restart. The fastest fix is:",
219
+ "",
220
+ " npx @cortexkit/magic-context@latest doctor --force",
221
+ "",
222
+ "Your data is safe; nothing is disabled permanently."
223
+ ].join(`
224
+ `);
225
+ try {
226
+ await sendStatusNotification2(client, sessionId, text, {});
227
+ } catch {
228
+ return;
229
+ }
230
+ }
231
+ async function sendStartupAnnouncement2(client, directory, version, features, footer, markSeen) {
232
+ if (!version || features.length === 0)
233
+ return;
234
+ const { sessionId } = getDesktopState(directory);
235
+ if (!sessionId) {
236
+ return;
237
+ }
238
+ const { isTuiConnected } = await importPluginModule(() => import("./rpc-notifications-3hed126v.js"));
239
+ if (isTuiConnected(sessionId) || isTuiConnected())
240
+ return;
241
+ const bullets = features.map((line) => ` • ${line}`).join(`
242
+ `);
243
+ const sections = [`${ANNOUNCEMENT_MARKER} v${version}:`, "", bullets];
244
+ if (footer && footer.trim().length > 0) {
245
+ sections.push("", footer);
246
+ }
247
+ const text = sections.join(`
248
+ `);
249
+ log(`[magic-context] sending startup announcement for v${version} to session ${sessionId}`);
250
+ try {
251
+ await sendStatusNotification2(client, sessionId, text, {
252
+ onDelivered: () => markSeen(version)
253
+ });
254
+ } catch (error) {
255
+ log(`[magic-context] announcement: failed to send: ${error instanceof Error ? error.message : String(error)}`);
256
+ }
257
+ }
258
+
259
+ export { __conflictWarningTest2, sendConflictWarning2, cleanupConflictWarnings2, sendSchemaFenceWarning2, sendStartupAnnouncement2 };
@@ -0,0 +1,30 @@
1
+ import {
2
+ log
3
+ } from "./index-hybnrwq0.js";
4
+
5
+ // src/shared/write-transaction-timing.ts
6
+ var SLOW_WRITE_TRANSACTION_THRESHOLD_MS = 1000;
7
+ function logSlowWriteTransaction(site, startedAt, thresholdMs = SLOW_WRITE_TRANSACTION_THRESHOLD_MS, completedAtMs = performance.now(), steps) {
8
+ try {
9
+ const durationMs = completedAtMs - startedAt;
10
+ if (durationMs < thresholdMs)
11
+ return;
12
+ const detail = steps ? Object.entries(steps).map(([name, ms]) => `${name}=${ms.toFixed(1)}ms`).join(" ") : "";
13
+ log(`[magic-context] slow write transaction: site=${site} held=${durationMs.toFixed(1)}ms${detail ? ` ${detail}` : ""}`);
14
+ } catch {}
15
+ }
16
+
17
+ class WriteTransactionSteps {
18
+ durations = {};
19
+ last = performance.now();
20
+ mark(name) {
21
+ const now = performance.now();
22
+ this.durations[name] = now - this.last;
23
+ this.last = now;
24
+ }
25
+ reset() {
26
+ this.last = performance.now();
27
+ }
28
+ }
29
+
30
+ export { logSlowWriteTransaction, WriteTransactionSteps };
@@ -1,6 +1,8 @@
1
1
  import {
2
- toolTemplateError
3
- } from "./index-remp7e2g.js";
2
+ toolTemplateError,
3
+ DEFAULT_PROTECTED_TOOLS,
4
+ mergeProtectedTools
5
+ } from "./index-q4yp4b52.js";
4
6
  import {
5
7
  getHarness,
6
8
  getMagicContextStorageDir
@@ -11,10 +13,14 @@ import {
11
13
  } from "./index-hybnrwq0.js";
12
14
  import {
13
15
  estimateTokens
14
- } from "./index-gd5qx1j9.js";
16
+ } from "./index-5eqk6z3s.js";
15
17
  import {
16
- shouldEnforcePrivateStoragePermissions
17
- } from "./index-e44zzy84.js";
18
+ shouldEnforcePrivateStoragePermissions,
19
+ ensureStorageDirectorySync,
20
+ writeStorageFileAsync,
21
+ writeStorageFileHandleAsync,
22
+ createStorageFileHandleAsync
23
+ } from "./index-1bc61ans.js";
18
24
  import {
19
25
  modelRefLookupOrder
20
26
  } from "./index-avwt563y.js";
@@ -92,8 +98,8 @@ function buildPrimaryLanguageDirective(language) {
92
98
  }
93
99
 
94
100
  // src/features/magic-context/memory/embedding-local.ts
95
- import { chmodSync, mkdirSync, readdirSync, statSync } from "node:fs";
96
- import { open, stat, unlink, writeFile } from "node:fs/promises";
101
+ import { readdirSync, statSync } from "node:fs";
102
+ import { stat, unlink } from "node:fs/promises";
97
103
  import { dirname, join } from "node:path";
98
104
  import { pathToFileURL } from "node:url";
99
105
  import { workerData } from "node:worker_threads";
@@ -5615,7 +5621,7 @@ var MagicContextConfigSchema = object({
5615
5621
  smart_notes: object({
5616
5622
  retina_handoff: boolean2().default(false).describe("When true, dreamer skips smart notes whose surface conditions compiled to retina provider configs at authoring time. Default false keeps both paths active until the retina consumer is deployed.")
5617
5623
  }).default({ retina_handoff: false }).describe("Smart-note ownership transition controls."),
5618
- cache_ttl: union([string(), object({ default: string() }).catchall(string())]).default("5m").describe(`How long Magic Context assumes the provider's cached prefix stays valid. This is MC's own deferral gate — it does not change the provider's actual cache lifetime. String (e.g. "5m", "1h", "30s") or per-model object ({ default: "5m", "provider/model": "1h", "provider/*": "never" }); keys resolve most-specific first (exact provider/model, bare model ID, shorter dash-prefixes, then the provider/* wildcard). Explicit per-model entries win; otherwise GPT-5.6 and later (including gpt-6*, through any provider prefix) use a built-in 30m lifetime before the object default or 5m fallback. An unset or global "5m" opts into built-in defaults; any other global string is an explicit policy and wins. Policy is frozen per session, including across restarts; a model switch resolves against that frozen policy. /ctx-status shows the effective value and source. OpenAI documents at least 30 minutes since the latest write or reuse: https://developers.openai.com/api/docs/guides/prompt-caching (Cache lifetime and Summary of model differences). Set to "never" to mean MC never assumes expiry (for lanes kept warm externally by a cache-keep tool) — disables the idle-TTL heuristic so MC never initiates a rebuild based on elapsed time. Provider-side extended TTL is a separate request-level concern (cache_control: { ttl } in the request body).`),
5624
+ cache_ttl: union([string(), object({ default: string() }).catchall(string())]).default("5m").describe(`How long Magic Context assumes the provider's cached prefix stays valid. This is MC's own deferral gate — it does not change the provider's actual cache lifetime. String (e.g. "5m", "1h", "30s") or per-model object ({ default: "5m", "provider/model": "1h", "provider/*": "never" }); keys resolve most-specific first (exact provider/model, bare model ID, shorter dash-prefixes, then the provider/* wildcard, then default). User and project settings, including an explicit "5m" or object default, apply on the next pass. Only built-in defaults are frozen per session, including across restarts: when unset, GPT-5.6 and later (including gpt-6*, through any provider prefix) use 30m, other models use 5m. /ctx-status shows the effective TTL and whether it comes from your config or a frozen built-in default. Editing the TTL does not itself rewrite prompt bytes; a lowered TTL rebuilds only after normal idle expiry. OpenAI documents at least 30 minutes since the latest write or reuse: https://developers.openai.com/api/docs/guides/prompt-caching (Cache lifetime and Summary of model differences). Set to "never" to mean MC never assumes expiry (for lanes kept warm externally by a cache-keep tool) — disables the idle-TTL heuristic so MC never initiates a rebuild based on elapsed time. Provider-side extended TTL is a separate request-level concern (cache_control: { ttl } in the request body).`),
5619
5625
  prompt_surface: PromptSurfaceConfigSchema.default({ default: "full" }).describe("Prompt-surface presets: default is full; models use bare model IDs, provider/model, or provider/* routing keys. Guidance and tool-description overrides are user-level only. OpenCode 1.x, Pi, and OMP register tool descriptions once per process (they follow the default preset). OpenCode 2 rewrites the five ctx_* descriptions per request from the draft model."),
5620
5626
  output_reserve: union([
5621
5627
  number2().min(0),
@@ -5653,8 +5659,8 @@ var MagicContextConfigSchema = object({
5653
5659
  mmap_size_mb: number2().min(0).max(8192).default(0).describe("Memory-mapped I/O size in MiB (PRAGMA mmap_size). 0 disables mmap (SQLite default). Raising it can cut read overhead on large DBs at the cost of address space. (min 0, max 8192, default 0)")
5654
5660
  }).default({ cache_size_mb: 64, mmap_size_mb: 0 }).describe("SQLite connection tuning for Magic Context's own context.db. These are per-connection PRAGMAs applied at open; they do not change the schema or what is stored."),
5655
5661
  storage: object({
5656
- enforce_private_permissions: boolean2().default(true).describe("When true (default), Magic Context creates and re-tightens its storage directories to owner-only 0700 and storage files to owner-only 0600. Set false only for a deliberate trusted-group deployment whose operator manages directory, database, WAL/SHM, cache, and RPC file permissions externally; Magic Context then never chmods or supplies restrictive creation modes. USER-LEVEL ONLY — ignored in project config for security. On Windows, POSIX chmod modes are already meaningless, so this setting is a no-op.")
5657
- }).default({ enforce_private_permissions: true }).describe("Storage permission policy. The default keeps session content and memories owner-private. Disabling enforcement is for trusted shared-group storage managed externally; every group member able to read the storage can read all stored session content and memories."),
5662
+ enforce_private_permissions: boolean2().default(true).describe("When true (default), Magic Context creates and re-tightens its TypeScript-mode storage directories to owner-only 0700 and storage files to owner-only 0600. Set false only for a deliberate trusted-group deployment whose operator manages those files externally; in TypeScript mode Magic Context then skips its own creation modes and recursive tightening. In Rust transform mode, ck-mc's store library always keeps the shared data directory owner-only 0700, regardless of this setting. USER-LEVEL ONLY — ignored in project config for security. On Windows, POSIX chmod modes are already meaningless, so this setting is a no-op.")
5663
+ }).default({ enforce_private_permissions: true }).describe("Storage permission policy. The default keeps session content and memories owner-private. Disabling enforcement is for trusted shared-group storage managed externally; TypeScript mode follows that policy, but Rust transform mode always keeps its shared data directory owner-only because ck-mc's store library enforces it."),
5658
5664
  embedding: EmbeddingConfigSchema.default({
5659
5665
  provider: "local",
5660
5666
  model: DEFAULT_LOCAL_EMBEDDING_MODEL,
@@ -5678,7 +5684,8 @@ var MagicContextConfigSchema = object({
5678
5684
  overlay: boolean2().default(true).describe("Pi only: show the persistent todo overlay above the editor while tasks are active.")
5679
5685
  }).default({ enabled: false, overlay: true }).describe("Pi-only todowrite tool and overlay controls. Pi registers tools and widgets at extension boot, so changing this after /cd requires /reload or restart."),
5680
5686
  pi: PiConfigSchema.describe("Pi-only child-process extension controls. This setting is user-level only; project configuration cannot choose which extensions a user's subagent children load."),
5681
- smart_drops: boolean2().default(false).describe("Content-aware reclaim of provably-superseded tool output, layered on the existing execute-pass auto-drop. When on: superseded todowrite (keep newest 1), spent ctx_reduce (keep newest 3), and zero-value meta (bash_status, bash_kill, ctx_note read/dismiss) outputs are dropped; older edits to a file are compressed to a filePath-preserving marker while the newest edit per file stays full. Only acts on passes already busting the cache, so it never originates a cache bust. Honors the protected-tag reserve. Experimental: opt-in, default off until cache stability is proven; when off the wire is byte-identical to the positional-only reclaim. Requires a restart."),
5687
+ smart_drops: unknown().optional().describe("Deprecated: ignored. Content-aware supersession reclaim is always on, only on passes already rebuilding the cache. Remove this key; it no longer does anything.").meta({ deprecated: true }),
5688
+ protected_tools: record(string(), number2().int().nonnegative()).default({ ...DEFAULT_PROTECTED_TOOLS }).transform((map) => mergeProtectedTools(map)).describe("Keep each tool's newest N still-active results in every automatic drop lane (issue 621). User and project maps merge over defaults {todowrite: 1, ctx_reduce: 3}; 0 turns protection off. Names are case-insensitive and ignore leading mcp_. Holds even at 95% pressure, with no byte cap: large protected outputs can reach refusal sooner. Queued drops, from the agent or historian publication, are held until newer calls displace the result and a later cache-rebuilding pass applies them. The historian's summary is unaffected; the raw result leaves at the next fold. Frozen strips are unaffected. Changes and rotation never originate a bust; dropped results are never restored."),
5682
5689
  caveman_text_compression: object({
5683
5690
  enabled: boolean2().default(false).describe("Apply deterministic caveman-style text compression to old conversation text. Active for primary sessions when enabled; never for subagents. Compresses user/assistant text in oldest-first tiers: ultra (oldest 20%), full, lite, untouched (newest 40%)."),
5684
5691
  min_chars: number2().min(100).max(1e4).default(500).describe("Text parts shorter than this (characters) stay untouched. Min 100, max 10000. Default: 500.")
@@ -5713,6 +5720,7 @@ var MagicContextConfigSchema = object({
5713
5720
  };
5714
5721
  });
5715
5722
  var LIVE_RELOAD_CONFIG_PATHS = [
5723
+ "cache_ttl",
5716
5724
  "mural.model",
5717
5725
  "toast_duration_ms",
5718
5726
  "historian.opencode.model",
@@ -8460,9 +8468,9 @@ async function acquireModelLoadLock(lockPath) {
8460
8468
  const waitStart = Date.now();
8461
8469
  while (true) {
8462
8470
  try {
8463
- const handle = await open(lockPath, "wx");
8471
+ const handle = await createStorageFileHandleAsync(lockPath, "wx");
8464
8472
  try {
8465
- await handle.writeFile(`pid=${process.pid} started=${Date.now()}
8473
+ await writeStorageFileHandleAsync(handle, `pid=${process.pid} started=${Date.now()}
8466
8474
  `);
8467
8475
  } catch {}
8468
8476
  await handle.close();
@@ -8498,7 +8506,7 @@ async function acquireModelLoadLock(lockPath) {
8498
8506
  function startLockHeartbeat(lockPath) {
8499
8507
  const HEARTBEAT_MS = Math.floor(STALE_LOCK_MS / 3);
8500
8508
  const timer = setInterval(() => {
8501
- writeFile(lockPath, `pid=${process.pid} alive=${Date.now()}
8509
+ writeStorageFileAsync(lockPath, `pid=${process.pid} alive=${Date.now()}
8502
8510
  `).catch(() => {});
8503
8511
  }, HEARTBEAT_MS);
8504
8512
  timer.unref?.();
@@ -8861,16 +8869,7 @@ class LocalEmbeddingProvider {
8861
8869
  }
8862
8870
  const modelCacheDir = modelCacheDirForRuntime();
8863
8871
  try {
8864
- if (shouldEnforcePrivateStoragePermissions()) {
8865
- mkdirSync(modelCacheDir, { recursive: true, mode: 448 });
8866
- if (process.platform !== "win32") {
8867
- try {
8868
- chmodSync(modelCacheDir, 448);
8869
- } catch {}
8870
- }
8871
- } else {
8872
- mkdirSync(modelCacheDir, { recursive: true });
8873
- }
8872
+ ensureStorageDirectorySync(modelCacheDir);
8874
8873
  env.cacheDir = modelCacheDir;
8875
8874
  } catch {
8876
8875
  log("[magic-context] could not create model cache dir, using library default");
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAyGvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAohCpC,QAAA,MAAM,MAAM,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAIjD,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA8GvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AA+kCpC,QAAA,MAAM,MAAM,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAIjD,CAAC;AAEF,eAAe,MAAM,CAAC"}