@earendil-works/pi-coding-agent 0.85.0 → 0.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (544) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/README.md +2 -3
  3. package/dist/bun/cli.d.ts +3 -1
  4. package/dist/bun/cli.d.ts.map +1 -1
  5. package/dist/bun/cli.js +3 -12
  6. package/dist/bun/cli.js.map +1 -1
  7. package/dist/bun/sandbox-env-setup.d.ts +2 -0
  8. package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
  9. package/dist/bun/sandbox-env-setup.js +4 -0
  10. package/dist/bun/sandbox-env-setup.js.map +1 -0
  11. package/dist/bundle/chunks/anthropic-messages-MYU5ZMRF.js +6 -0
  12. package/dist/bundle/chunks/azure-openai-responses-HUSQ3GP2.js +2 -0
  13. package/dist/bundle/chunks/bedrock-converse-stream.js +47 -38
  14. package/dist/bundle/chunks/chunk-7IOYH2SY.js +2 -0
  15. package/dist/bundle/chunks/chunk-7YM6BE7Y.js +1561 -0
  16. package/dist/bundle/chunks/chunk-A3JYRWB6.js +2 -0
  17. package/dist/bundle/chunks/chunk-DTD7JQ7Y.js +42 -0
  18. package/dist/bundle/chunks/chunk-FUXEF6JQ.js +44 -0
  19. package/dist/bundle/chunks/{chunk-IDDQWTHI.js → chunk-RCZIEVGO.js} +10 -1
  20. package/dist/bundle/chunks/chunk-S7SZN6Z3.js +2 -0
  21. package/dist/bundle/chunks/chunk-WIUZI2CJ.js +11 -0
  22. package/dist/bundle/chunks/github-copilot.js +1 -1
  23. package/dist/bundle/chunks/google-generative-ai-IMS5EK2Y.js +2 -0
  24. package/dist/bundle/chunks/google-vertex-O4YJEQUW.js +2 -0
  25. package/dist/bundle/chunks/jiti-loader-C3NU2SDH.js +21 -0
  26. package/dist/bundle/chunks/jiti-static-loader-E6ANQD5T.js +2 -0
  27. package/dist/bundle/chunks/mistral-conversations-NOSQHBEY.js +5 -0
  28. package/dist/bundle/chunks/{node-EM5FIVUN.js → node-O3RIBJRH.js} +1 -1
  29. package/dist/bundle/chunks/openai-codex-responses-QDSOTBBO.js +10 -0
  30. package/dist/bundle/chunks/openai-completions-KQPOPEVM.js +7 -0
  31. package/dist/bundle/chunks/openai-responses-HWEUZ6WZ.js +2 -0
  32. package/dist/bundle/chunks/{pi-messages-EGZIFQGG.js → pi-messages-GFKBWJHZ.js} +1 -1
  33. package/dist/bundle/chunks/virtual-modules-XW5APVUE.js +2 -0
  34. package/dist/bundle/cli.js +1 -1
  35. package/dist/bundle/index.js +1 -1
  36. package/dist/bundle/rpc-entry.js +1 -1
  37. package/dist/cli/args.d.ts.map +1 -1
  38. package/dist/cli/args.js +0 -2
  39. package/dist/cli/args.js.map +1 -1
  40. package/dist/cli/session-picker.d.ts +1 -1
  41. package/dist/cli/session-picker.d.ts.map +1 -1
  42. package/dist/cli/session-picker.js.map +1 -1
  43. package/dist/cli/setup.d.ts +2 -0
  44. package/dist/cli/setup.d.ts.map +1 -0
  45. package/dist/cli/setup.js +12 -0
  46. package/dist/cli/setup.js.map +1 -0
  47. package/dist/cli.d.ts.map +1 -1
  48. package/dist/cli.js +3 -25
  49. package/dist/cli.js.map +1 -1
  50. package/dist/config.d.ts.map +1 -1
  51. package/dist/config.js +1 -1
  52. package/dist/config.js.map +1 -1
  53. package/dist/core/agent-session.d.ts +56 -6
  54. package/dist/core/agent-session.d.ts.map +1 -1
  55. package/dist/core/agent-session.js +293 -155
  56. package/dist/core/agent-session.js.map +1 -1
  57. package/dist/core/bug-report-upload.d.ts +12 -0
  58. package/dist/core/bug-report-upload.d.ts.map +1 -0
  59. package/dist/core/bug-report-upload.js +22 -0
  60. package/dist/core/bug-report-upload.js.map +1 -0
  61. package/dist/core/bug-report.d.ts +176 -0
  62. package/dist/core/bug-report.d.ts.map +1 -0
  63. package/dist/core/bug-report.js +292 -0
  64. package/dist/core/bug-report.js.map +1 -0
  65. package/dist/core/cache-stats.d.ts.map +1 -1
  66. package/dist/core/cache-stats.js +12 -1
  67. package/dist/core/cache-stats.js.map +1 -1
  68. package/dist/core/cache-warmer.d.ts +102 -0
  69. package/dist/core/cache-warmer.d.ts.map +1 -0
  70. package/dist/core/cache-warmer.js +342 -0
  71. package/dist/core/cache-warmer.js.map +1 -0
  72. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  73. package/dist/core/compaction/branch-summarization.js +2 -2
  74. package/dist/core/compaction/branch-summarization.js.map +1 -1
  75. package/dist/core/compaction/compaction.d.ts +2 -2
  76. package/dist/core/compaction/compaction.d.ts.map +1 -1
  77. package/dist/core/compaction/compaction.js +11 -12
  78. package/dist/core/compaction/compaction.js.map +1 -1
  79. package/dist/core/crash-log.d.ts +22 -0
  80. package/dist/core/crash-log.d.ts.map +1 -0
  81. package/dist/core/crash-log.js +71 -0
  82. package/dist/core/crash-log.js.map +1 -0
  83. package/dist/core/experimental.d.ts +0 -4
  84. package/dist/core/experimental.d.ts.map +1 -1
  85. package/dist/core/experimental.js +0 -4
  86. package/dist/core/experimental.js.map +1 -1
  87. package/dist/core/extensions/index.d.ts +1 -1
  88. package/dist/core/extensions/index.d.ts.map +1 -1
  89. package/dist/core/extensions/index.js.map +1 -1
  90. package/dist/core/extensions/jiti-loader.d.ts +2 -0
  91. package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
  92. package/dist/core/extensions/jiti-loader.js +4 -0
  93. package/dist/core/extensions/jiti-loader.js.map +1 -0
  94. package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
  95. package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
  96. package/dist/core/extensions/jiti-static-loader.js +4 -0
  97. package/dist/core/extensions/jiti-static-loader.js.map +1 -0
  98. package/dist/core/extensions/loader.d.ts.map +1 -1
  99. package/dist/core/extensions/loader.js +38 -51
  100. package/dist/core/extensions/loader.js.map +1 -1
  101. package/dist/core/extensions/runner.d.ts +10 -7
  102. package/dist/core/extensions/runner.d.ts.map +1 -1
  103. package/dist/core/extensions/runner.js +85 -67
  104. package/dist/core/extensions/runner.js.map +1 -1
  105. package/dist/core/extensions/types.d.ts +60 -50
  106. package/dist/core/extensions/types.d.ts.map +1 -1
  107. package/dist/core/extensions/types.js.map +1 -1
  108. package/dist/core/extensions/virtual-modules.d.ts +3 -0
  109. package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
  110. package/dist/core/extensions/virtual-modules.js +38 -0
  111. package/dist/core/extensions/virtual-modules.js.map +1 -0
  112. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  113. package/dist/core/extensions/wrapper.js +1 -20
  114. package/dist/core/extensions/wrapper.js.map +1 -1
  115. package/dist/core/index.d.ts +2 -1
  116. package/dist/core/index.d.ts.map +1 -1
  117. package/dist/core/index.js.map +1 -1
  118. package/dist/core/keybindings.d.ts +6 -1
  119. package/dist/core/keybindings.d.ts.map +1 -1
  120. package/dist/core/keybindings.js +5 -1
  121. package/dist/core/keybindings.js.map +1 -1
  122. package/dist/core/messages.d.ts.map +1 -1
  123. package/dist/core/messages.js +1 -0
  124. package/dist/core/messages.js.map +1 -1
  125. package/dist/core/model-config.d.ts +101 -20
  126. package/dist/core/model-config.d.ts.map +1 -1
  127. package/dist/core/model-config.js +25 -18
  128. package/dist/core/model-config.js.map +1 -1
  129. package/dist/core/model-registry.d.ts +5 -1
  130. package/dist/core/model-registry.d.ts.map +1 -1
  131. package/dist/core/model-registry.js +8 -0
  132. package/dist/core/model-registry.js.map +1 -1
  133. package/dist/core/model-resolver.d.ts.map +1 -1
  134. package/dist/core/model-resolver.js +1 -1
  135. package/dist/core/model-resolver.js.map +1 -1
  136. package/dist/core/model-runtime.d.ts.map +1 -1
  137. package/dist/core/model-runtime.js +5 -3
  138. package/dist/core/model-runtime.js.map +1 -1
  139. package/dist/core/provider-composer.d.ts +3 -2
  140. package/dist/core/provider-composer.d.ts.map +1 -1
  141. package/dist/core/provider-composer.js +2 -0
  142. package/dist/core/provider-composer.js.map +1 -1
  143. package/dist/core/radius.d.ts +3 -0
  144. package/dist/core/radius.d.ts.map +1 -1
  145. package/dist/core/radius.js +6 -0
  146. package/dist/core/radius.js.map +1 -1
  147. package/dist/core/sdk.d.ts.map +1 -1
  148. package/dist/core/sdk.js +60 -38
  149. package/dist/core/sdk.js.map +1 -1
  150. package/dist/core/session-export.d.ts +6 -2
  151. package/dist/core/session-export.d.ts.map +1 -1
  152. package/dist/core/session-export.js +14 -13
  153. package/dist/core/session-export.js.map +1 -1
  154. package/dist/core/session-manager.d.ts +29 -6
  155. package/dist/core/session-manager.d.ts.map +1 -1
  156. package/dist/core/session-manager.js +159 -96
  157. package/dist/core/session-manager.js.map +1 -1
  158. package/dist/core/settings-manager.d.ts +20 -4
  159. package/dist/core/settings-manager.d.ts.map +1 -1
  160. package/dist/core/settings-manager.js +43 -7
  161. package/dist/core/settings-manager.js.map +1 -1
  162. package/dist/core/slash-commands.d.ts.map +1 -1
  163. package/dist/core/slash-commands.js +1 -0
  164. package/dist/core/slash-commands.js.map +1 -1
  165. package/dist/core/system-prompt.d.ts +49 -6
  166. package/dist/core/system-prompt.d.ts.map +1 -1
  167. package/dist/core/system-prompt.js +121 -92
  168. package/dist/core/system-prompt.js.map +1 -1
  169. package/dist/core/tools/bash.d.ts +2 -1
  170. package/dist/core/tools/bash.d.ts.map +1 -1
  171. package/dist/core/tools/bash.js +10 -4
  172. package/dist/core/tools/bash.js.map +1 -1
  173. package/dist/core/tools/edit.d.ts.map +1 -1
  174. package/dist/core/tools/edit.js +1 -2
  175. package/dist/core/tools/edit.js.map +1 -1
  176. package/dist/core/tools/read.d.ts.map +1 -1
  177. package/dist/core/tools/read.js +1 -2
  178. package/dist/core/tools/read.js.map +1 -1
  179. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  180. package/dist/core/tools/renderers/bash.js +9 -1
  181. package/dist/core/tools/renderers/bash.js.map +1 -1
  182. package/dist/core/tools/write.d.ts.map +1 -1
  183. package/dist/core/tools/write.js +1 -2
  184. package/dist/core/tools/write.js.map +1 -1
  185. package/dist/core/usage-totals.d.ts +1 -1
  186. package/dist/core/usage-totals.d.ts.map +1 -1
  187. package/dist/core/usage-totals.js +5 -1
  188. package/dist/core/usage-totals.js.map +1 -1
  189. package/dist/extensions/llama/client.d.ts +2 -0
  190. package/dist/extensions/llama/client.d.ts.map +1 -1
  191. package/dist/extensions/llama/client.js +7 -3
  192. package/dist/extensions/llama/client.js.map +1 -1
  193. package/dist/extensions/llama/provider.d.ts.map +1 -1
  194. package/dist/extensions/llama/provider.js +20 -5
  195. package/dist/extensions/llama/provider.js.map +1 -1
  196. package/dist/index.d.ts +3 -2
  197. package/dist/index.d.ts.map +1 -1
  198. package/dist/index.js.map +1 -1
  199. package/dist/main.d.ts.map +1 -1
  200. package/dist/main.js +13 -131
  201. package/dist/main.js.map +1 -1
  202. package/dist/migrations.d.ts.map +1 -1
  203. package/dist/migrations.js +2 -2
  204. package/dist/migrations.js.map +1 -1
  205. package/dist/modes/interactive/bug-report.d.ts +14 -0
  206. package/dist/modes/interactive/bug-report.d.ts.map +1 -0
  207. package/dist/modes/interactive/bug-report.js +209 -0
  208. package/dist/modes/interactive/bug-report.js.map +1 -0
  209. package/dist/modes/interactive/chat-viewport.d.ts.map +1 -1
  210. package/dist/modes/interactive/chat-viewport.js +1 -1
  211. package/dist/modes/interactive/chat-viewport.js.map +1 -1
  212. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  213. package/dist/modes/interactive/components/branch-summary-message.js +12 -5
  214. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  215. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  216. package/dist/modes/interactive/components/compaction-summary-message.js +12 -5
  217. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  218. package/dist/modes/interactive/components/custom-editor.d.ts +3 -3
  219. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  220. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  221. package/dist/modes/interactive/components/extension-input.d.ts +2 -0
  222. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  223. package/dist/modes/interactive/components/extension-input.js +6 -0
  224. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  225. package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
  226. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  227. package/dist/modes/interactive/components/extension-selector.js +4 -0
  228. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  229. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  230. package/dist/modes/interactive/components/footer.js +4 -1
  231. package/dist/modes/interactive/components/footer.js.map +1 -1
  232. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  233. package/dist/modes/interactive/components/model-selector.js +5 -5
  234. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  235. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  236. package/dist/modes/interactive/components/scoped-models-selector.js +8 -8
  237. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  238. package/dist/modes/interactive/components/session-selector.d.ts +5 -5
  239. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  240. package/dist/modes/interactive/components/session-selector.js +74 -48
  241. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  242. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  243. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  244. package/dist/modes/interactive/components/settings-selector.js +11 -0
  245. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  246. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  247. package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
  248. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  249. package/dist/modes/interactive/components/status-indicator.d.ts +2 -2
  250. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  251. package/dist/modes/interactive/components/status-indicator.js +7 -7
  252. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  253. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  254. package/dist/modes/interactive/components/thinking-selector.js +4 -4
  255. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  256. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  257. package/dist/modes/interactive/components/tool-execution.js +18 -9
  258. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  259. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  260. package/dist/modes/interactive/components/tree-selector.js +2 -0
  261. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  262. package/dist/modes/interactive/interactive-mode.d.ts +13 -1
  263. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  264. package/dist/modes/interactive/interactive-mode.js +220 -84
  265. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  266. package/dist/modes/interactive/session-share.d.ts +2 -0
  267. package/dist/modes/interactive/session-share.d.ts.map +1 -1
  268. package/dist/modes/interactive/session-share.js +8 -4
  269. package/dist/modes/interactive/session-share.js.map +1 -1
  270. package/dist/modes/interactive/tui-renderer.d.ts.map +1 -1
  271. package/dist/modes/interactive/tui-renderer.js +2 -2
  272. package/dist/modes/interactive/tui-renderer.js.map +1 -1
  273. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  274. package/dist/modes/rpc/rpc-mode.js +2 -2
  275. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  276. package/dist/utils/clipboard-command.d.ts +7 -0
  277. package/dist/utils/clipboard-command.d.ts.map +1 -0
  278. package/dist/utils/clipboard-command.js +45 -0
  279. package/dist/utils/clipboard-command.js.map +1 -0
  280. package/dist/utils/clipboard-image.d.ts.map +1 -1
  281. package/dist/utils/clipboard-image.js +52 -69
  282. package/dist/utils/clipboard-image.js.map +1 -1
  283. package/dist/utils/clipboard.d.ts.map +1 -1
  284. package/dist/utils/clipboard.js +61 -125
  285. package/dist/utils/clipboard.js.map +1 -1
  286. package/dist/utils/zip.d.ts +7 -0
  287. package/dist/utils/zip.d.ts.map +1 -0
  288. package/dist/utils/zip.js +60 -0
  289. package/dist/utils/zip.js.map +1 -0
  290. package/docs/compaction.md +39 -13
  291. package/docs/containerization.md +45 -0
  292. package/docs/custom-provider.md +22 -13
  293. package/docs/development.md +23 -4
  294. package/docs/docs.json +4 -0
  295. package/docs/environment-variables.md +3 -2
  296. package/docs/extensions.md +57 -43
  297. package/docs/json.md +4 -4
  298. package/docs/keybindings.md +2 -1
  299. package/docs/models.md +34 -3
  300. package/docs/providers.md +2 -2
  301. package/docs/sdk.md +4 -2
  302. package/docs/security.md +1 -1
  303. package/docs/session-format.md +82 -40
  304. package/docs/sessions.md +27 -0
  305. package/docs/settings.md +60 -1
  306. package/docs/termux.md +0 -1
  307. package/docs/tui.md +2 -2
  308. package/docs/usage.md +1 -0
  309. package/examples/extensions/README.md +0 -1
  310. package/examples/extensions/custom-provider-anthropic/index.ts +18 -12
  311. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  312. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  313. package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
  314. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  315. package/examples/extensions/gondolin/package-lock.json +2 -2
  316. package/examples/extensions/gondolin/package.json +1 -1
  317. package/examples/extensions/prompt-customizer.ts +19 -67
  318. package/examples/extensions/sandbox/package-lock.json +2 -2
  319. package/examples/extensions/sandbox/package.json +1 -1
  320. package/examples/extensions/with-deps/package-lock.json +2 -2
  321. package/examples/extensions/with-deps/package.json +1 -1
  322. package/npm-shrinkwrap.json +425 -778
  323. package/package.json +22 -27
  324. package/dist/bundle/chunks/anthropic-messages-QAQLEQIY.js +0 -6
  325. package/dist/bundle/chunks/azure-openai-responses-Q7MJBRE6.js +0 -2
  326. package/dist/bundle/chunks/chunk-2KVJKXS2.js +0 -50
  327. package/dist/bundle/chunks/chunk-AXIIZGTV.js +0 -2
  328. package/dist/bundle/chunks/chunk-EQ6DR6XK.js +0 -5
  329. package/dist/bundle/chunks/chunk-GMWCTUPB.js +0 -2
  330. package/dist/bundle/chunks/chunk-LZKJTKCT.js +0 -2
  331. package/dist/bundle/chunks/chunk-OUXLLA64.js +0 -11
  332. package/dist/bundle/chunks/chunk-R7UUJ4C2.js +0 -42
  333. package/dist/bundle/chunks/chunk-UAQELI3K.js +0 -2
  334. package/dist/bundle/chunks/chunk-WBE4J4AU.js +0 -9
  335. package/dist/bundle/chunks/chunk-WZB2R5YO.js +0 -1558
  336. package/dist/bundle/chunks/google-generative-ai-BSMTYDAM.js +0 -2
  337. package/dist/bundle/chunks/google-vertex-5C3HASOJ.js +0 -2
  338. package/dist/bundle/chunks/mistral-conversations-4M6BZBX6.js +0 -5
  339. package/dist/bundle/chunks/openai-codex-responses-YJOO52RW.js +0 -10
  340. package/dist/bundle/chunks/openai-completions-QOT3QX7D.js +0 -7
  341. package/dist/bundle/chunks/openai-responses-U7LNPQN4.js +0 -2
  342. package/dist/bundle/client.js +0 -2
  343. package/dist/bundle/coordinator.js +0 -3
  344. package/dist/cli/experimental/cli.d.ts +0 -10
  345. package/dist/cli/experimental/cli.d.ts.map +0 -1
  346. package/dist/cli/experimental/cli.js +0 -9
  347. package/dist/cli/experimental/cli.js.map +0 -1
  348. package/dist/cli/experimental/command-options.d.ts +0 -28
  349. package/dist/cli/experimental/command-options.d.ts.map +0 -1
  350. package/dist/cli/experimental/command-options.js +0 -84
  351. package/dist/cli/experimental/command-options.js.map +0 -1
  352. package/dist/cli/experimental/command.d.ts +0 -70
  353. package/dist/cli/experimental/command.d.ts.map +0 -1
  354. package/dist/cli/experimental/command.js +0 -144
  355. package/dist/cli/experimental/command.js.map +0 -1
  356. package/dist/cli/experimental/commands/client.d.ts +0 -19
  357. package/dist/cli/experimental/commands/client.d.ts.map +0 -1
  358. package/dist/cli/experimental/commands/client.js +0 -63
  359. package/dist/cli/experimental/commands/client.js.map +0 -1
  360. package/dist/cli/experimental/commands/server.d.ts +0 -17
  361. package/dist/cli/experimental/commands/server.d.ts.map +0 -1
  362. package/dist/cli/experimental/commands/server.js +0 -44
  363. package/dist/cli/experimental/commands/server.js.map +0 -1
  364. package/dist/client/index.d.ts +0 -2
  365. package/dist/client/index.d.ts.map +0 -1
  366. package/dist/client/index.js +0 -2
  367. package/dist/client/index.js.map +0 -1
  368. package/dist/experimental/client-runtime.d.ts +0 -43
  369. package/dist/experimental/client-runtime.d.ts.map +0 -1
  370. package/dist/experimental/client-runtime.js +0 -183
  371. package/dist/experimental/client-runtime.js.map +0 -1
  372. package/dist/experimental/client-tui-chat.d.ts +0 -14
  373. package/dist/experimental/client-tui-chat.d.ts.map +0 -1
  374. package/dist/experimental/client-tui-chat.js +0 -171
  375. package/dist/experimental/client-tui-chat.js.map +0 -1
  376. package/dist/experimental/client-tui.d.ts +0 -37
  377. package/dist/experimental/client-tui.d.ts.map +0 -1
  378. package/dist/experimental/client-tui.js +0 -702
  379. package/dist/experimental/client-tui.js.map +0 -1
  380. package/dist/experimental/client.d.ts +0 -25
  381. package/dist/experimental/client.d.ts.map +0 -1
  382. package/dist/experimental/client.js +0 -99
  383. package/dist/experimental/client.js.map +0 -1
  384. package/dist/experimental/coordinator-entry.d.ts +0 -3
  385. package/dist/experimental/coordinator-entry.d.ts.map +0 -1
  386. package/dist/experimental/coordinator-entry.js +0 -11
  387. package/dist/experimental/coordinator-entry.js.map +0 -1
  388. package/dist/experimental/coordinator.d.ts +0 -38
  389. package/dist/experimental/coordinator.d.ts.map +0 -1
  390. package/dist/experimental/coordinator.js +0 -570
  391. package/dist/experimental/coordinator.js.map +0 -1
  392. package/dist/experimental/mini/main.d.ts +0 -7
  393. package/dist/experimental/mini/main.d.ts.map +0 -1
  394. package/dist/experimental/mini/main.js +0 -21
  395. package/dist/experimental/mini/main.js.map +0 -1
  396. package/dist/experimental/mini/server/entry.d.ts +0 -3
  397. package/dist/experimental/mini/server/entry.d.ts.map +0 -1
  398. package/dist/experimental/mini/server/entry.js +0 -11
  399. package/dist/experimental/mini/server/entry.js.map +0 -1
  400. package/dist/experimental/mini/server/run.d.ts +0 -13
  401. package/dist/experimental/mini/server/run.d.ts.map +0 -1
  402. package/dist/experimental/mini/server/run.js +0 -150
  403. package/dist/experimental/mini/server/run.js.map +0 -1
  404. package/dist/experimental/mini/shared/protocol.d.ts +0 -127
  405. package/dist/experimental/mini/shared/protocol.d.ts.map +0 -1
  406. package/dist/experimental/mini/shared/protocol.js +0 -13
  407. package/dist/experimental/mini/shared/protocol.js.map +0 -1
  408. package/dist/experimental/mini/shared/rpc.d.ts +0 -49
  409. package/dist/experimental/mini/shared/rpc.d.ts.map +0 -1
  410. package/dist/experimental/mini/shared/rpc.js +0 -171
  411. package/dist/experimental/mini/shared/rpc.js.map +0 -1
  412. package/dist/experimental/mini/shared/transport.d.ts +0 -35
  413. package/dist/experimental/mini/shared/transport.d.ts.map +0 -1
  414. package/dist/experimental/mini/shared/transport.js +0 -94
  415. package/dist/experimental/mini/shared/transport.js.map +0 -1
  416. package/dist/experimental/mini/tui/run.d.ts +0 -9
  417. package/dist/experimental/mini/tui/run.d.ts.map +0 -1
  418. package/dist/experimental/mini/tui/run.js +0 -62
  419. package/dist/experimental/mini/tui/run.js.map +0 -1
  420. package/dist/experimental/mini/tui/session.d.ts +0 -26
  421. package/dist/experimental/mini/tui/session.d.ts.map +0 -1
  422. package/dist/experimental/mini/tui/session.js +0 -94
  423. package/dist/experimental/mini/tui/session.js.map +0 -1
  424. package/dist/experimental/mini/tui/view.d.ts +0 -10
  425. package/dist/experimental/mini/tui/view.d.ts.map +0 -1
  426. package/dist/experimental/mini/tui/view.js +0 -459
  427. package/dist/experimental/mini/tui/view.js.map +0 -1
  428. package/dist/experimental/mini/worker/entry.d.ts +0 -3
  429. package/dist/experimental/mini/worker/entry.d.ts.map +0 -1
  430. package/dist/experimental/mini/worker/entry.js +0 -10
  431. package/dist/experimental/mini/worker/entry.js.map +0 -1
  432. package/dist/experimental/mini/worker/lane-service.d.ts +0 -44
  433. package/dist/experimental/mini/worker/lane-service.d.ts.map +0 -1
  434. package/dist/experimental/mini/worker/lane-service.js +0 -97
  435. package/dist/experimental/mini/worker/lane-service.js.map +0 -1
  436. package/dist/experimental/mini/worker/models-service.d.ts +0 -19
  437. package/dist/experimental/mini/worker/models-service.d.ts.map +0 -1
  438. package/dist/experimental/mini/worker/models-service.js +0 -136
  439. package/dist/experimental/mini/worker/models-service.js.map +0 -1
  440. package/dist/experimental/mini/worker/run.d.ts +0 -14
  441. package/dist/experimental/mini/worker/run.d.ts.map +0 -1
  442. package/dist/experimental/mini/worker/run.js +0 -88
  443. package/dist/experimental/mini/worker/run.js.map +0 -1
  444. package/dist/experimental/plugin.d.ts +0 -4
  445. package/dist/experimental/plugin.d.ts.map +0 -1
  446. package/dist/experimental/plugin.js +0 -4
  447. package/dist/experimental/plugin.js.map +0 -1
  448. package/dist/experimental/plugins/bundled.d.ts +0 -7
  449. package/dist/experimental/plugins/bundled.d.ts.map +0 -1
  450. package/dist/experimental/plugins/bundled.js +0 -48
  451. package/dist/experimental/plugins/bundled.js.map +0 -1
  452. package/dist/experimental/plugins/package.d.ts +0 -18
  453. package/dist/experimental/plugins/package.d.ts.map +0 -1
  454. package/dist/experimental/plugins/package.js +0 -113
  455. package/dist/experimental/plugins/package.js.map +0 -1
  456. package/dist/experimental/process.d.ts +0 -20
  457. package/dist/experimental/process.d.ts.map +0 -1
  458. package/dist/experimental/process.js +0 -85
  459. package/dist/experimental/process.js.map +0 -1
  460. package/dist/experimental/radius-auth.d.ts +0 -17
  461. package/dist/experimental/radius-auth.d.ts.map +0 -1
  462. package/dist/experimental/radius-auth.js +0 -52
  463. package/dist/experimental/radius-auth.js.map +0 -1
  464. package/dist/experimental/radius-relay.d.ts +0 -90
  465. package/dist/experimental/radius-relay.d.ts.map +0 -1
  466. package/dist/experimental/radius-relay.js +0 -582
  467. package/dist/experimental/radius-relay.js.map +0 -1
  468. package/dist/experimental/server.d.ts +0 -75
  469. package/dist/experimental/server.d.ts.map +0 -1
  470. package/dist/experimental/server.js +0 -682
  471. package/dist/experimental/server.js.map +0 -1
  472. package/dist/experimental/services/agent-controller-provider.d.ts +0 -4
  473. package/dist/experimental/services/agent-controller-provider.d.ts.map +0 -1
  474. package/dist/experimental/services/agent-controller-provider.js +0 -84
  475. package/dist/experimental/services/agent-controller-provider.js.map +0 -1
  476. package/dist/experimental/services/agent-controller.d.ts +0 -57
  477. package/dist/experimental/services/agent-controller.d.ts.map +0 -1
  478. package/dist/experimental/services/agent-controller.js +0 -3
  479. package/dist/experimental/services/agent-controller.js.map +0 -1
  480. package/dist/experimental/services/connection.d.ts +0 -40
  481. package/dist/experimental/services/connection.d.ts.map +0 -1
  482. package/dist/experimental/services/connection.js +0 -300
  483. package/dist/experimental/services/connection.js.map +0 -1
  484. package/dist/experimental/services/models-provider.d.ts +0 -16
  485. package/dist/experimental/services/models-provider.d.ts.map +0 -1
  486. package/dist/experimental/services/models-provider.js +0 -116
  487. package/dist/experimental/services/models-provider.js.map +0 -1
  488. package/dist/experimental/services/models.d.ts +0 -36
  489. package/dist/experimental/services/models.d.ts.map +0 -1
  490. package/dist/experimental/services/models.js +0 -3
  491. package/dist/experimental/services/models.js.map +0 -1
  492. package/dist/experimental/services/plugins.d.ts +0 -16
  493. package/dist/experimental/services/plugins.d.ts.map +0 -1
  494. package/dist/experimental/services/plugins.js +0 -4
  495. package/dist/experimental/services/plugins.js.map +0 -1
  496. package/dist/experimental/services/presentation-ui.d.ts +0 -13
  497. package/dist/experimental/services/presentation-ui.d.ts.map +0 -1
  498. package/dist/experimental/services/presentation-ui.js +0 -3
  499. package/dist/experimental/services/presentation-ui.js.map +0 -1
  500. package/dist/experimental/services/server.d.ts +0 -19
  501. package/dist/experimental/services/server.d.ts.map +0 -1
  502. package/dist/experimental/services/server.js +0 -104
  503. package/dist/experimental/services/server.js.map +0 -1
  504. package/dist/experimental/services/sessions.d.ts +0 -28
  505. package/dist/experimental/services/sessions.d.ts.map +0 -1
  506. package/dist/experimental/services/sessions.js +0 -4
  507. package/dist/experimental/services/sessions.js.map +0 -1
  508. package/dist/experimental/services/slash-commands-provider.d.ts +0 -14
  509. package/dist/experimental/services/slash-commands-provider.d.ts.map +0 -1
  510. package/dist/experimental/services/slash-commands-provider.js +0 -200
  511. package/dist/experimental/services/slash-commands-provider.js.map +0 -1
  512. package/dist/experimental/services/slash-commands.d.ts +0 -24
  513. package/dist/experimental/services/slash-commands.d.ts.map +0 -1
  514. package/dist/experimental/services/slash-commands.js +0 -3
  515. package/dist/experimental/services/slash-commands.js.map +0 -1
  516. package/dist/experimental/services/transcript-provider.d.ts +0 -12
  517. package/dist/experimental/services/transcript-provider.d.ts.map +0 -1
  518. package/dist/experimental/services/transcript-provider.js +0 -109
  519. package/dist/experimental/services/transcript-provider.js.map +0 -1
  520. package/dist/experimental/services/transcript.d.ts +0 -13
  521. package/dist/experimental/services/transcript.d.ts.map +0 -1
  522. package/dist/experimental/services/transcript.js +0 -3
  523. package/dist/experimental/services/transcript.js.map +0 -1
  524. package/dist/experimental/services/worker.d.ts +0 -28
  525. package/dist/experimental/services/worker.d.ts.map +0 -1
  526. package/dist/experimental/services/worker.js +0 -107
  527. package/dist/experimental/services/worker.js.map +0 -1
  528. package/dist/experimental/session-worker-manager.d.ts +0 -24
  529. package/dist/experimental/session-worker-manager.d.ts.map +0 -1
  530. package/dist/experimental/session-worker-manager.js +0 -691
  531. package/dist/experimental/session-worker-manager.js.map +0 -1
  532. package/dist/experimental/session-worker.d.ts +0 -188
  533. package/dist/experimental/session-worker.d.ts.map +0 -1
  534. package/dist/experimental/session-worker.js +0 -785
  535. package/dist/experimental/session-worker.js.map +0 -1
  536. package/dist/experimental/source-resolver.d.ts +0 -2
  537. package/dist/experimental/source-resolver.d.ts.map +0 -1
  538. package/dist/experimental/source-resolver.js +0 -71
  539. package/dist/experimental/source-resolver.js.map +0 -1
  540. package/dist/utils/clipboard-native.d.ts +0 -11
  541. package/dist/utils/clipboard-native.d.ts.map +0 -1
  542. package/dist/utils/clipboard-native.js +0 -20
  543. package/dist/utils/clipboard-native.js.map +0 -1
  544. package/examples/extensions/kimi-deferred-tools.ts +0 -61
@@ -1,702 +0,0 @@
1
- import { resolve } from "node:path";
2
- import { combineFacetLoaders, createFacetHost, defineFacet, } from "@earendil-works/chord";
3
- import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
4
- import { CombinedAutocompleteProvider, Container, SelectList, setKeybindings, Text, } from "@earendil-works/pi-tui";
5
- import { getAgentDir } from "../config.js";
6
- import { KeybindingsManager } from "../core/keybindings.js";
7
- import { DefaultResourceLoader } from "../core/resource-loader.js";
8
- import { SettingsManager } from "../core/settings-manager.js";
9
- import { createChatViewport } from "../modes/interactive/chat-viewport.js";
10
- import { CustomEditor } from "../modes/interactive/components/custom-editor.js";
11
- import { getEditorTheme, setRegisteredThemes, stopThemeWatcher, theme } from "../modes/interactive/theme/theme.js";
12
- import { InteractiveThemeController } from "../modes/interactive/theme/theme-controller.js";
13
- import { createInteractiveTui } from "../modes/interactive/tui-renderer.js";
14
- import { openClientRuntime } from "./client-runtime.js";
15
- import { ExperimentalChatView } from "./client-tui-chat.js";
16
- import { createPresentationFacetLoaders } from "./plugins/bundled.js";
17
- import { AgentController } from "./services/agent-controller.js";
18
- import { PresentationPlugins } from "./services/plugins.js";
19
- import { PresentationUI } from "./services/presentation-ui.js";
20
- import { SessionDirectory, SessionManagement } from "./services/sessions.js";
21
- import { SlashCommands } from "./services/slash-commands.js";
22
- import { createBuiltInSlashCommandsFacet, createSlashCommandsRuntimeFacet, } from "./services/slash-commands-provider.js";
23
- import { Transcript } from "./services/transcript.js";
24
- const selectTheme = {
25
- selectedPrefix: (text) => theme.fg("accent", text),
26
- selectedText: (text) => theme.fg("accent", text),
27
- description: (text) => theme.fg("muted", text),
28
- scrollInfo: (text) => theme.fg("dim", text),
29
- noMatch: (text) => theme.fg("warning", text),
30
- };
31
- /** Service-only presentation driven by a replicated main-lane snapshot. */
32
- export class ExperimentalClientTui {
33
- #ui;
34
- #requestRender;
35
- #finish;
36
- #documentContainer = new Container();
37
- #sessionHeading = new Text("", 1, 0);
38
- #pendingMessagesContainer = new Container();
39
- #statusContainer = new Container();
40
- #editorContainer = new Container();
41
- #footerComponent = new Text("", 1, 0);
42
- #layoutRoot;
43
- #sharedFacets;
44
- #keybindings = KeybindingsManager.create();
45
- #presentationFacets;
46
- #facetHost;
47
- #facetReloadTail = Promise.resolve();
48
- #session;
49
- #slashCommands;
50
- #controller;
51
- #chatInput;
52
- #selectList;
53
- #selection;
54
- #screen = "chat";
55
- #selectedServerId;
56
- #sessionId;
57
- #status = "Starting Session…";
58
- #busy = false;
59
- #closed = false;
60
- #closePromise;
61
- #recoveryTransition = Promise.resolve();
62
- #laneUnsubscribe;
63
- #chatView;
64
- constructor(ui, requestRender, finish, loadedFacets) {
65
- this.#ui = ui;
66
- this.#requestRender = requestRender;
67
- this.#finish = finish;
68
- this.#sharedFacets = loadedFacets;
69
- setKeybindings(this.#keybindings);
70
- this.#chatInput = new CustomEditor(ui, getEditorTheme(), this.#keybindings, { paddingX: 1 });
71
- this.#chatInput.onSubmit = (message) => void this.#runPrompt(message);
72
- this.#chatInput.onEscape = () => this.#interrupt();
73
- this.#chatInput.onCtrlD = finish;
74
- this.#chatInput.onAction("app.clear", finish);
75
- this.#chatInput.onAction("app.model.select", () => void this.#executeSlashCommand("model", ""));
76
- this.#chatInput.onAction("app.message.followUp", () => {
77
- const text = this.#chatInput.getText().trim();
78
- if (text.length === 0)
79
- return;
80
- this.#chatInput.setText("");
81
- void this.#queueFollowUp(text);
82
- });
83
- this.#editorContainer.addChild(this.#chatInput);
84
- this.#layoutRoot = createChatViewport({
85
- document: this.#documentContainer,
86
- pendingMessages: this.#pendingMessagesContainer,
87
- status: this.#statusContainer,
88
- editor: this.#editorContainer,
89
- footer: this.#footerComponent,
90
- scrollbarTrackStyle: (text) => theme.fg("scrollbarTrack", text),
91
- scrollbarThumbStyle: (text) => theme.fg("scrollbarThumb", text),
92
- }).root;
93
- this.#rebuild();
94
- }
95
- static async create(options) {
96
- const prepared = await prepareClientSession(options.command, options.servers);
97
- const loadedFacets = await combineFacetLoaders(options.facetLoader === undefined ? [] : [options.facetLoader]).load();
98
- const component = new ExperimentalClientTui(options.ui, options.requestRender, options.finish, loadedFacets);
99
- try {
100
- await component.#start(prepared);
101
- await component.#openPreparedSession(prepared);
102
- return component;
103
- }
104
- catch (error) {
105
- try {
106
- await component.close();
107
- }
108
- catch (cleanupError) {
109
- throw new AggregateError([error, cleanupError], "Experimental TUI startup and cleanup failed");
110
- }
111
- throw error;
112
- }
113
- }
114
- get layoutRoot() {
115
- return this.#layoutRoot;
116
- }
117
- render(width) {
118
- return [
119
- ...this.#documentContainer.render(width),
120
- ...this.#pendingMessagesContainer.render(width),
121
- ...this.#statusContainer.render(width),
122
- ...this.#editorContainer.render(width),
123
- ...this.#footerComponent.render(width),
124
- ];
125
- }
126
- handleInput(data) {
127
- if (this.#busy) {
128
- if (this.#keybindings.matches(data, "app.clear") ||
129
- (this.#chatInput.getText().length === 0 && this.#keybindings.matches(data, "app.exit"))) {
130
- this.#finish();
131
- }
132
- return;
133
- }
134
- if (this.#screen === "chat") {
135
- this.#chatInput.handleInput(data);
136
- this.#requestRender();
137
- return;
138
- }
139
- this.#selectList?.handleInput(data);
140
- }
141
- invalidate() {
142
- this.#layoutRoot.invalidate();
143
- }
144
- dispose() {
145
- void this.close().catch(() => { });
146
- }
147
- refreshTheme() {
148
- const snapshot = this.#laneSnapshot();
149
- if (snapshot !== undefined)
150
- this.#chatView?.refreshTheme(snapshot);
151
- this.#rebuild();
152
- }
153
- showError(error) {
154
- this.#status = `Error: ${error}`;
155
- this.#rebuild();
156
- }
157
- close() {
158
- this.#closePromise ??= this.#close();
159
- return this.#closePromise;
160
- }
161
- async #start(prepared) {
162
- const server = prepared.server;
163
- let presentationFacets = await combineFacetLoaders(createPresentationFacetLoaders(prepared.presentationPlugins)).load();
164
- this.#presentationFacets = presentationFacets;
165
- let facetHost;
166
- const reloadPresentationPlugins = (data) => {
167
- const operation = this.#facetReloadTail.then(async () => {
168
- const candidate = await combineFacetLoaders(createPresentationFacetLoaders(data)).load();
169
- try {
170
- await facetHost.reload(candidate.facets);
171
- }
172
- catch (error) {
173
- try {
174
- await candidate.dispose();
175
- }
176
- catch (cleanupError) {
177
- throw new AggregateError([error, cleanupError], "TUI plugin reload and cleanup failed");
178
- }
179
- throw error;
180
- }
181
- const retired = presentationFacets;
182
- presentationFacets = candidate;
183
- this.#presentationFacets = candidate;
184
- await retired.dispose();
185
- });
186
- this.#facetReloadTail = operation.catch(() => { });
187
- return operation;
188
- };
189
- const presentationBridgeFacet = defineFacet({
190
- id: "@pi/presentation-bridge",
191
- setup: (env) => {
192
- env.provide(PresentationUI, {
193
- select: (title, items, selectedValue) => this.#select(title, items.map((item) => ({ ...item })), selectedValue),
194
- showStatus: (status) => {
195
- this.#status = status;
196
- this.#rebuild();
197
- },
198
- });
199
- const commands = env.use(SlashCommands);
200
- const controller = env.use(AgentController);
201
- const transcript = env.use(Transcript);
202
- const sessionFeature = {
203
- serverId: server.serverId,
204
- session: server.session,
205
- transcript,
206
- };
207
- env.onActivate(() => {
208
- if (this.#session !== undefined || this.#slashCommands !== undefined || this.#controller !== undefined) {
209
- throw new Error("Presentation services are already active");
210
- }
211
- this.#session = sessionFeature;
212
- this.#slashCommands = commands;
213
- this.#controller = controller;
214
- env.own(() => {
215
- if (this.#session === sessionFeature)
216
- this.#session = undefined;
217
- if (this.#slashCommands === commands)
218
- this.#slashCommands = undefined;
219
- if (this.#controller === controller)
220
- this.#controller = undefined;
221
- });
222
- env.own(commands.subscribe(() => this.#updateAutocomplete()));
223
- if (server.radius) {
224
- env.own(server.server.connection.subscribe((state) => this.#handleConnectionState(server.serverId, state)));
225
- env.own(server.session.attachment.subscribe((state) => this.#handleAttachmentState(sessionFeature, state)));
226
- }
227
- });
228
- },
229
- });
230
- facetHost = await createFacetHost({
231
- facets: [
232
- createSlashCommandsRuntimeFacet(),
233
- presentationBridgeFacet,
234
- createBuiltInSlashCommandsFacet({ reloadPresentationPlugins }),
235
- ...this.#sharedFacets.facets,
236
- ...presentationFacets.facets,
237
- ],
238
- serviceSources: [server.server, server.session],
239
- });
240
- this.#facetHost = facetHost;
241
- }
242
- async #openPreparedSession(prepared) {
243
- const feature = this.#session;
244
- if (feature === undefined)
245
- throw new Error(`No Session service is available for ${prepared.server.serverId}`);
246
- await feature.session.whenAttached(prepared.summary.sessionId, BACKGROUND_CONTEXT);
247
- this.#selectedServerId = feature.serverId;
248
- this.#sessionId = prepared.summary.sessionId;
249
- this.#updateAutocomplete();
250
- await this.#openLane(feature);
251
- this.#screen = "chat";
252
- this.#status = "";
253
- this.#rebuild();
254
- }
255
- async #close() {
256
- this.#closed = true;
257
- this.#completeSelection(undefined);
258
- const errors = [];
259
- try {
260
- await this.#recoveryTransition;
261
- await this.#closeLane();
262
- await this.#facetReloadTail;
263
- }
264
- catch (error) {
265
- errors.push(error);
266
- }
267
- if (this.#facetHost !== undefined) {
268
- try {
269
- await this.#facetHost.dispose();
270
- }
271
- catch (error) {
272
- errors.push(error);
273
- }
274
- this.#facetHost = undefined;
275
- }
276
- const generations = [this.#presentationFacets, this.#sharedFacets].filter((generation) => generation !== undefined);
277
- this.#presentationFacets = undefined;
278
- const results = await Promise.allSettled(generations.map((generation) => generation.dispose()));
279
- errors.push(...results.flatMap((result) => (result.status === "rejected" ? [result.reason] : [])));
280
- if (errors.length === 1)
281
- throw errors[0];
282
- if (errors.length > 1)
283
- throw new AggregateError(errors, "Failed to dispose experimental TUI facets");
284
- }
285
- #rebuild() {
286
- this.#sessionHeading.setText(this.#sessionId === undefined || this.#selectedServerId === undefined
287
- ? ""
288
- : theme.fg("dim", `Server: ${this.#selectedServerId}\nSession: ${this.#sessionId}`));
289
- this.#statusContainer.clear();
290
- if (this.#status.length > 0) {
291
- this.#statusContainer.addChild(new Text(theme.fg("dim", this.#status), 1, 0));
292
- }
293
- if (this.#chatView !== undefined)
294
- this.#statusContainer.addChild(this.#chatView.status);
295
- this.#footerComponent.setText(theme.fg("dim", this.#footer()));
296
- this.#editorContainer.clear();
297
- if (this.#screen === "select" && this.#selection !== undefined) {
298
- this.#chatInput.focused = false;
299
- const selector = new Container();
300
- selector.addChild(new Text(theme.bold(this.#selection.title), 1, 1));
301
- const items = [...this.#selection.items];
302
- this.#selectList = new SelectList(items, Math.min(Math.max(items.length, 1), 12), selectTheme);
303
- const selectedIndex = items.findIndex((item) => item.value === this.#selection?.selectedValue);
304
- if (selectedIndex >= 0)
305
- this.#selectList.setSelectedIndex(selectedIndex);
306
- this.#selectList.onSelect = (item) => this.#completeSelection(item.value);
307
- this.#selectList.onCancel = () => this.#completeSelection(undefined);
308
- selector.addChild(this.#selectList);
309
- this.#editorContainer.addChild(selector);
310
- }
311
- else {
312
- this.#selectList = undefined;
313
- this.#chatInput.focused = !this.#busy;
314
- this.#editorContainer.addChild(this.#chatInput);
315
- }
316
- this.#layoutRoot.invalidate();
317
- this.#requestRender();
318
- }
319
- #select(title, items, selectedValue) {
320
- if (this.#selection !== undefined)
321
- throw new Error("A slash command selector is already active");
322
- return new Promise((resolve) => {
323
- this.#selection = { title, items, ...(selectedValue === undefined ? {} : { selectedValue }), resolve };
324
- this.#screen = "select";
325
- this.#rebuild();
326
- });
327
- }
328
- #completeSelection(value) {
329
- const selection = this.#selection;
330
- if (selection === undefined)
331
- return;
332
- this.#selection = undefined;
333
- this.#screen = "chat";
334
- selection.resolve(value);
335
- if (!this.#closed)
336
- this.#rebuild();
337
- }
338
- #updateAutocomplete() {
339
- const commands = this.#selectedSlashCommands()?.list() ?? [];
340
- this.#chatInput.setAutocompleteProvider(new CombinedAutocompleteProvider(commands.map((command) => ({
341
- name: command.name,
342
- description: command.description,
343
- ...(command.argumentHint === undefined ? {} : { argumentHint: command.argumentHint }),
344
- ...(command.getArgumentCompletions === undefined
345
- ? {}
346
- : {
347
- getArgumentCompletions: async (prefix) => {
348
- const items = await command.getArgumentCompletions(prefix);
349
- return items === null ? null : [...items];
350
- },
351
- }),
352
- })), process.cwd()));
353
- this.#requestRender();
354
- }
355
- #selectedSlashCommands() {
356
- return this.#slashCommands;
357
- }
358
- #handleConnectionState(serverId, state) {
359
- if (this.#closed || this.#selectedServerId !== serverId)
360
- return;
361
- if (state.status === "connected") {
362
- if (this.#laneUnsubscribe === undefined) {
363
- this.#busy = true;
364
- this.#status = "Reattaching Session…";
365
- this.#rebuild();
366
- }
367
- return;
368
- }
369
- this.#busy = true;
370
- this.#status = state.status === "connecting" ? "Reconnecting to Radius…" : "Radius disconnected; retrying…";
371
- this.#queueRecovery(() => this.#closeLane());
372
- this.#rebuild();
373
- }
374
- #handleAttachmentState(feature, state) {
375
- if (this.#closed || this.#selectedServerId !== feature.serverId || this.#sessionId === undefined)
376
- return;
377
- if (state.status === "attached" && state.sessionId === this.#sessionId) {
378
- this.#queueRecovery(async () => {
379
- if (this.#laneUnsubscribe === undefined)
380
- await this.#openLane(feature);
381
- this.#busy = false;
382
- this.#status = "";
383
- this.#rebuild();
384
- });
385
- return;
386
- }
387
- if (state.status === "attaching" && state.sessionId === this.#sessionId) {
388
- this.#busy = true;
389
- this.#status = "Reattaching Session…";
390
- this.#rebuild();
391
- }
392
- }
393
- #queueRecovery(operation) {
394
- this.#recoveryTransition = this.#recoveryTransition
395
- .then(async () => {
396
- if (!this.#closed)
397
- await operation();
398
- })
399
- .catch((error) => {
400
- if (this.#closed)
401
- return;
402
- this.#busy = true;
403
- this.#status = `Reconnect error: ${message(error)}`;
404
- this.#rebuild();
405
- });
406
- }
407
- async #openLane(feature) {
408
- await this.#closeLane();
409
- const view = new ExperimentalChatView(this.#ui, process.cwd());
410
- this.#chatView = view;
411
- this.#documentContainer.addChild(this.#sessionHeading);
412
- this.#documentContainer.addChild(view.transcript);
413
- this.#pendingMessagesContainer.addChild(view.pendingMessages);
414
- this.#laneUnsubscribe = feature.transcript.state.subscribe((value) => {
415
- if (value.snapshot === null)
416
- return;
417
- view.apply(value.snapshot);
418
- this.#rebuild();
419
- });
420
- if (feature.transcript.state.value?.snapshot === null || feature.transcript.state.value?.snapshot === undefined) {
421
- await this.#closeLane();
422
- throw new Error("Transcript has no initialized snapshot");
423
- }
424
- }
425
- async #closeLane() {
426
- this.#laneUnsubscribe?.();
427
- this.#laneUnsubscribe = undefined;
428
- this.#chatView?.dispose();
429
- this.#chatView = undefined;
430
- this.#documentContainer.clear();
431
- this.#pendingMessagesContainer.clear();
432
- this.#statusContainer.clear();
433
- }
434
- async #runPrompt(messageText) {
435
- const prompt = messageText.trim();
436
- if (prompt.length === 0)
437
- return;
438
- if (prompt.startsWith("/")) {
439
- const separator = prompt.indexOf(" ");
440
- const name = prompt.slice(1, separator === -1 ? undefined : separator);
441
- const args = separator === -1 ? "" : prompt.slice(separator + 1).trim();
442
- await this.#executeSlashCommand(name, args);
443
- return;
444
- }
445
- this.#chatInput.setText("");
446
- try {
447
- await this.#submitPrompt(prompt);
448
- }
449
- catch (error) {
450
- this.#status = `Error: ${message(error)}`;
451
- this.#rebuild();
452
- }
453
- }
454
- async #executeSlashCommand(name, args) {
455
- const command = this.#selectedSlashCommands()
456
- ?.list()
457
- .find((candidate) => candidate.name === name);
458
- this.#chatInput.setText("");
459
- if (command === undefined) {
460
- this.#status = `Unknown slash command: /${name}`;
461
- this.#rebuild();
462
- return;
463
- }
464
- try {
465
- const result = await command.run(args, BACKGROUND_CONTEXT);
466
- if (result !== undefined) {
467
- if ("entryId" in result)
468
- this.#reportQueue(result);
469
- else
470
- this.#reportOperation(result);
471
- }
472
- }
473
- catch (error) {
474
- this.#status = `Error: ${message(error)}`;
475
- this.#rebuild();
476
- }
477
- }
478
- async #submitPrompt(prompt) {
479
- const controller = this.#selectedController();
480
- if (controller === undefined)
481
- throw new Error("No Session AgentController service is available");
482
- const operation = this.#laneSnapshot()?.operation;
483
- const running = operation !== null && operation !== undefined;
484
- this.#status = running ? "Queueing steering message…" : "Running turn…";
485
- this.#rebuild();
486
- if (running)
487
- this.#reportQueue(await controller.steer({ message: prompt, images: null }, BACKGROUND_CONTEXT));
488
- else
489
- this.#reportOperation(await controller.prompt({ message: prompt, images: null }, BACKGROUND_CONTEXT));
490
- }
491
- async #queueFollowUp(text) {
492
- const controller = this.#selectedController();
493
- if (controller === undefined)
494
- return;
495
- try {
496
- this.#status = "Queueing follow-up…";
497
- this.#rebuild();
498
- this.#reportQueue(await controller.followUp({ message: text, images: null }, BACKGROUND_CONTEXT));
499
- }
500
- catch (error) {
501
- this.#status = `Error: ${message(error)}`;
502
- this.#rebuild();
503
- }
504
- }
505
- #reportOperation(response) {
506
- this.#status = response.accepted
507
- ? response.error === null
508
- ? ""
509
- : `Operation failed: ${response.error.message}`
510
- : `Operation rejected: ${response.error.message}`;
511
- this.#rebuild();
512
- }
513
- #reportQueue(response) {
514
- this.#status = response.accepted ? `Queued ${response.entryId}.` : `Message rejected: ${response.error.message}`;
515
- this.#rebuild();
516
- }
517
- #interrupt() {
518
- const operation = this.#laneSnapshot()?.operation;
519
- const controller = this.#selectedController();
520
- if (operation === null || operation === undefined || controller === undefined)
521
- return;
522
- this.#status = `Aborting ${operation.id}…`;
523
- this.#rebuild();
524
- void controller.requestAbort(operation.id, BACKGROUND_CONTEXT).catch((error) => {
525
- this.#status = `Error: ${message(error)}`;
526
- this.#rebuild();
527
- });
528
- }
529
- #selectedController() {
530
- return this.#controller;
531
- }
532
- #laneSnapshot() {
533
- const snapshot = this.#session?.transcript.state.value?.snapshot;
534
- return snapshot === null ? undefined : snapshot;
535
- }
536
- #footer() {
537
- const snapshot = this.#laneSnapshot();
538
- if (!snapshot)
539
- return "/model · /thinking · /compact · /reload";
540
- return `${snapshot.configuration.model.provider}/${snapshot.configuration.model.modelId} · thinking:${snapshot.configuration.thinkingLevel} · ${snapshot.stats.messageCount} messages · /model · /thinking · /compact · /reload`;
541
- }
542
- }
543
- async function prepareClientSession(command, servers) {
544
- const opened = servers.map((server) => ({
545
- server,
546
- services: server.server.open({
547
- services: [SessionDirectory, SessionManagement, PresentationPlugins],
548
- assertAccess() { },
549
- onError() { },
550
- }),
551
- }));
552
- try {
553
- const features = opened.map(({ server, services }) => ({
554
- server,
555
- directory: services.use(SessionDirectory),
556
- management: services.use(SessionManagement),
557
- plugins: services.use(PresentationPlugins),
558
- }));
559
- await Promise.all(opened.map(({ services }) => services.ready(BACKGROUND_CONTEXT)));
560
- let selected;
561
- if (command.sessionId !== undefined) {
562
- const matches = features.flatMap((feature) => (feature.directory.state.value?.sessions ?? [])
563
- .filter((session) => session.sessionId === command.sessionId)
564
- .map((summary) => ({
565
- server: feature.server,
566
- management: feature.management,
567
- plugins: feature.plugins,
568
- summary,
569
- })));
570
- if (matches.length > 1)
571
- throw new Error(`Session ${command.sessionId} is available from more than one server`);
572
- selected = matches[0];
573
- if (selected === undefined) {
574
- if (command.connect?.transport === "radius") {
575
- throw new Error(`Remote server does not contain Session ${command.sessionId}`);
576
- }
577
- const feature = requireSingleServer(features);
578
- selected = {
579
- server: feature.server,
580
- management: feature.management,
581
- plugins: feature.plugins,
582
- summary: await feature.management.create({ id: command.sessionId }, BACKGROUND_CONTEXT),
583
- };
584
- }
585
- }
586
- else if (command.continue === true || command.resume === true) {
587
- selected = features
588
- .flatMap((feature) => (feature.directory.state.value?.sessions ?? []).map((summary) => ({
589
- server: feature.server,
590
- management: feature.management,
591
- plugins: feature.plugins,
592
- summary,
593
- })))
594
- .sort((left, right) => right.summary.createdAt - left.summary.createdAt ||
595
- left.summary.serverId.localeCompare(right.summary.serverId) ||
596
- left.summary.sessionId.localeCompare(right.summary.sessionId))[0];
597
- }
598
- if (selected === undefined) {
599
- const feature = requireSingleServer(features);
600
- selected = {
601
- server: feature.server,
602
- management: feature.management,
603
- plugins: feature.plugins,
604
- summary: await feature.management.create({}, BACKGROUND_CONTEXT),
605
- };
606
- }
607
- const presentationPlugins = await selected.plugins.prepareSession({
608
- sessionId: selected.summary.sessionId,
609
- packagePaths: command.pluginPackages?.map((packagePath) => resolve(packagePath)) ?? null,
610
- }, BACKGROUND_CONTEXT);
611
- await selected.management.attach(selected.summary.sessionId, BACKGROUND_CONTEXT);
612
- await selected.server.session.whenAttached(selected.summary.sessionId, BACKGROUND_CONTEXT);
613
- return {
614
- server: selected.server,
615
- summary: selected.summary,
616
- presentationPlugins,
617
- };
618
- }
619
- finally {
620
- await Promise.allSettled(opened.map(({ services }) => services.dispose(BACKGROUND_CONTEXT)));
621
- }
622
- }
623
- export async function runClientTui(command, options = {}) {
624
- const cwd = process.cwd();
625
- const agentDir = getAgentDir();
626
- const settingsManager = SettingsManager.create(cwd, agentDir);
627
- const resourceLoader = new DefaultResourceLoader({
628
- cwd,
629
- agentDir,
630
- settingsManager,
631
- noExtensions: true,
632
- noSkills: true,
633
- noPromptTemplates: true,
634
- noContextFiles: true,
635
- });
636
- await resourceLoader.reload();
637
- setRegisteredThemes(resourceLoader.getThemes().themes);
638
- const runtime = await openClientRuntime(command, options);
639
- const tui = createInteractiveTui({
640
- tuiMode: "fullscreen",
641
- showHardwareCursor: settingsManager.getShowHardwareCursor(),
642
- logDirectory: agentDir,
643
- });
644
- tui.setClearOnShrink(settingsManager.getClearOnShrink());
645
- let component;
646
- let tuiStarted = false;
647
- const themeController = new InteractiveThemeController(tui, {
648
- getSettingsManager: () => settingsManager,
649
- showError: (error) => component?.showError(error),
650
- onChanged: () => component?.refreshTheme(),
651
- });
652
- try {
653
- let finish;
654
- const finished = new Promise((resolve) => {
655
- finish = () => {
656
- themeController.disableAutoSync();
657
- if (tuiStarted) {
658
- tui.stop();
659
- tuiStarted = false;
660
- }
661
- resolve();
662
- };
663
- });
664
- component = await ExperimentalClientTui.create({
665
- command,
666
- ui: tui,
667
- servers: runtime.servers.map((server) => ({
668
- serverId: server.route.serverId,
669
- radius: server.route.transport === "radius",
670
- server: server.server,
671
- session: server.session,
672
- })),
673
- facetLoader: options.facetLoader,
674
- requestRender: () => tui.requestRender(),
675
- finish,
676
- });
677
- tui.addChild(component);
678
- tui.setLayoutRoot(component.layoutRoot);
679
- tui.setFocus(component);
680
- tuiStarted = true;
681
- tui.start();
682
- await themeController.applyFromSettings();
683
- await finished;
684
- }
685
- finally {
686
- themeController.dispose();
687
- stopThemeWatcher();
688
- if (tuiStarted)
689
- tui.stop();
690
- await component?.close();
691
- await runtime.dispose();
692
- }
693
- }
694
- function requireSingleServer(features) {
695
- if (features.length !== 1)
696
- throw new Error("Starting a Session requires exactly one server");
697
- return features[0];
698
- }
699
- function message(error) {
700
- return error instanceof Error ? error.message : String(error);
701
- }
702
- //# sourceMappingURL=client-tui.js.map