@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,32 @@
1
+ /**
2
+ * Resolve the final fallback model list to attempt for an OpenCode subagent
3
+ * call.
4
+ *
5
+ * Policy (decided 2026-05-10):
6
+ * - If user configured explicit `fallback_models` in their magic-context.jsonc
7
+ * for this agent: use ONLY those. Respects user intent, no surprise
8
+ * providers.
9
+ * - If user did NOT configure any: fall back to the plugin's builtin
10
+ * provider-agnostic chain (`AGENT_MODEL_REQUIREMENTS`).
11
+ *
12
+ * The returned list does NOT include the primary model — it's the ordered
13
+ * list of *alternates* to try after the primary fails. Each entry is
14
+ * "provider/modelID" form.
15
+ *
16
+ * Duplicates and empty strings are filtered. Entries that don't match the
17
+ * "provider/modelID" shape (must contain a "/" with non-empty parts) are
18
+ * also dropped — defensive guard against malformed user config.
19
+ */
20
+ export declare function resolveFallbackChain(agentName: string, userFallbacks: readonly string[] | string | undefined): string[];
21
+ /**
22
+ * Parse a "provider/modelID" string into the OpenCode `model` object shape.
23
+ * Returns null on invalid input.
24
+ *
25
+ * Note: only splits on the FIRST "/" — modelID can legitimately contain slashes
26
+ * (e.g. `lemonade/GLM-4.7-Flash-GGUF/main`).
27
+ */
28
+ export declare function parseProviderModel(spec: string): {
29
+ providerID: string;
30
+ modelID: string;
31
+ } | null;
32
+ //# sourceMappingURL=resolve-fallbacks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-fallbacks.d.ts","sourceRoot":"","sources":["../../src/shared/resolve-fallbacks.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAChC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,GACtD,MAAM,EAAE,CAUV;AA2BD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAO/F"}
@@ -0,0 +1,17 @@
1
+ export declare class MagicContextRpcClient {
2
+ private port;
3
+ private portDir;
4
+ private legacyPortFilePath;
5
+ private healthChecked;
6
+ constructor(storageDir: string, directory: string);
7
+ /** Call an RPC method. Retries port resolution if the server isn't ready yet. */
8
+ call<T = Record<string, unknown>>(method: string, params?: Record<string, unknown>): Promise<T>;
9
+ /** Check if the RPC server is reachable. */
10
+ isAvailable(): Promise<boolean>;
11
+ private resolvePort;
12
+ private readPortFile;
13
+ private healthCheck;
14
+ private fetchWithTimeout;
15
+ reset(): void;
16
+ }
17
+ //# sourceMappingURL=rpc-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-client.ts"],"names":[],"mappings":"AAiBA,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,IAAI,CAAuB;IACnC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,aAAa,CAAS;gBAElB,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAKjD,iFAAiF;IAC3E,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,OAAO,CAAC,CAAC,CAAC;IAiDb,4CAA4C;IACtC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YASvB,WAAW;IAkCzB,OAAO,CAAC,YAAY;YA4BN,WAAW;YAWX,gBAAgB;IAU9B,KAAK,IAAI,IAAI;CAIhB"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * In-memory notification queue for server→TUI push.
3
+ * Replaces SQLite plugin_messages table.
4
+ *
5
+ * Also tracks whether a TUI client is actively connected (polling).
6
+ * The server plugin cannot use `process.env.OPENCODE_CLIENT` to detect TUI
7
+ * because the server runs in a separate process from the TUI client.
8
+ */
9
+ export interface RpcNotification {
10
+ id: number;
11
+ type: string;
12
+ payload: Record<string, unknown>;
13
+ sessionId?: string;
14
+ }
15
+ /** Push a notification for TUI to pick up via polling. */
16
+ export declare function pushNotification(type: string, payload: Record<string, unknown>, sessionId?: string): void;
17
+ /** Return pending notifications after acking the client's last received id.
18
+ * Updates lastDrainAt so isTuiConnected() reflects recent activity. */
19
+ export declare function drainNotifications(lastReceivedId?: number): RpcNotification[];
20
+ /** Whether a TUI client is actively polling for notifications.
21
+ * Returns true only if the TUI has drained within the last 3 seconds.
22
+ * This prevents stale-connected state after TUI closes or disconnects. */
23
+ export declare function isTuiConnected(): boolean;
24
+ //# sourceMappingURL=rpc-notifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-notifications.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAUD,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACnB,IAAI,CAMN;AAED;wEACwE;AACxE,wBAAgB,kBAAkB,CAAC,cAAc,SAAI,GAAG,eAAe,EAAE,CAMxE;AAED;;2EAE2E;AAC3E,wBAAgB,cAAc,IAAI,OAAO,CAExC"}
@@ -0,0 +1,20 @@
1
+ type RpcHandler = (params: Record<string, unknown>) => Promise<Record<string, unknown>>;
2
+ export declare class MagicContextRpcServer {
3
+ private server;
4
+ private port;
5
+ private handlers;
6
+ private portFilePath;
7
+ private portDir;
8
+ private startedAt;
9
+ constructor(storageDir: string, directory: string);
10
+ /** Register an RPC method handler. */
11
+ handle(method: string, handler: RpcHandler): void;
12
+ /** Start the server on a random port, write port to disk. */
13
+ start(): Promise<number>;
14
+ private warnIfOtherLiveInstance;
15
+ /** Stop the server and clean up port file. */
16
+ stop(): void;
17
+ private dispatch;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=rpc-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-server.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-server.ts"],"names":[],"mappings":"AAaA,KAAK,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAExF,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAc;gBAEnB,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAKjD,sCAAsC;IACtC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAIjD,6DAA6D;IACvD,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAkD9B,OAAO,CAAC,uBAAuB;IAgB/B,8CAA8C;IAC9C,IAAI,IAAI,IAAI;IAYZ,OAAO,CAAC,QAAQ;CA4DnB"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Shared types for RPC between server and TUI plugins.
3
+ * Both sides import these — no SQLite dependency.
4
+ */
5
+ export interface SidebarSnapshot {
6
+ sessionId: string;
7
+ usagePercentage: number;
8
+ inputTokens: number;
9
+ contextLimit: number;
10
+ systemPromptTokens: number;
11
+ compartmentCount: number;
12
+ factCount: number;
13
+ memoryCount: number;
14
+ memoryBlockCount: number;
15
+ pendingOpsCount: number;
16
+ historianRunning: boolean;
17
+ compartmentInProgress: boolean;
18
+ sessionNoteCount: number;
19
+ readySmartNoteCount: number;
20
+ cacheTtl: string;
21
+ lastDreamerRunAt: number | null;
22
+ projectIdentity: string | null;
23
+ compartmentTokens: number;
24
+ factTokens: number;
25
+ memoryTokens: number;
26
+ /**
27
+ * Token estimate of real user/assistant discussion (text + reasoning +
28
+ * image parts) inside messages, excluding injected <session-history>
29
+ * blocks. Display layer shows this as "Conversation".
30
+ */
31
+ conversationTokens: number;
32
+ /**
33
+ * Token estimate of tool call I/O inside messages (tool_use, tool_result,
34
+ * tool, tool-invocation parts). Actionable — users can reduce via
35
+ * ctx_reduce. Display layer shows this as "Tool Calls".
36
+ */
37
+ toolCallTokens: number;
38
+ /**
39
+ * Measured token cost of tool schemas (description + JSON-schema
40
+ * parameters) OpenCode sends in the request `tools` parameter. Populated
41
+ * by the `tool.definition` plugin hook, keyed by
42
+ * `{providerID, modelID, agentName}`. Zero until the first turn after
43
+ * plugin startup measures the current agent's tool set. Display layer
44
+ * shows this as "Tool Definitions".
45
+ */
46
+ toolDefinitionTokens: number;
47
+ /**
48
+ * Effective execute-threshold percentage for this session's active model,
49
+ * after per-model resolution and the tokens→percentage conversion (when
50
+ * `execute_threshold_tokens` applies). Surfaces in the sidebar / status
51
+ * dialog header alongside `usagePercentage` so users can see how close
52
+ * the session is to triggering compaction. Defaults to `65` when no live
53
+ * model is known yet — matches the runtime fallback used by the
54
+ * scheduler and transform paths.
55
+ */
56
+ executeThreshold: number;
57
+ newWorkTokens?: number | null;
58
+ totalInputTokens?: number | null;
59
+ }
60
+ export interface StatusDetail extends SidebarSnapshot {
61
+ tagCounter: number;
62
+ activeTags: number;
63
+ droppedTags: number;
64
+ totalTags: number;
65
+ activeBytes: number;
66
+ lastResponseTime: number;
67
+ lastNudgeTokens: number;
68
+ lastNudgeBand: string;
69
+ lastTransformError: string | null;
70
+ isSubagent: boolean;
71
+ pendingOps: Array<{
72
+ tagId: number;
73
+ operation: string;
74
+ }>;
75
+ contextLimit: number;
76
+ cacheTtlMs: number;
77
+ cacheRemainingMs: number;
78
+ cacheExpired: boolean;
79
+ executeThreshold: number;
80
+ /**
81
+ * Which config source produced `executeThreshold`. "tokens" means
82
+ * execute_threshold_tokens matched for this session's model and was
83
+ * converted to a percentage. "percentage" means percentage config was used.
84
+ */
85
+ executeThresholdMode: "percentage" | "tokens";
86
+ /**
87
+ * When `executeThresholdMode === "tokens"`, the absolute clamped token value
88
+ * (≤ 80% × contextLimit) that will trigger execute. Undefined in percentage mode.
89
+ */
90
+ executeThresholdTokens?: number;
91
+ protectedTagCount: number;
92
+ nudgeInterval: number;
93
+ historyBudgetPercentage: number;
94
+ nextNudgeAfter: number;
95
+ historyBlockTokens: number;
96
+ compressionBudget: number | null;
97
+ compressionUsage: string | null;
98
+ }
99
+ export interface RpcNotificationMessage {
100
+ id: number;
101
+ type: string;
102
+ payload: Record<string, unknown>;
103
+ sessionId?: string;
104
+ }
105
+ //# sourceMappingURL=rpc-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-types.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;;;;;;OAQG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,YAAa,SAAQ,eAAe;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,oBAAoB,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC9C;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,EAAE,MAAM,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,sBAAsB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,19 @@
1
+ export interface RpcPortFileRecord {
2
+ port: number;
3
+ pid: number;
4
+ started_at: number;
5
+ }
6
+ /**
7
+ * Stable hash for a project directory — scopes RPC port files per-project
8
+ * so multiple OpenCode instances don't collide.
9
+ */
10
+ export declare function projectHash(directory: string): string;
11
+ /** Directory containing per-process RPC discovery files for a project. */
12
+ export declare function rpcPortDir(storageDir: string, directory: string): string;
13
+ /** Per-process RPC port file path. */
14
+ export declare function rpcPortFilePath(storageDir: string, directory: string, pid?: number): string;
15
+ /** Legacy single-port file used by v0.18.0 and earlier. */
16
+ export declare function legacyRpcPortFilePath(storageDir: string, directory: string): string;
17
+ export declare function isPidAlive(pid: number): boolean;
18
+ export declare function parseRpcPortFile(content: string, fallbackPid?: number): RpcPortFileRecord | null;
19
+ //# sourceMappingURL=rpc-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-utils.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-utils.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,sCAAsC;AACtC,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAc,GAAG,MAAM,CAEhG;AAED,2DAA2D;AAC3D,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnF;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQ/C;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,SAAI,GAAG,iBAAiB,GAAG,IAAI,CAwB3F"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Cross-runtime helpers that smooth over the small bun:sqlite ↔ better-sqlite3
3
+ * API differences without leaking either library into call sites.
4
+ */
5
+ import type { Database } from "./sqlite";
6
+ /**
7
+ * Close a database, ignoring errors.
8
+ *
9
+ * bun:sqlite supports `db.close(throwOnError = false)`. better-sqlite3 has
10
+ * only `db.close()` and throws on already-closed databases. This helper
11
+ * mirrors the bun "swallow errors" semantics for both runtimes — useful in
12
+ * test teardown and `finally` blocks where the caller doesn't care whether
13
+ * the close succeeded.
14
+ */
15
+ export declare function closeQuietly(db: Database | null | undefined): void;
16
+ //# sourceMappingURL=sqlite-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-helpers.d.ts","sourceRoot":"","sources":["../../src/shared/sqlite-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAUlE"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * SQLite chokepoint — runtime-detected backend selection.
3
+ *
4
+ * The same shipped plugin artifact must run under two different runtimes:
5
+ * - Bun (current OpenCode releases) → uses `bun:sqlite` (built-in, fast)
6
+ * - Node (OpenCode beta + future Pi plugin) → uses `better-sqlite3`
7
+ *
8
+ * Bun cannot load `better-sqlite3` (oven-sh/bun#4290), and Node has no
9
+ * `bun:sqlite` module. Static imports of either would crash at parse time
10
+ * in the wrong runtime, so we use dynamic imports gated by runtime detection.
11
+ *
12
+ * The Function-constructor wrapper around `import()` defeats bundler static
13
+ * analysis — without it, esbuild/bun build would try to resolve both modules
14
+ * during the bundle step, including the one that doesn't exist in the build
15
+ * runtime.
16
+ *
17
+ * Both libraries expose ~95% API parity:
18
+ * - new Database(path, { readonly?: boolean })
19
+ * - db.prepare(sql).run/get/all
20
+ * - db.exec(multistatement)
21
+ * - db.transaction(fn) → wrapped function
22
+ * - db.close()
23
+ *
24
+ * The 5% that differs (db.query, db.run, db.close(boolean), Database.open)
25
+ * is either rewritten to common-subset patterns or hidden behind the helpers
26
+ * in `./sqlite-helpers.ts`.
27
+ */
28
+ import type BetterSqlite3 from "better-sqlite3";
29
+ export declare const Database: typeof BetterSqlite3;
30
+ /** Instance type alias used by helpers and storage modules. */
31
+ export type Database = BetterSqlite3.Database;
32
+ /**
33
+ * Statement instance type used for WeakMap caches throughout the codebase.
34
+ *
35
+ * We deliberately use the variadic Statement<unknown[], unknown> shape rather
36
+ * than `ReturnType<Database["prepare"]>` because the latter resolves through
37
+ * a conditional return type in @types/better-sqlite3 that confuses TypeScript
38
+ * about how many arguments .run/.get/.all accept. With this explicit type,
39
+ * cached statements accept any number of bind args (matching bun:sqlite's
40
+ * historical behavior in this codebase).
41
+ */
42
+ export type Statement = BetterSqlite3.Statement<unknown[], unknown>;
43
+ //# sourceMappingURL=sqlite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/shared/sqlite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH,OAAO,KAAK,aAAa,MAAM,gBAAgB,CAAC;AAsFhD,eAAO,MAAM,QAAQ,EAAE,OAAO,aAA4B,CAAC;AAE3D,+DAA+D;AAC/D,MAAM,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Process-local deterministic JSON serialization for JSON-like plain
3
+ * objects. Keys are sorted by code-point order (NOT locale-sensitive).
4
+ *
5
+ * Contract:
6
+ * - Stable for plain objects, arrays, primitives, and `null`.
7
+ * - `undefined` serialized as the string "undefined".
8
+ * - Circular references serialized as the string `"[Circular]"`.
9
+ * - **NOT** a canonical cross-runtime / cross-locale JSON serializer.
10
+ * Two different runtimes that disagree on `JSON.stringify` of primitives
11
+ * (none known today) would produce different output.
12
+ *
13
+ * Used for:
14
+ * - `tool_definition_measurements` fingerprint hashing
15
+ * - `pending_compaction_marker_state` CAS comparison
16
+ *
17
+ * If a future use case needs true canonical JSON (e.g. cross-process
18
+ * signing), build a separate utility — do NOT widen this contract.
19
+ */
20
+ export declare function stableStringify(value: unknown, seen?: WeakSet<object>): string;
21
+ //# sourceMappingURL=stable-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stable-json.d.ts","sourceRoot":"","sources":["../../src/shared/stable-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,kBAAwB,GAAG,MAAM,CAiBpF"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Cross-harness subagent runner abstraction.
3
+ *
4
+ * Magic Context spawns three kinds of subagents — historian, dreamer, sidekick —
5
+ * each as a child "session" with its own model/prompt/tools. OpenCode and Pi
6
+ * have very different APIs for this:
7
+ *
8
+ * - OpenCode: `client.session.create({parentID}) → client.session.prompt() →
9
+ * client.session.messages() → client.session.delete()`. The plugin runs
10
+ * in-process with the OpenCode server and uses its SDK client directly.
11
+ *
12
+ * - Pi: no in-process child-session API. Instead `pi --print --mode=json`
13
+ * spawns a non-interactive subprocess that emits structured JSON events
14
+ * and exits when the agent loop finishes. Sessions are JSONL files on
15
+ * disk, optionally addressed via `--session <path>`.
16
+ *
17
+ * The runner interface below normalizes both into the same shape so the
18
+ * actual subagent business logic (historian XML parsing, dreamer task loop,
19
+ * sidekick augmentation) can stay harness-agnostic. Each harness ships its
20
+ * own runner implementation; agents take a `SubagentRunner` as a dep instead
21
+ * of reaching for `client.session.*` directly.
22
+ *
23
+ * Step 5a (this commit) defines the contract and ships `PiSubagentRunner`.
24
+ * Step 5b will refactor the OpenCode-side spawn paths in
25
+ * `compartment-runner-historian.ts`, `dreamer/runner.ts`, and
26
+ * `sidekick/agent.ts` onto an `OpenCodeSubagentRunner` so both harnesses
27
+ * share the agent business logic instead of duplicating it. Until 5b lands,
28
+ * OpenCode keeps its existing direct `client.session.*` calls untouched —
29
+ * the runner contract is purely additive on the OpenCode side.
30
+ */
31
+ /**
32
+ * Configuration for one subagent invocation.
33
+ *
34
+ * Mirrors the union of OpenCode's `session.create` + `session.prompt` body
35
+ * fields and Pi's `--print` CLI flags, picking the shared subset that all
36
+ * three subagent kinds (historian, dreamer, sidekick) actually use today.
37
+ *
38
+ * Fields:
39
+ * - `agent`: harness-specific agent name. OpenCode looks this up in its
40
+ * agent registry (`HISTORIAN_AGENT`, `DREAMER_AGENT`, `SIDEKICK_AGENT`).
41
+ * Pi has no concept of "agent name" beyond config, so this is ignored
42
+ * on the Pi side and used only by `OpenCodeSubagentRunner`.
43
+ * - `systemPrompt`: full system prompt for this child run. Replaces (not
44
+ * appends to) any harness-default system prompt.
45
+ * - `userMessage`: the single user-turn prompt. Subagent runs are always
46
+ * one-shot — no multi-turn conversation in the child.
47
+ * - `model`: provider/model identifier in the canonical "provider/model"
48
+ * shape (e.g. "anthropic/claude-sonnet-4-7"). Each runner is responsible
49
+ * for translating to its harness's native model selection.
50
+ * - `fallbackModels`: ordered list of models to try if `model` fails. Both
51
+ * harnesses retry on transient model failures.
52
+ * - `timeoutMs`: hard cap on the child run. The runner aborts the child on
53
+ * exceeding this and returns `{ ok: false, reason: "timeout" }`.
54
+ * - `cwd`: working directory for the child. OpenCode uses this for
55
+ * `query.directory`; Pi uses it as the spawn cwd so that `--cwd`-aware
56
+ * tools see the right project root.
57
+ * - `signal`: optional AbortSignal so callers can cancel an in-flight run
58
+ * (used by dreamer's lease-renewal-aborts-on-loss path).
59
+ */
60
+ export interface SubagentRunOptions {
61
+ agent: string;
62
+ systemPrompt: string;
63
+ userMessage: string;
64
+ model?: string | undefined;
65
+ fallbackModels?: readonly string[];
66
+ timeoutMs?: number | undefined;
67
+ cwd?: string | undefined;
68
+ signal?: AbortSignal | undefined;
69
+ /**
70
+ * Pi only: explicit thinking level, passed as `--thinking <level>` to the
71
+ * Pi subprocess. OpenCode ignores this field — thinking/reasoning is
72
+ * controlled via `variant` in the OpenCode agent config instead.
73
+ *
74
+ * Required when the configured historian/dreamer model supports reasoning
75
+ * (e.g. github-copilot/gpt-5.4) because Pi's own default resolution may
76
+ * pick a value the provider rejects. Set to "off" to disable thinking for
77
+ * speed (local models), or "medium"/"high" for better quality.
78
+ */
79
+ thinkingLevel?: string | undefined;
80
+ /**
81
+ * Optional progress callback. The runner invokes it for milestone events
82
+ * during the run: spawn, first event received, terminal stop reason
83
+ * detected, child exit. Used by historian/dreamer/sidekick to write
84
+ * lifecycle entries to the magic-context.log without polluting the
85
+ * normal stdout stream.
86
+ *
87
+ * Implementations must be non-throwing and fast — they're called on the
88
+ * runner's hot path. Errors are swallowed.
89
+ */
90
+ onProgress?: (event: SubagentProgressEvent) => void;
91
+ /** Optional token accounting metadata. When present, harness runners persist subagent_invocations. */
92
+ accountingSessionId?: string | undefined;
93
+ accountingSubagent?: "historian" | "historian_editor" | "compressor" | "dreamer" | "sidekick" | "user_memory_review" | "recomp" | undefined;
94
+ accountingTask?: string | null | undefined;
95
+ accountingParentInvocationId?: number | null | undefined;
96
+ }
97
+ /**
98
+ * Progress events emitted by a runner during a run. Distinct from the final
99
+ * `SubagentRunResult` — these are mid-run milestones plus (optionally) every
100
+ * raw event the underlying harness emits, so callers can write a complete
101
+ * trace to the log when diagnosing hangs.
102
+ *
103
+ * Categories:
104
+ * - `spawned` / `child_exit` / `stderr` — process lifecycle.
105
+ * - `first_event` — convenience: first event received from the child, useful
106
+ * for measuring auth/network warmup time.
107
+ * - `terminal` — runner detected the final assistant turn (Pi: assistant
108
+ * message_end with terminal stopReason and no toolCall; OpenCode: SDK
109
+ * `agent_end` equivalent).
110
+ * - `raw_event` — every parsed event from the harness's structured output
111
+ * stream (Pi NDJSON / OpenCode SDK events). Emitted unconditionally so
112
+ * debug logs can capture the full timeline. The `event` payload is
113
+ * harness-shaped — callers should treat it as `unknown` and log it raw.
114
+ */
115
+ export type SubagentProgressEvent = {
116
+ type: "spawned";
117
+ argv: readonly string[];
118
+ pid: number | undefined;
119
+ } | {
120
+ type: "first_event";
121
+ eventType: string;
122
+ ms: number;
123
+ } | {
124
+ type: "raw_event";
125
+ eventType: string | undefined;
126
+ event: unknown;
127
+ ms: number;
128
+ } | {
129
+ type: "terminal";
130
+ stopReason: string | undefined;
131
+ textLength: number;
132
+ hasToolCall: boolean;
133
+ ms: number;
134
+ } | {
135
+ type: "stderr";
136
+ chunk: string;
137
+ } | {
138
+ type: "child_exit";
139
+ code: number | null;
140
+ signal: string | null;
141
+ ms: number;
142
+ };
143
+ /**
144
+ * Result of one subagent invocation.
145
+ *
146
+ * The runner contract is "fail soft": transient errors, timeouts, model
147
+ * failures, and aborts all surface as `{ ok: false, reason }` with a
148
+ * machine-readable reason and a human-readable message. Throwing is
149
+ * reserved for programmer errors (bad arguments, missing dependencies)
150
+ * that the agent code couldn't have caused.
151
+ *
152
+ * Fields:
153
+ * - `ok`: true iff the child produced a final assistant message.
154
+ * - `assistantText`: concatenated text content from the final assistant
155
+ * message, with leading/trailing whitespace trimmed. Empty string if the
156
+ * child finished but produced no text (rare — usually means the model
157
+ * only emitted tool calls and we didn't follow up).
158
+ * - `reason`: failure category, one of:
159
+ * - `"timeout"`: hit `timeoutMs` before the child finished
160
+ * - `"abort"`: caller's `signal` was triggered
161
+ * - `"model_failed"`: every configured model + fallback returned an error
162
+ * - `"truncated"`: child stopped because model output hit length limits
163
+ * - `"spawn_failed"`: subprocess couldn't start (Pi only — binary missing,
164
+ * permission denied, etc.)
165
+ * - `"non_zero_exit"`: child exited unsuccessfully before a final answer
166
+ * - `"no_assistant"`: child completed without a final assistant message
167
+ * - `"parse_failed"`: child emitted output we couldn't parse (Pi only —
168
+ * JSON malformed or unexpected event ordering)
169
+ * - `error`: human-readable detail; safe to log, may include stack info.
170
+ * - `durationMs`: wall-clock time from runner-call to runner-return.
171
+ * - `meta`: optional harness-specific debug payload. Currently unused; left
172
+ * here so the OpenCode runner can surface the child session ID for log
173
+ * correlation when Step 5b lands.
174
+ */
175
+ export type SubagentRunResult = {
176
+ ok: true;
177
+ assistantText: string;
178
+ durationMs: number;
179
+ meta?: Record<string, unknown>;
180
+ } | {
181
+ ok: false;
182
+ reason: "timeout" | "abort" | "model_failed" | "truncated" | "spawn_failed" | "non_zero_exit" | "no_assistant" | "parse_failed";
183
+ error: string;
184
+ durationMs: number;
185
+ meta?: Record<string, unknown>;
186
+ };
187
+ /**
188
+ * Abstract runner contract.
189
+ *
190
+ * Each harness ships a single instance — the OpenCode plugin wires
191
+ * `OpenCodeSubagentRunner` and the Pi plugin wires `PiSubagentRunner` in
192
+ * its `extension` boot path. Agent code (historian, dreamer, sidekick)
193
+ * receives the runner as a dep and never reaches for harness-specific
194
+ * client APIs directly.
195
+ */
196
+ export interface SubagentRunner {
197
+ /** Human-readable harness name, for logging (`"opencode"` or `"pi"`). */
198
+ readonly harness: string;
199
+ /**
200
+ * Run one subagent invocation to completion.
201
+ *
202
+ * Always resolves with a `SubagentRunResult` — never throws for
203
+ * runtime/transport/model failures. Throwing is reserved for caller
204
+ * misuse (e.g. missing required option fields).
205
+ */
206
+ run(options: SubagentRunOptions): Promise<SubagentRunResult>;
207
+ }
208
+ //# sourceMappingURL=subagent-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent-runner.d.ts","sourceRoot":"","sources":["../../src/shared/subagent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,kBAAkB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAEpD,sGAAsG;IACtG,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,kBAAkB,CAAC,EACb,WAAW,GACX,kBAAkB,GAClB,YAAY,GACZ,SAAS,GACT,UAAU,GACV,oBAAoB,GACpB,QAAQ,GACR,SAAS,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,4BAA4B,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAC5D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,qBAAqB,GAC3B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACrE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACtD;IACI,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;CACd,GACD;IACI,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;CACd,GACD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,iBAAiB,GACvB;IACI,EAAE,EAAE,IAAI,CAAC;IACT,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,GACD;IACI,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EACA,SAAS,GACT,OAAO,GACP,cAAc,GACd,WAAW,GACX,cAAc,GACd,eAAe,GACf,cAAc,GACd,cAAc,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAER;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;;;;;OAMG;IACH,GAAG,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAChE"}
@@ -0,0 +1,3 @@
1
+ export declare function isSystemDirective(text: string): boolean;
2
+ export declare function removeSystemReminders(text: string): string;
3
+ //# sourceMappingURL=system-directive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-directive.d.ts","sourceRoot":"","sources":["../../src/shared/system-directive.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Harness-agnostic tagging over the Transcript interface.
3
+ *
4
+ * This is a deliberately minimal alternative to the OpenCode-specific
5
+ * `tag-messages.ts` that operates on `MessageLike[]`. The OpenCode flow
6
+ * carries 380+ lines of accumulated complexity:
7
+ *
8
+ * - source-content persistence (for cross-pass detag/restore behavior),
9
+ * - tool-call indexing across separate "tool" and "tool_result" parts,
10
+ * - reasoning-byte tracking for historian projection,
11
+ * - file-part stable IDs,
12
+ * - existing-tag resolver with content-id fallback.
13
+ *
14
+ * Most of that is OpenCode-specific (cache stability across multi-pass
15
+ * transforms, AI SDK part-id semantics, file part shapes). Pi's
16
+ * `pi.on("context", ...)` fires once per LLM call with a complete
17
+ * `AgentMessage[]`, so we can use a simpler tagging contract:
18
+ *
19
+ * 1. Walk the transcript in order.
20
+ * 2. For each tag-eligible part (text, tool_use, tool_result), assign
21
+ * a tag number via the shared `Tagger`.
22
+ * 3. Inject `§N§ ` prefix into the visible text (unless skipped).
23
+ * 4. Build a `TagTarget` so `applyPendingOperations` from
24
+ * `apply-operations.ts` can replace this part with a sentinel when
25
+ * a queued drop fires.
26
+ *
27
+ * Tool drops aggregate by call_id across both invocation and result
28
+ * occurrences (mirrors OpenCode tag-messages.ts:196-220). When a drop
29
+ * fires for a tool tag, BOTH the assistant `toolCall`/`tool_use` part
30
+ * and the user `toolResult`/`tool_result` part are mutated together so
31
+ * the LLM sees consistent dropped state. Without this aggregation:
32
+ *
33
+ * - Tool tag byte_size reflects only the args (~58 bytes for a `read`)
34
+ * because the FIRST occurrence (invocation) is tagged first and
35
+ * `assignTag` short-circuits the SECOND occurrence (result, ~4KB)
36
+ * to the same tag without updating byte_size.
37
+ * - Drops touch only the second occurrence (last write wins on
38
+ * `targets.set`), leaving the first in original form.
39
+ *
40
+ * Reuses unchanged from the OpenCode path:
41
+ *
42
+ * - `Tagger` (DB-backed counter + assignment store).
43
+ * - `applyPendingOperations` (operates on `Map<number, TagTarget>`).
44
+ * - `applyFlushedStatuses` (same).
45
+ * - Tag prefix primitives (`prependTag`, `stripTagPrefix`, `byteSize`).
46
+ */
47
+ import type { ContextDatabase } from "../features/magic-context/storage";
48
+ import type { Tagger } from "../features/magic-context/tagger";
49
+ import type { TagTarget } from "../hooks/magic-context/tag-messages";
50
+ import type { Transcript } from "./transcript";
51
+ export interface TagTranscriptOptions {
52
+ /**
53
+ * When true, skip injecting `§N§` prefix into visible text. Tags
54
+ * still get assigned in the DB so historian/drops can reference
55
+ * them; the agent just doesn't see the markers. Used when
56
+ * `ctx_reduce_enabled: false` (agent has no `ctx_reduce` tool to
57
+ * act on the markers). Cache-safe because skip behavior is
58
+ * consistent across passes.
59
+ */
60
+ skipPrefixInjection?: boolean;
61
+ }
62
+ export interface TagTranscriptResult {
63
+ targets: Map<number, TagTarget>;
64
+ }
65
+ export declare function tagTranscript(sessionId: string, transcript: Transcript, tagger: Tagger, db: ContextDatabase, options?: TagTranscriptOptions): TagTranscriptResult;
66
+ //# sourceMappingURL=tag-transcript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-transcript.d.ts","sourceRoot":"","sources":["../../src/shared/tag-transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAM/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACjC;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnC;AAyDD,wBAAgB,aAAa,CACzB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,eAAe,EACnB,OAAO,GAAE,oBAAyB,GACnC,mBAAmB,CAqKrB"}