@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,3364 @@
1
+ import { d as resolveGatewayPort, n as DEFAULT_GATEWAY_PORT } from "./paths-D2ytuv-2.js";
2
+ import { O as isRich, k as theme, m as restoreTerminalState, p as defaultRuntime, y as info } from "./entry.js";
3
+ import { N as resolveConfiguredModelRef, _ as ensureAuthProfileStore, _t as DEFAULT_PROVIDER, gt as DEFAULT_MODEL, ht as DEFAULT_CONTEXT_TOKENS } from "./auth-profiles-DoD7YxsD.js";
4
+ import { r as resolveCliName, t as formatCliCommand } from "./command-format-B0bnyrEA.js";
5
+ import { _ as parseAgentSessionKey, c as normalizeAgentId } from "./session-key-C-ig2pxJ.js";
6
+ import { m as resolveUserPath } from "./utils-7IMqr8vR.js";
7
+ import { n as runExec } from "./exec-CLQSz0CI.js";
8
+ import { t as resolveOpenClawPackageRoot } from "./openclaw-root-_zPXSqgo.js";
9
+ import { c as resolveDefaultAgentId, h as DEFAULT_IDENTITY_FILENAME, p as DEFAULT_BOOTSTRAP_FILENAME, r as resolveAgentDir, s as resolveAgentWorkspaceDir } from "./agent-scope-DBl1We79.js";
10
+ import { c as writeConfigFile, i as loadConfig, j as VERSION, o as readConfigFileSnapshot } from "./config-DSpb2aMV.js";
11
+ import { f as inspectPortUsage, m as formatPortDiagnostics } from "./errors--S5IAxQx.js";
12
+ import { a as findTailscaleBinary, o as getTailnetHostname, s as readTailscaleStatusJson } from "./tailscale-CCLcQalf.js";
13
+ import { n as callGateway, t as buildGatewayConnectionDetails } from "./call-D2DXG0AC.js";
14
+ import { n as listChannelPlugins } from "./plugins-BI-p2ba9.js";
15
+ import { Dr as getMemorySearchManager, Fn as readRestartSentinel, In as summarizeRestartSentinel, Jt as loadProviderUsageSummary, Kn as peekSystemEvents, Qt as listAgentsForGateway, Yt as formatUsageReportLines, _ as randomToken, a as applyWizardMetadata, b as summarizeExistingConfig, c as ensureWorkspaceAndSessions, d as handleReset, dn as lookupContextTokens, g as probeGatewayReachable, h as printWizardHeader, i as DEFAULT_WORKSPACE, l as formatControlUiSshHint, m as openUrl, p as normalizeGatewayTokenInput, q as getRemoteSkillEligibility, s as detectBrowserOpenSupport, v as resolveControlUiLinks, w as normalizeControlUiBasePath, x as waitForGatewayReachable } from "./loader-CU4bkeKe.js";
16
+ import { n as withProgress } from "./progress-D-Oc-KAH.js";
17
+ import { t as WizardCancelledError } from "./prompts-C2D9_VZC.js";
18
+ import { t as resolveChannelDefaultAccountId } from "./helpers-OUt4hxkS.js";
19
+ import { n as setupChannels } from "./onboard-channels-DJz2TusQ.js";
20
+ import { o as resolveStorePath } from "./paths-KUslkJRs.js";
21
+ import { I as resolveMainSessionKey, d as loadSessionStore } from "./sandbox-BGqDfFaH.js";
22
+ import { t as buildChannelSummary } from "./channel-summary-DS0kcHm2.js";
23
+ import { t as collectChannelStatusIssues } from "./channels-status-issues-Dxmd7zYk.js";
24
+ import { r as installCompletion } from "./completion-cli-B5nR7jt8.js";
25
+ import { a as gatewayInstallErrorHint, i as buildGatewayInstallPlan, n as GATEWAY_DAEMON_RUNTIME_OPTIONS, t as DEFAULT_GATEWAY_DAEMON_RUNTIME } from "./daemon-runtime-CHWbAfKs.js";
26
+ import { o as resolveGatewayLogPaths, t as resolveGatewayService } from "./service-C0ccl5rU.js";
27
+ import { r as isSystemdUserServiceAvailable } from "./systemd-kY3NnWdi.js";
28
+ import { o as readLastGatewayErrorLine } from "./service-audit-BM-iyLL7.js";
29
+ import { t as renderTable } from "./table-DDQGlZSe.js";
30
+ import { i as probeGateway, t as runSecurityAudit } from "./audit-Bj_dxNaD.js";
31
+ import { d as applyAuthChoice, g as ensureControlUiAssetsBuilt, h as promptAuthChoiceGrouped, l as resolvePreferredProviderForAuthChoice, o as applyPrimaryModel, r as promptRemoteGatewayConfig, s as promptDefaultModel, t as setupSkills, u as warnIfModelConfigLooksOff } from "./onboard-skills-ByHkU9nx.js";
32
+ import { a as resolveHeartbeatSummaryForAgent, i as healthCommand, n as formatHealthChannelLines, t as formatHealthCheckFailure } from "./health-format-BcsR5dtU.js";
33
+ import { C as resolveEffectiveUpdateChannel, S as normalizeUpdateChannel, c as formatUpdateOneLiner, d as checkShellCompletionStatus, h as compareSemverStrings, l as getUpdateCheckResult, m as checkUpdateStatus, p as ensureCompletionCacheExists, s as formatUpdateAvailableHint, u as resolveUpdateAvailability, x as formatUpdateChannelLabel } from "./update-runner-BfncKnU6.js";
34
+ import { n as logConfigUpdated } from "./logging-BJRQDTME.js";
35
+ import { t as buildWorkspaceHookStatus } from "./hooks-status-BETsyuUR.js";
36
+ import { t as buildWorkspaceSkillStatus } from "./skills-status-cD4rfMR9.js";
37
+ import { t as runTui } from "./tui-DFVs6pRO.js";
38
+ import { t as resolveNodeService } from "./node-service-JEBcPQat.js";
39
+ import { i as redactSecrets, n as formatDuration$1, r as formatGatewayAuthUsed, t as formatAge$1 } from "./format-Dv1wz41T.js";
40
+ import { spawnSync } from "node:child_process";
41
+ import path from "node:path";
42
+ import os from "node:os";
43
+ import fs from "node:fs";
44
+ import crypto from "node:crypto";
45
+ import fs$1 from "node:fs/promises";
46
+
47
+ //#region src/commands/onboard-hooks.ts
48
+ async function setupInternalHooks(cfg, runtime, prompter) {
49
+ await prompter.note([
50
+ "Hooks let you automate actions when agent commands are issued.",
51
+ "Example: Save session context to memory when you issue /new.",
52
+ "",
53
+ "Learn more: https://docs.cryptoclaw.ai/hooks"
54
+ ].join("\n"), "Hooks");
55
+ const eligibleHooks = buildWorkspaceHookStatus(resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg)), { config: cfg }).hooks.filter((h) => h.eligible);
56
+ if (eligibleHooks.length === 0) {
57
+ await prompter.note("No eligible hooks found. You can configure hooks later in your config.", "No Hooks Available");
58
+ return cfg;
59
+ }
60
+ const selected = (await prompter.multiselect({
61
+ message: "Enable hooks?",
62
+ options: [{
63
+ value: "__skip__",
64
+ label: "Skip for now"
65
+ }, ...eligibleHooks.map((hook) => ({
66
+ value: hook.name,
67
+ label: `${hook.emoji ?? "🔗"} ${hook.name}`,
68
+ hint: hook.description
69
+ }))]
70
+ })).filter((name) => name !== "__skip__");
71
+ if (selected.length === 0) return cfg;
72
+ const entries = { ...cfg.hooks?.internal?.entries };
73
+ for (const name of selected) entries[name] = { enabled: true };
74
+ const next = {
75
+ ...cfg,
76
+ hooks: {
77
+ ...cfg.hooks,
78
+ internal: {
79
+ enabled: true,
80
+ entries
81
+ }
82
+ }
83
+ };
84
+ await prompter.note([
85
+ `Enabled ${selected.length} hook${selected.length > 1 ? "s" : ""}: ${selected.join(", ")}`,
86
+ "",
87
+ "You can manage hooks later with:",
88
+ ` ${formatCliCommand("cryptoclaw hooks list")}`,
89
+ ` ${formatCliCommand("cryptoclaw hooks enable <name>")}`,
90
+ ` ${formatCliCommand("cryptoclaw hooks disable <name>")}`
91
+ ].join("\n"), "Hooks Configured");
92
+ return next;
93
+ }
94
+
95
+ //#endregion
96
+ //#region src/commands/onboard-wallet.ts
97
+ /**
98
+ * Wallet setup step for the onboarding wizard.
99
+ * Prompts the user to create, import, or skip wallet setup.
100
+ */
101
+ async function setupWallet(stateDir, prompter, opts) {
102
+ if (opts.skipWallet) return { action: "skipped" };
103
+ let WalletManager;
104
+ try {
105
+ WalletManager = (await import("./wallet-manager-CT1ykq2O.js")).WalletManager;
106
+ } catch {
107
+ await prompter.note("Blockchain extension not installed. Skipping wallet setup.\nInstall it later and run: cryptoclaw wallet create", "Wallet");
108
+ return { action: "skipped" };
109
+ }
110
+ const wm = new WalletManager(stateDir);
111
+ if (opts.walletCreate) {
112
+ const passphrase = process.env.CRYPTOCLAW_WALLET_PASSPHRASE;
113
+ if (!passphrase) throw new Error("--wallet-create requires CRYPTOCLAW_WALLET_PASSPHRASE environment variable");
114
+ const label = opts.walletLabel ?? "Default";
115
+ const wallet = await wm.createWallet(label, passphrase);
116
+ return {
117
+ action: "created",
118
+ address: wallet.address,
119
+ label: wallet.label
120
+ };
121
+ }
122
+ if (opts.walletImport) {
123
+ const privateKey = process.env.CRYPTOCLAW_WALLET_PRIVATE_KEY;
124
+ const passphrase = process.env.CRYPTOCLAW_WALLET_PASSPHRASE;
125
+ if (!privateKey || !passphrase) throw new Error("--wallet-import requires CRYPTOCLAW_WALLET_PRIVATE_KEY and CRYPTOCLAW_WALLET_PASSPHRASE environment variables");
126
+ const label = opts.walletLabel ?? "Imported";
127
+ const wallet = await wm.importWallet(privateKey, label, passphrase);
128
+ return {
129
+ action: "imported",
130
+ address: wallet.address,
131
+ label: wallet.label
132
+ };
133
+ }
134
+ if (wm.hasWallets()) {
135
+ const { wallets, activeWalletId } = wm.listWallets();
136
+ const active = wallets.find((w) => w.id === activeWalletId);
137
+ await prompter.note(`Active wallet: ${active?.label ?? "none"} (${active?.address ?? "—"})\nTotal wallets: ${wallets.length}`, "Existing Wallets");
138
+ const action = await prompter.select({
139
+ message: "Wallet setup",
140
+ options: [
141
+ {
142
+ value: "keep",
143
+ label: "Keep existing wallets"
144
+ },
145
+ {
146
+ value: "create",
147
+ label: "Create another wallet"
148
+ },
149
+ {
150
+ value: "skip",
151
+ label: "Skip"
152
+ }
153
+ ],
154
+ initialValue: "keep"
155
+ });
156
+ if (action === "keep" || action === "skip") return { action: action === "keep" ? "kept" : "skipped" };
157
+ } else {
158
+ const action = await prompter.select({
159
+ message: "Set up a blockchain wallet?",
160
+ options: [
161
+ {
162
+ value: "create",
163
+ label: "Create new wallet",
164
+ hint: "Generate a fresh key pair"
165
+ },
166
+ {
167
+ value: "import",
168
+ label: "Import existing wallet",
169
+ hint: "Paste a private key"
170
+ },
171
+ {
172
+ value: "skip",
173
+ label: "Skip for now"
174
+ }
175
+ ],
176
+ initialValue: "create"
177
+ });
178
+ if (action === "skip") return { action: "skipped" };
179
+ if (action === "import") return importWalletInteractive(wm, prompter, opts);
180
+ }
181
+ return createWalletInteractive(wm, prompter, opts);
182
+ }
183
+ async function createWalletInteractive(wm, prompter, opts) {
184
+ const label = opts.walletLabel ?? await prompter.text({
185
+ message: "Wallet label",
186
+ initialValue: "Default",
187
+ placeholder: "Default"
188
+ });
189
+ const passphrase = await prompter.text({
190
+ message: "Enter a passphrase to encrypt your wallet",
191
+ validate: (v) => v.length < 8 ? "Passphrase must be at least 8 characters" : void 0
192
+ });
193
+ if (await prompter.text({
194
+ message: "Confirm passphrase",
195
+ validate: (v) => v !== passphrase ? "Passphrases do not match" : void 0
196
+ }) !== passphrase) {
197
+ await prompter.note("Passphrases did not match. Skipping wallet creation.", "Wallet");
198
+ return { action: "skipped" };
199
+ }
200
+ const spinner = prompter.progress("Creating wallet...");
201
+ const wallet = await wm.createWallet(label, passphrase);
202
+ spinner.stop(`Wallet created: ${wallet.address}`);
203
+ await prompter.note([
204
+ `Address: ${wallet.address}`,
205
+ `Label: ${wallet.label}`,
206
+ "",
207
+ "Back up your passphrase securely.",
208
+ "You'll need it to sign transactions and export your key."
209
+ ].join("\n"), "Wallet Created");
210
+ return {
211
+ action: "created",
212
+ address: wallet.address,
213
+ label: wallet.label
214
+ };
215
+ }
216
+ async function importWalletInteractive(wm, prompter, opts) {
217
+ await prompter.note("Your private key will be encrypted with AES-256-GCM and stored locally.\nIt will never be exposed in agent chat or session transcripts.", "Security");
218
+ const privateKey = await prompter.text({
219
+ message: "Private key (0x...)",
220
+ validate: (v) => {
221
+ if (!/^0x[a-fA-F0-9]{64}$/.test(v)) return "Invalid private key format. Expected 0x followed by 64 hex characters.";
222
+ }
223
+ });
224
+ const label = opts.walletLabel ?? await prompter.text({
225
+ message: "Wallet label",
226
+ initialValue: "Imported",
227
+ placeholder: "Imported"
228
+ });
229
+ const passphrase = await prompter.text({
230
+ message: "Enter a passphrase to encrypt the wallet",
231
+ validate: (v) => v.length < 8 ? "Passphrase must be at least 8 characters" : void 0
232
+ });
233
+ const spinner = prompter.progress("Importing wallet...");
234
+ const wallet = await wm.importWallet(privateKey, label, passphrase);
235
+ spinner.stop(`Wallet imported: ${wallet.address}`);
236
+ await prompter.note([
237
+ `Address: ${wallet.address}`,
238
+ `Label: ${wallet.label}`,
239
+ "",
240
+ "Back up your passphrase securely."
241
+ ].join("\n"), "Wallet Imported");
242
+ return {
243
+ action: "imported",
244
+ address: wallet.address,
245
+ label: wallet.label
246
+ };
247
+ }
248
+
249
+ //#endregion
250
+ //#region src/wizard/onboarding.finalize.ts
251
+ async function finalizeOnboardingWizard(options) {
252
+ const { flow, opts, baseConfig, nextConfig, settings, prompter, runtime } = options;
253
+ const withWizardProgress = async (label, options, work) => {
254
+ const progress = prompter.progress(label);
255
+ try {
256
+ return await work(progress);
257
+ } finally {
258
+ progress.stop(options.doneMessage);
259
+ }
260
+ };
261
+ const systemdAvailable = process.platform === "linux" ? await isSystemdUserServiceAvailable() : true;
262
+ if (process.platform === "linux" && !systemdAvailable) await prompter.note("Systemd user services are unavailable. Skipping lingering checks and service install.", "Systemd");
263
+ if (process.platform === "linux" && systemdAvailable) {
264
+ const { ensureSystemdUserLingerInteractive } = await import("./systemd-linger-CFK5jDdq.js").then((n) => n.r);
265
+ await ensureSystemdUserLingerInteractive({
266
+ runtime,
267
+ prompter: {
268
+ confirm: prompter.confirm,
269
+ note: prompter.note
270
+ },
271
+ reason: "Linux installs use a systemd user service by default. Without lingering, systemd stops the user session on logout/idle and kills the Gateway.",
272
+ requireConfirm: false
273
+ });
274
+ }
275
+ const explicitInstallDaemon = typeof opts.installDaemon === "boolean" ? opts.installDaemon : void 0;
276
+ let installDaemon;
277
+ if (explicitInstallDaemon !== void 0) installDaemon = explicitInstallDaemon;
278
+ else if (process.platform === "linux" && !systemdAvailable) installDaemon = false;
279
+ else if (flow === "quickstart") installDaemon = true;
280
+ else installDaemon = await prompter.confirm({
281
+ message: "Install Gateway service (recommended)",
282
+ initialValue: true
283
+ });
284
+ if (process.platform === "linux" && !systemdAvailable && installDaemon) {
285
+ await prompter.note("Systemd user services are unavailable; skipping service install. Use your container supervisor or `docker compose up -d`.", "Gateway service");
286
+ installDaemon = false;
287
+ }
288
+ if (installDaemon) {
289
+ const daemonRuntime = flow === "quickstart" ? DEFAULT_GATEWAY_DAEMON_RUNTIME : await prompter.select({
290
+ message: "Gateway service runtime",
291
+ options: GATEWAY_DAEMON_RUNTIME_OPTIONS,
292
+ initialValue: opts.daemonRuntime ?? DEFAULT_GATEWAY_DAEMON_RUNTIME
293
+ });
294
+ if (flow === "quickstart") await prompter.note("QuickStart uses Node for the Gateway service (stable + supported).", "Gateway service runtime");
295
+ const service = resolveGatewayService();
296
+ const loaded = await service.isLoaded({ env: process.env });
297
+ if (loaded) {
298
+ const action = await prompter.select({
299
+ message: "Gateway service already installed",
300
+ options: [
301
+ {
302
+ value: "restart",
303
+ label: "Restart"
304
+ },
305
+ {
306
+ value: "reinstall",
307
+ label: "Reinstall"
308
+ },
309
+ {
310
+ value: "skip",
311
+ label: "Skip"
312
+ }
313
+ ]
314
+ });
315
+ if (action === "restart") await withWizardProgress("Gateway service", { doneMessage: "Gateway service restarted." }, async (progress) => {
316
+ progress.update("Restarting Gateway service…");
317
+ await service.restart({
318
+ env: process.env,
319
+ stdout: process.stdout
320
+ });
321
+ });
322
+ else if (action === "reinstall") await withWizardProgress("Gateway service", { doneMessage: "Gateway service uninstalled." }, async (progress) => {
323
+ progress.update("Uninstalling Gateway service…");
324
+ await service.uninstall({
325
+ env: process.env,
326
+ stdout: process.stdout
327
+ });
328
+ });
329
+ }
330
+ if (!loaded || loaded && !await service.isLoaded({ env: process.env })) {
331
+ const progress = prompter.progress("Gateway service");
332
+ let installError = null;
333
+ try {
334
+ progress.update("Preparing Gateway service…");
335
+ const { programArguments, workingDirectory, environment } = await buildGatewayInstallPlan({
336
+ env: process.env,
337
+ port: settings.port,
338
+ token: settings.gatewayToken,
339
+ runtime: daemonRuntime,
340
+ warn: (message, title) => prompter.note(message, title),
341
+ config: nextConfig
342
+ });
343
+ progress.update("Installing Gateway service…");
344
+ await service.install({
345
+ env: process.env,
346
+ stdout: process.stdout,
347
+ programArguments,
348
+ workingDirectory,
349
+ environment
350
+ });
351
+ } catch (err) {
352
+ installError = err instanceof Error ? err.message : String(err);
353
+ } finally {
354
+ progress.stop(installError ? "Gateway service install failed." : "Gateway service installed.");
355
+ }
356
+ if (installError) {
357
+ await prompter.note(`Gateway service install failed: ${installError}`, "Gateway");
358
+ await prompter.note(gatewayInstallErrorHint(), "Gateway");
359
+ }
360
+ }
361
+ }
362
+ if (!opts.skipHealth) {
363
+ await waitForGatewayReachable({
364
+ url: resolveControlUiLinks({
365
+ bind: nextConfig.gateway?.bind ?? "loopback",
366
+ port: settings.port,
367
+ customBindHost: nextConfig.gateway?.customBindHost,
368
+ basePath: void 0
369
+ }).wsUrl,
370
+ token: settings.gatewayToken,
371
+ deadlineMs: 15e3
372
+ });
373
+ try {
374
+ await healthCommand({
375
+ json: false,
376
+ timeoutMs: 1e4
377
+ }, runtime);
378
+ } catch (err) {
379
+ runtime.error(formatHealthCheckFailure(err));
380
+ await prompter.note([
381
+ "Docs:",
382
+ "https://docs.cryptoclaw.ai/gateway/health",
383
+ "https://docs.cryptoclaw.ai/gateway/troubleshooting"
384
+ ].join("\n"), "Health check help");
385
+ }
386
+ }
387
+ const controlUiEnabled = nextConfig.gateway?.controlUi?.enabled ?? baseConfig.gateway?.controlUi?.enabled ?? true;
388
+ if (!opts.skipUi && controlUiEnabled) {
389
+ const controlUiAssets = await ensureControlUiAssetsBuilt(runtime);
390
+ if (!controlUiAssets.ok && controlUiAssets.message) runtime.error(controlUiAssets.message);
391
+ }
392
+ await prompter.note("Add macOS, iOS, or Android nodes for camera, canvas, and notifications.", "Optional apps");
393
+ const controlUiBasePath = nextConfig.gateway?.controlUi?.basePath ?? baseConfig.gateway?.controlUi?.basePath;
394
+ const links = resolveControlUiLinks({
395
+ bind: settings.bind,
396
+ port: settings.port,
397
+ customBindHost: settings.customBindHost,
398
+ basePath: controlUiBasePath
399
+ });
400
+ const dashboardUrl = links.httpUrl;
401
+ const gatewayProbe = await probeGatewayReachable({
402
+ url: links.wsUrl,
403
+ token: settings.authMode === "token" ? settings.gatewayToken : void 0,
404
+ password: settings.authMode === "password" ? nextConfig.gateway?.auth?.password : ""
405
+ });
406
+ const gatewayStatusLine = gatewayProbe.ok ? "Gateway: reachable" : `Gateway: not detected${gatewayProbe.detail ? ` (${gatewayProbe.detail})` : ""}`;
407
+ const bootstrapPath = path.join(resolveUserPath(options.workspaceDir), DEFAULT_BOOTSTRAP_FILENAME);
408
+ const hasBootstrap = await fs$1.access(bootstrapPath).then(() => true).catch(() => false);
409
+ await prompter.note([
410
+ `Web UI: ${dashboardUrl}`,
411
+ `Gateway WS: ${links.wsUrl}`,
412
+ gatewayStatusLine,
413
+ "Docs: https://docs.cryptoclaw.ai/web/control-ui"
414
+ ].filter(Boolean).join("\n"), "Control UI");
415
+ let controlUiOpened = false;
416
+ let controlUiOpenHint;
417
+ let hatchChoice = null;
418
+ let launchedTui = false;
419
+ if (!opts.skipUi && gatewayProbe.ok) {
420
+ if (hasBootstrap) await prompter.note("Send your first message to your crypto AI agent.", "Start TUI");
421
+ await prompter.note([
422
+ ...settings.authMode === "token" && settings.gatewayToken ? [`Gateway token (save this!): ${settings.gatewayToken}`] : ["Gateway token: shared auth for the Gateway + Control UI."],
423
+ "Stored in: ~/.cryptoclaw/cryptoclaw.json (gateway.auth.token) or CRYPTOCLAW_GATEWAY_TOKEN.",
424
+ `View token: ${formatCliCommand("cryptoclaw config get gateway.auth.token")}`,
425
+ `Generate token: ${formatCliCommand("cryptoclaw doctor --generate-gateway-token")}`,
426
+ "The Web UI auto-reads the token from the Gateway — no copy-paste needed.",
427
+ `Open the dashboard anytime: ${formatCliCommand("cryptoclaw dashboard --no-open")}`
428
+ ].join("\n"), "Token");
429
+ hatchChoice = await prompter.select({
430
+ message: "How do you want to hatch your bot?",
431
+ options: [
432
+ {
433
+ value: "tui",
434
+ label: "Hatch in TUI (recommended)"
435
+ },
436
+ {
437
+ value: "web",
438
+ label: "Open the Web UI"
439
+ },
440
+ {
441
+ value: "later",
442
+ label: "Do this later"
443
+ }
444
+ ],
445
+ initialValue: "tui"
446
+ });
447
+ if (hatchChoice === "tui") {
448
+ restoreTerminalState("pre-onboarding tui");
449
+ await runTui({
450
+ url: links.wsUrl,
451
+ token: settings.authMode === "token" ? settings.gatewayToken : void 0,
452
+ password: settings.authMode === "password" ? nextConfig.gateway?.auth?.password : "",
453
+ deliver: false,
454
+ message: hasBootstrap ? "Wake up, my friend!" : void 0
455
+ });
456
+ launchedTui = true;
457
+ } else if (hatchChoice === "web") {
458
+ if ((await detectBrowserOpenSupport()).ok) {
459
+ controlUiOpened = await openUrl(dashboardUrl);
460
+ if (!controlUiOpened) controlUiOpenHint = formatControlUiSshHint({
461
+ port: settings.port,
462
+ basePath: controlUiBasePath
463
+ });
464
+ } else controlUiOpenHint = formatControlUiSshHint({
465
+ port: settings.port,
466
+ basePath: controlUiBasePath
467
+ });
468
+ await prompter.note([
469
+ `Dashboard link: ${dashboardUrl}`,
470
+ controlUiOpened ? "Opened in your browser. Keep that tab to control CryptoClaw." : "Copy/paste this URL in a browser on this machine to control CryptoClaw.",
471
+ controlUiOpenHint
472
+ ].filter(Boolean).join("\n"), "Dashboard ready");
473
+ } else await prompter.note(`When you're ready: ${formatCliCommand("cryptoclaw dashboard --no-open")}`, "Later");
474
+ } else if (opts.skipUi) await prompter.note("Skipping Control UI/TUI prompts.", "Control UI");
475
+ await prompter.note("Running agents on your computer is risky — harden your setup: https://docs.cryptoclaw.ai/security", "Security");
476
+ const cliName = resolveCliName();
477
+ const completionStatus = await checkShellCompletionStatus(cliName);
478
+ if (completionStatus.usesSlowPattern) {
479
+ if (await ensureCompletionCacheExists(cliName)) await installCompletion(completionStatus.shell, true, cliName);
480
+ } else if (completionStatus.profileInstalled && !completionStatus.cacheExists) await ensureCompletionCacheExists(cliName);
481
+ else if (!completionStatus.profileInstalled) {
482
+ if (await prompter.confirm({
483
+ message: `Enable ${completionStatus.shell} shell completion for ${cliName}?`,
484
+ initialValue: true
485
+ })) if (await ensureCompletionCacheExists(cliName)) {
486
+ await installCompletion(completionStatus.shell, true, cliName);
487
+ const profileHint = completionStatus.shell === "zsh" ? "~/.zshrc" : completionStatus.shell === "bash" ? "~/.bashrc" : "~/.config/fish/config.fish";
488
+ await prompter.note(`Shell completion installed. Restart your shell or run: source ${profileHint}`, "Shell completion");
489
+ } else await prompter.note(`Failed to generate completion cache. Run \`${cliName} completion --install\` later.`, "Shell completion");
490
+ }
491
+ if (!opts.skipUi && settings.authMode === "token" && Boolean(settings.gatewayToken) && hatchChoice === null) {
492
+ if ((await detectBrowserOpenSupport()).ok) {
493
+ controlUiOpened = await openUrl(dashboardUrl);
494
+ if (!controlUiOpened) controlUiOpenHint = formatControlUiSshHint({
495
+ port: settings.port,
496
+ basePath: controlUiBasePath
497
+ });
498
+ } else controlUiOpenHint = formatControlUiSshHint({
499
+ port: settings.port,
500
+ basePath: controlUiBasePath
501
+ });
502
+ await prompter.note([
503
+ `Dashboard link: ${dashboardUrl}`,
504
+ controlUiOpened ? "Opened in your browser. Keep that tab to control CryptoClaw." : "Copy/paste this URL in a browser on this machine to control CryptoClaw.",
505
+ controlUiOpenHint
506
+ ].filter(Boolean).join("\n"), "Dashboard ready");
507
+ }
508
+ const webSearchKey = (nextConfig.tools?.web?.search?.apiKey ?? "").trim();
509
+ const webSearchEnv = (process.env.BRAVE_API_KEY ?? "").trim();
510
+ if (!Boolean(webSearchKey || webSearchEnv)) await prompter.note(`Web search requires a Brave API key. Run ${formatCliCommand("cryptoclaw configure --section web")} or set BRAVE_API_KEY.`, "Web search (optional)");
511
+ const walletSuffix = options.walletAddress ? ` Wallet: ${options.walletAddress}` : "";
512
+ await prompter.outro(controlUiOpened ? `Setup complete. Dashboard opened; keep that tab to control CryptoClaw.${walletSuffix}` : `Setup complete. Use the dashboard link above to control CryptoClaw.${walletSuffix}`);
513
+ return { launchedTui };
514
+ }
515
+
516
+ //#endregion
517
+ //#region src/wizard/onboarding.gateway-config.ts
518
+ async function configureGatewayForOnboarding(opts) {
519
+ const { flow, localPort, quickstartGateway, prompter } = opts;
520
+ let { nextConfig } = opts;
521
+ const port = flow === "quickstart" ? quickstartGateway.port : Number.parseInt(String(await prompter.text({
522
+ message: "Gateway port",
523
+ initialValue: String(localPort),
524
+ validate: (value) => Number.isFinite(Number(value)) ? void 0 : "Invalid port"
525
+ })), 10);
526
+ let bind = flow === "quickstart" ? quickstartGateway.bind : await prompter.select({
527
+ message: "Gateway bind",
528
+ options: [
529
+ {
530
+ value: "loopback",
531
+ label: "Loopback (127.0.0.1)"
532
+ },
533
+ {
534
+ value: "lan",
535
+ label: "LAN (0.0.0.0)"
536
+ },
537
+ {
538
+ value: "tailnet",
539
+ label: "Tailnet (Tailscale IP)"
540
+ },
541
+ {
542
+ value: "auto",
543
+ label: "Auto (Loopback → LAN)"
544
+ },
545
+ {
546
+ value: "custom",
547
+ label: "Custom IP"
548
+ }
549
+ ]
550
+ });
551
+ let customBindHost = quickstartGateway.customBindHost;
552
+ if (bind === "custom") {
553
+ if (flow !== "quickstart" || !customBindHost) {
554
+ const input = await prompter.text({
555
+ message: "Custom IP address",
556
+ placeholder: "192.168.1.100",
557
+ initialValue: customBindHost ?? "",
558
+ validate: (value) => {
559
+ if (!value) return "IP address is required for custom bind mode";
560
+ const parts = value.trim().split(".");
561
+ if (parts.length !== 4) return "Invalid IPv4 address (e.g., 192.168.1.100)";
562
+ if (parts.every((part) => {
563
+ const n = parseInt(part, 10);
564
+ return !Number.isNaN(n) && n >= 0 && n <= 255 && part === String(n);
565
+ })) return;
566
+ return "Invalid IPv4 address (each octet must be 0-255)";
567
+ }
568
+ });
569
+ customBindHost = typeof input === "string" ? input.trim() : void 0;
570
+ }
571
+ }
572
+ let authMode = flow === "quickstart" ? quickstartGateway.authMode : await prompter.select({
573
+ message: "Gateway auth",
574
+ options: [{
575
+ value: "token",
576
+ label: "Token",
577
+ hint: "Recommended default (local + remote)"
578
+ }, {
579
+ value: "password",
580
+ label: "Password"
581
+ }],
582
+ initialValue: "token"
583
+ });
584
+ const tailscaleMode = flow === "quickstart" ? quickstartGateway.tailscaleMode : await prompter.select({
585
+ message: "Tailscale exposure",
586
+ options: [
587
+ {
588
+ value: "off",
589
+ label: "Off",
590
+ hint: "No Tailscale exposure"
591
+ },
592
+ {
593
+ value: "serve",
594
+ label: "Serve",
595
+ hint: "Private HTTPS for your tailnet (devices on Tailscale)"
596
+ },
597
+ {
598
+ value: "funnel",
599
+ label: "Funnel",
600
+ hint: "Public HTTPS via Tailscale Funnel (internet)"
601
+ }
602
+ ]
603
+ });
604
+ if (tailscaleMode !== "off") {
605
+ if (!await findTailscaleBinary()) await prompter.note([
606
+ "Tailscale binary not found in PATH or /Applications.",
607
+ "Ensure Tailscale is installed from:",
608
+ " https://tailscale.com/download/mac",
609
+ "",
610
+ "You can continue setup, but serve/funnel will fail at runtime."
611
+ ].join("\n"), "Tailscale Warning");
612
+ }
613
+ let tailscaleResetOnExit = flow === "quickstart" ? quickstartGateway.tailscaleResetOnExit : false;
614
+ if (tailscaleMode !== "off" && flow !== "quickstart") {
615
+ await prompter.note([
616
+ "Docs:",
617
+ "https://docs.cryptoclaw.ai/gateway/tailscale",
618
+ "https://docs.cryptoclaw.ai/web"
619
+ ].join("\n"), "Tailscale");
620
+ tailscaleResetOnExit = Boolean(await prompter.confirm({
621
+ message: "Reset Tailscale serve/funnel on exit?",
622
+ initialValue: false
623
+ }));
624
+ }
625
+ if (tailscaleMode !== "off" && bind !== "loopback") {
626
+ await prompter.note("Tailscale requires bind=loopback. Adjusting bind to loopback.", "Note");
627
+ bind = "loopback";
628
+ customBindHost = void 0;
629
+ }
630
+ if (tailscaleMode === "funnel" && authMode !== "password") {
631
+ await prompter.note("Tailscale funnel requires password auth.", "Note");
632
+ authMode = "password";
633
+ }
634
+ let gatewayToken;
635
+ if (authMode === "token") if (flow === "quickstart") gatewayToken = quickstartGateway.token ?? randomToken();
636
+ else gatewayToken = normalizeGatewayTokenInput(await prompter.text({
637
+ message: "Gateway token (blank to generate)",
638
+ placeholder: "Needed for multi-machine or non-loopback access",
639
+ initialValue: quickstartGateway.token ?? ""
640
+ })) || randomToken();
641
+ if (authMode === "password") {
642
+ const password = flow === "quickstart" && quickstartGateway.password ? quickstartGateway.password : await prompter.text({
643
+ message: "Gateway password",
644
+ validate: (value) => value?.trim() ? void 0 : "Required"
645
+ });
646
+ nextConfig = {
647
+ ...nextConfig,
648
+ gateway: {
649
+ ...nextConfig.gateway,
650
+ auth: {
651
+ ...nextConfig.gateway?.auth,
652
+ mode: "password",
653
+ password: String(password).trim()
654
+ }
655
+ }
656
+ };
657
+ } else if (authMode === "token") nextConfig = {
658
+ ...nextConfig,
659
+ gateway: {
660
+ ...nextConfig.gateway,
661
+ auth: {
662
+ ...nextConfig.gateway?.auth,
663
+ mode: "token",
664
+ token: gatewayToken
665
+ }
666
+ }
667
+ };
668
+ nextConfig = {
669
+ ...nextConfig,
670
+ gateway: {
671
+ ...nextConfig.gateway,
672
+ port,
673
+ bind,
674
+ ...bind === "custom" && customBindHost ? { customBindHost } : {},
675
+ tailscale: {
676
+ ...nextConfig.gateway?.tailscale,
677
+ mode: tailscaleMode,
678
+ resetOnExit: tailscaleResetOnExit
679
+ }
680
+ }
681
+ };
682
+ return {
683
+ nextConfig,
684
+ settings: {
685
+ port,
686
+ bind,
687
+ customBindHost: bind === "custom" ? customBindHost : void 0,
688
+ authMode,
689
+ gatewayToken,
690
+ tailscaleMode,
691
+ tailscaleResetOnExit
692
+ }
693
+ };
694
+ }
695
+
696
+ //#endregion
697
+ //#region src/wizard/onboarding.ts
698
+ async function requireRiskAcknowledgement(params) {
699
+ if (params.opts.acceptRisk === true) return;
700
+ await params.prompter.note([
701
+ "Security warning — please read.",
702
+ "",
703
+ "CryptoClaw is a hobby project and still in beta. Expect sharp edges.",
704
+ "This bot can read files and run actions if tools are enabled.",
705
+ "A bad prompt can trick it into doing unsafe things.",
706
+ "Never share your wallet passphrase or private keys with anyone — including AI agents.",
707
+ "",
708
+ "If you're not comfortable with basic security and access control, don't run CryptoClaw.",
709
+ "Ask someone experienced to help before enabling tools or exposing it to the internet.",
710
+ "",
711
+ "Recommended baseline:",
712
+ "- Pairing/allowlists + mention gating.",
713
+ "- Sandbox + least-privilege tools.",
714
+ "- Keep secrets out of the agent’s reachable filesystem.",
715
+ "- Use the strongest available model for any bot with tools or untrusted inboxes.",
716
+ "",
717
+ "Run regularly:",
718
+ "cryptoclaw security audit --deep",
719
+ "cryptoclaw security audit --fix",
720
+ "",
721
+ "Must read: https://docs.cryptoclaw.ai/gateway/security"
722
+ ].join("\n"), "Security");
723
+ if (!await params.prompter.confirm({
724
+ message: "I understand this is powerful and inherently risky. Continue?",
725
+ initialValue: false
726
+ })) throw new WizardCancelledError("risk not accepted");
727
+ }
728
+ async function runOnboardingWizard(opts, runtime = defaultRuntime, prompter) {
729
+ printWizardHeader(runtime);
730
+ await prompter.intro("CryptoClaw setup");
731
+ await requireRiskAcknowledgement({
732
+ opts,
733
+ prompter
734
+ });
735
+ const snapshot = await readConfigFileSnapshot();
736
+ let baseConfig = snapshot.valid ? snapshot.config : {};
737
+ if (snapshot.exists && !snapshot.valid) {
738
+ await prompter.note(summarizeExistingConfig(baseConfig), "Invalid config");
739
+ if (snapshot.issues.length > 0) await prompter.note([
740
+ ...snapshot.issues.map((iss) => `- ${iss.path}: ${iss.message}`),
741
+ "",
742
+ "Docs: https://docs.cryptoclaw.ai/gateway/configuration"
743
+ ].join("\n"), "Config issues");
744
+ await prompter.outro(`Config invalid. Run \`${formatCliCommand("cryptoclaw doctor")}\` to repair it, then re-run onboarding.`);
745
+ runtime.exit(1);
746
+ return;
747
+ }
748
+ const quickstartHint = `Configure details later via ${formatCliCommand("cryptoclaw configure")}.`;
749
+ const manualHint = "Configure port, network, Tailscale, and auth options.";
750
+ const explicitFlowRaw = opts.flow?.trim();
751
+ const normalizedExplicitFlow = explicitFlowRaw === "manual" ? "advanced" : explicitFlowRaw;
752
+ if (normalizedExplicitFlow && normalizedExplicitFlow !== "quickstart" && normalizedExplicitFlow !== "advanced") {
753
+ runtime.error("Invalid --flow (use quickstart, manual, or advanced).");
754
+ runtime.exit(1);
755
+ return;
756
+ }
757
+ let flow = (normalizedExplicitFlow === "quickstart" || normalizedExplicitFlow === "advanced" ? normalizedExplicitFlow : void 0) ?? await prompter.select({
758
+ message: "Onboarding mode",
759
+ options: [{
760
+ value: "quickstart",
761
+ label: "QuickStart",
762
+ hint: quickstartHint
763
+ }, {
764
+ value: "advanced",
765
+ label: "Manual",
766
+ hint: manualHint
767
+ }],
768
+ initialValue: "quickstart"
769
+ });
770
+ if (opts.mode === "remote" && flow === "quickstart") {
771
+ await prompter.note("QuickStart only supports local gateways. Switching to Manual mode.", "QuickStart");
772
+ flow = "advanced";
773
+ }
774
+ if (snapshot.exists) {
775
+ await prompter.note(summarizeExistingConfig(baseConfig), "Existing config detected");
776
+ if (await prompter.select({
777
+ message: "Config handling",
778
+ options: [
779
+ {
780
+ value: "keep",
781
+ label: "Use existing values"
782
+ },
783
+ {
784
+ value: "modify",
785
+ label: "Update values"
786
+ },
787
+ {
788
+ value: "reset",
789
+ label: "Reset"
790
+ }
791
+ ]
792
+ }) === "reset") {
793
+ const workspaceDefault = baseConfig.agents?.defaults?.workspace ?? DEFAULT_WORKSPACE;
794
+ await handleReset(await prompter.select({
795
+ message: "Reset scope",
796
+ options: [
797
+ {
798
+ value: "config",
799
+ label: "Config only"
800
+ },
801
+ {
802
+ value: "config+creds+sessions",
803
+ label: "Config + creds + sessions"
804
+ },
805
+ {
806
+ value: "full",
807
+ label: "Full reset (config + creds + sessions + workspace)"
808
+ }
809
+ ]
810
+ }), resolveUserPath(workspaceDefault), runtime);
811
+ baseConfig = {};
812
+ }
813
+ }
814
+ const quickstartGateway = (() => {
815
+ const hasExisting = typeof baseConfig.gateway?.port === "number" || baseConfig.gateway?.bind !== void 0 || baseConfig.gateway?.auth?.mode !== void 0 || baseConfig.gateway?.auth?.token !== void 0 || baseConfig.gateway?.auth?.password !== void 0 || baseConfig.gateway?.customBindHost !== void 0 || baseConfig.gateway?.tailscale?.mode !== void 0;
816
+ const bindRaw = baseConfig.gateway?.bind;
817
+ const bind = bindRaw === "loopback" || bindRaw === "lan" || bindRaw === "auto" || bindRaw === "custom" || bindRaw === "tailnet" ? bindRaw : "loopback";
818
+ let authMode = "token";
819
+ if (baseConfig.gateway?.auth?.mode === "token" || baseConfig.gateway?.auth?.mode === "password") authMode = baseConfig.gateway.auth.mode;
820
+ else if (baseConfig.gateway?.auth?.token) authMode = "token";
821
+ else if (baseConfig.gateway?.auth?.password) authMode = "password";
822
+ const tailscaleRaw = baseConfig.gateway?.tailscale?.mode;
823
+ const tailscaleMode = tailscaleRaw === "off" || tailscaleRaw === "serve" || tailscaleRaw === "funnel" ? tailscaleRaw : "off";
824
+ return {
825
+ hasExisting,
826
+ port: resolveGatewayPort(baseConfig),
827
+ bind,
828
+ authMode,
829
+ tailscaleMode,
830
+ token: baseConfig.gateway?.auth?.token,
831
+ password: baseConfig.gateway?.auth?.password,
832
+ customBindHost: baseConfig.gateway?.customBindHost,
833
+ tailscaleResetOnExit: baseConfig.gateway?.tailscale?.resetOnExit ?? false
834
+ };
835
+ })();
836
+ if (flow === "quickstart") {
837
+ const formatBind = (value) => {
838
+ if (value === "loopback") return "Loopback (127.0.0.1)";
839
+ if (value === "lan") return "LAN";
840
+ if (value === "custom") return "Custom IP";
841
+ if (value === "tailnet") return "Tailnet (Tailscale IP)";
842
+ return "Auto";
843
+ };
844
+ const formatAuth = (value) => {
845
+ if (value === "token") return "Token (default)";
846
+ return "Password";
847
+ };
848
+ const formatTailscale = (value) => {
849
+ if (value === "off") return "Off";
850
+ if (value === "serve") return "Serve";
851
+ return "Funnel";
852
+ };
853
+ const quickstartLines = quickstartGateway.hasExisting ? [
854
+ "Keeping your current gateway settings:",
855
+ `Gateway port: ${quickstartGateway.port}`,
856
+ `Gateway bind: ${formatBind(quickstartGateway.bind)}`,
857
+ ...quickstartGateway.bind === "custom" && quickstartGateway.customBindHost ? [`Gateway custom IP: ${quickstartGateway.customBindHost}`] : [],
858
+ `Gateway auth: ${formatAuth(quickstartGateway.authMode)}`,
859
+ `Tailscale exposure: ${formatTailscale(quickstartGateway.tailscaleMode)}`,
860
+ "Direct to chat channels."
861
+ ] : [
862
+ `Gateway port: ${DEFAULT_GATEWAY_PORT}`,
863
+ "Gateway bind: Loopback (127.0.0.1)",
864
+ "Gateway auth: Token (default)",
865
+ "Tailscale exposure: Off",
866
+ "Direct to chat channels."
867
+ ];
868
+ await prompter.note(quickstartLines.join("\n"), "QuickStart");
869
+ }
870
+ const localPort = resolveGatewayPort(baseConfig);
871
+ const localUrl = `ws://127.0.0.1:${localPort}`;
872
+ const localProbe = await probeGatewayReachable({
873
+ url: localUrl,
874
+ token: baseConfig.gateway?.auth?.token ?? process.env.CRYPTOCLAW_GATEWAY_TOKEN,
875
+ password: baseConfig.gateway?.auth?.password ?? process.env.CRYPTOCLAW_GATEWAY_PASSWORD
876
+ });
877
+ const remoteUrl = baseConfig.gateway?.remote?.url?.trim() ?? "";
878
+ const remoteProbe = remoteUrl ? await probeGatewayReachable({
879
+ url: remoteUrl,
880
+ token: baseConfig.gateway?.remote?.token
881
+ }) : null;
882
+ const mode = opts.mode ?? (flow === "quickstart" ? "local" : await prompter.select({
883
+ message: "What do you want to set up?",
884
+ options: [{
885
+ value: "local",
886
+ label: "Local gateway (this machine)",
887
+ hint: localProbe.ok ? `Gateway reachable (${localUrl})` : `No gateway detected (${localUrl})`
888
+ }, {
889
+ value: "remote",
890
+ label: "Remote gateway (info-only)",
891
+ hint: !remoteUrl ? "No remote URL configured yet" : remoteProbe?.ok ? `Gateway reachable (${remoteUrl})` : `Configured but unreachable (${remoteUrl})`
892
+ }]
893
+ }));
894
+ if (mode === "remote") {
895
+ let nextConfig = await promptRemoteGatewayConfig(baseConfig, prompter);
896
+ nextConfig = applyWizardMetadata(nextConfig, {
897
+ command: "onboard",
898
+ mode
899
+ });
900
+ await writeConfigFile(nextConfig);
901
+ logConfigUpdated(runtime);
902
+ await prompter.outro("Remote gateway configured.");
903
+ return;
904
+ }
905
+ const workspaceDir = resolveUserPath((opts.workspace ?? (flow === "quickstart" ? baseConfig.agents?.defaults?.workspace ?? DEFAULT_WORKSPACE : await prompter.text({
906
+ message: "Workspace directory",
907
+ initialValue: baseConfig.agents?.defaults?.workspace ?? DEFAULT_WORKSPACE
908
+ }))).trim() || DEFAULT_WORKSPACE);
909
+ let nextConfig = {
910
+ ...baseConfig,
911
+ agents: {
912
+ ...baseConfig.agents,
913
+ defaults: {
914
+ ...baseConfig.agents?.defaults,
915
+ workspace: workspaceDir
916
+ }
917
+ },
918
+ gateway: {
919
+ ...baseConfig.gateway,
920
+ mode: "local"
921
+ }
922
+ };
923
+ const authStore = ensureAuthProfileStore(void 0, { allowKeychainPrompt: false });
924
+ const authChoiceFromPrompt = opts.authChoice === void 0;
925
+ const authChoice = opts.authChoice ?? await promptAuthChoiceGrouped({
926
+ prompter,
927
+ store: authStore,
928
+ includeSkip: true
929
+ });
930
+ nextConfig = (await applyAuthChoice({
931
+ authChoice,
932
+ config: nextConfig,
933
+ prompter,
934
+ runtime,
935
+ setDefaultModel: true,
936
+ opts: {
937
+ tokenProvider: opts.tokenProvider,
938
+ token: opts.authChoice === "apiKey" && opts.token ? opts.token : void 0
939
+ }
940
+ })).config;
941
+ if (authChoiceFromPrompt) {
942
+ const modelSelection = await promptDefaultModel({
943
+ config: nextConfig,
944
+ prompter,
945
+ allowKeep: true,
946
+ ignoreAllowlist: true,
947
+ preferredProvider: resolvePreferredProviderForAuthChoice(authChoice)
948
+ });
949
+ if (modelSelection.model) nextConfig = applyPrimaryModel(nextConfig, modelSelection.model);
950
+ }
951
+ await warnIfModelConfigLooksOff(nextConfig, prompter);
952
+ let walletAddress;
953
+ if (!opts.skipWallet) {
954
+ const { resolveStateDir } = await import("./paths-D2ytuv-2.js").then((n) => n.a);
955
+ walletAddress = (await setupWallet(resolveStateDir(), prompter, {
956
+ walletCreate: opts.walletCreate,
957
+ walletImport: opts.walletImport,
958
+ walletLabel: opts.walletLabel,
959
+ skipWallet: opts.skipWallet
960
+ })).address;
961
+ if (walletAddress) await prompter.note(`Wallet ready: ${walletAddress}`, "Blockchain");
962
+ }
963
+ const existingDefault = (baseConfig.plugins?.entries)?.blockchain?.config?.defaultChain;
964
+ const defaultChain = flow === "quickstart" ? existingDefault ?? "bsc" : await prompter.select({
965
+ message: "Default blockchain network",
966
+ options: [
967
+ {
968
+ value: "bsc",
969
+ label: "BNB Smart Chain (BSC)",
970
+ hint: "Low fees, fast blocks"
971
+ },
972
+ {
973
+ value: "ethereum",
974
+ label: "Ethereum",
975
+ hint: "Largest ecosystem"
976
+ },
977
+ {
978
+ value: "base",
979
+ label: "Base",
980
+ hint: "Coinbase L2, low fees"
981
+ },
982
+ {
983
+ value: "arbitrum",
984
+ label: "Arbitrum",
985
+ hint: "Ethereum L2"
986
+ },
987
+ {
988
+ value: "polygon",
989
+ label: "Polygon",
990
+ hint: "Low fees, wide adoption"
991
+ }
992
+ ],
993
+ initialValue: existingDefault ?? "bsc"
994
+ });
995
+ const blockchainPluginEntries = (nextConfig.plugins?.entries)?.blockchain ?? {};
996
+ nextConfig = {
997
+ ...nextConfig,
998
+ plugins: {
999
+ ...nextConfig.plugins,
1000
+ entries: {
1001
+ ...nextConfig.plugins?.entries,
1002
+ blockchain: {
1003
+ ...blockchainPluginEntries,
1004
+ config: {
1005
+ ...blockchainPluginEntries.config,
1006
+ defaultChain
1007
+ }
1008
+ }
1009
+ }
1010
+ }
1011
+ };
1012
+ const gateway = await configureGatewayForOnboarding({
1013
+ flow,
1014
+ baseConfig,
1015
+ nextConfig,
1016
+ localPort,
1017
+ quickstartGateway,
1018
+ prompter,
1019
+ runtime
1020
+ });
1021
+ nextConfig = gateway.nextConfig;
1022
+ const settings = gateway.settings;
1023
+ if (opts.skipChannels ?? opts.skipProviders) await prompter.note("Skipping channel setup.", "Channels");
1024
+ else {
1025
+ const quickstartAllowFromChannels = flow === "quickstart" ? listChannelPlugins().filter((plugin) => plugin.meta.quickstartAllowFrom).map((plugin) => plugin.id) : [];
1026
+ nextConfig = await setupChannels(nextConfig, runtime, prompter, {
1027
+ allowSignalInstall: true,
1028
+ forceAllowFromChannels: quickstartAllowFromChannels,
1029
+ skipDmPolicyPrompt: flow === "quickstart",
1030
+ skipConfirm: flow === "quickstart",
1031
+ quickstartDefaults: flow === "quickstart"
1032
+ });
1033
+ }
1034
+ await writeConfigFile(nextConfig);
1035
+ logConfigUpdated(runtime);
1036
+ await ensureWorkspaceAndSessions(workspaceDir, runtime, { skipBootstrap: Boolean(nextConfig.agents?.defaults?.skipBootstrap) });
1037
+ if (opts.skipSkills) await prompter.note("Skipping skills setup.", "Skills");
1038
+ else nextConfig = await setupSkills(nextConfig, workspaceDir, runtime, prompter);
1039
+ nextConfig = await setupInternalHooks(nextConfig, runtime, prompter);
1040
+ nextConfig = applyWizardMetadata(nextConfig, {
1041
+ command: "onboard",
1042
+ mode
1043
+ });
1044
+ await writeConfigFile(nextConfig);
1045
+ const { launchedTui } = await finalizeOnboardingWizard({
1046
+ flow,
1047
+ opts,
1048
+ baseConfig,
1049
+ nextConfig,
1050
+ workspaceDir,
1051
+ settings,
1052
+ prompter,
1053
+ runtime,
1054
+ walletAddress
1055
+ });
1056
+ if (launchedTui) return;
1057
+ }
1058
+
1059
+ //#endregion
1060
+ //#region src/agents/identity-file.ts
1061
+ const IDENTITY_PLACEHOLDER_VALUES = new Set([
1062
+ "pick something you like",
1063
+ "ai? robot? familiar? ghost in the machine? something weirder?",
1064
+ "how do you come across? sharp? warm? chaotic? calm?",
1065
+ "your signature - pick one that feels right",
1066
+ "workspace-relative path, http(s) url, or data uri"
1067
+ ]);
1068
+ function normalizeIdentityValue(value) {
1069
+ let normalized = value.trim();
1070
+ normalized = normalized.replace(/^[*_]+|[*_]+$/g, "").trim();
1071
+ if (normalized.startsWith("(") && normalized.endsWith(")")) normalized = normalized.slice(1, -1).trim();
1072
+ normalized = normalized.replace(/[\u2013\u2014]/g, "-");
1073
+ normalized = normalized.replace(/\s+/g, " ").toLowerCase();
1074
+ return normalized;
1075
+ }
1076
+ function isIdentityPlaceholder(value) {
1077
+ const normalized = normalizeIdentityValue(value);
1078
+ return IDENTITY_PLACEHOLDER_VALUES.has(normalized);
1079
+ }
1080
+ function parseIdentityMarkdown(content) {
1081
+ const identity = {};
1082
+ const lines = content.split(/\r?\n/);
1083
+ for (const line of lines) {
1084
+ const cleaned = line.trim().replace(/^\s*-\s*/, "");
1085
+ const colonIndex = cleaned.indexOf(":");
1086
+ if (colonIndex === -1) continue;
1087
+ const label = cleaned.slice(0, colonIndex).replace(/[*_]/g, "").trim().toLowerCase();
1088
+ const value = cleaned.slice(colonIndex + 1).replace(/^[*_]+|[*_]+$/g, "").trim();
1089
+ if (!value) continue;
1090
+ if (isIdentityPlaceholder(value)) continue;
1091
+ if (label === "name") identity.name = value;
1092
+ if (label === "emoji") identity.emoji = value;
1093
+ if (label === "creature") identity.creature = value;
1094
+ if (label === "vibe") identity.vibe = value;
1095
+ if (label === "theme") identity.theme = value;
1096
+ if (label === "avatar") identity.avatar = value;
1097
+ }
1098
+ return identity;
1099
+ }
1100
+ function identityHasValues(identity) {
1101
+ return Boolean(identity.name || identity.emoji || identity.theme || identity.creature || identity.vibe || identity.avatar);
1102
+ }
1103
+ function loadIdentityFromFile(identityPath) {
1104
+ try {
1105
+ const parsed = parseIdentityMarkdown(fs.readFileSync(identityPath, "utf-8"));
1106
+ if (!identityHasValues(parsed)) return null;
1107
+ return parsed;
1108
+ } catch {
1109
+ return null;
1110
+ }
1111
+ }
1112
+ function loadAgentIdentityFromWorkspace(workspace) {
1113
+ return loadIdentityFromFile(path.join(workspace, DEFAULT_IDENTITY_FILENAME));
1114
+ }
1115
+
1116
+ //#endregion
1117
+ //#region src/commands/agents.config.ts
1118
+ function listAgentEntries(cfg) {
1119
+ const list = cfg.agents?.list;
1120
+ if (!Array.isArray(list)) return [];
1121
+ return list.filter((entry) => Boolean(entry && typeof entry === "object"));
1122
+ }
1123
+ function findAgentEntryIndex(list, agentId) {
1124
+ const id = normalizeAgentId(agentId);
1125
+ return list.findIndex((entry) => normalizeAgentId(entry.id) === id);
1126
+ }
1127
+ function resolveAgentName(cfg, agentId) {
1128
+ return listAgentEntries(cfg).find((agent) => normalizeAgentId(agent.id) === normalizeAgentId(agentId))?.name?.trim() || void 0;
1129
+ }
1130
+ function resolveAgentModel(cfg, agentId) {
1131
+ const entry = listAgentEntries(cfg).find((agent) => normalizeAgentId(agent.id) === normalizeAgentId(agentId));
1132
+ if (entry?.model) {
1133
+ if (typeof entry.model === "string" && entry.model.trim()) return entry.model.trim();
1134
+ if (typeof entry.model === "object") {
1135
+ const primary = entry.model.primary?.trim();
1136
+ if (primary) return primary;
1137
+ }
1138
+ }
1139
+ const raw = cfg.agents?.defaults?.model;
1140
+ if (typeof raw === "string") return raw;
1141
+ return raw?.primary?.trim() || void 0;
1142
+ }
1143
+ function loadAgentIdentity(workspace) {
1144
+ const parsed = loadAgentIdentityFromWorkspace(workspace);
1145
+ if (!parsed) return null;
1146
+ return identityHasValues(parsed) ? parsed : null;
1147
+ }
1148
+ function buildAgentSummaries(cfg) {
1149
+ const defaultAgentId = normalizeAgentId(resolveDefaultAgentId(cfg));
1150
+ const configuredAgents = listAgentEntries(cfg);
1151
+ const orderedIds = configuredAgents.length > 0 ? configuredAgents.map((agent) => normalizeAgentId(agent.id)) : [defaultAgentId];
1152
+ const bindingCounts = /* @__PURE__ */ new Map();
1153
+ for (const binding of cfg.bindings ?? []) {
1154
+ const agentId = normalizeAgentId(binding.agentId);
1155
+ bindingCounts.set(agentId, (bindingCounts.get(agentId) ?? 0) + 1);
1156
+ }
1157
+ return orderedIds.filter((id, index) => orderedIds.indexOf(id) === index).map((id) => {
1158
+ const workspace = resolveAgentWorkspaceDir(cfg, id);
1159
+ const identity = loadAgentIdentity(workspace);
1160
+ const configIdentity = configuredAgents.find((agent) => normalizeAgentId(agent.id) === id)?.identity;
1161
+ const identityName = identity?.name ?? configIdentity?.name?.trim();
1162
+ const identityEmoji = identity?.emoji ?? configIdentity?.emoji?.trim();
1163
+ const identitySource = identity ? "identity" : configIdentity && (identityName || identityEmoji) ? "config" : void 0;
1164
+ return {
1165
+ id,
1166
+ name: resolveAgentName(cfg, id),
1167
+ identityName,
1168
+ identityEmoji,
1169
+ identitySource,
1170
+ workspace,
1171
+ agentDir: resolveAgentDir(cfg, id),
1172
+ model: resolveAgentModel(cfg, id),
1173
+ bindings: bindingCounts.get(id) ?? 0,
1174
+ isDefault: id === defaultAgentId
1175
+ };
1176
+ });
1177
+ }
1178
+ function applyAgentConfig(cfg, params) {
1179
+ const agentId = normalizeAgentId(params.agentId);
1180
+ const name = params.name?.trim();
1181
+ const list = listAgentEntries(cfg);
1182
+ const index = findAgentEntryIndex(list, agentId);
1183
+ const nextEntry = {
1184
+ ...index >= 0 ? list[index] : { id: agentId },
1185
+ ...name ? { name } : {},
1186
+ ...params.workspace ? { workspace: params.workspace } : {},
1187
+ ...params.agentDir ? { agentDir: params.agentDir } : {},
1188
+ ...params.model ? { model: params.model } : {}
1189
+ };
1190
+ const nextList = [...list];
1191
+ if (index >= 0) nextList[index] = nextEntry;
1192
+ else {
1193
+ if (nextList.length === 0 && agentId !== normalizeAgentId(resolveDefaultAgentId(cfg))) nextList.push({ id: resolveDefaultAgentId(cfg) });
1194
+ nextList.push(nextEntry);
1195
+ }
1196
+ return {
1197
+ ...cfg,
1198
+ agents: {
1199
+ ...cfg.agents,
1200
+ list: nextList
1201
+ }
1202
+ };
1203
+ }
1204
+ function pruneAgentConfig(cfg, agentId) {
1205
+ const id = normalizeAgentId(agentId);
1206
+ const nextAgentsList = listAgentEntries(cfg).filter((entry) => normalizeAgentId(entry.id) !== id);
1207
+ const nextAgents = nextAgentsList.length > 0 ? nextAgentsList : void 0;
1208
+ const bindings = cfg.bindings ?? [];
1209
+ const filteredBindings = bindings.filter((binding) => normalizeAgentId(binding.agentId) !== id);
1210
+ const allow = cfg.tools?.agentToAgent?.allow ?? [];
1211
+ const filteredAllow = allow.filter((entry) => entry !== id);
1212
+ const nextAgentsConfig = cfg.agents ? {
1213
+ ...cfg.agents,
1214
+ list: nextAgents
1215
+ } : nextAgents ? { list: nextAgents } : void 0;
1216
+ const nextTools = cfg.tools?.agentToAgent ? {
1217
+ ...cfg.tools,
1218
+ agentToAgent: {
1219
+ ...cfg.tools.agentToAgent,
1220
+ allow: filteredAllow.length > 0 ? filteredAllow : void 0
1221
+ }
1222
+ } : cfg.tools;
1223
+ return {
1224
+ config: {
1225
+ ...cfg,
1226
+ agents: nextAgentsConfig,
1227
+ bindings: filteredBindings.length > 0 ? filteredBindings : void 0,
1228
+ tools: nextTools
1229
+ },
1230
+ removedBindings: bindings.length - filteredBindings.length,
1231
+ removedAllow: allow.length - filteredAllow.length
1232
+ };
1233
+ }
1234
+
1235
+ //#endregion
1236
+ //#region src/memory/status-format.ts
1237
+ function resolveMemoryVectorState(vector) {
1238
+ if (!vector.enabled) return {
1239
+ tone: "muted",
1240
+ state: "disabled"
1241
+ };
1242
+ if (vector.available === true) return {
1243
+ tone: "ok",
1244
+ state: "ready"
1245
+ };
1246
+ if (vector.available === false) return {
1247
+ tone: "warn",
1248
+ state: "unavailable"
1249
+ };
1250
+ return {
1251
+ tone: "muted",
1252
+ state: "unknown"
1253
+ };
1254
+ }
1255
+ function resolveMemoryFtsState(fts) {
1256
+ if (!fts.enabled) return {
1257
+ tone: "muted",
1258
+ state: "disabled"
1259
+ };
1260
+ return fts.available ? {
1261
+ tone: "ok",
1262
+ state: "ready"
1263
+ } : {
1264
+ tone: "warn",
1265
+ state: "unavailable"
1266
+ };
1267
+ }
1268
+ function resolveMemoryCacheSummary(cache) {
1269
+ if (!cache.enabled) return {
1270
+ tone: "muted",
1271
+ text: "cache off"
1272
+ };
1273
+ return {
1274
+ tone: "ok",
1275
+ text: `cache on${typeof cache.entries === "number" ? ` (${cache.entries})` : ""}`
1276
+ };
1277
+ }
1278
+
1279
+ //#endregion
1280
+ //#region src/infra/os-summary.ts
1281
+ function safeTrim(value) {
1282
+ return typeof value === "string" ? value.trim() : "";
1283
+ }
1284
+ function macosVersion() {
1285
+ return safeTrim(spawnSync("sw_vers", ["-productVersion"], { encoding: "utf-8" }).stdout) || os.release();
1286
+ }
1287
+ function resolveOsSummary() {
1288
+ const platform = os.platform();
1289
+ const release = os.release();
1290
+ const arch = os.arch();
1291
+ return {
1292
+ platform,
1293
+ arch,
1294
+ release,
1295
+ label: (() => {
1296
+ if (platform === "darwin") return `macos ${macosVersion()} (${arch})`;
1297
+ if (platform === "win32") return `windows ${release} (${arch})`;
1298
+ return `${platform} ${release} (${arch})`;
1299
+ })()
1300
+ };
1301
+ }
1302
+
1303
+ //#endregion
1304
+ //#region src/commands/status-all/agents.ts
1305
+ async function fileExists$1(p) {
1306
+ try {
1307
+ await fs$1.access(p);
1308
+ return true;
1309
+ } catch {
1310
+ return false;
1311
+ }
1312
+ }
1313
+ async function getAgentLocalStatuses$1(cfg) {
1314
+ const agentList = listAgentsForGateway(cfg);
1315
+ const now = Date.now();
1316
+ const agents = await Promise.all(agentList.agents.map(async (agent) => {
1317
+ const workspaceDir = (() => {
1318
+ try {
1319
+ return resolveAgentWorkspaceDir(cfg, agent.id);
1320
+ } catch {
1321
+ return null;
1322
+ }
1323
+ })();
1324
+ const bootstrapPending = workspaceDir != null ? await fileExists$1(path.join(workspaceDir, "BOOTSTRAP.md")) : null;
1325
+ const sessionsPath = resolveStorePath(cfg.session?.store, { agentId: agent.id });
1326
+ const store = (() => {
1327
+ try {
1328
+ return loadSessionStore(sessionsPath);
1329
+ } catch {
1330
+ return {};
1331
+ }
1332
+ })();
1333
+ const updatedAt = Object.values(store).reduce((max, entry) => Math.max(max, entry?.updatedAt ?? 0), 0);
1334
+ const lastUpdatedAt = updatedAt > 0 ? updatedAt : null;
1335
+ const lastActiveAgeMs = lastUpdatedAt ? now - lastUpdatedAt : null;
1336
+ const sessionsCount = Object.keys(store).filter((k) => k !== "global" && k !== "unknown").length;
1337
+ return {
1338
+ id: agent.id,
1339
+ name: agent.name,
1340
+ workspaceDir,
1341
+ bootstrapPending,
1342
+ sessionsPath,
1343
+ sessionsCount,
1344
+ lastUpdatedAt,
1345
+ lastActiveAgeMs
1346
+ };
1347
+ }));
1348
+ const totalSessions = agents.reduce((sum, a) => sum + a.sessionsCount, 0);
1349
+ const bootstrapPendingCount = agents.reduce((sum, a) => sum + (a.bootstrapPending ? 1 : 0), 0);
1350
+ return {
1351
+ defaultId: agentList.defaultId,
1352
+ agents,
1353
+ totalSessions,
1354
+ bootstrapPendingCount
1355
+ };
1356
+ }
1357
+
1358
+ //#endregion
1359
+ //#region src/commands/status-all/channels.ts
1360
+ const asRecord = (value) => value && typeof value === "object" ? value : {};
1361
+ function summarizeSources(sources) {
1362
+ const counts = /* @__PURE__ */ new Map();
1363
+ for (const s of sources) {
1364
+ const key = s?.trim() ? s.trim() : "unknown";
1365
+ counts.set(key, (counts.get(key) ?? 0) + 1);
1366
+ }
1367
+ const parts = [...counts.entries()].toSorted((a, b) => b[1] - a[1]).map(([key, n]) => `${key}${n > 1 ? `×${n}` : ""}`);
1368
+ return {
1369
+ label: parts.length > 0 ? parts.join("+") : "unknown",
1370
+ parts
1371
+ };
1372
+ }
1373
+ function existsSyncMaybe(p) {
1374
+ const path = p?.trim() || "";
1375
+ if (!path) return null;
1376
+ try {
1377
+ return fs.existsSync(path);
1378
+ } catch {
1379
+ return null;
1380
+ }
1381
+ }
1382
+ function sha256HexPrefix(value, len = 8) {
1383
+ return crypto.createHash("sha256").update(value).digest("hex").slice(0, len);
1384
+ }
1385
+ function formatTokenHint(token, opts) {
1386
+ const t = token.trim();
1387
+ if (!t) return "empty";
1388
+ if (!opts.showSecrets) return `sha256:${sha256HexPrefix(t)} · len ${t.length}`;
1389
+ const head = t.slice(0, 4);
1390
+ const tail = t.slice(-4);
1391
+ if (t.length <= 10) return `${t} · len ${t.length}`;
1392
+ return `${head}…${tail} · len ${t.length}`;
1393
+ }
1394
+ const formatAccountLabel = (params) => {
1395
+ const base = params.accountId || "default";
1396
+ if (params.name?.trim()) return `${base} (${params.name.trim()})`;
1397
+ return base;
1398
+ };
1399
+ const resolveAccountEnabled = (plugin, account, cfg) => {
1400
+ if (plugin.config.isEnabled) return plugin.config.isEnabled(account, cfg);
1401
+ return asRecord(account).enabled !== false;
1402
+ };
1403
+ const resolveAccountConfigured = async (plugin, account, cfg) => {
1404
+ if (plugin.config.isConfigured) return await plugin.config.isConfigured(account, cfg);
1405
+ return asRecord(account).configured !== false;
1406
+ };
1407
+ const buildAccountSnapshot = (params) => {
1408
+ const described = params.plugin.config.describeAccount?.(params.account, params.cfg);
1409
+ return {
1410
+ enabled: params.enabled,
1411
+ configured: params.configured,
1412
+ ...described,
1413
+ accountId: params.accountId
1414
+ };
1415
+ };
1416
+ const formatAllowFrom = (params) => {
1417
+ if (params.plugin.config.formatAllowFrom) return params.plugin.config.formatAllowFrom({
1418
+ cfg: params.cfg,
1419
+ accountId: params.accountId,
1420
+ allowFrom: params.allowFrom
1421
+ });
1422
+ return params.allowFrom.map((entry) => String(entry).trim()).filter(Boolean);
1423
+ };
1424
+ const buildAccountNotes = (params) => {
1425
+ const { plugin, cfg, entry } = params;
1426
+ const notes = [];
1427
+ const snapshot = entry.snapshot;
1428
+ if (snapshot.enabled === false) notes.push("disabled");
1429
+ if (snapshot.dmPolicy) notes.push(`dm:${snapshot.dmPolicy}`);
1430
+ if (snapshot.tokenSource && snapshot.tokenSource !== "none") notes.push(`token:${snapshot.tokenSource}`);
1431
+ if (snapshot.botTokenSource && snapshot.botTokenSource !== "none") notes.push(`bot:${snapshot.botTokenSource}`);
1432
+ if (snapshot.appTokenSource && snapshot.appTokenSource !== "none") notes.push(`app:${snapshot.appTokenSource}`);
1433
+ if (snapshot.baseUrl) notes.push(snapshot.baseUrl);
1434
+ if (snapshot.port != null) notes.push(`port:${snapshot.port}`);
1435
+ if (snapshot.cliPath) notes.push(`cli:${snapshot.cliPath}`);
1436
+ if (snapshot.dbPath) notes.push(`db:${snapshot.dbPath}`);
1437
+ const allowFrom = plugin.config.resolveAllowFrom?.({
1438
+ cfg,
1439
+ accountId: snapshot.accountId
1440
+ }) ?? snapshot.allowFrom;
1441
+ if (allowFrom?.length) {
1442
+ const formatted = formatAllowFrom({
1443
+ plugin,
1444
+ cfg,
1445
+ accountId: snapshot.accountId,
1446
+ allowFrom
1447
+ }).slice(0, 3);
1448
+ if (formatted.length > 0) notes.push(`allow:${formatted.join(",")}`);
1449
+ }
1450
+ return notes;
1451
+ };
1452
+ function resolveLinkFields(summary) {
1453
+ const rec = asRecord(summary);
1454
+ const linked = typeof rec.linked === "boolean" ? rec.linked : null;
1455
+ const authAgeMs = typeof rec.authAgeMs === "number" ? rec.authAgeMs : null;
1456
+ const self = asRecord(rec.self);
1457
+ return {
1458
+ linked,
1459
+ authAgeMs,
1460
+ selfE164: typeof self.e164 === "string" && self.e164.trim() ? self.e164.trim() : null
1461
+ };
1462
+ }
1463
+ function collectMissingPaths(accounts) {
1464
+ const missing = [];
1465
+ for (const entry of accounts) {
1466
+ const accountRec = asRecord(entry.account);
1467
+ const snapshotRec = asRecord(entry.snapshot);
1468
+ for (const key of [
1469
+ "tokenFile",
1470
+ "botTokenFile",
1471
+ "appTokenFile",
1472
+ "cliPath",
1473
+ "dbPath",
1474
+ "authDir"
1475
+ ]) {
1476
+ const raw = accountRec[key] ?? snapshotRec[key];
1477
+ if (existsSyncMaybe(raw) === false) missing.push(String(raw));
1478
+ }
1479
+ }
1480
+ return missing;
1481
+ }
1482
+ function summarizeTokenConfig(params) {
1483
+ const enabled = params.accounts.filter((a) => a.enabled);
1484
+ if (enabled.length === 0) return {
1485
+ state: null,
1486
+ detail: null
1487
+ };
1488
+ const accountRecs = enabled.map((a) => asRecord(a.account));
1489
+ const hasBotOrAppTokenFields = accountRecs.some((r) => "botToken" in r || "appToken" in r);
1490
+ const hasTokenField = accountRecs.some((r) => "token" in r);
1491
+ if (!hasBotOrAppTokenFields && !hasTokenField) return {
1492
+ state: null,
1493
+ detail: null
1494
+ };
1495
+ if (hasBotOrAppTokenFields) {
1496
+ const ready = enabled.filter((a) => {
1497
+ const rec = asRecord(a.account);
1498
+ const bot = typeof rec.botToken === "string" ? rec.botToken.trim() : "";
1499
+ const app = typeof rec.appToken === "string" ? rec.appToken.trim() : "";
1500
+ return Boolean(bot) && Boolean(app);
1501
+ });
1502
+ const partial = enabled.filter((a) => {
1503
+ const rec = asRecord(a.account);
1504
+ const bot = typeof rec.botToken === "string" ? rec.botToken.trim() : "";
1505
+ const app = typeof rec.appToken === "string" ? rec.appToken.trim() : "";
1506
+ const hasBot = Boolean(bot);
1507
+ const hasApp = Boolean(app);
1508
+ return hasBot && !hasApp || !hasBot && hasApp;
1509
+ });
1510
+ if (partial.length > 0) return {
1511
+ state: "warn",
1512
+ detail: `partial tokens (need bot+app) · accounts ${partial.length}`
1513
+ };
1514
+ if (ready.length === 0) return {
1515
+ state: "setup",
1516
+ detail: "no tokens (need bot+app)"
1517
+ };
1518
+ const botSources = summarizeSources(ready.map((a) => a.snapshot.botTokenSource ?? "none"));
1519
+ const appSources = summarizeSources(ready.map((a) => a.snapshot.appTokenSource ?? "none"));
1520
+ const sample = ready[0]?.account ? asRecord(ready[0].account) : {};
1521
+ const botToken = typeof sample.botToken === "string" ? sample.botToken : "";
1522
+ const appToken = typeof sample.appToken === "string" ? sample.appToken : "";
1523
+ const botHint = botToken.trim() ? formatTokenHint(botToken, { showSecrets: params.showSecrets }) : "";
1524
+ const appHint = appToken.trim() ? formatTokenHint(appToken, { showSecrets: params.showSecrets }) : "";
1525
+ const hint = botHint || appHint ? ` (bot ${botHint || "?"}, app ${appHint || "?"})` : "";
1526
+ return {
1527
+ state: "ok",
1528
+ detail: `tokens ok (bot ${botSources.label}, app ${appSources.label})${hint} · accounts ${ready.length}/${enabled.length || 1}`
1529
+ };
1530
+ }
1531
+ const ready = enabled.filter((a) => {
1532
+ const rec = asRecord(a.account);
1533
+ return typeof rec.token === "string" ? Boolean(rec.token.trim()) : false;
1534
+ });
1535
+ if (ready.length === 0) return {
1536
+ state: "setup",
1537
+ detail: "no token"
1538
+ };
1539
+ const sources = summarizeSources(ready.map((a) => a.snapshot.tokenSource));
1540
+ const sample = ready[0]?.account ? asRecord(ready[0].account) : {};
1541
+ const token = typeof sample.token === "string" ? sample.token : "";
1542
+ const hint = token.trim() ? ` (${formatTokenHint(token, { showSecrets: params.showSecrets })})` : "";
1543
+ return {
1544
+ state: "ok",
1545
+ detail: `token ${sources.label}${hint} · accounts ${ready.length}/${enabled.length || 1}`
1546
+ };
1547
+ }
1548
+ async function buildChannelsTable(cfg, opts) {
1549
+ const showSecrets = opts?.showSecrets === true;
1550
+ const rows = [];
1551
+ const details = [];
1552
+ for (const plugin of listChannelPlugins()) {
1553
+ const accountIds = plugin.config.listAccountIds(cfg);
1554
+ const defaultAccountId = resolveChannelDefaultAccountId({
1555
+ plugin,
1556
+ cfg,
1557
+ accountIds
1558
+ });
1559
+ const resolvedAccountIds = accountIds.length > 0 ? accountIds : [defaultAccountId];
1560
+ const accounts = [];
1561
+ for (const accountId of resolvedAccountIds) {
1562
+ const account = plugin.config.resolveAccount(cfg, accountId);
1563
+ const enabled = resolveAccountEnabled(plugin, account, cfg);
1564
+ const configured = await resolveAccountConfigured(plugin, account, cfg);
1565
+ const snapshot = buildAccountSnapshot({
1566
+ plugin,
1567
+ cfg,
1568
+ accountId,
1569
+ account,
1570
+ enabled,
1571
+ configured
1572
+ });
1573
+ accounts.push({
1574
+ accountId,
1575
+ account,
1576
+ enabled,
1577
+ configured,
1578
+ snapshot
1579
+ });
1580
+ }
1581
+ const anyEnabled = accounts.some((a) => a.enabled);
1582
+ const enabledAccounts = accounts.filter((a) => a.enabled);
1583
+ const configuredAccounts = enabledAccounts.filter((a) => a.configured);
1584
+ const defaultEntry = accounts.find((a) => a.accountId === defaultAccountId) ?? accounts[0];
1585
+ const link = resolveLinkFields(plugin.status?.buildChannelSummary ? await plugin.status.buildChannelSummary({
1586
+ account: defaultEntry?.account ?? {},
1587
+ cfg,
1588
+ defaultAccountId,
1589
+ snapshot: defaultEntry?.snapshot ?? { accountId: defaultAccountId }
1590
+ }) : void 0);
1591
+ const missingPaths = collectMissingPaths(enabledAccounts);
1592
+ const tokenSummary = summarizeTokenConfig({
1593
+ plugin,
1594
+ cfg,
1595
+ accounts,
1596
+ showSecrets
1597
+ });
1598
+ const issues = plugin.status?.collectStatusIssues ? plugin.status.collectStatusIssues(accounts.map((a) => a.snapshot)) : [];
1599
+ const label = plugin.meta.label ?? plugin.id;
1600
+ const state = (() => {
1601
+ if (!anyEnabled) return "off";
1602
+ if (missingPaths.length > 0) return "warn";
1603
+ if (issues.length > 0) return "warn";
1604
+ if (link.linked === false) return "setup";
1605
+ if (tokenSummary.state) return tokenSummary.state;
1606
+ if (link.linked === true) return "ok";
1607
+ if (configuredAccounts.length > 0) return "ok";
1608
+ return "setup";
1609
+ })();
1610
+ const detail = (() => {
1611
+ if (!anyEnabled) {
1612
+ if (!defaultEntry) return "disabled";
1613
+ return plugin.config.disabledReason?.(defaultEntry.account, cfg) ?? "disabled";
1614
+ }
1615
+ if (missingPaths.length > 0) return `missing file (${missingPaths[0]})`;
1616
+ if (issues.length > 0) return issues[0]?.message ?? "misconfigured";
1617
+ if (link.linked !== null) {
1618
+ const base = link.linked ? "linked" : "not linked";
1619
+ const extra = [];
1620
+ if (link.linked && link.selfE164) extra.push(link.selfE164);
1621
+ if (link.linked && link.authAgeMs != null && link.authAgeMs >= 0) extra.push(`auth ${formatAge$1(link.authAgeMs)}`);
1622
+ if (accounts.length > 1 || plugin.meta.forceAccountBinding) extra.push(`accounts ${accounts.length || 1}`);
1623
+ return extra.length > 0 ? `${base} · ${extra.join(" · ")}` : base;
1624
+ }
1625
+ if (tokenSummary.detail) return tokenSummary.detail;
1626
+ if (configuredAccounts.length > 0) {
1627
+ const head = "configured";
1628
+ if (accounts.length <= 1 && !plugin.meta.forceAccountBinding) return head;
1629
+ return `${head} · accounts ${configuredAccounts.length}/${enabledAccounts.length || 1}`;
1630
+ }
1631
+ return (defaultEntry && plugin.config.unconfiguredReason ? plugin.config.unconfiguredReason(defaultEntry.account, cfg) : null) ?? "not configured";
1632
+ })();
1633
+ rows.push({
1634
+ id: plugin.id,
1635
+ label,
1636
+ enabled: anyEnabled,
1637
+ state,
1638
+ detail
1639
+ });
1640
+ if (configuredAccounts.length > 0) details.push({
1641
+ title: `${label} accounts`,
1642
+ columns: [
1643
+ "Account",
1644
+ "Status",
1645
+ "Notes"
1646
+ ],
1647
+ rows: configuredAccounts.map((entry) => {
1648
+ const notes = buildAccountNotes({
1649
+ plugin,
1650
+ cfg,
1651
+ entry
1652
+ });
1653
+ return {
1654
+ Account: formatAccountLabel({
1655
+ accountId: entry.accountId,
1656
+ name: entry.snapshot.name
1657
+ }),
1658
+ Status: entry.enabled ? "OK" : "WARN",
1659
+ Notes: notes.join(" · ")
1660
+ };
1661
+ })
1662
+ });
1663
+ }
1664
+ return {
1665
+ rows,
1666
+ details
1667
+ };
1668
+ }
1669
+
1670
+ //#endregion
1671
+ //#region src/commands/status-all/gateway.ts
1672
+ async function readFileTailLines(filePath, maxLines) {
1673
+ const raw = await fs$1.readFile(filePath, "utf8").catch(() => "");
1674
+ if (!raw.trim()) return [];
1675
+ const lines = raw.replace(/\r/g, "").split("\n");
1676
+ return lines.slice(Math.max(0, lines.length - maxLines)).map((line) => line.trimEnd()).filter((line) => line.trim().length > 0);
1677
+ }
1678
+ function countMatches(haystack, needle) {
1679
+ if (!haystack || !needle) return 0;
1680
+ return haystack.split(needle).length - 1;
1681
+ }
1682
+ function shorten(message, maxLen) {
1683
+ const cleaned = message.replace(/\s+/g, " ").trim();
1684
+ if (cleaned.length <= maxLen) return cleaned;
1685
+ return `${cleaned.slice(0, Math.max(0, maxLen - 1))}…`;
1686
+ }
1687
+ function normalizeGwsLine(line) {
1688
+ return line.replace(/\s+runId=[^\s]+/g, "").replace(/\s+conn=[^\s]+/g, "").replace(/\s+id=[^\s]+/g, "").replace(/\s+error=Error:.*$/g, "").trim();
1689
+ }
1690
+ function consumeJsonBlock(lines, startIndex) {
1691
+ const startLine = lines[startIndex] ?? "";
1692
+ const braceAt = startLine.indexOf("{");
1693
+ if (braceAt < 0) return null;
1694
+ const parts = [startLine.slice(braceAt)];
1695
+ let depth = countMatches(parts[0] ?? "", "{") - countMatches(parts[0] ?? "", "}");
1696
+ let i = startIndex;
1697
+ while (depth > 0 && i + 1 < lines.length) {
1698
+ i += 1;
1699
+ const next = lines[i] ?? "";
1700
+ parts.push(next);
1701
+ depth += countMatches(next, "{") - countMatches(next, "}");
1702
+ }
1703
+ return {
1704
+ json: parts.join("\n"),
1705
+ endIndex: i
1706
+ };
1707
+ }
1708
+ function summarizeLogTail(rawLines, opts) {
1709
+ const maxLines = Math.max(6, opts?.maxLines ?? 26);
1710
+ const out = [];
1711
+ const groups = /* @__PURE__ */ new Map();
1712
+ const addGroup = (key, base) => {
1713
+ const existing = groups.get(key);
1714
+ if (existing) {
1715
+ existing.count += 1;
1716
+ return;
1717
+ }
1718
+ groups.set(key, {
1719
+ count: 1,
1720
+ index: out.length,
1721
+ base
1722
+ });
1723
+ out.push(base);
1724
+ };
1725
+ const addLine = (line) => {
1726
+ const trimmed = line.trimEnd();
1727
+ if (!trimmed) return;
1728
+ out.push(trimmed);
1729
+ };
1730
+ const lines = rawLines.map((line) => line.trimEnd()).filter(Boolean);
1731
+ for (let i = 0; i < lines.length; i += 1) {
1732
+ const line = lines[i] ?? "";
1733
+ const trimmedStart = line.trimStart();
1734
+ if ((trimmedStart.startsWith("\"") || trimmedStart === "}" || trimmedStart === "{" || trimmedStart.startsWith("}") || trimmedStart.startsWith("{")) && !trimmedStart.startsWith("[") && !trimmedStart.startsWith("#")) continue;
1735
+ const tokenRefresh = line.match(/^\[([^\]]+)\]\s+Token refresh failed:\s*(\d+)\s*(\{)?\s*$/);
1736
+ if (tokenRefresh) {
1737
+ const tag = tokenRefresh[1] ?? "unknown";
1738
+ const status = tokenRefresh[2] ?? "unknown";
1739
+ const block = consumeJsonBlock(lines, i);
1740
+ if (block) {
1741
+ i = block.endIndex;
1742
+ const parsed = (() => {
1743
+ try {
1744
+ return JSON.parse(block.json);
1745
+ } catch {
1746
+ return null;
1747
+ }
1748
+ })();
1749
+ const code = parsed?.error?.code?.trim() || null;
1750
+ const msg = parsed?.error?.message?.trim() || null;
1751
+ const msgShort = msg ? msg.toLowerCase().includes("signing in again") ? "re-auth required" : shorten(msg, 52) : null;
1752
+ const base = `[${tag}] token refresh ${status}${code ? ` ${code}` : ""}${msgShort ? ` · ${msgShort}` : ""}`;
1753
+ addGroup(`token:${tag}:${status}:${code ?? ""}:${msgShort ?? ""}`, base);
1754
+ continue;
1755
+ }
1756
+ }
1757
+ const embedded = line.match(/^Embedded agent failed before reply:\s+OAuth token refresh failed for ([^:]+):/);
1758
+ if (embedded) {
1759
+ const provider = embedded[1]?.trim() || "unknown";
1760
+ addGroup(`embedded:${provider}`, `Embedded agent: OAuth token refresh failed (${provider})`);
1761
+ continue;
1762
+ }
1763
+ if (line.startsWith("[gws]") && line.includes("errorCode=UNAVAILABLE") && line.includes("OAuth token refresh failed")) {
1764
+ const normalized = normalizeGwsLine(line);
1765
+ addGroup(`gws:${normalized}`, normalized);
1766
+ continue;
1767
+ }
1768
+ addLine(line);
1769
+ }
1770
+ for (const g of groups.values()) {
1771
+ if (g.count <= 1) continue;
1772
+ out[g.index] = `${g.base} ×${g.count}`;
1773
+ }
1774
+ const deduped = [];
1775
+ for (const line of out) {
1776
+ if (deduped[deduped.length - 1] === line) continue;
1777
+ deduped.push(line);
1778
+ }
1779
+ if (deduped.length <= maxLines) return deduped;
1780
+ const head = Math.min(6, Math.floor(maxLines / 3));
1781
+ const tail = Math.max(1, maxLines - head - 1);
1782
+ return [
1783
+ ...deduped.slice(0, head),
1784
+ `… ${deduped.length - head - tail} lines omitted …`,
1785
+ ...deduped.slice(-tail)
1786
+ ];
1787
+ }
1788
+ function pickGatewaySelfPresence$1(presence) {
1789
+ if (!Array.isArray(presence)) return null;
1790
+ const self = presence.find((e) => e.mode === "gateway" && e.reason === "self") ?? null;
1791
+ if (!self) return null;
1792
+ return {
1793
+ host: typeof self.host === "string" ? self.host : void 0,
1794
+ ip: typeof self.ip === "string" ? self.ip : void 0,
1795
+ version: typeof self.version === "string" ? self.version : void 0,
1796
+ platform: typeof self.platform === "string" ? self.platform : void 0
1797
+ };
1798
+ }
1799
+
1800
+ //#endregion
1801
+ //#region src/commands/status-all/diagnosis.ts
1802
+ async function appendStatusAllDiagnosis(params) {
1803
+ const { lines, muted, ok, warn, fail } = params;
1804
+ const emitCheck = (label, status) => {
1805
+ const icon = status === "ok" ? ok("✓") : status === "warn" ? warn("!") : fail("✗");
1806
+ const colored = status === "ok" ? ok(label) : status === "warn" ? warn(label) : fail(label);
1807
+ lines.push(`${icon} ${colored}`);
1808
+ };
1809
+ lines.push("");
1810
+ lines.push(muted("Gateway connection details:"));
1811
+ for (const line of redactSecrets(params.connectionDetailsForReport).split("\n").map((l) => l.trimEnd())) lines.push(` ${muted(line)}`);
1812
+ lines.push("");
1813
+ if (params.snap) {
1814
+ const status = !params.snap.exists ? "fail" : params.snap.valid ? "ok" : "warn";
1815
+ emitCheck(`Config: ${params.snap.path ?? "(unknown)"}`, status);
1816
+ const issues = [...params.snap.legacyIssues ?? [], ...params.snap.issues ?? []];
1817
+ const uniqueIssues = issues.filter((issue, index) => issues.findIndex((x) => x.path === issue.path && x.message === issue.message) === index);
1818
+ for (const issue of uniqueIssues.slice(0, 12)) lines.push(` - ${issue.path}: ${issue.message}`);
1819
+ if (uniqueIssues.length > 12) lines.push(` ${muted(`… +${uniqueIssues.length - 12} more`)}`);
1820
+ } else emitCheck("Config: read failed", "warn");
1821
+ if (params.remoteUrlMissing) {
1822
+ lines.push("");
1823
+ emitCheck("Gateway remote mode misconfigured (gateway.remote.url missing)", "warn");
1824
+ lines.push(` ${muted("Fix: set gateway.remote.url, or set gateway.mode=local.")}`);
1825
+ }
1826
+ if (params.sentinel?.payload) {
1827
+ emitCheck("Restart sentinel present", "warn");
1828
+ lines.push(` ${muted(`${summarizeRestartSentinel(params.sentinel.payload)} · ${formatAge$1(Date.now() - params.sentinel.payload.ts)}`)}`);
1829
+ } else emitCheck("Restart sentinel: none", "ok");
1830
+ const lastErrClean = params.lastErr?.trim() ?? "";
1831
+ const isTrivialLastErr = lastErrClean.length < 8 || lastErrClean === "}" || lastErrClean === "{";
1832
+ if (lastErrClean && !isTrivialLastErr) {
1833
+ lines.push("");
1834
+ lines.push(muted("Gateway last log line:"));
1835
+ lines.push(` ${muted(redactSecrets(lastErrClean))}`);
1836
+ }
1837
+ if (params.portUsage) {
1838
+ const portOk = params.portUsage.listeners.length === 0;
1839
+ emitCheck(`Port ${params.port}`, portOk ? "ok" : "warn");
1840
+ if (!portOk) for (const line of formatPortDiagnostics(params.portUsage)) lines.push(` ${muted(line)}`);
1841
+ }
1842
+ {
1843
+ const backend = params.tailscale.backendState ?? "unknown";
1844
+ const okBackend = backend === "Running";
1845
+ const hasDns = Boolean(params.tailscale.dnsName);
1846
+ emitCheck(params.tailscaleMode === "off" ? `Tailscale: off · ${backend}${params.tailscale.dnsName ? ` · ${params.tailscale.dnsName}` : ""}` : `Tailscale: ${params.tailscaleMode} · ${backend}${params.tailscale.dnsName ? ` · ${params.tailscale.dnsName}` : ""}`, okBackend && (params.tailscaleMode === "off" || hasDns) ? "ok" : "warn");
1847
+ if (params.tailscale.error) lines.push(` ${muted(`error: ${params.tailscale.error}`)}`);
1848
+ if (params.tailscale.ips.length > 0) lines.push(` ${muted(`ips: ${params.tailscale.ips.slice(0, 3).join(", ")}${params.tailscale.ips.length > 3 ? "…" : ""}`)}`);
1849
+ if (params.tailscaleHttpsUrl) lines.push(` ${muted(`https: ${params.tailscaleHttpsUrl}`)}`);
1850
+ }
1851
+ if (params.skillStatus) {
1852
+ const eligible = params.skillStatus.skills.filter((s) => s.eligible).length;
1853
+ const missing = params.skillStatus.skills.filter((s) => s.eligible && Object.values(s.missing).some((arr) => arr.length)).length;
1854
+ emitCheck(`Skills: ${eligible} eligible · ${missing} missing · ${params.skillStatus.workspaceDir}`, missing === 0 ? "ok" : "warn");
1855
+ }
1856
+ params.progress.setLabel("Reading logs…");
1857
+ const logPaths = (() => {
1858
+ try {
1859
+ return resolveGatewayLogPaths(process.env);
1860
+ } catch {
1861
+ return null;
1862
+ }
1863
+ })();
1864
+ if (logPaths) {
1865
+ params.progress.setLabel("Reading logs…");
1866
+ const [stderrTail, stdoutTail] = await Promise.all([readFileTailLines(logPaths.stderrPath, 40).catch(() => []), readFileTailLines(logPaths.stdoutPath, 40).catch(() => [])]);
1867
+ if (stderrTail.length > 0 || stdoutTail.length > 0) {
1868
+ lines.push("");
1869
+ lines.push(muted(`Gateway logs (tail, summarized): ${logPaths.logDir}`));
1870
+ lines.push(` ${muted(`# stderr: ${logPaths.stderrPath}`)}`);
1871
+ for (const line of summarizeLogTail(stderrTail, { maxLines: 22 }).map(redactSecrets)) lines.push(` ${muted(line)}`);
1872
+ lines.push(` ${muted(`# stdout: ${logPaths.stdoutPath}`)}`);
1873
+ for (const line of summarizeLogTail(stdoutTail, { maxLines: 22 }).map(redactSecrets)) lines.push(` ${muted(line)}`);
1874
+ }
1875
+ }
1876
+ params.progress.tick();
1877
+ if (params.channelsStatus) {
1878
+ emitCheck(`Channel issues (${params.channelIssues.length || "none"})`, params.channelIssues.length === 0 ? "ok" : "warn");
1879
+ for (const issue of params.channelIssues.slice(0, 12)) {
1880
+ const fixText = issue.fix ? ` · fix: ${issue.fix}` : "";
1881
+ lines.push(` - ${issue.channel}[${issue.accountId}] ${issue.kind}: ${issue.message}${fixText}`);
1882
+ }
1883
+ if (params.channelIssues.length > 12) lines.push(` ${muted(`… +${params.channelIssues.length - 12} more`)}`);
1884
+ } else emitCheck(`Channel issues skipped (gateway ${params.gatewayReachable ? "query failed" : "unreachable"})`, "warn");
1885
+ const healthErr = (() => {
1886
+ if (!params.health || typeof params.health !== "object") return "";
1887
+ const record = params.health;
1888
+ if (!("error" in record)) return "";
1889
+ const value = record.error;
1890
+ if (!value) return "";
1891
+ if (typeof value === "string") return value;
1892
+ try {
1893
+ return JSON.stringify(value, null, 2);
1894
+ } catch {
1895
+ return "[unserializable error]";
1896
+ }
1897
+ })();
1898
+ if (healthErr) {
1899
+ lines.push("");
1900
+ lines.push(muted("Gateway health:"));
1901
+ lines.push(` ${muted(redactSecrets(healthErr))}`);
1902
+ }
1903
+ lines.push("");
1904
+ lines.push(muted("Pasteable debug report. Auth tokens redacted."));
1905
+ lines.push("Troubleshooting: https://docs.cryptoclaw.ai/troubleshooting");
1906
+ lines.push("");
1907
+ }
1908
+
1909
+ //#endregion
1910
+ //#region src/commands/status-all/report-lines.ts
1911
+ async function buildStatusAllReportLines(params) {
1912
+ const rich = isRich();
1913
+ const heading = (text) => rich ? theme.heading(text) : text;
1914
+ const ok = (text) => rich ? theme.success(text) : text;
1915
+ const warn = (text) => rich ? theme.warn(text) : text;
1916
+ const fail = (text) => rich ? theme.error(text) : text;
1917
+ const muted = (text) => rich ? theme.muted(text) : text;
1918
+ const tableWidth = Math.max(60, (process.stdout.columns ?? 120) - 1);
1919
+ const overview = renderTable({
1920
+ width: tableWidth,
1921
+ columns: [{
1922
+ key: "Item",
1923
+ header: "Item",
1924
+ minWidth: 10
1925
+ }, {
1926
+ key: "Value",
1927
+ header: "Value",
1928
+ flex: true,
1929
+ minWidth: 24
1930
+ }],
1931
+ rows: params.overviewRows
1932
+ });
1933
+ const channelRows = params.channels.rows.map((row) => ({
1934
+ channelId: row.id,
1935
+ Channel: row.label,
1936
+ Enabled: row.enabled ? ok("ON") : muted("OFF"),
1937
+ State: row.state === "ok" ? ok("OK") : row.state === "warn" ? warn("WARN") : row.state === "off" ? muted("OFF") : theme.accentDim("SETUP"),
1938
+ Detail: row.detail
1939
+ }));
1940
+ const channelIssuesByChannel = (() => {
1941
+ const map = /* @__PURE__ */ new Map();
1942
+ for (const issue of params.channelIssues) {
1943
+ const key = issue.channel;
1944
+ const list = map.get(key);
1945
+ if (list) list.push(issue);
1946
+ else map.set(key, [issue]);
1947
+ }
1948
+ return map;
1949
+ })();
1950
+ const channelsTable = renderTable({
1951
+ width: tableWidth,
1952
+ columns: [
1953
+ {
1954
+ key: "Channel",
1955
+ header: "Channel",
1956
+ minWidth: 10
1957
+ },
1958
+ {
1959
+ key: "Enabled",
1960
+ header: "Enabled",
1961
+ minWidth: 7
1962
+ },
1963
+ {
1964
+ key: "State",
1965
+ header: "State",
1966
+ minWidth: 8
1967
+ },
1968
+ {
1969
+ key: "Detail",
1970
+ header: "Detail",
1971
+ flex: true,
1972
+ minWidth: 28
1973
+ }
1974
+ ],
1975
+ rows: channelRows.map((row) => {
1976
+ const issues = channelIssuesByChannel.get(row.channelId) ?? [];
1977
+ if (issues.length === 0) return row;
1978
+ const issue = issues[0];
1979
+ const suffix = ` · ${warn(`gateway: ${String(issue.message).slice(0, 90)}`)}`;
1980
+ return {
1981
+ ...row,
1982
+ State: warn("WARN"),
1983
+ Detail: `${row.Detail}${suffix}`
1984
+ };
1985
+ })
1986
+ });
1987
+ const agentsTable = renderTable({
1988
+ width: tableWidth,
1989
+ columns: [
1990
+ {
1991
+ key: "Agent",
1992
+ header: "Agent",
1993
+ minWidth: 12
1994
+ },
1995
+ {
1996
+ key: "Bootstrap",
1997
+ header: "Bootstrap",
1998
+ minWidth: 10
1999
+ },
2000
+ {
2001
+ key: "Sessions",
2002
+ header: "Sessions",
2003
+ align: "right",
2004
+ minWidth: 8
2005
+ },
2006
+ {
2007
+ key: "Active",
2008
+ header: "Active",
2009
+ minWidth: 10
2010
+ },
2011
+ {
2012
+ key: "Store",
2013
+ header: "Store",
2014
+ flex: true,
2015
+ minWidth: 34
2016
+ }
2017
+ ],
2018
+ rows: params.agentStatus.agents.map((a) => ({
2019
+ Agent: a.name?.trim() ? `${a.id} (${a.name.trim()})` : a.id,
2020
+ Bootstrap: a.bootstrapPending === true ? warn("PENDING") : a.bootstrapPending === false ? ok("OK") : "unknown",
2021
+ Sessions: String(a.sessionsCount),
2022
+ Active: a.lastActiveAgeMs != null ? formatAge$1(a.lastActiveAgeMs) : "unknown",
2023
+ Store: a.sessionsPath
2024
+ }))
2025
+ });
2026
+ const lines = [];
2027
+ lines.push(heading("CryptoClaw status --all"));
2028
+ lines.push("");
2029
+ lines.push(heading("Overview"));
2030
+ lines.push(overview.trimEnd());
2031
+ lines.push("");
2032
+ lines.push(heading("Channels"));
2033
+ lines.push(channelsTable.trimEnd());
2034
+ for (const detail of params.channels.details) {
2035
+ lines.push("");
2036
+ lines.push(heading(detail.title));
2037
+ lines.push(renderTable({
2038
+ width: tableWidth,
2039
+ columns: detail.columns.map((c) => ({
2040
+ key: c,
2041
+ header: c,
2042
+ flex: c === "Notes",
2043
+ minWidth: c === "Notes" ? 28 : 10
2044
+ })),
2045
+ rows: detail.rows.map((r) => ({
2046
+ ...r,
2047
+ ...r.Status === "OK" ? { Status: ok("OK") } : r.Status === "WARN" ? { Status: warn("WARN") } : {}
2048
+ }))
2049
+ }).trimEnd());
2050
+ }
2051
+ lines.push("");
2052
+ lines.push(heading("Agents"));
2053
+ lines.push(agentsTable.trimEnd());
2054
+ lines.push("");
2055
+ lines.push(heading("Diagnosis (read-only)"));
2056
+ await appendStatusAllDiagnosis({
2057
+ lines,
2058
+ progress: params.progress,
2059
+ muted,
2060
+ ok,
2061
+ warn,
2062
+ fail,
2063
+ connectionDetailsForReport: params.connectionDetailsForReport,
2064
+ ...params.diagnosis
2065
+ });
2066
+ return lines;
2067
+ }
2068
+
2069
+ //#endregion
2070
+ //#region src/commands/status-all.ts
2071
+ async function statusAllCommand(runtime, opts) {
2072
+ await withProgress({
2073
+ label: "Scanning status --all…",
2074
+ total: 11
2075
+ }, async (progress) => {
2076
+ progress.setLabel("Loading config…");
2077
+ const cfg = loadConfig();
2078
+ const osSummary = resolveOsSummary();
2079
+ const snap = await readConfigFileSnapshot().catch(() => null);
2080
+ progress.tick();
2081
+ progress.setLabel("Checking Tailscale…");
2082
+ const tailscaleMode = cfg.gateway?.tailscale?.mode ?? "off";
2083
+ const tailscale = await (async () => {
2084
+ try {
2085
+ const parsed = await readTailscaleStatusJson(runExec, { timeoutMs: 1200 });
2086
+ const backendState = typeof parsed.BackendState === "string" ? parsed.BackendState : null;
2087
+ const self = typeof parsed.Self === "object" && parsed.Self !== null ? parsed.Self : null;
2088
+ const dnsNameRaw = self && typeof self.DNSName === "string" ? self.DNSName : null;
2089
+ return {
2090
+ ok: true,
2091
+ backendState,
2092
+ dnsName: dnsNameRaw ? dnsNameRaw.replace(/\.$/, "") : null,
2093
+ ips: self && Array.isArray(self.TailscaleIPs) ? self.TailscaleIPs.filter((v) => typeof v === "string" && v.trim().length > 0).map((v) => v.trim()) : [],
2094
+ error: null
2095
+ };
2096
+ } catch (err) {
2097
+ return {
2098
+ ok: false,
2099
+ backendState: null,
2100
+ dnsName: null,
2101
+ ips: [],
2102
+ error: String(err)
2103
+ };
2104
+ }
2105
+ })();
2106
+ const tailscaleHttpsUrl = tailscaleMode !== "off" && tailscale.dnsName ? `https://${tailscale.dnsName}${normalizeControlUiBasePath(cfg.gateway?.controlUi?.basePath)}` : null;
2107
+ progress.tick();
2108
+ progress.setLabel("Checking for updates…");
2109
+ const update = await checkUpdateStatus({
2110
+ root: await resolveOpenClawPackageRoot({
2111
+ moduleUrl: import.meta.url,
2112
+ argv1: process.argv[1],
2113
+ cwd: process.cwd()
2114
+ }),
2115
+ timeoutMs: 6500,
2116
+ fetchGit: true,
2117
+ includeRegistry: true
2118
+ });
2119
+ const channelInfo = resolveEffectiveUpdateChannel({
2120
+ configChannel: normalizeUpdateChannel(cfg.update?.channel),
2121
+ installKind: update.installKind,
2122
+ git: update.git ? {
2123
+ tag: update.git.tag,
2124
+ branch: update.git.branch
2125
+ } : void 0
2126
+ });
2127
+ const channelLabel = formatUpdateChannelLabel({
2128
+ channel: channelInfo.channel,
2129
+ source: channelInfo.source,
2130
+ gitTag: update.git?.tag ?? null,
2131
+ gitBranch: update.git?.branch ?? null
2132
+ });
2133
+ const gitLabel = update.installKind === "git" ? (() => {
2134
+ const shortSha = update.git?.sha ? update.git.sha.slice(0, 8) : null;
2135
+ const branch = update.git?.branch && update.git.branch !== "HEAD" ? update.git.branch : null;
2136
+ const tag = update.git?.tag ?? null;
2137
+ return [
2138
+ branch ?? (tag ? "detached" : "git"),
2139
+ tag ? `tag ${tag}` : null,
2140
+ shortSha ? `@ ${shortSha}` : null
2141
+ ].filter(Boolean).join(" · ");
2142
+ })() : null;
2143
+ progress.tick();
2144
+ progress.setLabel("Probing gateway…");
2145
+ const connection = buildGatewayConnectionDetails({ config: cfg });
2146
+ const isRemoteMode = cfg.gateway?.mode === "remote";
2147
+ const remoteUrlRaw = typeof cfg.gateway?.remote?.url === "string" ? cfg.gateway.remote.url.trim() : "";
2148
+ const remoteUrlMissing = isRemoteMode && !remoteUrlRaw;
2149
+ const gatewayMode = isRemoteMode ? "remote" : "local";
2150
+ const resolveProbeAuth = (mode) => {
2151
+ const authToken = cfg.gateway?.auth?.token;
2152
+ const authPassword = cfg.gateway?.auth?.password;
2153
+ const remote = cfg.gateway?.remote;
2154
+ return {
2155
+ token: mode === "remote" ? typeof remote?.token === "string" && remote.token.trim() ? remote.token.trim() : void 0 : process.env.CRYPTOCLAW_GATEWAY_TOKEN?.trim() || (typeof authToken === "string" && authToken.trim() ? authToken.trim() : void 0),
2156
+ password: process.env.CRYPTOCLAW_GATEWAY_PASSWORD?.trim() || (mode === "remote" ? typeof remote?.password === "string" && remote.password.trim() ? remote.password.trim() : void 0 : typeof authPassword === "string" && authPassword.trim() ? authPassword.trim() : void 0)
2157
+ };
2158
+ };
2159
+ const localFallbackAuth = resolveProbeAuth("local");
2160
+ const remoteAuth = resolveProbeAuth("remote");
2161
+ const probeAuth = isRemoteMode && !remoteUrlMissing ? remoteAuth : localFallbackAuth;
2162
+ const gatewayProbe = await probeGateway({
2163
+ url: connection.url,
2164
+ auth: probeAuth,
2165
+ timeoutMs: Math.min(5e3, opts?.timeoutMs ?? 1e4)
2166
+ }).catch(() => null);
2167
+ const gatewayReachable = gatewayProbe?.ok === true;
2168
+ const gatewaySelf = pickGatewaySelfPresence$1(gatewayProbe?.presence ?? null);
2169
+ progress.tick();
2170
+ progress.setLabel("Checking services…");
2171
+ const readServiceSummary = async (service) => {
2172
+ try {
2173
+ const [loaded, runtimeInfo, command] = await Promise.all([
2174
+ service.isLoaded({ env: process.env }).catch(() => false),
2175
+ service.readRuntime(process.env).catch(() => void 0),
2176
+ service.readCommand(process.env).catch(() => null)
2177
+ ]);
2178
+ const installed = command != null;
2179
+ return {
2180
+ label: service.label,
2181
+ installed,
2182
+ loaded,
2183
+ loadedText: loaded ? service.loadedText : service.notLoadedText,
2184
+ runtime: runtimeInfo
2185
+ };
2186
+ } catch {
2187
+ return null;
2188
+ }
2189
+ };
2190
+ const daemon = await readServiceSummary(resolveGatewayService());
2191
+ const nodeService = await readServiceSummary(resolveNodeService());
2192
+ progress.tick();
2193
+ progress.setLabel("Scanning agents…");
2194
+ const agentStatus = await getAgentLocalStatuses$1(cfg);
2195
+ progress.tick();
2196
+ progress.setLabel("Summarizing channels…");
2197
+ const channels = await buildChannelsTable(cfg, { showSecrets: false });
2198
+ progress.tick();
2199
+ const connectionDetailsForReport = (() => {
2200
+ if (!remoteUrlMissing) return connection.message;
2201
+ const bindMode = cfg.gateway?.bind ?? "loopback";
2202
+ return [
2203
+ "Gateway mode: remote",
2204
+ "Gateway target: (missing gateway.remote.url)",
2205
+ `Config: ${snap?.path?.trim() ? snap.path.trim() : "(unknown config path)"}`,
2206
+ `Bind: ${bindMode}`,
2207
+ `Local fallback (used for probes): ${connection.url}`,
2208
+ "Fix: set gateway.remote.url, or set gateway.mode=local."
2209
+ ].join("\n");
2210
+ })();
2211
+ const callOverrides = remoteUrlMissing ? {
2212
+ url: connection.url,
2213
+ token: localFallbackAuth.token,
2214
+ password: localFallbackAuth.password
2215
+ } : {};
2216
+ progress.setLabel("Querying gateway…");
2217
+ const health = gatewayReachable ? await callGateway({
2218
+ method: "health",
2219
+ timeoutMs: Math.min(8e3, opts?.timeoutMs ?? 1e4),
2220
+ ...callOverrides
2221
+ }).catch((err) => ({ error: String(err) })) : { error: gatewayProbe?.error ?? "gateway unreachable" };
2222
+ const channelsStatus = gatewayReachable ? await callGateway({
2223
+ method: "channels.status",
2224
+ params: {
2225
+ probe: false,
2226
+ timeoutMs: opts?.timeoutMs ?? 1e4
2227
+ },
2228
+ timeoutMs: Math.min(8e3, opts?.timeoutMs ?? 1e4),
2229
+ ...callOverrides
2230
+ }).catch(() => null) : null;
2231
+ const channelIssues = channelsStatus ? collectChannelStatusIssues(channelsStatus) : [];
2232
+ progress.tick();
2233
+ progress.setLabel("Checking local state…");
2234
+ const sentinel = await readRestartSentinel().catch(() => null);
2235
+ const lastErr = await readLastGatewayErrorLine(process.env).catch(() => null);
2236
+ const port = resolveGatewayPort(cfg);
2237
+ const portUsage = await inspectPortUsage(port).catch(() => null);
2238
+ progress.tick();
2239
+ const defaultWorkspace = agentStatus.agents.find((a) => a.id === agentStatus.defaultId)?.workspaceDir ?? agentStatus.agents[0]?.workspaceDir ?? null;
2240
+ const skillStatus = defaultWorkspace != null ? (() => {
2241
+ try {
2242
+ return buildWorkspaceSkillStatus(defaultWorkspace, {
2243
+ config: cfg,
2244
+ eligibility: { remote: getRemoteSkillEligibility() }
2245
+ });
2246
+ } catch {
2247
+ return null;
2248
+ }
2249
+ })() : null;
2250
+ const dashboard = cfg.gateway?.controlUi?.enabled ?? true ? resolveControlUiLinks({
2251
+ port,
2252
+ bind: cfg.gateway?.bind,
2253
+ customBindHost: cfg.gateway?.customBindHost,
2254
+ basePath: cfg.gateway?.controlUi?.basePath
2255
+ }).httpUrl : null;
2256
+ const updateLine = (() => {
2257
+ if (update.installKind === "git" && update.git) {
2258
+ const parts = [];
2259
+ parts.push(update.git.branch ? `git ${update.git.branch}` : "git");
2260
+ if (update.git.upstream) parts.push(`↔ ${update.git.upstream}`);
2261
+ if (update.git.dirty) parts.push("dirty");
2262
+ if (update.git.behind != null && update.git.ahead != null) if (update.git.behind === 0 && update.git.ahead === 0) parts.push("up to date");
2263
+ else if (update.git.behind > 0 && update.git.ahead === 0) parts.push(`behind ${update.git.behind}`);
2264
+ else if (update.git.behind === 0 && update.git.ahead > 0) parts.push(`ahead ${update.git.ahead}`);
2265
+ else parts.push(`diverged (ahead ${update.git.ahead}, behind ${update.git.behind})`);
2266
+ if (update.git.fetchOk === false) parts.push("fetch failed");
2267
+ const latest = update.registry?.latestVersion;
2268
+ if (latest) {
2269
+ const cmp = compareSemverStrings(VERSION, latest);
2270
+ if (cmp === 0) parts.push(`npm latest ${latest}`);
2271
+ else if (cmp != null && cmp < 0) parts.push(`npm update ${latest}`);
2272
+ else parts.push(`npm latest ${latest} (local newer)`);
2273
+ } else if (update.registry?.error) parts.push("npm latest unknown");
2274
+ if (update.deps?.status === "ok") parts.push("deps ok");
2275
+ if (update.deps?.status === "stale") parts.push("deps stale");
2276
+ if (update.deps?.status === "missing") parts.push("deps missing");
2277
+ return parts.join(" · ");
2278
+ }
2279
+ const parts = [];
2280
+ parts.push(update.packageManager !== "unknown" ? update.packageManager : "pkg");
2281
+ const latest = update.registry?.latestVersion;
2282
+ if (latest) {
2283
+ const cmp = compareSemverStrings(VERSION, latest);
2284
+ if (cmp === 0) parts.push(`npm latest ${latest}`);
2285
+ else if (cmp != null && cmp < 0) parts.push(`npm update ${latest}`);
2286
+ else parts.push(`npm latest ${latest} (local newer)`);
2287
+ } else if (update.registry?.error) parts.push("npm latest unknown");
2288
+ if (update.deps?.status === "ok") parts.push("deps ok");
2289
+ if (update.deps?.status === "stale") parts.push("deps stale");
2290
+ if (update.deps?.status === "missing") parts.push("deps missing");
2291
+ return parts.join(" · ");
2292
+ })();
2293
+ const gatewayTarget = remoteUrlMissing ? `fallback ${connection.url}` : connection.url;
2294
+ const gatewayStatus = gatewayReachable ? `reachable ${formatDuration$1(gatewayProbe?.connectLatencyMs)}` : gatewayProbe?.error ? `unreachable (${gatewayProbe.error})` : "unreachable";
2295
+ const gatewayAuth = gatewayReachable ? ` · auth ${formatGatewayAuthUsed(probeAuth)}` : "";
2296
+ const gatewaySelfLine = gatewaySelf?.host || gatewaySelf?.ip || gatewaySelf?.version || gatewaySelf?.platform ? [
2297
+ gatewaySelf.host ? gatewaySelf.host : null,
2298
+ gatewaySelf.ip ? `(${gatewaySelf.ip})` : null,
2299
+ gatewaySelf.version ? `app ${gatewaySelf.version}` : null,
2300
+ gatewaySelf.platform ? gatewaySelf.platform : null
2301
+ ].filter(Boolean).join(" ") : null;
2302
+ const aliveThresholdMs = 10 * 6e4;
2303
+ const aliveAgents = agentStatus.agents.filter((a) => a.lastActiveAgeMs != null && a.lastActiveAgeMs <= aliveThresholdMs).length;
2304
+ const lines = await buildStatusAllReportLines({
2305
+ progress,
2306
+ overviewRows: [
2307
+ {
2308
+ Item: "Version",
2309
+ Value: VERSION
2310
+ },
2311
+ {
2312
+ Item: "OS",
2313
+ Value: osSummary.label
2314
+ },
2315
+ {
2316
+ Item: "Node",
2317
+ Value: process.versions.node
2318
+ },
2319
+ {
2320
+ Item: "Config",
2321
+ Value: snap?.path?.trim() ? snap.path.trim() : "(unknown config path)"
2322
+ },
2323
+ dashboard ? {
2324
+ Item: "Dashboard",
2325
+ Value: dashboard
2326
+ } : {
2327
+ Item: "Dashboard",
2328
+ Value: "disabled"
2329
+ },
2330
+ {
2331
+ Item: "Tailscale",
2332
+ Value: tailscaleMode === "off" ? `off${tailscale.backendState ? ` · ${tailscale.backendState}` : ""}${tailscale.dnsName ? ` · ${tailscale.dnsName}` : ""}` : tailscale.dnsName && tailscaleHttpsUrl ? `${tailscaleMode} · ${tailscale.backendState ?? "unknown"} · ${tailscale.dnsName} · ${tailscaleHttpsUrl}` : `${tailscaleMode} · ${tailscale.backendState ?? "unknown"} · magicdns unknown`
2333
+ },
2334
+ {
2335
+ Item: "Channel",
2336
+ Value: channelLabel
2337
+ },
2338
+ ...gitLabel ? [{
2339
+ Item: "Git",
2340
+ Value: gitLabel
2341
+ }] : [],
2342
+ {
2343
+ Item: "Update",
2344
+ Value: updateLine
2345
+ },
2346
+ {
2347
+ Item: "Gateway",
2348
+ Value: `${gatewayMode}${remoteUrlMissing ? " (remote.url missing)" : ""} · ${gatewayTarget} (${connection.urlSource}) · ${gatewayStatus}${gatewayAuth}`
2349
+ },
2350
+ {
2351
+ Item: "Security",
2352
+ Value: `Run: ${formatCliCommand("cryptoclaw security audit --deep")}`
2353
+ },
2354
+ gatewaySelfLine ? {
2355
+ Item: "Gateway self",
2356
+ Value: gatewaySelfLine
2357
+ } : {
2358
+ Item: "Gateway self",
2359
+ Value: "unknown"
2360
+ },
2361
+ daemon ? {
2362
+ Item: "Gateway service",
2363
+ Value: !daemon.installed ? `${daemon.label} not installed` : `${daemon.label} ${daemon.installed ? "installed · " : ""}${daemon.loadedText}${daemon.runtime?.status ? ` · ${daemon.runtime.status}` : ""}${daemon.runtime?.pid ? ` (pid ${daemon.runtime.pid})` : ""}`
2364
+ } : {
2365
+ Item: "Gateway service",
2366
+ Value: "unknown"
2367
+ },
2368
+ nodeService ? {
2369
+ Item: "Node service",
2370
+ Value: !nodeService.installed ? `${nodeService.label} not installed` : `${nodeService.label} ${nodeService.installed ? "installed · " : ""}${nodeService.loadedText}${nodeService.runtime?.status ? ` · ${nodeService.runtime.status}` : ""}${nodeService.runtime?.pid ? ` (pid ${nodeService.runtime.pid})` : ""}`
2371
+ } : {
2372
+ Item: "Node service",
2373
+ Value: "unknown"
2374
+ },
2375
+ {
2376
+ Item: "Agents",
2377
+ Value: `${agentStatus.agents.length} total · ${agentStatus.bootstrapPendingCount} bootstrapping · ${aliveAgents} active · ${agentStatus.totalSessions} sessions`
2378
+ }
2379
+ ],
2380
+ channels,
2381
+ channelIssues: channelIssues.map((issue) => ({
2382
+ channel: issue.channel,
2383
+ message: issue.message
2384
+ })),
2385
+ agentStatus,
2386
+ connectionDetailsForReport,
2387
+ diagnosis: {
2388
+ snap,
2389
+ remoteUrlMissing,
2390
+ sentinel,
2391
+ lastErr,
2392
+ port,
2393
+ portUsage,
2394
+ tailscaleMode,
2395
+ tailscale,
2396
+ tailscaleHttpsUrl,
2397
+ skillStatus,
2398
+ channelsStatus,
2399
+ channelIssues,
2400
+ gatewayReachable,
2401
+ health
2402
+ }
2403
+ });
2404
+ progress.setLabel("Rendering…");
2405
+ runtime.log(lines.join("\n"));
2406
+ progress.tick();
2407
+ });
2408
+ }
2409
+
2410
+ //#endregion
2411
+ //#region src/commands/status.format.ts
2412
+ const formatKTokens = (value) => `${(value / 1e3).toFixed(value >= 1e4 ? 0 : 1)}k`;
2413
+ const formatAge = (ms) => {
2414
+ if (!ms || ms < 0) return "unknown";
2415
+ const minutes = Math.round(ms / 6e4);
2416
+ if (minutes < 1) return "just now";
2417
+ if (minutes < 60) return `${minutes}m ago`;
2418
+ const hours = Math.round(minutes / 60);
2419
+ if (hours < 48) return `${hours}h ago`;
2420
+ return `${Math.round(hours / 24)}d ago`;
2421
+ };
2422
+ const formatDuration = (ms) => {
2423
+ if (ms == null || !Number.isFinite(ms)) return "unknown";
2424
+ if (ms < 1e3) return `${Math.round(ms)}ms`;
2425
+ return `${(ms / 1e3).toFixed(1)}s`;
2426
+ };
2427
+ const shortenText = (value, maxLen) => {
2428
+ const chars = Array.from(value);
2429
+ if (chars.length <= maxLen) return value;
2430
+ return `${chars.slice(0, Math.max(0, maxLen - 1)).join("")}…`;
2431
+ };
2432
+ const formatTokensCompact = (sess) => {
2433
+ const used = sess.totalTokens ?? 0;
2434
+ const ctx = sess.contextTokens;
2435
+ if (!ctx) return `${formatKTokens(used)} used`;
2436
+ const pctLabel = sess.percentUsed != null ? `${sess.percentUsed}%` : "?%";
2437
+ return `${formatKTokens(used)}/${formatKTokens(ctx)} (${pctLabel})`;
2438
+ };
2439
+ const formatDaemonRuntimeShort = (runtime) => {
2440
+ if (!runtime) return null;
2441
+ const status = runtime.status ?? "unknown";
2442
+ const details = [];
2443
+ if (runtime.pid) details.push(`pid ${runtime.pid}`);
2444
+ if (runtime.state && runtime.state.toLowerCase() !== status) details.push(`state ${runtime.state}`);
2445
+ const detail = runtime.detail?.replace(/\s+/g, " ").trim() || "";
2446
+ const noisyLaunchctlDetail = runtime.missingUnit === true && detail.toLowerCase().includes("could not find service");
2447
+ if (detail && !noisyLaunchctlDetail) details.push(detail);
2448
+ return details.length > 0 ? `${status} (${details.join(", ")})` : status;
2449
+ };
2450
+
2451
+ //#endregion
2452
+ //#region src/commands/status.daemon.ts
2453
+ async function buildDaemonStatusSummary(service, fallbackLabel) {
2454
+ try {
2455
+ const [loaded, runtime, command] = await Promise.all([
2456
+ service.isLoaded({ env: process.env }).catch(() => false),
2457
+ service.readRuntime(process.env).catch(() => void 0),
2458
+ service.readCommand(process.env).catch(() => null)
2459
+ ]);
2460
+ const installed = command != null;
2461
+ const loadedText = loaded ? service.loadedText : service.notLoadedText;
2462
+ const runtimeShort = formatDaemonRuntimeShort(runtime);
2463
+ return {
2464
+ label: service.label,
2465
+ installed,
2466
+ loadedText,
2467
+ runtimeShort
2468
+ };
2469
+ } catch {
2470
+ return {
2471
+ label: fallbackLabel,
2472
+ installed: null,
2473
+ loadedText: "unknown",
2474
+ runtimeShort: null
2475
+ };
2476
+ }
2477
+ }
2478
+ async function getDaemonStatusSummary() {
2479
+ return await buildDaemonStatusSummary(resolveGatewayService(), "Daemon");
2480
+ }
2481
+ async function getNodeDaemonStatusSummary() {
2482
+ return await buildDaemonStatusSummary(resolveNodeService(), "Node");
2483
+ }
2484
+
2485
+ //#endregion
2486
+ //#region src/commands/status.gateway-probe.ts
2487
+ function resolveGatewayProbeAuth(cfg) {
2488
+ const isRemoteMode = cfg.gateway?.mode === "remote";
2489
+ const remote = isRemoteMode ? cfg.gateway?.remote : void 0;
2490
+ const authToken = cfg.gateway?.auth?.token;
2491
+ const authPassword = cfg.gateway?.auth?.password;
2492
+ return {
2493
+ token: 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),
2494
+ password: process.env.CRYPTOCLAW_GATEWAY_PASSWORD?.trim() || (isRemoteMode ? typeof remote?.password === "string" && remote.password.trim().length > 0 ? remote.password.trim() : void 0 : typeof authPassword === "string" && authPassword.trim().length > 0 ? authPassword.trim() : void 0)
2495
+ };
2496
+ }
2497
+ function pickGatewaySelfPresence(presence) {
2498
+ if (!Array.isArray(presence)) return null;
2499
+ const self = presence.find((e) => e.mode === "gateway" && e.reason === "self") ?? null;
2500
+ if (!self) return null;
2501
+ return {
2502
+ host: typeof self.host === "string" ? self.host : void 0,
2503
+ ip: typeof self.ip === "string" ? self.ip : void 0,
2504
+ version: typeof self.version === "string" ? self.version : void 0,
2505
+ platform: typeof self.platform === "string" ? self.platform : void 0
2506
+ };
2507
+ }
2508
+
2509
+ //#endregion
2510
+ //#region src/commands/status.agent-local.ts
2511
+ async function fileExists(p) {
2512
+ try {
2513
+ await fs$1.access(p);
2514
+ return true;
2515
+ } catch {
2516
+ return false;
2517
+ }
2518
+ }
2519
+ async function getAgentLocalStatuses() {
2520
+ const cfg = loadConfig();
2521
+ const agentList = listAgentsForGateway(cfg);
2522
+ const now = Date.now();
2523
+ const statuses = [];
2524
+ for (const agent of agentList.agents) {
2525
+ const agentId = agent.id;
2526
+ const workspaceDir = (() => {
2527
+ try {
2528
+ return resolveAgentWorkspaceDir(cfg, agentId);
2529
+ } catch {
2530
+ return null;
2531
+ }
2532
+ })();
2533
+ const bootstrapPath = workspaceDir != null ? path.join(workspaceDir, "BOOTSTRAP.md") : null;
2534
+ const bootstrapPending = bootstrapPath != null ? await fileExists(bootstrapPath) : null;
2535
+ const sessionsPath = resolveStorePath(cfg.session?.store, { agentId });
2536
+ const store = (() => {
2537
+ try {
2538
+ return loadSessionStore(sessionsPath);
2539
+ } catch {
2540
+ return {};
2541
+ }
2542
+ })();
2543
+ const sessions = Object.entries(store).filter(([key]) => key !== "global" && key !== "unknown").map(([, entry]) => entry);
2544
+ const sessionsCount = sessions.length;
2545
+ const lastUpdatedAt = sessions.reduce((max, e) => Math.max(max, e?.updatedAt ?? 0), 0);
2546
+ const resolvedLastUpdatedAt = lastUpdatedAt > 0 ? lastUpdatedAt : null;
2547
+ const lastActiveAgeMs = resolvedLastUpdatedAt ? now - resolvedLastUpdatedAt : null;
2548
+ statuses.push({
2549
+ id: agentId,
2550
+ name: agent.name,
2551
+ workspaceDir,
2552
+ bootstrapPending,
2553
+ sessionsPath,
2554
+ sessionsCount,
2555
+ lastUpdatedAt: resolvedLastUpdatedAt,
2556
+ lastActiveAgeMs
2557
+ });
2558
+ }
2559
+ const totalSessions = statuses.reduce((sum, s) => sum + s.sessionsCount, 0);
2560
+ const bootstrapPendingCount = statuses.reduce((sum, s) => sum + (s.bootstrapPending ? 1 : 0), 0);
2561
+ return {
2562
+ defaultId: agentList.defaultId,
2563
+ agents: statuses,
2564
+ totalSessions,
2565
+ bootstrapPendingCount
2566
+ };
2567
+ }
2568
+
2569
+ //#endregion
2570
+ //#region src/commands/status.link-channel.ts
2571
+ async function resolveLinkChannelContext(cfg) {
2572
+ for (const plugin of listChannelPlugins()) {
2573
+ const defaultAccountId = resolveChannelDefaultAccountId({
2574
+ plugin,
2575
+ cfg,
2576
+ accountIds: plugin.config.listAccountIds(cfg)
2577
+ });
2578
+ const account = plugin.config.resolveAccount(cfg, defaultAccountId);
2579
+ const enabled = plugin.config.isEnabled ? plugin.config.isEnabled(account, cfg) : true;
2580
+ const configured = plugin.config.isConfigured ? await plugin.config.isConfigured(account, cfg) : true;
2581
+ const snapshot = plugin.config.describeAccount ? plugin.config.describeAccount(account, cfg) : {
2582
+ accountId: defaultAccountId,
2583
+ enabled,
2584
+ configured
2585
+ };
2586
+ const summaryRecord = plugin.status?.buildChannelSummary ? await plugin.status.buildChannelSummary({
2587
+ account,
2588
+ cfg,
2589
+ defaultAccountId,
2590
+ snapshot
2591
+ }) : void 0;
2592
+ const linked = summaryRecord && typeof summaryRecord.linked === "boolean" ? summaryRecord.linked : null;
2593
+ if (linked === null) continue;
2594
+ return {
2595
+ linked,
2596
+ authAgeMs: summaryRecord && typeof summaryRecord.authAgeMs === "number" ? summaryRecord.authAgeMs : null,
2597
+ account,
2598
+ accountId: defaultAccountId,
2599
+ plugin
2600
+ };
2601
+ }
2602
+ return null;
2603
+ }
2604
+
2605
+ //#endregion
2606
+ //#region src/commands/status.summary.ts
2607
+ const classifyKey = (key, entry) => {
2608
+ if (key === "global") return "global";
2609
+ if (key === "unknown") return "unknown";
2610
+ if (entry?.chatType === "group" || entry?.chatType === "channel") return "group";
2611
+ if (key.includes(":group:") || key.includes(":channel:")) return "group";
2612
+ return "direct";
2613
+ };
2614
+ const buildFlags = (entry) => {
2615
+ if (!entry) return [];
2616
+ const flags = [];
2617
+ const think = entry?.thinkingLevel;
2618
+ if (typeof think === "string" && think.length > 0) flags.push(`think:${think}`);
2619
+ const verbose = entry?.verboseLevel;
2620
+ if (typeof verbose === "string" && verbose.length > 0) flags.push(`verbose:${verbose}`);
2621
+ const reasoning = entry?.reasoningLevel;
2622
+ if (typeof reasoning === "string" && reasoning.length > 0) flags.push(`reasoning:${reasoning}`);
2623
+ const elevated = entry?.elevatedLevel;
2624
+ if (typeof elevated === "string" && elevated.length > 0) flags.push(`elevated:${elevated}`);
2625
+ if (entry?.systemSent) flags.push("system");
2626
+ if (entry?.abortedLastRun) flags.push("aborted");
2627
+ const sessionId = entry?.sessionId;
2628
+ if (typeof sessionId === "string" && sessionId.length > 0) flags.push(`id:${sessionId}`);
2629
+ return flags;
2630
+ };
2631
+ async function getStatusSummary() {
2632
+ const cfg = loadConfig();
2633
+ const linkContext = await resolveLinkChannelContext(cfg);
2634
+ const agentList = listAgentsForGateway(cfg);
2635
+ const heartbeatAgents = agentList.agents.map((agent) => {
2636
+ const summary = resolveHeartbeatSummaryForAgent(cfg, agent.id);
2637
+ return {
2638
+ agentId: agent.id,
2639
+ enabled: summary.enabled,
2640
+ every: summary.every,
2641
+ everyMs: summary.everyMs
2642
+ };
2643
+ });
2644
+ const channelSummary = await buildChannelSummary(cfg, {
2645
+ colorize: true,
2646
+ includeAllowFrom: true
2647
+ });
2648
+ const queuedSystemEvents = peekSystemEvents(resolveMainSessionKey(cfg));
2649
+ const configModel = resolveConfiguredModelRef({
2650
+ cfg,
2651
+ defaultProvider: DEFAULT_PROVIDER,
2652
+ defaultModel: DEFAULT_MODEL
2653
+ }).model ?? DEFAULT_MODEL;
2654
+ const configContextTokens = cfg.agents?.defaults?.contextTokens ?? lookupContextTokens(configModel) ?? DEFAULT_CONTEXT_TOKENS;
2655
+ const now = Date.now();
2656
+ const storeCache = /* @__PURE__ */ new Map();
2657
+ const loadStore = (storePath) => {
2658
+ const cached = storeCache.get(storePath);
2659
+ if (cached) return cached;
2660
+ const store = loadSessionStore(storePath);
2661
+ storeCache.set(storePath, store);
2662
+ return store;
2663
+ };
2664
+ const buildSessionRows = (store, opts = {}) => Object.entries(store).filter(([key]) => key !== "global" && key !== "unknown").map(([key, entry]) => {
2665
+ const updatedAt = entry?.updatedAt ?? null;
2666
+ const age = updatedAt ? now - updatedAt : null;
2667
+ const model = entry?.model ?? configModel ?? null;
2668
+ const contextTokens = entry?.contextTokens ?? lookupContextTokens(model) ?? configContextTokens ?? null;
2669
+ const input = entry?.inputTokens ?? 0;
2670
+ const output = entry?.outputTokens ?? 0;
2671
+ const total = entry?.totalTokens ?? input + output;
2672
+ const remaining = contextTokens != null ? Math.max(0, contextTokens - total) : null;
2673
+ const pct = contextTokens && contextTokens > 0 ? Math.min(999, Math.round(total / contextTokens * 100)) : null;
2674
+ const parsedAgentId = parseAgentSessionKey(key)?.agentId;
2675
+ return {
2676
+ agentId: opts.agentIdOverride ?? parsedAgentId,
2677
+ key,
2678
+ kind: classifyKey(key, entry),
2679
+ sessionId: entry?.sessionId,
2680
+ updatedAt,
2681
+ age,
2682
+ thinkingLevel: entry?.thinkingLevel,
2683
+ verboseLevel: entry?.verboseLevel,
2684
+ reasoningLevel: entry?.reasoningLevel,
2685
+ elevatedLevel: entry?.elevatedLevel,
2686
+ systemSent: entry?.systemSent,
2687
+ abortedLastRun: entry?.abortedLastRun,
2688
+ inputTokens: entry?.inputTokens,
2689
+ outputTokens: entry?.outputTokens,
2690
+ totalTokens: total ?? null,
2691
+ remainingTokens: remaining,
2692
+ percentUsed: pct,
2693
+ model,
2694
+ contextTokens,
2695
+ flags: buildFlags(entry)
2696
+ };
2697
+ }).sort((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0));
2698
+ const paths = /* @__PURE__ */ new Set();
2699
+ const byAgent = agentList.agents.map((agent) => {
2700
+ const storePath = resolveStorePath(cfg.session?.store, { agentId: agent.id });
2701
+ paths.add(storePath);
2702
+ const sessions = buildSessionRows(loadStore(storePath), { agentIdOverride: agent.id });
2703
+ return {
2704
+ agentId: agent.id,
2705
+ path: storePath,
2706
+ count: sessions.length,
2707
+ recent: sessions.slice(0, 10)
2708
+ };
2709
+ });
2710
+ const allSessions = Array.from(paths).flatMap((storePath) => buildSessionRows(loadStore(storePath))).toSorted((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0));
2711
+ const recent = allSessions.slice(0, 10);
2712
+ const totalSessions = allSessions.length;
2713
+ return {
2714
+ linkChannel: linkContext ? {
2715
+ id: linkContext.plugin.id,
2716
+ label: linkContext.plugin.meta.label ?? "Channel",
2717
+ linked: linkContext.linked,
2718
+ authAgeMs: linkContext.authAgeMs
2719
+ } : void 0,
2720
+ heartbeat: {
2721
+ defaultAgentId: agentList.defaultId,
2722
+ agents: heartbeatAgents
2723
+ },
2724
+ channelSummary,
2725
+ queuedSystemEvents,
2726
+ sessions: {
2727
+ paths: Array.from(paths),
2728
+ count: totalSessions,
2729
+ defaults: {
2730
+ model: configModel ?? null,
2731
+ contextTokens: configContextTokens ?? null
2732
+ },
2733
+ recent,
2734
+ byAgent
2735
+ }
2736
+ };
2737
+ }
2738
+
2739
+ //#endregion
2740
+ //#region src/commands/status.scan.ts
2741
+ function resolveMemoryPluginStatus(cfg) {
2742
+ if (!(cfg.plugins?.enabled !== false)) return {
2743
+ enabled: false,
2744
+ slot: null,
2745
+ reason: "plugins disabled"
2746
+ };
2747
+ const raw = typeof cfg.plugins?.slots?.memory === "string" ? cfg.plugins.slots.memory.trim() : "";
2748
+ if (raw && raw.toLowerCase() === "none") return {
2749
+ enabled: false,
2750
+ slot: null,
2751
+ reason: "plugins.slots.memory=\"none\""
2752
+ };
2753
+ return {
2754
+ enabled: true,
2755
+ slot: raw || "memory-core"
2756
+ };
2757
+ }
2758
+ async function scanStatus(opts, _runtime) {
2759
+ return await withProgress({
2760
+ label: "Scanning status…",
2761
+ total: 10,
2762
+ enabled: opts.json !== true
2763
+ }, async (progress) => {
2764
+ progress.setLabel("Loading config…");
2765
+ const cfg = loadConfig();
2766
+ const osSummary = resolveOsSummary();
2767
+ progress.tick();
2768
+ progress.setLabel("Checking Tailscale…");
2769
+ const tailscaleMode = cfg.gateway?.tailscale?.mode ?? "off";
2770
+ const tailscaleDns = tailscaleMode === "off" ? null : await getTailnetHostname((cmd, args) => runExec(cmd, args, {
2771
+ timeoutMs: 1200,
2772
+ maxBuffer: 2e5
2773
+ })).catch(() => null);
2774
+ const tailscaleHttpsUrl = tailscaleMode !== "off" && tailscaleDns ? `https://${tailscaleDns}${normalizeControlUiBasePath(cfg.gateway?.controlUi?.basePath)}` : null;
2775
+ progress.tick();
2776
+ progress.setLabel("Checking for updates…");
2777
+ const update = await getUpdateCheckResult({
2778
+ timeoutMs: opts.all ? 6500 : 2500,
2779
+ fetchGit: true,
2780
+ includeRegistry: true
2781
+ });
2782
+ progress.tick();
2783
+ progress.setLabel("Resolving agents…");
2784
+ const agentStatus = await getAgentLocalStatuses();
2785
+ progress.tick();
2786
+ progress.setLabel("Probing gateway…");
2787
+ const gatewayConnection = buildGatewayConnectionDetails();
2788
+ const isRemoteMode = cfg.gateway?.mode === "remote";
2789
+ const remoteUrlRaw = typeof cfg.gateway?.remote?.url === "string" ? cfg.gateway.remote.url : "";
2790
+ const remoteUrlMissing = isRemoteMode && !remoteUrlRaw.trim();
2791
+ const gatewayMode = isRemoteMode ? "remote" : "local";
2792
+ const gatewayProbe = remoteUrlMissing ? null : await probeGateway({
2793
+ url: gatewayConnection.url,
2794
+ auth: resolveGatewayProbeAuth(cfg),
2795
+ timeoutMs: Math.min(opts.all ? 5e3 : 2500, opts.timeoutMs ?? 1e4)
2796
+ }).catch(() => null);
2797
+ const gatewayReachable = gatewayProbe?.ok === true;
2798
+ const gatewaySelf = gatewayProbe?.presence ? pickGatewaySelfPresence(gatewayProbe.presence) : null;
2799
+ progress.tick();
2800
+ progress.setLabel("Querying channel status…");
2801
+ const channelsStatus = gatewayReachable ? await callGateway({
2802
+ method: "channels.status",
2803
+ params: {
2804
+ probe: false,
2805
+ timeoutMs: Math.min(8e3, opts.timeoutMs ?? 1e4)
2806
+ },
2807
+ timeoutMs: Math.min(opts.all ? 5e3 : 2500, opts.timeoutMs ?? 1e4)
2808
+ }).catch(() => null) : null;
2809
+ const channelIssues = channelsStatus ? collectChannelStatusIssues(channelsStatus) : [];
2810
+ progress.tick();
2811
+ progress.setLabel("Summarizing channels…");
2812
+ const channels = await buildChannelsTable(cfg, { showSecrets: process.env.CLAWDBOT_SHOW_SECRETS?.trim() !== "0" });
2813
+ progress.tick();
2814
+ progress.setLabel("Checking memory…");
2815
+ const memoryPlugin = resolveMemoryPluginStatus(cfg);
2816
+ const memory = await (async () => {
2817
+ if (!memoryPlugin.enabled) return null;
2818
+ if (memoryPlugin.slot !== "memory-core") return null;
2819
+ const agentId = agentStatus.defaultId ?? "main";
2820
+ const { manager } = await getMemorySearchManager({
2821
+ cfg,
2822
+ agentId
2823
+ });
2824
+ if (!manager) return null;
2825
+ try {
2826
+ await manager.probeVectorAvailability();
2827
+ } catch {}
2828
+ const status = manager.status();
2829
+ await manager.close?.().catch(() => {});
2830
+ return {
2831
+ agentId,
2832
+ ...status
2833
+ };
2834
+ })();
2835
+ progress.tick();
2836
+ progress.setLabel("Reading sessions…");
2837
+ const summary = await getStatusSummary();
2838
+ progress.tick();
2839
+ progress.setLabel("Rendering…");
2840
+ progress.tick();
2841
+ return {
2842
+ cfg,
2843
+ osSummary,
2844
+ tailscaleMode,
2845
+ tailscaleDns,
2846
+ tailscaleHttpsUrl,
2847
+ update,
2848
+ gatewayConnection,
2849
+ remoteUrlMissing,
2850
+ gatewayMode,
2851
+ gatewayProbe,
2852
+ gatewayReachable,
2853
+ gatewaySelf,
2854
+ channelIssues,
2855
+ agentStatus,
2856
+ channels,
2857
+ summary,
2858
+ memory,
2859
+ memoryPlugin
2860
+ };
2861
+ });
2862
+ }
2863
+
2864
+ //#endregion
2865
+ //#region src/commands/status.command.ts
2866
+ async function statusCommand(opts, runtime) {
2867
+ if (opts.all && !opts.json) {
2868
+ await statusAllCommand(runtime, { timeoutMs: opts.timeoutMs });
2869
+ return;
2870
+ }
2871
+ const { cfg, osSummary, tailscaleMode, tailscaleDns, tailscaleHttpsUrl, update, gatewayConnection, remoteUrlMissing, gatewayMode, gatewayProbe, gatewayReachable, gatewaySelf, channelIssues, agentStatus, channels, summary, memory, memoryPlugin } = await scanStatus({
2872
+ json: opts.json,
2873
+ timeoutMs: opts.timeoutMs,
2874
+ all: opts.all
2875
+ }, runtime);
2876
+ const securityAudit = await withProgress({
2877
+ label: "Running security audit…",
2878
+ indeterminate: true,
2879
+ enabled: opts.json !== true
2880
+ }, async () => await runSecurityAudit({
2881
+ config: cfg,
2882
+ deep: false,
2883
+ includeFilesystem: true,
2884
+ includeChannelSecurity: true
2885
+ }));
2886
+ const usage = opts.usage ? await withProgress({
2887
+ label: "Fetching usage snapshot…",
2888
+ indeterminate: true,
2889
+ enabled: opts.json !== true
2890
+ }, async () => await loadProviderUsageSummary({ timeoutMs: opts.timeoutMs })) : void 0;
2891
+ const health = opts.deep ? await withProgress({
2892
+ label: "Checking gateway health…",
2893
+ indeterminate: true,
2894
+ enabled: opts.json !== true
2895
+ }, async () => await callGateway({
2896
+ method: "health",
2897
+ params: { probe: true },
2898
+ timeoutMs: opts.timeoutMs
2899
+ })) : void 0;
2900
+ const lastHeartbeat = opts.deep && gatewayReachable ? await callGateway({
2901
+ method: "last-heartbeat",
2902
+ params: {},
2903
+ timeoutMs: opts.timeoutMs
2904
+ }).catch(() => null) : null;
2905
+ const channelInfo = resolveEffectiveUpdateChannel({
2906
+ configChannel: normalizeUpdateChannel(cfg.update?.channel),
2907
+ installKind: update.installKind,
2908
+ git: update.git ? {
2909
+ tag: update.git.tag,
2910
+ branch: update.git.branch
2911
+ } : void 0
2912
+ });
2913
+ if (opts.json) {
2914
+ const [daemon, nodeDaemon] = await Promise.all([getDaemonStatusSummary(), getNodeDaemonStatusSummary()]);
2915
+ runtime.log(JSON.stringify({
2916
+ ...summary,
2917
+ os: osSummary,
2918
+ update,
2919
+ updateChannel: channelInfo.channel,
2920
+ updateChannelSource: channelInfo.source,
2921
+ memory,
2922
+ memoryPlugin,
2923
+ gateway: {
2924
+ mode: gatewayMode,
2925
+ url: gatewayConnection.url,
2926
+ urlSource: gatewayConnection.urlSource,
2927
+ misconfigured: remoteUrlMissing,
2928
+ reachable: gatewayReachable,
2929
+ connectLatencyMs: gatewayProbe?.connectLatencyMs ?? null,
2930
+ self: gatewaySelf,
2931
+ error: gatewayProbe?.error ?? null
2932
+ },
2933
+ gatewayService: daemon,
2934
+ nodeService: nodeDaemon,
2935
+ agents: agentStatus,
2936
+ securityAudit,
2937
+ ...health || usage || lastHeartbeat ? {
2938
+ health,
2939
+ usage,
2940
+ lastHeartbeat
2941
+ } : {}
2942
+ }, null, 2));
2943
+ return;
2944
+ }
2945
+ const muted = (value) => theme.muted(value);
2946
+ const ok = (value) => theme.success(value);
2947
+ const warn = (value) => theme.warn(value);
2948
+ if (opts.verbose) {
2949
+ const details = buildGatewayConnectionDetails();
2950
+ runtime.log(info("Gateway connection:"));
2951
+ for (const line of details.message.split("\n")) runtime.log(` ${line}`);
2952
+ runtime.log("");
2953
+ }
2954
+ const tableWidth = Math.max(60, (process.stdout.columns ?? 120) - 1);
2955
+ const dashboard = (() => {
2956
+ if (!(cfg.gateway?.controlUi?.enabled ?? true)) return "disabled";
2957
+ return resolveControlUiLinks({
2958
+ port: resolveGatewayPort(cfg),
2959
+ bind: cfg.gateway?.bind,
2960
+ customBindHost: cfg.gateway?.customBindHost,
2961
+ basePath: cfg.gateway?.controlUi?.basePath
2962
+ }).httpUrl;
2963
+ })();
2964
+ const gatewayValue = (() => {
2965
+ const target = remoteUrlMissing ? `fallback ${gatewayConnection.url}` : `${gatewayConnection.url}${gatewayConnection.urlSource ? ` (${gatewayConnection.urlSource})` : ""}`;
2966
+ const reach = remoteUrlMissing ? warn("misconfigured (remote.url missing)") : gatewayReachable ? ok(`reachable ${formatDuration(gatewayProbe?.connectLatencyMs)}`) : warn(gatewayProbe?.error ? `unreachable (${gatewayProbe.error})` : "unreachable");
2967
+ const auth = gatewayReachable && !remoteUrlMissing ? ` · auth ${formatGatewayAuthUsed(resolveGatewayProbeAuth(cfg))}` : "";
2968
+ const self = gatewaySelf?.host || gatewaySelf?.version || gatewaySelf?.platform ? [
2969
+ gatewaySelf?.host ? gatewaySelf.host : null,
2970
+ gatewaySelf?.ip ? `(${gatewaySelf.ip})` : null,
2971
+ gatewaySelf?.version ? `app ${gatewaySelf.version}` : null,
2972
+ gatewaySelf?.platform ? gatewaySelf.platform : null
2973
+ ].filter(Boolean).join(" ") : null;
2974
+ return `${gatewayMode} · ${target} · ${reach}${auth}${self ? ` · ${self}` : ""}`;
2975
+ })();
2976
+ const agentsValue = (() => {
2977
+ const pending = agentStatus.bootstrapPendingCount > 0 ? `${agentStatus.bootstrapPendingCount} bootstrapping` : "no bootstraps";
2978
+ const def = agentStatus.agents.find((a) => a.id === agentStatus.defaultId);
2979
+ const defActive = def?.lastActiveAgeMs != null ? formatAge(def.lastActiveAgeMs) : "unknown";
2980
+ const defSuffix = def ? ` · default ${def.id} active ${defActive}` : "";
2981
+ return `${agentStatus.agents.length} · ${pending} · sessions ${agentStatus.totalSessions}${defSuffix}`;
2982
+ })();
2983
+ const [daemon, nodeDaemon] = await Promise.all([getDaemonStatusSummary(), getNodeDaemonStatusSummary()]);
2984
+ const daemonValue = (() => {
2985
+ if (daemon.installed === false) return `${daemon.label} not installed`;
2986
+ const installedPrefix = daemon.installed === true ? "installed · " : "";
2987
+ return `${daemon.label} ${installedPrefix}${daemon.loadedText}${daemon.runtimeShort ? ` · ${daemon.runtimeShort}` : ""}`;
2988
+ })();
2989
+ const nodeDaemonValue = (() => {
2990
+ if (nodeDaemon.installed === false) return `${nodeDaemon.label} not installed`;
2991
+ const installedPrefix = nodeDaemon.installed === true ? "installed · " : "";
2992
+ return `${nodeDaemon.label} ${installedPrefix}${nodeDaemon.loadedText}${nodeDaemon.runtimeShort ? ` · ${nodeDaemon.runtimeShort}` : ""}`;
2993
+ })();
2994
+ const defaults = summary.sessions.defaults;
2995
+ const defaultCtx = defaults.contextTokens ? ` (${formatKTokens(defaults.contextTokens)} ctx)` : "";
2996
+ const eventsValue = summary.queuedSystemEvents.length > 0 ? `${summary.queuedSystemEvents.length} queued` : "none";
2997
+ const probesValue = health ? ok("enabled") : muted("skipped (use --deep)");
2998
+ const heartbeatValue = (() => {
2999
+ const parts = summary.heartbeat.agents.map((agent) => {
3000
+ if (!agent.enabled || !agent.everyMs) return `disabled (${agent.agentId})`;
3001
+ return `${agent.every} (${agent.agentId})`;
3002
+ }).filter(Boolean);
3003
+ return parts.length > 0 ? parts.join(", ") : "disabled";
3004
+ })();
3005
+ const lastHeartbeatValue = (() => {
3006
+ if (!opts.deep) return null;
3007
+ if (!gatewayReachable) return warn("unavailable");
3008
+ if (!lastHeartbeat) return muted("none");
3009
+ const age = formatAge(Date.now() - lastHeartbeat.ts);
3010
+ const channel = lastHeartbeat.channel ?? "unknown";
3011
+ const accountLabel = lastHeartbeat.accountId ? `account ${lastHeartbeat.accountId}` : null;
3012
+ return [
3013
+ lastHeartbeat.status,
3014
+ `${age} ago`,
3015
+ channel,
3016
+ accountLabel
3017
+ ].filter(Boolean).join(" · ");
3018
+ })();
3019
+ const storeLabel = summary.sessions.paths.length > 1 ? `${summary.sessions.paths.length} stores` : summary.sessions.paths[0] ?? "unknown";
3020
+ const memoryValue = (() => {
3021
+ if (!memoryPlugin.enabled) return muted(`disabled${memoryPlugin.reason ? ` (${memoryPlugin.reason})` : ""}`);
3022
+ if (!memory) return muted(`enabled (${memoryPlugin.slot ? `plugin ${memoryPlugin.slot}` : "plugin"}) · unavailable`);
3023
+ const parts = [];
3024
+ const dirtySuffix = memory.dirty ? ` · ${warn("dirty")}` : "";
3025
+ parts.push(`${memory.files} files · ${memory.chunks} chunks${dirtySuffix}`);
3026
+ if (memory.sources?.length) parts.push(`sources ${memory.sources.join(", ")}`);
3027
+ if (memoryPlugin.slot) parts.push(`plugin ${memoryPlugin.slot}`);
3028
+ const colorByTone = (tone, text) => tone === "ok" ? ok(text) : tone === "warn" ? warn(text) : muted(text);
3029
+ const vector = memory.vector;
3030
+ if (vector) {
3031
+ const state = resolveMemoryVectorState(vector);
3032
+ const label = state.state === "disabled" ? "vector off" : `vector ${state.state}`;
3033
+ parts.push(colorByTone(state.tone, label));
3034
+ }
3035
+ const fts = memory.fts;
3036
+ if (fts) {
3037
+ const state = resolveMemoryFtsState(fts);
3038
+ const label = state.state === "disabled" ? "fts off" : `fts ${state.state}`;
3039
+ parts.push(colorByTone(state.tone, label));
3040
+ }
3041
+ const cache = memory.cache;
3042
+ if (cache) {
3043
+ const summary = resolveMemoryCacheSummary(cache);
3044
+ parts.push(colorByTone(summary.tone, summary.text));
3045
+ }
3046
+ return parts.join(" · ");
3047
+ })();
3048
+ const updateAvailability = resolveUpdateAvailability(update);
3049
+ const updateLine = formatUpdateOneLiner(update).replace(/^Update:\s*/i, "");
3050
+ const channelLabel = formatUpdateChannelLabel({
3051
+ channel: channelInfo.channel,
3052
+ source: channelInfo.source,
3053
+ gitTag: update.git?.tag ?? null,
3054
+ gitBranch: update.git?.branch ?? null
3055
+ });
3056
+ const gitLabel = update.installKind === "git" ? (() => {
3057
+ const shortSha = update.git?.sha ? update.git.sha.slice(0, 8) : null;
3058
+ const branch = update.git?.branch && update.git.branch !== "HEAD" ? update.git.branch : null;
3059
+ const tag = update.git?.tag ?? null;
3060
+ return [
3061
+ branch ?? (tag ? "detached" : "git"),
3062
+ tag ? `tag ${tag}` : null,
3063
+ shortSha ? `@ ${shortSha}` : null
3064
+ ].filter(Boolean).join(" · ");
3065
+ })() : null;
3066
+ const overviewRows = [
3067
+ {
3068
+ Item: "Dashboard",
3069
+ Value: dashboard
3070
+ },
3071
+ {
3072
+ Item: "OS",
3073
+ Value: `${osSummary.label} · node ${process.versions.node}`
3074
+ },
3075
+ {
3076
+ Item: "Tailscale",
3077
+ Value: tailscaleMode === "off" ? muted("off") : tailscaleDns && tailscaleHttpsUrl ? `${tailscaleMode} · ${tailscaleDns} · ${tailscaleHttpsUrl}` : warn(`${tailscaleMode} · magicdns unknown`)
3078
+ },
3079
+ {
3080
+ Item: "Channel",
3081
+ Value: channelLabel
3082
+ },
3083
+ ...gitLabel ? [{
3084
+ Item: "Git",
3085
+ Value: gitLabel
3086
+ }] : [],
3087
+ {
3088
+ Item: "Update",
3089
+ Value: updateAvailability.available ? warn(`available · ${updateLine}`) : updateLine
3090
+ },
3091
+ {
3092
+ Item: "Gateway",
3093
+ Value: gatewayValue
3094
+ },
3095
+ {
3096
+ Item: "Gateway service",
3097
+ Value: daemonValue
3098
+ },
3099
+ {
3100
+ Item: "Node service",
3101
+ Value: nodeDaemonValue
3102
+ },
3103
+ {
3104
+ Item: "Agents",
3105
+ Value: agentsValue
3106
+ },
3107
+ {
3108
+ Item: "Memory",
3109
+ Value: memoryValue
3110
+ },
3111
+ {
3112
+ Item: "Probes",
3113
+ Value: probesValue
3114
+ },
3115
+ {
3116
+ Item: "Events",
3117
+ Value: eventsValue
3118
+ },
3119
+ {
3120
+ Item: "Heartbeat",
3121
+ Value: heartbeatValue
3122
+ },
3123
+ ...lastHeartbeatValue ? [{
3124
+ Item: "Last heartbeat",
3125
+ Value: lastHeartbeatValue
3126
+ }] : [],
3127
+ {
3128
+ Item: "Sessions",
3129
+ Value: `${summary.sessions.count} active · default ${defaults.model ?? "unknown"}${defaultCtx} · ${storeLabel}`
3130
+ }
3131
+ ];
3132
+ runtime.log(theme.heading("CryptoClaw status"));
3133
+ runtime.log("");
3134
+ runtime.log(theme.heading("Overview"));
3135
+ runtime.log(renderTable({
3136
+ width: tableWidth,
3137
+ columns: [{
3138
+ key: "Item",
3139
+ header: "Item",
3140
+ minWidth: 12
3141
+ }, {
3142
+ key: "Value",
3143
+ header: "Value",
3144
+ flex: true,
3145
+ minWidth: 32
3146
+ }],
3147
+ rows: overviewRows
3148
+ }).trimEnd());
3149
+ runtime.log("");
3150
+ runtime.log(theme.heading("Security audit"));
3151
+ const fmtSummary = (value) => {
3152
+ return [
3153
+ theme.error(`${value.critical} critical`),
3154
+ theme.warn(`${value.warn} warn`),
3155
+ theme.muted(`${value.info} info`)
3156
+ ].join(" · ");
3157
+ };
3158
+ runtime.log(theme.muted(`Summary: ${fmtSummary(securityAudit.summary)}`));
3159
+ const importantFindings = securityAudit.findings.filter((f) => f.severity === "critical" || f.severity === "warn");
3160
+ if (importantFindings.length === 0) runtime.log(theme.muted("No critical or warn findings detected."));
3161
+ else {
3162
+ const severityLabel = (sev) => {
3163
+ if (sev === "critical") return theme.error("CRITICAL");
3164
+ if (sev === "warn") return theme.warn("WARN");
3165
+ return theme.muted("INFO");
3166
+ };
3167
+ const sevRank = (sev) => sev === "critical" ? 0 : sev === "warn" ? 1 : 2;
3168
+ const sorted = [...importantFindings].toSorted((a, b) => sevRank(a.severity) - sevRank(b.severity));
3169
+ const shown = sorted.slice(0, 6);
3170
+ for (const f of shown) {
3171
+ runtime.log(` ${severityLabel(f.severity)} ${f.title}`);
3172
+ runtime.log(` ${shortenText(f.detail.replaceAll("\n", " "), 160)}`);
3173
+ if (f.remediation?.trim()) runtime.log(` ${theme.muted(`Fix: ${f.remediation.trim()}`)}`);
3174
+ }
3175
+ if (sorted.length > shown.length) runtime.log(theme.muted(`… +${sorted.length - shown.length} more`));
3176
+ }
3177
+ runtime.log(theme.muted(`Full report: ${formatCliCommand("cryptoclaw security audit")}`));
3178
+ runtime.log(theme.muted(`Deep probe: ${formatCliCommand("cryptoclaw security audit --deep")}`));
3179
+ runtime.log("");
3180
+ runtime.log(theme.heading("Channels"));
3181
+ const channelIssuesByChannel = (() => {
3182
+ const map = /* @__PURE__ */ new Map();
3183
+ for (const issue of channelIssues) {
3184
+ const key = issue.channel;
3185
+ const list = map.get(key);
3186
+ if (list) list.push(issue);
3187
+ else map.set(key, [issue]);
3188
+ }
3189
+ return map;
3190
+ })();
3191
+ runtime.log(renderTable({
3192
+ width: tableWidth,
3193
+ columns: [
3194
+ {
3195
+ key: "Channel",
3196
+ header: "Channel",
3197
+ minWidth: 10
3198
+ },
3199
+ {
3200
+ key: "Enabled",
3201
+ header: "Enabled",
3202
+ minWidth: 7
3203
+ },
3204
+ {
3205
+ key: "State",
3206
+ header: "State",
3207
+ minWidth: 8
3208
+ },
3209
+ {
3210
+ key: "Detail",
3211
+ header: "Detail",
3212
+ flex: true,
3213
+ minWidth: 24
3214
+ }
3215
+ ],
3216
+ rows: channels.rows.map((row) => {
3217
+ const issues = channelIssuesByChannel.get(row.id) ?? [];
3218
+ const effectiveState = row.state === "off" ? "off" : issues.length > 0 ? "warn" : row.state;
3219
+ const issueSuffix = issues.length > 0 ? ` · ${warn(`gateway: ${shortenText(issues[0]?.message ?? "issue", 84)}`)}` : "";
3220
+ return {
3221
+ Channel: row.label,
3222
+ Enabled: row.enabled ? ok("ON") : muted("OFF"),
3223
+ State: effectiveState === "ok" ? ok("OK") : effectiveState === "warn" ? warn("WARN") : effectiveState === "off" ? muted("OFF") : theme.accentDim("SETUP"),
3224
+ Detail: `${row.detail}${issueSuffix}`
3225
+ };
3226
+ })
3227
+ }).trimEnd());
3228
+ runtime.log("");
3229
+ runtime.log(theme.heading("Sessions"));
3230
+ runtime.log(renderTable({
3231
+ width: tableWidth,
3232
+ columns: [
3233
+ {
3234
+ key: "Key",
3235
+ header: "Key",
3236
+ minWidth: 20,
3237
+ flex: true
3238
+ },
3239
+ {
3240
+ key: "Kind",
3241
+ header: "Kind",
3242
+ minWidth: 6
3243
+ },
3244
+ {
3245
+ key: "Age",
3246
+ header: "Age",
3247
+ minWidth: 9
3248
+ },
3249
+ {
3250
+ key: "Model",
3251
+ header: "Model",
3252
+ minWidth: 14
3253
+ },
3254
+ {
3255
+ key: "Tokens",
3256
+ header: "Tokens",
3257
+ minWidth: 16
3258
+ }
3259
+ ],
3260
+ rows: summary.sessions.recent.length > 0 ? summary.sessions.recent.map((sess) => ({
3261
+ Key: shortenText(sess.key, 32),
3262
+ Kind: sess.kind,
3263
+ Age: sess.updatedAt ? formatAge(sess.age) : "no activity",
3264
+ Model: sess.model ?? "unknown",
3265
+ Tokens: formatTokensCompact(sess)
3266
+ })) : [{
3267
+ Key: muted("no sessions yet"),
3268
+ Kind: "",
3269
+ Age: "",
3270
+ Model: "",
3271
+ Tokens: ""
3272
+ }]
3273
+ }).trimEnd());
3274
+ if (summary.queuedSystemEvents.length > 0) {
3275
+ runtime.log("");
3276
+ runtime.log(theme.heading("System events"));
3277
+ runtime.log(renderTable({
3278
+ width: tableWidth,
3279
+ columns: [{
3280
+ key: "Event",
3281
+ header: "Event",
3282
+ flex: true,
3283
+ minWidth: 24
3284
+ }],
3285
+ rows: summary.queuedSystemEvents.slice(0, 5).map((event) => ({ Event: event }))
3286
+ }).trimEnd());
3287
+ if (summary.queuedSystemEvents.length > 5) runtime.log(muted(`… +${summary.queuedSystemEvents.length - 5} more`));
3288
+ }
3289
+ if (health) {
3290
+ runtime.log("");
3291
+ runtime.log(theme.heading("Health"));
3292
+ const rows = [];
3293
+ rows.push({
3294
+ Item: "Gateway",
3295
+ Status: ok("reachable"),
3296
+ Detail: `${health.durationMs}ms`
3297
+ });
3298
+ for (const line of formatHealthChannelLines(health, { accountMode: "all" })) {
3299
+ const colon = line.indexOf(":");
3300
+ if (colon === -1) continue;
3301
+ const item = line.slice(0, colon).trim();
3302
+ const detail = line.slice(colon + 1).trim();
3303
+ const normalized = detail.toLowerCase();
3304
+ const status = (() => {
3305
+ if (normalized.startsWith("ok")) return ok("OK");
3306
+ if (normalized.startsWith("failed")) return warn("WARN");
3307
+ if (normalized.startsWith("not configured")) return muted("OFF");
3308
+ if (normalized.startsWith("configured")) return ok("OK");
3309
+ if (normalized.startsWith("linked")) return ok("LINKED");
3310
+ if (normalized.startsWith("not linked")) return warn("UNLINKED");
3311
+ return warn("WARN");
3312
+ })();
3313
+ rows.push({
3314
+ Item: item,
3315
+ Status: status,
3316
+ Detail: detail
3317
+ });
3318
+ }
3319
+ runtime.log(renderTable({
3320
+ width: tableWidth,
3321
+ columns: [
3322
+ {
3323
+ key: "Item",
3324
+ header: "Item",
3325
+ minWidth: 10
3326
+ },
3327
+ {
3328
+ key: "Status",
3329
+ header: "Status",
3330
+ minWidth: 8
3331
+ },
3332
+ {
3333
+ key: "Detail",
3334
+ header: "Detail",
3335
+ flex: true,
3336
+ minWidth: 28
3337
+ }
3338
+ ],
3339
+ rows
3340
+ }).trimEnd());
3341
+ }
3342
+ if (usage) {
3343
+ runtime.log("");
3344
+ runtime.log(theme.heading("Usage"));
3345
+ for (const line of formatUsageReportLines(usage)) runtime.log(line);
3346
+ }
3347
+ runtime.log("");
3348
+ runtime.log("FAQ: https://docs.cryptoclaw.ai/faq");
3349
+ runtime.log("Troubleshooting: https://docs.cryptoclaw.ai/troubleshooting");
3350
+ runtime.log("");
3351
+ const updateHint = formatUpdateAvailableHint(update);
3352
+ if (updateHint) {
3353
+ runtime.log(theme.warn(updateHint));
3354
+ runtime.log("");
3355
+ }
3356
+ runtime.log("Next steps:");
3357
+ runtime.log(` Need to share? ${formatCliCommand("cryptoclaw status --all")}`);
3358
+ runtime.log(` Need to debug live? ${formatCliCommand("cryptoclaw logs --follow")}`);
3359
+ if (gatewayReachable) runtime.log(` Need to test channels? ${formatCliCommand("cryptoclaw status --deep")}`);
3360
+ else runtime.log(` Fix reachability first: ${formatCliCommand("cryptoclaw gateway probe")}`);
3361
+ }
3362
+
3363
+ //#endregion
3364
+ export { findAgentEntryIndex as a, pruneAgentConfig as c, parseIdentityMarkdown as d, runOnboardingWizard as f, buildAgentSummaries as i, identityHasValues as l, getStatusSummary as n, listAgentEntries as o, applyAgentConfig as r, loadAgentIdentity as s, statusCommand as t, loadAgentIdentityFromWorkspace as u };