@termix-it/cryptoclaw 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1222) hide show
  1. package/CHANGELOG.md +1615 -0
  2. package/LICENSE +21 -0
  3. package/README-header.png +0 -0
  4. package/README.md +331 -0
  5. package/assets/avatar-placeholder.svg +19 -0
  6. package/assets/chrome-extension/README.md +22 -0
  7. package/assets/chrome-extension/background.js +438 -0
  8. package/assets/chrome-extension/icons/icon128.png +0 -0
  9. package/assets/chrome-extension/icons/icon16.png +0 -0
  10. package/assets/chrome-extension/icons/icon32.png +0 -0
  11. package/assets/chrome-extension/icons/icon48.png +0 -0
  12. package/assets/chrome-extension/manifest.json +25 -0
  13. package/assets/chrome-extension/options.html +196 -0
  14. package/assets/chrome-extension/options.js +59 -0
  15. package/assets/dmg-background-small.png +0 -0
  16. package/assets/dmg-background.png +0 -0
  17. package/cryptoclaw.mjs +14 -0
  18. package/dist/accounts-BPjR5SyC.js +251 -0
  19. package/dist/accounts-CIGHxE7R.js +251 -0
  20. package/dist/acp-cli-DBWmJpUJ.js +924 -0
  21. package/dist/acp-cli-DG9nygBk.js +926 -0
  22. package/dist/agent-3MZVCC-N.js +702 -0
  23. package/dist/agent-IDE9krld.js +702 -0
  24. package/dist/agent-scope-DBl1We79.js +370 -0
  25. package/dist/agent-scope-DLfFOxP6.js +370 -0
  26. package/dist/agent-scope-e_oNRhGi.js +606 -0
  27. package/dist/archive-Dy3Ezb-5.js +85 -0
  28. package/dist/archive-iT9wNsml.js +85 -0
  29. package/dist/audit-Bj_dxNaD.js +1853 -0
  30. package/dist/audit-jaTyyQX1.js +1853 -0
  31. package/dist/auth-RTEHx2eI.js +192 -0
  32. package/dist/auth-health-BlspzqyF.js +149 -0
  33. package/dist/auth-health-CCM6Z3vK.js +149 -0
  34. package/dist/auth-phxCaFNX.js +192 -0
  35. package/dist/auth-profiles-DoD7YxsD.js +2939 -0
  36. package/dist/boolean-BsqeuxE6.js +30 -0
  37. package/dist/brew-CAcErcKz.js +46 -0
  38. package/dist/brew-CqnNFIkD.js +46 -0
  39. package/dist/build-info.json +5 -0
  40. package/dist/call-D2DXG0AC.js +278 -0
  41. package/dist/call-DqxlETxE.js +278 -0
  42. package/dist/canvas-host/a2ui/.bundle.hash +1 -0
  43. package/dist/canvas-host/a2ui/a2ui.bundle.js +17765 -0
  44. package/dist/canvas-host/a2ui/index.html +307 -0
  45. package/dist/channel-options-BHpXOBuP.js +32 -0
  46. package/dist/channel-options-DUkxROTo.js +62 -0
  47. package/dist/channel-selection-BdigfMZZ.js +51 -0
  48. package/dist/channel-selection-D7jFTFec.js +51 -0
  49. package/dist/channel-summary-CobMoKN6.js +1120 -0
  50. package/dist/channel-summary-DS0kcHm2.js +1120 -0
  51. package/dist/channels-cli-D7ZNRrq7.js +1414 -0
  52. package/dist/channels-cli-DBwffwqw.js +1413 -0
  53. package/dist/channels-status-issues-C2UGSPvH.js +18 -0
  54. package/dist/channels-status-issues-Dxmd7zYk.js +18 -0
  55. package/dist/chrome-CwbWzmh4.js +1973 -0
  56. package/dist/chrome-SVqOMFxA.js +1953 -0
  57. package/dist/clack-prompter-k_egRADS.js +92 -0
  58. package/dist/clack-prompter-nSmn5cZ2.js +92 -0
  59. package/dist/cli/daemon-cli.js +2 -0
  60. package/dist/cli-C9xiWnx9.js +86 -0
  61. package/dist/cli-D6C9z94O.js +88 -0
  62. package/dist/cli-utils-B7iQwCY5.js +43 -0
  63. package/dist/cli-utils-CgOu3WAB.js +43 -0
  64. package/dist/client-BaTYzXOU.js +1617 -0
  65. package/dist/client-N6zH1neq.js +1617 -0
  66. package/dist/command-format-9IsYy-9N.js +52 -0
  67. package/dist/command-format-B0bnyrEA.js +38 -0
  68. package/dist/command-format-n_udBm8l.js +52 -0
  69. package/dist/command-options-DL1PhuUF.js +33 -0
  70. package/dist/commands-Dpeoos11.js +230 -0
  71. package/dist/completion-cli-B5nR7jt8.js +434 -0
  72. package/dist/completion-cli-CZ8zPqPs.js +773 -0
  73. package/dist/config-DSpb2aMV.js +4916 -0
  74. package/dist/config-IwiWafT3.js +5657 -0
  75. package/dist/config-dQK4rbfx.js +4916 -0
  76. package/dist/config-guard-DwIb5Y-v.js +5719 -0
  77. package/dist/configure-7M9mLC4o.js +896 -0
  78. package/dist/configure-CivCcvkA.js +896 -0
  79. package/dist/constants-C2T4hQIk.js +65 -0
  80. package/dist/constants-DBvu3LzZ.js +65 -0
  81. package/dist/control-service-BXC31sNw.js +61 -0
  82. package/dist/control-service-lVzEzp9f.js +61 -0
  83. package/dist/control-ui/apple-touch-icon.png +0 -0
  84. package/dist/control-ui/assets/index-DQ-7PWhX.js +7553 -0
  85. package/dist/control-ui/assets/index-DQ-7PWhX.js.map +1 -0
  86. package/dist/control-ui/assets/index-nlpH70Eh.css +1 -0
  87. package/dist/control-ui/favicon-32.png +0 -0
  88. package/dist/control-ui/favicon.ico +0 -0
  89. package/dist/control-ui/favicon.svg +22 -0
  90. package/dist/control-ui/index.html +17 -0
  91. package/dist/cron-cli-DS8ytfYQ.js +455 -0
  92. package/dist/cron-cli-Djb3HUdz.js +457 -0
  93. package/dist/daemon-cli-KoaJ2nJX.js +758 -0
  94. package/dist/daemon-cli-ZQIKLvAO.js +758 -0
  95. package/dist/daemon-runtime-CHWbAfKs.js +517 -0
  96. package/dist/daemon-runtime-DEjUQVjL.js +517 -0
  97. package/dist/deliver-DVRzRmNN.js +2557 -0
  98. package/dist/deliver-OfX6bSYR.js +2587 -0
  99. package/dist/deliver-sPBfRlXT.js +2587 -0
  100. package/dist/deps-BSdWD2wF.js +27 -0
  101. package/dist/deps-CZOfeWEp.js +27 -0
  102. package/dist/devices-cli-DHSpDnCS.js +207 -0
  103. package/dist/devices-cli-b9iF_uOi.js +205 -0
  104. package/dist/directory-cli-D0dTuAem.js +247 -0
  105. package/dist/directory-cli-qniSxsHo.js +245 -0
  106. package/dist/dispatcher-DA3u3CwV.js +160 -0
  107. package/dist/dns-cli-C0JUNb9O.js +201 -0
  108. package/dist/dns-cli-DwwMpMuN.js +199 -0
  109. package/dist/docs-cli-BlFHCHDz.js +161 -0
  110. package/dist/docs-cli-BpSPrY3Y.js +160 -0
  111. package/dist/doctor-Da1XgFcW.js +2584 -0
  112. package/dist/doctor-qrtookj-.js +2585 -0
  113. package/dist/entry.js +1156 -0
  114. package/dist/env-B2Cd_6IS.js +32 -0
  115. package/dist/errors--S5IAxQx.js +1952 -0
  116. package/dist/exec-CLQSz0CI.js +246 -0
  117. package/dist/exec-CW_QjkBi.js +246 -0
  118. package/dist/exec-D7I5LU33.js +1099 -0
  119. package/dist/exec-approvals-CuXem6Li.js +1043 -0
  120. package/dist/exec-approvals-P7vwSw4O.js +1043 -0
  121. package/dist/exec-approvals-cli-Csgqkksl.js +386 -0
  122. package/dist/exec-approvals-cli-Dk4yHE2L.js +388 -0
  123. package/dist/extensionAPI.js +64497 -0
  124. package/dist/format-B7OjpGnt.js +34 -0
  125. package/dist/format-Dv1wz41T.js +34 -0
  126. package/dist/gateway-cli-CJ7H2DgV.js +17352 -0
  127. package/dist/gateway-cli-CrKl-bIH.js +17352 -0
  128. package/dist/gateway-rpc--CH0NWWR.js +28 -0
  129. package/dist/gateway-rpc-BPfCU2Vi.js +28 -0
  130. package/dist/github-copilot-auth-CcPEEb3Q.js +1190 -0
  131. package/dist/github-copilot-auth-h3beCc_l.js +1190 -0
  132. package/dist/github-copilot-token-C1sArkX4.js +103 -0
  133. package/dist/github-copilot-token-DL6Pou2p.js +103 -0
  134. package/dist/github-copilot-token-hMl1wyZp.js +103 -0
  135. package/dist/gmail-setup-utils-CnVYPhaQ.js +428 -0
  136. package/dist/gmail-setup-utils-pZ9NnOvB.js +428 -0
  137. package/dist/health-format-BcsR5dtU.js +1211 -0
  138. package/dist/health-format-Pl8qK65t.js +1212 -0
  139. package/dist/help-format-BzWwbeSF.js +17 -0
  140. package/dist/help-format-CUnac_bT.js +17 -0
  141. package/dist/helpers-5yebzF4C.js +25 -0
  142. package/dist/helpers-CQI-5xS9.js +25 -0
  143. package/dist/helpers-CzQjTUbz.js +10 -0
  144. package/dist/helpers-OUt4hxkS.js +10 -0
  145. package/dist/hooks/bundled/boot-md/HOOK.md +19 -0
  146. package/dist/hooks/bundled/command-logger/HOOK.md +122 -0
  147. package/dist/hooks/bundled/session-memory/HOOK.md +109 -0
  148. package/dist/hooks/bundled/soul-evil/HOOK.md +71 -0
  149. package/dist/hooks-cli-BKHTdsn4.js +1058 -0
  150. package/dist/hooks-cli-zkLY25DX.js +1060 -0
  151. package/dist/hooks-status-BETsyuUR.js +443 -0
  152. package/dist/hooks-status-nPgxLL-x.js +443 -0
  153. package/dist/image-BFNcQzKp.js +629 -0
  154. package/dist/image-CC_YKDB-.js +1421 -0
  155. package/dist/image-DAsWVn7Q.js +629 -0
  156. package/dist/index.js +5900 -0
  157. package/dist/installs-Byb3s_8P.js +425 -0
  158. package/dist/installs-CELeuogN.js +425 -0
  159. package/dist/is-main-B6kCyqsv.js +25 -0
  160. package/dist/is-main-CBExsRNQ.js +25 -0
  161. package/dist/links-Brcj2Oc-.js +15 -0
  162. package/dist/links-cf9h8BXu.js +15 -0
  163. package/dist/loader-CU4bkeKe.js +61131 -0
  164. package/dist/logging-5MtSkLpb.js +1 -0
  165. package/dist/logging-BJRQDTME.js +15 -0
  166. package/dist/logging-CD55MXc7.js +15 -0
  167. package/dist/logging-kuFzZMsG.js +1 -0
  168. package/dist/login-qr-BCr2GKX6.js +475 -0
  169. package/dist/login-qr-BMbekoZW.js +478 -0
  170. package/dist/login-qr-HIPJAnbT.js +478 -0
  171. package/dist/logs-cli-CM7-XOcZ.js +230 -0
  172. package/dist/logs-cli-aqjT7oHu.js +228 -0
  173. package/dist/manager-C5m5qpB0.js +2871 -0
  174. package/dist/manager-CtGvmGvM.js +2872 -0
  175. package/dist/manager-DpZlm3gk.js +2870 -0
  176. package/dist/manifest-registry-BdTzIlta.js +669 -0
  177. package/dist/manifest-registry-DVQHMj0y.js +669 -0
  178. package/dist/message-channel-CfYBy4y3.js +110 -0
  179. package/dist/message-channel-CvHWS3C2.js +110 -0
  180. package/dist/model-selection-Av0fLq51.js +2940 -0
  181. package/dist/model-selection-DuI_Ue9Q.js +2691 -0
  182. package/dist/models-cli-C0JOZ5oP.js +2541 -0
  183. package/dist/models-cli-gmkzOpbq.js +2543 -0
  184. package/dist/net-D4G66Xui.js +137 -0
  185. package/dist/net-YrbuVTd2.js +137 -0
  186. package/dist/node-cli-BND9LLkM.js +1457 -0
  187. package/dist/node-cli-DNRB94ib.js +1459 -0
  188. package/dist/node-service-DTgDFo7M.js +67 -0
  189. package/dist/node-service-JEBcPQat.js +67 -0
  190. package/dist/nodes-cli-BCWlqHyR.js +1208 -0
  191. package/dist/nodes-cli-DWSo5dX7.js +1210 -0
  192. package/dist/nodes-screen-CMvShBEB.js +157 -0
  193. package/dist/nodes-screen-Cok3-EJw.js +157 -0
  194. package/dist/note-C5M2AQOP.js +73 -0
  195. package/dist/note-DEz9ZK7G.js +73 -0
  196. package/dist/onboard-channels-B75LjjVZ.js +671 -0
  197. package/dist/onboard-channels-DJz2TusQ.js +671 -0
  198. package/dist/onboard-skills-ByHkU9nx.js +3615 -0
  199. package/dist/onboard-skills-Wknr7pxR.js +3615 -0
  200. package/dist/onboarding-BejDjkx5.js +3455 -0
  201. package/dist/openclaw-root-YSGWCNem.js +84 -0
  202. package/dist/openclaw-root-_zPXSqgo.js +84 -0
  203. package/dist/pairing-cli-CFqD3IdI.js +122 -0
  204. package/dist/pairing-cli-Cn5vt4oI.js +120 -0
  205. package/dist/pairing-store-BHzy16_t.js +391 -0
  206. package/dist/pairing-store-BOhO49Bi.js +391 -0
  207. package/dist/parse-BZz5lHzQ.js +23 -0
  208. package/dist/parse-Bw0oH-rT.js +23 -0
  209. package/dist/parse-log-line-BxDgv4Uo.js +44 -0
  210. package/dist/parse-log-line-CUrpqe1w.js +44 -0
  211. package/dist/parse-timeout-D1XX_zN_.js +16 -0
  212. package/dist/parse-timeout-Du-wHHNi.js +16 -0
  213. package/dist/path-env-DQ-mM2ya.js +77 -0
  214. package/dist/path-env-eQ-HoQtS.js +77 -0
  215. package/dist/paths-C3yk0MGu.js +43 -0
  216. package/dist/paths-C90k-Dud.js +166 -0
  217. package/dist/paths-CGrNQEMk.js +201 -0
  218. package/dist/paths-D2ytuv-2.js +201 -0
  219. package/dist/paths-Dlp4VNXa.js +40 -0
  220. package/dist/paths-KUslkJRs.js +43 -0
  221. package/dist/pi-embedded-helpers-B7ARjDEK.js +1298 -0
  222. package/dist/pi-embedded-helpers-CQ9sq3Uu.js +8475 -0
  223. package/dist/pi-embedded-helpers-FPVRDeKf.js +1298 -0
  224. package/dist/pi-model-discovery-DWTTaAgY.js +20 -0
  225. package/dist/pi-model-discovery-EhM2JAQo.js +20 -0
  226. package/dist/pi-model-discovery-EwKVHlZB.js +20 -0
  227. package/dist/pi-tools.policy-Du4RZy9R.js +230 -0
  228. package/dist/plugin-auto-enable-EBxTHjFJ.js +461 -0
  229. package/dist/plugin-auto-enable-RwRwIUKC.js +461 -0
  230. package/dist/plugin-sdk/index.d.ts +8453 -0
  231. package/dist/plugin-sdk/index.js +23445 -0
  232. package/dist/plugin-sdk/pi-model-discovery-Dw3A6oXH.js +37 -0
  233. package/dist/plugins-BI-p2ba9.js +495 -0
  234. package/dist/plugins-Dk4UBZwz.js +496 -0
  235. package/dist/plugins-cli-CMg0G56J.js +441 -0
  236. package/dist/plugins-cli-CX7QeUjq.js +443 -0
  237. package/dist/ports-nXmd4Efh.js +96 -0
  238. package/dist/program-EAMJAB_2.js +191 -0
  239. package/dist/progress-D-Oc-KAH.js +133 -0
  240. package/dist/progress-DTEUicRP.js +133 -0
  241. package/dist/prompt-style-BBlJlXtd.js +9 -0
  242. package/dist/prompt-style-BntC_Eoo.js +9 -0
  243. package/dist/prompts-C2D9_VZC.js +10 -0
  244. package/dist/prompts-FbZThK8w.js +10 -0
  245. package/dist/pw-ai-D2jD_dho.js +1651 -0
  246. package/dist/pw-ai-D6JUaD41.js +1650 -0
  247. package/dist/pw-ai-ba2bHPGA.js +1649 -0
  248. package/dist/qmd-manager-B-ijyM7o.js +615 -0
  249. package/dist/qmd-manager-C_Jah5eo.js +618 -0
  250. package/dist/qmd-manager-xo4abL0u.js +618 -0
  251. package/dist/redact-1PNP01B_.js +97 -0
  252. package/dist/redact-BIMJ3ntQ.js +94 -0
  253. package/dist/redact-CVRUv382.js +97 -0
  254. package/dist/register.subclis-CJGimm3-.js +348 -0
  255. package/dist/reply-DfepuqG0.js +61133 -0
  256. package/dist/rolldown-runtime-Cbj13DAv.js +20 -0
  257. package/dist/routes-DkckwrRx.js +2410 -0
  258. package/dist/routes-Q42qtNl1.js +2410 -0
  259. package/dist/rpc-B4lvrGrD.js +95 -0
  260. package/dist/rpc-CbWcXAQK.js +95 -0
  261. package/dist/run-main-JFY3X4Xh.js +194 -0
  262. package/dist/sandbox-BGqDfFaH.js +2945 -0
  263. package/dist/sandbox-D_Tt3WRq.js +2945 -0
  264. package/dist/sandbox-cli-CaxqKiTq.js +461 -0
  265. package/dist/sandbox-cli-DA0Cbrzl.js +463 -0
  266. package/dist/security-cli-BZjA_GAD.js +508 -0
  267. package/dist/security-cli-Ct-pfF2h.js +506 -0
  268. package/dist/server-context-B9ez46MY.js +740 -0
  269. package/dist/server-context-C53lhEx_.js +740 -0
  270. package/dist/server-node-events-Cb6QOeDH.js +218 -0
  271. package/dist/server-node-events-DONmQvJg.js +216 -0
  272. package/dist/service-C0ccl5rU.js +680 -0
  273. package/dist/service-audit-AsnhO40e.js +542 -0
  274. package/dist/service-audit-BM-iyLL7.js +542 -0
  275. package/dist/service-mrQPgOXl.js +680 -0
  276. package/dist/session-cost-usage-B3HzifR9.js +692 -0
  277. package/dist/session-cost-usage-DH3c4xJA.js +692 -0
  278. package/dist/session-key-C-ig2pxJ.js +177 -0
  279. package/dist/session-key-CYpWeuht.js +177 -0
  280. package/dist/shared-CBcCIWC0.js +74 -0
  281. package/dist/shared-CtNMbLRE.js +150 -0
  282. package/dist/shared-DCh7fkR2.js +150 -0
  283. package/dist/shared-Na5zjEUc.js +74 -0
  284. package/dist/skill-scanner-AfOudYI1.js +255 -0
  285. package/dist/skill-scanner-BoGjHXUZ.js +255 -0
  286. package/dist/skills-7V483a6m.js +693 -0
  287. package/dist/skills-CsZRBUj0.js +694 -0
  288. package/dist/skills-cli-DQaq5LBX.js +290 -0
  289. package/dist/skills-cli-dVugbaAb.js +288 -0
  290. package/dist/skills-status-4_4zVBvV.js +187 -0
  291. package/dist/skills-status-cD4rfMR9.js +187 -0
  292. package/dist/sqlite-C4DljFNL.js +215 -0
  293. package/dist/sqlite-CvQzxS7q.js +197 -0
  294. package/dist/sqlite-Dnmf3LS7.js +215 -0
  295. package/dist/status-BakhDLuG.js +27 -0
  296. package/dist/status-BqtiImKF.js +21 -0
  297. package/dist/status-DHPz4Mg_.js +3364 -0
  298. package/dist/status-DSoYX3Ep.js +27 -0
  299. package/dist/status-Drziap9H.js +21 -0
  300. package/dist/subsystem-Btuh5yZj.js +834 -0
  301. package/dist/system-cli-CUQswQPX.js +83 -0
  302. package/dist/system-cli-Cz7in_Xr.js +81 -0
  303. package/dist/systemd-CFHiVC1D.js +438 -0
  304. package/dist/systemd-hints-CgQqk98i.js +19 -0
  305. package/dist/systemd-hints-DKVCFZS3.js +19 -0
  306. package/dist/systemd-kY3NnWdi.js +438 -0
  307. package/dist/systemd-linger-CFK5jDdq.js +75 -0
  308. package/dist/systemd-linger-CxBBzOjC.js +75 -0
  309. package/dist/table-DAOPkdc_.js +279 -0
  310. package/dist/table-DDQGlZSe.js +279 -0
  311. package/dist/tailnet-CZq_ZSNX.js +42 -0
  312. package/dist/tailnet-D5wOWpOX.js +42 -0
  313. package/dist/tailscale-BY0igR48.js +252 -0
  314. package/dist/tailscale-CCLcQalf.js +225 -0
  315. package/dist/tool-display-B2rS2o6B.js +795 -0
  316. package/dist/tool-display-Zbh1CRw5.js +795 -0
  317. package/dist/transcript-events-BOK6eOU8.js +17 -0
  318. package/dist/transcript-events-D2kT5WSz.js +17 -0
  319. package/dist/transcript-events-JLH5W4He.js +17 -0
  320. package/dist/tui-DFVs6pRO.js +2672 -0
  321. package/dist/tui-cli-CBKZVd1C.js +58 -0
  322. package/dist/tui-cli-DexeJOgZ.js +56 -0
  323. package/dist/tui-qPHLsB-x.js +2672 -0
  324. package/dist/update-B2q3duJD.js +317 -0
  325. package/dist/update-DNnej3C6.js +317 -0
  326. package/dist/update-cli-BPUtZjbl.js +1031 -0
  327. package/dist/update-cli-ehTYbpaU.js +1032 -0
  328. package/dist/update-runner-BfncKnU6.js +1375 -0
  329. package/dist/update-runner-DAeygRSU.js +1375 -0
  330. package/dist/usage-format-C4JfTbSp.js +36 -0
  331. package/dist/usage-format-DvowRSs-.js +36 -0
  332. package/dist/utils-7IMqr8vR.js +189 -0
  333. package/dist/utils-D7jskKIf.js +192 -0
  334. package/dist/wallet-manager-7KHKMCbT.js +264 -0
  335. package/dist/wallet-manager-CT1ykq2O.js +264 -0
  336. package/dist/webhooks-cli-C0CV-1jG.js +310 -0
  337. package/dist/webhooks-cli-DT16BygW.js +312 -0
  338. package/dist/widearea-dns-BJZTAyT3.js +127 -0
  339. package/dist/widearea-dns-Dk82I4Xa.js +127 -0
  340. package/dist/ws-6_dFpKWQ.js +13 -0
  341. package/dist/ws-D64QKPe6.js +13 -0
  342. package/dist/ws-log-BhQmGM0R.js +267 -0
  343. package/dist/ws-log-DsyLcTqD.js +267 -0
  344. package/dist/wsl-C24YfxH9.js +160 -0
  345. package/docs/.i18n/README.md +31 -0
  346. package/docs/.i18n/glossary.zh-CN.json +210 -0
  347. package/docs/.i18n/zh-CN.tm.jsonl +1329 -0
  348. package/docs/CNAME +1 -0
  349. package/docs/assets/macos-onboarding/01-macos-warning.jpeg +0 -0
  350. package/docs/assets/macos-onboarding/02-local-networks.jpeg +0 -0
  351. package/docs/assets/macos-onboarding/03-security-notice.png +0 -0
  352. package/docs/assets/macos-onboarding/04-choose-gateway.png +0 -0
  353. package/docs/assets/macos-onboarding/05-permissions.png +0 -0
  354. package/docs/assets/openclaw-logo-text-dark.png +0 -0
  355. package/docs/assets/openclaw-logo-text.png +0 -0
  356. package/docs/assets/pixel-lobster.svg +60 -0
  357. package/docs/assets/showcase/agents-ui.jpg +0 -0
  358. package/docs/assets/showcase/bambu-cli.png +0 -0
  359. package/docs/assets/showcase/codexmonitor.png +0 -0
  360. package/docs/assets/showcase/gohome-grafana.png +0 -0
  361. package/docs/assets/showcase/ios-testflight.jpg +0 -0
  362. package/docs/assets/showcase/oura-health.png +0 -0
  363. package/docs/assets/showcase/padel-cli.svg +11 -0
  364. package/docs/assets/showcase/padel-screenshot.jpg +0 -0
  365. package/docs/assets/showcase/papla-tts.jpg +0 -0
  366. package/docs/assets/showcase/pr-review-telegram.jpg +0 -0
  367. package/docs/assets/showcase/roborock-screenshot.jpg +0 -0
  368. package/docs/assets/showcase/roborock-status.svg +13 -0
  369. package/docs/assets/showcase/roof-camera-sky.jpg +0 -0
  370. package/docs/assets/showcase/snag.png +0 -0
  371. package/docs/assets/showcase/tesco-shop.jpg +0 -0
  372. package/docs/assets/showcase/wienerlinien.png +0 -0
  373. package/docs/assets/showcase/wine-cellar-skill.jpg +0 -0
  374. package/docs/assets/showcase/winix-air-purifier.jpg +0 -0
  375. package/docs/assets/showcase/xuezh-pronunciation.jpeg +0 -0
  376. package/docs/automation/auth-monitoring.md +44 -0
  377. package/docs/automation/cron-jobs.md +468 -0
  378. package/docs/automation/cron-vs-heartbeat.md +282 -0
  379. package/docs/automation/gmail-pubsub.md +256 -0
  380. package/docs/automation/poll.md +69 -0
  381. package/docs/automation/webhook.md +163 -0
  382. package/docs/bedrock.md +176 -0
  383. package/docs/brave-search.md +41 -0
  384. package/docs/broadcast-groups.md +442 -0
  385. package/docs/channels/bluebubbles.md +338 -0
  386. package/docs/channels/discord.md +476 -0
  387. package/docs/channels/feishu.md +577 -0
  388. package/docs/channels/googlechat.md +250 -0
  389. package/docs/channels/grammy.md +31 -0
  390. package/docs/channels/imessage.md +299 -0
  391. package/docs/channels/index.md +46 -0
  392. package/docs/channels/line.md +186 -0
  393. package/docs/channels/location.md +56 -0
  394. package/docs/channels/matrix.md +233 -0
  395. package/docs/channels/mattermost.md +138 -0
  396. package/docs/channels/msteams.md +768 -0
  397. package/docs/channels/nextcloud-talk.md +136 -0
  398. package/docs/channels/nostr.md +233 -0
  399. package/docs/channels/signal.md +202 -0
  400. package/docs/channels/slack.md +548 -0
  401. package/docs/channels/telegram.md +769 -0
  402. package/docs/channels/tlon.md +132 -0
  403. package/docs/channels/troubleshooting.md +29 -0
  404. package/docs/channels/twitch.md +379 -0
  405. package/docs/channels/whatsapp.md +404 -0
  406. package/docs/channels/zalo.md +189 -0
  407. package/docs/channels/zalouser.md +140 -0
  408. package/docs/cli/acp.md +170 -0
  409. package/docs/cli/agent.md +24 -0
  410. package/docs/cli/agents.md +75 -0
  411. package/docs/cli/approvals.md +50 -0
  412. package/docs/cli/browser.md +107 -0
  413. package/docs/cli/channels.md +79 -0
  414. package/docs/cli/config.md +50 -0
  415. package/docs/cli/configure.md +33 -0
  416. package/docs/cli/cron.md +42 -0
  417. package/docs/cli/dashboard.md +16 -0
  418. package/docs/cli/devices.md +70 -0
  419. package/docs/cli/directory.md +63 -0
  420. package/docs/cli/dns.md +23 -0
  421. package/docs/cli/docs.md +15 -0
  422. package/docs/cli/doctor.md +41 -0
  423. package/docs/cli/gateway.md +202 -0
  424. package/docs/cli/health.md +21 -0
  425. package/docs/cli/hooks.md +304 -0
  426. package/docs/cli/index.md +1031 -0
  427. package/docs/cli/logs.md +24 -0
  428. package/docs/cli/memory.md +45 -0
  429. package/docs/cli/message.md +239 -0
  430. package/docs/cli/models.md +79 -0
  431. package/docs/cli/node.md +112 -0
  432. package/docs/cli/nodes.md +73 -0
  433. package/docs/cli/onboard.md +43 -0
  434. package/docs/cli/pairing.md +21 -0
  435. package/docs/cli/plugins.md +62 -0
  436. package/docs/cli/reset.md +17 -0
  437. package/docs/cli/sandbox.md +152 -0
  438. package/docs/cli/security.md +26 -0
  439. package/docs/cli/sessions.md +16 -0
  440. package/docs/cli/setup.md +29 -0
  441. package/docs/cli/skills.md +26 -0
  442. package/docs/cli/status.md +26 -0
  443. package/docs/cli/system.md +60 -0
  444. package/docs/cli/tui.md +23 -0
  445. package/docs/cli/uninstall.md +17 -0
  446. package/docs/cli/update.md +98 -0
  447. package/docs/cli/voicecall.md +34 -0
  448. package/docs/cli/webhooks.md +25 -0
  449. package/docs/concepts/agent-loop.md +146 -0
  450. package/docs/concepts/agent-workspace.md +233 -0
  451. package/docs/concepts/agent.md +123 -0
  452. package/docs/concepts/architecture.md +129 -0
  453. package/docs/concepts/channel-routing.md +114 -0
  454. package/docs/concepts/compaction.md +61 -0
  455. package/docs/concepts/context.md +161 -0
  456. package/docs/concepts/features.md +53 -0
  457. package/docs/concepts/group-messages.md +84 -0
  458. package/docs/concepts/groups.md +373 -0
  459. package/docs/concepts/markdown-formatting.md +130 -0
  460. package/docs/concepts/memory.md +546 -0
  461. package/docs/concepts/messages.md +154 -0
  462. package/docs/concepts/model-failover.md +149 -0
  463. package/docs/concepts/model-providers.md +316 -0
  464. package/docs/concepts/models.md +208 -0
  465. package/docs/concepts/multi-agent.md +376 -0
  466. package/docs/concepts/oauth.md +145 -0
  467. package/docs/concepts/presence.md +102 -0
  468. package/docs/concepts/queue.md +89 -0
  469. package/docs/concepts/retry.md +69 -0
  470. package/docs/concepts/session-pruning.md +122 -0
  471. package/docs/concepts/session-tool.md +193 -0
  472. package/docs/concepts/session.md +204 -0
  473. package/docs/concepts/sessions.md +10 -0
  474. package/docs/concepts/streaming.md +135 -0
  475. package/docs/concepts/system-prompt.md +115 -0
  476. package/docs/concepts/timezone.md +91 -0
  477. package/docs/concepts/typebox.md +289 -0
  478. package/docs/concepts/typing-indicators.md +68 -0
  479. package/docs/concepts/usage-tracking.md +35 -0
  480. package/docs/date-time.md +128 -0
  481. package/docs/debug/node-issue.md +83 -0
  482. package/docs/debugging.md +162 -0
  483. package/docs/diagnostics/flags.md +91 -0
  484. package/docs/docs.json +1736 -0
  485. package/docs/environment.md +81 -0
  486. package/docs/experiments/onboarding-config-protocol.md +40 -0
  487. package/docs/experiments/plans/cron-add-hardening.md +63 -0
  488. package/docs/experiments/plans/group-policy-hardening.md +40 -0
  489. package/docs/experiments/plans/openresponses-gateway.md +123 -0
  490. package/docs/experiments/proposals/model-config.md +36 -0
  491. package/docs/experiments/research/memory.md +228 -0
  492. package/docs/gateway/authentication.md +145 -0
  493. package/docs/gateway/background-process.md +93 -0
  494. package/docs/gateway/bonjour.md +167 -0
  495. package/docs/gateway/bridge-protocol.md +89 -0
  496. package/docs/gateway/cli-backends.md +225 -0
  497. package/docs/gateway/configuration-examples.md +606 -0
  498. package/docs/gateway/configuration.md +3411 -0
  499. package/docs/gateway/discovery.md +116 -0
  500. package/docs/gateway/doctor.md +282 -0
  501. package/docs/gateway/gateway-lock.md +34 -0
  502. package/docs/gateway/health.md +35 -0
  503. package/docs/gateway/heartbeat.md +362 -0
  504. package/docs/gateway/index.md +328 -0
  505. package/docs/gateway/local-models.md +150 -0
  506. package/docs/gateway/logging.md +113 -0
  507. package/docs/gateway/multiple-gateways.md +112 -0
  508. package/docs/gateway/network-model.md +17 -0
  509. package/docs/gateway/openai-http-api.md +118 -0
  510. package/docs/gateway/openresponses-http-api.md +317 -0
  511. package/docs/gateway/pairing.md +99 -0
  512. package/docs/gateway/protocol.md +221 -0
  513. package/docs/gateway/remote-gateway-readme.md +157 -0
  514. package/docs/gateway/remote.md +129 -0
  515. package/docs/gateway/sandbox-vs-tool-policy-vs-elevated.md +128 -0
  516. package/docs/gateway/sandboxing.md +193 -0
  517. package/docs/gateway/security/formal-verification.md +164 -0
  518. package/docs/gateway/security/index.md +825 -0
  519. package/docs/gateway/tailscale.md +127 -0
  520. package/docs/gateway/tools-invoke-http-api.md +85 -0
  521. package/docs/gateway/troubleshooting.md +767 -0
  522. package/docs/help/faq.md +2829 -0
  523. package/docs/help/index.md +21 -0
  524. package/docs/help/troubleshooting.md +98 -0
  525. package/docs/hooks/soul-evil.md +69 -0
  526. package/docs/hooks.md +913 -0
  527. package/docs/images/feishu-step2-create-app.png +0 -0
  528. package/docs/images/feishu-step3-credentials.png +0 -0
  529. package/docs/images/feishu-step4-permissions.png +0 -0
  530. package/docs/images/feishu-step5-bot-capability.png +0 -0
  531. package/docs/images/feishu-step6-event-subscription.png +0 -0
  532. package/docs/images/groups-flow.svg +52 -0
  533. package/docs/images/mobile-ui-screenshot.png +0 -0
  534. package/docs/index.md +192 -0
  535. package/docs/install/ansible.md +208 -0
  536. package/docs/install/bun.md +59 -0
  537. package/docs/install/development-channels.md +75 -0
  538. package/docs/install/docker.md +567 -0
  539. package/docs/install/exe-dev.md +126 -0
  540. package/docs/install/fly.md +486 -0
  541. package/docs/install/gcp.md +503 -0
  542. package/docs/install/hetzner.md +330 -0
  543. package/docs/install/index.md +187 -0
  544. package/docs/install/installer.md +123 -0
  545. package/docs/install/macos-vm.md +281 -0
  546. package/docs/install/migrating.md +192 -0
  547. package/docs/install/nix.md +96 -0
  548. package/docs/install/node.md +78 -0
  549. package/docs/install/northflank.mdx +53 -0
  550. package/docs/install/railway.mdx +99 -0
  551. package/docs/install/render.mdx +165 -0
  552. package/docs/install/uninstall.md +128 -0
  553. package/docs/install/updating.md +228 -0
  554. package/docs/logging.md +350 -0
  555. package/docs/multi-agent-sandbox-tools.md +395 -0
  556. package/docs/network.md +54 -0
  557. package/docs/nodes/audio.md +114 -0
  558. package/docs/nodes/camera.md +156 -0
  559. package/docs/nodes/images.md +72 -0
  560. package/docs/nodes/index.md +341 -0
  561. package/docs/nodes/location-command.md +113 -0
  562. package/docs/nodes/media-understanding.md +379 -0
  563. package/docs/nodes/talk.md +90 -0
  564. package/docs/nodes/voicewake.md +65 -0
  565. package/docs/perplexity.md +80 -0
  566. package/docs/pi-dev.md +70 -0
  567. package/docs/pi.md +612 -0
  568. package/docs/platforms/android.md +148 -0
  569. package/docs/platforms/digitalocean.md +262 -0
  570. package/docs/platforms/index.md +53 -0
  571. package/docs/platforms/ios.md +107 -0
  572. package/docs/platforms/linux.md +94 -0
  573. package/docs/platforms/mac/bundled-gateway.md +73 -0
  574. package/docs/platforms/mac/canvas.md +125 -0
  575. package/docs/platforms/mac/child-process.md +69 -0
  576. package/docs/platforms/mac/dev-setup.md +102 -0
  577. package/docs/platforms/mac/health.md +34 -0
  578. package/docs/platforms/mac/icon.md +31 -0
  579. package/docs/platforms/mac/logging.md +57 -0
  580. package/docs/platforms/mac/menu-bar.md +81 -0
  581. package/docs/platforms/mac/peekaboo.md +65 -0
  582. package/docs/platforms/mac/permissions.md +44 -0
  583. package/docs/platforms/mac/release.md +85 -0
  584. package/docs/platforms/mac/remote.md +83 -0
  585. package/docs/platforms/mac/signing.md +47 -0
  586. package/docs/platforms/mac/skills.md +33 -0
  587. package/docs/platforms/mac/voice-overlay.md +60 -0
  588. package/docs/platforms/mac/voicewake.md +67 -0
  589. package/docs/platforms/mac/webchat.md +41 -0
  590. package/docs/platforms/mac/xpc.md +61 -0
  591. package/docs/platforms/macos.md +203 -0
  592. package/docs/platforms/oracle.md +303 -0
  593. package/docs/platforms/raspberry-pi.md +358 -0
  594. package/docs/platforms/windows.md +159 -0
  595. package/docs/plugin.md +664 -0
  596. package/docs/plugins/agent-tools.md +99 -0
  597. package/docs/plugins/manifest.md +71 -0
  598. package/docs/plugins/voice-call.md +284 -0
  599. package/docs/plugins/zalouser.md +81 -0
  600. package/docs/prose.md +134 -0
  601. package/docs/providers/anthropic.md +152 -0
  602. package/docs/providers/claude-max-api-proxy.md +148 -0
  603. package/docs/providers/cloudflare-ai-gateway.md +71 -0
  604. package/docs/providers/deepgram.md +93 -0
  605. package/docs/providers/github-copilot.md +72 -0
  606. package/docs/providers/glm.md +33 -0
  607. package/docs/providers/index.md +63 -0
  608. package/docs/providers/minimax.md +208 -0
  609. package/docs/providers/models.md +51 -0
  610. package/docs/providers/moonshot.md +142 -0
  611. package/docs/providers/ollama.md +277 -0
  612. package/docs/providers/openai.md +62 -0
  613. package/docs/providers/opencode.md +36 -0
  614. package/docs/providers/openrouter.md +37 -0
  615. package/docs/providers/qwen.md +53 -0
  616. package/docs/providers/synthetic.md +99 -0
  617. package/docs/providers/venice.md +267 -0
  618. package/docs/providers/vercel-ai-gateway.md +50 -0
  619. package/docs/providers/xiaomi.md +64 -0
  620. package/docs/providers/zai.md +36 -0
  621. package/docs/refactor/clawnet.md +417 -0
  622. package/docs/refactor/exec-host.md +316 -0
  623. package/docs/refactor/outbound-session-mirroring.md +85 -0
  624. package/docs/refactor/plugin-sdk.md +214 -0
  625. package/docs/refactor/strict-config.md +93 -0
  626. package/docs/reference/AGENTS.default.md +124 -0
  627. package/docs/reference/RELEASING.md +120 -0
  628. package/docs/reference/api-usage-costs.md +137 -0
  629. package/docs/reference/credits.md +27 -0
  630. package/docs/reference/device-models.md +47 -0
  631. package/docs/reference/rpc.md +43 -0
  632. package/docs/reference/session-management-compaction.md +285 -0
  633. package/docs/reference/templates/AGENTS.dev.md +83 -0
  634. package/docs/reference/templates/AGENTS.md +218 -0
  635. package/docs/reference/templates/BOOT.md +10 -0
  636. package/docs/reference/templates/BOOTSTRAP.md +61 -0
  637. package/docs/reference/templates/HEARTBEAT.md +11 -0
  638. package/docs/reference/templates/IDENTITY.dev.md +47 -0
  639. package/docs/reference/templates/IDENTITY.md +27 -0
  640. package/docs/reference/templates/SOUL.dev.md +76 -0
  641. package/docs/reference/templates/SOUL.md +42 -0
  642. package/docs/reference/templates/TOOLS.dev.md +24 -0
  643. package/docs/reference/templates/TOOLS.md +46 -0
  644. package/docs/reference/templates/USER.dev.md +18 -0
  645. package/docs/reference/templates/USER.md +22 -0
  646. package/docs/reference/test.md +50 -0
  647. package/docs/reference/transcript-hygiene.md +129 -0
  648. package/docs/reference/wizard.md +268 -0
  649. package/docs/scripts.md +28 -0
  650. package/docs/security/formal-verification.md +164 -0
  651. package/docs/start/bootstrapping.md +41 -0
  652. package/docs/start/docs-directory.md +64 -0
  653. package/docs/start/getting-started.md +120 -0
  654. package/docs/start/hubs.md +197 -0
  655. package/docs/start/lore.md +219 -0
  656. package/docs/start/onboarding.md +80 -0
  657. package/docs/start/openclaw.md +224 -0
  658. package/docs/start/pairing.md +86 -0
  659. package/docs/start/quickstart.md +22 -0
  660. package/docs/start/setup.md +162 -0
  661. package/docs/start/showcase.md +416 -0
  662. package/docs/start/wizard-cli-automation.md +141 -0
  663. package/docs/start/wizard-cli-reference.md +244 -0
  664. package/docs/start/wizard.md +108 -0
  665. package/docs/style.css +3 -0
  666. package/docs/testing.md +368 -0
  667. package/docs/token-use.md +112 -0
  668. package/docs/tools/agent-send.md +53 -0
  669. package/docs/tools/apply-patch.md +50 -0
  670. package/docs/tools/browser-linux-troubleshooting.md +139 -0
  671. package/docs/tools/browser-login.md +68 -0
  672. package/docs/tools/browser.md +576 -0
  673. package/docs/tools/chrome-extension.md +178 -0
  674. package/docs/tools/clawhub.md +257 -0
  675. package/docs/tools/creating-skills.md +54 -0
  676. package/docs/tools/elevated.md +57 -0
  677. package/docs/tools/exec-approvals.md +246 -0
  678. package/docs/tools/exec.md +179 -0
  679. package/docs/tools/firecrawl.md +61 -0
  680. package/docs/tools/index.md +512 -0
  681. package/docs/tools/llm-task.md +115 -0
  682. package/docs/tools/lobster.md +342 -0
  683. package/docs/tools/reactions.md +22 -0
  684. package/docs/tools/skills-config.md +76 -0
  685. package/docs/tools/skills.md +300 -0
  686. package/docs/tools/slash-commands.md +198 -0
  687. package/docs/tools/subagents.md +151 -0
  688. package/docs/tools/thinking.md +74 -0
  689. package/docs/tools/web.md +261 -0
  690. package/docs/tts.md +396 -0
  691. package/docs/tui.md +162 -0
  692. package/docs/vps.md +43 -0
  693. package/docs/web/control-ui.md +223 -0
  694. package/docs/web/dashboard.md +46 -0
  695. package/docs/web/index.md +116 -0
  696. package/docs/web/webchat.md +49 -0
  697. package/docs/whatsapp-openclaw-ai-zh.jpg +0 -0
  698. package/docs/whatsapp-openclaw.jpg +0 -0
  699. package/docs/zh-CN/AGENTS.md +59 -0
  700. package/docs/zh-CN/automation/auth-monitoring.md +47 -0
  701. package/docs/zh-CN/automation/cron-jobs.md +424 -0
  702. package/docs/zh-CN/automation/cron-vs-heartbeat.md +286 -0
  703. package/docs/zh-CN/automation/gmail-pubsub.md +249 -0
  704. package/docs/zh-CN/automation/poll.md +76 -0
  705. package/docs/zh-CN/automation/webhook.md +163 -0
  706. package/docs/zh-CN/bedrock.md +170 -0
  707. package/docs/zh-CN/brave-search.md +48 -0
  708. package/docs/zh-CN/broadcast-groups.md +449 -0
  709. package/docs/zh-CN/channels/bluebubbles.md +271 -0
  710. package/docs/zh-CN/channels/discord.md +468 -0
  711. package/docs/zh-CN/channels/feishu.md +629 -0
  712. package/docs/zh-CN/channels/googlechat.md +257 -0
  713. package/docs/zh-CN/channels/grammy.md +38 -0
  714. package/docs/zh-CN/channels/imessage.md +302 -0
  715. package/docs/zh-CN/channels/index.md +53 -0
  716. package/docs/zh-CN/channels/line.md +180 -0
  717. package/docs/zh-CN/channels/location.md +63 -0
  718. package/docs/zh-CN/channels/matrix.md +221 -0
  719. package/docs/zh-CN/channels/mattermost.md +144 -0
  720. package/docs/zh-CN/channels/msteams.md +775 -0
  721. package/docs/zh-CN/channels/nextcloud-talk.md +142 -0
  722. package/docs/zh-CN/channels/nostr.md +240 -0
  723. package/docs/zh-CN/channels/signal.md +209 -0
  724. package/docs/zh-CN/channels/slack.md +531 -0
  725. package/docs/zh-CN/channels/telegram.md +751 -0
  726. package/docs/zh-CN/channels/tlon.md +136 -0
  727. package/docs/zh-CN/channels/troubleshooting.md +36 -0
  728. package/docs/zh-CN/channels/twitch.md +385 -0
  729. package/docs/zh-CN/channels/whatsapp.md +411 -0
  730. package/docs/zh-CN/channels/zalo.md +196 -0
  731. package/docs/zh-CN/channels/zalouser.md +147 -0
  732. package/docs/zh-CN/cli/acp.md +173 -0
  733. package/docs/zh-CN/cli/agent.md +30 -0
  734. package/docs/zh-CN/cli/agents.md +82 -0
  735. package/docs/zh-CN/cli/approvals.md +57 -0
  736. package/docs/zh-CN/cli/browser.md +114 -0
  737. package/docs/zh-CN/cli/channels.md +86 -0
  738. package/docs/zh-CN/cli/config.md +57 -0
  739. package/docs/zh-CN/cli/configure.md +38 -0
  740. package/docs/zh-CN/cli/cron.md +43 -0
  741. package/docs/zh-CN/cli/dashboard.md +23 -0
  742. package/docs/zh-CN/cli/devices.md +74 -0
  743. package/docs/zh-CN/cli/directory.md +70 -0
  744. package/docs/zh-CN/cli/dns.md +30 -0
  745. package/docs/zh-CN/cli/docs.md +22 -0
  746. package/docs/zh-CN/cli/doctor.md +48 -0
  747. package/docs/zh-CN/cli/gateway.md +206 -0
  748. package/docs/zh-CN/cli/health.md +28 -0
  749. package/docs/zh-CN/cli/hooks.md +311 -0
  750. package/docs/zh-CN/cli/index.md +1032 -0
  751. package/docs/zh-CN/cli/logs.md +31 -0
  752. package/docs/zh-CN/cli/memory.md +52 -0
  753. package/docs/zh-CN/cli/message.md +246 -0
  754. package/docs/zh-CN/cli/models.md +85 -0
  755. package/docs/zh-CN/cli/node.md +115 -0
  756. package/docs/zh-CN/cli/nodes.md +80 -0
  757. package/docs/zh-CN/cli/onboard.md +36 -0
  758. package/docs/zh-CN/cli/pairing.md +28 -0
  759. package/docs/zh-CN/cli/plugins.md +66 -0
  760. package/docs/zh-CN/cli/reset.md +24 -0
  761. package/docs/zh-CN/cli/sandbox.md +158 -0
  762. package/docs/zh-CN/cli/security.md +33 -0
  763. package/docs/zh-CN/cli/sessions.md +23 -0
  764. package/docs/zh-CN/cli/setup.md +36 -0
  765. package/docs/zh-CN/cli/skills.md +33 -0
  766. package/docs/zh-CN/cli/status.md +33 -0
  767. package/docs/zh-CN/cli/system.md +63 -0
  768. package/docs/zh-CN/cli/tui.md +30 -0
  769. package/docs/zh-CN/cli/uninstall.md +24 -0
  770. package/docs/zh-CN/cli/update.md +101 -0
  771. package/docs/zh-CN/cli/voicecall.md +41 -0
  772. package/docs/zh-CN/cli/webhooks.md +32 -0
  773. package/docs/zh-CN/concepts/agent-loop.md +146 -0
  774. package/docs/zh-CN/concepts/agent-workspace.md +219 -0
  775. package/docs/zh-CN/concepts/agent.md +115 -0
  776. package/docs/zh-CN/concepts/architecture.md +123 -0
  777. package/docs/zh-CN/concepts/channel-routing.md +117 -0
  778. package/docs/zh-CN/concepts/compaction.md +67 -0
  779. package/docs/zh-CN/concepts/context.md +168 -0
  780. package/docs/zh-CN/concepts/features.md +59 -0
  781. package/docs/zh-CN/concepts/group-messages.md +91 -0
  782. package/docs/zh-CN/concepts/groups.md +379 -0
  783. package/docs/zh-CN/concepts/markdown-formatting.md +117 -0
  784. package/docs/zh-CN/concepts/memory.md +412 -0
  785. package/docs/zh-CN/concepts/messages.md +141 -0
  786. package/docs/zh-CN/concepts/model-failover.md +145 -0
  787. package/docs/zh-CN/concepts/model-providers.md +320 -0
  788. package/docs/zh-CN/concepts/models.md +196 -0
  789. package/docs/zh-CN/concepts/multi-agent.md +372 -0
  790. package/docs/zh-CN/concepts/oauth.md +151 -0
  791. package/docs/zh-CN/concepts/presence.md +99 -0
  792. package/docs/zh-CN/concepts/queue.md +94 -0
  793. package/docs/zh-CN/concepts/retry.md +76 -0
  794. package/docs/zh-CN/concepts/session-pruning.md +129 -0
  795. package/docs/zh-CN/concepts/session-tool.md +200 -0
  796. package/docs/zh-CN/concepts/session.md +166 -0
  797. package/docs/zh-CN/concepts/sessions.md +17 -0
  798. package/docs/zh-CN/concepts/streaming.md +133 -0
  799. package/docs/zh-CN/concepts/system-prompt.md +101 -0
  800. package/docs/zh-CN/concepts/timezone.md +96 -0
  801. package/docs/zh-CN/concepts/typebox.md +284 -0
  802. package/docs/zh-CN/concepts/typing-indicators.md +74 -0
  803. package/docs/zh-CN/concepts/usage-tracking.md +42 -0
  804. package/docs/zh-CN/date-time.md +129 -0
  805. package/docs/zh-CN/debug/node-issue.md +90 -0
  806. package/docs/zh-CN/debugging.md +160 -0
  807. package/docs/zh-CN/diagnostics/flags.md +98 -0
  808. package/docs/zh-CN/environment.md +88 -0
  809. package/docs/zh-CN/experiments/onboarding-config-protocol.md +47 -0
  810. package/docs/zh-CN/experiments/plans/cron-add-hardening.md +70 -0
  811. package/docs/zh-CN/experiments/plans/group-policy-hardening.md +45 -0
  812. package/docs/zh-CN/experiments/plans/openresponses-gateway.md +121 -0
  813. package/docs/zh-CN/experiments/proposals/model-config.md +42 -0
  814. package/docs/zh-CN/experiments/research/memory.md +235 -0
  815. package/docs/zh-CN/gateway/authentication.md +142 -0
  816. package/docs/zh-CN/gateway/background-process.md +100 -0
  817. package/docs/zh-CN/gateway/bonjour.md +174 -0
  818. package/docs/zh-CN/gateway/bridge-protocol.md +86 -0
  819. package/docs/zh-CN/gateway/cli-backends.md +213 -0
  820. package/docs/zh-CN/gateway/configuration-examples.md +587 -0
  821. package/docs/zh-CN/gateway/configuration.md +3332 -0
  822. package/docs/zh-CN/gateway/discovery.md +123 -0
  823. package/docs/zh-CN/gateway/doctor.md +238 -0
  824. package/docs/zh-CN/gateway/gateway-lock.md +41 -0
  825. package/docs/zh-CN/gateway/health.md +42 -0
  826. package/docs/zh-CN/gateway/heartbeat.md +274 -0
  827. package/docs/zh-CN/gateway/index.md +335 -0
  828. package/docs/zh-CN/gateway/local-models.md +157 -0
  829. package/docs/zh-CN/gateway/logging.md +114 -0
  830. package/docs/zh-CN/gateway/multiple-gateways.md +119 -0
  831. package/docs/zh-CN/gateway/network-model.md +23 -0
  832. package/docs/zh-CN/gateway/openai-http-api.md +125 -0
  833. package/docs/zh-CN/gateway/openresponses-http-api.md +317 -0
  834. package/docs/zh-CN/gateway/pairing.md +99 -0
  835. package/docs/zh-CN/gateway/protocol.md +220 -0
  836. package/docs/zh-CN/gateway/remote-gateway-readme.md +164 -0
  837. package/docs/zh-CN/gateway/remote.md +133 -0
  838. package/docs/zh-CN/gateway/sandbox-vs-tool-policy-vs-elevated.md +135 -0
  839. package/docs/zh-CN/gateway/sandboxing.md +188 -0
  840. package/docs/zh-CN/gateway/security/formal-verification.md +169 -0
  841. package/docs/zh-CN/gateway/security/index.md +777 -0
  842. package/docs/zh-CN/gateway/tailscale.md +124 -0
  843. package/docs/zh-CN/gateway/tools-invoke-http-api.md +92 -0
  844. package/docs/zh-CN/gateway/troubleshooting.md +771 -0
  845. package/docs/zh-CN/help/faq.md +2628 -0
  846. package/docs/zh-CN/help/index.md +28 -0
  847. package/docs/zh-CN/help/troubleshooting.md +104 -0
  848. package/docs/zh-CN/hooks/soul-evil.md +72 -0
  849. package/docs/zh-CN/hooks.md +919 -0
  850. package/docs/zh-CN/index.md +186 -0
  851. package/docs/zh-CN/install/ansible.md +215 -0
  852. package/docs/zh-CN/install/bun.md +65 -0
  853. package/docs/zh-CN/install/development-channels.md +81 -0
  854. package/docs/zh-CN/install/docker.md +532 -0
  855. package/docs/zh-CN/install/exe-dev.md +127 -0
  856. package/docs/zh-CN/install/fly.md +490 -0
  857. package/docs/zh-CN/install/gcp.md +510 -0
  858. package/docs/zh-CN/install/hetzner.md +337 -0
  859. package/docs/zh-CN/install/index.md +193 -0
  860. package/docs/zh-CN/install/installer.md +128 -0
  861. package/docs/zh-CN/install/macos-vm.md +288 -0
  862. package/docs/zh-CN/install/migrating.md +199 -0
  863. package/docs/zh-CN/install/nix.md +99 -0
  864. package/docs/zh-CN/install/node.md +85 -0
  865. package/docs/zh-CN/install/northflank.mdx +60 -0
  866. package/docs/zh-CN/install/railway.mdx +106 -0
  867. package/docs/zh-CN/install/render.mdx +169 -0
  868. package/docs/zh-CN/install/uninstall.md +135 -0
  869. package/docs/zh-CN/install/updating.md +233 -0
  870. package/docs/zh-CN/logging.md +329 -0
  871. package/docs/zh-CN/multi-agent-sandbox-tools.md +401 -0
  872. package/docs/zh-CN/network.md +59 -0
  873. package/docs/zh-CN/nodes/audio.md +120 -0
  874. package/docs/zh-CN/nodes/camera.md +162 -0
  875. package/docs/zh-CN/nodes/images.md +79 -0
  876. package/docs/zh-CN/nodes/index.md +348 -0
  877. package/docs/zh-CN/nodes/location-command.md +120 -0
  878. package/docs/zh-CN/nodes/media-understanding.md +380 -0
  879. package/docs/zh-CN/nodes/talk.md +97 -0
  880. package/docs/zh-CN/nodes/voicewake.md +72 -0
  881. package/docs/zh-CN/perplexity.md +84 -0
  882. package/docs/zh-CN/pi-dev.md +77 -0
  883. package/docs/zh-CN/pi.md +619 -0
  884. package/docs/zh-CN/platforms/android.md +155 -0
  885. package/docs/zh-CN/platforms/digitalocean.md +269 -0
  886. package/docs/zh-CN/platforms/index.md +60 -0
  887. package/docs/zh-CN/platforms/ios.md +114 -0
  888. package/docs/zh-CN/platforms/linux.md +101 -0
  889. package/docs/zh-CN/platforms/mac/bundled-gateway.md +75 -0
  890. package/docs/zh-CN/platforms/mac/canvas.md +128 -0
  891. package/docs/zh-CN/platforms/mac/child-process.md +73 -0
  892. package/docs/zh-CN/platforms/mac/dev-setup.md +109 -0
  893. package/docs/zh-CN/platforms/mac/health.md +41 -0
  894. package/docs/zh-CN/platforms/mac/icon.md +38 -0
  895. package/docs/zh-CN/platforms/mac/logging.md +64 -0
  896. package/docs/zh-CN/platforms/mac/menu-bar.md +88 -0
  897. package/docs/zh-CN/platforms/mac/peekaboo.md +62 -0
  898. package/docs/zh-CN/platforms/mac/permissions.md +46 -0
  899. package/docs/zh-CN/platforms/mac/release.md +92 -0
  900. package/docs/zh-CN/platforms/mac/remote.md +90 -0
  901. package/docs/zh-CN/platforms/mac/signing.md +54 -0
  902. package/docs/zh-CN/platforms/mac/skills.md +40 -0
  903. package/docs/zh-CN/platforms/mac/voice-overlay.md +67 -0
  904. package/docs/zh-CN/platforms/mac/voicewake.md +74 -0
  905. package/docs/zh-CN/platforms/mac/webchat.md +43 -0
  906. package/docs/zh-CN/platforms/mac/xpc.md +68 -0
  907. package/docs/zh-CN/platforms/macos.md +193 -0
  908. package/docs/zh-CN/platforms/oracle.md +310 -0
  909. package/docs/zh-CN/platforms/raspberry-pi.md +365 -0
  910. package/docs/zh-CN/platforms/windows.md +156 -0
  911. package/docs/zh-CN/plugin.md +639 -0
  912. package/docs/zh-CN/plugins/agent-tools.md +99 -0
  913. package/docs/zh-CN/plugins/manifest.md +68 -0
  914. package/docs/zh-CN/plugins/voice-call.md +250 -0
  915. package/docs/zh-CN/plugins/zalouser.md +88 -0
  916. package/docs/zh-CN/prose.md +141 -0
  917. package/docs/zh-CN/providers/anthropic.md +159 -0
  918. package/docs/zh-CN/providers/claude-max-api-proxy.md +155 -0
  919. package/docs/zh-CN/providers/deepgram.md +97 -0
  920. package/docs/zh-CN/providers/github-copilot.md +67 -0
  921. package/docs/zh-CN/providers/glm.md +39 -0
  922. package/docs/zh-CN/providers/index.md +68 -0
  923. package/docs/zh-CN/providers/minimax.md +206 -0
  924. package/docs/zh-CN/providers/models.md +55 -0
  925. package/docs/zh-CN/providers/moonshot.md +145 -0
  926. package/docs/zh-CN/providers/ollama.md +230 -0
  927. package/docs/zh-CN/providers/openai.md +68 -0
  928. package/docs/zh-CN/providers/opencode.md +41 -0
  929. package/docs/zh-CN/providers/openrouter.md +43 -0
  930. package/docs/zh-CN/providers/qwen.md +55 -0
  931. package/docs/zh-CN/providers/synthetic.md +102 -0
  932. package/docs/zh-CN/providers/venice.md +274 -0
  933. package/docs/zh-CN/providers/vercel-ai-gateway.md +57 -0
  934. package/docs/zh-CN/providers/xiaomi.md +68 -0
  935. package/docs/zh-CN/providers/zai.md +41 -0
  936. package/docs/zh-CN/refactor/clawnet.md +424 -0
  937. package/docs/zh-CN/refactor/exec-host.md +323 -0
  938. package/docs/zh-CN/refactor/outbound-session-mirroring.md +92 -0
  939. package/docs/zh-CN/refactor/plugin-sdk.md +221 -0
  940. package/docs/zh-CN/refactor/strict-config.md +100 -0
  941. package/docs/zh-CN/reference/AGENTS.default.md +131 -0
  942. package/docs/zh-CN/reference/RELEASING.md +123 -0
  943. package/docs/zh-CN/reference/api-usage-costs.md +136 -0
  944. package/docs/zh-CN/reference/credits.md +34 -0
  945. package/docs/zh-CN/reference/device-models.md +54 -0
  946. package/docs/zh-CN/reference/rpc.md +48 -0
  947. package/docs/zh-CN/reference/session-management-compaction.md +287 -0
  948. package/docs/zh-CN/reference/templates/AGENTS.dev.md +89 -0
  949. package/docs/zh-CN/reference/templates/AGENTS.md +225 -0
  950. package/docs/zh-CN/reference/templates/BOOT.md +17 -0
  951. package/docs/zh-CN/reference/templates/BOOTSTRAP.md +68 -0
  952. package/docs/zh-CN/reference/templates/HEARTBEAT.md +18 -0
  953. package/docs/zh-CN/reference/templates/IDENTITY.dev.md +54 -0
  954. package/docs/zh-CN/reference/templates/IDENTITY.md +35 -0
  955. package/docs/zh-CN/reference/templates/SOUL.dev.md +83 -0
  956. package/docs/zh-CN/reference/templates/SOUL.md +49 -0
  957. package/docs/zh-CN/reference/templates/TOOLS.dev.md +31 -0
  958. package/docs/zh-CN/reference/templates/TOOLS.md +53 -0
  959. package/docs/zh-CN/reference/templates/USER.dev.md +25 -0
  960. package/docs/zh-CN/reference/templates/USER.md +30 -0
  961. package/docs/zh-CN/reference/test.md +57 -0
  962. package/docs/zh-CN/reference/transcript-hygiene.md +109 -0
  963. package/docs/zh-CN/scripts.md +35 -0
  964. package/docs/zh-CN/security/formal-verification.md +171 -0
  965. package/docs/zh-CN/start/docs-directory.md +70 -0
  966. package/docs/zh-CN/start/getting-started.md +206 -0
  967. package/docs/zh-CN/start/hubs.md +200 -0
  968. package/docs/zh-CN/start/lore.md +226 -0
  969. package/docs/zh-CN/start/onboarding.md +105 -0
  970. package/docs/zh-CN/start/openclaw.md +248 -0
  971. package/docs/zh-CN/start/pairing.md +89 -0
  972. package/docs/zh-CN/start/quickstart.md +88 -0
  973. package/docs/zh-CN/start/setup.md +153 -0
  974. package/docs/zh-CN/start/showcase.md +423 -0
  975. package/docs/zh-CN/start/wizard.md +331 -0
  976. package/docs/zh-CN/testing.md +375 -0
  977. package/docs/zh-CN/token-use.md +119 -0
  978. package/docs/zh-CN/tools/agent-send.md +59 -0
  979. package/docs/zh-CN/tools/apply-patch.md +57 -0
  980. package/docs/zh-CN/tools/browser-linux-troubleshooting.md +144 -0
  981. package/docs/zh-CN/tools/browser-login.md +75 -0
  982. package/docs/zh-CN/tools/browser.md +553 -0
  983. package/docs/zh-CN/tools/chrome-extension.md +183 -0
  984. package/docs/zh-CN/tools/clawhub.md +209 -0
  985. package/docs/zh-CN/tools/creating-skills.md +61 -0
  986. package/docs/zh-CN/tools/elevated.md +64 -0
  987. package/docs/zh-CN/tools/exec-approvals.md +234 -0
  988. package/docs/zh-CN/tools/exec.md +169 -0
  989. package/docs/zh-CN/tools/firecrawl.md +68 -0
  990. package/docs/zh-CN/tools/index.md +515 -0
  991. package/docs/zh-CN/tools/llm-task.md +117 -0
  992. package/docs/zh-CN/tools/lobster.md +349 -0
  993. package/docs/zh-CN/tools/reactions.md +29 -0
  994. package/docs/zh-CN/tools/skills-config.md +78 -0
  995. package/docs/zh-CN/tools/skills.md +279 -0
  996. package/docs/zh-CN/tools/slash-commands.md +205 -0
  997. package/docs/zh-CN/tools/subagents.md +156 -0
  998. package/docs/zh-CN/tools/thinking.md +80 -0
  999. package/docs/zh-CN/tools/web.md +257 -0
  1000. package/docs/zh-CN/tts.md +375 -0
  1001. package/docs/zh-CN/tui.md +166 -0
  1002. package/docs/zh-CN/vps.md +47 -0
  1003. package/docs/zh-CN/web/control-ui.md +191 -0
  1004. package/docs/zh-CN/web/dashboard.md +53 -0
  1005. package/docs/zh-CN/web/index.md +118 -0
  1006. package/docs/zh-CN/web/webchat.md +56 -0
  1007. package/extensions/blockchain/cryptoclaw.plugin.json +17 -0
  1008. package/extensions/blockchain/index.ts +284 -0
  1009. package/extensions/blockchain/node_modules/.bin/cryptoclaw +21 -0
  1010. package/extensions/blockchain/node_modules/.bin/tsc +21 -0
  1011. package/extensions/blockchain/node_modules/.bin/tsserver +21 -0
  1012. package/extensions/blockchain/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  1013. package/extensions/blockchain/package.json +16 -0
  1014. package/extensions/blockchain/src/evm/chains.ts +150 -0
  1015. package/extensions/blockchain/src/evm/services/abi/erc1155.ts +128 -0
  1016. package/extensions/blockchain/src/evm/services/abi/erc20.ts +96 -0
  1017. package/extensions/blockchain/src/evm/services/abi/erc721.ts +130 -0
  1018. package/extensions/blockchain/src/evm/services/abi/erc8004-identity.ts +158 -0
  1019. package/extensions/blockchain/src/evm/services/abi/erc8004-reputation.ts +120 -0
  1020. package/extensions/blockchain/src/evm/services/abi/router-v2.ts +115 -0
  1021. package/extensions/blockchain/src/evm/services/abi/router-v3.ts +81 -0
  1022. package/extensions/blockchain/src/evm/services/agent-identity-config.test.ts +117 -0
  1023. package/extensions/blockchain/src/evm/services/agent-identity-config.ts +75 -0
  1024. package/extensions/blockchain/src/evm/services/agent-identity-store.ts +37 -0
  1025. package/extensions/blockchain/src/evm/services/agent-identity.ts +262 -0
  1026. package/extensions/blockchain/src/evm/services/balance.ts +76 -0
  1027. package/extensions/blockchain/src/evm/services/blocks.ts +25 -0
  1028. package/extensions/blockchain/src/evm/services/clients.ts +48 -0
  1029. package/extensions/blockchain/src/evm/services/contracts.ts +52 -0
  1030. package/extensions/blockchain/src/evm/services/dex-config.test.ts +145 -0
  1031. package/extensions/blockchain/src/evm/services/dex-config.ts +164 -0
  1032. package/extensions/blockchain/src/evm/services/ens.ts +27 -0
  1033. package/extensions/blockchain/src/evm/services/security.test.ts +127 -0
  1034. package/extensions/blockchain/src/evm/services/security.ts +110 -0
  1035. package/extensions/blockchain/src/evm/services/swap.test.ts +204 -0
  1036. package/extensions/blockchain/src/evm/services/swap.ts +534 -0
  1037. package/extensions/blockchain/src/evm/services/tokens.ts +118 -0
  1038. package/extensions/blockchain/src/evm/services/transactions.ts +54 -0
  1039. package/extensions/blockchain/src/evm/services/transfer.ts +174 -0
  1040. package/extensions/blockchain/src/evm/services/utils.ts +18 -0
  1041. package/extensions/blockchain/src/evm/tools/block-tools.ts +34 -0
  1042. package/extensions/blockchain/src/evm/tools/contract-tools.ts +138 -0
  1043. package/extensions/blockchain/src/evm/tools/identity-tools.ts +305 -0
  1044. package/extensions/blockchain/src/evm/tools/network-tools.ts +58 -0
  1045. package/extensions/blockchain/src/evm/tools/nft-tools.ts +103 -0
  1046. package/extensions/blockchain/src/evm/tools/security-tools.ts +38 -0
  1047. package/extensions/blockchain/src/evm/tools/swap-tools.ts +314 -0
  1048. package/extensions/blockchain/src/evm/tools/token-tools.ts +167 -0
  1049. package/extensions/blockchain/src/evm/tools/tx-tools.ts +73 -0
  1050. package/extensions/blockchain/src/evm/tools/wallet-tools.ts +196 -0
  1051. package/extensions/blockchain/src/tx-gate/confirmation.ts +55 -0
  1052. package/extensions/blockchain/src/tx-gate/spending-limits.ts +94 -0
  1053. package/extensions/blockchain/src/wallet/active-wallet.ts +27 -0
  1054. package/extensions/blockchain/src/wallet/key-guard.test.ts +156 -0
  1055. package/extensions/blockchain/src/wallet/key-guard.ts +80 -0
  1056. package/extensions/blockchain/src/wallet/keystore.ts +88 -0
  1057. package/extensions/blockchain/src/wallet/wallet-manager.test.ts +215 -0
  1058. package/extensions/blockchain/src/wallet/wallet-manager.ts +212 -0
  1059. package/extensions/copilot-proxy/README.md +24 -0
  1060. package/extensions/copilot-proxy/index.ts +149 -0
  1061. package/extensions/copilot-proxy/node_modules/.bin/cryptoclaw +21 -0
  1062. package/extensions/copilot-proxy/openclaw.plugin.json +9 -0
  1063. package/extensions/copilot-proxy/package.json +14 -0
  1064. package/extensions/diagnostics-otel/index.ts +15 -0
  1065. package/extensions/diagnostics-otel/node_modules/.bin/acorn +21 -0
  1066. package/extensions/diagnostics-otel/node_modules/.bin/cryptoclaw +21 -0
  1067. package/extensions/diagnostics-otel/openclaw.plugin.json +8 -0
  1068. package/extensions/diagnostics-otel/package.json +27 -0
  1069. package/extensions/diagnostics-otel/src/service.test.ts +227 -0
  1070. package/extensions/diagnostics-otel/src/service.ts +635 -0
  1071. package/extensions/discord/index.ts +17 -0
  1072. package/extensions/discord/node_modules/.bin/cryptoclaw +21 -0
  1073. package/extensions/discord/openclaw.plugin.json +9 -0
  1074. package/extensions/discord/package.json +14 -0
  1075. package/extensions/discord/src/channel.ts +422 -0
  1076. package/extensions/discord/src/runtime.ts +14 -0
  1077. package/extensions/imessage/index.ts +17 -0
  1078. package/extensions/imessage/node_modules/.bin/cryptoclaw +21 -0
  1079. package/extensions/imessage/openclaw.plugin.json +9 -0
  1080. package/extensions/imessage/package.json +14 -0
  1081. package/extensions/imessage/src/channel.ts +294 -0
  1082. package/extensions/imessage/src/runtime.ts +14 -0
  1083. package/extensions/memory-core/index.ts +38 -0
  1084. package/extensions/memory-core/node_modules/.bin/cryptoclaw +21 -0
  1085. package/extensions/memory-core/openclaw.plugin.json +9 -0
  1086. package/extensions/memory-core/package.json +17 -0
  1087. package/extensions/memory-lancedb/config.ts +139 -0
  1088. package/extensions/memory-lancedb/index.test.ts +295 -0
  1089. package/extensions/memory-lancedb/index.ts +608 -0
  1090. package/extensions/memory-lancedb/node_modules/.bin/arrow2csv +21 -0
  1091. package/extensions/memory-lancedb/node_modules/.bin/cryptoclaw +21 -0
  1092. package/extensions/memory-lancedb/node_modules/.bin/openai +21 -0
  1093. package/extensions/memory-lancedb/openclaw.plugin.json +60 -0
  1094. package/extensions/memory-lancedb/package.json +19 -0
  1095. package/extensions/nostr/CHANGELOG.md +80 -0
  1096. package/extensions/nostr/README.md +136 -0
  1097. package/extensions/nostr/index.ts +68 -0
  1098. package/extensions/nostr/node_modules/.bin/cryptoclaw +21 -0
  1099. package/extensions/nostr/node_modules/.bin/tsc +21 -0
  1100. package/extensions/nostr/node_modules/.bin/tsserver +21 -0
  1101. package/extensions/nostr/openclaw.plugin.json +9 -0
  1102. package/extensions/nostr/package.json +34 -0
  1103. package/extensions/nostr/src/channel.test.ts +151 -0
  1104. package/extensions/nostr/src/channel.ts +353 -0
  1105. package/extensions/nostr/src/config-schema.ts +90 -0
  1106. package/extensions/nostr/src/metrics.ts +478 -0
  1107. package/extensions/nostr/src/nostr-bus.fuzz.test.ts +533 -0
  1108. package/extensions/nostr/src/nostr-bus.integration.test.ts +448 -0
  1109. package/extensions/nostr/src/nostr-bus.test.ts +199 -0
  1110. package/extensions/nostr/src/nostr-bus.ts +715 -0
  1111. package/extensions/nostr/src/nostr-profile-http.test.ts +378 -0
  1112. package/extensions/nostr/src/nostr-profile-http.ts +519 -0
  1113. package/extensions/nostr/src/nostr-profile-import.test.ts +119 -0
  1114. package/extensions/nostr/src/nostr-profile-import.ts +262 -0
  1115. package/extensions/nostr/src/nostr-profile.fuzz.test.ts +477 -0
  1116. package/extensions/nostr/src/nostr-profile.test.ts +410 -0
  1117. package/extensions/nostr/src/nostr-profile.ts +277 -0
  1118. package/extensions/nostr/src/nostr-state-store.test.ts +131 -0
  1119. package/extensions/nostr/src/nostr-state-store.ts +226 -0
  1120. package/extensions/nostr/src/runtime.ts +14 -0
  1121. package/extensions/nostr/src/seen-tracker.ts +303 -0
  1122. package/extensions/nostr/src/types.test.ts +157 -0
  1123. package/extensions/nostr/src/types.ts +101 -0
  1124. package/extensions/nostr/test/setup.ts +5 -0
  1125. package/extensions/signal/index.ts +17 -0
  1126. package/extensions/signal/node_modules/.bin/cryptoclaw +21 -0
  1127. package/extensions/signal/openclaw.plugin.json +9 -0
  1128. package/extensions/signal/package.json +14 -0
  1129. package/extensions/signal/src/channel.ts +315 -0
  1130. package/extensions/signal/src/runtime.ts +14 -0
  1131. package/extensions/slack/index.ts +17 -0
  1132. package/extensions/slack/node_modules/.bin/cryptoclaw +21 -0
  1133. package/extensions/slack/openclaw.plugin.json +9 -0
  1134. package/extensions/slack/package.json +14 -0
  1135. package/extensions/slack/src/channel.ts +604 -0
  1136. package/extensions/slack/src/runtime.ts +14 -0
  1137. package/extensions/telegram/index.ts +17 -0
  1138. package/extensions/telegram/node_modules/.bin/cryptoclaw +21 -0
  1139. package/extensions/telegram/openclaw.plugin.json +9 -0
  1140. package/extensions/telegram/package.json +14 -0
  1141. package/extensions/telegram/src/channel.ts +482 -0
  1142. package/extensions/telegram/src/runtime.ts +14 -0
  1143. package/extensions/voice-call/CHANGELOG.md +115 -0
  1144. package/extensions/voice-call/README.md +139 -0
  1145. package/extensions/voice-call/index.ts +493 -0
  1146. package/extensions/voice-call/node_modules/.bin/cryptoclaw +21 -0
  1147. package/extensions/voice-call/openclaw.plugin.json +559 -0
  1148. package/extensions/voice-call/package.json +19 -0
  1149. package/extensions/voice-call/src/allowlist.ts +19 -0
  1150. package/extensions/voice-call/src/cli.ts +279 -0
  1151. package/extensions/voice-call/src/config.test.ts +234 -0
  1152. package/extensions/voice-call/src/config.ts +523 -0
  1153. package/extensions/voice-call/src/core-bridge.ts +159 -0
  1154. package/extensions/voice-call/src/manager/context.ts +21 -0
  1155. package/extensions/voice-call/src/manager/events.ts +188 -0
  1156. package/extensions/voice-call/src/manager/lookup.ts +35 -0
  1157. package/extensions/voice-call/src/manager/outbound.ts +275 -0
  1158. package/extensions/voice-call/src/manager/state.ts +48 -0
  1159. package/extensions/voice-call/src/manager/store.ts +91 -0
  1160. package/extensions/voice-call/src/manager/timers.ts +89 -0
  1161. package/extensions/voice-call/src/manager/twiml.ts +9 -0
  1162. package/extensions/voice-call/src/manager.test.ts +224 -0
  1163. package/extensions/voice-call/src/manager.ts +887 -0
  1164. package/extensions/voice-call/src/media-stream.test.ts +96 -0
  1165. package/extensions/voice-call/src/media-stream.ts +411 -0
  1166. package/extensions/voice-call/src/providers/base.ts +67 -0
  1167. package/extensions/voice-call/src/providers/index.ts +10 -0
  1168. package/extensions/voice-call/src/providers/mock.ts +165 -0
  1169. package/extensions/voice-call/src/providers/plivo.test.ts +27 -0
  1170. package/extensions/voice-call/src/providers/plivo.ts +515 -0
  1171. package/extensions/voice-call/src/providers/stt-openai-realtime.ts +311 -0
  1172. package/extensions/voice-call/src/providers/telnyx.ts +371 -0
  1173. package/extensions/voice-call/src/providers/tts-openai.ts +259 -0
  1174. package/extensions/voice-call/src/providers/twilio/api.ts +42 -0
  1175. package/extensions/voice-call/src/providers/twilio/webhook.ts +32 -0
  1176. package/extensions/voice-call/src/providers/twilio.test.ts +60 -0
  1177. package/extensions/voice-call/src/providers/twilio.ts +626 -0
  1178. package/extensions/voice-call/src/response-generator.ts +158 -0
  1179. package/extensions/voice-call/src/runtime.ts +212 -0
  1180. package/extensions/voice-call/src/telephony-audio.ts +90 -0
  1181. package/extensions/voice-call/src/telephony-tts.ts +104 -0
  1182. package/extensions/voice-call/src/tunnel.ts +314 -0
  1183. package/extensions/voice-call/src/types.ts +272 -0
  1184. package/extensions/voice-call/src/utils.ts +14 -0
  1185. package/extensions/voice-call/src/voice-mapping.ts +67 -0
  1186. package/extensions/voice-call/src/webhook-security.test.ts +377 -0
  1187. package/extensions/voice-call/src/webhook-security.ts +689 -0
  1188. package/extensions/voice-call/src/webhook.ts +491 -0
  1189. package/extensions/whatsapp/index.ts +17 -0
  1190. package/extensions/whatsapp/node_modules/.bin/cryptoclaw +21 -0
  1191. package/extensions/whatsapp/openclaw.plugin.json +9 -0
  1192. package/extensions/whatsapp/package.json +14 -0
  1193. package/extensions/whatsapp/src/channel.ts +508 -0
  1194. package/extensions/whatsapp/src/runtime.ts +14 -0
  1195. package/package.json +242 -0
  1196. package/skills/aave-bsc/SKILL.md +55 -0
  1197. package/skills/agent-identity/SKILL.md +48 -0
  1198. package/skills/bird/SKILL.md +224 -0
  1199. package/skills/canvas/SKILL.md +204 -0
  1200. package/skills/coding-agent/SKILL.md +285 -0
  1201. package/skills/coingecko/SKILL.md +114 -0
  1202. package/skills/contract-deployer/SKILL.md +42 -0
  1203. package/skills/debank/SKILL.md +143 -0
  1204. package/skills/defi-dashboard/SKILL.md +49 -0
  1205. package/skills/defillama/SKILL.md +117 -0
  1206. package/skills/discord/SKILL.md +578 -0
  1207. package/skills/dune/SKILL.md +178 -0
  1208. package/skills/etherscan/SKILL.md +117 -0
  1209. package/skills/four-meme/SKILL.md +80 -0
  1210. package/skills/gas-tracker/SKILL.md +43 -0
  1211. package/skills/github/SKILL.md +77 -0
  1212. package/skills/macro-calendar/SKILL.md +132 -0
  1213. package/skills/market-data/SKILL.md +44 -0
  1214. package/skills/nft-manager/SKILL.md +46 -0
  1215. package/skills/portfolio-tracker/SKILL.md +55 -0
  1216. package/skills/security-check/SKILL.md +153 -0
  1217. package/skills/tmux/SKILL.md +135 -0
  1218. package/skills/tmux/scripts/find-sessions.sh +112 -0
  1219. package/skills/tmux/scripts/wait-for-text.sh +83 -0
  1220. package/skills/token-swap/SKILL.md +71 -0
  1221. package/skills/wallet-manager/SKILL.md +65 -0
  1222. package/skills/whale-watcher/SKILL.md +43 -0
@@ -0,0 +1,2672 @@
1
+ import { d as resolveGatewayPort } from "./paths-D2ytuv-2.js";
2
+ import { f as visibleWidth } from "./entry.js";
3
+ import { _ as parseAgentSessionKey, c as normalizeAgentId, i as buildAgentMainSessionKey, l as normalizeMainKey } from "./session-key-C-ig2pxJ.js";
4
+ import { c as resolveDefaultAgentId } from "./agent-scope-DBl1We79.js";
5
+ import { i as loadConfig, j as VERSION } from "./config-DSpb2aMV.js";
6
+ import { Ct as PROTOCOL_VERSION, t as GatewayClient } from "./client-N6zH1neq.js";
7
+ import { a as resolveExplicitGatewayAuth, r as ensureExplicitGatewayAuth } from "./call-D2DXG0AC.js";
8
+ import { f as GATEWAY_CLIENT_CAPS, h as GATEWAY_CLIENT_NAMES, m as GATEWAY_CLIENT_MODES } from "./message-channel-CfYBy4y3.js";
9
+ import { I as listThinkingLevelLabels, P as formatThinkingLevels, U as resolveResponseUsageMode, V as normalizeUsageDisplay } from "./pi-embedded-helpers-FPVRDeKf.js";
10
+ import { a as extractContentFromMessage, c as formatContextUsageLine, d as resolveFinalAssistantText, h as listChatCommandsForConfig, i as composeThinkingAndContent, l as formatTokens, m as listChatCommands, n as formatAge, o as extractTextFromMessage, r as asString, s as extractThinkingFromMessage, u as isCommandMessage } from "./channel-summary-DS0kcHm2.js";
11
+ import { n as resolveToolDisplay, t as formatToolDetail } from "./tool-display-B2rS2o6B.js";
12
+ import { n as formatTokenCount } from "./usage-format-C4JfTbSp.js";
13
+ import { spawn } from "node:child_process";
14
+ import chalk from "chalk";
15
+ import { randomUUID } from "node:crypto";
16
+ import { Box, CombinedAutocompleteProvider, Container, Editor, Input, Key, Loader, Markdown, ProcessTerminal, SelectList, SettingsList, Spacer, TUI, Text, getEditorKeybindings, isKeyRelease, matchesKey, truncateToWidth } from "@mariozechner/pi-tui";
17
+ import { highlight, supportsLanguage } from "cli-highlight";
18
+
19
+ //#region src/tui/commands.ts
20
+ const VERBOSE_LEVELS = ["on", "off"];
21
+ const REASONING_LEVELS = ["on", "off"];
22
+ const ELEVATED_LEVELS = [
23
+ "on",
24
+ "off",
25
+ "ask",
26
+ "full"
27
+ ];
28
+ const ACTIVATION_LEVELS = ["mention", "always"];
29
+ const USAGE_FOOTER_LEVELS = [
30
+ "off",
31
+ "tokens",
32
+ "full"
33
+ ];
34
+ const COMMAND_ALIASES = { elev: "elevated" };
35
+ function parseCommand(input) {
36
+ const trimmed = input.replace(/^\//, "").trim();
37
+ if (!trimmed) return {
38
+ name: "",
39
+ args: ""
40
+ };
41
+ const [name, ...rest] = trimmed.split(/\s+/);
42
+ const normalized = name.toLowerCase();
43
+ return {
44
+ name: COMMAND_ALIASES[normalized] ?? normalized,
45
+ args: rest.join(" ").trim()
46
+ };
47
+ }
48
+ function getSlashCommands(options = {}) {
49
+ const thinkLevels = listThinkingLevelLabels(options.provider, options.model);
50
+ const commands = [
51
+ {
52
+ name: "help",
53
+ description: "Show slash command help"
54
+ },
55
+ {
56
+ name: "status",
57
+ description: "Show gateway status summary"
58
+ },
59
+ {
60
+ name: "agent",
61
+ description: "Switch agent (or open picker)"
62
+ },
63
+ {
64
+ name: "agents",
65
+ description: "Open agent picker"
66
+ },
67
+ {
68
+ name: "session",
69
+ description: "Switch session (or open picker)"
70
+ },
71
+ {
72
+ name: "sessions",
73
+ description: "Open session picker"
74
+ },
75
+ {
76
+ name: "model",
77
+ description: "Set model (or open picker)"
78
+ },
79
+ {
80
+ name: "models",
81
+ description: "Open model picker"
82
+ },
83
+ {
84
+ name: "think",
85
+ description: "Set thinking level",
86
+ getArgumentCompletions: (prefix) => thinkLevels.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
87
+ value,
88
+ label: value
89
+ }))
90
+ },
91
+ {
92
+ name: "verbose",
93
+ description: "Set verbose on/off",
94
+ getArgumentCompletions: (prefix) => VERBOSE_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
95
+ value,
96
+ label: value
97
+ }))
98
+ },
99
+ {
100
+ name: "reasoning",
101
+ description: "Set reasoning on/off",
102
+ getArgumentCompletions: (prefix) => REASONING_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
103
+ value,
104
+ label: value
105
+ }))
106
+ },
107
+ {
108
+ name: "usage",
109
+ description: "Toggle per-response usage line",
110
+ getArgumentCompletions: (prefix) => USAGE_FOOTER_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
111
+ value,
112
+ label: value
113
+ }))
114
+ },
115
+ {
116
+ name: "elevated",
117
+ description: "Set elevated on/off/ask/full",
118
+ getArgumentCompletions: (prefix) => ELEVATED_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
119
+ value,
120
+ label: value
121
+ }))
122
+ },
123
+ {
124
+ name: "elev",
125
+ description: "Alias for /elevated",
126
+ getArgumentCompletions: (prefix) => ELEVATED_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
127
+ value,
128
+ label: value
129
+ }))
130
+ },
131
+ {
132
+ name: "activation",
133
+ description: "Set group activation",
134
+ getArgumentCompletions: (prefix) => ACTIVATION_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
135
+ value,
136
+ label: value
137
+ }))
138
+ },
139
+ {
140
+ name: "abort",
141
+ description: "Abort active run"
142
+ },
143
+ {
144
+ name: "new",
145
+ description: "Reset the session"
146
+ },
147
+ {
148
+ name: "reset",
149
+ description: "Reset the session"
150
+ },
151
+ {
152
+ name: "settings",
153
+ description: "Open settings"
154
+ },
155
+ {
156
+ name: "exit",
157
+ description: "Exit the TUI"
158
+ },
159
+ {
160
+ name: "quit",
161
+ description: "Exit the TUI"
162
+ }
163
+ ];
164
+ const seen = new Set(commands.map((command) => command.name));
165
+ const gatewayCommands = options.cfg ? listChatCommandsForConfig(options.cfg) : listChatCommands();
166
+ for (const command of gatewayCommands) {
167
+ const aliases = command.textAliases.length > 0 ? command.textAliases : [`/${command.key}`];
168
+ for (const alias of aliases) {
169
+ const name = alias.replace(/^\//, "").trim();
170
+ if (!name || seen.has(name)) continue;
171
+ seen.add(name);
172
+ commands.push({
173
+ name,
174
+ description: command.description
175
+ });
176
+ }
177
+ }
178
+ return commands;
179
+ }
180
+ function helpText(options = {}) {
181
+ return [
182
+ "Slash commands:",
183
+ "/help",
184
+ "/commands",
185
+ "/status",
186
+ "/agent <id> (or /agents)",
187
+ "/session <key> (or /sessions)",
188
+ "/model <provider/model> (or /models)",
189
+ `/think <${formatThinkingLevels(options.provider, options.model, "|")}>`,
190
+ "/verbose <on|off>",
191
+ "/reasoning <on|off>",
192
+ "/usage <off|tokens|full>",
193
+ "/elevated <on|off|ask|full>",
194
+ "/elev <on|off|ask|full>",
195
+ "/activation <mention|always>",
196
+ "/new or /reset",
197
+ "/abort",
198
+ "/settings",
199
+ "/exit"
200
+ ].join("\n");
201
+ }
202
+
203
+ //#endregion
204
+ //#region src/tui/theme/syntax-theme.ts
205
+ /**
206
+ * Syntax highlighting theme for code blocks.
207
+ * Uses chalk functions to style different token types.
208
+ */
209
+ function createSyntaxTheme(fallback) {
210
+ return {
211
+ keyword: chalk.hex("#C586C0"),
212
+ built_in: chalk.hex("#4EC9B0"),
213
+ type: chalk.hex("#4EC9B0"),
214
+ literal: chalk.hex("#569CD6"),
215
+ number: chalk.hex("#B5CEA8"),
216
+ string: chalk.hex("#CE9178"),
217
+ regexp: chalk.hex("#D16969"),
218
+ symbol: chalk.hex("#B5CEA8"),
219
+ class: chalk.hex("#4EC9B0"),
220
+ function: chalk.hex("#DCDCAA"),
221
+ title: chalk.hex("#DCDCAA"),
222
+ params: chalk.hex("#9CDCFE"),
223
+ comment: chalk.hex("#6A9955"),
224
+ doctag: chalk.hex("#608B4E"),
225
+ meta: chalk.hex("#9CDCFE"),
226
+ "meta-keyword": chalk.hex("#C586C0"),
227
+ "meta-string": chalk.hex("#CE9178"),
228
+ section: chalk.hex("#DCDCAA"),
229
+ tag: chalk.hex("#569CD6"),
230
+ name: chalk.hex("#9CDCFE"),
231
+ attr: chalk.hex("#9CDCFE"),
232
+ attribute: chalk.hex("#9CDCFE"),
233
+ variable: chalk.hex("#9CDCFE"),
234
+ bullet: chalk.hex("#D7BA7D"),
235
+ code: chalk.hex("#CE9178"),
236
+ emphasis: chalk.italic,
237
+ strong: chalk.bold,
238
+ formula: chalk.hex("#C586C0"),
239
+ link: chalk.hex("#4EC9B0"),
240
+ quote: chalk.hex("#6A9955"),
241
+ addition: chalk.hex("#B5CEA8"),
242
+ deletion: chalk.hex("#F44747"),
243
+ "selector-tag": chalk.hex("#D7BA7D"),
244
+ "selector-id": chalk.hex("#D7BA7D"),
245
+ "selector-class": chalk.hex("#D7BA7D"),
246
+ "selector-attr": chalk.hex("#D7BA7D"),
247
+ "selector-pseudo": chalk.hex("#D7BA7D"),
248
+ "template-tag": chalk.hex("#C586C0"),
249
+ "template-variable": chalk.hex("#9CDCFE"),
250
+ default: fallback
251
+ };
252
+ }
253
+
254
+ //#endregion
255
+ //#region src/tui/theme/theme.ts
256
+ const palette = {
257
+ text: "#E8E3D5",
258
+ dim: "#7B7F87",
259
+ accent: "#F6C453",
260
+ accentSoft: "#F2A65A",
261
+ border: "#3C414B",
262
+ userBg: "#2B2F36",
263
+ userText: "#F3EEE0",
264
+ systemText: "#9BA3B2",
265
+ toolPendingBg: "#1F2A2F",
266
+ toolSuccessBg: "#1E2D23",
267
+ toolErrorBg: "#2F1F1F",
268
+ toolTitle: "#F6C453",
269
+ toolOutput: "#E1DACB",
270
+ quote: "#8CC8FF",
271
+ quoteBorder: "#3B4D6B",
272
+ code: "#F0C987",
273
+ codeBlock: "#1E232A",
274
+ codeBorder: "#343A45",
275
+ link: "#7DD3A5",
276
+ error: "#F97066",
277
+ success: "#7DD3A5"
278
+ };
279
+ const fg = (hex) => (text) => chalk.hex(hex)(text);
280
+ const bg = (hex) => (text) => chalk.bgHex(hex)(text);
281
+ const syntaxTheme = createSyntaxTheme(fg(palette.code));
282
+ /**
283
+ * Highlight code with syntax coloring.
284
+ * Returns an array of lines with ANSI escape codes.
285
+ */
286
+ function highlightCode(code, lang) {
287
+ try {
288
+ return highlight(code, {
289
+ language: lang && supportsLanguage(lang) ? lang : void 0,
290
+ theme: syntaxTheme,
291
+ ignoreIllegals: true
292
+ }).split("\n");
293
+ } catch {
294
+ return code.split("\n").map((line) => fg(palette.code)(line));
295
+ }
296
+ }
297
+ const theme = {
298
+ fg: fg(palette.text),
299
+ dim: fg(palette.dim),
300
+ accent: fg(palette.accent),
301
+ accentSoft: fg(palette.accentSoft),
302
+ success: fg(palette.success),
303
+ error: fg(palette.error),
304
+ header: (text) => chalk.bold(fg(palette.accent)(text)),
305
+ system: fg(palette.systemText),
306
+ userBg: bg(palette.userBg),
307
+ userText: fg(palette.userText),
308
+ toolTitle: fg(palette.toolTitle),
309
+ toolOutput: fg(palette.toolOutput),
310
+ toolPendingBg: bg(palette.toolPendingBg),
311
+ toolSuccessBg: bg(palette.toolSuccessBg),
312
+ toolErrorBg: bg(palette.toolErrorBg),
313
+ border: fg(palette.border),
314
+ bold: (text) => chalk.bold(text),
315
+ italic: (text) => chalk.italic(text)
316
+ };
317
+ const markdownTheme = {
318
+ heading: (text) => chalk.bold(fg(palette.accent)(text)),
319
+ link: (text) => fg(palette.link)(text),
320
+ linkUrl: (text) => chalk.dim(text),
321
+ code: (text) => fg(palette.code)(text),
322
+ codeBlock: (text) => fg(palette.code)(text),
323
+ codeBlockBorder: (text) => fg(palette.codeBorder)(text),
324
+ quote: (text) => fg(palette.quote)(text),
325
+ quoteBorder: (text) => fg(palette.quoteBorder)(text),
326
+ hr: (text) => fg(palette.border)(text),
327
+ listBullet: (text) => fg(palette.accentSoft)(text),
328
+ bold: (text) => chalk.bold(text),
329
+ italic: (text) => chalk.italic(text),
330
+ strikethrough: (text) => chalk.strikethrough(text),
331
+ underline: (text) => chalk.underline(text),
332
+ highlightCode
333
+ };
334
+ const selectListTheme = {
335
+ selectedPrefix: (text) => fg(palette.accent)(text),
336
+ selectedText: (text) => chalk.bold(fg(palette.accent)(text)),
337
+ description: (text) => fg(palette.dim)(text),
338
+ scrollInfo: (text) => fg(palette.dim)(text),
339
+ noMatch: (text) => fg(palette.dim)(text)
340
+ };
341
+ const filterableSelectListTheme = {
342
+ ...selectListTheme,
343
+ filterLabel: (text) => fg(palette.dim)(text)
344
+ };
345
+ const settingsListTheme = {
346
+ label: (text, selected) => selected ? chalk.bold(fg(palette.accent)(text)) : fg(palette.text)(text),
347
+ value: (text, selected) => selected ? fg(palette.accentSoft)(text) : fg(palette.dim)(text),
348
+ description: (text) => fg(palette.systemText)(text),
349
+ cursor: fg(palette.accent)("→ "),
350
+ hint: (text) => fg(palette.dim)(text)
351
+ };
352
+ const editorTheme = {
353
+ borderColor: (text) => fg(palette.border)(text),
354
+ selectList: selectListTheme
355
+ };
356
+ const searchableSelectListTheme = {
357
+ selectedPrefix: (text) => fg(palette.accent)(text),
358
+ selectedText: (text) => chalk.bold(fg(palette.accent)(text)),
359
+ description: (text) => fg(palette.dim)(text),
360
+ scrollInfo: (text) => fg(palette.dim)(text),
361
+ noMatch: (text) => fg(palette.dim)(text),
362
+ searchPrompt: (text) => fg(palette.accentSoft)(text),
363
+ searchInput: (text) => fg(palette.text)(text),
364
+ matchHighlight: (text) => chalk.bold(fg(palette.accent)(text))
365
+ };
366
+
367
+ //#endregion
368
+ //#region src/tui/components/assistant-message.ts
369
+ var AssistantMessageComponent = class extends Container {
370
+ constructor(text) {
371
+ super();
372
+ this.body = new Markdown(text, 1, 0, markdownTheme, { color: (line) => theme.fg(line) });
373
+ this.addChild(new Spacer(1));
374
+ this.addChild(this.body);
375
+ }
376
+ setText(text) {
377
+ this.body.setText(text);
378
+ }
379
+ };
380
+
381
+ //#endregion
382
+ //#region src/tui/components/tool-execution.ts
383
+ const PREVIEW_LINES = 12;
384
+ function formatArgs(toolName, args) {
385
+ const detail = formatToolDetail(resolveToolDisplay({
386
+ name: toolName,
387
+ args
388
+ }));
389
+ if (detail) return detail;
390
+ if (!args || typeof args !== "object") return "";
391
+ try {
392
+ return JSON.stringify(args);
393
+ } catch {
394
+ return "";
395
+ }
396
+ }
397
+ function extractText(result) {
398
+ if (!result?.content) return "";
399
+ const lines = [];
400
+ for (const entry of result.content) if (entry.type === "text" && entry.text) lines.push(entry.text);
401
+ else if (entry.type === "image") {
402
+ const mime = entry.mimeType ?? "image";
403
+ const size = entry.bytes ? ` ${Math.round(entry.bytes / 1024)}kb` : "";
404
+ const omitted = entry.omitted ? " (omitted)" : "";
405
+ lines.push(`[${mime}${size}${omitted}]`);
406
+ }
407
+ return lines.join("\n").trim();
408
+ }
409
+ var ToolExecutionComponent = class extends Container {
410
+ constructor(toolName, args) {
411
+ super();
412
+ this.expanded = false;
413
+ this.isError = false;
414
+ this.isPartial = true;
415
+ this.toolName = toolName;
416
+ this.args = args;
417
+ this.box = new Box(1, 1, (line) => theme.toolPendingBg(line));
418
+ this.header = new Text("", 0, 0);
419
+ this.argsLine = new Text("", 0, 0);
420
+ this.output = new Markdown("", 0, 0, markdownTheme, { color: (line) => theme.toolOutput(line) });
421
+ this.addChild(new Spacer(1));
422
+ this.addChild(this.box);
423
+ this.box.addChild(this.header);
424
+ this.box.addChild(this.argsLine);
425
+ this.box.addChild(this.output);
426
+ this.refresh();
427
+ }
428
+ setArgs(args) {
429
+ this.args = args;
430
+ this.refresh();
431
+ }
432
+ setExpanded(expanded) {
433
+ this.expanded = expanded;
434
+ this.refresh();
435
+ }
436
+ setResult(result, opts) {
437
+ this.result = result;
438
+ this.isPartial = false;
439
+ this.isError = Boolean(opts?.isError);
440
+ this.refresh();
441
+ }
442
+ setPartialResult(result) {
443
+ this.result = result;
444
+ this.isPartial = true;
445
+ this.refresh();
446
+ }
447
+ refresh() {
448
+ const bg = this.isPartial ? theme.toolPendingBg : this.isError ? theme.toolErrorBg : theme.toolSuccessBg;
449
+ this.box.setBgFn((line) => bg(line));
450
+ const display = resolveToolDisplay({
451
+ name: this.toolName,
452
+ args: this.args
453
+ });
454
+ const title = `${display.emoji} ${display.label}${this.isPartial ? " (running)" : ""}`;
455
+ this.header.setText(theme.toolTitle(theme.bold(title)));
456
+ const argLine = formatArgs(this.toolName, this.args);
457
+ this.argsLine.setText(argLine ? theme.dim(argLine) : theme.dim(" "));
458
+ const text = extractText(this.result) || (this.isPartial ? "…" : "");
459
+ if (!this.expanded && text) {
460
+ const lines = text.split("\n");
461
+ const preview = lines.length > PREVIEW_LINES ? `${lines.slice(0, PREVIEW_LINES).join("\n")}\n…` : text;
462
+ this.output.setText(preview);
463
+ } else this.output.setText(text);
464
+ }
465
+ };
466
+
467
+ //#endregion
468
+ //#region src/tui/components/user-message.ts
469
+ var UserMessageComponent = class extends Container {
470
+ constructor(text) {
471
+ super();
472
+ this.body = new Markdown(text, 1, 1, markdownTheme, {
473
+ bgColor: (line) => theme.userBg(line),
474
+ color: (line) => theme.userText(line)
475
+ });
476
+ this.addChild(new Spacer(1));
477
+ this.addChild(this.body);
478
+ }
479
+ setText(text) {
480
+ this.body.setText(text);
481
+ }
482
+ };
483
+
484
+ //#endregion
485
+ //#region src/tui/components/chat-log.ts
486
+ var ChatLog = class extends Container {
487
+ constructor(..._args) {
488
+ super(..._args);
489
+ this.toolById = /* @__PURE__ */ new Map();
490
+ this.streamingRuns = /* @__PURE__ */ new Map();
491
+ this.toolsExpanded = false;
492
+ }
493
+ clearAll() {
494
+ this.clear();
495
+ this.toolById.clear();
496
+ this.streamingRuns.clear();
497
+ }
498
+ addSystem(text) {
499
+ this.addChild(new Spacer(1));
500
+ this.addChild(new Text(theme.system(text), 1, 0));
501
+ }
502
+ addUser(text) {
503
+ this.addChild(new UserMessageComponent(text));
504
+ }
505
+ resolveRunId(runId) {
506
+ return runId ?? "default";
507
+ }
508
+ startAssistant(text, runId) {
509
+ const component = new AssistantMessageComponent(text);
510
+ this.streamingRuns.set(this.resolveRunId(runId), component);
511
+ this.addChild(component);
512
+ return component;
513
+ }
514
+ updateAssistant(text, runId) {
515
+ const effectiveRunId = this.resolveRunId(runId);
516
+ const existing = this.streamingRuns.get(effectiveRunId);
517
+ if (!existing) {
518
+ this.startAssistant(text, runId);
519
+ return;
520
+ }
521
+ existing.setText(text);
522
+ }
523
+ finalizeAssistant(text, runId) {
524
+ const effectiveRunId = this.resolveRunId(runId);
525
+ const existing = this.streamingRuns.get(effectiveRunId);
526
+ if (existing) {
527
+ existing.setText(text);
528
+ this.streamingRuns.delete(effectiveRunId);
529
+ return;
530
+ }
531
+ this.addChild(new AssistantMessageComponent(text));
532
+ }
533
+ startTool(toolCallId, toolName, args) {
534
+ const existing = this.toolById.get(toolCallId);
535
+ if (existing) {
536
+ existing.setArgs(args);
537
+ return existing;
538
+ }
539
+ const component = new ToolExecutionComponent(toolName, args);
540
+ component.setExpanded(this.toolsExpanded);
541
+ this.toolById.set(toolCallId, component);
542
+ this.addChild(component);
543
+ return component;
544
+ }
545
+ updateToolArgs(toolCallId, args) {
546
+ const existing = this.toolById.get(toolCallId);
547
+ if (!existing) return;
548
+ existing.setArgs(args);
549
+ }
550
+ updateToolResult(toolCallId, result, opts) {
551
+ const existing = this.toolById.get(toolCallId);
552
+ if (!existing) return;
553
+ if (opts?.partial) {
554
+ existing.setPartialResult(result);
555
+ return;
556
+ }
557
+ existing.setResult(result, { isError: opts?.isError });
558
+ }
559
+ setToolsExpanded(expanded) {
560
+ this.toolsExpanded = expanded;
561
+ for (const tool of this.toolById.values()) tool.setExpanded(expanded);
562
+ }
563
+ };
564
+
565
+ //#endregion
566
+ //#region src/tui/components/custom-editor.ts
567
+ var CustomEditor = class extends Editor {
568
+ handleInput(data) {
569
+ if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {
570
+ this.onAltEnter();
571
+ return;
572
+ }
573
+ if (matchesKey(data, Key.ctrl("l")) && this.onCtrlL) {
574
+ this.onCtrlL();
575
+ return;
576
+ }
577
+ if (matchesKey(data, Key.ctrl("o")) && this.onCtrlO) {
578
+ this.onCtrlO();
579
+ return;
580
+ }
581
+ if (matchesKey(data, Key.ctrl("p")) && this.onCtrlP) {
582
+ this.onCtrlP();
583
+ return;
584
+ }
585
+ if (matchesKey(data, Key.ctrl("g")) && this.onCtrlG) {
586
+ this.onCtrlG();
587
+ return;
588
+ }
589
+ if (matchesKey(data, Key.ctrl("t")) && this.onCtrlT) {
590
+ this.onCtrlT();
591
+ return;
592
+ }
593
+ if (matchesKey(data, Key.shift("tab")) && this.onShiftTab) {
594
+ this.onShiftTab();
595
+ return;
596
+ }
597
+ if (matchesKey(data, Key.escape) && this.onEscape && !this.isShowingAutocomplete()) {
598
+ this.onEscape();
599
+ return;
600
+ }
601
+ if (matchesKey(data, Key.ctrl("c")) && this.onCtrlC) {
602
+ this.onCtrlC();
603
+ return;
604
+ }
605
+ if (matchesKey(data, Key.ctrl("d"))) {
606
+ if (this.getText().length === 0 && this.onCtrlD) this.onCtrlD();
607
+ return;
608
+ }
609
+ super.handleInput(data);
610
+ }
611
+ };
612
+
613
+ //#endregion
614
+ //#region src/tui/gateway-chat.ts
615
+ var GatewayChatClient = class {
616
+ constructor(opts) {
617
+ const resolved = resolveGatewayConnection(opts);
618
+ this.connection = resolved;
619
+ this.readyPromise = new Promise((resolve) => {
620
+ this.resolveReady = resolve;
621
+ });
622
+ this.client = new GatewayClient({
623
+ url: resolved.url,
624
+ token: resolved.token,
625
+ password: resolved.password,
626
+ clientName: GATEWAY_CLIENT_NAMES.GATEWAY_CLIENT,
627
+ clientDisplayName: "cryptoclaw-tui",
628
+ clientVersion: VERSION,
629
+ platform: process.platform,
630
+ mode: GATEWAY_CLIENT_MODES.UI,
631
+ caps: [GATEWAY_CLIENT_CAPS.TOOL_EVENTS],
632
+ instanceId: randomUUID(),
633
+ minProtocol: PROTOCOL_VERSION,
634
+ maxProtocol: PROTOCOL_VERSION,
635
+ onHelloOk: (hello) => {
636
+ this.hello = hello;
637
+ this.resolveReady?.();
638
+ this.onConnected?.();
639
+ },
640
+ onEvent: (evt) => {
641
+ this.onEvent?.({
642
+ event: evt.event,
643
+ payload: evt.payload,
644
+ seq: evt.seq
645
+ });
646
+ },
647
+ onClose: (_code, reason) => {
648
+ this.onDisconnected?.(reason);
649
+ },
650
+ onGap: (info) => {
651
+ this.onGap?.(info);
652
+ }
653
+ });
654
+ }
655
+ start() {
656
+ this.client.start();
657
+ }
658
+ stop() {
659
+ this.client.stop();
660
+ }
661
+ async waitForReady() {
662
+ await this.readyPromise;
663
+ }
664
+ async sendChat(opts) {
665
+ const runId = opts.runId ?? randomUUID();
666
+ await this.client.request("chat.send", {
667
+ sessionKey: opts.sessionKey,
668
+ message: opts.message,
669
+ thinking: opts.thinking,
670
+ deliver: opts.deliver,
671
+ timeoutMs: opts.timeoutMs,
672
+ idempotencyKey: runId
673
+ });
674
+ return { runId };
675
+ }
676
+ async abortChat(opts) {
677
+ return await this.client.request("chat.abort", {
678
+ sessionKey: opts.sessionKey,
679
+ runId: opts.runId
680
+ });
681
+ }
682
+ async loadHistory(opts) {
683
+ return await this.client.request("chat.history", {
684
+ sessionKey: opts.sessionKey,
685
+ limit: opts.limit
686
+ });
687
+ }
688
+ async listSessions(opts) {
689
+ return await this.client.request("sessions.list", {
690
+ limit: opts?.limit,
691
+ activeMinutes: opts?.activeMinutes,
692
+ includeGlobal: opts?.includeGlobal,
693
+ includeUnknown: opts?.includeUnknown,
694
+ includeDerivedTitles: opts?.includeDerivedTitles,
695
+ includeLastMessage: opts?.includeLastMessage,
696
+ agentId: opts?.agentId
697
+ });
698
+ }
699
+ async listAgents() {
700
+ return await this.client.request("agents.list", {});
701
+ }
702
+ async patchSession(opts) {
703
+ return await this.client.request("sessions.patch", opts);
704
+ }
705
+ async resetSession(key) {
706
+ return await this.client.request("sessions.reset", { key });
707
+ }
708
+ async getStatus() {
709
+ return await this.client.request("status");
710
+ }
711
+ async listModels() {
712
+ const res = await this.client.request("models.list");
713
+ return Array.isArray(res?.models) ? res.models : [];
714
+ }
715
+ };
716
+ function resolveGatewayConnection(opts) {
717
+ const config = loadConfig();
718
+ const isRemoteMode = config.gateway?.mode === "remote";
719
+ const remote = isRemoteMode ? config.gateway?.remote : void 0;
720
+ const authToken = config.gateway?.auth?.token;
721
+ const localPort = resolveGatewayPort(config);
722
+ const urlOverride = typeof opts.url === "string" && opts.url.trim().length > 0 ? opts.url.trim() : void 0;
723
+ const explicitAuth = resolveExplicitGatewayAuth({
724
+ token: opts.token,
725
+ password: opts.password
726
+ });
727
+ ensureExplicitGatewayAuth({
728
+ urlOverride,
729
+ auth: explicitAuth,
730
+ errorHint: "Fix: pass --token or --password when using --url."
731
+ });
732
+ return {
733
+ url: urlOverride || (typeof remote?.url === "string" && remote.url.trim().length > 0 ? remote.url.trim() : void 0) || `ws://127.0.0.1:${localPort}`,
734
+ token: explicitAuth.token || (!urlOverride ? isRemoteMode ? typeof remote?.token === "string" && remote.token.trim().length > 0 ? remote.token.trim() : void 0 : process.env.CRYPTOCLAW_GATEWAY_TOKEN?.trim() || (typeof authToken === "string" && authToken.trim().length > 0 ? authToken.trim() : void 0) : void 0),
735
+ password: explicitAuth.password || (!urlOverride ? process.env.CRYPTOCLAW_GATEWAY_PASSWORD?.trim() || (typeof remote?.password === "string" && remote.password.trim().length > 0 ? remote.password.trim() : void 0) : void 0)
736
+ };
737
+ }
738
+
739
+ //#endregion
740
+ //#region src/utils/time-format.ts
741
+ function formatRelativeTime(timestamp) {
742
+ const diff = Date.now() - timestamp;
743
+ const seconds = Math.floor(diff / 1e3);
744
+ const minutes = Math.floor(seconds / 60);
745
+ const hours = Math.floor(minutes / 60);
746
+ const days = Math.floor(hours / 24);
747
+ if (seconds < 60) return "just now";
748
+ if (minutes < 60) return `${minutes}m ago`;
749
+ if (hours < 24) return `${hours}h ago`;
750
+ if (days === 1) return "Yesterday";
751
+ if (days < 7) return `${days}d ago`;
752
+ return new Date(timestamp).toLocaleDateString(void 0, {
753
+ month: "short",
754
+ day: "numeric"
755
+ });
756
+ }
757
+
758
+ //#endregion
759
+ //#region src/tui/components/fuzzy-filter.ts
760
+ /**
761
+ * Shared fuzzy filtering utilities for select list components.
762
+ */
763
+ /**
764
+ * Word boundary characters for matching.
765
+ */
766
+ const WORD_BOUNDARY_CHARS = /[\s\-_./:#@]/;
767
+ /**
768
+ * Check if position is at a word boundary.
769
+ */
770
+ function isWordBoundary(text, index) {
771
+ return index === 0 || WORD_BOUNDARY_CHARS.test(text[index - 1] ?? "");
772
+ }
773
+ /**
774
+ * Find index where query matches at a word boundary in text.
775
+ * Returns null if no match.
776
+ */
777
+ function findWordBoundaryIndex(text, query) {
778
+ if (!query) return null;
779
+ const textLower = text.toLowerCase();
780
+ const queryLower = query.toLowerCase();
781
+ const maxIndex = textLower.length - queryLower.length;
782
+ if (maxIndex < 0) return null;
783
+ for (let i = 0; i <= maxIndex; i++) if (textLower.startsWith(queryLower, i) && isWordBoundary(textLower, i)) return i;
784
+ return null;
785
+ }
786
+ /**
787
+ * Fuzzy match with pre-lowercased inputs (avoids toLowerCase on every keystroke).
788
+ * Returns score (lower = better) or null if no match.
789
+ */
790
+ function fuzzyMatchLower(queryLower, textLower) {
791
+ if (queryLower.length === 0) return 0;
792
+ if (queryLower.length > textLower.length) return null;
793
+ let queryIndex = 0;
794
+ let score = 0;
795
+ let lastMatchIndex = -1;
796
+ let consecutiveMatches = 0;
797
+ for (let i = 0; i < textLower.length && queryIndex < queryLower.length; i++) if (textLower[i] === queryLower[queryIndex]) {
798
+ const isAtWordBoundary = isWordBoundary(textLower, i);
799
+ if (lastMatchIndex === i - 1) {
800
+ consecutiveMatches++;
801
+ score -= consecutiveMatches * 5;
802
+ } else {
803
+ consecutiveMatches = 0;
804
+ if (lastMatchIndex >= 0) score += (i - lastMatchIndex - 1) * 2;
805
+ }
806
+ if (isAtWordBoundary) score -= 10;
807
+ score += i * .1;
808
+ lastMatchIndex = i;
809
+ queryIndex++;
810
+ }
811
+ return queryIndex < queryLower.length ? null : score;
812
+ }
813
+ /**
814
+ * Filter items using pre-lowercased searchTextLower field.
815
+ * Supports space-separated tokens (all must match).
816
+ */
817
+ function fuzzyFilterLower(items, queryLower) {
818
+ const trimmed = queryLower.trim();
819
+ if (!trimmed) return items;
820
+ const tokens = trimmed.split(/\s+/).filter((t) => t.length > 0);
821
+ if (tokens.length === 0) return items;
822
+ const results = [];
823
+ for (const item of items) {
824
+ const text = item.searchTextLower ?? "";
825
+ let totalScore = 0;
826
+ let allMatch = true;
827
+ for (const token of tokens) {
828
+ const score = fuzzyMatchLower(token, text);
829
+ if (score !== null) totalScore += score;
830
+ else {
831
+ allMatch = false;
832
+ break;
833
+ }
834
+ }
835
+ if (allMatch) results.push({
836
+ item,
837
+ score: totalScore
838
+ });
839
+ }
840
+ results.sort((a, b) => a.score - b.score);
841
+ return results.map((r) => r.item);
842
+ }
843
+ /**
844
+ * Prepare items for fuzzy filtering by pre-computing lowercase search text.
845
+ */
846
+ function prepareSearchItems(items) {
847
+ return items.map((item) => {
848
+ const parts = [];
849
+ if (item.label) parts.push(item.label);
850
+ if (item.description) parts.push(item.description);
851
+ if (item.searchText) parts.push(item.searchText);
852
+ return {
853
+ ...item,
854
+ searchTextLower: parts.join(" ").toLowerCase()
855
+ };
856
+ });
857
+ }
858
+
859
+ //#endregion
860
+ //#region src/tui/components/filterable-select-list.ts
861
+ /**
862
+ * Combines text input filtering with a select list.
863
+ * User types to filter, arrows/j/k to navigate, Enter to select, Escape to clear/cancel.
864
+ */
865
+ var FilterableSelectList = class {
866
+ constructor(items, maxVisible, theme) {
867
+ this.filterText = "";
868
+ this.allItems = prepareSearchItems(items);
869
+ this.maxVisible = maxVisible;
870
+ this.theme = theme;
871
+ this.input = new Input();
872
+ this.selectList = new SelectList(this.allItems, maxVisible, theme);
873
+ }
874
+ applyFilter() {
875
+ const queryLower = this.filterText.toLowerCase();
876
+ if (!queryLower.trim()) {
877
+ this.selectList = new SelectList(this.allItems, this.maxVisible, this.theme);
878
+ return;
879
+ }
880
+ this.selectList = new SelectList(fuzzyFilterLower(this.allItems, queryLower), this.maxVisible, this.theme);
881
+ }
882
+ invalidate() {
883
+ this.input.invalidate();
884
+ this.selectList.invalidate();
885
+ }
886
+ render(width) {
887
+ const lines = [];
888
+ const filterLabel = this.theme.filterLabel("Filter: ");
889
+ const inputText = this.input.render(width - 8)[0] ?? "";
890
+ lines.push(filterLabel + inputText);
891
+ lines.push(chalk.dim("─".repeat(Math.max(0, width))));
892
+ const listLines = this.selectList.render(width);
893
+ lines.push(...listLines);
894
+ return lines;
895
+ }
896
+ handleInput(keyData) {
897
+ const allowVimNav = !this.filterText.trim();
898
+ if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
899
+ this.selectList.handleInput("\x1B[A");
900
+ return;
901
+ }
902
+ if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
903
+ this.selectList.handleInput("\x1B[B");
904
+ return;
905
+ }
906
+ if (matchesKey(keyData, "enter")) {
907
+ const selected = this.selectList.getSelectedItem();
908
+ if (selected) this.onSelect?.(selected);
909
+ return;
910
+ }
911
+ if (getEditorKeybindings().matches(keyData, "selectCancel")) {
912
+ if (this.filterText) {
913
+ this.filterText = "";
914
+ this.input.setValue("");
915
+ this.applyFilter();
916
+ } else this.onCancel?.();
917
+ return;
918
+ }
919
+ const prevValue = this.input.getValue();
920
+ this.input.handleInput(keyData);
921
+ const newValue = this.input.getValue();
922
+ if (newValue !== prevValue) {
923
+ this.filterText = newValue;
924
+ this.applyFilter();
925
+ }
926
+ }
927
+ getSelectedItem() {
928
+ return this.selectList.getSelectedItem();
929
+ }
930
+ getFilterText() {
931
+ return this.filterText;
932
+ }
933
+ };
934
+
935
+ //#endregion
936
+ //#region src/tui/components/searchable-select-list.ts
937
+ /**
938
+ * A select list with a search input at the top for fuzzy filtering.
939
+ */
940
+ var SearchableSelectList = class {
941
+ constructor(items, maxVisible, theme) {
942
+ this.selectedIndex = 0;
943
+ this.regexCache = /* @__PURE__ */ new Map();
944
+ this.compareByScore = (a, b) => {
945
+ if (a.tier !== b.tier) return a.tier - b.tier;
946
+ if (a.score !== b.score) return a.score - b.score;
947
+ return this.getItemLabel(a.item).localeCompare(this.getItemLabel(b.item));
948
+ };
949
+ this.items = items;
950
+ this.filteredItems = items;
951
+ this.maxVisible = maxVisible;
952
+ this.theme = theme;
953
+ this.searchInput = new Input();
954
+ }
955
+ getCachedRegex(pattern) {
956
+ let regex = this.regexCache.get(pattern);
957
+ if (!regex) {
958
+ regex = new RegExp(this.escapeRegex(pattern), "gi");
959
+ this.regexCache.set(pattern, regex);
960
+ }
961
+ return regex;
962
+ }
963
+ updateFilter() {
964
+ const query = this.searchInput.getValue().trim();
965
+ if (!query) this.filteredItems = this.items;
966
+ else this.filteredItems = this.smartFilter(query);
967
+ this.selectedIndex = 0;
968
+ this.notifySelectionChange();
969
+ }
970
+ /**
971
+ * Smart filtering that prioritizes:
972
+ * 1. Exact substring match in label (highest priority)
973
+ * 2. Word-boundary prefix match in label
974
+ * 3. Exact substring in description
975
+ * 4. Fuzzy match (lowest priority)
976
+ */
977
+ smartFilter(query) {
978
+ const q = query.toLowerCase();
979
+ const scoredItems = [];
980
+ const fuzzyCandidates = [];
981
+ for (const item of this.items) {
982
+ const label = item.label.toLowerCase();
983
+ const desc = (item.description ?? "").toLowerCase();
984
+ const labelIndex = label.indexOf(q);
985
+ if (labelIndex !== -1) {
986
+ scoredItems.push({
987
+ item,
988
+ tier: 0,
989
+ score: labelIndex
990
+ });
991
+ continue;
992
+ }
993
+ const wordBoundaryIndex = findWordBoundaryIndex(label, q);
994
+ if (wordBoundaryIndex !== null) {
995
+ scoredItems.push({
996
+ item,
997
+ tier: 1,
998
+ score: wordBoundaryIndex
999
+ });
1000
+ continue;
1001
+ }
1002
+ const descIndex = desc.indexOf(q);
1003
+ if (descIndex !== -1) {
1004
+ scoredItems.push({
1005
+ item,
1006
+ tier: 2,
1007
+ score: descIndex
1008
+ });
1009
+ continue;
1010
+ }
1011
+ fuzzyCandidates.push(item);
1012
+ }
1013
+ scoredItems.sort(this.compareByScore);
1014
+ const fuzzyMatches = fuzzyFilterLower(prepareSearchItems(fuzzyCandidates), q);
1015
+ return [...scoredItems.map((s) => s.item), ...fuzzyMatches];
1016
+ }
1017
+ escapeRegex(str) {
1018
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1019
+ }
1020
+ getItemLabel(item) {
1021
+ return item.label || item.value;
1022
+ }
1023
+ highlightMatch(text, query) {
1024
+ const tokens = query.trim().split(/\s+/).map((token) => token.toLowerCase()).filter((token) => token.length > 0);
1025
+ if (tokens.length === 0) return text;
1026
+ const uniqueTokens = Array.from(new Set(tokens)).toSorted((a, b) => b.length - a.length);
1027
+ let result = text;
1028
+ for (const token of uniqueTokens) {
1029
+ const regex = this.getCachedRegex(token);
1030
+ result = result.replace(regex, (match) => this.theme.matchHighlight(match));
1031
+ }
1032
+ return result;
1033
+ }
1034
+ setSelectedIndex(index) {
1035
+ this.selectedIndex = Math.max(0, Math.min(index, this.filteredItems.length - 1));
1036
+ }
1037
+ invalidate() {
1038
+ this.searchInput.invalidate();
1039
+ }
1040
+ render(width) {
1041
+ const lines = [];
1042
+ const prompt = this.theme.searchPrompt("search: ");
1043
+ const inputWidth = Math.max(1, width - visibleWidth(prompt));
1044
+ const inputText = this.searchInput.render(inputWidth)[0] ?? "";
1045
+ lines.push(`${prompt}${this.theme.searchInput(inputText)}`);
1046
+ lines.push("");
1047
+ const query = this.searchInput.getValue().trim();
1048
+ if (this.filteredItems.length === 0) {
1049
+ lines.push(this.theme.noMatch(" No matches"));
1050
+ return lines;
1051
+ }
1052
+ const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible));
1053
+ const endIndex = Math.min(startIndex + this.maxVisible, this.filteredItems.length);
1054
+ for (let i = startIndex; i < endIndex; i++) {
1055
+ const item = this.filteredItems[i];
1056
+ if (!item) continue;
1057
+ const isSelected = i === this.selectedIndex;
1058
+ lines.push(this.renderItemLine(item, isSelected, width, query));
1059
+ }
1060
+ if (this.filteredItems.length > this.maxVisible) {
1061
+ const scrollInfo = `${this.selectedIndex + 1}/${this.filteredItems.length}`;
1062
+ lines.push(this.theme.scrollInfo(` ${scrollInfo}`));
1063
+ }
1064
+ return lines;
1065
+ }
1066
+ renderItemLine(item, isSelected, width, query) {
1067
+ const prefix = isSelected ? "→ " : " ";
1068
+ const prefixWidth = prefix.length;
1069
+ const displayValue = this.getItemLabel(item);
1070
+ if (item.description && width > 40) {
1071
+ const truncatedValue = truncateToWidth(displayValue, Math.min(30, width - prefixWidth - 4), "");
1072
+ const valueText = this.highlightMatch(truncatedValue, query);
1073
+ const spacingWidth = Math.max(1, 32 - visibleWidth(valueText));
1074
+ const spacing = " ".repeat(spacingWidth);
1075
+ const remainingWidth = width - (prefixWidth + visibleWidth(valueText) + spacing.length) - 2;
1076
+ if (remainingWidth > 10) {
1077
+ const truncatedDesc = truncateToWidth(item.description, remainingWidth, "");
1078
+ const highlightedDesc = this.highlightMatch(truncatedDesc, query);
1079
+ const line = `${prefix}${valueText}${spacing}${isSelected ? highlightedDesc : this.theme.description(highlightedDesc)}`;
1080
+ return isSelected ? this.theme.selectedText(line) : line;
1081
+ }
1082
+ }
1083
+ const truncatedValue = truncateToWidth(displayValue, width - prefixWidth - 2, "");
1084
+ const line = `${prefix}${this.highlightMatch(truncatedValue, query)}`;
1085
+ return isSelected ? this.theme.selectedText(line) : line;
1086
+ }
1087
+ handleInput(keyData) {
1088
+ if (isKeyRelease(keyData)) return;
1089
+ const allowVimNav = !this.searchInput.getValue().trim();
1090
+ if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
1091
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
1092
+ this.notifySelectionChange();
1093
+ return;
1094
+ }
1095
+ if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
1096
+ this.selectedIndex = Math.min(this.filteredItems.length - 1, this.selectedIndex + 1);
1097
+ this.notifySelectionChange();
1098
+ return;
1099
+ }
1100
+ if (matchesKey(keyData, "enter")) {
1101
+ const item = this.filteredItems[this.selectedIndex];
1102
+ if (item && this.onSelect) this.onSelect(item);
1103
+ return;
1104
+ }
1105
+ if (getEditorKeybindings().matches(keyData, "selectCancel")) {
1106
+ if (this.onCancel) this.onCancel();
1107
+ return;
1108
+ }
1109
+ const prevValue = this.searchInput.getValue();
1110
+ this.searchInput.handleInput(keyData);
1111
+ if (prevValue !== this.searchInput.getValue()) this.updateFilter();
1112
+ }
1113
+ notifySelectionChange() {
1114
+ const item = this.filteredItems[this.selectedIndex];
1115
+ if (item && this.onSelectionChange) this.onSelectionChange(item);
1116
+ }
1117
+ getSelectedItem() {
1118
+ return this.filteredItems[this.selectedIndex] ?? null;
1119
+ }
1120
+ };
1121
+
1122
+ //#endregion
1123
+ //#region src/tui/components/selectors.ts
1124
+ function createSearchableSelectList(items, maxVisible = 7) {
1125
+ return new SearchableSelectList(items, maxVisible, searchableSelectListTheme);
1126
+ }
1127
+ function createFilterableSelectList(items, maxVisible = 7) {
1128
+ return new FilterableSelectList(items, maxVisible, filterableSelectListTheme);
1129
+ }
1130
+ function createSettingsList(items, onChange, onCancel, maxVisible = 7) {
1131
+ return new SettingsList(items, maxVisible, settingsListTheme, onChange, onCancel);
1132
+ }
1133
+
1134
+ //#endregion
1135
+ //#region src/tui/tui-status-summary.ts
1136
+ function formatStatusSummary(summary) {
1137
+ const lines = [];
1138
+ lines.push("Gateway status");
1139
+ if (!summary.linkChannel) lines.push("Link channel: unknown");
1140
+ else {
1141
+ const linkLabel = summary.linkChannel.label ?? "Link channel";
1142
+ const linked = summary.linkChannel.linked === true;
1143
+ const authAge = linked && typeof summary.linkChannel.authAgeMs === "number" ? ` (last refreshed ${formatAge(summary.linkChannel.authAgeMs)})` : "";
1144
+ lines.push(`${linkLabel}: ${linked ? "linked" : "not linked"}${authAge}`);
1145
+ }
1146
+ const providerSummary = Array.isArray(summary.providerSummary) ? summary.providerSummary : [];
1147
+ if (providerSummary.length > 0) {
1148
+ lines.push("");
1149
+ lines.push("System:");
1150
+ for (const line of providerSummary) lines.push(` ${line}`);
1151
+ }
1152
+ const heartbeatAgents = summary.heartbeat?.agents ?? [];
1153
+ if (heartbeatAgents.length > 0) {
1154
+ const heartbeatParts = heartbeatAgents.map((agent) => {
1155
+ const agentId = agent.agentId ?? "unknown";
1156
+ if (!agent.enabled || !agent.everyMs) return `disabled (${agentId})`;
1157
+ return `${agent.every ?? "unknown"} (${agentId})`;
1158
+ });
1159
+ lines.push("");
1160
+ lines.push(`Heartbeat: ${heartbeatParts.join(", ")}`);
1161
+ }
1162
+ const sessionPaths = summary.sessions?.paths ?? [];
1163
+ if (sessionPaths.length === 1) lines.push(`Session store: ${sessionPaths[0]}`);
1164
+ else if (sessionPaths.length > 1) lines.push(`Session stores: ${sessionPaths.length}`);
1165
+ const defaults = summary.sessions?.defaults;
1166
+ const defaultModel = defaults?.model ?? "unknown";
1167
+ const defaultCtx = typeof defaults?.contextTokens === "number" ? ` (${formatTokenCount(defaults.contextTokens)} ctx)` : "";
1168
+ lines.push(`Default model: ${defaultModel}${defaultCtx}`);
1169
+ const sessionCount = summary.sessions?.count ?? 0;
1170
+ lines.push(`Active sessions: ${sessionCount}`);
1171
+ const recent = Array.isArray(summary.sessions?.recent) ? summary.sessions?.recent : [];
1172
+ if (recent.length > 0) {
1173
+ lines.push("Recent sessions:");
1174
+ for (const entry of recent) {
1175
+ const ageLabel = typeof entry.age === "number" ? formatAge(entry.age) : "no activity";
1176
+ const model = entry.model ?? "unknown";
1177
+ const usage = formatContextUsageLine({
1178
+ total: entry.totalTokens ?? null,
1179
+ context: entry.contextTokens ?? null,
1180
+ remaining: entry.remainingTokens ?? null,
1181
+ percent: entry.percentUsed ?? null
1182
+ });
1183
+ const flags = entry.flags?.length ? ` | flags: ${entry.flags.join(", ")}` : "";
1184
+ lines.push(`- ${entry.key}${entry.kind ? ` [${entry.kind}]` : ""} | ${ageLabel} | model ${model} | ${usage}${flags}`);
1185
+ }
1186
+ }
1187
+ const queued = Array.isArray(summary.queuedSystemEvents) ? summary.queuedSystemEvents : [];
1188
+ if (queued.length > 0) {
1189
+ const preview = queued.slice(0, 3).join(" | ");
1190
+ lines.push(`Queued system events (${queued.length}): ${preview}`);
1191
+ }
1192
+ return lines;
1193
+ }
1194
+
1195
+ //#endregion
1196
+ //#region src/tui/tui-command-handlers.ts
1197
+ function createCommandHandlers(context) {
1198
+ const { client, chatLog, tui, opts, state, deliverDefault, openOverlay, closeOverlay, refreshSessionInfo, loadHistory, setSession, refreshAgents, abortActive, setActivityStatus, formatSessionKey, applySessionInfoFromPatch, noteLocalRunId, forgetLocalRunId } = context;
1199
+ const setAgent = async (id) => {
1200
+ state.currentAgentId = normalizeAgentId(id);
1201
+ await setSession("");
1202
+ };
1203
+ const openModelSelector = async () => {
1204
+ try {
1205
+ const models = await client.listModels();
1206
+ if (models.length === 0) {
1207
+ chatLog.addSystem("no models available");
1208
+ tui.requestRender();
1209
+ return;
1210
+ }
1211
+ const selector = createSearchableSelectList(models.map((model) => ({
1212
+ value: `${model.provider}/${model.id}`,
1213
+ label: `${model.provider}/${model.id}`,
1214
+ description: model.name && model.name !== model.id ? model.name : ""
1215
+ })), 9);
1216
+ selector.onSelect = (item) => {
1217
+ (async () => {
1218
+ try {
1219
+ const result = await client.patchSession({
1220
+ key: state.currentSessionKey,
1221
+ model: item.value
1222
+ });
1223
+ chatLog.addSystem(`model set to ${item.value}`);
1224
+ applySessionInfoFromPatch(result);
1225
+ await refreshSessionInfo();
1226
+ } catch (err) {
1227
+ chatLog.addSystem(`model set failed: ${String(err)}`);
1228
+ }
1229
+ closeOverlay();
1230
+ tui.requestRender();
1231
+ })();
1232
+ };
1233
+ selector.onCancel = () => {
1234
+ closeOverlay();
1235
+ tui.requestRender();
1236
+ };
1237
+ openOverlay(selector);
1238
+ tui.requestRender();
1239
+ } catch (err) {
1240
+ chatLog.addSystem(`model list failed: ${String(err)}`);
1241
+ tui.requestRender();
1242
+ }
1243
+ };
1244
+ const openAgentSelector = async () => {
1245
+ await refreshAgents();
1246
+ if (state.agents.length === 0) {
1247
+ chatLog.addSystem("no agents found");
1248
+ tui.requestRender();
1249
+ return;
1250
+ }
1251
+ const selector = createSearchableSelectList(state.agents.map((agent) => ({
1252
+ value: agent.id,
1253
+ label: agent.name ? `${agent.id} (${agent.name})` : agent.id,
1254
+ description: agent.id === state.agentDefaultId ? "default" : ""
1255
+ })), 9);
1256
+ selector.onSelect = (item) => {
1257
+ (async () => {
1258
+ closeOverlay();
1259
+ await setAgent(item.value);
1260
+ tui.requestRender();
1261
+ })();
1262
+ };
1263
+ selector.onCancel = () => {
1264
+ closeOverlay();
1265
+ tui.requestRender();
1266
+ };
1267
+ openOverlay(selector);
1268
+ tui.requestRender();
1269
+ };
1270
+ const openSessionSelector = async () => {
1271
+ try {
1272
+ const selector = createFilterableSelectList((await client.listSessions({
1273
+ includeGlobal: false,
1274
+ includeUnknown: false,
1275
+ includeDerivedTitles: true,
1276
+ includeLastMessage: true,
1277
+ agentId: state.currentAgentId
1278
+ })).sessions.map((session) => {
1279
+ const title = session.derivedTitle ?? session.displayName;
1280
+ const formattedKey = formatSessionKey(session.key);
1281
+ const label = title && title !== formattedKey ? `${title} (${formattedKey})` : formattedKey;
1282
+ const timePart = session.updatedAt ? formatRelativeTime(session.updatedAt) : "";
1283
+ const preview = session.lastMessagePreview?.replace(/\s+/g, " ").trim();
1284
+ const description = timePart && preview ? `${timePart} · ${preview}` : preview ?? timePart;
1285
+ return {
1286
+ value: session.key,
1287
+ label,
1288
+ description,
1289
+ searchText: [
1290
+ session.displayName,
1291
+ session.label,
1292
+ session.subject,
1293
+ session.sessionId,
1294
+ session.key,
1295
+ session.lastMessagePreview
1296
+ ].filter(Boolean).join(" ")
1297
+ };
1298
+ }), 9);
1299
+ selector.onSelect = (item) => {
1300
+ (async () => {
1301
+ closeOverlay();
1302
+ await setSession(item.value);
1303
+ tui.requestRender();
1304
+ })();
1305
+ };
1306
+ selector.onCancel = () => {
1307
+ closeOverlay();
1308
+ tui.requestRender();
1309
+ };
1310
+ openOverlay(selector);
1311
+ tui.requestRender();
1312
+ } catch (err) {
1313
+ chatLog.addSystem(`sessions list failed: ${String(err)}`);
1314
+ tui.requestRender();
1315
+ }
1316
+ };
1317
+ const openSettings = () => {
1318
+ openOverlay(createSettingsList([{
1319
+ id: "tools",
1320
+ label: "Tool output",
1321
+ currentValue: state.toolsExpanded ? "expanded" : "collapsed",
1322
+ values: ["collapsed", "expanded"]
1323
+ }, {
1324
+ id: "thinking",
1325
+ label: "Show thinking",
1326
+ currentValue: state.showThinking ? "on" : "off",
1327
+ values: ["off", "on"]
1328
+ }], (id, value) => {
1329
+ if (id === "tools") {
1330
+ state.toolsExpanded = value === "expanded";
1331
+ chatLog.setToolsExpanded(state.toolsExpanded);
1332
+ }
1333
+ if (id === "thinking") {
1334
+ state.showThinking = value === "on";
1335
+ loadHistory();
1336
+ }
1337
+ tui.requestRender();
1338
+ }, () => {
1339
+ closeOverlay();
1340
+ tui.requestRender();
1341
+ }));
1342
+ tui.requestRender();
1343
+ };
1344
+ const handleCommand = async (raw) => {
1345
+ const { name, args } = parseCommand(raw);
1346
+ if (!name) return;
1347
+ switch (name) {
1348
+ case "help":
1349
+ chatLog.addSystem(helpText({
1350
+ provider: state.sessionInfo.modelProvider,
1351
+ model: state.sessionInfo.model
1352
+ }));
1353
+ break;
1354
+ case "status":
1355
+ try {
1356
+ const status = await client.getStatus();
1357
+ if (typeof status === "string") {
1358
+ chatLog.addSystem(status);
1359
+ break;
1360
+ }
1361
+ if (status && typeof status === "object") {
1362
+ const lines = formatStatusSummary(status);
1363
+ for (const line of lines) chatLog.addSystem(line);
1364
+ break;
1365
+ }
1366
+ chatLog.addSystem("status: unknown response");
1367
+ } catch (err) {
1368
+ chatLog.addSystem(`status failed: ${String(err)}`);
1369
+ }
1370
+ break;
1371
+ case "agent":
1372
+ if (!args) await openAgentSelector();
1373
+ else await setAgent(args);
1374
+ break;
1375
+ case "agents":
1376
+ await openAgentSelector();
1377
+ break;
1378
+ case "session":
1379
+ if (!args) await openSessionSelector();
1380
+ else await setSession(args);
1381
+ break;
1382
+ case "sessions":
1383
+ await openSessionSelector();
1384
+ break;
1385
+ case "model":
1386
+ if (!args) await openModelSelector();
1387
+ else try {
1388
+ const result = await client.patchSession({
1389
+ key: state.currentSessionKey,
1390
+ model: args
1391
+ });
1392
+ chatLog.addSystem(`model set to ${args}`);
1393
+ applySessionInfoFromPatch(result);
1394
+ await refreshSessionInfo();
1395
+ } catch (err) {
1396
+ chatLog.addSystem(`model set failed: ${String(err)}`);
1397
+ }
1398
+ break;
1399
+ case "models":
1400
+ await openModelSelector();
1401
+ break;
1402
+ case "think":
1403
+ if (!args) {
1404
+ const levels = formatThinkingLevels(state.sessionInfo.modelProvider, state.sessionInfo.model, "|");
1405
+ chatLog.addSystem(`usage: /think <${levels}>`);
1406
+ break;
1407
+ }
1408
+ try {
1409
+ const result = await client.patchSession({
1410
+ key: state.currentSessionKey,
1411
+ thinkingLevel: args
1412
+ });
1413
+ chatLog.addSystem(`thinking set to ${args}`);
1414
+ applySessionInfoFromPatch(result);
1415
+ await refreshSessionInfo();
1416
+ } catch (err) {
1417
+ chatLog.addSystem(`think failed: ${String(err)}`);
1418
+ }
1419
+ break;
1420
+ case "verbose":
1421
+ if (!args) {
1422
+ chatLog.addSystem("usage: /verbose <on|off>");
1423
+ break;
1424
+ }
1425
+ try {
1426
+ const result = await client.patchSession({
1427
+ key: state.currentSessionKey,
1428
+ verboseLevel: args
1429
+ });
1430
+ chatLog.addSystem(`verbose set to ${args}`);
1431
+ applySessionInfoFromPatch(result);
1432
+ await loadHistory();
1433
+ } catch (err) {
1434
+ chatLog.addSystem(`verbose failed: ${String(err)}`);
1435
+ }
1436
+ break;
1437
+ case "reasoning":
1438
+ if (!args) {
1439
+ chatLog.addSystem("usage: /reasoning <on|off>");
1440
+ break;
1441
+ }
1442
+ try {
1443
+ const result = await client.patchSession({
1444
+ key: state.currentSessionKey,
1445
+ reasoningLevel: args
1446
+ });
1447
+ chatLog.addSystem(`reasoning set to ${args}`);
1448
+ applySessionInfoFromPatch(result);
1449
+ await refreshSessionInfo();
1450
+ } catch (err) {
1451
+ chatLog.addSystem(`reasoning failed: ${String(err)}`);
1452
+ }
1453
+ break;
1454
+ case "usage": {
1455
+ const normalized = args ? normalizeUsageDisplay(args) : void 0;
1456
+ if (args && !normalized) {
1457
+ chatLog.addSystem("usage: /usage <off|tokens|full>");
1458
+ break;
1459
+ }
1460
+ const currentRaw = state.sessionInfo.responseUsage;
1461
+ const current = resolveResponseUsageMode(currentRaw);
1462
+ const next = normalized ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
1463
+ try {
1464
+ const result = await client.patchSession({
1465
+ key: state.currentSessionKey,
1466
+ responseUsage: next === "off" ? null : next
1467
+ });
1468
+ chatLog.addSystem(`usage footer: ${next}`);
1469
+ applySessionInfoFromPatch(result);
1470
+ await refreshSessionInfo();
1471
+ } catch (err) {
1472
+ chatLog.addSystem(`usage failed: ${String(err)}`);
1473
+ }
1474
+ break;
1475
+ }
1476
+ case "elevated":
1477
+ if (!args) {
1478
+ chatLog.addSystem("usage: /elevated <on|off|ask|full>");
1479
+ break;
1480
+ }
1481
+ if (![
1482
+ "on",
1483
+ "off",
1484
+ "ask",
1485
+ "full"
1486
+ ].includes(args)) {
1487
+ chatLog.addSystem("usage: /elevated <on|off|ask|full>");
1488
+ break;
1489
+ }
1490
+ try {
1491
+ const result = await client.patchSession({
1492
+ key: state.currentSessionKey,
1493
+ elevatedLevel: args
1494
+ });
1495
+ chatLog.addSystem(`elevated set to ${args}`);
1496
+ applySessionInfoFromPatch(result);
1497
+ await refreshSessionInfo();
1498
+ } catch (err) {
1499
+ chatLog.addSystem(`elevated failed: ${String(err)}`);
1500
+ }
1501
+ break;
1502
+ case "activation":
1503
+ if (!args) {
1504
+ chatLog.addSystem("usage: /activation <mention|always>");
1505
+ break;
1506
+ }
1507
+ try {
1508
+ const result = await client.patchSession({
1509
+ key: state.currentSessionKey,
1510
+ groupActivation: args === "always" ? "always" : "mention"
1511
+ });
1512
+ chatLog.addSystem(`activation set to ${args}`);
1513
+ applySessionInfoFromPatch(result);
1514
+ await refreshSessionInfo();
1515
+ } catch (err) {
1516
+ chatLog.addSystem(`activation failed: ${String(err)}`);
1517
+ }
1518
+ break;
1519
+ case "new":
1520
+ case "reset":
1521
+ try {
1522
+ state.sessionInfo.inputTokens = null;
1523
+ state.sessionInfo.outputTokens = null;
1524
+ state.sessionInfo.totalTokens = null;
1525
+ tui.requestRender();
1526
+ await client.resetSession(state.currentSessionKey);
1527
+ chatLog.addSystem(`session ${state.currentSessionKey} reset`);
1528
+ await loadHistory();
1529
+ } catch (err) {
1530
+ chatLog.addSystem(`reset failed: ${String(err)}`);
1531
+ }
1532
+ break;
1533
+ case "abort":
1534
+ await abortActive();
1535
+ break;
1536
+ case "settings":
1537
+ openSettings();
1538
+ break;
1539
+ case "exit":
1540
+ case "quit":
1541
+ client.stop();
1542
+ tui.stop();
1543
+ process.exit(0);
1544
+ break;
1545
+ default:
1546
+ await sendMessage(raw);
1547
+ break;
1548
+ }
1549
+ tui.requestRender();
1550
+ };
1551
+ const sendMessage = async (text) => {
1552
+ try {
1553
+ chatLog.addUser(text);
1554
+ tui.requestRender();
1555
+ const runId = randomUUID();
1556
+ noteLocalRunId(runId);
1557
+ state.activeChatRunId = runId;
1558
+ setActivityStatus("sending");
1559
+ await client.sendChat({
1560
+ sessionKey: state.currentSessionKey,
1561
+ message: text,
1562
+ thinking: opts.thinking,
1563
+ deliver: deliverDefault,
1564
+ timeoutMs: opts.timeoutMs,
1565
+ runId
1566
+ });
1567
+ setActivityStatus("waiting");
1568
+ } catch (err) {
1569
+ if (state.activeChatRunId) forgetLocalRunId?.(state.activeChatRunId);
1570
+ state.activeChatRunId = null;
1571
+ chatLog.addSystem(`send failed: ${String(err)}`);
1572
+ setActivityStatus("error");
1573
+ }
1574
+ tui.requestRender();
1575
+ };
1576
+ return {
1577
+ handleCommand,
1578
+ sendMessage,
1579
+ openModelSelector,
1580
+ openAgentSelector,
1581
+ openSessionSelector,
1582
+ openSettings,
1583
+ setAgent
1584
+ };
1585
+ }
1586
+
1587
+ //#endregion
1588
+ //#region src/tui/tui-stream-assembler.ts
1589
+ var TuiStreamAssembler = class {
1590
+ constructor() {
1591
+ this.runs = /* @__PURE__ */ new Map();
1592
+ }
1593
+ getOrCreateRun(runId) {
1594
+ let state = this.runs.get(runId);
1595
+ if (!state) {
1596
+ state = {
1597
+ thinkingText: "",
1598
+ contentText: "",
1599
+ displayText: ""
1600
+ };
1601
+ this.runs.set(runId, state);
1602
+ }
1603
+ return state;
1604
+ }
1605
+ updateRunState(state, message, showThinking) {
1606
+ const thinkingText = extractThinkingFromMessage(message);
1607
+ const contentText = extractContentFromMessage(message);
1608
+ if (thinkingText) state.thinkingText = thinkingText;
1609
+ if (contentText) state.contentText = contentText;
1610
+ state.displayText = composeThinkingAndContent({
1611
+ thinkingText: state.thinkingText,
1612
+ contentText: state.contentText,
1613
+ showThinking
1614
+ });
1615
+ }
1616
+ ingestDelta(runId, message, showThinking) {
1617
+ const state = this.getOrCreateRun(runId);
1618
+ const previousDisplayText = state.displayText;
1619
+ this.updateRunState(state, message, showThinking);
1620
+ if (!state.displayText || state.displayText === previousDisplayText) return null;
1621
+ return state.displayText;
1622
+ }
1623
+ finalize(runId, message, showThinking) {
1624
+ const state = this.getOrCreateRun(runId);
1625
+ this.updateRunState(state, message, showThinking);
1626
+ const finalComposed = state.displayText;
1627
+ const finalText = resolveFinalAssistantText({
1628
+ finalText: finalComposed,
1629
+ streamedText: state.displayText
1630
+ });
1631
+ this.runs.delete(runId);
1632
+ return finalText;
1633
+ }
1634
+ drop(runId) {
1635
+ this.runs.delete(runId);
1636
+ }
1637
+ };
1638
+
1639
+ //#endregion
1640
+ //#region src/tui/tui-event-handlers.ts
1641
+ function createEventHandlers(context) {
1642
+ const { chatLog, tui, state, setActivityStatus, refreshSessionInfo, loadHistory, isLocalRunId, forgetLocalRunId, clearLocalRunIds } = context;
1643
+ const finalizedRuns = /* @__PURE__ */ new Map();
1644
+ const sessionRuns = /* @__PURE__ */ new Map();
1645
+ let streamAssembler = new TuiStreamAssembler();
1646
+ let lastSessionKey = state.currentSessionKey;
1647
+ const pruneRunMap = (runs) => {
1648
+ if (runs.size <= 200) return;
1649
+ const keepUntil = Date.now() - 600 * 1e3;
1650
+ for (const [key, ts] of runs) {
1651
+ if (runs.size <= 150) break;
1652
+ if (ts < keepUntil) runs.delete(key);
1653
+ }
1654
+ if (runs.size > 200) for (const key of runs.keys()) {
1655
+ runs.delete(key);
1656
+ if (runs.size <= 150) break;
1657
+ }
1658
+ };
1659
+ const syncSessionKey = () => {
1660
+ if (state.currentSessionKey === lastSessionKey) return;
1661
+ lastSessionKey = state.currentSessionKey;
1662
+ finalizedRuns.clear();
1663
+ sessionRuns.clear();
1664
+ streamAssembler = new TuiStreamAssembler();
1665
+ clearLocalRunIds?.();
1666
+ };
1667
+ const noteSessionRun = (runId) => {
1668
+ sessionRuns.set(runId, Date.now());
1669
+ pruneRunMap(sessionRuns);
1670
+ };
1671
+ const noteFinalizedRun = (runId) => {
1672
+ finalizedRuns.set(runId, Date.now());
1673
+ sessionRuns.delete(runId);
1674
+ streamAssembler.drop(runId);
1675
+ pruneRunMap(finalizedRuns);
1676
+ };
1677
+ const handleChatEvent = (payload) => {
1678
+ if (!payload || typeof payload !== "object") return;
1679
+ const evt = payload;
1680
+ syncSessionKey();
1681
+ if (evt.sessionKey !== state.currentSessionKey) return;
1682
+ if (finalizedRuns.has(evt.runId)) {
1683
+ if (evt.state === "delta") return;
1684
+ if (evt.state === "final") return;
1685
+ }
1686
+ noteSessionRun(evt.runId);
1687
+ if (!state.activeChatRunId) state.activeChatRunId = evt.runId;
1688
+ if (evt.state === "delta") {
1689
+ const displayText = streamAssembler.ingestDelta(evt.runId, evt.message, state.showThinking);
1690
+ if (!displayText) return;
1691
+ chatLog.updateAssistant(displayText, evt.runId);
1692
+ setActivityStatus("streaming");
1693
+ }
1694
+ if (evt.state === "final") {
1695
+ if (isCommandMessage(evt.message)) {
1696
+ if (isLocalRunId?.(evt.runId)) forgetLocalRunId?.(evt.runId);
1697
+ else loadHistory?.();
1698
+ const text = extractTextFromMessage(evt.message);
1699
+ if (text) chatLog.addSystem(text);
1700
+ streamAssembler.drop(evt.runId);
1701
+ noteFinalizedRun(evt.runId);
1702
+ state.activeChatRunId = null;
1703
+ setActivityStatus("idle");
1704
+ refreshSessionInfo?.();
1705
+ tui.requestRender();
1706
+ return;
1707
+ }
1708
+ if (isLocalRunId?.(evt.runId)) forgetLocalRunId?.(evt.runId);
1709
+ else loadHistory?.();
1710
+ const stopReason = evt.message && typeof evt.message === "object" && !Array.isArray(evt.message) ? typeof evt.message.stopReason === "string" ? evt.message.stopReason : "" : "";
1711
+ const finalText = streamAssembler.finalize(evt.runId, evt.message, state.showThinking);
1712
+ chatLog.finalizeAssistant(finalText, evt.runId);
1713
+ noteFinalizedRun(evt.runId);
1714
+ state.activeChatRunId = null;
1715
+ setActivityStatus(stopReason === "error" ? "error" : "idle");
1716
+ refreshSessionInfo?.();
1717
+ }
1718
+ if (evt.state === "aborted") {
1719
+ chatLog.addSystem("run aborted");
1720
+ streamAssembler.drop(evt.runId);
1721
+ sessionRuns.delete(evt.runId);
1722
+ state.activeChatRunId = null;
1723
+ setActivityStatus("aborted");
1724
+ refreshSessionInfo?.();
1725
+ if (isLocalRunId?.(evt.runId)) forgetLocalRunId?.(evt.runId);
1726
+ else loadHistory?.();
1727
+ }
1728
+ if (evt.state === "error") {
1729
+ chatLog.addSystem(`run error: ${evt.errorMessage ?? "unknown"}`);
1730
+ streamAssembler.drop(evt.runId);
1731
+ sessionRuns.delete(evt.runId);
1732
+ state.activeChatRunId = null;
1733
+ setActivityStatus("error");
1734
+ refreshSessionInfo?.();
1735
+ if (isLocalRunId?.(evt.runId)) forgetLocalRunId?.(evt.runId);
1736
+ else loadHistory?.();
1737
+ }
1738
+ tui.requestRender();
1739
+ };
1740
+ const handleAgentEvent = (payload) => {
1741
+ if (!payload || typeof payload !== "object") return;
1742
+ const evt = payload;
1743
+ syncSessionKey();
1744
+ const isActiveRun = evt.runId === state.activeChatRunId;
1745
+ if (!(isActiveRun || sessionRuns.has(evt.runId) || finalizedRuns.has(evt.runId))) return;
1746
+ if (evt.stream === "tool") {
1747
+ const verbose = state.sessionInfo.verboseLevel ?? "off";
1748
+ const allowToolEvents = verbose !== "off";
1749
+ const allowToolOutput = verbose === "full";
1750
+ if (!allowToolEvents) return;
1751
+ const data = evt.data ?? {};
1752
+ const phase = asString(data.phase, "");
1753
+ const toolCallId = asString(data.toolCallId, "");
1754
+ const toolName = asString(data.name, "tool");
1755
+ if (!toolCallId) return;
1756
+ if (phase === "start") chatLog.startTool(toolCallId, toolName, data.args);
1757
+ else if (phase === "update") {
1758
+ if (!allowToolOutput) return;
1759
+ chatLog.updateToolResult(toolCallId, data.partialResult, { partial: true });
1760
+ } else if (phase === "result") if (allowToolOutput) chatLog.updateToolResult(toolCallId, data.result, { isError: Boolean(data.isError) });
1761
+ else chatLog.updateToolResult(toolCallId, { content: [] }, { isError: Boolean(data.isError) });
1762
+ tui.requestRender();
1763
+ return;
1764
+ }
1765
+ if (evt.stream === "lifecycle") {
1766
+ if (!isActiveRun) return;
1767
+ const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
1768
+ if (phase === "start") setActivityStatus("running");
1769
+ if (phase === "end") setActivityStatus("idle");
1770
+ if (phase === "error") setActivityStatus("error");
1771
+ tui.requestRender();
1772
+ }
1773
+ };
1774
+ return {
1775
+ handleChatEvent,
1776
+ handleAgentEvent
1777
+ };
1778
+ }
1779
+
1780
+ //#endregion
1781
+ //#region src/tui/tui-local-shell.ts
1782
+ function createLocalShellRunner(deps) {
1783
+ let localExecAsked = false;
1784
+ let localExecAllowed = false;
1785
+ const createSelector = deps.createSelector ?? createSearchableSelectList;
1786
+ const spawnCommand = deps.spawnCommand ?? spawn;
1787
+ const getCwd = deps.getCwd ?? (() => process.cwd());
1788
+ const env = deps.env ?? process.env;
1789
+ const maxChars = deps.maxOutputChars ?? 4e4;
1790
+ const ensureLocalExecAllowed = async () => {
1791
+ if (localExecAllowed) return true;
1792
+ if (localExecAsked) return false;
1793
+ localExecAsked = true;
1794
+ return await new Promise((resolve) => {
1795
+ deps.chatLog.addSystem("Allow local shell commands for this session?");
1796
+ deps.chatLog.addSystem("This runs commands on YOUR machine (not the gateway) and may delete files or reveal secrets.");
1797
+ deps.chatLog.addSystem("Select Yes/No (arrows + Enter), Esc to cancel.");
1798
+ const selector = createSelector([{
1799
+ value: "no",
1800
+ label: "No"
1801
+ }, {
1802
+ value: "yes",
1803
+ label: "Yes"
1804
+ }], 2);
1805
+ selector.onSelect = (item) => {
1806
+ deps.closeOverlay();
1807
+ if (item.value === "yes") {
1808
+ localExecAllowed = true;
1809
+ deps.chatLog.addSystem("local shell: enabled for this session");
1810
+ resolve(true);
1811
+ } else {
1812
+ deps.chatLog.addSystem("local shell: not enabled");
1813
+ resolve(false);
1814
+ }
1815
+ deps.tui.requestRender();
1816
+ };
1817
+ selector.onCancel = () => {
1818
+ deps.closeOverlay();
1819
+ deps.chatLog.addSystem("local shell: cancelled");
1820
+ deps.tui.requestRender();
1821
+ resolve(false);
1822
+ };
1823
+ deps.openOverlay(selector);
1824
+ deps.tui.requestRender();
1825
+ });
1826
+ };
1827
+ const runLocalShellLine = async (line) => {
1828
+ const cmd = line.slice(1);
1829
+ if (cmd === "") return;
1830
+ if (localExecAsked && !localExecAllowed) {
1831
+ deps.chatLog.addSystem("local shell: not enabled for this session");
1832
+ deps.tui.requestRender();
1833
+ return;
1834
+ }
1835
+ if (!await ensureLocalExecAllowed()) return;
1836
+ deps.chatLog.addSystem(`[local] $ ${cmd}`);
1837
+ deps.tui.requestRender();
1838
+ await new Promise((resolve) => {
1839
+ const child = spawnCommand(cmd, {
1840
+ shell: true,
1841
+ cwd: getCwd(),
1842
+ env
1843
+ });
1844
+ let stdout = "";
1845
+ let stderr = "";
1846
+ child.stdout.on("data", (buf) => {
1847
+ stdout += buf.toString("utf8");
1848
+ });
1849
+ child.stderr.on("data", (buf) => {
1850
+ stderr += buf.toString("utf8");
1851
+ });
1852
+ child.on("close", (code, signal) => {
1853
+ const combined = (stdout + (stderr ? (stdout ? "\n" : "") + stderr : "")).slice(0, maxChars).trimEnd();
1854
+ if (combined) for (const line of combined.split("\n")) deps.chatLog.addSystem(`[local] ${line}`);
1855
+ deps.chatLog.addSystem(`[local] exit ${code ?? "?"}${signal ? ` (signal ${String(signal)})` : ""}`);
1856
+ deps.tui.requestRender();
1857
+ resolve();
1858
+ });
1859
+ child.on("error", (err) => {
1860
+ deps.chatLog.addSystem(`[local] error: ${String(err)}`);
1861
+ deps.tui.requestRender();
1862
+ resolve();
1863
+ });
1864
+ });
1865
+ };
1866
+ return { runLocalShellLine };
1867
+ }
1868
+
1869
+ //#endregion
1870
+ //#region src/tui/tui-overlays.ts
1871
+ function createOverlayHandlers(host, fallbackFocus) {
1872
+ const openOverlay = (component) => {
1873
+ host.showOverlay(component);
1874
+ };
1875
+ const closeOverlay = () => {
1876
+ if (host.hasOverlay()) {
1877
+ host.hideOverlay();
1878
+ return;
1879
+ }
1880
+ host.setFocus(fallbackFocus);
1881
+ };
1882
+ return {
1883
+ openOverlay,
1884
+ closeOverlay
1885
+ };
1886
+ }
1887
+
1888
+ //#endregion
1889
+ //#region src/tui/tui-session-actions.ts
1890
+ function createSessionActions(context) {
1891
+ const { client, chatLog, tui, opts, state, agentNames, initialSessionInput, initialSessionAgentId, resolveSessionKey, updateHeader, updateFooter, updateAutocompleteProvider, setActivityStatus, clearLocalRunIds } = context;
1892
+ let refreshSessionInfoPromise = Promise.resolve();
1893
+ let lastSessionDefaults = null;
1894
+ const applyAgentsResult = (result) => {
1895
+ state.agentDefaultId = normalizeAgentId(result.defaultId);
1896
+ state.sessionMainKey = normalizeMainKey(result.mainKey);
1897
+ state.sessionScope = result.scope ?? state.sessionScope;
1898
+ state.agents = result.agents.map((agent) => ({
1899
+ id: normalizeAgentId(agent.id),
1900
+ name: agent.name?.trim() || void 0
1901
+ }));
1902
+ agentNames.clear();
1903
+ for (const agent of state.agents) if (agent.name) agentNames.set(agent.id, agent.name);
1904
+ if (!state.initialSessionApplied) {
1905
+ if (initialSessionAgentId) {
1906
+ if (state.agents.some((agent) => agent.id === initialSessionAgentId)) state.currentAgentId = initialSessionAgentId;
1907
+ } else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
1908
+ const nextSessionKey = resolveSessionKey(initialSessionInput);
1909
+ if (nextSessionKey !== state.currentSessionKey) state.currentSessionKey = nextSessionKey;
1910
+ state.initialSessionApplied = true;
1911
+ } else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
1912
+ updateHeader();
1913
+ updateFooter();
1914
+ };
1915
+ const refreshAgents = async () => {
1916
+ try {
1917
+ applyAgentsResult(await client.listAgents());
1918
+ } catch (err) {
1919
+ chatLog.addSystem(`agents list failed: ${String(err)}`);
1920
+ }
1921
+ };
1922
+ const updateAgentFromSessionKey = (key) => {
1923
+ const parsed = parseAgentSessionKey(key);
1924
+ if (!parsed) return;
1925
+ const next = normalizeAgentId(parsed.agentId);
1926
+ if (next !== state.currentAgentId) state.currentAgentId = next;
1927
+ };
1928
+ const resolveModelSelection = (entry) => {
1929
+ if (entry?.modelProvider || entry?.model) return {
1930
+ modelProvider: entry.modelProvider ?? state.sessionInfo.modelProvider,
1931
+ model: entry.model ?? state.sessionInfo.model
1932
+ };
1933
+ const overrideModel = entry?.modelOverride?.trim();
1934
+ if (overrideModel) return {
1935
+ modelProvider: entry?.providerOverride?.trim() || state.sessionInfo.modelProvider,
1936
+ model: overrideModel
1937
+ };
1938
+ return {
1939
+ modelProvider: state.sessionInfo.modelProvider,
1940
+ model: state.sessionInfo.model
1941
+ };
1942
+ };
1943
+ const applySessionInfo = (params) => {
1944
+ const entry = params.entry ?? void 0;
1945
+ const defaults = params.defaults ?? lastSessionDefaults ?? void 0;
1946
+ const previousDefaults = lastSessionDefaults;
1947
+ const defaultsChanged = params.defaults ? previousDefaults?.model !== params.defaults.model || previousDefaults?.modelProvider !== params.defaults.modelProvider || previousDefaults?.contextTokens !== params.defaults.contextTokens : false;
1948
+ if (params.defaults) lastSessionDefaults = params.defaults;
1949
+ const entryUpdatedAt = entry?.updatedAt ?? null;
1950
+ const currentUpdatedAt = state.sessionInfo.updatedAt ?? null;
1951
+ const modelChanged = entry?.modelProvider !== void 0 && entry.modelProvider !== state.sessionInfo.modelProvider || entry?.model !== void 0 && entry.model !== state.sessionInfo.model;
1952
+ if (!params.force && entryUpdatedAt !== null && currentUpdatedAt !== null && entryUpdatedAt < currentUpdatedAt && !defaultsChanged && !modelChanged) return;
1953
+ const next = { ...state.sessionInfo };
1954
+ if (entry?.thinkingLevel !== void 0) next.thinkingLevel = entry.thinkingLevel;
1955
+ if (entry?.verboseLevel !== void 0) next.verboseLevel = entry.verboseLevel;
1956
+ if (entry?.reasoningLevel !== void 0) next.reasoningLevel = entry.reasoningLevel;
1957
+ if (entry?.responseUsage !== void 0) next.responseUsage = entry.responseUsage;
1958
+ if (entry?.inputTokens !== void 0) next.inputTokens = entry.inputTokens;
1959
+ if (entry?.outputTokens !== void 0) next.outputTokens = entry.outputTokens;
1960
+ if (entry?.totalTokens !== void 0) next.totalTokens = entry.totalTokens;
1961
+ if (entry?.contextTokens !== void 0 || defaults?.contextTokens !== void 0) next.contextTokens = entry?.contextTokens ?? defaults?.contextTokens ?? state.sessionInfo.contextTokens;
1962
+ if (entry?.displayName !== void 0) next.displayName = entry.displayName;
1963
+ if (entry?.updatedAt !== void 0) next.updatedAt = entry.updatedAt;
1964
+ const selection = resolveModelSelection(entry);
1965
+ if (selection.modelProvider !== void 0) next.modelProvider = selection.modelProvider;
1966
+ if (selection.model !== void 0) next.model = selection.model;
1967
+ state.sessionInfo = next;
1968
+ updateAutocompleteProvider();
1969
+ updateFooter();
1970
+ tui.requestRender();
1971
+ };
1972
+ const runRefreshSessionInfo = async () => {
1973
+ try {
1974
+ const resolveListAgentId = () => {
1975
+ if (state.currentSessionKey === "global" || state.currentSessionKey === "unknown") return;
1976
+ const parsed = parseAgentSessionKey(state.currentSessionKey);
1977
+ return parsed?.agentId ? normalizeAgentId(parsed.agentId) : state.currentAgentId;
1978
+ };
1979
+ const listAgentId = resolveListAgentId();
1980
+ const result = await client.listSessions({
1981
+ includeGlobal: false,
1982
+ includeUnknown: false,
1983
+ agentId: listAgentId
1984
+ });
1985
+ const normalizeMatchKey = (key) => parseAgentSessionKey(key)?.rest ?? key;
1986
+ const currentMatchKey = normalizeMatchKey(state.currentSessionKey);
1987
+ const entry = result.sessions.find((row) => {
1988
+ if (row.key === state.currentSessionKey) return true;
1989
+ return normalizeMatchKey(row.key) === currentMatchKey;
1990
+ });
1991
+ if (entry?.key && entry.key !== state.currentSessionKey) {
1992
+ updateAgentFromSessionKey(entry.key);
1993
+ state.currentSessionKey = entry.key;
1994
+ updateHeader();
1995
+ }
1996
+ applySessionInfo({
1997
+ entry,
1998
+ defaults: result.defaults
1999
+ });
2000
+ } catch (err) {
2001
+ chatLog.addSystem(`sessions list failed: ${String(err)}`);
2002
+ }
2003
+ };
2004
+ const refreshSessionInfo = async () => {
2005
+ refreshSessionInfoPromise = refreshSessionInfoPromise.then(runRefreshSessionInfo, runRefreshSessionInfo);
2006
+ await refreshSessionInfoPromise;
2007
+ };
2008
+ const applySessionInfoFromPatch = (result) => {
2009
+ if (!result?.entry) return;
2010
+ if (result.key && result.key !== state.currentSessionKey) {
2011
+ updateAgentFromSessionKey(result.key);
2012
+ state.currentSessionKey = result.key;
2013
+ updateHeader();
2014
+ }
2015
+ const resolved = result.resolved;
2016
+ applySessionInfo({
2017
+ entry: resolved && (resolved.modelProvider || resolved.model) ? {
2018
+ ...result.entry,
2019
+ modelProvider: resolved.modelProvider ?? result.entry.modelProvider,
2020
+ model: resolved.model ?? result.entry.model
2021
+ } : result.entry,
2022
+ force: true
2023
+ });
2024
+ };
2025
+ const loadHistory = async () => {
2026
+ try {
2027
+ const record = await client.loadHistory({
2028
+ sessionKey: state.currentSessionKey,
2029
+ limit: opts.historyLimit ?? 200
2030
+ });
2031
+ state.currentSessionId = typeof record.sessionId === "string" ? record.sessionId : null;
2032
+ state.sessionInfo.thinkingLevel = record.thinkingLevel ?? state.sessionInfo.thinkingLevel;
2033
+ state.sessionInfo.verboseLevel = record.verboseLevel ?? state.sessionInfo.verboseLevel;
2034
+ const showTools = (state.sessionInfo.verboseLevel ?? "off") !== "off";
2035
+ chatLog.clearAll();
2036
+ chatLog.addSystem(`session ${state.currentSessionKey}`);
2037
+ for (const entry of record.messages ?? []) {
2038
+ if (!entry || typeof entry !== "object") continue;
2039
+ const message = entry;
2040
+ if (isCommandMessage(message)) {
2041
+ const text = extractTextFromMessage(message);
2042
+ if (text) chatLog.addSystem(text);
2043
+ continue;
2044
+ }
2045
+ if (message.role === "user") {
2046
+ const text = extractTextFromMessage(message);
2047
+ if (text) chatLog.addUser(text);
2048
+ continue;
2049
+ }
2050
+ if (message.role === "assistant") {
2051
+ const text = extractTextFromMessage(message, { includeThinking: state.showThinking });
2052
+ if (text) chatLog.finalizeAssistant(text);
2053
+ continue;
2054
+ }
2055
+ if (message.role === "toolResult") {
2056
+ if (!showTools) continue;
2057
+ const toolCallId = asString(message.toolCallId, "");
2058
+ const toolName = asString(message.toolName, "tool");
2059
+ chatLog.startTool(toolCallId, toolName, {}).setResult({
2060
+ content: Array.isArray(message.content) ? message.content : [],
2061
+ details: typeof message.details === "object" && message.details ? message.details : void 0
2062
+ }, { isError: Boolean(message.isError) });
2063
+ }
2064
+ }
2065
+ state.historyLoaded = true;
2066
+ } catch (err) {
2067
+ chatLog.addSystem(`history failed: ${String(err)}`);
2068
+ }
2069
+ await refreshSessionInfo();
2070
+ tui.requestRender();
2071
+ };
2072
+ const setSession = async (rawKey) => {
2073
+ const nextKey = resolveSessionKey(rawKey);
2074
+ updateAgentFromSessionKey(nextKey);
2075
+ state.currentSessionKey = nextKey;
2076
+ state.activeChatRunId = null;
2077
+ state.currentSessionId = null;
2078
+ state.historyLoaded = false;
2079
+ clearLocalRunIds?.();
2080
+ updateHeader();
2081
+ updateFooter();
2082
+ await loadHistory();
2083
+ };
2084
+ const abortActive = async () => {
2085
+ if (!state.activeChatRunId) {
2086
+ chatLog.addSystem("no active run");
2087
+ tui.requestRender();
2088
+ return;
2089
+ }
2090
+ try {
2091
+ await client.abortChat({
2092
+ sessionKey: state.currentSessionKey,
2093
+ runId: state.activeChatRunId
2094
+ });
2095
+ setActivityStatus("aborted");
2096
+ } catch (err) {
2097
+ chatLog.addSystem(`abort failed: ${String(err)}`);
2098
+ setActivityStatus("abort failed");
2099
+ }
2100
+ tui.requestRender();
2101
+ };
2102
+ return {
2103
+ applyAgentsResult,
2104
+ refreshAgents,
2105
+ refreshSessionInfo,
2106
+ applySessionInfoFromPatch,
2107
+ loadHistory,
2108
+ setSession,
2109
+ abortActive
2110
+ };
2111
+ }
2112
+
2113
+ //#endregion
2114
+ //#region src/tui/tui-waiting.ts
2115
+ const defaultWaitingPhrases = [
2116
+ "flibbertigibbeting",
2117
+ "kerfuffling",
2118
+ "dillydallying",
2119
+ "twiddling thumbs",
2120
+ "noodling",
2121
+ "bamboozling",
2122
+ "moseying",
2123
+ "hobnobbing",
2124
+ "pondering",
2125
+ "conjuring"
2126
+ ];
2127
+ function pickWaitingPhrase(tick, phrases = defaultWaitingPhrases) {
2128
+ return phrases[Math.floor(tick / 10) % phrases.length] ?? phrases[0] ?? "waiting";
2129
+ }
2130
+ function shimmerText(theme, text, tick) {
2131
+ const width = 6;
2132
+ const hi = (ch) => theme.bold(theme.accentSoft(ch));
2133
+ const pos = tick % (text.length + width);
2134
+ const start = Math.max(0, pos - width);
2135
+ const end = Math.min(text.length - 1, pos);
2136
+ let out = "";
2137
+ for (let i = 0; i < text.length; i++) {
2138
+ const ch = text[i];
2139
+ out += i >= start && i <= end ? hi(ch) : theme.dim(ch);
2140
+ }
2141
+ return out;
2142
+ }
2143
+ function buildWaitingStatusMessage(params) {
2144
+ const phrase = pickWaitingPhrase(params.tick, params.phrases);
2145
+ return `${shimmerText(params.theme, `${phrase}…`, params.tick)} • ${params.elapsed} | ${params.connectionStatus}`;
2146
+ }
2147
+
2148
+ //#endregion
2149
+ //#region src/tui/tui.ts
2150
+ function createEditorSubmitHandler(params) {
2151
+ return (text) => {
2152
+ const raw = text;
2153
+ const value = raw.trim();
2154
+ params.editor.setText("");
2155
+ if (!value) return;
2156
+ if (raw.startsWith("!") && raw !== "!") {
2157
+ params.editor.addToHistory(raw);
2158
+ params.handleBangLine(raw);
2159
+ return;
2160
+ }
2161
+ params.editor.addToHistory(value);
2162
+ if (value.startsWith("/")) {
2163
+ params.handleCommand(value);
2164
+ return;
2165
+ }
2166
+ params.sendMessage(value);
2167
+ };
2168
+ }
2169
+ async function runTui(opts) {
2170
+ const config = loadConfig();
2171
+ const initialSessionInput = (opts.session ?? "").trim();
2172
+ let sessionScope = config.session?.scope ?? "per-sender";
2173
+ let sessionMainKey = normalizeMainKey(config.session?.mainKey);
2174
+ let agentDefaultId = resolveDefaultAgentId(config);
2175
+ let currentAgentId = agentDefaultId;
2176
+ let agents = [];
2177
+ const agentNames = /* @__PURE__ */ new Map();
2178
+ let currentSessionKey = "";
2179
+ let initialSessionApplied = false;
2180
+ let currentSessionId = null;
2181
+ let activeChatRunId = null;
2182
+ let historyLoaded = false;
2183
+ let isConnected = false;
2184
+ let wasDisconnected = false;
2185
+ let toolsExpanded = false;
2186
+ let showThinking = false;
2187
+ const localRunIds = /* @__PURE__ */ new Set();
2188
+ const deliverDefault = opts.deliver ?? false;
2189
+ const autoMessage = opts.message?.trim();
2190
+ let autoMessageSent = false;
2191
+ let sessionInfo = {};
2192
+ let lastCtrlCAt = 0;
2193
+ let activityStatus = "idle";
2194
+ let connectionStatus = "connecting";
2195
+ let statusTimeout = null;
2196
+ let statusTimer = null;
2197
+ let statusStartedAt = null;
2198
+ let lastActivityStatus = activityStatus;
2199
+ const state = {
2200
+ get agentDefaultId() {
2201
+ return agentDefaultId;
2202
+ },
2203
+ set agentDefaultId(value) {
2204
+ agentDefaultId = value;
2205
+ },
2206
+ get sessionMainKey() {
2207
+ return sessionMainKey;
2208
+ },
2209
+ set sessionMainKey(value) {
2210
+ sessionMainKey = value;
2211
+ },
2212
+ get sessionScope() {
2213
+ return sessionScope;
2214
+ },
2215
+ set sessionScope(value) {
2216
+ sessionScope = value;
2217
+ },
2218
+ get agents() {
2219
+ return agents;
2220
+ },
2221
+ set agents(value) {
2222
+ agents = value;
2223
+ },
2224
+ get currentAgentId() {
2225
+ return currentAgentId;
2226
+ },
2227
+ set currentAgentId(value) {
2228
+ currentAgentId = value;
2229
+ },
2230
+ get currentSessionKey() {
2231
+ return currentSessionKey;
2232
+ },
2233
+ set currentSessionKey(value) {
2234
+ currentSessionKey = value;
2235
+ },
2236
+ get currentSessionId() {
2237
+ return currentSessionId;
2238
+ },
2239
+ set currentSessionId(value) {
2240
+ currentSessionId = value;
2241
+ },
2242
+ get activeChatRunId() {
2243
+ return activeChatRunId;
2244
+ },
2245
+ set activeChatRunId(value) {
2246
+ activeChatRunId = value;
2247
+ },
2248
+ get historyLoaded() {
2249
+ return historyLoaded;
2250
+ },
2251
+ set historyLoaded(value) {
2252
+ historyLoaded = value;
2253
+ },
2254
+ get sessionInfo() {
2255
+ return sessionInfo;
2256
+ },
2257
+ set sessionInfo(value) {
2258
+ sessionInfo = value;
2259
+ },
2260
+ get initialSessionApplied() {
2261
+ return initialSessionApplied;
2262
+ },
2263
+ set initialSessionApplied(value) {
2264
+ initialSessionApplied = value;
2265
+ },
2266
+ get isConnected() {
2267
+ return isConnected;
2268
+ },
2269
+ set isConnected(value) {
2270
+ isConnected = value;
2271
+ },
2272
+ get autoMessageSent() {
2273
+ return autoMessageSent;
2274
+ },
2275
+ set autoMessageSent(value) {
2276
+ autoMessageSent = value;
2277
+ },
2278
+ get toolsExpanded() {
2279
+ return toolsExpanded;
2280
+ },
2281
+ set toolsExpanded(value) {
2282
+ toolsExpanded = value;
2283
+ },
2284
+ get showThinking() {
2285
+ return showThinking;
2286
+ },
2287
+ set showThinking(value) {
2288
+ showThinking = value;
2289
+ },
2290
+ get connectionStatus() {
2291
+ return connectionStatus;
2292
+ },
2293
+ set connectionStatus(value) {
2294
+ connectionStatus = value;
2295
+ },
2296
+ get activityStatus() {
2297
+ return activityStatus;
2298
+ },
2299
+ set activityStatus(value) {
2300
+ activityStatus = value;
2301
+ },
2302
+ get statusTimeout() {
2303
+ return statusTimeout;
2304
+ },
2305
+ set statusTimeout(value) {
2306
+ statusTimeout = value;
2307
+ },
2308
+ get lastCtrlCAt() {
2309
+ return lastCtrlCAt;
2310
+ },
2311
+ set lastCtrlCAt(value) {
2312
+ lastCtrlCAt = value;
2313
+ }
2314
+ };
2315
+ const noteLocalRunId = (runId) => {
2316
+ if (!runId) return;
2317
+ localRunIds.add(runId);
2318
+ if (localRunIds.size > 200) {
2319
+ const [first] = localRunIds;
2320
+ if (first) localRunIds.delete(first);
2321
+ }
2322
+ };
2323
+ const forgetLocalRunId = (runId) => {
2324
+ localRunIds.delete(runId);
2325
+ };
2326
+ const isLocalRunId = (runId) => localRunIds.has(runId);
2327
+ const clearLocalRunIds = () => {
2328
+ localRunIds.clear();
2329
+ };
2330
+ const client = new GatewayChatClient({
2331
+ url: opts.url,
2332
+ token: opts.token,
2333
+ password: opts.password
2334
+ });
2335
+ const tui = new TUI(new ProcessTerminal());
2336
+ const header = new Text("", 1, 0);
2337
+ const statusContainer = new Container();
2338
+ const footer = new Text("", 1, 0);
2339
+ const chatLog = new ChatLog();
2340
+ const editor = new CustomEditor(tui, editorTheme);
2341
+ const root = new Container();
2342
+ root.addChild(header);
2343
+ root.addChild(chatLog);
2344
+ root.addChild(statusContainer);
2345
+ root.addChild(footer);
2346
+ root.addChild(editor);
2347
+ const updateAutocompleteProvider = () => {
2348
+ editor.setAutocompleteProvider(new CombinedAutocompleteProvider(getSlashCommands({
2349
+ cfg: config,
2350
+ provider: sessionInfo.modelProvider,
2351
+ model: sessionInfo.model
2352
+ }), process.cwd()));
2353
+ };
2354
+ tui.addChild(root);
2355
+ tui.setFocus(editor);
2356
+ const formatSessionKey = (key) => {
2357
+ if (key === "global" || key === "unknown") return key;
2358
+ return parseAgentSessionKey(key)?.rest ?? key;
2359
+ };
2360
+ const formatAgentLabel = (id) => {
2361
+ const name = agentNames.get(id);
2362
+ return name ? `${id} (${name})` : id;
2363
+ };
2364
+ const resolveSessionKey = (raw) => {
2365
+ const trimmed = (raw ?? "").trim();
2366
+ if (sessionScope === "global") return "global";
2367
+ if (!trimmed) return buildAgentMainSessionKey({
2368
+ agentId: currentAgentId,
2369
+ mainKey: sessionMainKey
2370
+ });
2371
+ if (trimmed === "global" || trimmed === "unknown") return trimmed;
2372
+ if (trimmed.startsWith("agent:")) return trimmed;
2373
+ return `agent:${currentAgentId}:${trimmed}`;
2374
+ };
2375
+ currentSessionKey = resolveSessionKey(initialSessionInput);
2376
+ const updateHeader = () => {
2377
+ const sessionLabel = formatSessionKey(currentSessionKey);
2378
+ const agentLabel = formatAgentLabel(currentAgentId);
2379
+ header.setText(theme.header(`cryptoclaw tui - ${client.connection.url} - agent ${agentLabel} - session ${sessionLabel}`));
2380
+ };
2381
+ const busyStates = new Set([
2382
+ "sending",
2383
+ "waiting",
2384
+ "streaming",
2385
+ "running"
2386
+ ]);
2387
+ let statusText = null;
2388
+ let statusLoader = null;
2389
+ const formatElapsed = (startMs) => {
2390
+ const totalSeconds = Math.max(0, Math.floor((Date.now() - startMs) / 1e3));
2391
+ if (totalSeconds < 60) return `${totalSeconds}s`;
2392
+ return `${Math.floor(totalSeconds / 60)}m ${totalSeconds % 60}s`;
2393
+ };
2394
+ const ensureStatusText = () => {
2395
+ if (statusText) return;
2396
+ statusContainer.clear();
2397
+ statusLoader?.stop();
2398
+ statusLoader = null;
2399
+ statusText = new Text("", 1, 0);
2400
+ statusContainer.addChild(statusText);
2401
+ };
2402
+ const ensureStatusLoader = () => {
2403
+ if (statusLoader) return;
2404
+ statusContainer.clear();
2405
+ statusText = null;
2406
+ statusLoader = new Loader(tui, (spinner) => theme.accent(spinner), (text) => theme.bold(theme.accentSoft(text)), "");
2407
+ statusContainer.addChild(statusLoader);
2408
+ };
2409
+ let waitingTick = 0;
2410
+ let waitingTimer = null;
2411
+ let waitingPhrase = null;
2412
+ const updateBusyStatusMessage = () => {
2413
+ if (!statusLoader || !statusStartedAt) return;
2414
+ const elapsed = formatElapsed(statusStartedAt);
2415
+ if (activityStatus === "waiting") {
2416
+ waitingTick++;
2417
+ statusLoader.setMessage(buildWaitingStatusMessage({
2418
+ theme,
2419
+ tick: waitingTick,
2420
+ elapsed,
2421
+ connectionStatus,
2422
+ phrases: waitingPhrase ? [waitingPhrase] : void 0
2423
+ }));
2424
+ return;
2425
+ }
2426
+ statusLoader.setMessage(`${activityStatus} • ${elapsed} | ${connectionStatus}`);
2427
+ };
2428
+ const startStatusTimer = () => {
2429
+ if (statusTimer) return;
2430
+ statusTimer = setInterval(() => {
2431
+ if (!busyStates.has(activityStatus)) return;
2432
+ updateBusyStatusMessage();
2433
+ }, 1e3);
2434
+ };
2435
+ const stopStatusTimer = () => {
2436
+ if (!statusTimer) return;
2437
+ clearInterval(statusTimer);
2438
+ statusTimer = null;
2439
+ };
2440
+ const startWaitingTimer = () => {
2441
+ if (waitingTimer) return;
2442
+ if (!waitingPhrase) waitingPhrase = defaultWaitingPhrases[Math.floor(Math.random() * defaultWaitingPhrases.length)] ?? defaultWaitingPhrases[0] ?? "waiting";
2443
+ waitingTick = 0;
2444
+ waitingTimer = setInterval(() => {
2445
+ if (activityStatus !== "waiting") return;
2446
+ updateBusyStatusMessage();
2447
+ }, 120);
2448
+ };
2449
+ const stopWaitingTimer = () => {
2450
+ if (!waitingTimer) return;
2451
+ clearInterval(waitingTimer);
2452
+ waitingTimer = null;
2453
+ waitingPhrase = null;
2454
+ };
2455
+ const renderStatus = () => {
2456
+ if (busyStates.has(activityStatus)) {
2457
+ if (!statusStartedAt || lastActivityStatus !== activityStatus) statusStartedAt = Date.now();
2458
+ ensureStatusLoader();
2459
+ if (activityStatus === "waiting") {
2460
+ stopStatusTimer();
2461
+ startWaitingTimer();
2462
+ } else {
2463
+ stopWaitingTimer();
2464
+ startStatusTimer();
2465
+ }
2466
+ updateBusyStatusMessage();
2467
+ } else {
2468
+ statusStartedAt = null;
2469
+ stopStatusTimer();
2470
+ stopWaitingTimer();
2471
+ statusLoader?.stop();
2472
+ statusLoader = null;
2473
+ ensureStatusText();
2474
+ const text = activityStatus ? `${connectionStatus} | ${activityStatus}` : connectionStatus;
2475
+ statusText?.setText(theme.dim(text));
2476
+ }
2477
+ lastActivityStatus = activityStatus;
2478
+ };
2479
+ const setConnectionStatus = (text, ttlMs) => {
2480
+ connectionStatus = text;
2481
+ renderStatus();
2482
+ if (statusTimeout) clearTimeout(statusTimeout);
2483
+ if (ttlMs && ttlMs > 0) statusTimeout = setTimeout(() => {
2484
+ connectionStatus = isConnected ? "connected" : "disconnected";
2485
+ renderStatus();
2486
+ }, ttlMs);
2487
+ };
2488
+ const setActivityStatus = (text) => {
2489
+ activityStatus = text;
2490
+ renderStatus();
2491
+ };
2492
+ const updateFooter = () => {
2493
+ const sessionKeyLabel = formatSessionKey(currentSessionKey);
2494
+ const sessionLabel = sessionInfo.displayName ? `${sessionKeyLabel} (${sessionInfo.displayName})` : sessionKeyLabel;
2495
+ const agentLabel = formatAgentLabel(currentAgentId);
2496
+ const modelLabel = sessionInfo.model ? sessionInfo.modelProvider ? `${sessionInfo.modelProvider}/${sessionInfo.model}` : sessionInfo.model : "unknown";
2497
+ const tokens = formatTokens(sessionInfo.totalTokens ?? null, sessionInfo.contextTokens ?? null);
2498
+ const think = sessionInfo.thinkingLevel ?? "off";
2499
+ const verbose = sessionInfo.verboseLevel ?? "off";
2500
+ const reasoning = sessionInfo.reasoningLevel ?? "off";
2501
+ const reasoningLabel = reasoning === "on" ? "reasoning" : reasoning === "stream" ? "reasoning:stream" : null;
2502
+ const footerParts = [
2503
+ `agent ${agentLabel}`,
2504
+ `session ${sessionLabel}`,
2505
+ modelLabel,
2506
+ think !== "off" ? `think ${think}` : null,
2507
+ verbose !== "off" ? `verbose ${verbose}` : null,
2508
+ reasoningLabel,
2509
+ tokens
2510
+ ].filter(Boolean);
2511
+ footer.setText(theme.dim(footerParts.join(" | ")));
2512
+ };
2513
+ const { openOverlay, closeOverlay } = createOverlayHandlers(tui, editor);
2514
+ const { refreshAgents, refreshSessionInfo, applySessionInfoFromPatch, loadHistory, setSession, abortActive } = createSessionActions({
2515
+ client,
2516
+ chatLog,
2517
+ tui,
2518
+ opts,
2519
+ state,
2520
+ agentNames,
2521
+ initialSessionInput,
2522
+ initialSessionAgentId: (() => {
2523
+ if (!initialSessionInput) return null;
2524
+ const parsed = parseAgentSessionKey(initialSessionInput);
2525
+ return parsed ? normalizeAgentId(parsed.agentId) : null;
2526
+ })(),
2527
+ resolveSessionKey,
2528
+ updateHeader,
2529
+ updateFooter,
2530
+ updateAutocompleteProvider,
2531
+ setActivityStatus,
2532
+ clearLocalRunIds
2533
+ });
2534
+ const { handleChatEvent, handleAgentEvent } = createEventHandlers({
2535
+ chatLog,
2536
+ tui,
2537
+ state,
2538
+ setActivityStatus,
2539
+ refreshSessionInfo,
2540
+ loadHistory,
2541
+ isLocalRunId,
2542
+ forgetLocalRunId,
2543
+ clearLocalRunIds
2544
+ });
2545
+ const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } = createCommandHandlers({
2546
+ client,
2547
+ chatLog,
2548
+ tui,
2549
+ opts,
2550
+ state,
2551
+ deliverDefault,
2552
+ openOverlay,
2553
+ closeOverlay,
2554
+ refreshSessionInfo,
2555
+ applySessionInfoFromPatch,
2556
+ loadHistory,
2557
+ setSession,
2558
+ refreshAgents,
2559
+ abortActive,
2560
+ setActivityStatus,
2561
+ formatSessionKey,
2562
+ noteLocalRunId,
2563
+ forgetLocalRunId
2564
+ });
2565
+ const { runLocalShellLine } = createLocalShellRunner({
2566
+ chatLog,
2567
+ tui,
2568
+ openOverlay,
2569
+ closeOverlay
2570
+ });
2571
+ updateAutocompleteProvider();
2572
+ editor.onSubmit = createEditorSubmitHandler({
2573
+ editor,
2574
+ handleCommand,
2575
+ sendMessage,
2576
+ handleBangLine: runLocalShellLine
2577
+ });
2578
+ editor.onEscape = () => {
2579
+ abortActive();
2580
+ };
2581
+ editor.onCtrlC = () => {
2582
+ const now = Date.now();
2583
+ if (editor.getText().trim().length > 0) {
2584
+ editor.setText("");
2585
+ setActivityStatus("cleared input");
2586
+ tui.requestRender();
2587
+ return;
2588
+ }
2589
+ if (now - lastCtrlCAt < 1e3) {
2590
+ client.stop();
2591
+ tui.stop();
2592
+ process.exit(0);
2593
+ }
2594
+ lastCtrlCAt = now;
2595
+ setActivityStatus("press ctrl+c again to exit");
2596
+ tui.requestRender();
2597
+ };
2598
+ editor.onCtrlD = () => {
2599
+ client.stop();
2600
+ tui.stop();
2601
+ process.exit(0);
2602
+ };
2603
+ editor.onCtrlO = () => {
2604
+ toolsExpanded = !toolsExpanded;
2605
+ chatLog.setToolsExpanded(toolsExpanded);
2606
+ setActivityStatus(toolsExpanded ? "tools expanded" : "tools collapsed");
2607
+ tui.requestRender();
2608
+ };
2609
+ editor.onCtrlL = () => {
2610
+ openModelSelector();
2611
+ };
2612
+ editor.onCtrlG = () => {
2613
+ openAgentSelector();
2614
+ };
2615
+ editor.onCtrlP = () => {
2616
+ openSessionSelector();
2617
+ };
2618
+ editor.onCtrlT = () => {
2619
+ showThinking = !showThinking;
2620
+ loadHistory();
2621
+ };
2622
+ client.onEvent = (evt) => {
2623
+ if (evt.event === "chat") handleChatEvent(evt.payload);
2624
+ if (evt.event === "agent") handleAgentEvent(evt.payload);
2625
+ };
2626
+ client.onConnected = () => {
2627
+ isConnected = true;
2628
+ const reconnected = wasDisconnected;
2629
+ wasDisconnected = false;
2630
+ setConnectionStatus("connected");
2631
+ (async () => {
2632
+ await refreshAgents();
2633
+ updateHeader();
2634
+ await loadHistory();
2635
+ setConnectionStatus(reconnected ? "gateway reconnected" : "gateway connected", 4e3);
2636
+ tui.requestRender();
2637
+ if (!autoMessageSent && autoMessage) {
2638
+ autoMessageSent = true;
2639
+ await sendMessage(autoMessage);
2640
+ }
2641
+ updateFooter();
2642
+ tui.requestRender();
2643
+ })();
2644
+ };
2645
+ client.onDisconnected = (reason) => {
2646
+ isConnected = false;
2647
+ wasDisconnected = true;
2648
+ historyLoaded = false;
2649
+ setConnectionStatus(`gateway disconnected: ${reason?.trim() ? reason.trim() : "closed"}`, 5e3);
2650
+ setActivityStatus("idle");
2651
+ updateFooter();
2652
+ tui.requestRender();
2653
+ };
2654
+ client.onGap = (info) => {
2655
+ setConnectionStatus(`event gap: expected ${info.expected}, got ${info.received}`, 5e3);
2656
+ tui.requestRender();
2657
+ };
2658
+ updateHeader();
2659
+ setConnectionStatus("connecting");
2660
+ updateFooter();
2661
+ tui.start();
2662
+ client.start();
2663
+ await new Promise((resolve) => {
2664
+ const finish = () => resolve();
2665
+ process.once("exit", finish);
2666
+ process.once("SIGINT", finish);
2667
+ process.once("SIGTERM", finish);
2668
+ });
2669
+ }
2670
+
2671
+ //#endregion
2672
+ export { runTui as t };