remoteclaw 0.1.0-next.049f396 → 0.1.0-next.05abcca

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 (1199) hide show
  1. package/README.md +11 -9
  2. package/dist/accounts-79XhjwAj.js +32 -0
  3. package/dist/accounts-B1M3fOxL.js +272 -0
  4. package/dist/accounts-BwbvnKsW.js +205 -0
  5. package/dist/accounts-CIVjmTg9.js +270 -0
  6. package/dist/accounts-D1awQXKu.js +36 -0
  7. package/dist/accounts-DHkGVGUR.js +36 -0
  8. package/dist/accounts-P7cmIXUM.js +206 -0
  9. package/dist/accounts-XFgBY644.js +47 -0
  10. package/dist/accounts-_ZuNC5bz.js +47 -0
  11. package/dist/ack-reactions-BGJ9Vigf.js +621 -0
  12. package/dist/ack-reactions-Diu9O24z.js +621 -0
  13. package/dist/acp-cli-BwZ-va2P.js +1316 -0
  14. package/dist/acp-cli-eVKByz-j.js +1311 -0
  15. package/dist/active-listener--jrUO-8L.js +37 -0
  16. package/dist/active-listener-C7SyMcNY.js +37 -0
  17. package/dist/agent-BAxK2KQW.js +688 -0
  18. package/dist/agent-Dd5Yfhmq.js +687 -0
  19. package/dist/agent-helpers-5F0tdxud.js +400 -0
  20. package/dist/agent-helpers-Bs2nBXeI.js +400 -0
  21. package/dist/agent-scope-BA1HP4K6.js +114 -0
  22. package/dist/agent-scope-CAQLm3LP.js +116 -0
  23. package/dist/agents-D--9DD91.js +754 -0
  24. package/dist/agents.config-CmyzLYqW.js +116 -0
  25. package/dist/agents.config-DerBqRzk.js +116 -0
  26. package/dist/ansi-DtaiOnt1.js +107 -0
  27. package/dist/audio-ClIuKwkl.js +43 -0
  28. package/dist/audio-DqlIYYTb.js +43 -0
  29. package/dist/audit-Cn0cNCE4.js +3114 -0
  30. package/dist/audit-DXY4NHBC.js +3114 -0
  31. package/dist/auth-B-QK8JhI.js +315 -0
  32. package/dist/auth-C1zx1O24.js +314 -0
  33. package/dist/auth-DDmNYVMW.js +448 -0
  34. package/dist/auth-DH1wEw0w.js +448 -0
  35. package/dist/banner-CBWZhANO.js +294 -0
  36. package/dist/binaries-CYwLdubd.js +13 -0
  37. package/dist/bindings-DFAFatwT.js +69 -0
  38. package/dist/bindings-GUKIzFCp.js +69 -0
  39. package/dist/bonjour-discovery-AQMJqY4V.js +378 -0
  40. package/dist/bonjour-discovery-BLcPWHFJ.js +378 -0
  41. package/dist/boot/handler.js +41 -84
  42. package/dist/browser-cli-8Dv5ogFT.js +1690 -0
  43. package/dist/browser-cli-wNLo8SOy.js +1694 -0
  44. package/dist/build-info.json +3 -3
  45. package/dist/call-BTHzKFbN.js +518 -0
  46. package/dist/call-D_NchaCs.js +517 -0
  47. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  48. package/dist/catalog-DgpN5jxU.js +186 -0
  49. package/dist/catalog-k056Nh93.js +186 -0
  50. package/dist/channel-account-context-BHIy71Yh.js +133 -0
  51. package/dist/channel-account-context-DXU_-EkJ.js +133 -0
  52. package/dist/channel-activity-BatlvP_U.js +292 -0
  53. package/dist/channel-activity-BhT7NQ_v.js +94 -0
  54. package/dist/channel-activity-CvjEwpJz.js +94 -0
  55. package/dist/channel-options-BCccA2WC.js +32 -0
  56. package/dist/channel-options-VPR_pNyS.js +33 -0
  57. package/dist/channel-selection-AH6_y6RS.js +51 -0
  58. package/dist/channel-selection-ovohyJQZ.js +51 -0
  59. package/dist/channel-web-APDaQ_wp.js +2134 -0
  60. package/dist/channel-web-BW_YuNlT.js +2132 -0
  61. package/dist/channels-cli-DVsZyaU5.js +1436 -0
  62. package/dist/channels-cli-ubrg5vcL.js +1440 -0
  63. package/dist/channels-status-issues-BbYNzwLp.js +18 -0
  64. package/dist/channels-status-issues-DRybAijg.js +18 -0
  65. package/dist/chat-envelope-AJFUAuBM.js +248 -0
  66. package/dist/chat-envelope-BrfcPlDM.js +248 -0
  67. package/dist/chrome-Bv2UtAMQ.js +1732 -0
  68. package/dist/chrome-C6Vc_7su.js +1733 -0
  69. package/dist/chunk-BAMyFYtF.js +341 -0
  70. package/dist/chunk-BzVoFUZL.js +341 -0
  71. package/dist/clack-prompter-C6mBTOzE.js +122 -0
  72. package/dist/clack-prompter-DKcYqv3o.js +121 -0
  73. package/dist/cleanup-utils-Cb-leJcy.js +94 -0
  74. package/dist/cli/daemon-cli.js +1 -1
  75. package/dist/cli-Cs1n6-eD.js +135 -0
  76. package/dist/cli-Di3p1tLN.js +131 -0
  77. package/dist/client-B6h7bgbF.js +2311 -0
  78. package/dist/client-CMtdm9Ii.js +2311 -0
  79. package/dist/clipboard-A06eV_5C.js +31 -0
  80. package/dist/clipboard-DQBl3coj.js +31 -0
  81. package/dist/command-format-BiiNHkWG.js +18 -0
  82. package/dist/command-format-Dntg_tnC.js +32 -0
  83. package/dist/command-logger/handler.js +1 -1
  84. package/dist/command-registry-CCAvdWh2.js +215 -0
  85. package/dist/commands-D93TXYhv.js +41 -0
  86. package/dist/commands-UD7V7QC9.js +41 -0
  87. package/dist/commands-registry-CCbTtSSK.js +891 -0
  88. package/dist/commands-registry-De8JhZLG.js +890 -0
  89. package/dist/common-D4fL3S2m.js +156 -0
  90. package/dist/common-DXNisGxw.js +156 -0
  91. package/dist/completion-cli-CLo-r-UP.js +452 -0
  92. package/dist/completion-cli-D4ajG3yt.js +452 -0
  93. package/dist/config-BTH7fB_v.js +3345 -0
  94. package/dist/config-DwuBnd6D.js +3347 -0
  95. package/dist/config-cli-D0D1LSNt.js +243 -0
  96. package/dist/config-cli-tWsFNKQM.js +247 -0
  97. package/dist/config-guard-BcT7soTj.js +92 -0
  98. package/dist/config-guard-Bqak3bDc.js +75 -0
  99. package/dist/config-validation-CHEjSJ5K.js +18 -0
  100. package/dist/config-validation-CvgqLhyG.js +18 -0
  101. package/dist/configure-CK_0tFJG.js +889 -0
  102. package/dist/configure-D0z0kE-B.js +891 -0
  103. package/dist/constants-BBVTjb1j.js +75 -0
  104. package/dist/constants-PMRtHBHU.js +75 -0
  105. package/dist/control-auth-DrGYtMJM.js +397 -0
  106. package/dist/control-auth-KY4Qdr2I.js +397 -0
  107. package/dist/control-ui/assets/index-DdiU_ccM.css +1 -0
  108. package/dist/control-ui/assets/index-kVUYi64u.js +7723 -0
  109. package/dist/control-ui/assets/index-kVUYi64u.js.map +1 -0
  110. package/dist/control-ui/index.html +2 -2
  111. package/dist/control-ui-assets-DO1L6M0S.js +186 -0
  112. package/dist/control-ui-assets-S_TLo6Fs.js +186 -0
  113. package/dist/conversation-label-CDH4rKMG.js +36 -0
  114. package/dist/conversation-label-CMOfgCVl.js +36 -0
  115. package/dist/cron-cli-C7h_hLHu.js +495 -0
  116. package/dist/cron-cli-DTNg0Uvl.js +499 -0
  117. package/dist/daemon-cli-BlJS9zWM.js +737 -0
  118. package/dist/daemon-cli-Cfc1yszp.js +735 -0
  119. package/dist/daemon-cli.js +174 -1167
  120. package/dist/daemon-install-BbBLuLWg.js +60 -0
  121. package/dist/daemon-install-WEBvqVOj.js +56 -0
  122. package/dist/daemon-install-helpers-BVtPC2TK.js +504 -0
  123. package/dist/daemon-install-helpers-DVr51zvE.js +504 -0
  124. package/dist/deliver-EB272zWh.js +481 -0
  125. package/dist/deliver-iGD_woru.js +481 -0
  126. package/dist/delivery-queue-BDvalA10.js +244 -0
  127. package/dist/delivery-queue-BimvYz5E.js +244 -0
  128. package/dist/devices-cli-BXCOsNFc.js +323 -0
  129. package/dist/devices-cli-CHGdYfrz.js +319 -0
  130. package/dist/diagnostics-BzzhTQzK.js +35 -0
  131. package/dist/diagnostics-DILtxtcE.js +35 -0
  132. package/dist/directory-cli-COS40yI9.js +221 -0
  133. package/dist/directory-cli-Cb5j1JTC.js +225 -0
  134. package/dist/dispatcher-BUqxh_mA.js +174 -0
  135. package/dist/dispatcher-By-KZRWZ.js +173 -0
  136. package/dist/dm-policy-shared-BCp9_z3w.js +22 -0
  137. package/dist/dm-policy-shared-DgeKqjOu.js +22 -0
  138. package/dist/dns-cli-B8yyXB2N.js +203 -0
  139. package/dist/dns-cli-DAkTk-gM.js +199 -0
  140. package/dist/dock-B0bIIDS3.js +906 -0
  141. package/dist/dock-C3PzQ6CS.js +907 -0
  142. package/dist/doctor-completion-BXGEqLhU.js +92 -0
  143. package/dist/doctor-completion-D_mNzioP.js +92 -0
  144. package/dist/doctor-config-flow-BDDsR2J1.js +978 -0
  145. package/dist/doctor-config-flow-CwFFRUic.js +979 -0
  146. package/dist/enable-C3I9dWel.js +59 -0
  147. package/dist/enable-DnwKeWnR.js +59 -0
  148. package/dist/entry.js +75 -21
  149. package/dist/env-DyyqmxSM.js +60 -0
  150. package/dist/env-vars-CD2_baIP.js +43 -0
  151. package/dist/env-vars-a7S70ba7.js +43 -0
  152. package/dist/errors-0dfGxeYQ.js +35 -0
  153. package/dist/errors-C1kDByVU.js +35 -0
  154. package/dist/exec-CAk1dxq_.js +164 -0
  155. package/dist/exec-epNpA1aU.js +164 -0
  156. package/dist/export-html/template.css +0 -36
  157. package/dist/export-html/template.js +1 -32
  158. package/dist/extensionAPI.js +1765 -1590
  159. package/dist/fetch-BMQq41sB.js +281 -0
  160. package/dist/fetch-Cky99wYB.js +281 -0
  161. package/dist/fetch-D3tw4B4n.js +67 -0
  162. package/dist/fetch-DTsU2XnC.js +67 -0
  163. package/dist/fetch-Dgm9ZHFm.js +67 -0
  164. package/dist/file-lock-DWH0TfVu.js +107 -0
  165. package/dist/file-lock-DXW9h9ek.js +107 -0
  166. package/dist/fs-safe-BjSd07M4.js +115 -0
  167. package/dist/fs-safe-aWIhCWlb.js +125 -0
  168. package/dist/gateway-cli-C4y4H61g.js +24546 -0
  169. package/dist/gateway-cli-CtFr42NV.js +24550 -0
  170. package/dist/gateway-rpc-B92CH0D3.js +28 -0
  171. package/dist/gateway-rpc-DZNlWapO.js +28 -0
  172. package/dist/gmail-setup-utils-CKyh29_R.js +422 -0
  173. package/dist/gmail-setup-utils-DquflkMR.js +423 -0
  174. package/dist/health-BYl7T-4m.js +1417 -0
  175. package/dist/health-DdviISKg.js +1414 -0
  176. package/dist/health-format-BE5TK5bs.js +28 -0
  177. package/dist/heartbeat-visibility-BO3iRpB6.js +125 -0
  178. package/dist/heartbeat-visibility-Cwp4TrTv.js +125 -0
  179. package/dist/help-format-D3JhWp1E.js +17 -0
  180. package/dist/helpers-DAEoFkbn.js +10 -0
  181. package/dist/helpers-ndPQWl6m.js +10 -0
  182. package/dist/hook-runner-global-C1thol1d.js +527 -0
  183. package/dist/hooks-cli-BKS9uZ0H.js +1221 -0
  184. package/dist/hooks-cli-FLWcCr9q.js +1217 -0
  185. package/dist/host-env-security-BGibnCbS.js +106 -0
  186. package/dist/host-env-security-axRnIi8d.js +106 -0
  187. package/dist/image-ops-CX41n0v5.js +354 -0
  188. package/dist/image-ops-DSL3eFfQ.js +354 -0
  189. package/dist/import-BSFgt760.js +604 -0
  190. package/dist/import-Da1CHJJg.js +606 -0
  191. package/dist/inbound-context-BLy-G2Eq.js +68 -0
  192. package/dist/inbound-context-a5bzQvRt.js +68 -0
  193. package/dist/index.js +137 -108
  194. package/dist/inspect-BEpFbi0c.js +286 -0
  195. package/dist/inspect-BeNNpWna.js +286 -0
  196. package/dist/installs-CH7Qq_m_.js +319 -0
  197. package/dist/installs-CcM8H2YA.js +319 -0
  198. package/dist/ipv4-DNo9AFDu.js +46 -0
  199. package/dist/ipv4-VfoVR5uR.js +46 -0
  200. package/dist/ir-BPwP8hIc.js +972 -0
  201. package/dist/json-files-BI20PLIm.js +46 -0
  202. package/dist/lifecycle-core-5Zxqwa6V.js +476 -0
  203. package/dist/lifecycle-core-C1bGeLby.js +474 -0
  204. package/dist/links-CtGBIrG8.js +15 -0
  205. package/dist/loader-BoP3JA-r.js +22411 -0
  206. package/dist/loader-DXbpue-L.js +22414 -0
  207. package/dist/logger-ASsO5Nz-.js +49 -0
  208. package/dist/logging-Cd9y2AdQ.js +20 -0
  209. package/dist/logging-DRwtiLIS.js +1 -0
  210. package/dist/logging-fywhKCmE.js +1 -0
  211. package/dist/login-B2UXzgaB.js +61 -0
  212. package/dist/login-BEFL3xY9.js +62 -0
  213. package/dist/login-qr-C7wAz2fe.js +329 -0
  214. package/dist/login-qr-DWpUP1Ud.js +325 -0
  215. package/dist/logs-cli-CAcd-pXA.js +240 -0
  216. package/dist/logs-cli-D7Bzarht.js +236 -0
  217. package/dist/markdown-tables-BBNUZp4n.js +29 -0
  218. package/dist/markdown-tables-NgPcfXoF.js +29 -0
  219. package/dist/media-4-qOIjO-.js +971 -0
  220. package/dist/media-DTwJhAbE.js +9481 -0
  221. package/dist/message-action-names-BsNTjuBE.js +2520 -0
  222. package/dist/message-action-names-ocKcq8_3.js +2520 -0
  223. package/dist/message-channel-CtcVHawF.js +91 -0
  224. package/dist/message-channel-tuc9CdEw.js +91 -0
  225. package/dist/mime-CAqaK3kp.js +146 -0
  226. package/dist/mime-ViuhRuMM.js +146 -0
  227. package/dist/net-DSkFMHJ8.js +225 -0
  228. package/dist/net-DTqfFYzt.js +225 -0
  229. package/dist/node-cli-BeXU67eQ.js +1458 -0
  230. package/dist/node-cli-i2aCtnmM.js +1462 -0
  231. package/dist/node-service-RyMlWp8N.js +67 -0
  232. package/dist/node-service-TL9b6Qfz.js +67 -0
  233. package/dist/nodes-cli-CtqnXBMD.js +1346 -0
  234. package/dist/nodes-cli-DgQU3LrG.js +1350 -0
  235. package/dist/nodes-screen-B7HJugJ0.js +250 -0
  236. package/dist/nodes-screen-nCRd71Mk.js +250 -0
  237. package/dist/note-B6142LyJ.js +92 -0
  238. package/dist/note-D-EI0czq.js +92 -0
  239. package/dist/npm-registry-spec-PPyRXSpx.js +786 -0
  240. package/dist/npm-registry-spec-uUmDWe6v.js +786 -0
  241. package/dist/npm-resolution-BC1LqCm2.js +86 -0
  242. package/dist/npm-resolution-DhlhUmRF.js +86 -0
  243. package/dist/onboard-CGpC2ecw.js +647 -0
  244. package/dist/onboard-auth-cNtb3FTP.js +211 -0
  245. package/dist/onboard-auth-gwz-0mZ6.js +207 -0
  246. package/dist/onboard-channels-CXjJYzHC.js +2548 -0
  247. package/dist/onboard-channels-vtaIxYml.js +2549 -0
  248. package/dist/onboard-config-DOmXYEvJ.js +39 -0
  249. package/dist/onboard-config-JmR21VYa.js +39 -0
  250. package/dist/onboard-helpers-8afRV_Tm.js +364 -0
  251. package/dist/onboard-helpers-DTRrJLj-.js +363 -0
  252. package/dist/onboard-jLzfwoPx.js +649 -0
  253. package/dist/onboard-remote-CFkvVAYg.js +127 -0
  254. package/dist/onboard-remote-JfBnmK70.js +127 -0
  255. package/dist/onboarding-Dt0LKvZn.js +586 -0
  256. package/dist/onboarding-gMKlA2bP.js +588 -0
  257. package/dist/onboarding.finalize-BDML6Jx7.js +403 -0
  258. package/dist/onboarding.finalize-D850VgMA.js +405 -0
  259. package/dist/onboarding.gateway-config-DolBTXWT.js +196 -0
  260. package/dist/onboarding.gateway-config-rJkIamlG.js +202 -0
  261. package/dist/outbound-CPMaDtgC.js +220 -0
  262. package/dist/outbound-CYSuCMiW.js +221 -0
  263. package/dist/outbound-attachment-Ci02LXoq.js +18 -0
  264. package/dist/outbound-attachment-CqZ7Qc_o.js +18 -0
  265. package/dist/outbound-attachment-CuqWdsdV.js +18 -0
  266. package/dist/pairing-cli-B9JKvvST.js +126 -0
  267. package/dist/pairing-cli-C4HrfIHe.js +130 -0
  268. package/dist/pairing-labels-CBmGQ31P.js +9 -0
  269. package/dist/pairing-labels-D0xwC7Xb.js +9 -0
  270. package/dist/pairing-store-BoF0g-iN.js +459 -0
  271. package/dist/pairing-store-CseXj-5p.js +460 -0
  272. package/dist/path-env-CPZbb7me.js +89 -0
  273. package/dist/path-env-GTM4HXCN.js +89 -0
  274. package/dist/path-safety-BFE0XmGC.js +14 -0
  275. package/dist/path-safety-BJ8ge6Ho.js +14 -0
  276. package/dist/paths-DHuXVC00.js +229 -0
  277. package/dist/plugin-auto-enable-B_9J1XED.js +302 -0
  278. package/dist/plugin-auto-enable-DghjlFCL.js +301 -0
  279. package/dist/plugin-registry-68h2T8vi.js +33 -0
  280. package/dist/plugin-registry-BitdVPb4.js +33 -0
  281. package/dist/plugin-sdk/agents/agent-helpers.d.ts +0 -1
  282. package/dist/plugin-sdk/agents/agent-scope.d.ts +11 -0
  283. package/dist/plugin-sdk/agents/agent-types.d.ts +1 -6
  284. package/dist/plugin-sdk/agents/agent-utils.d.ts +0 -14
  285. package/dist/plugin-sdk/agents/provider-utils.d.ts +0 -1
  286. package/dist/plugin-sdk/agents/subagent-registry.store.d.ts +0 -1
  287. package/dist/plugin-sdk/agents/subagent-spawn.d.ts +0 -1
  288. package/dist/plugin-sdk/agents/tools/sessions-helpers.d.ts +0 -1
  289. package/dist/plugin-sdk/auth/constants.d.ts +15 -0
  290. package/dist/plugin-sdk/auth/display.d.ts +7 -0
  291. package/dist/plugin-sdk/auth/doctor.d.ts +8 -0
  292. package/dist/plugin-sdk/auth/env-injection.d.ts +38 -0
  293. package/dist/plugin-sdk/auth/index.d.ts +10 -0
  294. package/dist/plugin-sdk/auth/oauth.d.ts +13 -0
  295. package/dist/plugin-sdk/auth/order.d.ts +8 -0
  296. package/dist/plugin-sdk/auth/paths.d.ts +3 -0
  297. package/dist/plugin-sdk/auth/profiles.d.ts +11 -0
  298. package/dist/plugin-sdk/auth/provider-auth.d.ts +32 -0
  299. package/dist/plugin-sdk/auth/store.d.ts +7 -0
  300. package/dist/plugin-sdk/auth/types.d.ts +45 -0
  301. package/dist/plugin-sdk/auth/usage.d.ts +80 -0
  302. package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +0 -1
  303. package/dist/plugin-sdk/auto-reply/reply/agent-runner-utils.d.ts +3 -36
  304. package/dist/plugin-sdk/auto-reply/reply/commands-status.d.ts +1 -7
  305. package/dist/plugin-sdk/auto-reply/reply/commands-subagents/shared.d.ts +1 -1
  306. package/dist/plugin-sdk/auto-reply/reply/commands-types.d.ts +1 -13
  307. package/dist/plugin-sdk/auto-reply/reply/directive-handling.levels.d.ts +1 -10
  308. package/dist/plugin-sdk/auto-reply/reply/directive-handling.params.d.ts +1 -11
  309. package/dist/plugin-sdk/auto-reply/reply/directive-handling.parse.d.ts +1 -29
  310. package/dist/plugin-sdk/auto-reply/reply/directive-handling.persist.d.ts +0 -3
  311. package/dist/plugin-sdk/auto-reply/reply/directive-handling.shared.d.ts +0 -25
  312. package/dist/plugin-sdk/auto-reply/reply/directives.d.ts +3 -42
  313. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-apply.d.ts +0 -9
  314. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-utils.d.ts +0 -1
  315. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives.d.ts +1 -20
  316. package/dist/plugin-sdk/auto-reply/reply/get-reply-inline-actions.d.ts +1 -12
  317. package/dist/plugin-sdk/auto-reply/reply/get-reply-run.d.ts +1 -15
  318. package/dist/plugin-sdk/auto-reply/reply/queue/types.d.ts +1 -17
  319. package/dist/plugin-sdk/auto-reply/reply/response-prefix-template.d.ts +4 -6
  320. package/dist/plugin-sdk/auto-reply/reply/session-run-accounting.d.ts +0 -7
  321. package/dist/plugin-sdk/auto-reply/reply/session-updates.d.ts +0 -10
  322. package/dist/plugin-sdk/auto-reply/reply.d.ts +1 -1
  323. package/dist/plugin-sdk/auto-reply/status.d.ts +3 -12
  324. package/dist/plugin-sdk/auto-reply/templating.d.ts +0 -4
  325. package/dist/plugin-sdk/auto-reply/thinking.d.ts +0 -15
  326. package/dist/plugin-sdk/auto-reply/types.d.ts +1 -2
  327. package/dist/plugin-sdk/channels/dock.d.ts +1 -2
  328. package/dist/plugin-sdk/channels/plugins/types.adapters.d.ts +0 -6
  329. package/dist/plugin-sdk/channels/plugins/types.core.d.ts +1 -0
  330. package/dist/plugin-sdk/channels/plugins/types.d.ts +1 -1
  331. package/dist/plugin-sdk/channels/plugins/types.plugin.d.ts +1 -2
  332. package/dist/plugin-sdk/channels/voice-credentials.d.ts +26 -0
  333. package/dist/plugin-sdk/commands/agent/session.d.ts +1 -2
  334. package/dist/plugin-sdk/commands/onboard-helpers.d.ts +0 -1
  335. package/dist/plugin-sdk/commands/onboard-types.d.ts +2 -1
  336. package/dist/plugin-sdk/config/defaults.d.ts +0 -1
  337. package/dist/plugin-sdk/config/legacy.migrations.d.ts +2 -1
  338. package/dist/plugin-sdk/config/legacy.shared.d.ts +0 -9
  339. package/dist/plugin-sdk/config/sessions/types.d.ts +0 -17
  340. package/dist/plugin-sdk/config/types.agent-defaults.d.ts +28 -120
  341. package/dist/plugin-sdk/config/types.agents.d.ts +8 -0
  342. package/dist/plugin-sdk/config/types.base.d.ts +0 -1
  343. package/dist/plugin-sdk/config/types.messages.d.ts +1 -6
  344. package/dist/plugin-sdk/config/types.remoteclaw.d.ts +2 -2
  345. package/dist/plugin-sdk/config/types.tools.d.ts +1 -74
  346. package/dist/plugin-sdk/config/types.tts.d.ts +2 -1
  347. package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +9 -70
  348. package/dist/plugin-sdk/config/zod-schema.agent-runtime.d.ts +12 -210
  349. package/dist/plugin-sdk/config/zod-schema.agents.d.ts +14 -86
  350. package/dist/plugin-sdk/config/zod-schema.core.d.ts +6 -234
  351. package/dist/plugin-sdk/config/zod-schema.d.ts +111 -378
  352. package/dist/plugin-sdk/config/zod-schema.providers-core.d.ts +148 -160
  353. package/dist/plugin-sdk/config/zod-schema.providers-whatsapp.d.ts +12 -12
  354. package/dist/plugin-sdk/config/zod-schema.providers.d.ts +88 -96
  355. package/dist/plugin-sdk/config/zod-schema.session.d.ts +4 -10
  356. package/dist/plugin-sdk/daemon/constants.d.ts +2 -2
  357. package/dist/plugin-sdk/gateway/protocol/index.d.ts +10 -17
  358. package/dist/plugin-sdk/gateway/protocol/schema/sessions.d.ts +0 -7
  359. package/dist/plugin-sdk/gateway/server/ws-types.d.ts +2 -0
  360. package/dist/plugin-sdk/gateway/session-utils.types.d.ts +0 -3
  361. package/dist/plugin-sdk/index.js +722 -1283
  362. package/dist/plugin-sdk/infra/agent-events.d.ts +1 -1
  363. package/dist/plugin-sdk/infra/provider-usage.auth.d.ts +0 -1
  364. package/dist/plugin-sdk/infra/provider-usage.load.d.ts +0 -1
  365. package/dist/plugin-sdk/line/config-schema.d.ts +4 -4
  366. package/dist/plugin-sdk/logging/levels.d.ts +1 -1
  367. package/dist/plugin-sdk/middleware/auth-key-retry.d.ts +31 -0
  368. package/dist/plugin-sdk/middleware/channel-bridge.d.ts +4 -0
  369. package/dist/plugin-sdk/middleware/cli-runtime-base.d.ts +6 -0
  370. package/dist/plugin-sdk/middleware/error-classifier.d.ts +5 -0
  371. package/dist/plugin-sdk/middleware/media-capability.d.ts +21 -0
  372. package/dist/plugin-sdk/middleware/media-resolver.d.ts +12 -0
  373. package/dist/plugin-sdk/middleware/runtime-factory.d.ts +42 -0
  374. package/dist/plugin-sdk/middleware/runtimes/claude.d.ts +10 -0
  375. package/dist/plugin-sdk/middleware/runtimes/codex.d.ts +5 -0
  376. package/dist/plugin-sdk/middleware/runtimes/gemini.d.ts +11 -0
  377. package/dist/plugin-sdk/middleware/runtimes/opencode.d.ts +5 -0
  378. package/dist/plugin-sdk/middleware/types.d.ts +41 -1
  379. package/dist/plugin-sdk/plugin-sdk/index.d.ts +5 -1
  380. package/dist/plugin-sdk/plugins/manifest-registry.d.ts +2 -0
  381. package/dist/plugin-sdk/plugins/manifest.d.ts +4 -4
  382. package/dist/plugin-sdk/plugins/registry.d.ts +18 -0
  383. package/dist/plugin-sdk/plugins/types.d.ts +5 -1
  384. package/dist/plugin-sdk/stt/defaults.d.ts +2 -0
  385. package/dist/plugin-sdk/stt/preflight.d.ts +14 -0
  386. package/dist/plugin-sdk/stt/providers/deepgram/index.d.ts +2 -0
  387. package/dist/plugin-sdk/stt/providers/google/index.d.ts +2 -0
  388. package/dist/plugin-sdk/stt/providers/groq/index.d.ts +2 -0
  389. package/dist/plugin-sdk/stt/providers/index.d.ts +4 -0
  390. package/dist/plugin-sdk/stt/providers/mistral/index.d.ts +2 -0
  391. package/dist/plugin-sdk/stt/providers/openai/index.d.ts +2 -0
  392. package/dist/plugin-sdk/stt/stt.d.ts +27 -0
  393. package/dist/plugin-sdk/stt/types.d.ts +22 -0
  394. package/dist/plugin-sdk/terminal/palette.d.ts +2 -2
  395. package/dist/plugin-sdk/tts/providers/edge.d.ts +2 -0
  396. package/dist/plugin-sdk/tts/providers/elevenlabs.d.ts +2 -0
  397. package/dist/plugin-sdk/tts/providers/index.d.ts +4 -0
  398. package/dist/plugin-sdk/tts/providers/openai.d.ts +2 -0
  399. package/dist/plugin-sdk/tts/tts.d.ts +13 -5
  400. package/dist/plugin-sdk/tts/types.d.ts +21 -0
  401. package/dist/plugins-BviLFPLV.js +255 -0
  402. package/dist/plugins-CaudBUbl.js +254 -0
  403. package/dist/plugins-cli-CsLhphNr.js +803 -0
  404. package/dist/plugins-cli-CujSP9NS.js +807 -0
  405. package/dist/ports-BtuzUQHl.js +370 -0
  406. package/dist/ports-CMcHia07.js +96 -0
  407. package/dist/ports-DALdfBQy.js +96 -0
  408. package/dist/ports-gRBeuUtp.js +316 -0
  409. package/dist/preflight-Bq8rimP-.js +667 -0
  410. package/dist/preflight-DyYbEp9X.js +667 -0
  411. package/dist/program-D64vUv0b.js +250 -0
  412. package/dist/program-context-CTFkimUr.js +474 -0
  413. package/dist/progress-BcwxtM9Q.js +124 -0
  414. package/dist/prompt-DtWGd43j.js +21 -0
  415. package/dist/prompt-select-styled-GW2PexAK.js +1672 -0
  416. package/dist/prompt-select-styled-JOuWGHX7.js +1669 -0
  417. package/dist/prompt-style-BpUMhEHC.js +9 -0
  418. package/dist/provider-auth-B7QgxlKt.js +187 -0
  419. package/dist/provider-auth-j-EQvvIk.js +187 -0
  420. package/dist/provider-dispatcher-Bx6CaIoV.js +660 -0
  421. package/dist/provider-dispatcher-DhkvjhO5.js +659 -0
  422. package/dist/push-apns--nEiZmEN.js +711 -0
  423. package/dist/push-apns-BtS6B6lb.js +713 -0
  424. package/dist/pw-ai-BpCsXF-x.js +1908 -0
  425. package/dist/pw-ai-ud_Kbn5S.js +1911 -0
  426. package/dist/qr-cli-BCeVLGfz.js +353 -0
  427. package/dist/qr-cli-Crsqtw01.js +349 -0
  428. package/dist/redact-Ci96Gj0O.js +191 -0
  429. package/dist/redact-snapshot-B9nof-Pb.js +1952 -0
  430. package/dist/redact-snapshot-BKiS91Mj.js +1952 -0
  431. package/dist/register.agent-CcvOeVnL.js +292 -0
  432. package/dist/register.agent-azH_tdVX.js +1014 -0
  433. package/dist/register.configure-DAaZLjHs.js +130 -0
  434. package/dist/register.configure-lUl8O79m.js +135 -0
  435. package/dist/register.import-B83Dn36B.js +29 -0
  436. package/dist/register.import-wIYU2cVW.js +31 -0
  437. package/dist/register.maintenance-Bo-ooQDU.js +501 -0
  438. package/dist/register.maintenance-BwZ4OkK2.js +503 -0
  439. package/dist/register.message-BQhRoEQQ.js +687 -0
  440. package/dist/register.message-CvZKWeGb.js +691 -0
  441. package/dist/register.onboard---3EPh-O.js +98 -0
  442. package/dist/register.onboard-rsHSJUvQ.js +94 -0
  443. package/dist/register.setup-B0gc_lne.js +118 -0
  444. package/dist/register.setup-MWpb7jxL.js +114 -0
  445. package/dist/register.status-health-sessions-BZJ0wTSa.js +429 -0
  446. package/dist/register.status-health-sessions-CyrUwwtB.js +667 -0
  447. package/dist/register.subclis-i2d2ugaJ.js +267 -0
  448. package/dist/replies-BIx-MbQ7.js +136 -0
  449. package/dist/replies-DVU655H4.js +136 -0
  450. package/dist/reply-CL5VMSKN.js +12372 -0
  451. package/dist/reply-XKyfU3rS.js +12375 -0
  452. package/dist/reply-directives-DQfJ001O.js +182 -0
  453. package/dist/reply-directives-DfUITt7C.js +182 -0
  454. package/dist/reply-payloads-ZHo6kfTS.js +527 -0
  455. package/dist/reply-prefix-BSf3PC0x.js +37 -0
  456. package/dist/reply-prefix-DBTlMHLK.js +37 -0
  457. package/dist/resolve-route-B-_IgETc.js +249 -0
  458. package/dist/resolve-route-C8ZsgWDQ.js +249 -0
  459. package/dist/response-prefix-template-3LeqJx2X.js +134 -0
  460. package/dist/response-prefix-template-DBrUVx5V.js +134 -0
  461. package/dist/retry-CDrH81GP.js +77 -0
  462. package/dist/retry-Dar_7pCv.js +77 -0
  463. package/dist/run-main-rOudcbbs.js +308 -0
  464. package/dist/runtime-guard-CK80eucm.js +60 -0
  465. package/dist/runtime-status-CR9445g5.js +12 -0
  466. package/dist/runtime-status-hFVEC3wO.js +12 -0
  467. package/dist/secure-random-CLWSvf8A.js +44 -0
  468. package/dist/security-cli-B8lXw9ke.js +488 -0
  469. package/dist/security-cli-CRkS3VAf.js +483 -0
  470. package/dist/send-6g8QKfWj.js +374 -0
  471. package/dist/send-B5Hz1PIn.js +29 -0
  472. package/dist/send-B8eIlA1u.js +349 -0
  473. package/dist/send-BFZPQE4j.js +492 -0
  474. package/dist/send-BpTDvE0D.js +1779 -0
  475. package/dist/send-BxOrO1Wv.js +1776 -0
  476. package/dist/send-C6gPJu-Z.js +11 -0
  477. package/dist/send-C7MoKtkN.js +426 -0
  478. package/dist/send-CXzq2LI6.js +2245 -0
  479. package/dist/send-CYOZoObr.js +547 -0
  480. package/dist/send-CfQyIvcC.js +332 -0
  481. package/dist/send-DUtuuwhw.js +492 -0
  482. package/dist/send-DbafVwxp.js +2245 -0
  483. package/dist/send-DeZg8K7y.js +349 -0
  484. package/dist/send-DwkjxJlv.js +547 -0
  485. package/dist/send-iX9xbxlU.js +1178 -0
  486. package/dist/server-BKfCzEzd.js +206 -0
  487. package/dist/server-fmO4eo7K.js +202 -0
  488. package/dist/server-lifecycle-CgPpP10P.js +2437 -0
  489. package/dist/server-lifecycle-Cn8yY5MW.js +2437 -0
  490. package/dist/server-node-events-C-ZzSBYh.js +391 -0
  491. package/dist/server-node-events-DYlyfDHM.js +395 -0
  492. package/dist/service-C2j81L86.js +670 -0
  493. package/dist/service-C8a0SXHD.js +670 -0
  494. package/dist/session-AulYhqOb.js +170 -0
  495. package/dist/session-C6VKWvx6.js +170 -0
  496. package/dist/session-cost-usage-0Vs4hgMe.js +627 -0
  497. package/dist/session-cost-usage-C-DsaOfN.js +627 -0
  498. package/dist/session-dirs-CO1f2ArM.js +318 -0
  499. package/dist/session-dirs-DoboH7Oy.js +318 -0
  500. package/dist/session-utils-CRK8ToKG.js +621 -0
  501. package/dist/session-utils-DWlkmCX8.js +621 -0
  502. package/dist/sessions-DtqrmUJS.js +2553 -0
  503. package/dist/sessions-gT-4fcX-.js +245 -0
  504. package/dist/shell-env-DBS5su07.js +163 -0
  505. package/dist/shell-env-c3j5zcU9.js +163 -0
  506. package/dist/ssrf-8wNqPNzN.js +183 -0
  507. package/dist/ssrf-CJIdPXuS.js +183 -0
  508. package/dist/status-BI_-xpDt.js +1947 -0
  509. package/dist/status-PZVwjKjl.js +1943 -0
  510. package/dist/status.update-BmuDZ7E7.js +449 -0
  511. package/dist/status.update-Mf6HSRvU.js +449 -0
  512. package/dist/store-B7PGEdFf.js +2555 -0
  513. package/dist/store-CzhBjUCN.js +64 -0
  514. package/dist/store-YkSxKAey.js +53 -0
  515. package/dist/store-ZNeFv2Q7.js +64 -0
  516. package/dist/subagent-registry-R1DiAM4R.js +4839 -0
  517. package/dist/subagent-registry-xLRXC8Bg.js +4841 -0
  518. package/dist/subsystem-BAW_f3DI.js +1195 -0
  519. package/dist/subsystem-DGSHVL8I.js +1081 -0
  520. package/dist/system-cli-9SvRrT9D.js +77 -0
  521. package/dist/system-cli-yCa5Q1YM.js +73 -0
  522. package/dist/systemd-40Rij3QR.js +547 -0
  523. package/dist/systemd-5C97CSzd.js +547 -0
  524. package/dist/systemd-hints-3iQteJw-.js +278 -0
  525. package/dist/systemd-hints-CyQqHq1i.js +278 -0
  526. package/dist/systemd-linger-B2rPbnAi.js +75 -0
  527. package/dist/systemd-linger-DDvkfxH-.js +75 -0
  528. package/dist/table-DFx25vNb.js +279 -0
  529. package/dist/tables-C5fI0PmT.js +55 -0
  530. package/dist/tables-Cm9qvQ9D.js +55 -0
  531. package/dist/tables-fRe01eP1.js +55 -0
  532. package/dist/tailnet-Da-_9e8E.js +40 -0
  533. package/dist/tailnet-xt92Yaop.js +40 -0
  534. package/dist/tailscale-CnV0JWca.js +230 -0
  535. package/dist/tailscale-VkEC8dzj.js +230 -0
  536. package/dist/targets-C99szk_e.js +114 -0
  537. package/dist/targets-CPaTjbpp.js +2607 -0
  538. package/dist/targets-D-p4rJVS.js +650 -0
  539. package/dist/targets-D2OQt8-7.js +650 -0
  540. package/dist/targets-D94MtTiZ.js +2606 -0
  541. package/dist/targets-RajrXTl7.js +220 -0
  542. package/dist/targets-_UWmnyI9.js +53 -0
  543. package/dist/targets-tDrl_ioQ.js +46 -0
  544. package/dist/thinking-4nOZPunr.js +60 -0
  545. package/dist/thinking-ZfH2V9Os.js +60 -0
  546. package/dist/tokens-TtJJxzRr.js +21 -0
  547. package/dist/tool-display-Bxs_1jIn.js +785 -0
  548. package/dist/tool-display-D9p_Ttkq.js +785 -0
  549. package/dist/tool-images-9Ron321Q.js +263 -0
  550. package/dist/tool-images-BWhy6WRN.js +263 -0
  551. package/dist/trash-B5xyvBDf.js +125 -0
  552. package/dist/trash-BpB96kHe.js +125 -0
  553. package/dist/tui-Ba0uZDrg.js +3237 -0
  554. package/dist/tui-Biz0HqDj.js +3237 -0
  555. package/dist/tui-cli-C-UV6o2v.js +63 -0
  556. package/dist/tui-cli-Ds_bLT-h.js +67 -0
  557. package/dist/types.tools-BBb2rl3g.js +23 -0
  558. package/dist/types.tools-BDJw1yFx.js +23 -0
  559. package/dist/update-Barj5dsg.js +349 -0
  560. package/dist/update-D839Q8su.js +349 -0
  561. package/dist/update-cli-C0LnrpIt.js +1148 -0
  562. package/dist/update-cli-CUypa-T-.js +1150 -0
  563. package/dist/usage-BI9kergH.js +5465 -0
  564. package/dist/utils-DPoNpP7D.js +631 -0
  565. package/dist/version-3QUZW8EP.js +52 -0
  566. package/dist/version-CVMnqdzu.js +52 -0
  567. package/dist/voice-credentials-64XAMSJm.js +46 -0
  568. package/dist/voice-credentials-v-CQkTpD.js +46 -0
  569. package/dist/web-63IbbidQ.js +3051 -0
  570. package/dist/web-D9N764Da.js +80 -0
  571. package/dist/web-DUvNYLzr.js +75 -0
  572. package/dist/webhooks-cli-owhVNNkz.js +334 -0
  573. package/dist/webhooks-cli-zlvka6QD.js +330 -0
  574. package/dist/whatsapp-actions-8DejyRG5.js +126 -0
  575. package/dist/whatsapp-actions-DCzp5LKe.js +131 -0
  576. package/dist/widearea-dns-CQqZIeu8.js +127 -0
  577. package/dist/workspace-CB7pVojf.js +441 -0
  578. package/dist/workspace-DWEyzM0F.js +439 -0
  579. package/dist/zod-schema-CvFqwpNE.js +2719 -0
  580. package/dist/zod-schema-Y5SQgJLm.js +2719 -0
  581. package/extensions/matrix/src/matrix/monitor/replies.ts +0 -24
  582. package/extensions/mattermost/src/mattermost/monitor-helpers.ts +0 -1
  583. package/extensions/voice-call/index.ts +18 -1
  584. package/package.json +3 -4
  585. package/dist/accounts-7fm_KzPm.js +0 -32
  586. package/dist/accounts-BFy_Z3od.js +0 -272
  587. package/dist/accounts-BTXSfPWi.js +0 -270
  588. package/dist/accounts-BxGS70Do.js +0 -36
  589. package/dist/accounts-CNY1TGj1.js +0 -47
  590. package/dist/accounts-DqRQ75w3.js +0 -36
  591. package/dist/accounts-iODF3SK2.js +0 -47
  592. package/dist/ack-reactions-C1hk85VE.js +0 -446
  593. package/dist/ack-reactions-DRC2CiDQ.js +0 -446
  594. package/dist/acp-cli-DD-PD4NM.js +0 -1326
  595. package/dist/acp-cli-DIyRCOum.js +0 -1320
  596. package/dist/active-listener-VzhWW8W6.js +0 -37
  597. package/dist/active-listener-z0qVEcom.js +0 -37
  598. package/dist/agent-D2HeDFFR.js +0 -731
  599. package/dist/agent-Da_eZ5BP.js +0 -732
  600. package/dist/agent-helpers-B6VfZ9_u.js +0 -606
  601. package/dist/agent-helpers-CTx5KKJu.js +0 -606
  602. package/dist/agent-scope-BqPmD-Ax.js +0 -114
  603. package/dist/agent-scope-DgQzamQB.js +0 -116
  604. package/dist/agents-TB3QpHoo.js +0 -788
  605. package/dist/agents.config-BsAQTYe1.js +0 -116
  606. package/dist/agents.config-C9fyYfAh.js +0 -116
  607. package/dist/ansi-D04X81yq.js +0 -14
  608. package/dist/audio-DPOuhNq7.js +0 -43
  609. package/dist/audio-VBcVDa08.js +0 -43
  610. package/dist/audio-preflight-CK3EA3Dv.js +0 -69
  611. package/dist/audio-preflight-tdXtrutj.js +0 -64
  612. package/dist/audit-CJipUWDi.js +0 -3138
  613. package/dist/audit-COWzB9Y1.js +0 -3138
  614. package/dist/auth-CAczFgAO.js +0 -448
  615. package/dist/auth-Deh9i9Eg.js +0 -448
  616. package/dist/auth-profiles-BquJGKLC.js +0 -279
  617. package/dist/auth-profiles-D8vKiBPq.js +0 -281
  618. package/dist/banner-CUWBOR42.js +0 -294
  619. package/dist/binaries-DXW6oATV.js +0 -13
  620. package/dist/bindings-8YtSWb91.js +0 -69
  621. package/dist/bindings-l1R5LQQH.js +0 -69
  622. package/dist/bonjour-discovery-DdAk1VyO.js +0 -378
  623. package/dist/bonjour-discovery-DuhiIZZx.js +0 -378
  624. package/dist/browser-cli-5Q9lhGdd.js +0 -1687
  625. package/dist/browser-cli-D2qMeSx1.js +0 -1692
  626. package/dist/call-CZHVeMf1.js +0 -2828
  627. package/dist/call-CoMjY7ah.js +0 -2829
  628. package/dist/catalog-CYiAleBT.js +0 -185
  629. package/dist/catalog-pjPqB2hC.js +0 -185
  630. package/dist/channel-account-context-CvIDAtHS.js +0 -550
  631. package/dist/channel-account-context-q-o0pG1A.js +0 -550
  632. package/dist/channel-activity-BaCNOZpP.js +0 -94
  633. package/dist/channel-activity-Cd1JhIUj.js +0 -292
  634. package/dist/channel-activity-DTKGf3j5.js +0 -94
  635. package/dist/channel-options-8SjIcDDI.js +0 -33
  636. package/dist/channel-options-BtQGtMF4.js +0 -32
  637. package/dist/channel-selection-C4DzrynU.js +0 -51
  638. package/dist/channel-selection-DdfhwFuY.js +0 -51
  639. package/dist/channel-web-BKJSXnwf.js +0 -2136
  640. package/dist/channel-web-BUzvNE_A.js +0 -2134
  641. package/dist/channels-cli-CCXY796Z.js +0 -1421
  642. package/dist/channels-cli-DTfx1zFC.js +0 -1426
  643. package/dist/channels-status-issues-DnmuqPsi.js +0 -18
  644. package/dist/channels-status-issues-p1pCvTh8.js +0 -18
  645. package/dist/chat-envelope-DEZ-5RY8.js +0 -248
  646. package/dist/chat-envelope-el7Uo-Fe.js +0 -248
  647. package/dist/chrome-Dd4dv0Vh.js +0 -1732
  648. package/dist/chrome-DdNEInwI.js +0 -1733
  649. package/dist/chunk-CSQfUhgF.js +0 -341
  650. package/dist/chunk-D0Y_w4oX.js +0 -341
  651. package/dist/clack-prompter-B7tOxhJd.js +0 -122
  652. package/dist/clack-prompter-CCFnKP_1.js +0 -121
  653. package/dist/cleanup-utils-CqAVZz2b.js +0 -94
  654. package/dist/cli-BRwDPW0r.js +0 -125
  655. package/dist/cli-CV86F7iv.js +0 -130
  656. package/dist/clipboard-D7_SKHPK.js +0 -31
  657. package/dist/clipboard-Dzkx6Q2K.js +0 -31
  658. package/dist/command-format-CVfo8I5f.js +0 -18
  659. package/dist/command-format-DgXcqxBt.js +0 -32
  660. package/dist/command-registry-BvLC28b4.js +0 -215
  661. package/dist/commands-B49Lu-pa.js +0 -41
  662. package/dist/commands-DI1BCqnj.js +0 -41
  663. package/dist/commands-registry-Cr6SIR3n.js +0 -892
  664. package/dist/commands-registry-agiTEGDz.js +0 -893
  665. package/dist/common-CMI-qsF8.js +0 -156
  666. package/dist/common-DSVmydhm.js +0 -156
  667. package/dist/completion-cli-C7O4JU8t.js +0 -452
  668. package/dist/completion-cli-CQNXtEJ7.js +0 -452
  669. package/dist/config-ChYRSJQt.js +0 -6953
  670. package/dist/config-CwtWvygh.js +0 -6951
  671. package/dist/config-cli-Df5nJcfO.js +0 -241
  672. package/dist/config-cli-Dqe5O1pl.js +0 -246
  673. package/dist/config-guard-C6hyuH-z.js +0 -75
  674. package/dist/config-guard-kNMQS_tm.js +0 -97
  675. package/dist/config-validation-BZBaBH69.js +0 -18
  676. package/dist/config-validation-DkrbzCyL.js +0 -18
  677. package/dist/configure-CoJmCHqT.js +0 -891
  678. package/dist/configure-DJbojDRf.js +0 -889
  679. package/dist/constants-BmRFoHl0.js +0 -67
  680. package/dist/constants-C9WPAluB.js +0 -67
  681. package/dist/control-auth-7k6Cb2zH.js +0 -397
  682. package/dist/control-auth-DBxfkJ3g.js +0 -397
  683. package/dist/control-ui/assets/index-B4ZM1lW1.js +0 -7738
  684. package/dist/control-ui/assets/index-B4ZM1lW1.js.map +0 -1
  685. package/dist/control-ui/assets/index-PED72sKF.css +0 -1
  686. package/dist/control-ui-assets-Cx_mw4D0.js +0 -186
  687. package/dist/control-ui-assets-W1AUuGrO.js +0 -186
  688. package/dist/conversation-label-C4SDz4sT.js +0 -36
  689. package/dist/conversation-label-D1frnvYe.js +0 -36
  690. package/dist/cron-cli-BJXQKtR3.js +0 -495
  691. package/dist/cron-cli-CTIj0WPW.js +0 -490
  692. package/dist/daemon-cli-CZbHvkRG.js +0 -1197
  693. package/dist/daemon-cli-Cf_YKWvV.js +0 -1199
  694. package/dist/daemon-install-CcohRvKV.js +0 -55
  695. package/dist/daemon-install-DDshfT0J.js +0 -60
  696. package/dist/daemon-install-helpers-CFGAfRlj.js +0 -462
  697. package/dist/daemon-install-helpers-DIUzSFG1.js +0 -462
  698. package/dist/defaults-B5KStIBg.js +0 -7
  699. package/dist/defaults-xUAL2Z-F.js +0 -7
  700. package/dist/deliver-BDf2lIEK.js +0 -481
  701. package/dist/deliver-DvmkSwLt.js +0 -481
  702. package/dist/delivery-queue-Cfa9Wmxp.js +0 -244
  703. package/dist/delivery-queue-CxVRi4tw.js +0 -244
  704. package/dist/devices-cli-CRsW5WOw.js +0 -316
  705. package/dist/devices-cli-Crzrk5uf.js +0 -321
  706. package/dist/diagnostics-99iCgBUh.js +0 -46
  707. package/dist/diagnostics-VC0cz7kX.js +0 -46
  708. package/dist/directory-cli-BnoQqeOX.js +0 -222
  709. package/dist/directory-cli-DdBAX3AV.js +0 -217
  710. package/dist/dm-policy-shared-DNqPbnip.js +0 -22
  711. package/dist/dm-policy-shared-vCb_hnqo.js +0 -22
  712. package/dist/dns-cli-D410XQr9.js +0 -197
  713. package/dist/dns-cli-Fgg96Xkg.js +0 -202
  714. package/dist/dock-DXSgTbDw.js +0 -928
  715. package/dist/dock-FtQwUHXE.js +0 -929
  716. package/dist/doctor-completion-BWmtCiFR.js +0 -92
  717. package/dist/doctor-completion-DTM_wDxy.js +0 -92
  718. package/dist/doctor-config-flow-Ccna5fPs.js +0 -1934
  719. package/dist/doctor-config-flow-DqzrK_jh.js +0 -1933
  720. package/dist/enable-DcJnkzfz.js +0 -59
  721. package/dist/enable-ibNq4UWy.js +0 -59
  722. package/dist/env-DeF64iu0.js +0 -60
  723. package/dist/env-vars-7aZqKPhk.js +0 -93
  724. package/dist/env-vars-CLGbxdpL.js +0 -93
  725. package/dist/errors-8F-77i6m.js +0 -35
  726. package/dist/errors-DZ199hOo.js +0 -35
  727. package/dist/exec-DbKuYyM1.js +0 -164
  728. package/dist/exec-DkFE7lqU.js +0 -164
  729. package/dist/fetch-C6XKGA11.js +0 -67
  730. package/dist/fetch-CEDsOiql.js +0 -67
  731. package/dist/fetch-ePscvwi1.js +0 -67
  732. package/dist/file-lock-CIvloidc.js +0 -107
  733. package/dist/file-lock-CzBL_VIx.js +0 -107
  734. package/dist/fs-safe-DSwT85uK.js +0 -88
  735. package/dist/fs-safe-DkBhNAc3.js +0 -98
  736. package/dist/gateway-cli-BJooqlkO.js +0 -23747
  737. package/dist/gateway-cli-C2wPjxY4.js +0 -23742
  738. package/dist/gateway-rpc-BcT4FqJQ.js +0 -28
  739. package/dist/gateway-rpc-DhKAJ5EW.js +0 -28
  740. package/dist/gmail-setup-utils-Cnx8A5pW.js +0 -422
  741. package/dist/gmail-setup-utils-nkabbKOE.js +0 -423
  742. package/dist/health-BZX-PyP0.js +0 -1420
  743. package/dist/health-BgD0koJx.js +0 -1423
  744. package/dist/health-format-BG95OE6N.js +0 -28
  745. package/dist/heartbeat-visibility-DeW9EIeS.js +0 -125
  746. package/dist/heartbeat-visibility-DvogUlnZ.js +0 -125
  747. package/dist/help-format-DAxf0l_h.js +0 -17
  748. package/dist/helpers-R7bU5IBz.js +0 -10
  749. package/dist/helpers-kkeXif0Q.js +0 -10
  750. package/dist/hook-runner-global-cyaKukZP.js +0 -527
  751. package/dist/hooks-cli-DTygpzqS.js +0 -1217
  752. package/dist/hooks-cli-Dg853OdZ.js +0 -1222
  753. package/dist/host-env-security-Bms2_EMV.js +0 -92
  754. package/dist/host-env-security-szwfmhC4.js +0 -92
  755. package/dist/image-ops-Bi6JPSkD.js +0 -354
  756. package/dist/image-ops-DWytvdh_.js +0 -354
  757. package/dist/import-D8BBZQgl.js +0 -170
  758. package/dist/import-DQ6NI4Fz.js +0 -168
  759. package/dist/inbound-context-CPkkQW0i.js +0 -68
  760. package/dist/inbound-context-DS_kpIYI.js +0 -68
  761. package/dist/inbound-path-policy-Bg4gZBx-.js +0 -250
  762. package/dist/inbound-path-policy-sdr5Ji0k.js +0 -250
  763. package/dist/inspect-Dt8hogS3.js +0 -559
  764. package/dist/inspect-vYIL1oA0.js +0 -559
  765. package/dist/installs-ClX3qQmh.js +0 -325
  766. package/dist/installs-CxjOiLUM.js +0 -325
  767. package/dist/ipv4--2WXMVtE.js +0 -46
  768. package/dist/ipv4-CDQpx1A7.js +0 -46
  769. package/dist/ir-BvKdMuSP.js +0 -940
  770. package/dist/json-files-DzpTak5i.js +0 -46
  771. package/dist/links-C3soDNDH.js +0 -15
  772. package/dist/loader-BWZ_iRxI.js +0 -22624
  773. package/dist/loader-ClFP7wvS.js +0 -22621
  774. package/dist/local-roots-B6rSCu4U.js +0 -314
  775. package/dist/local-roots-v2HlOaG5.js +0 -313
  776. package/dist/logger-Bw3cFE5t.js +0 -49
  777. package/dist/logging-C-nxX2fn.js +0 -20
  778. package/dist/login-Cmpeb59f.js +0 -62
  779. package/dist/login-D1CV2eNF.js +0 -61
  780. package/dist/login-qr-B3tpFLRV.js +0 -327
  781. package/dist/login-qr-CSQzrtFX.js +0 -322
  782. package/dist/logs-cli-BSiUZwb2.js +0 -238
  783. package/dist/logs-cli-DDtoJ1Fr.js +0 -233
  784. package/dist/markdown-tables-PJUMrC4T.js +0 -29
  785. package/dist/markdown-tables-dDWBbtqd.js +0 -29
  786. package/dist/media-Dqv7Q0aS.js +0 -10492
  787. package/dist/media-DtN0R9A0.js +0 -940
  788. package/dist/message-action-names-Bs50Ia1g.js +0 -2521
  789. package/dist/message-action-names-Btd7cMvx.js +0 -2521
  790. package/dist/message-channel-DzJqHVZD.js +0 -91
  791. package/dist/message-channel-uWMAiywE.js +0 -91
  792. package/dist/mime-BS3jhcZE.js +0 -149
  793. package/dist/mime-Cxh_64P6.js +0 -149
  794. package/dist/net-Cg8AQeke.js +0 -225
  795. package/dist/net-D6D0wgcF.js +0 -225
  796. package/dist/node-cli-Q2-n3Fgv.js +0 -24
  797. package/dist/node-cli-Uf6lAntf.js +0 -24
  798. package/dist/nodes-cli-DVLvMgBV.js +0 -1343
  799. package/dist/nodes-cli-Dxf7vAKk.js +0 -1348
  800. package/dist/nodes-screen-BR9sYoPa.js +0 -250
  801. package/dist/nodes-screen-Cw7Hv7M2.js +0 -250
  802. package/dist/note-Dlv4NmlQ.js +0 -92
  803. package/dist/note-kvWV4xtw.js +0 -92
  804. package/dist/npm-registry-spec-0qiKawvv.js +0 -786
  805. package/dist/npm-registry-spec-COvUzy5J.js +0 -786
  806. package/dist/npm-resolution-DJnq5QBs.js +0 -86
  807. package/dist/npm-resolution-DVl2spoD.js +0 -86
  808. package/dist/onboard-BcQWYGY3.js +0 -405
  809. package/dist/onboard-RQ_FAMyg.js +0 -407
  810. package/dist/onboard-channels-CHh_BuxJ.js +0 -2547
  811. package/dist/onboard-channels-DXD-CK_M.js +0 -2548
  812. package/dist/onboard-config-BCTthQ7J.js +0 -24
  813. package/dist/onboard-config-y-2cgT0V.js +0 -24
  814. package/dist/onboard-helpers-BRMP8mup.js +0 -362
  815. package/dist/onboard-helpers-CUGbuZwH.js +0 -363
  816. package/dist/onboard-remote-D-qWujdL.js +0 -127
  817. package/dist/onboard-remote-o_OW-uzc.js +0 -127
  818. package/dist/onboarding-Bf9kVcef.js +0 -541
  819. package/dist/onboarding-CVlOLLp1.js +0 -543
  820. package/dist/onboarding.finalize-CQSt37fw.js +0 -398
  821. package/dist/onboarding.finalize-DggVL7Ay.js +0 -401
  822. package/dist/onboarding.gateway-config-BLca3Td2.js +0 -198
  823. package/dist/onboarding.gateway-config-C1mcOkRh.js +0 -191
  824. package/dist/outbound-DXXccLDS.js +0 -220
  825. package/dist/outbound-ZnVvUReT.js +0 -221
  826. package/dist/outbound-attachment-CfRb07J7.js +0 -18
  827. package/dist/outbound-attachment-DGXTtERK.js +0 -18
  828. package/dist/outbound-attachment-_jj74QBM.js +0 -18
  829. package/dist/pairing-cli-Bgm4fRA3.js +0 -127
  830. package/dist/pairing-cli-J0uGb1nU.js +0 -122
  831. package/dist/pairing-labels-CVm65Jkh.js +0 -9
  832. package/dist/pairing-labels-DD1mcvQG.js +0 -9
  833. package/dist/pairing-store-5qapT5-t.js +0 -460
  834. package/dist/pairing-store-MLceBEeL.js +0 -459
  835. package/dist/path-env-DR5vn3QL.js +0 -89
  836. package/dist/path-env-qRJbjJzj.js +0 -89
  837. package/dist/path-guards-CIx4hURU.js +0 -31
  838. package/dist/path-guards-CrQOUlsq.js +0 -31
  839. package/dist/path-safety-DkT9RmTG.js +0 -14
  840. package/dist/path-safety-juI2XbO1.js +0 -14
  841. package/dist/paths-BTaH3rLn.js +0 -232
  842. package/dist/plugin-auto-enable-BUSF117F.js +0 -301
  843. package/dist/plugin-auto-enable-CoDnqA0S.js +0 -302
  844. package/dist/plugin-registry-D2B6nbn1.js +0 -33
  845. package/dist/plugin-registry-fLaMC0ik.js +0 -33
  846. package/dist/plugin-sdk/agents/agent-helpers/thinking.d.ts +0 -5
  847. package/dist/plugin-sdk/agents/agent-paths.d.ts +0 -1
  848. package/dist/plugin-sdk/agents/auth-profiles/constants.d.ts +0 -16
  849. package/dist/plugin-sdk/agents/auth-profiles/display.d.ts +0 -7
  850. package/dist/plugin-sdk/agents/auth-profiles/doctor.d.ts +0 -8
  851. package/dist/plugin-sdk/agents/auth-profiles/oauth.d.ts +0 -14
  852. package/dist/plugin-sdk/agents/auth-profiles/paths.d.ts +0 -4
  853. package/dist/plugin-sdk/agents/auth-profiles/profiles.d.ts +0 -12
  854. package/dist/plugin-sdk/agents/auth-profiles/session-override.d.ts +0 -18
  855. package/dist/plugin-sdk/agents/auth-profiles/store.d.ts +0 -10
  856. package/dist/plugin-sdk/agents/auth-profiles/types.d.ts +0 -13
  857. package/dist/plugin-sdk/agents/auth-profiles.d.ts +0 -8
  858. package/dist/plugin-sdk/agents/defaults.d.ts +0 -3
  859. package/dist/plugin-sdk/agents/provider-auth.d.ts +0 -40
  860. package/dist/plugin-sdk/auto-reply/model-runtime.d.ts +0 -17
  861. package/dist/plugin-sdk/auto-reply/reply/directive-handling.auth.d.ts +0 -19
  862. package/dist/plugin-sdk/auto-reply/reply/elevated-allowlist-matcher.d.ts +0 -20
  863. package/dist/plugin-sdk/auto-reply/reply/elevated-unavailable.d.ts +0 -8
  864. package/dist/plugin-sdk/auto-reply/reply/reply-elevated.d.ts +0 -16
  865. package/dist/plugin-sdk/compat/legacy-names.d.ts +0 -8
  866. package/dist/plugin-sdk/config/legacy.migrations.part-1.d.ts +0 -2
  867. package/dist/plugin-sdk/config/legacy.migrations.part-2.d.ts +0 -2
  868. package/dist/plugin-sdk/config/legacy.migrations.part-3.d.ts +0 -2
  869. package/dist/plugin-sdk/config/model-input.d.ts +0 -9
  870. package/dist/plugin-sdk/config/zod-schema.agent-model.d.ts +0 -5
  871. package/dist/plugin-sdk/link-understanding/apply.d.ts +0 -10
  872. package/dist/plugin-sdk/link-understanding/defaults.d.ts +0 -2
  873. package/dist/plugin-sdk/link-understanding/detect.d.ts +0 -3
  874. package/dist/plugin-sdk/link-understanding/format.d.ts +0 -4
  875. package/dist/plugin-sdk/link-understanding/runner.d.ts +0 -11
  876. package/dist/plugin-sdk/media/input-files.d.ts +0 -95
  877. package/dist/plugin-sdk/media-understanding/apply.d.ts +0 -19
  878. package/dist/plugin-sdk/media-understanding/attachments.d.ts +0 -49
  879. package/dist/plugin-sdk/media-understanding/audio-preflight.d.ts +0 -16
  880. package/dist/plugin-sdk/media-understanding/concurrency.d.ts +0 -1
  881. package/dist/plugin-sdk/media-understanding/defaults.d.ts +0 -12
  882. package/dist/plugin-sdk/media-understanding/errors.d.ts +0 -6
  883. package/dist/plugin-sdk/media-understanding/format.d.ts +0 -7
  884. package/dist/plugin-sdk/media-understanding/fs.d.ts +0 -1
  885. package/dist/plugin-sdk/media-understanding/output-extract.d.ts +0 -2
  886. package/dist/plugin-sdk/media-understanding/providers/anthropic/index.d.ts +0 -2
  887. package/dist/plugin-sdk/media-understanding/providers/deepgram/index.d.ts +0 -2
  888. package/dist/plugin-sdk/media-understanding/providers/google/index.d.ts +0 -2
  889. package/dist/plugin-sdk/media-understanding/providers/google/video.d.ts +0 -3
  890. package/dist/plugin-sdk/media-understanding/providers/groq/index.d.ts +0 -2
  891. package/dist/plugin-sdk/media-understanding/providers/index.d.ts +0 -4
  892. package/dist/plugin-sdk/media-understanding/providers/minimax/index.d.ts +0 -2
  893. package/dist/plugin-sdk/media-understanding/providers/mistral/index.d.ts +0 -2
  894. package/dist/plugin-sdk/media-understanding/providers/moonshot/index.d.ts +0 -2
  895. package/dist/plugin-sdk/media-understanding/providers/moonshot/video.d.ts +0 -3
  896. package/dist/plugin-sdk/media-understanding/providers/openai/index.d.ts +0 -2
  897. package/dist/plugin-sdk/media-understanding/providers/zai/index.d.ts +0 -2
  898. package/dist/plugin-sdk/media-understanding/resolve.d.ts +0 -44
  899. package/dist/plugin-sdk/media-understanding/runner.d.ts +0 -34
  900. package/dist/plugin-sdk/media-understanding/runner.entries.d.ts +0 -33
  901. package/dist/plugin-sdk/media-understanding/scope.d.ts +0 -9
  902. package/dist/plugin-sdk/media-understanding/types.d.ts +0 -74
  903. package/dist/plugin-sdk/media-understanding/video.d.ts +0 -2
  904. package/dist/plugin-sdk/sessions/model-overrides.d.ts +0 -14
  905. package/dist/plugin-sdk/telegram/reasoning-lane-coordinator.d.ts +0 -18
  906. package/dist/plugin-sdk/utils/mask-api-key.d.ts +0 -1
  907. package/dist/plugin-sdk/utils/run-with-concurrency.d.ts +0 -11
  908. package/dist/plugins-CsYMlnVa.js +0 -455
  909. package/dist/plugins-Dhit-VHt.js +0 -453
  910. package/dist/plugins-cli-BwuvKtN-.js +0 -798
  911. package/dist/plugins-cli-D34k2VsI.js +0 -793
  912. package/dist/ports-DrruB2fK.js +0 -370
  913. package/dist/ports-GT1yV-Tg.js +0 -96
  914. package/dist/ports-NPqtlfp0.js +0 -316
  915. package/dist/ports-QMI4-F9m.js +0 -96
  916. package/dist/program-C5ukTU6N.js +0 -244
  917. package/dist/program-context-D55P0vBV.js +0 -474
  918. package/dist/progress-CBkSaM6z.js +0 -124
  919. package/dist/prompt-Bllj1dhc.js +0 -21
  920. package/dist/prompt-select-styled-WStiI-bz.js +0 -1647
  921. package/dist/prompt-select-styled-ram-aXWu.js +0 -1650
  922. package/dist/prompt-style-DVEm3BZW.js +0 -9
  923. package/dist/provider-dispatcher-epFKwpGK.js +0 -659
  924. package/dist/provider-dispatcher-vEBMmwZ0.js +0 -660
  925. package/dist/push-apns-C0LyG-WB.js +0 -713
  926. package/dist/push-apns-DuG95AKC.js +0 -711
  927. package/dist/pw-ai-TygsEDgY.js +0 -1906
  928. package/dist/pw-ai-eS0sIkZo.js +0 -1910
  929. package/dist/qr-cli-B8sYhugo.js +0 -352
  930. package/dist/qr-cli-yP8i4Iv1.js +0 -347
  931. package/dist/redact-eZq1uwNK.js +0 -191
  932. package/dist/redact-snapshot-gOLgfKp3.js +0 -2028
  933. package/dist/redact-snapshot-uT-CXbM8.js +0 -2028
  934. package/dist/register.agent-CSoigVGq.js +0 -1043
  935. package/dist/register.agent-GZLrbUPm.js +0 -286
  936. package/dist/register.configure-CXpiRohq.js +0 -124
  937. package/dist/register.configure-RaqiHe5L.js +0 -130
  938. package/dist/register.import-Bs-UkOs-.js +0 -27
  939. package/dist/register.import-DLng8g-e.js +0 -30
  940. package/dist/register.maintenance-B-ZLQ56Y.js +0 -494
  941. package/dist/register.maintenance-Bjr_SmG9.js +0 -497
  942. package/dist/register.message-BCQ8Vg4O.js +0 -686
  943. package/dist/register.message-ChhiSr7g.js +0 -681
  944. package/dist/register.onboard-DJCqNufv.js +0 -257
  945. package/dist/register.onboard-jlxjsrv6.js +0 -262
  946. package/dist/register.setup-C-sdixz5.js +0 -114
  947. package/dist/register.setup-Dwpe4ArC.js +0 -109
  948. package/dist/register.status-health-sessions-BWFRHBCZ.js +0 -669
  949. package/dist/register.status-health-sessions-D7noMz9y.js +0 -423
  950. package/dist/register.subclis-DFI5u4a6.js +0 -267
  951. package/dist/replies-Bzcj-R8d.js +0 -136
  952. package/dist/replies-uvTI-4lg.js +0 -136
  953. package/dist/reply-B9qz9Wwk.js +0 -13897
  954. package/dist/reply-CmGAXQKc.js +0 -13900
  955. package/dist/reply-directives-Be97YiyM.js +0 -182
  956. package/dist/reply-directives-DsLughUT.js +0 -182
  957. package/dist/reply-payloads-DW0YgT82.js +0 -527
  958. package/dist/reply-prefix-BzoT8h8o.js +0 -38
  959. package/dist/reply-prefix-CSaiVnkC.js +0 -38
  960. package/dist/resolve-route-2P40JKXk.js +0 -249
  961. package/dist/resolve-route-_CwEKLq6.js +0 -249
  962. package/dist/response-prefix-template-BAlvtSjL.js +0 -136
  963. package/dist/response-prefix-template-D-tls8tI.js +0 -136
  964. package/dist/retry-B042l5UJ.js +0 -77
  965. package/dist/retry-BhuXOEVR.js +0 -77
  966. package/dist/run-main-B-O5ZtbU.js +0 -320
  967. package/dist/runner-DGkTSlOS.js +0 -2294
  968. package/dist/runner-hs4uxAUP.js +0 -2294
  969. package/dist/runtime-DJNp29jv.js +0 -94
  970. package/dist/runtime-guard-DZ_xuCc4.js +0 -60
  971. package/dist/secure-random-DTcQnwrI.js +0 -44
  972. package/dist/security-cli-1iY1lW6F.js +0 -484
  973. package/dist/security-cli-BuiPPQYU.js +0 -478
  974. package/dist/send-3lgWtHHf.js +0 -349
  975. package/dist/send-6l2S1bcr.js +0 -11
  976. package/dist/send-9NV7sSlD.js +0 -2245
  977. package/dist/send-B0TcjZUD.js +0 -1778
  978. package/dist/send-Bb6K_10X.js +0 -2245
  979. package/dist/send-BzN7X1Om.js +0 -374
  980. package/dist/send-CLrRM0El.js +0 -426
  981. package/dist/send-Caz-txXK.js +0 -492
  982. package/dist/send-DJEr4rP6.js +0 -547
  983. package/dist/send-DJiDHXsu.js +0 -349
  984. package/dist/send-DOjg7kJj.js +0 -1775
  985. package/dist/send-DVXOiKT4.js +0 -1174
  986. package/dist/send-Dc_K995l.js +0 -547
  987. package/dist/send-Dh6d3CLl.js +0 -332
  988. package/dist/send-iPAfbiYM.js +0 -492
  989. package/dist/send-pwe9Gu8e.js +0 -29
  990. package/dist/server-B0IC-Osg.js +0 -205
  991. package/dist/server-MccRxMpb.js +0 -200
  992. package/dist/server-lifecycle-C_0CfoP7.js +0 -2437
  993. package/dist/server-lifecycle-IKdGw1kM.js +0 -2437
  994. package/dist/server-node-events-Czr2gXp_.js +0 -393
  995. package/dist/server-node-events-DFG6cXud.js +0 -398
  996. package/dist/service-Bjqii5nW.js +0 -670
  997. package/dist/service-fp29z5Ww.js +0 -670
  998. package/dist/session-DBL5nHDy.js +0 -170
  999. package/dist/session-cost-usage-DX09eTPU.js +0 -627
  1000. package/dist/session-cost-usage-yYi525j3.js +0 -627
  1001. package/dist/session-dirs-Cj5xi7zX.js +0 -947
  1002. package/dist/session-dirs-DdF6TDsE.js +0 -947
  1003. package/dist/session-utils-C7BtKlun.js +0 -625
  1004. package/dist/session-utils-CLe1dano.js +0 -625
  1005. package/dist/session-xKIW6gL2.js +0 -170
  1006. package/dist/sessions-C65iUuN9.js +0 -2593
  1007. package/dist/sessions-DjZ9IshB.js +0 -252
  1008. package/dist/ssrf-Ck9HDZpv.js +0 -183
  1009. package/dist/ssrf-m7kFIobZ.js +0 -183
  1010. package/dist/status-C6ghjxvX.js +0 -2072
  1011. package/dist/status-D-qTB8aZ.js +0 -2068
  1012. package/dist/status.update-C55QM2xs.js +0 -79
  1013. package/dist/status.update-CBmPXwYN.js +0 -79
  1014. package/dist/store-Bjk6rTC_.js +0 -53
  1015. package/dist/store-C3tOpizT.js +0 -64
  1016. package/dist/store-uRA67h-o.js +0 -2595
  1017. package/dist/store-v3P-OWhi.js +0 -64
  1018. package/dist/subagent-registry-BTG1aAZ8.js +0 -4860
  1019. package/dist/subagent-registry-CoclNL5c.js +0 -4858
  1020. package/dist/subsystem-COd61u0P.js +0 -1139
  1021. package/dist/subsystem-D9ZpRKFP.js +0 -1079
  1022. package/dist/system-cli-C__5QOMX.js +0 -70
  1023. package/dist/system-cli-Dr4XoVTq.js +0 -75
  1024. package/dist/systemd-DSnlM3jX.js +0 -547
  1025. package/dist/systemd-TfK8GuTx.js +0 -547
  1026. package/dist/systemd-linger-Axnc1xCb.js +0 -75
  1027. package/dist/systemd-linger-_0_-RY4v.js +0 -75
  1028. package/dist/table-DPTzZyhu.js +0 -279
  1029. package/dist/tables-BQ-CvUfT.js +0 -55
  1030. package/dist/tables-D3a9iSU1.js +0 -55
  1031. package/dist/tables-D3zdgEuK.js +0 -55
  1032. package/dist/tailnet-CEudzG0i.js +0 -40
  1033. package/dist/tailnet-PnMrjwGT.js +0 -40
  1034. package/dist/tailscale-DTATQxAG.js +0 -230
  1035. package/dist/tailscale-Dbyahx0J.js +0 -230
  1036. package/dist/targets-B_0Y1i-1.js +0 -2173
  1037. package/dist/targets-CMhBAn87.js +0 -120
  1038. package/dist/targets-CTmhieRB.js +0 -650
  1039. package/dist/targets-CcTME3bp.js +0 -46
  1040. package/dist/targets-DfaVEd_u.js +0 -220
  1041. package/dist/targets-DtiQgjEL.js +0 -2172
  1042. package/dist/targets-DyybKefq.js +0 -53
  1043. package/dist/targets-rDolm5YS.js +0 -650
  1044. package/dist/tokens-DzFOtLlW.js +0 -21
  1045. package/dist/tool-display-Br6mwaJc.js +0 -785
  1046. package/dist/tool-display-sgNwLOBj.js +0 -785
  1047. package/dist/tool-images-BNfIJ_Kj.js +0 -263
  1048. package/dist/tool-images-kloBqxqK.js +0 -263
  1049. package/dist/trash-DPi0aCCQ.js +0 -125
  1050. package/dist/trash-D_Jd_yQZ.js +0 -125
  1051. package/dist/tui-BSDCI2hh.js +0 -3392
  1052. package/dist/tui-DT7hLOBk.js +0 -3392
  1053. package/dist/tui-cli-DUWvLaoG.js +0 -58
  1054. package/dist/tui-cli-Dn2iXQTO.js +0 -63
  1055. package/dist/update-Bgl3Pk2N.js +0 -349
  1056. package/dist/update-CFPFib4P.js +0 -349
  1057. package/dist/update-cli-DSDSQ2Xi.js +0 -1373
  1058. package/dist/update-cli-DYR_7NLy.js +0 -1370
  1059. package/dist/usage-CS1zeIan.js +0 -5279
  1060. package/dist/utils-LBKvDoPx.js +0 -631
  1061. package/dist/web-BECD5Akw.js +0 -70
  1062. package/dist/web-D4oENnAL.js +0 -3065
  1063. package/dist/web-KP-TI2sO.js +0 -76
  1064. package/dist/webhooks-cli-BqoG_i-D.js +0 -328
  1065. package/dist/webhooks-cli-Ddu7dfdE.js +0 -333
  1066. package/dist/whatsapp-actions-BZLIjQ8J.js +0 -122
  1067. package/dist/whatsapp-actions-KCc1vHN5.js +0 -128
  1068. package/dist/widearea-dns-DSoaA-eH.js +0 -127
  1069. package/dist/workspace-4EaHHEWi.js +0 -447
  1070. package/dist/workspace-B_1t_yq3.js +0 -449
  1071. /package/dist/{account-lookup-0KDSp5Mj.js → account-lookup-C0ndrpt-.js} +0 -0
  1072. /package/dist/{account-lookup-zvANGr2x.js → account-lookup-CIY_RKhi.js} +0 -0
  1073. /package/dist/{api-BeQMq2iS.js → api-BE4ZCWWB.js} +0 -0
  1074. /package/dist/{api-CxX8-gGz.js → api-wsk9zRVi.js} +0 -0
  1075. /package/dist/{argv-Co-b9Zsc.js → argv-BY8EVMTP.js} +0 -0
  1076. /package/dist/{brew-DbSbN8sD.js → brew-CmTYeZk1.js} +0 -0
  1077. /package/dist/{brew-C4zKZsHX.js → brew-V4lMBeE3.js} +0 -0
  1078. /package/dist/{chat-type-CYPyHAj-.js → chat-type-BP9akbag.js} +0 -0
  1079. /package/dist/{chat-type-DKb2TlGZ.js → chat-type-CH3W-zKy.js} +0 -0
  1080. /package/dist/{cleanup-utils-CwQvD73q.js → cleanup-utils-ZC2zvntc.js} +0 -0
  1081. /package/dist/{cli-name-BicfmwQX.js → cli-name-BZsYSp9l.js} +0 -0
  1082. /package/dist/{cli-name-C6rJGl18.js → cli-name-CRe5Ow_t.js} +0 -0
  1083. /package/dist/{cli-utils-BhXbz2UF.js → cli-utils-BUOtyfnU.js} +0 -0
  1084. /package/dist/{cli-utils-DZe_rVkZ.js → cli-utils-CGB3cBZm.js} +0 -0
  1085. /package/dist/{client-C61M8zI3.js → client-9dK56xly.js} +0 -0
  1086. /package/dist/{client-DdpmATKq.js → client-D-R1YdRD.js} +0 -0
  1087. /package/dist/{command-options-C4paWSGf.js → command-options-CnHA4TzR.js} +0 -0
  1088. /package/dist/{command-options-CA30lfLK.js → command-options-D2nN4AXX.js} +0 -0
  1089. /package/dist/{config-eval-CjGZtLwx.js → config-eval-BQIR-wSg.js} +0 -0
  1090. /package/dist/{config-eval-H_wlEYIG.js → config-eval-Bh82JoXK.js} +0 -0
  1091. /package/dist/{constants-ChptG3d7.js → constants-C7j1VA2S.js} +0 -0
  1092. /package/dist/{constants-DY6b-_Wl.js → constants-DoYLsBmv.js} +0 -0
  1093. /package/dist/{credentials-BHWUBHMd.js → credentials-C_RoJFmK.js} +0 -0
  1094. /package/dist/{credentials-DFsi1_e8.js → credentials-DM_Dj0m8.js} +0 -0
  1095. /package/dist/{daemon-runtime-CMnbwryP.js → daemon-runtime-9oDBR7YW.js} +0 -0
  1096. /package/dist/{daemon-runtime-CvqE4ysg.js → daemon-runtime-CzFI2dPw.js} +0 -0
  1097. /package/dist/{dangerous-name-matching-BzmiLXmA.js → dangerous-name-matching-BlTBBZns.js} +0 -0
  1098. /package/dist/{dangerous-name-matching-DaVRgwer.js → dangerous-name-matching-CSq9sJDG.js} +0 -0
  1099. /package/dist/{dangerous-tools-BOLoCRv4.js → dangerous-tools-BRmbBvRf.js} +0 -0
  1100. /package/dist/{dangerous-tools-Baq7Q-i6.js → dangerous-tools-D4jtl72G.js} +0 -0
  1101. /package/dist/{fetch-timeout-DTIN7CGM.js → fetch-timeout-CytN1wiO.js} +0 -0
  1102. /package/dist/{fetch-timeout-DoySHqfO.js → fetch-timeout-DBRRPNBi.js} +0 -0
  1103. /package/dist/{file-identity-BxlKD8Ys.js → file-identity-CeRK5CJC.js} +0 -0
  1104. /package/dist/{format-duration-CqUERz51.js → format-duration-B-Uv5nOi.js} +0 -0
  1105. /package/dist/{format-duration-Ct-yiwkS.js → format-duration-D1M3Zxu6.js} +0 -0
  1106. /package/dist/{format-relative-79_Y1n2Y.js → format-relative-Czf5fUjn.js} +0 -0
  1107. /package/dist/{format-relative-CxLpEQOX.js → format-relative-zwkkXJvs.js} +0 -0
  1108. /package/dist/{health-format-B_QRD8Si.js → health-format-DF54wvUU.js} +0 -0
  1109. /package/dist/{heartbeat-wake-LGEgcXjs.js → heartbeat-wake-CvHncCjP.js} +0 -0
  1110. /package/dist/{heartbeat-wake-Y97geucO.js → heartbeat-wake-DLxQm6-U.js} +0 -0
  1111. /package/dist/{help-format-NNm_Ov4H.js → help-format-CJQ7APRn.js} +0 -0
  1112. /package/dist/{helpers-BAsMXprO.js → helpers-BER76F_2.js} +0 -0
  1113. /package/dist/{helpers-DLgbkcEn.js → helpers-n2CtWpm9.js} +0 -0
  1114. /package/dist/{input-provenance-Bn6thJNm.js → input-provenance-gIfDn1ki.js} +0 -0
  1115. /package/dist/{input-provenance-xUsSMOsz.js → input-provenance-wkso1o5V.js} +0 -0
  1116. /package/dist/{ip-C9q3Oq20.js → ip-D4VG5EJO.js} +0 -0
  1117. /package/dist/{ip-D0zgNmBV.js → ip-MwCwRA7c.js} +0 -0
  1118. /package/dist/{is-main-DN8-sNR5.js → is-main-BmHYGRhd.js} +0 -0
  1119. /package/dist/{json-file-B7l5-Xhr.js → json-file-BW22hGtf.js} +0 -0
  1120. /package/dist/{json-file-ChO_R9yh.js → json-file-DwRAfAAy.js} +0 -0
  1121. /package/dist/{json-files-CmpYSF4G.js → json-files-Dy52honG.js} +0 -0
  1122. /package/dist/{lanes-ByWMUgrz.js → lanes-1CBKdsiR.js} +0 -0
  1123. /package/dist/{lanes-cHJ5arWg.js → lanes-DqVYfPRG.js} +0 -0
  1124. /package/dist/{links-Bz4V7R_p.js → links-CwTlzaPe.js} +0 -0
  1125. /package/dist/{location-DBWCGNLq.js → location-50gaJF5Z.js} +0 -0
  1126. /package/dist/{location-GbZ0bBRU.js → location-Qo8Ii1zo.js} +0 -0
  1127. /package/dist/{logger-DyL5G2DO.js → logger-B8BE0PyS.js} +0 -0
  1128. /package/dist/{logger-BWMPnILd.js → logger-CPvz-aPM.js} +0 -0
  1129. /package/dist/{logger-GvipVDfh.js → logger-cL0D2DCr.js} +0 -0
  1130. /package/dist/{logging-D8-Kozjc.js → logging-DTEoeoa3.js} +0 -0
  1131. /package/dist/{mutable-allowlist-detectors-DiZDtmlZ.js → mutable-allowlist-detectors-BXE7Hr7F.js} +0 -0
  1132. /package/dist/{mutable-allowlist-detectors-U5ThQr9V.js → mutable-allowlist-detectors-CtKavajp.js} +0 -0
  1133. /package/dist/{parse-log-line-enq8pduH.js → parse-log-line-GisaZn5H.js} +0 -0
  1134. /package/dist/{parse-log-line-mz9TG6ig.js → parse-log-line-ZsbwG_u7.js} +0 -0
  1135. /package/dist/{parse-timeout-BMP8a0_a.js → parse-timeout-BpphuwYl.js} +0 -0
  1136. /package/dist/{parse-timeout-CDkco8kd.js → parse-timeout-CE6BjmGU.js} +0 -0
  1137. /package/dist/plugin-sdk/{agents → auth}/api-key-rotation.d.ts +0 -0
  1138. /package/dist/plugin-sdk/{media-understanding → stt}/providers/deepgram/audio.d.ts +0 -0
  1139. /package/dist/plugin-sdk/{media-understanding → stt}/providers/google/audio.d.ts +0 -0
  1140. /package/dist/plugin-sdk/{media-understanding → stt}/providers/google/inline-data.d.ts +0 -0
  1141. /package/dist/plugin-sdk/{media-understanding → stt}/providers/openai/audio.d.ts +0 -0
  1142. /package/dist/plugin-sdk/{media-understanding → stt}/providers/shared.d.ts +0 -0
  1143. /package/dist/{plugins-allowlist-BbTQ5Z2k.js → plugins-allowlist-A38nxBRG.js} +0 -0
  1144. /package/dist/{plugins-allowlist-C20oaESO.js → plugins-allowlist-D2tS9tcu.js} +0 -0
  1145. /package/dist/{polls-B0CCBDeR.js → polls-BLyT08ZI.js} +0 -0
  1146. /package/dist/{polls-CwwHzYBM.js → polls-BmymsJEe.js} +0 -0
  1147. /package/dist/{ports-lsof-Wteul3ju.js → ports-lsof-CDyv5GJd.js} +0 -0
  1148. /package/dist/{process-scoped-map-CV9kDvfG.js → process-scoped-map-BCJR56ZB.js} +0 -0
  1149. /package/dist/{process-scoped-map-PEvnG75N.js → process-scoped-map-Cb1EHPyN.js} +0 -0
  1150. /package/dist/{program-context-jqeI5alP.js → program-context-DlXnmuB7.js} +0 -0
  1151. /package/dist/{progress-C1kUfYL-.js → progress-DRLmcFiG.js} +0 -0
  1152. /package/dist/{prompt-Yn2yClg1.js → prompt-BRGfic91.js} +0 -0
  1153. /package/dist/{prompt-style-DjEYC_s-.js → prompt-style-CUuA6OCy.js} +0 -0
  1154. /package/dist/{provider-utils-3JTMJroG.js → provider-utils-C9kBVF1f.js} +0 -0
  1155. /package/dist/{provider-utils-FaBmofiq.js → provider-utils-DiLhkKQp.js} +0 -0
  1156. /package/dist/{proxy-DL3MD6-P.js → proxy-BMJL0Qog.js} +0 -0
  1157. /package/dist/{proxy-DpNv2cSV.js → proxy-D-qGA1vm.js} +0 -0
  1158. /package/dist/{pw-ai-state-CGfLv6nV.js → pw-ai-state--TxTVwRW.js} +0 -0
  1159. /package/dist/{pw-ai-state-Dynx20hr.js → pw-ai-state-CwXeO5d0.js} +0 -0
  1160. /package/dist/{redact-Dx1Fue21.js → redact-BW8tobyp.js} +0 -0
  1161. /package/dist/{redact-identifier-BTIWtaa-.js → redact-identifier-BJOQDEj0.js} +0 -0
  1162. /package/dist/{redact-identifier-CAagcfWA.js → redact-identifier-Bv5SUUw-.js} +0 -0
  1163. /package/dist/{remoteclaw-root-C2HV2VeC.js → remoteclaw-root-BfPjgewe.js} +0 -0
  1164. /package/dist/{remoteclaw-root-DybYl8PL.js → remoteclaw-root-E4-hmb4E.js} +0 -0
  1165. /package/dist/{render-CCLsW6Lz.js → render-BhKzKdV0.js} +0 -0
  1166. /package/dist/{render-uf6PvGMV.js → render-e7fENCYH.js} +0 -0
  1167. /package/dist/{retry-DnqPAqWp.js → retry-BWv_fy4u.js} +0 -0
  1168. /package/dist/{runtime-guard-U-ewY_QH.js → runtime-guard-Bhx-pb8_.js} +0 -0
  1169. /package/dist/{secret-equal-BbHdTtqY.js → secret-equal-D6AoXne1.js} +0 -0
  1170. /package/dist/{secret-equal-CXJEZiWb.js → secret-equal-DLnUuWM3.js} +0 -0
  1171. /package/dist/{secure-random-CS2mSdTn.js → secure-random-CJtykx_p.js} +0 -0
  1172. /package/dist/{secure-random-_dzDDlFo.js → secure-random-CRVHgtmO.js} +0 -0
  1173. /package/dist/{session-key-5YLnn_qf.js → session-key-BF-9YzxC.js} +0 -0
  1174. /package/dist/{session-key-C2n-VILA.js → session-key-CgKWfjoZ.js} +0 -0
  1175. /package/dist/{stagger-BXv_apuy.js → stagger--wvODnNe.js} +0 -0
  1176. /package/dist/{stagger-MI9gd2rQ.js → stagger-BLmTO4cK.js} +0 -0
  1177. /package/dist/{status-BmtCS3T1.js → status-1zVD-Clq.js} +0 -0
  1178. /package/dist/{status-BrwHRn2B.js → status-BtRY0nXQ.js} +0 -0
  1179. /package/dist/{strip-inbound-meta-DjKcSFaW.js → strip-inbound-meta-zmUXypSS.js} +0 -0
  1180. /package/dist/{strip-inbound-meta-jy3bkUab.js → strip-inbound-meta-zqtN9FTK.js} +0 -0
  1181. /package/dist/{table-C1rdyYl9.js → table-On3hkCqi.js} +0 -0
  1182. /package/dist/{target-errors-BDpPcwh5.js → target-errors-DJVRKFcU.js} +0 -0
  1183. /package/dist/{target-errors-DdIAPcMM.js → target-errors-GZXDqlUu.js} +0 -0
  1184. /package/dist/{targets-C-2xwh9f.js → targets-B46m7u5J.js} +0 -0
  1185. /package/dist/{targets-D-qLBpTA.js → targets-B_d_1z3N.js} +0 -0
  1186. /package/dist/{targets-UncQvCVs.js → targets-D01MJGnh.js} +0 -0
  1187. /package/dist/{targets-BMenhVHg.js → targets-D3r6Zgic.js} +0 -0
  1188. /package/dist/{text-format-BQ3z_OXA.js → text-format-DarxU3JH.js} +0 -0
  1189. /package/dist/{text-format-oWqzVmah.js → text-format-Ds92M9UT.js} +0 -0
  1190. /package/dist/{tokens-B-jmvNR9.js → tokens-Dw7ZdYwT.js} +0 -0
  1191. /package/dist/{usage-BdhBT0Vz.js → usage-BIzKZ5dT.js} +0 -0
  1192. /package/dist/{usage-BtQcAnf6.js → usage-BvZOzIC7.js} +0 -0
  1193. /package/dist/{usage-format-C3mNLfhI.js → usage-format-CmniSPCG.js} +0 -0
  1194. /package/dist/{usage-format-DAaPzr_z.js → usage-format-D_KQYQ-w.js} +0 -0
  1195. /package/dist/{widearea-dns-CsmBVbez.js → widearea-dns-D01FFYZ8.js} +0 -0
  1196. /package/dist/{workspace-BzPeZDew.js → workspace-BJCKO8Ns.js} +0 -0
  1197. /package/dist/{workspace-DkGLVfOl.js → workspace-BisvA9oA.js} +0 -0
  1198. /package/dist/{wsl-B_sPlzWw.js → wsl-PDLKeX04.js} +0 -0
  1199. /package/dist/{wsl-BCnYV9O0.js → wsl-kFaeW76c.js} +0 -0
@@ -1,3392 +0,0 @@
1
- import { h as visibleWidth, m as stripAnsi$1 } from "./entry.js";
2
- import { C as parseAgentSessionKey, c as normalizeMainKey, r as buildAgentMainSessionKey, s as normalizeAgentId } from "./session-key-C2n-VILA.js";
3
- import { i as loadConfig } from "./config-CwtWvygh.js";
4
- import { r as VERSION } from "./env-vars-7aZqKPhk.js";
5
- import { o as resolveDefaultAgentId } from "./agent-scope-BqPmD-Ax.js";
6
- import { f as GATEWAY_CLIENT_MODES, p as GATEWAY_CLIENT_NAMES, u as GATEWAY_CLIENT_CAPS } from "./message-channel-uWMAiywE.js";
7
- import { n as stripLeadingInboundMetadata } from "./strip-inbound-meta-DjKcSFaW.js";
8
- import { At as PROTOCOL_VERSION, f as GatewayClient, i as ensureExplicitGatewayAuth, o as resolveExplicitGatewayAuth, t as buildGatewayConnectionDetails } from "./call-CZHVeMf1.js";
9
- import { f as formatRawAssistantErrorForUi, l as resolveResponseUsageMode, r as listThinkingLevelLabels, s as normalizeUsageDisplay, t as formatThinkingLevels } from "./agent-helpers-CTx5KKJu.js";
10
- import { n as resolveToolDisplay, t as formatToolDetail } from "./tool-display-Br6mwaJc.js";
11
- import { a as listChatCommandsForConfig, i as listChatCommands } from "./commands-registry-Cr6SIR3n.js";
12
- import { n as formatTimeAgo, t as formatRelativeTimestamp } from "./format-relative-CxLpEQOX.js";
13
- import { n as formatTokenCount } from "./usage-format-C3mNLfhI.js";
14
- import { spawn } from "node:child_process";
15
- import chalk from "chalk";
16
- import { randomUUID } from "node:crypto";
17
- import { Box, CombinedAutocompleteProvider, Container, Editor, Input, Key, Loader, Markdown, ProcessTerminal, SelectList, SettingsList, Spacer, TUI, Text, getEditorKeybindings, isKeyRelease, matchesKey, truncateToWidth } from "@mariozechner/pi-tui";
18
- import { highlight, supportsLanguage } from "cli-highlight";
19
-
20
- //#region src/tui/commands.ts
21
- const VERBOSE_LEVELS = ["on", "off"];
22
- const REASONING_LEVELS = ["on", "off"];
23
- const ELEVATED_LEVELS = [
24
- "on",
25
- "off",
26
- "ask",
27
- "full"
28
- ];
29
- const ACTIVATION_LEVELS = ["mention", "always"];
30
- const USAGE_FOOTER_LEVELS = [
31
- "off",
32
- "tokens",
33
- "full"
34
- ];
35
- const COMMAND_ALIASES = { elev: "elevated" };
36
- function createLevelCompletion(levels) {
37
- return (prefix) => levels.filter((value) => value.startsWith(prefix.toLowerCase())).map((value) => ({
38
- value,
39
- label: value
40
- }));
41
- }
42
- function parseCommand(input) {
43
- const trimmed = input.replace(/^\//, "").trim();
44
- if (!trimmed) return {
45
- name: "",
46
- args: ""
47
- };
48
- const [name, ...rest] = trimmed.split(/\s+/);
49
- const normalized = name.toLowerCase();
50
- return {
51
- name: COMMAND_ALIASES[normalized] ?? normalized,
52
- args: rest.join(" ").trim()
53
- };
54
- }
55
- function getSlashCommands(options = {}) {
56
- const thinkLevels = listThinkingLevelLabels(options.provider, options.model);
57
- const verboseCompletions = createLevelCompletion(VERBOSE_LEVELS);
58
- const reasoningCompletions = createLevelCompletion(REASONING_LEVELS);
59
- const usageCompletions = createLevelCompletion(USAGE_FOOTER_LEVELS);
60
- const elevatedCompletions = createLevelCompletion(ELEVATED_LEVELS);
61
- const activationCompletions = createLevelCompletion(ACTIVATION_LEVELS);
62
- const commands = [
63
- {
64
- name: "help",
65
- description: "Show slash command help"
66
- },
67
- {
68
- name: "status",
69
- description: "Show gateway status summary"
70
- },
71
- {
72
- name: "agent",
73
- description: "Switch agent (or open picker)"
74
- },
75
- {
76
- name: "agents",
77
- description: "Open agent picker"
78
- },
79
- {
80
- name: "session",
81
- description: "Switch session (or open picker)"
82
- },
83
- {
84
- name: "sessions",
85
- description: "Open session picker"
86
- },
87
- {
88
- name: "model",
89
- description: "Set model (or open picker)"
90
- },
91
- {
92
- name: "models",
93
- description: "Open model picker"
94
- },
95
- {
96
- name: "think",
97
- description: "Set thinking level",
98
- getArgumentCompletions: (prefix) => thinkLevels.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
99
- value,
100
- label: value
101
- }))
102
- },
103
- {
104
- name: "verbose",
105
- description: "Set verbose on/off",
106
- getArgumentCompletions: verboseCompletions
107
- },
108
- {
109
- name: "reasoning",
110
- description: "Set reasoning on/off",
111
- getArgumentCompletions: reasoningCompletions
112
- },
113
- {
114
- name: "usage",
115
- description: "Toggle per-response usage line",
116
- getArgumentCompletions: usageCompletions
117
- },
118
- {
119
- name: "elevated",
120
- description: "Set elevated on/off/ask/full",
121
- getArgumentCompletions: elevatedCompletions
122
- },
123
- {
124
- name: "elev",
125
- description: "Alias for /elevated",
126
- getArgumentCompletions: elevatedCompletions
127
- },
128
- {
129
- name: "activation",
130
- description: "Set group activation",
131
- getArgumentCompletions: activationCompletions
132
- },
133
- {
134
- name: "abort",
135
- description: "Abort active run"
136
- },
137
- {
138
- name: "new",
139
- description: "Reset the session"
140
- },
141
- {
142
- name: "reset",
143
- description: "Reset the session"
144
- },
145
- {
146
- name: "settings",
147
- description: "Open settings"
148
- },
149
- {
150
- name: "exit",
151
- description: "Exit the TUI"
152
- },
153
- {
154
- name: "quit",
155
- description: "Exit the TUI"
156
- }
157
- ];
158
- const seen = new Set(commands.map((command) => command.name));
159
- const gatewayCommands = options.cfg ? listChatCommandsForConfig(options.cfg) : listChatCommands();
160
- for (const command of gatewayCommands) {
161
- const aliases = command.textAliases.length > 0 ? command.textAliases : [`/${command.key}`];
162
- for (const alias of aliases) {
163
- const name = alias.replace(/^\//, "").trim();
164
- if (!name || seen.has(name)) continue;
165
- seen.add(name);
166
- commands.push({
167
- name,
168
- description: command.description
169
- });
170
- }
171
- }
172
- return commands;
173
- }
174
- function helpText(options = {}) {
175
- return [
176
- "Slash commands:",
177
- "/help",
178
- "/commands",
179
- "/status",
180
- "/agent <id> (or /agents)",
181
- "/session <key> (or /sessions)",
182
- "/model <provider/model> (or /models)",
183
- `/think <${formatThinkingLevels(options.provider, options.model, "|")}>`,
184
- "/verbose <on|off>",
185
- "/reasoning <on|off>",
186
- "/usage <off|tokens|full>",
187
- "/elevated <on|off|ask|full>",
188
- "/elev <on|off|ask|full>",
189
- "/activation <mention|always>",
190
- "/new or /reset",
191
- "/abort",
192
- "/settings",
193
- "/exit"
194
- ].join("\n");
195
- }
196
-
197
- //#endregion
198
- //#region src/tui/theme/syntax-theme.ts
199
- /**
200
- * Syntax highlighting theme for code blocks.
201
- * Uses chalk functions to style different token types.
202
- */
203
- function createSyntaxTheme(fallback) {
204
- return {
205
- keyword: chalk.hex("#C586C0"),
206
- built_in: chalk.hex("#4EC9B0"),
207
- type: chalk.hex("#4EC9B0"),
208
- literal: chalk.hex("#569CD6"),
209
- number: chalk.hex("#B5CEA8"),
210
- string: chalk.hex("#CE9178"),
211
- regexp: chalk.hex("#D16969"),
212
- symbol: chalk.hex("#B5CEA8"),
213
- class: chalk.hex("#4EC9B0"),
214
- function: chalk.hex("#DCDCAA"),
215
- title: chalk.hex("#DCDCAA"),
216
- params: chalk.hex("#9CDCFE"),
217
- comment: chalk.hex("#6A9955"),
218
- doctag: chalk.hex("#608B4E"),
219
- meta: chalk.hex("#9CDCFE"),
220
- "meta-keyword": chalk.hex("#C586C0"),
221
- "meta-string": chalk.hex("#CE9178"),
222
- section: chalk.hex("#DCDCAA"),
223
- tag: chalk.hex("#569CD6"),
224
- name: chalk.hex("#9CDCFE"),
225
- attr: chalk.hex("#9CDCFE"),
226
- attribute: chalk.hex("#9CDCFE"),
227
- variable: chalk.hex("#9CDCFE"),
228
- bullet: chalk.hex("#D7BA7D"),
229
- code: chalk.hex("#CE9178"),
230
- emphasis: chalk.italic,
231
- strong: chalk.bold,
232
- formula: chalk.hex("#C586C0"),
233
- link: chalk.hex("#4EC9B0"),
234
- quote: chalk.hex("#6A9955"),
235
- addition: chalk.hex("#B5CEA8"),
236
- deletion: chalk.hex("#F44747"),
237
- "selector-tag": chalk.hex("#D7BA7D"),
238
- "selector-id": chalk.hex("#D7BA7D"),
239
- "selector-class": chalk.hex("#D7BA7D"),
240
- "selector-attr": chalk.hex("#D7BA7D"),
241
- "selector-pseudo": chalk.hex("#D7BA7D"),
242
- "template-tag": chalk.hex("#C586C0"),
243
- "template-variable": chalk.hex("#9CDCFE"),
244
- default: fallback
245
- };
246
- }
247
-
248
- //#endregion
249
- //#region src/tui/theme/theme.ts
250
- const palette = {
251
- text: "#E8E3D5",
252
- dim: "#7B7F87",
253
- accent: "#F6C453",
254
- accentSoft: "#F2A65A",
255
- border: "#3C414B",
256
- userBg: "#2B2F36",
257
- userText: "#F3EEE0",
258
- systemText: "#9BA3B2",
259
- toolPendingBg: "#1F2A2F",
260
- toolSuccessBg: "#1E2D23",
261
- toolErrorBg: "#2F1F1F",
262
- toolTitle: "#F6C453",
263
- toolOutput: "#E1DACB",
264
- quote: "#8CC8FF",
265
- quoteBorder: "#3B4D6B",
266
- code: "#F0C987",
267
- codeBlock: "#1E232A",
268
- codeBorder: "#343A45",
269
- link: "#7DD3A5",
270
- error: "#F97066",
271
- success: "#7DD3A5"
272
- };
273
- const fg = (hex) => (text) => chalk.hex(hex)(text);
274
- const bg = (hex) => (text) => chalk.bgHex(hex)(text);
275
- const syntaxTheme = createSyntaxTheme(fg(palette.code));
276
- /**
277
- * Highlight code with syntax coloring.
278
- * Returns an array of lines with ANSI escape codes.
279
- */
280
- function highlightCode(code, lang) {
281
- try {
282
- return highlight(code, {
283
- language: lang && supportsLanguage(lang) ? lang : void 0,
284
- theme: syntaxTheme,
285
- ignoreIllegals: true
286
- }).split("\n");
287
- } catch {
288
- return code.split("\n").map((line) => fg(palette.code)(line));
289
- }
290
- }
291
- const theme = {
292
- fg: fg(palette.text),
293
- assistantText: (text) => text,
294
- dim: fg(palette.dim),
295
- accent: fg(palette.accent),
296
- accentSoft: fg(palette.accentSoft),
297
- success: fg(palette.success),
298
- error: fg(palette.error),
299
- header: (text) => chalk.bold(fg(palette.accent)(text)),
300
- system: fg(palette.systemText),
301
- userBg: bg(palette.userBg),
302
- userText: fg(palette.userText),
303
- toolTitle: fg(palette.toolTitle),
304
- toolOutput: fg(palette.toolOutput),
305
- toolPendingBg: bg(palette.toolPendingBg),
306
- toolSuccessBg: bg(palette.toolSuccessBg),
307
- toolErrorBg: bg(palette.toolErrorBg),
308
- border: fg(palette.border),
309
- bold: (text) => chalk.bold(text),
310
- italic: (text) => chalk.italic(text)
311
- };
312
- const markdownTheme = {
313
- heading: (text) => chalk.bold(fg(palette.accent)(text)),
314
- link: (text) => fg(palette.link)(text),
315
- linkUrl: (text) => chalk.dim(text),
316
- code: (text) => fg(palette.code)(text),
317
- codeBlock: (text) => fg(palette.code)(text),
318
- codeBlockBorder: (text) => fg(palette.codeBorder)(text),
319
- quote: (text) => fg(palette.quote)(text),
320
- quoteBorder: (text) => fg(palette.quoteBorder)(text),
321
- hr: (text) => fg(palette.border)(text),
322
- listBullet: (text) => fg(palette.accentSoft)(text),
323
- bold: (text) => chalk.bold(text),
324
- italic: (text) => chalk.italic(text),
325
- strikethrough: (text) => chalk.strikethrough(text),
326
- underline: (text) => chalk.underline(text),
327
- highlightCode
328
- };
329
- const baseSelectListTheme = {
330
- selectedPrefix: (text) => fg(palette.accent)(text),
331
- selectedText: (text) => chalk.bold(fg(palette.accent)(text)),
332
- description: (text) => fg(palette.dim)(text),
333
- scrollInfo: (text) => fg(palette.dim)(text),
334
- noMatch: (text) => fg(palette.dim)(text)
335
- };
336
- const selectListTheme = baseSelectListTheme;
337
- const filterableSelectListTheme = {
338
- ...baseSelectListTheme,
339
- filterLabel: (text) => fg(palette.dim)(text)
340
- };
341
- const settingsListTheme = {
342
- label: (text, selected) => selected ? chalk.bold(fg(palette.accent)(text)) : fg(palette.text)(text),
343
- value: (text, selected) => selected ? fg(palette.accentSoft)(text) : fg(palette.dim)(text),
344
- description: (text) => fg(palette.systemText)(text),
345
- cursor: fg(palette.accent)("→ "),
346
- hint: (text) => fg(palette.dim)(text)
347
- };
348
- const editorTheme = {
349
- borderColor: (text) => fg(palette.border)(text),
350
- selectList: selectListTheme
351
- };
352
- const searchableSelectListTheme = {
353
- ...baseSelectListTheme,
354
- searchPrompt: (text) => fg(palette.accentSoft)(text),
355
- searchInput: (text) => fg(palette.text)(text),
356
- matchHighlight: (text) => chalk.bold(fg(palette.accent)(text))
357
- };
358
-
359
- //#endregion
360
- //#region src/tui/osc8-hyperlinks.ts
361
- const SGR_PATTERN = "\\x1b\\[[0-9;]*m";
362
- const OSC8_PATTERN = "\\x1b\\]8;;.*?(?:\\x07|\\x1b\\\\)";
363
- const ANSI_RE = new RegExp(`${SGR_PATTERN}|${OSC8_PATTERN}`, "g");
364
- const SGR_START_RE = new RegExp(`^${SGR_PATTERN}`);
365
- const OSC8_START_RE = new RegExp(`^${OSC8_PATTERN}`);
366
- /**
367
- * Extract all unique URLs from raw markdown text.
368
- * Finds both bare URLs and markdown link hrefs [text](url).
369
- */
370
- function extractUrls(markdown) {
371
- const urls = /* @__PURE__ */ new Set();
372
- const mdLinkRe = /\[(?:[^\]]*)\]\(\s*<?(https?:\/\/[^)\s>]+)>?(?:\s+["'][^"']*["'])?\s*\)/g;
373
- let m;
374
- while ((m = mdLinkRe.exec(markdown)) !== null) urls.add(m[1]);
375
- const stripped = markdown.replace(/\[(?:[^\]]*)\]\(\s*<?https?:\/\/[^)\s>]+>?(?:\s+["'][^"']*["'])?\s*\)/g, "");
376
- const bareRe = /https?:\/\/[^\s)\]>]+/g;
377
- while ((m = bareRe.exec(stripped)) !== null) urls.add(m[0]);
378
- return [...urls];
379
- }
380
- /** Strip ANSI SGR and OSC 8 sequences to get visible text. */
381
- function stripAnsi(input) {
382
- return input.replace(ANSI_RE, "");
383
- }
384
- /**
385
- * Find URL ranges in a line's visible text, handling cross-line URL splits.
386
- */
387
- function findUrlRanges(visibleText, knownUrls, pending) {
388
- const ranges = [];
389
- let newPending = null;
390
- let searchFrom = 0;
391
- if (pending) {
392
- const remaining = pending.url.slice(pending.consumed);
393
- const trimmed = visibleText.trimStart();
394
- const leadingSpaces = visibleText.length - trimmed.length;
395
- let matchLen = 0;
396
- for (let j = 0; j < remaining.length && j < trimmed.length; j++) if (remaining[j] === trimmed[j]) matchLen++;
397
- else break;
398
- if (matchLen > 0) {
399
- ranges.push({
400
- start: leadingSpaces,
401
- end: leadingSpaces + matchLen,
402
- url: pending.url
403
- });
404
- searchFrom = leadingSpaces + matchLen;
405
- if (pending.consumed + matchLen < pending.url.length) newPending = {
406
- url: pending.url,
407
- consumed: pending.consumed + matchLen
408
- };
409
- }
410
- }
411
- const urlRe = /https?:\/\/[^\s)\]>]+/g;
412
- urlRe.lastIndex = searchFrom;
413
- let match;
414
- while ((match = urlRe.exec(visibleText)) !== null) {
415
- const fragment = match[0];
416
- const start = match.index;
417
- let resolvedUrl = fragment;
418
- let found = false;
419
- for (const known of knownUrls) if (known === fragment) {
420
- resolvedUrl = known;
421
- found = true;
422
- break;
423
- }
424
- if (!found) {
425
- let bestLen = 0;
426
- for (const known of knownUrls) if (known.startsWith(fragment) && known.length > bestLen) {
427
- resolvedUrl = known;
428
- bestLen = known.length;
429
- found = true;
430
- }
431
- }
432
- if (!found) {
433
- let bestLen = 0;
434
- for (const known of knownUrls) if (fragment.startsWith(known) && known.length > bestLen) {
435
- resolvedUrl = known;
436
- bestLen = known.length;
437
- }
438
- }
439
- ranges.push({
440
- start,
441
- end: start + fragment.length,
442
- url: resolvedUrl
443
- });
444
- if (resolvedUrl.length > fragment.length && resolvedUrl.startsWith(fragment)) newPending = {
445
- url: resolvedUrl,
446
- consumed: fragment.length
447
- };
448
- }
449
- return {
450
- ranges,
451
- pending: newPending
452
- };
453
- }
454
- /**
455
- * Apply OSC 8 hyperlink sequences to a line based on visible-text URL ranges.
456
- * Walks through the raw string character by character, inserting OSC 8
457
- * open/close sequences at URL range boundaries while preserving ANSI codes.
458
- */
459
- function applyOsc8Ranges(line, ranges) {
460
- if (ranges.length === 0) return line;
461
- const urlAt = /* @__PURE__ */ new Map();
462
- for (const r of ranges) for (let p = r.start; p < r.end; p++) urlAt.set(p, r.url);
463
- let result = "";
464
- let visiblePos = 0;
465
- let activeUrl = null;
466
- let i = 0;
467
- while (i < line.length) {
468
- if (line.charCodeAt(i) === 27) {
469
- const sgr = line.slice(i).match(SGR_START_RE);
470
- if (sgr) {
471
- result += sgr[0];
472
- i += sgr[0].length;
473
- continue;
474
- }
475
- const osc = line.slice(i).match(OSC8_START_RE);
476
- if (osc) {
477
- result += osc[0];
478
- i += osc[0].length;
479
- continue;
480
- }
481
- }
482
- const targetUrl = urlAt.get(visiblePos) ?? null;
483
- if (targetUrl !== activeUrl) {
484
- if (activeUrl !== null) result += "\x1B]8;;\x07";
485
- if (targetUrl !== null) result += `\x1b]8;;${targetUrl}\x07`;
486
- activeUrl = targetUrl;
487
- }
488
- result += line[i];
489
- visiblePos++;
490
- i++;
491
- }
492
- if (activeUrl !== null) result += "\x1B]8;;\x07";
493
- return result;
494
- }
495
- /**
496
- * Add OSC 8 hyperlinks to rendered lines using a pre-extracted URL list.
497
- *
498
- * For each line, finds URL-like substrings in the visible text, matches them
499
- * against known URLs, and wraps each fragment with OSC 8 escape sequences.
500
- * Handles URLs broken across multiple lines by pi-tui's word wrapping.
501
- */
502
- function addOsc8Hyperlinks(lines, urls) {
503
- if (urls.length === 0) return lines;
504
- let pending = null;
505
- return lines.map((line) => {
506
- const result = findUrlRanges(stripAnsi(line), urls, pending);
507
- pending = result.pending;
508
- return applyOsc8Ranges(line, result.ranges);
509
- });
510
- }
511
-
512
- //#endregion
513
- //#region src/tui/components/hyperlink-markdown.ts
514
- /**
515
- * Wrapper around pi-tui's Markdown component that adds OSC 8 terminal
516
- * hyperlinks to rendered output, making URLs clickable even when broken
517
- * across multiple lines by word wrapping.
518
- */
519
- var HyperlinkMarkdown = class {
520
- constructor(text, paddingX, paddingY, theme, options) {
521
- this.inner = new Markdown(text, paddingX, paddingY, theme, options);
522
- this.urls = extractUrls(text);
523
- }
524
- render(width) {
525
- return addOsc8Hyperlinks(this.inner.render(width), this.urls);
526
- }
527
- setText(text) {
528
- this.inner.setText(text);
529
- this.urls = extractUrls(text);
530
- }
531
- invalidate() {
532
- this.inner.invalidate();
533
- }
534
- };
535
-
536
- //#endregion
537
- //#region src/tui/components/assistant-message.ts
538
- var AssistantMessageComponent = class extends Container {
539
- constructor(text) {
540
- super();
541
- this.body = new HyperlinkMarkdown(text, 1, 0, markdownTheme, { color: (line) => theme.assistantText(line) });
542
- this.addChild(new Spacer(1));
543
- this.addChild(this.body);
544
- }
545
- setText(text) {
546
- this.body.setText(text);
547
- }
548
- };
549
-
550
- //#endregion
551
- //#region src/tui/tui-formatters.ts
552
- const REPLACEMENT_CHAR_RE = /\uFFFD/g;
553
- const MAX_TOKEN_CHARS = 32;
554
- const LONG_TOKEN_RE = /\S{33,}/g;
555
- const LONG_TOKEN_TEST_RE = /\S{33,}/;
556
- const BINARY_LINE_REPLACEMENT_THRESHOLD = 12;
557
- const URL_PREFIX_RE = /^(https?:\/\/|file:\/\/)/i;
558
- const WINDOWS_DRIVE_RE = /^[a-zA-Z]:[\\/]/;
559
- const FILE_LIKE_RE = /^[a-zA-Z0-9._-]+$/;
560
- const RTL_SCRIPT_RE = /[\u0590-\u08ff\ufb1d-\ufdff\ufe70-\ufefc]/;
561
- const BIDI_CONTROL_RE = /[\u202a-\u202e\u2066-\u2069]/;
562
- const RTL_ISOLATE_START = "⁧";
563
- const RTL_ISOLATE_END = "⁩";
564
- function hasControlChars(text) {
565
- for (const char of text) {
566
- const code = char.charCodeAt(0);
567
- if (code <= 31 && code !== 9 && code !== 10 && code !== 13 || code >= 127 && code <= 159) return true;
568
- }
569
- return false;
570
- }
571
- function stripControlChars(text) {
572
- if (!hasControlChars(text)) return text;
573
- let sanitized = "";
574
- for (const char of text) {
575
- const code = char.charCodeAt(0);
576
- if (!(code <= 31 && code !== 9 && code !== 10 && code !== 13) && !(code >= 127 && code <= 159)) sanitized += char;
577
- }
578
- return sanitized;
579
- }
580
- function chunkToken(token, maxChars) {
581
- if (token.length <= maxChars) return [token];
582
- const chunks = [];
583
- for (let i = 0; i < token.length; i += maxChars) chunks.push(token.slice(i, i + maxChars));
584
- return chunks;
585
- }
586
- function isCopySensitiveToken(token) {
587
- if (URL_PREFIX_RE.test(token)) return true;
588
- if (token.startsWith("/") || token.startsWith("~/") || token.startsWith("./") || token.startsWith("../")) return true;
589
- if (WINDOWS_DRIVE_RE.test(token) || token.startsWith("\\\\")) return true;
590
- if (token.includes("/") || token.includes("\\")) return true;
591
- return token.includes("_") && FILE_LIKE_RE.test(token);
592
- }
593
- function normalizeLongTokenForDisplay(token) {
594
- if (isCopySensitiveToken(token)) return token;
595
- return chunkToken(token, MAX_TOKEN_CHARS).join(" ");
596
- }
597
- function redactBinaryLikeLine(line) {
598
- const replacementCount = (line.match(REPLACEMENT_CHAR_RE) || []).length;
599
- if (replacementCount >= BINARY_LINE_REPLACEMENT_THRESHOLD && replacementCount * 2 >= line.length) return "[binary data omitted]";
600
- return line;
601
- }
602
- function isolateRtlLine(line) {
603
- if (!RTL_SCRIPT_RE.test(line) || BIDI_CONTROL_RE.test(line)) return line;
604
- return `${RTL_ISOLATE_START}${line}${RTL_ISOLATE_END}`;
605
- }
606
- function applyRtlIsolation(text) {
607
- if (!RTL_SCRIPT_RE.test(text)) return text;
608
- return text.split("\n").map((line) => isolateRtlLine(line)).join("\n");
609
- }
610
- function sanitizeRenderableText(text) {
611
- if (!text) return text;
612
- const hasAnsi = text.includes("\x1B");
613
- const hasReplacementChars = text.includes("�");
614
- const hasLongTokens = LONG_TOKEN_TEST_RE.test(text);
615
- const hasControls = hasControlChars(text);
616
- if (!hasAnsi && !hasReplacementChars && !hasLongTokens && !hasControls) return applyRtlIsolation(text);
617
- const withoutAnsi = hasAnsi ? stripAnsi$1(text) : text;
618
- const withoutControlChars = hasControls ? stripControlChars(withoutAnsi) : withoutAnsi;
619
- const redacted = hasReplacementChars ? withoutControlChars.split("\n").map((line) => redactBinaryLikeLine(line)).join("\n") : withoutControlChars;
620
- return applyRtlIsolation(LONG_TOKEN_TEST_RE.test(redacted) ? redacted.replace(LONG_TOKEN_RE, normalizeLongTokenForDisplay) : redacted);
621
- }
622
- function resolveFinalAssistantText(params) {
623
- const finalText = params.finalText ?? "";
624
- if (finalText.trim()) return finalText;
625
- const streamedText = params.streamedText ?? "";
626
- if (streamedText.trim()) return streamedText;
627
- return "(no output)";
628
- }
629
- function composeThinkingAndContent(params) {
630
- const thinkingText = params.thinkingText?.trim() ?? "";
631
- const contentText = params.contentText?.trim() ?? "";
632
- const parts = [];
633
- if (params.showThinking && thinkingText) parts.push(`[thinking]\n${thinkingText}`);
634
- if (contentText) parts.push(contentText);
635
- return parts.join("\n\n").trim();
636
- }
637
- function asMessageRecord(message) {
638
- if (!message || typeof message !== "object") return;
639
- return message;
640
- }
641
- function resolveMessageRecord(message) {
642
- const record = asMessageRecord(message);
643
- if (!record) return;
644
- return {
645
- record,
646
- content: record.content
647
- };
648
- }
649
- function formatAssistantErrorFromRecord(record) {
650
- if ((typeof record.stopReason === "string" ? record.stopReason : "") !== "error") return "";
651
- return formatRawAssistantErrorForUi(typeof record.errorMessage === "string" ? record.errorMessage : "");
652
- }
653
- function collectSanitizedBlockStrings(params) {
654
- if (!Array.isArray(params.content)) return [];
655
- const parts = [];
656
- for (const block of params.content) {
657
- if (!block || typeof block !== "object") continue;
658
- const rec = block;
659
- if (rec.type === params.blockType && typeof rec[params.valueKey] === "string") parts.push(sanitizeRenderableText(rec[params.valueKey]));
660
- }
661
- return parts;
662
- }
663
- /**
664
- * Extract ONLY thinking blocks from message content.
665
- * Model-agnostic: returns empty string if no thinking blocks exist.
666
- */
667
- function extractThinkingFromMessage(message) {
668
- const resolved = resolveMessageRecord(message);
669
- if (!resolved) return "";
670
- const { content } = resolved;
671
- if (typeof content === "string") return "";
672
- return collectSanitizedBlockStrings({
673
- content,
674
- blockType: "thinking",
675
- valueKey: "thinking"
676
- }).join("\n").trim();
677
- }
678
- /**
679
- * Extract ONLY text content blocks from message (excludes thinking).
680
- * Model-agnostic: works for any model with text content blocks.
681
- */
682
- function extractContentFromMessage(message) {
683
- const resolved = resolveMessageRecord(message);
684
- if (!resolved) return "";
685
- const { record, content } = resolved;
686
- if (typeof content === "string") return sanitizeRenderableText(content).trim();
687
- const parts = collectSanitizedBlockStrings({
688
- content,
689
- blockType: "text",
690
- valueKey: "text"
691
- });
692
- if (parts.length > 0) return parts.join("\n").trim();
693
- return formatAssistantErrorFromRecord(record);
694
- }
695
- function extractTextBlocks(content, opts) {
696
- if (typeof content === "string") return sanitizeRenderableText(content).trim();
697
- if (!Array.isArray(content)) return "";
698
- const textParts = collectSanitizedBlockStrings({
699
- content,
700
- blockType: "text",
701
- valueKey: "text"
702
- });
703
- return composeThinkingAndContent({
704
- thinkingText: (opts?.includeThinking === true ? collectSanitizedBlockStrings({
705
- content,
706
- blockType: "thinking",
707
- valueKey: "thinking"
708
- }) : []).join("\n").trim(),
709
- contentText: textParts.join("\n").trim(),
710
- showThinking: opts?.includeThinking ?? false
711
- });
712
- }
713
- function extractTextFromMessage(message, opts) {
714
- const record = asMessageRecord(message);
715
- if (!record) return "";
716
- const text = extractTextBlocks(record.content, opts);
717
- if (text) {
718
- if (record.role === "user") return stripLeadingInboundMetadata(text);
719
- return text;
720
- }
721
- const errorText = formatAssistantErrorFromRecord(record);
722
- if (!errorText) return "";
723
- return errorText;
724
- }
725
- function isCommandMessage(message) {
726
- if (!message || typeof message !== "object") return false;
727
- return message.command === true;
728
- }
729
- function formatTokens(total, context) {
730
- if (total == null && context == null) return "tokens ?";
731
- const totalLabel = total == null ? "?" : formatTokenCount(total);
732
- if (context == null) return `tokens ${totalLabel}`;
733
- const pct = typeof total === "number" && context > 0 ? Math.min(999, Math.round(total / context * 100)) : null;
734
- return `tokens ${totalLabel}/${formatTokenCount(context)}${pct !== null ? ` (${pct}%)` : ""}`;
735
- }
736
- function formatContextUsageLine(params) {
737
- const totalLabel = typeof params.total === "number" ? formatTokenCount(params.total) : "?";
738
- const ctxLabel = typeof params.context === "number" ? formatTokenCount(params.context) : "?";
739
- const pct = typeof params.percent === "number" ? Math.min(999, Math.round(params.percent)) : null;
740
- const extra = [typeof params.remaining === "number" ? `${formatTokenCount(params.remaining)} left` : null, pct !== null ? `${pct}%` : null].filter(Boolean).join(", ");
741
- return `tokens ${totalLabel}/${ctxLabel}${extra ? ` (${extra})` : ""}`;
742
- }
743
- function asString(value, fallback = "") {
744
- if (typeof value === "string") return value;
745
- if (typeof value === "number" || typeof value === "boolean") return String(value);
746
- return fallback;
747
- }
748
-
749
- //#endregion
750
- //#region src/tui/components/tool-execution.ts
751
- const PREVIEW_LINES = 12;
752
- function formatArgs(toolName, args) {
753
- const detail = formatToolDetail(resolveToolDisplay({
754
- name: toolName,
755
- args
756
- }));
757
- if (detail) return sanitizeRenderableText(detail);
758
- if (!args || typeof args !== "object") return "";
759
- try {
760
- return sanitizeRenderableText(JSON.stringify(args));
761
- } catch {
762
- return "";
763
- }
764
- }
765
- function extractText(result) {
766
- if (!result?.content) return "";
767
- const lines = [];
768
- for (const entry of result.content) if (entry.type === "text" && entry.text) lines.push(sanitizeRenderableText(entry.text));
769
- else if (entry.type === "image") {
770
- const mime = entry.mimeType ?? "image";
771
- const size = entry.bytes ? ` ${Math.round(entry.bytes / 1024)}kb` : "";
772
- const omitted = entry.omitted ? " (omitted)" : "";
773
- lines.push(`[${mime}${size}${omitted}]`);
774
- }
775
- return lines.join("\n").trim();
776
- }
777
- var ToolExecutionComponent = class extends Container {
778
- constructor(toolName, args) {
779
- super();
780
- this.expanded = false;
781
- this.isError = false;
782
- this.isPartial = true;
783
- this.toolName = toolName;
784
- this.args = args;
785
- this.box = new Box(1, 1, (line) => theme.toolPendingBg(line));
786
- this.header = new Text("", 0, 0);
787
- this.argsLine = new Text("", 0, 0);
788
- this.output = new Markdown("", 0, 0, markdownTheme, { color: (line) => theme.toolOutput(line) });
789
- this.addChild(new Spacer(1));
790
- this.addChild(this.box);
791
- this.box.addChild(this.header);
792
- this.box.addChild(this.argsLine);
793
- this.box.addChild(this.output);
794
- this.refresh();
795
- }
796
- setArgs(args) {
797
- this.args = args;
798
- this.refresh();
799
- }
800
- setExpanded(expanded) {
801
- this.expanded = expanded;
802
- this.refresh();
803
- }
804
- setResult(result, opts) {
805
- this.result = result;
806
- this.isPartial = false;
807
- this.isError = Boolean(opts?.isError);
808
- this.refresh();
809
- }
810
- setPartialResult(result) {
811
- this.result = result;
812
- this.isPartial = true;
813
- this.refresh();
814
- }
815
- refresh() {
816
- const bg = this.isPartial ? theme.toolPendingBg : this.isError ? theme.toolErrorBg : theme.toolSuccessBg;
817
- this.box.setBgFn((line) => bg(line));
818
- const display = resolveToolDisplay({
819
- name: this.toolName,
820
- args: this.args
821
- });
822
- const title = `${display.emoji} ${display.label}${this.isPartial ? " (running)" : ""}`;
823
- this.header.setText(theme.toolTitle(theme.bold(title)));
824
- const argLine = formatArgs(this.toolName, this.args);
825
- this.argsLine.setText(argLine ? theme.dim(argLine) : theme.dim(" "));
826
- const text = extractText(this.result) || (this.isPartial ? "…" : "");
827
- if (!this.expanded && text) {
828
- const lines = text.split("\n");
829
- const preview = lines.length > PREVIEW_LINES ? `${lines.slice(0, PREVIEW_LINES).join("\n")}\n…` : text;
830
- this.output.setText(preview);
831
- } else this.output.setText(text);
832
- }
833
- };
834
-
835
- //#endregion
836
- //#region src/tui/components/markdown-message.ts
837
- var MarkdownMessageComponent = class extends Container {
838
- constructor(text, y, options) {
839
- super();
840
- this.body = new Markdown(text, 1, y, markdownTheme, options);
841
- this.addChild(new Spacer(1));
842
- this.addChild(this.body);
843
- }
844
- setText(text) {
845
- this.body.setText(text);
846
- }
847
- };
848
-
849
- //#endregion
850
- //#region src/tui/components/user-message.ts
851
- var UserMessageComponent = class extends MarkdownMessageComponent {
852
- constructor(text) {
853
- super(text, 1, {
854
- bgColor: (line) => theme.userBg(line),
855
- color: (line) => theme.userText(line)
856
- });
857
- }
858
- };
859
-
860
- //#endregion
861
- //#region src/tui/components/chat-log.ts
862
- var ChatLog = class extends Container {
863
- constructor(maxComponents = 180) {
864
- super();
865
- this.toolById = /* @__PURE__ */ new Map();
866
- this.streamingRuns = /* @__PURE__ */ new Map();
867
- this.toolsExpanded = false;
868
- this.maxComponents = Math.max(20, Math.floor(maxComponents));
869
- }
870
- dropComponentReferences(component) {
871
- for (const [toolId, tool] of this.toolById.entries()) if (tool === component) this.toolById.delete(toolId);
872
- for (const [runId, message] of this.streamingRuns.entries()) if (message === component) this.streamingRuns.delete(runId);
873
- }
874
- pruneOverflow() {
875
- while (this.children.length > this.maxComponents) {
876
- const oldest = this.children[0];
877
- if (!oldest) return;
878
- this.removeChild(oldest);
879
- this.dropComponentReferences(oldest);
880
- }
881
- }
882
- append(component) {
883
- this.addChild(component);
884
- this.pruneOverflow();
885
- }
886
- clearAll() {
887
- this.clear();
888
- this.toolById.clear();
889
- this.streamingRuns.clear();
890
- }
891
- addSystem(text) {
892
- this.append(new Spacer(1));
893
- this.append(new Text(theme.system(text), 1, 0));
894
- }
895
- addUser(text) {
896
- this.append(new UserMessageComponent(text));
897
- }
898
- resolveRunId(runId) {
899
- return runId ?? "default";
900
- }
901
- startAssistant(text, runId) {
902
- const component = new AssistantMessageComponent(text);
903
- this.streamingRuns.set(this.resolveRunId(runId), component);
904
- this.append(component);
905
- return component;
906
- }
907
- updateAssistant(text, runId) {
908
- const effectiveRunId = this.resolveRunId(runId);
909
- const existing = this.streamingRuns.get(effectiveRunId);
910
- if (!existing) {
911
- this.startAssistant(text, runId);
912
- return;
913
- }
914
- existing.setText(text);
915
- }
916
- finalizeAssistant(text, runId) {
917
- const effectiveRunId = this.resolveRunId(runId);
918
- const existing = this.streamingRuns.get(effectiveRunId);
919
- if (existing) {
920
- existing.setText(text);
921
- this.streamingRuns.delete(effectiveRunId);
922
- return;
923
- }
924
- this.append(new AssistantMessageComponent(text));
925
- }
926
- dropAssistant(runId) {
927
- const effectiveRunId = this.resolveRunId(runId);
928
- const existing = this.streamingRuns.get(effectiveRunId);
929
- if (!existing) return;
930
- this.removeChild(existing);
931
- this.streamingRuns.delete(effectiveRunId);
932
- }
933
- startTool(toolCallId, toolName, args) {
934
- const existing = this.toolById.get(toolCallId);
935
- if (existing) {
936
- existing.setArgs(args);
937
- return existing;
938
- }
939
- const component = new ToolExecutionComponent(toolName, args);
940
- component.setExpanded(this.toolsExpanded);
941
- this.toolById.set(toolCallId, component);
942
- this.append(component);
943
- return component;
944
- }
945
- updateToolArgs(toolCallId, args) {
946
- const existing = this.toolById.get(toolCallId);
947
- if (!existing) return;
948
- existing.setArgs(args);
949
- }
950
- updateToolResult(toolCallId, result, opts) {
951
- const existing = this.toolById.get(toolCallId);
952
- if (!existing) return;
953
- if (opts?.partial) {
954
- existing.setPartialResult(result);
955
- return;
956
- }
957
- existing.setResult(result, { isError: opts?.isError });
958
- }
959
- setToolsExpanded(expanded) {
960
- this.toolsExpanded = expanded;
961
- for (const tool of this.toolById.values()) tool.setExpanded(expanded);
962
- }
963
- };
964
-
965
- //#endregion
966
- //#region src/tui/components/custom-editor.ts
967
- var CustomEditor = class extends Editor {
968
- handleInput(data) {
969
- if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {
970
- this.onAltEnter();
971
- return;
972
- }
973
- if (matchesKey(data, Key.ctrl("l")) && this.onCtrlL) {
974
- this.onCtrlL();
975
- return;
976
- }
977
- if (matchesKey(data, Key.ctrl("o")) && this.onCtrlO) {
978
- this.onCtrlO();
979
- return;
980
- }
981
- if (matchesKey(data, Key.ctrl("p")) && this.onCtrlP) {
982
- this.onCtrlP();
983
- return;
984
- }
985
- if (matchesKey(data, Key.ctrl("g")) && this.onCtrlG) {
986
- this.onCtrlG();
987
- return;
988
- }
989
- if (matchesKey(data, Key.ctrl("t")) && this.onCtrlT) {
990
- this.onCtrlT();
991
- return;
992
- }
993
- if (matchesKey(data, Key.shift("tab")) && this.onShiftTab) {
994
- this.onShiftTab();
995
- return;
996
- }
997
- if (matchesKey(data, Key.escape) && this.onEscape && !this.isShowingAutocomplete()) {
998
- this.onEscape();
999
- return;
1000
- }
1001
- if (matchesKey(data, Key.ctrl("c")) && this.onCtrlC) {
1002
- this.onCtrlC();
1003
- return;
1004
- }
1005
- if (matchesKey(data, Key.ctrl("d"))) {
1006
- if (this.getText().length === 0 && this.onCtrlD) this.onCtrlD();
1007
- return;
1008
- }
1009
- super.handleInput(data);
1010
- }
1011
- };
1012
-
1013
- //#endregion
1014
- //#region src/tui/gateway-chat.ts
1015
- var GatewayChatClient = class {
1016
- constructor(opts) {
1017
- const resolved = resolveGatewayConnection(opts);
1018
- this.connection = resolved;
1019
- this.readyPromise = new Promise((resolve) => {
1020
- this.resolveReady = resolve;
1021
- });
1022
- this.client = new GatewayClient({
1023
- url: resolved.url,
1024
- token: resolved.token,
1025
- password: resolved.password,
1026
- clientName: GATEWAY_CLIENT_NAMES.GATEWAY_CLIENT,
1027
- clientDisplayName: "remoteclaw-tui",
1028
- clientVersion: VERSION,
1029
- platform: process.platform,
1030
- mode: GATEWAY_CLIENT_MODES.UI,
1031
- caps: [GATEWAY_CLIENT_CAPS.TOOL_EVENTS],
1032
- instanceId: randomUUID(),
1033
- minProtocol: PROTOCOL_VERSION,
1034
- maxProtocol: PROTOCOL_VERSION,
1035
- onHelloOk: (hello) => {
1036
- this.hello = hello;
1037
- this.resolveReady?.();
1038
- this.onConnected?.();
1039
- },
1040
- onEvent: (evt) => {
1041
- this.onEvent?.({
1042
- event: evt.event,
1043
- payload: evt.payload,
1044
- seq: evt.seq
1045
- });
1046
- },
1047
- onClose: (_code, reason) => {
1048
- this.readyPromise = new Promise((resolve) => {
1049
- this.resolveReady = resolve;
1050
- });
1051
- this.onDisconnected?.(reason);
1052
- },
1053
- onGap: (info) => {
1054
- this.onGap?.(info);
1055
- }
1056
- });
1057
- }
1058
- start() {
1059
- this.client.start();
1060
- }
1061
- stop() {
1062
- this.client.stop();
1063
- }
1064
- async waitForReady() {
1065
- await this.readyPromise;
1066
- }
1067
- async sendChat(opts) {
1068
- const runId = opts.runId ?? randomUUID();
1069
- await this.client.request("chat.send", {
1070
- sessionKey: opts.sessionKey,
1071
- message: opts.message,
1072
- thinking: opts.thinking,
1073
- deliver: opts.deliver,
1074
- timeoutMs: opts.timeoutMs,
1075
- idempotencyKey: runId
1076
- });
1077
- return { runId };
1078
- }
1079
- async abortChat(opts) {
1080
- return await this.client.request("chat.abort", {
1081
- sessionKey: opts.sessionKey,
1082
- runId: opts.runId
1083
- });
1084
- }
1085
- async loadHistory(opts) {
1086
- return await this.client.request("chat.history", {
1087
- sessionKey: opts.sessionKey,
1088
- limit: opts.limit
1089
- });
1090
- }
1091
- async listSessions(opts) {
1092
- return await this.client.request("sessions.list", {
1093
- limit: opts?.limit,
1094
- activeMinutes: opts?.activeMinutes,
1095
- includeGlobal: opts?.includeGlobal,
1096
- includeUnknown: opts?.includeUnknown,
1097
- includeDerivedTitles: opts?.includeDerivedTitles,
1098
- includeLastMessage: opts?.includeLastMessage,
1099
- agentId: opts?.agentId
1100
- });
1101
- }
1102
- async listAgents() {
1103
- return await this.client.request("agents.list", {});
1104
- }
1105
- async patchSession(opts) {
1106
- return await this.client.request("sessions.patch", opts);
1107
- }
1108
- async resetSession(key, reason) {
1109
- return await this.client.request("sessions.reset", {
1110
- key,
1111
- ...reason ? { reason } : {}
1112
- });
1113
- }
1114
- async getStatus() {
1115
- return await this.client.request("status");
1116
- }
1117
- async listModels() {
1118
- const res = await this.client.request("models.list");
1119
- return Array.isArray(res?.models) ? res.models : [];
1120
- }
1121
- };
1122
- function resolveGatewayConnection(opts) {
1123
- const config = loadConfig();
1124
- const isRemoteMode = config.gateway?.mode === "remote";
1125
- const remote = isRemoteMode ? config.gateway?.remote : void 0;
1126
- const authToken = config.gateway?.auth?.token;
1127
- const urlOverride = typeof opts.url === "string" && opts.url.trim().length > 0 ? opts.url.trim() : void 0;
1128
- const explicitAuth = resolveExplicitGatewayAuth({
1129
- token: opts.token,
1130
- password: opts.password
1131
- });
1132
- ensureExplicitGatewayAuth({
1133
- urlOverride,
1134
- auth: explicitAuth,
1135
- errorHint: "Fix: pass --token or --password when using --url."
1136
- });
1137
- return {
1138
- url: buildGatewayConnectionDetails({
1139
- config,
1140
- ...urlOverride ? { url: urlOverride } : {}
1141
- }).url,
1142
- token: explicitAuth.token || (!urlOverride ? isRemoteMode ? typeof remote?.token === "string" && remote.token.trim().length > 0 ? remote.token.trim() : void 0 : process.env.REMOTECLAW_GATEWAY_TOKEN?.trim() || (typeof authToken === "string" && authToken.trim().length > 0 ? authToken.trim() : void 0) : void 0),
1143
- password: explicitAuth.password || (!urlOverride ? process.env.REMOTECLAW_GATEWAY_PASSWORD?.trim() || (typeof remote?.password === "string" && remote.password.trim().length > 0 ? remote.password.trim() : void 0) : void 0)
1144
- };
1145
- }
1146
-
1147
- //#endregion
1148
- //#region src/tui/components/fuzzy-filter.ts
1149
- /**
1150
- * Shared fuzzy filtering utilities for select list components.
1151
- */
1152
- /**
1153
- * Word boundary characters for matching.
1154
- */
1155
- const WORD_BOUNDARY_CHARS = /[\s\-_./:#@]/;
1156
- /**
1157
- * Check if position is at a word boundary.
1158
- */
1159
- function isWordBoundary(text, index) {
1160
- return index === 0 || WORD_BOUNDARY_CHARS.test(text[index - 1] ?? "");
1161
- }
1162
- /**
1163
- * Find index where query matches at a word boundary in text.
1164
- * Returns null if no match.
1165
- */
1166
- function findWordBoundaryIndex(text, query) {
1167
- if (!query) return null;
1168
- const textLower = text.toLowerCase();
1169
- const queryLower = query.toLowerCase();
1170
- const maxIndex = textLower.length - queryLower.length;
1171
- if (maxIndex < 0) return null;
1172
- for (let i = 0; i <= maxIndex; i++) if (textLower.startsWith(queryLower, i) && isWordBoundary(textLower, i)) return i;
1173
- return null;
1174
- }
1175
- /**
1176
- * Fuzzy match with pre-lowercased inputs (avoids toLowerCase on every keystroke).
1177
- * Returns score (lower = better) or null if no match.
1178
- */
1179
- function fuzzyMatchLower(queryLower, textLower) {
1180
- if (queryLower.length === 0) return 0;
1181
- if (queryLower.length > textLower.length) return null;
1182
- let queryIndex = 0;
1183
- let score = 0;
1184
- let lastMatchIndex = -1;
1185
- let consecutiveMatches = 0;
1186
- for (let i = 0; i < textLower.length && queryIndex < queryLower.length; i++) if (textLower[i] === queryLower[queryIndex]) {
1187
- const isAtWordBoundary = isWordBoundary(textLower, i);
1188
- if (lastMatchIndex === i - 1) {
1189
- consecutiveMatches++;
1190
- score -= consecutiveMatches * 5;
1191
- } else {
1192
- consecutiveMatches = 0;
1193
- if (lastMatchIndex >= 0) score += (i - lastMatchIndex - 1) * 2;
1194
- }
1195
- if (isAtWordBoundary) score -= 10;
1196
- score += i * .1;
1197
- lastMatchIndex = i;
1198
- queryIndex++;
1199
- }
1200
- return queryIndex < queryLower.length ? null : score;
1201
- }
1202
- /**
1203
- * Filter items using pre-lowercased searchTextLower field.
1204
- * Supports space-separated tokens (all must match).
1205
- */
1206
- function fuzzyFilterLower(items, queryLower) {
1207
- const trimmed = queryLower.trim();
1208
- if (!trimmed) return items;
1209
- const tokens = trimmed.split(/\s+/).filter((t) => t.length > 0);
1210
- if (tokens.length === 0) return items;
1211
- const results = [];
1212
- for (const item of items) {
1213
- const text = item.searchTextLower ?? "";
1214
- let totalScore = 0;
1215
- let allMatch = true;
1216
- for (const token of tokens) {
1217
- const score = fuzzyMatchLower(token, text);
1218
- if (score !== null) totalScore += score;
1219
- else {
1220
- allMatch = false;
1221
- break;
1222
- }
1223
- }
1224
- if (allMatch) results.push({
1225
- item,
1226
- score: totalScore
1227
- });
1228
- }
1229
- results.sort((a, b) => a.score - b.score);
1230
- return results.map((r) => r.item);
1231
- }
1232
- /**
1233
- * Prepare items for fuzzy filtering by pre-computing lowercase search text.
1234
- */
1235
- function prepareSearchItems(items) {
1236
- return items.map((item) => {
1237
- const parts = [];
1238
- if (item.label) parts.push(item.label);
1239
- if (item.description) parts.push(item.description);
1240
- if (item.searchText) parts.push(item.searchText);
1241
- return {
1242
- ...item,
1243
- searchTextLower: parts.join(" ").toLowerCase()
1244
- };
1245
- });
1246
- }
1247
-
1248
- //#endregion
1249
- //#region src/tui/components/filterable-select-list.ts
1250
- /**
1251
- * Combines text input filtering with a select list.
1252
- * User types to filter, arrows/j/k to navigate, Enter to select, Escape to clear/cancel.
1253
- */
1254
- var FilterableSelectList = class {
1255
- constructor(items, maxVisible, theme) {
1256
- this.filterText = "";
1257
- this.allItems = prepareSearchItems(items);
1258
- this.maxVisible = maxVisible;
1259
- this.theme = theme;
1260
- this.input = new Input();
1261
- this.selectList = new SelectList(this.allItems, maxVisible, theme);
1262
- }
1263
- applyFilter() {
1264
- const queryLower = this.filterText.toLowerCase();
1265
- if (!queryLower.trim()) {
1266
- this.selectList = new SelectList(this.allItems, this.maxVisible, this.theme);
1267
- return;
1268
- }
1269
- this.selectList = new SelectList(fuzzyFilterLower(this.allItems, queryLower), this.maxVisible, this.theme);
1270
- }
1271
- invalidate() {
1272
- this.input.invalidate();
1273
- this.selectList.invalidate();
1274
- }
1275
- render(width) {
1276
- const lines = [];
1277
- const filterLabel = this.theme.filterLabel("Filter: ");
1278
- const inputText = this.input.render(width - 8)[0] ?? "";
1279
- lines.push(filterLabel + inputText);
1280
- lines.push(chalk.dim("─".repeat(Math.max(0, width))));
1281
- const listLines = this.selectList.render(width);
1282
- lines.push(...listLines);
1283
- return lines;
1284
- }
1285
- handleInput(keyData) {
1286
- const allowVimNav = !this.filterText.trim();
1287
- if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
1288
- this.selectList.handleInput("\x1B[A");
1289
- return;
1290
- }
1291
- if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
1292
- this.selectList.handleInput("\x1B[B");
1293
- return;
1294
- }
1295
- if (matchesKey(keyData, "enter")) {
1296
- const selected = this.selectList.getSelectedItem();
1297
- if (selected) this.onSelect?.(selected);
1298
- return;
1299
- }
1300
- if (getEditorKeybindings().matches(keyData, "selectCancel")) {
1301
- if (this.filterText) {
1302
- this.filterText = "";
1303
- this.input.setValue("");
1304
- this.applyFilter();
1305
- } else this.onCancel?.();
1306
- return;
1307
- }
1308
- const prevValue = this.input.getValue();
1309
- this.input.handleInput(keyData);
1310
- const newValue = this.input.getValue();
1311
- if (newValue !== prevValue) {
1312
- this.filterText = newValue;
1313
- this.applyFilter();
1314
- }
1315
- }
1316
- getSelectedItem() {
1317
- return this.selectList.getSelectedItem();
1318
- }
1319
- getFilterText() {
1320
- return this.filterText;
1321
- }
1322
- };
1323
-
1324
- //#endregion
1325
- //#region src/tui/components/searchable-select-list.ts
1326
- const ANSI_ESCAPE = String.fromCharCode(27);
1327
- const ANSI_SGR_REGEX = new RegExp(`${ANSI_ESCAPE}\\[[0-9;]*m`, "g");
1328
- /**
1329
- * A select list with a search input at the top for fuzzy filtering.
1330
- */
1331
- var SearchableSelectList = class SearchableSelectList {
1332
- static {
1333
- this.DESCRIPTION_LAYOUT_MIN_WIDTH = 40;
1334
- }
1335
- static {
1336
- this.DESCRIPTION_MIN_WIDTH = 12;
1337
- }
1338
- static {
1339
- this.DESCRIPTION_SPACING_WIDTH = 2;
1340
- }
1341
- static {
1342
- this.RIGHT_MARGIN_WIDTH = 2;
1343
- }
1344
- constructor(items, maxVisible, theme) {
1345
- this.selectedIndex = 0;
1346
- this.regexCache = /* @__PURE__ */ new Map();
1347
- this.compareByScore = (a, b) => {
1348
- if (a.tier !== b.tier) return a.tier - b.tier;
1349
- if (a.score !== b.score) return a.score - b.score;
1350
- return this.getItemLabel(a.item).localeCompare(this.getItemLabel(b.item));
1351
- };
1352
- this.items = items;
1353
- this.filteredItems = items;
1354
- this.maxVisible = maxVisible;
1355
- this.theme = theme;
1356
- this.searchInput = new Input();
1357
- }
1358
- getCachedRegex(pattern) {
1359
- let regex = this.regexCache.get(pattern);
1360
- if (!regex) {
1361
- regex = new RegExp(this.escapeRegex(pattern), "gi");
1362
- this.regexCache.set(pattern, regex);
1363
- }
1364
- return regex;
1365
- }
1366
- updateFilter() {
1367
- const query = this.searchInput.getValue().trim();
1368
- if (!query) this.filteredItems = this.items;
1369
- else this.filteredItems = this.smartFilter(query);
1370
- this.selectedIndex = 0;
1371
- this.notifySelectionChange();
1372
- }
1373
- /**
1374
- * Smart filtering that prioritizes:
1375
- * 1. Exact substring match in label (highest priority)
1376
- * 2. Word-boundary prefix match in label
1377
- * 3. Exact substring in description
1378
- * 4. Fuzzy match (lowest priority)
1379
- */
1380
- smartFilter(query) {
1381
- const q = query.toLowerCase();
1382
- const scoredItems = [];
1383
- const fuzzyCandidates = [];
1384
- for (const item of this.items) {
1385
- const rawLabel = this.getItemLabel(item);
1386
- const rawDesc = item.description ?? "";
1387
- const label = stripAnsi$1(rawLabel).toLowerCase();
1388
- const desc = stripAnsi$1(rawDesc).toLowerCase();
1389
- const labelIndex = label.indexOf(q);
1390
- if (labelIndex !== -1) {
1391
- scoredItems.push({
1392
- item,
1393
- tier: 0,
1394
- score: labelIndex
1395
- });
1396
- continue;
1397
- }
1398
- const wordBoundaryIndex = findWordBoundaryIndex(label, q);
1399
- if (wordBoundaryIndex !== null) {
1400
- scoredItems.push({
1401
- item,
1402
- tier: 1,
1403
- score: wordBoundaryIndex
1404
- });
1405
- continue;
1406
- }
1407
- const descIndex = desc.indexOf(q);
1408
- if (descIndex !== -1) {
1409
- scoredItems.push({
1410
- item,
1411
- tier: 2,
1412
- score: descIndex
1413
- });
1414
- continue;
1415
- }
1416
- const searchText = item.searchText ?? "";
1417
- fuzzyCandidates.push({
1418
- item,
1419
- searchTextLower: [
1420
- rawLabel,
1421
- rawDesc,
1422
- searchText
1423
- ].map((value) => stripAnsi$1(value)).filter(Boolean).join(" ").toLowerCase()
1424
- });
1425
- }
1426
- scoredItems.sort(this.compareByScore);
1427
- const fuzzyMatches = fuzzyFilterLower(fuzzyCandidates, q);
1428
- return [...scoredItems.map((s) => s.item), ...fuzzyMatches.map((entry) => entry.item)];
1429
- }
1430
- escapeRegex(str) {
1431
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1432
- }
1433
- getItemLabel(item) {
1434
- return item.label || item.value;
1435
- }
1436
- splitAnsiParts(text) {
1437
- const parts = [];
1438
- ANSI_SGR_REGEX.lastIndex = 0;
1439
- let lastIndex = 0;
1440
- let match;
1441
- while ((match = ANSI_SGR_REGEX.exec(text)) !== null) {
1442
- if (match.index > lastIndex) parts.push({
1443
- text: text.slice(lastIndex, match.index),
1444
- isAnsi: false
1445
- });
1446
- parts.push({
1447
- text: match[0],
1448
- isAnsi: true
1449
- });
1450
- lastIndex = match.index + match[0].length;
1451
- }
1452
- if (lastIndex < text.length) parts.push({
1453
- text: text.slice(lastIndex),
1454
- isAnsi: false
1455
- });
1456
- return parts;
1457
- }
1458
- highlightMatch(text, query) {
1459
- const tokens = query.trim().split(/\s+/).map((token) => token.toLowerCase()).filter((token) => token.length > 0);
1460
- if (tokens.length === 0) return text;
1461
- const uniqueTokens = Array.from(new Set(tokens)).toSorted((a, b) => b.length - a.length);
1462
- let parts = this.splitAnsiParts(text);
1463
- for (const token of uniqueTokens) {
1464
- const regex = this.getCachedRegex(token);
1465
- const nextParts = [];
1466
- for (const part of parts) {
1467
- if (part.isAnsi) {
1468
- nextParts.push(part);
1469
- continue;
1470
- }
1471
- regex.lastIndex = 0;
1472
- const replaced = part.text.replace(regex, (match) => this.theme.matchHighlight(match));
1473
- if (replaced === part.text) {
1474
- nextParts.push(part);
1475
- continue;
1476
- }
1477
- nextParts.push(...this.splitAnsiParts(replaced));
1478
- }
1479
- parts = nextParts;
1480
- }
1481
- return parts.map((part) => part.text).join("");
1482
- }
1483
- setSelectedIndex(index) {
1484
- this.selectedIndex = Math.max(0, Math.min(index, this.filteredItems.length - 1));
1485
- }
1486
- invalidate() {
1487
- this.searchInput.invalidate();
1488
- }
1489
- render(width) {
1490
- const lines = [];
1491
- const prompt = this.theme.searchPrompt("search: ");
1492
- const inputWidth = Math.max(1, width - visibleWidth(prompt));
1493
- const inputText = this.searchInput.render(inputWidth)[0] ?? "";
1494
- lines.push(`${prompt}${this.theme.searchInput(inputText)}`);
1495
- lines.push("");
1496
- const query = this.searchInput.getValue().trim();
1497
- if (this.filteredItems.length === 0) {
1498
- lines.push(this.theme.noMatch(" No matches"));
1499
- return lines;
1500
- }
1501
- const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible));
1502
- const endIndex = Math.min(startIndex + this.maxVisible, this.filteredItems.length);
1503
- for (let i = startIndex; i < endIndex; i++) {
1504
- const item = this.filteredItems[i];
1505
- if (!item) continue;
1506
- const isSelected = i === this.selectedIndex;
1507
- lines.push(this.renderItemLine(item, isSelected, width, query));
1508
- }
1509
- if (this.filteredItems.length > this.maxVisible) {
1510
- const scrollInfo = `${this.selectedIndex + 1}/${this.filteredItems.length}`;
1511
- lines.push(this.theme.scrollInfo(` ${scrollInfo}`));
1512
- }
1513
- return lines;
1514
- }
1515
- renderItemLine(item, isSelected, width, query) {
1516
- const prefix = isSelected ? "→ " : " ";
1517
- const prefixWidth = prefix.length;
1518
- const displayValue = this.getItemLabel(item);
1519
- const description = item.description;
1520
- if (description) {
1521
- const descriptionLayout = this.getDescriptionLayout(width, prefixWidth);
1522
- if (descriptionLayout) {
1523
- const truncatedValue = truncateToWidth(displayValue, descriptionLayout.maxValueWidth, "");
1524
- const valueText = this.highlightMatch(truncatedValue, query);
1525
- const usedByValue = visibleWidth(valueText);
1526
- const descriptionWidth = descriptionLayout.availableWidth - usedByValue - descriptionLayout.spacingWidth;
1527
- if (descriptionWidth >= SearchableSelectList.DESCRIPTION_MIN_WIDTH) {
1528
- const spacing = " ".repeat(descriptionLayout.spacingWidth);
1529
- const truncatedDesc = truncateToWidth(description, descriptionWidth, "");
1530
- const highlightedDesc = this.highlightMatch(truncatedDesc, query);
1531
- const line = `${prefix}${valueText}${spacing}${isSelected ? highlightedDesc : this.theme.description(highlightedDesc)}`;
1532
- return isSelected ? this.theme.selectedText(line) : line;
1533
- }
1534
- }
1535
- }
1536
- const truncatedValue = truncateToWidth(displayValue, width - prefixWidth - 2, "");
1537
- const line = `${prefix}${this.highlightMatch(truncatedValue, query)}`;
1538
- return isSelected ? this.theme.selectedText(line) : line;
1539
- }
1540
- getDescriptionLayout(width, prefixWidth) {
1541
- if (width <= SearchableSelectList.DESCRIPTION_LAYOUT_MIN_WIDTH) return null;
1542
- const availableWidth = Math.max(1, width - prefixWidth - SearchableSelectList.RIGHT_MARGIN_WIDTH);
1543
- const maxValueWidth = availableWidth - SearchableSelectList.DESCRIPTION_MIN_WIDTH - SearchableSelectList.DESCRIPTION_SPACING_WIDTH;
1544
- if (maxValueWidth < 1) return null;
1545
- return {
1546
- availableWidth,
1547
- maxValueWidth,
1548
- spacingWidth: SearchableSelectList.DESCRIPTION_SPACING_WIDTH
1549
- };
1550
- }
1551
- handleInput(keyData) {
1552
- if (isKeyRelease(keyData)) return;
1553
- const allowVimNav = !this.searchInput.getValue().trim();
1554
- if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
1555
- this.selectedIndex = Math.max(0, this.selectedIndex - 1);
1556
- this.notifySelectionChange();
1557
- return;
1558
- }
1559
- if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
1560
- this.selectedIndex = Math.min(this.filteredItems.length - 1, this.selectedIndex + 1);
1561
- this.notifySelectionChange();
1562
- return;
1563
- }
1564
- if (matchesKey(keyData, "enter")) {
1565
- const item = this.filteredItems[this.selectedIndex];
1566
- if (item && this.onSelect) this.onSelect(item);
1567
- return;
1568
- }
1569
- if (getEditorKeybindings().matches(keyData, "selectCancel")) {
1570
- if (this.onCancel) this.onCancel();
1571
- return;
1572
- }
1573
- const prevValue = this.searchInput.getValue();
1574
- this.searchInput.handleInput(keyData);
1575
- if (prevValue !== this.searchInput.getValue()) this.updateFilter();
1576
- }
1577
- notifySelectionChange() {
1578
- const item = this.filteredItems[this.selectedIndex];
1579
- if (item && this.onSelectionChange) this.onSelectionChange(item);
1580
- }
1581
- getSelectedItem() {
1582
- return this.filteredItems[this.selectedIndex] ?? null;
1583
- }
1584
- };
1585
-
1586
- //#endregion
1587
- //#region src/tui/components/selectors.ts
1588
- function createSearchableSelectList(items, maxVisible = 7) {
1589
- return new SearchableSelectList(items, maxVisible, searchableSelectListTheme);
1590
- }
1591
- function createFilterableSelectList(items, maxVisible = 7) {
1592
- return new FilterableSelectList(items, maxVisible, filterableSelectListTheme);
1593
- }
1594
- function createSettingsList(items, onChange, onCancel, maxVisible = 7) {
1595
- return new SettingsList(items, maxVisible, settingsListTheme, onChange, onCancel);
1596
- }
1597
-
1598
- //#endregion
1599
- //#region src/tui/tui-status-summary.ts
1600
- function formatStatusSummary(summary) {
1601
- const lines = [];
1602
- lines.push("Gateway status");
1603
- if (!summary.linkChannel) lines.push("Link channel: unknown");
1604
- else {
1605
- const linkLabel = summary.linkChannel.label ?? "Link channel";
1606
- const linked = summary.linkChannel.linked === true;
1607
- const authAge = linked && typeof summary.linkChannel.authAgeMs === "number" ? ` (last refreshed ${formatTimeAgo(summary.linkChannel.authAgeMs)})` : "";
1608
- lines.push(`${linkLabel}: ${linked ? "linked" : "not linked"}${authAge}`);
1609
- }
1610
- const providerSummary = Array.isArray(summary.providerSummary) ? summary.providerSummary : [];
1611
- if (providerSummary.length > 0) {
1612
- lines.push("");
1613
- lines.push("System:");
1614
- for (const line of providerSummary) lines.push(` ${line}`);
1615
- }
1616
- const heartbeatAgents = summary.heartbeat?.agents ?? [];
1617
- if (heartbeatAgents.length > 0) {
1618
- const heartbeatParts = heartbeatAgents.map((agent) => {
1619
- const agentId = agent.agentId ?? "unknown";
1620
- if (!agent.enabled || !agent.everyMs) return `disabled (${agentId})`;
1621
- return `${agent.every ?? "unknown"} (${agentId})`;
1622
- });
1623
- lines.push("");
1624
- lines.push(`Heartbeat: ${heartbeatParts.join(", ")}`);
1625
- }
1626
- const sessionPaths = summary.sessions?.paths ?? [];
1627
- if (sessionPaths.length === 1) lines.push(`Session store: ${sessionPaths[0]}`);
1628
- else if (sessionPaths.length > 1) lines.push(`Session stores: ${sessionPaths.length}`);
1629
- const defaults = summary.sessions?.defaults;
1630
- const defaultModel = defaults?.model ?? "unknown";
1631
- const defaultCtx = typeof defaults?.contextTokens === "number" ? ` (${formatTokenCount(defaults.contextTokens)} ctx)` : "";
1632
- lines.push(`Default model: ${defaultModel}${defaultCtx}`);
1633
- const sessionCount = summary.sessions?.count ?? 0;
1634
- lines.push(`Active sessions: ${sessionCount}`);
1635
- const recent = Array.isArray(summary.sessions?.recent) ? summary.sessions?.recent : [];
1636
- if (recent.length > 0) {
1637
- lines.push("Recent sessions:");
1638
- for (const entry of recent) {
1639
- const ageLabel = typeof entry.age === "number" ? formatTimeAgo(entry.age) : "no activity";
1640
- const model = entry.model ?? "unknown";
1641
- const usage = formatContextUsageLine({
1642
- total: entry.totalTokens ?? null,
1643
- context: entry.contextTokens ?? null,
1644
- remaining: entry.remainingTokens ?? null,
1645
- percent: entry.percentUsed ?? null
1646
- });
1647
- const flags = entry.flags?.length ? ` | flags: ${entry.flags.join(", ")}` : "";
1648
- lines.push(`- ${entry.key}${entry.kind ? ` [${entry.kind}]` : ""} | ${ageLabel} | model ${model} | ${usage}${flags}`);
1649
- }
1650
- }
1651
- const queued = Array.isArray(summary.queuedSystemEvents) ? summary.queuedSystemEvents : [];
1652
- if (queued.length > 0) {
1653
- const preview = queued.slice(0, 3).join(" | ");
1654
- lines.push(`Queued system events (${queued.length}): ${preview}`);
1655
- }
1656
- return lines;
1657
- }
1658
-
1659
- //#endregion
1660
- //#region src/tui/tui-command-handlers.ts
1661
- function createCommandHandlers(context) {
1662
- const { client, chatLog, tui, opts, state, deliverDefault, openOverlay, closeOverlay, refreshSessionInfo, loadHistory, setSession, refreshAgents, abortActive, setActivityStatus, formatSessionKey, applySessionInfoFromPatch, noteLocalRunId, forgetLocalRunId, requestExit } = context;
1663
- const setAgent = async (id) => {
1664
- state.currentAgentId = normalizeAgentId(id);
1665
- await setSession("");
1666
- };
1667
- const closeOverlayAndRender = () => {
1668
- closeOverlay();
1669
- tui.requestRender();
1670
- };
1671
- const openSelector = (selector, onSelect) => {
1672
- selector.onSelect = (item) => {
1673
- (async () => {
1674
- await onSelect(item.value);
1675
- closeOverlayAndRender();
1676
- })();
1677
- };
1678
- selector.onCancel = closeOverlayAndRender;
1679
- openOverlay(selector);
1680
- tui.requestRender();
1681
- };
1682
- const openModelSelector = async () => {
1683
- try {
1684
- const models = await client.listModels();
1685
- if (models.length === 0) {
1686
- chatLog.addSystem("no models available");
1687
- tui.requestRender();
1688
- return;
1689
- }
1690
- openSelector(createSearchableSelectList(models.map((model) => ({
1691
- value: `${model.provider}/${model.id}`,
1692
- label: `${model.provider}/${model.id}`,
1693
- description: model.name && model.name !== model.id ? model.name : ""
1694
- })), 9), async (value) => {
1695
- try {
1696
- const result = await client.patchSession({
1697
- key: state.currentSessionKey,
1698
- model: value
1699
- });
1700
- chatLog.addSystem(`model set to ${value}`);
1701
- applySessionInfoFromPatch(result);
1702
- await refreshSessionInfo();
1703
- } catch (err) {
1704
- chatLog.addSystem(`model set failed: ${String(err)}`);
1705
- }
1706
- });
1707
- } catch (err) {
1708
- chatLog.addSystem(`model list failed: ${String(err)}`);
1709
- tui.requestRender();
1710
- }
1711
- };
1712
- const openAgentSelector = async () => {
1713
- await refreshAgents();
1714
- if (state.agents.length === 0) {
1715
- chatLog.addSystem("no agents found");
1716
- tui.requestRender();
1717
- return;
1718
- }
1719
- openSelector(createSearchableSelectList(state.agents.map((agent) => ({
1720
- value: agent.id,
1721
- label: agent.name ? `${agent.id} (${agent.name})` : agent.id,
1722
- description: agent.id === state.agentDefaultId ? "default" : ""
1723
- })), 9), async (value) => {
1724
- await setAgent(value);
1725
- });
1726
- };
1727
- const openSessionSelector = async () => {
1728
- try {
1729
- openSelector(createFilterableSelectList((await client.listSessions({
1730
- includeGlobal: false,
1731
- includeUnknown: false,
1732
- includeDerivedTitles: true,
1733
- includeLastMessage: true,
1734
- agentId: state.currentAgentId
1735
- })).sessions.map((session) => {
1736
- const title = session.derivedTitle ?? session.displayName;
1737
- const formattedKey = formatSessionKey(session.key);
1738
- const label = title && title !== formattedKey ? `${title} (${formattedKey})` : formattedKey;
1739
- const timePart = session.updatedAt ? formatRelativeTimestamp(session.updatedAt, {
1740
- dateFallback: true,
1741
- fallback: ""
1742
- }) : "";
1743
- const preview = session.lastMessagePreview?.replace(/\s+/g, " ").trim();
1744
- const description = timePart && preview ? `${timePart} · ${preview}` : preview ?? timePart;
1745
- return {
1746
- value: session.key,
1747
- label,
1748
- description,
1749
- searchText: [
1750
- session.displayName,
1751
- session.label,
1752
- session.subject,
1753
- session.sessionId,
1754
- session.key,
1755
- session.lastMessagePreview
1756
- ].filter(Boolean).join(" ")
1757
- };
1758
- }), 9), async (value) => {
1759
- await setSession(value);
1760
- });
1761
- } catch (err) {
1762
- chatLog.addSystem(`sessions list failed: ${String(err)}`);
1763
- tui.requestRender();
1764
- }
1765
- };
1766
- const openSettings = () => {
1767
- openOverlay(createSettingsList([{
1768
- id: "tools",
1769
- label: "Tool output",
1770
- currentValue: state.toolsExpanded ? "expanded" : "collapsed",
1771
- values: ["collapsed", "expanded"]
1772
- }, {
1773
- id: "thinking",
1774
- label: "Show thinking",
1775
- currentValue: state.showThinking ? "on" : "off",
1776
- values: ["off", "on"]
1777
- }], (id, value) => {
1778
- if (id === "tools") {
1779
- state.toolsExpanded = value === "expanded";
1780
- chatLog.setToolsExpanded(state.toolsExpanded);
1781
- }
1782
- if (id === "thinking") {
1783
- state.showThinking = value === "on";
1784
- loadHistory();
1785
- }
1786
- tui.requestRender();
1787
- }, () => {
1788
- closeOverlay();
1789
- tui.requestRender();
1790
- }));
1791
- tui.requestRender();
1792
- };
1793
- const handleCommand = async (raw) => {
1794
- const { name, args } = parseCommand(raw);
1795
- if (!name) return;
1796
- switch (name) {
1797
- case "help":
1798
- chatLog.addSystem(helpText({
1799
- provider: state.sessionInfo.modelProvider,
1800
- model: state.sessionInfo.model
1801
- }));
1802
- break;
1803
- case "status":
1804
- try {
1805
- const status = await client.getStatus();
1806
- if (typeof status === "string") {
1807
- chatLog.addSystem(status);
1808
- break;
1809
- }
1810
- if (status && typeof status === "object") {
1811
- const lines = formatStatusSummary(status);
1812
- for (const line of lines) chatLog.addSystem(line);
1813
- break;
1814
- }
1815
- chatLog.addSystem("status: unknown response");
1816
- } catch (err) {
1817
- chatLog.addSystem(`status failed: ${String(err)}`);
1818
- }
1819
- break;
1820
- case "agent":
1821
- if (!args) await openAgentSelector();
1822
- else await setAgent(args);
1823
- break;
1824
- case "agents":
1825
- await openAgentSelector();
1826
- break;
1827
- case "session":
1828
- if (!args) await openSessionSelector();
1829
- else await setSession(args);
1830
- break;
1831
- case "sessions":
1832
- await openSessionSelector();
1833
- break;
1834
- case "model":
1835
- if (!args) await openModelSelector();
1836
- else try {
1837
- const result = await client.patchSession({
1838
- key: state.currentSessionKey,
1839
- model: args
1840
- });
1841
- chatLog.addSystem(`model set to ${args}`);
1842
- applySessionInfoFromPatch(result);
1843
- await refreshSessionInfo();
1844
- } catch (err) {
1845
- chatLog.addSystem(`model set failed: ${String(err)}`);
1846
- }
1847
- break;
1848
- case "models":
1849
- await openModelSelector();
1850
- break;
1851
- case "think":
1852
- if (!args) {
1853
- const levels = formatThinkingLevels(state.sessionInfo.modelProvider, state.sessionInfo.model, "|");
1854
- chatLog.addSystem(`usage: /think <${levels}>`);
1855
- break;
1856
- }
1857
- try {
1858
- const result = await client.patchSession({
1859
- key: state.currentSessionKey,
1860
- thinkingLevel: args
1861
- });
1862
- chatLog.addSystem(`thinking set to ${args}`);
1863
- applySessionInfoFromPatch(result);
1864
- await refreshSessionInfo();
1865
- } catch (err) {
1866
- chatLog.addSystem(`think failed: ${String(err)}`);
1867
- }
1868
- break;
1869
- case "verbose":
1870
- if (!args) {
1871
- chatLog.addSystem("usage: /verbose <on|off>");
1872
- break;
1873
- }
1874
- try {
1875
- const result = await client.patchSession({
1876
- key: state.currentSessionKey,
1877
- verboseLevel: args
1878
- });
1879
- chatLog.addSystem(`verbose set to ${args}`);
1880
- applySessionInfoFromPatch(result);
1881
- await loadHistory();
1882
- } catch (err) {
1883
- chatLog.addSystem(`verbose failed: ${String(err)}`);
1884
- }
1885
- break;
1886
- case "reasoning":
1887
- if (!args) {
1888
- chatLog.addSystem("usage: /reasoning <on|off>");
1889
- break;
1890
- }
1891
- try {
1892
- const result = await client.patchSession({
1893
- key: state.currentSessionKey,
1894
- reasoningLevel: args
1895
- });
1896
- chatLog.addSystem(`reasoning set to ${args}`);
1897
- applySessionInfoFromPatch(result);
1898
- await refreshSessionInfo();
1899
- } catch (err) {
1900
- chatLog.addSystem(`reasoning failed: ${String(err)}`);
1901
- }
1902
- break;
1903
- case "usage": {
1904
- const normalized = args ? normalizeUsageDisplay(args) : void 0;
1905
- if (args && !normalized) {
1906
- chatLog.addSystem("usage: /usage <off|tokens|full>");
1907
- break;
1908
- }
1909
- const currentRaw = state.sessionInfo.responseUsage;
1910
- const current = resolveResponseUsageMode(currentRaw);
1911
- const next = normalized ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
1912
- try {
1913
- const result = await client.patchSession({
1914
- key: state.currentSessionKey,
1915
- responseUsage: next === "off" ? null : next
1916
- });
1917
- chatLog.addSystem(`usage footer: ${next}`);
1918
- applySessionInfoFromPatch(result);
1919
- await refreshSessionInfo();
1920
- } catch (err) {
1921
- chatLog.addSystem(`usage failed: ${String(err)}`);
1922
- }
1923
- break;
1924
- }
1925
- case "elevated":
1926
- if (!args) {
1927
- chatLog.addSystem("usage: /elevated <on|off|ask|full>");
1928
- break;
1929
- }
1930
- if (![
1931
- "on",
1932
- "off",
1933
- "ask",
1934
- "full"
1935
- ].includes(args)) {
1936
- chatLog.addSystem("usage: /elevated <on|off|ask|full>");
1937
- break;
1938
- }
1939
- try {
1940
- const result = await client.patchSession({
1941
- key: state.currentSessionKey,
1942
- elevatedLevel: args
1943
- });
1944
- chatLog.addSystem(`elevated set to ${args}`);
1945
- applySessionInfoFromPatch(result);
1946
- await refreshSessionInfo();
1947
- } catch (err) {
1948
- chatLog.addSystem(`elevated failed: ${String(err)}`);
1949
- }
1950
- break;
1951
- case "activation":
1952
- if (!args) {
1953
- chatLog.addSystem("usage: /activation <mention|always>");
1954
- break;
1955
- }
1956
- try {
1957
- const result = await client.patchSession({
1958
- key: state.currentSessionKey,
1959
- groupActivation: args === "always" ? "always" : "mention"
1960
- });
1961
- chatLog.addSystem(`activation set to ${args}`);
1962
- applySessionInfoFromPatch(result);
1963
- await refreshSessionInfo();
1964
- } catch (err) {
1965
- chatLog.addSystem(`activation failed: ${String(err)}`);
1966
- }
1967
- break;
1968
- case "new":
1969
- case "reset":
1970
- try {
1971
- state.sessionInfo.inputTokens = null;
1972
- state.sessionInfo.outputTokens = null;
1973
- state.sessionInfo.totalTokens = null;
1974
- tui.requestRender();
1975
- await client.resetSession(state.currentSessionKey, name);
1976
- chatLog.addSystem(`session ${state.currentSessionKey} reset`);
1977
- await loadHistory();
1978
- } catch (err) {
1979
- chatLog.addSystem(`reset failed: ${String(err)}`);
1980
- }
1981
- break;
1982
- case "abort":
1983
- await abortActive();
1984
- break;
1985
- case "settings":
1986
- openSettings();
1987
- break;
1988
- case "exit":
1989
- case "quit":
1990
- requestExit();
1991
- break;
1992
- default:
1993
- await sendMessage(raw);
1994
- break;
1995
- }
1996
- tui.requestRender();
1997
- };
1998
- const sendMessage = async (text) => {
1999
- if (!state.isConnected) {
2000
- chatLog.addSystem("not connected to gateway — message not sent");
2001
- setActivityStatus("disconnected");
2002
- tui.requestRender();
2003
- return;
2004
- }
2005
- try {
2006
- chatLog.addUser(text);
2007
- tui.requestRender();
2008
- const runId = randomUUID();
2009
- noteLocalRunId(runId);
2010
- state.activeChatRunId = runId;
2011
- setActivityStatus("sending");
2012
- tui.requestRender();
2013
- await client.sendChat({
2014
- sessionKey: state.currentSessionKey,
2015
- message: text,
2016
- thinking: opts.thinking,
2017
- deliver: deliverDefault,
2018
- timeoutMs: opts.timeoutMs,
2019
- runId
2020
- });
2021
- setActivityStatus("waiting");
2022
- tui.requestRender();
2023
- } catch (err) {
2024
- if (state.activeChatRunId) forgetLocalRunId?.(state.activeChatRunId);
2025
- state.activeChatRunId = null;
2026
- chatLog.addSystem(`send failed: ${String(err)}`);
2027
- setActivityStatus("error");
2028
- tui.requestRender();
2029
- }
2030
- };
2031
- return {
2032
- handleCommand,
2033
- sendMessage,
2034
- openModelSelector,
2035
- openAgentSelector,
2036
- openSessionSelector,
2037
- openSettings,
2038
- setAgent
2039
- };
2040
- }
2041
-
2042
- //#endregion
2043
- //#region src/tui/tui-stream-assembler.ts
2044
- function extractTextBlocksAndSignals(message) {
2045
- if (!message || typeof message !== "object") return {
2046
- textBlocks: [],
2047
- sawNonTextContentBlocks: false
2048
- };
2049
- const content = message.content;
2050
- if (typeof content === "string") {
2051
- const text = content.trim();
2052
- return {
2053
- textBlocks: text ? [text] : [],
2054
- sawNonTextContentBlocks: false
2055
- };
2056
- }
2057
- if (!Array.isArray(content)) return {
2058
- textBlocks: [],
2059
- sawNonTextContentBlocks: false
2060
- };
2061
- const textBlocks = [];
2062
- let sawNonTextContentBlocks = false;
2063
- for (const block of content) {
2064
- if (!block || typeof block !== "object") continue;
2065
- const rec = block;
2066
- if (rec.type === "text" && typeof rec.text === "string") {
2067
- const text = rec.text.trim();
2068
- if (text) textBlocks.push(text);
2069
- continue;
2070
- }
2071
- if (typeof rec.type === "string" && rec.type !== "thinking") sawNonTextContentBlocks = true;
2072
- }
2073
- return {
2074
- textBlocks,
2075
- sawNonTextContentBlocks
2076
- };
2077
- }
2078
- function isDroppedBoundaryTextBlockSubset(params) {
2079
- const { streamedTextBlocks, finalTextBlocks } = params;
2080
- if (finalTextBlocks.length === 0 || finalTextBlocks.length >= streamedTextBlocks.length) return false;
2081
- if (finalTextBlocks.every((block, index) => streamedTextBlocks[index] === block)) return true;
2082
- const suffixStart = streamedTextBlocks.length - finalTextBlocks.length;
2083
- return finalTextBlocks.every((block, index) => streamedTextBlocks[suffixStart + index] === block);
2084
- }
2085
- var TuiStreamAssembler = class {
2086
- constructor() {
2087
- this.runs = /* @__PURE__ */ new Map();
2088
- }
2089
- getOrCreateRun(runId) {
2090
- let state = this.runs.get(runId);
2091
- if (!state) {
2092
- state = {
2093
- thinkingText: "",
2094
- contentText: "",
2095
- contentBlocks: [],
2096
- sawNonTextContentBlocks: false,
2097
- displayText: ""
2098
- };
2099
- this.runs.set(runId, state);
2100
- }
2101
- return state;
2102
- }
2103
- updateRunState(state, message, showThinking, opts) {
2104
- const thinkingText = extractThinkingFromMessage(message);
2105
- const contentText = extractContentFromMessage(message);
2106
- const { textBlocks, sawNonTextContentBlocks } = extractTextBlocksAndSignals(message);
2107
- if (thinkingText) state.thinkingText = thinkingText;
2108
- if (contentText) {
2109
- const nextContentBlocks = textBlocks.length > 0 ? textBlocks : [contentText];
2110
- if (!(opts?.protectBoundaryDrops === true && (state.sawNonTextContentBlocks || sawNonTextContentBlocks) && isDroppedBoundaryTextBlockSubset({
2111
- streamedTextBlocks: state.contentBlocks,
2112
- finalTextBlocks: nextContentBlocks
2113
- }))) {
2114
- state.contentText = contentText;
2115
- state.contentBlocks = nextContentBlocks;
2116
- }
2117
- }
2118
- if (sawNonTextContentBlocks) state.sawNonTextContentBlocks = true;
2119
- state.displayText = composeThinkingAndContent({
2120
- thinkingText: state.thinkingText,
2121
- contentText: state.contentText,
2122
- showThinking
2123
- });
2124
- }
2125
- ingestDelta(runId, message, showThinking) {
2126
- const state = this.getOrCreateRun(runId);
2127
- const previousDisplayText = state.displayText;
2128
- this.updateRunState(state, message, showThinking, { protectBoundaryDrops: true });
2129
- if (!state.displayText || state.displayText === previousDisplayText) return null;
2130
- return state.displayText;
2131
- }
2132
- finalize(runId, message, showThinking) {
2133
- const state = this.getOrCreateRun(runId);
2134
- const streamedDisplayText = state.displayText;
2135
- const streamedTextBlocks = [...state.contentBlocks];
2136
- const streamedSawNonTextContentBlocks = state.sawNonTextContentBlocks;
2137
- this.updateRunState(state, message, showThinking);
2138
- const finalComposed = state.displayText;
2139
- const finalText = resolveFinalAssistantText({
2140
- finalText: streamedSawNonTextContentBlocks && isDroppedBoundaryTextBlockSubset({
2141
- streamedTextBlocks,
2142
- finalTextBlocks: state.contentBlocks
2143
- }) ? streamedDisplayText : finalComposed,
2144
- streamedText: streamedDisplayText
2145
- });
2146
- this.runs.delete(runId);
2147
- return finalText;
2148
- }
2149
- drop(runId) {
2150
- this.runs.delete(runId);
2151
- }
2152
- };
2153
-
2154
- //#endregion
2155
- //#region src/tui/tui-event-handlers.ts
2156
- function createEventHandlers(context) {
2157
- const { chatLog, tui, state, setActivityStatus, refreshSessionInfo, loadHistory, isLocalRunId, forgetLocalRunId, clearLocalRunIds } = context;
2158
- const finalizedRuns = /* @__PURE__ */ new Map();
2159
- const sessionRuns = /* @__PURE__ */ new Map();
2160
- let streamAssembler = new TuiStreamAssembler();
2161
- let lastSessionKey = state.currentSessionKey;
2162
- const pruneRunMap = (runs) => {
2163
- if (runs.size <= 200) return;
2164
- const keepUntil = Date.now() - 600 * 1e3;
2165
- for (const [key, ts] of runs) {
2166
- if (runs.size <= 150) break;
2167
- if (ts < keepUntil) runs.delete(key);
2168
- }
2169
- if (runs.size > 200) for (const key of runs.keys()) {
2170
- runs.delete(key);
2171
- if (runs.size <= 150) break;
2172
- }
2173
- };
2174
- const syncSessionKey = () => {
2175
- if (state.currentSessionKey === lastSessionKey) return;
2176
- lastSessionKey = state.currentSessionKey;
2177
- finalizedRuns.clear();
2178
- sessionRuns.clear();
2179
- streamAssembler = new TuiStreamAssembler();
2180
- clearLocalRunIds?.();
2181
- };
2182
- const noteSessionRun = (runId) => {
2183
- sessionRuns.set(runId, Date.now());
2184
- pruneRunMap(sessionRuns);
2185
- };
2186
- const noteFinalizedRun = (runId) => {
2187
- finalizedRuns.set(runId, Date.now());
2188
- sessionRuns.delete(runId);
2189
- streamAssembler.drop(runId);
2190
- pruneRunMap(finalizedRuns);
2191
- };
2192
- const clearActiveRunIfMatch = (runId) => {
2193
- if (state.activeChatRunId === runId) state.activeChatRunId = null;
2194
- };
2195
- const finalizeRun = (params) => {
2196
- noteFinalizedRun(params.runId);
2197
- clearActiveRunIfMatch(params.runId);
2198
- if (params.wasActiveRun) setActivityStatus(params.status);
2199
- refreshSessionInfo?.();
2200
- };
2201
- const terminateRun = (params) => {
2202
- streamAssembler.drop(params.runId);
2203
- sessionRuns.delete(params.runId);
2204
- clearActiveRunIfMatch(params.runId);
2205
- if (params.wasActiveRun) setActivityStatus(params.status);
2206
- refreshSessionInfo?.();
2207
- };
2208
- const hasConcurrentActiveRun = (runId) => {
2209
- const activeRunId = state.activeChatRunId;
2210
- if (!activeRunId || activeRunId === runId) return false;
2211
- return sessionRuns.has(activeRunId);
2212
- };
2213
- const maybeRefreshHistoryForRun = (runId) => {
2214
- if (isLocalRunId?.(runId)) {
2215
- forgetLocalRunId?.(runId);
2216
- return;
2217
- }
2218
- if (hasConcurrentActiveRun(runId)) return;
2219
- loadHistory?.();
2220
- };
2221
- const handleChatEvent = (payload) => {
2222
- if (!payload || typeof payload !== "object") return;
2223
- const evt = payload;
2224
- syncSessionKey();
2225
- if (evt.sessionKey !== state.currentSessionKey) return;
2226
- if (finalizedRuns.has(evt.runId)) {
2227
- if (evt.state === "delta") return;
2228
- if (evt.state === "final") return;
2229
- }
2230
- noteSessionRun(evt.runId);
2231
- if (!state.activeChatRunId) state.activeChatRunId = evt.runId;
2232
- if (evt.state === "delta") {
2233
- const displayText = streamAssembler.ingestDelta(evt.runId, evt.message, state.showThinking);
2234
- if (!displayText) return;
2235
- chatLog.updateAssistant(displayText, evt.runId);
2236
- setActivityStatus("streaming");
2237
- }
2238
- if (evt.state === "final") {
2239
- const wasActiveRun = state.activeChatRunId === evt.runId;
2240
- if (!evt.message) {
2241
- maybeRefreshHistoryForRun(evt.runId);
2242
- chatLog.dropAssistant(evt.runId);
2243
- finalizeRun({
2244
- runId: evt.runId,
2245
- wasActiveRun,
2246
- status: "idle"
2247
- });
2248
- tui.requestRender();
2249
- return;
2250
- }
2251
- if (isCommandMessage(evt.message)) {
2252
- maybeRefreshHistoryForRun(evt.runId);
2253
- const text = extractTextFromMessage(evt.message);
2254
- if (text) chatLog.addSystem(text);
2255
- finalizeRun({
2256
- runId: evt.runId,
2257
- wasActiveRun,
2258
- status: "idle"
2259
- });
2260
- tui.requestRender();
2261
- return;
2262
- }
2263
- maybeRefreshHistoryForRun(evt.runId);
2264
- const stopReason = evt.message && typeof evt.message === "object" && !Array.isArray(evt.message) ? typeof evt.message.stopReason === "string" ? evt.message.stopReason : "" : "";
2265
- const finalText = streamAssembler.finalize(evt.runId, evt.message, state.showThinking);
2266
- if (finalText === "(no output)" && !isLocalRunId?.(evt.runId)) chatLog.dropAssistant(evt.runId);
2267
- else chatLog.finalizeAssistant(finalText, evt.runId);
2268
- finalizeRun({
2269
- runId: evt.runId,
2270
- wasActiveRun,
2271
- status: stopReason === "error" ? "error" : "idle"
2272
- });
2273
- }
2274
- if (evt.state === "aborted") {
2275
- const wasActiveRun = state.activeChatRunId === evt.runId;
2276
- chatLog.addSystem("run aborted");
2277
- terminateRun({
2278
- runId: evt.runId,
2279
- wasActiveRun,
2280
- status: "aborted"
2281
- });
2282
- maybeRefreshHistoryForRun(evt.runId);
2283
- }
2284
- if (evt.state === "error") {
2285
- const wasActiveRun = state.activeChatRunId === evt.runId;
2286
- chatLog.addSystem(`run error: ${evt.errorMessage ?? "unknown"}`);
2287
- terminateRun({
2288
- runId: evt.runId,
2289
- wasActiveRun,
2290
- status: "error"
2291
- });
2292
- maybeRefreshHistoryForRun(evt.runId);
2293
- }
2294
- tui.requestRender();
2295
- };
2296
- const handleAgentEvent = (payload) => {
2297
- if (!payload || typeof payload !== "object") return;
2298
- const evt = payload;
2299
- syncSessionKey();
2300
- const isActiveRun = evt.runId === state.activeChatRunId;
2301
- if (!(isActiveRun || sessionRuns.has(evt.runId) || finalizedRuns.has(evt.runId))) return;
2302
- if (evt.stream === "tool") {
2303
- const verbose = state.sessionInfo.verboseLevel ?? "off";
2304
- const allowToolEvents = verbose !== "off";
2305
- const allowToolOutput = verbose === "full";
2306
- if (!allowToolEvents) return;
2307
- const data = evt.data ?? {};
2308
- const phase = asString(data.phase, "");
2309
- const toolCallId = asString(data.toolCallId, "");
2310
- const toolName = asString(data.name, "tool");
2311
- if (!toolCallId) return;
2312
- if (phase === "start") chatLog.startTool(toolCallId, toolName, data.args);
2313
- else if (phase === "update") {
2314
- if (!allowToolOutput) return;
2315
- chatLog.updateToolResult(toolCallId, data.partialResult, { partial: true });
2316
- } else if (phase === "result") if (allowToolOutput) chatLog.updateToolResult(toolCallId, data.result, { isError: Boolean(data.isError) });
2317
- else chatLog.updateToolResult(toolCallId, { content: [] }, { isError: Boolean(data.isError) });
2318
- tui.requestRender();
2319
- return;
2320
- }
2321
- if (evt.stream === "lifecycle") {
2322
- if (!isActiveRun) return;
2323
- const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
2324
- if (phase === "start") setActivityStatus("running");
2325
- if (phase === "end") setActivityStatus("idle");
2326
- if (phase === "error") setActivityStatus("error");
2327
- tui.requestRender();
2328
- }
2329
- };
2330
- return {
2331
- handleChatEvent,
2332
- handleAgentEvent
2333
- };
2334
- }
2335
-
2336
- //#endregion
2337
- //#region src/tui/tui-local-shell.ts
2338
- function createLocalShellRunner(deps) {
2339
- let localExecAsked = false;
2340
- let localExecAllowed = false;
2341
- const createSelector = deps.createSelector ?? createSearchableSelectList;
2342
- const spawnCommand = deps.spawnCommand ?? spawn;
2343
- const getCwd = deps.getCwd ?? (() => process.cwd());
2344
- const env = deps.env ?? process.env;
2345
- const maxChars = deps.maxOutputChars ?? 4e4;
2346
- const ensureLocalExecAllowed = async () => {
2347
- if (localExecAllowed) return true;
2348
- if (localExecAsked) return false;
2349
- localExecAsked = true;
2350
- return await new Promise((resolve) => {
2351
- deps.chatLog.addSystem("Allow local shell commands for this session?");
2352
- deps.chatLog.addSystem("This runs commands on YOUR machine (not the gateway) and may delete files or reveal secrets.");
2353
- deps.chatLog.addSystem("Select Yes/No (arrows + Enter), Esc to cancel.");
2354
- const selector = createSelector([{
2355
- value: "no",
2356
- label: "No"
2357
- }, {
2358
- value: "yes",
2359
- label: "Yes"
2360
- }], 2);
2361
- selector.onSelect = (item) => {
2362
- deps.closeOverlay();
2363
- if (item.value === "yes") {
2364
- localExecAllowed = true;
2365
- deps.chatLog.addSystem("local shell: enabled for this session");
2366
- resolve(true);
2367
- } else {
2368
- deps.chatLog.addSystem("local shell: not enabled");
2369
- resolve(false);
2370
- }
2371
- deps.tui.requestRender();
2372
- };
2373
- selector.onCancel = () => {
2374
- deps.closeOverlay();
2375
- deps.chatLog.addSystem("local shell: cancelled");
2376
- deps.tui.requestRender();
2377
- resolve(false);
2378
- };
2379
- deps.openOverlay(selector);
2380
- deps.tui.requestRender();
2381
- });
2382
- };
2383
- const runLocalShellLine = async (line) => {
2384
- const cmd = line.slice(1);
2385
- if (cmd === "") return;
2386
- if (localExecAsked && !localExecAllowed) {
2387
- deps.chatLog.addSystem("local shell: not enabled for this session");
2388
- deps.tui.requestRender();
2389
- return;
2390
- }
2391
- if (!await ensureLocalExecAllowed()) return;
2392
- deps.chatLog.addSystem(`[local] $ ${cmd}`);
2393
- deps.tui.requestRender();
2394
- const appendWithCap = (text, chunk) => {
2395
- const combined = text + chunk;
2396
- return combined.length > maxChars ? combined.slice(-maxChars) : combined;
2397
- };
2398
- await new Promise((resolve) => {
2399
- const child = spawnCommand(cmd, {
2400
- shell: true,
2401
- cwd: getCwd(),
2402
- env
2403
- });
2404
- let stdout = "";
2405
- let stderr = "";
2406
- child.stdout.on("data", (buf) => {
2407
- stdout = appendWithCap(stdout, buf.toString("utf8"));
2408
- });
2409
- child.stderr.on("data", (buf) => {
2410
- stderr = appendWithCap(stderr, buf.toString("utf8"));
2411
- });
2412
- child.on("close", (code, signal) => {
2413
- const combined = (stdout + (stderr ? (stdout ? "\n" : "") + stderr : "")).slice(0, maxChars).trimEnd();
2414
- if (combined) for (const line of combined.split("\n")) deps.chatLog.addSystem(`[local] ${line}`);
2415
- deps.chatLog.addSystem(`[local] exit ${code ?? "?"}${signal ? ` (signal ${String(signal)})` : ""}`);
2416
- deps.tui.requestRender();
2417
- resolve();
2418
- });
2419
- child.on("error", (err) => {
2420
- deps.chatLog.addSystem(`[local] error: ${String(err)}`);
2421
- deps.tui.requestRender();
2422
- resolve();
2423
- });
2424
- });
2425
- };
2426
- return { runLocalShellLine };
2427
- }
2428
-
2429
- //#endregion
2430
- //#region src/tui/tui-overlays.ts
2431
- function createOverlayHandlers(host, fallbackFocus) {
2432
- const openOverlay = (component) => {
2433
- host.showOverlay(component);
2434
- };
2435
- const closeOverlay = () => {
2436
- if (host.hasOverlay()) {
2437
- host.hideOverlay();
2438
- return;
2439
- }
2440
- host.setFocus(fallbackFocus);
2441
- };
2442
- return {
2443
- openOverlay,
2444
- closeOverlay
2445
- };
2446
- }
2447
-
2448
- //#endregion
2449
- //#region src/tui/tui-session-actions.ts
2450
- function createSessionActions(context) {
2451
- const { client, chatLog, tui, opts, state, agentNames, initialSessionInput, initialSessionAgentId, resolveSessionKey, updateHeader, updateFooter, updateAutocompleteProvider, setActivityStatus, clearLocalRunIds } = context;
2452
- let refreshSessionInfoPromise = Promise.resolve();
2453
- let lastSessionDefaults = null;
2454
- const applyAgentsResult = (result) => {
2455
- state.agentDefaultId = normalizeAgentId(result.defaultId);
2456
- state.sessionMainKey = normalizeMainKey(result.mainKey);
2457
- state.sessionScope = result.scope ?? state.sessionScope;
2458
- state.agents = result.agents.map((agent) => ({
2459
- id: normalizeAgentId(agent.id),
2460
- name: agent.name?.trim() || void 0
2461
- }));
2462
- agentNames.clear();
2463
- for (const agent of state.agents) if (agent.name) agentNames.set(agent.id, agent.name);
2464
- if (!state.initialSessionApplied) {
2465
- if (initialSessionAgentId) {
2466
- if (state.agents.some((agent) => agent.id === initialSessionAgentId)) state.currentAgentId = initialSessionAgentId;
2467
- } else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
2468
- const nextSessionKey = resolveSessionKey(initialSessionInput);
2469
- if (nextSessionKey !== state.currentSessionKey) state.currentSessionKey = nextSessionKey;
2470
- state.initialSessionApplied = true;
2471
- } else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
2472
- updateHeader();
2473
- updateFooter();
2474
- };
2475
- const refreshAgents = async () => {
2476
- try {
2477
- applyAgentsResult(await client.listAgents());
2478
- } catch (err) {
2479
- chatLog.addSystem(`agents list failed: ${String(err)}`);
2480
- }
2481
- };
2482
- const updateAgentFromSessionKey = (key) => {
2483
- const parsed = parseAgentSessionKey(key);
2484
- if (!parsed) return;
2485
- const next = normalizeAgentId(parsed.agentId);
2486
- if (next !== state.currentAgentId) state.currentAgentId = next;
2487
- };
2488
- const resolveModelSelection = (entry) => {
2489
- if (entry?.modelProvider || entry?.model) return {
2490
- modelProvider: entry.modelProvider ?? state.sessionInfo.modelProvider,
2491
- model: entry.model ?? state.sessionInfo.model
2492
- };
2493
- const overrideModel = entry?.modelOverride?.trim();
2494
- if (overrideModel) return {
2495
- modelProvider: entry?.providerOverride?.trim() || state.sessionInfo.modelProvider,
2496
- model: overrideModel
2497
- };
2498
- return {
2499
- modelProvider: state.sessionInfo.modelProvider,
2500
- model: state.sessionInfo.model
2501
- };
2502
- };
2503
- const applySessionInfo = (params) => {
2504
- const entry = params.entry ?? void 0;
2505
- const defaults = params.defaults ?? lastSessionDefaults ?? void 0;
2506
- const previousDefaults = lastSessionDefaults;
2507
- const defaultsChanged = params.defaults ? previousDefaults?.model !== params.defaults.model || previousDefaults?.modelProvider !== params.defaults.modelProvider || previousDefaults?.contextTokens !== params.defaults.contextTokens : false;
2508
- if (params.defaults) lastSessionDefaults = params.defaults;
2509
- const entryUpdatedAt = entry?.updatedAt ?? null;
2510
- const currentUpdatedAt = state.sessionInfo.updatedAt ?? null;
2511
- const modelChanged = entry?.modelProvider !== void 0 && entry.modelProvider !== state.sessionInfo.modelProvider || entry?.model !== void 0 && entry.model !== state.sessionInfo.model;
2512
- if (!params.force && entryUpdatedAt !== null && currentUpdatedAt !== null && entryUpdatedAt < currentUpdatedAt && !defaultsChanged && !modelChanged) return;
2513
- const next = { ...state.sessionInfo };
2514
- if (entry?.thinkingLevel !== void 0) next.thinkingLevel = entry.thinkingLevel;
2515
- if (entry?.verboseLevel !== void 0) next.verboseLevel = entry.verboseLevel;
2516
- if (entry?.reasoningLevel !== void 0) next.reasoningLevel = entry.reasoningLevel;
2517
- if (entry?.responseUsage !== void 0) next.responseUsage = entry.responseUsage;
2518
- if (entry?.inputTokens !== void 0) next.inputTokens = entry.inputTokens;
2519
- if (entry?.outputTokens !== void 0) next.outputTokens = entry.outputTokens;
2520
- if (entry?.totalTokens !== void 0) next.totalTokens = entry.totalTokens;
2521
- if (entry?.contextTokens !== void 0 || defaults?.contextTokens !== void 0) next.contextTokens = entry?.contextTokens ?? defaults?.contextTokens ?? state.sessionInfo.contextTokens;
2522
- if (entry?.displayName !== void 0) next.displayName = entry.displayName;
2523
- if (entry?.updatedAt !== void 0) next.updatedAt = entry.updatedAt;
2524
- const selection = resolveModelSelection(entry);
2525
- if (selection.modelProvider !== void 0) next.modelProvider = selection.modelProvider;
2526
- if (selection.model !== void 0) next.model = selection.model;
2527
- state.sessionInfo = next;
2528
- updateAutocompleteProvider();
2529
- updateFooter();
2530
- tui.requestRender();
2531
- };
2532
- const runRefreshSessionInfo = async () => {
2533
- try {
2534
- const resolveListAgentId = () => {
2535
- if (state.currentSessionKey === "global" || state.currentSessionKey === "unknown") return;
2536
- const parsed = parseAgentSessionKey(state.currentSessionKey);
2537
- return parsed?.agentId ? normalizeAgentId(parsed.agentId) : state.currentAgentId;
2538
- };
2539
- const listAgentId = resolveListAgentId();
2540
- const result = await client.listSessions({
2541
- includeGlobal: false,
2542
- includeUnknown: false,
2543
- agentId: listAgentId
2544
- });
2545
- const normalizeMatchKey = (key) => parseAgentSessionKey(key)?.rest ?? key;
2546
- const currentMatchKey = normalizeMatchKey(state.currentSessionKey);
2547
- const entry = result.sessions.find((row) => {
2548
- if (row.key === state.currentSessionKey) return true;
2549
- return normalizeMatchKey(row.key) === currentMatchKey;
2550
- });
2551
- if (entry?.key && entry.key !== state.currentSessionKey) {
2552
- updateAgentFromSessionKey(entry.key);
2553
- state.currentSessionKey = entry.key;
2554
- updateHeader();
2555
- }
2556
- applySessionInfo({
2557
- entry,
2558
- defaults: result.defaults
2559
- });
2560
- } catch (err) {
2561
- chatLog.addSystem(`sessions list failed: ${String(err)}`);
2562
- }
2563
- };
2564
- const refreshSessionInfo = async () => {
2565
- refreshSessionInfoPromise = refreshSessionInfoPromise.then(runRefreshSessionInfo, runRefreshSessionInfo);
2566
- await refreshSessionInfoPromise;
2567
- };
2568
- const applySessionInfoFromPatch = (result) => {
2569
- if (!result?.entry) return;
2570
- if (result.key && result.key !== state.currentSessionKey) {
2571
- updateAgentFromSessionKey(result.key);
2572
- state.currentSessionKey = result.key;
2573
- updateHeader();
2574
- }
2575
- const resolved = result.resolved;
2576
- applySessionInfo({
2577
- entry: resolved && (resolved.modelProvider || resolved.model) ? {
2578
- ...result.entry,
2579
- modelProvider: resolved.modelProvider ?? result.entry.modelProvider,
2580
- model: resolved.model ?? result.entry.model
2581
- } : result.entry,
2582
- force: true
2583
- });
2584
- };
2585
- const loadHistory = async () => {
2586
- try {
2587
- const record = await client.loadHistory({
2588
- sessionKey: state.currentSessionKey,
2589
- limit: opts.historyLimit ?? 200
2590
- });
2591
- state.currentSessionId = typeof record.sessionId === "string" ? record.sessionId : null;
2592
- state.sessionInfo.thinkingLevel = record.thinkingLevel ?? state.sessionInfo.thinkingLevel;
2593
- state.sessionInfo.verboseLevel = record.verboseLevel ?? state.sessionInfo.verboseLevel;
2594
- const showTools = (state.sessionInfo.verboseLevel ?? "off") !== "off";
2595
- chatLog.clearAll();
2596
- chatLog.addSystem(`session ${state.currentSessionKey}`);
2597
- for (const entry of record.messages ?? []) {
2598
- if (!entry || typeof entry !== "object") continue;
2599
- const message = entry;
2600
- if (isCommandMessage(message)) {
2601
- const text = extractTextFromMessage(message);
2602
- if (text) chatLog.addSystem(text);
2603
- continue;
2604
- }
2605
- if (message.role === "user") {
2606
- const text = extractTextFromMessage(message);
2607
- if (text) chatLog.addUser(text);
2608
- continue;
2609
- }
2610
- if (message.role === "assistant") {
2611
- const text = extractTextFromMessage(message, { includeThinking: state.showThinking });
2612
- if (text) chatLog.finalizeAssistant(text);
2613
- continue;
2614
- }
2615
- if (message.role === "toolResult") {
2616
- if (!showTools) continue;
2617
- const toolCallId = asString(message.toolCallId, "");
2618
- const toolName = asString(message.toolName, "tool");
2619
- chatLog.startTool(toolCallId, toolName, {}).setResult({
2620
- content: Array.isArray(message.content) ? message.content : [],
2621
- details: typeof message.details === "object" && message.details ? message.details : void 0
2622
- }, { isError: Boolean(message.isError) });
2623
- }
2624
- }
2625
- state.historyLoaded = true;
2626
- } catch (err) {
2627
- chatLog.addSystem(`history failed: ${String(err)}`);
2628
- }
2629
- await refreshSessionInfo();
2630
- tui.requestRender();
2631
- };
2632
- const setSession = async (rawKey) => {
2633
- const nextKey = resolveSessionKey(rawKey);
2634
- updateAgentFromSessionKey(nextKey);
2635
- state.currentSessionKey = nextKey;
2636
- state.activeChatRunId = null;
2637
- state.currentSessionId = null;
2638
- state.historyLoaded = false;
2639
- clearLocalRunIds?.();
2640
- updateHeader();
2641
- updateFooter();
2642
- await loadHistory();
2643
- };
2644
- const abortActive = async () => {
2645
- if (!state.activeChatRunId) {
2646
- chatLog.addSystem("no active run");
2647
- tui.requestRender();
2648
- return;
2649
- }
2650
- try {
2651
- await client.abortChat({
2652
- sessionKey: state.currentSessionKey,
2653
- runId: state.activeChatRunId
2654
- });
2655
- setActivityStatus("aborted");
2656
- } catch (err) {
2657
- chatLog.addSystem(`abort failed: ${String(err)}`);
2658
- setActivityStatus("abort failed");
2659
- }
2660
- tui.requestRender();
2661
- };
2662
- return {
2663
- applyAgentsResult,
2664
- refreshAgents,
2665
- refreshSessionInfo,
2666
- applySessionInfoFromPatch,
2667
- loadHistory,
2668
- setSession,
2669
- abortActive
2670
- };
2671
- }
2672
-
2673
- //#endregion
2674
- //#region src/tui/tui-waiting.ts
2675
- const defaultWaitingPhrases = [
2676
- "flibbertigibbeting",
2677
- "kerfuffling",
2678
- "dillydallying",
2679
- "twiddling thumbs",
2680
- "noodling",
2681
- "bamboozling",
2682
- "moseying",
2683
- "hobnobbing",
2684
- "pondering",
2685
- "conjuring"
2686
- ];
2687
- function pickWaitingPhrase(tick, phrases = defaultWaitingPhrases) {
2688
- return phrases[Math.floor(tick / 10) % phrases.length] ?? phrases[0] ?? "waiting";
2689
- }
2690
- function shimmerText(theme, text, tick) {
2691
- const width = 6;
2692
- const hi = (ch) => theme.bold(theme.accentSoft(ch));
2693
- const pos = tick % (text.length + width);
2694
- const start = Math.max(0, pos - width);
2695
- const end = Math.min(text.length - 1, pos);
2696
- let out = "";
2697
- for (let i = 0; i < text.length; i++) {
2698
- const ch = text[i];
2699
- out += i >= start && i <= end ? hi(ch) : theme.dim(ch);
2700
- }
2701
- return out;
2702
- }
2703
- function buildWaitingStatusMessage(params) {
2704
- const phrase = pickWaitingPhrase(params.tick, params.phrases);
2705
- return `${shimmerText(params.theme, `${phrase}…`, params.tick)} • ${params.elapsed} | ${params.connectionStatus}`;
2706
- }
2707
-
2708
- //#endregion
2709
- //#region src/tui/tui.ts
2710
- function createEditorSubmitHandler(params) {
2711
- return (text) => {
2712
- const raw = text;
2713
- const value = raw.trim();
2714
- params.editor.setText("");
2715
- if (!value) return;
2716
- if (raw.startsWith("!") && raw !== "!") {
2717
- params.editor.addToHistory(raw);
2718
- params.handleBangLine(raw);
2719
- return;
2720
- }
2721
- params.editor.addToHistory(value);
2722
- if (value.startsWith("/")) {
2723
- params.handleCommand(value);
2724
- return;
2725
- }
2726
- params.sendMessage(value);
2727
- };
2728
- }
2729
- function shouldEnableWindowsGitBashPasteFallback(params) {
2730
- const platform = params?.platform ?? process.platform;
2731
- const env = params?.env ?? process.env;
2732
- const termProgram = (env.TERM_PROGRAM ?? "").toLowerCase();
2733
- if (platform === "darwin") {
2734
- if (termProgram.includes("iterm") || termProgram.includes("apple_terminal")) return true;
2735
- return false;
2736
- }
2737
- if (platform !== "win32") return false;
2738
- const msystem = (env.MSYSTEM ?? "").toUpperCase();
2739
- const shell = env.SHELL ?? "";
2740
- if (msystem.startsWith("MINGW") || msystem.startsWith("MSYS")) return true;
2741
- if (shell.toLowerCase().includes("bash")) return true;
2742
- return termProgram.includes("mintty");
2743
- }
2744
- function createSubmitBurstCoalescer(params) {
2745
- const windowMs = Math.max(1, params.burstWindowMs ?? 50);
2746
- const now = params.now ?? (() => Date.now());
2747
- const setTimer = params.setTimer ?? setTimeout;
2748
- const clearTimer = params.clearTimer ?? clearTimeout;
2749
- let pending = null;
2750
- let pendingAt = 0;
2751
- let flushTimer = null;
2752
- const clearFlushTimer = () => {
2753
- if (!flushTimer) return;
2754
- clearTimer(flushTimer);
2755
- flushTimer = null;
2756
- };
2757
- const flushPending = () => {
2758
- if (pending === null) return;
2759
- const value = pending;
2760
- pending = null;
2761
- pendingAt = 0;
2762
- clearFlushTimer();
2763
- params.submit(value);
2764
- };
2765
- const scheduleFlush = () => {
2766
- clearFlushTimer();
2767
- flushTimer = setTimer(() => {
2768
- flushPending();
2769
- }, windowMs);
2770
- };
2771
- return (value) => {
2772
- if (!params.enabled) {
2773
- params.submit(value);
2774
- return;
2775
- }
2776
- if (value.includes("\n")) {
2777
- flushPending();
2778
- params.submit(value);
2779
- return;
2780
- }
2781
- const ts = now();
2782
- if (pending === null) {
2783
- pending = value;
2784
- pendingAt = ts;
2785
- scheduleFlush();
2786
- return;
2787
- }
2788
- if (ts - pendingAt <= windowMs) {
2789
- pending = `${pending}\n${value}`;
2790
- pendingAt = ts;
2791
- scheduleFlush();
2792
- return;
2793
- }
2794
- flushPending();
2795
- pending = value;
2796
- pendingAt = ts;
2797
- scheduleFlush();
2798
- };
2799
- }
2800
- function resolveTuiSessionKey(params) {
2801
- const trimmed = (params.raw ?? "").trim();
2802
- if (!trimmed) {
2803
- if (params.sessionScope === "global") return "global";
2804
- return buildAgentMainSessionKey({
2805
- agentId: params.currentAgentId,
2806
- mainKey: params.sessionMainKey
2807
- });
2808
- }
2809
- if (trimmed === "global" || trimmed === "unknown") return trimmed;
2810
- if (trimmed.startsWith("agent:")) return trimmed;
2811
- return `agent:${params.currentAgentId}:${trimmed}`;
2812
- }
2813
- function resolveGatewayDisconnectState(reason) {
2814
- const reasonLabel = reason?.trim() ? reason.trim() : "closed";
2815
- if (/pairing required/i.test(reasonLabel)) return {
2816
- connectionStatus: `gateway disconnected: ${reasonLabel}`,
2817
- activityStatus: "pairing required: run remoteclaw devices list",
2818
- pairingHint: "Pairing required. Run `remoteclaw devices list`, approve your request ID, then reconnect."
2819
- };
2820
- return {
2821
- connectionStatus: `gateway disconnected: ${reasonLabel}`,
2822
- activityStatus: "idle"
2823
- };
2824
- }
2825
- function createBackspaceDeduper(params) {
2826
- const dedupeWindowMs = Math.max(0, Math.floor(params?.dedupeWindowMs ?? 8));
2827
- const now = params?.now ?? (() => Date.now());
2828
- let lastBackspaceAt = -1;
2829
- return (data) => {
2830
- if (!matchesKey(data, Key.backspace)) return data;
2831
- const ts = now();
2832
- if (lastBackspaceAt >= 0 && ts - lastBackspaceAt <= dedupeWindowMs) return "";
2833
- lastBackspaceAt = ts;
2834
- return data;
2835
- };
2836
- }
2837
- function resolveCtrlCAction(params) {
2838
- const exitWindowMs = Math.max(1, Math.floor(params.exitWindowMs ?? 1e3));
2839
- if (params.hasInput) return {
2840
- action: "clear",
2841
- nextLastCtrlCAt: params.now
2842
- };
2843
- if (params.now - params.lastCtrlCAt <= exitWindowMs) return {
2844
- action: "exit",
2845
- nextLastCtrlCAt: params.lastCtrlCAt
2846
- };
2847
- return {
2848
- action: "warn",
2849
- nextLastCtrlCAt: params.now
2850
- };
2851
- }
2852
- async function runTui(opts) {
2853
- const config = loadConfig();
2854
- const initialSessionInput = (opts.session ?? "").trim();
2855
- let sessionScope = config.session?.scope ?? "per-sender";
2856
- let sessionMainKey = normalizeMainKey(config.session?.mainKey);
2857
- let agentDefaultId = resolveDefaultAgentId(config);
2858
- let currentAgentId = agentDefaultId;
2859
- let agents = [];
2860
- const agentNames = /* @__PURE__ */ new Map();
2861
- let currentSessionKey = "";
2862
- let initialSessionApplied = false;
2863
- let currentSessionId = null;
2864
- let activeChatRunId = null;
2865
- let historyLoaded = false;
2866
- let isConnected = false;
2867
- let wasDisconnected = false;
2868
- let toolsExpanded = false;
2869
- let showThinking = false;
2870
- let pairingHintShown = false;
2871
- const localRunIds = /* @__PURE__ */ new Set();
2872
- const deliverDefault = opts.deliver ?? false;
2873
- const autoMessage = opts.message?.trim();
2874
- let autoMessageSent = false;
2875
- let sessionInfo = {};
2876
- let lastCtrlCAt = 0;
2877
- let exitRequested = false;
2878
- let activityStatus = "idle";
2879
- let connectionStatus = "connecting";
2880
- let statusTimeout = null;
2881
- let statusTimer = null;
2882
- let statusStartedAt = null;
2883
- let lastActivityStatus = activityStatus;
2884
- const state = {
2885
- get agentDefaultId() {
2886
- return agentDefaultId;
2887
- },
2888
- set agentDefaultId(value) {
2889
- agentDefaultId = value;
2890
- },
2891
- get sessionMainKey() {
2892
- return sessionMainKey;
2893
- },
2894
- set sessionMainKey(value) {
2895
- sessionMainKey = value;
2896
- },
2897
- get sessionScope() {
2898
- return sessionScope;
2899
- },
2900
- set sessionScope(value) {
2901
- sessionScope = value;
2902
- },
2903
- get agents() {
2904
- return agents;
2905
- },
2906
- set agents(value) {
2907
- agents = value;
2908
- },
2909
- get currentAgentId() {
2910
- return currentAgentId;
2911
- },
2912
- set currentAgentId(value) {
2913
- currentAgentId = value;
2914
- },
2915
- get currentSessionKey() {
2916
- return currentSessionKey;
2917
- },
2918
- set currentSessionKey(value) {
2919
- currentSessionKey = value;
2920
- },
2921
- get currentSessionId() {
2922
- return currentSessionId;
2923
- },
2924
- set currentSessionId(value) {
2925
- currentSessionId = value;
2926
- },
2927
- get activeChatRunId() {
2928
- return activeChatRunId;
2929
- },
2930
- set activeChatRunId(value) {
2931
- activeChatRunId = value;
2932
- },
2933
- get historyLoaded() {
2934
- return historyLoaded;
2935
- },
2936
- set historyLoaded(value) {
2937
- historyLoaded = value;
2938
- },
2939
- get sessionInfo() {
2940
- return sessionInfo;
2941
- },
2942
- set sessionInfo(value) {
2943
- sessionInfo = value;
2944
- },
2945
- get initialSessionApplied() {
2946
- return initialSessionApplied;
2947
- },
2948
- set initialSessionApplied(value) {
2949
- initialSessionApplied = value;
2950
- },
2951
- get isConnected() {
2952
- return isConnected;
2953
- },
2954
- set isConnected(value) {
2955
- isConnected = value;
2956
- },
2957
- get autoMessageSent() {
2958
- return autoMessageSent;
2959
- },
2960
- set autoMessageSent(value) {
2961
- autoMessageSent = value;
2962
- },
2963
- get toolsExpanded() {
2964
- return toolsExpanded;
2965
- },
2966
- set toolsExpanded(value) {
2967
- toolsExpanded = value;
2968
- },
2969
- get showThinking() {
2970
- return showThinking;
2971
- },
2972
- set showThinking(value) {
2973
- showThinking = value;
2974
- },
2975
- get connectionStatus() {
2976
- return connectionStatus;
2977
- },
2978
- set connectionStatus(value) {
2979
- connectionStatus = value;
2980
- },
2981
- get activityStatus() {
2982
- return activityStatus;
2983
- },
2984
- set activityStatus(value) {
2985
- activityStatus = value;
2986
- },
2987
- get statusTimeout() {
2988
- return statusTimeout;
2989
- },
2990
- set statusTimeout(value) {
2991
- statusTimeout = value;
2992
- },
2993
- get lastCtrlCAt() {
2994
- return lastCtrlCAt;
2995
- },
2996
- set lastCtrlCAt(value) {
2997
- lastCtrlCAt = value;
2998
- }
2999
- };
3000
- const noteLocalRunId = (runId) => {
3001
- if (!runId) return;
3002
- localRunIds.add(runId);
3003
- if (localRunIds.size > 200) {
3004
- const [first] = localRunIds;
3005
- if (first) localRunIds.delete(first);
3006
- }
3007
- };
3008
- const forgetLocalRunId = (runId) => {
3009
- localRunIds.delete(runId);
3010
- };
3011
- const isLocalRunId = (runId) => localRunIds.has(runId);
3012
- const clearLocalRunIds = () => {
3013
- localRunIds.clear();
3014
- };
3015
- const client = new GatewayChatClient({
3016
- url: opts.url,
3017
- token: opts.token,
3018
- password: opts.password
3019
- });
3020
- const tui = new TUI(new ProcessTerminal());
3021
- const dedupeBackspace = createBackspaceDeduper();
3022
- tui.addInputListener((data) => {
3023
- const next = dedupeBackspace(data);
3024
- if (next.length === 0) return { consume: true };
3025
- return { data: next };
3026
- });
3027
- const header = new Text("", 1, 0);
3028
- const statusContainer = new Container();
3029
- const footer = new Text("", 1, 0);
3030
- const chatLog = new ChatLog();
3031
- const editor = new CustomEditor(tui, editorTheme);
3032
- const root = new Container();
3033
- root.addChild(header);
3034
- root.addChild(chatLog);
3035
- root.addChild(statusContainer);
3036
- root.addChild(footer);
3037
- root.addChild(editor);
3038
- const updateAutocompleteProvider = () => {
3039
- editor.setAutocompleteProvider(new CombinedAutocompleteProvider(getSlashCommands({
3040
- cfg: config,
3041
- provider: sessionInfo.modelProvider,
3042
- model: sessionInfo.model
3043
- }), process.cwd()));
3044
- };
3045
- tui.addChild(root);
3046
- tui.setFocus(editor);
3047
- const formatSessionKey = (key) => {
3048
- if (key === "global" || key === "unknown") return key;
3049
- return parseAgentSessionKey(key)?.rest ?? key;
3050
- };
3051
- const formatAgentLabel = (id) => {
3052
- const name = agentNames.get(id);
3053
- return name ? `${id} (${name})` : id;
3054
- };
3055
- const resolveSessionKey = (raw) => {
3056
- return resolveTuiSessionKey({
3057
- raw,
3058
- sessionScope,
3059
- currentAgentId,
3060
- sessionMainKey
3061
- });
3062
- };
3063
- currentSessionKey = resolveSessionKey(initialSessionInput);
3064
- const updateHeader = () => {
3065
- const sessionLabel = formatSessionKey(currentSessionKey);
3066
- const agentLabel = formatAgentLabel(currentAgentId);
3067
- header.setText(theme.header(`remoteclaw tui - ${client.connection.url} - agent ${agentLabel} - session ${sessionLabel}`));
3068
- };
3069
- const busyStates = new Set([
3070
- "sending",
3071
- "waiting",
3072
- "streaming",
3073
- "running"
3074
- ]);
3075
- let statusText = null;
3076
- let statusLoader = null;
3077
- const formatElapsed = (startMs) => {
3078
- const totalSeconds = Math.max(0, Math.floor((Date.now() - startMs) / 1e3));
3079
- if (totalSeconds < 60) return `${totalSeconds}s`;
3080
- return `${Math.floor(totalSeconds / 60)}m ${totalSeconds % 60}s`;
3081
- };
3082
- const ensureStatusText = () => {
3083
- if (statusText) return;
3084
- statusContainer.clear();
3085
- statusLoader?.stop();
3086
- statusLoader = null;
3087
- statusText = new Text("", 1, 0);
3088
- statusContainer.addChild(statusText);
3089
- };
3090
- const ensureStatusLoader = () => {
3091
- if (statusLoader) return;
3092
- statusContainer.clear();
3093
- statusText = null;
3094
- statusLoader = new Loader(tui, (spinner) => theme.accent(spinner), (text) => theme.bold(theme.accentSoft(text)), "");
3095
- statusContainer.addChild(statusLoader);
3096
- };
3097
- let waitingTick = 0;
3098
- let waitingTimer = null;
3099
- let waitingPhrase = null;
3100
- const updateBusyStatusMessage = () => {
3101
- if (!statusLoader || !statusStartedAt) return;
3102
- const elapsed = formatElapsed(statusStartedAt);
3103
- if (activityStatus === "waiting") {
3104
- waitingTick++;
3105
- statusLoader.setMessage(buildWaitingStatusMessage({
3106
- theme,
3107
- tick: waitingTick,
3108
- elapsed,
3109
- connectionStatus,
3110
- phrases: waitingPhrase ? [waitingPhrase] : void 0
3111
- }));
3112
- return;
3113
- }
3114
- statusLoader.setMessage(`${activityStatus} • ${elapsed} | ${connectionStatus}`);
3115
- };
3116
- const startStatusTimer = () => {
3117
- if (statusTimer) return;
3118
- statusTimer = setInterval(() => {
3119
- if (!busyStates.has(activityStatus)) return;
3120
- updateBusyStatusMessage();
3121
- }, 1e3);
3122
- };
3123
- const stopStatusTimer = () => {
3124
- if (!statusTimer) return;
3125
- clearInterval(statusTimer);
3126
- statusTimer = null;
3127
- };
3128
- const startWaitingTimer = () => {
3129
- if (waitingTimer) return;
3130
- if (!waitingPhrase) waitingPhrase = defaultWaitingPhrases[Math.floor(Math.random() * defaultWaitingPhrases.length)] ?? defaultWaitingPhrases[0] ?? "waiting";
3131
- waitingTick = 0;
3132
- waitingTimer = setInterval(() => {
3133
- if (activityStatus !== "waiting") return;
3134
- updateBusyStatusMessage();
3135
- }, 120);
3136
- };
3137
- const stopWaitingTimer = () => {
3138
- if (!waitingTimer) return;
3139
- clearInterval(waitingTimer);
3140
- waitingTimer = null;
3141
- waitingPhrase = null;
3142
- };
3143
- const renderStatus = () => {
3144
- if (busyStates.has(activityStatus)) {
3145
- if (!statusStartedAt || lastActivityStatus !== activityStatus) statusStartedAt = Date.now();
3146
- ensureStatusLoader();
3147
- if (activityStatus === "waiting") {
3148
- stopStatusTimer();
3149
- startWaitingTimer();
3150
- } else {
3151
- stopWaitingTimer();
3152
- startStatusTimer();
3153
- }
3154
- updateBusyStatusMessage();
3155
- } else {
3156
- statusStartedAt = null;
3157
- stopStatusTimer();
3158
- stopWaitingTimer();
3159
- statusLoader?.stop();
3160
- statusLoader = null;
3161
- ensureStatusText();
3162
- const text = activityStatus ? `${connectionStatus} | ${activityStatus}` : connectionStatus;
3163
- statusText?.setText(theme.dim(text));
3164
- }
3165
- lastActivityStatus = activityStatus;
3166
- };
3167
- const setConnectionStatus = (text, ttlMs) => {
3168
- connectionStatus = text;
3169
- renderStatus();
3170
- if (statusTimeout) clearTimeout(statusTimeout);
3171
- if (ttlMs && ttlMs > 0) statusTimeout = setTimeout(() => {
3172
- connectionStatus = isConnected ? "connected" : "disconnected";
3173
- renderStatus();
3174
- }, ttlMs);
3175
- };
3176
- const setActivityStatus = (text) => {
3177
- activityStatus = text;
3178
- renderStatus();
3179
- };
3180
- const updateFooter = () => {
3181
- const sessionKeyLabel = formatSessionKey(currentSessionKey);
3182
- const sessionLabel = sessionInfo.displayName ? `${sessionKeyLabel} (${sessionInfo.displayName})` : sessionKeyLabel;
3183
- const agentLabel = formatAgentLabel(currentAgentId);
3184
- const modelLabel = sessionInfo.model ? sessionInfo.modelProvider ? `${sessionInfo.modelProvider}/${sessionInfo.model}` : sessionInfo.model : "unknown";
3185
- const tokens = formatTokens(sessionInfo.totalTokens ?? null, sessionInfo.contextTokens ?? null);
3186
- const think = sessionInfo.thinkingLevel ?? "off";
3187
- const verbose = sessionInfo.verboseLevel ?? "off";
3188
- const reasoning = sessionInfo.reasoningLevel ?? "off";
3189
- const reasoningLabel = reasoning === "on" ? "reasoning" : reasoning === "stream" ? "reasoning:stream" : null;
3190
- const footerParts = [
3191
- `agent ${agentLabel}`,
3192
- `session ${sessionLabel}`,
3193
- modelLabel,
3194
- think !== "off" ? `think ${think}` : null,
3195
- verbose !== "off" ? `verbose ${verbose}` : null,
3196
- reasoningLabel,
3197
- tokens
3198
- ].filter(Boolean);
3199
- footer.setText(theme.dim(footerParts.join(" | ")));
3200
- };
3201
- const { openOverlay, closeOverlay } = createOverlayHandlers(tui, editor);
3202
- const { refreshAgents, refreshSessionInfo, applySessionInfoFromPatch, loadHistory, setSession, abortActive } = createSessionActions({
3203
- client,
3204
- chatLog,
3205
- tui,
3206
- opts,
3207
- state,
3208
- agentNames,
3209
- initialSessionInput,
3210
- initialSessionAgentId: (() => {
3211
- if (!initialSessionInput) return null;
3212
- const parsed = parseAgentSessionKey(initialSessionInput);
3213
- return parsed ? normalizeAgentId(parsed.agentId) : null;
3214
- })(),
3215
- resolveSessionKey,
3216
- updateHeader,
3217
- updateFooter,
3218
- updateAutocompleteProvider,
3219
- setActivityStatus,
3220
- clearLocalRunIds
3221
- });
3222
- const { handleChatEvent, handleAgentEvent } = createEventHandlers({
3223
- chatLog,
3224
- tui,
3225
- state,
3226
- setActivityStatus,
3227
- refreshSessionInfo,
3228
- loadHistory,
3229
- isLocalRunId,
3230
- forgetLocalRunId,
3231
- clearLocalRunIds
3232
- });
3233
- const requestExit = () => {
3234
- if (exitRequested) return;
3235
- exitRequested = true;
3236
- client.stop();
3237
- tui.stop();
3238
- process.exit(0);
3239
- };
3240
- const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } = createCommandHandlers({
3241
- client,
3242
- chatLog,
3243
- tui,
3244
- opts,
3245
- state,
3246
- deliverDefault,
3247
- openOverlay,
3248
- closeOverlay,
3249
- refreshSessionInfo,
3250
- applySessionInfoFromPatch,
3251
- loadHistory,
3252
- setSession,
3253
- refreshAgents,
3254
- abortActive,
3255
- setActivityStatus,
3256
- formatSessionKey,
3257
- noteLocalRunId,
3258
- forgetLocalRunId,
3259
- requestExit
3260
- });
3261
- const { runLocalShellLine } = createLocalShellRunner({
3262
- chatLog,
3263
- tui,
3264
- openOverlay,
3265
- closeOverlay
3266
- });
3267
- updateAutocompleteProvider();
3268
- editor.onSubmit = createSubmitBurstCoalescer({
3269
- submit: createEditorSubmitHandler({
3270
- editor,
3271
- handleCommand,
3272
- sendMessage,
3273
- handleBangLine: runLocalShellLine
3274
- }),
3275
- enabled: shouldEnableWindowsGitBashPasteFallback()
3276
- });
3277
- editor.onEscape = () => {
3278
- abortActive();
3279
- };
3280
- const handleCtrlC = () => {
3281
- const now = Date.now();
3282
- const decision = resolveCtrlCAction({
3283
- hasInput: editor.getText().trim().length > 0,
3284
- now,
3285
- lastCtrlCAt
3286
- });
3287
- lastCtrlCAt = decision.nextLastCtrlCAt;
3288
- if (decision.action === "clear") {
3289
- editor.setText("");
3290
- setActivityStatus("cleared input; press ctrl+c again to exit");
3291
- tui.requestRender();
3292
- return;
3293
- }
3294
- if (decision.action === "exit") {
3295
- requestExit();
3296
- return;
3297
- }
3298
- setActivityStatus("press ctrl+c again to exit");
3299
- tui.requestRender();
3300
- };
3301
- editor.onCtrlC = () => {
3302
- handleCtrlC();
3303
- };
3304
- editor.onCtrlD = () => {
3305
- requestExit();
3306
- };
3307
- editor.onCtrlO = () => {
3308
- toolsExpanded = !toolsExpanded;
3309
- chatLog.setToolsExpanded(toolsExpanded);
3310
- setActivityStatus(toolsExpanded ? "tools expanded" : "tools collapsed");
3311
- tui.requestRender();
3312
- };
3313
- editor.onCtrlL = () => {
3314
- openModelSelector();
3315
- };
3316
- editor.onCtrlG = () => {
3317
- openAgentSelector();
3318
- };
3319
- editor.onCtrlP = () => {
3320
- openSessionSelector();
3321
- };
3322
- editor.onCtrlT = () => {
3323
- showThinking = !showThinking;
3324
- loadHistory();
3325
- };
3326
- client.onEvent = (evt) => {
3327
- if (evt.event === "chat") handleChatEvent(evt.payload);
3328
- if (evt.event === "agent") handleAgentEvent(evt.payload);
3329
- };
3330
- client.onConnected = () => {
3331
- isConnected = true;
3332
- pairingHintShown = false;
3333
- const reconnected = wasDisconnected;
3334
- wasDisconnected = false;
3335
- setConnectionStatus("connected");
3336
- (async () => {
3337
- await refreshAgents();
3338
- updateHeader();
3339
- await loadHistory();
3340
- setConnectionStatus(reconnected ? "gateway reconnected" : "gateway connected", 4e3);
3341
- tui.requestRender();
3342
- if (!autoMessageSent && autoMessage) {
3343
- autoMessageSent = true;
3344
- await sendMessage(autoMessage);
3345
- }
3346
- updateFooter();
3347
- tui.requestRender();
3348
- })();
3349
- };
3350
- client.onDisconnected = (reason) => {
3351
- isConnected = false;
3352
- wasDisconnected = true;
3353
- historyLoaded = false;
3354
- const disconnectState = resolveGatewayDisconnectState(reason);
3355
- setConnectionStatus(disconnectState.connectionStatus, 5e3);
3356
- setActivityStatus(disconnectState.activityStatus);
3357
- if (disconnectState.pairingHint && !pairingHintShown) {
3358
- pairingHintShown = true;
3359
- chatLog.addSystem(disconnectState.pairingHint);
3360
- }
3361
- updateFooter();
3362
- tui.requestRender();
3363
- };
3364
- client.onGap = (info) => {
3365
- setConnectionStatus(`event gap: expected ${info.expected}, got ${info.received}`, 5e3);
3366
- tui.requestRender();
3367
- };
3368
- updateHeader();
3369
- setConnectionStatus("connecting");
3370
- updateFooter();
3371
- const sigintHandler = () => {
3372
- handleCtrlC();
3373
- };
3374
- const sigtermHandler = () => {
3375
- requestExit();
3376
- };
3377
- process.on("SIGINT", sigintHandler);
3378
- process.on("SIGTERM", sigtermHandler);
3379
- tui.start();
3380
- client.start();
3381
- await new Promise((resolve) => {
3382
- const finish = () => {
3383
- process.removeListener("SIGINT", sigintHandler);
3384
- process.removeListener("SIGTERM", sigtermHandler);
3385
- resolve();
3386
- };
3387
- process.once("exit", finish);
3388
- });
3389
- }
3390
-
3391
- //#endregion
3392
- export { runTui as t };