@wolfx/opencode-magic-context 0.21.8-patch.1

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 (544) hide show
  1. package/dist/agents/dreamer.d.ts +2 -0
  2. package/dist/agents/dreamer.d.ts.map +1 -0
  3. package/dist/agents/historian.d.ts +3 -0
  4. package/dist/agents/historian.d.ts.map +1 -0
  5. package/dist/agents/magic-context-prompt.d.ts +3 -0
  6. package/dist/agents/magic-context-prompt.d.ts.map +1 -0
  7. package/dist/agents/permissions.d.ts +142 -0
  8. package/dist/agents/permissions.d.ts.map +1 -0
  9. package/dist/agents/sidekick.d.ts +2 -0
  10. package/dist/agents/sidekick.d.ts.map +1 -0
  11. package/dist/config/agent-disable.d.ts +26 -0
  12. package/dist/config/agent-disable.d.ts.map +1 -0
  13. package/dist/config/index.d.ts +33 -0
  14. package/dist/config/index.d.ts.map +1 -0
  15. package/dist/config/schema/agent-overrides.d.ts +55 -0
  16. package/dist/config/schema/agent-overrides.d.ts.map +1 -0
  17. package/dist/config/schema/magic-context.d.ts +841 -0
  18. package/dist/config/schema/magic-context.d.ts.map +1 -0
  19. package/dist/config/schema.d.ts +3 -0
  20. package/dist/config/schema.d.ts.map +1 -0
  21. package/dist/config/variable.d.ts +48 -0
  22. package/dist/config/variable.d.ts.map +1 -0
  23. package/dist/features/builtin-commands/commands.d.ts +3 -0
  24. package/dist/features/builtin-commands/commands.d.ts.map +1 -0
  25. package/dist/features/builtin-commands/types.d.ts +5 -0
  26. package/dist/features/builtin-commands/types.d.ts.map +1 -0
  27. package/dist/features/magic-context/compaction-marker.d.ts +91 -0
  28. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -0
  29. package/dist/features/magic-context/compaction.d.ts +7 -0
  30. package/dist/features/magic-context/compaction.d.ts.map +1 -0
  31. package/dist/features/magic-context/compartment-lease.d.ts +14 -0
  32. package/dist/features/magic-context/compartment-lease.d.ts.map +1 -0
  33. package/dist/features/magic-context/compartment-storage.d.ts +130 -0
  34. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -0
  35. package/dist/features/magic-context/compression-depth-storage.d.ts +14 -0
  36. package/dist/features/magic-context/compression-depth-storage.d.ts.map +1 -0
  37. package/dist/features/magic-context/defaults.d.ts +2 -0
  38. package/dist/features/magic-context/defaults.d.ts.map +1 -0
  39. package/dist/features/magic-context/dreamer/index.d.ts +8 -0
  40. package/dist/features/magic-context/dreamer/index.d.ts.map +1 -0
  41. package/dist/features/magic-context/dreamer/lease.d.ts +8 -0
  42. package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -0
  43. package/dist/features/magic-context/dreamer/queue.d.ts +44 -0
  44. package/dist/features/magic-context/dreamer/queue.d.ts.map +1 -0
  45. package/dist/features/magic-context/dreamer/runner.d.ts +81 -0
  46. package/dist/features/magic-context/dreamer/runner.d.ts.map +1 -0
  47. package/dist/features/magic-context/dreamer/scheduler.d.ts +33 -0
  48. package/dist/features/magic-context/dreamer/scheduler.d.ts.map +1 -0
  49. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +41 -0
  50. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -0
  51. package/dist/features/magic-context/dreamer/storage-dream-state.d.ts +5 -0
  52. package/dist/features/magic-context/dreamer/storage-dream-state.d.ts.map +1 -0
  53. package/dist/features/magic-context/dreamer/task-prompts.d.ts +26 -0
  54. package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -0
  55. package/dist/features/magic-context/git-commits/git-log-reader.d.ts +57 -0
  56. package/dist/features/magic-context/git-commits/git-log-reader.d.ts.map +1 -0
  57. package/dist/features/magic-context/git-commits/index.d.ts +7 -0
  58. package/dist/features/magic-context/git-commits/index.d.ts.map +1 -0
  59. package/dist/features/magic-context/git-commits/indexer.d.ts +43 -0
  60. package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -0
  61. package/dist/features/magic-context/git-commits/search-git-commits.d.ts +32 -0
  62. package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -0
  63. package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts +19 -0
  64. package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts.map +1 -0
  65. package/dist/features/magic-context/git-commits/storage-git-commits.d.ts +47 -0
  66. package/dist/features/magic-context/git-commits/storage-git-commits.d.ts.map +1 -0
  67. package/dist/features/magic-context/index.d.ts +12 -0
  68. package/dist/features/magic-context/index.d.ts.map +1 -0
  69. package/dist/features/magic-context/key-files/aft-availability.d.ts +11 -0
  70. package/dist/features/magic-context/key-files/aft-availability.d.ts.map +1 -0
  71. package/dist/features/magic-context/key-files/identify-key-files.d.ts +84 -0
  72. package/dist/features/magic-context/key-files/identify-key-files.d.ts.map +1 -0
  73. package/dist/features/magic-context/key-files/project-key-files.d.ts +42 -0
  74. package/dist/features/magic-context/key-files/project-key-files.d.ts.map +1 -0
  75. package/dist/features/magic-context/key-files/read-history.d.ts +26 -0
  76. package/dist/features/magic-context/key-files/read-history.d.ts.map +1 -0
  77. package/dist/features/magic-context/key-files/read-stats.d.ts +20 -0
  78. package/dist/features/magic-context/key-files/read-stats.d.ts.map +1 -0
  79. package/dist/features/magic-context/key-files/storage-key-files.d.ts +25 -0
  80. package/dist/features/magic-context/key-files/storage-key-files.d.ts.map +1 -0
  81. package/dist/features/magic-context/memory/constants.d.ts +5 -0
  82. package/dist/features/magic-context/memory/constants.d.ts.map +1 -0
  83. package/dist/features/magic-context/memory/cosine-similarity.d.ts +2 -0
  84. package/dist/features/magic-context/memory/cosine-similarity.d.ts.map +1 -0
  85. package/dist/features/magic-context/memory/embedding-backfill.d.ts +9 -0
  86. package/dist/features/magic-context/memory/embedding-backfill.d.ts.map +1 -0
  87. package/dist/features/magic-context/memory/embedding-cache.d.ts +8 -0
  88. package/dist/features/magic-context/memory/embedding-cache.d.ts.map +1 -0
  89. package/dist/features/magic-context/memory/embedding-identity.d.ts +11 -0
  90. package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -0
  91. package/dist/features/magic-context/memory/embedding-local.d.ts +20 -0
  92. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -0
  93. package/dist/features/magic-context/memory/embedding-openai.d.ts +44 -0
  94. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -0
  95. package/dist/features/magic-context/memory/embedding-probe.d.ts +69 -0
  96. package/dist/features/magic-context/memory/embedding-probe.d.ts.map +1 -0
  97. package/dist/features/magic-context/memory/embedding-provider.d.ts +15 -0
  98. package/dist/features/magic-context/memory/embedding-provider.d.ts.map +1 -0
  99. package/dist/features/magic-context/memory/embedding.d.ts +39 -0
  100. package/dist/features/magic-context/memory/embedding.d.ts.map +1 -0
  101. package/dist/features/magic-context/memory/index.d.ts +12 -0
  102. package/dist/features/magic-context/memory/index.d.ts.map +1 -0
  103. package/dist/features/magic-context/memory/normalize-hash.d.ts +3 -0
  104. package/dist/features/magic-context/memory/normalize-hash.d.ts.map +1 -0
  105. package/dist/features/magic-context/memory/project-identity.d.ts +23 -0
  106. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -0
  107. package/dist/features/magic-context/memory/promotion.d.ts +13 -0
  108. package/dist/features/magic-context/memory/promotion.d.ts.map +1 -0
  109. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +8 -0
  110. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -0
  111. package/dist/features/magic-context/memory/storage-memory-fts.d.ts +12 -0
  112. package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -0
  113. package/dist/features/magic-context/memory/storage-memory.d.ts +31 -0
  114. package/dist/features/magic-context/memory/storage-memory.d.ts.map +1 -0
  115. package/dist/features/magic-context/memory/types.d.ts +37 -0
  116. package/dist/features/magic-context/memory/types.d.ts.map +1 -0
  117. package/dist/features/magic-context/message-index-async.d.ts +12 -0
  118. package/dist/features/magic-context/message-index-async.d.ts.map +1 -0
  119. package/dist/features/magic-context/message-index.d.ts +10 -0
  120. package/dist/features/magic-context/message-index.d.ts.map +1 -0
  121. package/dist/features/magic-context/migrations.d.ts +33 -0
  122. package/dist/features/magic-context/migrations.d.ts.map +1 -0
  123. package/dist/features/magic-context/mock-database.d.ts +3 -0
  124. package/dist/features/magic-context/mock-database.d.ts.map +1 -0
  125. package/dist/features/magic-context/overflow-detection.d.ts +51 -0
  126. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -0
  127. package/dist/features/magic-context/plugin-messages.d.ts +75 -0
  128. package/dist/features/magic-context/plugin-messages.d.ts.map +1 -0
  129. package/dist/features/magic-context/project-embedding-registry.d.ts +44 -0
  130. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -0
  131. package/dist/features/magic-context/range-parser.d.ts +13 -0
  132. package/dist/features/magic-context/range-parser.d.ts.map +1 -0
  133. package/dist/features/magic-context/resolve-subagent-fallback.d.ts +40 -0
  134. package/dist/features/magic-context/resolve-subagent-fallback.d.ts.map +1 -0
  135. package/dist/features/magic-context/scheduler.d.ts +18 -0
  136. package/dist/features/magic-context/scheduler.d.ts.map +1 -0
  137. package/dist/features/magic-context/search.d.ts +69 -0
  138. package/dist/features/magic-context/search.d.ts.map +1 -0
  139. package/dist/features/magic-context/sidekick/agent.d.ts +13 -0
  140. package/dist/features/magic-context/sidekick/agent.d.ts.map +1 -0
  141. package/dist/features/magic-context/sidekick/core.d.ts +38 -0
  142. package/dist/features/magic-context/sidekick/core.d.ts.map +1 -0
  143. package/dist/features/magic-context/sidekick/index.d.ts +3 -0
  144. package/dist/features/magic-context/sidekick/index.d.ts.map +1 -0
  145. package/dist/features/magic-context/storage-db.d.ts +48 -0
  146. package/dist/features/magic-context/storage-db.d.ts.map +1 -0
  147. package/dist/features/magic-context/storage-meta-persisted.d.ts +246 -0
  148. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -0
  149. package/dist/features/magic-context/storage-meta-session.d.ts +6 -0
  150. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -0
  151. package/dist/features/magic-context/storage-meta-shared.d.ts +31 -0
  152. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -0
  153. package/dist/features/magic-context/storage-meta.d.ts +3 -0
  154. package/dist/features/magic-context/storage-meta.d.ts.map +1 -0
  155. package/dist/features/magic-context/storage-notes.d.ts +62 -0
  156. package/dist/features/magic-context/storage-notes.d.ts.map +1 -0
  157. package/dist/features/magic-context/storage-ops.d.ts +7 -0
  158. package/dist/features/magic-context/storage-ops.d.ts.map +1 -0
  159. package/dist/features/magic-context/storage-source.d.ts +5 -0
  160. package/dist/features/magic-context/storage-source.d.ts.map +1 -0
  161. package/dist/features/magic-context/storage-subagent-invocations.d.ts +52 -0
  162. package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -0
  163. package/dist/features/magic-context/storage-tags.d.ts +206 -0
  164. package/dist/features/magic-context/storage-tags.d.ts.map +1 -0
  165. package/dist/features/magic-context/storage.d.ts +11 -0
  166. package/dist/features/magic-context/storage.d.ts.map +1 -0
  167. package/dist/features/magic-context/subagent-token-capture.d.ts +33 -0
  168. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -0
  169. package/dist/features/magic-context/tagger.d.ts +64 -0
  170. package/dist/features/magic-context/tagger.d.ts.map +1 -0
  171. package/dist/features/magic-context/tool-definition-tokens.d.ts +79 -0
  172. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -0
  173. package/dist/features/magic-context/tool-owner-backfill.d.ts +90 -0
  174. package/dist/features/magic-context/tool-owner-backfill.d.ts.map +1 -0
  175. package/dist/features/magic-context/types.d.ts +72 -0
  176. package/dist/features/magic-context/types.d.ts.map +1 -0
  177. package/dist/features/magic-context/user-memory/review-user-memories.d.ts +22 -0
  178. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -0
  179. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts +33 -0
  180. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -0
  181. package/dist/features/magic-context/work-metrics.d.ts +13 -0
  182. package/dist/features/magic-context/work-metrics.d.ts.map +1 -0
  183. package/dist/hooks/auto-update-checker/cache.d.ts +23 -0
  184. package/dist/hooks/auto-update-checker/cache.d.ts.map +1 -0
  185. package/dist/hooks/auto-update-checker/checker.d.ts +13 -0
  186. package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -0
  187. package/dist/hooks/auto-update-checker/constants.d.ts +10 -0
  188. package/dist/hooks/auto-update-checker/constants.d.ts.map +1 -0
  189. package/dist/hooks/auto-update-checker/index.d.ts +40 -0
  190. package/dist/hooks/auto-update-checker/index.d.ts.map +1 -0
  191. package/dist/hooks/auto-update-checker/types.d.ts +50 -0
  192. package/dist/hooks/auto-update-checker/types.d.ts.map +1 -0
  193. package/dist/hooks/is-anthropic-provider.d.ts +2 -0
  194. package/dist/hooks/is-anthropic-provider.d.ts.map +1 -0
  195. package/dist/hooks/magic-context/apply-context-nudge.d.ts +5 -0
  196. package/dist/hooks/magic-context/apply-context-nudge.d.ts.map +1 -0
  197. package/dist/hooks/magic-context/apply-operations.d.ts +7 -0
  198. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -0
  199. package/dist/hooks/magic-context/auto-search-hint.d.ts +34 -0
  200. package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -0
  201. package/dist/hooks/magic-context/auto-search-runner.d.ts +53 -0
  202. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -0
  203. package/dist/hooks/magic-context/boundary-execution.d.ts +24 -0
  204. package/dist/hooks/magic-context/boundary-execution.d.ts.map +1 -0
  205. package/dist/hooks/magic-context/cache-busting-signals.d.ts +10 -0
  206. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -0
  207. package/dist/hooks/magic-context/caveman-cleanup.d.ts +86 -0
  208. package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -0
  209. package/dist/hooks/magic-context/caveman.d.ts +35 -0
  210. package/dist/hooks/magic-context/caveman.d.ts.map +1 -0
  211. package/dist/hooks/magic-context/command-handler.d.ts +89 -0
  212. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -0
  213. package/dist/hooks/magic-context/compaction-marker-manager.d.ts +106 -0
  214. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -0
  215. package/dist/hooks/magic-context/compartment-parser.d.ts +18 -0
  216. package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -0
  217. package/dist/hooks/magic-context/compartment-prompt.d.ts +19 -0
  218. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -0
  219. package/dist/hooks/magic-context/compartment-runner-compressor.d.ts +87 -0
  220. package/dist/hooks/magic-context/compartment-runner-compressor.d.ts.map +1 -0
  221. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts +26 -0
  222. package/dist/hooks/magic-context/compartment-runner-drop-queue.d.ts.map +1 -0
  223. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +42 -0
  224. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -0
  225. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +6 -0
  226. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -0
  227. package/dist/hooks/magic-context/compartment-runner-mapping.d.ts +33 -0
  228. package/dist/hooks/magic-context/compartment-runner-mapping.d.ts.map +1 -0
  229. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts +29 -0
  230. package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -0
  231. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts +3 -0
  232. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -0
  233. package/dist/hooks/magic-context/compartment-runner-state-xml.d.ts +21 -0
  234. package/dist/hooks/magic-context/compartment-runner-state-xml.d.ts.map +1 -0
  235. package/dist/hooks/magic-context/compartment-runner-types.d.ts +102 -0
  236. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -0
  237. package/dist/hooks/magic-context/compartment-runner-validation.d.ts +28 -0
  238. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -0
  239. package/dist/hooks/magic-context/compartment-runner.d.ts +54 -0
  240. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -0
  241. package/dist/hooks/magic-context/compartment-trigger.d.ts +17 -0
  242. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -0
  243. package/dist/hooks/magic-context/derive-budgets.d.ts +57 -0
  244. package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -0
  245. package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts +4 -0
  246. package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts.map +1 -0
  247. package/dist/hooks/magic-context/event-handler.d.ts +49 -0
  248. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -0
  249. package/dist/hooks/magic-context/event-payloads.d.ts +62 -0
  250. package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -0
  251. package/dist/hooks/magic-context/event-resolvers.d.ts +72 -0
  252. package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -0
  253. package/dist/hooks/magic-context/execute-flush.d.ts +3 -0
  254. package/dist/hooks/magic-context/execute-flush.d.ts.map +1 -0
  255. package/dist/hooks/magic-context/execute-status.d.ts +12 -0
  256. package/dist/hooks/magic-context/execute-status.d.ts.map +1 -0
  257. package/dist/hooks/magic-context/format-bytes.d.ts +2 -0
  258. package/dist/hooks/magic-context/format-bytes.d.ts.map +1 -0
  259. package/dist/hooks/magic-context/heuristic-cleanup.d.ts +22 -0
  260. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -0
  261. package/dist/hooks/magic-context/historian-state-file.d.ts +43 -0
  262. package/dist/hooks/magic-context/historian-state-file.d.ts.map +1 -0
  263. package/dist/hooks/magic-context/hook-handlers.d.ts +165 -0
  264. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -0
  265. package/dist/hooks/magic-context/hook.d.ts +118 -0
  266. package/dist/hooks/magic-context/hook.d.ts.map +1 -0
  267. package/dist/hooks/magic-context/image-token-estimate.d.ts +6 -0
  268. package/dist/hooks/magic-context/image-token-estimate.d.ts.map +1 -0
  269. package/dist/hooks/magic-context/index.d.ts +3 -0
  270. package/dist/hooks/magic-context/index.d.ts.map +1 -0
  271. package/dist/hooks/magic-context/inject-compartments.d.ts +52 -0
  272. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -0
  273. package/dist/hooks/magic-context/key-files-block.d.ts +27 -0
  274. package/dist/hooks/magic-context/key-files-block.d.ts.map +1 -0
  275. package/dist/hooks/magic-context/live-session-state.d.ts +42 -0
  276. package/dist/hooks/magic-context/live-session-state.d.ts.map +1 -0
  277. package/dist/hooks/magic-context/note-nudger.d.ts +71 -0
  278. package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -0
  279. package/dist/hooks/magic-context/note-visibility.d.ts +43 -0
  280. package/dist/hooks/magic-context/note-visibility.d.ts.map +1 -0
  281. package/dist/hooks/magic-context/nudge-bands.d.ts +6 -0
  282. package/dist/hooks/magic-context/nudge-bands.d.ts.map +1 -0
  283. package/dist/hooks/magic-context/nudge-injection.d.ts +7 -0
  284. package/dist/hooks/magic-context/nudge-injection.d.ts.map +1 -0
  285. package/dist/hooks/magic-context/nudge-placement-store.d.ts +15 -0
  286. package/dist/hooks/magic-context/nudge-placement-store.d.ts.map +1 -0
  287. package/dist/hooks/magic-context/nudger.d.ts +21 -0
  288. package/dist/hooks/magic-context/nudger.d.ts.map +1 -0
  289. package/dist/hooks/magic-context/read-session-chunk.d.ts +99 -0
  290. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -0
  291. package/dist/hooks/magic-context/read-session-db.d.ts +21 -0
  292. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -0
  293. package/dist/hooks/magic-context/read-session-formatting.d.ts +35 -0
  294. package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -0
  295. package/dist/hooks/magic-context/read-session-raw.d.ts +10 -0
  296. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -0
  297. package/dist/hooks/magic-context/send-session-notification.d.ts +13 -0
  298. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -0
  299. package/dist/hooks/magic-context/sentinel.d.ts +102 -0
  300. package/dist/hooks/magic-context/sentinel.d.ts.map +1 -0
  301. package/dist/hooks/magic-context/strip-content.d.ts +140 -0
  302. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -0
  303. package/dist/hooks/magic-context/strip-structural-noise.d.ts +17 -0
  304. package/dist/hooks/magic-context/strip-structural-noise.d.ts.map +1 -0
  305. package/dist/hooks/magic-context/system-injection-stripper.d.ts +2 -0
  306. package/dist/hooks/magic-context/system-injection-stripper.d.ts.map +1 -0
  307. package/dist/hooks/magic-context/system-prompt-hash.d.ts +85 -0
  308. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -0
  309. package/dist/hooks/magic-context/tag-content-primitives.d.ts +6 -0
  310. package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -0
  311. package/dist/hooks/magic-context/tag-id-fallback.d.ts +9 -0
  312. package/dist/hooks/magic-context/tag-id-fallback.d.ts.map +1 -0
  313. package/dist/hooks/magic-context/tag-messages.d.ts +48 -0
  314. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -0
  315. package/dist/hooks/magic-context/tag-part-guards.d.ts +23 -0
  316. package/dist/hooks/magic-context/tag-part-guards.d.ts.map +1 -0
  317. package/dist/hooks/magic-context/temporal-awareness.d.ts +73 -0
  318. package/dist/hooks/magic-context/temporal-awareness.d.ts.map +1 -0
  319. package/dist/hooks/magic-context/text-complete.d.ts +8 -0
  320. package/dist/hooks/magic-context/text-complete.d.ts.map +1 -0
  321. package/dist/hooks/magic-context/todo-view.d.ts +102 -0
  322. package/dist/hooks/magic-context/todo-view.d.ts.map +1 -0
  323. package/dist/hooks/magic-context/tokenizer-calibration.d.ts +85 -0
  324. package/dist/hooks/magic-context/tokenizer-calibration.d.ts.map +1 -0
  325. package/dist/hooks/magic-context/tool-drop-target.d.ts +48 -0
  326. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -0
  327. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +66 -0
  328. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -0
  329. package/dist/hooks/magic-context/transform-context-state.d.ts +12 -0
  330. package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -0
  331. package/dist/hooks/magic-context/transform-message-helpers.d.ts +29 -0
  332. package/dist/hooks/magic-context/transform-message-helpers.d.ts.map +1 -0
  333. package/dist/hooks/magic-context/transform-operations.d.ts +5 -0
  334. package/dist/hooks/magic-context/transform-operations.d.ts.map +1 -0
  335. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +100 -0
  336. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -0
  337. package/dist/hooks/magic-context/transform-stage-logger.d.ts +2 -0
  338. package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -0
  339. package/dist/hooks/magic-context/transform.d.ts +145 -0
  340. package/dist/hooks/magic-context/transform.d.ts.map +1 -0
  341. package/dist/index.d.ts +4 -0
  342. package/dist/index.d.ts.map +1 -0
  343. package/dist/index.js +179800 -0
  344. package/dist/plugin/conflict-warning-hook.d.ts +34 -0
  345. package/dist/plugin/conflict-warning-hook.d.ts.map +1 -0
  346. package/dist/plugin/dream-timer.d.ts +44 -0
  347. package/dist/plugin/dream-timer.d.ts.map +1 -0
  348. package/dist/plugin/embedding-bootstrap-helpers.d.ts +35 -0
  349. package/dist/plugin/embedding-bootstrap-helpers.d.ts.map +1 -0
  350. package/dist/plugin/embedding-bootstrap.d.ts +3 -0
  351. package/dist/plugin/embedding-bootstrap.d.ts.map +1 -0
  352. package/dist/plugin/event.d.ts +13 -0
  353. package/dist/plugin/event.d.ts.map +1 -0
  354. package/dist/plugin/hooks/create-session-hooks.d.ts +44 -0
  355. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -0
  356. package/dist/plugin/messages-transform.d.ts +46 -0
  357. package/dist/plugin/messages-transform.d.ts.map +1 -0
  358. package/dist/plugin/normalize-tool-arg-schemas.d.ts +7 -0
  359. package/dist/plugin/normalize-tool-arg-schemas.d.ts.map +1 -0
  360. package/dist/plugin/rpc-handlers.d.ts +21 -0
  361. package/dist/plugin/rpc-handlers.d.ts.map +1 -0
  362. package/dist/plugin/sidebar-snapshot-cache.d.ts +19 -0
  363. package/dist/plugin/sidebar-snapshot-cache.d.ts.map +1 -0
  364. package/dist/plugin/tool-registry.d.ts +8 -0
  365. package/dist/plugin/tool-registry.d.ts.map +1 -0
  366. package/dist/plugin/types.d.ts +3 -0
  367. package/dist/plugin/types.d.ts.map +1 -0
  368. package/dist/shared/announcement.d.ts +55 -0
  369. package/dist/shared/announcement.d.ts.map +1 -0
  370. package/dist/shared/assistant-message-extractor.d.ts +2 -0
  371. package/dist/shared/assistant-message-extractor.d.ts.map +1 -0
  372. package/dist/shared/bounded-session-map.d.ts +45 -0
  373. package/dist/shared/bounded-session-map.d.ts.map +1 -0
  374. package/dist/shared/conflict-detector.d.ts +74 -0
  375. package/dist/shared/conflict-detector.d.ts.map +1 -0
  376. package/dist/shared/conflict-fixer.d.ts +3 -0
  377. package/dist/shared/conflict-fixer.d.ts.map +1 -0
  378. package/dist/shared/data-path.d.ts +121 -0
  379. package/dist/shared/data-path.d.ts.map +1 -0
  380. package/dist/shared/error-message.d.ts +32 -0
  381. package/dist/shared/error-message.d.ts.map +1 -0
  382. package/dist/shared/format-bytes.d.ts +2 -0
  383. package/dist/shared/format-bytes.d.ts.map +1 -0
  384. package/dist/shared/format-threshold.d.ts +24 -0
  385. package/dist/shared/format-threshold.d.ts.map +1 -0
  386. package/dist/shared/harness.d.ts +43 -0
  387. package/dist/shared/harness.d.ts.map +1 -0
  388. package/dist/shared/index.d.ts +6 -0
  389. package/dist/shared/index.d.ts.map +1 -0
  390. package/dist/shared/internal-initiator-marker.d.ts +2 -0
  391. package/dist/shared/internal-initiator-marker.d.ts.map +1 -0
  392. package/dist/shared/jsonc-parser.d.ts +8 -0
  393. package/dist/shared/jsonc-parser.d.ts.map +1 -0
  394. package/dist/shared/logger.d.ts +10 -0
  395. package/dist/shared/logger.d.ts.map +1 -0
  396. package/dist/shared/model-requirements.d.ts +26 -0
  397. package/dist/shared/model-requirements.d.ts.map +1 -0
  398. package/dist/shared/model-suggestion-retry.d.ts +68 -0
  399. package/dist/shared/model-suggestion-retry.d.ts.map +1 -0
  400. package/dist/shared/models-dev-cache.d.ts +65 -0
  401. package/dist/shared/models-dev-cache.d.ts.map +1 -0
  402. package/dist/shared/native-binding.d.ts +87 -0
  403. package/dist/shared/native-binding.d.ts.map +1 -0
  404. package/dist/shared/normalize-sdk-response.d.ts +5 -0
  405. package/dist/shared/normalize-sdk-response.d.ts.map +1 -0
  406. package/dist/shared/opencode-compaction-detector.d.ts +2 -0
  407. package/dist/shared/opencode-compaction-detector.d.ts.map +1 -0
  408. package/dist/shared/opencode-config-dir-types.d.ts +14 -0
  409. package/dist/shared/opencode-config-dir-types.d.ts.map +1 -0
  410. package/dist/shared/opencode-config-dir.d.ts +5 -0
  411. package/dist/shared/opencode-config-dir.d.ts.map +1 -0
  412. package/dist/shared/record-type-guard.d.ts +2 -0
  413. package/dist/shared/record-type-guard.d.ts.map +1 -0
  414. package/dist/shared/resolve-fallbacks.d.ts +32 -0
  415. package/dist/shared/resolve-fallbacks.d.ts.map +1 -0
  416. package/dist/shared/rpc-client.d.ts +17 -0
  417. package/dist/shared/rpc-client.d.ts.map +1 -0
  418. package/dist/shared/rpc-notifications.d.ts +24 -0
  419. package/dist/shared/rpc-notifications.d.ts.map +1 -0
  420. package/dist/shared/rpc-server.d.ts +20 -0
  421. package/dist/shared/rpc-server.d.ts.map +1 -0
  422. package/dist/shared/rpc-types.d.ts +105 -0
  423. package/dist/shared/rpc-types.d.ts.map +1 -0
  424. package/dist/shared/rpc-utils.d.ts +19 -0
  425. package/dist/shared/rpc-utils.d.ts.map +1 -0
  426. package/dist/shared/sqlite-helpers.d.ts +16 -0
  427. package/dist/shared/sqlite-helpers.d.ts.map +1 -0
  428. package/dist/shared/sqlite.d.ts +43 -0
  429. package/dist/shared/sqlite.d.ts.map +1 -0
  430. package/dist/shared/stable-json.d.ts +21 -0
  431. package/dist/shared/stable-json.d.ts.map +1 -0
  432. package/dist/shared/subagent-runner.d.ts +208 -0
  433. package/dist/shared/subagent-runner.d.ts.map +1 -0
  434. package/dist/shared/system-directive.d.ts +3 -0
  435. package/dist/shared/system-directive.d.ts.map +1 -0
  436. package/dist/shared/tag-transcript.d.ts +66 -0
  437. package/dist/shared/tag-transcript.d.ts.map +1 -0
  438. package/dist/shared/transcript-opencode.d.ts +71 -0
  439. package/dist/shared/transcript-opencode.d.ts.map +1 -0
  440. package/dist/shared/transcript.d.ts +212 -0
  441. package/dist/shared/transcript.d.ts.map +1 -0
  442. package/dist/shared/tui-config.d.ts +10 -0
  443. package/dist/shared/tui-config.d.ts.map +1 -0
  444. package/dist/tools/ctx-expand/constants.d.ts +3 -0
  445. package/dist/tools/ctx-expand/constants.d.ts.map +1 -0
  446. package/dist/tools/ctx-expand/index.d.ts +2 -0
  447. package/dist/tools/ctx-expand/index.d.ts.map +1 -0
  448. package/dist/tools/ctx-expand/tools.d.ts +3 -0
  449. package/dist/tools/ctx-expand/tools.d.ts.map +1 -0
  450. package/dist/tools/ctx-expand/types.d.ts +5 -0
  451. package/dist/tools/ctx-expand/types.d.ts.map +1 -0
  452. package/dist/tools/ctx-memory/constants.d.ts +4 -0
  453. package/dist/tools/ctx-memory/constants.d.ts.map +1 -0
  454. package/dist/tools/ctx-memory/index.d.ts +4 -0
  455. package/dist/tools/ctx-memory/index.d.ts.map +1 -0
  456. package/dist/tools/ctx-memory/tools.d.ts +4 -0
  457. package/dist/tools/ctx-memory/tools.d.ts.map +1 -0
  458. package/dist/tools/ctx-memory/types.d.ts +35 -0
  459. package/dist/tools/ctx-memory/types.d.ts.map +1 -0
  460. package/dist/tools/ctx-note/constants.d.ts +2 -0
  461. package/dist/tools/ctx-note/constants.d.ts.map +1 -0
  462. package/dist/tools/ctx-note/index.d.ts +4 -0
  463. package/dist/tools/ctx-note/index.d.ts.map +1 -0
  464. package/dist/tools/ctx-note/tools.d.ts +15 -0
  465. package/dist/tools/ctx-note/tools.d.ts.map +1 -0
  466. package/dist/tools/ctx-note/types.d.ts +9 -0
  467. package/dist/tools/ctx-note/types.d.ts.map +1 -0
  468. package/dist/tools/ctx-reduce/constants.d.ts +2 -0
  469. package/dist/tools/ctx-reduce/constants.d.ts.map +1 -0
  470. package/dist/tools/ctx-reduce/index.d.ts +4 -0
  471. package/dist/tools/ctx-reduce/index.d.ts.map +1 -0
  472. package/dist/tools/ctx-reduce/tools.d.ts +9 -0
  473. package/dist/tools/ctx-reduce/tools.d.ts.map +1 -0
  474. package/dist/tools/ctx-reduce/types.d.ts +4 -0
  475. package/dist/tools/ctx-reduce/types.d.ts.map +1 -0
  476. package/dist/tools/ctx-search/constants.d.ts +4 -0
  477. package/dist/tools/ctx-search/constants.d.ts.map +1 -0
  478. package/dist/tools/ctx-search/index.d.ts +4 -0
  479. package/dist/tools/ctx-search/index.d.ts.map +1 -0
  480. package/dist/tools/ctx-search/tools.d.ts +4 -0
  481. package/dist/tools/ctx-search/tools.d.ts.map +1 -0
  482. package/dist/tools/ctx-search/types.d.ts +34 -0
  483. package/dist/tools/ctx-search/types.d.ts.map +1 -0
  484. package/dist/tools/index.d.ts +6 -0
  485. package/dist/tools/index.d.ts.map +1 -0
  486. package/dist/tui/data/context-db.d.ts +36 -0
  487. package/dist/tui/data/context-db.d.ts.map +1 -0
  488. package/package.json +80 -0
  489. package/src/shared/announcement.test.ts +143 -0
  490. package/src/shared/announcement.ts +97 -0
  491. package/src/shared/assistant-message-extractor.ts +74 -0
  492. package/src/shared/bounded-session-map.test.ts +97 -0
  493. package/src/shared/bounded-session-map.ts +84 -0
  494. package/src/shared/conflict-detector.test.ts +232 -0
  495. package/src/shared/conflict-detector.ts +371 -0
  496. package/src/shared/conflict-fixer.test.ts +124 -0
  497. package/src/shared/conflict-fixer.ts +222 -0
  498. package/src/shared/data-path.test.ts +159 -0
  499. package/src/shared/data-path.ts +155 -0
  500. package/src/shared/error-message.test.ts +94 -0
  501. package/src/shared/error-message.ts +115 -0
  502. package/src/shared/format-bytes.ts +5 -0
  503. package/src/shared/format-threshold.ts +28 -0
  504. package/src/shared/harness.ts +61 -0
  505. package/src/shared/index.ts +5 -0
  506. package/src/shared/internal-initiator-marker.ts +1 -0
  507. package/src/shared/jsonc-parser.ts +138 -0
  508. package/src/shared/logger.ts +94 -0
  509. package/src/shared/model-requirements.ts +86 -0
  510. package/src/shared/model-suggestion-retry.test.ts +251 -0
  511. package/src/shared/model-suggestion-retry.ts +348 -0
  512. package/src/shared/models-dev-cache.test.ts +394 -0
  513. package/src/shared/models-dev-cache.ts +337 -0
  514. package/src/shared/native-binding.ts +311 -0
  515. package/src/shared/normalize-sdk-response.ts +40 -0
  516. package/src/shared/opencode-compaction-detector.test.ts +222 -0
  517. package/src/shared/opencode-compaction-detector.ts +81 -0
  518. package/src/shared/opencode-config-dir-types.ts +15 -0
  519. package/src/shared/opencode-config-dir.ts +38 -0
  520. package/src/shared/record-type-guard.ts +3 -0
  521. package/src/shared/resolve-fallbacks.test.ts +136 -0
  522. package/src/shared/resolve-fallbacks.ts +76 -0
  523. package/src/shared/rpc-client.test.ts +161 -0
  524. package/src/shared/rpc-client.ts +183 -0
  525. package/src/shared/rpc-notifications.test.ts +20 -0
  526. package/src/shared/rpc-notifications.ts +53 -0
  527. package/src/shared/rpc-server.ts +174 -0
  528. package/src/shared/rpc-types.ts +104 -0
  529. package/src/shared/rpc-utils.ts +72 -0
  530. package/src/shared/session-messages-bounded.test.ts +112 -0
  531. package/src/shared/sqlite-helpers.ts +27 -0
  532. package/src/shared/sqlite.ts +134 -0
  533. package/src/shared/stable-json.test.ts +87 -0
  534. package/src/shared/stable-json.ts +37 -0
  535. package/src/shared/subagent-runner.ts +222 -0
  536. package/src/shared/system-directive.ts +9 -0
  537. package/src/shared/tag-transcript.ts +553 -0
  538. package/src/shared/transcript-opencode.ts +259 -0
  539. package/src/shared/transcript.ts +226 -0
  540. package/src/shared/tui-config.ts +99 -0
  541. package/src/tui/data/context-db.ts +303 -0
  542. package/src/tui/index.tsx +692 -0
  543. package/src/tui/slots/sidebar-content.tsx +482 -0
  544. package/src/tui/types/opencode-plugin-tui.d.ts +232 -0
@@ -0,0 +1,85 @@
1
+ import { type ContextDatabase } from "../../features/magic-context/storage";
2
+ /**
3
+ * Clear all per-session cache entries the system-prompt handler maintains,
4
+ * including the module-scope user-profile/key-files maps and the per-handler
5
+ * sticky-date/cached-docs maps (the latter passed in via the cleanup handle).
6
+ * Called from the session-deleted event path.
7
+ */
8
+ export declare function clearSystemPromptHashSession(sessionId: string, handleMaps: {
9
+ stickyDateBySession: Map<string, string>;
10
+ cachedDocsBySession: Map<string, string | null>;
11
+ }): void;
12
+ /**
13
+ * Handle system prompt via experimental.chat.system.transform:
14
+ *
15
+ * 1. Inject generic magic-context guidance into the system prompt.
16
+ * Skips injection if guidance is already present (e.g., baked into the
17
+ * agent prompt by oh-my-opencode).
18
+ *
19
+ * 2. Detect system prompt changes for cache-flush triggering.
20
+ * If the hash changes between turns, the Anthropic prompt-cache prefix is
21
+ * already busted, so we flush queued operations immediately.
22
+ */
23
+ export declare function createSystemPromptHashHandler(deps: {
24
+ db: ContextDatabase;
25
+ protectedTags: number;
26
+ ctxReduceEnabled: boolean;
27
+ dropToolStructure: boolean;
28
+ dreamerEnabled: boolean;
29
+ /** When true + dreamerEnabled, inject ARCHITECTURE.md and STRUCTURE.md into system prompt */
30
+ injectDocs: boolean;
31
+ /** Project root directory for reading doc files */
32
+ directory: string;
33
+ /**
34
+ * One-shot signal that disk-backed adjuncts (project docs, user
35
+ * profile, key files, sticky date) need to be re-read on this pass.
36
+ * Drained at the end of the handler regardless of whether anything
37
+ * actually refreshed — defer passes after this point MUST hit cached
38
+ * values to keep the system prompt cache-stable.
39
+ */
40
+ systemPromptRefreshSessions: Set<string>;
41
+ /**
42
+ * Producer side: when this handler detects a real prompt-content hash
43
+ * change, it adds the session to all three sets so downstream consumers
44
+ * (transform `prepareCompartmentInjection`, postprocess heuristics)
45
+ * react on the same cycle. The hash change usually pairs with a new
46
+ * agent identity, so all three are appropriate.
47
+ */
48
+ historyRefreshSessions: Set<string>;
49
+ pendingMaterializationSessions: Set<string>;
50
+ lastHeuristicsTurnId: Map<string, string>;
51
+ /**
52
+ * Issue #53: when false, Magic Context skips ALL system-prompt injection
53
+ * for ALL agents. Global escape hatch for users who don't want any
54
+ * Magic Context guidance / docs / user-profile / key-files / sticky date
55
+ * touching the system prompt. (default: true)
56
+ */
57
+ injectionEnabled?: boolean;
58
+ /**
59
+ * Issue #53: per-agent opt-out. If the agent's system prompt contains
60
+ * any of these substrings, skip ALL injection for this call. Lets users
61
+ * mark specific custom agents (e.g. read-only QA agents that deny our
62
+ * `ctx_*` tools) as no-injection without having to disable injection
63
+ * globally.
64
+ */
65
+ injectionSkipSignatures?: string[];
66
+ /** When true, inject stable user memories as <user-profile> into system prompt */
67
+ experimentalUserMemories?: boolean;
68
+ /** When true, inject pinned key files as <key-files> into system prompt */
69
+ experimentalPinKeyFiles?: boolean;
70
+ /** Token budget for key files injection (default 10000) */
71
+ experimentalPinKeyFilesTokenBudget?: number;
72
+ /** When true, add a temporal-awareness guidance paragraph + surface compartment dates */
73
+ experimentalTemporalAwareness?: boolean;
74
+ /** When true (and ctx_reduce_enabled is false), inject a "BEWARE: history compression is on"
75
+ * warning so the agent doesn't mimic its own caveman-compressed past output. */
76
+ experimentalCavemanTextCompression?: boolean;
77
+ }): {
78
+ handler: (input: {
79
+ sessionID?: string;
80
+ }, output: {
81
+ system: string[];
82
+ }) => Promise<void>;
83
+ clearSession: (sessionId: string) => void;
84
+ };
85
+ //# sourceMappingURL=system-prompt-hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt-hash.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/system-prompt-hash.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,KAAK,eAAe,EAGvB,MAAM,sCAAsC,CAAC;AAiB9C;;;;;GAKG;AACH,wBAAgB,4BAA4B,CACxC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE;IACR,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CACnD,GACF,IAAI,CAKN;AAsED;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAChD,EAAE,EAAE,eAAe,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,6FAA6F;IAC7F,UAAU,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,2BAA2B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,8BAA8B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5C,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,kFAAkF;IAClF,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,2EAA2E;IAC3E,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,2DAA2D;IAC3D,kCAAkC,CAAC,EAAE,MAAM,CAAC;IAC5C,yFAAyF;IACzF,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC;qFACiF;IACjF,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAChD,GAAG;IACA,OAAO,EAAE,CAAC,KAAK,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C,CA0UA"}
@@ -0,0 +1,6 @@
1
+ import type { ThinkingLikePart } from "./tag-messages";
2
+ export declare function byteSize(value: string): number;
3
+ export declare function stripTagPrefix(value: string): string;
4
+ export declare function prependTag(tagId: number, value: string): string;
5
+ export declare function isThinkingPart(part: unknown): part is ThinkingLikePart;
6
+ //# sourceMappingURL=tag-content-primitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-content-primitives.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/tag-content-primitives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAuCvD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOpD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,gBAAgB,CAItE"}
@@ -0,0 +1,9 @@
1
+ import type { ContextDatabase } from "../../features/magic-context/storage";
2
+ import type { Tagger } from "../../features/magic-context/tagger";
3
+ type TaggableContentType = "message" | "file";
4
+ export interface ExistingTagResolver {
5
+ resolve: (messageId: string, type: TaggableContentType, currentContentId: string, ordinal: number) => number | undefined;
6
+ }
7
+ export declare function createExistingTagResolver(sessionId: string, tagger: Tagger, db: ContextDatabase): ExistingTagResolver;
8
+ export {};
9
+ //# sourceMappingURL=tag-id-fallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-id-fallback.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/tag-id-fallback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAElE,KAAK,mBAAmB,GAAG,SAAS,GAAG,MAAM,CAAC;AAgB9C,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,CACL,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,mBAAmB,EACzB,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,KACd,MAAM,GAAG,SAAS,CAAC;CAC3B;AAmCD,wBAAgB,yBAAyB,CACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,eAAe,GACpB,mBAAmB,CAkCrB"}
@@ -0,0 +1,48 @@
1
+ import type { ContextDatabase } from "../../features/magic-context/storage";
2
+ import { type Tagger } from "../../features/magic-context/tagger";
3
+ import { type ToolCallIndex, type ToolDropResult, ToolMutationBatch } from "./tool-drop-target";
4
+ export type MessageInfo = {
5
+ id?: string;
6
+ role?: string;
7
+ sessionID?: string;
8
+ };
9
+ export interface ThinkingLikePart {
10
+ type: string;
11
+ thinking?: string;
12
+ text?: string;
13
+ }
14
+ export type MessageLike = {
15
+ info: MessageInfo;
16
+ parts: unknown[];
17
+ };
18
+ export type TagTarget = {
19
+ setContent: (content: string) => boolean;
20
+ getContent?: () => string | null;
21
+ drop?: () => ToolDropResult;
22
+ truncate?: () => ToolDropResult;
23
+ message?: MessageLike;
24
+ };
25
+ export interface TagMessagesResult {
26
+ targets: Map<number, TagTarget>;
27
+ reasoningByMessage: Map<MessageLike, ThinkingLikePart[]>;
28
+ messageTagNumbers: Map<MessageLike, number>;
29
+ toolCallIndex: ToolCallIndex;
30
+ batch: ToolMutationBatch;
31
+ hasRecentReduceCall: boolean;
32
+ /** Whether recent assistant messages contain git commit hash patterns */
33
+ hasRecentCommit: boolean;
34
+ }
35
+ export interface TagMessagesOptions {
36
+ /**
37
+ * When true, skip injecting §N§ prefix into message text/tool output parts.
38
+ * DB-level tag records are still created normally — this flag only affects
39
+ * whether the agent-visible part content gets the tag prefix. Used when
40
+ * `ctx_reduce_enabled: false` so agents don't see tag markers they can't
41
+ * act on. Subagents also set this flag (they are always treated as
42
+ * ctx_reduce_enabled=false). Cache-safe: skipping is consistent across
43
+ * passes, so message shape stays stable.
44
+ */
45
+ skipPrefixInjection?: boolean;
46
+ }
47
+ export declare function tagMessages(sessionId: string, messages: MessageLike[], tagger: Tagger, db: ContextDatabase, options?: TagMessagesOptions): TagMessagesResult;
48
+ //# sourceMappingURL=tag-messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-messages.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/tag-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAQ5E,OAAO,EAAwB,KAAK,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAaxF,OAAO,EAGH,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,iBAAiB,EACpB,MAAM,oBAAoB,CAAC;AA+E5B,MAAM,MAAM,WAAW,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7E,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC;AAElE,MAAM,MAAM,SAAS,GAAG;IACpB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,UAAU,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,cAAc,CAAC;IAChC,OAAO,CAAC,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAChC,kBAAkB,EAAE,GAAG,CAAC,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACzD,iBAAiB,EAAE,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC5C,aAAa,EAAE,aAAa,CAAC;IAC7B,KAAK,EAAE,iBAAiB,CAAC;IACzB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,yEAAyE;IACzE,eAAe,EAAE,OAAO,CAAC;CAC5B;AAkED,MAAM,WAAW,kBAAkB;IAC/B;;;;;;;;OAQG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,wBAAgB,WAAW,CACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,WAAW,EAAE,EACvB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,eAAe,EACnB,OAAO,GAAE,kBAAuB,GACjC,iBAAiB,CA+UnB"}
@@ -0,0 +1,23 @@
1
+ import { stripTagPrefix } from "./tag-content-primitives";
2
+ export { stripTagPrefix };
3
+ export interface ValidTextPart {
4
+ type: string;
5
+ text: string;
6
+ }
7
+ export interface ValidToolPart {
8
+ type: string;
9
+ callID: string;
10
+ state: {
11
+ output: string;
12
+ input?: Record<string, unknown>;
13
+ };
14
+ }
15
+ interface ValidFilePart {
16
+ type: string;
17
+ url: string;
18
+ }
19
+ export declare function isTextPart(part: unknown): part is ValidTextPart;
20
+ export declare function isToolPartWithOutput(part: unknown): part is ValidToolPart;
21
+ export declare function isFilePart(part: unknown): part is ValidFilePart;
22
+ export declare function buildFileSourceContent(parts: unknown[]): string | null;
23
+ //# sourceMappingURL=tag-part-guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-part-guards.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/tag-part-guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CAC9D;AAED,UAAU,aAAa;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAI/D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAMzE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAI/D;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CAQtE"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Temporal awareness utilities.
3
+ *
4
+ * When enabled via experimental.temporal_awareness, the plugin:
5
+ * 1. Prepends <!-- +Xm --> / <!-- +2h 15m --> / <!-- +3d 4h --> HTML comments
6
+ * to user messages where the gap since the previous message exceeds
7
+ * TEMPORAL_AWARENESS_THRESHOLD_SECONDS.
8
+ * 2. Adds start="YYYY-MM-DD" end="YYYY-MM-DD" date attributes to <compartment>
9
+ * elements in the injected <session-history> block.
10
+ *
11
+ * The gap is measured from the previous message's effective end time:
12
+ * - Assistant (completed): prev.time.completed
13
+ * - Assistant (in-flight/aborted): prev.time.created (best available)
14
+ * - User: prev.time.created (user messages have no completed field)
15
+ *
16
+ * All values are derived deterministically from immutable message timestamps,
17
+ * so injection is stable across transform passes and cache-safe.
18
+ */
19
+ /** User message gaps below this threshold get no marker. 5 minutes. */
20
+ export declare const TEMPORAL_AWARENESS_THRESHOLD_SECONDS = 300;
21
+ /**
22
+ * Format a gap in seconds as a compact adaptive string.
23
+ * Returns null for gaps below the threshold (no marker should be injected).
24
+ *
25
+ * < 5 min → null
26
+ * 5 min - 1 hour → "+Xm" (e.g. "+12m")
27
+ * 1 hour - 1 day → "+Xh Ym" / "+Xh" when Y == 0
28
+ * 1 day - 1 week → "+Xd Yh" / "+Xd" when Y == 0
29
+ * >= 1 week → "+Xw Yd" / "+Xw" when Y == 0
30
+ *
31
+ * Non-finite, negative, or zero deltas return null.
32
+ */
33
+ export declare function formatGap(seconds: number): string | null;
34
+ /**
35
+ * Compute the effective end time for a raw OpenCode message given its
36
+ * time.created and optional time.completed fields.
37
+ *
38
+ * For completed assistants use `completed`; for everything else (user messages,
39
+ * in-flight/aborted assistants) use `created`.
40
+ */
41
+ export declare function effectiveEndMs(time: {
42
+ created: number;
43
+ completed?: number;
44
+ }): number;
45
+ /**
46
+ * Format a Unix ms timestamp as YYYY-MM-DD in the process local timezone.
47
+ * Used for compartment start/end date attributes.
48
+ */
49
+ export declare function formatDate(ms: number): string;
50
+ /** Regex matching the injected HTML comment so we can recognize / avoid
51
+ * double-injecting on retried transform passes. */
52
+ export declare const TEMPORAL_MARKER_PATTERN: RegExp;
53
+ /**
54
+ * Produce the HTML comment prefix line for a given gap marker, or null if the
55
+ * gap is below threshold.
56
+ */
57
+ export declare function temporalMarkerPrefix(seconds: number): string | null;
58
+ /**
59
+ * Inject HTML-comment gap markers into user-message text parts when
60
+ * temporal awareness is enabled and the gap since the previous message's
61
+ * effective end time exceeds TEMPORAL_AWARENESS_THRESHOLD_SECONDS.
62
+ *
63
+ * Idempotent: if a text already starts with a temporal marker (e.g. from a
64
+ * previous transform pass), injection is skipped. Returns the number of
65
+ * messages that received a new marker.
66
+ *
67
+ * The marker is prepended BEFORE any §N§ tag added by tagMessages runs after
68
+ * this function, since tagging happens in the normal transform flow and
69
+ * stripTagPrefix re-strips `§N§` on re-tagging — leaving the marker intact
70
+ * between the tag and the user's text on subsequent passes.
71
+ */
72
+ export declare function injectTemporalMarkers(messages: unknown[]): number;
73
+ //# sourceMappingURL=temporal-awareness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal-awareness.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/temporal-awareness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,uEAAuE;AACvE,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAQxD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAyBxD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEpF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAM7C;AAED;oDACoD;AACpD,eAAO,MAAM,uBAAuB,QAA+C,CAAC;AAEpF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAInE;AAiCD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAuCjE"}
@@ -0,0 +1,8 @@
1
+ export declare function createTextCompleteHandler(): (_input: {
2
+ sessionID: string;
3
+ messageID: string;
4
+ partID: string;
5
+ }, output: {
6
+ text: string;
7
+ }) => Promise<void>;
8
+ //# sourceMappingURL=text-complete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-complete.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/text-complete.ts"],"names":[],"mappings":"AAyCA,wBAAgB,yBAAyB,KAEjC,QAAQ;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAChE,QAAQ;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,KACzB,OAAO,CAAC,IAAI,CAAC,CAKnB"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Todo state synthesis — synthetic todowrite injection.
3
+ *
4
+ * Instead of inventing a custom `<current-todos>` block (which agents would
5
+ * need to learn to parse), we synthesize a realistic `todowrite` tool part
6
+ * and inject it into the latest assistant message on cache-busting passes.
7
+ * The agent reads it through their existing todowrite-tracking mental model:
8
+ * the wire shape is identical to OpenCode's stored todowrite tool parts
9
+ * (`{type: "tool", callID, tool: "todowrite", state: {input, output, ...}}`).
10
+ *
11
+ * Cache safety:
12
+ * - Snapshot capture (in hook-handlers.ts on tool.execute.after) writes DB
13
+ * only — no message mutation.
14
+ * - Injection happens in transform-postprocess-phase.ts AFTER tagging and
15
+ * AFTER applyPendingOperations, so the synthetic part never gets tagged
16
+ * and is invisible to ctx_reduce/heuristic-cleanup/auto_drop_tool_age.
17
+ * - The synthetic callID is deterministic (sha256(stateJson)) so a stable
18
+ * snapshot produces a stable wire shape across passes; on defer passes we
19
+ * re-inject the same part at the same anchor, idempotent via callID match.
20
+ *
21
+ * Wire shape verified against:
22
+ * - OpenCode source: ~/Work/OSS/opencode/packages/opencode/src/tool/todo.ts
23
+ * - Production OpenCode DB sample: part where data LIKE '%"tool":"todowrite"%'
24
+ */
25
+ export interface TodoItem {
26
+ content: string;
27
+ status: string;
28
+ priority: string;
29
+ }
30
+ /**
31
+ * Normalize a `todowrite` args.todos array into a stable JSON string.
32
+ * Returns `null` if the input is not a valid todo array.
33
+ *
34
+ * Used by the snapshot capture path (`hook-handlers.ts`) to produce a
35
+ * deterministic representation that survives JSON round-tripping with
36
+ * stable field order.
37
+ */
38
+ export declare function normalizeTodoStateJson(todos: unknown): string | null;
39
+ /**
40
+ * A synthetic OpenCode tool part matching the wire shape of a real
41
+ * `todowrite` tool result.
42
+ *
43
+ * NOTE — deliberate field omissions vs OpenCode `ToolPart`:
44
+ * - `id`, `sessionID`, `messageID`: OpenCode generates these from
45
+ * `Identifier.ascending(...)` for parts that originate from real tool
46
+ * calls and persist to the OpenCode DB. The synthetic part is
47
+ * transform-only (never persisted to OpenCode's DB), so these fields
48
+ * would be meaningless. The OpenCode wire serializer
49
+ * (`MessageV2.toModelMessagesEffect`) only reads `part.state.*`,
50
+ * `part.callID`, `part.tool`, and `part.metadata` — none of the
51
+ * omitted fields participate in wire serialization. Verified against
52
+ * ~/Work/OSS/opencode/packages/opencode/src/session/message-v2.ts:851-884.
53
+ */
54
+ export interface SyntheticTodoPart {
55
+ type: "tool";
56
+ callID: string;
57
+ tool: "todowrite";
58
+ state: {
59
+ status: "completed";
60
+ input: {
61
+ todos: TodoItem[];
62
+ };
63
+ output: string;
64
+ title: string;
65
+ metadata: {
66
+ todos: TodoItem[];
67
+ truncated: false;
68
+ };
69
+ time: {
70
+ start: number;
71
+ end: number;
72
+ };
73
+ };
74
+ /** Marker so other plugin code can detect synthetic parts and skip them. */
75
+ syntheticTodoMarker: true;
76
+ }
77
+ /**
78
+ * Build a synthetic todowrite tool part from a normalized state JSON.
79
+ * Returns `null` if the state is empty or all todos are terminal — in
80
+ * those cases the agent doesn't need a reminder.
81
+ */
82
+ export declare function buildSyntheticTodoPart(stateJson: string): SyntheticTodoPart | null;
83
+ /**
84
+ * Compute a deterministic call_id from the snapshot JSON. Stable for stable
85
+ * state; identical state across passes produces identical callID, which
86
+ * gives byte-identical wire shape on both cache-busting and defer passes.
87
+ *
88
+ * Format chosen to clearly distinguish from real provider-generated IDs:
89
+ * - Anthropic: `toolu_<24 base62 chars>`
90
+ * - OpenAI: `call_<random>`
91
+ * - Synthetic: `mc_synthetic_todo_<16 hex chars>`
92
+ *
93
+ * Providers do not validate callID format — they only require matching IDs
94
+ * between tool_use and tool_result.
95
+ */
96
+ export declare function computeSyntheticCallId(stateJson: string): string;
97
+ /**
98
+ * Detect whether a part is a synthetic todo part this module produced.
99
+ * Used to skip synthetic parts during tagging and other tool-walk passes.
100
+ */
101
+ export declare function isSyntheticTodoPart(part: unknown): boolean;
102
+ //# sourceMappingURL=todo-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"todo-view.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/todo-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,MAAM,WAAW,QAAQ;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAeD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAcpE;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE;QACH,MAAM,EAAE,WAAW,CAAC;QACpB,KAAK,EAAE;YAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;SAAE,CAAC;QAC7B,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE;YAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;YAAC,SAAS,EAAE,KAAK,CAAA;SAAE,CAAC;QAClD,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;KACxC,CAAC;IACF,4EAA4E;IAC5E,mBAAmB,EAAE,IAAI,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAkClF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAmB1D"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Per-model tokenizer calibration ratios.
3
+ *
4
+ * ai-tokenizer's `claude` / `o200k_base` / `cl100k_base` / `p50k_base` encodings
5
+ * approximate provider tokenizers but drift from the API's actual count by
6
+ * model-specific amounts. Empirically measured ratios from
7
+ * `scripts/calibrate-tokenizer/` (sweep against real production system prompt
8
+ * + 39 MCP-style tools + minimal conversation, comparing local count vs each
9
+ * provider's own usage.input_tokens).
10
+ *
11
+ * `system_ratio = api_tokens / local_raw_tokens` for plain-text system prompts
12
+ * `tools_ratio = api_tokens / local_raw_tokens` for the tools array
13
+ *
14
+ * Multiplying the local count by these ratios yields the API's count.
15
+ *
16
+ * Pattern matching: longest prefix wins. Unknown models fall back to 1.0 / 1.0
17
+ * (no calibration). Re-run the harness when adding new models or after a
18
+ * provider tokenizer change.
19
+ */
20
+ export interface ModelCalibration {
21
+ systemRatio: number;
22
+ toolsRatio: number;
23
+ }
24
+ /**
25
+ * Look up calibration ratios for a given `providerID/modelID` key. Performs
26
+ * longest-prefix match (case-insensitive). Returns neutral ratios (1.0/1.0)
27
+ * for unknown models so the calibration is a no-op rather than incorrect.
28
+ */
29
+ export declare function resolveModelCalibration(providerId: string | undefined, modelId: string | undefined): ModelCalibration;
30
+ /**
31
+ * Apply calibration to local raw counts and absorb the residual into the
32
+ * unknown-drift buckets so all categories sum to exactly inputTokens.
33
+ *
34
+ * Bucket policy by stability:
35
+ * 1. **Calibrated** (System, Tool Defs) — local count × measured per-model
36
+ * ratio. We have empirically derived ratios from `scripts/calibrate-tokenizer/`,
37
+ * so these match the API to within ~5%.
38
+ * 2. **Verbatim** (Compartments, Facts, Memories) — local raw count, no
39
+ * scaling. Magic-context owns this content end-to-end (rendered XML,
40
+ * injected via `prepareCompartmentInjection`), and the compressor uses
41
+ * the same local count for budget math (`execute-status.ts` "History
42
+ * block"). Showing a different number here would confuse users and
43
+ * desync the sidebar from `/ctx-status`.
44
+ * 3. **Residual absorbers** (Conversation, Tool Calls) — proportionally
45
+ * scaled to absorb whatever's left after (1) and (2). These have the
46
+ * most genuine drift (mixed user/assistant text + tool I/O) and the
47
+ * least fixed structure, so attributing the unknown remainder here is
48
+ * the most honest mapping.
49
+ *
50
+ * Behavior at the edges:
51
+ * - inputTokens === 0 → returns all zeros.
52
+ * - residual local sum === 0 (no conversation or tool calls yet) →
53
+ * conversation absorbs the full remainder so the bar still adds up.
54
+ * - non-residual buckets together exceed inputTokens (rare clamp case) →
55
+ * residuals = 0; calibrated + verbatim are scaled down proportionally so
56
+ * the sum never exceeds inputTokens.
57
+ * - rounding: residual ±1 token from rounding lands in the larger residual
58
+ * bucket so exact equality is preserved.
59
+ */
60
+ export interface CalibratedBuckets {
61
+ systemTokens: number;
62
+ toolDefinitionTokens: number;
63
+ compartmentTokens: number;
64
+ factTokens: number;
65
+ memoryTokens: number;
66
+ conversationTokens: number;
67
+ toolCallTokens: number;
68
+ }
69
+ export interface CalibrationInput {
70
+ inputTokens: number;
71
+ /** Local raw count (ai-tokenizer) for the system prompt. */
72
+ systemLocal: number;
73
+ /** Local raw count (ai-tokenizer) for the tool definitions. */
74
+ toolDefsLocal: number;
75
+ /** Verbatim — local raw counts displayed unchanged so the sidebar matches `/ctx-status`. */
76
+ compartmentsLocal: number;
77
+ factsLocal: number;
78
+ memoriesLocal: number;
79
+ /** Residual absorbers — proportionally scaled to absorb the remainder. */
80
+ conversationLocal: number;
81
+ toolCallsLocal: number;
82
+ calibration: ModelCalibration;
83
+ }
84
+ export declare function calibrateBuckets(input: CalibrationInput): CalibratedBuckets;
85
+ //# sourceMappingURL=tokenizer-calibration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenizer-calibration.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/tokenizer-calibration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,gBAAgB;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACtB;AAsED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACnC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,GAC5B,gBAAgB,CAYlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,iBAAiB;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;IACtB,4FAA4F;IAC5F,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,gBAAgB,CAAC;CACjC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,CA+H3E"}
@@ -0,0 +1,48 @@
1
+ import type { MessageLike, ThinkingLikePart } from "./tag-messages";
2
+ export type ToolDropResult = "removed" | "truncated" | "absent" | "incomplete";
3
+ interface ToolCallObservation {
4
+ callId: string;
5
+ kind: "invocation" | "result";
6
+ }
7
+ export interface IndexedOccurrence {
8
+ message: MessageLike;
9
+ part: unknown;
10
+ kind: "invocation" | "result";
11
+ }
12
+ export interface ToolCallIndexEntry {
13
+ occurrences: IndexedOccurrence[];
14
+ hasResult: boolean;
15
+ }
16
+ export type ToolCallIndex = Map<string, ToolCallIndexEntry>;
17
+ export declare function hasMeaningfulPart(part: unknown): boolean;
18
+ export declare function extractToolCallObservation(part: unknown): ToolCallObservation | null;
19
+ export declare class ToolMutationBatch {
20
+ private partsToRemove;
21
+ private affectedMessages;
22
+ private messages;
23
+ constructor(messages: MessageLike[]);
24
+ markForRemoval(occurrence: IndexedOccurrence): void;
25
+ finalize(): void;
26
+ }
27
+ /**
28
+ * Build a TagTarget for a single tool composite key
29
+ * (`<ownerMsgId>\x00<callId>`).
30
+ *
31
+ * v3.3.1 Layer C: pre-fix this took a bare `callId`. Two assistant turns
32
+ * reusing the same callId produced two TagTargets that both pointed at
33
+ * the same `index.get(callId)` entry — last-write-wins on `targets.set`
34
+ * silently merged them into one drop target, and a queued drop on the
35
+ * older tag would mutate the newer turn's content. Composite keys
36
+ * guarantee one TagTarget per (owner, callId) pair, so each turn's tag
37
+ * gets its own independent drop scope.
38
+ *
39
+ * The `index` map is keyed by composite key as well — see
40
+ * `tag-messages.ts` for the matching producer.
41
+ */
42
+ export declare function createToolDropTarget(compositeKey: string, thinkingParts: ThinkingLikePart[], index: ToolCallIndex, batch: ToolMutationBatch): {
43
+ setContent: (content: string) => boolean;
44
+ drop: () => ToolDropResult;
45
+ truncate: () => ToolDropResult;
46
+ };
47
+ export {};
48
+ //# sourceMappingURL=tool-drop-target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-drop-target.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/tool-drop-target.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEpE,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE/E,UAAU,mBAAmB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC;CACjC;AAED,MAAM,WAAW,kBAAkB;IAC/B,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,SAAS,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AA8H5D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CASxD;AASD,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,GAAG,mBAAmB,GAAG,IAAI,CAepF;AAMD,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,QAAQ,CAAgB;gBAEpB,QAAQ,EAAE,WAAW,EAAE;IAInC,cAAc,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAKnD,QAAQ,IAAI,IAAI;CAgBnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAChC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,gBAAgB,EAAE,EACjC,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,iBAAiB,GACzB;IACC,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,IAAI,EAAE,MAAM,cAAc,CAAC;IAC3B,QAAQ,EAAE,MAAM,cAAc,CAAC;CAClC,CAmDA"}
@@ -0,0 +1,66 @@
1
+ import { type ContextDatabase } from "../../features/magic-context/storage";
2
+ import type { PluginContext } from "../../plugin/types";
3
+ import { type PreparedCompartmentInjection } from "./inject-compartments";
4
+ import type { MessageLike } from "./transform-operations";
5
+ export declare function clearCompressorCooldown(sessionId: string): void;
6
+ interface RunCompartmentPhaseArgs {
7
+ canRunCompartments: boolean;
8
+ fullFeatureMode: boolean;
9
+ /** False when historian.disable=true, blocking historian-backed child agents. */
10
+ historianRunnable?: boolean;
11
+ sessionMeta: {
12
+ compartmentInProgress: boolean;
13
+ };
14
+ contextUsage: {
15
+ percentage: number;
16
+ };
17
+ client?: PluginContext["client"];
18
+ db: ContextDatabase;
19
+ sessionId: string;
20
+ resolvedSessionId: string;
21
+ historianChunkTokens: number;
22
+ historyBudgetTokens?: number;
23
+ historianTimeoutMs?: number;
24
+ fallbackModels?: readonly string[];
25
+ compartmentDirectory: string;
26
+ messages: MessageLike[];
27
+ pendingCompartmentInjection: PreparedCompartmentInjection | null;
28
+ fallbackModelId?: string;
29
+ ensureProjectRegistered?: (directory: string, db: ContextDatabase) => Promise<void>;
30
+ projectPath?: string;
31
+ injectionBudgetTokens?: number;
32
+ getNotificationParams?: () => import("./send-session-notification").NotificationParams;
33
+ /** True when this pass is already safe for background compression to run. */
34
+ safeForBackgroundCompression?: boolean;
35
+ deferredHistoryRefreshSessions: Set<string>;
36
+ /** True when transform already triggered recovery/emergency historian work this pass. */
37
+ skipAwaitForThisPass?: boolean;
38
+ /** When true, extract user behavior observations from historian output */
39
+ experimentalUserMemories?: boolean;
40
+ /** When true, inject wall-clock dates on compartments in <session-history>. */
41
+ experimentalTemporalAwareness?: boolean;
42
+ /** When true, run a second editor pass after historian to clean U: lines. */
43
+ historianTwoPass?: boolean;
44
+ /** Compressor floor ratio: floor = ceil(lastEndMessage / minCompartmentRatio). */
45
+ compressorMinCompartmentRatio?: number;
46
+ /** Compressor max merge depth (1-5). Compartments at or above this depth are skipped. */
47
+ compressorMaxMergeDepth?: number;
48
+ /** Compressor cooldown in milliseconds between background runs. */
49
+ compressorCooldownMs?: number;
50
+ /** Cross-session memory feature gate (`memory.enabled`). Issue #44. */
51
+ memoryEnabled?: boolean;
52
+ /** Auto-promotion gate (`memory.auto_promote`). Issue #44. */
53
+ autoPromote?: boolean;
54
+ /** Forwarded to compartment runner — see CompartmentRunnerDeps.onCompartmentStatePublished. */
55
+ onCompartmentStatePublished?: (sessionId: string) => void;
56
+ }
57
+ export declare function runCompartmentPhase(args: RunCompartmentPhaseArgs): Promise<{
58
+ pendingCompartmentInjection: PreparedCompartmentInjection | null;
59
+ awaitedCompartmentRun: boolean;
60
+ compartmentInProgress: boolean;
61
+ published: boolean;
62
+ justAwaitedPublication: boolean;
63
+ rebuiltHistoryThisPass: boolean;
64
+ }>;
65
+ export {};
66
+ //# sourceMappingURL=transform-compartment-phase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-compartment-phase.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-compartment-phase.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,sCAAsC,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAYxD,OAAO,EACH,KAAK,4BAA4B,EAEpC,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAc1D,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE/D;AAED,UAAU,uBAAuB;IAC7B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,iFAAiF;IACjF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE;QAAE,qBAAqB,EAAE,OAAO,CAAA;KAAE,CAAC;IAChD,YAAY,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,EAAE,EAAE,eAAe,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,2BAA2B,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACjE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uBAAuB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,OAAO,6BAA6B,EAAE,kBAAkB,CAAC;IACvF,6EAA6E;IAC7E,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,8BAA8B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5C,yFAAyF;IACzF,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,0EAA0E;IAC1E,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,+EAA+E;IAC/E,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kFAAkF;IAClF,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,yFAAyF;IACzF,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,mEAAmE;IACnE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,uEAAuE;IACvE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+FAA+F;IAC/F,2BAA2B,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7D;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC;IAC9E,2BAA2B,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACjE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,sBAAsB,EAAE,OAAO,CAAC;IAChC,sBAAsB,EAAE,OAAO,CAAC;CACnC,CAAC,CA+TD"}
@@ -0,0 +1,12 @@
1
+ import type { Scheduler } from "../../features/magic-context/scheduler";
2
+ import type { ContextDatabase } from "../../features/magic-context/storage";
3
+ import type { ContextUsage, SessionMeta } from "../../features/magic-context/types";
4
+ type ContextUsageCacheEntry = {
5
+ usage: ContextUsage;
6
+ updatedAt: number;
7
+ lastResponseTime?: number;
8
+ };
9
+ export declare function loadContextUsage(contextUsageMap: Map<string, ContextUsageCacheEntry>, db: ContextDatabase, sessionId: string): ContextUsage;
10
+ export declare function resolveSchedulerDecision(scheduler: Scheduler, sessionMeta: SessionMeta, contextUsage: ContextUsage, sessionId: string, modelKey?: string): "execute" | "defer";
11
+ export {};
12
+ //# sourceMappingURL=transform-context-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-context-state.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-context-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGpF,KAAK,sBAAsB,GAAG;IAC1B,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAYF,wBAAgB,gBAAgB,CAC5B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,EACpD,EAAE,EAAE,eAAe,EACnB,SAAS,EAAE,MAAM,GAClB,YAAY,CAgCd;AAED,wBAAgB,wBAAwB,CACpC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,GAClB,SAAS,GAAG,OAAO,CAkBrB"}