@draht/coding-agent 2026.9.5-1 → 2026.10.4-3

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 (1015) hide show
  1. package/CHANGELOG.md +458 -0
  2. package/dist/bun/cli.d.ts +1 -1
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js +6 -3
  5. package/dist/bun/cli.js.map +1 -1
  6. package/dist/bun/sandbox-env-setup.d.ts +2 -0
  7. package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
  8. package/dist/bun/sandbox-env-setup.js +4 -0
  9. package/dist/bun/sandbox-env-setup.js.map +1 -0
  10. package/dist/bundle/chunks/anthropic-messages-E2P6C3P7.js +6 -0
  11. package/dist/bundle/chunks/anthropic.js +75 -0
  12. package/dist/bundle/chunks/azure-openai-responses-JZMSTDIM.js +2 -0
  13. package/dist/bundle/chunks/bedrock-converse-stream.js +79 -0
  14. package/dist/bundle/chunks/chunk-2E5VODES.js +2 -0
  15. package/dist/bundle/chunks/chunk-2FBJKY7F.js +2 -0
  16. package/dist/bundle/chunks/chunk-2JZLKNZ4.js +3 -0
  17. package/dist/bundle/chunks/chunk-2N4I6WXC.js +2 -0
  18. package/dist/bundle/chunks/chunk-3HF756LN.js +1472 -0
  19. package/dist/bundle/chunks/chunk-5QJFWTKA.js +4 -0
  20. package/dist/bundle/chunks/chunk-63BK6WK2.js +2 -0
  21. package/dist/bundle/chunks/chunk-A4OX5CPR.js +146 -0
  22. package/dist/bundle/chunks/chunk-AFL4IDSI.js +82 -0
  23. package/dist/bundle/chunks/chunk-D3HO453P.js +42 -0
  24. package/dist/bundle/chunks/chunk-EBVYI75P.js +2 -0
  25. package/dist/bundle/chunks/chunk-FBU742QF.js +2 -0
  26. package/dist/bundle/chunks/chunk-FHX2S5IG.js +31 -0
  27. package/dist/bundle/chunks/chunk-GBFVS2SF.js +12 -0
  28. package/dist/bundle/chunks/chunk-GVXA72ZA.js +2 -0
  29. package/dist/bundle/chunks/chunk-HJ72RANT.js +2 -0
  30. package/dist/bundle/chunks/chunk-HTJ3L72O.js +2 -0
  31. package/dist/bundle/chunks/chunk-HZ2UHMBT.js +2 -0
  32. package/dist/bundle/chunks/chunk-I5OKY6RH.js +11 -0
  33. package/dist/bundle/chunks/chunk-JTLUBTZT.js +2 -0
  34. package/dist/bundle/chunks/chunk-KPO5375S.js +2 -0
  35. package/dist/bundle/chunks/chunk-KY2BG6BC.js +11 -0
  36. package/dist/bundle/chunks/chunk-LO6CVU2L.js +6 -0
  37. package/dist/bundle/chunks/chunk-QMN7OD6G.js +2 -0
  38. package/dist/bundle/chunks/chunk-SDRCE6OP.js +2 -0
  39. package/dist/bundle/chunks/chunk-SPZUYYP5.js +170 -0
  40. package/dist/bundle/chunks/chunk-UTRX2VHB.js +44 -0
  41. package/dist/bundle/chunks/chunk-V5HG6S2T.js +4 -0
  42. package/dist/bundle/chunks/chunk-VPYAVQLP.js +137 -0
  43. package/dist/bundle/chunks/chunk-VXUJMEMO.js +2 -0
  44. package/dist/bundle/chunks/chunk-XBUEMKIY.js +2 -0
  45. package/dist/bundle/chunks/chunk-XHCO4PPH.js +8 -0
  46. package/dist/bundle/chunks/chunk-XO3IECI5.js +18 -0
  47. package/dist/bundle/chunks/chunk-XOGEYN4Q.js +2 -0
  48. package/dist/bundle/chunks/cli-L74YA5GF.js +51 -0
  49. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +2 -0
  50. package/dist/bundle/chunks/codemode-worker.js +315 -0
  51. package/dist/bundle/chunks/execute-EMOVNTD6.js +328 -0
  52. package/dist/bundle/chunks/github-copilot.js +2 -0
  53. package/dist/bundle/chunks/google-antigravity.js +75 -0
  54. package/dist/bundle/chunks/google-gemini-cli.js +75 -0
  55. package/dist/bundle/chunks/google-generative-ai-HPNDIAZD.js +2 -0
  56. package/dist/bundle/chunks/google-vertex-KPAWJ4SP.js +2 -0
  57. package/dist/bundle/chunks/https-proxy-agent-WQIRL24U.js +13 -0
  58. package/dist/bundle/chunks/image-resize-worker.js +2 -0
  59. package/dist/bundle/chunks/jiti-loader-RKXLMQV2.js +2 -0
  60. package/dist/bundle/chunks/kimi-coding.js +2 -0
  61. package/dist/bundle/chunks/lib-ULKZYRGD.js +9 -0
  62. package/dist/bundle/chunks/llama-cpp-classify-EJ5XMSQL.js +22 -0
  63. package/dist/bundle/chunks/meta.js +2 -0
  64. package/dist/bundle/chunks/mistral-conversations-FMSPWQ7A.js +5 -0
  65. package/dist/bundle/chunks/multipart-parser-HMCXZ4BD.js +3 -0
  66. package/dist/bundle/chunks/node-4JNG6XQO.js +16 -0
  67. package/dist/bundle/chunks/node-6IIDYB3K.js +2 -0
  68. package/dist/bundle/chunks/openai-chatgpt.js +75 -0
  69. package/dist/bundle/chunks/openai-codex-responses-TU7NGPXE.js +10 -0
  70. package/dist/bundle/chunks/openai-codex.js +75 -0
  71. package/dist/bundle/chunks/openai-completions-GANCQQO5.js +7 -0
  72. package/dist/bundle/chunks/openai-responses-ASDPAX3E.js +3 -0
  73. package/dist/bundle/chunks/opencode-go.js +2 -0
  74. package/dist/bundle/chunks/openrouter-images-NROSQXMZ.js +2 -0
  75. package/dist/bundle/chunks/openrouter.js +75 -0
  76. package/dist/bundle/chunks/pi-messages-2QEJYOAO.js +8 -0
  77. package/dist/bundle/chunks/radius.js +75 -0
  78. package/dist/bundle/chunks/runtime-RYUR6LRB.js +2 -0
  79. package/dist/bundle/chunks/settings-manager-CHEMMAGQ.js +2 -0
  80. package/dist/bundle/chunks/src-KDGO7EGF.js +4 -0
  81. package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +2 -0
  82. package/dist/bundle/chunks/virtual-modules-OC56AAJ7.js +2 -0
  83. package/dist/bundle/chunks/xai.js +75 -0
  84. package/dist/bundle/cli-runtime.js +3 -0
  85. package/dist/bundle/cli.js +5 -0
  86. package/dist/bundle/index.js +2 -0
  87. package/dist/bundle/rpc-entry.js +3 -0
  88. package/dist/cli/args.d.ts +4 -0
  89. package/dist/cli/args.d.ts.map +1 -1
  90. package/dist/cli/args.js +72 -21
  91. package/dist/cli/args.js.map +1 -1
  92. package/dist/cli/auth-check.d.ts +19 -0
  93. package/dist/cli/auth-check.d.ts.map +1 -0
  94. package/dist/cli/auth-check.js +50 -0
  95. package/dist/cli/auth-check.js.map +1 -0
  96. package/dist/cli/auth-command.d.ts +24 -0
  97. package/dist/cli/auth-command.d.ts.map +1 -0
  98. package/dist/cli/auth-command.js +103 -0
  99. package/dist/cli/auth-command.js.map +1 -0
  100. package/dist/cli/config-selector.d.ts.map +1 -1
  101. package/dist/cli/config-selector.js +3 -2
  102. package/dist/cli/config-selector.js.map +1 -1
  103. package/dist/cli/credential-print.d.ts +5 -3
  104. package/dist/cli/credential-print.d.ts.map +1 -1
  105. package/dist/cli/credential-print.js +42 -30
  106. package/dist/cli/credential-print.js.map +1 -1
  107. package/dist/cli/file-processor.d.ts +1 -1
  108. package/dist/cli/file-processor.d.ts.map +1 -1
  109. package/dist/cli/file-processor.js +2 -1
  110. package/dist/cli/file-processor.js.map +1 -1
  111. package/dist/cli/list-models.d.ts +1 -1
  112. package/dist/cli/list-models.d.ts.map +1 -1
  113. package/dist/cli/list-models.js +2 -2
  114. package/dist/cli/list-models.js.map +1 -1
  115. package/dist/cli/session-picker.d.ts +1 -1
  116. package/dist/cli/session-picker.d.ts.map +1 -1
  117. package/dist/cli/session-picker.js.map +1 -1
  118. package/dist/cli/setup.d.ts +2 -0
  119. package/dist/cli/setup.d.ts.map +1 -0
  120. package/dist/cli/setup.js +12 -0
  121. package/dist/cli/setup.js.map +1 -0
  122. package/dist/cli/startup-ui.d.ts +2 -2
  123. package/dist/cli/startup-ui.d.ts.map +1 -1
  124. package/dist/cli/startup-ui.js +42 -33
  125. package/dist/cli/startup-ui.js.map +1 -1
  126. package/dist/cli.js +3 -12
  127. package/dist/cli.js.map +1 -1
  128. package/dist/config.d.ts +20 -4
  129. package/dist/config.d.ts.map +1 -1
  130. package/dist/config.js +42 -6
  131. package/dist/config.js.map +1 -1
  132. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  133. package/dist/core/agent-session-runtime.js +12 -3
  134. package/dist/core/agent-session-runtime.js.map +1 -1
  135. package/dist/core/agent-session-services.d.ts +1 -0
  136. package/dist/core/agent-session-services.d.ts.map +1 -1
  137. package/dist/core/agent-session-services.js +14 -0
  138. package/dist/core/agent-session-services.js.map +1 -1
  139. package/dist/core/agent-session.d.ts +237 -39
  140. package/dist/core/agent-session.d.ts.map +1 -1
  141. package/dist/core/agent-session.js +1386 -565
  142. package/dist/core/agent-session.js.map +1 -1
  143. package/dist/core/auth-storage.d.ts +20 -8
  144. package/dist/core/auth-storage.d.ts.map +1 -1
  145. package/dist/core/auth-storage.js +199 -56
  146. package/dist/core/auth-storage.js.map +1 -1
  147. package/dist/core/bug-report-upload.d.ts +11 -0
  148. package/dist/core/bug-report-upload.d.ts.map +1 -0
  149. package/dist/core/bug-report-upload.js +20 -0
  150. package/dist/core/bug-report-upload.js.map +1 -0
  151. package/dist/core/bug-report.d.ts +176 -0
  152. package/dist/core/bug-report.d.ts.map +1 -0
  153. package/dist/core/bug-report.js +292 -0
  154. package/dist/core/bug-report.js.map +1 -0
  155. package/dist/core/builtins/duet.js +2 -2
  156. package/dist/core/builtins/duet.js.map +1 -1
  157. package/dist/core/cache-stats.d.ts.map +1 -1
  158. package/dist/core/cache-stats.js +12 -1
  159. package/dist/core/cache-stats.js.map +1 -1
  160. package/dist/core/cache-warmer.d.ts +103 -0
  161. package/dist/core/cache-warmer.d.ts.map +1 -0
  162. package/dist/core/cache-warmer.js +356 -0
  163. package/dist/core/cache-warmer.js.map +1 -0
  164. package/dist/core/checkpoints/checkpoint-manager.d.ts +8 -4
  165. package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -1
  166. package/dist/core/checkpoints/checkpoint-manager.js +46 -10
  167. package/dist/core/checkpoints/checkpoint-manager.js.map +1 -1
  168. package/dist/core/checkpoints/rewind.d.ts +4 -2
  169. package/dist/core/checkpoints/rewind.d.ts.map +1 -1
  170. package/dist/core/checkpoints/rewind.js +4 -3
  171. package/dist/core/checkpoints/rewind.js.map +1 -1
  172. package/dist/core/compaction/branch-summarization.js +2 -2
  173. package/dist/core/compaction/branch-summarization.js.map +1 -1
  174. package/dist/core/compaction/compaction.d.ts +9 -6
  175. package/dist/core/compaction/compaction.d.ts.map +1 -1
  176. package/dist/core/compaction/compaction.js +196 -118
  177. package/dist/core/compaction/compaction.js.map +1 -1
  178. package/dist/core/compaction/utils.d.ts +2 -1
  179. package/dist/core/compaction/utils.d.ts.map +1 -1
  180. package/dist/core/compaction/utils.js +25 -18
  181. package/dist/core/compaction/utils.js.map +1 -1
  182. package/dist/core/context-windows.d.ts.map +1 -1
  183. package/dist/core/context-windows.js +13 -3
  184. package/dist/core/context-windows.js.map +1 -1
  185. package/dist/core/crash-log.d.ts +27 -0
  186. package/dist/core/crash-log.d.ts.map +1 -0
  187. package/dist/core/crash-log.js +140 -0
  188. package/dist/core/crash-log.js.map +1 -0
  189. package/dist/core/defaults.d.ts +1 -0
  190. package/dist/core/defaults.d.ts.map +1 -1
  191. package/dist/core/defaults.js +9 -0
  192. package/dist/core/defaults.js.map +1 -1
  193. package/dist/core/experimental.js +1 -1
  194. package/dist/core/experimental.js.map +1 -1
  195. package/dist/core/export-html/template.css +10 -0
  196. package/dist/core/export-html/template.js +72 -18
  197. package/dist/core/extensions/index.d.ts +2 -2
  198. package/dist/core/extensions/index.d.ts.map +1 -1
  199. package/dist/core/extensions/index.js +1 -1
  200. package/dist/core/extensions/index.js.map +1 -1
  201. package/dist/core/extensions/jiti-loader.d.ts +2 -0
  202. package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
  203. package/dist/core/extensions/jiti-loader.js +5 -0
  204. package/dist/core/extensions/jiti-loader.js.map +1 -0
  205. package/dist/core/extensions/loader.d.ts.map +1 -1
  206. package/dist/core/extensions/loader.js +228 -89
  207. package/dist/core/extensions/loader.js.map +1 -1
  208. package/dist/core/extensions/runner.d.ts +47 -8
  209. package/dist/core/extensions/runner.d.ts.map +1 -1
  210. package/dist/core/extensions/runner.js +376 -104
  211. package/dist/core/extensions/runner.js.map +1 -1
  212. package/dist/core/extensions/types.d.ts +521 -88
  213. package/dist/core/extensions/types.d.ts.map +1 -1
  214. package/dist/core/extensions/types.js +3 -0
  215. package/dist/core/extensions/types.js.map +1 -1
  216. package/dist/core/extensions/virtual-modules.d.ts +3 -0
  217. package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
  218. package/dist/core/extensions/virtual-modules.js +37 -0
  219. package/dist/core/extensions/virtual-modules.js.map +1 -0
  220. package/dist/core/extensions/wrapper.d.ts +2 -2
  221. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  222. package/dist/core/extensions/wrapper.js +3 -22
  223. package/dist/core/extensions/wrapper.js.map +1 -1
  224. package/dist/core/footer-data-provider.d.ts +1 -1
  225. package/dist/core/footer-data-provider.js +19 -18
  226. package/dist/core/footer-data-provider.js.map +1 -1
  227. package/dist/core/index.d.ts +2 -1
  228. package/dist/core/index.d.ts.map +1 -1
  229. package/dist/core/index.js.map +1 -1
  230. package/dist/core/keybindings.d.ts +83 -13
  231. package/dist/core/keybindings.d.ts.map +1 -1
  232. package/dist/core/keybindings.js +33 -7
  233. package/dist/core/keybindings.js.map +1 -1
  234. package/dist/core/mcp-servers.d.ts +119 -0
  235. package/dist/core/mcp-servers.d.ts.map +1 -0
  236. package/dist/core/mcp-servers.js +191 -0
  237. package/dist/core/mcp-servers.js.map +1 -0
  238. package/dist/core/messages.d.ts +1 -1
  239. package/dist/core/messages.d.ts.map +1 -1
  240. package/dist/core/messages.js +1 -0
  241. package/dist/core/messages.js.map +1 -1
  242. package/dist/core/model-config.d.ts +202 -20
  243. package/dist/core/model-config.d.ts.map +1 -1
  244. package/dist/core/model-config.js +53 -18
  245. package/dist/core/model-config.js.map +1 -1
  246. package/dist/core/model-registry.d.ts +19 -2
  247. package/dist/core/model-registry.d.ts.map +1 -1
  248. package/dist/core/model-registry.js +39 -2
  249. package/dist/core/model-registry.js.map +1 -1
  250. package/dist/core/model-resolver.d.ts +7 -5
  251. package/dist/core/model-resolver.d.ts.map +1 -1
  252. package/dist/core/model-resolver.js +29 -17
  253. package/dist/core/model-resolver.js.map +1 -1
  254. package/dist/core/model-runtime.d.ts +79 -20
  255. package/dist/core/model-runtime.d.ts.map +1 -1
  256. package/dist/core/model-runtime.js +460 -134
  257. package/dist/core/model-runtime.js.map +1 -1
  258. package/dist/core/models-store.d.ts +12 -7
  259. package/dist/core/models-store.d.ts.map +1 -1
  260. package/dist/core/models-store.js +87 -18
  261. package/dist/core/models-store.js.map +1 -1
  262. package/dist/core/multi-agent/fsm.js +8 -3
  263. package/dist/core/multi-agent/fsm.js.map +1 -1
  264. package/dist/core/multi-agent/mailbox.js +1 -3
  265. package/dist/core/multi-agent/mailbox.js.map +1 -1
  266. package/dist/core/multi-agent/permission-gate.d.ts +5 -2
  267. package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
  268. package/dist/core/multi-agent/permission-gate.js +597 -34
  269. package/dist/core/multi-agent/permission-gate.js.map +1 -1
  270. package/dist/core/multi-agent/task-board.js +2 -4
  271. package/dist/core/multi-agent/task-board.js.map +1 -1
  272. package/dist/core/multi-agent/worktree.js +1 -3
  273. package/dist/core/multi-agent/worktree.js.map +1 -1
  274. package/dist/core/nested-tool-calls.d.ts +102 -0
  275. package/dist/core/nested-tool-calls.d.ts.map +1 -0
  276. package/dist/core/nested-tool-calls.js +178 -0
  277. package/dist/core/nested-tool-calls.js.map +1 -0
  278. package/dist/core/package-manager.d.ts +10 -0
  279. package/dist/core/package-manager.d.ts.map +1 -1
  280. package/dist/core/package-manager.js +149 -33
  281. package/dist/core/package-manager.js.map +1 -1
  282. package/dist/core/pi-manifest.d.ts.map +1 -1
  283. package/dist/core/pi-manifest.js +13 -12
  284. package/dist/core/pi-manifest.js.map +1 -1
  285. package/dist/core/prompt-templates.d.ts +6 -1
  286. package/dist/core/prompt-templates.d.ts.map +1 -1
  287. package/dist/core/prompt-templates.js +63 -37
  288. package/dist/core/prompt-templates.js.map +1 -1
  289. package/dist/core/provider-attribution.js +5 -5
  290. package/dist/core/provider-attribution.js.map +1 -1
  291. package/dist/core/provider-composer.d.ts +44 -20
  292. package/dist/core/provider-composer.d.ts.map +1 -1
  293. package/dist/core/provider-composer.js +151 -51
  294. package/dist/core/provider-composer.js.map +1 -1
  295. package/dist/core/radius.d.ts +13 -0
  296. package/dist/core/radius.d.ts.map +1 -1
  297. package/dist/core/radius.js +19 -0
  298. package/dist/core/radius.js.map +1 -1
  299. package/dist/core/remote-catalog-provider.d.ts +10 -3
  300. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  301. package/dist/core/remote-catalog-provider.js +105 -81
  302. package/dist/core/remote-catalog-provider.js.map +1 -1
  303. package/dist/core/resource-loader.d.ts +7 -1
  304. package/dist/core/resource-loader.d.ts.map +1 -1
  305. package/dist/core/resource-loader.js +219 -42
  306. package/dist/core/resource-loader.js.map +1 -1
  307. package/dist/core/runtime-credentials.d.ts +5 -5
  308. package/dist/core/runtime-credentials.d.ts.map +1 -1
  309. package/dist/core/runtime-credentials.js +13 -9
  310. package/dist/core/runtime-credentials.js.map +1 -1
  311. package/dist/core/sandbox/executor.js +1 -0
  312. package/dist/core/sandbox/executor.js.map +1 -1
  313. package/dist/core/sdk.d.ts +7 -5
  314. package/dist/core/sdk.d.ts.map +1 -1
  315. package/dist/core/sdk.js +100 -52
  316. package/dist/core/sdk.js.map +1 -1
  317. package/dist/core/session-cwd.js +1 -0
  318. package/dist/core/session-cwd.js.map +1 -1
  319. package/dist/core/session-export.d.ts +8 -0
  320. package/dist/core/session-export.d.ts.map +1 -0
  321. package/dist/core/session-export.js +33 -0
  322. package/dist/core/session-export.js.map +1 -0
  323. package/dist/core/session-manager.d.ts +75 -15
  324. package/dist/core/session-manager.d.ts.map +1 -1
  325. package/dist/core/session-manager.js +314 -144
  326. package/dist/core/session-manager.js.map +1 -1
  327. package/dist/core/settings-diagnostics.d.ts +9 -0
  328. package/dist/core/settings-diagnostics.d.ts.map +1 -0
  329. package/dist/core/settings-diagnostics.js +21 -0
  330. package/dist/core/settings-diagnostics.js.map +1 -0
  331. package/dist/core/settings-manager.d.ts +84 -4
  332. package/dist/core/settings-manager.d.ts.map +1 -1
  333. package/dist/core/settings-manager.js +239 -25
  334. package/dist/core/settings-manager.js.map +1 -1
  335. package/dist/core/skills.d.ts.map +1 -1
  336. package/dist/core/skills.js +51 -33
  337. package/dist/core/skills.js.map +1 -1
  338. package/dist/core/slash-commands.d.ts.map +1 -1
  339. package/dist/core/slash-commands.js +3 -1
  340. package/dist/core/slash-commands.js.map +1 -1
  341. package/dist/core/soak/soak-log.js +6 -0
  342. package/dist/core/soak/soak-log.js.map +1 -1
  343. package/dist/core/socket-server/socket-server.js +11 -0
  344. package/dist/core/socket-server/socket-server.js.map +1 -1
  345. package/dist/core/socket-server/types.d.ts +2 -1
  346. package/dist/core/socket-server/types.d.ts.map +1 -1
  347. package/dist/core/socket-server/types.js.map +1 -1
  348. package/dist/core/source-info.d.ts +8 -0
  349. package/dist/core/source-info.d.ts.map +1 -1
  350. package/dist/core/source-info.js +16 -0
  351. package/dist/core/source-info.js.map +1 -1
  352. package/dist/core/system-prompt.d.ts +49 -6
  353. package/dist/core/system-prompt.d.ts.map +1 -1
  354. package/dist/core/system-prompt.js +126 -89
  355. package/dist/core/system-prompt.js.map +1 -1
  356. package/dist/core/tools/bash.d.ts +32 -2
  357. package/dist/core/tools/bash.d.ts.map +1 -1
  358. package/dist/core/tools/bash.js +82 -143
  359. package/dist/core/tools/bash.js.map +1 -1
  360. package/dist/core/tools/edit-diff.d.ts +0 -5
  361. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  362. package/dist/core/tools/edit-diff.js +2 -5
  363. package/dist/core/tools/edit-diff.js.map +1 -1
  364. package/dist/core/tools/edit.d.ts +5 -12
  365. package/dist/core/tools/edit.d.ts.map +1 -1
  366. package/dist/core/tools/edit.js +19 -171
  367. package/dist/core/tools/edit.js.map +1 -1
  368. package/dist/core/tools/find.d.ts +4 -0
  369. package/dist/core/tools/find.d.ts.map +1 -1
  370. package/dist/core/tools/find.js +11 -58
  371. package/dist/core/tools/find.js.map +1 -1
  372. package/dist/core/tools/grep.d.ts +4 -0
  373. package/dist/core/tools/grep.d.ts.map +1 -1
  374. package/dist/core/tools/grep.js +10 -62
  375. package/dist/core/tools/grep.js.map +1 -1
  376. package/dist/core/tools/index.d.ts +4 -1
  377. package/dist/core/tools/index.d.ts.map +1 -1
  378. package/dist/core/tools/index.js +18 -1
  379. package/dist/core/tools/index.js.map +1 -1
  380. package/dist/core/tools/ls.d.ts +4 -0
  381. package/dist/core/tools/ls.d.ts.map +1 -1
  382. package/dist/core/tools/ls.js +9 -50
  383. package/dist/core/tools/ls.js.map +1 -1
  384. package/dist/core/tools/output-accumulator.d.ts +11 -0
  385. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  386. package/dist/core/tools/output-accumulator.js +54 -12
  387. package/dist/core/tools/output-accumulator.js.map +1 -1
  388. package/dist/core/tools/powershell.d.ts +16 -0
  389. package/dist/core/tools/powershell.d.ts.map +1 -0
  390. package/dist/core/tools/powershell.js +39 -0
  391. package/dist/core/tools/powershell.js.map +1 -0
  392. package/dist/core/tools/read.d.ts +8 -1
  393. package/dist/core/tools/read.d.ts.map +1 -1
  394. package/dist/core/tools/read.js +16 -123
  395. package/dist/core/tools/read.js.map +1 -1
  396. package/dist/core/tools/render-utils.d.ts +6 -0
  397. package/dist/core/tools/render-utils.d.ts.map +1 -1
  398. package/dist/core/tools/render-utils.js +26 -0
  399. package/dist/core/tools/render-utils.js.map +1 -1
  400. package/dist/core/tools/renderers/bash.d.ts +12 -0
  401. package/dist/core/tools/renderers/bash.d.ts.map +1 -0
  402. package/dist/core/tools/renderers/bash.js +117 -0
  403. package/dist/core/tools/renderers/bash.js.map +1 -0
  404. package/dist/core/tools/renderers/edit.d.ts +23 -0
  405. package/dist/core/tools/renderers/edit.d.ts.map +1 -0
  406. package/dist/core/tools/renderers/edit.js +167 -0
  407. package/dist/core/tools/renderers/edit.js.map +1 -0
  408. package/dist/core/tools/renderers/find.d.ts +10 -0
  409. package/dist/core/tools/renderers/find.d.ts.map +1 -0
  410. package/dist/core/tools/renderers/find.js +64 -0
  411. package/dist/core/tools/renderers/find.js.map +1 -0
  412. package/dist/core/tools/renderers/grep.d.ts +10 -0
  413. package/dist/core/tools/renderers/grep.d.ts.map +1 -0
  414. package/dist/core/tools/renderers/grep.js +69 -0
  415. package/dist/core/tools/renderers/grep.js.map +1 -0
  416. package/dist/core/tools/renderers/index.d.ts +28 -0
  417. package/dist/core/tools/renderers/index.d.ts.map +1 -0
  418. package/dist/core/tools/renderers/index.js +47 -0
  419. package/dist/core/tools/renderers/index.js.map +1 -0
  420. package/dist/core/tools/renderers/ls.d.ts +10 -0
  421. package/dist/core/tools/renderers/ls.d.ts.map +1 -0
  422. package/dist/core/tools/renderers/ls.js +58 -0
  423. package/dist/core/tools/renderers/ls.js.map +1 -0
  424. package/dist/core/tools/renderers/read.d.ts +11 -0
  425. package/dist/core/tools/renderers/read.d.ts.map +1 -0
  426. package/dist/core/tools/renderers/read.js +130 -0
  427. package/dist/core/tools/renderers/read.js.map +1 -0
  428. package/dist/core/tools/renderers/write.d.ts +10 -0
  429. package/dist/core/tools/renderers/write.d.ts.map +1 -0
  430. package/dist/core/tools/renderers/write.js +153 -0
  431. package/dist/core/tools/renderers/write.js.map +1 -0
  432. package/dist/core/tools/tool-definition-wrapper.d.ts +5 -3
  433. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  434. package/dist/core/tools/tool-definition-wrapper.js +3 -1
  435. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  436. package/dist/core/tools/truncate.d.ts +14 -0
  437. package/dist/core/tools/truncate.d.ts.map +1 -1
  438. package/dist/core/tools/truncate.js +29 -0
  439. package/dist/core/tools/truncate.js.map +1 -1
  440. package/dist/core/tools/write.d.ts +4 -0
  441. package/dist/core/tools/write.d.ts.map +1 -1
  442. package/dist/core/tools/write.js +12 -147
  443. package/dist/core/tools/write.js.map +1 -1
  444. package/dist/core/trust-manager.d.ts.map +1 -1
  445. package/dist/core/trust-manager.js +4 -1
  446. package/dist/core/trust-manager.js.map +1 -1
  447. package/dist/core/usage-totals.d.ts +3 -1
  448. package/dist/core/usage-totals.d.ts.map +1 -1
  449. package/dist/core/usage-totals.js +28 -1
  450. package/dist/core/usage-totals.js.map +1 -1
  451. package/dist/core/virtual-models.d.ts +117 -0
  452. package/dist/core/virtual-models.d.ts.map +1 -0
  453. package/dist/core/virtual-models.js +124 -0
  454. package/dist/core/virtual-models.js.map +1 -0
  455. package/dist/experimental/micro/api.d.ts +81 -0
  456. package/dist/experimental/micro/api.d.ts.map +1 -0
  457. package/dist/experimental/micro/api.js +2 -0
  458. package/dist/experimental/micro/api.js.map +1 -0
  459. package/dist/experimental/micro/main.d.ts +3 -0
  460. package/dist/experimental/micro/main.d.ts.map +1 -0
  461. package/dist/experimental/micro/main.js +21 -0
  462. package/dist/experimental/micro/main.js.map +1 -0
  463. package/dist/experimental/micro/models.d.ts +11 -0
  464. package/dist/experimental/micro/models.d.ts.map +1 -0
  465. package/dist/experimental/micro/models.js +95 -0
  466. package/dist/experimental/micro/models.js.map +1 -0
  467. package/dist/experimental/micro/runtime.d.ts +12 -0
  468. package/dist/experimental/micro/runtime.d.ts.map +1 -0
  469. package/dist/experimental/micro/runtime.js +465 -0
  470. package/dist/experimental/micro/runtime.js.map +1 -0
  471. package/dist/experimental/micro/sessions.d.ts +10 -0
  472. package/dist/experimental/micro/sessions.d.ts.map +1 -0
  473. package/dist/experimental/micro/sessions.js +41 -0
  474. package/dist/experimental/micro/sessions.js.map +1 -0
  475. package/dist/experimental/micro/tools.d.ts +10 -0
  476. package/dist/experimental/micro/tools.d.ts.map +1 -0
  477. package/dist/experimental/micro/tools.js +96 -0
  478. package/dist/experimental/micro/tools.js.map +1 -0
  479. package/dist/experimental/micro/tui.d.ts +3 -0
  480. package/dist/experimental/micro/tui.d.ts.map +1 -0
  481. package/dist/experimental/micro/tui.js +510 -0
  482. package/dist/experimental/micro/tui.js.map +1 -0
  483. package/dist/experimental/mini/main.d.ts +7 -0
  484. package/dist/experimental/mini/main.d.ts.map +1 -0
  485. package/dist/experimental/mini/main.js +21 -0
  486. package/dist/experimental/mini/main.js.map +1 -0
  487. package/dist/experimental/mini/server/entry.d.ts +3 -0
  488. package/dist/experimental/mini/server/entry.d.ts.map +1 -0
  489. package/dist/experimental/mini/server/entry.js +11 -0
  490. package/dist/experimental/mini/server/entry.js.map +1 -0
  491. package/dist/experimental/mini/server/run.d.ts +13 -0
  492. package/dist/experimental/mini/server/run.d.ts.map +1 -0
  493. package/dist/experimental/mini/server/run.js +150 -0
  494. package/dist/experimental/mini/server/run.js.map +1 -0
  495. package/dist/experimental/mini/shared/protocol.d.ts +127 -0
  496. package/dist/experimental/mini/shared/protocol.d.ts.map +1 -0
  497. package/dist/experimental/mini/shared/protocol.js +13 -0
  498. package/dist/experimental/mini/shared/protocol.js.map +1 -0
  499. package/dist/experimental/mini/shared/rpc.d.ts +49 -0
  500. package/dist/experimental/mini/shared/rpc.d.ts.map +1 -0
  501. package/dist/experimental/mini/shared/rpc.js +171 -0
  502. package/dist/experimental/mini/shared/rpc.js.map +1 -0
  503. package/dist/experimental/mini/shared/transport.d.ts +35 -0
  504. package/dist/experimental/mini/shared/transport.d.ts.map +1 -0
  505. package/dist/experimental/mini/shared/transport.js +94 -0
  506. package/dist/experimental/mini/shared/transport.js.map +1 -0
  507. package/dist/experimental/mini/tui/run.d.ts +9 -0
  508. package/dist/experimental/mini/tui/run.d.ts.map +1 -0
  509. package/dist/experimental/mini/tui/run.js +62 -0
  510. package/dist/experimental/mini/tui/run.js.map +1 -0
  511. package/dist/experimental/mini/tui/session.d.ts +26 -0
  512. package/dist/experimental/mini/tui/session.d.ts.map +1 -0
  513. package/dist/experimental/mini/tui/session.js +94 -0
  514. package/dist/experimental/mini/tui/session.js.map +1 -0
  515. package/dist/experimental/mini/tui/view.d.ts +10 -0
  516. package/dist/experimental/mini/tui/view.d.ts.map +1 -0
  517. package/dist/experimental/mini/tui/view.js +461 -0
  518. package/dist/experimental/mini/tui/view.js.map +1 -0
  519. package/dist/experimental/mini/worker/entry.d.ts +3 -0
  520. package/dist/experimental/mini/worker/entry.d.ts.map +1 -0
  521. package/dist/experimental/mini/worker/entry.js +10 -0
  522. package/dist/experimental/mini/worker/entry.js.map +1 -0
  523. package/dist/experimental/mini/worker/lane-service.d.ts +44 -0
  524. package/dist/experimental/mini/worker/lane-service.d.ts.map +1 -0
  525. package/dist/experimental/mini/worker/lane-service.js +97 -0
  526. package/dist/experimental/mini/worker/lane-service.js.map +1 -0
  527. package/dist/experimental/mini/worker/models-service.d.ts +19 -0
  528. package/dist/experimental/mini/worker/models-service.d.ts.map +1 -0
  529. package/dist/experimental/mini/worker/models-service.js +136 -0
  530. package/dist/experimental/mini/worker/models-service.js.map +1 -0
  531. package/dist/experimental/mini/worker/run.d.ts +14 -0
  532. package/dist/experimental/mini/worker/run.d.ts.map +1 -0
  533. package/dist/experimental/mini/worker/run.js +88 -0
  534. package/dist/experimental/mini/worker/run.js.map +1 -0
  535. package/dist/extensions/codemode/execute.d.ts +16 -0
  536. package/dist/extensions/codemode/execute.d.ts.map +1 -0
  537. package/dist/extensions/codemode/execute.js +429 -0
  538. package/dist/extensions/codemode/execute.js.map +1 -0
  539. package/dist/extensions/codemode/execute.lazy.d.ts +3 -0
  540. package/dist/extensions/codemode/execute.lazy.d.ts.map +1 -0
  541. package/dist/extensions/codemode/execute.lazy.js +3 -0
  542. package/dist/extensions/codemode/execute.lazy.js.map +1 -0
  543. package/dist/extensions/codemode/index.d.ts +21 -0
  544. package/dist/extensions/codemode/index.d.ts.map +1 -0
  545. package/dist/extensions/codemode/index.js +31 -0
  546. package/dist/extensions/codemode/index.js.map +1 -0
  547. package/dist/extensions/codemode/renderer.d.ts +12 -0
  548. package/dist/extensions/codemode/renderer.d.ts.map +1 -0
  549. package/dist/extensions/codemode/renderer.js +137 -0
  550. package/dist/extensions/codemode/renderer.js.map +1 -0
  551. package/dist/extensions/codemode/tool.d.ts +123 -0
  552. package/dist/extensions/codemode/tool.d.ts.map +1 -0
  553. package/dist/extensions/codemode/tool.js +315 -0
  554. package/dist/extensions/codemode/tool.js.map +1 -0
  555. package/dist/extensions/codemode/worker.d.ts +7 -0
  556. package/dist/extensions/codemode/worker.d.ts.map +1 -0
  557. package/dist/extensions/codemode/worker.js +7 -0
  558. package/dist/extensions/codemode/worker.js.map +1 -0
  559. package/dist/extensions/index.d.ts.map +1 -1
  560. package/dist/extensions/index.js +9 -1
  561. package/dist/extensions/index.js.map +1 -1
  562. package/dist/extensions/llama/client.d.ts +8 -0
  563. package/dist/extensions/llama/client.d.ts.map +1 -1
  564. package/dist/extensions/llama/client.js +13 -0
  565. package/dist/extensions/llama/client.js.map +1 -1
  566. package/dist/extensions/llama/huggingface.js +2 -0
  567. package/dist/extensions/llama/huggingface.js.map +1 -1
  568. package/dist/extensions/llama/index.d.ts.map +1 -1
  569. package/dist/extensions/llama/index.js +13 -2
  570. package/dist/extensions/llama/index.js.map +1 -1
  571. package/dist/extensions/llama/provider.d.ts +4 -2
  572. package/dist/extensions/llama/provider.d.ts.map +1 -1
  573. package/dist/extensions/llama/provider.js +119 -17
  574. package/dist/extensions/llama/provider.js.map +1 -1
  575. package/dist/extensions/llama/ui.js +28 -12
  576. package/dist/extensions/llama/ui.js.map +1 -1
  577. package/dist/extensions/mcp/cli.d.ts +21 -0
  578. package/dist/extensions/mcp/cli.d.ts.map +1 -0
  579. package/dist/extensions/mcp/cli.js +500 -0
  580. package/dist/extensions/mcp/cli.js.map +1 -0
  581. package/dist/extensions/mcp/cli.lazy.d.ts +3 -0
  582. package/dist/extensions/mcp/cli.lazy.d.ts.map +1 -0
  583. package/dist/extensions/mcp/cli.lazy.js +3 -0
  584. package/dist/extensions/mcp/cli.lazy.js.map +1 -0
  585. package/dist/extensions/mcp/config.d.ts +72 -0
  586. package/dist/extensions/mcp/config.d.ts.map +1 -0
  587. package/dist/extensions/mcp/config.js +158 -0
  588. package/dist/extensions/mcp/config.js.map +1 -0
  589. package/dist/extensions/mcp/index.d.ts +76 -0
  590. package/dist/extensions/mcp/index.d.ts.map +1 -0
  591. package/dist/extensions/mcp/index.js +1055 -0
  592. package/dist/extensions/mcp/index.js.map +1 -0
  593. package/dist/extensions/mcp/log.d.ts +16 -0
  594. package/dist/extensions/mcp/log.d.ts.map +1 -0
  595. package/dist/extensions/mcp/log.js +66 -0
  596. package/dist/extensions/mcp/log.js.map +1 -0
  597. package/dist/extensions/mcp/oauth.d.ts +96 -0
  598. package/dist/extensions/mcp/oauth.d.ts.map +1 -0
  599. package/dist/extensions/mcp/oauth.js +333 -0
  600. package/dist/extensions/mcp/oauth.js.map +1 -0
  601. package/dist/extensions/mcp/resources.d.ts +43 -0
  602. package/dist/extensions/mcp/resources.d.ts.map +1 -0
  603. package/dist/extensions/mcp/resources.js +262 -0
  604. package/dist/extensions/mcp/resources.js.map +1 -0
  605. package/dist/extensions/mcp/runtime.d.ts +98 -0
  606. package/dist/extensions/mcp/runtime.d.ts.map +1 -0
  607. package/dist/extensions/mcp/runtime.js +394 -0
  608. package/dist/extensions/mcp/runtime.js.map +1 -0
  609. package/dist/extensions/mcp/runtime.lazy.d.ts +3 -0
  610. package/dist/extensions/mcp/runtime.lazy.d.ts.map +1 -0
  611. package/dist/extensions/mcp/runtime.lazy.js +3 -0
  612. package/dist/extensions/mcp/runtime.lazy.js.map +1 -0
  613. package/dist/extensions/mcp/tools.d.ts +84 -0
  614. package/dist/extensions/mcp/tools.d.ts.map +1 -0
  615. package/dist/extensions/mcp/tools.js +251 -0
  616. package/dist/extensions/mcp/tools.js.map +1 -0
  617. package/dist/extensions/mcp/ui.d.ts +60 -0
  618. package/dist/extensions/mcp/ui.d.ts.map +1 -0
  619. package/dist/extensions/mcp/ui.js +174 -0
  620. package/dist/extensions/mcp/ui.js.map +1 -0
  621. package/dist/extensions/stub-provider/provider.d.ts +2 -2
  622. package/dist/extensions/stub-provider/provider.d.ts.map +1 -1
  623. package/dist/extensions/stub-provider/provider.js +2 -1
  624. package/dist/extensions/stub-provider/provider.js.map +1 -1
  625. package/dist/extensions/tool-search/index.d.ts +12 -0
  626. package/dist/extensions/tool-search/index.d.ts.map +1 -0
  627. package/dist/extensions/tool-search/index.js +15 -0
  628. package/dist/extensions/tool-search/index.js.map +1 -0
  629. package/dist/extensions/tool-search/tool.d.ts +73 -0
  630. package/dist/extensions/tool-search/tool.d.ts.map +1 -0
  631. package/dist/extensions/tool-search/tool.js +189 -0
  632. package/dist/extensions/tool-search/tool.js.map +1 -0
  633. package/dist/index.d.ts +20 -11
  634. package/dist/index.d.ts.map +1 -1
  635. package/dist/index.js +12 -6
  636. package/dist/index.js.map +1 -1
  637. package/dist/main.d.ts +4 -0
  638. package/dist/main.d.ts.map +1 -1
  639. package/dist/main.js +123 -51
  640. package/dist/main.js.map +1 -1
  641. package/dist/migrations.d.ts +1 -1
  642. package/dist/migrations.js +7 -6
  643. package/dist/migrations.js.map +1 -1
  644. package/dist/modes/index.d.ts +1 -0
  645. package/dist/modes/index.d.ts.map +1 -1
  646. package/dist/modes/index.js.map +1 -1
  647. package/dist/modes/interactive/bug-report.d.ts +19 -0
  648. package/dist/modes/interactive/bug-report.d.ts.map +1 -0
  649. package/dist/modes/interactive/bug-report.js +211 -0
  650. package/dist/modes/interactive/bug-report.js.map +1 -0
  651. package/dist/modes/interactive/chat-viewport.d.ts +20 -0
  652. package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
  653. package/dist/modes/interactive/chat-viewport.js +28 -0
  654. package/dist/modes/interactive/chat-viewport.js.map +1 -0
  655. package/dist/modes/interactive/components/armin.js +10 -6
  656. package/dist/modes/interactive/components/armin.js.map +1 -1
  657. package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
  658. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  659. package/dist/modes/interactive/components/assistant-message.js +38 -15
  660. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  661. package/dist/modes/interactive/components/bash-execution.js +9 -4
  662. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  663. package/dist/modes/interactive/components/bordered-loader.js +3 -0
  664. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  665. package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
  666. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  667. package/dist/modes/interactive/components/branch-summary-message.js +15 -6
  668. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  669. package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
  670. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  671. package/dist/modes/interactive/components/compaction-summary-message.js +15 -6
  672. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  673. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  674. package/dist/modes/interactive/components/config-selector.js +35 -8
  675. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  676. package/dist/modes/interactive/components/countdown-timer.js +5 -0
  677. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  678. package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
  679. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  680. package/dist/modes/interactive/components/custom-editor.js +54 -2
  681. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  682. package/dist/modes/interactive/components/custom-entry.js +4 -1
  683. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  684. package/dist/modes/interactive/components/custom-message.js +7 -1
  685. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  686. package/dist/modes/interactive/components/daxnuts.js +8 -6
  687. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  688. package/dist/modes/interactive/components/dynamic-border.js +1 -0
  689. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  690. package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
  691. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  692. package/dist/modes/interactive/components/extension-editor.js +14 -3
  693. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  694. package/dist/modes/interactive/components/extension-input.d.ts +2 -0
  695. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  696. package/dist/modes/interactive/components/extension-input.js +14 -2
  697. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  698. package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
  699. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  700. package/dist/modes/interactive/components/extension-selector.js +16 -1
  701. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  702. package/dist/modes/interactive/components/first-time-setup.d.ts +4 -4
  703. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  704. package/dist/modes/interactive/components/first-time-setup.js +12 -4
  705. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  706. package/dist/modes/interactive/components/footer.d.ts +7 -0
  707. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  708. package/dist/modes/interactive/components/footer.js +51 -6
  709. package/dist/modes/interactive/components/footer.js.map +1 -1
  710. package/dist/modes/interactive/components/index.d.ts +1 -1
  711. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  712. package/dist/modes/interactive/components/index.js.map +1 -1
  713. package/dist/modes/interactive/components/login-dialog.js +9 -3
  714. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  715. package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
  716. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
  717. package/dist/modes/interactive/components/markdown-transform.js +19 -0
  718. package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
  719. package/dist/modes/interactive/components/mermaid.d.ts +11 -0
  720. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
  721. package/dist/modes/interactive/components/mermaid.js +75 -0
  722. package/dist/modes/interactive/components/mermaid.js.map +1 -0
  723. package/dist/modes/interactive/components/model-selector.d.ts +10 -4
  724. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  725. package/dist/modes/interactive/components/model-selector.js +101 -40
  726. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  727. package/dist/modes/interactive/components/oauth-selector.js +11 -3
  728. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  729. package/dist/modes/interactive/components/scoped-models-selector.d.ts +4 -0
  730. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  731. package/dist/modes/interactive/components/scoped-models-selector.js +60 -32
  732. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  733. package/dist/modes/interactive/components/session-selector.d.ts +5 -5
  734. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  735. package/dist/modes/interactive/components/session-selector.js +128 -78
  736. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  737. package/dist/modes/interactive/components/settings-selector.d.ts +23 -4
  738. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  739. package/dist/modes/interactive/components/settings-selector.js +230 -67
  740. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  741. package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
  742. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
  743. package/dist/modes/interactive/components/settings-submenu.js +165 -0
  744. package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
  745. package/dist/modes/interactive/components/show-images-selector.js +1 -0
  746. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  747. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  748. package/dist/modes/interactive/components/skill-invocation-message.js +14 -5
  749. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  750. package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
  751. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  752. package/dist/modes/interactive/components/status-indicator.js +12 -3
  753. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  754. package/dist/modes/interactive/components/theme-selector.js +2 -0
  755. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  756. package/dist/modes/interactive/components/themed-text.d.ts +17 -0
  757. package/dist/modes/interactive/components/themed-text.d.ts.map +1 -0
  758. package/dist/modes/interactive/components/themed-text.js +29 -0
  759. package/dist/modes/interactive/components/themed-text.js.map +1 -0
  760. package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
  761. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  762. package/dist/modes/interactive/components/thinking-selector.js +76 -18
  763. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  764. package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
  765. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  766. package/dist/modes/interactive/components/tool-execution.js +78 -52
  767. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  768. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  769. package/dist/modes/interactive/components/tree-selector.js +44 -18
  770. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  771. package/dist/modes/interactive/components/trust-selector.js +8 -2
  772. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  773. package/dist/modes/interactive/components/user-message-selector.js +6 -3
  774. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  775. package/dist/modes/interactive/components/user-message.d.ts +3 -1
  776. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  777. package/dist/modes/interactive/components/user-message.js +12 -2
  778. package/dist/modes/interactive/components/user-message.js.map +1 -1
  779. package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
  780. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  781. package/dist/modes/interactive/components/visual-truncate.js +39 -6
  782. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  783. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  784. package/dist/modes/interactive/external-editor.js +2 -1
  785. package/dist/modes/interactive/external-editor.js.map +1 -1
  786. package/dist/modes/interactive/interactive-mode.d.ts +69 -5
  787. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  788. package/dist/modes/interactive/interactive-mode.js +1314 -593
  789. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  790. package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
  791. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
  792. package/dist/modes/interactive/model-catalog-refresh.js +34 -0
  793. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
  794. package/dist/modes/interactive/session-share.d.ts +23 -0
  795. package/dist/modes/interactive/session-share.d.ts.map +1 -0
  796. package/dist/modes/interactive/session-share.js +130 -0
  797. package/dist/modes/interactive/session-share.js.map +1 -0
  798. package/dist/modes/interactive/theme/dark.json +54 -63
  799. package/dist/modes/interactive/theme/light.json +52 -60
  800. package/dist/modes/interactive/theme/system-theme.d.ts +54 -0
  801. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
  802. package/dist/modes/interactive/theme/system-theme.js +535 -0
  803. package/dist/modes/interactive/theme/system-theme.js.map +1 -0
  804. package/dist/modes/interactive/theme/theme-controller.d.ts +59 -7
  805. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  806. package/dist/modes/interactive/theme/theme-controller.js +164 -51
  807. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  808. package/dist/modes/interactive/theme/theme-json.d.ts +85 -0
  809. package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
  810. package/dist/modes/interactive/theme/theme-json.js +132 -0
  811. package/dist/modes/interactive/theme/theme-json.js.map +1 -0
  812. package/dist/modes/interactive/theme/theme-schema.json +24 -3
  813. package/dist/modes/interactive/theme/theme.d.ts +80 -42
  814. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  815. package/dist/modes/interactive/theme/theme.js +274 -417
  816. package/dist/modes/interactive/theme/theme.js.map +1 -1
  817. package/dist/modes/interactive/tui-renderer.d.ts +22 -0
  818. package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
  819. package/dist/modes/interactive/tui-renderer.js +67 -0
  820. package/dist/modes/interactive/tui-renderer.js.map +1 -0
  821. package/dist/modes/json-event.d.ts +34 -0
  822. package/dist/modes/json-event.d.ts.map +1 -0
  823. package/dist/modes/json-event.js +29 -0
  824. package/dist/modes/json-event.js.map +1 -0
  825. package/dist/modes/print-mode.d.ts +1 -1
  826. package/dist/modes/print-mode.d.ts.map +1 -1
  827. package/dist/modes/print-mode.js +12 -2
  828. package/dist/modes/print-mode.js.map +1 -1
  829. package/dist/modes/rpc/rpc-client.d.ts +17 -9
  830. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  831. package/dist/modes/rpc/rpc-client.js +27 -15
  832. package/dist/modes/rpc/rpc-client.js.map +1 -1
  833. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  834. package/dist/modes/rpc/rpc-mode.js +14 -12
  835. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  836. package/dist/modes/rpc/rpc-types.d.ts +22 -1
  837. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  838. package/dist/modes/rpc/rpc-types.js.map +1 -1
  839. package/dist/package-manager-cli.d.ts +1 -0
  840. package/dist/package-manager-cli.d.ts.map +1 -1
  841. package/dist/package-manager-cli.js +217 -63
  842. package/dist/package-manager-cli.js.map +1 -1
  843. package/dist/prompts/commands/plan-phase.md +1 -0
  844. package/dist/prompts/commands/review.md +2 -0
  845. package/dist/prompts/commands/verify-work.md +1 -0
  846. package/dist/prompts/commands/why.md +4 -0
  847. package/dist/rpc-entry.js +1 -0
  848. package/dist/rpc-entry.js.map +1 -1
  849. package/dist/skills/blast-radius/SKILL.md +1 -0
  850. package/dist/skills/explainers/SKILL.md +65 -0
  851. package/dist/skills/unslop/SKILL.md +19 -1
  852. package/dist/utils/abort.d.ts +5 -0
  853. package/dist/utils/abort.d.ts.map +1 -0
  854. package/dist/utils/abort.js +48 -0
  855. package/dist/utils/abort.js.map +1 -0
  856. package/dist/utils/changelog.js +1 -1
  857. package/dist/utils/changelog.js.map +1 -1
  858. package/dist/utils/child-process.d.ts +1 -1
  859. package/dist/utils/child-process.js +1 -1
  860. package/dist/utils/child-process.js.map +1 -1
  861. package/dist/utils/clipboard-command.d.ts +7 -0
  862. package/dist/utils/clipboard-command.d.ts.map +1 -0
  863. package/dist/utils/clipboard-command.js +45 -0
  864. package/dist/utils/clipboard-command.js.map +1 -0
  865. package/dist/utils/clipboard-image.d.ts.map +1 -1
  866. package/dist/utils/clipboard-image.js +60 -91
  867. package/dist/utils/clipboard-image.js.map +1 -1
  868. package/dist/utils/clipboard.d.ts +2 -0
  869. package/dist/utils/clipboard.d.ts.map +1 -1
  870. package/dist/utils/clipboard.js +116 -121
  871. package/dist/utils/clipboard.js.map +1 -1
  872. package/dist/utils/draht-user-agent.d.ts +2 -0
  873. package/dist/utils/draht-user-agent.d.ts.map +1 -0
  874. package/dist/utils/draht-user-agent.js +5 -0
  875. package/dist/utils/draht-user-agent.js.map +1 -0
  876. package/dist/utils/exif-orientation.d.ts +2 -1
  877. package/dist/utils/exif-orientation.d.ts.map +1 -1
  878. package/dist/utils/exif-orientation.js.map +1 -1
  879. package/dist/utils/frontmatter.d.ts.map +1 -1
  880. package/dist/utils/frontmatter.js +2 -1
  881. package/dist/utils/frontmatter.js.map +1 -1
  882. package/dist/utils/management-http.d.ts +25 -0
  883. package/dist/utils/management-http.d.ts.map +1 -0
  884. package/dist/utils/management-http.js +54 -0
  885. package/dist/utils/management-http.js.map +1 -0
  886. package/dist/utils/mime.js +1 -1
  887. package/dist/utils/mime.js.map +1 -1
  888. package/dist/utils/paths.d.ts +4 -3
  889. package/dist/utils/paths.d.ts.map +1 -1
  890. package/dist/utils/paths.js +15 -4
  891. package/dist/utils/paths.js.map +1 -1
  892. package/dist/utils/photon.d.ts +2 -1
  893. package/dist/utils/photon.d.ts.map +1 -1
  894. package/dist/utils/photon.js.map +1 -1
  895. package/dist/utils/shell.d.ts +4 -3
  896. package/dist/utils/shell.d.ts.map +1 -1
  897. package/dist/utils/shell.js +20 -35
  898. package/dist/utils/shell.js.map +1 -1
  899. package/dist/utils/syntax-highlight.d.ts +1 -0
  900. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  901. package/dist/utils/syntax-highlight.js +62 -1
  902. package/dist/utils/syntax-highlight.js.map +1 -1
  903. package/dist/utils/text.d.ts +8 -0
  904. package/dist/utils/text.d.ts.map +1 -0
  905. package/dist/utils/text.js +9 -0
  906. package/dist/utils/text.js.map +1 -0
  907. package/dist/utils/tool-result-images.d.ts +21 -0
  908. package/dist/utils/tool-result-images.d.ts.map +1 -0
  909. package/dist/utils/tool-result-images.js +48 -0
  910. package/dist/utils/tool-result-images.js.map +1 -0
  911. package/dist/utils/tools-manager.d.ts +11 -1
  912. package/dist/utils/tools-manager.d.ts.map +1 -1
  913. package/dist/utils/tools-manager.js +53 -36
  914. package/dist/utils/tools-manager.js.map +1 -1
  915. package/dist/utils/version-check.d.ts +4 -1
  916. package/dist/utils/version-check.d.ts.map +1 -1
  917. package/dist/utils/version-check.js +30 -9
  918. package/dist/utils/version-check.js.map +1 -1
  919. package/dist/utils/wsl.d.ts +3 -0
  920. package/dist/utils/wsl.d.ts.map +1 -0
  921. package/dist/utils/wsl.js +15 -0
  922. package/dist/utils/wsl.js.map +1 -0
  923. package/dist/utils/zip.d.ts +7 -0
  924. package/dist/utils/zip.d.ts.map +1 -0
  925. package/dist/utils/zip.js +60 -0
  926. package/dist/utils/zip.js.map +1 -0
  927. package/docs/cli-integration.md +106 -0
  928. package/docs/cli.md +374 -0
  929. package/docs/compaction.md +91 -29
  930. package/docs/configuration.md +47 -0
  931. package/docs/containerization.md +100 -66
  932. package/docs/custom-provider.md +109 -707
  933. package/docs/docs.json +155 -99
  934. package/docs/environment-variables.md +30 -17
  935. package/docs/extensions.md +169 -2811
  936. package/docs/how-pi-works.md +53 -0
  937. package/docs/images/interactive-mode.png +0 -0
  938. package/docs/index.md +25 -69
  939. package/docs/json.md +197 -56
  940. package/docs/keybindings.md +89 -93
  941. package/docs/llama-cpp.md +18 -3
  942. package/docs/mcp.md +231 -0
  943. package/docs/message-types.md +261 -0
  944. package/docs/models.md +94 -478
  945. package/docs/packages.md +67 -163
  946. package/docs/prompt-templates.md +31 -68
  947. package/docs/providers.md +118 -215
  948. package/docs/quickstart.md +55 -108
  949. package/docs/rpc-commands.md +860 -0
  950. package/docs/rpc-extension-ui.md +200 -0
  951. package/docs/rpc.md +139 -1518
  952. package/docs/sdk.md +79 -1127
  953. package/docs/security.md +76 -32
  954. package/docs/session-format.md +73 -219
  955. package/docs/sessions.md +36 -116
  956. package/docs/settings.md +124 -257
  957. package/docs/shell-aliases.md +85 -5
  958. package/docs/skills.md +52 -189
  959. package/docs/slash-commands.md +61 -0
  960. package/docs/terminal-setup.md +132 -61
  961. package/docs/termux.md +74 -84
  962. package/docs/themes.md +91 -252
  963. package/docs/tmux.md +31 -39
  964. package/docs/tui.md +74 -891
  965. package/docs/usage.md +54 -255
  966. package/docs/virtual-models.md +114 -0
  967. package/docs/windows.md +57 -7
  968. package/examples/extensions/antigravity-image-gen.ts +9 -9
  969. package/examples/extensions/bash-spawn-hook.ts +1 -1
  970. package/examples/extensions/border-status-editor.ts +1 -1
  971. package/examples/extensions/built-in-tool-renderer.ts +16 -40
  972. package/examples/extensions/custom-compaction.ts +1 -16
  973. package/examples/extensions/custom-provider-anthropic/index.ts +20 -13
  974. package/examples/extensions/custom-provider-gitlab-duo/index.ts +4 -3
  975. package/examples/extensions/custom-provider-gitlab-duo/test.ts +5 -5
  976. package/examples/extensions/debug-provider.ts +90 -0
  977. package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
  978. package/examples/extensions/dynamic-resources/dynamic.json +3 -1
  979. package/examples/extensions/git-checkpoint.ts +2 -2
  980. package/examples/extensions/handoff.ts +2 -11
  981. package/examples/extensions/jev-router.ts +113 -0
  982. package/examples/extensions/minimal-mode.ts +24 -96
  983. package/examples/extensions/notify.ts +3 -1
  984. package/examples/extensions/prompt-customizer.ts +19 -67
  985. package/examples/extensions/qna.ts +3 -7
  986. package/examples/extensions/subagent/agents.ts +40 -9
  987. package/examples/extensions/subagent/index.ts +27 -4
  988. package/examples/extensions/summarize.ts +7 -18
  989. package/examples/extensions/titlebar-spinner.ts +1 -1
  990. package/examples/rpc-client.ts +35 -0
  991. package/examples/rpc-extension-ui.ts +38 -9
  992. package/examples/sdk/02-custom-model.ts +1 -2
  993. package/examples/sdk/06-extensions.ts +1 -1
  994. package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
  995. package/examples/sdk/12-full-control.ts +1 -1
  996. package/examples/sdk/14-codemode-mcp.ts +61 -0
  997. package/package.json +25 -30
  998. package/prompts/commands/plan-phase.md +1 -0
  999. package/prompts/commands/review.md +2 -0
  1000. package/prompts/commands/verify-work.md +1 -0
  1001. package/prompts/commands/why.md +4 -0
  1002. package/skills/blast-radius/SKILL.md +1 -0
  1003. package/skills/explainers/SKILL.md +65 -0
  1004. package/skills/unslop/SKILL.md +19 -1
  1005. package/dist/utils/clipboard-native.d.ts +0 -11
  1006. package/dist/utils/clipboard-native.d.ts.map +0 -1
  1007. package/dist/utils/clipboard-native.js +0 -20
  1008. package/dist/utils/clipboard-native.js.map +0 -1
  1009. package/dist/utils/pi-user-agent.d.ts +0 -2
  1010. package/dist/utils/pi-user-agent.d.ts.map +0 -1
  1011. package/dist/utils/pi-user-agent.js +0 -5
  1012. package/dist/utils/pi-user-agent.js.map +0 -1
  1013. package/docs/development.md +0 -71
  1014. package/docs/tree.md +0 -231
  1015. package/examples/extensions/kimi-deferred-tools.ts +0 -61
package/docs/rpc.md CHANGED
@@ -1,1330 +1,141 @@
1
1
  # RPC Mode
2
2
 
3
- RPC mode enables headless operation of the coding agent via a JSON protocol over stdin/stdout. This is useful for embedding the agent in other applications, IDEs, or custom UIs.
3
+ RPC mode runs draht as a long-lived subprocess controlled through JSON records on stdin and stdout. Use it for language-independent integrations, process isolation, IDEs, and custom user interfaces.
4
4
 
5
- **Note for Node.js/TypeScript users**: If you're building a Node.js application, consider using `AgentSession` directly from `@draht/coding-agent` instead of spawning a subprocess. See [`src/core/agent-session.ts`](../src/core/agent-session.ts) for the API. For a subprocess-based TypeScript client, see [`src/modes/rpc/rpc-client.ts`](../src/modes/rpc/rpc-client.ts).
5
+ For an in-process Node.js or Bun integration, prefer the [SDK](sdk.md). For a subprocess-based TypeScript integration, prefer the exported `RpcClient`, which starts draht, correlates responses, exposes typed command methods, and delivers events to listeners.
6
6
 
7
- ## Starting RPC Mode
7
+ | Interface | Process boundary | Control model | Best fit |
8
+ |---|---|---|---|
9
+ | [SDK](sdk.md) | In process | Direct TypeScript methods and events | Node.js or Bun hosts that want complete API access |
10
+ | RPC | Child process | JSONL commands, responses, and events | Other languages, isolated processes, IDEs, or custom clients |
8
11
 
9
- ```bash
10
- draht --mode rpc [options]
11
- ```
12
-
13
- Common options:
14
- - `--provider <name>`: Set the LLM provider (anthropic, openai, google, etc.)
15
- - `--model <pattern>`: Model pattern or ID (supports `provider/id` and optional `:<thinking>`)
16
- - `--name <name>` / `-n <name>`: Set the session display name at startup
17
- - `--no-session`: Disable session persistence
18
- - `--session-dir <path>`: Custom session storage directory
19
-
20
- ## Protocol Overview
21
-
22
- - **Commands**: JSON objects sent to stdin, one per line
23
- - **Responses**: JSON objects with `type: "response"` indicating command success/failure
24
- - **Events**: Agent events streamed to stdout as JSON lines
25
-
26
- All commands support an optional `id` field for request/response correlation. If provided, the corresponding response will include the same `id`. `bash_execution_update` events also include the `id` of their originating `bash` command.
27
-
28
- ### Framing
29
-
30
- RPC mode uses strict JSONL semantics with LF (`\n`) as the only record delimiter.
31
-
32
- This matters for clients:
33
- - Split records on `\n` only
34
- - Accept optional `\r\n` input by stripping a trailing `\r`
35
- - Do not use generic line readers that treat Unicode separators as newlines
36
-
37
- In particular, Node `readline` is not protocol-compliant for RPC mode because it also splits on `U+2028` and `U+2029`, which are valid inside JSON strings.
38
-
39
- ## Commands
40
-
41
- ### Prompting
42
-
43
- #### prompt
44
-
45
- Send a user prompt to the agent. The command response is emitted after the prompt is accepted, queued, or handled. Events continue streaming asynchronously after acceptance.
46
-
47
- ```json
48
- {"id": "req-1", "type": "prompt", "message": "Hello, world!"}
49
- ```
50
-
51
- With images:
52
- ```json
53
- {"type": "prompt", "message": "What's in this image?", "images": [{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}]}
54
- ```
55
-
56
- **During streaming**: If the agent is already streaming, you must specify `streamingBehavior` to queue the message:
57
-
58
- ```json
59
- {"type": "prompt", "message": "New instruction", "streamingBehavior": "steer"}
60
- ```
61
-
62
- - `"steer"`: Queue the message while the agent is running. It is delivered after the current assistant turn finishes executing its tool calls, before the next LLM call.
63
- - `"followUp"`: Wait until the agent finishes. Message is delivered only when agent stops.
64
-
65
- If the agent is streaming and no `streamingBehavior` is specified, the command returns an error.
66
-
67
- **Extension commands**: If the message is an extension command (e.g., `/mycommand`), it executes immediately even during streaming. Extension commands manage their own LLM interaction via `pi.sendMessage()`.
68
-
69
- **Input expansion**: Skill commands (`/skill:name`) and prompt templates (`/template`) are expanded before sending/queueing.
70
-
71
- Response:
72
- ```json
73
- {"id": "req-1", "type": "response", "command": "prompt", "success": true}
74
- ```
75
-
76
- `success: true` means the prompt was accepted, queued, or handled immediately. `success: false` means the prompt was rejected before acceptance. Failures after acceptance are reported through the normal event and message stream, not as a second `response` for the same request id.
77
-
78
- The `images` field is optional. Each image uses `ImageContent` format: `{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}`.
79
-
80
- #### steer
81
-
82
- Queue a steering message while the agent is running. It is delivered after the current assistant turn finishes executing its tool calls, before the next LLM call. Skill commands and prompt templates are expanded. Extension commands are not allowed (use `prompt` instead).
83
-
84
- ```json
85
- {"type": "steer", "message": "Stop and do this instead"}
86
- ```
87
-
88
- With images:
89
- ```json
90
- {"type": "steer", "message": "Look at this instead", "images": [{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}]}
91
- ```
92
-
93
- The `images` field is optional. Each image uses `ImageContent` format (same as `prompt`).
94
-
95
- Response:
96
- ```json
97
- {"type": "response", "command": "steer", "success": true}
98
- ```
99
-
100
- See [set_steering_mode](#set_steering_mode) for controlling how steering messages are processed.
101
-
102
- #### follow_up
103
-
104
- Queue a follow-up message to be processed after the agent finishes. Delivered only when agent has no more tool calls or steering messages. Skill commands and prompt templates are expanded. Extension commands are not allowed (use `prompt` instead).
105
-
106
- ```json
107
- {"type": "follow_up", "message": "After you're done, also do this"}
108
- ```
109
-
110
- With images:
111
- ```json
112
- {"type": "follow_up", "message": "Also check this image", "images": [{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}]}
113
- ```
114
-
115
- The `images` field is optional. Each image uses `ImageContent` format (same as `prompt`).
116
-
117
- Response:
118
- ```json
119
- {"type": "response", "command": "follow_up", "success": true}
120
- ```
121
-
122
- See [set_follow_up_mode](#set_follow_up_mode) for controlling how follow-up messages are processed.
123
-
124
- #### abort
125
-
126
- Abort the current agent operation.
127
-
128
- ```json
129
- {"type": "abort"}
130
- ```
131
-
132
- Response:
133
- ```json
134
- {"type": "response", "command": "abort", "success": true}
135
- ```
136
-
137
- #### new_session
138
-
139
- Start a fresh session. Can be cancelled by a `session_before_switch` extension event handler.
140
-
141
- ```json
142
- {"type": "new_session"}
143
- ```
144
-
145
- With optional parent session tracking:
146
- ```json
147
- {"type": "new_session", "parentSession": "/path/to/parent-session.jsonl"}
148
- ```
149
-
150
- Response:
151
- ```json
152
- {"type": "response", "command": "new_session", "success": true, "data": {"cancelled": false}}
153
- ```
154
-
155
- If an extension cancelled:
156
- ```json
157
- {"type": "response", "command": "new_session", "success": true, "data": {"cancelled": true}}
158
- ```
159
-
160
- ### State
161
-
162
- #### get_state
163
-
164
- Get current session state.
165
-
166
- ```json
167
- {"type": "get_state"}
168
- ```
169
-
170
- Response:
171
- ```json
172
- {
173
- "type": "response",
174
- "command": "get_state",
175
- "success": true,
176
- "data": {
177
- "model": {...},
178
- "thinkingLevel": "medium",
179
- "isStreaming": false,
180
- "isCompacting": false,
181
- "steeringMode": "all",
182
- "followUpMode": "one-at-a-time",
183
- "sessionFile": "/path/to/session.jsonl",
184
- "sessionId": "abc123",
185
- "sessionName": "my-feature-work",
186
- "autoCompactionEnabled": true,
187
- "messageCount": 5,
188
- "pendingMessageCount": 0
189
- }
190
- }
191
- ```
192
-
193
- The `model` field is a full [Model](#model) object or `null`. The `sessionName` field is the display name set via `set_session_name`, or omitted if not set.
194
-
195
- #### get_messages
196
-
197
- Get all messages in the conversation.
198
-
199
- ```json
200
- {"type": "get_messages"}
201
- ```
202
-
203
- Response:
204
- ```json
205
- {
206
- "type": "response",
207
- "command": "get_messages",
208
- "success": true,
209
- "data": {"messages": [...]}
210
- }
211
- ```
212
-
213
- Messages are `AgentMessage` objects (see [Message Types](#message-types)).
214
-
215
- ### Model
216
-
217
- #### set_model
218
-
219
- Switch to a specific model.
220
-
221
- ```json
222
- {"type": "set_model", "provider": "anthropic", "modelId": "claude-sonnet-4-20250514"}
223
- ```
224
-
225
- Response contains the full [Model](#model) object:
226
- ```json
227
- {
228
- "type": "response",
229
- "command": "set_model",
230
- "success": true,
231
- "data": {...}
232
- }
233
- ```
234
-
235
- #### cycle_model
236
-
237
- Cycle to the next available model. Returns `null` data if only one model available.
238
-
239
- ```json
240
- {"type": "cycle_model"}
241
- ```
242
-
243
- Response:
244
- ```json
245
- {
246
- "type": "response",
247
- "command": "cycle_model",
248
- "success": true,
249
- "data": {
250
- "model": {...},
251
- "thinkingLevel": "medium",
252
- "isScoped": false
253
- }
254
- }
255
- ```
256
-
257
- The `model` field is a full [Model](#model) object.
258
-
259
- #### get_available_models
260
-
261
- List all configured models.
262
-
263
- ```json
264
- {"type": "get_available_models"}
265
- ```
266
-
267
- Response contains an array of full [Model](#model) objects:
268
- ```json
269
- {
270
- "type": "response",
271
- "command": "get_available_models",
272
- "success": true,
273
- "data": {
274
- "models": [...]
275
- }
276
- }
277
- ```
278
-
279
- ### Thinking
280
-
281
- #### set_thinking_level
282
-
283
- Set the reasoning/thinking level for models that support it.
284
-
285
- ```json
286
- {"type": "set_thinking_level", "level": "high"}
287
- ```
288
-
289
- Levels: `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"`
290
-
291
- `"xhigh"` and `"max"` are exposed only when supported by the selected model. Some models, including GPT-5.6, expose both.
292
-
293
- Response:
294
- ```json
295
- {"type": "response", "command": "set_thinking_level", "success": true}
296
- ```
297
-
298
- #### cycle_thinking_level
299
-
300
- Cycle through available thinking levels. Returns `null` data if model doesn't support thinking.
301
-
302
- ```json
303
- {"type": "cycle_thinking_level"}
304
- ```
305
-
306
- Response:
307
- ```json
308
- {
309
- "type": "response",
310
- "command": "cycle_thinking_level",
311
- "success": true,
312
- "data": {"level": "high"}
313
- }
314
- ```
315
-
316
- #### get_available_thinking_levels
317
-
318
- List the thinking levels supported by the current model. Returns `["off"]` for a model without reasoning support.
319
-
320
- ```json
321
- {"type": "get_available_thinking_levels"}
322
- ```
323
-
324
- Response:
325
- ```json
326
- {
327
- "type": "response",
328
- "command": "get_available_thinking_levels",
329
- "success": true,
330
- "data": {
331
- "levels": ["off", "minimal", "low", "medium", "high"]
332
- }
333
- }
334
- ```
335
-
336
- ### Queue Modes
337
-
338
- #### set_steering_mode
339
-
340
- Control how steering messages (from `steer`) are delivered.
341
-
342
- ```json
343
- {"type": "set_steering_mode", "mode": "one-at-a-time"}
344
- ```
345
-
346
- Modes:
347
- - `"all"`: Deliver all steering messages after the current assistant turn finishes executing its tool calls
348
- - `"one-at-a-time"`: Deliver one steering message per completed assistant turn (default)
349
-
350
- Response:
351
- ```json
352
- {"type": "response", "command": "set_steering_mode", "success": true}
353
- ```
354
-
355
- #### set_follow_up_mode
356
-
357
- Control how follow-up messages (from `follow_up`) are delivered.
358
-
359
- ```json
360
- {"type": "set_follow_up_mode", "mode": "one-at-a-time"}
361
- ```
362
-
363
- Modes:
364
- - `"all"`: Deliver all follow-up messages when agent finishes
365
- - `"one-at-a-time"`: Deliver one follow-up message per agent completion (default)
366
-
367
- Response:
368
- ```json
369
- {"type": "response", "command": "set_follow_up_mode", "success": true}
370
- ```
371
-
372
- ### Compaction
373
-
374
- #### compact
375
-
376
- Manually compact conversation context to reduce token usage.
377
-
378
- ```json
379
- {"type": "compact"}
380
- ```
381
-
382
- With custom instructions:
383
- ```json
384
- {"type": "compact", "customInstructions": "Focus on code changes"}
385
- ```
386
-
387
- Response:
388
- ```json
389
- {
390
- "type": "response",
391
- "command": "compact",
392
- "success": true,
393
- "data": {
394
- "summary": "Summary of conversation...",
395
- "firstKeptEntryId": "abc123",
396
- "tokensBefore": 150000,
397
- "estimatedTokensAfter": 32000,
398
- "usage": {
399
- "input": 32000,
400
- "output": 1200,
401
- "cacheRead": 0,
402
- "cacheWrite": 0,
403
- "totalTokens": 33200,
404
- "cost": {"input": 0.01, "output": 0.02, "cacheRead": 0, "cacheWrite": 0, "total": 0.03}
405
- },
406
- "details": {}
407
- }
408
- }
409
- ```
410
-
411
- `estimatedTokensAfter` is a heuristic estimate over the rebuilt message context immediately after compaction, not a provider-exact token count. `usage` reports the LLM call or calls that generated the summary and may be omitted by custom compaction handlers.
412
-
413
- #### set_auto_compaction
414
-
415
- Enable or disable automatic compaction when context is nearly full.
416
-
417
- ```json
418
- {"type": "set_auto_compaction", "enabled": true}
419
- ```
420
-
421
- Response:
422
- ```json
423
- {"type": "response", "command": "set_auto_compaction", "success": true}
424
- ```
425
-
426
- ### Retry
427
-
428
- #### set_auto_retry
429
-
430
- Enable or disable automatic retry on transient errors (overloaded, rate limit, 5xx).
431
-
432
- ```json
433
- {"type": "set_auto_retry", "enabled": true}
434
- ```
435
-
436
- Response:
437
- ```json
438
- {"type": "response", "command": "set_auto_retry", "success": true}
439
- ```
440
-
441
- #### abort_retry
442
-
443
- Abort an in-progress retry (cancel the delay and stop retrying).
444
-
445
- ```json
446
- {"type": "abort_retry"}
447
- ```
448
-
449
- Response:
450
- ```json
451
- {"type": "response", "command": "abort_retry", "success": true}
452
- ```
453
-
454
- ### Bash
455
-
456
- #### bash
457
-
458
- Execute a shell command and add output to conversation context. Output streams as `bash_execution_update` events while the command runs; the response contains the final result.
459
-
460
- ```json
461
- {"id": "req-1", "type": "bash", "command": "ls -la"}
462
- ```
463
-
464
- Include an `id` to associate streamed `bash_execution_update` events with this command.
465
-
466
- Response:
467
- ```json
468
- {
469
- "id": "req-1",
470
- "type": "response",
471
- "command": "bash",
472
- "success": true,
473
- "data": {
474
- "output": "total 48\ndrwxr-xr-x ...",
475
- "exitCode": 0,
476
- "cancelled": false,
477
- "truncated": false
478
- }
479
- }
480
- ```
481
-
482
- If output was truncated, includes `fullOutputPath`:
483
- ```json
484
- {
485
- "type": "response",
486
- "command": "bash",
487
- "success": true,
488
- "data": {
489
- "output": "truncated output...",
490
- "exitCode": 0,
491
- "cancelled": false,
492
- "truncated": true,
493
- "fullOutputPath": "/tmp/pi-bash-abc123.log"
494
- }
495
- }
496
- ```
497
-
498
- **How bash results reach the LLM:**
499
-
500
- The `bash` command executes immediately and returns a `BashResult`. Internally, a `BashExecutionMessage` is created and stored in the agent's message state.
501
-
502
- When the next `prompt` command is sent, all messages (including `BashExecutionMessage`) are transformed before being sent to the LLM. The `BashExecutionMessage` is converted to a `UserMessage` with this format:
503
-
504
- ````
505
- Ran `ls -la`
506
- ```
507
- total 48
508
- drwxr-xr-x ...
509
- ```
510
- ````
511
-
512
- This means:
513
- 1. Bash output is included in the LLM context on the **next prompt**, not immediately
514
- 2. Multiple bash commands can be executed before a prompt; all outputs will be included
515
-
516
- #### abort_bash
517
-
518
- Abort a running bash command.
519
-
520
- ```json
521
- {"type": "abort_bash"}
522
- ```
523
-
524
- Response:
525
- ```json
526
- {"type": "response", "command": "abort_bash", "success": true}
527
- ```
528
-
529
- ### Session
530
-
531
- #### get_session_stats
532
-
533
- Get token usage, cost statistics, and current context window usage.
534
-
535
- ```json
536
- {"type": "get_session_stats"}
537
- ```
538
-
539
- Response:
540
- ```json
541
- {
542
- "type": "response",
543
- "command": "get_session_stats",
544
- "success": true,
545
- "data": {
546
- "sessionFile": "/path/to/session.jsonl",
547
- "sessionId": "abc123",
548
- "userMessages": 5,
549
- "assistantMessages": 5,
550
- "toolCalls": 12,
551
- "toolResults": 12,
552
- "totalMessages": 22,
553
- "tokens": {
554
- "input": 50000,
555
- "output": 10000,
556
- "cacheRead": 40000,
557
- "cacheWrite": 5000,
558
- "total": 105000
559
- },
560
- "cost": 0.45,
561
- "contextUsage": {
562
- "tokens": 60000,
563
- "contextWindow": 200000,
564
- "percent": 30
565
- }
566
- }
567
- }
568
- ```
569
-
570
- `tokens` and `cost` include assistant messages, usage reported by tools, and compaction/branch-summary generation across the full session. `contextUsage` contains the actual current context-window estimate used for compaction and footer display.
571
-
572
- `contextUsage` is omitted when no model or context window is available. `contextUsage.tokens` and `contextUsage.percent` are `null` immediately after compaction until a fresh post-compaction assistant response provides valid usage data.
573
-
574
- #### export_html
575
-
576
- Export session to an HTML file.
577
-
578
- ```json
579
- {"type": "export_html"}
580
- ```
581
-
582
- With custom path:
583
- ```json
584
- {"type": "export_html", "outputPath": "/tmp/session.html"}
585
- ```
586
-
587
- Response:
588
- ```json
589
- {
590
- "type": "response",
591
- "command": "export_html",
592
- "success": true,
593
- "data": {"path": "/tmp/session.html"}
594
- }
595
- ```
596
-
597
- #### switch_session
598
-
599
- Load a different session file. Can be cancelled by a `session_before_switch` extension event handler.
600
-
601
- ```json
602
- {"type": "switch_session", "sessionPath": "/path/to/session.jsonl"}
603
- ```
604
-
605
- Response:
606
- ```json
607
- {"type": "response", "command": "switch_session", "success": true, "data": {"cancelled": false}}
608
- ```
609
-
610
- If an extension cancelled the switch:
611
- ```json
612
- {"type": "response", "command": "switch_session", "success": true, "data": {"cancelled": true}}
613
- ```
614
-
615
- #### fork
616
-
617
- Create a new fork from a previous user message on the active branch. Can be cancelled by a `session_before_fork` extension event handler. Returns the text of the message being forked from.
618
-
619
- ```json
620
- {"type": "fork", "entryId": "abc123"}
621
- ```
622
-
623
- Response:
624
- ```json
625
- {
626
- "type": "response",
627
- "command": "fork",
628
- "success": true,
629
- "data": {"text": "The original prompt text...", "cancelled": false}
630
- }
631
- ```
632
-
633
- If an extension cancelled the fork:
634
- ```json
635
- {
636
- "type": "response",
637
- "command": "fork",
638
- "success": true,
639
- "data": {"text": "The original prompt text...", "cancelled": true}
640
- }
641
- ```
642
-
643
- #### clone
644
-
645
- Duplicate the current active branch into a new session at the current position. Can be cancelled by a `session_before_fork` extension event handler.
646
-
647
- ```json
648
- {"type": "clone"}
649
- ```
650
-
651
- Response:
652
- ```json
653
- {
654
- "type": "response",
655
- "command": "clone",
656
- "success": true,
657
- "data": {"cancelled": false}
658
- }
659
- ```
660
-
661
- If an extension cancelled the clone:
662
- ```json
663
- {
664
- "type": "response",
665
- "command": "clone",
666
- "success": true,
667
- "data": {"cancelled": true}
668
- }
669
- ```
670
-
671
- #### get_fork_messages
672
-
673
- Get user messages available for forking.
674
-
675
- ```json
676
- {"type": "get_fork_messages"}
677
- ```
678
-
679
- Response:
680
- ```json
681
- {
682
- "type": "response",
683
- "command": "get_fork_messages",
684
- "success": true,
685
- "data": {
686
- "messages": [
687
- {"entryId": "abc123", "text": "First prompt..."},
688
- {"entryId": "def456", "text": "Second prompt..."}
689
- ]
690
- }
691
- }
692
- ```
693
-
694
- #### get_entries
695
-
696
- Get all session entries in append order (excluding the session header). The session is an append-only tree of entries with stable ids, so an entry id works as a durable cursor: pass the last entry id you have seen as `since` to get only entries strictly after it, even across client restarts. Unlike `get_messages`, this includes pre-compaction history and abandoned branches.
697
-
698
- ```json
699
- {"type": "get_entries"}
700
- ```
701
-
702
- With a cursor:
703
- ```json
704
- {"type": "get_entries", "since": "abc123"}
705
- ```
706
-
707
- Response:
708
- ```json
709
- {
710
- "type": "response",
711
- "command": "get_entries",
712
- "success": true,
713
- "data": {
714
- "entries": [
715
- {"type": "message", "id": "def456", "parentId": "abc123", "timestamp": "...", "message": {"role": "user", "...": "..."}}
716
- ],
717
- "leafId": "def456"
718
- }
719
- }
720
- ```
721
-
722
- `leafId` is the id of the current leaf entry (`null` for an empty session), so a client can tell in one round trip whether the active branch moved. If `since` does not match any entry id, the response is `success: false`.
723
-
724
- #### get_tree
725
-
726
- Get the session as a tree of entries. Each node is `{entry, children, label?, labelTimestamp?}`. A well-formed session has a single root; orphaned entries (broken parent chain) also appear as roots.
727
-
728
- ```json
729
- {"type": "get_tree"}
730
- ```
731
-
732
- Response:
733
- ```json
734
- {
735
- "type": "response",
736
- "command": "get_tree",
737
- "success": true,
738
- "data": {
739
- "tree": [
740
- {
741
- "entry": {"type": "message", "id": "abc123", "parentId": null, "...": "..."},
742
- "children": [
743
- {"entry": {"type": "message", "id": "def456", "parentId": "abc123", "...": "..."}, "children": []}
744
- ]
745
- }
746
- ],
747
- "leafId": "def456"
748
- }
749
- }
750
- ```
751
-
752
- #### get_last_assistant_text
753
-
754
- Get the text content of the last assistant message.
755
-
756
- ```json
757
- {"type": "get_last_assistant_text"}
758
- ```
759
-
760
- Response:
761
- ```json
762
- {
763
- "type": "response",
764
- "command": "get_last_assistant_text",
765
- "success": true,
766
- "data": {"text": "The assistant's response..."}
767
- }
768
- ```
769
-
770
- Returns `{"text": null}` if no assistant messages exist.
771
-
772
- #### set_session_name
773
-
774
- Set a display name for the current session. The name appears in session listings and helps identify sessions.
775
-
776
- ```json
777
- {"type": "set_session_name", "name": "my-feature-work"}
778
- ```
779
-
780
- Response:
781
- ```json
782
- {
783
- "type": "response",
784
- "command": "set_session_name",
785
- "success": true
786
- }
787
- ```
788
-
789
- The current session name is available via `get_state` in the `sessionName` field. To set the initial name when starting RPC mode, pass `--name <name>` or `-n <name>` to the `draht --mode rpc` process.
790
-
791
- ### Commands
792
-
793
- #### get_commands
794
-
795
- Get available commands (extension commands, prompt templates, and skills). These can be invoked via the `prompt` command by prefixing with `/`.
796
-
797
- ```json
798
- {"type": "get_commands"}
799
- ```
800
-
801
- Response:
802
- ```json
803
- {
804
- "type": "response",
805
- "command": "get_commands",
806
- "success": true,
807
- "data": {
808
- "commands": [
809
- {"name": "session-name", "description": "Set or clear session name", "source": "extension", "path": "/home/user/.draht/agent/extensions/session.ts"},
810
- {"name": "fix-tests", "description": "Fix failing tests", "source": "prompt", "location": "project", "path": "/home/user/myproject/.draht/agent/prompts/fix-tests.md"},
811
- {"name": "skill:brave-search", "description": "Web search via Brave API", "source": "skill", "location": "user", "path": "/home/user/.draht/agent/skills/brave-search/SKILL.md"}
812
- ]
813
- }
814
- }
815
- ```
816
-
817
- Each command has:
818
- - `name`: Command name (invoke with `/name`)
819
- - `description`: Human-readable description (optional for extension commands)
820
- - `source`: What kind of command:
821
- - `"extension"`: Registered via `pi.registerCommand()` in an extension
822
- - `"prompt"`: Loaded from a prompt template `.md` file
823
- - `"skill"`: Loaded from a skill directory (name is prefixed with `skill:`)
824
- - `location`: Where it was loaded from (optional, not present for extensions):
825
- - `"user"`: User-level (`~/.draht/agent/`)
826
- - `"project"`: Project-level (`./.draht/agent/`)
827
- - `"path"`: Explicit path via CLI or settings
828
- - `path`: Absolute file path to the command source (optional)
829
-
830
- **Note**: Built-in TUI commands (`/settings`, `/hotkeys`, etc.) are not included. They are handled only in interactive mode and would not execute if sent via `prompt`.
831
-
832
- ## Events
833
-
834
- Events are streamed to stdout as JSON lines during agent operation. Events do not generally include an `id` field; `bash_execution_update` includes the `id` of its originating `bash` command when one was provided.
835
-
836
- ### Event Types
837
-
838
- | Event | Description |
839
- |-------|-------------|
840
- | `agent_start` | Agent begins processing |
841
- | `agent_end` | One low-level agent run completes (may still be followed by retry, compaction, or queued continuations) |
842
- | `agent_settled` | Agent run is fully settled; no automatic retry, compaction retry, or queued continuation remains |
843
- | `turn_start` | New turn begins |
844
- | `turn_end` | Turn completes (includes assistant message and tool results) |
845
- | `message_start` | Message begins |
846
- | `message_update` | Streaming update (text/thinking/toolcall deltas) |
847
- | `message_end` | Message completes |
848
- | `bash_execution_update` | Direct RPC bash command output chunk |
849
- | `tool_execution_start` | Tool begins execution |
850
- | `tool_execution_update` | Tool execution progress (streaming output) |
851
- | `tool_execution_end` | Tool completes |
852
- | `queue_update` | Pending steering/follow-up queue changed |
853
- | `compaction_start` | Compaction begins |
854
- | `compaction_end` | Compaction completes |
855
- | `auto_retry_start` | Auto-retry begins (after transient error) |
856
- | `auto_retry_end` | Auto-retry completes (success or final failure) |
857
- | `summarization_retry_scheduled` | Retry scheduled for a transient compaction or branch-summary summarization error |
858
- | `summarization_retry_attempt_start` | Retried summarization request starts |
859
- | `summarization_retry_finished` | Summarization retry loop completes |
860
- | `extension_error` | Extension threw an error |
861
-
862
- ### agent_start
863
-
864
- Emitted when the agent begins processing a prompt.
865
-
866
- ```json
867
- {"type": "agent_start"}
868
- ```
869
-
870
- ### agent_end
871
-
872
- Emitted when one low-level agent run completes. Contains all messages generated during this run. If `willRetry` is true, an automatic retry will follow.
873
-
874
- ```json
875
- {
876
- "type": "agent_end",
877
- "messages": [...],
878
- "willRetry": false
879
- }
880
- ```
881
-
882
- ### agent_settled
883
-
884
- Emitted after the full session-level run settles. At this point draht will not continue automatically through retry, compaction retry, or queued follow-up messages.
885
-
886
- ```json
887
- {"type": "agent_settled"}
888
- ```
889
-
890
- ### turn_start / turn_end
891
-
892
- A turn consists of one assistant response plus any resulting tool calls and results.
893
-
894
- ```json
895
- {"type": "turn_start"}
896
- ```
897
-
898
- ```json
899
- {
900
- "type": "turn_end",
901
- "message": {...},
902
- "toolResults": [...]
903
- }
904
- ```
905
-
906
- ### message_start / message_end
907
-
908
- Emitted when a message begins and completes. The `message` field contains an `AgentMessage`.
909
-
910
- ```json
911
- {"type": "message_start", "message": {...}}
912
- {"type": "message_end", "message": {...}}
913
- ```
914
-
915
- ### message_update (Streaming)
916
-
917
- Emitted during streaming of assistant messages. Contains both the partial message and a streaming delta event.
918
-
919
- ```json
920
- {
921
- "type": "message_update",
922
- "message": {...},
923
- "assistantMessageEvent": {
924
- "type": "text_delta",
925
- "contentIndex": 0,
926
- "delta": "Hello ",
927
- "partial": {...}
928
- }
929
- }
930
- ```
931
-
932
- The `assistantMessageEvent` field contains one of these delta types:
933
-
934
- | Type | Description |
935
- |------|-------------|
936
- | `start` | Message generation started |
937
- | `text_start` | Text content block started |
938
- | `text_delta` | Text content chunk |
939
- | `text_end` | Text content block ended |
940
- | `thinking_start` | Thinking block started |
941
- | `thinking_delta` | Thinking content chunk |
942
- | `thinking_end` | Thinking block ended |
943
- | `toolcall_start` | Tool call started |
944
- | `toolcall_delta` | Tool call arguments chunk |
945
- | `toolcall_end` | Tool call ended (includes full `toolCall` object) |
946
- | `done` | Message complete (reason: `"stop"`, `"length"`, `"toolUse"`) |
947
- | `error` | Error occurred (reason: `"aborted"`, `"error"`) |
948
-
949
- Example streaming a text response:
950
- ```json
951
- {"type":"message_update","message":{...},"assistantMessageEvent":{"type":"text_start","contentIndex":0,"partial":{...}}}
952
- {"type":"message_update","message":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello","partial":{...}}}
953
- {"type":"message_update","message":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":" world","partial":{...}}}
954
- {"type":"message_update","message":{...},"assistantMessageEvent":{"type":"text_end","contentIndex":0,"content":"Hello world","partial":{...}}}
955
- ```
956
-
957
- ### bash_execution_update
958
-
959
- Emitted once for each output chunk from a direct `bash` command. `id` matches the command's `id`, allowing clients to associate output with the correct command.
960
-
961
- Events stream all output while the command runs, even if the final `bash` response's `output` is truncated.
962
-
963
- ```json
964
- {
965
- "type": "bash_execution_update",
966
- "id": "req-1",
967
- "delta": "total 48\n"
968
- }
969
- ```
970
-
971
- ### tool_execution_start / tool_execution_update / tool_execution_end
972
-
973
- Emitted when a tool begins, streams progress, and completes execution.
974
-
975
- ```json
976
- {
977
- "type": "tool_execution_start",
978
- "toolCallId": "call_abc123",
979
- "toolName": "bash",
980
- "args": {"command": "ls -la"}
981
- }
982
- ```
983
-
984
- During execution, `tool_execution_update` events stream partial results (e.g., bash output as it arrives):
985
-
986
- ```json
987
- {
988
- "type": "tool_execution_update",
989
- "toolCallId": "call_abc123",
990
- "toolName": "bash",
991
- "args": {"command": "ls -la"},
992
- "partialResult": {
993
- "content": [{"type": "text", "text": "partial output so far..."}],
994
- "details": {"truncation": null, "fullOutputPath": null}
995
- }
996
- }
997
- ```
998
-
999
- When complete:
1000
-
1001
- ```json
1002
- {
1003
- "type": "tool_execution_end",
1004
- "toolCallId": "call_abc123",
1005
- "toolName": "bash",
1006
- "result": {
1007
- "content": [{"type": "text", "text": "total 48\n..."}],
1008
- "details": {...}
1009
- },
1010
- "isError": false
1011
- }
1012
- ```
1013
-
1014
- Use `toolCallId` to correlate events. The `partialResult` in `tool_execution_update` contains the accumulated output so far (not just the delta), allowing clients to simply replace their display on each update.
1015
-
1016
- ### queue_update
1017
-
1018
- Emitted whenever the pending steering or follow-up queue changes.
1019
-
1020
- ```json
1021
- {
1022
- "type": "queue_update",
1023
- "steering": ["Focus on error handling"],
1024
- "followUp": ["After that, summarize the result"]
1025
- }
1026
- ```
1027
-
1028
- ### compaction_start / compaction_end
1029
-
1030
- Emitted when compaction runs, whether manual or automatic.
1031
-
1032
- ```json
1033
- {"type": "compaction_start", "reason": "threshold"}
1034
- ```
1035
-
1036
- The `reason` field is `"manual"`, `"threshold"`, or `"overflow"`.
1037
-
1038
- ```json
1039
- {
1040
- "type": "compaction_end",
1041
- "reason": "threshold",
1042
- "result": {
1043
- "summary": "Summary of conversation...",
1044
- "firstKeptEntryId": "abc123",
1045
- "tokensBefore": 150000,
1046
- "estimatedTokensAfter": 32000,
1047
- "usage": {
1048
- "input": 32000,
1049
- "output": 1200,
1050
- "cacheRead": 0,
1051
- "cacheWrite": 0,
1052
- "totalTokens": 33200,
1053
- "cost": {"input": 0.01, "output": 0.02, "cacheRead": 0, "cacheWrite": 0, "total": 0.03}
1054
- },
1055
- "details": {}
1056
- },
1057
- "aborted": false,
1058
- "willRetry": false
1059
- }
1060
- ```
1061
-
1062
- If `reason` was `"overflow"` and compaction succeeds, `willRetry` is `true` and the agent will automatically retry the prompt.
1063
-
1064
- If compaction was aborted, `result` is `null` and `aborted` is `true`.
1065
-
1066
- If compaction failed (e.g., API quota exceeded), `result` is `null`, `aborted` is `false`, and `errorMessage` contains the error description.
1067
-
1068
- ### auto_retry_start / auto_retry_end
12
+ ## Start RPC mode
1069
13
 
1070
- Emitted when automatic retry is triggered after a transient error (overloaded, rate limit, 5xx).
1071
-
1072
- ```json
1073
- {
1074
- "type": "auto_retry_start",
1075
- "attempt": 1,
1076
- "maxAttempts": 3,
1077
- "delayMs": 2000,
1078
- "errorMessage": "529 {\"type\":\"error\",\"error\":{\"type\":\"overloaded_error\",\"message\":\"Overloaded\"}}"
1079
- }
1080
- ```
1081
-
1082
- ```json
1083
- {
1084
- "type": "auto_retry_end",
1085
- "success": true,
1086
- "attempt": 2
1087
- }
1088
- ```
1089
-
1090
- On final failure (max retries exceeded):
1091
- ```json
1092
- {
1093
- "type": "auto_retry_end",
1094
- "success": false,
1095
- "attempt": 3,
1096
- "finalError": "529 overloaded_error: Overloaded"
1097
- }
14
+ ```bash
15
+ draht --mode rpc --no-session
1098
16
  ```
1099
17
 
1100
- ### summarization_retry_scheduled / summarization_retry_attempt_start / summarization_retry_finished
18
+ Normal CLI options still select the working folder, model, tools, resources, and session behavior. Common choices include `--provider`, `--model`, `--name`, `--no-session`, and `--session-dir`. See [Command Line](cli.md) for the complete, version-specific interface; `draht --help` is authoritative for the installed version.
1101
19
 
1102
- Emitted when compaction or branch-summary summarization retries after a transient provider error. These events use the same retry settings as automatic assistant-turn retries.
20
+ RPC mode rejects `@file` prompt arguments. Send prompts through the [`prompt`](rpc-commands.md#prompt) command instead.
1103
21
 
1104
- ```json
1105
- {
1106
- "type": "summarization_retry_scheduled",
1107
- "attempt": 1,
1108
- "maxAttempts": 3,
1109
- "delayMs": 2000,
1110
- "errorMessage": "terminated"
1111
- }
1112
- ```
22
+ ## Protocol records
1113
23
 
1114
- ```json
1115
- {
1116
- "type": "summarization_retry_attempt_start",
1117
- "source": "compaction",
1118
- "reason": "threshold"
1119
- }
1120
- ```
24
+ The protocol has four record families:
1121
25
 
1122
- For branch summaries, `source` is `"branchSummary"` and no `reason` is present.
26
+ | Direction | Record | Purpose |
27
+ |---|---|---|
28
+ | stdin | Command | Ask draht to prompt, inspect state, change configuration, or manage the session |
29
+ | stdout | `response` | Report whether one command succeeded and return any command data |
30
+ | stdout | Session event | Stream run, message, tool, queue, compaction, and retry activity |
31
+ | Both | Extension UI record | Forward supported extension interactions between draht and the client |
1123
32
 
1124
- ```json
1125
- {
1126
- "type": "summarization_retry_finished"
1127
- }
1128
- ```
33
+ See [RPC Commands](rpc-commands.md), [JSON Event Stream](json.md), and [RPC Extension UI](rpc-extension-ui.md) for the canonical record definitions.
1129
34
 
1130
- ### extension_error
35
+ ### Correlate commands and responses
1131
36
 
1132
- Emitted when an extension throws an error.
37
+ Every command accepts an optional string `id`. A matching response repeats it:
1133
38
 
1134
39
  ```json
1135
- {
1136
- "type": "extension_error",
1137
- "extensionPath": "/path/to/extension.ts",
1138
- "event": "tool_call",
1139
- "error": "Error message..."
1140
- }
40
+ {"id":"req-1","type":"get_state"}
41
+ {"id":"req-1","type":"response","command":"get_state","success":true,"data":{"...":"..."}}
1141
42
  ```
1142
43
 
1143
- ## Extension UI Protocol
1144
-
1145
- Extensions can request user interaction via `ctx.ui.select()`, `ctx.ui.confirm()`, etc. In RPC mode, these are translated into a request/response sub-protocol on top of the base command/event flow.
1146
-
1147
- There are two categories of extension UI methods:
44
+ Use unique IDs whenever more than one command can be outstanding. Command handling is asynchronous, so clients should correlate by ID rather than response order.
1148
45
 
1149
- - **Dialog methods** (`select`, `confirm`, `input`, `editor`): emit an `extension_ui_request` on stdout and block until the client sends back an `extension_ui_response` on stdin with the matching `id`.
1150
- - **Fire-and-forget methods** (`notify`, `setStatus`, `setWidget`, `setTitle`, `set_editor_text`): emit an `extension_ui_request` on stdout but do not expect a response. The client can display the information or ignore it.
46
+ Session events generally have no command ID because they describe session activity. `bash_execution_update` is the exception: when the originating [`bash`](rpc-commands.md#bash) command has an ID, its output events repeat that ID.
1151
47
 
1152
- If a dialog method includes a `timeout` field, the agent-side will auto-resolve with a default value when the timeout expires. The client does not need to track timeouts.
48
+ An `extension_ui_response` uses the ID supplied by its `extension_ui_request`. It does not produce a normal command response.
1153
49
 
1154
- Some `ExtensionUIContext` methods are not supported or degraded in RPC mode because they require direct TUI access:
1155
- - `custom()` returns `undefined`
1156
- - `setWorkingMessage()`, `setWorkingIndicator()`, `setFooter()`, `setHeader()`, `setEditorComponent()`, `setToolsExpanded()` are no-ops
1157
- - `getEditorText()` returns `""`
1158
- - `getToolsExpanded()` returns `false`
1159
- - `pasteToEditor()` delegates to `setEditorText()` (no paste/collapse handling)
1160
- - `getAllThemes()` returns `[]`
1161
- - `getTheme()` returns `undefined`
1162
- - `setTheme()` returns `{ success: false, error: "..." }`
50
+ ## Framing
1163
51
 
1164
- Note: `ctx.mode` is `"rpc"` and `ctx.hasUI` is `true` in RPC mode because the dialog and fire-and-forget methods are functional via the extension UI sub-protocol. Use `ctx.mode === "tui"` to guard TUI-specific features like `custom()` that require a real terminal.
52
+ RPC uses strict JSONL framing. Write one complete JSON object per record and terminate it with LF (`\n`). Read stdout as a byte or UTF-8 stream and split records only on LF. Strip an optional preceding carriage return to accept CRLF input.
1165
53
 
1166
- ### Extension UI Requests (stdout)
54
+ Do not use a generic line reader that treats Unicode line or paragraph separators as record boundaries. In particular, Node.js `readline` also splits on `U+2028` and `U+2029`, which are valid inside JSON strings.
1167
55
 
1168
- All requests have `type: "extension_ui_request"`, a unique `id`, and a `method` field.
56
+ Read stdout continuously. draht honors stdout backpressure, but a client that stops reading can stall the process. Honor stdin backpressure when writing commands. Stdout is reserved for protocol records; diagnostics and application logging go to stderr.
1169
57
 
1170
- #### select
58
+ ## Run lifecycle
1171
59
 
1172
- Prompt the user to choose from a list. Dialog methods with a `timeout` field include the timeout in milliseconds; the agent auto-resolves with `undefined` if the client doesn't respond in time.
60
+ A successful `prompt` response means the prompt was accepted, queued, or handled. It does not mean model work completed:
1173
61
 
1174
62
  ```json
1175
- {
1176
- "type": "extension_ui_request",
1177
- "id": "uuid-1",
1178
- "method": "select",
1179
- "title": "Allow dangerous command?",
1180
- "options": ["Allow", "Block"],
1181
- "timeout": 10000
1182
- }
1183
- ```
1184
-
1185
- Expected response: `extension_ui_response` with `value` (the selected option string) or `cancelled: true`.
1186
-
1187
- #### confirm
1188
-
1189
- Prompt the user for yes/no confirmation.
1190
-
1191
- ```json
1192
- {
1193
- "type": "extension_ui_request",
1194
- "id": "uuid-2",
1195
- "method": "confirm",
1196
- "title": "Clear session?",
1197
- "message": "All messages will be lost.",
1198
- "timeout": 5000
1199
- }
63
+ {"id":"req-2","type":"prompt","message":"Review this repository"}
64
+ {"id":"req-2","type":"response","command":"prompt","success":true,"data":{"disposition":"started"}}
1200
65
  ```
1201
66
 
1202
- Expected response: `extension_ui_response` with `confirmed: true/false` or `cancelled: true`.
1203
-
1204
- #### input
1205
-
1206
- Prompt the user for free-form text.
67
+ `data.disposition` reports what happened to the prompt. If it is `"handled"`, no run started for this prompt, so don't wait for `agent_settled`. See [RPC Commands](rpc-commands.md#prompt) for all values.
1207
68
 
1208
- ```json
1209
- {
1210
- "type": "extension_ui_request",
1211
- "id": "uuid-3",
1212
- "method": "input",
1213
- "title": "Enter a value",
1214
- "placeholder": "type something..."
1215
- }
1216
- ```
69
+ Continue consuming [events](json.md) after that response. `agent_end` marks the end of one low-level agent run, but retries, overflow recovery, compaction, steering, or follow-up work can still follow. Wait for `agent_settled` when the client needs to know draht will not continue automatically.
1217
70
 
1218
- Expected response: `extension_ui_response` with `value` (the entered text) or `cancelled: true`.
71
+ Subscribe before sending a prompt to avoid missing a fast completion. `RpcClient.promptAndWait()` does this internally. If using separate `RpcClient` calls, install the event listener before `prompt()` and call `waitForIdle()` only while a run is active.
1219
72
 
1220
- #### editor
73
+ ## Errors
1221
74
 
1222
- Open a multi-line text editor with optional prefilled content.
75
+ A failed command returns one response with `success: false`:
1223
76
 
1224
77
  ```json
1225
- {
1226
- "type": "extension_ui_request",
1227
- "id": "uuid-4",
1228
- "method": "editor",
1229
- "title": "Edit some text",
1230
- "prefill": "Line 1\nLine 2\nLine 3"
1231
- }
78
+ {"id":"req-3","type":"response","command":"set_model","success":false,"error":"Model not found: invalid/model"}
1232
79
  ```
1233
80
 
1234
- Expected response: `extension_ui_response` with `value` (the edited text) or `cancelled: true`.
1235
-
1236
- #### notify
1237
-
1238
- Display a notification. Fire-and-forget, no response expected.
81
+ Malformed JSON produces a parse response without a request ID:
1239
82
 
1240
83
  ```json
1241
- {
1242
- "type": "extension_ui_request",
1243
- "id": "uuid-5",
1244
- "method": "notify",
1245
- "message": "Command blocked by user",
1246
- "notifyType": "warning"
1247
- }
84
+ {"type":"response","command":"parse","success":false,"error":"Failed to parse command: Unexpected token..."}
1248
85
  ```
1249
86
 
1250
- The `notifyType` field is `"info"`, `"warning"`, or `"error"`. Defaults to `"info"` if omitted.
1251
-
1252
- #### setStatus
87
+ A success response only covers command handling. Provider failures and aborts after a prompt is accepted appear in the message and event stream.
1253
88
 
1254
- Set or clear a status entry in the footer/status bar. Fire-and-forget.
1255
-
1256
- ```json
1257
- {
1258
- "type": "extension_ui_request",
1259
- "id": "uuid-6",
1260
- "method": "setStatus",
1261
- "statusKey": "my-ext",
1262
- "statusText": "Turn 3 running..."
1263
- }
1264
- ```
89
+ Clients must also handle child-process startup failures, unexpected exits, stderr diagnostics, cancellation, and their own deadlines. Do not parse stderr as protocol data.
1265
90
 
1266
- Send `statusText: undefined` (or omit it) to clear the status entry for that key.
91
+ ## Shutdown
1267
92
 
1268
- #### setWidget
93
+ Close the child's stdin to request an orderly shutdown. draht disposes the active runtime before exiting. Clients should still handle process signals and unexpected exits.
1269
94
 
1270
- Set or clear a widget (block of text lines) displayed above or below the editor. Fire-and-forget.
95
+ An extension can also request shutdown through its extension context. draht completes shutdown after the current command or after the active run emits `agent_settled`.
1271
96
 
1272
- ```json
1273
- {
1274
- "type": "extension_ui_request",
1275
- "id": "uuid-7",
1276
- "method": "setWidget",
1277
- "widgetKey": "my-ext",
1278
- "widgetLines": ["--- My Widget ---", "Line 1", "Line 2"],
1279
- "widgetPlacement": "aboveEditor"
1280
- }
1281
- ```
97
+ ## Minimal client
1282
98
 
1283
- Send `widgetLines: undefined` (or omit it) to clear the widget. The `widgetPlacement` field is `"aboveEditor"` (default) or `"belowEditor"`. Only string arrays are supported in RPC mode; component factories are ignored.
99
+ This Python example uses a binary pipe reader, which splits on LF without treating Unicode separators as protocol boundaries:
1284
100
 
1285
- #### setTitle
101
+ ```python
102
+ import json
103
+ import subprocess
1286
104
 
1287
- Set the terminal window/tab title. Fire-and-forget.
105
+ process = subprocess.Popen(
106
+ ["draht", "--mode", "rpc", "--no-session"],
107
+ stdin=subprocess.PIPE,
108
+ stdout=subprocess.PIPE,
109
+ )
1288
110
 
1289
- ```json
1290
- {
1291
- "type": "extension_ui_request",
1292
- "id": "uuid-8",
1293
- "method": "setTitle",
1294
- "title": "draht - my project"
1295
- }
1296
- ```
111
+ assert process.stdin is not None
112
+ assert process.stdout is not None
1297
113
 
1298
- #### set_editor_text
114
+ command = {"id": "prompt-1", "type": "prompt", "message": "Hello"}
115
+ process.stdin.write(json.dumps(command).encode("utf-8") + b"\n")
116
+ process.stdin.flush()
1299
117
 
1300
- Set the text in the input editor. Fire-and-forget.
118
+ while line := process.stdout.readline():
119
+ record = json.loads(line)
120
+ if record.get("type") == "message_update":
121
+ update = record["assistantMessageEvent"]
122
+ if update["type"] == "text_delta":
123
+ print(update["delta"], end="", flush=True)
124
+ elif record.get("type") == "agent_settled":
125
+ print()
126
+ break
1301
127
 
1302
- ```json
1303
- {
1304
- "type": "extension_ui_request",
1305
- "id": "uuid-9",
1306
- "method": "set_editor_text",
1307
- "text": "prefilled text for the user"
1308
- }
128
+ process.stdin.close()
129
+ process.wait()
1309
130
  ```
1310
131
 
1311
- ### Extension UI Responses (stdin)
1312
-
1313
- Responses are sent for dialog methods only (`select`, `confirm`, `input`, `editor`). The `id` must match the request. An answer whose `id` matches no open dialog is silently dropped.
1314
-
1315
- #### Value response (select, input, editor)
1316
-
1317
- ```json
1318
- {"type": "extension_ui_response", "id": "uuid-1", "value": "Allow"}
1319
- ```
132
+ For maintained TypeScript clients, use the checked [RPC client example](../examples/rpc-client.ts). It requires a built draht CLI because the repository example points to `dist/cli.js`.
1320
133
 
1321
- #### Confirmation response (confirm)
134
+ ## Extension UI option ids
1322
135
 
1323
- ```json
1324
- {"type": "extension_ui_response", "id": "uuid-2", "confirmed": true}
1325
- ```
136
+ [RPC Extension UI](rpc-extension-ui.md) defines the dialog requests and their `confirmed` / `value` / `cancelled` responses. draht extends dialog answers with an optional `optionId`, and an answer whose `id` matches no open dialog is silently dropped.
1326
137
 
1327
- #### Naming the option that was chosen (`optionId`)
138
+ ### Naming the option that was chosen (`optionId`)
1328
139
 
1329
140
  A request may carry a `detail` object describing what is being decided. When it does, `detail.options`
1330
141
  is the immutable set of options that request offered, each stating its own meaning:
@@ -1374,7 +185,7 @@ Rules, all enforced by the agent:
1374
185
  so `optionId` is ignored and the answer decides on `confirmed` / `value` as usual. A client may
1375
186
  therefore attach `optionId` unconditionally without risk of stranding those dialogs.
1376
187
 
1377
- #### Refused response (`command: "extension_ui_response"`)
188
+ ### Refused response (`command: "extension_ui_response"`)
1378
189
 
1379
190
  A rejected `optionId` is reported on stdout as an ordinary failed-command response — note that
1380
191
  `command` here is `"extension_ui_response"`, a value **no client ever sends as a command**. Clients
@@ -1395,253 +206,63 @@ request: the dialog is still open and still answerable, and a subsequent valid a
1395
206
  `optionId`, or with none at all — decides it. A client that receives this line should correct its
1396
207
  answer and send it again; ignoring it leaves the agent waiting.
1397
208
 
1398
- #### Cancellation response (any dialog)
1399
-
1400
- Dismiss any dialog method. The extension receives `undefined` (for select/input/editor) or `false` (for confirm).
1401
-
1402
- ```json
1403
- {"type": "extension_ui_response", "id": "uuid-3", "cancelled": true}
1404
- ```
1405
-
1406
- ## Error Handling
1407
-
1408
- Failed commands return a response with `success: false`:
1409
-
1410
- ```json
1411
- {
1412
- "type": "response",
1413
- "command": "set_model",
1414
- "success": false,
1415
- "error": "Model not found: invalid/model"
1416
- }
1417
- ```
1418
-
1419
- Parse errors:
1420
-
1421
- ```json
1422
- {
1423
- "type": "response",
1424
- "command": "parse",
1425
- "success": false,
1426
- "error": "Failed to parse command: Unexpected token..."
1427
- }
1428
- ```
1429
-
1430
- ## Types
1431
-
1432
- Source files:
1433
- - [`packages/ai/src/types.ts`](../../ai/src/types.ts) - `Model`, `UserMessage`, `AssistantMessage`, `ToolResultMessage`
1434
- - [`packages/agent/src/types.ts`](../../agent/src/types.ts) - `AgentMessage`, `AgentEvent`
1435
- - [`src/core/messages.ts`](../src/core/messages.ts) - `BashExecutionMessage`
1436
- - [`src/modes/rpc/rpc-types.ts`](../src/modes/rpc/rpc-types.ts) - RPC command/response types, extension UI request/response types
1437
-
1438
- ### Model
1439
-
1440
- ```json
1441
- {
1442
- "id": "claude-sonnet-4-20250514",
1443
- "name": "Claude Sonnet 4",
1444
- "api": "anthropic-messages",
1445
- "provider": "anthropic",
1446
- "baseUrl": "https://api.anthropic.com",
1447
- "reasoning": true,
1448
- "input": ["text", "image"],
1449
- "contextWindow": 200000,
1450
- "maxTokens": 16384,
1451
- "cost": {
1452
- "input": 3.0,
1453
- "output": 15.0,
1454
- "cacheRead": 0.3,
1455
- "cacheWrite": 3.75
1456
- }
1457
- }
1458
- ```
1459
-
1460
- ### UserMessage
1461
-
1462
- ```json
1463
- {
1464
- "role": "user",
1465
- "content": "Hello!",
1466
- "timestamp": 1733234567890,
1467
- "attachments": []
1468
- }
1469
- ```
1470
-
1471
- The `content` field can be a string or an array of `TextContent`/`ImageContent` blocks.
1472
-
1473
- ### AssistantMessage
1474
-
1475
- ```json
1476
- {
1477
- "role": "assistant",
1478
- "content": [
1479
- {"type": "text", "text": "Hello! How can I help?"},
1480
- {"type": "thinking", "thinking": "User is greeting me..."},
1481
- {"type": "toolCall", "id": "call_123", "name": "bash", "arguments": {"command": "ls"}}
1482
- ],
1483
- "api": "anthropic-messages",
1484
- "provider": "anthropic",
1485
- "model": "claude-sonnet-4-20250514",
1486
- "usage": {
1487
- "input": 100,
1488
- "output": 50,
1489
- "cacheRead": 0,
1490
- "cacheWrite": 0,
1491
- "cost": {"input": 0.0003, "output": 0.00075, "cacheRead": 0, "cacheWrite": 0, "total": 0.00105}
1492
- },
1493
- "stopReason": "stop",
1494
- "timestamp": 1733234567890
1495
- }
1496
- ```
1497
-
1498
- Stop reasons: `"stop"`, `"length"`, `"toolUse"`, `"error"`, `"aborted"`
1499
-
1500
- ### ToolResultMessage
1501
-
1502
- ```json
1503
- {
1504
- "role": "toolResult",
1505
- "toolCallId": "call_123",
1506
- "toolName": "bash",
1507
- "content": [{"type": "text", "text": "total 48\ndrwxr-xr-x ..."}],
1508
- "usage": {
1509
- "input": 100,
1510
- "output": 50,
1511
- "cacheRead": 0,
1512
- "cacheWrite": 0,
1513
- "totalTokens": 150,
1514
- "cost": {"input": 0.0003, "output": 0.00075, "cacheRead": 0, "cacheWrite": 0, "total": 0.00105}
1515
- },
1516
- "isError": false,
1517
- "timestamp": 1733234567890
1518
- }
1519
- ```
1520
-
1521
- `usage` is optional and reports nested LLM work performed by the tool. When present, it contributes to session token and cost totals.
1522
-
1523
- ### BashExecutionMessage
1524
-
1525
- Created by the `bash` RPC command (not by LLM tool calls):
1526
-
1527
- ```json
1528
- {
1529
- "role": "bashExecution",
1530
- "command": "ls -la",
1531
- "output": "total 48\ndrwxr-xr-x ...",
1532
- "exitCode": 0,
1533
- "cancelled": false,
1534
- "truncated": false,
1535
- "fullOutputPath": null,
1536
- "timestamp": 1733234567890
1537
- }
1538
- ```
1539
-
1540
- ### Attachment
1541
-
1542
- ```json
1543
- {
1544
- "id": "img1",
1545
- "type": "image",
1546
- "fileName": "photo.jpg",
1547
- "mimeType": "image/jpeg",
1548
- "size": 102400,
1549
- "content": "base64-encoded-data...",
1550
- "extractedText": null,
1551
- "preview": null
1552
- }
1553
- ```
1554
-
1555
- ## Example: Basic Client (Python)
1556
-
1557
- ```python
1558
- import subprocess
1559
- import json
1560
-
1561
- proc = subprocess.Popen(
1562
- ["draht", "--mode", "rpc", "--no-session"],
1563
- stdin=subprocess.PIPE,
1564
- stdout=subprocess.PIPE,
1565
- text=True
1566
- )
1567
-
1568
- def send(cmd):
1569
- proc.stdin.write(json.dumps(cmd) + "\n")
1570
- proc.stdin.flush()
1571
-
1572
- def read_events():
1573
- for line in proc.stdout:
1574
- yield json.loads(line)
1575
-
1576
- # Send prompt
1577
- send({"type": "prompt", "message": "Hello!"})
1578
-
1579
- # Process events
1580
- for event in read_events():
1581
- if event.get("type") == "message_update":
1582
- delta = event.get("assistantMessageEvent", {})
1583
- if delta.get("type") == "text_delta":
1584
- print(delta["delta"], end="", flush=True)
1585
-
1586
- if event.get("type") == "agent_end":
1587
- print()
1588
- break
1589
- ```
1590
-
1591
- ## Example: Interactive Client (Node.js)
1592
-
1593
- See [`test/rpc-example.ts`](../test/rpc-example.ts) for a complete interactive example, or [`src/modes/rpc/rpc-client.ts`](../src/modes/rpc/rpc-client.ts) for a typed client implementation.
1594
-
1595
- For a complete example of handling the extension UI protocol, see [`examples/rpc-extension-ui.ts`](../examples/rpc-extension-ui.ts) which pairs with the [`examples/extensions/rpc-demo.ts`](../examples/extensions/rpc-demo.ts) extension.
1596
-
1597
- ```javascript
1598
- const { spawn } = require("child_process");
1599
- const { StringDecoder } = require("string_decoder");
1600
-
1601
- const agent = spawn("draht", ["--mode", "rpc", "--no-session"]);
1602
-
1603
- function attachJsonlReader(stream, onLine) {
1604
- const decoder = new StringDecoder("utf8");
1605
- let buffer = "";
1606
-
1607
- stream.on("data", (chunk) => {
1608
- buffer += typeof chunk === "string" ? chunk : decoder.write(chunk);
1609
-
1610
- while (true) {
1611
- const newlineIndex = buffer.indexOf("\n");
1612
- if (newlineIndex === -1) break;
1613
-
1614
- let line = buffer.slice(0, newlineIndex);
1615
- buffer = buffer.slice(newlineIndex + 1);
1616
- if (line.endsWith("\r")) line = line.slice(0, -1);
1617
- onLine(line);
1618
- }
1619
- });
1620
-
1621
- stream.on("end", () => {
1622
- buffer += decoder.end();
1623
- if (buffer.length > 0) {
1624
- onLine(buffer.endsWith("\r") ? buffer.slice(0, -1) : buffer);
1625
- }
1626
- });
1627
- }
1628
-
1629
- attachJsonlReader(agent.stdout, (line) => {
1630
- const event = JSON.parse(line);
1631
-
1632
- if (event.type === "message_update") {
1633
- const { assistantMessageEvent } = event;
1634
- if (assistantMessageEvent.type === "text_delta") {
1635
- process.stdout.write(assistantMessageEvent.delta);
1636
- }
1637
- }
1638
- });
1639
-
1640
- // Send prompt
1641
- agent.stdin.write(JSON.stringify({ type: "prompt", message: "Hello" }) + "\n");
1642
-
1643
- // Abort on Ctrl+C
1644
- process.on("SIGINT", () => {
1645
- agent.stdin.write(JSON.stringify({ type: "abort" }) + "\n");
1646
- });
1647
- ```
209
+ ## Reference
210
+
211
+ - [RPC Commands](rpc-commands.md): every stdin command and response
212
+ - [JSON Event Stream](json.md): shared stdout session events and streaming reconstruction
213
+ - [RPC Extension UI](rpc-extension-ui.md): dialogs, notifications, responses, and limitations
214
+ - [Message Types](message-types.md): messages and content blocks used by responses and events
215
+ - [Session File Format](session-format.md): entries returned by session commands
216
+ - [`rpc-types.ts`](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/modes/rpc/rpc-types.ts): exported TypeScript protocol definitions
217
+ - [`RpcClient`](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/modes/rpc/rpc-client.ts): subprocess client implementation
218
+
219
+ ## Moved reference anchors
220
+
221
+ The detailed references formerly on this page now have dedicated pages. These anchors preserve existing links.
222
+
223
+ <a id="prompt"></a>
224
+ <a id="steer"></a>
225
+ <a id="follow_up"></a>
226
+ <a id="abort"></a>
227
+ <a id="clear_queue"></a>
228
+ <a id="new_session"></a>
229
+ <a id="get_state"></a>
230
+ <a id="get_messages"></a>
231
+ <a id="set_model"></a>
232
+ <a id="cycle_model"></a>
233
+ <a id="get_available_models"></a>
234
+ <a id="set_thinking_level"></a>
235
+ <a id="cycle_thinking_level"></a>
236
+ <a id="get_available_thinking_levels"></a>
237
+ <a id="set_steering_mode"></a>
238
+ <a id="set_follow_up_mode"></a>
239
+ <a id="compact"></a>
240
+ <a id="set_auto_compaction"></a>
241
+ <a id="set_auto_retry"></a>
242
+ <a id="abort_retry"></a>
243
+ <a id="bash"></a>
244
+ <a id="abort_bash"></a>
245
+ <a id="get_session_stats"></a>
246
+ <a id="export_html"></a>
247
+ <a id="switch_session"></a>
248
+ <a id="fork"></a>
249
+ <a id="clone"></a>
250
+ <a id="get_fork_messages"></a>
251
+ <a id="get_entries"></a>
252
+ <a id="get_tree"></a>
253
+ <a id="get_last_assistant_text"></a>
254
+ <a id="set_session_name"></a>
255
+ <a id="get_commands"></a>
256
+
257
+ Command details moved to [RPC Commands](rpc-commands.md).
258
+
259
+ <a id="message_update-streaming"></a>
260
+ <a id="bash_execution_update"></a>
261
+ <a id="compaction_start--compaction_end"></a>
262
+ <a id="summarization_retry_scheduled--summarization_retry_attempt_start--summarization_retry_finished"></a>
263
+
264
+ Event details moved to [JSON Event Stream](json.md).
265
+
266
+ <a id="extension-ui-protocol"></a>
267
+
268
+ Extension interaction details moved to [RPC Extension UI](rpc-extension-ui.md).