silentlake 2026.3.24

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 (1893) hide show
  1. package/CHANGELOG.md +4587 -0
  2. package/LICENSE +21 -0
  3. package/README.md +248 -0
  4. package/assets/avatar-placeholder.svg +19 -0
  5. package/assets/chrome-extension/icons/icon128.png +0 -0
  6. package/assets/chrome-extension/icons/icon16.png +0 -0
  7. package/assets/chrome-extension/icons/icon32.png +0 -0
  8. package/assets/chrome-extension/icons/icon48.png +0 -0
  9. package/assets/dmg-background-small.png +0 -0
  10. package/assets/dmg-background.png +0 -0
  11. package/assets/silentlake-banner.png +0 -0
  12. package/dist/APEv2Parser-BZv_dP9t.js +269 -0
  13. package/dist/APEv2Parser-CPzxFNBB.js +5 -0
  14. package/dist/AbstractID3Parser-mvDFcjYV.js +47 -0
  15. package/dist/AiffParser-BXQ9SRZk.js +145 -0
  16. package/dist/AsfParser-CmBDUlZE.js +631 -0
  17. package/dist/BasicParser-DhmXREDo.js +853 -0
  18. package/dist/DsdiffParser-CTKKGyZg.js +150 -0
  19. package/dist/DsfParser-Ds-YQe4Z.js +101 -0
  20. package/dist/FlacParser-B1XVPgXF.js +5 -0
  21. package/dist/FlacParser-DMPyL1y4.js +367 -0
  22. package/dist/ID3v1Parser-BICWWVDG.js +289 -0
  23. package/dist/ID3v2Parser-BmZHSUqs.js +650 -0
  24. package/dist/ID3v2Token-DeJf4tYQ.js +145 -0
  25. package/dist/MP4Parser-Cjf-Zs8T.js +1061 -0
  26. package/dist/MatroskaParser-DgBzBe8t.js +909 -0
  27. package/dist/MpegParser-D5swTpA1.js +744 -0
  28. package/dist/MusepackParser-D8EQXnpK.js +285 -0
  29. package/dist/OggParser-BcIYPHwP.js +390 -0
  30. package/dist/Util-D_zGsr97.js +170 -0
  31. package/dist/WavPackParser-hosU8gfo.js +166 -0
  32. package/dist/WaveParser-CA00FZrC.js +273 -0
  33. package/dist/abort-cutoff-CERmtgZI.js +56 -0
  34. package/dist/abort-cutoff.runtime-DZkGKKzv.js +61 -0
  35. package/dist/abort-signal-CsrBEr94.js +13 -0
  36. package/dist/account-helpers-D3c_eI7c.js +37 -0
  37. package/dist/account-helpers-ru3jdZSV.js +12 -0
  38. package/dist/account-id-DZnNZg8x.js +1 -0
  39. package/dist/account-id-ZCrgXl7Z.js +44 -0
  40. package/dist/account-lookup-nkoa-foB.js +10 -0
  41. package/dist/account-snapshot-fields-Cvq7803C.js +116 -0
  42. package/dist/account-summary-B5Xzvntm.js +36 -0
  43. package/dist/accounts-43SvCDEA.js +212 -0
  44. package/dist/accounts-CYgFhv2o.js +105 -0
  45. package/dist/accounts-ChlyF7cx.js +112 -0
  46. package/dist/ack-reactions-CNVwfOBj.js +43 -0
  47. package/dist/acp-cli-B4Rv7-xU.js +2033 -0
  48. package/dist/acp-runtime-BdLdT-QY.js +1 -0
  49. package/dist/actions.runtime-CqnQssoB.js +217 -0
  50. package/dist/actions.runtime-FLmCvVRd.js +236 -0
  51. package/dist/agent-CBOdzEvR.js +1 -0
  52. package/dist/agent-scope-BLhzf-o0.js +17 -0
  53. package/dist/agent-scope-DPP4Z_UU.js +193 -0
  54. package/dist/agents-D8pBK0II.js +855 -0
  55. package/dist/agents-Dihz1Ihx.js +323 -0
  56. package/dist/agents.config-C_lrnc9J.js +18 -0
  57. package/dist/agents.config-D1VqC78r.js +121 -0
  58. package/dist/allow-from-BPSBITdd.js +9 -0
  59. package/dist/allow-from-BwTLpvhp.js +20 -0
  60. package/dist/allow-from-C4iBpqFI.js +62 -0
  61. package/dist/allowlist-config-edit-CKbnMmwS.js +279 -0
  62. package/dist/allowlist-match-CYmPgg1K.js +63 -0
  63. package/dist/ansi-BEJF8NKS.js +54 -0
  64. package/dist/anthropic-vertex-provider-Dd5agCN9.js +60 -0
  65. package/dist/apply.runtime-DhKxNSJE.js +370 -0
  66. package/dist/apply.runtime-ghlh-P6X.js +211 -0
  67. package/dist/archive-Tr0wIUO-.js +532 -0
  68. package/dist/arg-split-Dtda0YDl.js +38 -0
  69. package/dist/artifacts-C_4LekPC.js +39 -0
  70. package/dist/audit-BOPSQQtd.js +54 -0
  71. package/dist/audit-C5kdrCi_.js +788 -0
  72. package/dist/audit-channel.allow-from.runtime-B7BHNblL.js +17 -0
  73. package/dist/audit-channel.collect.runtime-CjAbXFBV.js +521 -0
  74. package/dist/audit-channel.discord.runtime-BBY6S9lg.js +5 -0
  75. package/dist/audit-channel.telegram.runtime-SJnxOJH2.js +8 -0
  76. package/dist/audit-channel.zalouser.runtime-SGRWvHxT.js +5 -0
  77. package/dist/audit-extra.async-DY8v7LXH.js +817 -0
  78. package/dist/audit-fs-oDMUa5N_.js +375 -0
  79. package/dist/audit-membership-runtime-BPjFryEx.js +261 -0
  80. package/dist/audit.deep.runtime-WFf-TpsD.js +31 -0
  81. package/dist/audit.nondeep.runtime-B4BaEaRU.js +842 -0
  82. package/dist/audit.runtime-rFjCrods.js +74 -0
  83. package/dist/auth-O6LQFLHJ.js +416 -0
  84. package/dist/auth-choice-DIBaxmAQ.js +219 -0
  85. package/dist/auth-choice-PrbpIjyg.js +610 -0
  86. package/dist/auth-choice-legacy-Clyw2lVc.js +17 -0
  87. package/dist/auth-choice-options-ohUw8QR-.js +127 -0
  88. package/dist/auth-choice-prompt-Cm0s-9Du.js +215 -0
  89. package/dist/auth-choice-prompt-DI-Xl1Nv.js +36 -0
  90. package/dist/auth-choice-rKBOd02a.js +64 -0
  91. package/dist/auth-choice.apply-helpers-BibBSEl9.js +66 -0
  92. package/dist/auth-choice.plugin-providers.runtime-gqF9NO7_.js +219 -0
  93. package/dist/auth-health-TWboMYA5.js +166 -0
  94. package/dist/auth-mode-policy-DywddkT-.js +18 -0
  95. package/dist/auth-profiles-CWEIQV77.js +1047 -0
  96. package/dist/auth-profiles.runtime-B98lwopF.js +48 -0
  97. package/dist/avatar-policy-Ds9e6uHI.js +67 -0
  98. package/dist/axios-xDDnM0KG.js +12831 -0
  99. package/dist/backup-create-B6JAR6jJ.js +461 -0
  100. package/dist/banner-bez5CpOK.js +351 -0
  101. package/dist/base-session-key-Cf2rkwag.js +14 -0
  102. package/dist/bindings-BV4AtNSY.js +21 -0
  103. package/dist/bindings-kjwuC11Q.js +69 -0
  104. package/dist/bluebubbles-C1M3Geg0.js +87 -0
  105. package/dist/bluebubbles-DRW3JdOY.js +603 -0
  106. package/dist/bluebubbles-dEl4QpYz.js +37 -0
  107. package/dist/bonjour-discovery-C2oY96BG.js +376 -0
  108. package/dist/boolean-DKtCJu_W.js +29 -0
  109. package/dist/boolean-param-xAGXUSSN.js +13 -0
  110. package/dist/boundary-file-read-BP6VMpqH.js +106 -0
  111. package/dist/boundary-path-B3FFLYNx.js +557 -0
  112. package/dist/brave-CkimJe4j.js +405 -0
  113. package/dist/brew-DSwWqzLd.js +44 -0
  114. package/dist/browser-cli-D3kBUBNc.js +1502 -0
  115. package/dist/bundled/boot-md/handler.js +381 -0
  116. package/dist/bundled/bootstrap-extra-files/handler.js +56 -0
  117. package/dist/bundled/command-logger/handler.js +62 -0
  118. package/dist/bundled/session-memory/handler.js +401 -0
  119. package/dist/call-BDvaXe4i.js +44 -0
  120. package/dist/call-BmLt3xO1.js +639 -0
  121. package/dist/catalog-BwAYUfL7.js +240 -0
  122. package/dist/channel-BBCuV5OT.js +4945 -0
  123. package/dist/channel-BDBXuqeg.js +321 -0
  124. package/dist/channel-C8h1Irxm.js +1284 -0
  125. package/dist/channel-CbGpFzo4.js +1602 -0
  126. package/dist/channel-Ci3K8fI9.js +1006 -0
  127. package/dist/channel-DGT5N1v7.js +1077 -0
  128. package/dist/channel-account-context-Bwa-YH_o.js +104 -0
  129. package/dist/channel-actions-DU2CR3xW.js +37 -0
  130. package/dist/channel-activity-B8aReQoE.js +35 -0
  131. package/dist/channel-config-3Uv6ve2_.js +115 -0
  132. package/dist/channel-config-helpers-CieQWILI.js +377 -0
  133. package/dist/channel-config-schema-DEVsCZpj.js +1 -0
  134. package/dist/channel-feedback-G6zh8efr.js +245 -0
  135. package/dist/channel-inbound-DwzVf2PK.js +395 -0
  136. package/dist/channel-lifecycle-CpU1dRbh.js +354 -0
  137. package/dist/channel-options-DJaIP4Dv.js +38 -0
  138. package/dist/channel-pairing-D54mn51y.js +66 -0
  139. package/dist/channel-plugin-common-BhTxCE5t.js +1 -0
  140. package/dist/channel-plugin-ids-CFeS3qir.js +26 -0
  141. package/dist/channel-plugin-resolution-DUngfdFj.js +112 -0
  142. package/dist/channel-policy-C4GKHvhz.js +1 -0
  143. package/dist/channel-reply-pipeline-CPTuaW8n.js +15 -0
  144. package/dist/channel-send-result-By8EpCPw.js +40 -0
  145. package/dist/channel-setup-Ck35g7zI.js +49 -0
  146. package/dist/channel-shared-LkXtTPXk.js +308 -0
  147. package/dist/channel-summary-CdYLGMVt.js +137 -0
  148. package/dist/channel-summary-D33z52ft.js +41 -0
  149. package/dist/channel-targets-DfnKGXez.js +87 -0
  150. package/dist/channel.runtime-DAyBR2A5.js +324 -0
  151. package/dist/channel.runtime-DVq5tC2D.js +35 -0
  152. package/dist/channel.runtime-DaLTDGtF.js +288 -0
  153. package/dist/channel.runtime-FKfTev2g.js +512 -0
  154. package/dist/channel.runtime-owqedh1t.js +268 -0
  155. package/dist/channel.runtime-wOTeiifp.js +230 -0
  156. package/dist/channels-CIHgkPea.js +408 -0
  157. package/dist/channels-ZXK6Jiuk.js +1393 -0
  158. package/dist/channels-cli-Bj6qSlkE.js +412 -0
  159. package/dist/channels-status-issues-C_U44M8Y.js +16 -0
  160. package/dist/chat-type-C-n03mQY.js +10 -0
  161. package/dist/clack-prompter-DuzDnaLi.js +112 -0
  162. package/dist/clawbot-cli-YNPuwmTB.js +218 -0
  163. package/dist/cli/daemon-cli.js +88 -0
  164. package/dist/cli-CW46WAZn.js +254 -0
  165. package/dist/cli-name-Daok7A7-.js +25 -0
  166. package/dist/cli-runtime-aAVwbEYy.js +7 -0
  167. package/dist/cli-utils-Np4NAAtt.js +39 -0
  168. package/dist/command-format-CYK9XiUC.js +16 -0
  169. package/dist/command-format-g8YUHNir.js +2 -0
  170. package/dist/command-gating-BQXGSqc9.js +40 -0
  171. package/dist/command-options-5coRiipK.js +25 -0
  172. package/dist/command-poll-backoff-CpkSns-6.js +56 -0
  173. package/dist/command-poll-backoff.runtime-YT6EGcLN.js +7 -0
  174. package/dist/command-registry-BI2MOs89.js +242 -0
  175. package/dist/command-registry-BMsxnuoC.js +14 -0
  176. package/dist/command-secret-gateway-ChXyZwos.js +211 -0
  177. package/dist/command-secret-targets-COcwhn-D.js +88 -0
  178. package/dist/command-secret-targets-CQJT3viO.js +3 -0
  179. package/dist/commands-Bb9xUwz9.js +42 -0
  180. package/dist/commands-core-C1usZXC2.js +4923 -0
  181. package/dist/commands-core.runtime-OTZivlO2.js +232 -0
  182. package/dist/commands-registry-ChCep1KJ.js +295 -0
  183. package/dist/commands-registry.data-XyUTELK9.js +904 -0
  184. package/dist/commands-registry.runtime-m5WTxFtv.js +25 -0
  185. package/dist/commands-status.runtime-C8_hpNgj.js +211 -0
  186. package/dist/commands.runtime-BZPnQKcW.js +232 -0
  187. package/dist/common-CUBlLRXB.js +457 -0
  188. package/dist/compact.runtime-Djmzpbn6.js +216 -0
  189. package/dist/completion-cli-D8tLgE5W.js +445 -0
  190. package/dist/completion-cli-Dz89naVA.js +17 -0
  191. package/dist/config-6sZwvXJD.js +88 -0
  192. package/dist/config-B7tPwoHZ.js +38 -0
  193. package/dist/config-DdDLrP_v.js +273 -0
  194. package/dist/config-cli-C10R8azD.js +945 -0
  195. package/dist/config-guard-B1c73BYQ.js +126 -0
  196. package/dist/config-helpers-3u5wfLBu.js +117 -0
  197. package/dist/config-pn7LKJdW.js +23 -0
  198. package/dist/config-presence-BmUF_5K9.js +79 -0
  199. package/dist/config-regex-CvZFnWkO.js +39 -0
  200. package/dist/config-runtime-CstET7fq.js +142 -0
  201. package/dist/config-schema-5YkIW1xw.js +270 -0
  202. package/dist/config-schema-B1UGMwZ8.js +31 -0
  203. package/dist/config-schema-DzlnsY3D.js +33 -0
  204. package/dist/config-state-CE0CGjey.js +288 -0
  205. package/dist/config-validation-CkVqgkHr.js +272 -0
  206. package/dist/config-value-DgJrpclm.js +25 -0
  207. package/dist/configure-DMkp7Sr4.js +1126 -0
  208. package/dist/configure-DOrQthLy.js +344 -0
  209. package/dist/connection-auth-BSQJeDOU.js +30 -0
  210. package/dist/constants-C_Scc680.js +71 -0
  211. package/dist/control-ui-assets-DjqeIg6A.js +232 -0
  212. package/dist/control-ui-shared-DP000Pxd.js +29 -0
  213. package/dist/conversation-runtime-1O0Aaolb.js +1458 -0
  214. package/dist/core-C7aHA4Aq.js +187 -0
  215. package/dist/core-command-descriptors-DCUYAEZd.js +96 -0
  216. package/dist/credentials-BPwBlm1X.js +265 -0
  217. package/dist/cron-cli-N2Hw_02d.js +579 -0
  218. package/dist/daemon-cli-DgfaF9xx.js +354 -0
  219. package/dist/daemon-install-CbclJo5M.js +134 -0
  220. package/dist/daemon-install-plan.shared-DK6BHlWI.js +222 -0
  221. package/dist/daemon-runtime-CbClrCwc.js +12 -0
  222. package/dist/dangerous-config-flags-BJtLWIk7.js +15 -0
  223. package/dist/dangerous-name-matching-DZa_t0RM.js +44 -0
  224. package/dist/dangerous-tools-yGPDFTHh.js +27 -0
  225. package/dist/date-time-DCAyaBop.js +118 -0
  226. package/dist/dedupe-Cgnk5BbX.js +55 -0
  227. package/dist/defaults-CEdZhIIb.js +6 -0
  228. package/dist/delegate-D4ql5N70.js +43 -0
  229. package/dist/deliver-B004w1Mv.js +212 -0
  230. package/dist/deliver-runtime-IYvc0giI.js +211 -0
  231. package/dist/delivery-queue-B19wDCjT.js +3 -0
  232. package/dist/delivery-queue-DrrqB4Hi.js +299 -0
  233. package/dist/device-auth-GEXe9vqR.js +15 -0
  234. package/dist/device-bootstrap-CwwokLEY.js +96 -0
  235. package/dist/device-bootstrap-Dbhe6oe8.js +1 -0
  236. package/dist/device-metadata-normalization-BDSQ_eA7.js +21 -0
  237. package/dist/device-pairing-cFWbBray.js +553 -0
  238. package/dist/devices-cli-DzycjFzS.js +366 -0
  239. package/dist/diagnostic-DqJXx_4Q.js +310 -0
  240. package/dist/diagnostic-events-ktCoG8Br.js +48 -0
  241. package/dist/diagnostics-CMhyGsPu.js +33 -0
  242. package/dist/diagnostics-DpLHpQ9c.js +14 -0
  243. package/dist/directive-handling.fast-lane-toP_ri_H.js +273 -0
  244. package/dist/directive-handling.impl-BRARyrsT.js +638 -0
  245. package/dist/directive-handling.impl-CUB4MOnK.js +214 -0
  246. package/dist/directive-handling.levels-8vnMeuGX.js +2 -0
  247. package/dist/directive-handling.levels-CoruY1AA.js +13 -0
  248. package/dist/directive-handling.persist.runtime-78Du6PgL.js +170 -0
  249. package/dist/directive-handling.shared-DCGUCHjn.js +147 -0
  250. package/dist/directory-cli-DVsDcgIU.js +437 -0
  251. package/dist/directory-config-helpers-CURJ8mj7.js +129 -0
  252. package/dist/directory-runtime-DhC8QkMq.js +19 -0
  253. package/dist/directory.static-DQaG9ohH.js +44 -0
  254. package/dist/discord-CYj8s73O.js +214 -0
  255. package/dist/discord-L9zvSHVn.js +635 -0
  256. package/dist/discord-core-5tkl-BzP.js +1 -0
  257. package/dist/dm-policy-shared-6bCJzHOS.js +188 -0
  258. package/dist/dns-cli-BMvHy265.js +223 -0
  259. package/dist/docker-XFNiArwM.js +1254 -0
  260. package/dist/docs-cli-BTaH94wD.js +176 -0
  261. package/dist/doctor-completion-DKx5m2UC.js +90 -0
  262. package/dist/doctor-config-preflight-BzQgc3_t.js +40 -0
  263. package/dist/doctor-config-preflight-DxVCut8L.js +150 -0
  264. package/dist/doctor-state-migrations-CTF66iAy.js +732 -0
  265. package/dist/doctor-state-migrations-D0VP4dUh.js +212 -0
  266. package/dist/entry-status-B2OWAf0s.js +172 -0
  267. package/dist/entry.js +210 -0
  268. package/dist/env-BP70DGuy.js +30 -0
  269. package/dist/env-overrides-JneV60sd.js +434 -0
  270. package/dist/env-overrides.runtime-DLrwions.js +18 -0
  271. package/dist/env-substitution-D6t_sLS_.js +136 -0
  272. package/dist/errors-BxyFnvP3.js +58 -0
  273. package/dist/exec-Dmex2w_d.js +310 -0
  274. package/dist/exec-approvals-BJhuySBz.js +386 -0
  275. package/dist/exec-approvals-allowlist-B_wPddCb.js +384 -0
  276. package/dist/exec-approvals-cli-C2dwhSkX.js +427 -0
  277. package/dist/exec-safe-bin-runtime-policy-BZkObC8r.js +89 -0
  278. package/dist/exec-safety-CaaBy-Zw.js +24 -0
  279. package/dist/extension-shared-5txN7IXK.js +74 -0
  280. package/dist/extensionAPI.js +218 -0
  281. package/dist/extensions/amazon-bedrock/index.js +231 -0
  282. package/dist/extensions/anthropic/index.js +330 -0
  283. package/dist/extensions/bluebubbles/index.js +224 -0
  284. package/dist/extensions/bluebubbles/setup-entry.js +289 -0
  285. package/dist/extensions/brave/index.js +23 -0
  286. package/dist/extensions/byteplus/index.js +112 -0
  287. package/dist/extensions/chutes/index.js +221 -0
  288. package/dist/extensions/cloudflare-ai-gateway/index.js +218 -0
  289. package/dist/extensions/copilot-proxy/index.js +125 -0
  290. package/dist/extensions/device-pair/index.js +1040 -0
  291. package/dist/extensions/discord/index.js +215 -0
  292. package/dist/extensions/discord/setup-entry.js +215 -0
  293. package/dist/extensions/elevenlabs/index.js +223 -0
  294. package/dist/extensions/fal/index.js +112 -0
  295. package/dist/extensions/feishu/index.js +227 -0
  296. package/dist/extensions/feishu/setup-entry.js +112 -0
  297. package/dist/extensions/firecrawl/index.js +211 -0
  298. package/dist/extensions/github-copilot/index.js +490 -0
  299. package/dist/extensions/google/index.js +211 -0
  300. package/dist/extensions/huggingface/index.js +108 -0
  301. package/dist/extensions/imessage/index.js +223 -0
  302. package/dist/extensions/imessage/setup-entry.js +220 -0
  303. package/dist/extensions/irc/index.js +220 -0
  304. package/dist/extensions/irc/setup-entry.js +222 -0
  305. package/dist/extensions/kilocode/index.js +282 -0
  306. package/dist/extensions/kimi-coding/index.js +148 -0
  307. package/dist/extensions/line/index.js +57 -0
  308. package/dist/extensions/line/setup-entry.js +49 -0
  309. package/dist/extensions/llm-task/index.js +157 -0
  310. package/dist/extensions/lobster/index.js +261 -0
  311. package/dist/extensions/mattermost/index.js +220 -0
  312. package/dist/extensions/mattermost/setup-entry.js +222 -0
  313. package/dist/extensions/memory-core/index.js +36 -0
  314. package/dist/extensions/microsoft/index.js +223 -0
  315. package/dist/extensions/minimax/index.js +437 -0
  316. package/dist/extensions/mistral/index.js +149 -0
  317. package/dist/extensions/modelstudio/index.js +144 -0
  318. package/dist/extensions/moonshot/index.js +211 -0
  319. package/dist/extensions/nextcloud-talk/index.js +221 -0
  320. package/dist/extensions/nextcloud-talk/setup-entry.js +223 -0
  321. package/dist/extensions/nvidia/index.js +29 -0
  322. package/dist/extensions/ollama/index.js +118 -0
  323. package/dist/extensions/open-prose/index.js +10 -0
  324. package/dist/extensions/openai/index.js +677 -0
  325. package/dist/extensions/opencode/index.js +116 -0
  326. package/dist/extensions/opencode-go/index.js +114 -0
  327. package/dist/extensions/openrouter/index.js +398 -0
  328. package/dist/extensions/openshell/index.js +923 -0
  329. package/dist/extensions/perplexity/index.js +23 -0
  330. package/dist/extensions/phone-control/index.js +276 -0
  331. package/dist/extensions/qianfan/index.js +114 -0
  332. package/dist/extensions/qwen-portal-auth/index.js +350 -0
  333. package/dist/extensions/sglang/index.js +285 -0
  334. package/dist/extensions/signal/index.js +218 -0
  335. package/dist/extensions/signal/setup-entry.js +218 -0
  336. package/dist/extensions/slack/index.js +222 -0
  337. package/dist/extensions/slack/setup-entry.js +220 -0
  338. package/dist/extensions/synology-chat/index.js +56 -0
  339. package/dist/extensions/synology-chat/setup-entry.js +58 -0
  340. package/dist/extensions/synthetic/index.js +112 -0
  341. package/dist/extensions/talk-voice/index.js +197 -0
  342. package/dist/extensions/tavily/index.js +211 -0
  343. package/dist/extensions/telegram/index.js +221 -0
  344. package/dist/extensions/telegram/setup-entry.js +221 -0
  345. package/dist/extensions/thread-ownership/index.js +70 -0
  346. package/dist/extensions/together/index.js +113 -0
  347. package/dist/extensions/venice/index.js +132 -0
  348. package/dist/extensions/vercel-ai-gateway/index.js +86 -0
  349. package/dist/extensions/vllm/index.js +285 -0
  350. package/dist/extensions/voice-call/index.js +5715 -0
  351. package/dist/extensions/volcengine/index.js +112 -0
  352. package/dist/extensions/xai/index.js +211 -0
  353. package/dist/extensions/xiaomi/index.js +115 -0
  354. package/dist/extensions/zai/index.js +559 -0
  355. package/dist/extensions/zalo/index.js +225 -0
  356. package/dist/extensions/zalo/setup-entry.js +226 -0
  357. package/dist/external-content-BUdUOqkv.js +238 -0
  358. package/dist/feishu-CgbwAF0e.js +2664 -0
  359. package/dist/feishu-Dh5fEbh5.js +59127 -0
  360. package/dist/fetch-guard-DIyN1HW5.js +165 -0
  361. package/dist/fetch-timeout-C5xpMuGd.js +36 -0
  362. package/dist/file-identity-Cw0fQxYY.js +11 -0
  363. package/dist/file-lock-WbEmczmY.js +107 -0
  364. package/dist/filter-oMGaNOM1.js +20 -0
  365. package/dist/format-DH8ysi7s.js +19 -0
  366. package/dist/format-datetime-BGS6tLDE.js +73 -0
  367. package/dist/format-duration-CO0BGWB0.js +57 -0
  368. package/dist/format-relative-C3nDxnXz.js +54 -0
  369. package/dist/frontmatter-S5vS-I4a.js +309 -0
  370. package/dist/fs-safe-D3qzH-ab.js +731 -0
  371. package/dist/gateway-cli-PQNp7o0j.js +28378 -0
  372. package/dist/gateway-install-token-DV5KjD4F.js +164 -0
  373. package/dist/gateway-rpc-C0Ey-rik.js +26 -0
  374. package/dist/gateway-runtime-ih2e7a2K.js +42 -0
  375. package/dist/gaxios-fetch-compat-KX6bsqFm.js +165 -0
  376. package/dist/gemini-auth-B5ljg7jr.js +29 -0
  377. package/dist/git-commit-BIdLubm5.js +2 -0
  378. package/dist/git-commit-OvUvjri2.js +177 -0
  379. package/dist/github-copilot-auth-Ccm-cBwy.js +104 -0
  380. package/dist/global-singleton-4KwY5RvX.js +13 -0
  381. package/dist/globals-41sdSaKv.js +38 -0
  382. package/dist/gmail-setup-utils-BX68dZla.js +419 -0
  383. package/dist/group-access-DJZrYPx1.js +113 -0
  384. package/dist/group-keys-BD_IYSMs.js +44 -0
  385. package/dist/group-policy-CWFxv3iB.js +201 -0
  386. package/dist/group-policy-warnings-Ddu6lBkh.js +175 -0
  387. package/dist/health-Bu1sbyYy.js +573 -0
  388. package/dist/health-Cbxc9Bn3.js +59 -0
  389. package/dist/health-format-B5XfOTuJ.js +26 -0
  390. package/dist/heartbeat-7aHh0m3d.js +169 -0
  391. package/dist/heartbeat-summary-Das49TYq.js +57 -0
  392. package/dist/help-CcbF7-ha.js +81 -0
  393. package/dist/help-format-Dv45FpYu.js +15 -0
  394. package/dist/helpers-DJ-5HEbE.js +24 -0
  395. package/dist/helpers-MxyaLZUk.js +32 -0
  396. package/dist/history-CHjo8B5W.js +102 -0
  397. package/dist/hook-runtime-BnNBi_q4.js +1 -0
  398. package/dist/hooks-cli-DUYK4RM1.js +1102 -0
  399. package/dist/hooks-policy-BL6HDLUn.js +20 -0
  400. package/dist/hooks-status-gzNmo3li.js +78 -0
  401. package/dist/host-env-security-BogNN146.js +223 -0
  402. package/dist/http-body-CCiSfloA.js +237 -0
  403. package/dist/http-registry-WFFbLYRd.js +153 -0
  404. package/dist/identity-DovQV4zD.js +112 -0
  405. package/dist/identity-cyBYcoXS.js +84 -0
  406. package/dist/identity-file-EndG1nfc.js +60 -0
  407. package/dist/image-generation-CNKc-mFK.js +441 -0
  408. package/dist/image-kJ7Tbov4.js +211 -0
  409. package/dist/image-ops-j01UkxEv.js +371 -0
  410. package/dist/imessage-B5pSMT47.js +219 -0
  411. package/dist/imessage-CoIuY1Ro.js +1451 -0
  412. package/dist/imessage-Cqjsq4VW.js +190 -0
  413. package/dist/imessage-core-CsYJuaRZ.js +1 -0
  414. package/dist/inbound-envelope-4P3IIJc3.js +61 -0
  415. package/dist/inbound-reply-dispatch-i2Vekqyy.js +72 -0
  416. package/dist/includes-7XyL3p1c.js +188 -0
  417. package/dist/includes-scan-y-rS6tTw.js +55 -0
  418. package/dist/index.js +57 -0
  419. package/dist/infra/warning-filter.js +2 -0
  420. package/dist/inspect-CcxlJ1ba.js +279 -0
  421. package/dist/install-safe-path-Rwbw1XCZ.js +62 -0
  422. package/dist/installs-iHi2aSjM.js +532 -0
  423. package/dist/interactive-F7iY0yED.js +8 -0
  424. package/dist/interactive-runtime-OweOj_Vv.js +90 -0
  425. package/dist/internal-hooks-0uipqzRY.js +156 -0
  426. package/dist/io-BX49DsSJ.js +35 -0
  427. package/dist/io-jOnQRia2.js +7178 -0
  428. package/dist/ip-C8vmzVu0.js +203 -0
  429. package/dist/ipv4-DAmsJVOV.js +82 -0
  430. package/dist/irc-AZ-Ec8be.js +12 -0
  431. package/dist/irc-CCSRuEC2.js +660 -0
  432. package/dist/is-main-YViS6wOn.js +27 -0
  433. package/dist/issue-format-CBEXVico.js +31 -0
  434. package/dist/issue-format-D3HehoKZ.js +4 -0
  435. package/dist/json-file-C2zjA0Gv.js +23 -0
  436. package/dist/json-files-WW-H_psG.js +60 -0
  437. package/dist/json-pointer-f9dEnBoR.js +43 -0
  438. package/dist/json-store-O1LwpnBH.js +37 -0
  439. package/dist/kb-cli-DMZs6PCu.js +65 -0
  440. package/dist/keyed-async-queue-CPUWV5Pm.js +32 -0
  441. package/dist/kill-tree-CbjXBw3z.js +149 -0
  442. package/dist/kilocode-shared-DS7_0IMs.js +29 -0
  443. package/dist/launchd-tyqGVx9U.js +491 -0
  444. package/dist/lazy-runtime-BcXbyAaC.js +1 -0
  445. package/dist/lazy-runtime-bWkd2cs3.js +29 -0
  446. package/dist/legacy-names-CUNZ4vHN.js +7 -0
  447. package/dist/legacy-web-search-BgZjNG2h.js +222 -0
  448. package/dist/lib-CERS7N4b.js +503 -0
  449. package/dist/lib-PPICrHv1.js +1938 -0
  450. package/dist/library-CZ461krl.js +211 -0
  451. package/dist/lifecycle-core-Dnxnw0oy.js +382 -0
  452. package/dist/line/accounts.js +10 -0
  453. package/dist/line/send.js +39 -0
  454. package/dist/line/template-messages.js +2 -0
  455. package/dist/line-CJSvwApm.js +1 -0
  456. package/dist/line-N9vL-2JB.js +688 -0
  457. package/dist/line-core-BOIxkjgu.js +1 -0
  458. package/dist/links-Bilm-v0z.js +13 -0
  459. package/dist/llm-slug-generator-BuAuQ5Ft.js +68 -0
  460. package/dist/llm-slug-generator.js +212 -0
  461. package/dist/llm-task-Dx8ymRFr.js +1 -0
  462. package/dist/local-roots-DAzCjWbC.js +34 -0
  463. package/dist/location-DefAH9WS.js +42 -0
  464. package/dist/logger-CoEtkjhn.js +550 -0
  465. package/dist/logger-Cqy7-Maj.js +70 -0
  466. package/dist/logging-B2wMcpWV.js +13 -0
  467. package/dist/logging-Bz1qZDPg.js +16 -0
  468. package/dist/logging-CArEWRgI.js +36 -0
  469. package/dist/logging-CbTTfADU.js +1 -0
  470. package/dist/logs-cli-BSjKwaur.js +261 -0
  471. package/dist/magic-string.es-DJPWMt-n.js +1011 -0
  472. package/dist/main-session-DKr0lBVk.js +36 -0
  473. package/dist/manager-ChTGDe87.js +2005 -0
  474. package/dist/manager-DuwFn87U.js +4226 -0
  475. package/dist/manager-runtime-E16jsvRe.js +59 -0
  476. package/dist/manager.runtime-F9F1eFiB.js +827 -0
  477. package/dist/manifest-registry-B90TyTWl.js +1350 -0
  478. package/dist/map-size-CMTQVKUV.js +15 -0
  479. package/dist/markdown-to-line-BWwaRx5F.js +640 -0
  480. package/dist/mask-api-key-CprzEe7l.js +10 -0
  481. package/dist/matrix-DzvdUw97.js +228 -0
  482. package/dist/matrix-migration-snapshot-adoDbNii.js +702 -0
  483. package/dist/mattermost-DO0BCfF3.js +1 -0
  484. package/dist/mattermost-SjOt4QDb.js +15 -0
  485. package/dist/mcp-cli-BC_VPl_o.js +94 -0
  486. package/dist/mcp-config-Coky4zS4.js +108 -0
  487. package/dist/media-limits-Cuvmmhop.js +14 -0
  488. package/dist/media-understanding-DD2uMjK8.js +48 -0
  489. package/dist/media-understanding.runtime-Kbb2bRmk.js +216 -0
  490. package/dist/memory-DBjQ0TPd.js +1 -0
  491. package/dist/memory-cli-Cm4Df0hJ.js +215 -0
  492. package/dist/memory-cli-yzqneSF8.js +541 -0
  493. package/dist/memory-search-Das1tiuB.js +204 -0
  494. package/dist/memory-search-DxmSTjHq.js +18 -0
  495. package/dist/mention-gating-B_q-EHFx.js +25 -0
  496. package/dist/mentions-Bxys_va0.js +154 -0
  497. package/dist/message-channel-Cy-gN4K2.js +106 -0
  498. package/dist/message-hook-mappers-BBTV3JRQ.js +249 -0
  499. package/dist/method-scopes-DgypDW23.js +2649 -0
  500. package/dist/mime-C4vVTBso.js +150 -0
  501. package/dist/minimal-C5yUxtHy.js +2120 -0
  502. package/dist/model-auth-B__TJTPw.js +309 -0
  503. package/dist/model-auth-env-CF9ts7Th.js +111 -0
  504. package/dist/model-catalog.runtime-CWh17vcc.js +211 -0
  505. package/dist/model-id-normalization-Y-MIsyK_.js +16 -0
  506. package/dist/model-input-BB2wSAHb.js +20 -0
  507. package/dist/model-overrides-sIzKU2wo.js +84 -0
  508. package/dist/model-param-b-DIFEhICm.js +15 -0
  509. package/dist/model-picker-CAPjetT3.js +400 -0
  510. package/dist/model-picker-DEw9viWc.js +215 -0
  511. package/dist/model-picker.runtime-ixYl7lB5.js +224 -0
  512. package/dist/model-selection-BTpJnslv.js +437 -0
  513. package/dist/model-selection-Ci9cPkL2.js +765 -0
  514. package/dist/model-suppression.runtime-D8cIb6Y5.js +216 -0
  515. package/dist/models-BQtc3khN.js +226 -0
  516. package/dist/models-CQgBV5dW.js +2536 -0
  517. package/dist/models-cli-DbQ-QpQk.js +418 -0
  518. package/dist/models-config-D2xK-G6c.js +211 -0
  519. package/dist/models-config.providers.discovery-BaIk1NKL.js +141 -0
  520. package/dist/models-config.runtime-Cf7q9uAQ.js +211 -0
  521. package/dist/monitor-B5QmKaD7.js +3272 -0
  522. package/dist/monitor-CL5OYLih.js +878 -0
  523. package/dist/monitor-CNZxrM4d.js +3145 -0
  524. package/dist/monitor-CyQVZdDh.js +223 -0
  525. package/dist/multimodal-DC43jYNv.js +75 -0
  526. package/dist/mutable-allowlist-detectors-C6EAzWYE.js +62 -0
  527. package/dist/net-DlJFp95v.js +270 -0
  528. package/dist/network-mode-DOgvmom4.js +17 -0
  529. package/dist/nextcloud-talk-ChMP88s-.js +12 -0
  530. package/dist/nextcloud-talk-CwnkUy8E.js +1 -0
  531. package/dist/node-cli-BZDC7rXg.js +2484 -0
  532. package/dist/node-command-policy-Bg2g6Xjp.js +192 -0
  533. package/dist/node-commands-B6W6Eo0b.js +11 -0
  534. package/dist/node-require-BgDD9bTi.js +14 -0
  535. package/dist/node-resolve-BunMro3f.js +69 -0
  536. package/dist/node-service-CEZZaqba.js +65 -0
  537. package/dist/node-startup-env-Gz8ZQniA.js +50 -0
  538. package/dist/nodes-cli-B4Jr9vct.js +1330 -0
  539. package/dist/nodes-screen-CQ7IvP62.js +401 -0
  540. package/dist/normalize-secret-input-_PgpexOG.js +32 -0
  541. package/dist/note-dfjacCV8.js +109 -0
  542. package/dist/npm-pack-install-CYNRv-vM.js +574 -0
  543. package/dist/npm-resolution-Ml2aA6Nu.js +60 -0
  544. package/dist/oauth.runtime-DA_48MPQ.js +687 -0
  545. package/dist/oauth.runtime-DS1ry5__.js +318 -0
  546. package/dist/oauth.runtime-qCkidk8J.js +180 -0
  547. package/dist/ollama-defaults-asNuGW4_.js +4 -0
  548. package/dist/onboard-BM6gO6Uw.js +589 -0
  549. package/dist/onboard-D9IU-7uw.js +48 -0
  550. package/dist/onboard-DQaHGPRm.js +25 -0
  551. package/dist/onboard-channels-BdQtLjYb.js +300 -0
  552. package/dist/onboard-channels-DIVUygs5.js +1257 -0
  553. package/dist/onboard-config-DFKb-0sE.js +29 -0
  554. package/dist/onboard-config-DYykzJhx.js +2 -0
  555. package/dist/onboard-custom-CDP4w1AT.js +216 -0
  556. package/dist/onboard-custom-DhJN13UV.js +644 -0
  557. package/dist/onboard-helpers-B7XTd4Pw.js +335 -0
  558. package/dist/onboard-helpers-BUKtx5Bq.js +54 -0
  559. package/dist/onboard-hooks-BHSSLAhI.js +73 -0
  560. package/dist/onboard-remote-BOzEPdHA.js +59 -0
  561. package/dist/onboard-remote-DVza19_k.js +182 -0
  562. package/dist/onboard-search-CrS-n9_3.js +446 -0
  563. package/dist/onboard-skills-BojzIPvk.js +133 -0
  564. package/dist/onboard-skills-D7HyCVjz.js +69 -0
  565. package/dist/openai-codex-provider.runtime-BFsopDHI.js +2 -0
  566. package/dist/openai-defaults-B7FUywsh.js +10 -0
  567. package/dist/openclaw-exec-env-AcZ9we1N.js +14 -0
  568. package/dist/openclaw-root-TUHYdr9B.js +88 -0
  569. package/dist/openclaw-tools.runtime-draZJo5r.js +211 -0
  570. package/dist/outbound-media-69yrWRDt.js +11 -0
  571. package/dist/outbound-runtime-ic_7ulJJ.js +1 -0
  572. package/dist/pairing-challenge-CNrPmmi9.js +48 -0
  573. package/dist/pairing-cli-BohXW2BK.js +150 -0
  574. package/dist/pairing-labels-CNKCSmBK.js +7 -0
  575. package/dist/pairing-message-CBv2njJT.js +4 -0
  576. package/dist/pairing-store-C4lsd4pO.js +590 -0
  577. package/dist/pairing-token-gKj4SNFJ.js +55 -0
  578. package/dist/parse-duration-BBGYkY0S.js +41 -0
  579. package/dist/parse-finite-number-CP4MQF_w.js +30 -0
  580. package/dist/parse-log-line-CVh9zu3Q.js +43 -0
  581. package/dist/parse-port-COyt3COn.js +8 -0
  582. package/dist/path-alias-guards-ZTKqurNH.js +40 -0
  583. package/dist/path-env-CPkz6U0Y.js +87 -0
  584. package/dist/paths-CTjJI9l0.js +179 -0
  585. package/dist/paths-GHJ97ebE.js +268 -0
  586. package/dist/paths-nCHyK08H.js +56 -0
  587. package/dist/perplexity-Beshd9zu.js +422 -0
  588. package/dist/persistent-dedupe-bjKjVI5u.js +116 -0
  589. package/dist/pi-embedded-CSQySvOV.js +168518 -0
  590. package/dist/pi-model-discovery-CuX5CDyZ.js +125 -0
  591. package/dist/pi-model-discovery-runtime-DNsMrX1n.js +44 -0
  592. package/dist/pi-tools.before-tool-call.runtime-DxVqzMVf.js +387 -0
  593. package/dist/platform-launcher-CqGy6UhP.js +83 -0
  594. package/dist/plugin-entry-CwuwM1jC.js +17 -0
  595. package/dist/plugin-install-JJwfOXtg.js +216 -0
  596. package/dist/plugin-install-plan-cixz1_W4.js +49 -0
  597. package/dist/plugin-install-vkpI1UNd.js +184 -0
  598. package/dist/plugin-registry-C3j_DUnj.js +51 -0
  599. package/dist/plugin-registry-DB_yxabS.js +213 -0
  600. package/dist/plugin-sdk/account-helpers.js +3 -0
  601. package/dist/plugin-sdk/account-id.js +2 -0
  602. package/dist/plugin-sdk/account-resolution.js +216 -0
  603. package/dist/plugin-sdk/acp-runtime.js +46 -0
  604. package/dist/plugin-sdk/agent-runtime.js +215 -0
  605. package/dist/plugin-sdk/allow-from.js +17 -0
  606. package/dist/plugin-sdk/allowlist-config-edit.js +2 -0
  607. package/dist/plugin-sdk/bluebubbles.js +232 -0
  608. package/dist/plugin-sdk/boolean-param.js +2 -0
  609. package/dist/plugin-sdk/channel-actions.js +16 -0
  610. package/dist/plugin-sdk/channel-config-helpers.js +15 -0
  611. package/dist/plugin-sdk/channel-config-schema.js +5 -0
  612. package/dist/plugin-sdk/channel-contract.js +1 -0
  613. package/dist/plugin-sdk/channel-feedback.js +4 -0
  614. package/dist/plugin-sdk/channel-inbound.js +53 -0
  615. package/dist/plugin-sdk/channel-lifecycle.js +2 -0
  616. package/dist/plugin-sdk/channel-pairing.js +2 -0
  617. package/dist/plugin-sdk/channel-policy.js +19 -0
  618. package/dist/plugin-sdk/channel-reply-pipeline.js +23 -0
  619. package/dist/plugin-sdk/channel-runtime.js +33 -0
  620. package/dist/plugin-sdk/channel-send-result.js +2 -0
  621. package/dist/plugin-sdk/channel-setup.js +24 -0
  622. package/dist/plugin-sdk/channel-targets.js +3 -0
  623. package/dist/plugin-sdk/cli-runtime.js +5 -0
  624. package/dist/plugin-sdk/command-auth.js +212 -0
  625. package/dist/plugin-sdk/compat.js +59 -0
  626. package/dist/plugin-sdk/config-runtime.js +51 -0
  627. package/dist/plugin-sdk/conversation-runtime.js +55 -0
  628. package/dist/plugin-sdk/core.js +40 -0
  629. package/dist/plugin-sdk/device-bootstrap.js +6 -0
  630. package/dist/plugin-sdk/diagnostics-otel.js +7 -0
  631. package/dist/plugin-sdk/diffs.js +3 -0
  632. package/dist/plugin-sdk/directory-runtime.js +5 -0
  633. package/dist/plugin-sdk/discord-core.js +26 -0
  634. package/dist/plugin-sdk/discord.js +219 -0
  635. package/dist/plugin-sdk/extension-shared.js +15 -0
  636. package/dist/plugin-sdk/feishu.js +101 -0
  637. package/dist/plugin-sdk/gateway-runtime.js +46 -0
  638. package/dist/plugin-sdk/googlechat.js +93 -0
  639. package/dist/plugin-sdk/group-access.js +2 -0
  640. package/dist/plugin-sdk/hook-runtime.js +12 -0
  641. package/dist/plugin-sdk/image-generation.js +51 -0
  642. package/dist/plugin-sdk/imessage-core.js +214 -0
  643. package/dist/plugin-sdk/imessage.js +223 -0
  644. package/dist/plugin-sdk/index.js +55 -0
  645. package/dist/plugin-sdk/infra-runtime.js +223 -0
  646. package/dist/plugin-sdk/interactive-runtime.js +3 -0
  647. package/dist/plugin-sdk/irc.js +232 -0
  648. package/dist/plugin-sdk/json-store.js +9 -0
  649. package/dist/plugin-sdk/keyed-async-queue.js +2 -0
  650. package/dist/plugin-sdk/lazy-runtime.js +2 -0
  651. package/dist/plugin-sdk/line-core.js +29 -0
  652. package/dist/plugin-sdk/line.js +22 -0
  653. package/dist/plugin-sdk/llm-task.js +7 -0
  654. package/dist/plugin-sdk/matrix-runtime-heavy.js +223 -0
  655. package/dist/plugin-sdk/matrix-runtime-shared.js +2 -0
  656. package/dist/plugin-sdk/matrix.js +84 -0
  657. package/dist/plugin-sdk/mattermost.js +233 -0
  658. package/dist/plugin-sdk/media-runtime.js +212 -0
  659. package/dist/plugin-sdk/media-understanding-runtime.js +211 -0
  660. package/dist/plugin-sdk/media-understanding.js +15 -0
  661. package/dist/plugin-sdk/memory-core.js +2 -0
  662. package/dist/plugin-sdk/memory-lancedb.js +2 -0
  663. package/dist/plugin-sdk/msteams.js +244 -0
  664. package/dist/plugin-sdk/nextcloud-talk.js +231 -0
  665. package/dist/plugin-sdk/nostr.js +50 -0
  666. package/dist/plugin-sdk/ollama-setup.js +33 -0
  667. package/dist/plugin-sdk/outbound-runtime.js +23 -0
  668. package/dist/plugin-sdk/plugin-entry.js +3 -0
  669. package/dist/plugin-sdk/plugin-runtime.js +211 -0
  670. package/dist/plugin-sdk/process-runtime.js +12 -0
  671. package/dist/plugin-sdk/provider-auth-api-key.js +53 -0
  672. package/dist/plugin-sdk/provider-auth-login.js +2 -0
  673. package/dist/plugin-sdk/provider-auth.js +37 -0
  674. package/dist/plugin-sdk/provider-catalog.js +2 -0
  675. package/dist/plugin-sdk/provider-env-vars.js +2 -0
  676. package/dist/plugin-sdk/provider-google.js +3 -0
  677. package/dist/plugin-sdk/provider-models.js +27 -0
  678. package/dist/plugin-sdk/provider-onboard.js +20 -0
  679. package/dist/plugin-sdk/provider-setup.js +58 -0
  680. package/dist/plugin-sdk/provider-stream.js +211 -0
  681. package/dist/plugin-sdk/provider-usage.js +18 -0
  682. package/dist/plugin-sdk/provider-web-search.js +23 -0
  683. package/dist/plugin-sdk/provider-zai-endpoint.js +3 -0
  684. package/dist/plugin-sdk/reply-history.js +23 -0
  685. package/dist/plugin-sdk/reply-payload.js +2 -0
  686. package/dist/plugin-sdk/reply-runtime.js +211 -0
  687. package/dist/plugin-sdk/request-url.js +2 -0
  688. package/dist/plugin-sdk/routing.js +25 -0
  689. package/dist/plugin-sdk/runtime-env.js +15 -0
  690. package/dist/plugin-sdk/runtime-store.js +2 -0
  691. package/dist/plugin-sdk/runtime.js +15 -0
  692. package/dist/plugin-sdk/sandbox.js +66 -0
  693. package/dist/plugin-sdk/secret-input.js +3 -0
  694. package/dist/plugin-sdk/security-runtime.js +18 -0
  695. package/dist/plugin-sdk/self-hosted-provider-setup.js +33 -0
  696. package/dist/plugin-sdk/setup-adapter-runtime.js +2 -0
  697. package/dist/plugin-sdk/setup-runtime.js +17 -0
  698. package/dist/plugin-sdk/setup-tools.js +21 -0
  699. package/dist/plugin-sdk/setup.js +26 -0
  700. package/dist/plugin-sdk/signal.js +220 -0
  701. package/dist/plugin-sdk/slack-core.js +22 -0
  702. package/dist/plugin-sdk/slack.js +223 -0
  703. package/dist/plugin-sdk/speech-runtime.js +213 -0
  704. package/dist/plugin-sdk/speech.js +212 -0
  705. package/dist/plugin-sdk/ssrf-runtime.js +5 -0
  706. package/dist/plugin-sdk/state-paths.js +3 -0
  707. package/dist/plugin-sdk/status-helpers.js +9 -0
  708. package/dist/plugin-sdk/telegram-core.js +23 -0
  709. package/dist/plugin-sdk/telegram.js +224 -0
  710. package/dist/plugin-sdk/testing.js +13174 -0
  711. package/dist/plugin-sdk/text-runtime.js +45 -0
  712. package/dist/plugin-sdk/thread-bindings-runtime.js +2 -0
  713. package/dist/plugin-sdk/thread-ownership.js +2 -0
  714. package/dist/plugin-sdk/tlon.js +57 -0
  715. package/dist/plugin-sdk/tool-send.js +2 -0
  716. package/dist/plugin-sdk/twitch.js +46 -0
  717. package/dist/plugin-sdk/voice-call.js +213 -0
  718. package/dist/plugin-sdk/web-media.js +28 -0
  719. package/dist/plugin-sdk/webhook-ingress.js +7 -0
  720. package/dist/plugin-sdk/webhook-path.js +2 -0
  721. package/dist/plugin-sdk/whatsapp-core.js +219 -0
  722. package/dist/plugin-sdk/whatsapp-shared.js +18 -0
  723. package/dist/plugin-sdk/windows-spawn.js +2 -0
  724. package/dist/plugin-sdk/zalo.js +239 -0
  725. package/dist/plugin-sdk/zalouser.js +240 -0
  726. package/dist/plugins/build-smoke-entry.js +211 -0
  727. package/dist/plugins/runtime/index.js +229 -0
  728. package/dist/plugins-1Z50ecJ6.js +1 -0
  729. package/dist/plugins-C6fKmNuA.js +7 -0
  730. package/dist/plugins-cli-BkgQkGaU.js +1192 -0
  731. package/dist/policy-CpkbSAfm.js +60 -0
  732. package/dist/polls-B2VH7SN9.js +35 -0
  733. package/dist/ports-BjWuIIQw.js +262 -0
  734. package/dist/ports-DFiK_Jc-.js +385 -0
  735. package/dist/ports-lsof-DtJqhFOr.js +25 -0
  736. package/dist/ports-probe-BQqp8l8E.js +14 -0
  737. package/dist/preflight-audio.runtime-Fi9mofpp.js +216 -0
  738. package/dist/probe-BM9sbCgS.js +20 -0
  739. package/dist/probe-DLBOZftS.js +134 -0
  740. package/dist/probe-auth-Bjp3G4CI.js +48 -0
  741. package/dist/probe-auth-DMSPTRRk.js +45 -0
  742. package/dist/process-runtime-C7el-Ri4.js +1 -0
  743. package/dist/process-scoped-map-C4gOa-gv.js +61 -0
  744. package/dist/profile-utils-BcMYGFPT.js +15 -0
  745. package/dist/profiles-D17eMKQZ.js +683 -0
  746. package/dist/program-Ch-76sgl.js +155 -0
  747. package/dist/program-context-BMWNUfqL.js +10 -0
  748. package/dist/program-context-CD_RvRYh.js +2 -0
  749. package/dist/progress-D1r9bZU1.js +132 -0
  750. package/dist/prompt-select-styled-NUKYS9QR.js +4879 -0
  751. package/dist/prompt-style-BvciNCqy.js +7 -0
  752. package/dist/prompts-NtuylUyl.js +9 -0
  753. package/dist/prototype-keys-Cm_8mWvq.js +11 -0
  754. package/dist/provider-api-key-auth-BE0taXiB.js +108 -0
  755. package/dist/provider-api-key-auth.runtime-jDZZUAMX.js +34 -0
  756. package/dist/provider-auth-Bw8x1a3o.js +58 -0
  757. package/dist/provider-auth-api-key-BrQYvdxi.js +1 -0
  758. package/dist/provider-auth-choice-BYbPq0eC.js +128 -0
  759. package/dist/provider-auth-choice-helpers-Bj1GkOSn.js +48 -0
  760. package/dist/provider-auth-choice-preference-tKq5gaJL.js +192 -0
  761. package/dist/provider-auth-choice.runtime-DegPpvRJ.js +223 -0
  762. package/dist/provider-auth-choices-QSilukI1.js +58 -0
  763. package/dist/provider-auth-guidance-gninjjq8.js +34 -0
  764. package/dist/provider-auth-helpers-B0dS-1WK.js +86 -0
  765. package/dist/provider-auth-input-BftBdgvW.js +112 -0
  766. package/dist/provider-auth-login-D0n0lMuc.js +8 -0
  767. package/dist/provider-auth-login.runtime-LvuBkQrc.js +243 -0
  768. package/dist/provider-auth-mode-sTdccIKL.js +20 -0
  769. package/dist/provider-auth-ref-BS3gwrNr.js +168 -0
  770. package/dist/provider-auth-ref-BmEcEN7K.js +3 -0
  771. package/dist/provider-catalog--18-pW5t.js +11 -0
  772. package/dist/provider-catalog-2P2hel74.js +48 -0
  773. package/dist/provider-catalog-B0FqWSwe.js +48 -0
  774. package/dist/provider-catalog-BvORKzzD.js +91 -0
  775. package/dist/provider-catalog-C34j1_or.js +26 -0
  776. package/dist/provider-catalog-C5vmXjmb.js +11 -0
  777. package/dist/provider-catalog-CBufm2Dr.js +36 -0
  778. package/dist/provider-catalog-D7QvsUXS.js +12 -0
  779. package/dist/provider-catalog-DKy_dzQZ.js +41 -0
  780. package/dist/provider-env-vars-CsQlY7bF.js +110 -0
  781. package/dist/provider-id-BpXo5t6v.js +31 -0
  782. package/dist/provider-model-allowlist-4HSOnlX-.js +24 -0
  783. package/dist/provider-model-primary-NJ-xlhec.js +53 -0
  784. package/dist/provider-models-C2EjYMwW.js +2416 -0
  785. package/dist/provider-oauth-flow-BQN6F6EC.js +33 -0
  786. package/dist/provider-ollama-setup-DhQvDwAj.js +309 -0
  787. package/dist/provider-onboard-CjOfyeQG.js +1 -0
  788. package/dist/provider-onboarding-config-DOZ3pFA6.js +165 -0
  789. package/dist/provider-openai-codex-oauth-tls-Bo8U4D3E.js +101 -0
  790. package/dist/provider-runtime.runtime-DnP2jpoM.js +211 -0
  791. package/dist/provider-self-hosted-setup-CUrmsugW.js +182 -0
  792. package/dist/provider-usage-ClDVmkhl.js +633 -0
  793. package/dist/provider-usage-DIC6cn-3.js +211 -0
  794. package/dist/provider-web-search-NzK8ep1E.js +507 -0
  795. package/dist/provider-wizard-C6jCuyQe.js +236 -0
  796. package/dist/provider-zai-endpoint-DeDABzT4.js +106 -0
  797. package/dist/proxy-H5O2p6AP.js +121 -0
  798. package/dist/proxy-env-DG2u55RW.js +40 -0
  799. package/dist/push-apns-D4zD2tmP.js +1050 -0
  800. package/dist/pw-ai-BuPUVeUK.js +1876 -0
  801. package/dist/qmd-manager-BpygGMW9.js +1571 -0
  802. package/dist/qr-cli-DnWHXcxh.js +370 -0
  803. package/dist/qr-cli-yaZ0FZ6z.js +213 -0
  804. package/dist/query-expansion-Do45hILP.js +1114 -0
  805. package/dist/reactions-BcC_XZqD.js +281 -0
  806. package/dist/read-only-account-inspect-DPJzadPo.js +42 -0
  807. package/dist/read-only-account-inspect.discord.runtime-CW9DDKH8.js +216 -0
  808. package/dist/read-only-account-inspect.slack.runtime-BcXBPyh3.js +216 -0
  809. package/dist/read-only-account-inspect.telegram.runtime-Y7h0Jbdj.js +216 -0
  810. package/dist/redact-BDinS1q9.js +102 -0
  811. package/dist/redact-identifier-FUiWQxv5.js +13 -0
  812. package/dist/redact-snapshot-DBPmeYy2.js +2654 -0
  813. package/dist/ref-contract-CCBBbf1r.js +53 -0
  814. package/dist/register-CppP7Ddc.js +43 -0
  815. package/dist/register.agent-BOD5ROGQ.js +546 -0
  816. package/dist/register.backup-Y2VGqcRu.js +269 -0
  817. package/dist/register.configure-1qiTINph.js +354 -0
  818. package/dist/register.maintenance-shn-zigv.js +694 -0
  819. package/dist/register.message-mR4CLSoo.js +812 -0
  820. package/dist/register.onboard-CkDryVid.js +298 -0
  821. package/dist/register.setup-B0xW5olD.js +318 -0
  822. package/dist/register.status-health-sessions-CuhWc03j.js +604 -0
  823. package/dist/register.subclis-BazXM5TW.js +315 -0
  824. package/dist/register.subclis-C2d8UDhH.js +13 -0
  825. package/dist/registry-C3q59Qj0.js +55 -0
  826. package/dist/registry-CPsHw6xU.js +219 -0
  827. package/dist/registry-CxgtJ09C.js +28 -0
  828. package/dist/registry-rgYi7KoO.js +160 -0
  829. package/dist/repair-qXnOAvDy.js +105 -0
  830. package/dist/replies-EiwmmZ_W.js +122 -0
  831. package/dist/reply-history-CVCD5oE9.js +1 -0
  832. package/dist/reply-payload-DBGc074f.js +232 -0
  833. package/dist/report-cli-DB1jQx32.js +42 -0
  834. package/dist/request-url-BKfWAQx8.js +10 -0
  835. package/dist/resolve-Ckjd8TAk.js +14 -0
  836. package/dist/resolve-T2q_0ARF.js +619 -0
  837. package/dist/resolve-route-vEY3ONZ2.js +466 -0
  838. package/dist/resolve-utils-CbqJY2bs.js +102 -0
  839. package/dist/response-generator-VdoCcQ3y.js +153 -0
  840. package/dist/restart-stale-pids-CLGiqU2E.js +187 -0
  841. package/dist/retry-D15TD1S3.js +168 -0
  842. package/dist/root-help-B9Aou4ho.js +32 -0
  843. package/dist/routes-TpLEcKO8.js +7084 -0
  844. package/dist/routing-Y3m0o-kB.js +26 -0
  845. package/dist/rpc-C6MN-nVc.js +67 -0
  846. package/dist/run-command-DRKv5Lj6.js +32 -0
  847. package/dist/run-main-YZSMdx0B.js +424 -0
  848. package/dist/run-with-concurrency-BrSjWzpg.js +41 -0
  849. package/dist/runtime-B66W9flm.js +43 -0
  850. package/dist/runtime-C9VaVKYZ.js +2338 -0
  851. package/dist/runtime-CT2LIJZu.js +91 -0
  852. package/dist/runtime-CqDQ81eY.js +143 -0
  853. package/dist/runtime-CuvWMN7E.js +89 -0
  854. package/dist/runtime-D4_OpzA1.js +5 -0
  855. package/dist/runtime-DP-4DZja.js +5 -0
  856. package/dist/runtime-Dl17x_cV.js +1 -0
  857. package/dist/runtime-Z35JoYPC.js +30 -0
  858. package/dist/runtime-api-D79M0lQN.js +1 -0
  859. package/dist/runtime-api-y3zfnQGK.js +39 -0
  860. package/dist/runtime-discord-ops.runtime-Bg5h5v9-.js +234 -0
  861. package/dist/runtime-env-a_iwdJIv.js +1 -0
  862. package/dist/runtime-forwarders-DtMc8rBP.js +44 -0
  863. package/dist/runtime-group-policy-B7irU4eu.js +59 -0
  864. package/dist/runtime-guard-y62lPDGY.js +58 -0
  865. package/dist/runtime-parse-CeqXmZHJ.js +84 -0
  866. package/dist/runtime-paths-CstaCCMi.js +334 -0
  867. package/dist/runtime-slack-ops.runtime-BumgKDhS.js +226 -0
  868. package/dist/runtime-status-CgL02wYX.js +15 -0
  869. package/dist/runtime-store-Bt3Sdbrn.js +22 -0
  870. package/dist/runtime-telegram-ops.runtime-rSLQ3KrE.js +233 -0
  871. package/dist/runtime-whatsapp-boundary-xZem0NyQ.js +364 -0
  872. package/dist/safe-open-sync-Bt9R1Mnf.js +83 -0
  873. package/dist/safe-regex-tLlDZYfM.js +244 -0
  874. package/dist/safe-text-B_CQuica.js +16 -0
  875. package/dist/sandbox-CUUouiKs.js +2795 -0
  876. package/dist/sandbox-cli-BN8y0Get.js +499 -0
  877. package/dist/sandbox-paths-fqp_TZdO.js +144 -0
  878. package/dist/sandbox-qSs4h3sk.js +1 -0
  879. package/dist/sanitize-env-vars-vNSNqm0y.js +74 -0
  880. package/dist/scan-paths-BJmvUZ1E.js +28 -0
  881. package/dist/search-manager-DWhFgwyp.js +17 -0
  882. package/dist/search-manager-r8Cw4ZRv.js +392 -0
  883. package/dist/secret-equal-ObQfyZGa.js +9 -0
  884. package/dist/secret-file-Ch0yuOXR.js +11 -0
  885. package/dist/secret-file-DYJtH6kf.js +92 -0
  886. package/dist/secret-input-4REZ4sHo.js +35 -0
  887. package/dist/secrets-cli-D1df8b0o.js +2304 -0
  888. package/dist/secure-random-Cs8tw_HQ.js +10 -0
  889. package/dist/security-cli-V66ESmdT.js +676 -0
  890. package/dist/security-runtime-BuEhpJVE.js +23 -0
  891. package/dist/send-3tabvle6.js +100 -0
  892. package/dist/send-CC5J3tyW.js +1026 -0
  893. package/dist/send-deps-CrFMNvqO.js +19 -0
  894. package/dist/send-i2-mdtiE.js +250 -0
  895. package/dist/server-BTOjmlyi.js +116 -0
  896. package/dist/server-middleware-CCqKhKUb.js +106 -0
  897. package/dist/server-node-events-D6y22Tt8.js +611 -0
  898. package/dist/server-startup-matrix-migration-DHWSoS73.js +1595 -0
  899. package/dist/service-Bxc9uL2e.js +774 -0
  900. package/dist/service-CBLajPZL.js +21 -0
  901. package/dist/session-cost-usage-BmbaBvk4.js +212 -0
  902. package/dist/session-cost-usage-C30Jl2SI.js +615 -0
  903. package/dist/session-fork.runtime-BZfcC1Nc.js +51 -0
  904. package/dist/session-key-gFFk3uv9.js +216 -0
  905. package/dist/session-write-lock-DNKvpjKf.js +324 -0
  906. package/dist/sessions-BIH_j_XS.js +222 -0
  907. package/dist/sessions-D5dWcxC_.js +212 -0
  908. package/dist/sessions-DaSBVNwD.js +669 -0
  909. package/dist/setup-C2XF1YH3.js +397 -0
  910. package/dist/setup-CN-teRpz.js +8 -0
  911. package/dist/setup-adapter-runtime-Bjv2adwG.js +1 -0
  912. package/dist/setup-binary-BOJA7zdN.js +30 -0
  913. package/dist/setup-browser-BhNPCUtK.js +71 -0
  914. package/dist/setup-core-BsG09DZH.js +149 -0
  915. package/dist/setup-core-D-O1GQax.js +162 -0
  916. package/dist/setup-core-Dtm54Rcq.js +510 -0
  917. package/dist/setup-entry-B1mTa7bU.js +10 -0
  918. package/dist/setup-entry-CTMgw-K5.js +13 -0
  919. package/dist/setup-entry-Cmd_cufO.js +13 -0
  920. package/dist/setup-entry-CybgA3zP.js +12 -0
  921. package/dist/setup-entry-DED_hL6i.js +12 -0
  922. package/dist/setup-entry-WCq9VMWx.js +14 -0
  923. package/dist/setup-group-access-BtPApRvE.js +70 -0
  924. package/dist/setup-helpers-B62Ecg9r.js +362 -0
  925. package/dist/setup-surface-B7A7qowY.js +452 -0
  926. package/dist/setup-surface-BBYJVRXc.js +380 -0
  927. package/dist/setup-surface-CFUz_BJi.js +298 -0
  928. package/dist/setup-tools-BPiMjAN7.js +1 -0
  929. package/dist/setup-wizard-helpers-COZ1UAdX.js +770 -0
  930. package/dist/setup-wizard-proxy-Slwi-1gX.js +116 -0
  931. package/dist/setup.finalize-B8O01nge.js +633 -0
  932. package/dist/setup.gateway-config-BPDIFk__.js +288 -0
  933. package/dist/setup.secret-input-BL-bqJpt.js +25 -0
  934. package/dist/shared-AygSbeCK.js +50 -0
  935. package/dist/shared-BHqDLkMG.js +127 -0
  936. package/dist/shared-BPtG8PgB.js +70 -0
  937. package/dist/shared-BU0QgVMZ.js +36 -0
  938. package/dist/shared-Bzr2UyEm.js +351 -0
  939. package/dist/shared-C_XXbGIF.js +87 -0
  940. package/dist/shared-Diw3KzwZ.js +82 -0
  941. package/dist/shared-DngjQumT.js +196 -0
  942. package/dist/shared-DzH3zmAy.js +64 -0
  943. package/dist/shared-LeP8iUTz.js +54 -0
  944. package/dist/shell-argv-DWV43Vya.js +72 -0
  945. package/dist/shell-env-cD92jEyV.js +181 -0
  946. package/dist/signal-BQd9f9dF.js +315 -0
  947. package/dist/signal-Ca7y47bM.js +46 -0
  948. package/dist/signal-Did9U_fa.js +214 -0
  949. package/dist/signal-cli-install-DxoL8CgF.js +188 -0
  950. package/dist/skill-commands-CiSwTFBQ.js +652 -0
  951. package/dist/skill-commands.runtime-CEwlWT4j.js +34 -0
  952. package/dist/skill-scanner-DG7MT7pu.js +354 -0
  953. package/dist/skills-BC8GJ9Rp.js +22 -0
  954. package/dist/skills-CCgKs_NJ.js +863 -0
  955. package/dist/skills-cli-dhYXJCuL.js +339 -0
  956. package/dist/skills-install-DiriUXJd.js +763 -0
  957. package/dist/skills-status-BmQTn4jL.js +23 -0
  958. package/dist/skills-status-a9b899Y3.js +169 -0
  959. package/dist/slack-CXgv7nu7.js +730 -0
  960. package/dist/slack-CcSByPzI.js +217 -0
  961. package/dist/slack-CtcCh0Lj.js +24537 -0
  962. package/dist/slack-core-DcsbATUs.js +1 -0
  963. package/dist/slash-commands.runtime-kO8EUKYW.js +228 -0
  964. package/dist/slash-dispatch.runtime-Bu2yMeFy.js +238 -0
  965. package/dist/slash-skill-commands.runtime-wwX3tF84.js +216 -0
  966. package/dist/speech-bSreRuDH.js +1 -0
  967. package/dist/speech-runtime-y1FcnGVA.js +1 -0
  968. package/dist/src-CmXHIz5f.js +846 -0
  969. package/dist/ssh-config-ChqR6ijV.js +77 -0
  970. package/dist/ssh-tunnel-Cz51VBAt.js +159 -0
  971. package/dist/ssh-tunnel-DWze2IQS.js +16 -0
  972. package/dist/ssrf-Dk9XaoKN.js +220 -0
  973. package/dist/ssrf-policy-Dk6oMa20.js +69 -0
  974. package/dist/ssrf-runtime-C-mAQLVA.js +1 -0
  975. package/dist/stagger-DU7FjHYo.js +54 -0
  976. package/dist/state-paths-DJIGEFq_.js +1 -0
  977. package/dist/status-69r8-Zey.js +75 -0
  978. package/dist/status-BdLTvZOL.js +44 -0
  979. package/dist/status-Bt7DQmRI.js +1665 -0
  980. package/dist/status-CoUFSBgt.js +202 -0
  981. package/dist/status-DbI3Kbh5.js +235 -0
  982. package/dist/status-DeKlzu_o.js +212 -0
  983. package/dist/status-Haie42Fc.js +606 -0
  984. package/dist/status-helpers-Cda-rGLX.js +101 -0
  985. package/dist/status-json-DS1M_MWJ.js +322 -0
  986. package/dist/status.link-channel-Cb8bZ_Od.js +40 -0
  987. package/dist/status.scan.deps.runtime-7_6VUs50.js +77 -0
  988. package/dist/status.scan.runtime-DtR8BIE9.js +14 -0
  989. package/dist/status.summary-l_Bi1buR.js +600 -0
  990. package/dist/status.summary.runtime-Cng6MzRU.js +151 -0
  991. package/dist/status.update-DtbnnPKx.js +79 -0
  992. package/dist/store-CvL8MPei.js +1446 -0
  993. package/dist/store.runtime-hgnvmZgO.js +43 -0
  994. package/dist/string-normalization-CvzuCAZv.js +19 -0
  995. package/dist/string-sample-BOLqzr4Y.js +11 -0
  996. package/dist/subagent-orphan-recovery-si1z2iBu.js +407 -0
  997. package/dist/subagent-registry-runtime-CXUDI8gL.js +211 -0
  998. package/dist/subcli-descriptors-CY_nHzpZ.js +151 -0
  999. package/dist/subsystem-CUp-6QQf.js +421 -0
  1000. package/dist/synology-chat-CdejNfs0.js +12 -0
  1001. package/dist/system-cli-DkOaXHkQ.js +99 -0
  1002. package/dist/system-events-mAu6Ap6K.js +75 -0
  1003. package/dist/system-message-DA9eUYzB.js +16 -0
  1004. package/dist/system-run-command-Cxq2F1MB.js +258 -0
  1005. package/dist/systemd-CrxZBFae.js +557 -0
  1006. package/dist/systemd-hints-y-zJ9aTm.js +315 -0
  1007. package/dist/systemd-linger-BdklDcLg.js +16 -0
  1008. package/dist/systemd-linger-DLrbG9_d.js +68 -0
  1009. package/dist/table-DFMOhmNZ.js +305 -0
  1010. package/dist/tailnet-ofqBrXzu.js +38 -0
  1011. package/dist/tailscale-Cbsx-2HB.js +254 -0
  1012. package/dist/target-errors-ksphhzJg.js +26 -0
  1013. package/dist/target-registry-krAVlXi_.js +1321 -0
  1014. package/dist/telegram/audit.js +2 -0
  1015. package/dist/telegram/token.js +211 -0
  1016. package/dist/telegram-BjDUP22F.js +10910 -0
  1017. package/dist/telegram-DMiNSGAJ.js +575 -0
  1018. package/dist/telegram-Dt11B3JL.js +218 -0
  1019. package/dist/telegram-core-B4Jo-uko.js +1 -0
  1020. package/dist/template-messages-kh7VfgOb.js +214 -0
  1021. package/dist/text-chunking-CUf5WgqG.js +19 -0
  1022. package/dist/text-format-sFXlJfHH.js +8 -0
  1023. package/dist/text-runtime-C_Roi_Je.js +1418 -0
  1024. package/dist/theme-B5HDbQfl.js +2 -0
  1025. package/dist/theme-CdOoMzRk.js +34 -0
  1026. package/dist/thinking-BBD_0HSp.js +68 -0
  1027. package/dist/thinking.shared-CncvRHts.js +246 -0
  1028. package/dist/thread-bindings-messages-Cdo8jSa9.js +229 -0
  1029. package/dist/thread-bindings-policy-DMjOaNyR.js +119 -0
  1030. package/dist/thread-bindings-runtime-Ckwk3Uuz.js +1 -0
  1031. package/dist/threading-helpers-Cq55SUtb.js +14 -0
  1032. package/dist/timeouts-BwR1sGom.js +72 -0
  1033. package/dist/tmp-openclaw-dir-idKIOMmb.js +102 -0
  1034. package/dist/token-Bgv8XEsC.js +50 -0
  1035. package/dist/tool-catalog-BV6FcEWS.js +337 -0
  1036. package/dist/tool-policy-match-CHqTCSdK.js +46 -0
  1037. package/dist/tool-send-9LXKcrda.js +16 -0
  1038. package/dist/topology-cli-BhUXVViF.js +43 -0
  1039. package/dist/transcript-events-B1V6z5ct.js +29 -0
  1040. package/dist/tui-DDJMGCFK.js +3838 -0
  1041. package/dist/tui-cli-ByN-ZH6y.js +237 -0
  1042. package/dist/typebox-D0SHDJST.js +175 -0
  1043. package/dist/types-BCKGVVld.js +83 -0
  1044. package/dist/types-CtpUGsDP.js +30 -0
  1045. package/dist/types.secrets-BWSeXrF4.js +80 -0
  1046. package/dist/types.tools-BBO8HCi6.js +22 -0
  1047. package/dist/typing-DG_YqWJ7.js +224 -0
  1048. package/dist/unhandled-rejections-CDJ8dOVP.js +170 -0
  1049. package/dist/unhandled-rejections-O6cVOz2D.js +4 -0
  1050. package/dist/update-Br8U-txJ.js +1039 -0
  1051. package/dist/update-check-C3TeQaWg.js +464 -0
  1052. package/dist/update-cli-XHfIntD0.js +1625 -0
  1053. package/dist/update-offset-store-36vzzZXw.js +211 -0
  1054. package/dist/upsert-with-lock-Bb96JHpb.js +34 -0
  1055. package/dist/url-userinfo-Db63ng4y.js +14 -0
  1056. package/dist/utils-Bxk6BLTg.js +236 -0
  1057. package/dist/utils-vDeUf98G.js +7 -0
  1058. package/dist/version-DCY9_obP.js +64 -0
  1059. package/dist/version-DRF-wKTV.js +2 -0
  1060. package/dist/voice-call-D4fgwZNO.js +1 -0
  1061. package/dist/warning-filter-CgvLQB4Y.js +56 -0
  1062. package/dist/web-media-BfBb8i48.js +1 -0
  1063. package/dist/web-media-CtU6jM5V.js +498 -0
  1064. package/dist/webhook-ingress-CupqYpKM.js +338 -0
  1065. package/dist/webhook-memory-guards-BHrFZ4yq.js +129 -0
  1066. package/dist/webhook-path-BGFZ55ML.js +22 -0
  1067. package/dist/webhook-shared-Cvk3b0ac.js +349 -0
  1068. package/dist/webhooks-cli-vOAoBF9b.js +357 -0
  1069. package/dist/whatsapp-D5nD0rGG.js +58 -0
  1070. package/dist/whatsapp-DXbWlm3A.js +82 -0
  1071. package/dist/whatsapp-core-C2WGMsaY.js +89451 -0
  1072. package/dist/whatsapp-heartbeat-CSWnPQ7q.js +84 -0
  1073. package/dist/whatsapp-shared-BmHKqTtR.js +95 -0
  1074. package/dist/widearea-dns-CXimgJzu.js +125 -0
  1075. package/dist/windows-argv-IXrdWrJj.js +145 -0
  1076. package/dist/windows-spawn-vMJGZo89.js +154 -0
  1077. package/dist/with-timeout-2AKTISee.js +58 -0
  1078. package/dist/workspace-BH7CXmrr.js +479 -0
  1079. package/dist/workspace-dirs-_O4V3xCR.js +13 -0
  1080. package/dist/workspace-v5XppK5M.js +302 -0
  1081. package/dist/ws-By-QcLjg.js +11 -0
  1082. package/dist/wsl-BV3Cb66X.js +57 -0
  1083. package/dist/zalo-CHQzsLhE.js +301 -0
  1084. package/dist/zalo-CcJ3J9f2.js +13 -0
  1085. package/dist/zod-schema.agent-runtime-T_EC_6fg.js +600 -0
  1086. package/dist/zod-schema.core-BdgRr-F1.js +545 -0
  1087. package/dist/zod-schema.providers-core-Dgq7MTqU.js +1613 -0
  1088. package/docs/.i18n/README.md +31 -0
  1089. package/docs/.i18n/glossary.ja-JP.json +14 -0
  1090. package/docs/.i18n/glossary.zh-CN.json +242 -0
  1091. package/docs/.i18n/ja-JP.tm.jsonl +0 -0
  1092. package/docs/assets/install-script.svg +1 -0
  1093. package/docs/assets/macos-onboarding/01-macos-warning.jpeg +0 -0
  1094. package/docs/assets/macos-onboarding/02-local-networks.jpeg +0 -0
  1095. package/docs/assets/macos-onboarding/03-security-notice.png +0 -0
  1096. package/docs/assets/macos-onboarding/04-choose-gateway.png +0 -0
  1097. package/docs/assets/macos-onboarding/05-permissions.png +0 -0
  1098. package/docs/assets/openclaw-logo-text-dark.png +0 -0
  1099. package/docs/assets/openclaw-logo-text-dark.svg +418 -0
  1100. package/docs/assets/openclaw-logo-text.png +0 -0
  1101. package/docs/assets/openclaw-logo-text.svg +418 -0
  1102. package/docs/assets/pixel-lobster.svg +60 -0
  1103. package/docs/assets/showcase/agents-ui.jpg +0 -0
  1104. package/docs/assets/showcase/bambu-cli.png +0 -0
  1105. package/docs/assets/showcase/codexmonitor.png +0 -0
  1106. package/docs/assets/showcase/gohome-grafana.png +0 -0
  1107. package/docs/assets/showcase/ios-testflight.jpg +0 -0
  1108. package/docs/assets/showcase/oura-health.png +0 -0
  1109. package/docs/assets/showcase/padel-cli.svg +11 -0
  1110. package/docs/assets/showcase/padel-screenshot.jpg +0 -0
  1111. package/docs/assets/showcase/papla-tts.jpg +0 -0
  1112. package/docs/assets/showcase/pr-review-telegram.jpg +0 -0
  1113. package/docs/assets/showcase/roborock-screenshot.jpg +0 -0
  1114. package/docs/assets/showcase/roborock-status.svg +13 -0
  1115. package/docs/assets/showcase/roof-camera-sky.jpg +0 -0
  1116. package/docs/assets/showcase/snag.png +0 -0
  1117. package/docs/assets/showcase/tesco-shop.jpg +0 -0
  1118. package/docs/assets/showcase/wienerlinien.png +0 -0
  1119. package/docs/assets/showcase/wine-cellar-skill.jpg +0 -0
  1120. package/docs/assets/showcase/winix-air-purifier.jpg +0 -0
  1121. package/docs/assets/showcase/xuezh-pronunciation.jpeg +0 -0
  1122. package/docs/assets/sponsors/blacksmith.svg +14 -0
  1123. package/docs/assets/sponsors/convex.svg +16 -0
  1124. package/docs/assets/sponsors/openai.svg +3 -0
  1125. package/docs/assets/sponsors/vercel.svg +5 -0
  1126. package/docs/auth-credential-semantics.md +53 -0
  1127. package/docs/automation/auth-monitoring.md +44 -0
  1128. package/docs/automation/cron-jobs.md +727 -0
  1129. package/docs/automation/cron-vs-heartbeat.md +286 -0
  1130. package/docs/automation/gmail-pubsub.md +256 -0
  1131. package/docs/automation/hooks.md +1049 -0
  1132. package/docs/automation/poll.md +86 -0
  1133. package/docs/automation/standing-orders.md +251 -0
  1134. package/docs/automation/troubleshooting.md +122 -0
  1135. package/docs/automation/webhook.md +217 -0
  1136. package/docs/brave-search.md +93 -0
  1137. package/docs/channels/bluebubbles.md +347 -0
  1138. package/docs/channels/broadcast-groups.md +442 -0
  1139. package/docs/channels/channel-routing.md +139 -0
  1140. package/docs/channels/discord.md +1229 -0
  1141. package/docs/channels/feishu.md +747 -0
  1142. package/docs/channels/googlechat.md +261 -0
  1143. package/docs/channels/group-messages.md +84 -0
  1144. package/docs/channels/groups.md +379 -0
  1145. package/docs/channels/imessage.md +367 -0
  1146. package/docs/channels/index.md +47 -0
  1147. package/docs/channels/irc.md +242 -0
  1148. package/docs/channels/line.md +194 -0
  1149. package/docs/channels/location.md +56 -0
  1150. package/docs/channels/matrix.md +677 -0
  1151. package/docs/channels/mattermost.md +427 -0
  1152. package/docs/channels/msteams.md +780 -0
  1153. package/docs/channels/nextcloud-talk.md +138 -0
  1154. package/docs/channels/nostr.md +242 -0
  1155. package/docs/channels/pairing.md +114 -0
  1156. package/docs/channels/signal.md +329 -0
  1157. package/docs/channels/slack.md +603 -0
  1158. package/docs/channels/synology-chat.md +132 -0
  1159. package/docs/channels/telegram.md +987 -0
  1160. package/docs/channels/tlon.md +276 -0
  1161. package/docs/channels/troubleshooting.md +118 -0
  1162. package/docs/channels/twitch.md +379 -0
  1163. package/docs/channels/whatsapp.md +460 -0
  1164. package/docs/channels/zalo.md +243 -0
  1165. package/docs/channels/zalouser.md +181 -0
  1166. package/docs/ci.md +55 -0
  1167. package/docs/cli/acp.md +288 -0
  1168. package/docs/cli/agent.md +29 -0
  1169. package/docs/cli/agents.md +123 -0
  1170. package/docs/cli/approvals.md +50 -0
  1171. package/docs/cli/backup.md +76 -0
  1172. package/docs/cli/browser.md +106 -0
  1173. package/docs/cli/channels.md +102 -0
  1174. package/docs/cli/clawbot.md +21 -0
  1175. package/docs/cli/completion.md +35 -0
  1176. package/docs/cli/config.md +295 -0
  1177. package/docs/cli/configure.md +36 -0
  1178. package/docs/cli/cron.md +77 -0
  1179. package/docs/cli/daemon.md +53 -0
  1180. package/docs/cli/dashboard.md +22 -0
  1181. package/docs/cli/devices.md +139 -0
  1182. package/docs/cli/directory.md +63 -0
  1183. package/docs/cli/dns.md +23 -0
  1184. package/docs/cli/docs.md +15 -0
  1185. package/docs/cli/doctor.md +48 -0
  1186. package/docs/cli/gateway.md +235 -0
  1187. package/docs/cli/health.md +21 -0
  1188. package/docs/cli/hooks.md +318 -0
  1189. package/docs/cli/index.md +1147 -0
  1190. package/docs/cli/logs.md +28 -0
  1191. package/docs/cli/memory.md +66 -0
  1192. package/docs/cli/message.md +278 -0
  1193. package/docs/cli/models.md +81 -0
  1194. package/docs/cli/node.md +127 -0
  1195. package/docs/cli/nodes.md +75 -0
  1196. package/docs/cli/onboard.md +157 -0
  1197. package/docs/cli/pairing.md +32 -0
  1198. package/docs/cli/plugins.md +186 -0
  1199. package/docs/cli/qr.md +46 -0
  1200. package/docs/cli/reset.md +20 -0
  1201. package/docs/cli/sandbox.md +197 -0
  1202. package/docs/cli/secrets.md +188 -0
  1203. package/docs/cli/security.md +79 -0
  1204. package/docs/cli/sessions.md +110 -0
  1205. package/docs/cli/setup.md +29 -0
  1206. package/docs/cli/skills.md +26 -0
  1207. package/docs/cli/status.md +30 -0
  1208. package/docs/cli/system.md +60 -0
  1209. package/docs/cli/tui.md +30 -0
  1210. package/docs/cli/uninstall.md +20 -0
  1211. package/docs/cli/update.md +103 -0
  1212. package/docs/cli/voicecall.md +34 -0
  1213. package/docs/cli/webhooks.md +25 -0
  1214. package/docs/concepts/agent-loop.md +148 -0
  1215. package/docs/concepts/agent-workspace.md +236 -0
  1216. package/docs/concepts/agent.md +122 -0
  1217. package/docs/concepts/architecture.md +137 -0
  1218. package/docs/concepts/compaction.md +123 -0
  1219. package/docs/concepts/context-engine.md +268 -0
  1220. package/docs/concepts/context.md +172 -0
  1221. package/docs/concepts/delegate-architecture.md +296 -0
  1222. package/docs/concepts/features.md +73 -0
  1223. package/docs/concepts/markdown-formatting.md +130 -0
  1224. package/docs/concepts/memory.md +108 -0
  1225. package/docs/concepts/messages.md +154 -0
  1226. package/docs/concepts/model-failover.md +152 -0
  1227. package/docs/concepts/model-providers.md +607 -0
  1228. package/docs/concepts/models.md +225 -0
  1229. package/docs/concepts/multi-agent.md +552 -0
  1230. package/docs/concepts/oauth.md +158 -0
  1231. package/docs/concepts/presence.md +102 -0
  1232. package/docs/concepts/queue.md +89 -0
  1233. package/docs/concepts/retry.md +69 -0
  1234. package/docs/concepts/session-pruning.md +121 -0
  1235. package/docs/concepts/session-tool.md +242 -0
  1236. package/docs/concepts/session.md +310 -0
  1237. package/docs/concepts/streaming.md +155 -0
  1238. package/docs/concepts/system-prompt.md +132 -0
  1239. package/docs/concepts/timezone.md +91 -0
  1240. package/docs/concepts/typebox.md +291 -0
  1241. package/docs/concepts/typing-indicators.md +68 -0
  1242. package/docs/concepts/usage-tracking.md +35 -0
  1243. package/docs/date-time.md +128 -0
  1244. package/docs/debug/node-issue.md +85 -0
  1245. package/docs/diagnostics/flags.md +91 -0
  1246. package/docs/docs.json +2061 -0
  1247. package/docs/gateway/authentication.md +179 -0
  1248. package/docs/gateway/background-process.md +97 -0
  1249. package/docs/gateway/bonjour.md +177 -0
  1250. package/docs/gateway/bridge-protocol.md +91 -0
  1251. package/docs/gateway/cli-backends.md +225 -0
  1252. package/docs/gateway/configuration-examples.md +651 -0
  1253. package/docs/gateway/configuration-reference.md +3123 -0
  1254. package/docs/gateway/configuration.md +633 -0
  1255. package/docs/gateway/discovery.md +123 -0
  1256. package/docs/gateway/doctor.md +362 -0
  1257. package/docs/gateway/gateway-lock.md +34 -0
  1258. package/docs/gateway/health.md +44 -0
  1259. package/docs/gateway/heartbeat.md +393 -0
  1260. package/docs/gateway/index.md +261 -0
  1261. package/docs/gateway/local-models.md +152 -0
  1262. package/docs/gateway/logging.md +113 -0
  1263. package/docs/gateway/multiple-gateways.md +112 -0
  1264. package/docs/gateway/network-model.md +22 -0
  1265. package/docs/gateway/openai-http-api.md +132 -0
  1266. package/docs/gateway/openresponses-http-api.md +295 -0
  1267. package/docs/gateway/openshell.md +307 -0
  1268. package/docs/gateway/pairing.md +99 -0
  1269. package/docs/gateway/protocol.md +267 -0
  1270. package/docs/gateway/remote-gateway-readme.md +158 -0
  1271. package/docs/gateway/remote.md +153 -0
  1272. package/docs/gateway/sandbox-vs-tool-policy-vs-elevated.md +134 -0
  1273. package/docs/gateway/sandboxing.md +469 -0
  1274. package/docs/gateway/secrets-plan-contract.md +116 -0
  1275. package/docs/gateway/secrets.md +503 -0
  1276. package/docs/gateway/security/index.md +1213 -0
  1277. package/docs/gateway/tailscale.md +132 -0
  1278. package/docs/gateway/tools-invoke-http-api.md +110 -0
  1279. package/docs/gateway/troubleshooting.md +378 -0
  1280. package/docs/gateway/trusted-proxy-auth.md +330 -0
  1281. package/docs/help/debugging.md +168 -0
  1282. package/docs/help/environment.md +163 -0
  1283. package/docs/help/faq.md +2999 -0
  1284. package/docs/help/index.md +28 -0
  1285. package/docs/help/scripts.md +28 -0
  1286. package/docs/help/testing.md +524 -0
  1287. package/docs/help/troubleshooting.md +297 -0
  1288. package/docs/images/configure-model-picker-unsearchable.png +0 -0
  1289. package/docs/images/feishu-step2-create-app.png +0 -0
  1290. package/docs/images/feishu-step3-credentials.png +0 -0
  1291. package/docs/images/feishu-step4-permissions.png +0 -0
  1292. package/docs/images/feishu-step5-bot-capability.png +0 -0
  1293. package/docs/images/feishu-step6-event-subscription.png +0 -0
  1294. package/docs/images/feishu-verification-token.png +0 -0
  1295. package/docs/images/groups-flow.svg +52 -0
  1296. package/docs/images/mobile-ui-screenshot.png +0 -0
  1297. package/docs/index.md +196 -0
  1298. package/docs/install/ansible.md +230 -0
  1299. package/docs/install/azure.md +311 -0
  1300. package/docs/install/bun.md +55 -0
  1301. package/docs/install/development-channels.md +120 -0
  1302. package/docs/install/digitalocean.md +129 -0
  1303. package/docs/install/docker-vm-runtime.md +142 -0
  1304. package/docs/install/docker.md +375 -0
  1305. package/docs/install/exe-dev.md +126 -0
  1306. package/docs/install/fly.md +501 -0
  1307. package/docs/install/gcp.md +402 -0
  1308. package/docs/install/hetzner.md +251 -0
  1309. package/docs/install/index.md +183 -0
  1310. package/docs/install/installer.md +415 -0
  1311. package/docs/install/kubernetes.md +191 -0
  1312. package/docs/install/macos-vm.md +281 -0
  1313. package/docs/install/migrating-matrix.md +346 -0
  1314. package/docs/install/migrating.md +110 -0
  1315. package/docs/install/nix.md +89 -0
  1316. package/docs/install/node.md +138 -0
  1317. package/docs/install/northflank.mdx +54 -0
  1318. package/docs/install/oracle.md +156 -0
  1319. package/docs/install/podman.md +133 -0
  1320. package/docs/install/railway.mdx +100 -0
  1321. package/docs/install/raspberry-pi.md +159 -0
  1322. package/docs/install/render.mdx +169 -0
  1323. package/docs/install/uninstall.md +128 -0
  1324. package/docs/install/updating.md +128 -0
  1325. package/docs/ja-JP/index.md +186 -0
  1326. package/docs/ja-JP/start/getting-started.md +125 -0
  1327. package/docs/ja-JP/start/wizard.md +77 -0
  1328. package/docs/logging.md +352 -0
  1329. package/docs/nav-tabs-underline.js +100 -0
  1330. package/docs/network.md +54 -0
  1331. package/docs/nodes/audio.md +187 -0
  1332. package/docs/nodes/camera.md +162 -0
  1333. package/docs/nodes/images.md +72 -0
  1334. package/docs/nodes/index.md +393 -0
  1335. package/docs/nodes/location-command.md +98 -0
  1336. package/docs/nodes/media-understanding.md +394 -0
  1337. package/docs/nodes/talk.md +92 -0
  1338. package/docs/nodes/troubleshooting.md +114 -0
  1339. package/docs/nodes/voicewake.md +66 -0
  1340. package/docs/perplexity.md +174 -0
  1341. package/docs/pi-dev.md +80 -0
  1342. package/docs/pi.md +567 -0
  1343. package/docs/platforms/android.md +168 -0
  1344. package/docs/platforms/digitalocean.md +266 -0
  1345. package/docs/platforms/index.md +54 -0
  1346. package/docs/platforms/ios.md +220 -0
  1347. package/docs/platforms/linux.md +94 -0
  1348. package/docs/platforms/mac/bundled-gateway.md +73 -0
  1349. package/docs/platforms/mac/canvas.md +125 -0
  1350. package/docs/platforms/mac/child-process.md +69 -0
  1351. package/docs/platforms/mac/dev-setup.md +104 -0
  1352. package/docs/platforms/mac/health.md +34 -0
  1353. package/docs/platforms/mac/icon.md +31 -0
  1354. package/docs/platforms/mac/logging.md +57 -0
  1355. package/docs/platforms/mac/menu-bar.md +81 -0
  1356. package/docs/platforms/mac/peekaboo.md +65 -0
  1357. package/docs/platforms/mac/permissions.md +50 -0
  1358. package/docs/platforms/mac/remote.md +84 -0
  1359. package/docs/platforms/mac/signing.md +47 -0
  1360. package/docs/platforms/mac/skills.md +33 -0
  1361. package/docs/platforms/mac/voice-overlay.md +60 -0
  1362. package/docs/platforms/mac/voicewake.md +67 -0
  1363. package/docs/platforms/mac/webchat.md +43 -0
  1364. package/docs/platforms/mac/xpc.md +61 -0
  1365. package/docs/platforms/macos.md +226 -0
  1366. package/docs/platforms/oracle.md +303 -0
  1367. package/docs/platforms/raspberry-pi.md +412 -0
  1368. package/docs/platforms/windows.md +241 -0
  1369. package/docs/plugins/agent-tools.md +10 -0
  1370. package/docs/plugins/architecture.md +1363 -0
  1371. package/docs/plugins/building-extensions.md +10 -0
  1372. package/docs/plugins/building-plugins.md +376 -0
  1373. package/docs/plugins/bundles.md +181 -0
  1374. package/docs/plugins/community.md +141 -0
  1375. package/docs/plugins/manifest.md +145 -0
  1376. package/docs/plugins/sdk-migration.md +169 -0
  1377. package/docs/plugins/voice-call.md +380 -0
  1378. package/docs/plugins/zalouser.md +77 -0
  1379. package/docs/prose.md +134 -0
  1380. package/docs/providers/anthropic.md +259 -0
  1381. package/docs/providers/bedrock.md +176 -0
  1382. package/docs/providers/claude-max-api-proxy.md +154 -0
  1383. package/docs/providers/cloudflare-ai-gateway.md +71 -0
  1384. package/docs/providers/deepgram.md +93 -0
  1385. package/docs/providers/github-copilot.md +72 -0
  1386. package/docs/providers/glm.md +43 -0
  1387. package/docs/providers/google.md +78 -0
  1388. package/docs/providers/groq.md +96 -0
  1389. package/docs/providers/huggingface.md +209 -0
  1390. package/docs/providers/index.md +69 -0
  1391. package/docs/providers/kilocode.md +74 -0
  1392. package/docs/providers/litellm.md +154 -0
  1393. package/docs/providers/minimax.md +224 -0
  1394. package/docs/providers/mistral.md +54 -0
  1395. package/docs/providers/models.md +45 -0
  1396. package/docs/providers/modelstudio.md +66 -0
  1397. package/docs/providers/moonshot.md +175 -0
  1398. package/docs/providers/nvidia.md +55 -0
  1399. package/docs/providers/ollama.md +352 -0
  1400. package/docs/providers/openai.md +303 -0
  1401. package/docs/providers/opencode-go.md +45 -0
  1402. package/docs/providers/opencode.md +64 -0
  1403. package/docs/providers/openrouter.md +37 -0
  1404. package/docs/providers/perplexity-provider.md +62 -0
  1405. package/docs/providers/qianfan.md +38 -0
  1406. package/docs/providers/qwen.md +53 -0
  1407. package/docs/providers/sglang.md +104 -0
  1408. package/docs/providers/synthetic.md +99 -0
  1409. package/docs/providers/together.md +66 -0
  1410. package/docs/providers/venice.md +282 -0
  1411. package/docs/providers/vercel-ai-gateway.md +60 -0
  1412. package/docs/providers/vllm.md +92 -0
  1413. package/docs/providers/volcengine.md +74 -0
  1414. package/docs/providers/xai.md +60 -0
  1415. package/docs/providers/xiaomi.md +86 -0
  1416. package/docs/providers/zai.md +46 -0
  1417. package/docs/reference/AGENTS.default.md +126 -0
  1418. package/docs/reference/RELEASING.md +42 -0
  1419. package/docs/reference/api-usage-costs.md +144 -0
  1420. package/docs/reference/credits.md +30 -0
  1421. package/docs/reference/device-models.md +47 -0
  1422. package/docs/reference/memory-config.md +711 -0
  1423. package/docs/reference/prompt-caching.md +185 -0
  1424. package/docs/reference/rpc.md +43 -0
  1425. package/docs/reference/secretref-credential-surface.md +140 -0
  1426. package/docs/reference/secretref-user-supplied-credentials-matrix.json +563 -0
  1427. package/docs/reference/session-management-compaction.md +324 -0
  1428. package/docs/reference/templates/AGENTS.dev.md +83 -0
  1429. package/docs/reference/templates/AGENTS.md +219 -0
  1430. package/docs/reference/templates/BOOT.md +11 -0
  1431. package/docs/reference/templates/BOOTSTRAP.md +62 -0
  1432. package/docs/reference/templates/HEARTBEAT.md +14 -0
  1433. package/docs/reference/templates/IDENTITY.dev.md +47 -0
  1434. package/docs/reference/templates/IDENTITY.md +29 -0
  1435. package/docs/reference/templates/SOUL.dev.md +76 -0
  1436. package/docs/reference/templates/SOUL.md +43 -0
  1437. package/docs/reference/templates/TOOLS.dev.md +24 -0
  1438. package/docs/reference/templates/TOOLS.md +47 -0
  1439. package/docs/reference/templates/USER.dev.md +18 -0
  1440. package/docs/reference/templates/USER.md +23 -0
  1441. package/docs/reference/test.md +90 -0
  1442. package/docs/reference/token-use.md +175 -0
  1443. package/docs/reference/transcript-hygiene.md +151 -0
  1444. package/docs/reference/wizard.md +235 -0
  1445. package/docs/security/CONTRIBUTING-THREAT-MODEL.md +98 -0
  1446. package/docs/security/THREAT-MODEL-ATLAS.md +611 -0
  1447. package/docs/security/formal-verification.md +167 -0
  1448. package/docs/start/bootstrapping.md +41 -0
  1449. package/docs/start/docs-directory.md +66 -0
  1450. package/docs/start/getting-started.md +116 -0
  1451. package/docs/start/hubs.md +198 -0
  1452. package/docs/start/lore.md +219 -0
  1453. package/docs/start/onboarding-overview.md +67 -0
  1454. package/docs/start/onboarding.md +91 -0
  1455. package/docs/start/openclaw.md +216 -0
  1456. package/docs/start/quickstart.md +22 -0
  1457. package/docs/start/setup.md +164 -0
  1458. package/docs/start/showcase.md +418 -0
  1459. package/docs/start/wizard-cli-automation.md +215 -0
  1460. package/docs/start/wizard-cli-reference.md +299 -0
  1461. package/docs/start/wizard.md +125 -0
  1462. package/docs/style.css +37 -0
  1463. package/docs/tools/acp-agents.md +623 -0
  1464. package/docs/tools/agent-send.md +100 -0
  1465. package/docs/tools/apply-patch.md +51 -0
  1466. package/docs/tools/brave-search.md +93 -0
  1467. package/docs/tools/browser-linux-troubleshooting.md +138 -0
  1468. package/docs/tools/browser-login.md +73 -0
  1469. package/docs/tools/browser-wsl2-windows-remote-cdp-troubleshooting.md +211 -0
  1470. package/docs/tools/browser.md +731 -0
  1471. package/docs/tools/btw.md +142 -0
  1472. package/docs/tools/capability-cookbook.md +119 -0
  1473. package/docs/tools/clawhub.md +257 -0
  1474. package/docs/tools/creating-skills.md +117 -0
  1475. package/docs/tools/diffs.md +386 -0
  1476. package/docs/tools/elevated.md +114 -0
  1477. package/docs/tools/exec-approvals.md +400 -0
  1478. package/docs/tools/exec.md +204 -0
  1479. package/docs/tools/firecrawl.md +140 -0
  1480. package/docs/tools/index.md +137 -0
  1481. package/docs/tools/llm-task.md +119 -0
  1482. package/docs/tools/lobster.md +340 -0
  1483. package/docs/tools/loop-detection.md +100 -0
  1484. package/docs/tools/multi-agent-sandbox-tools.md +364 -0
  1485. package/docs/tools/pdf.md +156 -0
  1486. package/docs/tools/perplexity-search.md +174 -0
  1487. package/docs/tools/plugin.md +251 -0
  1488. package/docs/tools/reactions.md +64 -0
  1489. package/docs/tools/skills-config.md +86 -0
  1490. package/docs/tools/skills.md +306 -0
  1491. package/docs/tools/slash-commands.md +294 -0
  1492. package/docs/tools/subagents.md +295 -0
  1493. package/docs/tools/tavily.md +125 -0
  1494. package/docs/tools/thinking.md +96 -0
  1495. package/docs/tools/tts.md +406 -0
  1496. package/docs/tools/web.md +516 -0
  1497. package/docs/tts.md +406 -0
  1498. package/docs/vps.md +112 -0
  1499. package/docs/web/control-ui.md +275 -0
  1500. package/docs/web/dashboard.md +54 -0
  1501. package/docs/web/index.md +120 -0
  1502. package/docs/web/tui.md +170 -0
  1503. package/docs/web/webchat.md +61 -0
  1504. package/docs/whatsapp-openclaw-ai-zh.jpg +0 -0
  1505. package/docs/whatsapp-openclaw.jpg +0 -0
  1506. package/docs/zh-CN/AGENTS.md +61 -0
  1507. package/docs/zh-CN/automation/auth-monitoring.md +47 -0
  1508. package/docs/zh-CN/automation/cron-jobs.md +435 -0
  1509. package/docs/zh-CN/automation/cron-vs-heartbeat.md +286 -0
  1510. package/docs/zh-CN/automation/gmail-pubsub.md +249 -0
  1511. package/docs/zh-CN/automation/hooks.md +1051 -0
  1512. package/docs/zh-CN/automation/poll.md +76 -0
  1513. package/docs/zh-CN/automation/troubleshooting.md +8 -0
  1514. package/docs/zh-CN/automation/webhook.md +163 -0
  1515. package/docs/zh-CN/brave-search.md +60 -0
  1516. package/docs/zh-CN/channels/bluebubbles.md +354 -0
  1517. package/docs/zh-CN/channels/broadcast-groups.md +449 -0
  1518. package/docs/zh-CN/channels/channel-routing.md +117 -0
  1519. package/docs/zh-CN/channels/discord.md +468 -0
  1520. package/docs/zh-CN/channels/feishu.md +728 -0
  1521. package/docs/zh-CN/channels/googlechat.md +257 -0
  1522. package/docs/zh-CN/channels/grammy.md +38 -0
  1523. package/docs/zh-CN/channels/group-messages.md +91 -0
  1524. package/docs/zh-CN/channels/groups.md +379 -0
  1525. package/docs/zh-CN/channels/imessage.md +302 -0
  1526. package/docs/zh-CN/channels/index.md +53 -0
  1527. package/docs/zh-CN/channels/line.md +180 -0
  1528. package/docs/zh-CN/channels/location.md +63 -0
  1529. package/docs/zh-CN/channels/matrix.md +221 -0
  1530. package/docs/zh-CN/channels/mattermost.md +144 -0
  1531. package/docs/zh-CN/channels/msteams.md +775 -0
  1532. package/docs/zh-CN/channels/nextcloud-talk.md +142 -0
  1533. package/docs/zh-CN/channels/nostr.md +249 -0
  1534. package/docs/zh-CN/channels/pairing.md +89 -0
  1535. package/docs/zh-CN/channels/signal.md +209 -0
  1536. package/docs/zh-CN/channels/slack.md +531 -0
  1537. package/docs/zh-CN/channels/synology-chat.md +138 -0
  1538. package/docs/zh-CN/channels/telegram.md +751 -0
  1539. package/docs/zh-CN/channels/tlon.md +136 -0
  1540. package/docs/zh-CN/channels/troubleshooting.md +36 -0
  1541. package/docs/zh-CN/channels/twitch.md +385 -0
  1542. package/docs/zh-CN/channels/whatsapp.md +411 -0
  1543. package/docs/zh-CN/channels/zalo.md +196 -0
  1544. package/docs/zh-CN/channels/zalouser.md +147 -0
  1545. package/docs/zh-CN/cli/acp.md +173 -0
  1546. package/docs/zh-CN/cli/agent.md +30 -0
  1547. package/docs/zh-CN/cli/agents.md +82 -0
  1548. package/docs/zh-CN/cli/approvals.md +57 -0
  1549. package/docs/zh-CN/cli/browser.md +114 -0
  1550. package/docs/zh-CN/cli/channels.md +86 -0
  1551. package/docs/zh-CN/cli/config.md +57 -0
  1552. package/docs/zh-CN/cli/configure.md +38 -0
  1553. package/docs/zh-CN/cli/cron.md +43 -0
  1554. package/docs/zh-CN/cli/dashboard.md +23 -0
  1555. package/docs/zh-CN/cli/devices.md +74 -0
  1556. package/docs/zh-CN/cli/directory.md +70 -0
  1557. package/docs/zh-CN/cli/dns.md +30 -0
  1558. package/docs/zh-CN/cli/docs.md +22 -0
  1559. package/docs/zh-CN/cli/doctor.md +48 -0
  1560. package/docs/zh-CN/cli/gateway.md +206 -0
  1561. package/docs/zh-CN/cli/health.md +28 -0
  1562. package/docs/zh-CN/cli/hooks.md +298 -0
  1563. package/docs/zh-CN/cli/index.md +1143 -0
  1564. package/docs/zh-CN/cli/logs.md +31 -0
  1565. package/docs/zh-CN/cli/memory.md +52 -0
  1566. package/docs/zh-CN/cli/message.md +246 -0
  1567. package/docs/zh-CN/cli/models.md +85 -0
  1568. package/docs/zh-CN/cli/node.md +115 -0
  1569. package/docs/zh-CN/cli/nodes.md +80 -0
  1570. package/docs/zh-CN/cli/onboard.md +164 -0
  1571. package/docs/zh-CN/cli/pairing.md +28 -0
  1572. package/docs/zh-CN/cli/plugins.md +66 -0
  1573. package/docs/zh-CN/cli/reset.md +24 -0
  1574. package/docs/zh-CN/cli/sandbox.md +158 -0
  1575. package/docs/zh-CN/cli/security.md +33 -0
  1576. package/docs/zh-CN/cli/sessions.md +23 -0
  1577. package/docs/zh-CN/cli/setup.md +36 -0
  1578. package/docs/zh-CN/cli/skills.md +33 -0
  1579. package/docs/zh-CN/cli/status.md +33 -0
  1580. package/docs/zh-CN/cli/system.md +63 -0
  1581. package/docs/zh-CN/cli/tui.md +30 -0
  1582. package/docs/zh-CN/cli/uninstall.md +24 -0
  1583. package/docs/zh-CN/cli/update.md +101 -0
  1584. package/docs/zh-CN/cli/voicecall.md +41 -0
  1585. package/docs/zh-CN/cli/webhooks.md +32 -0
  1586. package/docs/zh-CN/concepts/agent-loop.md +146 -0
  1587. package/docs/zh-CN/concepts/agent-workspace.md +219 -0
  1588. package/docs/zh-CN/concepts/agent.md +115 -0
  1589. package/docs/zh-CN/concepts/architecture.md +123 -0
  1590. package/docs/zh-CN/concepts/compaction.md +67 -0
  1591. package/docs/zh-CN/concepts/context.md +168 -0
  1592. package/docs/zh-CN/concepts/features.md +59 -0
  1593. package/docs/zh-CN/concepts/markdown-formatting.md +117 -0
  1594. package/docs/zh-CN/concepts/memory.md +412 -0
  1595. package/docs/zh-CN/concepts/messages.md +141 -0
  1596. package/docs/zh-CN/concepts/model-failover.md +145 -0
  1597. package/docs/zh-CN/concepts/model-providers.md +606 -0
  1598. package/docs/zh-CN/concepts/models.md +225 -0
  1599. package/docs/zh-CN/concepts/multi-agent.md +372 -0
  1600. package/docs/zh-CN/concepts/oauth.md +164 -0
  1601. package/docs/zh-CN/concepts/presence.md +99 -0
  1602. package/docs/zh-CN/concepts/queue.md +94 -0
  1603. package/docs/zh-CN/concepts/retry.md +76 -0
  1604. package/docs/zh-CN/concepts/session-pruning.md +129 -0
  1605. package/docs/zh-CN/concepts/session-tool.md +200 -0
  1606. package/docs/zh-CN/concepts/session.md +166 -0
  1607. package/docs/zh-CN/concepts/streaming.md +133 -0
  1608. package/docs/zh-CN/concepts/system-prompt.md +101 -0
  1609. package/docs/zh-CN/concepts/timezone.md +96 -0
  1610. package/docs/zh-CN/concepts/typebox.md +284 -0
  1611. package/docs/zh-CN/concepts/typing-indicators.md +74 -0
  1612. package/docs/zh-CN/concepts/usage-tracking.md +42 -0
  1613. package/docs/zh-CN/date-time.md +129 -0
  1614. package/docs/zh-CN/debug/node-issue.md +90 -0
  1615. package/docs/zh-CN/diagnostics/flags.md +98 -0
  1616. package/docs/zh-CN/gateway/authentication.md +184 -0
  1617. package/docs/zh-CN/gateway/background-process.md +100 -0
  1618. package/docs/zh-CN/gateway/bonjour.md +174 -0
  1619. package/docs/zh-CN/gateway/bridge-protocol.md +86 -0
  1620. package/docs/zh-CN/gateway/cli-backends.md +213 -0
  1621. package/docs/zh-CN/gateway/configuration-examples.md +587 -0
  1622. package/docs/zh-CN/gateway/configuration-reference.md +3103 -0
  1623. package/docs/zh-CN/gateway/configuration.md +640 -0
  1624. package/docs/zh-CN/gateway/discovery.md +123 -0
  1625. package/docs/zh-CN/gateway/doctor.md +238 -0
  1626. package/docs/zh-CN/gateway/gateway-lock.md +41 -0
  1627. package/docs/zh-CN/gateway/health.md +42 -0
  1628. package/docs/zh-CN/gateway/heartbeat.md +274 -0
  1629. package/docs/zh-CN/gateway/index.md +335 -0
  1630. package/docs/zh-CN/gateway/local-models.md +159 -0
  1631. package/docs/zh-CN/gateway/logging.md +114 -0
  1632. package/docs/zh-CN/gateway/multiple-gateways.md +119 -0
  1633. package/docs/zh-CN/gateway/network-model.md +23 -0
  1634. package/docs/zh-CN/gateway/openai-http-api.md +125 -0
  1635. package/docs/zh-CN/gateway/openresponses-http-api.md +317 -0
  1636. package/docs/zh-CN/gateway/pairing.md +99 -0
  1637. package/docs/zh-CN/gateway/protocol.md +220 -0
  1638. package/docs/zh-CN/gateway/remote-gateway-readme.md +164 -0
  1639. package/docs/zh-CN/gateway/remote.md +133 -0
  1640. package/docs/zh-CN/gateway/sandbox-vs-tool-policy-vs-elevated.md +135 -0
  1641. package/docs/zh-CN/gateway/sandboxing.md +188 -0
  1642. package/docs/zh-CN/gateway/security/index.md +777 -0
  1643. package/docs/zh-CN/gateway/tailscale.md +124 -0
  1644. package/docs/zh-CN/gateway/tools-invoke-http-api.md +92 -0
  1645. package/docs/zh-CN/gateway/troubleshooting.md +771 -0
  1646. package/docs/zh-CN/help/debugging.md +160 -0
  1647. package/docs/zh-CN/help/environment.md +88 -0
  1648. package/docs/zh-CN/help/faq.md +2640 -0
  1649. package/docs/zh-CN/help/index.md +28 -0
  1650. package/docs/zh-CN/help/scripts.md +35 -0
  1651. package/docs/zh-CN/help/testing.md +375 -0
  1652. package/docs/zh-CN/help/troubleshooting.md +104 -0
  1653. package/docs/zh-CN/index.md +186 -0
  1654. package/docs/zh-CN/install/ansible.md +215 -0
  1655. package/docs/zh-CN/install/bun.md +65 -0
  1656. package/docs/zh-CN/install/development-channels.md +81 -0
  1657. package/docs/zh-CN/install/docker.md +532 -0
  1658. package/docs/zh-CN/install/exe-dev.md +133 -0
  1659. package/docs/zh-CN/install/fly.md +490 -0
  1660. package/docs/zh-CN/install/gcp.md +510 -0
  1661. package/docs/zh-CN/install/hetzner.md +337 -0
  1662. package/docs/zh-CN/install/index.md +235 -0
  1663. package/docs/zh-CN/install/installer.md +422 -0
  1664. package/docs/zh-CN/install/macos-vm.md +288 -0
  1665. package/docs/zh-CN/install/migrating.md +199 -0
  1666. package/docs/zh-CN/install/nix.md +99 -0
  1667. package/docs/zh-CN/install/node.md +8 -0
  1668. package/docs/zh-CN/install/northflank.mdx +60 -0
  1669. package/docs/zh-CN/install/railway.mdx +106 -0
  1670. package/docs/zh-CN/install/render.mdx +169 -0
  1671. package/docs/zh-CN/install/uninstall.md +135 -0
  1672. package/docs/zh-CN/install/updating.md +233 -0
  1673. package/docs/zh-CN/logging.md +329 -0
  1674. package/docs/zh-CN/network.md +59 -0
  1675. package/docs/zh-CN/nodes/audio.md +120 -0
  1676. package/docs/zh-CN/nodes/camera.md +162 -0
  1677. package/docs/zh-CN/nodes/images.md +79 -0
  1678. package/docs/zh-CN/nodes/index.md +348 -0
  1679. package/docs/zh-CN/nodes/location-command.md +120 -0
  1680. package/docs/zh-CN/nodes/media-understanding.md +380 -0
  1681. package/docs/zh-CN/nodes/talk.md +97 -0
  1682. package/docs/zh-CN/nodes/troubleshooting.md +8 -0
  1683. package/docs/zh-CN/nodes/voicewake.md +72 -0
  1684. package/docs/zh-CN/perplexity.md +102 -0
  1685. package/docs/zh-CN/pi-dev.md +77 -0
  1686. package/docs/zh-CN/pi.md +619 -0
  1687. package/docs/zh-CN/platforms/android.md +155 -0
  1688. package/docs/zh-CN/platforms/digitalocean.md +273 -0
  1689. package/docs/zh-CN/platforms/index.md +60 -0
  1690. package/docs/zh-CN/platforms/ios.md +114 -0
  1691. package/docs/zh-CN/platforms/linux.md +100 -0
  1692. package/docs/zh-CN/platforms/mac/bundled-gateway.md +75 -0
  1693. package/docs/zh-CN/platforms/mac/canvas.md +128 -0
  1694. package/docs/zh-CN/platforms/mac/child-process.md +73 -0
  1695. package/docs/zh-CN/platforms/mac/dev-setup.md +109 -0
  1696. package/docs/zh-CN/platforms/mac/health.md +41 -0
  1697. package/docs/zh-CN/platforms/mac/icon.md +38 -0
  1698. package/docs/zh-CN/platforms/mac/logging.md +64 -0
  1699. package/docs/zh-CN/platforms/mac/menu-bar.md +88 -0
  1700. package/docs/zh-CN/platforms/mac/peekaboo.md +62 -0
  1701. package/docs/zh-CN/platforms/mac/permissions.md +46 -0
  1702. package/docs/zh-CN/platforms/mac/remote.md +90 -0
  1703. package/docs/zh-CN/platforms/mac/signing.md +54 -0
  1704. package/docs/zh-CN/platforms/mac/skills.md +40 -0
  1705. package/docs/zh-CN/platforms/mac/voice-overlay.md +67 -0
  1706. package/docs/zh-CN/platforms/mac/voicewake.md +74 -0
  1707. package/docs/zh-CN/platforms/mac/webchat.md +43 -0
  1708. package/docs/zh-CN/platforms/mac/xpc.md +68 -0
  1709. package/docs/zh-CN/platforms/macos.md +193 -0
  1710. package/docs/zh-CN/platforms/oracle.md +310 -0
  1711. package/docs/zh-CN/platforms/raspberry-pi.md +416 -0
  1712. package/docs/zh-CN/platforms/windows.md +247 -0
  1713. package/docs/zh-CN/plugins/agent-tools.md +99 -0
  1714. package/docs/zh-CN/plugins/manifest.md +68 -0
  1715. package/docs/zh-CN/plugins/voice-call.md +250 -0
  1716. package/docs/zh-CN/plugins/zalouser.md +88 -0
  1717. package/docs/zh-CN/prose.md +141 -0
  1718. package/docs/zh-CN/providers/anthropic.md +265 -0
  1719. package/docs/zh-CN/providers/bedrock.md +170 -0
  1720. package/docs/zh-CN/providers/claude-max-api-proxy.md +155 -0
  1721. package/docs/zh-CN/providers/cloudflare-ai-gateway.md +78 -0
  1722. package/docs/zh-CN/providers/deepgram.md +97 -0
  1723. package/docs/zh-CN/providers/github-copilot.md +67 -0
  1724. package/docs/zh-CN/providers/glm.md +50 -0
  1725. package/docs/zh-CN/providers/huggingface.md +216 -0
  1726. package/docs/zh-CN/providers/index.md +69 -0
  1727. package/docs/zh-CN/providers/kilocode.md +80 -0
  1728. package/docs/zh-CN/providers/litellm.md +160 -0
  1729. package/docs/zh-CN/providers/minimax.md +222 -0
  1730. package/docs/zh-CN/providers/mistral.md +61 -0
  1731. package/docs/zh-CN/providers/models.md +51 -0
  1732. package/docs/zh-CN/providers/moonshot.md +182 -0
  1733. package/docs/zh-CN/providers/nvidia.md +62 -0
  1734. package/docs/zh-CN/providers/ollama.md +359 -0
  1735. package/docs/zh-CN/providers/openai.md +308 -0
  1736. package/docs/zh-CN/providers/opencode-go.md +52 -0
  1737. package/docs/zh-CN/providers/opencode.md +71 -0
  1738. package/docs/zh-CN/providers/openrouter.md +44 -0
  1739. package/docs/zh-CN/providers/qianfan.md +45 -0
  1740. package/docs/zh-CN/providers/qwen.md +55 -0
  1741. package/docs/zh-CN/providers/sglang.md +111 -0
  1742. package/docs/zh-CN/providers/synthetic.md +106 -0
  1743. package/docs/zh-CN/providers/together.md +72 -0
  1744. package/docs/zh-CN/providers/venice.md +289 -0
  1745. package/docs/zh-CN/providers/vercel-ai-gateway.md +66 -0
  1746. package/docs/zh-CN/providers/xiaomi.md +93 -0
  1747. package/docs/zh-CN/providers/zai.md +53 -0
  1748. package/docs/zh-CN/reference/AGENTS.default.md +131 -0
  1749. package/docs/zh-CN/reference/RELEASING.md +48 -0
  1750. package/docs/zh-CN/reference/api-usage-costs.md +141 -0
  1751. package/docs/zh-CN/reference/credits.md +34 -0
  1752. package/docs/zh-CN/reference/device-models.md +54 -0
  1753. package/docs/zh-CN/reference/rpc.md +48 -0
  1754. package/docs/zh-CN/reference/session-management-compaction.md +287 -0
  1755. package/docs/zh-CN/reference/templates/AGENTS.dev.md +89 -0
  1756. package/docs/zh-CN/reference/templates/AGENTS.md +225 -0
  1757. package/docs/zh-CN/reference/templates/BOOT.md +17 -0
  1758. package/docs/zh-CN/reference/templates/BOOTSTRAP.md +68 -0
  1759. package/docs/zh-CN/reference/templates/HEARTBEAT.md +18 -0
  1760. package/docs/zh-CN/reference/templates/IDENTITY.dev.md +54 -0
  1761. package/docs/zh-CN/reference/templates/IDENTITY.md +36 -0
  1762. package/docs/zh-CN/reference/templates/SOUL.dev.md +83 -0
  1763. package/docs/zh-CN/reference/templates/SOUL.md +49 -0
  1764. package/docs/zh-CN/reference/templates/TOOLS.dev.md +31 -0
  1765. package/docs/zh-CN/reference/templates/TOOLS.md +53 -0
  1766. package/docs/zh-CN/reference/templates/USER.dev.md +25 -0
  1767. package/docs/zh-CN/reference/templates/USER.md +30 -0
  1768. package/docs/zh-CN/reference/test.md +57 -0
  1769. package/docs/zh-CN/reference/token-use.md +119 -0
  1770. package/docs/zh-CN/reference/transcript-hygiene.md +109 -0
  1771. package/docs/zh-CN/reference/wizard.md +242 -0
  1772. package/docs/zh-CN/security/formal-verification.md +171 -0
  1773. package/docs/zh-CN/start/bootstrapping.md +9 -0
  1774. package/docs/zh-CN/start/docs-directory.md +70 -0
  1775. package/docs/zh-CN/start/getting-started.md +143 -0
  1776. package/docs/zh-CN/start/hubs.md +194 -0
  1777. package/docs/zh-CN/start/lore.md +226 -0
  1778. package/docs/zh-CN/start/onboarding-overview.md +58 -0
  1779. package/docs/zh-CN/start/onboarding.md +105 -0
  1780. package/docs/zh-CN/start/openclaw.md +248 -0
  1781. package/docs/zh-CN/start/quickstart.md +88 -0
  1782. package/docs/zh-CN/start/setup.md +153 -0
  1783. package/docs/zh-CN/start/showcase.md +423 -0
  1784. package/docs/zh-CN/start/wizard-cli-automation.md +222 -0
  1785. package/docs/zh-CN/start/wizard-cli-reference.md +306 -0
  1786. package/docs/zh-CN/start/wizard.md +132 -0
  1787. package/docs/zh-CN/tools/agent-send.md +59 -0
  1788. package/docs/zh-CN/tools/apply-patch.md +57 -0
  1789. package/docs/zh-CN/tools/browser-linux-troubleshooting.md +144 -0
  1790. package/docs/zh-CN/tools/browser-login.md +75 -0
  1791. package/docs/zh-CN/tools/browser.md +553 -0
  1792. package/docs/zh-CN/tools/chrome-extension.md +183 -0
  1793. package/docs/zh-CN/tools/clawhub.md +209 -0
  1794. package/docs/zh-CN/tools/creating-skills.md +61 -0
  1795. package/docs/zh-CN/tools/elevated.md +64 -0
  1796. package/docs/zh-CN/tools/exec-approvals.md +234 -0
  1797. package/docs/zh-CN/tools/exec.md +169 -0
  1798. package/docs/zh-CN/tools/firecrawl.md +68 -0
  1799. package/docs/zh-CN/tools/index.md +515 -0
  1800. package/docs/zh-CN/tools/llm-task.md +117 -0
  1801. package/docs/zh-CN/tools/lobster.md +349 -0
  1802. package/docs/zh-CN/tools/multi-agent-sandbox-tools.md +401 -0
  1803. package/docs/zh-CN/tools/plugin.md +1612 -0
  1804. package/docs/zh-CN/tools/reactions.md +29 -0
  1805. package/docs/zh-CN/tools/skills-config.md +78 -0
  1806. package/docs/zh-CN/tools/skills.md +279 -0
  1807. package/docs/zh-CN/tools/slash-commands.md +205 -0
  1808. package/docs/zh-CN/tools/subagents.md +167 -0
  1809. package/docs/zh-CN/tools/thinking.md +80 -0
  1810. package/docs/zh-CN/tools/web.md +289 -0
  1811. package/docs/zh-CN/tts.md +375 -0
  1812. package/docs/zh-CN/vps.md +47 -0
  1813. package/docs/zh-CN/web/control-ui.md +191 -0
  1814. package/docs/zh-CN/web/dashboard.md +53 -0
  1815. package/docs/zh-CN/web/index.md +118 -0
  1816. package/docs/zh-CN/web/tui.md +166 -0
  1817. package/docs/zh-CN/web/webchat.md +56 -0
  1818. package/openclaw.mjs +135 -0
  1819. package/package.json +835 -0
  1820. package/skills/1password/SKILL.md +70 -0
  1821. package/skills/1password/references/cli-examples.md +29 -0
  1822. package/skills/1password/references/get-started.md +17 -0
  1823. package/skills/apple-notes/SKILL.md +77 -0
  1824. package/skills/apple-reminders/SKILL.md +118 -0
  1825. package/skills/bear-notes/SKILL.md +107 -0
  1826. package/skills/blogwatcher/SKILL.md +69 -0
  1827. package/skills/blucli/SKILL.md +47 -0
  1828. package/skills/bluebubbles/SKILL.md +131 -0
  1829. package/skills/camsnap/SKILL.md +45 -0
  1830. package/skills/canvas/SKILL.md +198 -0
  1831. package/skills/clawhub/SKILL.md +77 -0
  1832. package/skills/coding-agent/SKILL.md +295 -0
  1833. package/skills/discord/SKILL.md +197 -0
  1834. package/skills/doubao-code/SKILL.md +43 -0
  1835. package/skills/eightctl/SKILL.md +50 -0
  1836. package/skills/gemini/SKILL.md +43 -0
  1837. package/skills/gh-issues/SKILL.md +865 -0
  1838. package/skills/gifgrep/SKILL.md +79 -0
  1839. package/skills/github/SKILL.md +163 -0
  1840. package/skills/gog/SKILL.md +116 -0
  1841. package/skills/goplaces/SKILL.md +52 -0
  1842. package/skills/healthcheck/SKILL.md +245 -0
  1843. package/skills/himalaya/SKILL.md +257 -0
  1844. package/skills/himalaya/references/configuration.md +184 -0
  1845. package/skills/himalaya/references/message-composition.md +199 -0
  1846. package/skills/imsg/SKILL.md +122 -0
  1847. package/skills/kimi-code/SKILL.md +42 -0
  1848. package/skills/mcporter/SKILL.md +61 -0
  1849. package/skills/model-usage/SKILL.md +69 -0
  1850. package/skills/model-usage/references/codexbar-cli.md +33 -0
  1851. package/skills/model-usage/scripts/model_usage.py +320 -0
  1852. package/skills/model-usage/scripts/test_model_usage.py +40 -0
  1853. package/skills/nano-pdf/SKILL.md +38 -0
  1854. package/skills/node-connect/SKILL.md +142 -0
  1855. package/skills/notion/SKILL.md +174 -0
  1856. package/skills/obsidian/SKILL.md +81 -0
  1857. package/skills/openai-image-gen/SKILL.md +92 -0
  1858. package/skills/openai-image-gen/scripts/gen.py +328 -0
  1859. package/skills/openai-image-gen/scripts/test_gen.py +140 -0
  1860. package/skills/openai-whisper/SKILL.md +38 -0
  1861. package/skills/openai-whisper-api/SKILL.md +52 -0
  1862. package/skills/openai-whisper-api/scripts/transcribe.sh +85 -0
  1863. package/skills/openhue/SKILL.md +112 -0
  1864. package/skills/oracle/SKILL.md +125 -0
  1865. package/skills/ordercli/SKILL.md +78 -0
  1866. package/skills/peekaboo/SKILL.md +190 -0
  1867. package/skills/sag/SKILL.md +87 -0
  1868. package/skills/session-logs/SKILL.md +115 -0
  1869. package/skills/sherpa-onnx-tts/SKILL.md +103 -0
  1870. package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
  1871. package/skills/skill-creator/SKILL.md +372 -0
  1872. package/skills/skill-creator/license.txt +202 -0
  1873. package/skills/skill-creator/scripts/init_skill.py +378 -0
  1874. package/skills/skill-creator/scripts/package_skill.py +139 -0
  1875. package/skills/skill-creator/scripts/quick_validate.py +159 -0
  1876. package/skills/skill-creator/scripts/test_package_skill.py +160 -0
  1877. package/skills/skill-creator/scripts/test_quick_validate.py +72 -0
  1878. package/skills/slack/SKILL.md +144 -0
  1879. package/skills/songsee/SKILL.md +49 -0
  1880. package/skills/sonoscli/SKILL.md +65 -0
  1881. package/skills/spotify-player/SKILL.md +64 -0
  1882. package/skills/summarize/SKILL.md +87 -0
  1883. package/skills/things-mac/SKILL.md +86 -0
  1884. package/skills/tmux/SKILL.md +153 -0
  1885. package/skills/tmux/scripts/find-sessions.sh +112 -0
  1886. package/skills/tmux/scripts/wait-for-text.sh +83 -0
  1887. package/skills/trello/SKILL.md +95 -0
  1888. package/skills/video-frames/SKILL.md +46 -0
  1889. package/skills/video-frames/scripts/frame.sh +81 -0
  1890. package/skills/voice-call/SKILL.md +45 -0
  1891. package/skills/wacli/SKILL.md +72 -0
  1892. package/skills/weather/SKILL.md +112 -0
  1893. package/skills/xurl/SKILL.md +461 -0
@@ -0,0 +1,3838 @@
1
+ import { i as visibleWidth, r as stripAnsi$1 } from "./ansi-BEJF8NKS.js";
2
+ import { d as normalizeUsageDisplay, p as resolveResponseUsageMode } from "./thinking.shared-CncvRHts.js";
3
+ import { S as parseAgentSessionKey, c as normalizeAgentId, l as normalizeMainKey, r as buildAgentMainSessionKey } from "./session-key-gFFk3uv9.js";
4
+ import { c as resolveAgentIdByWorkspacePath, m as resolveDefaultAgentId } from "./agent-scope-DPP4Z_UU.js";
5
+ import { s as loadConfig } from "./io-jOnQRia2.js";
6
+ import { n as VERSION } from "./version-DCY9_obP.js";
7
+ import { a as hasConfiguredSecretInput } from "./types.secrets-BWSeXrF4.js";
8
+ import { t as assertExplicitGatewayAuthModeWhenBothConfigured } from "./auth-mode-policy-DywddkT-.js";
9
+ import { f as GATEWAY_CLIENT_CAPS, h as GATEWAY_CLIENT_NAMES, m as GATEWAY_CLIENT_MODES } from "./message-channel-Cy-gN4K2.js";
10
+ import { u as GatewayClient } from "./method-scopes-DgypDW23.js";
11
+ import { c as resolveExplicitGatewayAuth, o as ensureExplicitGatewayAuth, t as buildGatewayConnectionDetails } from "./call-BmLt3xO1.js";
12
+ import { $p as formatToolDetail, Uo as stripLeadingInboundMetadata, em as resolveToolDisplay, sd as formatTokenCount, tm as formatRawAssistantErrorForUi } from "./pi-embedded-CSQySvOV.js";
13
+ import { n as listThinkingLevelLabels, t as formatThinkingLevels } from "./thinking-BBD_0HSp.js";
14
+ import { Y as resolveConfiguredSecretInputString } from "./routes-TpLEcKO8.js";
15
+ import { c as listChatCommands, l as listChatCommandsForConfig } from "./commands-registry-ChCep1KJ.js";
16
+ import { n as formatTimeAgo, t as formatRelativeTimestamp } from "./format-relative-C3nDxnXz.js";
17
+ import { spawn } from "node:child_process";
18
+ import chalk from "chalk";
19
+ import { randomUUID } from "node:crypto";
20
+ import { Box, CombinedAutocompleteProvider, Container, Editor, Input, Key, Loader, Markdown, ProcessTerminal, SelectList, SettingsList, Spacer, TUI, Text, getEditorKeybindings, isKeyRelease, matchesKey, truncateToWidth } from "@mariozechner/pi-tui";
21
+ import { highlight, supportsLanguage } from "cli-highlight";
22
+ //#region src/tui/commands.ts
23
+ const VERBOSE_LEVELS = ["on", "off"];
24
+ const FAST_LEVELS = [
25
+ "status",
26
+ "on",
27
+ "off"
28
+ ];
29
+ const REASONING_LEVELS = ["on", "off"];
30
+ const ELEVATED_LEVELS = [
31
+ "on",
32
+ "off",
33
+ "ask",
34
+ "full"
35
+ ];
36
+ const ACTIVATION_LEVELS = ["mention", "always"];
37
+ const USAGE_FOOTER_LEVELS = [
38
+ "off",
39
+ "tokens",
40
+ "full"
41
+ ];
42
+ const COMMAND_ALIASES = { elev: "elevated" };
43
+ function createLevelCompletion(levels) {
44
+ return (prefix) => levels.filter((value) => value.startsWith(prefix.toLowerCase())).map((value) => ({
45
+ value,
46
+ label: value
47
+ }));
48
+ }
49
+ function parseCommand(input) {
50
+ const trimmed = input.replace(/^\//, "").trim();
51
+ if (!trimmed) return {
52
+ name: "",
53
+ args: ""
54
+ };
55
+ const [name, ...rest] = trimmed.split(/\s+/);
56
+ const normalized = name.toLowerCase();
57
+ return {
58
+ name: COMMAND_ALIASES[normalized] ?? normalized,
59
+ args: rest.join(" ").trim()
60
+ };
61
+ }
62
+ function getSlashCommands(options = {}) {
63
+ const thinkLevels = listThinkingLevelLabels(options.provider, options.model);
64
+ const verboseCompletions = createLevelCompletion(VERBOSE_LEVELS);
65
+ const fastCompletions = createLevelCompletion(FAST_LEVELS);
66
+ const reasoningCompletions = createLevelCompletion(REASONING_LEVELS);
67
+ const usageCompletions = createLevelCompletion(USAGE_FOOTER_LEVELS);
68
+ const elevatedCompletions = createLevelCompletion(ELEVATED_LEVELS);
69
+ const activationCompletions = createLevelCompletion(ACTIVATION_LEVELS);
70
+ const commands = [
71
+ {
72
+ name: "help",
73
+ description: "Show slash command help"
74
+ },
75
+ {
76
+ name: "status",
77
+ description: "Show gateway status summary"
78
+ },
79
+ {
80
+ name: "agent",
81
+ description: "Switch agent (or open picker)"
82
+ },
83
+ {
84
+ name: "agents",
85
+ description: "Open agent picker"
86
+ },
87
+ {
88
+ name: "session",
89
+ description: "Switch session (or open picker)"
90
+ },
91
+ {
92
+ name: "sessions",
93
+ description: "Open session picker"
94
+ },
95
+ {
96
+ name: "model",
97
+ description: "Set model (or open picker)"
98
+ },
99
+ {
100
+ name: "models",
101
+ description: "Open model picker"
102
+ },
103
+ {
104
+ name: "think",
105
+ description: "Set thinking level",
106
+ getArgumentCompletions: (prefix) => thinkLevels.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
107
+ value,
108
+ label: value
109
+ }))
110
+ },
111
+ {
112
+ name: "fast",
113
+ description: "Set fast mode on/off",
114
+ getArgumentCompletions: fastCompletions
115
+ },
116
+ {
117
+ name: "verbose",
118
+ description: "Set verbose on/off",
119
+ getArgumentCompletions: verboseCompletions
120
+ },
121
+ {
122
+ name: "reasoning",
123
+ description: "Set reasoning on/off",
124
+ getArgumentCompletions: reasoningCompletions
125
+ },
126
+ {
127
+ name: "usage",
128
+ description: "Toggle per-response usage line",
129
+ getArgumentCompletions: usageCompletions
130
+ },
131
+ {
132
+ name: "elevated",
133
+ description: "Set elevated on/off/ask/full",
134
+ getArgumentCompletions: elevatedCompletions
135
+ },
136
+ {
137
+ name: "elev",
138
+ description: "Alias for /elevated",
139
+ getArgumentCompletions: elevatedCompletions
140
+ },
141
+ {
142
+ name: "activation",
143
+ description: "Set group activation",
144
+ getArgumentCompletions: activationCompletions
145
+ },
146
+ {
147
+ name: "abort",
148
+ description: "Abort active run"
149
+ },
150
+ {
151
+ name: "new",
152
+ description: "Reset the session"
153
+ },
154
+ {
155
+ name: "reset",
156
+ description: "Reset the session"
157
+ },
158
+ {
159
+ name: "settings",
160
+ description: "Open settings"
161
+ },
162
+ {
163
+ name: "exit",
164
+ description: "Exit the TUI"
165
+ },
166
+ {
167
+ name: "quit",
168
+ description: "Exit the TUI"
169
+ }
170
+ ];
171
+ const seen = new Set(commands.map((command) => command.name));
172
+ const gatewayCommands = options.cfg ? listChatCommandsForConfig(options.cfg) : listChatCommands();
173
+ for (const command of gatewayCommands) {
174
+ const aliases = command.textAliases.length > 0 ? command.textAliases : [`/${command.key}`];
175
+ for (const alias of aliases) {
176
+ const name = alias.replace(/^\//, "").trim();
177
+ if (!name || seen.has(name)) continue;
178
+ seen.add(name);
179
+ commands.push({
180
+ name,
181
+ description: command.description
182
+ });
183
+ }
184
+ }
185
+ return commands;
186
+ }
187
+ function helpText(options = {}) {
188
+ return [
189
+ "Slash commands:",
190
+ "/help",
191
+ "/commands",
192
+ "/status",
193
+ "/agent <id> (or /agents)",
194
+ "/session <key> (or /sessions)",
195
+ "/model <provider/model> (or /models)",
196
+ `/think <${formatThinkingLevels(options.provider, options.model, "|")}>`,
197
+ "/fast <status|on|off>",
198
+ "/verbose <on|off>",
199
+ "/reasoning <on|off>",
200
+ "/usage <off|tokens|full>",
201
+ "/elevated <on|off|ask|full>",
202
+ "/elev <on|off|ask|full>",
203
+ "/activation <mention|always>",
204
+ "/new or /reset",
205
+ "/abort",
206
+ "/settings",
207
+ "/exit"
208
+ ].join("\n");
209
+ }
210
+ //#endregion
211
+ //#region src/tui/theme/syntax-theme.ts
212
+ /**
213
+ * Syntax highlighting theme for code blocks.
214
+ * Uses chalk functions to style different token types.
215
+ */
216
+ function createSyntaxTheme(fallback, light = false) {
217
+ if (light) return {
218
+ keyword: chalk.hex("#AF00DB"),
219
+ built_in: chalk.hex("#267F99"),
220
+ type: chalk.hex("#267F99"),
221
+ literal: chalk.hex("#0000FF"),
222
+ number: chalk.hex("#098658"),
223
+ string: chalk.hex("#A31515"),
224
+ regexp: chalk.hex("#811F3F"),
225
+ symbol: chalk.hex("#098658"),
226
+ class: chalk.hex("#267F99"),
227
+ function: chalk.hex("#795E26"),
228
+ title: chalk.hex("#795E26"),
229
+ params: chalk.hex("#001080"),
230
+ comment: chalk.hex("#008000"),
231
+ doctag: chalk.hex("#008000"),
232
+ meta: chalk.hex("#001080"),
233
+ "meta-keyword": chalk.hex("#AF00DB"),
234
+ "meta-string": chalk.hex("#A31515"),
235
+ section: chalk.hex("#795E26"),
236
+ tag: chalk.hex("#800000"),
237
+ name: chalk.hex("#001080"),
238
+ attr: chalk.hex("#C50000"),
239
+ attribute: chalk.hex("#C50000"),
240
+ variable: chalk.hex("#001080"),
241
+ bullet: chalk.hex("#795E26"),
242
+ code: chalk.hex("#A31515"),
243
+ emphasis: chalk.italic,
244
+ strong: chalk.bold,
245
+ formula: chalk.hex("#AF00DB"),
246
+ link: chalk.hex("#267F99"),
247
+ quote: chalk.hex("#008000"),
248
+ addition: chalk.hex("#098658"),
249
+ deletion: chalk.hex("#A31515"),
250
+ "selector-tag": chalk.hex("#800000"),
251
+ "selector-id": chalk.hex("#800000"),
252
+ "selector-class": chalk.hex("#800000"),
253
+ "selector-attr": chalk.hex("#800000"),
254
+ "selector-pseudo": chalk.hex("#800000"),
255
+ "template-tag": chalk.hex("#AF00DB"),
256
+ "template-variable": chalk.hex("#001080"),
257
+ default: fallback
258
+ };
259
+ return {
260
+ keyword: chalk.hex("#C586C0"),
261
+ built_in: chalk.hex("#4EC9B0"),
262
+ type: chalk.hex("#4EC9B0"),
263
+ literal: chalk.hex("#569CD6"),
264
+ number: chalk.hex("#B5CEA8"),
265
+ string: chalk.hex("#CE9178"),
266
+ regexp: chalk.hex("#D16969"),
267
+ symbol: chalk.hex("#B5CEA8"),
268
+ class: chalk.hex("#4EC9B0"),
269
+ function: chalk.hex("#DCDCAA"),
270
+ title: chalk.hex("#DCDCAA"),
271
+ params: chalk.hex("#9CDCFE"),
272
+ comment: chalk.hex("#6A9955"),
273
+ doctag: chalk.hex("#608B4E"),
274
+ meta: chalk.hex("#9CDCFE"),
275
+ "meta-keyword": chalk.hex("#C586C0"),
276
+ "meta-string": chalk.hex("#CE9178"),
277
+ section: chalk.hex("#DCDCAA"),
278
+ tag: chalk.hex("#569CD6"),
279
+ name: chalk.hex("#9CDCFE"),
280
+ attr: chalk.hex("#9CDCFE"),
281
+ attribute: chalk.hex("#9CDCFE"),
282
+ variable: chalk.hex("#9CDCFE"),
283
+ bullet: chalk.hex("#D7BA7D"),
284
+ code: chalk.hex("#CE9178"),
285
+ emphasis: chalk.italic,
286
+ strong: chalk.bold,
287
+ formula: chalk.hex("#C586C0"),
288
+ link: chalk.hex("#4EC9B0"),
289
+ quote: chalk.hex("#6A9955"),
290
+ addition: chalk.hex("#B5CEA8"),
291
+ deletion: chalk.hex("#F44747"),
292
+ "selector-tag": chalk.hex("#D7BA7D"),
293
+ "selector-id": chalk.hex("#D7BA7D"),
294
+ "selector-class": chalk.hex("#D7BA7D"),
295
+ "selector-attr": chalk.hex("#D7BA7D"),
296
+ "selector-pseudo": chalk.hex("#D7BA7D"),
297
+ "template-tag": chalk.hex("#C586C0"),
298
+ "template-variable": chalk.hex("#9CDCFE"),
299
+ default: fallback
300
+ };
301
+ }
302
+ //#endregion
303
+ //#region src/tui/theme/theme.ts
304
+ const DARK_TEXT = "#E8E3D5";
305
+ const LIGHT_TEXT = "#1E1E1E";
306
+ const XTERM_LEVELS = [
307
+ 0,
308
+ 95,
309
+ 135,
310
+ 175,
311
+ 215,
312
+ 255
313
+ ];
314
+ function channelToSrgb(value) {
315
+ const normalized = value / 255;
316
+ return normalized <= .03928 ? normalized / 12.92 : ((normalized + .055) / 1.055) ** 2.4;
317
+ }
318
+ function relativeLuminanceRgb(r, g, b) {
319
+ const red = channelToSrgb(r);
320
+ const green = channelToSrgb(g);
321
+ const blue = channelToSrgb(b);
322
+ return .2126 * red + .7152 * green + .0722 * blue;
323
+ }
324
+ function relativeLuminanceHex(hex) {
325
+ return relativeLuminanceRgb(Number.parseInt(hex.slice(1, 3), 16), Number.parseInt(hex.slice(3, 5), 16), Number.parseInt(hex.slice(5, 7), 16));
326
+ }
327
+ function contrastRatio(background, foregroundHex) {
328
+ const foreground = relativeLuminanceHex(foregroundHex);
329
+ const lighter = Math.max(background, foreground);
330
+ const darker = Math.min(background, foreground);
331
+ return (lighter + .05) / (darker + .05);
332
+ }
333
+ function pickHigherContrastText(r, g, b) {
334
+ const background = relativeLuminanceRgb(r, g, b);
335
+ return contrastRatio(background, LIGHT_TEXT) >= contrastRatio(background, DARK_TEXT);
336
+ }
337
+ function isLightBackground() {
338
+ const explicit = process.env.OPENCLAW_THEME?.toLowerCase();
339
+ if (explicit === "light") return true;
340
+ if (explicit === "dark") return false;
341
+ const colorfgbg = process.env.COLORFGBG;
342
+ if (colorfgbg && colorfgbg.length <= 64) {
343
+ const sep = colorfgbg.lastIndexOf(";");
344
+ const bg = Number.parseInt(sep >= 0 ? colorfgbg.slice(sep + 1) : colorfgbg, 10);
345
+ if (bg >= 0 && bg <= 255) {
346
+ if (bg <= 15) return bg === 7 || bg === 15;
347
+ if (bg >= 232) return bg >= 244;
348
+ const cubeIndex = bg - 16;
349
+ const bVal = XTERM_LEVELS[cubeIndex % 6];
350
+ const gVal = XTERM_LEVELS[Math.floor(cubeIndex / 6) % 6];
351
+ const rVal = XTERM_LEVELS[Math.floor(cubeIndex / 36)];
352
+ return pickHigherContrastText(rVal, gVal, bVal);
353
+ }
354
+ }
355
+ return false;
356
+ }
357
+ /** Whether the terminal has a light background. Exported for testing only. */
358
+ const lightMode = isLightBackground();
359
+ const palette = lightMode ? {
360
+ text: "#1E1E1E",
361
+ dim: "#5B6472",
362
+ accent: "#B45309",
363
+ accentSoft: "#C2410C",
364
+ border: "#5B6472",
365
+ userBg: "#F3F0E8",
366
+ userText: "#1E1E1E",
367
+ systemText: "#4B5563",
368
+ toolPendingBg: "#EFF6FF",
369
+ toolSuccessBg: "#ECFDF5",
370
+ toolErrorBg: "#FEF2F2",
371
+ toolTitle: "#B45309",
372
+ toolOutput: "#374151",
373
+ quote: "#1D4ED8",
374
+ quoteBorder: "#2563EB",
375
+ code: "#92400E",
376
+ codeBlock: "#F9FAFB",
377
+ codeBorder: "#92400E",
378
+ link: "#047857",
379
+ error: "#DC2626",
380
+ success: "#047857"
381
+ } : {
382
+ text: "#E8E3D5",
383
+ dim: "#7B7F87",
384
+ accent: "#F6C453",
385
+ accentSoft: "#F2A65A",
386
+ border: "#3C414B",
387
+ userBg: "#2B2F36",
388
+ userText: "#F3EEE0",
389
+ systemText: "#9BA3B2",
390
+ toolPendingBg: "#1F2A2F",
391
+ toolSuccessBg: "#1E2D23",
392
+ toolErrorBg: "#2F1F1F",
393
+ toolTitle: "#F6C453",
394
+ toolOutput: "#E1DACB",
395
+ quote: "#8CC8FF",
396
+ quoteBorder: "#3B4D6B",
397
+ code: "#F0C987",
398
+ codeBlock: "#1E232A",
399
+ codeBorder: "#343A45",
400
+ link: "#7DD3A5",
401
+ error: "#F97066",
402
+ success: "#7DD3A5"
403
+ };
404
+ const fg = (hex) => (text) => chalk.hex(hex)(text);
405
+ const bg = (hex) => (text) => chalk.bgHex(hex)(text);
406
+ const syntaxTheme = createSyntaxTheme(fg(palette.code), lightMode);
407
+ /**
408
+ * Highlight code with syntax coloring.
409
+ * Returns an array of lines with ANSI escape codes.
410
+ */
411
+ function highlightCode(code, lang) {
412
+ try {
413
+ return highlight(code, {
414
+ language: lang && supportsLanguage(lang) ? lang : void 0,
415
+ theme: syntaxTheme,
416
+ ignoreIllegals: true
417
+ }).split("\n");
418
+ } catch {
419
+ return code.split("\n").map((line) => fg(palette.code)(line));
420
+ }
421
+ }
422
+ const theme = {
423
+ fg: fg(palette.text),
424
+ assistantText: (text) => text,
425
+ dim: fg(palette.dim),
426
+ accent: fg(palette.accent),
427
+ accentSoft: fg(palette.accentSoft),
428
+ success: fg(palette.success),
429
+ error: fg(palette.error),
430
+ header: (text) => chalk.bold(fg(palette.accent)(text)),
431
+ system: fg(palette.systemText),
432
+ userBg: bg(palette.userBg),
433
+ userText: fg(palette.userText),
434
+ toolTitle: fg(palette.toolTitle),
435
+ toolOutput: fg(palette.toolOutput),
436
+ toolPendingBg: bg(palette.toolPendingBg),
437
+ toolSuccessBg: bg(palette.toolSuccessBg),
438
+ toolErrorBg: bg(palette.toolErrorBg),
439
+ border: fg(palette.border),
440
+ bold: (text) => chalk.bold(text),
441
+ italic: (text) => chalk.italic(text)
442
+ };
443
+ const markdownTheme = {
444
+ heading: (text) => chalk.bold(fg(palette.accent)(text)),
445
+ link: (text) => fg(palette.link)(text),
446
+ linkUrl: (text) => chalk.dim(text),
447
+ code: (text) => fg(palette.code)(text),
448
+ codeBlock: (text) => fg(palette.code)(text),
449
+ codeBlockBorder: (text) => fg(palette.codeBorder)(text),
450
+ quote: (text) => fg(palette.quote)(text),
451
+ quoteBorder: (text) => fg(palette.quoteBorder)(text),
452
+ hr: (text) => fg(palette.border)(text),
453
+ listBullet: (text) => fg(palette.accentSoft)(text),
454
+ bold: (text) => chalk.bold(text),
455
+ italic: (text) => chalk.italic(text),
456
+ strikethrough: (text) => chalk.strikethrough(text),
457
+ underline: (text) => chalk.underline(text),
458
+ highlightCode
459
+ };
460
+ const baseSelectListTheme = {
461
+ selectedPrefix: (text) => fg(palette.accent)(text),
462
+ selectedText: (text) => chalk.bold(fg(palette.accent)(text)),
463
+ description: (text) => fg(palette.dim)(text),
464
+ scrollInfo: (text) => fg(palette.dim)(text),
465
+ noMatch: (text) => fg(palette.dim)(text)
466
+ };
467
+ const selectListTheme = baseSelectListTheme;
468
+ const filterableSelectListTheme = {
469
+ ...baseSelectListTheme,
470
+ filterLabel: (text) => fg(palette.dim)(text)
471
+ };
472
+ const settingsListTheme = {
473
+ label: (text, selected) => selected ? chalk.bold(fg(palette.accent)(text)) : fg(palette.text)(text),
474
+ value: (text, selected) => selected ? fg(palette.accentSoft)(text) : fg(palette.dim)(text),
475
+ description: (text) => fg(palette.systemText)(text),
476
+ cursor: fg(palette.accent)("→ "),
477
+ hint: (text) => fg(palette.dim)(text)
478
+ };
479
+ const editorTheme = {
480
+ borderColor: (text) => fg(palette.border)(text),
481
+ selectList: selectListTheme
482
+ };
483
+ const searchableSelectListTheme = {
484
+ ...baseSelectListTheme,
485
+ searchPrompt: (text) => fg(palette.accentSoft)(text),
486
+ searchInput: (text) => fg(palette.text)(text),
487
+ matchHighlight: (text) => chalk.bold(fg(palette.accent)(text))
488
+ };
489
+ //#endregion
490
+ //#region src/tui/osc8-hyperlinks.ts
491
+ const SGR_PATTERN = "\\x1b\\[[0-9;]*m";
492
+ const OSC8_PATTERN = "\\x1b\\]8;;.*?(?:\\x07|\\x1b\\\\)";
493
+ const ANSI_RE = new RegExp(`${SGR_PATTERN}|${OSC8_PATTERN}`, "g");
494
+ const SGR_START_RE = new RegExp(`^${SGR_PATTERN}`);
495
+ const OSC8_START_RE = new RegExp(`^${OSC8_PATTERN}`);
496
+ /**
497
+ * Extract all unique URLs from raw markdown text.
498
+ * Finds both bare URLs and markdown link hrefs [text](url).
499
+ */
500
+ function extractUrls(markdown) {
501
+ const urls = /* @__PURE__ */ new Set();
502
+ const mdLinkRe = /\[(?:[^\]]*)\]\(\s*<?(https?:\/\/[^)\s>]+)>?(?:\s+["'][^"']*["'])?\s*\)/g;
503
+ let m;
504
+ while ((m = mdLinkRe.exec(markdown)) !== null) urls.add(m[1]);
505
+ const stripped = markdown.replace(/\[(?:[^\]]*)\]\(\s*<?https?:\/\/[^)\s>]+>?(?:\s+["'][^"']*["'])?\s*\)/g, "");
506
+ const bareRe = /https?:\/\/[^\s)\]>]+/g;
507
+ while ((m = bareRe.exec(stripped)) !== null) urls.add(m[0]);
508
+ return [...urls];
509
+ }
510
+ /** Strip ANSI SGR and OSC 8 sequences to get visible text. */
511
+ function stripAnsi(input) {
512
+ return input.replace(ANSI_RE, "");
513
+ }
514
+ /**
515
+ * Find URL ranges in a line's visible text, handling cross-line URL splits.
516
+ */
517
+ function findUrlRanges(visibleText, knownUrls, pending) {
518
+ const ranges = [];
519
+ let newPending = null;
520
+ let searchFrom = 0;
521
+ if (pending) {
522
+ const remaining = pending.url.slice(pending.consumed);
523
+ const trimmed = visibleText.trimStart();
524
+ const leadingSpaces = visibleText.length - trimmed.length;
525
+ let matchLen = 0;
526
+ for (let j = 0; j < remaining.length && j < trimmed.length; j++) if (remaining[j] === trimmed[j]) matchLen++;
527
+ else break;
528
+ if (matchLen > 0) {
529
+ ranges.push({
530
+ start: leadingSpaces,
531
+ end: leadingSpaces + matchLen,
532
+ url: pending.url
533
+ });
534
+ searchFrom = leadingSpaces + matchLen;
535
+ if (pending.consumed + matchLen < pending.url.length) newPending = {
536
+ url: pending.url,
537
+ consumed: pending.consumed + matchLen
538
+ };
539
+ }
540
+ }
541
+ const urlRe = /https?:\/\/[^\s)\]>]+/g;
542
+ urlRe.lastIndex = searchFrom;
543
+ let match;
544
+ while ((match = urlRe.exec(visibleText)) !== null) {
545
+ const fragment = match[0];
546
+ const start = match.index;
547
+ let resolvedUrl = fragment;
548
+ let found = false;
549
+ for (const known of knownUrls) if (known === fragment) {
550
+ resolvedUrl = known;
551
+ found = true;
552
+ break;
553
+ }
554
+ if (!found) {
555
+ let bestLen = 0;
556
+ for (const known of knownUrls) if (known.startsWith(fragment) && known.length > bestLen) {
557
+ resolvedUrl = known;
558
+ bestLen = known.length;
559
+ found = true;
560
+ }
561
+ }
562
+ if (!found) {
563
+ let bestLen = 0;
564
+ for (const known of knownUrls) if (fragment.startsWith(known) && known.length > bestLen) {
565
+ resolvedUrl = known;
566
+ bestLen = known.length;
567
+ }
568
+ }
569
+ ranges.push({
570
+ start,
571
+ end: start + fragment.length,
572
+ url: resolvedUrl
573
+ });
574
+ if (resolvedUrl.length > fragment.length && resolvedUrl.startsWith(fragment)) newPending = {
575
+ url: resolvedUrl,
576
+ consumed: fragment.length
577
+ };
578
+ }
579
+ return {
580
+ ranges,
581
+ pending: newPending
582
+ };
583
+ }
584
+ /**
585
+ * Apply OSC 8 hyperlink sequences to a line based on visible-text URL ranges.
586
+ * Walks through the raw string character by character, inserting OSC 8
587
+ * open/close sequences at URL range boundaries while preserving ANSI codes.
588
+ */
589
+ function applyOsc8Ranges(line, ranges) {
590
+ if (ranges.length === 0) return line;
591
+ const urlAt = /* @__PURE__ */ new Map();
592
+ for (const r of ranges) for (let p = r.start; p < r.end; p++) urlAt.set(p, r.url);
593
+ let result = "";
594
+ let visiblePos = 0;
595
+ let activeUrl = null;
596
+ let i = 0;
597
+ while (i < line.length) {
598
+ if (line.charCodeAt(i) === 27) {
599
+ const sgr = line.slice(i).match(SGR_START_RE);
600
+ if (sgr) {
601
+ result += sgr[0];
602
+ i += sgr[0].length;
603
+ continue;
604
+ }
605
+ const osc = line.slice(i).match(OSC8_START_RE);
606
+ if (osc) {
607
+ result += osc[0];
608
+ i += osc[0].length;
609
+ continue;
610
+ }
611
+ }
612
+ const targetUrl = urlAt.get(visiblePos) ?? null;
613
+ if (targetUrl !== activeUrl) {
614
+ if (activeUrl !== null) result += "\x1B]8;;\x07";
615
+ if (targetUrl !== null) result += `\x1b]8;;${targetUrl}\x07`;
616
+ activeUrl = targetUrl;
617
+ }
618
+ result += line[i];
619
+ visiblePos++;
620
+ i++;
621
+ }
622
+ if (activeUrl !== null) result += "\x1B]8;;\x07";
623
+ return result;
624
+ }
625
+ /**
626
+ * Add OSC 8 hyperlinks to rendered lines using a pre-extracted URL list.
627
+ *
628
+ * For each line, finds URL-like substrings in the visible text, matches them
629
+ * against known URLs, and wraps each fragment with OSC 8 escape sequences.
630
+ * Handles URLs broken across multiple lines by pi-tui's word wrapping.
631
+ */
632
+ function addOsc8Hyperlinks(lines, urls) {
633
+ if (urls.length === 0) return lines;
634
+ let pending = null;
635
+ return lines.map((line) => {
636
+ const result = findUrlRanges(stripAnsi(line), urls, pending);
637
+ pending = result.pending;
638
+ return applyOsc8Ranges(line, result.ranges);
639
+ });
640
+ }
641
+ //#endregion
642
+ //#region src/tui/components/hyperlink-markdown.ts
643
+ /**
644
+ * Wrapper around pi-tui's Markdown component that adds OSC 8 terminal
645
+ * hyperlinks to rendered output, making URLs clickable even when broken
646
+ * across multiple lines by word wrapping.
647
+ */
648
+ var HyperlinkMarkdown = class {
649
+ constructor(text, paddingX, paddingY, theme, options) {
650
+ this.inner = new Markdown(text, paddingX, paddingY, theme, options);
651
+ this.urls = extractUrls(text);
652
+ }
653
+ render(width) {
654
+ return addOsc8Hyperlinks(this.inner.render(width), this.urls);
655
+ }
656
+ setText(text) {
657
+ this.inner.setText(text);
658
+ this.urls = extractUrls(text);
659
+ }
660
+ invalidate() {
661
+ this.inner.invalidate();
662
+ }
663
+ };
664
+ //#endregion
665
+ //#region src/tui/components/assistant-message.ts
666
+ var AssistantMessageComponent = class extends Container {
667
+ constructor(text) {
668
+ super();
669
+ this.body = new HyperlinkMarkdown(text, 1, 0, markdownTheme, { color: (line) => theme.assistantText(line) });
670
+ this.addChild(new Spacer(1));
671
+ this.addChild(this.body);
672
+ }
673
+ setText(text) {
674
+ this.body.setText(text);
675
+ }
676
+ };
677
+ //#endregion
678
+ //#region src/tui/components/btw-inline-message.ts
679
+ var BtwInlineMessage = class extends Container {
680
+ constructor(params) {
681
+ super();
682
+ this.setResult(params);
683
+ }
684
+ setResult(params) {
685
+ this.clear();
686
+ this.addChild(new Spacer(1));
687
+ this.addChild(new Text(theme.header(`BTW: ${params.question}`), 1, 0));
688
+ if (params.isError) this.addChild(new Text(theme.error(params.text), 1, 0));
689
+ else this.addChild(new AssistantMessageComponent(params.text));
690
+ this.addChild(new Text(theme.dim("Press Enter or Esc to dismiss"), 1, 0));
691
+ }
692
+ };
693
+ //#endregion
694
+ //#region src/tui/tui-formatters.ts
695
+ const REPLACEMENT_CHAR_RE = /\uFFFD/g;
696
+ const MAX_TOKEN_CHARS = 32;
697
+ const LONG_TOKEN_RE = /\S{33,}/g;
698
+ const LONG_TOKEN_TEST_RE = /\S{33,}/;
699
+ const BINARY_LINE_REPLACEMENT_THRESHOLD = 12;
700
+ const URL_PREFIX_RE = /^(https?:\/\/|file:\/\/)/i;
701
+ const WINDOWS_DRIVE_RE = /^[a-zA-Z]:[\\/]/;
702
+ const FILE_LIKE_RE = /^[a-zA-Z0-9._-]+$/;
703
+ const EDGE_PUNCTUATION_RE = /^[`"'([{<]+|[`"')\]}>.,:;!?]+$/g;
704
+ const TOKENISH_MIN_LENGTH = 24;
705
+ const RTL_SCRIPT_RE = /[\u0590-\u08ff\ufb1d-\ufdff\ufe70-\ufefc]/;
706
+ const BIDI_CONTROL_RE = /[\u202a-\u202e\u2066-\u2069]/;
707
+ const RTL_ISOLATE_START = "⁧";
708
+ const RTL_ISOLATE_END = "⁩";
709
+ function hasControlChars(text) {
710
+ for (const char of text) {
711
+ const code = char.charCodeAt(0);
712
+ if (code <= 31 && code !== 9 && code !== 10 && code !== 13 || code >= 127 && code <= 159) return true;
713
+ }
714
+ return false;
715
+ }
716
+ function stripControlChars(text) {
717
+ if (!hasControlChars(text)) return text;
718
+ let sanitized = "";
719
+ for (const char of text) {
720
+ const code = char.charCodeAt(0);
721
+ if (!(code <= 31 && code !== 9 && code !== 10 && code !== 13) && !(code >= 127 && code <= 159)) sanitized += char;
722
+ }
723
+ return sanitized;
724
+ }
725
+ function chunkToken(token, maxChars) {
726
+ if (token.length <= maxChars) return [token];
727
+ const chunks = [];
728
+ for (let i = 0; i < token.length; i += maxChars) chunks.push(token.slice(i, i + maxChars));
729
+ return chunks;
730
+ }
731
+ function isCopySensitiveToken(token) {
732
+ const candidate = token.replace(EDGE_PUNCTUATION_RE, "") || token;
733
+ if (URL_PREFIX_RE.test(token)) return true;
734
+ if (token.startsWith("/") || token.startsWith("~/") || token.startsWith("./") || token.startsWith("../")) return true;
735
+ if (WINDOWS_DRIVE_RE.test(token) || token.startsWith("\\\\")) return true;
736
+ if (token.includes("/") || token.includes("\\")) return true;
737
+ if (token.includes("_") && FILE_LIKE_RE.test(token)) return true;
738
+ if (candidate.length >= TOKENISH_MIN_LENGTH && /[a-z]/i.test(candidate) && /\d/.test(candidate)) return true;
739
+ return false;
740
+ }
741
+ function normalizeLongTokenForDisplay(token) {
742
+ if (isCopySensitiveToken(token)) return token;
743
+ return chunkToken(token, MAX_TOKEN_CHARS).join(" ");
744
+ }
745
+ function redactBinaryLikeLine(line) {
746
+ const replacementCount = (line.match(REPLACEMENT_CHAR_RE) || []).length;
747
+ if (replacementCount >= BINARY_LINE_REPLACEMENT_THRESHOLD && replacementCount * 2 >= line.length) return "[binary data omitted]";
748
+ return line;
749
+ }
750
+ function isolateRtlLine(line) {
751
+ if (!RTL_SCRIPT_RE.test(line) || BIDI_CONTROL_RE.test(line)) return line;
752
+ return `${RTL_ISOLATE_START}${line}${RTL_ISOLATE_END}`;
753
+ }
754
+ function applyRtlIsolation(text) {
755
+ if (!RTL_SCRIPT_RE.test(text)) return text;
756
+ return text.split("\n").map((line) => isolateRtlLine(line)).join("\n");
757
+ }
758
+ function sanitizeRenderableText(text) {
759
+ if (!text) return text;
760
+ const hasAnsi = text.includes("\x1B");
761
+ const hasReplacementChars = text.includes("�");
762
+ const hasLongTokens = LONG_TOKEN_TEST_RE.test(text);
763
+ const hasControls = hasControlChars(text);
764
+ if (!hasAnsi && !hasReplacementChars && !hasLongTokens && !hasControls) return applyRtlIsolation(text);
765
+ const withoutAnsi = hasAnsi ? stripAnsi$1(text) : text;
766
+ const withoutControlChars = hasControls ? stripControlChars(withoutAnsi) : withoutAnsi;
767
+ const redacted = hasReplacementChars ? withoutControlChars.split("\n").map((line) => redactBinaryLikeLine(line)).join("\n") : withoutControlChars;
768
+ return applyRtlIsolation(LONG_TOKEN_TEST_RE.test(redacted) ? redacted.replace(LONG_TOKEN_RE, normalizeLongTokenForDisplay) : redacted);
769
+ }
770
+ function resolveFinalAssistantText(params) {
771
+ const finalText = params.finalText ?? "";
772
+ if (finalText.trim()) return finalText;
773
+ const streamedText = params.streamedText ?? "";
774
+ if (streamedText.trim()) return streamedText;
775
+ const errorMessage = params.errorMessage ?? "";
776
+ if (errorMessage.trim()) return formatRawAssistantErrorForUi(errorMessage);
777
+ return "(no output)";
778
+ }
779
+ function composeThinkingAndContent(params) {
780
+ const thinkingText = params.thinkingText?.trim() ?? "";
781
+ const contentText = params.contentText?.trim() ?? "";
782
+ const parts = [];
783
+ if (params.showThinking && thinkingText) parts.push(`[thinking]\n${thinkingText}`);
784
+ if (contentText) parts.push(contentText);
785
+ return parts.join("\n\n").trim();
786
+ }
787
+ function asMessageRecord(message) {
788
+ if (!message || typeof message !== "object") return;
789
+ return message;
790
+ }
791
+ function resolveMessageRecord(message) {
792
+ const record = asMessageRecord(message);
793
+ if (!record) return;
794
+ return {
795
+ record,
796
+ content: record.content
797
+ };
798
+ }
799
+ function formatAssistantErrorFromRecord(record) {
800
+ if ((typeof record.stopReason === "string" ? record.stopReason : "") !== "error") return "";
801
+ return formatRawAssistantErrorForUi(typeof record.errorMessage === "string" ? record.errorMessage : "");
802
+ }
803
+ function collectSanitizedBlockStrings(params) {
804
+ if (!Array.isArray(params.content)) return [];
805
+ const parts = [];
806
+ for (const block of params.content) {
807
+ if (!block || typeof block !== "object") continue;
808
+ const rec = block;
809
+ if (rec.type === params.blockType && typeof rec[params.valueKey] === "string") parts.push(sanitizeRenderableText(rec[params.valueKey]));
810
+ }
811
+ return parts;
812
+ }
813
+ /**
814
+ * Extract ONLY thinking blocks from message content.
815
+ * Model-agnostic: returns empty string if no thinking blocks exist.
816
+ */
817
+ function extractThinkingFromMessage(message) {
818
+ const resolved = resolveMessageRecord(message);
819
+ if (!resolved) return "";
820
+ const { content } = resolved;
821
+ if (typeof content === "string") return "";
822
+ return collectSanitizedBlockStrings({
823
+ content,
824
+ blockType: "thinking",
825
+ valueKey: "thinking"
826
+ }).join("\n").trim();
827
+ }
828
+ /**
829
+ * Extract ONLY text content blocks from message (excludes thinking).
830
+ * Model-agnostic: works for any model with text content blocks.
831
+ */
832
+ function extractContentFromMessage(message) {
833
+ const resolved = resolveMessageRecord(message);
834
+ if (!resolved) return "";
835
+ const { record, content } = resolved;
836
+ if (typeof content === "string") return sanitizeRenderableText(content).trim();
837
+ const parts = collectSanitizedBlockStrings({
838
+ content,
839
+ blockType: "text",
840
+ valueKey: "text"
841
+ });
842
+ if (parts.length > 0) return parts.join("\n").trim();
843
+ return formatAssistantErrorFromRecord(record);
844
+ }
845
+ function extractTextBlocks(content, opts) {
846
+ if (typeof content === "string") return sanitizeRenderableText(content).trim();
847
+ if (!Array.isArray(content)) return "";
848
+ const textParts = collectSanitizedBlockStrings({
849
+ content,
850
+ blockType: "text",
851
+ valueKey: "text"
852
+ });
853
+ return composeThinkingAndContent({
854
+ thinkingText: (opts?.includeThinking === true ? collectSanitizedBlockStrings({
855
+ content,
856
+ blockType: "thinking",
857
+ valueKey: "thinking"
858
+ }) : []).join("\n").trim(),
859
+ contentText: textParts.join("\n").trim(),
860
+ showThinking: opts?.includeThinking ?? false
861
+ });
862
+ }
863
+ function extractTextFromMessage(message, opts) {
864
+ const record = asMessageRecord(message);
865
+ if (!record) return "";
866
+ const text = extractTextBlocks(record.content, opts);
867
+ if (text) {
868
+ if (record.role === "user") return stripLeadingInboundMetadata(text);
869
+ return text;
870
+ }
871
+ const errorText = formatAssistantErrorFromRecord(record);
872
+ if (!errorText) return "";
873
+ return errorText;
874
+ }
875
+ function isCommandMessage(message) {
876
+ if (!message || typeof message !== "object") return false;
877
+ return message.command === true;
878
+ }
879
+ function formatTokens(total, context) {
880
+ if (total == null && context == null) return "tokens ?";
881
+ const totalLabel = total == null ? "?" : formatTokenCount(total);
882
+ if (context == null) return `tokens ${totalLabel}`;
883
+ const pct = typeof total === "number" && context > 0 ? Math.min(999, Math.round(total / context * 100)) : null;
884
+ return `tokens ${totalLabel}/${formatTokenCount(context)}${pct !== null ? ` (${pct}%)` : ""}`;
885
+ }
886
+ function formatContextUsageLine(params) {
887
+ const totalLabel = typeof params.total === "number" ? formatTokenCount(params.total) : "?";
888
+ const ctxLabel = typeof params.context === "number" ? formatTokenCount(params.context) : "?";
889
+ const pct = typeof params.percent === "number" ? Math.min(999, Math.round(params.percent)) : null;
890
+ const extra = [typeof params.remaining === "number" ? `${formatTokenCount(params.remaining)} left` : null, pct !== null ? `${pct}%` : null].filter(Boolean).join(", ");
891
+ return `tokens ${totalLabel}/${ctxLabel}${extra ? ` (${extra})` : ""}`;
892
+ }
893
+ function asString(value, fallback = "") {
894
+ if (typeof value === "string") return value;
895
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
896
+ return fallback;
897
+ }
898
+ //#endregion
899
+ //#region src/tui/components/tool-execution.ts
900
+ const PREVIEW_LINES = 12;
901
+ function formatArgs(toolName, args) {
902
+ const detail = formatToolDetail(resolveToolDisplay({
903
+ name: toolName,
904
+ args
905
+ }));
906
+ if (detail) return sanitizeRenderableText(detail);
907
+ if (!args || typeof args !== "object") return "";
908
+ try {
909
+ return sanitizeRenderableText(JSON.stringify(args));
910
+ } catch {
911
+ return "";
912
+ }
913
+ }
914
+ function extractText(result) {
915
+ if (!result?.content) return "";
916
+ const lines = [];
917
+ for (const entry of result.content) if (entry.type === "text" && entry.text) lines.push(sanitizeRenderableText(entry.text));
918
+ else if (entry.type === "image") {
919
+ const mime = entry.mimeType ?? "image";
920
+ const size = entry.bytes ? ` ${Math.round(entry.bytes / 1024)}kb` : "";
921
+ const omitted = entry.omitted ? " (omitted)" : "";
922
+ lines.push(`[${mime}${size}${omitted}]`);
923
+ }
924
+ return lines.join("\n").trim();
925
+ }
926
+ var ToolExecutionComponent = class extends Container {
927
+ constructor(toolName, args) {
928
+ super();
929
+ this.expanded = false;
930
+ this.isError = false;
931
+ this.isPartial = true;
932
+ this.toolName = toolName;
933
+ this.args = args;
934
+ this.box = new Box(1, 1, (line) => theme.toolPendingBg(line));
935
+ this.header = new Text("", 0, 0);
936
+ this.argsLine = new Text("", 0, 0);
937
+ this.output = new Markdown("", 0, 0, markdownTheme, { color: (line) => theme.toolOutput(line) });
938
+ this.addChild(new Spacer(1));
939
+ this.addChild(this.box);
940
+ this.box.addChild(this.header);
941
+ this.box.addChild(this.argsLine);
942
+ this.box.addChild(this.output);
943
+ this.refresh();
944
+ }
945
+ setArgs(args) {
946
+ this.args = args;
947
+ this.refresh();
948
+ }
949
+ setExpanded(expanded) {
950
+ this.expanded = expanded;
951
+ this.refresh();
952
+ }
953
+ setResult(result, opts) {
954
+ this.result = result;
955
+ this.isPartial = false;
956
+ this.isError = Boolean(opts?.isError);
957
+ this.refresh();
958
+ }
959
+ setPartialResult(result) {
960
+ this.result = result;
961
+ this.isPartial = true;
962
+ this.refresh();
963
+ }
964
+ refresh() {
965
+ const bg = this.isPartial ? theme.toolPendingBg : this.isError ? theme.toolErrorBg : theme.toolSuccessBg;
966
+ this.box.setBgFn((line) => bg(line));
967
+ const display = resolveToolDisplay({
968
+ name: this.toolName,
969
+ args: this.args
970
+ });
971
+ const title = `${display.emoji} ${display.label}${this.isPartial ? " (running)" : ""}`;
972
+ this.header.setText(theme.toolTitle(theme.bold(title)));
973
+ const argLine = formatArgs(this.toolName, this.args);
974
+ this.argsLine.setText(argLine ? theme.dim(argLine) : theme.dim(" "));
975
+ const text = extractText(this.result) || (this.isPartial ? "…" : "");
976
+ if (!this.expanded && text) {
977
+ const lines = text.split("\n");
978
+ const preview = lines.length > PREVIEW_LINES ? `${lines.slice(0, PREVIEW_LINES).join("\n")}\n…` : text;
979
+ this.output.setText(preview);
980
+ } else this.output.setText(text);
981
+ }
982
+ };
983
+ //#endregion
984
+ //#region src/tui/components/markdown-message.ts
985
+ var MarkdownMessageComponent = class extends Container {
986
+ constructor(text, y, options) {
987
+ super();
988
+ this.body = new Markdown(text, 1, y, markdownTheme, options);
989
+ this.addChild(new Spacer(1));
990
+ this.addChild(this.body);
991
+ }
992
+ setText(text) {
993
+ this.body.setText(text);
994
+ }
995
+ };
996
+ //#endregion
997
+ //#region src/tui/components/user-message.ts
998
+ var UserMessageComponent = class extends MarkdownMessageComponent {
999
+ constructor(text) {
1000
+ super(text, 1, {
1001
+ bgColor: (line) => theme.userBg(line),
1002
+ color: (line) => theme.userText(line)
1003
+ });
1004
+ }
1005
+ };
1006
+ //#endregion
1007
+ //#region src/tui/components/chat-log.ts
1008
+ var ChatLog = class extends Container {
1009
+ constructor(maxComponents = 180) {
1010
+ super();
1011
+ this.toolById = /* @__PURE__ */ new Map();
1012
+ this.streamingRuns = /* @__PURE__ */ new Map();
1013
+ this.btwMessage = null;
1014
+ this.toolsExpanded = false;
1015
+ this.maxComponents = Math.max(20, Math.floor(maxComponents));
1016
+ }
1017
+ dropComponentReferences(component) {
1018
+ for (const [toolId, tool] of this.toolById.entries()) if (tool === component) this.toolById.delete(toolId);
1019
+ for (const [runId, message] of this.streamingRuns.entries()) if (message === component) this.streamingRuns.delete(runId);
1020
+ if (this.btwMessage === component) this.btwMessage = null;
1021
+ }
1022
+ pruneOverflow() {
1023
+ while (this.children.length > this.maxComponents) {
1024
+ const oldest = this.children[0];
1025
+ if (!oldest) return;
1026
+ this.removeChild(oldest);
1027
+ this.dropComponentReferences(oldest);
1028
+ }
1029
+ }
1030
+ append(component) {
1031
+ this.addChild(component);
1032
+ this.pruneOverflow();
1033
+ }
1034
+ clearAll() {
1035
+ this.clear();
1036
+ this.toolById.clear();
1037
+ this.streamingRuns.clear();
1038
+ this.btwMessage = null;
1039
+ }
1040
+ addSystem(text) {
1041
+ this.append(new Spacer(1));
1042
+ this.append(new Text(theme.system(text), 1, 0));
1043
+ }
1044
+ addUser(text) {
1045
+ this.append(new UserMessageComponent(text));
1046
+ }
1047
+ resolveRunId(runId) {
1048
+ return runId ?? "default";
1049
+ }
1050
+ startAssistant(text, runId) {
1051
+ const effectiveRunId = this.resolveRunId(runId);
1052
+ const existing = this.streamingRuns.get(effectiveRunId);
1053
+ if (existing) {
1054
+ existing.setText(text);
1055
+ return existing;
1056
+ }
1057
+ const component = new AssistantMessageComponent(text);
1058
+ this.streamingRuns.set(effectiveRunId, component);
1059
+ this.append(component);
1060
+ return component;
1061
+ }
1062
+ updateAssistant(text, runId) {
1063
+ const effectiveRunId = this.resolveRunId(runId);
1064
+ const existing = this.streamingRuns.get(effectiveRunId);
1065
+ if (!existing) {
1066
+ this.startAssistant(text, runId);
1067
+ return;
1068
+ }
1069
+ existing.setText(text);
1070
+ }
1071
+ finalizeAssistant(text, runId) {
1072
+ const effectiveRunId = this.resolveRunId(runId);
1073
+ const existing = this.streamingRuns.get(effectiveRunId);
1074
+ if (existing) {
1075
+ existing.setText(text);
1076
+ this.streamingRuns.delete(effectiveRunId);
1077
+ return;
1078
+ }
1079
+ this.append(new AssistantMessageComponent(text));
1080
+ }
1081
+ dropAssistant(runId) {
1082
+ const effectiveRunId = this.resolveRunId(runId);
1083
+ const existing = this.streamingRuns.get(effectiveRunId);
1084
+ if (!existing) return;
1085
+ this.removeChild(existing);
1086
+ this.streamingRuns.delete(effectiveRunId);
1087
+ }
1088
+ showBtw(params) {
1089
+ if (this.btwMessage) {
1090
+ this.btwMessage.setResult(params);
1091
+ if (this.children[this.children.length - 1] !== this.btwMessage) {
1092
+ this.removeChild(this.btwMessage);
1093
+ this.append(this.btwMessage);
1094
+ }
1095
+ return this.btwMessage;
1096
+ }
1097
+ const component = new BtwInlineMessage(params);
1098
+ this.btwMessage = component;
1099
+ this.append(component);
1100
+ return component;
1101
+ }
1102
+ dismissBtw() {
1103
+ if (!this.btwMessage) return;
1104
+ this.removeChild(this.btwMessage);
1105
+ this.btwMessage = null;
1106
+ }
1107
+ hasVisibleBtw() {
1108
+ return this.btwMessage !== null;
1109
+ }
1110
+ startTool(toolCallId, toolName, args) {
1111
+ const existing = this.toolById.get(toolCallId);
1112
+ if (existing) {
1113
+ existing.setArgs(args);
1114
+ return existing;
1115
+ }
1116
+ const component = new ToolExecutionComponent(toolName, args);
1117
+ component.setExpanded(this.toolsExpanded);
1118
+ this.toolById.set(toolCallId, component);
1119
+ this.append(component);
1120
+ return component;
1121
+ }
1122
+ updateToolArgs(toolCallId, args) {
1123
+ const existing = this.toolById.get(toolCallId);
1124
+ if (!existing) return;
1125
+ existing.setArgs(args);
1126
+ }
1127
+ updateToolResult(toolCallId, result, opts) {
1128
+ const existing = this.toolById.get(toolCallId);
1129
+ if (!existing) return;
1130
+ if (opts?.partial) {
1131
+ existing.setPartialResult(result);
1132
+ return;
1133
+ }
1134
+ existing.setResult(result, { isError: opts?.isError });
1135
+ }
1136
+ setToolsExpanded(expanded) {
1137
+ this.toolsExpanded = expanded;
1138
+ for (const tool of this.toolById.values()) tool.setExpanded(expanded);
1139
+ }
1140
+ };
1141
+ //#endregion
1142
+ //#region src/tui/components/custom-editor.ts
1143
+ var CustomEditor = class extends Editor {
1144
+ handleInput(data) {
1145
+ if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {
1146
+ this.onAltEnter();
1147
+ return;
1148
+ }
1149
+ if (matchesKey(data, Key.ctrl("l")) && this.onCtrlL) {
1150
+ this.onCtrlL();
1151
+ return;
1152
+ }
1153
+ if (matchesKey(data, Key.ctrl("o")) && this.onCtrlO) {
1154
+ this.onCtrlO();
1155
+ return;
1156
+ }
1157
+ if (matchesKey(data, Key.ctrl("p")) && this.onCtrlP) {
1158
+ this.onCtrlP();
1159
+ return;
1160
+ }
1161
+ if (matchesKey(data, Key.ctrl("g")) && this.onCtrlG) {
1162
+ this.onCtrlG();
1163
+ return;
1164
+ }
1165
+ if (matchesKey(data, Key.ctrl("t")) && this.onCtrlT) {
1166
+ this.onCtrlT();
1167
+ return;
1168
+ }
1169
+ if (matchesKey(data, Key.shift("tab")) && this.onShiftTab) {
1170
+ this.onShiftTab();
1171
+ return;
1172
+ }
1173
+ if (matchesKey(data, Key.escape) && this.onEscape && !this.isShowingAutocomplete()) {
1174
+ this.onEscape();
1175
+ return;
1176
+ }
1177
+ if (matchesKey(data, Key.ctrl("c")) && this.onCtrlC) {
1178
+ this.onCtrlC();
1179
+ return;
1180
+ }
1181
+ if (matchesKey(data, Key.ctrl("d"))) {
1182
+ if (this.getText().length === 0 && this.onCtrlD) this.onCtrlD();
1183
+ return;
1184
+ }
1185
+ super.handleInput(data);
1186
+ }
1187
+ };
1188
+ //#endregion
1189
+ //#region src/tui/gateway-chat.ts
1190
+ function trimToUndefined(value) {
1191
+ if (typeof value !== "string") return;
1192
+ const trimmed = value.trim();
1193
+ return trimmed.length > 0 ? trimmed : void 0;
1194
+ }
1195
+ function throwGatewayAuthResolutionError(reason) {
1196
+ throw new Error([
1197
+ reason,
1198
+ "Fix: set OPENCLAW_GATEWAY_TOKEN/OPENCLAW_GATEWAY_PASSWORD, pass --token/--password,",
1199
+ "or resolve the configured secret provider for this credential."
1200
+ ].join("\n"));
1201
+ }
1202
+ var GatewayChatClient = class GatewayChatClient {
1203
+ constructor(connection) {
1204
+ this.connection = connection;
1205
+ this.readyPromise = new Promise((resolve) => {
1206
+ this.resolveReady = resolve;
1207
+ });
1208
+ this.client = new GatewayClient({
1209
+ url: connection.url,
1210
+ token: connection.token,
1211
+ password: connection.password,
1212
+ clientName: GATEWAY_CLIENT_NAMES.GATEWAY_CLIENT,
1213
+ clientDisplayName: "openclaw-tui",
1214
+ clientVersion: VERSION,
1215
+ platform: process.platform,
1216
+ mode: GATEWAY_CLIENT_MODES.UI,
1217
+ caps: [GATEWAY_CLIENT_CAPS.TOOL_EVENTS],
1218
+ instanceId: randomUUID(),
1219
+ minProtocol: 3,
1220
+ maxProtocol: 3,
1221
+ onHelloOk: (hello) => {
1222
+ this.hello = hello;
1223
+ this.resolveReady?.();
1224
+ this.onConnected?.();
1225
+ },
1226
+ onEvent: (evt) => {
1227
+ this.onEvent?.({
1228
+ event: evt.event,
1229
+ payload: evt.payload,
1230
+ seq: evt.seq
1231
+ });
1232
+ },
1233
+ onClose: (_code, reason) => {
1234
+ this.readyPromise = new Promise((resolve) => {
1235
+ this.resolveReady = resolve;
1236
+ });
1237
+ this.onDisconnected?.(reason);
1238
+ },
1239
+ onGap: (info) => {
1240
+ this.onGap?.(info);
1241
+ }
1242
+ });
1243
+ }
1244
+ static async connect(opts) {
1245
+ return new GatewayChatClient(await resolveGatewayConnection(opts));
1246
+ }
1247
+ start() {
1248
+ this.client.start();
1249
+ }
1250
+ stop() {
1251
+ this.client.stop();
1252
+ }
1253
+ async waitForReady() {
1254
+ await this.readyPromise;
1255
+ }
1256
+ async sendChat(opts) {
1257
+ const runId = opts.runId ?? randomUUID();
1258
+ await this.client.request("chat.send", {
1259
+ sessionKey: opts.sessionKey,
1260
+ message: opts.message,
1261
+ thinking: opts.thinking,
1262
+ deliver: opts.deliver,
1263
+ timeoutMs: opts.timeoutMs,
1264
+ idempotencyKey: runId
1265
+ });
1266
+ return { runId };
1267
+ }
1268
+ async abortChat(opts) {
1269
+ return await this.client.request("chat.abort", {
1270
+ sessionKey: opts.sessionKey,
1271
+ runId: opts.runId
1272
+ });
1273
+ }
1274
+ async loadHistory(opts) {
1275
+ return await this.client.request("chat.history", {
1276
+ sessionKey: opts.sessionKey,
1277
+ limit: opts.limit
1278
+ });
1279
+ }
1280
+ async listSessions(opts) {
1281
+ return await this.client.request("sessions.list", {
1282
+ limit: opts?.limit,
1283
+ activeMinutes: opts?.activeMinutes,
1284
+ includeGlobal: opts?.includeGlobal,
1285
+ includeUnknown: opts?.includeUnknown,
1286
+ includeDerivedTitles: opts?.includeDerivedTitles,
1287
+ includeLastMessage: opts?.includeLastMessage,
1288
+ agentId: opts?.agentId
1289
+ });
1290
+ }
1291
+ async listAgents() {
1292
+ return await this.client.request("agents.list", {});
1293
+ }
1294
+ async patchSession(opts) {
1295
+ return await this.client.request("sessions.patch", opts);
1296
+ }
1297
+ async resetSession(key, reason) {
1298
+ return await this.client.request("sessions.reset", {
1299
+ key,
1300
+ ...reason ? { reason } : {}
1301
+ });
1302
+ }
1303
+ async getStatus() {
1304
+ return await this.client.request("status");
1305
+ }
1306
+ async listModels() {
1307
+ const res = await this.client.request("models.list");
1308
+ return Array.isArray(res?.models) ? res.models : [];
1309
+ }
1310
+ };
1311
+ async function resolveGatewayConnection(opts) {
1312
+ const config = loadConfig();
1313
+ const env = process.env;
1314
+ const gatewayAuthMode = config.gateway?.auth?.mode;
1315
+ const isRemoteMode = config.gateway?.mode === "remote";
1316
+ const remote = config.gateway?.remote;
1317
+ const envToken = trimToUndefined(env.OPENCLAW_GATEWAY_TOKEN);
1318
+ const envPassword = trimToUndefined(env.OPENCLAW_GATEWAY_PASSWORD);
1319
+ const urlOverride = typeof opts.url === "string" && opts.url.trim().length > 0 ? opts.url.trim() : void 0;
1320
+ const explicitAuth = resolveExplicitGatewayAuth({
1321
+ token: opts.token,
1322
+ password: opts.password
1323
+ });
1324
+ ensureExplicitGatewayAuth({
1325
+ urlOverride,
1326
+ urlOverrideSource: "cli",
1327
+ explicitAuth,
1328
+ errorHint: "Fix: pass --token or --password when using --url."
1329
+ });
1330
+ const url = buildGatewayConnectionDetails({
1331
+ config,
1332
+ ...urlOverride ? { url: urlOverride } : {}
1333
+ }).url;
1334
+ if (urlOverride) return {
1335
+ url,
1336
+ token: explicitAuth.token,
1337
+ password: explicitAuth.password
1338
+ };
1339
+ if (isRemoteMode) {
1340
+ const remoteToken = explicitAuth.token ? { value: explicitAuth.token } : await resolveConfiguredSecretInputString({
1341
+ value: remote?.token,
1342
+ path: "gateway.remote.token",
1343
+ env,
1344
+ config
1345
+ });
1346
+ const remotePassword = explicitAuth.password || envPassword ? { value: explicitAuth.password ?? envPassword } : await resolveConfiguredSecretInputString({
1347
+ value: remote?.password,
1348
+ path: "gateway.remote.password",
1349
+ env,
1350
+ config
1351
+ });
1352
+ const token = explicitAuth.token ?? remoteToken.value;
1353
+ const password = explicitAuth.password ?? envPassword ?? remotePassword.value;
1354
+ if (!token && !password) throwGatewayAuthResolutionError(remoteToken.unresolvedRefReason ?? remotePassword.unresolvedRefReason ?? "Missing gateway auth credentials.");
1355
+ return {
1356
+ url,
1357
+ token,
1358
+ password
1359
+ };
1360
+ }
1361
+ if (gatewayAuthMode === "none" || gatewayAuthMode === "trusted-proxy") return {
1362
+ url,
1363
+ token: explicitAuth.token ?? envToken,
1364
+ password: explicitAuth.password ?? envPassword
1365
+ };
1366
+ try {
1367
+ assertExplicitGatewayAuthModeWhenBothConfigured(config);
1368
+ } catch (err) {
1369
+ throwGatewayAuthResolutionError(err instanceof Error ? err.message : String(err));
1370
+ }
1371
+ const defaults = config.secrets?.defaults;
1372
+ const hasConfiguredToken = hasConfiguredSecretInput(config.gateway?.auth?.token, defaults);
1373
+ const hasConfiguredPassword = hasConfiguredSecretInput(config.gateway?.auth?.password, defaults);
1374
+ if (gatewayAuthMode === "password") {
1375
+ const localPassword = explicitAuth.password || envPassword ? { value: explicitAuth.password ?? envPassword } : await resolveConfiguredSecretInputString({
1376
+ value: config.gateway?.auth?.password,
1377
+ path: "gateway.auth.password",
1378
+ env,
1379
+ config
1380
+ });
1381
+ const password = explicitAuth.password ?? envPassword ?? localPassword.value;
1382
+ if (!password) throwGatewayAuthResolutionError(localPassword.unresolvedRefReason ?? "Missing gateway auth password.");
1383
+ return {
1384
+ url,
1385
+ token: explicitAuth.token ?? envToken,
1386
+ password
1387
+ };
1388
+ }
1389
+ const resolveToken = async () => {
1390
+ const localToken = explicitAuth.token ? { value: explicitAuth.token } : await resolveConfiguredSecretInputString({
1391
+ value: config.gateway?.auth?.token,
1392
+ path: "gateway.auth.token",
1393
+ env,
1394
+ config
1395
+ });
1396
+ const token = explicitAuth.token ?? localToken.value ?? envToken;
1397
+ if (!token) throwGatewayAuthResolutionError(localToken.unresolvedRefReason ?? "Missing gateway auth token.");
1398
+ return token;
1399
+ };
1400
+ if (gatewayAuthMode === "token") return {
1401
+ url,
1402
+ token: await resolveToken(),
1403
+ password: explicitAuth.password ?? envPassword
1404
+ };
1405
+ const passwordCandidate = explicitAuth.password ?? envPassword;
1406
+ if (Boolean(passwordCandidate) || hasConfiguredPassword && !hasConfiguredToken) {
1407
+ const localPassword = passwordCandidate ? { value: passwordCandidate } : await resolveConfiguredSecretInputString({
1408
+ value: config.gateway?.auth?.password,
1409
+ path: "gateway.auth.password",
1410
+ env,
1411
+ config
1412
+ });
1413
+ const password = explicitAuth.password ?? localPassword.value ?? envPassword;
1414
+ if (!password) throwGatewayAuthResolutionError(localPassword.unresolvedRefReason ?? "Missing gateway auth password.");
1415
+ return {
1416
+ url,
1417
+ token: explicitAuth.token ?? envToken,
1418
+ password
1419
+ };
1420
+ }
1421
+ return {
1422
+ url,
1423
+ token: await resolveToken(),
1424
+ password: explicitAuth.password ?? envPassword
1425
+ };
1426
+ }
1427
+ //#endregion
1428
+ //#region src/tui/components/fuzzy-filter.ts
1429
+ /**
1430
+ * Shared fuzzy filtering utilities for select list components.
1431
+ */
1432
+ /**
1433
+ * Word boundary characters for matching.
1434
+ */
1435
+ const WORD_BOUNDARY_CHARS = /[\s\-_./:#@]/;
1436
+ /**
1437
+ * Check if position is at a word boundary.
1438
+ */
1439
+ function isWordBoundary(text, index) {
1440
+ return index === 0 || WORD_BOUNDARY_CHARS.test(text[index - 1] ?? "");
1441
+ }
1442
+ /**
1443
+ * Find index where query matches at a word boundary in text.
1444
+ * Returns null if no match.
1445
+ */
1446
+ function findWordBoundaryIndex(text, query) {
1447
+ if (!query) return null;
1448
+ const textLower = text.toLowerCase();
1449
+ const queryLower = query.toLowerCase();
1450
+ const maxIndex = textLower.length - queryLower.length;
1451
+ if (maxIndex < 0) return null;
1452
+ for (let i = 0; i <= maxIndex; i++) if (textLower.startsWith(queryLower, i) && isWordBoundary(textLower, i)) return i;
1453
+ return null;
1454
+ }
1455
+ /**
1456
+ * Fuzzy match with pre-lowercased inputs (avoids toLowerCase on every keystroke).
1457
+ * Returns score (lower = better) or null if no match.
1458
+ */
1459
+ function fuzzyMatchLower(queryLower, textLower) {
1460
+ if (queryLower.length === 0) return 0;
1461
+ if (queryLower.length > textLower.length) return null;
1462
+ let queryIndex = 0;
1463
+ let score = 0;
1464
+ let lastMatchIndex = -1;
1465
+ let consecutiveMatches = 0;
1466
+ for (let i = 0; i < textLower.length && queryIndex < queryLower.length; i++) if (textLower[i] === queryLower[queryIndex]) {
1467
+ const isAtWordBoundary = isWordBoundary(textLower, i);
1468
+ if (lastMatchIndex === i - 1) {
1469
+ consecutiveMatches++;
1470
+ score -= consecutiveMatches * 5;
1471
+ } else {
1472
+ consecutiveMatches = 0;
1473
+ if (lastMatchIndex >= 0) score += (i - lastMatchIndex - 1) * 2;
1474
+ }
1475
+ if (isAtWordBoundary) score -= 10;
1476
+ score += i * .1;
1477
+ lastMatchIndex = i;
1478
+ queryIndex++;
1479
+ }
1480
+ return queryIndex < queryLower.length ? null : score;
1481
+ }
1482
+ /**
1483
+ * Filter items using pre-lowercased searchTextLower field.
1484
+ * Supports space-separated tokens (all must match).
1485
+ */
1486
+ function fuzzyFilterLower(items, queryLower) {
1487
+ const trimmed = queryLower.trim();
1488
+ if (!trimmed) return items;
1489
+ const tokens = trimmed.split(/\s+/).filter((t) => t.length > 0);
1490
+ if (tokens.length === 0) return items;
1491
+ const results = [];
1492
+ for (const item of items) {
1493
+ const text = item.searchTextLower ?? "";
1494
+ let totalScore = 0;
1495
+ let allMatch = true;
1496
+ for (const token of tokens) {
1497
+ const score = fuzzyMatchLower(token, text);
1498
+ if (score !== null) totalScore += score;
1499
+ else {
1500
+ allMatch = false;
1501
+ break;
1502
+ }
1503
+ }
1504
+ if (allMatch) results.push({
1505
+ item,
1506
+ score: totalScore
1507
+ });
1508
+ }
1509
+ results.sort((a, b) => a.score - b.score);
1510
+ return results.map((r) => r.item);
1511
+ }
1512
+ /**
1513
+ * Prepare items for fuzzy filtering by pre-computing lowercase search text.
1514
+ */
1515
+ function prepareSearchItems(items) {
1516
+ return items.map((item) => {
1517
+ const parts = [];
1518
+ if (item.label) parts.push(item.label);
1519
+ if (item.description) parts.push(item.description);
1520
+ if (item.searchText) parts.push(item.searchText);
1521
+ return {
1522
+ ...item,
1523
+ searchTextLower: parts.join(" ").toLowerCase()
1524
+ };
1525
+ });
1526
+ }
1527
+ //#endregion
1528
+ //#region src/tui/components/filterable-select-list.ts
1529
+ /**
1530
+ * Combines text input filtering with a select list.
1531
+ * User types to filter, arrows/j/k to navigate, Enter to select, Escape to clear/cancel.
1532
+ */
1533
+ var FilterableSelectList = class {
1534
+ constructor(items, maxVisible, theme) {
1535
+ this.filterText = "";
1536
+ this.allItems = prepareSearchItems(items);
1537
+ this.maxVisible = maxVisible;
1538
+ this.theme = theme;
1539
+ this.input = new Input();
1540
+ this.selectList = new SelectList(this.allItems, maxVisible, theme);
1541
+ }
1542
+ applyFilter() {
1543
+ const queryLower = this.filterText.toLowerCase();
1544
+ if (!queryLower.trim()) {
1545
+ this.selectList = new SelectList(this.allItems, this.maxVisible, this.theme);
1546
+ return;
1547
+ }
1548
+ this.selectList = new SelectList(fuzzyFilterLower(this.allItems, queryLower), this.maxVisible, this.theme);
1549
+ }
1550
+ invalidate() {
1551
+ this.input.invalidate();
1552
+ this.selectList.invalidate();
1553
+ }
1554
+ render(width) {
1555
+ const lines = [];
1556
+ const filterLabel = this.theme.filterLabel("Filter: ");
1557
+ const inputText = this.input.render(width - 8)[0] ?? "";
1558
+ lines.push(filterLabel + inputText);
1559
+ lines.push(chalk.dim("─".repeat(Math.max(0, width))));
1560
+ const listLines = this.selectList.render(width);
1561
+ lines.push(...listLines);
1562
+ return lines;
1563
+ }
1564
+ handleInput(keyData) {
1565
+ const allowVimNav = !this.filterText.trim();
1566
+ if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
1567
+ this.selectList.handleInput("\x1B[A");
1568
+ return;
1569
+ }
1570
+ if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
1571
+ this.selectList.handleInput("\x1B[B");
1572
+ return;
1573
+ }
1574
+ if (matchesKey(keyData, "enter")) {
1575
+ const selected = this.selectList.getSelectedItem();
1576
+ if (selected) this.onSelect?.(selected);
1577
+ return;
1578
+ }
1579
+ if (getEditorKeybindings().matches(keyData, "selectCancel")) {
1580
+ if (this.filterText) {
1581
+ this.filterText = "";
1582
+ this.input.setValue("");
1583
+ this.applyFilter();
1584
+ } else this.onCancel?.();
1585
+ return;
1586
+ }
1587
+ const prevValue = this.input.getValue();
1588
+ this.input.handleInput(keyData);
1589
+ const newValue = this.input.getValue();
1590
+ if (newValue !== prevValue) {
1591
+ this.filterText = newValue;
1592
+ this.applyFilter();
1593
+ }
1594
+ }
1595
+ getSelectedItem() {
1596
+ return this.selectList.getSelectedItem();
1597
+ }
1598
+ getFilterText() {
1599
+ return this.filterText;
1600
+ }
1601
+ };
1602
+ //#endregion
1603
+ //#region src/tui/components/searchable-select-list.ts
1604
+ const ANSI_ESCAPE = String.fromCharCode(27);
1605
+ const ANSI_SGR_REGEX = new RegExp(`${ANSI_ESCAPE}\\[[0-9;]*m`, "g");
1606
+ /**
1607
+ * A select list with a search input at the top for fuzzy filtering.
1608
+ */
1609
+ var SearchableSelectList = class SearchableSelectList {
1610
+ static {
1611
+ this.DESCRIPTION_LAYOUT_MIN_WIDTH = 40;
1612
+ }
1613
+ static {
1614
+ this.DESCRIPTION_MIN_WIDTH = 12;
1615
+ }
1616
+ static {
1617
+ this.DESCRIPTION_SPACING_WIDTH = 2;
1618
+ }
1619
+ static {
1620
+ this.RIGHT_MARGIN_WIDTH = 2;
1621
+ }
1622
+ constructor(items, maxVisible, theme) {
1623
+ this.selectedIndex = 0;
1624
+ this.regexCache = /* @__PURE__ */ new Map();
1625
+ this.compareByScore = (a, b) => {
1626
+ if (a.tier !== b.tier) return a.tier - b.tier;
1627
+ if (a.score !== b.score) return a.score - b.score;
1628
+ return this.getItemLabel(a.item).localeCompare(this.getItemLabel(b.item));
1629
+ };
1630
+ this.items = items;
1631
+ this.filteredItems = items;
1632
+ this.maxVisible = maxVisible;
1633
+ this.theme = theme;
1634
+ this.searchInput = new Input();
1635
+ }
1636
+ getCachedRegex(pattern) {
1637
+ let regex = this.regexCache.get(pattern);
1638
+ if (!regex) {
1639
+ regex = new RegExp(this.escapeRegex(pattern), "gi");
1640
+ this.regexCache.set(pattern, regex);
1641
+ }
1642
+ return regex;
1643
+ }
1644
+ updateFilter() {
1645
+ const query = this.searchInput.getValue().trim();
1646
+ if (!query) this.filteredItems = this.items;
1647
+ else this.filteredItems = this.smartFilter(query);
1648
+ this.selectedIndex = 0;
1649
+ this.notifySelectionChange();
1650
+ }
1651
+ /**
1652
+ * Smart filtering that prioritizes:
1653
+ * 1. Exact substring match in label (highest priority)
1654
+ * 2. Word-boundary prefix match in label
1655
+ * 3. Exact substring in description
1656
+ * 4. Fuzzy match (lowest priority)
1657
+ */
1658
+ smartFilter(query) {
1659
+ const q = query.toLowerCase();
1660
+ const scoredItems = [];
1661
+ const fuzzyCandidates = [];
1662
+ for (const item of this.items) {
1663
+ const rawLabel = this.getItemLabel(item);
1664
+ const rawDesc = item.description ?? "";
1665
+ const label = stripAnsi$1(rawLabel).toLowerCase();
1666
+ const desc = stripAnsi$1(rawDesc).toLowerCase();
1667
+ const labelIndex = label.indexOf(q);
1668
+ if (labelIndex !== -1) {
1669
+ scoredItems.push({
1670
+ item,
1671
+ tier: 0,
1672
+ score: labelIndex
1673
+ });
1674
+ continue;
1675
+ }
1676
+ const wordBoundaryIndex = findWordBoundaryIndex(label, q);
1677
+ if (wordBoundaryIndex !== null) {
1678
+ scoredItems.push({
1679
+ item,
1680
+ tier: 1,
1681
+ score: wordBoundaryIndex
1682
+ });
1683
+ continue;
1684
+ }
1685
+ const descIndex = desc.indexOf(q);
1686
+ if (descIndex !== -1) {
1687
+ scoredItems.push({
1688
+ item,
1689
+ tier: 2,
1690
+ score: descIndex
1691
+ });
1692
+ continue;
1693
+ }
1694
+ const searchText = item.searchText ?? "";
1695
+ fuzzyCandidates.push({
1696
+ item,
1697
+ searchTextLower: [
1698
+ rawLabel,
1699
+ rawDesc,
1700
+ searchText
1701
+ ].map((value) => stripAnsi$1(value)).filter(Boolean).join(" ").toLowerCase()
1702
+ });
1703
+ }
1704
+ scoredItems.sort(this.compareByScore);
1705
+ const fuzzyMatches = fuzzyFilterLower(fuzzyCandidates, q);
1706
+ return [...scoredItems.map((s) => s.item), ...fuzzyMatches.map((entry) => entry.item)];
1707
+ }
1708
+ escapeRegex(str) {
1709
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1710
+ }
1711
+ getItemLabel(item) {
1712
+ return item.label || item.value;
1713
+ }
1714
+ splitAnsiParts(text) {
1715
+ const parts = [];
1716
+ ANSI_SGR_REGEX.lastIndex = 0;
1717
+ let lastIndex = 0;
1718
+ let match;
1719
+ while ((match = ANSI_SGR_REGEX.exec(text)) !== null) {
1720
+ if (match.index > lastIndex) parts.push({
1721
+ text: text.slice(lastIndex, match.index),
1722
+ isAnsi: false
1723
+ });
1724
+ parts.push({
1725
+ text: match[0],
1726
+ isAnsi: true
1727
+ });
1728
+ lastIndex = match.index + match[0].length;
1729
+ }
1730
+ if (lastIndex < text.length) parts.push({
1731
+ text: text.slice(lastIndex),
1732
+ isAnsi: false
1733
+ });
1734
+ return parts;
1735
+ }
1736
+ highlightMatch(text, query) {
1737
+ const tokens = query.trim().split(/\s+/).map((token) => token.toLowerCase()).filter((token) => token.length > 0);
1738
+ if (tokens.length === 0) return text;
1739
+ const uniqueTokens = Array.from(new Set(tokens)).toSorted((a, b) => b.length - a.length);
1740
+ let parts = this.splitAnsiParts(text);
1741
+ for (const token of uniqueTokens) {
1742
+ const regex = this.getCachedRegex(token);
1743
+ const nextParts = [];
1744
+ for (const part of parts) {
1745
+ if (part.isAnsi) {
1746
+ nextParts.push(part);
1747
+ continue;
1748
+ }
1749
+ regex.lastIndex = 0;
1750
+ const replaced = part.text.replace(regex, (match) => this.theme.matchHighlight(match));
1751
+ if (replaced === part.text) {
1752
+ nextParts.push(part);
1753
+ continue;
1754
+ }
1755
+ nextParts.push(...this.splitAnsiParts(replaced));
1756
+ }
1757
+ parts = nextParts;
1758
+ }
1759
+ return parts.map((part) => part.text).join("");
1760
+ }
1761
+ setSelectedIndex(index) {
1762
+ this.selectedIndex = Math.max(0, Math.min(index, this.filteredItems.length - 1));
1763
+ }
1764
+ invalidate() {
1765
+ this.searchInput.invalidate();
1766
+ }
1767
+ render(width) {
1768
+ const lines = [];
1769
+ const prompt = this.theme.searchPrompt("search: ");
1770
+ const inputWidth = Math.max(1, width - visibleWidth(prompt));
1771
+ const inputText = this.searchInput.render(inputWidth)[0] ?? "";
1772
+ lines.push(`${prompt}${this.theme.searchInput(inputText)}`);
1773
+ lines.push("");
1774
+ const query = this.searchInput.getValue().trim();
1775
+ if (this.filteredItems.length === 0) {
1776
+ lines.push(this.theme.noMatch(" No matches"));
1777
+ return lines;
1778
+ }
1779
+ const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible));
1780
+ const endIndex = Math.min(startIndex + this.maxVisible, this.filteredItems.length);
1781
+ for (let i = startIndex; i < endIndex; i++) {
1782
+ const item = this.filteredItems[i];
1783
+ if (!item) continue;
1784
+ const isSelected = i === this.selectedIndex;
1785
+ lines.push(this.renderItemLine(item, isSelected, width, query));
1786
+ }
1787
+ if (this.filteredItems.length > this.maxVisible) {
1788
+ const scrollInfo = `${this.selectedIndex + 1}/${this.filteredItems.length}`;
1789
+ lines.push(this.theme.scrollInfo(` ${scrollInfo}`));
1790
+ }
1791
+ return lines;
1792
+ }
1793
+ renderItemLine(item, isSelected, width, query) {
1794
+ const prefix = isSelected ? "→ " : " ";
1795
+ const prefixWidth = prefix.length;
1796
+ const displayValue = this.getItemLabel(item);
1797
+ const description = item.description;
1798
+ if (description) {
1799
+ const descriptionLayout = this.getDescriptionLayout(width, prefixWidth);
1800
+ if (descriptionLayout) {
1801
+ const truncatedValue = truncateToWidth(displayValue, descriptionLayout.maxValueWidth, "");
1802
+ const valueText = this.highlightMatch(truncatedValue, query);
1803
+ const usedByValue = visibleWidth(valueText);
1804
+ const descriptionWidth = descriptionLayout.availableWidth - usedByValue - descriptionLayout.spacingWidth;
1805
+ if (descriptionWidth >= SearchableSelectList.DESCRIPTION_MIN_WIDTH) {
1806
+ const spacing = " ".repeat(descriptionLayout.spacingWidth);
1807
+ const truncatedDesc = truncateToWidth(description, descriptionWidth, "");
1808
+ const highlightedDesc = this.highlightMatch(truncatedDesc, query);
1809
+ const line = `${prefix}${valueText}${spacing}${isSelected ? highlightedDesc : this.theme.description(highlightedDesc)}`;
1810
+ return isSelected ? this.theme.selectedText(line) : line;
1811
+ }
1812
+ }
1813
+ }
1814
+ const truncatedValue = truncateToWidth(displayValue, width - prefixWidth - 2, "");
1815
+ const line = `${prefix}${this.highlightMatch(truncatedValue, query)}`;
1816
+ return isSelected ? this.theme.selectedText(line) : line;
1817
+ }
1818
+ getDescriptionLayout(width, prefixWidth) {
1819
+ if (width <= SearchableSelectList.DESCRIPTION_LAYOUT_MIN_WIDTH) return null;
1820
+ const availableWidth = Math.max(1, width - prefixWidth - SearchableSelectList.RIGHT_MARGIN_WIDTH);
1821
+ const maxValueWidth = availableWidth - SearchableSelectList.DESCRIPTION_MIN_WIDTH - SearchableSelectList.DESCRIPTION_SPACING_WIDTH;
1822
+ if (maxValueWidth < 1) return null;
1823
+ return {
1824
+ availableWidth,
1825
+ maxValueWidth,
1826
+ spacingWidth: SearchableSelectList.DESCRIPTION_SPACING_WIDTH
1827
+ };
1828
+ }
1829
+ handleInput(keyData) {
1830
+ if (isKeyRelease(keyData)) return;
1831
+ const allowVimNav = !this.searchInput.getValue().trim();
1832
+ if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
1833
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
1834
+ this.notifySelectionChange();
1835
+ return;
1836
+ }
1837
+ if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
1838
+ this.selectedIndex = Math.min(this.filteredItems.length - 1, this.selectedIndex + 1);
1839
+ this.notifySelectionChange();
1840
+ return;
1841
+ }
1842
+ if (matchesKey(keyData, "enter")) {
1843
+ const item = this.filteredItems[this.selectedIndex];
1844
+ if (item && this.onSelect) this.onSelect(item);
1845
+ return;
1846
+ }
1847
+ if (getEditorKeybindings().matches(keyData, "selectCancel")) {
1848
+ if (this.onCancel) this.onCancel();
1849
+ return;
1850
+ }
1851
+ const prevValue = this.searchInput.getValue();
1852
+ this.searchInput.handleInput(keyData);
1853
+ if (prevValue !== this.searchInput.getValue()) this.updateFilter();
1854
+ }
1855
+ notifySelectionChange() {
1856
+ const item = this.filteredItems[this.selectedIndex];
1857
+ if (item && this.onSelectionChange) this.onSelectionChange(item);
1858
+ }
1859
+ getSelectedItem() {
1860
+ return this.filteredItems[this.selectedIndex] ?? null;
1861
+ }
1862
+ };
1863
+ //#endregion
1864
+ //#region src/tui/components/selectors.ts
1865
+ function createSearchableSelectList(items, maxVisible = 7) {
1866
+ return new SearchableSelectList(items, maxVisible, searchableSelectListTheme);
1867
+ }
1868
+ function createFilterableSelectList(items, maxVisible = 7) {
1869
+ return new FilterableSelectList(items, maxVisible, filterableSelectListTheme);
1870
+ }
1871
+ function createSettingsList(items, onChange, onCancel, maxVisible = 7) {
1872
+ return new SettingsList(items, maxVisible, settingsListTheme, onChange, onCancel);
1873
+ }
1874
+ //#endregion
1875
+ //#region src/tui/tui-status-summary.ts
1876
+ function formatStatusSummary(summary) {
1877
+ const lines = [];
1878
+ lines.push("Gateway status");
1879
+ if (summary.runtimeVersion) lines.push(`Version: ${summary.runtimeVersion}`);
1880
+ if (!summary.linkChannel) lines.push("Link channel: unknown");
1881
+ else {
1882
+ const linkLabel = summary.linkChannel.label ?? "Link channel";
1883
+ const linked = summary.linkChannel.linked === true;
1884
+ const authAge = linked && typeof summary.linkChannel.authAgeMs === "number" ? ` (last refreshed ${formatTimeAgo(summary.linkChannel.authAgeMs)})` : "";
1885
+ lines.push(`${linkLabel}: ${linked ? "linked" : "not linked"}${authAge}`);
1886
+ }
1887
+ const providerSummary = Array.isArray(summary.providerSummary) ? summary.providerSummary : [];
1888
+ if (providerSummary.length > 0) {
1889
+ lines.push("");
1890
+ lines.push("System:");
1891
+ for (const line of providerSummary) lines.push(` ${line}`);
1892
+ }
1893
+ const heartbeatAgents = summary.heartbeat?.agents ?? [];
1894
+ if (heartbeatAgents.length > 0) {
1895
+ const heartbeatParts = heartbeatAgents.map((agent) => {
1896
+ const agentId = agent.agentId ?? "unknown";
1897
+ if (!agent.enabled || !agent.everyMs) return `disabled (${agentId})`;
1898
+ return `${agent.every ?? "unknown"} (${agentId})`;
1899
+ });
1900
+ lines.push("");
1901
+ lines.push(`Heartbeat: ${heartbeatParts.join(", ")}`);
1902
+ }
1903
+ const sessionPaths = summary.sessions?.paths ?? [];
1904
+ if (sessionPaths.length === 1) lines.push(`Session store: ${sessionPaths[0]}`);
1905
+ else if (sessionPaths.length > 1) lines.push(`Session stores: ${sessionPaths.length}`);
1906
+ const defaults = summary.sessions?.defaults;
1907
+ const defaultModel = defaults?.model ?? "unknown";
1908
+ const defaultCtx = typeof defaults?.contextTokens === "number" ? ` (${formatTokenCount(defaults.contextTokens)} ctx)` : "";
1909
+ lines.push(`Default model: ${defaultModel}${defaultCtx}`);
1910
+ const sessionCount = summary.sessions?.count ?? 0;
1911
+ lines.push(`Active sessions: ${sessionCount}`);
1912
+ const recent = Array.isArray(summary.sessions?.recent) ? summary.sessions?.recent : [];
1913
+ if (recent.length > 0) {
1914
+ lines.push("Recent sessions:");
1915
+ for (const entry of recent) {
1916
+ const ageLabel = typeof entry.age === "number" ? formatTimeAgo(entry.age) : "no activity";
1917
+ const model = entry.model ?? "unknown";
1918
+ const usage = formatContextUsageLine({
1919
+ total: entry.totalTokens ?? null,
1920
+ context: entry.contextTokens ?? null,
1921
+ remaining: entry.remainingTokens ?? null,
1922
+ percent: entry.percentUsed ?? null
1923
+ });
1924
+ const flags = entry.flags?.length ? ` | flags: ${entry.flags.join(", ")}` : "";
1925
+ lines.push(`- ${entry.key}${entry.kind ? ` [${entry.kind}]` : ""} | ${ageLabel} | model ${model} | ${usage}${flags}`);
1926
+ }
1927
+ }
1928
+ const queued = Array.isArray(summary.queuedSystemEvents) ? summary.queuedSystemEvents : [];
1929
+ if (queued.length > 0) {
1930
+ const preview = queued.slice(0, 3).join(" | ");
1931
+ lines.push(`Queued system events (${queued.length}): ${preview}`);
1932
+ }
1933
+ return lines;
1934
+ }
1935
+ //#endregion
1936
+ //#region src/tui/tui-command-handlers.ts
1937
+ function isBtwCommand(text) {
1938
+ return /^\/btw(?::|\s|$)/i.test(text.trim());
1939
+ }
1940
+ function createCommandHandlers(context) {
1941
+ const { client, chatLog, tui, opts, state, deliverDefault, openOverlay, closeOverlay, refreshSessionInfo, loadHistory, setSession, refreshAgents, abortActive, setActivityStatus, formatSessionKey, applySessionInfoFromPatch, noteLocalRunId, noteLocalBtwRunId, forgetLocalRunId, forgetLocalBtwRunId, requestExit } = context;
1942
+ const setAgent = async (id) => {
1943
+ state.currentAgentId = normalizeAgentId(id);
1944
+ await setSession("");
1945
+ };
1946
+ const closeOverlayAndRender = () => {
1947
+ closeOverlay();
1948
+ tui.requestRender();
1949
+ };
1950
+ const openSelector = (selector, onSelect) => {
1951
+ selector.onSelect = (item) => {
1952
+ (async () => {
1953
+ await onSelect(item.value);
1954
+ closeOverlayAndRender();
1955
+ })();
1956
+ };
1957
+ selector.onCancel = closeOverlayAndRender;
1958
+ openOverlay(selector);
1959
+ tui.requestRender();
1960
+ };
1961
+ const openModelSelector = async () => {
1962
+ try {
1963
+ const models = await client.listModels();
1964
+ if (models.length === 0) {
1965
+ chatLog.addSystem("no models available");
1966
+ tui.requestRender();
1967
+ return;
1968
+ }
1969
+ openSelector(createSearchableSelectList(models.map((model) => ({
1970
+ value: `${model.provider}/${model.id}`,
1971
+ label: `${model.provider}/${model.id}`,
1972
+ description: model.name && model.name !== model.id ? model.name : ""
1973
+ })), 9), async (value) => {
1974
+ try {
1975
+ const result = await client.patchSession({
1976
+ key: state.currentSessionKey,
1977
+ model: value
1978
+ });
1979
+ chatLog.addSystem(`model set to ${value}`);
1980
+ applySessionInfoFromPatch(result);
1981
+ await refreshSessionInfo();
1982
+ } catch (err) {
1983
+ chatLog.addSystem(`model set failed: ${String(err)}`);
1984
+ }
1985
+ });
1986
+ } catch (err) {
1987
+ chatLog.addSystem(`model list failed: ${String(err)}`);
1988
+ tui.requestRender();
1989
+ }
1990
+ };
1991
+ const openAgentSelector = async () => {
1992
+ await refreshAgents();
1993
+ if (state.agents.length === 0) {
1994
+ chatLog.addSystem("no agents found");
1995
+ tui.requestRender();
1996
+ return;
1997
+ }
1998
+ openSelector(createSearchableSelectList(state.agents.map((agent) => ({
1999
+ value: agent.id,
2000
+ label: agent.name ? `${agent.id} (${agent.name})` : agent.id,
2001
+ description: agent.id === state.agentDefaultId ? "default" : ""
2002
+ })), 9), async (value) => {
2003
+ await setAgent(value);
2004
+ });
2005
+ };
2006
+ const openSessionSelector = async () => {
2007
+ try {
2008
+ openSelector(createFilterableSelectList((await client.listSessions({
2009
+ includeGlobal: false,
2010
+ includeUnknown: false,
2011
+ includeDerivedTitles: true,
2012
+ includeLastMessage: true,
2013
+ agentId: state.currentAgentId
2014
+ })).sessions.map((session) => {
2015
+ const title = session.derivedTitle ?? session.displayName;
2016
+ const formattedKey = formatSessionKey(session.key);
2017
+ const label = title && title !== formattedKey ? `${title} (${formattedKey})` : formattedKey;
2018
+ const timePart = session.updatedAt ? formatRelativeTimestamp(session.updatedAt, {
2019
+ dateFallback: true,
2020
+ fallback: ""
2021
+ }) : "";
2022
+ const preview = session.lastMessagePreview?.replace(/\s+/g, " ").trim();
2023
+ const description = timePart && preview ? `${timePart} · ${preview}` : preview ?? timePart;
2024
+ return {
2025
+ value: session.key,
2026
+ label,
2027
+ description,
2028
+ searchText: [
2029
+ session.displayName,
2030
+ session.label,
2031
+ session.subject,
2032
+ session.sessionId,
2033
+ session.key,
2034
+ session.lastMessagePreview
2035
+ ].filter(Boolean).join(" ")
2036
+ };
2037
+ }), 9), async (value) => {
2038
+ await setSession(value);
2039
+ });
2040
+ } catch (err) {
2041
+ chatLog.addSystem(`sessions list failed: ${String(err)}`);
2042
+ tui.requestRender();
2043
+ }
2044
+ };
2045
+ const openSettings = () => {
2046
+ openOverlay(createSettingsList([{
2047
+ id: "tools",
2048
+ label: "Tool output",
2049
+ currentValue: state.toolsExpanded ? "expanded" : "collapsed",
2050
+ values: ["collapsed", "expanded"]
2051
+ }, {
2052
+ id: "thinking",
2053
+ label: "Show thinking",
2054
+ currentValue: state.showThinking ? "on" : "off",
2055
+ values: ["off", "on"]
2056
+ }], (id, value) => {
2057
+ if (id === "tools") {
2058
+ state.toolsExpanded = value === "expanded";
2059
+ chatLog.setToolsExpanded(state.toolsExpanded);
2060
+ }
2061
+ if (id === "thinking") {
2062
+ state.showThinking = value === "on";
2063
+ loadHistory();
2064
+ }
2065
+ tui.requestRender();
2066
+ }, () => {
2067
+ closeOverlay();
2068
+ tui.requestRender();
2069
+ }));
2070
+ tui.requestRender();
2071
+ };
2072
+ const handleCommand = async (raw) => {
2073
+ const { name, args } = parseCommand(raw);
2074
+ if (!name) return;
2075
+ switch (name) {
2076
+ case "help":
2077
+ chatLog.addSystem(helpText({
2078
+ provider: state.sessionInfo.modelProvider,
2079
+ model: state.sessionInfo.model
2080
+ }));
2081
+ break;
2082
+ case "status":
2083
+ try {
2084
+ const status = await client.getStatus();
2085
+ if (typeof status === "string") {
2086
+ chatLog.addSystem(status);
2087
+ break;
2088
+ }
2089
+ if (status && typeof status === "object") {
2090
+ const lines = formatStatusSummary(status);
2091
+ for (const line of lines) chatLog.addSystem(line);
2092
+ break;
2093
+ }
2094
+ chatLog.addSystem("status: unknown response");
2095
+ } catch (err) {
2096
+ chatLog.addSystem(`status failed: ${String(err)}`);
2097
+ }
2098
+ break;
2099
+ case "agent":
2100
+ if (!args) await openAgentSelector();
2101
+ else await setAgent(args);
2102
+ break;
2103
+ case "agents":
2104
+ await openAgentSelector();
2105
+ break;
2106
+ case "session":
2107
+ if (!args) await openSessionSelector();
2108
+ else await setSession(args);
2109
+ break;
2110
+ case "sessions":
2111
+ await openSessionSelector();
2112
+ break;
2113
+ case "model":
2114
+ if (!args) await openModelSelector();
2115
+ else try {
2116
+ const result = await client.patchSession({
2117
+ key: state.currentSessionKey,
2118
+ model: args
2119
+ });
2120
+ chatLog.addSystem(`model set to ${args}`);
2121
+ applySessionInfoFromPatch(result);
2122
+ await refreshSessionInfo();
2123
+ } catch (err) {
2124
+ chatLog.addSystem(`model set failed: ${String(err)}`);
2125
+ }
2126
+ break;
2127
+ case "models":
2128
+ await openModelSelector();
2129
+ break;
2130
+ case "think":
2131
+ if (!args) {
2132
+ const levels = formatThinkingLevels(state.sessionInfo.modelProvider, state.sessionInfo.model, "|");
2133
+ chatLog.addSystem(`usage: /think <${levels}>`);
2134
+ break;
2135
+ }
2136
+ try {
2137
+ const result = await client.patchSession({
2138
+ key: state.currentSessionKey,
2139
+ thinkingLevel: args
2140
+ });
2141
+ chatLog.addSystem(`thinking set to ${args}`);
2142
+ applySessionInfoFromPatch(result);
2143
+ await refreshSessionInfo();
2144
+ } catch (err) {
2145
+ chatLog.addSystem(`think failed: ${String(err)}`);
2146
+ }
2147
+ break;
2148
+ case "verbose":
2149
+ if (!args) {
2150
+ chatLog.addSystem("usage: /verbose <on|off>");
2151
+ break;
2152
+ }
2153
+ try {
2154
+ const result = await client.patchSession({
2155
+ key: state.currentSessionKey,
2156
+ verboseLevel: args
2157
+ });
2158
+ chatLog.addSystem(`verbose set to ${args}`);
2159
+ applySessionInfoFromPatch(result);
2160
+ await loadHistory();
2161
+ } catch (err) {
2162
+ chatLog.addSystem(`verbose failed: ${String(err)}`);
2163
+ }
2164
+ break;
2165
+ case "fast":
2166
+ if (!args || args === "status") {
2167
+ chatLog.addSystem(`fast mode: ${state.sessionInfo.fastMode ? "on" : "off"}`);
2168
+ break;
2169
+ }
2170
+ if (args !== "on" && args !== "off") {
2171
+ chatLog.addSystem("usage: /fast <status|on|off>");
2172
+ break;
2173
+ }
2174
+ try {
2175
+ const result = await client.patchSession({
2176
+ key: state.currentSessionKey,
2177
+ fastMode: args === "on"
2178
+ });
2179
+ chatLog.addSystem(`fast mode ${args === "on" ? "enabled" : "disabled"}`);
2180
+ applySessionInfoFromPatch(result);
2181
+ await refreshSessionInfo();
2182
+ } catch (err) {
2183
+ chatLog.addSystem(`fast failed: ${String(err)}`);
2184
+ }
2185
+ break;
2186
+ case "reasoning":
2187
+ if (!args) {
2188
+ chatLog.addSystem("usage: /reasoning <on|off>");
2189
+ break;
2190
+ }
2191
+ try {
2192
+ const result = await client.patchSession({
2193
+ key: state.currentSessionKey,
2194
+ reasoningLevel: args
2195
+ });
2196
+ chatLog.addSystem(`reasoning set to ${args}`);
2197
+ applySessionInfoFromPatch(result);
2198
+ await refreshSessionInfo();
2199
+ } catch (err) {
2200
+ chatLog.addSystem(`reasoning failed: ${String(err)}`);
2201
+ }
2202
+ break;
2203
+ case "usage": {
2204
+ const normalized = args ? normalizeUsageDisplay(args) : void 0;
2205
+ if (args && !normalized) {
2206
+ chatLog.addSystem("usage: /usage <off|tokens|full>");
2207
+ break;
2208
+ }
2209
+ const currentRaw = state.sessionInfo.responseUsage;
2210
+ const current = resolveResponseUsageMode(currentRaw);
2211
+ const next = normalized ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
2212
+ try {
2213
+ const result = await client.patchSession({
2214
+ key: state.currentSessionKey,
2215
+ responseUsage: next === "off" ? null : next
2216
+ });
2217
+ chatLog.addSystem(`usage footer: ${next}`);
2218
+ applySessionInfoFromPatch(result);
2219
+ await refreshSessionInfo();
2220
+ } catch (err) {
2221
+ chatLog.addSystem(`usage failed: ${String(err)}`);
2222
+ }
2223
+ break;
2224
+ }
2225
+ case "elevated":
2226
+ if (!args) {
2227
+ chatLog.addSystem("usage: /elevated <on|off|ask|full>");
2228
+ break;
2229
+ }
2230
+ if (![
2231
+ "on",
2232
+ "off",
2233
+ "ask",
2234
+ "full"
2235
+ ].includes(args)) {
2236
+ chatLog.addSystem("usage: /elevated <on|off|ask|full>");
2237
+ break;
2238
+ }
2239
+ try {
2240
+ const result = await client.patchSession({
2241
+ key: state.currentSessionKey,
2242
+ elevatedLevel: args
2243
+ });
2244
+ chatLog.addSystem(`elevated set to ${args}`);
2245
+ applySessionInfoFromPatch(result);
2246
+ await refreshSessionInfo();
2247
+ } catch (err) {
2248
+ chatLog.addSystem(`elevated failed: ${String(err)}`);
2249
+ }
2250
+ break;
2251
+ case "activation":
2252
+ if (!args) {
2253
+ chatLog.addSystem("usage: /activation <mention|always>");
2254
+ break;
2255
+ }
2256
+ try {
2257
+ const result = await client.patchSession({
2258
+ key: state.currentSessionKey,
2259
+ groupActivation: args === "always" ? "always" : "mention"
2260
+ });
2261
+ chatLog.addSystem(`activation set to ${args}`);
2262
+ applySessionInfoFromPatch(result);
2263
+ await refreshSessionInfo();
2264
+ } catch (err) {
2265
+ chatLog.addSystem(`activation failed: ${String(err)}`);
2266
+ }
2267
+ break;
2268
+ case "new":
2269
+ try {
2270
+ state.sessionInfo.inputTokens = null;
2271
+ state.sessionInfo.outputTokens = null;
2272
+ state.sessionInfo.totalTokens = null;
2273
+ tui.requestRender();
2274
+ const uniqueKey = `tui-${randomUUID()}`;
2275
+ await setSession(uniqueKey);
2276
+ chatLog.addSystem(`new session: ${uniqueKey}`);
2277
+ } catch (err) {
2278
+ chatLog.addSystem(`new session failed: ${sanitizeRenderableText(String(err))}`);
2279
+ }
2280
+ break;
2281
+ case "reset":
2282
+ try {
2283
+ state.sessionInfo.inputTokens = null;
2284
+ state.sessionInfo.outputTokens = null;
2285
+ state.sessionInfo.totalTokens = null;
2286
+ tui.requestRender();
2287
+ await client.resetSession(state.currentSessionKey, name);
2288
+ chatLog.addSystem(`session ${state.currentSessionKey} reset`);
2289
+ await loadHistory();
2290
+ } catch (err) {
2291
+ chatLog.addSystem(`reset failed: ${sanitizeRenderableText(String(err))}`);
2292
+ }
2293
+ break;
2294
+ case "abort":
2295
+ await abortActive();
2296
+ break;
2297
+ case "settings":
2298
+ openSettings();
2299
+ break;
2300
+ case "exit":
2301
+ case "quit":
2302
+ requestExit();
2303
+ break;
2304
+ default:
2305
+ await sendMessage(raw);
2306
+ break;
2307
+ }
2308
+ tui.requestRender();
2309
+ };
2310
+ const sendMessage = async (text) => {
2311
+ if (!state.isConnected) {
2312
+ chatLog.addSystem("not connected to gateway — message not sent");
2313
+ setActivityStatus("disconnected");
2314
+ tui.requestRender();
2315
+ return;
2316
+ }
2317
+ const isBtw = isBtwCommand(text);
2318
+ const runId = randomUUID();
2319
+ try {
2320
+ if (!isBtw) {
2321
+ chatLog.addUser(text);
2322
+ noteLocalRunId(runId);
2323
+ state.activeChatRunId = runId;
2324
+ setActivityStatus("sending");
2325
+ } else noteLocalBtwRunId?.(runId);
2326
+ tui.requestRender();
2327
+ await client.sendChat({
2328
+ sessionKey: state.currentSessionKey,
2329
+ message: text,
2330
+ thinking: opts.thinking,
2331
+ deliver: deliverDefault,
2332
+ timeoutMs: opts.timeoutMs,
2333
+ runId
2334
+ });
2335
+ if (!isBtw) {
2336
+ setActivityStatus("waiting");
2337
+ tui.requestRender();
2338
+ }
2339
+ } catch (err) {
2340
+ if (isBtw) forgetLocalBtwRunId?.(runId);
2341
+ if (!isBtw && state.activeChatRunId) forgetLocalRunId?.(state.activeChatRunId);
2342
+ if (!isBtw) state.activeChatRunId = null;
2343
+ chatLog.addSystem(`${isBtw ? "btw failed" : "send failed"}: ${String(err)}`);
2344
+ if (!isBtw) setActivityStatus("error");
2345
+ tui.requestRender();
2346
+ }
2347
+ };
2348
+ return {
2349
+ handleCommand,
2350
+ sendMessage,
2351
+ openModelSelector,
2352
+ openAgentSelector,
2353
+ openSessionSelector,
2354
+ openSettings,
2355
+ setAgent
2356
+ };
2357
+ }
2358
+ //#endregion
2359
+ //#region src/tui/tui-stream-assembler.ts
2360
+ function extractTextBlocksAndSignals(message) {
2361
+ if (!message || typeof message !== "object") return {
2362
+ textBlocks: [],
2363
+ sawNonTextContentBlocks: false
2364
+ };
2365
+ const content = message.content;
2366
+ if (typeof content === "string") {
2367
+ const text = content.trim();
2368
+ return {
2369
+ textBlocks: text ? [text] : [],
2370
+ sawNonTextContentBlocks: false
2371
+ };
2372
+ }
2373
+ if (!Array.isArray(content)) return {
2374
+ textBlocks: [],
2375
+ sawNonTextContentBlocks: false
2376
+ };
2377
+ const textBlocks = [];
2378
+ let sawNonTextContentBlocks = false;
2379
+ for (const block of content) {
2380
+ if (!block || typeof block !== "object") continue;
2381
+ const rec = block;
2382
+ if (rec.type === "text" && typeof rec.text === "string") {
2383
+ const text = rec.text.trim();
2384
+ if (text) textBlocks.push(text);
2385
+ continue;
2386
+ }
2387
+ if (typeof rec.type === "string" && rec.type !== "thinking") sawNonTextContentBlocks = true;
2388
+ }
2389
+ return {
2390
+ textBlocks,
2391
+ sawNonTextContentBlocks
2392
+ };
2393
+ }
2394
+ function isDroppedBoundaryTextBlockSubset(params) {
2395
+ const { streamedTextBlocks, finalTextBlocks } = params;
2396
+ if (finalTextBlocks.length === 0 || finalTextBlocks.length >= streamedTextBlocks.length) return false;
2397
+ if (finalTextBlocks.every((block, index) => streamedTextBlocks[index] === block)) return true;
2398
+ const suffixStart = streamedTextBlocks.length - finalTextBlocks.length;
2399
+ return finalTextBlocks.every((block, index) => streamedTextBlocks[suffixStart + index] === block);
2400
+ }
2401
+ function shouldPreserveBoundaryDroppedText(params) {
2402
+ if (params.boundaryDropMode === "off") return false;
2403
+ if (!(params.boundaryDropMode === "streamed-or-incoming" ? params.streamedSawNonTextContentBlocks || params.incomingSawNonTextContentBlocks : params.streamedSawNonTextContentBlocks)) return false;
2404
+ return isDroppedBoundaryTextBlockSubset({
2405
+ streamedTextBlocks: params.streamedTextBlocks,
2406
+ finalTextBlocks: params.nextContentBlocks
2407
+ });
2408
+ }
2409
+ var TuiStreamAssembler = class {
2410
+ constructor() {
2411
+ this.runs = /* @__PURE__ */ new Map();
2412
+ }
2413
+ getOrCreateRun(runId) {
2414
+ let state = this.runs.get(runId);
2415
+ if (!state) {
2416
+ state = {
2417
+ thinkingText: "",
2418
+ contentText: "",
2419
+ contentBlocks: [],
2420
+ sawNonTextContentBlocks: false,
2421
+ displayText: ""
2422
+ };
2423
+ this.runs.set(runId, state);
2424
+ }
2425
+ return state;
2426
+ }
2427
+ updateRunState(state, message, showThinking, opts) {
2428
+ const thinkingText = extractThinkingFromMessage(message);
2429
+ const contentText = extractContentFromMessage(message);
2430
+ const { textBlocks, sawNonTextContentBlocks } = extractTextBlocksAndSignals(message);
2431
+ if (thinkingText) state.thinkingText = thinkingText;
2432
+ if (contentText) {
2433
+ const nextContentBlocks = textBlocks.length > 0 ? textBlocks : [contentText];
2434
+ if (!shouldPreserveBoundaryDroppedText({
2435
+ boundaryDropMode: opts?.boundaryDropMode ?? "off",
2436
+ streamedSawNonTextContentBlocks: state.sawNonTextContentBlocks,
2437
+ incomingSawNonTextContentBlocks: sawNonTextContentBlocks,
2438
+ streamedTextBlocks: state.contentBlocks,
2439
+ nextContentBlocks
2440
+ })) {
2441
+ state.contentText = contentText;
2442
+ state.contentBlocks = nextContentBlocks;
2443
+ }
2444
+ }
2445
+ if (sawNonTextContentBlocks) state.sawNonTextContentBlocks = true;
2446
+ state.displayText = composeThinkingAndContent({
2447
+ thinkingText: state.thinkingText,
2448
+ contentText: state.contentText,
2449
+ showThinking
2450
+ });
2451
+ }
2452
+ ingestDelta(runId, message, showThinking) {
2453
+ const state = this.getOrCreateRun(runId);
2454
+ const previousDisplayText = state.displayText;
2455
+ this.updateRunState(state, message, showThinking, { boundaryDropMode: "streamed-or-incoming" });
2456
+ if (!state.displayText || state.displayText === previousDisplayText) return null;
2457
+ return state.displayText;
2458
+ }
2459
+ finalize(runId, message, showThinking, errorMessage) {
2460
+ const state = this.getOrCreateRun(runId);
2461
+ const streamedDisplayText = state.displayText;
2462
+ const streamedTextBlocks = [...state.contentBlocks];
2463
+ const streamedSawNonTextContentBlocks = state.sawNonTextContentBlocks;
2464
+ this.updateRunState(state, message, showThinking, { boundaryDropMode: "streamed-only" });
2465
+ const finalComposed = state.displayText;
2466
+ const finalText = resolveFinalAssistantText({
2467
+ finalText: streamedSawNonTextContentBlocks && isDroppedBoundaryTextBlockSubset({
2468
+ streamedTextBlocks,
2469
+ finalTextBlocks: state.contentBlocks
2470
+ }) ? streamedDisplayText : finalComposed,
2471
+ streamedText: streamedDisplayText,
2472
+ errorMessage
2473
+ });
2474
+ this.runs.delete(runId);
2475
+ return finalText;
2476
+ }
2477
+ drop(runId) {
2478
+ this.runs.delete(runId);
2479
+ }
2480
+ };
2481
+ //#endregion
2482
+ //#region src/tui/tui-event-handlers.ts
2483
+ function createEventHandlers(context) {
2484
+ const { chatLog, btw, tui, state, setActivityStatus, refreshSessionInfo, loadHistory, isLocalRunId, forgetLocalRunId, clearLocalRunIds, isLocalBtwRunId, forgetLocalBtwRunId, clearLocalBtwRunIds } = context;
2485
+ const finalizedRuns = /* @__PURE__ */ new Map();
2486
+ const sessionRuns = /* @__PURE__ */ new Map();
2487
+ let streamAssembler = new TuiStreamAssembler();
2488
+ let lastSessionKey = state.currentSessionKey;
2489
+ const pruneRunMap = (runs) => {
2490
+ if (runs.size <= 200) return;
2491
+ const keepUntil = Date.now() - 600 * 1e3;
2492
+ for (const [key, ts] of runs) {
2493
+ if (runs.size <= 150) break;
2494
+ if (ts < keepUntil) runs.delete(key);
2495
+ }
2496
+ if (runs.size > 200) for (const key of runs.keys()) {
2497
+ runs.delete(key);
2498
+ if (runs.size <= 150) break;
2499
+ }
2500
+ };
2501
+ const syncSessionKey = () => {
2502
+ if (state.currentSessionKey === lastSessionKey) return;
2503
+ lastSessionKey = state.currentSessionKey;
2504
+ finalizedRuns.clear();
2505
+ sessionRuns.clear();
2506
+ streamAssembler = new TuiStreamAssembler();
2507
+ clearLocalRunIds?.();
2508
+ clearLocalBtwRunIds?.();
2509
+ btw.clear();
2510
+ };
2511
+ const noteSessionRun = (runId) => {
2512
+ sessionRuns.set(runId, Date.now());
2513
+ pruneRunMap(sessionRuns);
2514
+ };
2515
+ const noteFinalizedRun = (runId) => {
2516
+ finalizedRuns.set(runId, Date.now());
2517
+ sessionRuns.delete(runId);
2518
+ streamAssembler.drop(runId);
2519
+ pruneRunMap(finalizedRuns);
2520
+ };
2521
+ const clearActiveRunIfMatch = (runId) => {
2522
+ if (state.activeChatRunId === runId) state.activeChatRunId = null;
2523
+ };
2524
+ const finalizeRun = (params) => {
2525
+ noteFinalizedRun(params.runId);
2526
+ clearActiveRunIfMatch(params.runId);
2527
+ if (params.wasActiveRun) setActivityStatus(params.status);
2528
+ refreshSessionInfo?.();
2529
+ };
2530
+ const terminateRun = (params) => {
2531
+ streamAssembler.drop(params.runId);
2532
+ sessionRuns.delete(params.runId);
2533
+ clearActiveRunIfMatch(params.runId);
2534
+ if (params.wasActiveRun) setActivityStatus(params.status);
2535
+ refreshSessionInfo?.();
2536
+ };
2537
+ const hasConcurrentActiveRun = (runId) => {
2538
+ const activeRunId = state.activeChatRunId;
2539
+ if (!activeRunId || activeRunId === runId) return false;
2540
+ return sessionRuns.has(activeRunId);
2541
+ };
2542
+ const maybeRefreshHistoryForRun = (runId, opts) => {
2543
+ if (isLocalRunId?.(runId) ?? false) {
2544
+ forgetLocalRunId?.(runId);
2545
+ if (!opts?.allowLocalWithoutDisplayableFinal) return;
2546
+ }
2547
+ if (hasConcurrentActiveRun(runId)) return;
2548
+ loadHistory?.();
2549
+ };
2550
+ const isSameSessionKey = (left, right) => {
2551
+ const normalizedLeft = (left ?? "").trim().toLowerCase();
2552
+ const normalizedRight = (right ?? "").trim().toLowerCase();
2553
+ if (!normalizedLeft || !normalizedRight) return false;
2554
+ if (normalizedLeft === normalizedRight) return true;
2555
+ const parsedLeft = parseAgentSessionKey(normalizedLeft);
2556
+ const parsedRight = parseAgentSessionKey(normalizedRight);
2557
+ if (parsedLeft && parsedRight) return parsedLeft.agentId === parsedRight.agentId && parsedLeft.rest === parsedRight.rest;
2558
+ if (parsedLeft) return parsedLeft.rest === normalizedRight;
2559
+ if (parsedRight) return normalizedLeft === parsedRight.rest;
2560
+ return false;
2561
+ };
2562
+ const handleChatEvent = (payload) => {
2563
+ if (!payload || typeof payload !== "object") return;
2564
+ const evt = payload;
2565
+ syncSessionKey();
2566
+ if (!isSameSessionKey(evt.sessionKey, state.currentSessionKey)) return;
2567
+ if (finalizedRuns.has(evt.runId)) {
2568
+ if (evt.state === "delta") return;
2569
+ if (evt.state === "final") return;
2570
+ }
2571
+ noteSessionRun(evt.runId);
2572
+ if (!state.activeChatRunId && !isLocalBtwRunId?.(evt.runId)) state.activeChatRunId = evt.runId;
2573
+ if (evt.state === "delta") {
2574
+ const displayText = streamAssembler.ingestDelta(evt.runId, evt.message, state.showThinking);
2575
+ if (!displayText) return;
2576
+ chatLog.updateAssistant(displayText, evt.runId);
2577
+ setActivityStatus("streaming");
2578
+ }
2579
+ if (evt.state === "final") {
2580
+ const isLocalBtwRun = isLocalBtwRunId?.(evt.runId) ?? false;
2581
+ const wasActiveRun = state.activeChatRunId === evt.runId;
2582
+ if (!evt.message && isLocalBtwRun) {
2583
+ forgetLocalBtwRunId?.(evt.runId);
2584
+ noteFinalizedRun(evt.runId);
2585
+ tui.requestRender();
2586
+ return;
2587
+ }
2588
+ if (!evt.message) {
2589
+ maybeRefreshHistoryForRun(evt.runId, { allowLocalWithoutDisplayableFinal: true });
2590
+ chatLog.dropAssistant(evt.runId);
2591
+ finalizeRun({
2592
+ runId: evt.runId,
2593
+ wasActiveRun,
2594
+ status: "idle"
2595
+ });
2596
+ tui.requestRender();
2597
+ return;
2598
+ }
2599
+ if (isCommandMessage(evt.message)) {
2600
+ maybeRefreshHistoryForRun(evt.runId);
2601
+ const text = extractTextFromMessage(evt.message);
2602
+ if (text) chatLog.addSystem(text);
2603
+ finalizeRun({
2604
+ runId: evt.runId,
2605
+ wasActiveRun,
2606
+ status: "idle"
2607
+ });
2608
+ tui.requestRender();
2609
+ return;
2610
+ }
2611
+ maybeRefreshHistoryForRun(evt.runId);
2612
+ const stopReason = evt.message && typeof evt.message === "object" && !Array.isArray(evt.message) ? typeof evt.message.stopReason === "string" ? evt.message.stopReason : "" : "";
2613
+ const finalText = streamAssembler.finalize(evt.runId, evt.message, state.showThinking, evt.errorMessage);
2614
+ if (finalText === "(no output)" && !isLocalRunId?.(evt.runId)) chatLog.dropAssistant(evt.runId);
2615
+ else chatLog.finalizeAssistant(finalText, evt.runId);
2616
+ finalizeRun({
2617
+ runId: evt.runId,
2618
+ wasActiveRun,
2619
+ status: stopReason === "error" ? "error" : "idle"
2620
+ });
2621
+ }
2622
+ if (evt.state === "aborted") {
2623
+ forgetLocalBtwRunId?.(evt.runId);
2624
+ const wasActiveRun = state.activeChatRunId === evt.runId;
2625
+ chatLog.addSystem("run aborted");
2626
+ terminateRun({
2627
+ runId: evt.runId,
2628
+ wasActiveRun,
2629
+ status: "aborted"
2630
+ });
2631
+ maybeRefreshHistoryForRun(evt.runId);
2632
+ }
2633
+ if (evt.state === "error") {
2634
+ forgetLocalBtwRunId?.(evt.runId);
2635
+ const wasActiveRun = state.activeChatRunId === evt.runId;
2636
+ chatLog.addSystem(`run error: ${evt.errorMessage ?? "unknown"}`);
2637
+ terminateRun({
2638
+ runId: evt.runId,
2639
+ wasActiveRun,
2640
+ status: "error"
2641
+ });
2642
+ maybeRefreshHistoryForRun(evt.runId);
2643
+ }
2644
+ tui.requestRender();
2645
+ };
2646
+ const handleAgentEvent = (payload) => {
2647
+ if (!payload || typeof payload !== "object") return;
2648
+ const evt = payload;
2649
+ syncSessionKey();
2650
+ const isActiveRun = evt.runId === state.activeChatRunId;
2651
+ if (!(isActiveRun || sessionRuns.has(evt.runId) || finalizedRuns.has(evt.runId))) return;
2652
+ if (evt.stream === "tool") {
2653
+ const verbose = state.sessionInfo.verboseLevel ?? "off";
2654
+ const allowToolEvents = verbose !== "off";
2655
+ const allowToolOutput = verbose === "full";
2656
+ if (!allowToolEvents) return;
2657
+ const data = evt.data ?? {};
2658
+ const phase = asString(data.phase, "");
2659
+ const toolCallId = asString(data.toolCallId, "");
2660
+ const toolName = asString(data.name, "tool");
2661
+ if (!toolCallId) return;
2662
+ if (phase === "start") chatLog.startTool(toolCallId, toolName, data.args);
2663
+ else if (phase === "update") {
2664
+ if (!allowToolOutput) return;
2665
+ chatLog.updateToolResult(toolCallId, data.partialResult, { partial: true });
2666
+ } else if (phase === "result") if (allowToolOutput) chatLog.updateToolResult(toolCallId, data.result, { isError: Boolean(data.isError) });
2667
+ else chatLog.updateToolResult(toolCallId, { content: [] }, { isError: Boolean(data.isError) });
2668
+ tui.requestRender();
2669
+ return;
2670
+ }
2671
+ if (evt.stream === "lifecycle") {
2672
+ if (!isActiveRun) return;
2673
+ const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
2674
+ if (phase === "start") setActivityStatus("running");
2675
+ if (phase === "end") setActivityStatus("idle");
2676
+ if (phase === "error") setActivityStatus("error");
2677
+ tui.requestRender();
2678
+ }
2679
+ };
2680
+ const handleBtwEvent = (payload) => {
2681
+ if (!payload || typeof payload !== "object") return;
2682
+ const evt = payload;
2683
+ syncSessionKey();
2684
+ if (!isSameSessionKey(evt.sessionKey, state.currentSessionKey)) return;
2685
+ if (evt.kind !== "btw") return;
2686
+ const question = evt.question.trim();
2687
+ const text = evt.text.trim();
2688
+ if (!question || !text) return;
2689
+ btw.showResult({
2690
+ question,
2691
+ text,
2692
+ isError: evt.isError
2693
+ });
2694
+ tui.requestRender();
2695
+ };
2696
+ return {
2697
+ handleChatEvent,
2698
+ handleAgentEvent,
2699
+ handleBtwEvent
2700
+ };
2701
+ }
2702
+ //#endregion
2703
+ //#region src/tui/tui-local-shell.ts
2704
+ function createLocalShellRunner(deps) {
2705
+ let localExecAsked = false;
2706
+ let localExecAllowed = false;
2707
+ const createSelector = deps.createSelector ?? createSearchableSelectList;
2708
+ const spawnCommand = deps.spawnCommand ?? spawn;
2709
+ const getCwd = deps.getCwd ?? (() => process.cwd());
2710
+ const env = deps.env ?? process.env;
2711
+ const maxChars = deps.maxOutputChars ?? 4e4;
2712
+ const ensureLocalExecAllowed = async () => {
2713
+ if (localExecAllowed) return true;
2714
+ if (localExecAsked) return false;
2715
+ localExecAsked = true;
2716
+ return await new Promise((resolve) => {
2717
+ deps.chatLog.addSystem("Allow local shell commands for this session?");
2718
+ deps.chatLog.addSystem("This runs commands on YOUR machine (not the gateway) and may delete files or reveal secrets.");
2719
+ deps.chatLog.addSystem("Select Yes/No (arrows + Enter), Esc to cancel.");
2720
+ const selector = createSelector([{
2721
+ value: "no",
2722
+ label: "No"
2723
+ }, {
2724
+ value: "yes",
2725
+ label: "Yes"
2726
+ }], 2);
2727
+ selector.onSelect = (item) => {
2728
+ deps.closeOverlay();
2729
+ if (item.value === "yes") {
2730
+ localExecAllowed = true;
2731
+ deps.chatLog.addSystem("local shell: enabled for this session");
2732
+ resolve(true);
2733
+ } else {
2734
+ deps.chatLog.addSystem("local shell: not enabled");
2735
+ resolve(false);
2736
+ }
2737
+ deps.tui.requestRender();
2738
+ };
2739
+ selector.onCancel = () => {
2740
+ deps.closeOverlay();
2741
+ deps.chatLog.addSystem("local shell: cancelled");
2742
+ deps.tui.requestRender();
2743
+ resolve(false);
2744
+ };
2745
+ deps.openOverlay(selector);
2746
+ deps.tui.requestRender();
2747
+ });
2748
+ };
2749
+ const runLocalShellLine = async (line) => {
2750
+ const cmd = line.slice(1);
2751
+ if (cmd === "") return;
2752
+ if (localExecAsked && !localExecAllowed) {
2753
+ deps.chatLog.addSystem("local shell: not enabled for this session");
2754
+ deps.tui.requestRender();
2755
+ return;
2756
+ }
2757
+ if (!await ensureLocalExecAllowed()) return;
2758
+ deps.chatLog.addSystem(`[local] $ ${cmd}`);
2759
+ deps.tui.requestRender();
2760
+ const appendWithCap = (text, chunk) => {
2761
+ const combined = text + chunk;
2762
+ return combined.length > maxChars ? combined.slice(-maxChars) : combined;
2763
+ };
2764
+ await new Promise((resolve) => {
2765
+ const child = spawnCommand(cmd, {
2766
+ shell: true,
2767
+ cwd: getCwd(),
2768
+ env: {
2769
+ ...env,
2770
+ OPENCLAW_SHELL: "tui-local"
2771
+ }
2772
+ });
2773
+ let stdout = "";
2774
+ let stderr = "";
2775
+ child.stdout.on("data", (buf) => {
2776
+ stdout = appendWithCap(stdout, buf.toString("utf8"));
2777
+ });
2778
+ child.stderr.on("data", (buf) => {
2779
+ stderr = appendWithCap(stderr, buf.toString("utf8"));
2780
+ });
2781
+ child.on("close", (code, signal) => {
2782
+ const combined = (stdout + (stderr ? (stdout ? "\n" : "") + stderr : "")).slice(0, maxChars).trimEnd();
2783
+ if (combined) for (const line of combined.split("\n")) deps.chatLog.addSystem(`[local] ${line}`);
2784
+ deps.chatLog.addSystem(`[local] exit ${code ?? "?"}${signal ? ` (signal ${String(signal)})` : ""}`);
2785
+ deps.tui.requestRender();
2786
+ resolve();
2787
+ });
2788
+ child.on("error", (err) => {
2789
+ deps.chatLog.addSystem(`[local] error: ${String(err)}`);
2790
+ deps.tui.requestRender();
2791
+ resolve();
2792
+ });
2793
+ });
2794
+ };
2795
+ return { runLocalShellLine };
2796
+ }
2797
+ //#endregion
2798
+ //#region src/tui/tui-overlays.ts
2799
+ function createOverlayHandlers(host, fallbackFocus) {
2800
+ const openOverlay = (component) => {
2801
+ host.showOverlay(component);
2802
+ };
2803
+ const closeOverlay = () => {
2804
+ if (host.hasOverlay()) {
2805
+ host.hideOverlay();
2806
+ return;
2807
+ }
2808
+ host.setFocus(fallbackFocus);
2809
+ };
2810
+ return {
2811
+ openOverlay,
2812
+ closeOverlay
2813
+ };
2814
+ }
2815
+ //#endregion
2816
+ //#region src/tui/tui-session-actions.ts
2817
+ function createSessionActions(context) {
2818
+ const { client, chatLog, btw, tui, opts, state, agentNames, initialSessionInput, initialSessionAgentId, resolveSessionKey, updateHeader, updateFooter, updateAutocompleteProvider, setActivityStatus, clearLocalRunIds } = context;
2819
+ let refreshSessionInfoPromise = Promise.resolve();
2820
+ let lastSessionDefaults = null;
2821
+ const applyAgentsResult = (result) => {
2822
+ state.agentDefaultId = normalizeAgentId(result.defaultId);
2823
+ state.sessionMainKey = normalizeMainKey(result.mainKey);
2824
+ state.sessionScope = result.scope ?? state.sessionScope;
2825
+ state.agents = result.agents.map((agent) => ({
2826
+ id: normalizeAgentId(agent.id),
2827
+ name: agent.name?.trim() || void 0
2828
+ }));
2829
+ agentNames.clear();
2830
+ for (const agent of state.agents) if (agent.name) agentNames.set(agent.id, agent.name);
2831
+ if (!state.initialSessionApplied) {
2832
+ if (initialSessionAgentId) {
2833
+ if (state.agents.some((agent) => agent.id === initialSessionAgentId)) state.currentAgentId = initialSessionAgentId;
2834
+ } else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
2835
+ const nextSessionKey = resolveSessionKey(initialSessionInput);
2836
+ if (nextSessionKey !== state.currentSessionKey) state.currentSessionKey = nextSessionKey;
2837
+ state.initialSessionApplied = true;
2838
+ } else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
2839
+ updateHeader();
2840
+ updateFooter();
2841
+ };
2842
+ const refreshAgents = async () => {
2843
+ try {
2844
+ applyAgentsResult(await client.listAgents());
2845
+ } catch (err) {
2846
+ chatLog.addSystem(`agents list failed: ${String(err)}`);
2847
+ }
2848
+ };
2849
+ const updateAgentFromSessionKey = (key) => {
2850
+ const parsed = parseAgentSessionKey(key);
2851
+ if (!parsed) return;
2852
+ const next = normalizeAgentId(parsed.agentId);
2853
+ if (next !== state.currentAgentId) state.currentAgentId = next;
2854
+ };
2855
+ const resolveModelSelection = (entry) => {
2856
+ if (entry?.modelProvider || entry?.model) return {
2857
+ modelProvider: entry.modelProvider ?? state.sessionInfo.modelProvider,
2858
+ model: entry.model ?? state.sessionInfo.model
2859
+ };
2860
+ const overrideModel = entry?.modelOverride?.trim();
2861
+ if (overrideModel) return {
2862
+ modelProvider: entry?.providerOverride?.trim() || state.sessionInfo.modelProvider,
2863
+ model: overrideModel
2864
+ };
2865
+ return {
2866
+ modelProvider: state.sessionInfo.modelProvider,
2867
+ model: state.sessionInfo.model
2868
+ };
2869
+ };
2870
+ const applySessionInfo = (params) => {
2871
+ const entry = params.entry ?? void 0;
2872
+ const defaults = params.defaults ?? lastSessionDefaults ?? void 0;
2873
+ const previousDefaults = lastSessionDefaults;
2874
+ const defaultsChanged = params.defaults ? previousDefaults?.model !== params.defaults.model || previousDefaults?.modelProvider !== params.defaults.modelProvider || previousDefaults?.contextTokens !== params.defaults.contextTokens : false;
2875
+ if (params.defaults) lastSessionDefaults = params.defaults;
2876
+ const entryUpdatedAt = entry?.updatedAt ?? null;
2877
+ const currentUpdatedAt = state.sessionInfo.updatedAt ?? null;
2878
+ if (!params.force && entryUpdatedAt !== null && currentUpdatedAt !== null && entryUpdatedAt < currentUpdatedAt && !defaultsChanged) return;
2879
+ const next = { ...state.sessionInfo };
2880
+ if (entry?.thinkingLevel !== void 0) next.thinkingLevel = entry.thinkingLevel;
2881
+ if (entry?.fastMode !== void 0) next.fastMode = entry.fastMode;
2882
+ if (entry?.verboseLevel !== void 0) next.verboseLevel = entry.verboseLevel;
2883
+ if (entry?.reasoningLevel !== void 0) next.reasoningLevel = entry.reasoningLevel;
2884
+ if (entry?.responseUsage !== void 0) next.responseUsage = entry.responseUsage;
2885
+ if (entry?.inputTokens !== void 0) next.inputTokens = entry.inputTokens;
2886
+ if (entry?.outputTokens !== void 0) next.outputTokens = entry.outputTokens;
2887
+ if (entry?.totalTokens !== void 0) next.totalTokens = entry.totalTokens;
2888
+ if (entry?.contextTokens !== void 0 || defaults?.contextTokens !== void 0) next.contextTokens = entry?.contextTokens ?? defaults?.contextTokens ?? state.sessionInfo.contextTokens;
2889
+ if (entry?.displayName !== void 0) next.displayName = entry.displayName;
2890
+ if (entry?.updatedAt !== void 0) next.updatedAt = entry.updatedAt;
2891
+ const selection = resolveModelSelection(entry);
2892
+ if (selection.modelProvider !== void 0) next.modelProvider = selection.modelProvider;
2893
+ if (selection.model !== void 0) next.model = selection.model;
2894
+ state.sessionInfo = next;
2895
+ updateAutocompleteProvider();
2896
+ updateFooter();
2897
+ tui.requestRender();
2898
+ };
2899
+ const runRefreshSessionInfo = async () => {
2900
+ try {
2901
+ const resolveListAgentId = () => {
2902
+ if (state.currentSessionKey === "global" || state.currentSessionKey === "unknown") return;
2903
+ const parsed = parseAgentSessionKey(state.currentSessionKey);
2904
+ return parsed?.agentId ? normalizeAgentId(parsed.agentId) : state.currentAgentId;
2905
+ };
2906
+ const listAgentId = resolveListAgentId();
2907
+ const result = await client.listSessions({
2908
+ includeGlobal: false,
2909
+ includeUnknown: false,
2910
+ agentId: listAgentId
2911
+ });
2912
+ const normalizeMatchKey = (key) => parseAgentSessionKey(key)?.rest ?? key;
2913
+ const currentMatchKey = normalizeMatchKey(state.currentSessionKey);
2914
+ const entry = result.sessions.find((row) => {
2915
+ if (row.key === state.currentSessionKey) return true;
2916
+ return normalizeMatchKey(row.key) === currentMatchKey;
2917
+ });
2918
+ if (entry?.key && entry.key !== state.currentSessionKey) {
2919
+ updateAgentFromSessionKey(entry.key);
2920
+ state.currentSessionKey = entry.key;
2921
+ updateHeader();
2922
+ }
2923
+ applySessionInfo({
2924
+ entry,
2925
+ defaults: result.defaults
2926
+ });
2927
+ } catch (err) {
2928
+ chatLog.addSystem(`sessions list failed: ${String(err)}`);
2929
+ }
2930
+ };
2931
+ const refreshSessionInfo = async () => {
2932
+ refreshSessionInfoPromise = refreshSessionInfoPromise.then(runRefreshSessionInfo, runRefreshSessionInfo);
2933
+ await refreshSessionInfoPromise;
2934
+ };
2935
+ const applySessionInfoFromPatch = (result) => {
2936
+ if (!result?.entry) return;
2937
+ if (result.key && result.key !== state.currentSessionKey) {
2938
+ updateAgentFromSessionKey(result.key);
2939
+ state.currentSessionKey = result.key;
2940
+ updateHeader();
2941
+ }
2942
+ const resolved = result.resolved;
2943
+ applySessionInfo({
2944
+ entry: resolved && (resolved.modelProvider || resolved.model) ? {
2945
+ ...result.entry,
2946
+ modelProvider: resolved.modelProvider ?? result.entry.modelProvider,
2947
+ model: resolved.model ?? result.entry.model
2948
+ } : result.entry,
2949
+ force: true
2950
+ });
2951
+ };
2952
+ const loadHistory = async () => {
2953
+ try {
2954
+ const record = await client.loadHistory({
2955
+ sessionKey: state.currentSessionKey,
2956
+ limit: opts.historyLimit ?? 200
2957
+ });
2958
+ state.currentSessionId = typeof record.sessionId === "string" ? record.sessionId : null;
2959
+ state.sessionInfo.thinkingLevel = record.thinkingLevel ?? state.sessionInfo.thinkingLevel;
2960
+ state.sessionInfo.fastMode = record.fastMode ?? state.sessionInfo.fastMode;
2961
+ state.sessionInfo.verboseLevel = record.verboseLevel ?? state.sessionInfo.verboseLevel;
2962
+ const showTools = (state.sessionInfo.verboseLevel ?? "off") !== "off";
2963
+ chatLog.clearAll();
2964
+ btw.clear();
2965
+ chatLog.addSystem(`session ${state.currentSessionKey}`);
2966
+ for (const entry of record.messages ?? []) {
2967
+ if (!entry || typeof entry !== "object") continue;
2968
+ const message = entry;
2969
+ if (isCommandMessage(message)) {
2970
+ const text = extractTextFromMessage(message);
2971
+ if (text) chatLog.addSystem(text);
2972
+ continue;
2973
+ }
2974
+ if (message.role === "user") {
2975
+ const text = extractTextFromMessage(message);
2976
+ if (text) chatLog.addUser(text);
2977
+ continue;
2978
+ }
2979
+ if (message.role === "assistant") {
2980
+ const text = extractTextFromMessage(message, { includeThinking: state.showThinking });
2981
+ if (text) chatLog.finalizeAssistant(text);
2982
+ continue;
2983
+ }
2984
+ if (message.role === "toolResult") {
2985
+ if (!showTools) continue;
2986
+ const toolCallId = asString(message.toolCallId, "");
2987
+ const toolName = asString(message.toolName, "tool");
2988
+ chatLog.startTool(toolCallId, toolName, {}).setResult({
2989
+ content: Array.isArray(message.content) ? message.content : [],
2990
+ details: typeof message.details === "object" && message.details ? message.details : void 0
2991
+ }, { isError: Boolean(message.isError) });
2992
+ }
2993
+ }
2994
+ state.historyLoaded = true;
2995
+ } catch (err) {
2996
+ chatLog.addSystem(`history failed: ${String(err)}`);
2997
+ }
2998
+ await refreshSessionInfo();
2999
+ tui.requestRender();
3000
+ };
3001
+ const setSession = async (rawKey) => {
3002
+ const nextKey = resolveSessionKey(rawKey);
3003
+ updateAgentFromSessionKey(nextKey);
3004
+ state.currentSessionKey = nextKey;
3005
+ state.activeChatRunId = null;
3006
+ state.currentSessionId = null;
3007
+ state.sessionInfo.updatedAt = null;
3008
+ state.historyLoaded = false;
3009
+ clearLocalRunIds?.();
3010
+ btw.clear();
3011
+ updateHeader();
3012
+ updateFooter();
3013
+ await loadHistory();
3014
+ };
3015
+ const abortActive = async () => {
3016
+ if (!state.activeChatRunId) {
3017
+ chatLog.addSystem("no active run");
3018
+ tui.requestRender();
3019
+ return;
3020
+ }
3021
+ try {
3022
+ await client.abortChat({
3023
+ sessionKey: state.currentSessionKey,
3024
+ runId: state.activeChatRunId
3025
+ });
3026
+ setActivityStatus("aborted");
3027
+ } catch (err) {
3028
+ chatLog.addSystem(`abort failed: ${String(err)}`);
3029
+ setActivityStatus("abort failed");
3030
+ }
3031
+ tui.requestRender();
3032
+ };
3033
+ return {
3034
+ applyAgentsResult,
3035
+ refreshAgents,
3036
+ refreshSessionInfo,
3037
+ applySessionInfoFromPatch,
3038
+ loadHistory,
3039
+ setSession,
3040
+ abortActive
3041
+ };
3042
+ }
3043
+ //#endregion
3044
+ //#region src/tui/tui-submit.ts
3045
+ function createEditorSubmitHandler(params) {
3046
+ return (text) => {
3047
+ const raw = text;
3048
+ const value = raw.trim();
3049
+ params.editor.setText("");
3050
+ if (!value) return;
3051
+ if (raw.startsWith("!") && raw !== "!") {
3052
+ params.editor.addToHistory(raw);
3053
+ params.handleBangLine(raw);
3054
+ return;
3055
+ }
3056
+ params.editor.addToHistory(value);
3057
+ if (value.startsWith("/")) {
3058
+ params.handleCommand(value);
3059
+ return;
3060
+ }
3061
+ params.sendMessage(value);
3062
+ };
3063
+ }
3064
+ function shouldEnableWindowsGitBashPasteFallback(params) {
3065
+ const platform = params?.platform ?? process.platform;
3066
+ const env = params?.env ?? process.env;
3067
+ const termProgram = (env.TERM_PROGRAM ?? "").toLowerCase();
3068
+ if (platform === "darwin") {
3069
+ if (termProgram.includes("iterm") || termProgram.includes("apple_terminal")) return true;
3070
+ return false;
3071
+ }
3072
+ if (platform !== "win32") return false;
3073
+ const msystem = (env.MSYSTEM ?? "").toUpperCase();
3074
+ const shell = env.SHELL ?? "";
3075
+ if (msystem.startsWith("MINGW") || msystem.startsWith("MSYS")) return true;
3076
+ if (shell.toLowerCase().includes("bash")) return true;
3077
+ return termProgram.includes("mintty");
3078
+ }
3079
+ function createSubmitBurstCoalescer(params) {
3080
+ const windowMs = Math.max(1, params.burstWindowMs ?? 50);
3081
+ const now = params.now ?? (() => Date.now());
3082
+ const setTimer = params.setTimer ?? setTimeout;
3083
+ const clearTimer = params.clearTimer ?? clearTimeout;
3084
+ let pending = null;
3085
+ let pendingAt = 0;
3086
+ let flushTimer = null;
3087
+ const clearFlushTimer = () => {
3088
+ if (!flushTimer) return;
3089
+ clearTimer(flushTimer);
3090
+ flushTimer = null;
3091
+ };
3092
+ const flushPending = () => {
3093
+ if (pending === null) return;
3094
+ const value = pending;
3095
+ pending = null;
3096
+ pendingAt = 0;
3097
+ clearFlushTimer();
3098
+ params.submit(value);
3099
+ };
3100
+ const scheduleFlush = () => {
3101
+ clearFlushTimer();
3102
+ flushTimer = setTimer(() => {
3103
+ flushPending();
3104
+ }, windowMs);
3105
+ };
3106
+ return (value) => {
3107
+ if (!params.enabled) {
3108
+ params.submit(value);
3109
+ return;
3110
+ }
3111
+ if (value.includes("\n")) {
3112
+ flushPending();
3113
+ params.submit(value);
3114
+ return;
3115
+ }
3116
+ const ts = now();
3117
+ if (pending === null) {
3118
+ pending = value;
3119
+ pendingAt = ts;
3120
+ scheduleFlush();
3121
+ return;
3122
+ }
3123
+ if (ts - pendingAt <= windowMs) {
3124
+ pending = `${pending}\n${value}`;
3125
+ pendingAt = ts;
3126
+ scheduleFlush();
3127
+ return;
3128
+ }
3129
+ flushPending();
3130
+ pending = value;
3131
+ pendingAt = ts;
3132
+ scheduleFlush();
3133
+ };
3134
+ }
3135
+ //#endregion
3136
+ //#region src/tui/tui-waiting.ts
3137
+ const defaultWaitingPhrases = [
3138
+ "flibbertigibbeting",
3139
+ "kerfuffling",
3140
+ "dillydallying",
3141
+ "twiddling thumbs",
3142
+ "noodling",
3143
+ "bamboozling",
3144
+ "moseying",
3145
+ "hobnobbing",
3146
+ "pondering",
3147
+ "conjuring"
3148
+ ];
3149
+ function pickWaitingPhrase(tick, phrases = defaultWaitingPhrases) {
3150
+ return phrases[Math.floor(tick / 10) % phrases.length] ?? phrases[0] ?? "waiting";
3151
+ }
3152
+ function shimmerText(theme, text, tick) {
3153
+ const width = 6;
3154
+ const hi = (ch) => theme.bold(theme.accentSoft(ch));
3155
+ const pos = tick % (text.length + width);
3156
+ const start = Math.max(0, pos - width);
3157
+ const end = Math.min(text.length - 1, pos);
3158
+ let out = "";
3159
+ for (let i = 0; i < text.length; i++) {
3160
+ const ch = text[i];
3161
+ out += i >= start && i <= end ? hi(ch) : theme.dim(ch);
3162
+ }
3163
+ return out;
3164
+ }
3165
+ function buildWaitingStatusMessage(params) {
3166
+ const phrase = pickWaitingPhrase(params.tick, params.phrases);
3167
+ return `${shimmerText(params.theme, `${phrase}…`, params.tick)} • ${params.elapsed} | ${params.connectionStatus}`;
3168
+ }
3169
+ //#endregion
3170
+ //#region src/tui/tui.ts
3171
+ function resolveTuiSessionKey(params) {
3172
+ const trimmed = (params.raw ?? "").trim();
3173
+ if (!trimmed) {
3174
+ if (params.sessionScope === "global") return "global";
3175
+ return buildAgentMainSessionKey({
3176
+ agentId: params.currentAgentId,
3177
+ mainKey: params.sessionMainKey
3178
+ });
3179
+ }
3180
+ if (trimmed === "global" || trimmed === "unknown") return trimmed;
3181
+ if (trimmed.startsWith("agent:")) return trimmed.toLowerCase();
3182
+ return `agent:${params.currentAgentId}:${trimmed.toLowerCase()}`;
3183
+ }
3184
+ function resolveInitialTuiAgentId(params) {
3185
+ const parsed = parseAgentSessionKey((params.initialSessionInput ?? "").trim());
3186
+ if (parsed?.agentId) return normalizeAgentId(parsed.agentId);
3187
+ const inferredFromWorkspace = resolveAgentIdByWorkspacePath(params.cfg, params.cwd ?? process.cwd());
3188
+ if (inferredFromWorkspace) return inferredFromWorkspace;
3189
+ return normalizeAgentId(params.fallbackAgentId);
3190
+ }
3191
+ function resolveGatewayDisconnectState(reason) {
3192
+ const reasonLabel = reason?.trim() ? reason.trim() : "closed";
3193
+ if (/pairing required/i.test(reasonLabel)) return {
3194
+ connectionStatus: `gateway disconnected: ${reasonLabel}`,
3195
+ activityStatus: "pairing required: run openclaw devices list",
3196
+ pairingHint: "Pairing required. Run `openclaw devices list`, approve your request ID, then reconnect."
3197
+ };
3198
+ return {
3199
+ connectionStatus: `gateway disconnected: ${reasonLabel}`,
3200
+ activityStatus: "idle"
3201
+ };
3202
+ }
3203
+ function createBackspaceDeduper(params) {
3204
+ const dedupeWindowMs = Math.max(0, Math.floor(params?.dedupeWindowMs ?? 8));
3205
+ const now = params?.now ?? (() => Date.now());
3206
+ let lastBackspaceAt = -1;
3207
+ return (data) => {
3208
+ if (!matchesKey(data, Key.backspace)) return data;
3209
+ const ts = now();
3210
+ if (lastBackspaceAt >= 0 && ts - lastBackspaceAt <= dedupeWindowMs) return "";
3211
+ lastBackspaceAt = ts;
3212
+ return data;
3213
+ };
3214
+ }
3215
+ function isIgnorableTuiStopError(error) {
3216
+ if (!error || typeof error !== "object") return false;
3217
+ const err = error;
3218
+ const code = typeof err.code === "string" ? err.code : "";
3219
+ const syscall = typeof err.syscall === "string" ? err.syscall : "";
3220
+ const message = typeof err.message === "string" ? err.message : "";
3221
+ if (code === "EBADF" && syscall === "setRawMode") return true;
3222
+ return /setRawMode/i.test(message) && /EBADF/i.test(message);
3223
+ }
3224
+ function stopTuiSafely(stop) {
3225
+ try {
3226
+ stop();
3227
+ } catch (error) {
3228
+ if (!isIgnorableTuiStopError(error)) throw error;
3229
+ }
3230
+ }
3231
+ function resolveCtrlCAction(params) {
3232
+ const exitWindowMs = Math.max(1, Math.floor(params.exitWindowMs ?? 1e3));
3233
+ if (params.hasInput) return {
3234
+ action: "clear",
3235
+ nextLastCtrlCAt: params.now
3236
+ };
3237
+ if (params.now - params.lastCtrlCAt <= exitWindowMs) return {
3238
+ action: "exit",
3239
+ nextLastCtrlCAt: params.lastCtrlCAt
3240
+ };
3241
+ return {
3242
+ action: "warn",
3243
+ nextLastCtrlCAt: params.now
3244
+ };
3245
+ }
3246
+ async function runTui(opts) {
3247
+ const config = loadConfig();
3248
+ const initialSessionInput = (opts.session ?? "").trim();
3249
+ let sessionScope = config.session?.scope ?? "per-sender";
3250
+ let sessionMainKey = normalizeMainKey(config.session?.mainKey);
3251
+ let agentDefaultId = resolveDefaultAgentId(config);
3252
+ let currentAgentId = resolveInitialTuiAgentId({
3253
+ cfg: config,
3254
+ fallbackAgentId: agentDefaultId,
3255
+ initialSessionInput,
3256
+ cwd: process.cwd()
3257
+ });
3258
+ let agents = [];
3259
+ const agentNames = /* @__PURE__ */ new Map();
3260
+ let currentSessionKey = "";
3261
+ let initialSessionApplied = false;
3262
+ let currentSessionId = null;
3263
+ let activeChatRunId = null;
3264
+ let historyLoaded = false;
3265
+ let isConnected = false;
3266
+ let wasDisconnected = false;
3267
+ let toolsExpanded = false;
3268
+ let showThinking = false;
3269
+ let pairingHintShown = false;
3270
+ const localRunIds = /* @__PURE__ */ new Set();
3271
+ const localBtwRunIds = /* @__PURE__ */ new Set();
3272
+ const deliverDefault = opts.deliver ?? false;
3273
+ const autoMessage = opts.message?.trim();
3274
+ let autoMessageSent = false;
3275
+ let sessionInfo = {};
3276
+ let lastCtrlCAt = 0;
3277
+ let exitRequested = false;
3278
+ let activityStatus = "idle";
3279
+ let connectionStatus = "connecting";
3280
+ let statusTimeout = null;
3281
+ let statusTimer = null;
3282
+ let statusStartedAt = null;
3283
+ let lastActivityStatus = activityStatus;
3284
+ const state = {
3285
+ get agentDefaultId() {
3286
+ return agentDefaultId;
3287
+ },
3288
+ set agentDefaultId(value) {
3289
+ agentDefaultId = value;
3290
+ },
3291
+ get sessionMainKey() {
3292
+ return sessionMainKey;
3293
+ },
3294
+ set sessionMainKey(value) {
3295
+ sessionMainKey = value;
3296
+ },
3297
+ get sessionScope() {
3298
+ return sessionScope;
3299
+ },
3300
+ set sessionScope(value) {
3301
+ sessionScope = value;
3302
+ },
3303
+ get agents() {
3304
+ return agents;
3305
+ },
3306
+ set agents(value) {
3307
+ agents = value;
3308
+ },
3309
+ get currentAgentId() {
3310
+ return currentAgentId;
3311
+ },
3312
+ set currentAgentId(value) {
3313
+ currentAgentId = value;
3314
+ },
3315
+ get currentSessionKey() {
3316
+ return currentSessionKey;
3317
+ },
3318
+ set currentSessionKey(value) {
3319
+ currentSessionKey = value;
3320
+ },
3321
+ get currentSessionId() {
3322
+ return currentSessionId;
3323
+ },
3324
+ set currentSessionId(value) {
3325
+ currentSessionId = value;
3326
+ },
3327
+ get activeChatRunId() {
3328
+ return activeChatRunId;
3329
+ },
3330
+ set activeChatRunId(value) {
3331
+ activeChatRunId = value;
3332
+ },
3333
+ get historyLoaded() {
3334
+ return historyLoaded;
3335
+ },
3336
+ set historyLoaded(value) {
3337
+ historyLoaded = value;
3338
+ },
3339
+ get sessionInfo() {
3340
+ return sessionInfo;
3341
+ },
3342
+ set sessionInfo(value) {
3343
+ sessionInfo = value;
3344
+ },
3345
+ get initialSessionApplied() {
3346
+ return initialSessionApplied;
3347
+ },
3348
+ set initialSessionApplied(value) {
3349
+ initialSessionApplied = value;
3350
+ },
3351
+ get isConnected() {
3352
+ return isConnected;
3353
+ },
3354
+ set isConnected(value) {
3355
+ isConnected = value;
3356
+ },
3357
+ get autoMessageSent() {
3358
+ return autoMessageSent;
3359
+ },
3360
+ set autoMessageSent(value) {
3361
+ autoMessageSent = value;
3362
+ },
3363
+ get toolsExpanded() {
3364
+ return toolsExpanded;
3365
+ },
3366
+ set toolsExpanded(value) {
3367
+ toolsExpanded = value;
3368
+ },
3369
+ get showThinking() {
3370
+ return showThinking;
3371
+ },
3372
+ set showThinking(value) {
3373
+ showThinking = value;
3374
+ },
3375
+ get connectionStatus() {
3376
+ return connectionStatus;
3377
+ },
3378
+ set connectionStatus(value) {
3379
+ connectionStatus = value;
3380
+ },
3381
+ get activityStatus() {
3382
+ return activityStatus;
3383
+ },
3384
+ set activityStatus(value) {
3385
+ activityStatus = value;
3386
+ },
3387
+ get statusTimeout() {
3388
+ return statusTimeout;
3389
+ },
3390
+ set statusTimeout(value) {
3391
+ statusTimeout = value;
3392
+ },
3393
+ get lastCtrlCAt() {
3394
+ return lastCtrlCAt;
3395
+ },
3396
+ set lastCtrlCAt(value) {
3397
+ lastCtrlCAt = value;
3398
+ }
3399
+ };
3400
+ const noteLocalRunId = (runId) => {
3401
+ if (!runId) return;
3402
+ localRunIds.add(runId);
3403
+ if (localRunIds.size > 200) {
3404
+ const [first] = localRunIds;
3405
+ if (first) localRunIds.delete(first);
3406
+ }
3407
+ };
3408
+ const forgetLocalRunId = (runId) => {
3409
+ localRunIds.delete(runId);
3410
+ };
3411
+ const isLocalRunId = (runId) => localRunIds.has(runId);
3412
+ const clearLocalRunIds = () => {
3413
+ localRunIds.clear();
3414
+ };
3415
+ const noteLocalBtwRunId = (runId) => {
3416
+ if (!runId) return;
3417
+ localBtwRunIds.add(runId);
3418
+ if (localBtwRunIds.size > 200) {
3419
+ const [first] = localBtwRunIds;
3420
+ if (first) localBtwRunIds.delete(first);
3421
+ }
3422
+ };
3423
+ const forgetLocalBtwRunId = (runId) => {
3424
+ localBtwRunIds.delete(runId);
3425
+ };
3426
+ const isLocalBtwRunId = (runId) => localBtwRunIds.has(runId);
3427
+ const clearLocalBtwRunIds = () => {
3428
+ localBtwRunIds.clear();
3429
+ };
3430
+ const client = await GatewayChatClient.connect({
3431
+ url: opts.url,
3432
+ token: opts.token,
3433
+ password: opts.password
3434
+ });
3435
+ const tui = new TUI(new ProcessTerminal());
3436
+ const dedupeBackspace = createBackspaceDeduper();
3437
+ tui.addInputListener((data) => {
3438
+ const next = dedupeBackspace(data);
3439
+ if (next.length === 0) return { consume: true };
3440
+ return { data: next };
3441
+ });
3442
+ const header = new Text("", 1, 0);
3443
+ const statusContainer = new Container();
3444
+ const footer = new Text("", 1, 0);
3445
+ const chatLog = new ChatLog();
3446
+ const editor = new CustomEditor(tui, editorTheme);
3447
+ const root = new Container();
3448
+ root.addChild(header);
3449
+ root.addChild(chatLog);
3450
+ root.addChild(statusContainer);
3451
+ root.addChild(footer);
3452
+ root.addChild(editor);
3453
+ const updateAutocompleteProvider = () => {
3454
+ editor.setAutocompleteProvider(new CombinedAutocompleteProvider(getSlashCommands({
3455
+ cfg: config,
3456
+ provider: sessionInfo.modelProvider,
3457
+ model: sessionInfo.model
3458
+ }), process.cwd()));
3459
+ };
3460
+ tui.addChild(root);
3461
+ tui.setFocus(editor);
3462
+ const formatSessionKey = (key) => {
3463
+ if (key === "global" || key === "unknown") return key;
3464
+ return parseAgentSessionKey(key)?.rest ?? key;
3465
+ };
3466
+ const formatAgentLabel = (id) => {
3467
+ const name = agentNames.get(id);
3468
+ return name ? `${id} (${name})` : id;
3469
+ };
3470
+ const resolveSessionKey = (raw) => {
3471
+ return resolveTuiSessionKey({
3472
+ raw,
3473
+ sessionScope,
3474
+ currentAgentId,
3475
+ sessionMainKey
3476
+ });
3477
+ };
3478
+ currentSessionKey = resolveSessionKey(initialSessionInput);
3479
+ const updateHeader = () => {
3480
+ const sessionLabel = formatSessionKey(currentSessionKey);
3481
+ const agentLabel = formatAgentLabel(currentAgentId);
3482
+ header.setText(theme.header(`openclaw tui - ${client.connection.url} - agent ${agentLabel} - session ${sessionLabel}`));
3483
+ };
3484
+ const busyStates = new Set([
3485
+ "sending",
3486
+ "waiting",
3487
+ "streaming",
3488
+ "running"
3489
+ ]);
3490
+ let statusText = null;
3491
+ let statusLoader = null;
3492
+ const formatElapsed = (startMs) => {
3493
+ const totalSeconds = Math.max(0, Math.floor((Date.now() - startMs) / 1e3));
3494
+ if (totalSeconds < 60) return `${totalSeconds}s`;
3495
+ return `${Math.floor(totalSeconds / 60)}m ${totalSeconds % 60}s`;
3496
+ };
3497
+ const ensureStatusText = () => {
3498
+ if (statusText) return;
3499
+ statusContainer.clear();
3500
+ statusLoader?.stop();
3501
+ statusLoader = null;
3502
+ statusText = new Text("", 1, 0);
3503
+ statusContainer.addChild(statusText);
3504
+ };
3505
+ const ensureStatusLoader = () => {
3506
+ if (statusLoader) return;
3507
+ statusContainer.clear();
3508
+ statusText = null;
3509
+ statusLoader = new Loader(tui, (spinner) => theme.accent(spinner), (text) => theme.bold(theme.accentSoft(text)), "");
3510
+ statusContainer.addChild(statusLoader);
3511
+ };
3512
+ let waitingTick = 0;
3513
+ let waitingTimer = null;
3514
+ let waitingPhrase = null;
3515
+ const updateBusyStatusMessage = () => {
3516
+ if (!statusLoader || !statusStartedAt) return;
3517
+ const elapsed = formatElapsed(statusStartedAt);
3518
+ if (activityStatus === "waiting") {
3519
+ waitingTick++;
3520
+ statusLoader.setMessage(buildWaitingStatusMessage({
3521
+ theme,
3522
+ tick: waitingTick,
3523
+ elapsed,
3524
+ connectionStatus,
3525
+ phrases: waitingPhrase ? [waitingPhrase] : void 0
3526
+ }));
3527
+ return;
3528
+ }
3529
+ statusLoader.setMessage(`${activityStatus} • ${elapsed} | ${connectionStatus}`);
3530
+ };
3531
+ const startStatusTimer = () => {
3532
+ if (statusTimer) return;
3533
+ statusTimer = setInterval(() => {
3534
+ if (!busyStates.has(activityStatus)) return;
3535
+ updateBusyStatusMessage();
3536
+ }, 1e3);
3537
+ };
3538
+ const stopStatusTimer = () => {
3539
+ if (!statusTimer) return;
3540
+ clearInterval(statusTimer);
3541
+ statusTimer = null;
3542
+ };
3543
+ const startWaitingTimer = () => {
3544
+ if (waitingTimer) return;
3545
+ if (!waitingPhrase) waitingPhrase = defaultWaitingPhrases[Math.floor(Math.random() * defaultWaitingPhrases.length)] ?? defaultWaitingPhrases[0] ?? "waiting";
3546
+ waitingTick = 0;
3547
+ waitingTimer = setInterval(() => {
3548
+ if (activityStatus !== "waiting") return;
3549
+ updateBusyStatusMessage();
3550
+ }, 120);
3551
+ };
3552
+ const stopWaitingTimer = () => {
3553
+ if (!waitingTimer) return;
3554
+ clearInterval(waitingTimer);
3555
+ waitingTimer = null;
3556
+ waitingPhrase = null;
3557
+ };
3558
+ const renderStatus = () => {
3559
+ if (busyStates.has(activityStatus)) {
3560
+ if (!statusStartedAt || lastActivityStatus !== activityStatus) statusStartedAt = Date.now();
3561
+ ensureStatusLoader();
3562
+ if (activityStatus === "waiting") {
3563
+ stopStatusTimer();
3564
+ startWaitingTimer();
3565
+ } else {
3566
+ stopWaitingTimer();
3567
+ startStatusTimer();
3568
+ }
3569
+ updateBusyStatusMessage();
3570
+ } else {
3571
+ statusStartedAt = null;
3572
+ stopStatusTimer();
3573
+ stopWaitingTimer();
3574
+ statusLoader?.stop();
3575
+ statusLoader = null;
3576
+ ensureStatusText();
3577
+ const text = activityStatus ? `${connectionStatus} | ${activityStatus}` : connectionStatus;
3578
+ statusText?.setText(theme.dim(text));
3579
+ }
3580
+ lastActivityStatus = activityStatus;
3581
+ };
3582
+ const setConnectionStatus = (text, ttlMs) => {
3583
+ connectionStatus = text;
3584
+ renderStatus();
3585
+ if (statusTimeout) clearTimeout(statusTimeout);
3586
+ if (ttlMs && ttlMs > 0) statusTimeout = setTimeout(() => {
3587
+ connectionStatus = isConnected ? "connected" : "disconnected";
3588
+ renderStatus();
3589
+ }, ttlMs);
3590
+ };
3591
+ const setActivityStatus = (text) => {
3592
+ activityStatus = text;
3593
+ renderStatus();
3594
+ };
3595
+ const updateFooter = () => {
3596
+ const sessionKeyLabel = formatSessionKey(currentSessionKey);
3597
+ const sessionLabel = sessionInfo.displayName ? `${sessionKeyLabel} (${sessionInfo.displayName})` : sessionKeyLabel;
3598
+ const agentLabel = formatAgentLabel(currentAgentId);
3599
+ const modelLabel = sessionInfo.model ? sessionInfo.modelProvider ? `${sessionInfo.modelProvider}/${sessionInfo.model}` : sessionInfo.model : "unknown";
3600
+ const tokens = formatTokens(sessionInfo.totalTokens ?? null, sessionInfo.contextTokens ?? null);
3601
+ const think = sessionInfo.thinkingLevel ?? "off";
3602
+ const fast = sessionInfo.fastMode === true;
3603
+ const verbose = sessionInfo.verboseLevel ?? "off";
3604
+ const reasoning = sessionInfo.reasoningLevel ?? "off";
3605
+ const reasoningLabel = reasoning === "on" ? "reasoning" : reasoning === "stream" ? "reasoning:stream" : null;
3606
+ const footerParts = [
3607
+ `agent ${agentLabel}`,
3608
+ `session ${sessionLabel}`,
3609
+ modelLabel,
3610
+ think !== "off" ? `think ${think}` : null,
3611
+ fast ? "fast" : null,
3612
+ verbose !== "off" ? `verbose ${verbose}` : null,
3613
+ reasoningLabel,
3614
+ tokens
3615
+ ].filter(Boolean);
3616
+ footer.setText(theme.dim(footerParts.join(" | ")));
3617
+ };
3618
+ const { openOverlay, closeOverlay } = createOverlayHandlers(tui, editor);
3619
+ const btw = {
3620
+ showResult: (params) => {
3621
+ chatLog.showBtw(params);
3622
+ },
3623
+ clear: () => {
3624
+ chatLog.dismissBtw();
3625
+ }
3626
+ };
3627
+ const { refreshAgents, refreshSessionInfo, applySessionInfoFromPatch, loadHistory, setSession, abortActive } = createSessionActions({
3628
+ client,
3629
+ chatLog,
3630
+ btw,
3631
+ tui,
3632
+ opts,
3633
+ state,
3634
+ agentNames,
3635
+ initialSessionInput,
3636
+ initialSessionAgentId: (() => {
3637
+ if (!initialSessionInput) return null;
3638
+ const parsed = parseAgentSessionKey(initialSessionInput);
3639
+ return parsed ? normalizeAgentId(parsed.agentId) : null;
3640
+ })(),
3641
+ resolveSessionKey,
3642
+ updateHeader,
3643
+ updateFooter,
3644
+ updateAutocompleteProvider,
3645
+ setActivityStatus,
3646
+ clearLocalRunIds
3647
+ });
3648
+ const { handleChatEvent, handleAgentEvent, handleBtwEvent } = createEventHandlers({
3649
+ chatLog,
3650
+ btw,
3651
+ tui,
3652
+ state,
3653
+ setActivityStatus,
3654
+ refreshSessionInfo,
3655
+ loadHistory,
3656
+ isLocalRunId,
3657
+ forgetLocalRunId,
3658
+ clearLocalRunIds,
3659
+ isLocalBtwRunId,
3660
+ forgetLocalBtwRunId,
3661
+ clearLocalBtwRunIds
3662
+ });
3663
+ const requestExit = () => {
3664
+ if (exitRequested) return;
3665
+ exitRequested = true;
3666
+ client.stop();
3667
+ stopTuiSafely(() => tui.stop());
3668
+ process.exit(0);
3669
+ };
3670
+ const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } = createCommandHandlers({
3671
+ client,
3672
+ chatLog,
3673
+ tui,
3674
+ opts,
3675
+ state,
3676
+ deliverDefault,
3677
+ openOverlay,
3678
+ closeOverlay,
3679
+ refreshSessionInfo,
3680
+ applySessionInfoFromPatch,
3681
+ loadHistory,
3682
+ setSession,
3683
+ refreshAgents,
3684
+ abortActive,
3685
+ setActivityStatus,
3686
+ formatSessionKey,
3687
+ noteLocalRunId,
3688
+ noteLocalBtwRunId,
3689
+ forgetLocalRunId,
3690
+ forgetLocalBtwRunId,
3691
+ requestExit
3692
+ });
3693
+ const { runLocalShellLine } = createLocalShellRunner({
3694
+ chatLog,
3695
+ tui,
3696
+ openOverlay,
3697
+ closeOverlay
3698
+ });
3699
+ updateAutocompleteProvider();
3700
+ editor.onSubmit = createSubmitBurstCoalescer({
3701
+ submit: createEditorSubmitHandler({
3702
+ editor,
3703
+ handleCommand,
3704
+ sendMessage,
3705
+ handleBangLine: runLocalShellLine
3706
+ }),
3707
+ enabled: shouldEnableWindowsGitBashPasteFallback()
3708
+ });
3709
+ editor.onEscape = () => {
3710
+ if (chatLog.hasVisibleBtw()) {
3711
+ chatLog.dismissBtw();
3712
+ tui.requestRender();
3713
+ return;
3714
+ }
3715
+ abortActive();
3716
+ };
3717
+ const handleCtrlC = () => {
3718
+ const now = Date.now();
3719
+ const decision = resolveCtrlCAction({
3720
+ hasInput: editor.getText().trim().length > 0,
3721
+ now,
3722
+ lastCtrlCAt
3723
+ });
3724
+ lastCtrlCAt = decision.nextLastCtrlCAt;
3725
+ if (decision.action === "clear") {
3726
+ editor.setText("");
3727
+ setActivityStatus("cleared input; press ctrl+c again to exit");
3728
+ tui.requestRender();
3729
+ return;
3730
+ }
3731
+ if (decision.action === "exit") {
3732
+ requestExit();
3733
+ return;
3734
+ }
3735
+ setActivityStatus("press ctrl+c again to exit");
3736
+ tui.requestRender();
3737
+ };
3738
+ editor.onCtrlC = () => {
3739
+ handleCtrlC();
3740
+ };
3741
+ editor.onCtrlD = () => {
3742
+ requestExit();
3743
+ };
3744
+ editor.onCtrlO = () => {
3745
+ toolsExpanded = !toolsExpanded;
3746
+ chatLog.setToolsExpanded(toolsExpanded);
3747
+ setActivityStatus(toolsExpanded ? "tools expanded" : "tools collapsed");
3748
+ tui.requestRender();
3749
+ };
3750
+ editor.onCtrlL = () => {
3751
+ openModelSelector();
3752
+ };
3753
+ editor.onCtrlG = () => {
3754
+ openAgentSelector();
3755
+ };
3756
+ editor.onCtrlP = () => {
3757
+ openSessionSelector();
3758
+ };
3759
+ editor.onCtrlT = () => {
3760
+ showThinking = !showThinking;
3761
+ loadHistory();
3762
+ };
3763
+ tui.addInputListener((data) => {
3764
+ if (!chatLog.hasVisibleBtw()) return;
3765
+ if (editor.getText().length > 0) return;
3766
+ if (matchesKey(data, "enter")) {
3767
+ chatLog.dismissBtw();
3768
+ tui.requestRender();
3769
+ return { consume: true };
3770
+ }
3771
+ });
3772
+ client.onEvent = (evt) => {
3773
+ if (evt.event === "chat") handleChatEvent(evt.payload);
3774
+ if (evt.event === "chat.side_result") handleBtwEvent(evt.payload);
3775
+ if (evt.event === "agent") handleAgentEvent(evt.payload);
3776
+ };
3777
+ client.onConnected = () => {
3778
+ isConnected = true;
3779
+ pairingHintShown = false;
3780
+ const reconnected = wasDisconnected;
3781
+ wasDisconnected = false;
3782
+ setConnectionStatus("connected");
3783
+ (async () => {
3784
+ await refreshAgents();
3785
+ updateHeader();
3786
+ await loadHistory();
3787
+ setConnectionStatus(reconnected ? "gateway reconnected" : "gateway connected", 4e3);
3788
+ tui.requestRender();
3789
+ if (!autoMessageSent && autoMessage) {
3790
+ autoMessageSent = true;
3791
+ await sendMessage(autoMessage);
3792
+ }
3793
+ updateFooter();
3794
+ tui.requestRender();
3795
+ })();
3796
+ };
3797
+ client.onDisconnected = (reason) => {
3798
+ isConnected = false;
3799
+ wasDisconnected = true;
3800
+ historyLoaded = false;
3801
+ const disconnectState = resolveGatewayDisconnectState(reason);
3802
+ setConnectionStatus(disconnectState.connectionStatus, 5e3);
3803
+ setActivityStatus(disconnectState.activityStatus);
3804
+ if (disconnectState.pairingHint && !pairingHintShown) {
3805
+ pairingHintShown = true;
3806
+ chatLog.addSystem(disconnectState.pairingHint);
3807
+ }
3808
+ updateFooter();
3809
+ tui.requestRender();
3810
+ };
3811
+ client.onGap = (info) => {
3812
+ setConnectionStatus(`event gap: expected ${info.expected}, got ${info.received}`, 5e3);
3813
+ tui.requestRender();
3814
+ };
3815
+ updateHeader();
3816
+ setConnectionStatus("connecting");
3817
+ updateFooter();
3818
+ const sigintHandler = () => {
3819
+ handleCtrlC();
3820
+ };
3821
+ const sigtermHandler = () => {
3822
+ requestExit();
3823
+ };
3824
+ process.on("SIGINT", sigintHandler);
3825
+ process.on("SIGTERM", sigtermHandler);
3826
+ tui.start();
3827
+ client.start();
3828
+ await new Promise((resolve) => {
3829
+ const finish = () => {
3830
+ process.removeListener("SIGINT", sigintHandler);
3831
+ process.removeListener("SIGTERM", sigtermHandler);
3832
+ resolve();
3833
+ };
3834
+ process.once("exit", finish);
3835
+ });
3836
+ }
3837
+ //#endregion
3838
+ export { runTui as t };