mu-harness 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (478) hide show
  1. package/README.md +47 -0
  2. package/dist/index.d.ts +1673 -0
  3. package/dist/index.js +6596 -0
  4. package/package.json +20 -20
  5. package/esm/_dnt.polyfills.d.ts +0 -11
  6. package/esm/_dnt.polyfills.js +0 -15
  7. package/esm/agents/index.d.ts +0 -4
  8. package/esm/agents/index.js +0 -3
  9. package/esm/agents/loader.d.ts +0 -2
  10. package/esm/agents/loader.js +0 -24
  11. package/esm/agents/parser.d.ts +0 -2
  12. package/esm/agents/parser.js +0 -46
  13. package/esm/agents/registry.d.ts +0 -11
  14. package/esm/agents/registry.js +0 -102
  15. package/esm/agents/types.d.ts +0 -12
  16. package/esm/agents/types.js +0 -1
  17. package/esm/channels/adapter.d.ts +0 -26
  18. package/esm/channels/adapter.js +0 -27
  19. package/esm/channels/channel.d.ts +0 -7
  20. package/esm/channels/channel.js +0 -32
  21. package/esm/channels/index.d.ts +0 -5
  22. package/esm/channels/index.js +0 -4
  23. package/esm/channels/manager.d.ts +0 -6
  24. package/esm/channels/manager.js +0 -28
  25. package/esm/channels/types.d.ts +0 -32
  26. package/esm/channels/types.js +0 -1
  27. package/esm/channels/ws/client.d.ts +0 -24
  28. package/esm/channels/ws/client.js +0 -330
  29. package/esm/channels/ws/index.d.ts +0 -6
  30. package/esm/channels/ws/index.js +0 -6
  31. package/esm/channels/ws/protocol.d.ts +0 -251
  32. package/esm/channels/ws/protocol.js +0 -118
  33. package/esm/channels/ws/server.d.ts +0 -25
  34. package/esm/channels/ws/server.js +0 -348
  35. package/esm/channels/ws/session-service.d.ts +0 -36
  36. package/esm/channels/ws/session-service.js +0 -55
  37. package/esm/channels/ws/sub-agent.d.ts +0 -8
  38. package/esm/channels/ws/sub-agent.js +0 -72
  39. package/esm/channels/ws/wire-events.d.ts +0 -3
  40. package/esm/channels/ws/wire-events.js +0 -38
  41. package/esm/channels/ws/wire.d.ts +0 -45
  42. package/esm/channels/ws/wire.js +0 -67
  43. package/esm/channels/ws/ws-client.d.ts +0 -13
  44. package/esm/channels/ws/ws-client.js +0 -55
  45. package/esm/commands/defaults.d.ts +0 -20
  46. package/esm/commands/defaults.js +0 -219
  47. package/esm/commands/index.d.ts +0 -4
  48. package/esm/commands/index.js +0 -3
  49. package/esm/commands/registry.d.ts +0 -2
  50. package/esm/commands/registry.js +0 -59
  51. package/esm/commands/skill.d.ts +0 -7
  52. package/esm/commands/skill.js +0 -16
  53. package/esm/commands/types.d.ts +0 -26
  54. package/esm/commands/types.js +0 -1
  55. package/esm/common/frontmatter.d.ts +0 -6
  56. package/esm/common/frontmatter.js +0 -18
  57. package/esm/common/index.d.ts +0 -2
  58. package/esm/common/index.js +0 -2
  59. package/esm/common/utils.d.ts +0 -6
  60. package/esm/common/utils.js +0 -21
  61. package/esm/config/index.d.ts +0 -2
  62. package/esm/config/index.js +0 -1
  63. package/esm/config/resolve.d.ts +0 -2
  64. package/esm/config/resolve.js +0 -10
  65. package/esm/config/types.d.ts +0 -15
  66. package/esm/config/types.js +0 -1
  67. package/esm/deps/jsr.io/@std/yaml/1.1.0/_chars.d.ts +0 -32
  68. package/esm/deps/jsr.io/@std/yaml/1.1.0/_chars.js +0 -48
  69. package/esm/deps/jsr.io/@std/yaml/1.1.0/_dumper_state.d.ts +0 -105
  70. package/esm/deps/jsr.io/@std/yaml/1.1.0/_dumper_state.js +0 -638
  71. package/esm/deps/jsr.io/@std/yaml/1.1.0/_loader_state.d.ts +0 -63
  72. package/esm/deps/jsr.io/@std/yaml/1.1.0/_loader_state.js +0 -1371
  73. package/esm/deps/jsr.io/@std/yaml/1.1.0/_schema.d.ts +0 -43
  74. package/esm/deps/jsr.io/@std/yaml/1.1.0/_schema.js +0 -117
  75. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/binary.d.ts +0 -2
  76. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/binary.js +0 -103
  77. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/bool.d.ts +0 -2
  78. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/bool.js +0 -32
  79. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/float.d.ts +0 -2
  80. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/float.js +0 -96
  81. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/int.d.ts +0 -2
  82. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/int.js +0 -159
  83. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/map.d.ts +0 -2
  84. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/map.js +0 -14
  85. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/merge.d.ts +0 -2
  86. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/merge.js +0 -10
  87. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/nil.d.ts +0 -2
  88. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/nil.js +0 -22
  89. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/omap.d.ts +0 -2
  90. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/omap.js +0 -29
  91. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/pairs.d.ts +0 -2
  92. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/pairs.js +0 -19
  93. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/regexp.d.ts +0 -2
  94. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/regexp.js +0 -30
  95. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/seq.d.ts +0 -2
  96. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/seq.js +0 -10
  97. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/set.d.ts +0 -2
  98. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/set.js +0 -14
  99. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/str.d.ts +0 -2
  100. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/str.js +0 -9
  101. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/timestamp.d.ts +0 -2
  102. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/timestamp.js +0 -81
  103. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/undefined.d.ts +0 -2
  104. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/undefined.js +0 -20
  105. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type.d.ts +0 -31
  106. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type.js +0 -6
  107. package/esm/deps/jsr.io/@std/yaml/1.1.0/_utils.d.ts +0 -3
  108. package/esm/deps/jsr.io/@std/yaml/1.1.0/_utils.js +0 -13
  109. package/esm/deps/jsr.io/@std/yaml/1.1.0/mod.d.ts +0 -49
  110. package/esm/deps/jsr.io/@std/yaml/1.1.0/mod.js +0 -52
  111. package/esm/deps/jsr.io/@std/yaml/1.1.0/parse.d.ts +0 -75
  112. package/esm/deps/jsr.io/@std/yaml/1.1.0/parse.js +0 -91
  113. package/esm/deps/jsr.io/@std/yaml/1.1.0/stringify.d.ts +0 -99
  114. package/esm/deps/jsr.io/@std/yaml/1.1.0/stringify.js +0 -33
  115. package/esm/harness/compaction.d.ts +0 -14
  116. package/esm/harness/compaction.js +0 -21
  117. package/esm/harness/create.d.ts +0 -2
  118. package/esm/harness/create.js +0 -287
  119. package/esm/harness/environment.d.ts +0 -10
  120. package/esm/harness/environment.js +0 -14
  121. package/esm/harness/index.d.ts +0 -6
  122. package/esm/harness/index.js +0 -5
  123. package/esm/harness/instructions.d.ts +0 -17
  124. package/esm/harness/instructions.js +0 -78
  125. package/esm/harness/memory.d.ts +0 -18
  126. package/esm/harness/memory.js +0 -59
  127. package/esm/harness/models.d.ts +0 -18
  128. package/esm/harness/models.js +0 -34
  129. package/esm/harness/types.d.ts +0 -54
  130. package/esm/harness/types.js +0 -1
  131. package/esm/hooks/index.d.ts +0 -3
  132. package/esm/hooks/index.js +0 -2
  133. package/esm/hooks/merge-hooks.d.ts +0 -2
  134. package/esm/hooks/merge-hooks.js +0 -52
  135. package/esm/hooks/types.d.ts +0 -33
  136. package/esm/hooks/types.js +0 -1
  137. package/esm/hooks/with-hooks.d.ts +0 -3
  138. package/esm/hooks/with-hooks.js +0 -12
  139. package/esm/index.d.ts +0 -15
  140. package/esm/index.js +0 -15
  141. package/esm/package.json +0 -3
  142. package/esm/permissions/allow-list.d.ts +0 -4
  143. package/esm/permissions/allow-list.js +0 -8
  144. package/esm/permissions/approval-manager.d.ts +0 -31
  145. package/esm/permissions/approval-manager.js +0 -55
  146. package/esm/permissions/approval.d.ts +0 -17
  147. package/esm/permissions/approval.js +0 -13
  148. package/esm/permissions/glob.d.ts +0 -1
  149. package/esm/permissions/glob.js +0 -2
  150. package/esm/permissions/index.d.ts +0 -4
  151. package/esm/permissions/index.js +0 -4
  152. package/esm/plugin/define.d.ts +0 -2
  153. package/esm/plugin/define.js +0 -1
  154. package/esm/plugin/import-ts.d.ts +0 -1
  155. package/esm/plugin/import-ts.js +0 -85
  156. package/esm/plugin/index.d.ts +0 -5
  157. package/esm/plugin/index.js +0 -4
  158. package/esm/plugin/resolve.d.ts +0 -13
  159. package/esm/plugin/resolve.js +0 -17
  160. package/esm/plugin/store.d.ts +0 -8
  161. package/esm/plugin/store.js +0 -26
  162. package/esm/plugin/types.d.ts +0 -11
  163. package/esm/plugin/types.js +0 -1
  164. package/esm/scheduler/command.d.ts +0 -3
  165. package/esm/scheduler/command.js +0 -19
  166. package/esm/scheduler/engine/index.d.ts +0 -4
  167. package/esm/scheduler/engine/index.js +0 -3
  168. package/esm/scheduler/engine/memory-store.d.ts +0 -2
  169. package/esm/scheduler/engine/memory-store.js +0 -23
  170. package/esm/scheduler/engine/scheduler.d.ts +0 -13
  171. package/esm/scheduler/engine/scheduler.js +0 -73
  172. package/esm/scheduler/engine/store.d.ts +0 -4
  173. package/esm/scheduler/engine/store.js +0 -55
  174. package/esm/scheduler/engine/types.d.ts +0 -55
  175. package/esm/scheduler/engine/types.js +0 -1
  176. package/esm/scheduler/index.d.ts +0 -4
  177. package/esm/scheduler/index.js +0 -3
  178. package/esm/scheduler/tool.d.ts +0 -8
  179. package/esm/scheduler/tool.js +0 -48
  180. package/esm/session/agent-session.d.ts +0 -15
  181. package/esm/session/agent-session.js +0 -159
  182. package/esm/session/catalog.d.ts +0 -24
  183. package/esm/session/catalog.js +0 -55
  184. package/esm/session/index.d.ts +0 -7
  185. package/esm/session/index.js +0 -6
  186. package/esm/session/manager.d.ts +0 -38
  187. package/esm/session/manager.js +0 -70
  188. package/esm/session/persist.d.ts +0 -3
  189. package/esm/session/persist.js +0 -29
  190. package/esm/session/store.d.ts +0 -13
  191. package/esm/session/store.js +0 -24
  192. package/esm/session/title.d.ts +0 -9
  193. package/esm/session/title.js +0 -24
  194. package/esm/session/types.d.ts +0 -38
  195. package/esm/session/types.js +0 -1
  196. package/esm/skills/index.d.ts +0 -7
  197. package/esm/skills/index.js +0 -6
  198. package/esm/skills/loader.d.ts +0 -2
  199. package/esm/skills/loader.js +0 -51
  200. package/esm/skills/parser.d.ts +0 -2
  201. package/esm/skills/parser.js +0 -19
  202. package/esm/skills/platform.d.ts +0 -1
  203. package/esm/skills/platform.js +0 -9
  204. package/esm/skills/registry.d.ts +0 -9
  205. package/esm/skills/registry.js +0 -21
  206. package/esm/skills/run.d.ts +0 -14
  207. package/esm/skills/run.js +0 -44
  208. package/esm/skills/tool.d.ts +0 -3
  209. package/esm/skills/tool.js +0 -31
  210. package/esm/skills/types.d.ts +0 -8
  211. package/esm/skills/types.js +0 -1
  212. package/esm/subAgents/index.d.ts +0 -4
  213. package/esm/subAgents/index.js +0 -3
  214. package/esm/subAgents/registry.d.ts +0 -2
  215. package/esm/subAgents/registry.js +0 -18
  216. package/esm/subAgents/runner.d.ts +0 -11
  217. package/esm/subAgents/runner.js +0 -33
  218. package/esm/subAgents/tool.d.ts +0 -6
  219. package/esm/subAgents/tool.js +0 -64
  220. package/esm/subAgents/types.d.ts +0 -18
  221. package/esm/subAgents/types.js +0 -1
  222. package/esm/tui/chat/ChatApp.d.ts +0 -204
  223. package/esm/tui/chat/ChatApp.js +0 -1502
  224. package/esm/tui/chat/commands.d.ts +0 -16
  225. package/esm/tui/chat/commands.js +0 -21
  226. package/esm/tui/chat/editor.d.ts +0 -43
  227. package/esm/tui/chat/editor.js +0 -205
  228. package/esm/tui/chat/index.d.ts +0 -9
  229. package/esm/tui/chat/index.js +0 -7
  230. package/esm/tui/chat/markdown.d.ts +0 -9
  231. package/esm/tui/chat/markdown.js +0 -295
  232. package/esm/tui/chat/picker.d.ts +0 -17
  233. package/esm/tui/chat/picker.js +0 -202
  234. package/esm/tui/chat/status.d.ts +0 -14
  235. package/esm/tui/chat/status.js +0 -46
  236. package/esm/tui/chat/theme.d.ts +0 -97
  237. package/esm/tui/chat/theme.js +0 -201
  238. package/esm/tui/chat/transcript.d.ts +0 -78
  239. package/esm/tui/chat/transcript.js +0 -421
  240. package/esm/tui/index.d.ts +0 -3
  241. package/esm/tui/index.js +0 -7
  242. package/script/_dnt.polyfills.d.ts +0 -11
  243. package/script/_dnt.polyfills.js +0 -16
  244. package/script/agents/index.d.ts +0 -4
  245. package/script/agents/index.js +0 -12
  246. package/script/agents/loader.d.ts +0 -2
  247. package/script/agents/loader.js +0 -28
  248. package/script/agents/parser.d.ts +0 -2
  249. package/script/agents/parser.js +0 -50
  250. package/script/agents/registry.d.ts +0 -11
  251. package/script/agents/registry.js +0 -109
  252. package/script/agents/types.d.ts +0 -12
  253. package/script/agents/types.js +0 -2
  254. package/script/channels/adapter.d.ts +0 -26
  255. package/script/channels/adapter.js +0 -30
  256. package/script/channels/channel.d.ts +0 -7
  257. package/script/channels/channel.js +0 -36
  258. package/script/channels/index.d.ts +0 -5
  259. package/script/channels/index.js +0 -24
  260. package/script/channels/manager.d.ts +0 -6
  261. package/script/channels/manager.js +0 -32
  262. package/script/channels/types.d.ts +0 -32
  263. package/script/channels/types.js +0 -2
  264. package/script/channels/ws/client.d.ts +0 -24
  265. package/script/channels/ws/client.js +0 -333
  266. package/script/channels/ws/index.d.ts +0 -6
  267. package/script/channels/ws/index.js +0 -30
  268. package/script/channels/ws/protocol.d.ts +0 -251
  269. package/script/channels/ws/protocol.js +0 -122
  270. package/script/channels/ws/server.d.ts +0 -25
  271. package/script/channels/ws/server.js +0 -351
  272. package/script/channels/ws/session-service.d.ts +0 -36
  273. package/script/channels/ws/session-service.js +0 -58
  274. package/script/channels/ws/sub-agent.d.ts +0 -8
  275. package/script/channels/ws/sub-agent.js +0 -75
  276. package/script/channels/ws/wire-events.d.ts +0 -3
  277. package/script/channels/ws/wire-events.js +0 -41
  278. package/script/channels/ws/wire.d.ts +0 -45
  279. package/script/channels/ws/wire.js +0 -77
  280. package/script/channels/ws/ws-client.d.ts +0 -13
  281. package/script/channels/ws/ws-client.js +0 -58
  282. package/script/commands/defaults.d.ts +0 -20
  283. package/script/commands/defaults.js +0 -229
  284. package/script/commands/index.d.ts +0 -4
  285. package/script/commands/index.js +0 -15
  286. package/script/commands/registry.d.ts +0 -2
  287. package/script/commands/registry.js +0 -63
  288. package/script/commands/skill.d.ts +0 -7
  289. package/script/commands/skill.js +0 -20
  290. package/script/commands/types.d.ts +0 -26
  291. package/script/commands/types.js +0 -2
  292. package/script/common/frontmatter.d.ts +0 -6
  293. package/script/common/frontmatter.js +0 -23
  294. package/script/common/index.d.ts +0 -2
  295. package/script/common/index.js +0 -9
  296. package/script/common/utils.d.ts +0 -6
  297. package/script/common/utils.js +0 -26
  298. package/script/config/index.d.ts +0 -2
  299. package/script/config/index.js +0 -5
  300. package/script/config/resolve.d.ts +0 -2
  301. package/script/config/resolve.js +0 -14
  302. package/script/config/types.d.ts +0 -15
  303. package/script/config/types.js +0 -2
  304. package/script/deps/jsr.io/@std/yaml/1.1.0/_chars.d.ts +0 -32
  305. package/script/deps/jsr.io/@std/yaml/1.1.0/_chars.js +0 -55
  306. package/script/deps/jsr.io/@std/yaml/1.1.0/_dumper_state.d.ts +0 -105
  307. package/script/deps/jsr.io/@std/yaml/1.1.0/_dumper_state.js +0 -642
  308. package/script/deps/jsr.io/@std/yaml/1.1.0/_loader_state.d.ts +0 -63
  309. package/script/deps/jsr.io/@std/yaml/1.1.0/_loader_state.js +0 -1375
  310. package/script/deps/jsr.io/@std/yaml/1.1.0/_schema.d.ts +0 -43
  311. package/script/deps/jsr.io/@std/yaml/1.1.0/_schema.js +0 -121
  312. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/binary.d.ts +0 -2
  313. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/binary.js +0 -106
  314. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/bool.d.ts +0 -2
  315. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/bool.js +0 -35
  316. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/float.d.ts +0 -2
  317. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/float.js +0 -99
  318. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/int.d.ts +0 -2
  319. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/int.js +0 -162
  320. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/map.d.ts +0 -2
  321. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/map.js +0 -17
  322. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/merge.d.ts +0 -2
  323. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/merge.js +0 -13
  324. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/nil.d.ts +0 -2
  325. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/nil.js +0 -25
  326. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/omap.d.ts +0 -2
  327. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/omap.js +0 -32
  328. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/pairs.d.ts +0 -2
  329. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/pairs.js +0 -22
  330. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/regexp.d.ts +0 -2
  331. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/regexp.js +0 -33
  332. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/seq.d.ts +0 -2
  333. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/seq.js +0 -13
  334. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/set.d.ts +0 -2
  335. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/set.js +0 -17
  336. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/str.d.ts +0 -2
  337. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/str.js +0 -12
  338. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/timestamp.d.ts +0 -2
  339. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/timestamp.js +0 -84
  340. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/undefined.d.ts +0 -2
  341. package/script/deps/jsr.io/@std/yaml/1.1.0/_type/undefined.js +0 -23
  342. package/script/deps/jsr.io/@std/yaml/1.1.0/_type.d.ts +0 -31
  343. package/script/deps/jsr.io/@std/yaml/1.1.0/_type.js +0 -7
  344. package/script/deps/jsr.io/@std/yaml/1.1.0/_utils.d.ts +0 -3
  345. package/script/deps/jsr.io/@std/yaml/1.1.0/_utils.js +0 -18
  346. package/script/deps/jsr.io/@std/yaml/1.1.0/mod.d.ts +0 -49
  347. package/script/deps/jsr.io/@std/yaml/1.1.0/mod.js +0 -68
  348. package/script/deps/jsr.io/@std/yaml/1.1.0/parse.d.ts +0 -75
  349. package/script/deps/jsr.io/@std/yaml/1.1.0/parse.js +0 -95
  350. package/script/deps/jsr.io/@std/yaml/1.1.0/stringify.d.ts +0 -99
  351. package/script/deps/jsr.io/@std/yaml/1.1.0/stringify.js +0 -36
  352. package/script/harness/compaction.d.ts +0 -14
  353. package/script/harness/compaction.js +0 -24
  354. package/script/harness/create.d.ts +0 -2
  355. package/script/harness/create.js +0 -294
  356. package/script/harness/environment.d.ts +0 -10
  357. package/script/harness/environment.js +0 -17
  358. package/script/harness/index.d.ts +0 -6
  359. package/script/harness/index.js +0 -14
  360. package/script/harness/instructions.d.ts +0 -17
  361. package/script/harness/instructions.js +0 -82
  362. package/script/harness/memory.d.ts +0 -18
  363. package/script/harness/memory.js +0 -63
  364. package/script/harness/models.d.ts +0 -18
  365. package/script/harness/models.js +0 -38
  366. package/script/harness/types.d.ts +0 -54
  367. package/script/harness/types.js +0 -2
  368. package/script/hooks/index.d.ts +0 -3
  369. package/script/hooks/index.js +0 -7
  370. package/script/hooks/merge-hooks.d.ts +0 -2
  371. package/script/hooks/merge-hooks.js +0 -56
  372. package/script/hooks/types.d.ts +0 -33
  373. package/script/hooks/types.js +0 -2
  374. package/script/hooks/with-hooks.d.ts +0 -3
  375. package/script/hooks/with-hooks.js +0 -16
  376. package/script/index.d.ts +0 -15
  377. package/script/index.js +0 -31
  378. package/script/package.json +0 -3
  379. package/script/permissions/allow-list.d.ts +0 -4
  380. package/script/permissions/allow-list.js +0 -13
  381. package/script/permissions/approval-manager.d.ts +0 -31
  382. package/script/permissions/approval-manager.js +0 -59
  383. package/script/permissions/approval.d.ts +0 -17
  384. package/script/permissions/approval.js +0 -17
  385. package/script/permissions/glob.d.ts +0 -1
  386. package/script/permissions/glob.js +0 -6
  387. package/script/permissions/index.d.ts +0 -4
  388. package/script/permissions/index.js +0 -12
  389. package/script/plugin/define.d.ts +0 -2
  390. package/script/plugin/define.js +0 -5
  391. package/script/plugin/import-ts.d.ts +0 -1
  392. package/script/plugin/import-ts.js +0 -122
  393. package/script/plugin/index.d.ts +0 -5
  394. package/script/plugin/index.js +0 -11
  395. package/script/plugin/resolve.d.ts +0 -13
  396. package/script/plugin/resolve.js +0 -21
  397. package/script/plugin/store.d.ts +0 -8
  398. package/script/plugin/store.js +0 -30
  399. package/script/plugin/types.d.ts +0 -11
  400. package/script/plugin/types.js +0 -2
  401. package/script/scheduler/command.d.ts +0 -3
  402. package/script/scheduler/command.js +0 -23
  403. package/script/scheduler/engine/index.d.ts +0 -4
  404. package/script/scheduler/engine/index.js +0 -9
  405. package/script/scheduler/engine/memory-store.d.ts +0 -2
  406. package/script/scheduler/engine/memory-store.js +0 -27
  407. package/script/scheduler/engine/scheduler.d.ts +0 -13
  408. package/script/scheduler/engine/scheduler.js +0 -77
  409. package/script/scheduler/engine/store.d.ts +0 -4
  410. package/script/scheduler/engine/store.js +0 -59
  411. package/script/scheduler/engine/types.d.ts +0 -55
  412. package/script/scheduler/engine/types.js +0 -2
  413. package/script/scheduler/index.d.ts +0 -4
  414. package/script/scheduler/index.js +0 -11
  415. package/script/scheduler/tool.d.ts +0 -8
  416. package/script/scheduler/tool.js +0 -52
  417. package/script/session/agent-session.d.ts +0 -15
  418. package/script/session/agent-session.js +0 -163
  419. package/script/session/catalog.d.ts +0 -24
  420. package/script/session/catalog.js +0 -59
  421. package/script/session/index.d.ts +0 -7
  422. package/script/session/index.js +0 -17
  423. package/script/session/manager.d.ts +0 -38
  424. package/script/session/manager.js +0 -74
  425. package/script/session/persist.d.ts +0 -3
  426. package/script/session/persist.js +0 -33
  427. package/script/session/store.d.ts +0 -13
  428. package/script/session/store.js +0 -28
  429. package/script/session/title.d.ts +0 -9
  430. package/script/session/title.js +0 -30
  431. package/script/session/types.d.ts +0 -38
  432. package/script/session/types.js +0 -2
  433. package/script/skills/index.d.ts +0 -7
  434. package/script/skills/index.js +0 -16
  435. package/script/skills/loader.d.ts +0 -2
  436. package/script/skills/loader.js +0 -55
  437. package/script/skills/parser.d.ts +0 -2
  438. package/script/skills/parser.js +0 -23
  439. package/script/skills/platform.d.ts +0 -1
  440. package/script/skills/platform.js +0 -13
  441. package/script/skills/registry.d.ts +0 -9
  442. package/script/skills/registry.js +0 -25
  443. package/script/skills/run.d.ts +0 -14
  444. package/script/skills/run.js +0 -49
  445. package/script/skills/tool.d.ts +0 -3
  446. package/script/skills/tool.js +0 -35
  447. package/script/skills/types.d.ts +0 -8
  448. package/script/skills/types.js +0 -2
  449. package/script/subAgents/index.d.ts +0 -4
  450. package/script/subAgents/index.js +0 -9
  451. package/script/subAgents/registry.d.ts +0 -2
  452. package/script/subAgents/registry.js +0 -22
  453. package/script/subAgents/runner.d.ts +0 -11
  454. package/script/subAgents/runner.js +0 -37
  455. package/script/subAgents/tool.d.ts +0 -6
  456. package/script/subAgents/tool.js +0 -68
  457. package/script/subAgents/types.d.ts +0 -18
  458. package/script/subAgents/types.js +0 -2
  459. package/script/tui/chat/ChatApp.d.ts +0 -204
  460. package/script/tui/chat/ChatApp.js +0 -1506
  461. package/script/tui/chat/commands.d.ts +0 -16
  462. package/script/tui/chat/commands.js +0 -25
  463. package/script/tui/chat/editor.d.ts +0 -43
  464. package/script/tui/chat/editor.js +0 -209
  465. package/script/tui/chat/index.d.ts +0 -9
  466. package/script/tui/chat/index.js +0 -25
  467. package/script/tui/chat/markdown.d.ts +0 -9
  468. package/script/tui/chat/markdown.js +0 -300
  469. package/script/tui/chat/picker.d.ts +0 -17
  470. package/script/tui/chat/picker.js +0 -208
  471. package/script/tui/chat/status.d.ts +0 -14
  472. package/script/tui/chat/status.js +0 -53
  473. package/script/tui/chat/theme.d.ts +0 -97
  474. package/script/tui/chat/theme.js +0 -209
  475. package/script/tui/chat/transcript.d.ts +0 -78
  476. package/script/tui/chat/transcript.js +0 -429
  477. package/script/tui/index.d.ts +0 -3
  478. package/script/tui/index.js +0 -25
@@ -0,0 +1,1673 @@
1
+ import { Message, Tool, ContentPart, LoopEvent, Provider, ModelModalities, Usage } from 'mu-core';
2
+ import { Color, Component, InputEvent, Surface } from 'mu-tui';
3
+ export { wrapText } from 'mu-tui';
4
+
5
+ type ToolDecision = 'allow' | 'ask' | 'deny';
6
+ type GrantValue = ToolDecision | Record<string, ToolDecision>;
7
+ type ToolGrants = string[] | Record<string, GrantValue>;
8
+ interface Agent {
9
+ name: string;
10
+ description: string;
11
+ prompt: string;
12
+ tools?: ToolGrants;
13
+ model?: string;
14
+ color?: string;
15
+ extends?: string;
16
+ }
17
+
18
+ interface AgentRegistry {
19
+ list(): Agent[];
20
+ get(name: string): Agent | undefined;
21
+ add(agent: Agent): void;
22
+ replaceAll(agents: Agent[]): void;
23
+ }
24
+ declare const grantArg: (tool: string, input: unknown) => string | undefined;
25
+ declare const toolDecision: (agent: Agent, tool: string, arg?: string) => ToolDecision;
26
+ declare const toolNames: (agent: Agent) => string[] | undefined;
27
+ declare const createAgentRegistry: (agents?: Agent[]) => AgentRegistry;
28
+
29
+ declare const parseAgent: (source: string, fallbackName: string) => Agent;
30
+
31
+ declare const loadAgents: (dir: string) => Promise<Agent[]>;
32
+
33
+ type AgentSessionEvent = {
34
+ type: 'turn_start';
35
+ input: Message;
36
+ } | LoopEvent | {
37
+ type: 'turn_end';
38
+ } | {
39
+ type: 'error';
40
+ error: unknown;
41
+ };
42
+ /** The request the provider sees for a turn, assembled from the live session. */
43
+ interface AssembledRequest {
44
+ /** Final system prompt: base system + prepareRequest hook injections + tool prompt blocks. */
45
+ system: string;
46
+ /** Final tool set (after prepareRequest hooks — may differ from session.tools, e.g. per-agent filtering). */
47
+ tools: readonly Tool[];
48
+ /** Final message list (system message + body + any hook-injected messages). */
49
+ messages: readonly Message[];
50
+ }
51
+ interface AgentSession {
52
+ readonly id: string;
53
+ readonly model?: string;
54
+ readonly messages: readonly Message[];
55
+ readonly tools: readonly Tool[];
56
+ /** Assemble the request from the CURRENT in-memory session — what the next turn would send. */
57
+ assembleRequest?(): Promise<AssembledRequest>;
58
+ /** Exact token count of `text` via the model's own tokenizer, when the provider supports it. */
59
+ countTokens?(text: string): Promise<number | undefined>;
60
+ /** The active model's context window in tokens, when reportable. */
61
+ contextWindow?(): Promise<number | undefined>;
62
+ /** Summarize older messages (keeping the system + last N) to free context. */
63
+ compact?(opts?: {
64
+ keepLastTurns?: number;
65
+ }): Promise<void>;
66
+ send(input: string | ContentPart[]): Promise<void>;
67
+ abort(): void;
68
+ subscribe(listener: (event: AgentSessionEvent) => void): () => void;
69
+ }
70
+
71
+ interface PreparedRequest {
72
+ system?: string;
73
+ tools?: Tool[];
74
+ messages?: Message[];
75
+ }
76
+ /** Context handed to `afterTurn` — inspect usage and trigger compaction without owning the message array. */
77
+ interface AfterTurnContext {
78
+ messages: readonly Message[];
79
+ countTokens(text: string): Promise<number | undefined>;
80
+ contextWindow(): Promise<number | undefined>;
81
+ /** Summarize older messages (keeping the system + last N), replacing them in place. */
82
+ compact(opts?: {
83
+ keepLastTurns?: number;
84
+ }): Promise<void>;
85
+ }
86
+ interface AgentSessionHooks {
87
+ sessionStart?(): void | Promise<void>;
88
+ prepareRequest?(req: {
89
+ system: string;
90
+ tools: Tool[];
91
+ }): PreparedRequest | void | Promise<PreparedRequest | void>;
92
+ beforeToolCall?(call: {
93
+ name: string;
94
+ input: unknown;
95
+ }): void | ContentPart[] | Promise<void | ContentPart[]>;
96
+ afterToolCall?(call: {
97
+ name: string;
98
+ result: ContentPart[];
99
+ }): void | ContentPart[] | Promise<void | ContentPart[]>;
100
+ /** Fires after a turn completes (not on abort) — used for auto-compaction and memory writes. */
101
+ afterTurn?(ctx: AfterTurnContext): void | Promise<void>;
102
+ }
103
+
104
+ declare const withHooks: (tool: Tool, hooks: AgentSessionHooks) => Tool;
105
+
106
+ declare const mergeHooks: (list: (AgentSessionHooks | undefined)[]) => AgentSessionHooks;
107
+
108
+ interface Skill {
109
+ name: string;
110
+ description: string;
111
+ prompt: string;
112
+ dir?: string;
113
+ platforms?: string[];
114
+ command?: string;
115
+ }
116
+
117
+ interface SkillRegistry {
118
+ list(): Skill[];
119
+ get(name: string): Skill | undefined;
120
+ add(skill: Skill): void;
121
+ replaceAll(skills: Skill[]): void;
122
+ select(names: string[]): SkillRegistry;
123
+ }
124
+ declare const createSkillRegistry: (skills?: Skill[]) => SkillRegistry;
125
+
126
+ declare const parseSkill: (source: string, fallbackName: string, dir?: string) => Skill;
127
+
128
+ declare const loadSkills: (dir: string, current?: string) => Promise<Skill[]>;
129
+
130
+ declare const skillMatchesPlatform: (platforms: string[] | undefined, current?: string) => boolean;
131
+
132
+ declare const createSkillTool: (registry: SkillRegistry) => Tool;
133
+
134
+ interface SubAgentResult {
135
+ agent: string;
136
+ text: string;
137
+ }
138
+ interface SubAgentRun {
139
+ runId: string;
140
+ agent: string;
141
+ parentId?: string;
142
+ session: AgentSession;
143
+ }
144
+ interface SubAgentRegistry {
145
+ register(run: SubAgentRun): void;
146
+ get(runId: string): SubAgentRun | undefined;
147
+ list(): SubAgentRun[];
148
+ byParent(parentId: string): SubAgentRun[];
149
+ subscribe(listener: (run: SubAgentRun) => void): () => void;
150
+ }
151
+
152
+ declare const createSubAgentRegistry: () => SubAgentRegistry;
153
+
154
+ interface RunSubAgentDeps {
155
+ spawn(agent: Agent): AgentSession;
156
+ runs?: SubAgentRegistry;
157
+ parentId?: string;
158
+ runId?: string;
159
+ signal?: AbortSignal;
160
+ }
161
+ declare const runSubAgent: (agent: Agent, task: string, deps: RunSubAgentDeps) => Promise<SubAgentResult>;
162
+
163
+ declare const createSubAgentTool: (deps: {
164
+ registry: AgentRegistry;
165
+ } & RunSubAgentDeps) => Tool;
166
+
167
+ interface RunSkillDeps extends RunSubAgentDeps {
168
+ skills: SkillRegistry;
169
+ agents?: AgentRegistry;
170
+ }
171
+ declare const runSkill: (deps: RunSkillDeps, args: {
172
+ skill: string;
173
+ task: string;
174
+ agent: string;
175
+ }) => Promise<string>;
176
+ declare const createRunSkillTool: (deps: RunSkillDeps) => Tool;
177
+
178
+ interface Plugin {
179
+ name: string;
180
+ tools?: Tool[];
181
+ hooks?: AgentSessionHooks;
182
+ agents?: Agent[];
183
+ skills?: Skill[];
184
+ }
185
+
186
+ declare const definePlugin: (plugin: Plugin) => Plugin;
187
+
188
+ interface Resolved {
189
+ tools: Tool[];
190
+ hooks: AgentSessionHooks;
191
+ }
192
+ interface ResolveInput {
193
+ tools?: Tool[];
194
+ hooks?: AgentSessionHooks;
195
+ plugins?: Plugin[];
196
+ }
197
+ declare const resolve: (config: ResolveInput) => Resolved;
198
+
199
+ interface PluginStore {
200
+ write(name: string, content: string): Promise<string>;
201
+ list(): Promise<string[]>;
202
+ remove(name: string): Promise<void>;
203
+ }
204
+ declare const createPluginStore: ({ dir }: {
205
+ dir: string;
206
+ }) => PluginStore;
207
+
208
+ declare const importModule: (spec: string) => Promise<Record<string, unknown>>;
209
+
210
+ interface AgentSessionConfig {
211
+ provider: Provider;
212
+ model: string;
213
+ tools?: Tool[];
214
+ hooks?: AgentSessionHooks;
215
+ plugins?: Plugin[];
216
+ system?: string;
217
+ id?: string;
218
+ messages?: Message[];
219
+ }
220
+ declare const createAgentSession: (config: AgentSessionConfig) => AgentSession;
221
+
222
+ interface StoredSession {
223
+ id: string;
224
+ messages: Message[];
225
+ }
226
+ interface SessionStore {
227
+ load(id: string): Promise<StoredSession>;
228
+ append(id: string, messages: Message[]): Promise<void>;
229
+ rewrite(id: string, messages: readonly Message[]): Promise<void>;
230
+ delete(id: string): Promise<void>;
231
+ }
232
+ declare const createSessionStore: ({ dir }: {
233
+ dir: string;
234
+ }) => SessionStore;
235
+
236
+ interface SessionRecord {
237
+ id: string;
238
+ title?: string;
239
+ cwd?: string;
240
+ parentId?: string;
241
+ createdAt: number;
242
+ }
243
+ interface SessionCatalog {
244
+ record(id: string, info: {
245
+ cwd?: string;
246
+ parentId?: string;
247
+ }): void;
248
+ setTitle(id: string, title: string): void;
249
+ get(id: string): SessionRecord | undefined;
250
+ list(filter?: {
251
+ cwd?: string;
252
+ parentId?: string;
253
+ }): SessionRecord[];
254
+ delete(id: string): void;
255
+ close(): void;
256
+ }
257
+ declare const createSessionCatalog: ({ file }: {
258
+ file: string;
259
+ }) => SessionCatalog;
260
+
261
+ declare const persistTo: (store: SessionStore, session: AgentSession, persisted?: number) => AgentSession;
262
+
263
+ interface ReviveInput {
264
+ id: string;
265
+ model?: string;
266
+ messages?: Message[];
267
+ }
268
+ interface SessionManagerOptions {
269
+ store: SessionStore;
270
+ catalog: SessionCatalog;
271
+ revive(input: ReviveInput): AgentSession;
272
+ newId(): string;
273
+ cwd?: string;
274
+ title?(input: {
275
+ id: string;
276
+ text: string;
277
+ }): void;
278
+ }
279
+ interface SessionManager {
280
+ create(options?: {
281
+ id?: string;
282
+ model?: string;
283
+ cwd?: string;
284
+ }): AgentSession;
285
+ open(id: string): Promise<AgentSession>;
286
+ fork(id: string, upToIndex: number): Promise<AgentSession>;
287
+ list(filter?: {
288
+ cwd?: string;
289
+ parentId?: string;
290
+ }): Promise<SessionRecord[]>;
291
+ get(id: string): Promise<SessionRecord | undefined>;
292
+ read(id: string): Promise<StoredSession | undefined>;
293
+ rename(id: string, title: string): void;
294
+ delete(id: string): Promise<void>;
295
+ }
296
+ declare const createSessionManager: ({ store, catalog, revive, newId, cwd, title }: SessionManagerOptions) => SessionManager;
297
+
298
+ declare const titleFallback: (text: string, max?: number) => string;
299
+ declare const cleanTitle: (raw: string, max?: number) => string;
300
+ interface RunTitlerOptions {
301
+ id: string;
302
+ text: string;
303
+ setTitle(id: string, title: string): void | Promise<void>;
304
+ generate(text: string): Promise<string>;
305
+ }
306
+ declare const runTitler: (options: RunTitlerOptions) => Promise<void>;
307
+
308
+ type ChannelEvent = AgentSessionEvent | {
309
+ type: 'channel_open';
310
+ title: string;
311
+ } | {
312
+ type: 'channel_close';
313
+ };
314
+ type ChannelManagerEvent = {
315
+ channelId: string;
316
+ } & ChannelEvent;
317
+ interface Channel {
318
+ readonly id: string;
319
+ readonly title: string;
320
+ readonly started: boolean;
321
+ readonly messages: readonly Message[];
322
+ /** The live AgentSession, once started — exposes `lastRequest` for inspection commands. */
323
+ readonly session?: AgentSession;
324
+ send(input: string | ContentPart[]): Promise<void>;
325
+ abort(): void;
326
+ subscribe(listener: (event: AgentSessionEvent) => void): () => void;
327
+ }
328
+ interface ChannelManager {
329
+ open(opts?: {
330
+ id?: string;
331
+ title?: string;
332
+ }): Channel;
333
+ get(id: string): Channel | undefined;
334
+ list(): Channel[];
335
+ close(id: string): void;
336
+ subscribe(listener: (event: ChannelManagerEvent) => void): () => void;
337
+ }
338
+
339
+ declare const createChannel: (config: {
340
+ id: string;
341
+ title: string;
342
+ createSession: (id: string) => AgentSession | Promise<AgentSession>;
343
+ }) => Channel;
344
+
345
+ declare const createChannelManager: (config: {
346
+ createSession: (id: string) => AgentSession | Promise<AgentSession>;
347
+ idGen?: () => string;
348
+ }) => ChannelManager;
349
+
350
+ declare const filterTools: (pool: Tool[], allow: string[] | undefined) => Tool[];
351
+ declare const allowList: (names: string[] | undefined) => AgentSessionHooks;
352
+
353
+ interface ApprovalCall {
354
+ id: string;
355
+ name: string;
356
+ input: unknown;
357
+ }
358
+ interface RequireApprovalOptions {
359
+ needsApproval(call: {
360
+ name: string;
361
+ input: unknown;
362
+ }): boolean;
363
+ prompt(call: ApprovalCall): boolean | Promise<boolean>;
364
+ onDeny?(call: ApprovalCall): ContentPart[];
365
+ newId?(): string;
366
+ }
367
+ declare const requireApproval: (options: RequireApprovalOptions) => AgentSessionHooks;
368
+
369
+ type ApprovalAction = 'approve' | 'approve_always' | 'deny';
370
+ type ApprovalDecision = 'allow' | 'ask' | 'deny';
371
+ interface PendingApproval {
372
+ id: string;
373
+ name: string;
374
+ input: unknown;
375
+ agent?: string;
376
+ }
377
+ interface ApprovalManager {
378
+ hooks: AgentSessionHooks;
379
+ hooksFor(opts: {
380
+ decide(call: {
381
+ name: string;
382
+ input: unknown;
383
+ }): ApprovalDecision;
384
+ agent?(): string | undefined;
385
+ }): AgentSessionHooks;
386
+ pending(): PendingApproval[];
387
+ resolve(id: string, action: ApprovalAction): boolean;
388
+ subscribe(listener: (req: PendingApproval) => void): () => void;
389
+ }
390
+ interface ApprovalManagerOptions {
391
+ needsApproval?: (call: {
392
+ name: string;
393
+ input: unknown;
394
+ }) => boolean;
395
+ askTools?: string[];
396
+ newId?: () => string;
397
+ }
398
+ declare const createApprovalManager: (options?: ApprovalManagerOptions) => ApprovalManager;
399
+
400
+ declare const matchesAnyGlob: (value: string, patterns: string[]) => boolean;
401
+
402
+ interface CommandResult {
403
+ ok: boolean;
404
+ output?: unknown;
405
+ error?: string;
406
+ }
407
+ interface CommandContext {
408
+ sessionId?: string;
409
+ /** The live session for this invocation — lets a command inspect what the model actually saw. */
410
+ session?: AgentSession;
411
+ }
412
+ interface Command {
413
+ name: string;
414
+ description: string;
415
+ aliases?: string[];
416
+ run: (args: string, ctx: CommandContext) => CommandResult | Promise<CommandResult>;
417
+ }
418
+ interface CommandRegistry {
419
+ register(command: Command, options?: {
420
+ override?: boolean;
421
+ }): void;
422
+ unregister(name: string): void;
423
+ list(): Command[];
424
+ get(name: string): Command | undefined;
425
+ run(input: string, ctx?: CommandContext): Promise<CommandResult>;
426
+ }
427
+
428
+ declare const createAgentsCommand: (agents: AgentRegistry) => Command;
429
+ declare const createSkillsCommand: (skills: SkillRegistry) => Command;
430
+ declare const createSessionsCommand: (sessions: SessionManager, options?: {
431
+ cwd?: string;
432
+ }) => Command;
433
+ declare const createQuitCommand: (onQuit: () => void | Promise<void>) => Command;
434
+ /**
435
+ * Universal `/context` — the live session's context broken down into all categories
436
+ * (system / context / instructions / memory / tools / you / agent / tool-output), each
437
+ * counted with the model's own tokenizer, plus the context-window fill % and a colour
438
+ * heatmap. Works on every channel.
439
+ */
440
+ declare const createContextCommand: () => Command;
441
+ /** Universal `/compact` — manually summarize older messages to free context now. */
442
+ declare const createCompactCommand: () => Command;
443
+ declare const createHelpCommand: (list: () => Command[]) => Command;
444
+
445
+ declare const createCommandRegistry: (commands?: Command[]) => CommandRegistry;
446
+
447
+ type SkillCommandDeps = RunSkillDeps & {
448
+ activeAgent?: () => Agent | undefined;
449
+ };
450
+ declare const createSkillCommand: (skill: Skill, deps: SkillCommandDeps) => Command;
451
+
452
+ interface XdgDirs {
453
+ configHome: string;
454
+ dataHome: string;
455
+ stateHome: string;
456
+ }
457
+ interface HarnessConfigOptions {
458
+ hostName: string;
459
+ xdg: XdgDirs;
460
+ }
461
+ interface HarnessConfig {
462
+ hostName: string;
463
+ configDir: string;
464
+ dataDir: string;
465
+ stateDir: string;
466
+ }
467
+
468
+ declare const createHarnessConfig: (options: HarnessConfigOptions) => HarnessConfig;
469
+
470
+ type Schedule = {
471
+ kind: 'cron';
472
+ expr: string;
473
+ timezone?: string;
474
+ } | {
475
+ kind: 'interval';
476
+ ms: number;
477
+ } | {
478
+ kind: 'once';
479
+ at?: number;
480
+ };
481
+ interface TaskResult {
482
+ ok: boolean;
483
+ output?: string;
484
+ error?: string;
485
+ }
486
+ interface Task {
487
+ id: string;
488
+ skill?: string;
489
+ prompt: string;
490
+ agent?: string;
491
+ schedule: Schedule;
492
+ enabled: boolean;
493
+ createdAt: number;
494
+ lastRun?: number;
495
+ lastResult?: TaskResult;
496
+ }
497
+ type SchedulerEvent = {
498
+ type: 'task_started';
499
+ task: Task;
500
+ at: number;
501
+ } | {
502
+ type: 'task_completed';
503
+ task: Task;
504
+ at: number;
505
+ durationMs: number;
506
+ result: TaskResult;
507
+ } | {
508
+ type: 'task_failed';
509
+ task: Task;
510
+ at: number;
511
+ durationMs: number;
512
+ error: string;
513
+ };
514
+ type TaskInput = Omit<Task, 'id' | 'enabled' | 'createdAt' | 'lastRun' | 'lastResult'> & {
515
+ enabled?: boolean;
516
+ };
517
+ type TaskRunner = (task: Task) => Promise<TaskResult>;
518
+ interface TaskStore {
519
+ list(): Promise<Task[]>;
520
+ get(id: string): Promise<Task | undefined>;
521
+ create(input: TaskInput): Promise<Task>;
522
+ update(id: string, patch: Partial<Task>): Promise<Task | undefined>;
523
+ remove(id: string): Promise<void>;
524
+ }
525
+
526
+ declare const createTaskStore: (options: {
527
+ dir: string;
528
+ }) => TaskStore;
529
+
530
+ declare const createMemoryTaskStore: (initial?: Task[]) => TaskStore;
531
+
532
+ interface Scheduler {
533
+ start(): Promise<void>;
534
+ stop(): void;
535
+ reload(): Promise<void>;
536
+ runNow(id: string): Promise<void>;
537
+ }
538
+ declare const createScheduler: (deps: {
539
+ store: TaskStore;
540
+ run: TaskRunner;
541
+ onEvent?: (event: SchedulerEvent) => void;
542
+ onError?: (error: unknown, task: Task) => void;
543
+ }) => Scheduler;
544
+
545
+ declare const createScheduleTaskTool: (deps: {
546
+ store: TaskStore;
547
+ skills: SkillRegistry;
548
+ onChange?: () => void | Promise<void>;
549
+ }) => Tool;
550
+
551
+ declare const createTasksCommand: (tasks: TaskStore) => Command;
552
+
553
+ interface CompactionOptions {
554
+ /** Compact once estimated usage exceeds this fraction of the context window. Default 0.8. */
555
+ thresholdPct?: number;
556
+ /** Number of most-recent messages kept verbatim through a compaction. Default 6. */
557
+ keepLastTurns?: number;
558
+ }
559
+ /**
560
+ * An `afterTurn` hook that auto-compacts the conversation as it approaches the context
561
+ * window: when the estimated token usage crosses `thresholdPct`, older messages are
562
+ * summarized (keeping the system message + the last `keepLastTurns`). The gap between the
563
+ * threshold and the window is the reserved compaction buffer.
564
+ */
565
+ declare function createCompactionHook(opts?: CompactionOptions): AgentSessionHooks;
566
+
567
+ interface ModelRegistryOptions {
568
+ providers: Record<string, Provider>;
569
+ default: string;
570
+ }
571
+ interface ResolvedModel {
572
+ provider: Provider;
573
+ model: string;
574
+ }
575
+ interface ModelRegistry {
576
+ readonly selected: string;
577
+ readonly providers: string[];
578
+ select(ref: string): void;
579
+ resolve(ref?: string): ResolvedModel;
580
+ /** Probe a model's input modalities via its provider (may load the model). Undefined if unsupported. */
581
+ capabilities(ref?: string): Promise<ModelModalities | undefined>;
582
+ }
583
+ declare const createModelRegistry: (options: ModelRegistryOptions) => ModelRegistry;
584
+
585
+ declare const VOICE_UNAVAILABLE = "voiceModel not configured and the current model doesn't support sound";
586
+ interface VoiceOptions {
587
+ model?: string;
588
+ }
589
+ interface VoiceTranscriber {
590
+ transcribe(data: Uint8Array, mime: string): Promise<string>;
591
+ unavailableReason(): Promise<string | undefined>;
592
+ }
593
+ declare const createVoice: (models: ModelRegistry, options?: VoiceOptions) => VoiceTranscriber;
594
+
595
+ type HarnessOptions = HarnessConfigOptions & Omit<AgentSessionConfig, 'provider' | 'model' | 'id' | 'messages'> & {
596
+ providers: Record<string, Provider>;
597
+ model: string;
598
+ agents?: Agent[];
599
+ defaultAgents?: Agent[];
600
+ skills?: Skill[];
601
+ agentDirs?: {
602
+ local?: string;
603
+ config?: string;
604
+ };
605
+ title?: boolean;
606
+ titleModel?: string;
607
+ cwd?: string;
608
+ sourceUrl?: string;
609
+ scheduler?: boolean;
610
+ /** Speech-to-text for `/voice`. `model` is sent recorded audio; falls back to the selected model when unset. */
611
+ voice?: {
612
+ model?: string;
613
+ };
614
+ /** Auto-compaction settings, or `false` to disable. Default: enabled at 80% of the window. */
615
+ compaction?: CompactionOptions | false;
616
+ approvals?: {
617
+ manager: ApprovalManager;
618
+ activeAgent: () => Agent | undefined;
619
+ decide?: (agent: Agent, call: {
620
+ name: string;
621
+ input: unknown;
622
+ }) => ToolDecision;
623
+ };
624
+ };
625
+ interface Harness {
626
+ readonly config: HarnessConfig;
627
+ readonly models: ModelRegistry;
628
+ readonly voice: VoiceTranscriber;
629
+ readonly plugins: PluginStore;
630
+ readonly sessions: SessionManager;
631
+ readonly agents: AgentRegistry;
632
+ readonly skills: SkillRegistry;
633
+ readonly subAgents: SubAgentRegistry;
634
+ dispatchSubAgent(agent: string, task: string, parentId: string): Promise<SubAgentResult>;
635
+ reloadDefinitions(): Promise<void>;
636
+ readonly commands: CommandRegistry;
637
+ readonly scheduler?: Scheduler;
638
+ readonly tasks?: TaskStore;
639
+ readonly cwd: string;
640
+ close(): void;
641
+ }
642
+
643
+ interface ChannelAdapterContext {
644
+ readonly harness: Harness;
645
+ readonly manager: ChannelManager;
646
+ readonly approvals: ApprovalManager;
647
+ }
648
+ interface ChannelAdapterHandle {
649
+ stop(): Promise<void>;
650
+ }
651
+ interface ChannelAdapter {
652
+ readonly name: string;
653
+ start(ctx: ChannelAdapterContext): Promise<ChannelAdapterHandle>;
654
+ }
655
+ interface RunChannelsOptions {
656
+ harness: Harness;
657
+ approvals: ApprovalManager;
658
+ adapters: ChannelAdapter[];
659
+ idGen?: () => string;
660
+ }
661
+ interface ChannelHost {
662
+ readonly manager: ChannelManager;
663
+ stop(): Promise<void>;
664
+ }
665
+ declare function runChannels(opts: RunChannelsOptions): Promise<ChannelHost>;
666
+
667
+ type WireRole = 'user' | 'assistant' | 'system' | 'tool';
668
+ /** A non-text content part carried over the wire as base64. */
669
+ interface WireAttachment {
670
+ kind: 'image' | 'audio';
671
+ mime: string;
672
+ data: string;
673
+ }
674
+ declare const partsToAttachments: (parts: readonly ContentPart[]) => WireAttachment[];
675
+ declare const attachmentsToParts: (attachments: readonly WireAttachment[]) => ContentPart[];
676
+ interface WireToolCall {
677
+ id: string;
678
+ function: {
679
+ name: string;
680
+ arguments: string;
681
+ };
682
+ }
683
+ interface WireToolResultInfo {
684
+ name: string;
685
+ content: string;
686
+ error?: boolean;
687
+ }
688
+ interface WireMessageMeta {
689
+ source?: string;
690
+ visibility?: 'ui' | 'llm' | 'both';
691
+ transient?: boolean;
692
+ }
693
+ interface WireMessage {
694
+ id: string;
695
+ ts: number;
696
+ role: WireRole;
697
+ content: string;
698
+ reasoning?: string;
699
+ channelId?: string;
700
+ toolCalls?: WireToolCall[];
701
+ toolCallId?: string;
702
+ toolResult?: WireToolResultInfo;
703
+ attachments?: WireAttachment[];
704
+ meta?: WireMessageMeta;
705
+ }
706
+ declare function messagesToWire(messages: readonly Message[], baseTs?: number): WireMessage[];
707
+
708
+ interface SessionSummaryWire {
709
+ id: string;
710
+ title: string;
711
+ createdAt: number;
712
+ updatedAt: number;
713
+ messageCount: number;
714
+ }
715
+ interface PersistedSessionWire {
716
+ version?: 1;
717
+ id: string;
718
+ title: string;
719
+ createdAt: number;
720
+ updatedAt: number;
721
+ messages: WireMessage[];
722
+ }
723
+ interface SessionService {
724
+ agents(): Agent[];
725
+ create(id: string, title?: string): Promise<void>;
726
+ list(): Promise<SessionSummaryWire[]>;
727
+ history(id: string): Promise<PersistedSessionWire | null>;
728
+ rawMessages(id: string): Promise<Message[]>;
729
+ fork(id: string, upToIndex: number): Promise<{
730
+ id: string;
731
+ messages: Message[];
732
+ }>;
733
+ delete(id: string): Promise<void>;
734
+ rename(id: string, title: string): void;
735
+ readonly subAgents: SubAgentRegistry;
736
+ }
737
+ declare function createSessionService(harness: Harness, manager: ChannelManager): SessionService;
738
+
739
+ interface WireModel {
740
+ id: string;
741
+ ownedBy?: string;
742
+ }
743
+ type WsInbound = {
744
+ type: 'chat';
745
+ sessionId?: string;
746
+ text: string;
747
+ attachments?: WireAttachment[];
748
+ } | {
749
+ type: 'command';
750
+ sessionId?: string;
751
+ text: string;
752
+ } | {
753
+ type: 'commands';
754
+ } | {
755
+ type: 'agents';
756
+ } | {
757
+ type: 'approval_response';
758
+ requestId: string;
759
+ action: ApprovalAction;
760
+ } | {
761
+ type: 'set_active_agent';
762
+ agentId: string;
763
+ sessionId?: string;
764
+ } | {
765
+ type: 'abort';
766
+ sessionId: string;
767
+ } | {
768
+ type: 'models:list';
769
+ } | {
770
+ type: 'models:select';
771
+ ref: string;
772
+ } | {
773
+ type: 'subagent:dispatch';
774
+ requestId: string;
775
+ agent: string;
776
+ task: string;
777
+ parentId: string;
778
+ } | {
779
+ type: 'sessions:list';
780
+ } | {
781
+ type: 'sessions:create';
782
+ sessionId?: string;
783
+ title?: string;
784
+ } | {
785
+ type: 'sessions:delete';
786
+ sessionId: string;
787
+ } | {
788
+ type: 'sessions:rename';
789
+ sessionId: string;
790
+ title: string;
791
+ } | {
792
+ type: 'sessions:fork';
793
+ requestId: string;
794
+ sessionId: string;
795
+ upToIndex: number;
796
+ } | {
797
+ type: 'sessions:get';
798
+ sessionId: string;
799
+ } | {
800
+ type: 'voice:check';
801
+ requestId: string;
802
+ } | {
803
+ type: 'voice:transcribe';
804
+ requestId: string;
805
+ mime: string;
806
+ data: string;
807
+ };
808
+ declare function parseInbound(raw: unknown): WsInbound | {
809
+ error: string;
810
+ };
811
+ interface WireAgent {
812
+ name: string;
813
+ description: string;
814
+ color?: string;
815
+ }
816
+ interface WireCommand {
817
+ command: string;
818
+ description: string;
819
+ }
820
+ type WireSessionChangeKind = 'created' | 'updated' | 'deleted' | 'renamed';
821
+ interface WireRule {
822
+ tool: string;
823
+ argsPattern?: string;
824
+ decision: 'allow' | 'deny' | 'ask';
825
+ }
826
+ interface WireApprovalRequest {
827
+ type: 'approval_request';
828
+ requestId: string;
829
+ sessionId: string | null;
830
+ toolName: string;
831
+ args: string;
832
+ matchedRule: WireRule | undefined;
833
+ }
834
+ interface SubAgentToolCallDetail {
835
+ name?: string;
836
+ arguments?: string;
837
+ }
838
+ interface SubAgentToolResultDetail {
839
+ name?: string;
840
+ content?: string;
841
+ error?: boolean;
842
+ }
843
+ type SubAgentEventWire = {
844
+ runId: string;
845
+ parentSessionId: string;
846
+ agentName: string;
847
+ type: 'started';
848
+ detail?: {
849
+ task?: string;
850
+ };
851
+ } | {
852
+ runId: string;
853
+ parentSessionId: string;
854
+ agentName: string;
855
+ type: 'content';
856
+ detail?: string;
857
+ } | {
858
+ runId: string;
859
+ parentSessionId: string;
860
+ agentName: string;
861
+ type: 'tool_call';
862
+ detail?: SubAgentToolCallDetail;
863
+ } | {
864
+ runId: string;
865
+ parentSessionId: string;
866
+ agentName: string;
867
+ type: 'tool_result';
868
+ detail?: SubAgentToolResultDetail;
869
+ } | {
870
+ runId: string;
871
+ parentSessionId: string;
872
+ agentName: string;
873
+ type: 'completed';
874
+ detail?: {
875
+ content?: string;
876
+ };
877
+ } | {
878
+ runId: string;
879
+ parentSessionId: string;
880
+ agentName: string;
881
+ type: 'error';
882
+ detail?: string;
883
+ };
884
+ interface WireSchedulerTask {
885
+ id: string;
886
+ cron: string;
887
+ prompt: string;
888
+ timezone?: string;
889
+ channel?: string;
890
+ }
891
+ type WireSchedulerEvent = {
892
+ type: 'task_started';
893
+ task: WireSchedulerTask;
894
+ at: number;
895
+ } | {
896
+ type: 'task_completed';
897
+ task: WireSchedulerTask;
898
+ at: number;
899
+ durationMs: number;
900
+ } | {
901
+ type: 'task_failed';
902
+ task: WireSchedulerTask;
903
+ at: number;
904
+ error: string;
905
+ };
906
+ type WsOutbound = {
907
+ type: 'commands';
908
+ commands: WireCommand[];
909
+ } | {
910
+ type: 'capabilities';
911
+ vision: boolean;
912
+ audio: boolean;
913
+ } | {
914
+ type: 'model_loading';
915
+ model: string;
916
+ loading: boolean;
917
+ } | {
918
+ type: 'agents';
919
+ agents: WireAgent[];
920
+ activeAgentId?: string | null;
921
+ } | {
922
+ type: 'active_agent';
923
+ agentId: string | null;
924
+ sessionId?: string;
925
+ reason?: string;
926
+ } | {
927
+ type: 'stream';
928
+ sessionId: string;
929
+ text: string;
930
+ } | {
931
+ type: 'reasoning';
932
+ sessionId: string;
933
+ text: string;
934
+ } | {
935
+ type: 'turn_start';
936
+ sessionId: string;
937
+ } | {
938
+ type: 'turn_end';
939
+ sessionId: string;
940
+ reason?: 'complete' | 'aborted' | 'error';
941
+ } | {
942
+ type: 'usage';
943
+ sessionId: string;
944
+ usage: Usage;
945
+ } | {
946
+ type: 'message';
947
+ sessionId: string;
948
+ message: WireMessage;
949
+ } | {
950
+ type: 'models:listed';
951
+ models: WireModel[];
952
+ selected: string;
953
+ } | {
954
+ type: 'subagent:result';
955
+ requestId: string;
956
+ agent: string;
957
+ text: string;
958
+ } | {
959
+ type: 'subagent:error';
960
+ requestId: string;
961
+ message: string;
962
+ } | {
963
+ type: 'voice:availability';
964
+ requestId: string;
965
+ reason?: string;
966
+ } | {
967
+ type: 'voice:result';
968
+ requestId: string;
969
+ text: string;
970
+ } | {
971
+ type: 'voice:error';
972
+ requestId: string;
973
+ message: string;
974
+ } | {
975
+ type: 'sessions:listed';
976
+ sessions: SessionSummaryWire[];
977
+ } | {
978
+ type: 'sessions:changed';
979
+ sessionId: string;
980
+ kind: WireSessionChangeKind;
981
+ } | {
982
+ type: 'sessions:history';
983
+ sessionId: string;
984
+ session: PersistedSessionWire | null;
985
+ } | {
986
+ type: 'sessions:raw';
987
+ sessionId: string;
988
+ messages: Message[];
989
+ } | {
990
+ type: 'sessions:forked';
991
+ requestId: string;
992
+ sessionId: string;
993
+ messages: Message[];
994
+ } | WireApprovalRequest | {
995
+ type: 'scheduler_event';
996
+ event: WireSchedulerEvent;
997
+ } | {
998
+ type: 'sub_agent_event';
999
+ event: SubAgentEventWire;
1000
+ } | {
1001
+ type: 'error';
1002
+ sessionId?: string;
1003
+ message: string;
1004
+ };
1005
+ declare function approvalRequestToWire(req: PendingApproval, sessionId: string | null): WireApprovalRequest;
1006
+
1007
+ interface WebSocketAdapterOptions {
1008
+ port: number;
1009
+ host?: string;
1010
+ authToken?: string;
1011
+ activeAgentId?: string;
1012
+ listModels?: () => Promise<WireModel[]>;
1013
+ /** Modalities the configured model accepts. Image/audio attachments are dropped when off. */
1014
+ capabilities?: {
1015
+ vision?: boolean;
1016
+ audio?: boolean;
1017
+ };
1018
+ maxPayloadBytes?: number;
1019
+ log?: (msg: string) => void;
1020
+ }
1021
+ type WebSocketAdapter = ChannelAdapter & {
1022
+ push(frame: WsOutbound): void;
1023
+ /** Update the advertised model capabilities and broadcast a fresh `capabilities` frame. */
1024
+ setCapabilities(caps: {
1025
+ vision: boolean;
1026
+ audio: boolean;
1027
+ }): void;
1028
+ };
1029
+ declare function webSocketAdapter(opts: WebSocketAdapterOptions): WebSocketAdapter;
1030
+
1031
+ interface TextStyle {
1032
+ fg?: Color;
1033
+ bg?: Color;
1034
+ bold?: boolean;
1035
+ dim?: boolean;
1036
+ italic?: boolean;
1037
+ underline?: boolean;
1038
+ }
1039
+ interface ThemeColors {
1040
+ background: Color;
1041
+ surface: Color;
1042
+ surfaceMuted: Color;
1043
+ border: Color;
1044
+ text: Color;
1045
+ textMuted: Color;
1046
+ accent: Color;
1047
+ success: Color;
1048
+ warning: Color;
1049
+ danger: Color;
1050
+ syntaxKeyword: Color;
1051
+ syntaxString: Color;
1052
+ syntaxFunction: Color;
1053
+ syntaxNumber: Color;
1054
+ syntaxComment: Color;
1055
+ }
1056
+ interface ThemeStyles {
1057
+ body: TextStyle;
1058
+ muted: TextStyle;
1059
+ title: TextStyle;
1060
+ userMessage: TextStyle;
1061
+ assistantMessage: TextStyle;
1062
+ reasoning: TextStyle;
1063
+ commandPaletteItem: TextStyle;
1064
+ commandPaletteHover: TextStyle;
1065
+ commandPaletteSelected: TextStyle;
1066
+ bashPrompt: TextStyle;
1067
+ errorLine: TextStyle;
1068
+ errorPrefix: TextStyle;
1069
+ }
1070
+ interface Theme {
1071
+ name: string;
1072
+ colors: ThemeColors;
1073
+ styles: ThemeStyles;
1074
+ }
1075
+ declare const palette: {
1076
+ readonly neutral: {
1077
+ readonly 0: Color;
1078
+ readonly 50: Color;
1079
+ readonly 100: Color;
1080
+ readonly 200: Color;
1081
+ readonly 300: Color;
1082
+ readonly 400: Color;
1083
+ readonly 500: Color;
1084
+ readonly 600: Color;
1085
+ readonly 700: Color;
1086
+ readonly 800: Color;
1087
+ readonly 900: Color;
1088
+ readonly 925: Color;
1089
+ readonly 950: Color;
1090
+ };
1091
+ readonly blue: {
1092
+ readonly 300: Color;
1093
+ readonly 400: Color;
1094
+ readonly 600: Color;
1095
+ };
1096
+ readonly red: {
1097
+ readonly 400: Color;
1098
+ readonly 600: Color;
1099
+ };
1100
+ readonly green: {
1101
+ readonly 400: Color;
1102
+ readonly 600: Color;
1103
+ readonly 800: Color;
1104
+ };
1105
+ readonly yellow: {
1106
+ readonly 300: Color;
1107
+ readonly 400: Color;
1108
+ readonly 500: Color;
1109
+ };
1110
+ };
1111
+ declare const darkTheme: Theme;
1112
+ declare const lightTheme: Theme;
1113
+ declare const themesByName: Record<string, Theme>;
1114
+ declare function fgToAnsi(color: Color): string;
1115
+ declare function bgToAnsi(color: Color): string;
1116
+ declare function styleToAnsi(style: TextStyle): string;
1117
+ declare function asHexColor(value: string | undefined): `#${string}` | undefined;
1118
+ type ThemeSubscriber = (theme: Theme) => void;
1119
+ declare class ThemeProvider {
1120
+ private theme;
1121
+ private readonly subscribers;
1122
+ constructor(initial: Theme);
1123
+ current(): Theme;
1124
+ setTheme(next: Theme): void;
1125
+ subscribe(fn: ThemeSubscriber): () => void;
1126
+ }
1127
+
1128
+ interface MarkdownLine {
1129
+ text: string;
1130
+ bleed: boolean;
1131
+ }
1132
+ declare function renderMarkdown(content: string, width: number, theme: Theme, bleed?: number): MarkdownLine[];
1133
+ declare function markdown(content: string, theme: Theme): Component;
1134
+
1135
+ interface MultilineEditorOptions {
1136
+ placeholder?: string;
1137
+ maxRows?: number;
1138
+ onSubmit?: (value: string) => void;
1139
+ onChange?: (value: string) => void;
1140
+ }
1141
+ interface ChipRange {
1142
+ start: number;
1143
+ end: number;
1144
+ }
1145
+ declare class MultilineEditor implements Component {
1146
+ private value;
1147
+ private cursor;
1148
+ private readonly placeholder;
1149
+ private readonly maxRows;
1150
+ hiddenPrefix: string;
1151
+ chipColor?: () => string;
1152
+ mentionRanges?: (value: string, cursor: number) => ChipRange[];
1153
+ onPaste?: (text: string) => string | undefined;
1154
+ onSubmit?: (value: string) => void;
1155
+ onChange?: (value: string) => void;
1156
+ constructor(opts?: MultilineEditorOptions);
1157
+ getValue(): string;
1158
+ setValue(value: string): void;
1159
+ get cursorPos(): number;
1160
+ setCursor(n: number): void;
1161
+ rows(): number;
1162
+ handleInput(event: InputEvent): void;
1163
+ private handleKey;
1164
+ private lineStart;
1165
+ private lineEnd;
1166
+ private insert;
1167
+ private chips;
1168
+ private moveLeft;
1169
+ private moveRight;
1170
+ private backspace;
1171
+ private deleteForward;
1172
+ private cursorRowCol;
1173
+ render(s: Surface): void;
1174
+ private renderRow;
1175
+ }
1176
+
1177
+ interface Candidate {
1178
+ label: string;
1179
+ insert: string;
1180
+ kind: 'file' | 'dir' | 'agent';
1181
+ }
1182
+ declare function collectCandidates(cwd: string, agentNames: string[]): Candidate[];
1183
+ declare function rank(query: string, candidates: Candidate[], limit?: number): Candidate[];
1184
+ interface MentionRange {
1185
+ start: number;
1186
+ end: number;
1187
+ }
1188
+ declare function mentionRanges(value: string, excludeStart?: number): MentionRange[];
1189
+ interface ActiveMention {
1190
+ start: number;
1191
+ query: string;
1192
+ }
1193
+ declare function activeMention(value: string, cursor: number): ActiveMention | undefined;
1194
+
1195
+ declare const spinnerFrame: (tick: number) => string;
1196
+ declare const formatTokens: (n: number) => string;
1197
+ interface StatusState {
1198
+ label: string;
1199
+ busy: boolean;
1200
+ spinnerTick: number;
1201
+ context: string;
1202
+ minimal?: boolean;
1203
+ recording?: {
1204
+ seconds: number;
1205
+ tick: number;
1206
+ };
1207
+ }
1208
+ declare function statusFromEvent(event: AgentSessionEvent): string | undefined;
1209
+ declare function statusComponent(state: StatusState, theme: Theme): Component;
1210
+
1211
+ type Entry = {
1212
+ kind: 'user';
1213
+ text: string;
1214
+ } | {
1215
+ kind: 'reasoning';
1216
+ text: string;
1217
+ closed: boolean;
1218
+ } | {
1219
+ kind: 'assistant';
1220
+ text: string;
1221
+ agent?: string;
1222
+ agentColor?: Color;
1223
+ } | {
1224
+ kind: 'tool_call';
1225
+ name: string;
1226
+ input: unknown;
1227
+ } | {
1228
+ kind: 'shell';
1229
+ cmd: string;
1230
+ output: string;
1231
+ error: boolean;
1232
+ } | {
1233
+ kind: 'subagent';
1234
+ agent: string;
1235
+ status: SubAgentStatus;
1236
+ tools: number;
1237
+ activity: string;
1238
+ result: string;
1239
+ log: string[];
1240
+ open: boolean;
1241
+ messages?: readonly Message[];
1242
+ } | {
1243
+ kind: 'note';
1244
+ text: string;
1245
+ error: boolean;
1246
+ };
1247
+ type SubAgentEntry = Extract<Entry, {
1248
+ kind: 'subagent';
1249
+ }>;
1250
+ type SubAgentStatus = 'running' | 'done' | 'error' | 'canceled';
1251
+ interface SubAgentHandle {
1252
+ addTool(label: string): void;
1253
+ finish(result: string): void;
1254
+ fail(message: string): void;
1255
+ cancel(): void;
1256
+ }
1257
+ declare class Transcript {
1258
+ entries: Entry[];
1259
+ expanded: boolean;
1260
+ thinkingVisible: boolean;
1261
+ speaker: {
1262
+ name: string;
1263
+ color?: Color;
1264
+ } | undefined;
1265
+ private pending;
1266
+ private pendingReasoning;
1267
+ reset(): void;
1268
+ private speakerTag;
1269
+ private closeReasoning;
1270
+ toggleExpanded(): boolean;
1271
+ toggleReasoning(): boolean;
1272
+ appendUser(text: string): void;
1273
+ note(content: string, error?: boolean): void;
1274
+ appendSubAgent(agent: string, messages?: readonly Message[]): SubAgentHandle;
1275
+ appendShell(cmd: string): {
1276
+ setOutput: (output: string, error?: boolean) => void;
1277
+ };
1278
+ seed(messages: readonly Message[]): void;
1279
+ applyEvent(event: AgentSessionEvent): void;
1280
+ }
1281
+ declare function formatToolArgs(name: string, input: unknown, max?: number): string;
1282
+ declare const stickyHeader: (value: string, theme: Theme) => Component;
1283
+ declare function entryComponent(entry: Entry, theme: Theme, expanded: boolean): Component;
1284
+ declare function transcriptComponent(model: Transcript, theme: Theme): Component;
1285
+
1286
+ interface RecorderSpec {
1287
+ cmd: string;
1288
+ args: (out: string) => string[];
1289
+ }
1290
+ declare function detectRecorder(): Promise<RecorderSpec | undefined>;
1291
+ interface VoiceRecording {
1292
+ stop(): Promise<Uint8Array>;
1293
+ cancel(): Promise<void>;
1294
+ elapsed(): number;
1295
+ }
1296
+ interface StartVoiceOptions {
1297
+ recorder: RecorderSpec;
1298
+ now: () => number;
1299
+ }
1300
+ declare function startRecording(opts: StartVoiceOptions): Promise<VoiceRecording>;
1301
+ /** Wrap raw little-endian 16-bit mono PCM in a minimal WAV container. */
1302
+ declare function pcmToWav(pcm: Uint8Array, sampleRate?: number): Uint8Array;
1303
+ interface StreamingRecorderSpec {
1304
+ cmd: string;
1305
+ args: string[];
1306
+ }
1307
+ declare function detectStreamingRecorder(): Promise<StreamingRecorderSpec | undefined>;
1308
+ interface StreamingRecording {
1309
+ stop(): Promise<void>;
1310
+ }
1311
+ /**
1312
+ * Spawn a recorder streaming raw s16le mono PCM to stdout; each stdout chunk is
1313
+ * delivered to `onChunk`. Spawn failures (binary vanished after detection, EACCES…)
1314
+ * arrive asynchronously via the child's 'error' event: without a listener Node
1315
+ * re-throws them as an uncaught exception that tears down the whole TUI, so we
1316
+ * always attach one and forward it to `onError` for graceful degradation.
1317
+ */
1318
+ declare function startStreamingRecording(recorder: StreamingRecorderSpec, onChunk: (pcm: Uint8Array) => void, onError?: (err: Error) => void): StreamingRecording;
1319
+ interface RealtimeDictationOptions {
1320
+ transcribe: (wav: Uint8Array) => Promise<string>;
1321
+ onPartial: (text: string) => void;
1322
+ /** New PCM bytes that trigger another transcription pass. Default ~1.5s @ 16k mono s16le. */
1323
+ passEveryBytes?: number;
1324
+ }
1325
+ interface RealtimeDictation {
1326
+ push(pcm: Uint8Array): void;
1327
+ /** Stop, run a final correction pass over all audio, return the full transcript. */
1328
+ finish(): Promise<string>;
1329
+ cancel(): void;
1330
+ }
1331
+ /**
1332
+ * Client-driven incremental dictation: accumulates PCM and re-transcribes the whole
1333
+ * buffer every `passEveryBytes`, serialized so a slow model simply yields fewer passes.
1334
+ * Each partial re-derives the tail, so the latest words self-correct as more audio arrives;
1335
+ * `finish()` runs one last full pass.
1336
+ */
1337
+ declare function createRealtimeDictation(opts: RealtimeDictationOptions): RealtimeDictation;
1338
+
1339
+ interface ModelInfo {
1340
+ id: string;
1341
+ ownedBy?: string;
1342
+ }
1343
+ interface ChatFeatures {
1344
+ approvals?: boolean;
1345
+ subAgents?: boolean;
1346
+ sessionPicker?: boolean;
1347
+ modelPicker?: boolean;
1348
+ /** The active model accepts image input. Default off — must be opted in. */
1349
+ vision?: boolean;
1350
+ /** The active model accepts audio input. Default off — must be opted in. */
1351
+ audio?: boolean;
1352
+ }
1353
+ interface ChatHost {
1354
+ session?: AgentSession;
1355
+ approvals: ApprovalManager;
1356
+ cwd: string;
1357
+ createSession(): AgentSession;
1358
+ forkSession(id: string, upToIndex: number): Promise<AgentSession>;
1359
+ listSessions(): Promise<SessionRecord[]>;
1360
+ openSession(id: string): Promise<AgentSession>;
1361
+ selectModel(ref: string): void;
1362
+ modelRef(): string;
1363
+ listModels(): Promise<ModelInfo[]>;
1364
+ agentRef(): string;
1365
+ agentColor(): string | undefined;
1366
+ cycleAgent(): string;
1367
+ agentNames(): string[];
1368
+ subAgents: SubAgentRegistry;
1369
+ dispatchSubAgent(agent: string, task: string, parentId: string): Promise<SubAgentResult>;
1370
+ initialTheme: string;
1371
+ saveTheme(name: string): void;
1372
+ initialThinking: boolean;
1373
+ saveThinking(visible: boolean): void;
1374
+ history?: {
1375
+ load(): string[];
1376
+ append(text: string): void;
1377
+ };
1378
+ features?: ChatFeatures;
1379
+ voice?: {
1380
+ transcribe(audio: Uint8Array, mime: string): Promise<string>;
1381
+ unavailableReason?(): Promise<string | undefined>;
1382
+ };
1383
+ /** Subscribe to model load/unload state (cold-start). Optional — only WS-backed hosts emit it. */
1384
+ subscribeModelLoading?(listener: (model: string, loading: boolean) => void): () => void;
1385
+ banner?: string;
1386
+ minimal?: boolean;
1387
+ commands?(): {
1388
+ name: string;
1389
+ description: string;
1390
+ }[];
1391
+ runCommand?(input: string, ctx?: {
1392
+ session?: AgentSession;
1393
+ }): Promise<{
1394
+ ok: boolean;
1395
+ output?: unknown;
1396
+ error?: string;
1397
+ }>;
1398
+ onExit(code: number): void;
1399
+ }
1400
+ declare class ChatApp {
1401
+ private readonly host;
1402
+ private readonly tui;
1403
+ private readonly terminal;
1404
+ private readonly editor;
1405
+ private readonly scroll;
1406
+ private readonly transcript;
1407
+ private readonly subScroll;
1408
+ private readonly subTranscript;
1409
+ private readonly themeProvider;
1410
+ private readonly commands;
1411
+ private session;
1412
+ private readonly features;
1413
+ private readonly banner;
1414
+ private readonly minimal;
1415
+ private unsubscribe;
1416
+ private unsubscribeTheme;
1417
+ private unsubscribeSubAgents;
1418
+ private unsubscribeModelLoading;
1419
+ private modelLoading;
1420
+ private readonly runUnsubs;
1421
+ private readonly activeRuns;
1422
+ private mentionAc;
1423
+ private readonly status;
1424
+ private running;
1425
+ private readonly queue;
1426
+ private readonly pendingShell;
1427
+ private readonly pastes;
1428
+ private pasteSeq;
1429
+ private readonly attachments;
1430
+ private attachSeq;
1431
+ private models;
1432
+ private paletteCursor;
1433
+ private paletteDismissedFor;
1434
+ private pickerMention;
1435
+ private pickerRanked;
1436
+ private pickerCursor;
1437
+ private history;
1438
+ private historyIndex;
1439
+ private historyDraft;
1440
+ private spinnerTimer;
1441
+ private lastEsc;
1442
+ private modelPickerOpen;
1443
+ private modelHandle;
1444
+ private sessionPickerOpen;
1445
+ private sessionHandle;
1446
+ private approvalQueue;
1447
+ private approvalCursor;
1448
+ private unsubscribeApproval;
1449
+ private errorText;
1450
+ private errorTimer;
1451
+ private recording;
1452
+ private recordTimer;
1453
+ private recordStarting;
1454
+ private callRec;
1455
+ private callDict;
1456
+ private callStarting;
1457
+ private callTranscript;
1458
+ private callStart;
1459
+ private callTimer;
1460
+ private stopped;
1461
+ constructor(host: ChatHost);
1462
+ start(): Promise<void>;
1463
+ stop(): Promise<void>;
1464
+ private theme;
1465
+ private commandHost;
1466
+ private openSessionPicker;
1467
+ private buildSessionPicker;
1468
+ private bindSession;
1469
+ private feature;
1470
+ private ensureSession;
1471
+ private clearRuns;
1472
+ private abortRuns;
1473
+ private onSubAgentRun;
1474
+ private tryDispatch;
1475
+ private dispatchMention;
1476
+ private swapSession;
1477
+ private onModelLoading;
1478
+ private handleEvent;
1479
+ private applyUsage;
1480
+ private onTurnComplete;
1481
+ private stripFileMentions;
1482
+ private send;
1483
+ private capturePaste;
1484
+ private expandPastes;
1485
+ private capable;
1486
+ private pasteClipboardImage;
1487
+ private toggleVoice;
1488
+ private startVoice;
1489
+ private stopRecordTimer;
1490
+ private finishVoice;
1491
+ private cancelVoice;
1492
+ private callActive;
1493
+ private toggleCall;
1494
+ private startCall;
1495
+ private stopCallTimer;
1496
+ private finishCall;
1497
+ private cancelCall;
1498
+ private attachFromFile;
1499
+ private addAttachment;
1500
+ private stripAttachmentPlaceholders;
1501
+ private clearAttachments;
1502
+ private flushShellContext;
1503
+ private submit;
1504
+ private clearPastes;
1505
+ private enqueueFromInput;
1506
+ private onInputChange;
1507
+ private intercept;
1508
+ private cycleAgent;
1509
+ private onEscape;
1510
+ private cancelGeneration;
1511
+ private harnessCommands;
1512
+ private allCommands;
1513
+ private paletteItems;
1514
+ private paletteMove;
1515
+ private paletteComplete;
1516
+ private paletteRun;
1517
+ private runCommand;
1518
+ private pickerVisible;
1519
+ private pickerMove;
1520
+ private pickerAccept;
1521
+ private pushHistory;
1522
+ private navigateHistory;
1523
+ private newSession;
1524
+ private openModelPicker;
1525
+ private buildModelPicker;
1526
+ private moveApproval;
1527
+ private resolveApproval;
1528
+ private approvalView;
1529
+ private switchModel;
1530
+ private exportContext;
1531
+ private toggleExpand;
1532
+ private toggleThinking;
1533
+ private toggleTheme;
1534
+ private onCtrlC;
1535
+ private recordShell;
1536
+ private runShell;
1537
+ private setStatus;
1538
+ private showError;
1539
+ private clearError;
1540
+ private startSpinner;
1541
+ private stopSpinner;
1542
+ private loadModels;
1543
+ private modelLabel;
1544
+ private updateSpeaker;
1545
+ private promptGlyph;
1546
+ private inputPanel;
1547
+ private callView;
1548
+ private editorInner;
1549
+ private errorView;
1550
+ private waitingView;
1551
+ private inputGroup;
1552
+ private statusBar;
1553
+ private dock;
1554
+ private jumpToBottom;
1555
+ private jumpToBottomHint;
1556
+ private stickyHeaderView;
1557
+ private governingUser;
1558
+ private focusedSub;
1559
+ private subAgentHeader;
1560
+ private subAgentView;
1561
+ private centered;
1562
+ private bannerBlock;
1563
+ private root;
1564
+ }
1565
+
1566
+ interface ChatCommand {
1567
+ name: string;
1568
+ description: string;
1569
+ run: (args: string) => void | Promise<void>;
1570
+ }
1571
+ interface CommandHost {
1572
+ newSession(): void;
1573
+ openModelPicker(): void;
1574
+ toggleExpand(): void;
1575
+ toggleThinking(): void;
1576
+ exportContext(args: string): void | Promise<void>;
1577
+ listSessions(): void;
1578
+ voice(): void;
1579
+ call(): void;
1580
+ quit(): void;
1581
+ }
1582
+
1583
+ declare const runChat: (host: ChatHost) => ChatApp;
1584
+
1585
+ interface ConnectHarnessOptions {
1586
+ url: string;
1587
+ token?: string;
1588
+ sessionId?: string;
1589
+ cwd: string;
1590
+ initialTheme?: string;
1591
+ saveTheme?: (name: string) => void;
1592
+ initialThinking?: boolean;
1593
+ saveThinking?: (visible: boolean) => void;
1594
+ history?: {
1595
+ load(): string[];
1596
+ append(text: string): void;
1597
+ };
1598
+ banner?: string;
1599
+ minimal?: boolean;
1600
+ features?: ChatFeatures;
1601
+ onExit?: (code: number) => void;
1602
+ }
1603
+ interface RemoteHarness {
1604
+ host: ChatHost;
1605
+ close(): Promise<void>;
1606
+ }
1607
+ declare function connectHarness(opts: ConnectHarnessOptions): Promise<RemoteHarness>;
1608
+
1609
+ interface WsClientOptions {
1610
+ url: string;
1611
+ token?: string;
1612
+ sessionId?: string;
1613
+ }
1614
+ interface WsClient {
1615
+ connect(): Promise<void>;
1616
+ /** Returns false (frame dropped) when the socket is not OPEN, so callers can
1617
+ * settle a just-registered request waiter instead of hanging forever. */
1618
+ send(frame: WsInbound): boolean;
1619
+ on(handler: (frame: WsOutbound) => void): () => void;
1620
+ /** Fires once when the socket closes (after a normal close or an error), so the
1621
+ * caller can reject any in-flight request waiters. */
1622
+ onClose(handler: () => void): () => void;
1623
+ close(): Promise<void>;
1624
+ }
1625
+ declare function createWsClient(opts: WsClientOptions): WsClient;
1626
+
1627
+ interface Emitter<T> {
1628
+ emit(event: T): void;
1629
+ subscribe(listener: (event: T) => void): () => void;
1630
+ }
1631
+ declare const createEmitter: <T>() => Emitter<T>;
1632
+ declare const strList: (value: unknown) => string[];
1633
+
1634
+ interface Frontmatter {
1635
+ fields: Record<string, unknown>;
1636
+ body: string;
1637
+ }
1638
+ declare const parseFrontmatter: (source: string) => Frontmatter;
1639
+ declare const str: (value: unknown) => string | undefined;
1640
+
1641
+ declare const createHarness: (options: HarnessOptions) => Promise<Harness>;
1642
+
1643
+ type MemoryScope = 'local' | 'global';
1644
+ interface MemoryStore {
1645
+ /** Project-scoped memory file (cwd/.mu/MEMORY.md). */
1646
+ readonly localPath: string;
1647
+ /** Global memory file (dataDir/MEMORY.md), shared across all projects. */
1648
+ readonly globalPath: string;
1649
+ /** Concatenated memory (global then project), capped per scope, or undefined when empty. */
1650
+ load(): Promise<string | undefined>;
1651
+ /** Append a durable fact to the chosen scope's memory file. */
1652
+ remember(fact: string, scope: MemoryScope): Promise<void>;
1653
+ }
1654
+ declare function createMemoryStore(opts: {
1655
+ cwd: string;
1656
+ dataDir: string;
1657
+ }): MemoryStore;
1658
+ /** A `remember` tool the agent calls to persist durable facts to local or global memory. */
1659
+ declare function createRememberTool(store: MemoryStore): Tool;
1660
+
1661
+ /**
1662
+ * Load project-instruction files (AGENTS.md / CLAUDE.md, opencode-style) across harness
1663
+ * scopes: GLOBAL (configDir, every project) and LOCAL (cwd + ancestors, project-specific),
1664
+ * plus on-demand NESTED scopes — any subdirectory the agent has touched (`accessed`) whose
1665
+ * AGENTS.md should apply while working there. Concatenated shallow → deep so the most
1666
+ * specific instructions land last. Returns undefined when nothing is found.
1667
+ */
1668
+ declare function loadInstructions(cwd: string, configDir: string, opts?: {
1669
+ files?: readonly string[];
1670
+ accessed?: Iterable<string>;
1671
+ }): Promise<string | undefined>;
1672
+
1673
+ export { type ActiveMention, type Agent, type AgentRegistry, type AgentSession, type AgentSessionConfig, type AgentSessionEvent, type AgentSessionHooks, type ApprovalAction, type ApprovalCall, type ApprovalDecision, type ApprovalManager, type ApprovalManagerOptions, type Candidate, type Channel, type ChannelAdapter, type ChannelAdapterContext, type ChannelAdapterHandle, type ChannelEvent, type ChannelHost, type ChannelManager, type ChannelManagerEvent, ChatApp, type ChatCommand, type ChatFeatures, type ChatHost, type Command, type CommandContext, type CommandHost, type CommandRegistry, type CommandResult, type CompactionOptions, type ConnectHarnessOptions, type Emitter, type Entry, type Frontmatter, type GrantValue, type Harness, type HarnessConfig, type HarnessConfigOptions, type HarnessOptions, type MarkdownLine, type MemoryScope, type MemoryStore, type MentionRange, type ModelInfo, type ModelRegistry, type ModelRegistryOptions, MultilineEditor, type MultilineEditorOptions, type PendingApproval, type PersistedSessionWire, type Plugin, type PluginStore, type PreparedRequest, type RealtimeDictation, type RealtimeDictationOptions, type RecorderSpec, type RemoteHarness, type RequireApprovalOptions, type ResolveInput, type Resolved, type ResolvedModel, type ReviveInput, type RunChannelsOptions, type RunSkillDeps, type RunSubAgentDeps, type RunTitlerOptions, type Schedule, type Scheduler, type SchedulerEvent, type SessionCatalog, type SessionManager, type SessionManagerOptions, type SessionRecord, type SessionService, type SessionStore, type SessionSummaryWire, type Skill, type SkillCommandDeps, type SkillRegistry, type StartVoiceOptions, type StatusState, type StoredSession, type StreamingRecorderSpec, type StreamingRecording, type SubAgentEntry, type SubAgentEventWire, type SubAgentHandle, type SubAgentRegistry, type SubAgentResult, type SubAgentRun, type SubAgentStatus, type SubAgentToolCallDetail, type SubAgentToolResultDetail, type Task, type TaskInput, type TaskResult, type TaskRunner, type TaskStore, type TextStyle, type Theme, type ThemeColors, ThemeProvider, type ThemeStyles, type ThemeSubscriber, type ToolDecision, type ToolGrants, Transcript, VOICE_UNAVAILABLE, type VoiceOptions, type VoiceRecording, type VoiceTranscriber, type WebSocketAdapter, type WebSocketAdapterOptions, type WireAgent, type WireApprovalRequest, type WireAttachment, type WireCommand, type WireMessage, type WireModel, type WireRule, type WireSchedulerEvent, type WireSchedulerTask, type WireSessionChangeKind, type WsClient, type WsClientOptions, type WsInbound, type WsOutbound, type XdgDirs, activeMention, allowList, approvalRequestToWire, asHexColor, attachmentsToParts, bgToAnsi, cleanTitle, collectCandidates, connectHarness, createAgentRegistry, createAgentSession, createAgentsCommand, createApprovalManager, createChannel, createChannelManager, createCommandRegistry, createCompactCommand, createCompactionHook, createContextCommand, createEmitter, createHarness, createHarnessConfig, createHelpCommand, createMemoryStore, createMemoryTaskStore, createModelRegistry, createPluginStore, createQuitCommand, createRealtimeDictation, createRememberTool, createRunSkillTool, createScheduleTaskTool, createScheduler, createSessionCatalog, createSessionManager, createSessionService, createSessionStore, createSessionsCommand, createSkillCommand, createSkillRegistry, createSkillTool, createSkillsCommand, createSubAgentRegistry, createSubAgentTool, createTaskStore, createTasksCommand, createVoice, createWsClient, darkTheme, definePlugin, detectRecorder, detectStreamingRecorder, entryComponent, fgToAnsi, filterTools, formatTokens, formatToolArgs, grantArg, importModule, lightTheme, loadAgents, loadInstructions, loadSkills, markdown, matchesAnyGlob, mentionRanges, mergeHooks, messagesToWire, palette, parseAgent, parseFrontmatter, parseInbound, parseSkill, partsToAttachments, pcmToWav, persistTo, rank, renderMarkdown, requireApproval, resolve, runChannels, runChat, runSkill, runSubAgent, runTitler, skillMatchesPlatform, spinnerFrame, startRecording, startStreamingRecording, statusComponent, statusFromEvent, stickyHeader, str, strList, styleToAnsi, themesByName, titleFallback, toolDecision, toolNames, transcriptComponent, webSocketAdapter, withHooks };