@noxsoft/anima 2.0.2 → 2.0.4

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 (829) hide show
  1. package/README.md +1260 -28
  2. package/dist/accounts-Bth3PpPD.js +260 -0
  3. package/dist/accounts-D8CPKNkN.js +259 -0
  4. package/dist/acp-cli-ByK6lS6c.js +1081 -0
  5. package/dist/acp-cli-CaQCjIw4.js +1084 -0
  6. package/dist/agent-BgIkqd3F.js +725 -0
  7. package/dist/agent-N5BDcge4.js +725 -0
  8. package/dist/agent-events-COH7NDW2.js +182 -0
  9. package/dist/agent-scope-CPphqq-U.js +452 -0
  10. package/dist/agent-scope-DZgptr9J.js +452 -0
  11. package/dist/agent-scope-cj2QCT6R.js +112 -0
  12. package/dist/agents-NEudYMdg.js +774 -0
  13. package/dist/agents.config-Bujs-NIy.js +182 -0
  14. package/dist/agents.config-jp7OLssr.js +182 -0
  15. package/dist/argv-BMZMiW7v.js +73 -0
  16. package/dist/audit-C-UJhfdv.js +2401 -0
  17. package/dist/audit-CeCO7SK5.js +2401 -0
  18. package/dist/auth-BNZsOHGF.js +648 -0
  19. package/dist/auth-DMPZWzEa.js +639 -0
  20. package/dist/auth-choice-5VnaGMD-.js +2681 -0
  21. package/dist/auth-choice-DA2k4vs8.js +2681 -0
  22. package/dist/auth-health-B7FqA26_.js +149 -0
  23. package/dist/auth-health-VO_MPqVX.js +149 -0
  24. package/dist/auth-profiles-BDrNYX_n.js +1564 -0
  25. package/dist/auth-profiles-CxSHydjn.js +2689 -0
  26. package/dist/banner-BtDZPRzi.js +294 -0
  27. package/dist/browser-cli-8yQMpxb8.js +1679 -0
  28. package/dist/browser-cli-Czg3JtDH.js +1676 -0
  29. package/dist/build-info.json +3 -3
  30. package/dist/bundled/boot-md/handler.js +16 -16
  31. package/dist/bundled/bootstrap-extra-files/handler.js +4 -4
  32. package/dist/bundled/command-logger/handler.js +1 -1
  33. package/dist/bundled/session-memory/handler.js +5 -5
  34. package/dist/call-BIzCaKZb.js +282 -0
  35. package/dist/call-BYDpTVCZ.js +282 -0
  36. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  37. package/dist/catalog-CqKiUgu6.js +185 -0
  38. package/dist/catalog-DMfEg-oK.js +185 -0
  39. package/dist/channel-options-BrtCtyrT.js +32 -0
  40. package/dist/channel-options-CO21Gl8p.js +33 -0
  41. package/dist/channel-selection-Bbm1lq3P.js +51 -0
  42. package/dist/channel-selection-CqcX7Ocw.js +51 -0
  43. package/dist/channel-web-DrsT6OAE.js +2162 -0
  44. package/dist/channels-cli-Juyh1S6n.js +1304 -0
  45. package/dist/channels-cli-zNvi1m5c.js +1306 -0
  46. package/dist/channels-status-issues-CqzqshW4.js +18 -0
  47. package/dist/channels-status-issues-DdJdO866.js +18 -0
  48. package/dist/chrome-C4dOMO8z.js +1601 -0
  49. package/dist/chrome-DdcDzAtH.js +1629 -0
  50. package/dist/chrome-U3DRzjJD.js +1601 -0
  51. package/dist/chunk-D2nLsrEW.js +348 -0
  52. package/dist/clack-prompter-BI3RDW5w.js +92 -0
  53. package/dist/clack-prompter-Dwr1m_IZ.js +92 -0
  54. package/dist/cli/daemon-cli.js +1 -1
  55. package/dist/cli-C3cpDaz8.js +99 -0
  56. package/dist/cli-CjWUGdGC.js +101 -0
  57. package/dist/cli-session-BVjY_XrW.js +5463 -0
  58. package/dist/cli-session-gtuYN2Iq.js +5408 -0
  59. package/dist/client-Dswwze5_.js +1692 -0
  60. package/dist/client-LRKFjo4A.js +1692 -0
  61. package/dist/clipboard-BZKS9O1u.js +31 -0
  62. package/dist/clipboard-DES8b1AM.js +31 -0
  63. package/dist/command-format-CP1YTNCl.js +52 -0
  64. package/dist/command-format-CVL4K5cj.js +52 -0
  65. package/dist/command-format-G6N2zghg.js +38 -0
  66. package/dist/command-registry-BBvNvysr.js +248 -0
  67. package/dist/commands-AZ3n8Y2c.js +726 -0
  68. package/dist/commands-BMnD_QRY.js +726 -0
  69. package/dist/commands-registry-cFqZ6Ib4.js +766 -0
  70. package/dist/commands-registry-q13H7ng5.js +766 -0
  71. package/dist/common-CX5458fH.js +287 -0
  72. package/dist/common-DJbnT8ws.js +287 -0
  73. package/dist/completion-cli-BADRBcIl.js +432 -0
  74. package/dist/completion-cli-DMQgiObF.js +431 -0
  75. package/dist/config-CU-Axg8P.js +5704 -0
  76. package/dist/config-DaqbUdkI.js +5705 -0
  77. package/dist/config-cli-BPlbwiuA.js +244 -0
  78. package/dist/config-cli-DXgZJkPU.js +247 -0
  79. package/dist/config-guard-Ba49JNds.js +76 -0
  80. package/dist/config-guard-Cu0qMKZJ.js +93 -0
  81. package/dist/config-kVVm5EYV.js +6523 -0
  82. package/dist/config-sync-CzLnLTXt.js +91 -0
  83. package/dist/config-sync-DuydxPWx.js +91 -0
  84. package/dist/configure-CHgacLyi.js +960 -0
  85. package/dist/configure-DfHXDa1L.js +959 -0
  86. package/dist/context-DzgXOckU.js +60 -0
  87. package/dist/control-service-8_wKHwBa.js +72 -0
  88. package/dist/control-service-BtL1Jto_.js +72 -0
  89. package/dist/cron-cli-BCzSR2c0.js +448 -0
  90. package/dist/cron-cli-CCWNkykU.js +451 -0
  91. package/dist/daemon-cli-Bjkbu9Vy.js +565 -0
  92. package/dist/daemon-cli-CmlHcC1J.js +566 -0
  93. package/dist/daemon-cli.js +16 -16
  94. package/dist/daemon-runtime-C0tz7VAC.js +460 -0
  95. package/dist/daemon-runtime-rUTqCVwJ.js +460 -0
  96. package/dist/deliver-BBggsviM.js +1097 -0
  97. package/dist/deliver-CePITOl8.js +1162 -0
  98. package/dist/deliver-DFnVaetP.js +1097 -0
  99. package/dist/delivery-queue-BJQK3oh5.js +220 -0
  100. package/dist/deps-CeEKhrp7.js +42 -0
  101. package/dist/devices-cli-DQrDMrZH.js +198 -0
  102. package/dist/devices-cli-Oe-A1Dv0.js +195 -0
  103. package/dist/diagnostics-DxMFrBLO.js +35 -0
  104. package/dist/diagnostics-m79ZlMmZ.js +35 -0
  105. package/dist/directory-cli-BL6h8cGF.js +246 -0
  106. package/dist/directory-cli-Cjgmi_sj.js +243 -0
  107. package/dist/dispatcher-DAFbQM-c.js +100 -0
  108. package/dist/dispatcher-DNd40gUn.js +100 -0
  109. package/dist/dist-CqDI82ei.js +929 -0
  110. package/dist/dist-DnHRxR5U.js +929 -0
  111. package/dist/dns-cli-CFtV3BXK.js +200 -0
  112. package/dist/dns-cli-NyIHvQ5S.js +197 -0
  113. package/dist/dock-BdXLb5oY.js +753 -0
  114. package/dist/dock-jYICmNcI.js +753 -0
  115. package/dist/docs-cli-CrOaIK_H.js +161 -0
  116. package/dist/docs-cli-D_cmJDSr.js +159 -0
  117. package/dist/doctor-BpGxKrBl.js +1815 -0
  118. package/dist/doctor-D12wNQPU.js +1813 -0
  119. package/dist/doctor-completion-DeOfofek.js +92 -0
  120. package/dist/doctor-completion-DwjqdEcK.js +92 -0
  121. package/dist/doctor-config-flow-BI3mpkbd.js +1232 -0
  122. package/dist/doctor-config-flow-wMHheFkC.js +1232 -0
  123. package/dist/engine-BCtL-AMw.js +563 -0
  124. package/dist/engine-Bk_UT413.js +563 -0
  125. package/dist/entry.js +5 -5
  126. package/dist/env-v6411I8h.js +32 -0
  127. package/dist/exec-B7sUS164.js +1167 -0
  128. package/dist/exec-approvals-CroGJRUg.js +1221 -0
  129. package/dist/exec-approvals-cli-BTxF_RsH.js +371 -0
  130. package/dist/exec-approvals-cli-n1gyGwH2.js +368 -0
  131. package/dist/exec-mhSykkaa.js +255 -0
  132. package/dist/extensionAPI.js +3 -3
  133. package/dist/frontmatter-BmHq0vRD.js +204 -0
  134. package/dist/gateway-cli-DDBadlrS.js +19971 -0
  135. package/dist/gateway-cli-IZNkOMBe.js +19972 -0
  136. package/dist/gateway-rpc-Dtx8HN-n.js +28 -0
  137. package/dist/gateway-rpc-L2PVSqGj.js +28 -0
  138. package/dist/github-copilot-auth-DKyqDaGU.js +1418 -0
  139. package/dist/github-copilot-auth-DXpOMSd3.js +1418 -0
  140. package/dist/gmail-setup-utils-BKNczIJ9.js +428 -0
  141. package/dist/gmail-setup-utils-co0ppccC.js +428 -0
  142. package/dist/health-Bm8ZTvC3.js +1253 -0
  143. package/dist/health-DUf1gt4E.js +1258 -0
  144. package/dist/health-format-BksT6F68.js +208 -0
  145. package/dist/health-format-uzh1xYLD.js +208 -0
  146. package/dist/heartbeat-visibility-1TJb1Zao.js +98 -0
  147. package/dist/heartbeat-visibility-CwodtdcX.js +98 -0
  148. package/dist/help-format-C6cv_aZp.js +17 -0
  149. package/dist/helpers-N-uSFKOn.js +10 -0
  150. package/dist/hooks-cli-1POsXqOl.js +993 -0
  151. package/dist/hooks-cli-BGjILbze.js +991 -0
  152. package/dist/hooks-status-DE07n5RC.js +356 -0
  153. package/dist/hooks-status-Du-d1jde.js +356 -0
  154. package/dist/image-ops-B_AYV3tp.js +541 -0
  155. package/dist/image-ops-Bp0C6Mvr.js +541 -0
  156. package/dist/index.js +82 -82
  157. package/dist/init-9A0s7bWG.js +122 -0
  158. package/dist/init-DoyCHJDC.js +122 -0
  159. package/dist/installs-D1C9wHAq.js +383 -0
  160. package/dist/installs-Dh4dHayM.js +383 -0
  161. package/dist/ipv4-DCItfaJo.js +1964 -0
  162. package/dist/ipv4-DSOUVx0i.js +1964 -0
  163. package/dist/lanes-BvSnHq2h.js +232 -0
  164. package/dist/lifecycle-core-BY4WIf9g.js +388 -0
  165. package/dist/lifecycle-core-TQKyXO-6.js +387 -0
  166. package/dist/links-CNu_8RZl.js +15 -0
  167. package/dist/links-D2tt2ouh.js +15 -0
  168. package/dist/llm-slug-generator.js +4 -4
  169. package/dist/logging-BIeRw0WR.js +15 -0
  170. package/dist/logging-C7lb3Vjc.js +15 -0
  171. package/dist/login-DXWKewA2.js +59 -0
  172. package/dist/login-Fhh4uWmf.js +61 -0
  173. package/dist/login-pPs3UO38.js +61 -0
  174. package/dist/login-qr-CevLD8cV.js +326 -0
  175. package/dist/login-qr-GF2JMIy-.js +323 -0
  176. package/dist/login-qr-ZYYKD6Yt.js +321 -0
  177. package/dist/logs-cli-CzXbX8HZ.js +242 -0
  178. package/dist/logs-cli-D9ngH9PF.js +245 -0
  179. package/dist/manager-BD5rA3w0.js +3244 -0
  180. package/dist/manager-BDPgBQSH.js +3246 -0
  181. package/dist/manager-DRWMWM--.js +3244 -0
  182. package/dist/manifest-registry-DbvPaBXY.js +748 -0
  183. package/dist/manifest-registry-kHX_MFa1.js +748 -0
  184. package/dist/markdown-tables-CqwihY2m.js +347 -0
  185. package/dist/markdown-tables-DJV7eAJZ.js +348 -0
  186. package/dist/media-lUqN-0O9.js +1342 -0
  187. package/dist/memory-cli-BLXSpgnN.js +868 -0
  188. package/dist/memory-cli-BcGVkkRJ.js +869 -0
  189. package/dist/message-channel-D_jIO87f.js +110 -0
  190. package/dist/migrate-BpVOar4L.js +157 -0
  191. package/dist/migrate-CkgGDkWy.js +157 -0
  192. package/dist/model-selection-Cqt6aJ0G.js +2691 -0
  193. package/dist/models-CExsNQPH.js +2510 -0
  194. package/dist/models-cli-Ba3Jmwev.js +2739 -0
  195. package/dist/models-cli-iDAlsbL2.js +258 -0
  196. package/dist/net-0A_zcaQD.js +218 -0
  197. package/dist/node-cli-ATmwCXIk.js +1319 -0
  198. package/dist/node-cli-DYFR_V25.js +1322 -0
  199. package/dist/node-service-CN4LqR1A.js +67 -0
  200. package/dist/node-service-CWt3MdSC.js +67 -0
  201. package/dist/nodes-cli-BeVmhTz3.js +1197 -0
  202. package/dist/nodes-cli-QeJIfa18.js +1200 -0
  203. package/dist/nodes-screen-DHyWAlla.js +234 -0
  204. package/dist/nodes-screen-qs3jRBPk.js +234 -0
  205. package/dist/note-CSlg2BnB.js +73 -0
  206. package/dist/note-Ctvglhp1.js +73 -0
  207. package/dist/npm-registry-spec-DQd4M22q.js +351 -0
  208. package/dist/npm-registry-spec-PxisIMts.js +351 -0
  209. package/dist/onboard-DeruD10m.js +1166 -0
  210. package/dist/onboard-SAcu5N6N.js +1165 -0
  211. package/dist/onboard-channels-C4iSfFXR.js +672 -0
  212. package/dist/onboard-channels-oVTVgoyg.js +672 -0
  213. package/dist/onboard-helpers-B8roRwLP.js +365 -0
  214. package/dist/onboard-helpers-Dgh26hgP.js +365 -0
  215. package/dist/onboarding-Bi-ac8we.js +911 -0
  216. package/dist/onboarding-C2gjB2u8.js +910 -0
  217. package/dist/orchestrator-DlbAYMQP.js +357 -0
  218. package/dist/orchestrator-DlwVRVDA.js +357 -0
  219. package/dist/outbound-CkKgc6iR.js +2062 -0
  220. package/dist/outbound-Vfm5yDh3.js +214 -0
  221. package/dist/outbound-bs_VK51X.js +214 -0
  222. package/dist/outbound-send-deps-DDjiMfEL.js +55 -0
  223. package/dist/pairing-cli-CJYeuEik.js +118 -0
  224. package/dist/pairing-cli-mqopHI8s.js +121 -0
  225. package/dist/pairing-store-BsXzUDPv.js +388 -0
  226. package/dist/pairing-store-DoNj00-X.js +388 -0
  227. package/dist/path-env-C_xpiG8l.js +89 -0
  228. package/dist/path-env-DSSMHu5A.js +89 -0
  229. package/dist/paths-B1vRVCad.js +126 -0
  230. package/dist/paths-BMuHNFxg.js +238 -0
  231. package/dist/paths-BXQQzXGQ.js +129 -0
  232. package/dist/paths-Buw_geoe.js +54 -0
  233. package/dist/paths-DA9WYabg.js +222 -0
  234. package/dist/paths-DfQGx0_k.js +129 -0
  235. package/dist/pi-auth-json-DOPW3e4X.js +78 -0
  236. package/dist/pi-auth-json-MruLmI_X.js +82 -0
  237. package/dist/pi-auth-json-lae_wwwo.js +80 -0
  238. package/dist/pi-model-discovery-7q0GxMrp.js +3 -0
  239. package/dist/pi-tools.policy-Csmla32P.js +200 -0
  240. package/dist/pi-tools.policy-xYdDLEv9.js +200 -0
  241. package/dist/plugin-auto-enable-CViVVWgg.js +282 -0
  242. package/dist/plugin-auto-enable-CjZ238UI.js +282 -0
  243. package/dist/plugin-registry-B4Aw2hzq.js +32 -0
  244. package/dist/plugin-registry-DW81arxW.js +32 -0
  245. package/dist/plugin-sdk/cli/cli-name.d.ts +1 -1
  246. package/dist/plugin-sdk/config/paths.d.ts +2 -2
  247. package/dist/plugin-sdk/index.js +7 -7
  248. package/dist/plugins-DhcGAPDB.js +38 -0
  249. package/dist/plugins-DtghNRtM.js +168 -0
  250. package/dist/plugins-cli-4vWTmOAb.js +736 -0
  251. package/dist/plugins-cli-CdTMbP0X.js +734 -0
  252. package/dist/polls-D6eCdatA.js +1343 -0
  253. package/dist/ports-BtZx-JKD.js +96 -0
  254. package/dist/ports-C8bKN8s0.js +96 -0
  255. package/dist/ports-DHiKnPRX.js +344 -0
  256. package/dist/ports-vd93M_Pt.js +317 -0
  257. package/dist/program-CX3aUVeb.js +176 -0
  258. package/dist/program-context-BPos0ivo.js +496 -0
  259. package/dist/progress-oiAjiiNi.js +133 -0
  260. package/dist/prompt-style-Cm4wOtKm.js +9 -0
  261. package/dist/pw-ai-4QbK5YFe.js +1865 -0
  262. package/dist/pw-ai-BWz3Cxt7.js +1868 -0
  263. package/dist/pw-ai-C83HBue2.js +1867 -0
  264. package/dist/qmd-manager-BcMeZiGD.js +938 -0
  265. package/dist/qmd-manager-CPypGJ0P.js +935 -0
  266. package/dist/qmd-manager-CRrSkfia.js +937 -0
  267. package/dist/register.agent-DDY8KJhn.js +265 -0
  268. package/dist/register.agent-DKawm-9d.js +1003 -0
  269. package/dist/register.anima-CEWUo29k.js +193 -0
  270. package/dist/register.anima-DBWz2rk_.js +193 -0
  271. package/dist/register.configure-BX67qV8k.js +103 -0
  272. package/dist/register.configure-CWsySuiq.js +101 -0
  273. package/dist/register.maintenance-0k-ZNhDg.js +543 -0
  274. package/dist/register.maintenance-BIwx1fzX.js +543 -0
  275. package/dist/register.message-CXPsoakA.js +657 -0
  276. package/dist/register.message-DA3jvfgI.js +660 -0
  277. package/dist/register.onboard-C4HG7Hqv.js +170 -0
  278. package/dist/register.onboard-GOpdif-j.js +170 -0
  279. package/dist/register.setup-B17vZT7C.js +175 -0
  280. package/dist/register.setup-GJyUDCqh.js +175 -0
  281. package/dist/register.status-health-sessions-D5876dGx.js +313 -0
  282. package/dist/register.status-health-sessions-lOewVIZR.js +142 -0
  283. package/dist/register.subclis-Dwnujj5C.js +255 -0
  284. package/dist/reply-CR5T_oQJ.js +32212 -0
  285. package/dist/reply-prefix-BcrS4Umd.js +100 -0
  286. package/dist/reply-prefix-Btb5o2NH.js +100 -0
  287. package/dist/reply-r089HuRA.js +32212 -0
  288. package/dist/routes-B4czFzIb.js +1820 -0
  289. package/dist/routes-ucJWAk5O.js +1820 -0
  290. package/dist/rpc-BnKxnQ0v.js +70 -0
  291. package/dist/rpc-DgE-xnyx.js +70 -0
  292. package/dist/run-main-B74kv84C.js +371 -0
  293. package/dist/runtime-guard-CKFdts2L.js +60 -0
  294. package/dist/sandbox-CJTS3er6.js +858 -0
  295. package/dist/sandbox-DBSiVHt_.js +859 -0
  296. package/dist/sandbox-cli-CrkjyU5M.js +461 -0
  297. package/dist/sandbox-cli-D1r5y6Sz.js +458 -0
  298. package/dist/security-cli-BZUdnkhn.js +462 -0
  299. package/dist/security-cli-DS09ebvA.js +465 -0
  300. package/dist/server-context-C0xZbYhg.js +824 -0
  301. package/dist/server-context-DVh2z7om.js +824 -0
  302. package/dist/server-node-events-bu9lpkMH.js +233 -0
  303. package/dist/server-node-events-i1Rrww31.js +231 -0
  304. package/dist/service-CJJwLEor.js +642 -0
  305. package/dist/service-DxLxBhaU.js +642 -0
  306. package/dist/service-audit-DB4Y3Ekp.js +488 -0
  307. package/dist/service-audit-M8y4TXVb.js +488 -0
  308. package/dist/session-CGxOLFs2.js +179 -0
  309. package/dist/session-DTTbdKb0.js +181 -0
  310. package/dist/session-cost-usage-FcdJl9c3.js +600 -0
  311. package/dist/session-cost-usage-qdfsGU2a.js +600 -0
  312. package/dist/session-yOhWcsD2.js +181 -0
  313. package/dist/sessions-B-Cu7JZq.js +1296 -0
  314. package/dist/sessions-BgLN4KFr.js +180 -0
  315. package/dist/sessions-CnRjwdVr.js +1296 -0
  316. package/dist/sessions-wRKla1Qh.js +2038 -0
  317. package/dist/shared-DS3UaJSP.js +66 -0
  318. package/dist/shared-DxNHzky3.js +77 -0
  319. package/dist/shared-Qpt4hUDi.js +66 -0
  320. package/dist/shared-kzrojZ1B.js +77 -0
  321. package/dist/skill-scanner-DLJji5Ye.js +263 -0
  322. package/dist/skills-BWFIEp4j.js +807 -0
  323. package/dist/skills-DV4zKdCx.js +808 -0
  324. package/dist/skills-cli-BY53ILm2.js +289 -0
  325. package/dist/skills-cli-CO3gxl8A.js +286 -0
  326. package/dist/skills-status-DX5pcqY3.js +166 -0
  327. package/dist/skills-status-zhcKzGkp.js +166 -0
  328. package/dist/sqlite-B6MojU1I.js +321 -0
  329. package/dist/sqlite-CuprTGR7.js +453 -0
  330. package/dist/sqlite-dzD-jMjs.js +368 -0
  331. package/dist/start-Cu3aLoSf.js +297 -0
  332. package/dist/start-Dz7tMAl8.js +296 -0
  333. package/dist/status-CaSxhxfV.js +2132 -0
  334. package/dist/status-D2C0JCX3.js +2137 -0
  335. package/dist/status-DlFMsQzh.js +27 -0
  336. package/dist/status-G0CITnKR.js +27 -0
  337. package/dist/status.update-CHjhVxJY.js +79 -0
  338. package/dist/status.update-DVFelehi.js +79 -0
  339. package/dist/subagent-registry-3Xb4el-8.js +14 -0
  340. package/dist/subagent-registry-CdSjz14I.js +2760 -0
  341. package/dist/subagent-registry-DNDhbHWi.js +2759 -0
  342. package/dist/subsystem-DfKstnEK.js +860 -0
  343. package/dist/system-cli-B5mt0FWa.js +82 -0
  344. package/dist/system-cli-Dg3UQ3Zz.js +79 -0
  345. package/dist/systemd-B43AvOGx.js +452 -0
  346. package/dist/systemd-RpPE0XGg.js +452 -0
  347. package/dist/systemd-hints-DMJT-Bbc.js +36 -0
  348. package/dist/systemd-hints-vRInKcz9.js +36 -0
  349. package/dist/systemd-linger-Dzyxqsod.js +75 -0
  350. package/dist/systemd-linger-EujbmI5A.js +75 -0
  351. package/dist/table-DhXHfRX2.js +279 -0
  352. package/dist/table-bWCLW-3P.js +279 -0
  353. package/dist/timeout-Ddn-5kAO.js +232 -0
  354. package/dist/tokens-3psI_Qk2.js +14 -0
  355. package/dist/tokens-BaM53PEx.js +14 -0
  356. package/dist/trash-Bmxs1Rnm.js +23 -0
  357. package/dist/trash-C39a6hKA.js +23 -0
  358. package/dist/tui-BHgBWhHE.js +3894 -0
  359. package/dist/tui-cli-B9Sq5-cC.js +50 -0
  360. package/dist/tui-cli-Dw7v4JoJ.js +47 -0
  361. package/dist/tui-mUwDwqvd.js +3894 -0
  362. package/dist/update-DF0GHG0j.js +317 -0
  363. package/dist/update-DoZLVjva.js +317 -0
  364. package/dist/update-check-Bt1dVPVN.js +400 -0
  365. package/dist/update-check-D5qAKes7.js +400 -0
  366. package/dist/update-cli-BNu2Oi7H.js +1105 -0
  367. package/dist/update-cli-D36AmALA.js +1105 -0
  368. package/dist/update-runner-CNQQaTwA.js +894 -0
  369. package/dist/update-runner-CvxZmbu-.js +894 -0
  370. package/dist/usage-BGCwNnjk.js +4516 -0
  371. package/dist/utils-DZ8pnOD5.js +243 -0
  372. package/dist/web-B5QG839O.js +46842 -0
  373. package/dist/web-Cmnvk9v0.js +2203 -0
  374. package/dist/web-Cv2KnTnL.js +63 -0
  375. package/dist/webhooks-cli-B6y89Pj_.js +319 -0
  376. package/dist/webhooks-cli-BDzHON4w.js +316 -0
  377. package/dist/whatsapp-actions-C_5MwVxM.js +45 -0
  378. package/dist/whatsapp-actions-hgYA12To.js +53 -0
  379. package/dist/whatsapp-actions-zTiVOoOV.js +49 -0
  380. package/dist/widearea-dns-BeIdnISJ.js +127 -0
  381. package/dist/widearea-dns-CF1gxpJ-.js +127 -0
  382. package/dist/workspace-DLna1IxR.js +649 -0
  383. package/dist/ws-log-Q4wO1Ztb.js +267 -0
  384. package/dist/ws-log-xF0kxDzp.js +267 -0
  385. package/package.json +1 -2
  386. package/dist/accounts-Cc5E4IDO.js +0 -260
  387. package/dist/accounts-CcVrwKqv.js +0 -259
  388. package/dist/acp-cli-DvphOKuh.js +0 -1081
  389. package/dist/acp-cli-p28pQ65a.js +0 -1084
  390. package/dist/agent-Cj7uDJaZ.js +0 -725
  391. package/dist/agent-Cuj9-2sT.js +0 -725
  392. package/dist/agent-events-BEBQsyE5.js +0 -182
  393. package/dist/agent-scope-BVf4aSwY.js +0 -112
  394. package/dist/agent-scope-OZi7lb8S.js +0 -452
  395. package/dist/agent-scope-V1bi9OYL.js +0 -452
  396. package/dist/agents-BUWqn_Ui.js +0 -774
  397. package/dist/agents.config-Dvo2ULxs.js +0 -182
  398. package/dist/agents.config-d6H0_3oj.js +0 -182
  399. package/dist/argv-DqUHKf0o.js +0 -73
  400. package/dist/audit-C6okOOSh.js +0 -2401
  401. package/dist/audit-VWjIdwC7.js +0 -2401
  402. package/dist/auth-91o2YM96.js +0 -648
  403. package/dist/auth-choice-CAmACV13.js +0 -2681
  404. package/dist/auth-choice-p3SeHPj2.js +0 -2681
  405. package/dist/auth-health-B_jXrWe6.js +0 -149
  406. package/dist/auth-health-DCicUKYR.js +0 -149
  407. package/dist/auth-lZ26wsbN.js +0 -639
  408. package/dist/auth-profiles-CCDD56dU.js +0 -1564
  409. package/dist/auth-profiles-DxI8L7bs.js +0 -2689
  410. package/dist/banner-Cohn04J6.js +0 -294
  411. package/dist/browser-cli-DANzjztE.js +0 -1676
  412. package/dist/browser-cli-WjsVH741.js +0 -1679
  413. package/dist/call-BAHvlu2G.js +0 -282
  414. package/dist/call-Ct7EGP_L.js +0 -282
  415. package/dist/catalog-BAayBt1L.js +0 -185
  416. package/dist/catalog-BNsf97BM.js +0 -185
  417. package/dist/channel-options-Dx9nPlX8.js +0 -33
  418. package/dist/channel-options-ZdvXrTGs.js +0 -32
  419. package/dist/channel-selection-CujyiWGM.js +0 -51
  420. package/dist/channel-selection-DfGpCyh2.js +0 -51
  421. package/dist/channel-web-CC0hkgkR.js +0 -2162
  422. package/dist/channels-cli-D7lNBpIb.js +0 -1304
  423. package/dist/channels-cli-DUPG8WDv.js +0 -1306
  424. package/dist/channels-status-issues-DBc1pU_R.js +0 -18
  425. package/dist/channels-status-issues-DjO9MHIG.js +0 -18
  426. package/dist/chrome-Bi6iZ5sG.js +0 -1601
  427. package/dist/chrome-DNSv7Cpy.js +0 -1629
  428. package/dist/chrome-DScZx4Lk.js +0 -1601
  429. package/dist/chunk-mxPVo000.js +0 -348
  430. package/dist/clack-prompter-B0kl7shw.js +0 -92
  431. package/dist/clack-prompter-B1YxZdRy.js +0 -92
  432. package/dist/cli-CfHUkOD0.js +0 -101
  433. package/dist/cli-ClMrIh6l.js +0 -99
  434. package/dist/cli-session-BkPTd9Pk.js +0 -5463
  435. package/dist/cli-session-Dd8DKb5a.js +0 -5408
  436. package/dist/client-C1avc0vD.js +0 -1692
  437. package/dist/client-CC94YZrT.js +0 -1692
  438. package/dist/clipboard-B2fBy8tG.js +0 -31
  439. package/dist/clipboard-BbGnZskJ.js +0 -31
  440. package/dist/command-format-Clp46jkj.js +0 -38
  441. package/dist/command-format-DELazozB.js +0 -52
  442. package/dist/command-format-SkzzRqR1.js +0 -52
  443. package/dist/command-registry-DZ4hkmA0.js +0 -248
  444. package/dist/commands-DtYZJSPn.js +0 -568
  445. package/dist/commands-Dujk1JmY.js +0 -568
  446. package/dist/commands-registry-Bd0xbvwG.js +0 -766
  447. package/dist/commands-registry-DYfRSVF3.js +0 -766
  448. package/dist/common-D6bu0zHC.js +0 -287
  449. package/dist/common-zW9Y2P1B.js +0 -287
  450. package/dist/completion-cli-tSe7Pmqm.js +0 -431
  451. package/dist/completion-cli-vn4IScs5.js +0 -432
  452. package/dist/config-C8rUDJXY.js +0 -5704
  453. package/dist/config-CLZ_XGVw.js +0 -6523
  454. package/dist/config-SY8M0kM_.js +0 -5705
  455. package/dist/config-cli-1V7D2Wsw.js +0 -247
  456. package/dist/config-cli-CjWEC81L.js +0 -244
  457. package/dist/config-guard-BW2gpKj_.js +0 -93
  458. package/dist/config-guard-BvxuzHpo.js +0 -76
  459. package/dist/config-sync-CoIIbEOe.js +0 -91
  460. package/dist/config-sync-DvAttep0.js +0 -91
  461. package/dist/configure-Bf0oupCE.js +0 -959
  462. package/dist/configure-DRM-7zFf.js +0 -960
  463. package/dist/context-D5iEFzv9.js +0 -60
  464. package/dist/control-service-C8m8F9pr.js +0 -72
  465. package/dist/control-service-DKotCWCg.js +0 -72
  466. package/dist/cron-cli-DB_FLYHD.js +0 -448
  467. package/dist/cron-cli-bxm5lrrO.js +0 -451
  468. package/dist/daemon-cli-1LsOnICv.js +0 -566
  469. package/dist/daemon-cli-CC2NrJ7a.js +0 -565
  470. package/dist/daemon-runtime-BXZhtBL9.js +0 -460
  471. package/dist/daemon-runtime-DW4USC7r.js +0 -460
  472. package/dist/deliver-B4HuPwJA.js +0 -1162
  473. package/dist/deliver-LiY5oL52.js +0 -1097
  474. package/dist/deliver-xrmk7xjh.js +0 -1097
  475. package/dist/delivery-queue-TnQykYsg.js +0 -220
  476. package/dist/deps-CMMOiOsF.js +0 -42
  477. package/dist/devices-cli-Be5he2SA.js +0 -195
  478. package/dist/devices-cli-z6ecoFe9.js +0 -198
  479. package/dist/diagnostics-Dj75aEHN.js +0 -35
  480. package/dist/diagnostics-DlIw6fqD.js +0 -35
  481. package/dist/directory-cli-CEy-0nxj.js +0 -243
  482. package/dist/directory-cli-DpzKcigr.js +0 -246
  483. package/dist/dispatcher-10Shiuz3.js +0 -100
  484. package/dist/dispatcher-3Jae6AiW.js +0 -100
  485. package/dist/dns-cli-Bat1pkc-.js +0 -200
  486. package/dist/dns-cli-NohNyEo0.js +0 -197
  487. package/dist/dock-DbxBBv30.js +0 -753
  488. package/dist/dock-cPBY4qGl.js +0 -753
  489. package/dist/docs-cli-BWp6p-Tq.js +0 -161
  490. package/dist/docs-cli-x22FnZfL.js +0 -159
  491. package/dist/doctor-BrT5m_on.js +0 -1815
  492. package/dist/doctor-Pp2HVnjM.js +0 -1813
  493. package/dist/doctor-completion-DNTimX9o.js +0 -92
  494. package/dist/doctor-completion-ylN9QAJ6.js +0 -92
  495. package/dist/doctor-config-flow-D1w3700T.js +0 -1232
  496. package/dist/doctor-config-flow-Dq50iE1R.js +0 -1232
  497. package/dist/engine-B9avUJL5.js +0 -563
  498. package/dist/engine-BiUQ25D4.js +0 -563
  499. package/dist/env-0lJfCPsw.js +0 -32
  500. package/dist/exec-BenD3A5l.js +0 -1167
  501. package/dist/exec-Bv3pyjeM.js +0 -255
  502. package/dist/exec-approvals-CdLmKX2R.js +0 -1221
  503. package/dist/exec-approvals-cli-DXfV6G8H.js +0 -368
  504. package/dist/exec-approvals-cli-J2cZs10o.js +0 -371
  505. package/dist/frontmatter-YijVi0FQ.js +0 -204
  506. package/dist/gateway-cli-DOAbA0pc.js +0 -19972
  507. package/dist/gateway-cli-QpWtBhQy.js +0 -19971
  508. package/dist/gateway-rpc-DJKBil9s.js +0 -28
  509. package/dist/gateway-rpc-DVterpLP.js +0 -28
  510. package/dist/github-copilot-auth-4IUFp669.js +0 -1418
  511. package/dist/github-copilot-auth-C9E0IROs.js +0 -1418
  512. package/dist/gmail-setup-utils-BPo_LkKI.js +0 -428
  513. package/dist/gmail-setup-utils-D3Yqgor7.js +0 -428
  514. package/dist/health-BeZnqp6m.js +0 -1258
  515. package/dist/health-Cn2OoVWZ.js +0 -1253
  516. package/dist/health-format-CdP99j3Y.js +0 -208
  517. package/dist/health-format-JEChH08S.js +0 -208
  518. package/dist/heartbeat-visibility-BL3WAchI.js +0 -98
  519. package/dist/heartbeat-visibility-CQ9QimI7.js +0 -98
  520. package/dist/help-format-Dl4bsrLI.js +0 -17
  521. package/dist/helpers-ZKNRexvX.js +0 -10
  522. package/dist/hooks-cli-D99hXt7K.js +0 -991
  523. package/dist/hooks-cli-DMB8RiEO.js +0 -993
  524. package/dist/hooks-status-B-e96dZj.js +0 -356
  525. package/dist/hooks-status-C_9sE0ox.js +0 -356
  526. package/dist/image-ops-Dlt3T7th.js +0 -541
  527. package/dist/image-ops-omlvdfah.js +0 -541
  528. package/dist/init-Bm04RagW.js +0 -122
  529. package/dist/init-CaJBf4p1.js +0 -122
  530. package/dist/installs-C2iMRBVz.js +0 -383
  531. package/dist/installs-D-cPGdCw.js +0 -383
  532. package/dist/ipv4-Bf7NS3QU.js +0 -1964
  533. package/dist/ipv4-wWNs8IH_.js +0 -1964
  534. package/dist/lanes-CNxj3tit.js +0 -232
  535. package/dist/lifecycle-core-B_7XRcvF.js +0 -388
  536. package/dist/lifecycle-core-By83PVAK.js +0 -387
  537. package/dist/links-BfjHVTB_.js +0 -15
  538. package/dist/links-DPGe0OHw.js +0 -15
  539. package/dist/logging-DB6BQmhi.js +0 -15
  540. package/dist/logging-mcb66J0p.js +0 -15
  541. package/dist/login-BDCg6D0N.js +0 -61
  542. package/dist/login-BDfnbjnZ.js +0 -59
  543. package/dist/login-BqH1itcg.js +0 -61
  544. package/dist/login-qr-CyOw3R4r.js +0 -321
  545. package/dist/login-qr-D8ECtb72.js +0 -323
  546. package/dist/login-qr-RnR7e4Bw.js +0 -326
  547. package/dist/logs-cli--j89L74J.js +0 -245
  548. package/dist/logs-cli-DpEMg_Gq.js +0 -242
  549. package/dist/manager-B4OyvcxT.js +0 -3244
  550. package/dist/manager-Cqc1CeH7.js +0 -3246
  551. package/dist/manager-DUyQPFvj.js +0 -3244
  552. package/dist/manifest-registry-CW1zCyRF.js +0 -748
  553. package/dist/manifest-registry-D4lM2RdV.js +0 -748
  554. package/dist/markdown-tables-BT1X6jqH.js +0 -347
  555. package/dist/markdown-tables-DHgOK2vI.js +0 -348
  556. package/dist/media-THyainiE.js +0 -1342
  557. package/dist/memory-cli-BKocCWXM.js +0 -868
  558. package/dist/memory-cli-Jmma-xI_.js +0 -869
  559. package/dist/message-channel-dSTVVCyX.js +0 -110
  560. package/dist/migrate-BR6iAIjO.js +0 -157
  561. package/dist/migrate-D0EcMs0f.js +0 -157
  562. package/dist/model-selection-YcSr9CgC.js +0 -2691
  563. package/dist/models-1vUQBVfw.js +0 -2510
  564. package/dist/models-cli-BK3BwUhL.js +0 -2739
  565. package/dist/models-cli-DECrM8oA.js +0 -258
  566. package/dist/net-B5lXhYLV.js +0 -218
  567. package/dist/node-cli-cLHUNpPD.js +0 -1319
  568. package/dist/node-cli-fO7Y132S.js +0 -1322
  569. package/dist/node-service-BFxHJsno.js +0 -67
  570. package/dist/node-service-DUnan4uK.js +0 -67
  571. package/dist/nodes-cli-BCq35E6N.js +0 -1200
  572. package/dist/nodes-cli-vD7MwAKP.js +0 -1197
  573. package/dist/nodes-screen-1YiLkqr5.js +0 -234
  574. package/dist/nodes-screen-DZeD8hE5.js +0 -234
  575. package/dist/note-Bi8Wb8DV.js +0 -73
  576. package/dist/note-uiuPxhyX.js +0 -73
  577. package/dist/npm-registry-spec-B-XIShkB.js +0 -351
  578. package/dist/npm-registry-spec-za3itb5Y.js +0 -351
  579. package/dist/onboard-Ds6w_sWo.js +0 -1165
  580. package/dist/onboard-SAVx3bp4.js +0 -1166
  581. package/dist/onboard-channels-Cg_EkBa4.js +0 -672
  582. package/dist/onboard-channels-D7NbA55V.js +0 -672
  583. package/dist/onboard-helpers-DO_hgZb9.js +0 -365
  584. package/dist/onboard-helpers-_XgJgeqh.js +0 -365
  585. package/dist/onboarding-3hLmDd0r.js +0 -911
  586. package/dist/onboarding-B4LKLsbU.js +0 -910
  587. package/dist/orchestrator-BKzmyBWy.js +0 -357
  588. package/dist/orchestrator-BN3QCz2s.js +0 -357
  589. package/dist/outbound-BgA9hNlP.js +0 -2062
  590. package/dist/outbound-CjdvVhUI.js +0 -214
  591. package/dist/outbound-DOGe6qb2.js +0 -214
  592. package/dist/outbound-send-deps-Du5aBpd7.js +0 -55
  593. package/dist/pairing-cli-2vnyg_Nd.js +0 -118
  594. package/dist/pairing-cli-BH1KQtNV.js +0 -121
  595. package/dist/pairing-store-DJz_9Gv0.js +0 -388
  596. package/dist/pairing-store-DmOzxcuk.js +0 -388
  597. package/dist/path-env-Bu6k0jDQ.js +0 -89
  598. package/dist/path-env-C0zQSjw8.js +0 -89
  599. package/dist/paths-BTc4nk-6.js +0 -126
  600. package/dist/paths-BgUi2Z2G.js +0 -54
  601. package/dist/paths-C6VCWKo3.js +0 -238
  602. package/dist/paths-CCxa0o9c.js +0 -222
  603. package/dist/paths-CxRf2rBG.js +0 -129
  604. package/dist/paths-hcX1Gqg5.js +0 -129
  605. package/dist/pi-auth-json-B68R7q7_.js +0 -82
  606. package/dist/pi-auth-json-CR0jXAgq.js +0 -78
  607. package/dist/pi-auth-json-ZYzi3nxs.js +0 -80
  608. package/dist/pi-model-discovery-Cxs4pvC2.js +0 -3
  609. package/dist/pi-tools.policy-D81U5xy0.js +0 -200
  610. package/dist/pi-tools.policy-DSHkkb5b.js +0 -200
  611. package/dist/plugin-auto-enable-CxF4bpDN.js +0 -282
  612. package/dist/plugin-auto-enable-jNaAeyEh.js +0 -282
  613. package/dist/plugin-registry-C7XWotZG.js +0 -32
  614. package/dist/plugin-registry-DcUCbGax.js +0 -32
  615. package/dist/plugins-B362e77G.js +0 -168
  616. package/dist/plugins-CmSUIUNi.js +0 -38
  617. package/dist/plugins-cli-BsCEnoQ7.js +0 -734
  618. package/dist/plugins-cli-QSIsMUG7.js +0 -736
  619. package/dist/polls-CItfB1H8.js +0 -1343
  620. package/dist/ports-BVLMN1Sr.js +0 -96
  621. package/dist/ports-CqLSlU6Z.js +0 -317
  622. package/dist/ports-D94CwCrv.js +0 -344
  623. package/dist/ports-D_NHthOz.js +0 -96
  624. package/dist/program-DkJHjI0R.js +0 -176
  625. package/dist/program-context-DnyGM2SC.js +0 -496
  626. package/dist/progress-Bek_GyWS.js +0 -133
  627. package/dist/prompt-style-lu0clOOE.js +0 -9
  628. package/dist/pw-ai-BLVMuSLv.js +0 -1867
  629. package/dist/pw-ai-DZJWEF_f.js +0 -1865
  630. package/dist/pw-ai-dzf-ptcn.js +0 -1868
  631. package/dist/qmd-manager-Cur_Ekn0.js +0 -937
  632. package/dist/qmd-manager-DNAUuwjK.js +0 -938
  633. package/dist/qmd-manager-DepEoASu.js +0 -935
  634. package/dist/register.agent-CSWvzOkR.js +0 -265
  635. package/dist/register.agent-UeH2NXmH.js +0 -1003
  636. package/dist/register.anima-DOdee0dh.js +0 -193
  637. package/dist/register.anima-HHDWsz6r.js +0 -193
  638. package/dist/register.configure-CSJFxdz9.js +0 -103
  639. package/dist/register.configure-D84Fvcz4.js +0 -101
  640. package/dist/register.maintenance-B3pvNbZb.js +0 -543
  641. package/dist/register.maintenance-BKVOwkw6.js +0 -543
  642. package/dist/register.message-BAO6CPl2.js +0 -657
  643. package/dist/register.message-OXoOKE_6.js +0 -660
  644. package/dist/register.onboard-BK_ixVmD.js +0 -170
  645. package/dist/register.onboard-cfCaPx6j.js +0 -170
  646. package/dist/register.setup-BGfDnzph.js +0 -175
  647. package/dist/register.setup-Y-Q74M-0.js +0 -175
  648. package/dist/register.status-health-sessions-CT14eitH.js +0 -142
  649. package/dist/register.status-health-sessions-TfZMzAUn.js +0 -313
  650. package/dist/register.subclis-BZwdlNHC.js +0 -255
  651. package/dist/reply-mlsExaZm.js +0 -32212
  652. package/dist/reply-prefix-B0CfR4bM.js +0 -100
  653. package/dist/reply-prefix-w4a39ybC.js +0 -100
  654. package/dist/reply-qalRISe_.js +0 -32212
  655. package/dist/routes-CENsHJyg.js +0 -1820
  656. package/dist/routes-DO0HqW2e.js +0 -1820
  657. package/dist/rpc-C0pjNhBi.js +0 -70
  658. package/dist/rpc-DZ44PIXE.js +0 -70
  659. package/dist/run-main-BMpKw8Mp.js +0 -371
  660. package/dist/runtime-guard-BSUFiAQV.js +0 -60
  661. package/dist/sandbox-BIGfMYEI.js +0 -858
  662. package/dist/sandbox-DxP3IpUP.js +0 -859
  663. package/dist/sandbox-cli-DtLGH8sL.js +0 -461
  664. package/dist/sandbox-cli-_Tg7lfJ_.js +0 -458
  665. package/dist/security-cli-BRwgbedo.js +0 -462
  666. package/dist/security-cli-D3bSuyZt.js +0 -465
  667. package/dist/server-context-49XFFxFg.js +0 -824
  668. package/dist/server-context-LrlgrZzS.js +0 -824
  669. package/dist/server-node-events-Dm52i7NW.js +0 -231
  670. package/dist/server-node-events-QX523UyF.js +0 -233
  671. package/dist/service-BNVpYcQe.js +0 -642
  672. package/dist/service-D56aMXUB.js +0 -642
  673. package/dist/service-audit-D0X_XAB2.js +0 -488
  674. package/dist/service-audit-qmf6XMmP.js +0 -488
  675. package/dist/session-CrQQLLhx.js +0 -179
  676. package/dist/session-LocsOOWJ.js +0 -181
  677. package/dist/session-Vlce2BAT.js +0 -181
  678. package/dist/session-cost-usage-BwiTZuKl.js +0 -600
  679. package/dist/session-cost-usage-DT9YNXTJ.js +0 -600
  680. package/dist/sessions-BfV53TbG.js +0 -1296
  681. package/dist/sessions-BimpX_km.js +0 -180
  682. package/dist/sessions-DcXpzig0.js +0 -1296
  683. package/dist/sessions-Wd18dukK.js +0 -2038
  684. package/dist/shared-Bsr69u_7.js +0 -77
  685. package/dist/shared-Cgly1vPb.js +0 -66
  686. package/dist/shared-JOo05hST.js +0 -66
  687. package/dist/shared-f7dvQsi7.js +0 -77
  688. package/dist/skill-scanner-CkaVLABv.js +0 -263
  689. package/dist/skills-B-G7UHOa.js +0 -808
  690. package/dist/skills-B5LQx4lT.js +0 -807
  691. package/dist/skills-cli-DUGe2ZWW.js +0 -286
  692. package/dist/skills-cli-DtOk0bvK.js +0 -289
  693. package/dist/skills-status-Clq9ZnYu.js +0 -166
  694. package/dist/skills-status-JQluhU-P.js +0 -166
  695. package/dist/sqlite-BukcjdJa.js +0 -321
  696. package/dist/sqlite-CGcOZZ0C.js +0 -368
  697. package/dist/sqlite-Ck6f9KWc.js +0 -453
  698. package/dist/start--xmSFepB.js +0 -372
  699. package/dist/start-BdlZbqrr.js +0 -371
  700. package/dist/status-BgoeFm6g.js +0 -2137
  701. package/dist/status-BjjDrUq7.js +0 -27
  702. package/dist/status-Ct0DgOZ-.js +0 -2132
  703. package/dist/status-RA_uNmK0.js +0 -27
  704. package/dist/status.update-BjOH3GlS.js +0 -79
  705. package/dist/status.update-DLU1qBf0.js +0 -79
  706. package/dist/subagent-registry-9RLdKxES.js +0 -2760
  707. package/dist/subagent-registry-Byuex3zp.js +0 -2759
  708. package/dist/subagent-registry-DOBunBYS.js +0 -14
  709. package/dist/subsystem-Dowf8fSU.js +0 -860
  710. package/dist/system-cli-C5oBpzni.js +0 -79
  711. package/dist/system-cli-DXNKD_Id.js +0 -82
  712. package/dist/systemd-BSrHDyeU.js +0 -452
  713. package/dist/systemd-By5xdSB4.js +0 -452
  714. package/dist/systemd-hints-BtjL_5Rh.js +0 -36
  715. package/dist/systemd-hints-sJmr6cjb.js +0 -36
  716. package/dist/systemd-linger-CTmV2Gci.js +0 -75
  717. package/dist/systemd-linger-CmyqQkeC.js +0 -75
  718. package/dist/table-BL0lJzsm.js +0 -279
  719. package/dist/table-DoiRPsn0.js +0 -279
  720. package/dist/timeout-CswI_K-U.js +0 -232
  721. package/dist/tokens-C-X7wDKj.js +0 -14
  722. package/dist/tokens-DkvqA72p.js +0 -14
  723. package/dist/trash-BJLK1vMn.js +0 -23
  724. package/dist/trash-_x5UZ94k.js +0 -23
  725. package/dist/tui-BHjxDFZC.js +0 -3894
  726. package/dist/tui-CgOocwN8.js +0 -3894
  727. package/dist/tui-cli-5ANH8dE5.js +0 -47
  728. package/dist/tui-cli-BQ4P-JW_.js +0 -50
  729. package/dist/update-LFgxHHPd.js +0 -317
  730. package/dist/update-TxptCqk7.js +0 -317
  731. package/dist/update-check-CWc7YXmc.js +0 -400
  732. package/dist/update-check-IhlWaui6.js +0 -400
  733. package/dist/update-cli-PtXU62w7.js +0 -1105
  734. package/dist/update-cli-Va0EtETG.js +0 -1105
  735. package/dist/update-runner-BLeKFkiB.js +0 -894
  736. package/dist/update-runner-Iuzpc-_y.js +0 -894
  737. package/dist/usage-ApGvBLVg.js +0 -4516
  738. package/dist/utils-Bsw__U-F.js +0 -243
  739. package/dist/web-B6_Ky60G.js +0 -63
  740. package/dist/web-EZLQEWXY.js +0 -46842
  741. package/dist/web-pec8YJUX.js +0 -2203
  742. package/dist/webhooks-cli-BYQKTHTp.js +0 -319
  743. package/dist/webhooks-cli-C2_xtsUQ.js +0 -316
  744. package/dist/whatsapp-actions-C72VCq8f.js +0 -49
  745. package/dist/whatsapp-actions-Ck9Uv0Nw.js +0 -45
  746. package/dist/whatsapp-actions-D0reTj2k.js +0 -53
  747. package/dist/widearea-dns-B6ocX23x.js +0 -127
  748. package/dist/widearea-dns-NsEUNYwz.js +0 -127
  749. package/dist/workspace-Dcfoy5JJ.js +0 -649
  750. package/dist/ws-log-N8R5MvGE.js +0 -267
  751. package/dist/ws-log-gwFxPxj5.js +0 -267
  752. /package/dist/{auto-update-CUeF99gI.js → auto-update-CpF0fycd.js} +0 -0
  753. /package/dist/{auto-update-cgkp9ZTJ.js → auto-update-DNWdO7uF.js} +0 -0
  754. /package/dist/{brew-CVZkr0GU.js → brew-nqf_MiE4.js} +0 -0
  755. /package/dist/{budget-DxYQSekw.js → budget-CPedI-qW.js} +0 -0
  756. /package/dist/{budget-BWBp8Res.js → budget-CRpvqDRX.js} +0 -0
  757. /package/dist/{cli-utils-DtAxdCte.js → cli-utils-C1YHVD4o.js} +0 -0
  758. /package/dist/{command-options-CSbuuqHr.js → command-options-BbponVnw.js} +0 -0
  759. /package/dist/{command-options-Cp1tf96a.js → command-options-s0gnvXnS.js} +0 -0
  760. /package/dist/{constants-O8yBqCBv.js → constants-Dhb6zSIV.js} +0 -0
  761. /package/dist/{dangerous-tools-5ObDWy1N.js → dangerous-tools-DGTtJ_JR.js} +0 -0
  762. /package/dist/{dangerous-tools-Jwr7jqNw.js → dangerous-tools-DxrfTOfT.js} +0 -0
  763. /package/dist/{delivery-queue-B6IHz4Ry.js → delivery-queue-Bxm0nzw7.js} +0 -0
  764. /package/dist/{display-BDOsXu8F.js → display-Jy3UdGzA.js} +0 -0
  765. /package/dist/{errors-CHow2wtt.js → errors-CKaCqKga.js} +0 -0
  766. /package/dist/{exec-BizYYQgP.js → exec-DDmuVVNq.js} +0 -0
  767. /package/dist/{format-Mq6iU0_5.js → format-ByEjgyTF.js} +0 -0
  768. /package/dist/{format-duration-DhWzz_5b.js → format-duration-Aaj5tjJd.js} +0 -0
  769. /package/dist/{format-relative-C6kUHuOj.js → format-relative-79_Y1n2Y.js} +0 -0
  770. /package/dist/{help-format-DUBI91Ti.js → help-format-BMKzarov.js} +0 -0
  771. /package/dist/{helpers-eJFa4K6r.js → helpers-DpEB9Mh0.js} +0 -0
  772. /package/dist/{helpers-DLgbkcEn.js → helpers-FMld9sBT.js} +0 -0
  773. /package/dist/{input-provenance-DJBdpeKk.js → input-provenance-Cy_KnBlP.js} +0 -0
  774. /package/dist/{is-main-Dt9DTcH1.js → is-main-yjaVwMtJ.js} +0 -0
  775. /package/dist/{loader-l2OBdJ8x.js → loader-Br7Vr0zn.js} +0 -0
  776. /package/dist/{loader-BoYxRfcW.js → loader-CkmOrXcC.js} +0 -0
  777. /package/dist/{logging-BdnOSVPD.js → logging-CY-Q5cwf.js} +0 -0
  778. /package/dist/{message-channel-w4F2b2F6.js → message-channel-dua8OOGJ.js} +0 -0
  779. /package/dist/{mime-B1ZoR53M.js → mime-CBg4KybI.js} +0 -0
  780. /package/dist/{model-param-b-DPwyNGn8.js → model-param-b-DW9f0NN8.js} +0 -0
  781. /package/dist/{node-match-8XZnaid6.js → node-match-BV8bTBd4.js} +0 -0
  782. /package/dist/{normalize-GDK8JTNW.js → normalize-_lmlBOW9.js} +0 -0
  783. /package/dist/{openclaw-root-C85WMnVV.js → openclaw-root-JPvmPTf7.js} +0 -0
  784. /package/dist/{outbound-send-deps-ANnAhImn.js → outbound-send-deps-BfUvuWGa.js} +0 -0
  785. /package/dist/{parse-6-2MDhdT.js → parse-CZRwKocn.js} +0 -0
  786. /package/dist/{parse-log-line-Bqh1SSzC.js → parse-log-line-CvrZEK6A.js} +0 -0
  787. /package/dist/{parse-log-line-DUZCjXbl.js → parse-log-line-mLdat0AH.js} +0 -0
  788. /package/dist/{parse-port-BKB9Exlg.js → parse-port-BSOOdo7I.js} +0 -0
  789. /package/dist/{parse-port-DrfvwwiL.js → parse-port-Y0NK62x1.js} +0 -0
  790. /package/dist/{parse-timeout-Di_tcEmi.js → parse-timeout-DVPQ3n9j.js} +0 -0
  791. /package/dist/{paths-DcVEkYX5.js → paths-DHjlJ6cn.js} +0 -0
  792. /package/dist/{pi-model-discovery-DsRqYJLy.js → pi-model-discovery-DzEIEgHL.js} +0 -0
  793. /package/dist/{plugins-CDJw924T.js → plugins-D6PBOdkn.js} +0 -0
  794. /package/dist/{program-context-Bvn8046-.js → program-context-Q1hkT73c.js} +0 -0
  795. /package/dist/{progress-CbZ2D53A.js → progress-C9Ha1NJh.js} +0 -0
  796. /package/dist/{prompt-style-DKy6qQxR.js → prompt-style-DQi8j03a.js} +0 -0
  797. /package/dist/{prompts-BI__va99.js → prompts-BEHxUC3w.js} +0 -0
  798. /package/dist/{prompts-_dDWkCAz.js → prompts-CSOhuiqe.js} +0 -0
  799. /package/dist/{queue-D_u34pbL.js → queue-BJGo7kAB.js} +0 -0
  800. /package/dist/{queue-PG591iID.js → queue-DYgUbdoq.js} +0 -0
  801. /package/dist/{redact-ClVwO7Nn.js → redact-CyKvdFrg.js} +0 -0
  802. /package/dist/{registry-Bs_DJK9E.js → registry-C5MAYD4V.js} +0 -0
  803. /package/dist/{registry-D_zlP1U-.js → registry-CRrXXVs0.js} +0 -0
  804. /package/dist/{requirements-BzZxj2Wu.js → requirements-CGkxTCu4.js} +0 -0
  805. /package/dist/{requirements-DIW1svgA.js → requirements-CIDaOcbO.js} +0 -0
  806. /package/dist/{runtime-guard-DeOXA_86.js → runtime-guard-nL3Lp8T-.js} +0 -0
  807. /package/dist/{secret-equal-Dghy3xsA.js → secret-equal-DJpmLXlG.js} +0 -0
  808. /package/dist/{send-BhAfdGII.js → send-CTcxgDDU.js} +0 -0
  809. /package/dist/{send-ga9udK1_.js → send-DPezUR3-.js} +0 -0
  810. /package/dist/{send-C2t9xpXI.js → send-DZQTaG7-.js} +0 -0
  811. /package/dist/{send-DigO-i9j.js → send-VDff2gra.js} +0 -0
  812. /package/dist/{send-Dz2BDHll.js → send-bgQNV8d1.js} +0 -0
  813. /package/dist/{session-key-BGiG_JcT.js → session-key-CQT-NR6w.js} +0 -0
  814. /package/dist/{shell-argv-CAq1mLa2.js → shell-argv-n9IueeJQ.js} +0 -0
  815. /package/dist/{skill-scanner-Coo4QoCd.js → skill-scanner-o6NgVMD9.js} +0 -0
  816. /package/dist/{status-CMnlcBVc.js → status-C53kTIXF.js} +0 -0
  817. /package/dist/{status-tDZPwewW.js → status-CZDDA_Sy.js} +0 -0
  818. /package/dist/{system-run-command-X9lDJIy0.js → system-run-command-BCjUffN9.js} +0 -0
  819. /package/dist/{system-run-command-DGk7dwQP.js → system-run-command-CqAqKL9K.js} +0 -0
  820. /package/dist/{tailnet-CuiNECdL.js → tailnet-Ciwjv243.js} +0 -0
  821. /package/dist/{templates-CeYJjVzw.js → templates-37RKpACb.js} +0 -0
  822. /package/dist/{templates-I3Z0xplD.js → templates-DPalk30o.js} +0 -0
  823. /package/dist/{thinking-BXEswx1X.js → thinking-2hxwmvTl.js} +0 -0
  824. /package/dist/{transcript-events-C1hdue6u.js → transcript-events-Bp7fGnwv.js} +0 -0
  825. /package/dist/{transcript-tools-DuyYOkUq.js → transcript-tools-D4Lbxlka.js} +0 -0
  826. /package/dist/{usage-format-BAirWUSO.js → usage-format-6Uar63S0.js} +0 -0
  827. /package/dist/{utils-C9sj30YY.js → utils-DT8uXjFS.js} +0 -0
  828. /package/dist/{wsl-CqyuRvtM.js → wsl-CrPvx2kZ.js} +0 -0
  829. /package/dist/{wsl-ymJYvc9Q.js → wsl-UvJ5dHah.js} +0 -0
@@ -0,0 +1,3894 @@
1
+ import { m as visibleWidth, p as stripAnsi } from "./entry.js";
2
+ import { i as buildAgentMainSessionKey, l as normalizeAgentId, u as normalizeMainKey, x as parseAgentSessionKey } from "./session-key-CQT-NR6w.js";
3
+ import { x as shortenHomeInString } from "./utils-DT8uXjFS.js";
4
+ import { c as resolveDefaultAgentId } from "./agent-scope-DZgptr9J.js";
5
+ import { M as VERSION, i as loadConfig } from "./config-CU-Axg8P.js";
6
+ import { Dt as PROTOCOL_VERSION, t as GatewayClient } from "./client-Dswwze5_.js";
7
+ import { a as resolveExplicitGatewayAuth, r as ensureExplicitGatewayAuth, t as buildGatewayConnectionDetails } from "./call-BIzCaKZb.js";
8
+ import { f as GATEWAY_CLIENT_CAPS, h as GATEWAY_CLIENT_NAMES, m as GATEWAY_CLIENT_MODES } from "./message-channel-dua8OOGJ.js";
9
+ import { c as normalizeUsageDisplay, r as listThinkingLevelLabels, t as formatThinkingLevels, u as resolveResponseUsageMode } from "./thinking-2hxwmvTl.js";
10
+ import { n as listChatCommandsForConfig, t as listChatCommands } from "./commands-registry-cFqZ6Ib4.js";
11
+ import { n as formatTimeAgo, t as formatRelativeTimestamp } from "./format-relative-79_Y1n2Y.js";
12
+ import { n as formatTokenCount } from "./usage-format-6Uar63S0.js";
13
+ import { r as redactToolDetail } from "./redact-CyKvdFrg.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 parseCommand(input) {
37
+ const trimmed = input.replace(/^\//, "").trim();
38
+ if (!trimmed) return {
39
+ name: "",
40
+ args: ""
41
+ };
42
+ const [name, ...rest] = trimmed.split(/\s+/);
43
+ const normalized = name.toLowerCase();
44
+ return {
45
+ name: COMMAND_ALIASES[normalized] ?? normalized,
46
+ args: rest.join(" ").trim()
47
+ };
48
+ }
49
+ function getSlashCommands(options = {}) {
50
+ const thinkLevels = listThinkingLevelLabels(options.provider, options.model);
51
+ const commands = [
52
+ {
53
+ name: "help",
54
+ description: "Show slash command help"
55
+ },
56
+ {
57
+ name: "status",
58
+ description: "Show gateway status summary"
59
+ },
60
+ {
61
+ name: "agent",
62
+ description: "Switch agent (or open picker)"
63
+ },
64
+ {
65
+ name: "agents",
66
+ description: "Open agent picker"
67
+ },
68
+ {
69
+ name: "session",
70
+ description: "Switch session (or open picker)"
71
+ },
72
+ {
73
+ name: "sessions",
74
+ description: "Open session picker"
75
+ },
76
+ {
77
+ name: "model",
78
+ description: "Set model (or open picker)"
79
+ },
80
+ {
81
+ name: "models",
82
+ description: "Open model picker"
83
+ },
84
+ {
85
+ name: "think",
86
+ description: "Set thinking level",
87
+ getArgumentCompletions: (prefix) => thinkLevels.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
88
+ value,
89
+ label: value
90
+ }))
91
+ },
92
+ {
93
+ name: "verbose",
94
+ description: "Set verbose on/off",
95
+ getArgumentCompletions: (prefix) => VERBOSE_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
96
+ value,
97
+ label: value
98
+ }))
99
+ },
100
+ {
101
+ name: "reasoning",
102
+ description: "Set reasoning on/off",
103
+ getArgumentCompletions: (prefix) => REASONING_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
104
+ value,
105
+ label: value
106
+ }))
107
+ },
108
+ {
109
+ name: "usage",
110
+ description: "Toggle per-response usage line",
111
+ getArgumentCompletions: (prefix) => USAGE_FOOTER_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
112
+ value,
113
+ label: value
114
+ }))
115
+ },
116
+ {
117
+ name: "elevated",
118
+ description: "Set elevated on/off/ask/full",
119
+ getArgumentCompletions: (prefix) => ELEVATED_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
120
+ value,
121
+ label: value
122
+ }))
123
+ },
124
+ {
125
+ name: "elev",
126
+ description: "Alias for /elevated",
127
+ getArgumentCompletions: (prefix) => ELEVATED_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
128
+ value,
129
+ label: value
130
+ }))
131
+ },
132
+ {
133
+ name: "activation",
134
+ description: "Set group activation",
135
+ getArgumentCompletions: (prefix) => ACTIVATION_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
136
+ value,
137
+ label: value
138
+ }))
139
+ },
140
+ {
141
+ name: "abort",
142
+ description: "Abort active run"
143
+ },
144
+ {
145
+ name: "new",
146
+ description: "Reset the session"
147
+ },
148
+ {
149
+ name: "reset",
150
+ description: "Reset the session"
151
+ },
152
+ {
153
+ name: "settings",
154
+ description: "Open settings"
155
+ },
156
+ {
157
+ name: "exit",
158
+ description: "Exit the TUI"
159
+ },
160
+ {
161
+ name: "quit",
162
+ description: "Exit the TUI"
163
+ }
164
+ ];
165
+ const seen = new Set(commands.map((command) => command.name));
166
+ const gatewayCommands = options.cfg ? listChatCommandsForConfig(options.cfg) : listChatCommands();
167
+ for (const command of gatewayCommands) {
168
+ const aliases = command.textAliases.length > 0 ? command.textAliases : [`/${command.key}`];
169
+ for (const alias of aliases) {
170
+ const name = alias.replace(/^\//, "").trim();
171
+ if (!name || seen.has(name)) continue;
172
+ seen.add(name);
173
+ commands.push({
174
+ name,
175
+ description: command.description
176
+ });
177
+ }
178
+ }
179
+ return commands;
180
+ }
181
+ function helpText(options = {}) {
182
+ return [
183
+ "Slash commands:",
184
+ "/help",
185
+ "/commands",
186
+ "/status",
187
+ "/agent <id> (or /agents)",
188
+ "/session <key> (or /sessions)",
189
+ "/model <provider/model> (or /models)",
190
+ `/think <${formatThinkingLevels(options.provider, options.model, "|")}>`,
191
+ "/verbose <on|off>",
192
+ "/reasoning <on|off>",
193
+ "/usage <off|tokens|full>",
194
+ "/elevated <on|off|ask|full>",
195
+ "/elev <on|off|ask|full>",
196
+ "/activation <mention|always>",
197
+ "/new or /reset",
198
+ "/abort",
199
+ "/settings",
200
+ "/exit"
201
+ ].join("\n");
202
+ }
203
+
204
+ //#endregion
205
+ //#region src/tui/theme/syntax-theme.ts
206
+ /**
207
+ * Syntax highlighting theme for code blocks.
208
+ * Uses chalk functions to style different token types.
209
+ */
210
+ function createSyntaxTheme(fallback) {
211
+ return {
212
+ keyword: chalk.hex("#C586C0"),
213
+ built_in: chalk.hex("#4EC9B0"),
214
+ type: chalk.hex("#4EC9B0"),
215
+ literal: chalk.hex("#569CD6"),
216
+ number: chalk.hex("#B5CEA8"),
217
+ string: chalk.hex("#CE9178"),
218
+ regexp: chalk.hex("#D16969"),
219
+ symbol: chalk.hex("#B5CEA8"),
220
+ class: chalk.hex("#4EC9B0"),
221
+ function: chalk.hex("#DCDCAA"),
222
+ title: chalk.hex("#DCDCAA"),
223
+ params: chalk.hex("#9CDCFE"),
224
+ comment: chalk.hex("#6A9955"),
225
+ doctag: chalk.hex("#608B4E"),
226
+ meta: chalk.hex("#9CDCFE"),
227
+ "meta-keyword": chalk.hex("#C586C0"),
228
+ "meta-string": chalk.hex("#CE9178"),
229
+ section: chalk.hex("#DCDCAA"),
230
+ tag: chalk.hex("#569CD6"),
231
+ name: chalk.hex("#9CDCFE"),
232
+ attr: chalk.hex("#9CDCFE"),
233
+ attribute: chalk.hex("#9CDCFE"),
234
+ variable: chalk.hex("#9CDCFE"),
235
+ bullet: chalk.hex("#D7BA7D"),
236
+ code: chalk.hex("#CE9178"),
237
+ emphasis: chalk.italic,
238
+ strong: chalk.bold,
239
+ formula: chalk.hex("#C586C0"),
240
+ link: chalk.hex("#4EC9B0"),
241
+ quote: chalk.hex("#6A9955"),
242
+ addition: chalk.hex("#B5CEA8"),
243
+ deletion: chalk.hex("#F44747"),
244
+ "selector-tag": chalk.hex("#D7BA7D"),
245
+ "selector-id": chalk.hex("#D7BA7D"),
246
+ "selector-class": chalk.hex("#D7BA7D"),
247
+ "selector-attr": chalk.hex("#D7BA7D"),
248
+ "selector-pseudo": chalk.hex("#D7BA7D"),
249
+ "template-tag": chalk.hex("#C586C0"),
250
+ "template-variable": chalk.hex("#9CDCFE"),
251
+ default: fallback
252
+ };
253
+ }
254
+
255
+ //#endregion
256
+ //#region src/tui/theme/theme.ts
257
+ const palette = {
258
+ text: "#E8E3D5",
259
+ dim: "#7B7F87",
260
+ accent: "#F6C453",
261
+ accentSoft: "#F2A65A",
262
+ border: "#3C414B",
263
+ userBg: "#2B2F36",
264
+ userText: "#F3EEE0",
265
+ systemText: "#9BA3B2",
266
+ toolPendingBg: "#1F2A2F",
267
+ toolSuccessBg: "#1E2D23",
268
+ toolErrorBg: "#2F1F1F",
269
+ toolTitle: "#F6C453",
270
+ toolOutput: "#E1DACB",
271
+ quote: "#8CC8FF",
272
+ quoteBorder: "#3B4D6B",
273
+ code: "#F0C987",
274
+ codeBlock: "#1E232A",
275
+ codeBorder: "#343A45",
276
+ link: "#7DD3A5",
277
+ error: "#F97066",
278
+ success: "#7DD3A5"
279
+ };
280
+ const fg = (hex) => (text) => chalk.hex(hex)(text);
281
+ const bg = (hex) => (text) => chalk.bgHex(hex)(text);
282
+ const syntaxTheme = createSyntaxTheme(fg(palette.code));
283
+ /**
284
+ * Highlight code with syntax coloring.
285
+ * Returns an array of lines with ANSI escape codes.
286
+ */
287
+ function highlightCode(code, lang) {
288
+ try {
289
+ return highlight(code, {
290
+ language: lang && supportsLanguage(lang) ? lang : void 0,
291
+ theme: syntaxTheme,
292
+ ignoreIllegals: true
293
+ }).split("\n");
294
+ } catch {
295
+ return code.split("\n").map((line) => fg(palette.code)(line));
296
+ }
297
+ }
298
+ const theme = {
299
+ fg: fg(palette.text),
300
+ assistantText: (text) => text,
301
+ dim: fg(palette.dim),
302
+ accent: fg(palette.accent),
303
+ accentSoft: fg(palette.accentSoft),
304
+ success: fg(palette.success),
305
+ error: fg(palette.error),
306
+ header: (text) => chalk.bold(fg(palette.accent)(text)),
307
+ system: fg(palette.systemText),
308
+ userBg: bg(palette.userBg),
309
+ userText: fg(palette.userText),
310
+ toolTitle: fg(palette.toolTitle),
311
+ toolOutput: fg(palette.toolOutput),
312
+ toolPendingBg: bg(palette.toolPendingBg),
313
+ toolSuccessBg: bg(palette.toolSuccessBg),
314
+ toolErrorBg: bg(palette.toolErrorBg),
315
+ border: fg(palette.border),
316
+ bold: (text) => chalk.bold(text),
317
+ italic: (text) => chalk.italic(text)
318
+ };
319
+ const markdownTheme = {
320
+ heading: (text) => chalk.bold(fg(palette.accent)(text)),
321
+ link: (text) => fg(palette.link)(text),
322
+ linkUrl: (text) => chalk.dim(text),
323
+ code: (text) => fg(palette.code)(text),
324
+ codeBlock: (text) => fg(palette.code)(text),
325
+ codeBlockBorder: (text) => fg(palette.codeBorder)(text),
326
+ quote: (text) => fg(palette.quote)(text),
327
+ quoteBorder: (text) => fg(palette.quoteBorder)(text),
328
+ hr: (text) => fg(palette.border)(text),
329
+ listBullet: (text) => fg(palette.accentSoft)(text),
330
+ bold: (text) => chalk.bold(text),
331
+ italic: (text) => chalk.italic(text),
332
+ strikethrough: (text) => chalk.strikethrough(text),
333
+ underline: (text) => chalk.underline(text),
334
+ highlightCode
335
+ };
336
+ const selectListTheme = {
337
+ selectedPrefix: (text) => fg(palette.accent)(text),
338
+ selectedText: (text) => chalk.bold(fg(palette.accent)(text)),
339
+ description: (text) => fg(palette.dim)(text),
340
+ scrollInfo: (text) => fg(palette.dim)(text),
341
+ noMatch: (text) => fg(palette.dim)(text)
342
+ };
343
+ const filterableSelectListTheme = {
344
+ ...selectListTheme,
345
+ filterLabel: (text) => fg(palette.dim)(text)
346
+ };
347
+ const settingsListTheme = {
348
+ label: (text, selected) => selected ? chalk.bold(fg(palette.accent)(text)) : fg(palette.text)(text),
349
+ value: (text, selected) => selected ? fg(palette.accentSoft)(text) : fg(palette.dim)(text),
350
+ description: (text) => fg(palette.systemText)(text),
351
+ cursor: fg(palette.accent)("→ "),
352
+ hint: (text) => fg(palette.dim)(text)
353
+ };
354
+ const editorTheme = {
355
+ borderColor: (text) => fg(palette.border)(text),
356
+ selectList: selectListTheme
357
+ };
358
+ const searchableSelectListTheme = {
359
+ selectedPrefix: (text) => fg(palette.accent)(text),
360
+ selectedText: (text) => chalk.bold(fg(palette.accent)(text)),
361
+ description: (text) => fg(palette.dim)(text),
362
+ scrollInfo: (text) => fg(palette.dim)(text),
363
+ noMatch: (text) => fg(palette.dim)(text),
364
+ searchPrompt: (text) => fg(palette.accentSoft)(text),
365
+ searchInput: (text) => fg(palette.text)(text),
366
+ matchHighlight: (text) => chalk.bold(fg(palette.accent)(text))
367
+ };
368
+
369
+ //#endregion
370
+ //#region src/tui/components/assistant-message.ts
371
+ var AssistantMessageComponent = class extends Container {
372
+ constructor(text) {
373
+ super();
374
+ this.body = new Markdown(text, 1, 0, markdownTheme, { color: (line) => theme.assistantText(line) });
375
+ this.addChild(new Spacer(1));
376
+ this.addChild(this.body);
377
+ }
378
+ setText(text) {
379
+ this.body.setText(text);
380
+ }
381
+ };
382
+
383
+ //#endregion
384
+ //#region src/agents/tool-display-common.ts
385
+ function normalizeToolName(name) {
386
+ return (name ?? "tool").trim();
387
+ }
388
+ function defaultTitle(name) {
389
+ const cleaned = name.replace(/_/g, " ").trim();
390
+ if (!cleaned) return "Tool";
391
+ return cleaned.split(/\s+/).map((part) => part.length <= 2 && part.toUpperCase() === part ? part : `${part.at(0)?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
392
+ }
393
+ function normalizeVerb(value) {
394
+ const trimmed = value?.trim();
395
+ if (!trimmed) return;
396
+ return trimmed.replace(/_/g, " ");
397
+ }
398
+ function coerceDisplayValue(value, opts = {}) {
399
+ const maxStringChars = opts.maxStringChars ?? 160;
400
+ const maxArrayEntries = opts.maxArrayEntries ?? 3;
401
+ if (value === null || value === void 0) return;
402
+ if (typeof value === "string") {
403
+ const trimmed = value.trim();
404
+ if (!trimmed) return;
405
+ const firstLine = trimmed.split(/\r?\n/)[0]?.trim() ?? "";
406
+ if (!firstLine) return;
407
+ if (firstLine.length > maxStringChars) return `${firstLine.slice(0, Math.max(0, maxStringChars - 3))}…`;
408
+ return firstLine;
409
+ }
410
+ if (typeof value === "boolean") {
411
+ if (!value && !opts.includeFalse) return;
412
+ return value ? "true" : "false";
413
+ }
414
+ if (typeof value === "number") {
415
+ if (!Number.isFinite(value)) return opts.includeNonFinite ? String(value) : void 0;
416
+ if (value === 0 && !opts.includeZero) return;
417
+ return String(value);
418
+ }
419
+ if (Array.isArray(value)) {
420
+ const values = value.map((item) => coerceDisplayValue(item, opts)).filter((item) => Boolean(item));
421
+ if (values.length === 0) return;
422
+ const preview = values.slice(0, maxArrayEntries).join(", ");
423
+ return values.length > maxArrayEntries ? `${preview}…` : preview;
424
+ }
425
+ }
426
+ function lookupValueByPath(args, path) {
427
+ if (!args || typeof args !== "object") return;
428
+ let current = args;
429
+ for (const segment of path.split(".")) {
430
+ if (!segment) return;
431
+ if (!current || typeof current !== "object") return;
432
+ current = current[segment];
433
+ }
434
+ return current;
435
+ }
436
+ function formatDetailKey(raw, overrides = {}) {
437
+ const last = raw.split(".").filter(Boolean).at(-1) ?? raw;
438
+ const override = overrides[last];
439
+ if (override) return override;
440
+ return last.replace(/_/g, " ").replace(/-/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim().toLowerCase() || last.toLowerCase();
441
+ }
442
+ function resolveReadDetail(args) {
443
+ if (!args || typeof args !== "object") return;
444
+ const record = args;
445
+ const path = typeof record.path === "string" ? record.path : void 0;
446
+ if (!path) return;
447
+ const offset = typeof record.offset === "number" ? record.offset : void 0;
448
+ const limit = typeof record.limit === "number" ? record.limit : void 0;
449
+ if (offset !== void 0 && limit !== void 0) return `${path}:${offset}-${offset + limit}`;
450
+ return path;
451
+ }
452
+ function resolveWriteDetail(args) {
453
+ if (!args || typeof args !== "object") return;
454
+ const record = args;
455
+ return typeof record.path === "string" ? record.path : void 0;
456
+ }
457
+ function resolveActionSpec(spec, action) {
458
+ if (!spec || !action) return;
459
+ return spec.actions?.[action] ?? void 0;
460
+ }
461
+ function resolveDetailFromKeys(args, keys, opts) {
462
+ if (opts.mode === "first") {
463
+ for (const key of keys) {
464
+ const display = coerceDisplayValue(lookupValueByPath(args, key), opts.coerce);
465
+ if (display) return display;
466
+ }
467
+ return;
468
+ }
469
+ const entries = [];
470
+ for (const key of keys) {
471
+ const display = coerceDisplayValue(lookupValueByPath(args, key), opts.coerce);
472
+ if (!display) continue;
473
+ entries.push({
474
+ label: opts.formatKey ? opts.formatKey(key) : key,
475
+ value: display
476
+ });
477
+ }
478
+ if (entries.length === 0) return;
479
+ if (entries.length === 1) return entries[0].value;
480
+ const seen = /* @__PURE__ */ new Set();
481
+ const unique = [];
482
+ for (const entry of entries) {
483
+ const token = `${entry.label}:${entry.value}`;
484
+ if (seen.has(token)) continue;
485
+ seen.add(token);
486
+ unique.push(entry);
487
+ }
488
+ if (unique.length === 0) return;
489
+ return unique.slice(0, opts.maxEntries ?? 8).map((entry) => `${entry.label} ${entry.value}`).join(" · ");
490
+ }
491
+
492
+ //#endregion
493
+ //#region src/agents/tool-display.json
494
+ var tool_display_default = {
495
+ version: 1,
496
+ fallback: {
497
+ "emoji": "🧩",
498
+ "detailKeys": [
499
+ "command",
500
+ "path",
501
+ "url",
502
+ "targetUrl",
503
+ "targetId",
504
+ "ref",
505
+ "element",
506
+ "node",
507
+ "nodeId",
508
+ "id",
509
+ "requestId",
510
+ "to",
511
+ "channelId",
512
+ "guildId",
513
+ "userId",
514
+ "name",
515
+ "query",
516
+ "pattern",
517
+ "messageId"
518
+ ]
519
+ },
520
+ tools: {
521
+ "exec": {
522
+ "emoji": "🛠️",
523
+ "title": "Exec",
524
+ "detailKeys": ["command"]
525
+ },
526
+ "process": {
527
+ "emoji": "🧰",
528
+ "title": "Process",
529
+ "detailKeys": ["sessionId"]
530
+ },
531
+ "read": {
532
+ "emoji": "📖",
533
+ "title": "Read",
534
+ "detailKeys": ["path"]
535
+ },
536
+ "write": {
537
+ "emoji": "✍️",
538
+ "title": "Write",
539
+ "detailKeys": ["path"]
540
+ },
541
+ "edit": {
542
+ "emoji": "📝",
543
+ "title": "Edit",
544
+ "detailKeys": ["path"]
545
+ },
546
+ "apply_patch": {
547
+ "emoji": "🩹",
548
+ "title": "Apply Patch",
549
+ "detailKeys": []
550
+ },
551
+ "attach": {
552
+ "emoji": "📎",
553
+ "title": "Attach",
554
+ "detailKeys": [
555
+ "path",
556
+ "url",
557
+ "fileName"
558
+ ]
559
+ },
560
+ "browser": {
561
+ "emoji": "🌐",
562
+ "title": "Browser",
563
+ "actions": {
564
+ "status": { "label": "status" },
565
+ "start": { "label": "start" },
566
+ "stop": { "label": "stop" },
567
+ "tabs": { "label": "tabs" },
568
+ "open": {
569
+ "label": "open",
570
+ "detailKeys": ["targetUrl"]
571
+ },
572
+ "focus": {
573
+ "label": "focus",
574
+ "detailKeys": ["targetId"]
575
+ },
576
+ "close": {
577
+ "label": "close",
578
+ "detailKeys": ["targetId"]
579
+ },
580
+ "snapshot": {
581
+ "label": "snapshot",
582
+ "detailKeys": [
583
+ "targetUrl",
584
+ "targetId",
585
+ "ref",
586
+ "element",
587
+ "format"
588
+ ]
589
+ },
590
+ "screenshot": {
591
+ "label": "screenshot",
592
+ "detailKeys": [
593
+ "targetUrl",
594
+ "targetId",
595
+ "ref",
596
+ "element"
597
+ ]
598
+ },
599
+ "navigate": {
600
+ "label": "navigate",
601
+ "detailKeys": ["targetUrl", "targetId"]
602
+ },
603
+ "console": {
604
+ "label": "console",
605
+ "detailKeys": ["level", "targetId"]
606
+ },
607
+ "pdf": {
608
+ "label": "pdf",
609
+ "detailKeys": ["targetId"]
610
+ },
611
+ "upload": {
612
+ "label": "upload",
613
+ "detailKeys": [
614
+ "paths",
615
+ "ref",
616
+ "inputRef",
617
+ "element",
618
+ "targetId"
619
+ ]
620
+ },
621
+ "dialog": {
622
+ "label": "dialog",
623
+ "detailKeys": [
624
+ "accept",
625
+ "promptText",
626
+ "targetId"
627
+ ]
628
+ },
629
+ "act": {
630
+ "label": "act",
631
+ "detailKeys": [
632
+ "request.kind",
633
+ "request.ref",
634
+ "request.selector",
635
+ "request.text",
636
+ "request.value"
637
+ ]
638
+ }
639
+ }
640
+ },
641
+ "canvas": {
642
+ "emoji": "🖼️",
643
+ "title": "Canvas",
644
+ "actions": {
645
+ "present": {
646
+ "label": "present",
647
+ "detailKeys": [
648
+ "target",
649
+ "node",
650
+ "nodeId"
651
+ ]
652
+ },
653
+ "hide": {
654
+ "label": "hide",
655
+ "detailKeys": ["node", "nodeId"]
656
+ },
657
+ "navigate": {
658
+ "label": "navigate",
659
+ "detailKeys": [
660
+ "url",
661
+ "node",
662
+ "nodeId"
663
+ ]
664
+ },
665
+ "eval": {
666
+ "label": "eval",
667
+ "detailKeys": [
668
+ "javaScript",
669
+ "node",
670
+ "nodeId"
671
+ ]
672
+ },
673
+ "snapshot": {
674
+ "label": "snapshot",
675
+ "detailKeys": [
676
+ "format",
677
+ "node",
678
+ "nodeId"
679
+ ]
680
+ },
681
+ "a2ui_push": {
682
+ "label": "A2UI push",
683
+ "detailKeys": [
684
+ "jsonlPath",
685
+ "node",
686
+ "nodeId"
687
+ ]
688
+ },
689
+ "a2ui_reset": {
690
+ "label": "A2UI reset",
691
+ "detailKeys": ["node", "nodeId"]
692
+ }
693
+ }
694
+ },
695
+ "nodes": {
696
+ "emoji": "📱",
697
+ "title": "Nodes",
698
+ "actions": {
699
+ "status": { "label": "status" },
700
+ "describe": {
701
+ "label": "describe",
702
+ "detailKeys": ["node", "nodeId"]
703
+ },
704
+ "pending": { "label": "pending" },
705
+ "approve": {
706
+ "label": "approve",
707
+ "detailKeys": ["requestId"]
708
+ },
709
+ "reject": {
710
+ "label": "reject",
711
+ "detailKeys": ["requestId"]
712
+ },
713
+ "notify": {
714
+ "label": "notify",
715
+ "detailKeys": [
716
+ "node",
717
+ "nodeId",
718
+ "title",
719
+ "body"
720
+ ]
721
+ },
722
+ "camera_snap": {
723
+ "label": "camera snap",
724
+ "detailKeys": [
725
+ "node",
726
+ "nodeId",
727
+ "facing",
728
+ "deviceId"
729
+ ]
730
+ },
731
+ "camera_list": {
732
+ "label": "camera list",
733
+ "detailKeys": ["node", "nodeId"]
734
+ },
735
+ "camera_clip": {
736
+ "label": "camera clip",
737
+ "detailKeys": [
738
+ "node",
739
+ "nodeId",
740
+ "facing",
741
+ "duration",
742
+ "durationMs"
743
+ ]
744
+ },
745
+ "screen_record": {
746
+ "label": "screen record",
747
+ "detailKeys": [
748
+ "node",
749
+ "nodeId",
750
+ "duration",
751
+ "durationMs",
752
+ "fps",
753
+ "screenIndex"
754
+ ]
755
+ }
756
+ }
757
+ },
758
+ "cron": {
759
+ "emoji": "⏰",
760
+ "title": "Cron",
761
+ "actions": {
762
+ "status": { "label": "status" },
763
+ "list": { "label": "list" },
764
+ "add": {
765
+ "label": "add",
766
+ "detailKeys": [
767
+ "job.name",
768
+ "job.id",
769
+ "job.schedule",
770
+ "job.cron"
771
+ ]
772
+ },
773
+ "update": {
774
+ "label": "update",
775
+ "detailKeys": ["id"]
776
+ },
777
+ "remove": {
778
+ "label": "remove",
779
+ "detailKeys": ["id"]
780
+ },
781
+ "run": {
782
+ "label": "run",
783
+ "detailKeys": ["id"]
784
+ },
785
+ "runs": {
786
+ "label": "runs",
787
+ "detailKeys": ["id"]
788
+ },
789
+ "wake": {
790
+ "label": "wake",
791
+ "detailKeys": ["text", "mode"]
792
+ }
793
+ }
794
+ },
795
+ "gateway": {
796
+ "emoji": "🔌",
797
+ "title": "Gateway",
798
+ "actions": { "restart": {
799
+ "label": "restart",
800
+ "detailKeys": ["reason", "delayMs"]
801
+ } }
802
+ },
803
+ "message": {
804
+ "emoji": "✉️",
805
+ "title": "Message",
806
+ "actions": {
807
+ "send": {
808
+ "label": "send",
809
+ "detailKeys": [
810
+ "provider",
811
+ "to",
812
+ "media",
813
+ "replyTo",
814
+ "threadId"
815
+ ]
816
+ },
817
+ "poll": {
818
+ "label": "poll",
819
+ "detailKeys": [
820
+ "provider",
821
+ "to",
822
+ "pollQuestion"
823
+ ]
824
+ },
825
+ "react": {
826
+ "label": "react",
827
+ "detailKeys": [
828
+ "provider",
829
+ "to",
830
+ "messageId",
831
+ "emoji",
832
+ "remove"
833
+ ]
834
+ },
835
+ "reactions": {
836
+ "label": "reactions",
837
+ "detailKeys": [
838
+ "provider",
839
+ "to",
840
+ "messageId",
841
+ "limit"
842
+ ]
843
+ },
844
+ "read": {
845
+ "label": "read",
846
+ "detailKeys": [
847
+ "provider",
848
+ "to",
849
+ "limit"
850
+ ]
851
+ },
852
+ "edit": {
853
+ "label": "edit",
854
+ "detailKeys": [
855
+ "provider",
856
+ "to",
857
+ "messageId"
858
+ ]
859
+ },
860
+ "delete": {
861
+ "label": "delete",
862
+ "detailKeys": [
863
+ "provider",
864
+ "to",
865
+ "messageId"
866
+ ]
867
+ },
868
+ "pin": {
869
+ "label": "pin",
870
+ "detailKeys": [
871
+ "provider",
872
+ "to",
873
+ "messageId"
874
+ ]
875
+ },
876
+ "unpin": {
877
+ "label": "unpin",
878
+ "detailKeys": [
879
+ "provider",
880
+ "to",
881
+ "messageId"
882
+ ]
883
+ },
884
+ "list-pins": {
885
+ "label": "list pins",
886
+ "detailKeys": ["provider", "to"]
887
+ },
888
+ "permissions": {
889
+ "label": "permissions",
890
+ "detailKeys": [
891
+ "provider",
892
+ "channelId",
893
+ "to"
894
+ ]
895
+ },
896
+ "thread-create": {
897
+ "label": "thread create",
898
+ "detailKeys": [
899
+ "provider",
900
+ "channelId",
901
+ "threadName"
902
+ ]
903
+ },
904
+ "thread-list": {
905
+ "label": "thread list",
906
+ "detailKeys": [
907
+ "provider",
908
+ "guildId",
909
+ "channelId"
910
+ ]
911
+ },
912
+ "thread-reply": {
913
+ "label": "thread reply",
914
+ "detailKeys": [
915
+ "provider",
916
+ "channelId",
917
+ "messageId"
918
+ ]
919
+ },
920
+ "search": {
921
+ "label": "search",
922
+ "detailKeys": [
923
+ "provider",
924
+ "guildId",
925
+ "query"
926
+ ]
927
+ },
928
+ "sticker": {
929
+ "label": "sticker",
930
+ "detailKeys": [
931
+ "provider",
932
+ "to",
933
+ "stickerId"
934
+ ]
935
+ },
936
+ "member-info": {
937
+ "label": "member",
938
+ "detailKeys": [
939
+ "provider",
940
+ "guildId",
941
+ "userId"
942
+ ]
943
+ },
944
+ "role-info": {
945
+ "label": "roles",
946
+ "detailKeys": ["provider", "guildId"]
947
+ },
948
+ "emoji-list": {
949
+ "label": "emoji list",
950
+ "detailKeys": ["provider", "guildId"]
951
+ },
952
+ "emoji-upload": {
953
+ "label": "emoji upload",
954
+ "detailKeys": [
955
+ "provider",
956
+ "guildId",
957
+ "emojiName"
958
+ ]
959
+ },
960
+ "sticker-upload": {
961
+ "label": "sticker upload",
962
+ "detailKeys": [
963
+ "provider",
964
+ "guildId",
965
+ "stickerName"
966
+ ]
967
+ },
968
+ "role-add": {
969
+ "label": "role add",
970
+ "detailKeys": [
971
+ "provider",
972
+ "guildId",
973
+ "userId",
974
+ "roleId"
975
+ ]
976
+ },
977
+ "role-remove": {
978
+ "label": "role remove",
979
+ "detailKeys": [
980
+ "provider",
981
+ "guildId",
982
+ "userId",
983
+ "roleId"
984
+ ]
985
+ },
986
+ "channel-info": {
987
+ "label": "channel",
988
+ "detailKeys": ["provider", "channelId"]
989
+ },
990
+ "channel-list": {
991
+ "label": "channels",
992
+ "detailKeys": ["provider", "guildId"]
993
+ },
994
+ "voice-status": {
995
+ "label": "voice",
996
+ "detailKeys": [
997
+ "provider",
998
+ "guildId",
999
+ "userId"
1000
+ ]
1001
+ },
1002
+ "event-list": {
1003
+ "label": "events",
1004
+ "detailKeys": ["provider", "guildId"]
1005
+ },
1006
+ "event-create": {
1007
+ "label": "event create",
1008
+ "detailKeys": [
1009
+ "provider",
1010
+ "guildId",
1011
+ "eventName"
1012
+ ]
1013
+ },
1014
+ "timeout": {
1015
+ "label": "timeout",
1016
+ "detailKeys": [
1017
+ "provider",
1018
+ "guildId",
1019
+ "userId"
1020
+ ]
1021
+ },
1022
+ "kick": {
1023
+ "label": "kick",
1024
+ "detailKeys": [
1025
+ "provider",
1026
+ "guildId",
1027
+ "userId"
1028
+ ]
1029
+ },
1030
+ "ban": {
1031
+ "label": "ban",
1032
+ "detailKeys": [
1033
+ "provider",
1034
+ "guildId",
1035
+ "userId"
1036
+ ]
1037
+ }
1038
+ }
1039
+ },
1040
+ "agents_list": {
1041
+ "emoji": "🧭",
1042
+ "title": "Agents",
1043
+ "detailKeys": []
1044
+ },
1045
+ "sessions_list": {
1046
+ "emoji": "🗂️",
1047
+ "title": "Sessions",
1048
+ "detailKeys": [
1049
+ "kinds",
1050
+ "limit",
1051
+ "activeMinutes",
1052
+ "messageLimit"
1053
+ ]
1054
+ },
1055
+ "sessions_history": {
1056
+ "emoji": "🧾",
1057
+ "title": "Session History",
1058
+ "detailKeys": [
1059
+ "sessionKey",
1060
+ "limit",
1061
+ "includeTools"
1062
+ ]
1063
+ },
1064
+ "sessions_send": {
1065
+ "emoji": "📨",
1066
+ "title": "Session Send",
1067
+ "detailKeys": [
1068
+ "label",
1069
+ "sessionKey",
1070
+ "agentId",
1071
+ "timeoutSeconds"
1072
+ ]
1073
+ },
1074
+ "sessions_spawn": {
1075
+ "emoji": "🧑‍🔧",
1076
+ "title": "Sub-agent",
1077
+ "detailKeys": [
1078
+ "label",
1079
+ "task",
1080
+ "agentId",
1081
+ "model",
1082
+ "thinking",
1083
+ "runTimeoutSeconds",
1084
+ "cleanup"
1085
+ ]
1086
+ },
1087
+ "subagents": {
1088
+ "emoji": "🤖",
1089
+ "title": "Subagents",
1090
+ "actions": {
1091
+ "list": {
1092
+ "label": "list",
1093
+ "detailKeys": ["recentMinutes"]
1094
+ },
1095
+ "kill": {
1096
+ "label": "kill",
1097
+ "detailKeys": ["target"]
1098
+ },
1099
+ "steer": {
1100
+ "label": "steer",
1101
+ "detailKeys": ["target"]
1102
+ }
1103
+ }
1104
+ },
1105
+ "session_status": {
1106
+ "emoji": "📊",
1107
+ "title": "Session Status",
1108
+ "detailKeys": ["sessionKey", "model"]
1109
+ },
1110
+ "memory_search": {
1111
+ "emoji": "🧠",
1112
+ "title": "Memory Search",
1113
+ "detailKeys": ["query"]
1114
+ },
1115
+ "memory_get": {
1116
+ "emoji": "📓",
1117
+ "title": "Memory Get",
1118
+ "detailKeys": [
1119
+ "path",
1120
+ "from",
1121
+ "lines"
1122
+ ]
1123
+ },
1124
+ "web_search": {
1125
+ "emoji": "🔎",
1126
+ "title": "Web Search",
1127
+ "detailKeys": ["query", "count"]
1128
+ },
1129
+ "web_fetch": {
1130
+ "emoji": "📄",
1131
+ "title": "Web Fetch",
1132
+ "detailKeys": [
1133
+ "url",
1134
+ "extractMode",
1135
+ "maxChars"
1136
+ ]
1137
+ },
1138
+ "whatsapp_login": {
1139
+ "emoji": "🟢",
1140
+ "title": "WhatsApp Login",
1141
+ "actions": {
1142
+ "start": { "label": "start" },
1143
+ "wait": { "label": "wait" }
1144
+ }
1145
+ }
1146
+ }
1147
+ };
1148
+
1149
+ //#endregion
1150
+ //#region src/agents/tool-display.ts
1151
+ const TOOL_DISPLAY_CONFIG = tool_display_default;
1152
+ const FALLBACK = TOOL_DISPLAY_CONFIG.fallback ?? { emoji: "🧩" };
1153
+ const TOOL_MAP = TOOL_DISPLAY_CONFIG.tools ?? {};
1154
+ const DETAIL_LABEL_OVERRIDES = {
1155
+ agentId: "agent",
1156
+ sessionKey: "session",
1157
+ targetId: "target",
1158
+ targetUrl: "url",
1159
+ nodeId: "node",
1160
+ requestId: "request",
1161
+ messageId: "message",
1162
+ threadId: "thread",
1163
+ channelId: "channel",
1164
+ guildId: "guild",
1165
+ userId: "user",
1166
+ runTimeoutSeconds: "timeout",
1167
+ timeoutSeconds: "timeout",
1168
+ includeTools: "tools",
1169
+ pollQuestion: "poll",
1170
+ maxChars: "max chars"
1171
+ };
1172
+ const MAX_DETAIL_ENTRIES = 8;
1173
+ function resolveToolDisplay(params) {
1174
+ const name = normalizeToolName(params.name);
1175
+ const key = name.toLowerCase();
1176
+ const spec = TOOL_MAP[key];
1177
+ const emoji = spec?.emoji ?? FALLBACK.emoji ?? "🧩";
1178
+ const title = spec?.title ?? defaultTitle(name);
1179
+ const label = spec?.label ?? title;
1180
+ const actionRaw = params.args && typeof params.args === "object" ? params.args.action : void 0;
1181
+ const action = typeof actionRaw === "string" ? actionRaw.trim() : void 0;
1182
+ const actionSpec = resolveActionSpec(spec, action);
1183
+ const verb = normalizeVerb(actionSpec?.label ?? action);
1184
+ let detail;
1185
+ if (key === "read") detail = resolveReadDetail(params.args);
1186
+ if (!detail && (key === "write" || key === "edit" || key === "attach")) detail = resolveWriteDetail(params.args);
1187
+ const detailKeys = actionSpec?.detailKeys ?? spec?.detailKeys ?? FALLBACK.detailKeys ?? [];
1188
+ if (!detail && detailKeys.length > 0) detail = resolveDetailFromKeys(params.args, detailKeys, {
1189
+ mode: "summary",
1190
+ maxEntries: MAX_DETAIL_ENTRIES,
1191
+ formatKey: (raw) => formatDetailKey(raw, DETAIL_LABEL_OVERRIDES)
1192
+ });
1193
+ if (!detail && params.meta) detail = params.meta;
1194
+ if (detail) detail = shortenHomeInString(detail);
1195
+ return {
1196
+ name,
1197
+ emoji,
1198
+ title,
1199
+ label,
1200
+ verb,
1201
+ detail
1202
+ };
1203
+ }
1204
+ function formatToolDetail(display) {
1205
+ const parts = [];
1206
+ if (display.verb) parts.push(display.verb);
1207
+ if (display.detail) parts.push(redactToolDetail(display.detail));
1208
+ if (parts.length === 0) return;
1209
+ return parts.join(" · ");
1210
+ }
1211
+
1212
+ //#endregion
1213
+ //#region src/tui/tui-formatters.ts
1214
+ const REPLACEMENT_CHAR_RE = /\uFFFD/g;
1215
+ const MAX_TOKEN_CHARS = 32;
1216
+ const LONG_TOKEN_RE = /\S{33,}/g;
1217
+ const LONG_TOKEN_TEST_RE = /\S{33,}/;
1218
+ const BINARY_LINE_REPLACEMENT_THRESHOLD = 12;
1219
+ function hasControlChars(text) {
1220
+ for (const char of text) {
1221
+ const code = char.charCodeAt(0);
1222
+ if (code <= 31 && code !== 9 && code !== 10 && code !== 13 || code >= 127 && code <= 159) return true;
1223
+ }
1224
+ return false;
1225
+ }
1226
+ function stripControlChars(text) {
1227
+ if (!hasControlChars(text)) return text;
1228
+ let sanitized = "";
1229
+ for (const char of text) {
1230
+ const code = char.charCodeAt(0);
1231
+ if (!(code <= 31 && code !== 9 && code !== 10 && code !== 13) && !(code >= 127 && code <= 159)) sanitized += char;
1232
+ }
1233
+ return sanitized;
1234
+ }
1235
+ function chunkToken(token, maxChars) {
1236
+ if (token.length <= maxChars) return [token];
1237
+ const chunks = [];
1238
+ for (let i = 0; i < token.length; i += maxChars) chunks.push(token.slice(i, i + maxChars));
1239
+ return chunks;
1240
+ }
1241
+ function redactBinaryLikeLine(line) {
1242
+ const replacementCount = (line.match(REPLACEMENT_CHAR_RE) || []).length;
1243
+ if (replacementCount >= BINARY_LINE_REPLACEMENT_THRESHOLD && replacementCount * 2 >= line.length) return "[binary data omitted]";
1244
+ return line;
1245
+ }
1246
+ function sanitizeRenderableText(text) {
1247
+ if (!text) return text;
1248
+ const hasAnsi = text.includes("\x1B");
1249
+ const hasReplacementChars = text.includes("�");
1250
+ const hasLongTokens = LONG_TOKEN_TEST_RE.test(text);
1251
+ const hasControls = hasControlChars(text);
1252
+ if (!hasAnsi && !hasReplacementChars && !hasLongTokens && !hasControls) return text;
1253
+ const withoutAnsi = hasAnsi ? stripAnsi(text) : text;
1254
+ const withoutControlChars = hasControls ? stripControlChars(withoutAnsi) : withoutAnsi;
1255
+ const redacted = hasReplacementChars ? withoutControlChars.split("\n").map((line) => redactBinaryLikeLine(line)).join("\n") : withoutControlChars;
1256
+ return LONG_TOKEN_TEST_RE.test(redacted) ? redacted.replace(LONG_TOKEN_RE, (token) => chunkToken(token, MAX_TOKEN_CHARS).join(" ")) : redacted;
1257
+ }
1258
+ function resolveFinalAssistantText(params) {
1259
+ const finalText = params.finalText ?? "";
1260
+ if (finalText.trim()) return finalText;
1261
+ const streamedText = params.streamedText ?? "";
1262
+ if (streamedText.trim()) return streamedText;
1263
+ return "(no output)";
1264
+ }
1265
+ function composeThinkingAndContent(params) {
1266
+ const thinkingText = params.thinkingText?.trim() ?? "";
1267
+ const contentText = params.contentText?.trim() ?? "";
1268
+ const parts = [];
1269
+ if (params.showThinking && thinkingText) parts.push(`[thinking]\n${thinkingText}`);
1270
+ if (contentText) parts.push(contentText);
1271
+ return parts.join("\n\n").trim();
1272
+ }
1273
+ /**
1274
+ * Extract ONLY thinking blocks from message content.
1275
+ * Model-agnostic: returns empty string if no thinking blocks exist.
1276
+ */
1277
+ function extractThinkingFromMessage(message) {
1278
+ if (!message || typeof message !== "object") return "";
1279
+ const content = message.content;
1280
+ if (typeof content === "string") return "";
1281
+ if (!Array.isArray(content)) return "";
1282
+ const parts = [];
1283
+ for (const block of content) {
1284
+ if (!block || typeof block !== "object") continue;
1285
+ const rec = block;
1286
+ if (rec.type === "thinking" && typeof rec.thinking === "string") parts.push(sanitizeRenderableText(rec.thinking));
1287
+ }
1288
+ return parts.join("\n").trim();
1289
+ }
1290
+ /**
1291
+ * Extract ONLY text content blocks from message (excludes thinking).
1292
+ * Model-agnostic: works for any model with text content blocks.
1293
+ */
1294
+ function extractContentFromMessage(message) {
1295
+ if (!message || typeof message !== "object") return "";
1296
+ const record = message;
1297
+ const content = record.content;
1298
+ if (typeof content === "string") return sanitizeRenderableText(content).trim();
1299
+ if (!Array.isArray(content)) {
1300
+ if ((typeof record.stopReason === "string" ? record.stopReason : "") === "error") return formatRawAssistantErrorForUi(typeof record.errorMessage === "string" ? record.errorMessage : "");
1301
+ return "";
1302
+ }
1303
+ const parts = [];
1304
+ for (const block of content) {
1305
+ if (!block || typeof block !== "object") continue;
1306
+ const rec = block;
1307
+ if (rec.type === "text" && typeof rec.text === "string") parts.push(sanitizeRenderableText(rec.text));
1308
+ }
1309
+ if (parts.length === 0) {
1310
+ if ((typeof record.stopReason === "string" ? record.stopReason : "") === "error") return formatRawAssistantErrorForUi(typeof record.errorMessage === "string" ? record.errorMessage : "");
1311
+ }
1312
+ return parts.join("\n").trim();
1313
+ }
1314
+ function extractTextBlocks(content, opts) {
1315
+ if (typeof content === "string") return sanitizeRenderableText(content).trim();
1316
+ if (!Array.isArray(content)) return "";
1317
+ const thinkingParts = [];
1318
+ const textParts = [];
1319
+ for (const block of content) {
1320
+ if (!block || typeof block !== "object") continue;
1321
+ const record = block;
1322
+ if (record.type === "text" && typeof record.text === "string") textParts.push(sanitizeRenderableText(record.text));
1323
+ if (opts?.includeThinking && record.type === "thinking" && typeof record.thinking === "string") thinkingParts.push(sanitizeRenderableText(record.thinking));
1324
+ }
1325
+ return composeThinkingAndContent({
1326
+ thinkingText: thinkingParts.join("\n").trim(),
1327
+ contentText: textParts.join("\n").trim(),
1328
+ showThinking: opts?.includeThinking ?? false
1329
+ });
1330
+ }
1331
+ function extractTextFromMessage(message, opts) {
1332
+ if (!message || typeof message !== "object") return "";
1333
+ const record = message;
1334
+ const text = extractTextBlocks(record.content, opts);
1335
+ if (text) return text;
1336
+ if ((typeof record.stopReason === "string" ? record.stopReason : "") !== "error") return "";
1337
+ return formatRawAssistantErrorForUi(typeof record.errorMessage === "string" ? record.errorMessage : "");
1338
+ }
1339
+ function isCommandMessage(message) {
1340
+ if (!message || typeof message !== "object") return false;
1341
+ return message.command === true;
1342
+ }
1343
+ function formatTokens(total, context) {
1344
+ if (total == null && context == null) return "tokens ?";
1345
+ const totalLabel = total == null ? "?" : formatTokenCount(total);
1346
+ if (context == null) return `tokens ${totalLabel}`;
1347
+ const pct = typeof total === "number" && context > 0 ? Math.min(999, Math.round(total / context * 100)) : null;
1348
+ return `tokens ${totalLabel}/${formatTokenCount(context)}${pct !== null ? ` (${pct}%)` : ""}`;
1349
+ }
1350
+ function formatContextUsageLine(params) {
1351
+ const totalLabel = typeof params.total === "number" ? formatTokenCount(params.total) : "?";
1352
+ const ctxLabel = typeof params.context === "number" ? formatTokenCount(params.context) : "?";
1353
+ const pct = typeof params.percent === "number" ? Math.min(999, Math.round(params.percent)) : null;
1354
+ const extra = [typeof params.remaining === "number" ? `${formatTokenCount(params.remaining)} left` : null, pct !== null ? `${pct}%` : null].filter(Boolean).join(", ");
1355
+ return `tokens ${totalLabel}/${ctxLabel}${extra ? ` (${extra})` : ""}`;
1356
+ }
1357
+ function asString(value, fallback = "") {
1358
+ if (typeof value === "string") return value;
1359
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
1360
+ return fallback;
1361
+ }
1362
+
1363
+ //#endregion
1364
+ //#region src/tui/components/tool-execution.ts
1365
+ const PREVIEW_LINES = 12;
1366
+ function formatArgs(toolName, args) {
1367
+ const detail = formatToolDetail(resolveToolDisplay({
1368
+ name: toolName,
1369
+ args
1370
+ }));
1371
+ if (detail) return sanitizeRenderableText(detail);
1372
+ if (!args || typeof args !== "object") return "";
1373
+ try {
1374
+ return sanitizeRenderableText(JSON.stringify(args));
1375
+ } catch {
1376
+ return "";
1377
+ }
1378
+ }
1379
+ function extractText(result) {
1380
+ if (!result?.content) return "";
1381
+ const lines = [];
1382
+ for (const entry of result.content) if (entry.type === "text" && entry.text) lines.push(sanitizeRenderableText(entry.text));
1383
+ else if (entry.type === "image") {
1384
+ const mime = entry.mimeType ?? "image";
1385
+ const size = entry.bytes ? ` ${Math.round(entry.bytes / 1024)}kb` : "";
1386
+ const omitted = entry.omitted ? " (omitted)" : "";
1387
+ lines.push(`[${mime}${size}${omitted}]`);
1388
+ }
1389
+ return lines.join("\n").trim();
1390
+ }
1391
+ var ToolExecutionComponent = class extends Container {
1392
+ constructor(toolName, args) {
1393
+ super();
1394
+ this.expanded = false;
1395
+ this.isError = false;
1396
+ this.isPartial = true;
1397
+ this.toolName = toolName;
1398
+ this.args = args;
1399
+ this.box = new Box(1, 1, (line) => theme.toolPendingBg(line));
1400
+ this.header = new Text("", 0, 0);
1401
+ this.argsLine = new Text("", 0, 0);
1402
+ this.output = new Markdown("", 0, 0, markdownTheme, { color: (line) => theme.toolOutput(line) });
1403
+ this.addChild(new Spacer(1));
1404
+ this.addChild(this.box);
1405
+ this.box.addChild(this.header);
1406
+ this.box.addChild(this.argsLine);
1407
+ this.box.addChild(this.output);
1408
+ this.refresh();
1409
+ }
1410
+ setArgs(args) {
1411
+ this.args = args;
1412
+ this.refresh();
1413
+ }
1414
+ setExpanded(expanded) {
1415
+ this.expanded = expanded;
1416
+ this.refresh();
1417
+ }
1418
+ setResult(result, opts) {
1419
+ this.result = result;
1420
+ this.isPartial = false;
1421
+ this.isError = Boolean(opts?.isError);
1422
+ this.refresh();
1423
+ }
1424
+ setPartialResult(result) {
1425
+ this.result = result;
1426
+ this.isPartial = true;
1427
+ this.refresh();
1428
+ }
1429
+ refresh() {
1430
+ const bg = this.isPartial ? theme.toolPendingBg : this.isError ? theme.toolErrorBg : theme.toolSuccessBg;
1431
+ this.box.setBgFn((line) => bg(line));
1432
+ const display = resolveToolDisplay({
1433
+ name: this.toolName,
1434
+ args: this.args
1435
+ });
1436
+ const title = `${display.emoji} ${display.label}${this.isPartial ? " (running)" : ""}`;
1437
+ this.header.setText(theme.toolTitle(theme.bold(title)));
1438
+ const argLine = formatArgs(this.toolName, this.args);
1439
+ this.argsLine.setText(argLine ? theme.dim(argLine) : theme.dim(" "));
1440
+ const text = extractText(this.result) || (this.isPartial ? "…" : "");
1441
+ if (!this.expanded && text) {
1442
+ const lines = text.split("\n");
1443
+ const preview = lines.length > PREVIEW_LINES ? `${lines.slice(0, PREVIEW_LINES).join("\n")}\n…` : text;
1444
+ this.output.setText(preview);
1445
+ } else this.output.setText(text);
1446
+ }
1447
+ };
1448
+
1449
+ //#endregion
1450
+ //#region src/tui/components/user-message.ts
1451
+ var UserMessageComponent = class extends Container {
1452
+ constructor(text) {
1453
+ super();
1454
+ this.body = new Markdown(text, 1, 1, markdownTheme, {
1455
+ bgColor: (line) => theme.userBg(line),
1456
+ color: (line) => theme.userText(line)
1457
+ });
1458
+ this.addChild(new Spacer(1));
1459
+ this.addChild(this.body);
1460
+ }
1461
+ setText(text) {
1462
+ this.body.setText(text);
1463
+ }
1464
+ };
1465
+
1466
+ //#endregion
1467
+ //#region src/tui/components/chat-log.ts
1468
+ var ChatLog = class extends Container {
1469
+ constructor(..._args) {
1470
+ super(..._args);
1471
+ this.toolById = /* @__PURE__ */ new Map();
1472
+ this.streamingRuns = /* @__PURE__ */ new Map();
1473
+ this.toolsExpanded = false;
1474
+ }
1475
+ clearAll() {
1476
+ this.clear();
1477
+ this.toolById.clear();
1478
+ this.streamingRuns.clear();
1479
+ }
1480
+ addSystem(text) {
1481
+ this.addChild(new Spacer(1));
1482
+ this.addChild(new Text(theme.system(text), 1, 0));
1483
+ }
1484
+ addUser(text) {
1485
+ this.addChild(new UserMessageComponent(text));
1486
+ }
1487
+ resolveRunId(runId) {
1488
+ return runId ?? "default";
1489
+ }
1490
+ startAssistant(text, runId) {
1491
+ const component = new AssistantMessageComponent(text);
1492
+ this.streamingRuns.set(this.resolveRunId(runId), component);
1493
+ this.addChild(component);
1494
+ return component;
1495
+ }
1496
+ updateAssistant(text, runId) {
1497
+ const effectiveRunId = this.resolveRunId(runId);
1498
+ const existing = this.streamingRuns.get(effectiveRunId);
1499
+ if (!existing) {
1500
+ this.startAssistant(text, runId);
1501
+ return;
1502
+ }
1503
+ existing.setText(text);
1504
+ }
1505
+ finalizeAssistant(text, runId) {
1506
+ const effectiveRunId = this.resolveRunId(runId);
1507
+ const existing = this.streamingRuns.get(effectiveRunId);
1508
+ if (existing) {
1509
+ existing.setText(text);
1510
+ this.streamingRuns.delete(effectiveRunId);
1511
+ return;
1512
+ }
1513
+ this.addChild(new AssistantMessageComponent(text));
1514
+ }
1515
+ dropAssistant(runId) {
1516
+ const effectiveRunId = this.resolveRunId(runId);
1517
+ const existing = this.streamingRuns.get(effectiveRunId);
1518
+ if (!existing) return;
1519
+ this.removeChild(existing);
1520
+ this.streamingRuns.delete(effectiveRunId);
1521
+ }
1522
+ startTool(toolCallId, toolName, args) {
1523
+ const existing = this.toolById.get(toolCallId);
1524
+ if (existing) {
1525
+ existing.setArgs(args);
1526
+ return existing;
1527
+ }
1528
+ const component = new ToolExecutionComponent(toolName, args);
1529
+ component.setExpanded(this.toolsExpanded);
1530
+ this.toolById.set(toolCallId, component);
1531
+ this.addChild(component);
1532
+ return component;
1533
+ }
1534
+ updateToolArgs(toolCallId, args) {
1535
+ const existing = this.toolById.get(toolCallId);
1536
+ if (!existing) return;
1537
+ existing.setArgs(args);
1538
+ }
1539
+ updateToolResult(toolCallId, result, opts) {
1540
+ const existing = this.toolById.get(toolCallId);
1541
+ if (!existing) return;
1542
+ if (opts?.partial) {
1543
+ existing.setPartialResult(result);
1544
+ return;
1545
+ }
1546
+ existing.setResult(result, { isError: opts?.isError });
1547
+ }
1548
+ setToolsExpanded(expanded) {
1549
+ this.toolsExpanded = expanded;
1550
+ for (const tool of this.toolById.values()) tool.setExpanded(expanded);
1551
+ }
1552
+ };
1553
+
1554
+ //#endregion
1555
+ //#region src/tui/components/custom-editor.ts
1556
+ var CustomEditor = class extends Editor {
1557
+ handleInput(data) {
1558
+ if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {
1559
+ this.onAltEnter();
1560
+ return;
1561
+ }
1562
+ if (matchesKey(data, Key.ctrl("l")) && this.onCtrlL) {
1563
+ this.onCtrlL();
1564
+ return;
1565
+ }
1566
+ if (matchesKey(data, Key.ctrl("o")) && this.onCtrlO) {
1567
+ this.onCtrlO();
1568
+ return;
1569
+ }
1570
+ if (matchesKey(data, Key.ctrl("p")) && this.onCtrlP) {
1571
+ this.onCtrlP();
1572
+ return;
1573
+ }
1574
+ if (matchesKey(data, Key.ctrl("g")) && this.onCtrlG) {
1575
+ this.onCtrlG();
1576
+ return;
1577
+ }
1578
+ if (matchesKey(data, Key.ctrl("t")) && this.onCtrlT) {
1579
+ this.onCtrlT();
1580
+ return;
1581
+ }
1582
+ if (matchesKey(data, Key.shift("tab")) && this.onShiftTab) {
1583
+ this.onShiftTab();
1584
+ return;
1585
+ }
1586
+ if (matchesKey(data, Key.escape) && this.onEscape && !this.isShowingAutocomplete()) {
1587
+ this.onEscape();
1588
+ return;
1589
+ }
1590
+ if (matchesKey(data, Key.ctrl("c")) && this.onCtrlC) {
1591
+ this.onCtrlC();
1592
+ return;
1593
+ }
1594
+ if (matchesKey(data, Key.ctrl("d"))) {
1595
+ if (this.getText().length === 0 && this.onCtrlD) this.onCtrlD();
1596
+ return;
1597
+ }
1598
+ super.handleInput(data);
1599
+ }
1600
+ };
1601
+
1602
+ //#endregion
1603
+ //#region src/tui/gateway-chat.ts
1604
+ var GatewayChatClient = class {
1605
+ constructor(opts) {
1606
+ const resolved = resolveGatewayConnection(opts);
1607
+ this.connection = resolved;
1608
+ this.readyPromise = new Promise((resolve) => {
1609
+ this.resolveReady = resolve;
1610
+ });
1611
+ this.client = new GatewayClient({
1612
+ url: resolved.url,
1613
+ token: resolved.token,
1614
+ password: resolved.password,
1615
+ clientName: GATEWAY_CLIENT_NAMES.GATEWAY_CLIENT,
1616
+ clientDisplayName: "anima-tui",
1617
+ clientVersion: VERSION,
1618
+ platform: process.platform,
1619
+ mode: GATEWAY_CLIENT_MODES.UI,
1620
+ caps: [GATEWAY_CLIENT_CAPS.TOOL_EVENTS],
1621
+ instanceId: randomUUID(),
1622
+ minProtocol: PROTOCOL_VERSION,
1623
+ maxProtocol: PROTOCOL_VERSION,
1624
+ onHelloOk: (hello) => {
1625
+ this.hello = hello;
1626
+ this.resolveReady?.();
1627
+ this.onConnected?.();
1628
+ },
1629
+ onEvent: (evt) => {
1630
+ this.onEvent?.({
1631
+ event: evt.event,
1632
+ payload: evt.payload,
1633
+ seq: evt.seq
1634
+ });
1635
+ },
1636
+ onClose: (_code, reason) => {
1637
+ this.onDisconnected?.(reason);
1638
+ },
1639
+ onGap: (info) => {
1640
+ this.onGap?.(info);
1641
+ }
1642
+ });
1643
+ }
1644
+ start() {
1645
+ this.client.start();
1646
+ }
1647
+ stop() {
1648
+ this.client.stop();
1649
+ }
1650
+ async waitForReady() {
1651
+ await this.readyPromise;
1652
+ }
1653
+ async sendChat(opts) {
1654
+ const runId = opts.runId ?? randomUUID();
1655
+ await this.client.request("chat.send", {
1656
+ sessionKey: opts.sessionKey,
1657
+ message: opts.message,
1658
+ thinking: opts.thinking,
1659
+ deliver: opts.deliver,
1660
+ timeoutMs: opts.timeoutMs,
1661
+ idempotencyKey: runId
1662
+ });
1663
+ return { runId };
1664
+ }
1665
+ async abortChat(opts) {
1666
+ return await this.client.request("chat.abort", {
1667
+ sessionKey: opts.sessionKey,
1668
+ runId: opts.runId
1669
+ });
1670
+ }
1671
+ async loadHistory(opts) {
1672
+ return await this.client.request("chat.history", {
1673
+ sessionKey: opts.sessionKey,
1674
+ limit: opts.limit
1675
+ });
1676
+ }
1677
+ async listSessions(opts) {
1678
+ return await this.client.request("sessions.list", {
1679
+ limit: opts?.limit,
1680
+ activeMinutes: opts?.activeMinutes,
1681
+ includeGlobal: opts?.includeGlobal,
1682
+ includeUnknown: opts?.includeUnknown,
1683
+ includeDerivedTitles: opts?.includeDerivedTitles,
1684
+ includeLastMessage: opts?.includeLastMessage,
1685
+ agentId: opts?.agentId
1686
+ });
1687
+ }
1688
+ async listAgents() {
1689
+ return await this.client.request("agents.list", {});
1690
+ }
1691
+ async patchSession(opts) {
1692
+ return await this.client.request("sessions.patch", opts);
1693
+ }
1694
+ async resetSession(key, reason) {
1695
+ return await this.client.request("sessions.reset", {
1696
+ key,
1697
+ ...reason ? { reason } : {}
1698
+ });
1699
+ }
1700
+ async getStatus() {
1701
+ return await this.client.request("status");
1702
+ }
1703
+ async listModels() {
1704
+ const res = await this.client.request("models.list");
1705
+ return Array.isArray(res?.models) ? res.models : [];
1706
+ }
1707
+ };
1708
+ function resolveGatewayConnection(opts) {
1709
+ const config = loadConfig();
1710
+ const isRemoteMode = config.gateway?.mode === "remote";
1711
+ const remote = isRemoteMode ? config.gateway?.remote : void 0;
1712
+ const authToken = config.gateway?.auth?.token;
1713
+ const urlOverride = typeof opts.url === "string" && opts.url.trim().length > 0 ? opts.url.trim() : void 0;
1714
+ const explicitAuth = resolveExplicitGatewayAuth({
1715
+ token: opts.token,
1716
+ password: opts.password
1717
+ });
1718
+ ensureExplicitGatewayAuth({
1719
+ urlOverride,
1720
+ auth: explicitAuth,
1721
+ errorHint: "Fix: pass --token or --password when using --url."
1722
+ });
1723
+ return {
1724
+ url: buildGatewayConnectionDetails({
1725
+ config,
1726
+ ...urlOverride ? { url: urlOverride } : {}
1727
+ }).url,
1728
+ token: explicitAuth.token || (!urlOverride ? isRemoteMode ? typeof remote?.token === "string" && remote.token.trim().length > 0 ? remote.token.trim() : void 0 : process.env.ANIMA_GATEWAY_TOKEN?.trim() || (typeof authToken === "string" && authToken.trim().length > 0 ? authToken.trim() : void 0) : void 0),
1729
+ password: explicitAuth.password || (!urlOverride ? process.env.ANIMA_GATEWAY_PASSWORD?.trim() || (typeof remote?.password === "string" && remote.password.trim().length > 0 ? remote.password.trim() : void 0) : void 0)
1730
+ };
1731
+ }
1732
+
1733
+ //#endregion
1734
+ //#region src/tui/components/fuzzy-filter.ts
1735
+ /**
1736
+ * Shared fuzzy filtering utilities for select list components.
1737
+ */
1738
+ /**
1739
+ * Word boundary characters for matching.
1740
+ */
1741
+ const WORD_BOUNDARY_CHARS = /[\s\-_./:#@]/;
1742
+ /**
1743
+ * Check if position is at a word boundary.
1744
+ */
1745
+ function isWordBoundary(text, index) {
1746
+ return index === 0 || WORD_BOUNDARY_CHARS.test(text[index - 1] ?? "");
1747
+ }
1748
+ /**
1749
+ * Find index where query matches at a word boundary in text.
1750
+ * Returns null if no match.
1751
+ */
1752
+ function findWordBoundaryIndex(text, query) {
1753
+ if (!query) return null;
1754
+ const textLower = text.toLowerCase();
1755
+ const queryLower = query.toLowerCase();
1756
+ const maxIndex = textLower.length - queryLower.length;
1757
+ if (maxIndex < 0) return null;
1758
+ for (let i = 0; i <= maxIndex; i++) if (textLower.startsWith(queryLower, i) && isWordBoundary(textLower, i)) return i;
1759
+ return null;
1760
+ }
1761
+ /**
1762
+ * Fuzzy match with pre-lowercased inputs (avoids toLowerCase on every keystroke).
1763
+ * Returns score (lower = better) or null if no match.
1764
+ */
1765
+ function fuzzyMatchLower(queryLower, textLower) {
1766
+ if (queryLower.length === 0) return 0;
1767
+ if (queryLower.length > textLower.length) return null;
1768
+ let queryIndex = 0;
1769
+ let score = 0;
1770
+ let lastMatchIndex = -1;
1771
+ let consecutiveMatches = 0;
1772
+ for (let i = 0; i < textLower.length && queryIndex < queryLower.length; i++) if (textLower[i] === queryLower[queryIndex]) {
1773
+ const isAtWordBoundary = isWordBoundary(textLower, i);
1774
+ if (lastMatchIndex === i - 1) {
1775
+ consecutiveMatches++;
1776
+ score -= consecutiveMatches * 5;
1777
+ } else {
1778
+ consecutiveMatches = 0;
1779
+ if (lastMatchIndex >= 0) score += (i - lastMatchIndex - 1) * 2;
1780
+ }
1781
+ if (isAtWordBoundary) score -= 10;
1782
+ score += i * .1;
1783
+ lastMatchIndex = i;
1784
+ queryIndex++;
1785
+ }
1786
+ return queryIndex < queryLower.length ? null : score;
1787
+ }
1788
+ /**
1789
+ * Filter items using pre-lowercased searchTextLower field.
1790
+ * Supports space-separated tokens (all must match).
1791
+ */
1792
+ function fuzzyFilterLower(items, queryLower) {
1793
+ const trimmed = queryLower.trim();
1794
+ if (!trimmed) return items;
1795
+ const tokens = trimmed.split(/\s+/).filter((t) => t.length > 0);
1796
+ if (tokens.length === 0) return items;
1797
+ const results = [];
1798
+ for (const item of items) {
1799
+ const text = item.searchTextLower ?? "";
1800
+ let totalScore = 0;
1801
+ let allMatch = true;
1802
+ for (const token of tokens) {
1803
+ const score = fuzzyMatchLower(token, text);
1804
+ if (score !== null) totalScore += score;
1805
+ else {
1806
+ allMatch = false;
1807
+ break;
1808
+ }
1809
+ }
1810
+ if (allMatch) results.push({
1811
+ item,
1812
+ score: totalScore
1813
+ });
1814
+ }
1815
+ results.sort((a, b) => a.score - b.score);
1816
+ return results.map((r) => r.item);
1817
+ }
1818
+ /**
1819
+ * Prepare items for fuzzy filtering by pre-computing lowercase search text.
1820
+ */
1821
+ function prepareSearchItems(items) {
1822
+ return items.map((item) => {
1823
+ const parts = [];
1824
+ if (item.label) parts.push(item.label);
1825
+ if (item.description) parts.push(item.description);
1826
+ if (item.searchText) parts.push(item.searchText);
1827
+ return {
1828
+ ...item,
1829
+ searchTextLower: parts.join(" ").toLowerCase()
1830
+ };
1831
+ });
1832
+ }
1833
+
1834
+ //#endregion
1835
+ //#region src/tui/components/filterable-select-list.ts
1836
+ /**
1837
+ * Combines text input filtering with a select list.
1838
+ * User types to filter, arrows/j/k to navigate, Enter to select, Escape to clear/cancel.
1839
+ */
1840
+ var FilterableSelectList = class {
1841
+ constructor(items, maxVisible, theme) {
1842
+ this.filterText = "";
1843
+ this.allItems = prepareSearchItems(items);
1844
+ this.maxVisible = maxVisible;
1845
+ this.theme = theme;
1846
+ this.input = new Input();
1847
+ this.selectList = new SelectList(this.allItems, maxVisible, theme);
1848
+ }
1849
+ applyFilter() {
1850
+ const queryLower = this.filterText.toLowerCase();
1851
+ if (!queryLower.trim()) {
1852
+ this.selectList = new SelectList(this.allItems, this.maxVisible, this.theme);
1853
+ return;
1854
+ }
1855
+ this.selectList = new SelectList(fuzzyFilterLower(this.allItems, queryLower), this.maxVisible, this.theme);
1856
+ }
1857
+ invalidate() {
1858
+ this.input.invalidate();
1859
+ this.selectList.invalidate();
1860
+ }
1861
+ render(width) {
1862
+ const lines = [];
1863
+ const filterLabel = this.theme.filterLabel("Filter: ");
1864
+ const inputText = this.input.render(width - 8)[0] ?? "";
1865
+ lines.push(filterLabel + inputText);
1866
+ lines.push(chalk.dim("─".repeat(Math.max(0, width))));
1867
+ const listLines = this.selectList.render(width);
1868
+ lines.push(...listLines);
1869
+ return lines;
1870
+ }
1871
+ handleInput(keyData) {
1872
+ const allowVimNav = !this.filterText.trim();
1873
+ if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
1874
+ this.selectList.handleInput("\x1B[A");
1875
+ return;
1876
+ }
1877
+ if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
1878
+ this.selectList.handleInput("\x1B[B");
1879
+ return;
1880
+ }
1881
+ if (matchesKey(keyData, "enter")) {
1882
+ const selected = this.selectList.getSelectedItem();
1883
+ if (selected) this.onSelect?.(selected);
1884
+ return;
1885
+ }
1886
+ if (getEditorKeybindings().matches(keyData, "selectCancel")) {
1887
+ if (this.filterText) {
1888
+ this.filterText = "";
1889
+ this.input.setValue("");
1890
+ this.applyFilter();
1891
+ } else this.onCancel?.();
1892
+ return;
1893
+ }
1894
+ const prevValue = this.input.getValue();
1895
+ this.input.handleInput(keyData);
1896
+ const newValue = this.input.getValue();
1897
+ if (newValue !== prevValue) {
1898
+ this.filterText = newValue;
1899
+ this.applyFilter();
1900
+ }
1901
+ }
1902
+ getSelectedItem() {
1903
+ return this.selectList.getSelectedItem();
1904
+ }
1905
+ getFilterText() {
1906
+ return this.filterText;
1907
+ }
1908
+ };
1909
+
1910
+ //#endregion
1911
+ //#region src/tui/components/searchable-select-list.ts
1912
+ const ANSI_ESCAPE = String.fromCharCode(27);
1913
+ const ANSI_SGR_REGEX = new RegExp(`${ANSI_ESCAPE}\\[[0-9;]*m`, "g");
1914
+ /**
1915
+ * A select list with a search input at the top for fuzzy filtering.
1916
+ */
1917
+ var SearchableSelectList = class SearchableSelectList {
1918
+ static {
1919
+ this.DESCRIPTION_LAYOUT_MIN_WIDTH = 40;
1920
+ }
1921
+ static {
1922
+ this.DESCRIPTION_MIN_WIDTH = 12;
1923
+ }
1924
+ static {
1925
+ this.DESCRIPTION_SPACING_WIDTH = 2;
1926
+ }
1927
+ static {
1928
+ this.RIGHT_MARGIN_WIDTH = 2;
1929
+ }
1930
+ constructor(items, maxVisible, theme) {
1931
+ this.selectedIndex = 0;
1932
+ this.regexCache = /* @__PURE__ */ new Map();
1933
+ this.compareByScore = (a, b) => {
1934
+ if (a.tier !== b.tier) return a.tier - b.tier;
1935
+ if (a.score !== b.score) return a.score - b.score;
1936
+ return this.getItemLabel(a.item).localeCompare(this.getItemLabel(b.item));
1937
+ };
1938
+ this.items = items;
1939
+ this.filteredItems = items;
1940
+ this.maxVisible = maxVisible;
1941
+ this.theme = theme;
1942
+ this.searchInput = new Input();
1943
+ }
1944
+ getCachedRegex(pattern) {
1945
+ let regex = this.regexCache.get(pattern);
1946
+ if (!regex) {
1947
+ regex = new RegExp(this.escapeRegex(pattern), "gi");
1948
+ this.regexCache.set(pattern, regex);
1949
+ }
1950
+ return regex;
1951
+ }
1952
+ updateFilter() {
1953
+ const query = this.searchInput.getValue().trim();
1954
+ if (!query) this.filteredItems = this.items;
1955
+ else this.filteredItems = this.smartFilter(query);
1956
+ this.selectedIndex = 0;
1957
+ this.notifySelectionChange();
1958
+ }
1959
+ /**
1960
+ * Smart filtering that prioritizes:
1961
+ * 1. Exact substring match in label (highest priority)
1962
+ * 2. Word-boundary prefix match in label
1963
+ * 3. Exact substring in description
1964
+ * 4. Fuzzy match (lowest priority)
1965
+ */
1966
+ smartFilter(query) {
1967
+ const q = query.toLowerCase();
1968
+ const scoredItems = [];
1969
+ const fuzzyCandidates = [];
1970
+ for (const item of this.items) {
1971
+ const rawLabel = this.getItemLabel(item);
1972
+ const rawDesc = item.description ?? "";
1973
+ const label = stripAnsi(rawLabel).toLowerCase();
1974
+ const desc = stripAnsi(rawDesc).toLowerCase();
1975
+ const labelIndex = label.indexOf(q);
1976
+ if (labelIndex !== -1) {
1977
+ scoredItems.push({
1978
+ item,
1979
+ tier: 0,
1980
+ score: labelIndex
1981
+ });
1982
+ continue;
1983
+ }
1984
+ const wordBoundaryIndex = findWordBoundaryIndex(label, q);
1985
+ if (wordBoundaryIndex !== null) {
1986
+ scoredItems.push({
1987
+ item,
1988
+ tier: 1,
1989
+ score: wordBoundaryIndex
1990
+ });
1991
+ continue;
1992
+ }
1993
+ const descIndex = desc.indexOf(q);
1994
+ if (descIndex !== -1) {
1995
+ scoredItems.push({
1996
+ item,
1997
+ tier: 2,
1998
+ score: descIndex
1999
+ });
2000
+ continue;
2001
+ }
2002
+ const searchText = item.searchText ?? "";
2003
+ fuzzyCandidates.push({
2004
+ item,
2005
+ searchTextLower: [
2006
+ rawLabel,
2007
+ rawDesc,
2008
+ searchText
2009
+ ].map((value) => stripAnsi(value)).filter(Boolean).join(" ").toLowerCase()
2010
+ });
2011
+ }
2012
+ scoredItems.sort(this.compareByScore);
2013
+ const fuzzyMatches = fuzzyFilterLower(fuzzyCandidates, q);
2014
+ return [...scoredItems.map((s) => s.item), ...fuzzyMatches.map((entry) => entry.item)];
2015
+ }
2016
+ escapeRegex(str) {
2017
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2018
+ }
2019
+ getItemLabel(item) {
2020
+ return item.label || item.value;
2021
+ }
2022
+ splitAnsiParts(text) {
2023
+ const parts = [];
2024
+ ANSI_SGR_REGEX.lastIndex = 0;
2025
+ let lastIndex = 0;
2026
+ let match;
2027
+ while ((match = ANSI_SGR_REGEX.exec(text)) !== null) {
2028
+ if (match.index > lastIndex) parts.push({
2029
+ text: text.slice(lastIndex, match.index),
2030
+ isAnsi: false
2031
+ });
2032
+ parts.push({
2033
+ text: match[0],
2034
+ isAnsi: true
2035
+ });
2036
+ lastIndex = match.index + match[0].length;
2037
+ }
2038
+ if (lastIndex < text.length) parts.push({
2039
+ text: text.slice(lastIndex),
2040
+ isAnsi: false
2041
+ });
2042
+ return parts;
2043
+ }
2044
+ highlightMatch(text, query) {
2045
+ const tokens = query.trim().split(/\s+/).map((token) => token.toLowerCase()).filter((token) => token.length > 0);
2046
+ if (tokens.length === 0) return text;
2047
+ const uniqueTokens = Array.from(new Set(tokens)).toSorted((a, b) => b.length - a.length);
2048
+ let parts = this.splitAnsiParts(text);
2049
+ for (const token of uniqueTokens) {
2050
+ const regex = this.getCachedRegex(token);
2051
+ const nextParts = [];
2052
+ for (const part of parts) {
2053
+ if (part.isAnsi) {
2054
+ nextParts.push(part);
2055
+ continue;
2056
+ }
2057
+ regex.lastIndex = 0;
2058
+ const replaced = part.text.replace(regex, (match) => this.theme.matchHighlight(match));
2059
+ if (replaced === part.text) {
2060
+ nextParts.push(part);
2061
+ continue;
2062
+ }
2063
+ nextParts.push(...this.splitAnsiParts(replaced));
2064
+ }
2065
+ parts = nextParts;
2066
+ }
2067
+ return parts.map((part) => part.text).join("");
2068
+ }
2069
+ setSelectedIndex(index) {
2070
+ this.selectedIndex = Math.max(0, Math.min(index, this.filteredItems.length - 1));
2071
+ }
2072
+ invalidate() {
2073
+ this.searchInput.invalidate();
2074
+ }
2075
+ render(width) {
2076
+ const lines = [];
2077
+ const prompt = this.theme.searchPrompt("search: ");
2078
+ const inputWidth = Math.max(1, width - visibleWidth(prompt));
2079
+ const inputText = this.searchInput.render(inputWidth)[0] ?? "";
2080
+ lines.push(`${prompt}${this.theme.searchInput(inputText)}`);
2081
+ lines.push("");
2082
+ const query = this.searchInput.getValue().trim();
2083
+ if (this.filteredItems.length === 0) {
2084
+ lines.push(this.theme.noMatch(" No matches"));
2085
+ return lines;
2086
+ }
2087
+ const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible));
2088
+ const endIndex = Math.min(startIndex + this.maxVisible, this.filteredItems.length);
2089
+ for (let i = startIndex; i < endIndex; i++) {
2090
+ const item = this.filteredItems[i];
2091
+ if (!item) continue;
2092
+ const isSelected = i === this.selectedIndex;
2093
+ lines.push(this.renderItemLine(item, isSelected, width, query));
2094
+ }
2095
+ if (this.filteredItems.length > this.maxVisible) {
2096
+ const scrollInfo = `${this.selectedIndex + 1}/${this.filteredItems.length}`;
2097
+ lines.push(this.theme.scrollInfo(` ${scrollInfo}`));
2098
+ }
2099
+ return lines;
2100
+ }
2101
+ renderItemLine(item, isSelected, width, query) {
2102
+ const prefix = isSelected ? "→ " : " ";
2103
+ const prefixWidth = prefix.length;
2104
+ const displayValue = this.getItemLabel(item);
2105
+ const description = item.description;
2106
+ if (description) {
2107
+ const descriptionLayout = this.getDescriptionLayout(width, prefixWidth);
2108
+ if (descriptionLayout) {
2109
+ const truncatedValue = truncateToWidth(displayValue, descriptionLayout.maxValueWidth, "");
2110
+ const valueText = this.highlightMatch(truncatedValue, query);
2111
+ const usedByValue = visibleWidth(valueText);
2112
+ const descriptionWidth = descriptionLayout.availableWidth - usedByValue - descriptionLayout.spacingWidth;
2113
+ if (descriptionWidth >= SearchableSelectList.DESCRIPTION_MIN_WIDTH) {
2114
+ const spacing = " ".repeat(descriptionLayout.spacingWidth);
2115
+ const truncatedDesc = truncateToWidth(description, descriptionWidth, "");
2116
+ const highlightedDesc = this.highlightMatch(truncatedDesc, query);
2117
+ const line = `${prefix}${valueText}${spacing}${isSelected ? highlightedDesc : this.theme.description(highlightedDesc)}`;
2118
+ return isSelected ? this.theme.selectedText(line) : line;
2119
+ }
2120
+ }
2121
+ }
2122
+ const truncatedValue = truncateToWidth(displayValue, width - prefixWidth - 2, "");
2123
+ const line = `${prefix}${this.highlightMatch(truncatedValue, query)}`;
2124
+ return isSelected ? this.theme.selectedText(line) : line;
2125
+ }
2126
+ getDescriptionLayout(width, prefixWidth) {
2127
+ if (width <= SearchableSelectList.DESCRIPTION_LAYOUT_MIN_WIDTH) return null;
2128
+ const availableWidth = Math.max(1, width - prefixWidth - SearchableSelectList.RIGHT_MARGIN_WIDTH);
2129
+ const maxValueWidth = availableWidth - SearchableSelectList.DESCRIPTION_MIN_WIDTH - SearchableSelectList.DESCRIPTION_SPACING_WIDTH;
2130
+ if (maxValueWidth < 1) return null;
2131
+ return {
2132
+ availableWidth,
2133
+ maxValueWidth,
2134
+ spacingWidth: SearchableSelectList.DESCRIPTION_SPACING_WIDTH
2135
+ };
2136
+ }
2137
+ handleInput(keyData) {
2138
+ if (isKeyRelease(keyData)) return;
2139
+ const allowVimNav = !this.searchInput.getValue().trim();
2140
+ if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
2141
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
2142
+ this.notifySelectionChange();
2143
+ return;
2144
+ }
2145
+ if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
2146
+ this.selectedIndex = Math.min(this.filteredItems.length - 1, this.selectedIndex + 1);
2147
+ this.notifySelectionChange();
2148
+ return;
2149
+ }
2150
+ if (matchesKey(keyData, "enter")) {
2151
+ const item = this.filteredItems[this.selectedIndex];
2152
+ if (item && this.onSelect) this.onSelect(item);
2153
+ return;
2154
+ }
2155
+ if (getEditorKeybindings().matches(keyData, "selectCancel")) {
2156
+ if (this.onCancel) this.onCancel();
2157
+ return;
2158
+ }
2159
+ const prevValue = this.searchInput.getValue();
2160
+ this.searchInput.handleInput(keyData);
2161
+ if (prevValue !== this.searchInput.getValue()) this.updateFilter();
2162
+ }
2163
+ notifySelectionChange() {
2164
+ const item = this.filteredItems[this.selectedIndex];
2165
+ if (item && this.onSelectionChange) this.onSelectionChange(item);
2166
+ }
2167
+ getSelectedItem() {
2168
+ return this.filteredItems[this.selectedIndex] ?? null;
2169
+ }
2170
+ };
2171
+
2172
+ //#endregion
2173
+ //#region src/tui/components/selectors.ts
2174
+ function createSearchableSelectList(items, maxVisible = 7) {
2175
+ return new SearchableSelectList(items, maxVisible, searchableSelectListTheme);
2176
+ }
2177
+ function createFilterableSelectList(items, maxVisible = 7) {
2178
+ return new FilterableSelectList(items, maxVisible, filterableSelectListTheme);
2179
+ }
2180
+ function createSettingsList(items, onChange, onCancel, maxVisible = 7) {
2181
+ return new SettingsList(items, maxVisible, settingsListTheme, onChange, onCancel);
2182
+ }
2183
+
2184
+ //#endregion
2185
+ //#region src/tui/tui-status-summary.ts
2186
+ function formatStatusSummary(summary) {
2187
+ const lines = [];
2188
+ lines.push("Gateway status");
2189
+ if (!summary.linkChannel) lines.push("Link channel: unknown");
2190
+ else {
2191
+ const linkLabel = summary.linkChannel.label ?? "Link channel";
2192
+ const linked = summary.linkChannel.linked === true;
2193
+ const authAge = linked && typeof summary.linkChannel.authAgeMs === "number" ? ` (last refreshed ${formatTimeAgo(summary.linkChannel.authAgeMs)})` : "";
2194
+ lines.push(`${linkLabel}: ${linked ? "linked" : "not linked"}${authAge}`);
2195
+ }
2196
+ const providerSummary = Array.isArray(summary.providerSummary) ? summary.providerSummary : [];
2197
+ if (providerSummary.length > 0) {
2198
+ lines.push("");
2199
+ lines.push("System:");
2200
+ for (const line of providerSummary) lines.push(` ${line}`);
2201
+ }
2202
+ const heartbeatAgents = summary.heartbeat?.agents ?? [];
2203
+ if (heartbeatAgents.length > 0) {
2204
+ const heartbeatParts = heartbeatAgents.map((agent) => {
2205
+ const agentId = agent.agentId ?? "unknown";
2206
+ if (!agent.enabled || !agent.everyMs) return `disabled (${agentId})`;
2207
+ return `${agent.every ?? "unknown"} (${agentId})`;
2208
+ });
2209
+ lines.push("");
2210
+ lines.push(`Heartbeat: ${heartbeatParts.join(", ")}`);
2211
+ }
2212
+ const sessionPaths = summary.sessions?.paths ?? [];
2213
+ if (sessionPaths.length === 1) lines.push(`Session store: ${sessionPaths[0]}`);
2214
+ else if (sessionPaths.length > 1) lines.push(`Session stores: ${sessionPaths.length}`);
2215
+ const defaults = summary.sessions?.defaults;
2216
+ const defaultModel = defaults?.model ?? "unknown";
2217
+ const defaultCtx = typeof defaults?.contextTokens === "number" ? ` (${formatTokenCount(defaults.contextTokens)} ctx)` : "";
2218
+ lines.push(`Default model: ${defaultModel}${defaultCtx}`);
2219
+ const sessionCount = summary.sessions?.count ?? 0;
2220
+ lines.push(`Active sessions: ${sessionCount}`);
2221
+ const recent = Array.isArray(summary.sessions?.recent) ? summary.sessions?.recent : [];
2222
+ if (recent.length > 0) {
2223
+ lines.push("Recent sessions:");
2224
+ for (const entry of recent) {
2225
+ const ageLabel = typeof entry.age === "number" ? formatTimeAgo(entry.age) : "no activity";
2226
+ const model = entry.model ?? "unknown";
2227
+ const usage = formatContextUsageLine({
2228
+ total: entry.totalTokens ?? null,
2229
+ context: entry.contextTokens ?? null,
2230
+ remaining: entry.remainingTokens ?? null,
2231
+ percent: entry.percentUsed ?? null
2232
+ });
2233
+ const flags = entry.flags?.length ? ` | flags: ${entry.flags.join(", ")}` : "";
2234
+ lines.push(`- ${entry.key}${entry.kind ? ` [${entry.kind}]` : ""} | ${ageLabel} | model ${model} | ${usage}${flags}`);
2235
+ }
2236
+ }
2237
+ const queued = Array.isArray(summary.queuedSystemEvents) ? summary.queuedSystemEvents : [];
2238
+ if (queued.length > 0) {
2239
+ const preview = queued.slice(0, 3).join(" | ");
2240
+ lines.push(`Queued system events (${queued.length}): ${preview}`);
2241
+ }
2242
+ return lines;
2243
+ }
2244
+
2245
+ //#endregion
2246
+ //#region src/tui/tui-command-handlers.ts
2247
+ function createCommandHandlers(context) {
2248
+ const { client, chatLog, tui, opts, state, deliverDefault, openOverlay, closeOverlay, refreshSessionInfo, loadHistory, setSession, refreshAgents, abortActive, setActivityStatus, formatSessionKey, applySessionInfoFromPatch, noteLocalRunId, forgetLocalRunId } = context;
2249
+ const setAgent = async (id) => {
2250
+ state.currentAgentId = normalizeAgentId(id);
2251
+ await setSession("");
2252
+ };
2253
+ const openModelSelector = async () => {
2254
+ try {
2255
+ const models = await client.listModels();
2256
+ if (models.length === 0) {
2257
+ chatLog.addSystem("no models available");
2258
+ tui.requestRender();
2259
+ return;
2260
+ }
2261
+ const selector = createSearchableSelectList(models.map((model) => ({
2262
+ value: `${model.provider}/${model.id}`,
2263
+ label: `${model.provider}/${model.id}`,
2264
+ description: model.name && model.name !== model.id ? model.name : ""
2265
+ })), 9);
2266
+ selector.onSelect = (item) => {
2267
+ (async () => {
2268
+ try {
2269
+ const result = await client.patchSession({
2270
+ key: state.currentSessionKey,
2271
+ model: item.value
2272
+ });
2273
+ chatLog.addSystem(`model set to ${item.value}`);
2274
+ applySessionInfoFromPatch(result);
2275
+ await refreshSessionInfo();
2276
+ } catch (err) {
2277
+ chatLog.addSystem(`model set failed: ${String(err)}`);
2278
+ }
2279
+ closeOverlay();
2280
+ tui.requestRender();
2281
+ })();
2282
+ };
2283
+ selector.onCancel = () => {
2284
+ closeOverlay();
2285
+ tui.requestRender();
2286
+ };
2287
+ openOverlay(selector);
2288
+ tui.requestRender();
2289
+ } catch (err) {
2290
+ chatLog.addSystem(`model list failed: ${String(err)}`);
2291
+ tui.requestRender();
2292
+ }
2293
+ };
2294
+ const openAgentSelector = async () => {
2295
+ await refreshAgents();
2296
+ if (state.agents.length === 0) {
2297
+ chatLog.addSystem("no agents found");
2298
+ tui.requestRender();
2299
+ return;
2300
+ }
2301
+ const selector = createSearchableSelectList(state.agents.map((agent) => ({
2302
+ value: agent.id,
2303
+ label: agent.name ? `${agent.id} (${agent.name})` : agent.id,
2304
+ description: agent.id === state.agentDefaultId ? "default" : ""
2305
+ })), 9);
2306
+ selector.onSelect = (item) => {
2307
+ (async () => {
2308
+ closeOverlay();
2309
+ await setAgent(item.value);
2310
+ tui.requestRender();
2311
+ })();
2312
+ };
2313
+ selector.onCancel = () => {
2314
+ closeOverlay();
2315
+ tui.requestRender();
2316
+ };
2317
+ openOverlay(selector);
2318
+ tui.requestRender();
2319
+ };
2320
+ const openSessionSelector = async () => {
2321
+ try {
2322
+ const selector = createFilterableSelectList((await client.listSessions({
2323
+ includeGlobal: false,
2324
+ includeUnknown: false,
2325
+ includeDerivedTitles: true,
2326
+ includeLastMessage: true,
2327
+ agentId: state.currentAgentId
2328
+ })).sessions.map((session) => {
2329
+ const title = session.derivedTitle ?? session.displayName;
2330
+ const formattedKey = formatSessionKey(session.key);
2331
+ const label = title && title !== formattedKey ? `${title} (${formattedKey})` : formattedKey;
2332
+ const timePart = session.updatedAt ? formatRelativeTimestamp(session.updatedAt, {
2333
+ dateFallback: true,
2334
+ fallback: ""
2335
+ }) : "";
2336
+ const preview = session.lastMessagePreview?.replace(/\s+/g, " ").trim();
2337
+ const description = timePart && preview ? `${timePart} · ${preview}` : preview ?? timePart;
2338
+ return {
2339
+ value: session.key,
2340
+ label,
2341
+ description,
2342
+ searchText: [
2343
+ session.displayName,
2344
+ session.label,
2345
+ session.subject,
2346
+ session.sessionId,
2347
+ session.key,
2348
+ session.lastMessagePreview
2349
+ ].filter(Boolean).join(" ")
2350
+ };
2351
+ }), 9);
2352
+ selector.onSelect = (item) => {
2353
+ (async () => {
2354
+ closeOverlay();
2355
+ await setSession(item.value);
2356
+ tui.requestRender();
2357
+ })();
2358
+ };
2359
+ selector.onCancel = () => {
2360
+ closeOverlay();
2361
+ tui.requestRender();
2362
+ };
2363
+ openOverlay(selector);
2364
+ tui.requestRender();
2365
+ } catch (err) {
2366
+ chatLog.addSystem(`sessions list failed: ${String(err)}`);
2367
+ tui.requestRender();
2368
+ }
2369
+ };
2370
+ const openSettings = () => {
2371
+ openOverlay(createSettingsList([{
2372
+ id: "tools",
2373
+ label: "Tool output",
2374
+ currentValue: state.toolsExpanded ? "expanded" : "collapsed",
2375
+ values: ["collapsed", "expanded"]
2376
+ }, {
2377
+ id: "thinking",
2378
+ label: "Show thinking",
2379
+ currentValue: state.showThinking ? "on" : "off",
2380
+ values: ["off", "on"]
2381
+ }], (id, value) => {
2382
+ if (id === "tools") {
2383
+ state.toolsExpanded = value === "expanded";
2384
+ chatLog.setToolsExpanded(state.toolsExpanded);
2385
+ }
2386
+ if (id === "thinking") {
2387
+ state.showThinking = value === "on";
2388
+ loadHistory();
2389
+ }
2390
+ tui.requestRender();
2391
+ }, () => {
2392
+ closeOverlay();
2393
+ tui.requestRender();
2394
+ }));
2395
+ tui.requestRender();
2396
+ };
2397
+ const handleCommand = async (raw) => {
2398
+ const { name, args } = parseCommand(raw);
2399
+ if (!name) return;
2400
+ switch (name) {
2401
+ case "help":
2402
+ chatLog.addSystem(helpText({
2403
+ provider: state.sessionInfo.modelProvider,
2404
+ model: state.sessionInfo.model
2405
+ }));
2406
+ break;
2407
+ case "status":
2408
+ try {
2409
+ const status = await client.getStatus();
2410
+ if (typeof status === "string") {
2411
+ chatLog.addSystem(status);
2412
+ break;
2413
+ }
2414
+ if (status && typeof status === "object") {
2415
+ const lines = formatStatusSummary(status);
2416
+ for (const line of lines) chatLog.addSystem(line);
2417
+ break;
2418
+ }
2419
+ chatLog.addSystem("status: unknown response");
2420
+ } catch (err) {
2421
+ chatLog.addSystem(`status failed: ${String(err)}`);
2422
+ }
2423
+ break;
2424
+ case "agent":
2425
+ if (!args) await openAgentSelector();
2426
+ else await setAgent(args);
2427
+ break;
2428
+ case "agents":
2429
+ await openAgentSelector();
2430
+ break;
2431
+ case "session":
2432
+ if (!args) await openSessionSelector();
2433
+ else await setSession(args);
2434
+ break;
2435
+ case "sessions":
2436
+ await openSessionSelector();
2437
+ break;
2438
+ case "model":
2439
+ if (!args) await openModelSelector();
2440
+ else try {
2441
+ const result = await client.patchSession({
2442
+ key: state.currentSessionKey,
2443
+ model: args
2444
+ });
2445
+ chatLog.addSystem(`model set to ${args}`);
2446
+ applySessionInfoFromPatch(result);
2447
+ await refreshSessionInfo();
2448
+ } catch (err) {
2449
+ chatLog.addSystem(`model set failed: ${String(err)}`);
2450
+ }
2451
+ break;
2452
+ case "models":
2453
+ await openModelSelector();
2454
+ break;
2455
+ case "think":
2456
+ if (!args) {
2457
+ const levels = formatThinkingLevels(state.sessionInfo.modelProvider, state.sessionInfo.model, "|");
2458
+ chatLog.addSystem(`usage: /think <${levels}>`);
2459
+ break;
2460
+ }
2461
+ try {
2462
+ const result = await client.patchSession({
2463
+ key: state.currentSessionKey,
2464
+ thinkingLevel: args
2465
+ });
2466
+ chatLog.addSystem(`thinking set to ${args}`);
2467
+ applySessionInfoFromPatch(result);
2468
+ await refreshSessionInfo();
2469
+ } catch (err) {
2470
+ chatLog.addSystem(`think failed: ${String(err)}`);
2471
+ }
2472
+ break;
2473
+ case "verbose":
2474
+ if (!args) {
2475
+ chatLog.addSystem("usage: /verbose <on|off>");
2476
+ break;
2477
+ }
2478
+ try {
2479
+ const result = await client.patchSession({
2480
+ key: state.currentSessionKey,
2481
+ verboseLevel: args
2482
+ });
2483
+ chatLog.addSystem(`verbose set to ${args}`);
2484
+ applySessionInfoFromPatch(result);
2485
+ await loadHistory();
2486
+ } catch (err) {
2487
+ chatLog.addSystem(`verbose failed: ${String(err)}`);
2488
+ }
2489
+ break;
2490
+ case "reasoning":
2491
+ if (!args) {
2492
+ chatLog.addSystem("usage: /reasoning <on|off>");
2493
+ break;
2494
+ }
2495
+ try {
2496
+ const result = await client.patchSession({
2497
+ key: state.currentSessionKey,
2498
+ reasoningLevel: args
2499
+ });
2500
+ chatLog.addSystem(`reasoning set to ${args}`);
2501
+ applySessionInfoFromPatch(result);
2502
+ await refreshSessionInfo();
2503
+ } catch (err) {
2504
+ chatLog.addSystem(`reasoning failed: ${String(err)}`);
2505
+ }
2506
+ break;
2507
+ case "usage": {
2508
+ const normalized = args ? normalizeUsageDisplay(args) : void 0;
2509
+ if (args && !normalized) {
2510
+ chatLog.addSystem("usage: /usage <off|tokens|full>");
2511
+ break;
2512
+ }
2513
+ const currentRaw = state.sessionInfo.responseUsage;
2514
+ const current = resolveResponseUsageMode(currentRaw);
2515
+ const next = normalized ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
2516
+ try {
2517
+ const result = await client.patchSession({
2518
+ key: state.currentSessionKey,
2519
+ responseUsage: next === "off" ? null : next
2520
+ });
2521
+ chatLog.addSystem(`usage footer: ${next}`);
2522
+ applySessionInfoFromPatch(result);
2523
+ await refreshSessionInfo();
2524
+ } catch (err) {
2525
+ chatLog.addSystem(`usage failed: ${String(err)}`);
2526
+ }
2527
+ break;
2528
+ }
2529
+ case "elevated":
2530
+ if (!args) {
2531
+ chatLog.addSystem("usage: /elevated <on|off|ask|full>");
2532
+ break;
2533
+ }
2534
+ if (![
2535
+ "on",
2536
+ "off",
2537
+ "ask",
2538
+ "full"
2539
+ ].includes(args)) {
2540
+ chatLog.addSystem("usage: /elevated <on|off|ask|full>");
2541
+ break;
2542
+ }
2543
+ try {
2544
+ const result = await client.patchSession({
2545
+ key: state.currentSessionKey,
2546
+ elevatedLevel: args
2547
+ });
2548
+ chatLog.addSystem(`elevated set to ${args}`);
2549
+ applySessionInfoFromPatch(result);
2550
+ await refreshSessionInfo();
2551
+ } catch (err) {
2552
+ chatLog.addSystem(`elevated failed: ${String(err)}`);
2553
+ }
2554
+ break;
2555
+ case "activation":
2556
+ if (!args) {
2557
+ chatLog.addSystem("usage: /activation <mention|always>");
2558
+ break;
2559
+ }
2560
+ try {
2561
+ const result = await client.patchSession({
2562
+ key: state.currentSessionKey,
2563
+ groupActivation: args === "always" ? "always" : "mention"
2564
+ });
2565
+ chatLog.addSystem(`activation set to ${args}`);
2566
+ applySessionInfoFromPatch(result);
2567
+ await refreshSessionInfo();
2568
+ } catch (err) {
2569
+ chatLog.addSystem(`activation failed: ${String(err)}`);
2570
+ }
2571
+ break;
2572
+ case "new":
2573
+ case "reset":
2574
+ try {
2575
+ state.sessionInfo.inputTokens = null;
2576
+ state.sessionInfo.outputTokens = null;
2577
+ state.sessionInfo.totalTokens = null;
2578
+ tui.requestRender();
2579
+ await client.resetSession(state.currentSessionKey, name);
2580
+ chatLog.addSystem(`session ${state.currentSessionKey} reset`);
2581
+ await loadHistory();
2582
+ } catch (err) {
2583
+ chatLog.addSystem(`reset failed: ${String(err)}`);
2584
+ }
2585
+ break;
2586
+ case "abort":
2587
+ await abortActive();
2588
+ break;
2589
+ case "settings":
2590
+ openSettings();
2591
+ break;
2592
+ case "exit":
2593
+ case "quit":
2594
+ client.stop();
2595
+ tui.stop();
2596
+ process.exit(0);
2597
+ break;
2598
+ default:
2599
+ await sendMessage(raw);
2600
+ break;
2601
+ }
2602
+ tui.requestRender();
2603
+ };
2604
+ const sendMessage = async (text) => {
2605
+ try {
2606
+ chatLog.addUser(text);
2607
+ tui.requestRender();
2608
+ const runId = randomUUID();
2609
+ noteLocalRunId(runId);
2610
+ state.activeChatRunId = runId;
2611
+ setActivityStatus("sending");
2612
+ await client.sendChat({
2613
+ sessionKey: state.currentSessionKey,
2614
+ message: text,
2615
+ thinking: opts.thinking,
2616
+ deliver: deliverDefault,
2617
+ timeoutMs: opts.timeoutMs,
2618
+ runId
2619
+ });
2620
+ setActivityStatus("waiting");
2621
+ } catch (err) {
2622
+ if (state.activeChatRunId) forgetLocalRunId?.(state.activeChatRunId);
2623
+ state.activeChatRunId = null;
2624
+ chatLog.addSystem(`send failed: ${String(err)}`);
2625
+ setActivityStatus("error");
2626
+ }
2627
+ tui.requestRender();
2628
+ };
2629
+ return {
2630
+ handleCommand,
2631
+ sendMessage,
2632
+ openModelSelector,
2633
+ openAgentSelector,
2634
+ openSessionSelector,
2635
+ openSettings,
2636
+ setAgent
2637
+ };
2638
+ }
2639
+
2640
+ //#endregion
2641
+ //#region src/tui/tui-stream-assembler.ts
2642
+ function extractTextBlocksAndSignals(message) {
2643
+ if (!message || typeof message !== "object") return {
2644
+ textBlocks: [],
2645
+ sawNonTextContentBlocks: false
2646
+ };
2647
+ const content = message.content;
2648
+ if (typeof content === "string") {
2649
+ const text = content.trim();
2650
+ return {
2651
+ textBlocks: text ? [text] : [],
2652
+ sawNonTextContentBlocks: false
2653
+ };
2654
+ }
2655
+ if (!Array.isArray(content)) return {
2656
+ textBlocks: [],
2657
+ sawNonTextContentBlocks: false
2658
+ };
2659
+ const textBlocks = [];
2660
+ let sawNonTextContentBlocks = false;
2661
+ for (const block of content) {
2662
+ if (!block || typeof block !== "object") continue;
2663
+ const rec = block;
2664
+ if (rec.type === "text" && typeof rec.text === "string") {
2665
+ const text = rec.text.trim();
2666
+ if (text) textBlocks.push(text);
2667
+ continue;
2668
+ }
2669
+ if (typeof rec.type === "string" && rec.type !== "thinking") sawNonTextContentBlocks = true;
2670
+ }
2671
+ return {
2672
+ textBlocks,
2673
+ sawNonTextContentBlocks
2674
+ };
2675
+ }
2676
+ function isDroppedBoundaryTextBlockSubset(params) {
2677
+ const { streamedTextBlocks, finalTextBlocks } = params;
2678
+ if (finalTextBlocks.length === 0 || finalTextBlocks.length >= streamedTextBlocks.length) return false;
2679
+ if (finalTextBlocks.every((block, index) => streamedTextBlocks[index] === block)) return true;
2680
+ const suffixStart = streamedTextBlocks.length - finalTextBlocks.length;
2681
+ return finalTextBlocks.every((block, index) => streamedTextBlocks[suffixStart + index] === block);
2682
+ }
2683
+ var TuiStreamAssembler = class {
2684
+ constructor() {
2685
+ this.runs = /* @__PURE__ */ new Map();
2686
+ }
2687
+ getOrCreateRun(runId) {
2688
+ let state = this.runs.get(runId);
2689
+ if (!state) {
2690
+ state = {
2691
+ thinkingText: "",
2692
+ contentText: "",
2693
+ contentBlocks: [],
2694
+ sawNonTextContentBlocks: false,
2695
+ displayText: ""
2696
+ };
2697
+ this.runs.set(runId, state);
2698
+ }
2699
+ return state;
2700
+ }
2701
+ updateRunState(state, message, showThinking, opts) {
2702
+ const thinkingText = extractThinkingFromMessage(message);
2703
+ const contentText = extractContentFromMessage(message);
2704
+ const { textBlocks, sawNonTextContentBlocks } = extractTextBlocksAndSignals(message);
2705
+ if (thinkingText) state.thinkingText = thinkingText;
2706
+ if (contentText) {
2707
+ const nextContentBlocks = textBlocks.length > 0 ? textBlocks : [contentText];
2708
+ if (!(opts?.protectBoundaryDrops === true && (state.sawNonTextContentBlocks || sawNonTextContentBlocks) && isDroppedBoundaryTextBlockSubset({
2709
+ streamedTextBlocks: state.contentBlocks,
2710
+ finalTextBlocks: nextContentBlocks
2711
+ }))) {
2712
+ state.contentText = contentText;
2713
+ state.contentBlocks = nextContentBlocks;
2714
+ }
2715
+ }
2716
+ if (sawNonTextContentBlocks) state.sawNonTextContentBlocks = true;
2717
+ state.displayText = composeThinkingAndContent({
2718
+ thinkingText: state.thinkingText,
2719
+ contentText: state.contentText,
2720
+ showThinking
2721
+ });
2722
+ }
2723
+ ingestDelta(runId, message, showThinking) {
2724
+ const state = this.getOrCreateRun(runId);
2725
+ const previousDisplayText = state.displayText;
2726
+ this.updateRunState(state, message, showThinking, { protectBoundaryDrops: true });
2727
+ if (!state.displayText || state.displayText === previousDisplayText) return null;
2728
+ return state.displayText;
2729
+ }
2730
+ finalize(runId, message, showThinking) {
2731
+ const state = this.getOrCreateRun(runId);
2732
+ const streamedDisplayText = state.displayText;
2733
+ const streamedTextBlocks = [...state.contentBlocks];
2734
+ const streamedSawNonTextContentBlocks = state.sawNonTextContentBlocks;
2735
+ this.updateRunState(state, message, showThinking);
2736
+ const finalComposed = state.displayText;
2737
+ const finalText = resolveFinalAssistantText({
2738
+ finalText: streamedSawNonTextContentBlocks && isDroppedBoundaryTextBlockSubset({
2739
+ streamedTextBlocks,
2740
+ finalTextBlocks: state.contentBlocks
2741
+ }) ? streamedDisplayText : finalComposed,
2742
+ streamedText: streamedDisplayText
2743
+ });
2744
+ this.runs.delete(runId);
2745
+ return finalText;
2746
+ }
2747
+ drop(runId) {
2748
+ this.runs.delete(runId);
2749
+ }
2750
+ };
2751
+
2752
+ //#endregion
2753
+ //#region src/tui/tui-event-handlers.ts
2754
+ function createEventHandlers(context) {
2755
+ const { chatLog, tui, state, setActivityStatus, refreshSessionInfo, loadHistory, isLocalRunId, forgetLocalRunId, clearLocalRunIds } = context;
2756
+ const finalizedRuns = /* @__PURE__ */ new Map();
2757
+ const sessionRuns = /* @__PURE__ */ new Map();
2758
+ let streamAssembler = new TuiStreamAssembler();
2759
+ let lastSessionKey = state.currentSessionKey;
2760
+ const pruneRunMap = (runs) => {
2761
+ if (runs.size <= 200) return;
2762
+ const keepUntil = Date.now() - 600 * 1e3;
2763
+ for (const [key, ts] of runs) {
2764
+ if (runs.size <= 150) break;
2765
+ if (ts < keepUntil) runs.delete(key);
2766
+ }
2767
+ if (runs.size > 200) for (const key of runs.keys()) {
2768
+ runs.delete(key);
2769
+ if (runs.size <= 150) break;
2770
+ }
2771
+ };
2772
+ const syncSessionKey = () => {
2773
+ if (state.currentSessionKey === lastSessionKey) return;
2774
+ lastSessionKey = state.currentSessionKey;
2775
+ finalizedRuns.clear();
2776
+ sessionRuns.clear();
2777
+ streamAssembler = new TuiStreamAssembler();
2778
+ clearLocalRunIds?.();
2779
+ };
2780
+ const noteSessionRun = (runId) => {
2781
+ sessionRuns.set(runId, Date.now());
2782
+ pruneRunMap(sessionRuns);
2783
+ };
2784
+ const noteFinalizedRun = (runId) => {
2785
+ finalizedRuns.set(runId, Date.now());
2786
+ sessionRuns.delete(runId);
2787
+ streamAssembler.drop(runId);
2788
+ pruneRunMap(finalizedRuns);
2789
+ };
2790
+ const clearActiveRunIfMatch = (runId) => {
2791
+ if (state.activeChatRunId === runId) state.activeChatRunId = null;
2792
+ };
2793
+ const hasConcurrentActiveRun = (runId) => {
2794
+ const activeRunId = state.activeChatRunId;
2795
+ if (!activeRunId || activeRunId === runId) return false;
2796
+ return sessionRuns.has(activeRunId);
2797
+ };
2798
+ const maybeRefreshHistoryForRun = (runId) => {
2799
+ if (isLocalRunId?.(runId)) {
2800
+ forgetLocalRunId?.(runId);
2801
+ return;
2802
+ }
2803
+ if (hasConcurrentActiveRun(runId)) return;
2804
+ loadHistory?.();
2805
+ };
2806
+ const handleChatEvent = (payload) => {
2807
+ if (!payload || typeof payload !== "object") return;
2808
+ const evt = payload;
2809
+ syncSessionKey();
2810
+ if (evt.sessionKey !== state.currentSessionKey) return;
2811
+ if (finalizedRuns.has(evt.runId)) {
2812
+ if (evt.state === "delta") return;
2813
+ if (evt.state === "final") return;
2814
+ }
2815
+ noteSessionRun(evt.runId);
2816
+ if (!state.activeChatRunId) state.activeChatRunId = evt.runId;
2817
+ if (evt.state === "delta") {
2818
+ const displayText = streamAssembler.ingestDelta(evt.runId, evt.message, state.showThinking);
2819
+ if (!displayText) return;
2820
+ chatLog.updateAssistant(displayText, evt.runId);
2821
+ setActivityStatus("streaming");
2822
+ }
2823
+ if (evt.state === "final") {
2824
+ const wasActiveRun = state.activeChatRunId === evt.runId;
2825
+ if (!evt.message) {
2826
+ maybeRefreshHistoryForRun(evt.runId);
2827
+ chatLog.dropAssistant(evt.runId);
2828
+ noteFinalizedRun(evt.runId);
2829
+ clearActiveRunIfMatch(evt.runId);
2830
+ if (wasActiveRun) setActivityStatus("idle");
2831
+ refreshSessionInfo?.();
2832
+ tui.requestRender();
2833
+ return;
2834
+ }
2835
+ if (isCommandMessage(evt.message)) {
2836
+ maybeRefreshHistoryForRun(evt.runId);
2837
+ const text = extractTextFromMessage(evt.message);
2838
+ if (text) chatLog.addSystem(text);
2839
+ streamAssembler.drop(evt.runId);
2840
+ noteFinalizedRun(evt.runId);
2841
+ clearActiveRunIfMatch(evt.runId);
2842
+ if (wasActiveRun) setActivityStatus("idle");
2843
+ refreshSessionInfo?.();
2844
+ tui.requestRender();
2845
+ return;
2846
+ }
2847
+ maybeRefreshHistoryForRun(evt.runId);
2848
+ const stopReason = evt.message && typeof evt.message === "object" && !Array.isArray(evt.message) ? typeof evt.message.stopReason === "string" ? evt.message.stopReason : "" : "";
2849
+ const finalText = streamAssembler.finalize(evt.runId, evt.message, state.showThinking);
2850
+ if (finalText === "(no output)" && !isLocalRunId?.(evt.runId)) chatLog.dropAssistant(evt.runId);
2851
+ else chatLog.finalizeAssistant(finalText, evt.runId);
2852
+ noteFinalizedRun(evt.runId);
2853
+ clearActiveRunIfMatch(evt.runId);
2854
+ if (wasActiveRun) setActivityStatus(stopReason === "error" ? "error" : "idle");
2855
+ refreshSessionInfo?.();
2856
+ }
2857
+ if (evt.state === "aborted") {
2858
+ const wasActiveRun = state.activeChatRunId === evt.runId;
2859
+ chatLog.addSystem("run aborted");
2860
+ streamAssembler.drop(evt.runId);
2861
+ sessionRuns.delete(evt.runId);
2862
+ clearActiveRunIfMatch(evt.runId);
2863
+ if (wasActiveRun) setActivityStatus("aborted");
2864
+ refreshSessionInfo?.();
2865
+ maybeRefreshHistoryForRun(evt.runId);
2866
+ }
2867
+ if (evt.state === "error") {
2868
+ const wasActiveRun = state.activeChatRunId === evt.runId;
2869
+ chatLog.addSystem(`run error: ${evt.errorMessage ?? "unknown"}`);
2870
+ streamAssembler.drop(evt.runId);
2871
+ sessionRuns.delete(evt.runId);
2872
+ clearActiveRunIfMatch(evt.runId);
2873
+ if (wasActiveRun) setActivityStatus("error");
2874
+ refreshSessionInfo?.();
2875
+ maybeRefreshHistoryForRun(evt.runId);
2876
+ }
2877
+ tui.requestRender();
2878
+ };
2879
+ const handleAgentEvent = (payload) => {
2880
+ if (!payload || typeof payload !== "object") return;
2881
+ const evt = payload;
2882
+ syncSessionKey();
2883
+ const isActiveRun = evt.runId === state.activeChatRunId;
2884
+ if (!(isActiveRun || sessionRuns.has(evt.runId) || finalizedRuns.has(evt.runId))) return;
2885
+ if (evt.stream === "tool") {
2886
+ const verbose = state.sessionInfo.verboseLevel ?? "off";
2887
+ const allowToolEvents = verbose !== "off";
2888
+ const allowToolOutput = verbose === "full";
2889
+ if (!allowToolEvents) return;
2890
+ const data = evt.data ?? {};
2891
+ const phase = asString(data.phase, "");
2892
+ const toolCallId = asString(data.toolCallId, "");
2893
+ const toolName = asString(data.name, "tool");
2894
+ if (!toolCallId) return;
2895
+ if (phase === "start") chatLog.startTool(toolCallId, toolName, data.args);
2896
+ else if (phase === "update") {
2897
+ if (!allowToolOutput) return;
2898
+ chatLog.updateToolResult(toolCallId, data.partialResult, { partial: true });
2899
+ } else if (phase === "result") if (allowToolOutput) chatLog.updateToolResult(toolCallId, data.result, { isError: Boolean(data.isError) });
2900
+ else chatLog.updateToolResult(toolCallId, { content: [] }, { isError: Boolean(data.isError) });
2901
+ tui.requestRender();
2902
+ return;
2903
+ }
2904
+ if (evt.stream === "lifecycle") {
2905
+ if (!isActiveRun) return;
2906
+ const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
2907
+ if (phase === "start") setActivityStatus("running");
2908
+ if (phase === "end") setActivityStatus("idle");
2909
+ if (phase === "error") setActivityStatus("error");
2910
+ tui.requestRender();
2911
+ }
2912
+ };
2913
+ return {
2914
+ handleChatEvent,
2915
+ handleAgentEvent
2916
+ };
2917
+ }
2918
+
2919
+ //#endregion
2920
+ //#region src/tui/tui-local-shell.ts
2921
+ function createLocalShellRunner(deps) {
2922
+ let localExecAsked = false;
2923
+ let localExecAllowed = false;
2924
+ const createSelector = deps.createSelector ?? createSearchableSelectList;
2925
+ const spawnCommand = deps.spawnCommand ?? spawn;
2926
+ const getCwd = deps.getCwd ?? (() => process.cwd());
2927
+ const env = deps.env ?? process.env;
2928
+ const maxChars = deps.maxOutputChars ?? 4e4;
2929
+ const ensureLocalExecAllowed = async () => {
2930
+ if (localExecAllowed) return true;
2931
+ if (localExecAsked) return false;
2932
+ localExecAsked = true;
2933
+ return await new Promise((resolve) => {
2934
+ deps.chatLog.addSystem("Allow local shell commands for this session?");
2935
+ deps.chatLog.addSystem("This runs commands on YOUR machine (not the gateway) and may delete files or reveal secrets.");
2936
+ deps.chatLog.addSystem("Select Yes/No (arrows + Enter), Esc to cancel.");
2937
+ const selector = createSelector([{
2938
+ value: "no",
2939
+ label: "No"
2940
+ }, {
2941
+ value: "yes",
2942
+ label: "Yes"
2943
+ }], 2);
2944
+ selector.onSelect = (item) => {
2945
+ deps.closeOverlay();
2946
+ if (item.value === "yes") {
2947
+ localExecAllowed = true;
2948
+ deps.chatLog.addSystem("local shell: enabled for this session");
2949
+ resolve(true);
2950
+ } else {
2951
+ deps.chatLog.addSystem("local shell: not enabled");
2952
+ resolve(false);
2953
+ }
2954
+ deps.tui.requestRender();
2955
+ };
2956
+ selector.onCancel = () => {
2957
+ deps.closeOverlay();
2958
+ deps.chatLog.addSystem("local shell: cancelled");
2959
+ deps.tui.requestRender();
2960
+ resolve(false);
2961
+ };
2962
+ deps.openOverlay(selector);
2963
+ deps.tui.requestRender();
2964
+ });
2965
+ };
2966
+ const runLocalShellLine = async (line) => {
2967
+ const cmd = line.slice(1);
2968
+ if (cmd === "") return;
2969
+ if (localExecAsked && !localExecAllowed) {
2970
+ deps.chatLog.addSystem("local shell: not enabled for this session");
2971
+ deps.tui.requestRender();
2972
+ return;
2973
+ }
2974
+ if (!await ensureLocalExecAllowed()) return;
2975
+ deps.chatLog.addSystem(`[local] $ ${cmd}`);
2976
+ deps.tui.requestRender();
2977
+ const appendWithCap = (text, chunk) => {
2978
+ const combined = text + chunk;
2979
+ return combined.length > maxChars ? combined.slice(-maxChars) : combined;
2980
+ };
2981
+ await new Promise((resolve) => {
2982
+ const child = spawnCommand(cmd, {
2983
+ shell: true,
2984
+ cwd: getCwd(),
2985
+ env
2986
+ });
2987
+ let stdout = "";
2988
+ let stderr = "";
2989
+ child.stdout.on("data", (buf) => {
2990
+ stdout = appendWithCap(stdout, buf.toString("utf8"));
2991
+ });
2992
+ child.stderr.on("data", (buf) => {
2993
+ stderr = appendWithCap(stderr, buf.toString("utf8"));
2994
+ });
2995
+ child.on("close", (code, signal) => {
2996
+ const combined = (stdout + (stderr ? (stdout ? "\n" : "") + stderr : "")).slice(0, maxChars).trimEnd();
2997
+ if (combined) for (const line of combined.split("\n")) deps.chatLog.addSystem(`[local] ${line}`);
2998
+ deps.chatLog.addSystem(`[local] exit ${code ?? "?"}${signal ? ` (signal ${String(signal)})` : ""}`);
2999
+ deps.tui.requestRender();
3000
+ resolve();
3001
+ });
3002
+ child.on("error", (err) => {
3003
+ deps.chatLog.addSystem(`[local] error: ${String(err)}`);
3004
+ deps.tui.requestRender();
3005
+ resolve();
3006
+ });
3007
+ });
3008
+ };
3009
+ return { runLocalShellLine };
3010
+ }
3011
+
3012
+ //#endregion
3013
+ //#region src/tui/tui-overlays.ts
3014
+ function createOverlayHandlers(host, fallbackFocus) {
3015
+ const openOverlay = (component) => {
3016
+ host.showOverlay(component);
3017
+ };
3018
+ const closeOverlay = () => {
3019
+ if (host.hasOverlay()) {
3020
+ host.hideOverlay();
3021
+ return;
3022
+ }
3023
+ host.setFocus(fallbackFocus);
3024
+ };
3025
+ return {
3026
+ openOverlay,
3027
+ closeOverlay
3028
+ };
3029
+ }
3030
+
3031
+ //#endregion
3032
+ //#region src/tui/tui-session-actions.ts
3033
+ function createSessionActions(context) {
3034
+ const { client, chatLog, tui, opts, state, agentNames, initialSessionInput, initialSessionAgentId, resolveSessionKey, updateHeader, updateFooter, updateAutocompleteProvider, setActivityStatus, clearLocalRunIds } = context;
3035
+ let refreshSessionInfoPromise = Promise.resolve();
3036
+ let lastSessionDefaults = null;
3037
+ const applyAgentsResult = (result) => {
3038
+ state.agentDefaultId = normalizeAgentId(result.defaultId);
3039
+ state.sessionMainKey = normalizeMainKey(result.mainKey);
3040
+ state.sessionScope = result.scope ?? state.sessionScope;
3041
+ state.agents = result.agents.map((agent) => ({
3042
+ id: normalizeAgentId(agent.id),
3043
+ name: agent.name?.trim() || void 0
3044
+ }));
3045
+ agentNames.clear();
3046
+ for (const agent of state.agents) if (agent.name) agentNames.set(agent.id, agent.name);
3047
+ if (!state.initialSessionApplied) {
3048
+ if (initialSessionAgentId) {
3049
+ if (state.agents.some((agent) => agent.id === initialSessionAgentId)) state.currentAgentId = initialSessionAgentId;
3050
+ } else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
3051
+ const nextSessionKey = resolveSessionKey(initialSessionInput);
3052
+ if (nextSessionKey !== state.currentSessionKey) state.currentSessionKey = nextSessionKey;
3053
+ state.initialSessionApplied = true;
3054
+ } else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
3055
+ updateHeader();
3056
+ updateFooter();
3057
+ };
3058
+ const refreshAgents = async () => {
3059
+ try {
3060
+ applyAgentsResult(await client.listAgents());
3061
+ } catch (err) {
3062
+ chatLog.addSystem(`agents list failed: ${String(err)}`);
3063
+ }
3064
+ };
3065
+ const updateAgentFromSessionKey = (key) => {
3066
+ const parsed = parseAgentSessionKey(key);
3067
+ if (!parsed) return;
3068
+ const next = normalizeAgentId(parsed.agentId);
3069
+ if (next !== state.currentAgentId) state.currentAgentId = next;
3070
+ };
3071
+ const resolveModelSelection = (entry) => {
3072
+ if (entry?.modelProvider || entry?.model) return {
3073
+ modelProvider: entry.modelProvider ?? state.sessionInfo.modelProvider,
3074
+ model: entry.model ?? state.sessionInfo.model
3075
+ };
3076
+ const overrideModel = entry?.modelOverride?.trim();
3077
+ if (overrideModel) return {
3078
+ modelProvider: entry?.providerOverride?.trim() || state.sessionInfo.modelProvider,
3079
+ model: overrideModel
3080
+ };
3081
+ return {
3082
+ modelProvider: state.sessionInfo.modelProvider,
3083
+ model: state.sessionInfo.model
3084
+ };
3085
+ };
3086
+ const applySessionInfo = (params) => {
3087
+ const entry = params.entry ?? void 0;
3088
+ const defaults = params.defaults ?? lastSessionDefaults ?? void 0;
3089
+ const previousDefaults = lastSessionDefaults;
3090
+ const defaultsChanged = params.defaults ? previousDefaults?.model !== params.defaults.model || previousDefaults?.modelProvider !== params.defaults.modelProvider || previousDefaults?.contextTokens !== params.defaults.contextTokens : false;
3091
+ if (params.defaults) lastSessionDefaults = params.defaults;
3092
+ const entryUpdatedAt = entry?.updatedAt ?? null;
3093
+ const currentUpdatedAt = state.sessionInfo.updatedAt ?? null;
3094
+ const modelChanged = entry?.modelProvider !== void 0 && entry.modelProvider !== state.sessionInfo.modelProvider || entry?.model !== void 0 && entry.model !== state.sessionInfo.model;
3095
+ if (!params.force && entryUpdatedAt !== null && currentUpdatedAt !== null && entryUpdatedAt < currentUpdatedAt && !defaultsChanged && !modelChanged) return;
3096
+ const next = { ...state.sessionInfo };
3097
+ if (entry?.thinkingLevel !== void 0) next.thinkingLevel = entry.thinkingLevel;
3098
+ if (entry?.verboseLevel !== void 0) next.verboseLevel = entry.verboseLevel;
3099
+ if (entry?.reasoningLevel !== void 0) next.reasoningLevel = entry.reasoningLevel;
3100
+ if (entry?.responseUsage !== void 0) next.responseUsage = entry.responseUsage;
3101
+ if (entry?.inputTokens !== void 0) next.inputTokens = entry.inputTokens;
3102
+ if (entry?.outputTokens !== void 0) next.outputTokens = entry.outputTokens;
3103
+ if (entry?.totalTokens !== void 0) next.totalTokens = entry.totalTokens;
3104
+ if (entry?.contextTokens !== void 0 || defaults?.contextTokens !== void 0) next.contextTokens = entry?.contextTokens ?? defaults?.contextTokens ?? state.sessionInfo.contextTokens;
3105
+ if (entry?.displayName !== void 0) next.displayName = entry.displayName;
3106
+ if (entry?.updatedAt !== void 0) next.updatedAt = entry.updatedAt;
3107
+ const selection = resolveModelSelection(entry);
3108
+ if (selection.modelProvider !== void 0) next.modelProvider = selection.modelProvider;
3109
+ if (selection.model !== void 0) next.model = selection.model;
3110
+ state.sessionInfo = next;
3111
+ updateAutocompleteProvider();
3112
+ updateFooter();
3113
+ tui.requestRender();
3114
+ };
3115
+ const runRefreshSessionInfo = async () => {
3116
+ try {
3117
+ const resolveListAgentId = () => {
3118
+ if (state.currentSessionKey === "global" || state.currentSessionKey === "unknown") return;
3119
+ const parsed = parseAgentSessionKey(state.currentSessionKey);
3120
+ return parsed?.agentId ? normalizeAgentId(parsed.agentId) : state.currentAgentId;
3121
+ };
3122
+ const listAgentId = resolveListAgentId();
3123
+ const result = await client.listSessions({
3124
+ includeGlobal: false,
3125
+ includeUnknown: false,
3126
+ agentId: listAgentId
3127
+ });
3128
+ const normalizeMatchKey = (key) => parseAgentSessionKey(key)?.rest ?? key;
3129
+ const currentMatchKey = normalizeMatchKey(state.currentSessionKey);
3130
+ const entry = result.sessions.find((row) => {
3131
+ if (row.key === state.currentSessionKey) return true;
3132
+ return normalizeMatchKey(row.key) === currentMatchKey;
3133
+ });
3134
+ if (entry?.key && entry.key !== state.currentSessionKey) {
3135
+ updateAgentFromSessionKey(entry.key);
3136
+ state.currentSessionKey = entry.key;
3137
+ updateHeader();
3138
+ }
3139
+ applySessionInfo({
3140
+ entry,
3141
+ defaults: result.defaults
3142
+ });
3143
+ } catch (err) {
3144
+ chatLog.addSystem(`sessions list failed: ${String(err)}`);
3145
+ }
3146
+ };
3147
+ const refreshSessionInfo = async () => {
3148
+ refreshSessionInfoPromise = refreshSessionInfoPromise.then(runRefreshSessionInfo, runRefreshSessionInfo);
3149
+ await refreshSessionInfoPromise;
3150
+ };
3151
+ const applySessionInfoFromPatch = (result) => {
3152
+ if (!result?.entry) return;
3153
+ if (result.key && result.key !== state.currentSessionKey) {
3154
+ updateAgentFromSessionKey(result.key);
3155
+ state.currentSessionKey = result.key;
3156
+ updateHeader();
3157
+ }
3158
+ const resolved = result.resolved;
3159
+ applySessionInfo({
3160
+ entry: resolved && (resolved.modelProvider || resolved.model) ? {
3161
+ ...result.entry,
3162
+ modelProvider: resolved.modelProvider ?? result.entry.modelProvider,
3163
+ model: resolved.model ?? result.entry.model
3164
+ } : result.entry,
3165
+ force: true
3166
+ });
3167
+ };
3168
+ const loadHistory = async () => {
3169
+ try {
3170
+ const record = await client.loadHistory({
3171
+ sessionKey: state.currentSessionKey,
3172
+ limit: opts.historyLimit ?? 200
3173
+ });
3174
+ state.currentSessionId = typeof record.sessionId === "string" ? record.sessionId : null;
3175
+ state.sessionInfo.thinkingLevel = record.thinkingLevel ?? state.sessionInfo.thinkingLevel;
3176
+ state.sessionInfo.verboseLevel = record.verboseLevel ?? state.sessionInfo.verboseLevel;
3177
+ const showTools = (state.sessionInfo.verboseLevel ?? "off") !== "off";
3178
+ chatLog.clearAll();
3179
+ chatLog.addSystem(`session ${state.currentSessionKey}`);
3180
+ for (const entry of record.messages ?? []) {
3181
+ if (!entry || typeof entry !== "object") continue;
3182
+ const message = entry;
3183
+ if (isCommandMessage(message)) {
3184
+ const text = extractTextFromMessage(message);
3185
+ if (text) chatLog.addSystem(text);
3186
+ continue;
3187
+ }
3188
+ if (message.role === "user") {
3189
+ const text = extractTextFromMessage(message);
3190
+ if (text) chatLog.addUser(text);
3191
+ continue;
3192
+ }
3193
+ if (message.role === "assistant") {
3194
+ const text = extractTextFromMessage(message, { includeThinking: state.showThinking });
3195
+ if (text) chatLog.finalizeAssistant(text);
3196
+ continue;
3197
+ }
3198
+ if (message.role === "toolResult") {
3199
+ if (!showTools) continue;
3200
+ const toolCallId = asString(message.toolCallId, "");
3201
+ const toolName = asString(message.toolName, "tool");
3202
+ chatLog.startTool(toolCallId, toolName, {}).setResult({
3203
+ content: Array.isArray(message.content) ? message.content : [],
3204
+ details: typeof message.details === "object" && message.details ? message.details : void 0
3205
+ }, { isError: Boolean(message.isError) });
3206
+ }
3207
+ }
3208
+ state.historyLoaded = true;
3209
+ } catch (err) {
3210
+ chatLog.addSystem(`history failed: ${String(err)}`);
3211
+ }
3212
+ await refreshSessionInfo();
3213
+ tui.requestRender();
3214
+ };
3215
+ const setSession = async (rawKey) => {
3216
+ const nextKey = resolveSessionKey(rawKey);
3217
+ updateAgentFromSessionKey(nextKey);
3218
+ state.currentSessionKey = nextKey;
3219
+ state.activeChatRunId = null;
3220
+ state.currentSessionId = null;
3221
+ state.historyLoaded = false;
3222
+ clearLocalRunIds?.();
3223
+ updateHeader();
3224
+ updateFooter();
3225
+ await loadHistory();
3226
+ };
3227
+ const abortActive = async () => {
3228
+ if (!state.activeChatRunId) {
3229
+ chatLog.addSystem("no active run");
3230
+ tui.requestRender();
3231
+ return;
3232
+ }
3233
+ try {
3234
+ await client.abortChat({
3235
+ sessionKey: state.currentSessionKey,
3236
+ runId: state.activeChatRunId
3237
+ });
3238
+ setActivityStatus("aborted");
3239
+ } catch (err) {
3240
+ chatLog.addSystem(`abort failed: ${String(err)}`);
3241
+ setActivityStatus("abort failed");
3242
+ }
3243
+ tui.requestRender();
3244
+ };
3245
+ return {
3246
+ applyAgentsResult,
3247
+ refreshAgents,
3248
+ refreshSessionInfo,
3249
+ applySessionInfoFromPatch,
3250
+ loadHistory,
3251
+ setSession,
3252
+ abortActive
3253
+ };
3254
+ }
3255
+
3256
+ //#endregion
3257
+ //#region src/tui/tui-waiting.ts
3258
+ const defaultWaitingPhrases = [
3259
+ "flibbertigibbeting",
3260
+ "kerfuffling",
3261
+ "dillydallying",
3262
+ "twiddling thumbs",
3263
+ "noodling",
3264
+ "bamboozling",
3265
+ "moseying",
3266
+ "hobnobbing",
3267
+ "pondering",
3268
+ "conjuring"
3269
+ ];
3270
+ function pickWaitingPhrase(tick, phrases = defaultWaitingPhrases) {
3271
+ return phrases[Math.floor(tick / 10) % phrases.length] ?? phrases[0] ?? "waiting";
3272
+ }
3273
+ function shimmerText(theme, text, tick) {
3274
+ const width = 6;
3275
+ const hi = (ch) => theme.bold(theme.accentSoft(ch));
3276
+ const pos = tick % (text.length + width);
3277
+ const start = Math.max(0, pos - width);
3278
+ const end = Math.min(text.length - 1, pos);
3279
+ let out = "";
3280
+ for (let i = 0; i < text.length; i++) {
3281
+ const ch = text[i];
3282
+ out += i >= start && i <= end ? hi(ch) : theme.dim(ch);
3283
+ }
3284
+ return out;
3285
+ }
3286
+ function buildWaitingStatusMessage(params) {
3287
+ const phrase = pickWaitingPhrase(params.tick, params.phrases);
3288
+ return `${shimmerText(params.theme, `${phrase}…`, params.tick)} • ${params.elapsed} | ${params.connectionStatus}`;
3289
+ }
3290
+
3291
+ //#endregion
3292
+ //#region src/tui/tui.ts
3293
+ function createEditorSubmitHandler(params) {
3294
+ return (text) => {
3295
+ const raw = text;
3296
+ const value = raw.trim();
3297
+ params.editor.setText("");
3298
+ if (!value) return;
3299
+ if (raw.startsWith("!") && raw !== "!") {
3300
+ params.editor.addToHistory(raw);
3301
+ params.handleBangLine(raw);
3302
+ return;
3303
+ }
3304
+ params.editor.addToHistory(value);
3305
+ if (value.startsWith("/")) {
3306
+ params.handleCommand(value);
3307
+ return;
3308
+ }
3309
+ params.sendMessage(value);
3310
+ };
3311
+ }
3312
+ function shouldEnableWindowsGitBashPasteFallback(params) {
3313
+ if ((params?.platform ?? process.platform) !== "win32") return false;
3314
+ const env = params?.env ?? process.env;
3315
+ const msystem = (env.MSYSTEM ?? "").toUpperCase();
3316
+ const shell = env.SHELL ?? "";
3317
+ const termProgram = (env.TERM_PROGRAM ?? "").toLowerCase();
3318
+ if (msystem.startsWith("MINGW") || msystem.startsWith("MSYS")) return true;
3319
+ if (shell.toLowerCase().includes("bash")) return true;
3320
+ return termProgram.includes("mintty");
3321
+ }
3322
+ function createSubmitBurstCoalescer(params) {
3323
+ const windowMs = Math.max(1, params.burstWindowMs ?? 50);
3324
+ const now = params.now ?? (() => Date.now());
3325
+ const setTimer = params.setTimer ?? setTimeout;
3326
+ const clearTimer = params.clearTimer ?? clearTimeout;
3327
+ let pending = null;
3328
+ let pendingAt = 0;
3329
+ let flushTimer = null;
3330
+ const clearFlushTimer = () => {
3331
+ if (!flushTimer) return;
3332
+ clearTimer(flushTimer);
3333
+ flushTimer = null;
3334
+ };
3335
+ const flushPending = () => {
3336
+ if (pending === null) return;
3337
+ const value = pending;
3338
+ pending = null;
3339
+ pendingAt = 0;
3340
+ clearFlushTimer();
3341
+ params.submit(value);
3342
+ };
3343
+ const scheduleFlush = () => {
3344
+ clearFlushTimer();
3345
+ flushTimer = setTimer(() => {
3346
+ flushPending();
3347
+ }, windowMs);
3348
+ };
3349
+ return (value) => {
3350
+ if (!params.enabled) {
3351
+ params.submit(value);
3352
+ return;
3353
+ }
3354
+ if (value.includes("\n")) {
3355
+ flushPending();
3356
+ params.submit(value);
3357
+ return;
3358
+ }
3359
+ const ts = now();
3360
+ if (pending === null) {
3361
+ pending = value;
3362
+ pendingAt = ts;
3363
+ scheduleFlush();
3364
+ return;
3365
+ }
3366
+ if (ts - pendingAt <= windowMs) {
3367
+ pending = `${pending}\n${value}`;
3368
+ pendingAt = ts;
3369
+ scheduleFlush();
3370
+ return;
3371
+ }
3372
+ flushPending();
3373
+ pending = value;
3374
+ pendingAt = ts;
3375
+ scheduleFlush();
3376
+ };
3377
+ }
3378
+ function resolveTuiSessionKey(params) {
3379
+ const trimmed = (params.raw ?? "").trim();
3380
+ if (!trimmed) {
3381
+ if (params.sessionScope === "global") return "global";
3382
+ return buildAgentMainSessionKey({
3383
+ agentId: params.currentAgentId,
3384
+ mainKey: params.sessionMainKey
3385
+ });
3386
+ }
3387
+ if (trimmed === "global" || trimmed === "unknown") return trimmed;
3388
+ if (trimmed.startsWith("agent:")) return trimmed;
3389
+ return `agent:${params.currentAgentId}:${trimmed}`;
3390
+ }
3391
+ async function runTui(opts) {
3392
+ const config = loadConfig();
3393
+ const initialSessionInput = (opts.session ?? "").trim();
3394
+ let sessionScope = config.session?.scope ?? "per-sender";
3395
+ let sessionMainKey = normalizeMainKey(config.session?.mainKey);
3396
+ let agentDefaultId = resolveDefaultAgentId(config);
3397
+ let currentAgentId = agentDefaultId;
3398
+ let agents = [];
3399
+ const agentNames = /* @__PURE__ */ new Map();
3400
+ let currentSessionKey = "";
3401
+ let initialSessionApplied = false;
3402
+ let currentSessionId = null;
3403
+ let activeChatRunId = null;
3404
+ let historyLoaded = false;
3405
+ let isConnected = false;
3406
+ let wasDisconnected = false;
3407
+ let toolsExpanded = false;
3408
+ let showThinking = false;
3409
+ const localRunIds = /* @__PURE__ */ new Set();
3410
+ const deliverDefault = opts.deliver ?? false;
3411
+ const autoMessage = opts.message?.trim();
3412
+ let autoMessageSent = false;
3413
+ let sessionInfo = {};
3414
+ let lastCtrlCAt = 0;
3415
+ let activityStatus = "idle";
3416
+ let connectionStatus = "connecting";
3417
+ let statusTimeout = null;
3418
+ let statusTimer = null;
3419
+ let statusStartedAt = null;
3420
+ let lastActivityStatus = activityStatus;
3421
+ const state = {
3422
+ get agentDefaultId() {
3423
+ return agentDefaultId;
3424
+ },
3425
+ set agentDefaultId(value) {
3426
+ agentDefaultId = value;
3427
+ },
3428
+ get sessionMainKey() {
3429
+ return sessionMainKey;
3430
+ },
3431
+ set sessionMainKey(value) {
3432
+ sessionMainKey = value;
3433
+ },
3434
+ get sessionScope() {
3435
+ return sessionScope;
3436
+ },
3437
+ set sessionScope(value) {
3438
+ sessionScope = value;
3439
+ },
3440
+ get agents() {
3441
+ return agents;
3442
+ },
3443
+ set agents(value) {
3444
+ agents = value;
3445
+ },
3446
+ get currentAgentId() {
3447
+ return currentAgentId;
3448
+ },
3449
+ set currentAgentId(value) {
3450
+ currentAgentId = value;
3451
+ },
3452
+ get currentSessionKey() {
3453
+ return currentSessionKey;
3454
+ },
3455
+ set currentSessionKey(value) {
3456
+ currentSessionKey = value;
3457
+ },
3458
+ get currentSessionId() {
3459
+ return currentSessionId;
3460
+ },
3461
+ set currentSessionId(value) {
3462
+ currentSessionId = value;
3463
+ },
3464
+ get activeChatRunId() {
3465
+ return activeChatRunId;
3466
+ },
3467
+ set activeChatRunId(value) {
3468
+ activeChatRunId = value;
3469
+ },
3470
+ get historyLoaded() {
3471
+ return historyLoaded;
3472
+ },
3473
+ set historyLoaded(value) {
3474
+ historyLoaded = value;
3475
+ },
3476
+ get sessionInfo() {
3477
+ return sessionInfo;
3478
+ },
3479
+ set sessionInfo(value) {
3480
+ sessionInfo = value;
3481
+ },
3482
+ get initialSessionApplied() {
3483
+ return initialSessionApplied;
3484
+ },
3485
+ set initialSessionApplied(value) {
3486
+ initialSessionApplied = value;
3487
+ },
3488
+ get isConnected() {
3489
+ return isConnected;
3490
+ },
3491
+ set isConnected(value) {
3492
+ isConnected = value;
3493
+ },
3494
+ get autoMessageSent() {
3495
+ return autoMessageSent;
3496
+ },
3497
+ set autoMessageSent(value) {
3498
+ autoMessageSent = value;
3499
+ },
3500
+ get toolsExpanded() {
3501
+ return toolsExpanded;
3502
+ },
3503
+ set toolsExpanded(value) {
3504
+ toolsExpanded = value;
3505
+ },
3506
+ get showThinking() {
3507
+ return showThinking;
3508
+ },
3509
+ set showThinking(value) {
3510
+ showThinking = value;
3511
+ },
3512
+ get connectionStatus() {
3513
+ return connectionStatus;
3514
+ },
3515
+ set connectionStatus(value) {
3516
+ connectionStatus = value;
3517
+ },
3518
+ get activityStatus() {
3519
+ return activityStatus;
3520
+ },
3521
+ set activityStatus(value) {
3522
+ activityStatus = value;
3523
+ },
3524
+ get statusTimeout() {
3525
+ return statusTimeout;
3526
+ },
3527
+ set statusTimeout(value) {
3528
+ statusTimeout = value;
3529
+ },
3530
+ get lastCtrlCAt() {
3531
+ return lastCtrlCAt;
3532
+ },
3533
+ set lastCtrlCAt(value) {
3534
+ lastCtrlCAt = value;
3535
+ }
3536
+ };
3537
+ const noteLocalRunId = (runId) => {
3538
+ if (!runId) return;
3539
+ localRunIds.add(runId);
3540
+ if (localRunIds.size > 200) {
3541
+ const [first] = localRunIds;
3542
+ if (first) localRunIds.delete(first);
3543
+ }
3544
+ };
3545
+ const forgetLocalRunId = (runId) => {
3546
+ localRunIds.delete(runId);
3547
+ };
3548
+ const isLocalRunId = (runId) => localRunIds.has(runId);
3549
+ const clearLocalRunIds = () => {
3550
+ localRunIds.clear();
3551
+ };
3552
+ const client = new GatewayChatClient({
3553
+ url: opts.url,
3554
+ token: opts.token,
3555
+ password: opts.password
3556
+ });
3557
+ const tui = new TUI(new ProcessTerminal());
3558
+ const header = new Text("", 1, 0);
3559
+ const statusContainer = new Container();
3560
+ const footer = new Text("", 1, 0);
3561
+ const chatLog = new ChatLog();
3562
+ const editor = new CustomEditor(tui, editorTheme);
3563
+ const root = new Container();
3564
+ root.addChild(header);
3565
+ root.addChild(chatLog);
3566
+ root.addChild(statusContainer);
3567
+ root.addChild(footer);
3568
+ root.addChild(editor);
3569
+ const updateAutocompleteProvider = () => {
3570
+ editor.setAutocompleteProvider(new CombinedAutocompleteProvider(getSlashCommands({
3571
+ cfg: config,
3572
+ provider: sessionInfo.modelProvider,
3573
+ model: sessionInfo.model
3574
+ }), process.cwd()));
3575
+ };
3576
+ tui.addChild(root);
3577
+ tui.setFocus(editor);
3578
+ const formatSessionKey = (key) => {
3579
+ if (key === "global" || key === "unknown") return key;
3580
+ return parseAgentSessionKey(key)?.rest ?? key;
3581
+ };
3582
+ const formatAgentLabel = (id) => {
3583
+ const name = agentNames.get(id);
3584
+ return name ? `${id} (${name})` : id;
3585
+ };
3586
+ const resolveSessionKey = (raw) => {
3587
+ return resolveTuiSessionKey({
3588
+ raw,
3589
+ sessionScope,
3590
+ currentAgentId,
3591
+ sessionMainKey
3592
+ });
3593
+ };
3594
+ currentSessionKey = resolveSessionKey(initialSessionInput);
3595
+ const updateHeader = () => {
3596
+ const sessionLabel = formatSessionKey(currentSessionKey);
3597
+ const agentLabel = formatAgentLabel(currentAgentId);
3598
+ header.setText(theme.header(`anima tui - ${client.connection.url} - agent ${agentLabel} - session ${sessionLabel}`));
3599
+ };
3600
+ const busyStates = new Set([
3601
+ "sending",
3602
+ "waiting",
3603
+ "streaming",
3604
+ "running"
3605
+ ]);
3606
+ let statusText = null;
3607
+ let statusLoader = null;
3608
+ const formatElapsed = (startMs) => {
3609
+ const totalSeconds = Math.max(0, Math.floor((Date.now() - startMs) / 1e3));
3610
+ if (totalSeconds < 60) return `${totalSeconds}s`;
3611
+ return `${Math.floor(totalSeconds / 60)}m ${totalSeconds % 60}s`;
3612
+ };
3613
+ const ensureStatusText = () => {
3614
+ if (statusText) return;
3615
+ statusContainer.clear();
3616
+ statusLoader?.stop();
3617
+ statusLoader = null;
3618
+ statusText = new Text("", 1, 0);
3619
+ statusContainer.addChild(statusText);
3620
+ };
3621
+ const ensureStatusLoader = () => {
3622
+ if (statusLoader) return;
3623
+ statusContainer.clear();
3624
+ statusText = null;
3625
+ statusLoader = new Loader(tui, (spinner) => theme.accent(spinner), (text) => theme.bold(theme.accentSoft(text)), "");
3626
+ statusContainer.addChild(statusLoader);
3627
+ };
3628
+ let waitingTick = 0;
3629
+ let waitingTimer = null;
3630
+ let waitingPhrase = null;
3631
+ const updateBusyStatusMessage = () => {
3632
+ if (!statusLoader || !statusStartedAt) return;
3633
+ const elapsed = formatElapsed(statusStartedAt);
3634
+ if (activityStatus === "waiting") {
3635
+ waitingTick++;
3636
+ statusLoader.setMessage(buildWaitingStatusMessage({
3637
+ theme,
3638
+ tick: waitingTick,
3639
+ elapsed,
3640
+ connectionStatus,
3641
+ phrases: waitingPhrase ? [waitingPhrase] : void 0
3642
+ }));
3643
+ return;
3644
+ }
3645
+ statusLoader.setMessage(`${activityStatus} • ${elapsed} | ${connectionStatus}`);
3646
+ };
3647
+ const startStatusTimer = () => {
3648
+ if (statusTimer) return;
3649
+ statusTimer = setInterval(() => {
3650
+ if (!busyStates.has(activityStatus)) return;
3651
+ updateBusyStatusMessage();
3652
+ }, 1e3);
3653
+ };
3654
+ const stopStatusTimer = () => {
3655
+ if (!statusTimer) return;
3656
+ clearInterval(statusTimer);
3657
+ statusTimer = null;
3658
+ };
3659
+ const startWaitingTimer = () => {
3660
+ if (waitingTimer) return;
3661
+ if (!waitingPhrase) waitingPhrase = defaultWaitingPhrases[Math.floor(Math.random() * defaultWaitingPhrases.length)] ?? defaultWaitingPhrases[0] ?? "waiting";
3662
+ waitingTick = 0;
3663
+ waitingTimer = setInterval(() => {
3664
+ if (activityStatus !== "waiting") return;
3665
+ updateBusyStatusMessage();
3666
+ }, 120);
3667
+ };
3668
+ const stopWaitingTimer = () => {
3669
+ if (!waitingTimer) return;
3670
+ clearInterval(waitingTimer);
3671
+ waitingTimer = null;
3672
+ waitingPhrase = null;
3673
+ };
3674
+ const renderStatus = () => {
3675
+ if (busyStates.has(activityStatus)) {
3676
+ if (!statusStartedAt || lastActivityStatus !== activityStatus) statusStartedAt = Date.now();
3677
+ ensureStatusLoader();
3678
+ if (activityStatus === "waiting") {
3679
+ stopStatusTimer();
3680
+ startWaitingTimer();
3681
+ } else {
3682
+ stopWaitingTimer();
3683
+ startStatusTimer();
3684
+ }
3685
+ updateBusyStatusMessage();
3686
+ } else {
3687
+ statusStartedAt = null;
3688
+ stopStatusTimer();
3689
+ stopWaitingTimer();
3690
+ statusLoader?.stop();
3691
+ statusLoader = null;
3692
+ ensureStatusText();
3693
+ const text = activityStatus ? `${connectionStatus} | ${activityStatus}` : connectionStatus;
3694
+ statusText?.setText(theme.dim(text));
3695
+ }
3696
+ lastActivityStatus = activityStatus;
3697
+ };
3698
+ const setConnectionStatus = (text, ttlMs) => {
3699
+ connectionStatus = text;
3700
+ renderStatus();
3701
+ if (statusTimeout) clearTimeout(statusTimeout);
3702
+ if (ttlMs && ttlMs > 0) statusTimeout = setTimeout(() => {
3703
+ connectionStatus = isConnected ? "connected" : "disconnected";
3704
+ renderStatus();
3705
+ }, ttlMs);
3706
+ };
3707
+ const setActivityStatus = (text) => {
3708
+ activityStatus = text;
3709
+ renderStatus();
3710
+ };
3711
+ const updateFooter = () => {
3712
+ const sessionKeyLabel = formatSessionKey(currentSessionKey);
3713
+ const sessionLabel = sessionInfo.displayName ? `${sessionKeyLabel} (${sessionInfo.displayName})` : sessionKeyLabel;
3714
+ const agentLabel = formatAgentLabel(currentAgentId);
3715
+ const modelLabel = sessionInfo.model ? sessionInfo.modelProvider ? `${sessionInfo.modelProvider}/${sessionInfo.model}` : sessionInfo.model : "unknown";
3716
+ const tokens = formatTokens(sessionInfo.totalTokens ?? null, sessionInfo.contextTokens ?? null);
3717
+ const think = sessionInfo.thinkingLevel ?? "off";
3718
+ const verbose = sessionInfo.verboseLevel ?? "off";
3719
+ const reasoning = sessionInfo.reasoningLevel ?? "off";
3720
+ const reasoningLabel = reasoning === "on" ? "reasoning" : reasoning === "stream" ? "reasoning:stream" : null;
3721
+ const footerParts = [
3722
+ `agent ${agentLabel}`,
3723
+ `session ${sessionLabel}`,
3724
+ modelLabel,
3725
+ think !== "off" ? `think ${think}` : null,
3726
+ verbose !== "off" ? `verbose ${verbose}` : null,
3727
+ reasoningLabel,
3728
+ tokens
3729
+ ].filter(Boolean);
3730
+ footer.setText(theme.dim(footerParts.join(" | ")));
3731
+ };
3732
+ const { openOverlay, closeOverlay } = createOverlayHandlers(tui, editor);
3733
+ const { refreshAgents, refreshSessionInfo, applySessionInfoFromPatch, loadHistory, setSession, abortActive } = createSessionActions({
3734
+ client,
3735
+ chatLog,
3736
+ tui,
3737
+ opts,
3738
+ state,
3739
+ agentNames,
3740
+ initialSessionInput,
3741
+ initialSessionAgentId: (() => {
3742
+ if (!initialSessionInput) return null;
3743
+ const parsed = parseAgentSessionKey(initialSessionInput);
3744
+ return parsed ? normalizeAgentId(parsed.agentId) : null;
3745
+ })(),
3746
+ resolveSessionKey,
3747
+ updateHeader,
3748
+ updateFooter,
3749
+ updateAutocompleteProvider,
3750
+ setActivityStatus,
3751
+ clearLocalRunIds
3752
+ });
3753
+ const { handleChatEvent, handleAgentEvent } = createEventHandlers({
3754
+ chatLog,
3755
+ tui,
3756
+ state,
3757
+ setActivityStatus,
3758
+ refreshSessionInfo,
3759
+ loadHistory,
3760
+ isLocalRunId,
3761
+ forgetLocalRunId,
3762
+ clearLocalRunIds
3763
+ });
3764
+ const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } = createCommandHandlers({
3765
+ client,
3766
+ chatLog,
3767
+ tui,
3768
+ opts,
3769
+ state,
3770
+ deliverDefault,
3771
+ openOverlay,
3772
+ closeOverlay,
3773
+ refreshSessionInfo,
3774
+ applySessionInfoFromPatch,
3775
+ loadHistory,
3776
+ setSession,
3777
+ refreshAgents,
3778
+ abortActive,
3779
+ setActivityStatus,
3780
+ formatSessionKey,
3781
+ noteLocalRunId,
3782
+ forgetLocalRunId
3783
+ });
3784
+ const { runLocalShellLine } = createLocalShellRunner({
3785
+ chatLog,
3786
+ tui,
3787
+ openOverlay,
3788
+ closeOverlay
3789
+ });
3790
+ updateAutocompleteProvider();
3791
+ editor.onSubmit = createSubmitBurstCoalescer({
3792
+ submit: createEditorSubmitHandler({
3793
+ editor,
3794
+ handleCommand,
3795
+ sendMessage,
3796
+ handleBangLine: runLocalShellLine
3797
+ }),
3798
+ enabled: shouldEnableWindowsGitBashPasteFallback()
3799
+ });
3800
+ editor.onEscape = () => {
3801
+ abortActive();
3802
+ };
3803
+ editor.onCtrlC = () => {
3804
+ const now = Date.now();
3805
+ if (editor.getText().trim().length > 0) {
3806
+ editor.setText("");
3807
+ setActivityStatus("cleared input");
3808
+ tui.requestRender();
3809
+ return;
3810
+ }
3811
+ if (now - lastCtrlCAt < 1e3) {
3812
+ client.stop();
3813
+ tui.stop();
3814
+ process.exit(0);
3815
+ }
3816
+ lastCtrlCAt = now;
3817
+ setActivityStatus("press ctrl+c again to exit");
3818
+ tui.requestRender();
3819
+ };
3820
+ editor.onCtrlD = () => {
3821
+ client.stop();
3822
+ tui.stop();
3823
+ process.exit(0);
3824
+ };
3825
+ editor.onCtrlO = () => {
3826
+ toolsExpanded = !toolsExpanded;
3827
+ chatLog.setToolsExpanded(toolsExpanded);
3828
+ setActivityStatus(toolsExpanded ? "tools expanded" : "tools collapsed");
3829
+ tui.requestRender();
3830
+ };
3831
+ editor.onCtrlL = () => {
3832
+ openModelSelector();
3833
+ };
3834
+ editor.onCtrlG = () => {
3835
+ openAgentSelector();
3836
+ };
3837
+ editor.onCtrlP = () => {
3838
+ openSessionSelector();
3839
+ };
3840
+ editor.onCtrlT = () => {
3841
+ showThinking = !showThinking;
3842
+ loadHistory();
3843
+ };
3844
+ client.onEvent = (evt) => {
3845
+ if (evt.event === "chat") handleChatEvent(evt.payload);
3846
+ if (evt.event === "agent") handleAgentEvent(evt.payload);
3847
+ };
3848
+ client.onConnected = () => {
3849
+ isConnected = true;
3850
+ const reconnected = wasDisconnected;
3851
+ wasDisconnected = false;
3852
+ setConnectionStatus("connected");
3853
+ (async () => {
3854
+ await refreshAgents();
3855
+ updateHeader();
3856
+ await loadHistory();
3857
+ setConnectionStatus(reconnected ? "gateway reconnected" : "gateway connected", 4e3);
3858
+ tui.requestRender();
3859
+ if (!autoMessageSent && autoMessage) {
3860
+ autoMessageSent = true;
3861
+ await sendMessage(autoMessage);
3862
+ }
3863
+ updateFooter();
3864
+ tui.requestRender();
3865
+ })();
3866
+ };
3867
+ client.onDisconnected = (reason) => {
3868
+ isConnected = false;
3869
+ wasDisconnected = true;
3870
+ historyLoaded = false;
3871
+ setConnectionStatus(`gateway disconnected: ${reason?.trim() ? reason.trim() : "closed"}`, 5e3);
3872
+ setActivityStatus("idle");
3873
+ updateFooter();
3874
+ tui.requestRender();
3875
+ };
3876
+ client.onGap = (info) => {
3877
+ setConnectionStatus(`event gap: expected ${info.expected}, got ${info.received}`, 5e3);
3878
+ tui.requestRender();
3879
+ };
3880
+ updateHeader();
3881
+ setConnectionStatus("connecting");
3882
+ updateFooter();
3883
+ tui.start();
3884
+ client.start();
3885
+ await new Promise((resolve) => {
3886
+ const finish = () => resolve();
3887
+ process.once("exit", finish);
3888
+ process.once("SIGINT", finish);
3889
+ process.once("SIGTERM", finish);
3890
+ });
3891
+ }
3892
+
3893
+ //#endregion
3894
+ export { runTui as t };