@captain-app/openclaw 2026.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1528 -0
- package/LICENSE +21 -0
- package/README-header.png +0 -0
- package/README.md +539 -0
- package/assets/avatar-placeholder.svg +19 -0
- package/assets/chrome-extension/README.md +22 -0
- package/assets/chrome-extension/background.js +438 -0
- package/assets/chrome-extension/icons/icon128.png +0 -0
- package/assets/chrome-extension/icons/icon16.png +0 -0
- package/assets/chrome-extension/icons/icon32.png +0 -0
- package/assets/chrome-extension/icons/icon48.png +0 -0
- package/assets/chrome-extension/manifest.json +25 -0
- package/assets/chrome-extension/options.html +196 -0
- package/assets/chrome-extension/options.js +59 -0
- package/assets/dmg-background-small.png +0 -0
- package/assets/dmg-background.png +0 -0
- package/dist/accounts-ClnuDahN.js +250 -0
- package/dist/accounts-DzBgAM3C.js +251 -0
- package/dist/acp-cli-BEDDkzXH.js +926 -0
- package/dist/acp-cli-CwV4mdnW.js +923 -0
- package/dist/agent-CArjbSeE.js +695 -0
- package/dist/agent-CB7x5HLT.js +695 -0
- package/dist/agent-scope-BbT4OG2N.js +545 -0
- package/dist/agent-scope-C_O6Vpl0.js +545 -0
- package/dist/agent-scope-Csu2B6AM.js +606 -0
- package/dist/archive-CWrnG1CH.js +85 -0
- package/dist/archive-ccN9aDgq.js +85 -0
- package/dist/audit-DXPkQ275.js +1686 -0
- package/dist/audit-eH7nwgsM.js +1686 -0
- package/dist/auth-health-Bj7Gjbv0.js +149 -0
- package/dist/auth-health-CjjJhHey.js +149 -0
- package/dist/auth-nnRYiqpH.js +192 -0
- package/dist/auth-profiles-DVLfuixr.js +2954 -0
- package/dist/auth-y1BLPUhX.js +192 -0
- package/dist/boolean-Wzu0-e0P.js +30 -0
- package/dist/brew-Cqi8b49_.js +46 -0
- package/dist/brew-DyBGNK8A.js +46 -0
- package/dist/build-info.json +5 -0
- package/dist/call-B7EveN4V.js +252 -0
- package/dist/call-vuUQIjOj.js +252 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -0
- package/dist/canvas-host/a2ui/a2ui.bundle.js +17780 -0
- package/dist/canvas-host/a2ui/index.html +307 -0
- package/dist/channel-options-CJfmOkol.js +32 -0
- package/dist/channel-options-lFguMTz1.js +62 -0
- package/dist/channel-selection-BmND9mWj.js +51 -0
- package/dist/channel-selection-cGhL9G0c.js +51 -0
- package/dist/channel-summary-B4G513Eb.js +1154 -0
- package/dist/channel-summary-MCwBCa5y.js +1154 -0
- package/dist/channels-cli-C2Of1mZG.js +1411 -0
- package/dist/channels-cli-DFynrP1H.js +1413 -0
- package/dist/channels-status-issues-YohTjZ-I.js +18 -0
- package/dist/channels-status-issues-ZcR1U-m5.js +18 -0
- package/dist/chrome-B3IuUad-.js +1953 -0
- package/dist/chrome-BZ9K48w9.js +1973 -0
- package/dist/clack-prompter-B9yLhyOm.js +92 -0
- package/dist/clack-prompter-BybM9xdL.js +92 -0
- package/dist/cli/daemon-cli.js +2 -0
- package/dist/cli-BJZdJwug.js +89 -0
- package/dist/cli-BQSoKu3d.js +86 -0
- package/dist/cli-utils-CO4jEMn0.js +43 -0
- package/dist/cli-utils-gtE-0a0D.js +43 -0
- package/dist/client-DPqNOpK3.js +1609 -0
- package/dist/client-DySXIFCA.js +1609 -0
- package/dist/command-format-CFzL448l.js +52 -0
- package/dist/command-format-DELazozB.js +52 -0
- package/dist/command-format-ayFsmwwz.js +38 -0
- package/dist/command-options-CsjxK4cZ.js +33 -0
- package/dist/commands-BRe9VTyU.js +229 -0
- package/dist/completion-cli-DlkjK0iC.js +390 -0
- package/dist/completion-cli-E6Pt41AL.js +387 -0
- package/dist/config-BtSTwPcH.js +4882 -0
- package/dist/config-DfMIMT-f.js +4881 -0
- package/dist/config-_d7_WcRv.js +5623 -0
- package/dist/config-guard-wSnm-U8a.js +5628 -0
- package/dist/configure-CPHAFKlg.js +895 -0
- package/dist/configure-DK1XgXYx.js +894 -0
- package/dist/constants-CNTiY-ZN.js +65 -0
- package/dist/constants-hpmbslG7.js +65 -0
- package/dist/control-service-CqX5g_ko.js +61 -0
- package/dist/control-service-o6xe3hEb.js +61 -0
- package/dist/control-ui/apple-touch-icon.png +0 -0
- package/dist/control-ui/assets/index-RwcW4Xl0.css +1 -0
- package/dist/control-ui/assets/index-ryaCcbyp.js +4584 -0
- package/dist/control-ui/assets/index-ryaCcbyp.js.map +1 -0
- package/dist/control-ui/favicon-32.png +0 -0
- package/dist/control-ui/favicon.ico +0 -0
- package/dist/control-ui/favicon.svg +22 -0
- package/dist/control-ui/index.html +17 -0
- package/dist/cron-cli-BoSaDgvH.js +453 -0
- package/dist/cron-cli-qVandvsD.js +456 -0
- package/dist/daemon-cli-C4gGWa15.js +760 -0
- package/dist/daemon-cli-DV_X0Krf.js +761 -0
- package/dist/daemon-runtime-D5hbSrdO.js +460 -0
- package/dist/daemon-runtime-DXUfrXBC.js +460 -0
- package/dist/deliver-BxK5nI2P.js +2587 -0
- package/dist/deliver-Dwzg9LUd.js +2557 -0
- package/dist/deliver-qpYZp20m.js +2587 -0
- package/dist/deps-CUXtMV9d.js +27 -0
- package/dist/deps-WBvZpFV_.js +27 -0
- package/dist/devices-cli-B2s18Qrh.js +207 -0
- package/dist/devices-cli-D1UEtMUJ.js +204 -0
- package/dist/directory-cli-BXQbrkfM.js +247 -0
- package/dist/directory-cli-CqA7tRbq.js +244 -0
- package/dist/dispatcher-Dyv7T-1r.js +160 -0
- package/dist/dns-cli-CWxKD22D.js +198 -0
- package/dist/dns-cli-CzKr_Fxj.js +201 -0
- package/dist/docs-cli-BNyxUbWr.js +159 -0
- package/dist/docs-cli-DYpTbo3i.js +161 -0
- package/dist/doctor-C8fDYZLq.js +2583 -0
- package/dist/doctor-hYcqp7c0.js +2585 -0
- package/dist/entry.js +1326 -0
- package/dist/env-l7QVNj6j.js +32 -0
- package/dist/errors-CMCg46fK.js +1952 -0
- package/dist/exec-B8JKbXKW.js +246 -0
- package/dist/exec-BMnoMcZW.js +1099 -0
- package/dist/exec-HEWTMJ7j.js +246 -0
- package/dist/exec-approvals-DtrnHx6M.js +1026 -0
- package/dist/exec-approvals-Y42bE8ud.js +1026 -0
- package/dist/exec-approvals-cli-CIedYxP3.js +385 -0
- package/dist/exec-approvals-cli-xpbxnj4O.js +388 -0
- package/dist/extensionAPI.js +66572 -0
- package/dist/format-Dzy9uRLE.js +34 -0
- package/dist/format-sj0fELBK.js +34 -0
- package/dist/gateway-cli-5A-KNLEC.js +16635 -0
- package/dist/gateway-cli-B8kS4chb.js +16637 -0
- package/dist/gateway-rpc-15n38Ize.js +28 -0
- package/dist/gateway-rpc-TMVRgGfj.js +28 -0
- package/dist/github-copilot-auth-DVZj4Zgh.js +1104 -0
- package/dist/github-copilot-auth-DeGYyLY9.js +1104 -0
- package/dist/github-copilot-token-B3SA95yo.js +103 -0
- package/dist/github-copilot-token-C8XFYz0i.js +103 -0
- package/dist/github-copilot-token-CnxakiSC.js +103 -0
- package/dist/gmail-setup-utils-CWPC386a.js +428 -0
- package/dist/gmail-setup-utils-eJVB5Ewp.js +428 -0
- package/dist/health-format-B0tMTk3C.js +1189 -0
- package/dist/health-format-DaURVaUn.js +1188 -0
- package/dist/help-format-CEsRHU2f.js +17 -0
- package/dist/help-format-GuCWws6r.js +17 -0
- package/dist/helpers-BEJ-phFf.js +25 -0
- package/dist/helpers-BtbBZVKZ.js +10 -0
- package/dist/helpers-C12w9zxf.js +10 -0
- package/dist/helpers-CzjGJZmJ.js +25 -0
- package/dist/hooks/bundled/boot-md/HOOK.md +19 -0
- package/dist/hooks/bundled/command-logger/HOOK.md +122 -0
- package/dist/hooks/bundled/session-memory/HOOK.md +109 -0
- package/dist/hooks/bundled/soul-evil/HOOK.md +71 -0
- package/dist/hooks-cli-BZCMAnW2.js +1058 -0
- package/dist/hooks-cli-D0CEFg3P.js +1061 -0
- package/dist/hooks-status-Bn7_O8PM.js +443 -0
- package/dist/hooks-status-BrWVfIn0.js +443 -0
- package/dist/image-BS022pvv.js +1421 -0
- package/dist/image-BzJtY34J.js +629 -0
- package/dist/image-CBqmIbQQ.js +629 -0
- package/dist/index.js +5809 -0
- package/dist/installs-BP4K5L33.js +388 -0
- package/dist/installs-DOpTt7VZ.js +388 -0
- package/dist/is-main-B4o72sqg.js +25 -0
- package/dist/is-main-PYGa3tDA.js +25 -0
- package/dist/links-B4nk2iDf.js +15 -0
- package/dist/links-DwjRqxgR.js +15 -0
- package/dist/loader-Cn4EV_pf.js +63690 -0
- package/dist/logging-CS3tbYDj.js +15 -0
- package/dist/logging-CY-Q5cwf.js +1 -0
- package/dist/logging-DhiLkhLw.js +15 -0
- package/dist/logging-pqyrk15z.js +1 -0
- package/dist/login-qr-CD164Aw1.js +478 -0
- package/dist/login-qr-D7Zdgji2.js +478 -0
- package/dist/login-qr-YgILJ4VC.js +475 -0
- package/dist/logs-cli-BdS0Uv0I.js +227 -0
- package/dist/logs-cli-CqSN1GzB.js +230 -0
- package/dist/manager-CfGY5zND.js +2870 -0
- package/dist/manager-CjuBqFRL.js +2870 -0
- package/dist/manager-CoBEAQKm.js +2872 -0
- package/dist/manifest-registry-Bwjq9Iev.js +668 -0
- package/dist/manifest-registry-D2Yntqcb.js +668 -0
- package/dist/message-channel-Cjsiqxok.js +105 -0
- package/dist/message-channel-D6v_oPAg.js +105 -0
- package/dist/model-selection-Cv5Ox_tY.js +2956 -0
- package/dist/model-selection-Dr-5U5-l.js +2708 -0
- package/dist/models-cli-B39ckynD.js +2541 -0
- package/dist/models-cli-DoiYsBYw.js +2544 -0
- package/dist/net-CFCxaipF.js +137 -0
- package/dist/net-DKJPqXuW.js +137 -0
- package/dist/node-cli-C_FYF-RA.js +1456 -0
- package/dist/node-cli-DWPoNsQS.js +1459 -0
- package/dist/node-service-DcJREOww.js +67 -0
- package/dist/node-service-DuZ9Us9h.js +67 -0
- package/dist/nodes-cli-Elo6tlen.js +1210 -0
- package/dist/nodes-cli-zqryRUWB.js +1207 -0
- package/dist/nodes-screen-C4aCrxie.js +157 -0
- package/dist/nodes-screen-D4PSynkR.js +157 -0
- package/dist/note-CQhSvgQv.js +73 -0
- package/dist/note-_C44YfAQ.js +73 -0
- package/dist/onboard-channels-CHBDi-ZA.js +670 -0
- package/dist/onboard-channels-DOEKyxaL.js +670 -0
- package/dist/onboard-skills-BUTXREDZ.js +3327 -0
- package/dist/onboard-skills-CSLYZmZA.js +3327 -0
- package/dist/onboarding-CgKb8b39.js +3232 -0
- package/dist/openclaw-root-9ILYSmJ9.js +84 -0
- package/dist/openclaw-root-Cvotktkd.js +84 -0
- package/dist/pairing-cli-B4UGR2at.js +114 -0
- package/dist/pairing-cli-BWDDl8cf.js +117 -0
- package/dist/pairing-labels-ClZ-fTWT.js +9 -0
- package/dist/pairing-labels-Ds7BPOkj.js +9 -0
- package/dist/pairing-store-DDLNuzmx.js +391 -0
- package/dist/pairing-store-DRn08lZD.js +391 -0
- package/dist/parse-87ybtYW1.js +23 -0
- package/dist/parse-OCFfznr3.js +23 -0
- package/dist/parse-log-line-C9aL5PUL.js +44 -0
- package/dist/parse-log-line-DxRaGzQb.js +44 -0
- package/dist/parse-timeout-CFqNj7No.js +16 -0
- package/dist/parse-timeout-DV8NQQWk.js +16 -0
- package/dist/path-env-C7kiJUgG.js +77 -0
- package/dist/path-env-DEj4CiFN.js +77 -0
- package/dist/paths-B-q1nXdY.js +43 -0
- package/dist/paths-B1kfl4h5.js +164 -0
- package/dist/paths-B4kigINg.js +40 -0
- package/dist/paths-CHGbP1-A.js +43 -0
- package/dist/paths-scjhy7N2.js +180 -0
- package/dist/pi-embedded-helpers-C19wUpMB.js +8451 -0
- package/dist/pi-embedded-helpers-CT5VuLCb.js +1293 -0
- package/dist/pi-embedded-helpers-Dl8e5Rf8.js +1293 -0
- package/dist/pi-model-discovery-B6CsmK6Y.js +20 -0
- package/dist/pi-model-discovery-DsRqYJLy.js +20 -0
- package/dist/pi-model-discovery-EhM2JAQo.js +20 -0
- package/dist/pi-tools.policy-BvkSDFDN.js +229 -0
- package/dist/plugin-auto-enable-Bd_StZzz.js +461 -0
- package/dist/plugin-auto-enable-DBhXb_0x.js +461 -0
- package/dist/plugin-sdk/agent-scope-DdwUKIOe.js +606 -0
- package/dist/plugin-sdk/chrome-G8apFa5p.js +1953 -0
- package/dist/plugin-sdk/command-format-qUVxzqYm.js +52 -0
- package/dist/plugin-sdk/config-Cm1M7tgH.js +5623 -0
- package/dist/plugin-sdk/deliver-Cl8uowiO.js +2557 -0
- package/dist/plugin-sdk/exec-Cm9b2r9Q.js +1107 -0
- package/dist/plugin-sdk/github-copilot-token-BHNcM4_B.js +103 -0
- package/dist/plugin-sdk/image-7PgoS2VD.js +1421 -0
- package/dist/plugin-sdk/index.d.ts +8908 -0
- package/dist/plugin-sdk/index.js +70888 -0
- package/dist/plugin-sdk/login-qr-qTALvWi2.js +475 -0
- package/dist/plugin-sdk/manager-Cs3EQZCb.js +2870 -0
- package/dist/plugin-sdk/model-selection-BgC1E1a7.js +2708 -0
- package/dist/plugin-sdk/paths-BYpoyRv5.js +164 -0
- package/dist/plugin-sdk/paths-DNQE-bvr.js +40 -0
- package/dist/plugin-sdk/pi-embedded-helpers-5jNqW_dE.js +8755 -0
- package/dist/plugin-sdk/pi-model-discovery-BUGEht9A.js +20 -0
- package/dist/plugin-sdk/pw-ai-COTtei4a.js +1649 -0
- package/dist/plugin-sdk/qmd-manager-ClSwiAJl.js +615 -0
- package/dist/plugin-sdk/redact-2AzjOfk2.js +94 -0
- package/dist/plugin-sdk/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/plugin-sdk/sqlite-gCW7MlLs.js +215 -0
- package/dist/plugin-sdk/transcript-events-DGF257vD.js +17 -0
- package/dist/plugins-C3Bm-HQV.js +494 -0
- package/dist/plugins-QJjTXliB.js +495 -0
- package/dist/plugins-cli-DTci0JQb.js +443 -0
- package/dist/plugins-cli-wJsN1HHK.js +440 -0
- package/dist/ports-CiW9dmMq.js +96 -0
- package/dist/program-BWpTHh1I.js +188 -0
- package/dist/progress-Bcjniu7m.js +133 -0
- package/dist/progress-CvaSPjS9.js +133 -0
- package/dist/prompt-style-CFsleyxV.js +9 -0
- package/dist/prompt-style-DYJdrXyV.js +9 -0
- package/dist/prompts-Bt9fwsg2.js +10 -0
- package/dist/prompts-CudpZgTI.js +10 -0
- package/dist/pw-ai-08F3GD-3.js +1649 -0
- package/dist/pw-ai-ZmHxHQnx.js +1651 -0
- package/dist/pw-ai-tNPuRNn3.js +1649 -0
- package/dist/qmd-manager-2r-4n3sP.js +617 -0
- package/dist/qmd-manager-CF52nuBg.js +615 -0
- package/dist/qmd-manager-HEm5H2mk.js +616 -0
- package/dist/redact-BICFkpn7.js +97 -0
- package/dist/redact-BIMJ3ntQ.js +94 -0
- package/dist/redact-KzWHRS5J.js +97 -0
- package/dist/register.subclis-D2K25c84.js +348 -0
- package/dist/register.subclis-Dd8LbOLi.js +342 -0
- package/dist/reply-5UNWRwMn.js +63693 -0
- package/dist/restart-sentinel-Cr0vUxB8.js +65 -0
- package/dist/restart-sentinel-DUemCjgU.js +65 -0
- package/dist/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/routes-C6UpTPas.js +2410 -0
- package/dist/routes-ClNyEvlm.js +2410 -0
- package/dist/rpc-D0mf7DIw.js +95 -0
- package/dist/rpc-DYdOrgd9.js +95 -0
- package/dist/run-main-CojI7gWx.js +194 -0
- package/dist/runtime-guard-68M_evhb.js +60 -0
- package/dist/runtime-guard-DkjmhnBD.js +60 -0
- package/dist/sandbox-Ca81z3Tw.js +2924 -0
- package/dist/sandbox-cli-D75GApgp.js +459 -0
- package/dist/sandbox-cli-E4SJsC1C.js +462 -0
- package/dist/sandbox-knontqD9.js +2925 -0
- package/dist/security-cli-BLihvXO-.js +503 -0
- package/dist/security-cli-IGQCsK4g.js +506 -0
- package/dist/server-context-B9GX5GOI.js +740 -0
- package/dist/server-context-BFH7HB_M.js +740 -0
- package/dist/server-node-events-CTdHBiEA.js +218 -0
- package/dist/server-node-events-DAV14qPr.js +215 -0
- package/dist/service-BZNBq9hq.js +680 -0
- package/dist/service-C-BLXx9U.js +680 -0
- package/dist/service-audit-BfJv4NqZ.js +542 -0
- package/dist/service-audit-Bw3M2OEI.js +542 -0
- package/dist/shared-5SH-45AX.js +74 -0
- package/dist/shared-BxRm5uLU.js +74 -0
- package/dist/shared-C80Rmxsd.js +150 -0
- package/dist/shared-fGK6_D2v.js +150 -0
- package/dist/skills-Bhp0l6UK.js +693 -0
- package/dist/skills-Tky2kCMO.js +694 -0
- package/dist/skills-cli-6rCClAE4.js +287 -0
- package/dist/skills-cli-C4nLCrLw.js +290 -0
- package/dist/skills-status-CENcKr3I.js +187 -0
- package/dist/skills-status-DX1eUYvk.js +187 -0
- package/dist/sqlite-CmdZSZRx.js +197 -0
- package/dist/sqlite-Dnmf3LS7.js +215 -0
- package/dist/sqlite-QDf0yuU0.js +215 -0
- package/dist/status-BSfGAp2D.js +27 -0
- package/dist/status-Bp_2NMjt.js +27 -0
- package/dist/status-C0ANDr0T.js +3140 -0
- package/dist/status-CCHBIZnm.js +21 -0
- package/dist/status-Vuqbw2Bb.js +21 -0
- package/dist/status.update-BZW5r8Su.js +79 -0
- package/dist/status.update-BnD93_O8.js +79 -0
- package/dist/subsystem-CAq3uyo7.js +834 -0
- package/dist/system-cli-Bb9zmCO1.js +83 -0
- package/dist/system-cli-TIIQ04ls.js +80 -0
- package/dist/systemd-0Qa_nGqe.js +438 -0
- package/dist/systemd-Czb0Xsm7.js +438 -0
- package/dist/systemd-hints-CWoEOQRb.js +19 -0
- package/dist/systemd-hints-Cv3RN_mZ.js +19 -0
- package/dist/systemd-linger-CsdvcIoS.js +75 -0
- package/dist/systemd-linger-DKUFHcLn.js +75 -0
- package/dist/table-DNPESyNj.js +279 -0
- package/dist/table-DS4-gmkV.js +279 -0
- package/dist/tailnet-Bg_vE5qi.js +42 -0
- package/dist/tailnet-CrNWlQRJ.js +42 -0
- package/dist/tailscale-CBv58toW.js +252 -0
- package/dist/tailscale-DCnMs7_q.js +225 -0
- package/dist/tool-display-BEACy9rK.js +795 -0
- package/dist/tool-display-NYQnSpdo.js +795 -0
- package/dist/transcript-events-CsB1Saa6.js +17 -0
- package/dist/transcript-events-DDYvbmRV.js +17 -0
- package/dist/transcript-events-JLH5W4He.js +17 -0
- package/dist/tui--NY0rnjr.js +2542 -0
- package/dist/tui-DqJfGtvM.js +2543 -0
- package/dist/tui-cli-BuHNY6wF.js +54 -0
- package/dist/tui-cli-LMFV982e.js +57 -0
- package/dist/update-CRpHtCgz.js +317 -0
- package/dist/update-D3qruxhj.js +317 -0
- package/dist/update-cli-CFF-pslM.js +948 -0
- package/dist/update-cli-cn9pEMX7.js +951 -0
- package/dist/update-runner-CxGU142L.js +1221 -0
- package/dist/update-runner-DNobz_ft.js +1221 -0
- package/dist/utils-CKSrBNwq.js +192 -0
- package/dist/utils-DX85MiPR.js +188 -0
- package/dist/webhooks-cli-BGtt2HAR.js +312 -0
- package/dist/webhooks-cli-DHLZrEO_.js +309 -0
- package/dist/widearea-dns-BpG7ATO8.js +127 -0
- package/dist/widearea-dns-D4wkCJly.js +127 -0
- package/dist/ws-3zr8WUwL.js +13 -0
- package/dist/ws-log-BXcT2xQk.js +267 -0
- package/dist/ws-log-DbDIUsgz.js +267 -0
- package/dist/ws-lzrgabja.js +13 -0
- package/dist/wsl-D2O2qOrl.js +160 -0
- package/docs/.i18n/README.md +31 -0
- package/docs/.i18n/glossary.zh-CN.json +190 -0
- package/docs/.i18n/zh-CN.tm.jsonl +1329 -0
- package/docs/CNAME +1 -0
- package/docs/_config.yml +53 -0
- package/docs/_layouts/default.html +145 -0
- package/docs/assets/markdown.css +179 -0
- package/docs/assets/openclaw-logo-text-dark.png +0 -0
- package/docs/assets/openclaw-logo-text.png +0 -0
- package/docs/assets/pixel-lobster.svg +60 -0
- package/docs/assets/showcase/agents-ui.jpg +0 -0
- package/docs/assets/showcase/bambu-cli.png +0 -0
- package/docs/assets/showcase/codexmonitor.png +0 -0
- package/docs/assets/showcase/gohome-grafana.png +0 -0
- package/docs/assets/showcase/ios-testflight.jpg +0 -0
- package/docs/assets/showcase/oura-health.png +0 -0
- package/docs/assets/showcase/padel-cli.svg +11 -0
- package/docs/assets/showcase/padel-screenshot.jpg +0 -0
- package/docs/assets/showcase/papla-tts.jpg +0 -0
- package/docs/assets/showcase/pr-review-telegram.jpg +0 -0
- package/docs/assets/showcase/roborock-screenshot.jpg +0 -0
- package/docs/assets/showcase/roborock-status.svg +13 -0
- package/docs/assets/showcase/roof-camera-sky.jpg +0 -0
- package/docs/assets/showcase/snag.png +0 -0
- package/docs/assets/showcase/tesco-shop.jpg +0 -0
- package/docs/assets/showcase/wienerlinien.png +0 -0
- package/docs/assets/showcase/wine-cellar-skill.jpg +0 -0
- package/docs/assets/showcase/winix-air-purifier.jpg +0 -0
- package/docs/assets/showcase/xuezh-pronunciation.jpeg +0 -0
- package/docs/assets/terminal.css +473 -0
- package/docs/assets/theme.js +55 -0
- package/docs/automation/auth-monitoring.md +44 -0
- package/docs/automation/cron-jobs.md +468 -0
- package/docs/automation/cron-vs-heartbeat.md +282 -0
- package/docs/automation/gmail-pubsub.md +256 -0
- package/docs/automation/poll.md +69 -0
- package/docs/automation/webhook.md +163 -0
- package/docs/bedrock.md +176 -0
- package/docs/brave-search.md +41 -0
- package/docs/broadcast-groups.md +442 -0
- package/docs/channels/bluebubbles.md +338 -0
- package/docs/channels/discord.md +475 -0
- package/docs/channels/feishu.md +507 -0
- package/docs/channels/googlechat.md +250 -0
- package/docs/channels/grammy.md +31 -0
- package/docs/channels/imessage.md +299 -0
- package/docs/channels/index.md +46 -0
- package/docs/channels/line.md +186 -0
- package/docs/channels/location.md +56 -0
- package/docs/channels/matrix.md +233 -0
- package/docs/channels/mattermost.md +138 -0
- package/docs/channels/msteams.md +768 -0
- package/docs/channels/nextcloud-talk.md +136 -0
- package/docs/channels/nostr.md +233 -0
- package/docs/channels/signal.md +202 -0
- package/docs/channels/slack.md +548 -0
- package/docs/channels/telegram.md +750 -0
- package/docs/channels/tlon.md +132 -0
- package/docs/channels/troubleshooting.md +29 -0
- package/docs/channels/twitch.md +379 -0
- package/docs/channels/whatsapp.md +404 -0
- package/docs/channels/zalo.md +189 -0
- package/docs/channels/zalouser.md +140 -0
- package/docs/cli/acp.md +170 -0
- package/docs/cli/agent.md +24 -0
- package/docs/cli/agents.md +75 -0
- package/docs/cli/approvals.md +50 -0
- package/docs/cli/browser.md +107 -0
- package/docs/cli/channels.md +79 -0
- package/docs/cli/config.md +50 -0
- package/docs/cli/configure.md +33 -0
- package/docs/cli/cron.md +42 -0
- package/docs/cli/dashboard.md +16 -0
- package/docs/cli/devices.md +67 -0
- package/docs/cli/directory.md +63 -0
- package/docs/cli/dns.md +23 -0
- package/docs/cli/docs.md +15 -0
- package/docs/cli/doctor.md +41 -0
- package/docs/cli/gateway.md +199 -0
- package/docs/cli/health.md +21 -0
- package/docs/cli/hooks.md +304 -0
- package/docs/cli/index.md +1029 -0
- package/docs/cli/logs.md +24 -0
- package/docs/cli/memory.md +45 -0
- package/docs/cli/message.md +239 -0
- package/docs/cli/models.md +79 -0
- package/docs/cli/node.md +112 -0
- package/docs/cli/nodes.md +73 -0
- package/docs/cli/onboard.md +29 -0
- package/docs/cli/pairing.md +21 -0
- package/docs/cli/plugins.md +62 -0
- package/docs/cli/reset.md +17 -0
- package/docs/cli/sandbox.md +152 -0
- package/docs/cli/security.md +26 -0
- package/docs/cli/sessions.md +16 -0
- package/docs/cli/setup.md +29 -0
- package/docs/cli/skills.md +26 -0
- package/docs/cli/status.md +26 -0
- package/docs/cli/system.md +60 -0
- package/docs/cli/tui.md +23 -0
- package/docs/cli/uninstall.md +17 -0
- package/docs/cli/update.md +98 -0
- package/docs/cli/voicecall.md +34 -0
- package/docs/cli/webhooks.md +25 -0
- package/docs/concepts/agent-loop.md +146 -0
- package/docs/concepts/agent-workspace.md +233 -0
- package/docs/concepts/agent.md +123 -0
- package/docs/concepts/architecture.md +129 -0
- package/docs/concepts/channel-routing.md +114 -0
- package/docs/concepts/compaction.md +61 -0
- package/docs/concepts/context.md +161 -0
- package/docs/concepts/group-messages.md +84 -0
- package/docs/concepts/groups.md +373 -0
- package/docs/concepts/markdown-formatting.md +130 -0
- package/docs/concepts/memory.md +546 -0
- package/docs/concepts/messages.md +154 -0
- package/docs/concepts/model-failover.md +149 -0
- package/docs/concepts/model-providers.md +316 -0
- package/docs/concepts/models.md +208 -0
- package/docs/concepts/multi-agent.md +376 -0
- package/docs/concepts/oauth.md +145 -0
- package/docs/concepts/presence.md +102 -0
- package/docs/concepts/queue.md +89 -0
- package/docs/concepts/retry.md +69 -0
- package/docs/concepts/session-pruning.md +122 -0
- package/docs/concepts/session-tool.md +193 -0
- package/docs/concepts/session.md +188 -0
- package/docs/concepts/sessions.md +10 -0
- package/docs/concepts/streaming.md +135 -0
- package/docs/concepts/system-prompt.md +115 -0
- package/docs/concepts/timezone.md +91 -0
- package/docs/concepts/typebox.md +289 -0
- package/docs/concepts/typing-indicators.md +68 -0
- package/docs/concepts/usage-tracking.md +35 -0
- package/docs/date-time.md +128 -0
- package/docs/debug/node-issue.md +83 -0
- package/docs/debugging.md +162 -0
- package/docs/diagnostics/flags.md +91 -0
- package/docs/docs.json +1587 -0
- package/docs/environment.md +81 -0
- package/docs/experiments/onboarding-config-protocol.md +40 -0
- package/docs/experiments/plans/cron-add-hardening.md +63 -0
- package/docs/experiments/plans/group-policy-hardening.md +40 -0
- package/docs/experiments/plans/openresponses-gateway.md +123 -0
- package/docs/experiments/proposals/model-config.md +36 -0
- package/docs/experiments/research/memory.md +228 -0
- package/docs/gateway/authentication.md +145 -0
- package/docs/gateway/background-process.md +93 -0
- package/docs/gateway/bonjour.md +167 -0
- package/docs/gateway/bridge-protocol.md +89 -0
- package/docs/gateway/cli-backends.md +223 -0
- package/docs/gateway/configuration-examples.md +606 -0
- package/docs/gateway/configuration.md +3393 -0
- package/docs/gateway/discovery.md +116 -0
- package/docs/gateway/doctor.md +282 -0
- package/docs/gateway/gateway-lock.md +34 -0
- package/docs/gateway/health.md +35 -0
- package/docs/gateway/heartbeat.md +302 -0
- package/docs/gateway/index.md +328 -0
- package/docs/gateway/local-models.md +150 -0
- package/docs/gateway/logging.md +113 -0
- package/docs/gateway/multiple-gateways.md +112 -0
- package/docs/gateway/openai-http-api.md +118 -0
- package/docs/gateway/openresponses-http-api.md +317 -0
- package/docs/gateway/pairing.md +99 -0
- package/docs/gateway/protocol.md +221 -0
- package/docs/gateway/remote-gateway-readme.md +157 -0
- package/docs/gateway/remote.md +127 -0
- package/docs/gateway/sandbox-vs-tool-policy-vs-elevated.md +128 -0
- package/docs/gateway/sandboxing.md +193 -0
- package/docs/gateway/security/formal-verification.md +164 -0
- package/docs/gateway/security/index.md +825 -0
- package/docs/gateway/tailscale.md +127 -0
- package/docs/gateway/tools-invoke-http-api.md +85 -0
- package/docs/gateway/troubleshooting.md +767 -0
- package/docs/help/faq.md +2830 -0
- package/docs/help/index.md +21 -0
- package/docs/help/troubleshooting.md +98 -0
- package/docs/hooks/soul-evil.md +69 -0
- package/docs/hooks.md +913 -0
- package/docs/images/feishu-step2-create-app.png +0 -0
- package/docs/images/feishu-step3-credentials.png +0 -0
- package/docs/images/feishu-step4-permissions.png +0 -0
- package/docs/images/feishu-step5-bot-capability.png +0 -0
- package/docs/images/feishu-step6-event-subscription.png +0 -0
- package/docs/images/groups-flow.svg +52 -0
- package/docs/images/mobile-ui-screenshot.png +0 -0
- package/docs/index.md +258 -0
- package/docs/install/ansible.md +208 -0
- package/docs/install/bun.md +59 -0
- package/docs/install/development-channels.md +75 -0
- package/docs/install/docker.md +567 -0
- package/docs/install/index.md +185 -0
- package/docs/install/installer.md +123 -0
- package/docs/install/migrating.md +192 -0
- package/docs/install/nix.md +96 -0
- package/docs/install/node.md +78 -0
- package/docs/install/uninstall.md +128 -0
- package/docs/install/updating.md +228 -0
- package/docs/logging.md +350 -0
- package/docs/multi-agent-sandbox-tools.md +395 -0
- package/docs/network.md +54 -0
- package/docs/nodes/audio.md +114 -0
- package/docs/nodes/camera.md +156 -0
- package/docs/nodes/images.md +72 -0
- package/docs/nodes/index.md +341 -0
- package/docs/nodes/location-command.md +113 -0
- package/docs/nodes/media-understanding.md +379 -0
- package/docs/nodes/talk.md +90 -0
- package/docs/nodes/voicewake.md +65 -0
- package/docs/northflank.mdx +53 -0
- package/docs/perplexity.md +80 -0
- package/docs/pi-dev.md +70 -0
- package/docs/pi.md +612 -0
- package/docs/platforms/android.md +148 -0
- package/docs/platforms/digitalocean.md +262 -0
- package/docs/platforms/exe-dev.md +125 -0
- package/docs/platforms/fly.md +486 -0
- package/docs/platforms/gcp.md +503 -0
- package/docs/platforms/hetzner.md +330 -0
- package/docs/platforms/index.md +53 -0
- package/docs/platforms/ios.md +107 -0
- package/docs/platforms/linux.md +94 -0
- package/docs/platforms/mac/bundled-gateway.md +73 -0
- package/docs/platforms/mac/canvas.md +125 -0
- package/docs/platforms/mac/child-process.md +69 -0
- package/docs/platforms/mac/dev-setup.md +102 -0
- package/docs/platforms/mac/health.md +34 -0
- package/docs/platforms/mac/icon.md +31 -0
- package/docs/platforms/mac/logging.md +57 -0
- package/docs/platforms/mac/menu-bar.md +81 -0
- package/docs/platforms/mac/peekaboo.md +65 -0
- package/docs/platforms/mac/permissions.md +44 -0
- package/docs/platforms/mac/release.md +85 -0
- package/docs/platforms/mac/remote.md +83 -0
- package/docs/platforms/mac/signing.md +47 -0
- package/docs/platforms/mac/skills.md +33 -0
- package/docs/platforms/mac/voice-overlay.md +60 -0
- package/docs/platforms/mac/voicewake.md +67 -0
- package/docs/platforms/mac/webchat.md +41 -0
- package/docs/platforms/mac/xpc.md +61 -0
- package/docs/platforms/macos-vm.md +281 -0
- package/docs/platforms/macos.md +203 -0
- package/docs/platforms/oracle.md +303 -0
- package/docs/platforms/raspberry-pi.md +358 -0
- package/docs/platforms/windows.md +159 -0
- package/docs/plugin.md +664 -0
- package/docs/plugins/agent-tools.md +99 -0
- package/docs/plugins/manifest.md +71 -0
- package/docs/plugins/voice-call.md +284 -0
- package/docs/plugins/zalouser.md +81 -0
- package/docs/prose.md +134 -0
- package/docs/providers/anthropic.md +152 -0
- package/docs/providers/claude-max-api-proxy.md +148 -0
- package/docs/providers/cloudflare-ai-gateway.md +71 -0
- package/docs/providers/deepgram.md +93 -0
- package/docs/providers/github-copilot.md +72 -0
- package/docs/providers/glm.md +33 -0
- package/docs/providers/index.md +63 -0
- package/docs/providers/minimax.md +208 -0
- package/docs/providers/models.md +51 -0
- package/docs/providers/moonshot.md +142 -0
- package/docs/providers/ollama.md +223 -0
- package/docs/providers/openai.md +62 -0
- package/docs/providers/opencode.md +36 -0
- package/docs/providers/openrouter.md +37 -0
- package/docs/providers/qwen.md +53 -0
- package/docs/providers/synthetic.md +99 -0
- package/docs/providers/venice.md +267 -0
- package/docs/providers/vercel-ai-gateway.md +50 -0
- package/docs/providers/xiaomi.md +64 -0
- package/docs/providers/zai.md +36 -0
- package/docs/railway.mdx +99 -0
- package/docs/refactor/clawnet.md +417 -0
- package/docs/refactor/exec-host.md +316 -0
- package/docs/refactor/outbound-session-mirroring.md +85 -0
- package/docs/refactor/plugin-sdk.md +214 -0
- package/docs/refactor/strict-config.md +93 -0
- package/docs/reference/AGENTS.default.md +124 -0
- package/docs/reference/RELEASING.md +120 -0
- package/docs/reference/api-usage-costs.md +137 -0
- package/docs/reference/device-models.md +47 -0
- package/docs/reference/rpc.md +43 -0
- package/docs/reference/session-management-compaction.md +285 -0
- package/docs/reference/templates/AGENTS.dev.md +83 -0
- package/docs/reference/templates/AGENTS.md +218 -0
- package/docs/reference/templates/BOOT.md +10 -0
- package/docs/reference/templates/BOOTSTRAP.md +61 -0
- package/docs/reference/templates/HEARTBEAT.md +11 -0
- package/docs/reference/templates/IDENTITY.dev.md +47 -0
- package/docs/reference/templates/IDENTITY.md +27 -0
- package/docs/reference/templates/SOUL.dev.md +76 -0
- package/docs/reference/templates/SOUL.md +42 -0
- package/docs/reference/templates/TOOLS.dev.md +24 -0
- package/docs/reference/templates/TOOLS.md +46 -0
- package/docs/reference/templates/USER.dev.md +18 -0
- package/docs/reference/templates/USER.md +22 -0
- package/docs/reference/test.md +50 -0
- package/docs/reference/transcript-hygiene.md +129 -0
- package/docs/render.mdx +165 -0
- package/docs/scripts.md +28 -0
- package/docs/security/formal-verification.md +164 -0
- package/docs/start/getting-started.md +208 -0
- package/docs/start/hubs.md +185 -0
- package/docs/start/lore.md +219 -0
- package/docs/start/onboarding.md +110 -0
- package/docs/start/openclaw.md +241 -0
- package/docs/start/pairing.md +86 -0
- package/docs/start/setup.md +149 -0
- package/docs/start/showcase.md +416 -0
- package/docs/start/wizard.md +349 -0
- package/docs/testing.md +368 -0
- package/docs/token-use.md +112 -0
- package/docs/tools/agent-send.md +53 -0
- package/docs/tools/apply-patch.md +50 -0
- package/docs/tools/browser-linux-troubleshooting.md +139 -0
- package/docs/tools/browser-login.md +68 -0
- package/docs/tools/browser.md +576 -0
- package/docs/tools/chrome-extension.md +178 -0
- package/docs/tools/clawhub.md +257 -0
- package/docs/tools/creating-skills.md +54 -0
- package/docs/tools/elevated.md +57 -0
- package/docs/tools/exec-approvals.md +246 -0
- package/docs/tools/exec.md +179 -0
- package/docs/tools/firecrawl.md +61 -0
- package/docs/tools/index.md +509 -0
- package/docs/tools/llm-task.md +115 -0
- package/docs/tools/lobster.md +342 -0
- package/docs/tools/reactions.md +22 -0
- package/docs/tools/skills-config.md +76 -0
- package/docs/tools/skills.md +300 -0
- package/docs/tools/slash-commands.md +198 -0
- package/docs/tools/subagents.md +151 -0
- package/docs/tools/thinking.md +73 -0
- package/docs/tools/web.md +261 -0
- package/docs/tts.md +396 -0
- package/docs/tui.md +159 -0
- package/docs/vps.md +43 -0
- package/docs/web/control-ui.md +221 -0
- package/docs/web/dashboard.md +46 -0
- package/docs/web/index.md +116 -0
- package/docs/web/webchat.md +49 -0
- package/docs/whatsapp-openclaw-ai-zh.jpg +0 -0
- package/docs/whatsapp-openclaw.jpg +0 -0
- package/docs/zh-CN/AGENTS.md +59 -0
- package/docs/zh-CN/automation/auth-monitoring.md +47 -0
- package/docs/zh-CN/automation/cron-jobs.md +424 -0
- package/docs/zh-CN/automation/cron-vs-heartbeat.md +286 -0
- package/docs/zh-CN/automation/gmail-pubsub.md +249 -0
- package/docs/zh-CN/automation/poll.md +76 -0
- package/docs/zh-CN/automation/webhook.md +163 -0
- package/docs/zh-CN/bedrock.md +170 -0
- package/docs/zh-CN/brave-search.md +48 -0
- package/docs/zh-CN/broadcast-groups.md +449 -0
- package/docs/zh-CN/channels/bluebubbles.md +271 -0
- package/docs/zh-CN/channels/discord.md +468 -0
- package/docs/zh-CN/channels/feishu.md +513 -0
- package/docs/zh-CN/channels/googlechat.md +257 -0
- package/docs/zh-CN/channels/grammy.md +38 -0
- package/docs/zh-CN/channels/imessage.md +302 -0
- package/docs/zh-CN/channels/index.md +53 -0
- package/docs/zh-CN/channels/line.md +180 -0
- package/docs/zh-CN/channels/location.md +63 -0
- package/docs/zh-CN/channels/matrix.md +221 -0
- package/docs/zh-CN/channels/mattermost.md +144 -0
- package/docs/zh-CN/channels/msteams.md +775 -0
- package/docs/zh-CN/channels/nextcloud-talk.md +142 -0
- package/docs/zh-CN/channels/nostr.md +240 -0
- package/docs/zh-CN/channels/signal.md +209 -0
- package/docs/zh-CN/channels/slack.md +531 -0
- package/docs/zh-CN/channels/telegram.md +751 -0
- package/docs/zh-CN/channels/tlon.md +136 -0
- package/docs/zh-CN/channels/troubleshooting.md +36 -0
- package/docs/zh-CN/channels/twitch.md +385 -0
- package/docs/zh-CN/channels/whatsapp.md +411 -0
- package/docs/zh-CN/channels/zalo.md +196 -0
- package/docs/zh-CN/channels/zalouser.md +147 -0
- package/docs/zh-CN/cli/acp.md +173 -0
- package/docs/zh-CN/cli/agent.md +30 -0
- package/docs/zh-CN/cli/agents.md +82 -0
- package/docs/zh-CN/cli/approvals.md +57 -0
- package/docs/zh-CN/cli/browser.md +114 -0
- package/docs/zh-CN/cli/channels.md +86 -0
- package/docs/zh-CN/cli/config.md +57 -0
- package/docs/zh-CN/cli/configure.md +38 -0
- package/docs/zh-CN/cli/cron.md +43 -0
- package/docs/zh-CN/cli/dashboard.md +23 -0
- package/docs/zh-CN/cli/devices.md +74 -0
- package/docs/zh-CN/cli/directory.md +70 -0
- package/docs/zh-CN/cli/dns.md +30 -0
- package/docs/zh-CN/cli/docs.md +22 -0
- package/docs/zh-CN/cli/doctor.md +48 -0
- package/docs/zh-CN/cli/gateway.md +206 -0
- package/docs/zh-CN/cli/health.md +28 -0
- package/docs/zh-CN/cli/hooks.md +311 -0
- package/docs/zh-CN/cli/index.md +1032 -0
- package/docs/zh-CN/cli/logs.md +31 -0
- package/docs/zh-CN/cli/memory.md +52 -0
- package/docs/zh-CN/cli/message.md +246 -0
- package/docs/zh-CN/cli/models.md +85 -0
- package/docs/zh-CN/cli/node.md +115 -0
- package/docs/zh-CN/cli/nodes.md +80 -0
- package/docs/zh-CN/cli/onboard.md +36 -0
- package/docs/zh-CN/cli/pairing.md +28 -0
- package/docs/zh-CN/cli/plugins.md +66 -0
- package/docs/zh-CN/cli/reset.md +24 -0
- package/docs/zh-CN/cli/sandbox.md +158 -0
- package/docs/zh-CN/cli/security.md +33 -0
- package/docs/zh-CN/cli/sessions.md +23 -0
- package/docs/zh-CN/cli/setup.md +36 -0
- package/docs/zh-CN/cli/skills.md +33 -0
- package/docs/zh-CN/cli/status.md +33 -0
- package/docs/zh-CN/cli/system.md +63 -0
- package/docs/zh-CN/cli/tui.md +30 -0
- package/docs/zh-CN/cli/uninstall.md +24 -0
- package/docs/zh-CN/cli/update.md +101 -0
- package/docs/zh-CN/cli/voicecall.md +41 -0
- package/docs/zh-CN/cli/webhooks.md +32 -0
- package/docs/zh-CN/concepts/agent-loop.md +146 -0
- package/docs/zh-CN/concepts/agent-workspace.md +219 -0
- package/docs/zh-CN/concepts/agent.md +115 -0
- package/docs/zh-CN/concepts/architecture.md +123 -0
- package/docs/zh-CN/concepts/channel-routing.md +117 -0
- package/docs/zh-CN/concepts/compaction.md +67 -0
- package/docs/zh-CN/concepts/context.md +168 -0
- package/docs/zh-CN/concepts/group-messages.md +91 -0
- package/docs/zh-CN/concepts/groups.md +379 -0
- package/docs/zh-CN/concepts/markdown-formatting.md +117 -0
- package/docs/zh-CN/concepts/memory.md +412 -0
- package/docs/zh-CN/concepts/messages.md +141 -0
- package/docs/zh-CN/concepts/model-failover.md +145 -0
- package/docs/zh-CN/concepts/model-providers.md +320 -0
- package/docs/zh-CN/concepts/models.md +196 -0
- package/docs/zh-CN/concepts/multi-agent.md +372 -0
- package/docs/zh-CN/concepts/oauth.md +151 -0
- package/docs/zh-CN/concepts/presence.md +99 -0
- package/docs/zh-CN/concepts/queue.md +94 -0
- package/docs/zh-CN/concepts/retry.md +76 -0
- package/docs/zh-CN/concepts/session-pruning.md +129 -0
- package/docs/zh-CN/concepts/session-tool.md +200 -0
- package/docs/zh-CN/concepts/session.md +166 -0
- package/docs/zh-CN/concepts/sessions.md +17 -0
- package/docs/zh-CN/concepts/streaming.md +133 -0
- package/docs/zh-CN/concepts/system-prompt.md +101 -0
- package/docs/zh-CN/concepts/timezone.md +96 -0
- package/docs/zh-CN/concepts/typebox.md +284 -0
- package/docs/zh-CN/concepts/typing-indicators.md +74 -0
- package/docs/zh-CN/concepts/usage-tracking.md +42 -0
- package/docs/zh-CN/date-time.md +129 -0
- package/docs/zh-CN/debug/node-issue.md +90 -0
- package/docs/zh-CN/debugging.md +160 -0
- package/docs/zh-CN/diagnostics/flags.md +98 -0
- package/docs/zh-CN/environment.md +88 -0
- package/docs/zh-CN/experiments/onboarding-config-protocol.md +47 -0
- package/docs/zh-CN/experiments/plans/cron-add-hardening.md +70 -0
- package/docs/zh-CN/experiments/plans/group-policy-hardening.md +45 -0
- package/docs/zh-CN/experiments/plans/openresponses-gateway.md +121 -0
- package/docs/zh-CN/experiments/proposals/model-config.md +42 -0
- package/docs/zh-CN/experiments/research/memory.md +235 -0
- package/docs/zh-CN/gateway/authentication.md +142 -0
- package/docs/zh-CN/gateway/background-process.md +100 -0
- package/docs/zh-CN/gateway/bonjour.md +174 -0
- package/docs/zh-CN/gateway/bridge-protocol.md +86 -0
- package/docs/zh-CN/gateway/cli-backends.md +213 -0
- package/docs/zh-CN/gateway/configuration-examples.md +587 -0
- package/docs/zh-CN/gateway/configuration.md +3332 -0
- package/docs/zh-CN/gateway/discovery.md +123 -0
- package/docs/zh-CN/gateway/doctor.md +238 -0
- package/docs/zh-CN/gateway/gateway-lock.md +41 -0
- package/docs/zh-CN/gateway/health.md +42 -0
- package/docs/zh-CN/gateway/heartbeat.md +274 -0
- package/docs/zh-CN/gateway/index.md +335 -0
- package/docs/zh-CN/gateway/local-models.md +157 -0
- package/docs/zh-CN/gateway/logging.md +114 -0
- package/docs/zh-CN/gateway/multiple-gateways.md +119 -0
- package/docs/zh-CN/gateway/openai-http-api.md +125 -0
- package/docs/zh-CN/gateway/openresponses-http-api.md +317 -0
- package/docs/zh-CN/gateway/pairing.md +99 -0
- package/docs/zh-CN/gateway/protocol.md +220 -0
- package/docs/zh-CN/gateway/remote-gateway-readme.md +164 -0
- package/docs/zh-CN/gateway/remote.md +133 -0
- package/docs/zh-CN/gateway/sandbox-vs-tool-policy-vs-elevated.md +135 -0
- package/docs/zh-CN/gateway/sandboxing.md +188 -0
- package/docs/zh-CN/gateway/security/formal-verification.md +169 -0
- package/docs/zh-CN/gateway/security/index.md +777 -0
- package/docs/zh-CN/gateway/tailscale.md +124 -0
- package/docs/zh-CN/gateway/tools-invoke-http-api.md +92 -0
- package/docs/zh-CN/gateway/troubleshooting.md +771 -0
- package/docs/zh-CN/help/faq.md +2628 -0
- package/docs/zh-CN/help/index.md +28 -0
- package/docs/zh-CN/help/troubleshooting.md +104 -0
- package/docs/zh-CN/hooks/soul-evil.md +72 -0
- package/docs/zh-CN/hooks.md +919 -0
- package/docs/zh-CN/index.md +264 -0
- package/docs/zh-CN/install/ansible.md +215 -0
- package/docs/zh-CN/install/bun.md +65 -0
- package/docs/zh-CN/install/development-channels.md +81 -0
- package/docs/zh-CN/install/docker.md +532 -0
- package/docs/zh-CN/install/index.md +193 -0
- package/docs/zh-CN/install/installer.md +128 -0
- package/docs/zh-CN/install/migrating.md +199 -0
- package/docs/zh-CN/install/nix.md +99 -0
- package/docs/zh-CN/install/node.md +85 -0
- package/docs/zh-CN/install/uninstall.md +135 -0
- package/docs/zh-CN/install/updating.md +233 -0
- package/docs/zh-CN/logging.md +329 -0
- package/docs/zh-CN/multi-agent-sandbox-tools.md +401 -0
- package/docs/zh-CN/network.md +59 -0
- package/docs/zh-CN/nodes/audio.md +120 -0
- package/docs/zh-CN/nodes/camera.md +162 -0
- package/docs/zh-CN/nodes/images.md +79 -0
- package/docs/zh-CN/nodes/index.md +348 -0
- package/docs/zh-CN/nodes/location-command.md +120 -0
- package/docs/zh-CN/nodes/media-understanding.md +380 -0
- package/docs/zh-CN/nodes/talk.md +97 -0
- package/docs/zh-CN/nodes/voicewake.md +72 -0
- package/docs/zh-CN/northflank.mdx +60 -0
- package/docs/zh-CN/perplexity.md +84 -0
- package/docs/zh-CN/pi-dev.md +77 -0
- package/docs/zh-CN/pi.md +619 -0
- package/docs/zh-CN/platforms/android.md +155 -0
- package/docs/zh-CN/platforms/digitalocean.md +269 -0
- package/docs/zh-CN/platforms/exe-dev.md +127 -0
- package/docs/zh-CN/platforms/fly.md +490 -0
- package/docs/zh-CN/platforms/gcp.md +510 -0
- package/docs/zh-CN/platforms/hetzner.md +337 -0
- package/docs/zh-CN/platforms/index.md +60 -0
- package/docs/zh-CN/platforms/ios.md +114 -0
- package/docs/zh-CN/platforms/linux.md +101 -0
- package/docs/zh-CN/platforms/mac/bundled-gateway.md +75 -0
- package/docs/zh-CN/platforms/mac/canvas.md +128 -0
- package/docs/zh-CN/platforms/mac/child-process.md +73 -0
- package/docs/zh-CN/platforms/mac/dev-setup.md +109 -0
- package/docs/zh-CN/platforms/mac/health.md +41 -0
- package/docs/zh-CN/platforms/mac/icon.md +38 -0
- package/docs/zh-CN/platforms/mac/logging.md +64 -0
- package/docs/zh-CN/platforms/mac/menu-bar.md +88 -0
- package/docs/zh-CN/platforms/mac/peekaboo.md +62 -0
- package/docs/zh-CN/platforms/mac/permissions.md +46 -0
- package/docs/zh-CN/platforms/mac/release.md +92 -0
- package/docs/zh-CN/platforms/mac/remote.md +90 -0
- package/docs/zh-CN/platforms/mac/signing.md +54 -0
- package/docs/zh-CN/platforms/mac/skills.md +40 -0
- package/docs/zh-CN/platforms/mac/voice-overlay.md +67 -0
- package/docs/zh-CN/platforms/mac/voicewake.md +74 -0
- package/docs/zh-CN/platforms/mac/webchat.md +43 -0
- package/docs/zh-CN/platforms/mac/xpc.md +68 -0
- package/docs/zh-CN/platforms/macos-vm.md +288 -0
- package/docs/zh-CN/platforms/macos.md +193 -0
- package/docs/zh-CN/platforms/oracle.md +310 -0
- package/docs/zh-CN/platforms/raspberry-pi.md +365 -0
- package/docs/zh-CN/platforms/windows.md +156 -0
- package/docs/zh-CN/plugin.md +639 -0
- package/docs/zh-CN/plugins/agent-tools.md +99 -0
- package/docs/zh-CN/plugins/manifest.md +68 -0
- package/docs/zh-CN/plugins/voice-call.md +250 -0
- package/docs/zh-CN/plugins/zalouser.md +88 -0
- package/docs/zh-CN/prose.md +141 -0
- package/docs/zh-CN/providers/anthropic.md +159 -0
- package/docs/zh-CN/providers/claude-max-api-proxy.md +155 -0
- package/docs/zh-CN/providers/deepgram.md +97 -0
- package/docs/zh-CN/providers/github-copilot.md +67 -0
- package/docs/zh-CN/providers/glm.md +39 -0
- package/docs/zh-CN/providers/index.md +68 -0
- package/docs/zh-CN/providers/minimax.md +206 -0
- package/docs/zh-CN/providers/models.md +55 -0
- package/docs/zh-CN/providers/moonshot.md +145 -0
- package/docs/zh-CN/providers/ollama.md +230 -0
- package/docs/zh-CN/providers/openai.md +68 -0
- package/docs/zh-CN/providers/opencode.md +41 -0
- package/docs/zh-CN/providers/openrouter.md +43 -0
- package/docs/zh-CN/providers/qwen.md +55 -0
- package/docs/zh-CN/providers/synthetic.md +102 -0
- package/docs/zh-CN/providers/venice.md +274 -0
- package/docs/zh-CN/providers/vercel-ai-gateway.md +57 -0
- package/docs/zh-CN/providers/xiaomi.md +68 -0
- package/docs/zh-CN/providers/zai.md +41 -0
- package/docs/zh-CN/railway.mdx +106 -0
- package/docs/zh-CN/refactor/clawnet.md +424 -0
- package/docs/zh-CN/refactor/exec-host.md +323 -0
- package/docs/zh-CN/refactor/outbound-session-mirroring.md +92 -0
- package/docs/zh-CN/refactor/plugin-sdk.md +221 -0
- package/docs/zh-CN/refactor/strict-config.md +100 -0
- package/docs/zh-CN/reference/AGENTS.default.md +131 -0
- package/docs/zh-CN/reference/RELEASING.md +123 -0
- package/docs/zh-CN/reference/api-usage-costs.md +136 -0
- package/docs/zh-CN/reference/device-models.md +54 -0
- package/docs/zh-CN/reference/rpc.md +48 -0
- package/docs/zh-CN/reference/session-management-compaction.md +287 -0
- package/docs/zh-CN/reference/templates/AGENTS.dev.md +89 -0
- package/docs/zh-CN/reference/templates/AGENTS.md +225 -0
- package/docs/zh-CN/reference/templates/BOOT.md +17 -0
- package/docs/zh-CN/reference/templates/BOOTSTRAP.md +68 -0
- package/docs/zh-CN/reference/templates/HEARTBEAT.md +18 -0
- package/docs/zh-CN/reference/templates/IDENTITY.dev.md +54 -0
- package/docs/zh-CN/reference/templates/IDENTITY.md +35 -0
- package/docs/zh-CN/reference/templates/SOUL.dev.md +83 -0
- package/docs/zh-CN/reference/templates/SOUL.md +49 -0
- package/docs/zh-CN/reference/templates/TOOLS.dev.md +31 -0
- package/docs/zh-CN/reference/templates/TOOLS.md +53 -0
- package/docs/zh-CN/reference/templates/USER.dev.md +25 -0
- package/docs/zh-CN/reference/templates/USER.md +30 -0
- package/docs/zh-CN/reference/test.md +57 -0
- package/docs/zh-CN/reference/transcript-hygiene.md +109 -0
- package/docs/zh-CN/render.mdx +169 -0
- package/docs/zh-CN/scripts.md +35 -0
- package/docs/zh-CN/security/formal-verification.md +171 -0
- package/docs/zh-CN/start/getting-started.md +206 -0
- package/docs/zh-CN/start/hubs.md +191 -0
- package/docs/zh-CN/start/lore.md +226 -0
- package/docs/zh-CN/start/onboarding.md +105 -0
- package/docs/zh-CN/start/openclaw.md +248 -0
- package/docs/zh-CN/start/pairing.md +89 -0
- package/docs/zh-CN/start/setup.md +153 -0
- package/docs/zh-CN/start/showcase.md +423 -0
- package/docs/zh-CN/start/wizard.md +331 -0
- package/docs/zh-CN/testing.md +375 -0
- package/docs/zh-CN/token-use.md +119 -0
- package/docs/zh-CN/tools/agent-send.md +59 -0
- package/docs/zh-CN/tools/apply-patch.md +57 -0
- package/docs/zh-CN/tools/browser-linux-troubleshooting.md +144 -0
- package/docs/zh-CN/tools/browser-login.md +75 -0
- package/docs/zh-CN/tools/browser.md +553 -0
- package/docs/zh-CN/tools/chrome-extension.md +183 -0
- package/docs/zh-CN/tools/clawhub.md +209 -0
- package/docs/zh-CN/tools/creating-skills.md +61 -0
- package/docs/zh-CN/tools/elevated.md +64 -0
- package/docs/zh-CN/tools/exec-approvals.md +234 -0
- package/docs/zh-CN/tools/exec.md +169 -0
- package/docs/zh-CN/tools/firecrawl.md +68 -0
- package/docs/zh-CN/tools/index.md +515 -0
- package/docs/zh-CN/tools/llm-task.md +117 -0
- package/docs/zh-CN/tools/lobster.md +349 -0
- package/docs/zh-CN/tools/reactions.md +29 -0
- package/docs/zh-CN/tools/skills-config.md +78 -0
- package/docs/zh-CN/tools/skills.md +279 -0
- package/docs/zh-CN/tools/slash-commands.md +205 -0
- package/docs/zh-CN/tools/subagents.md +156 -0
- package/docs/zh-CN/tools/thinking.md +80 -0
- package/docs/zh-CN/tools/web.md +257 -0
- package/docs/zh-CN/tts.md +375 -0
- package/docs/zh-CN/tui.md +166 -0
- package/docs/zh-CN/vps.md +47 -0
- package/docs/zh-CN/web/control-ui.md +191 -0
- package/docs/zh-CN/web/dashboard.md +53 -0
- package/docs/zh-CN/web/index.md +118 -0
- package/docs/zh-CN/web/webchat.md +56 -0
- package/extensions/bluebubbles/README.md +45 -0
- package/extensions/bluebubbles/index.ts +19 -0
- package/extensions/bluebubbles/node_modules/.bin/openclaw +21 -0
- package/extensions/bluebubbles/openclaw.plugin.json +9 -0
- package/extensions/bluebubbles/package.json +36 -0
- package/extensions/bluebubbles/src/accounts.ts +88 -0
- package/extensions/bluebubbles/src/actions.test.ts +650 -0
- package/extensions/bluebubbles/src/actions.ts +438 -0
- package/extensions/bluebubbles/src/attachments.test.ts +345 -0
- package/extensions/bluebubbles/src/attachments.ts +300 -0
- package/extensions/bluebubbles/src/channel.ts +414 -0
- package/extensions/bluebubbles/src/chat.test.ts +461 -0
- package/extensions/bluebubbles/src/chat.ts +378 -0
- package/extensions/bluebubbles/src/config-schema.ts +51 -0
- package/extensions/bluebubbles/src/media-send.ts +174 -0
- package/extensions/bluebubbles/src/monitor.test.ts +2342 -0
- package/extensions/bluebubbles/src/monitor.ts +2490 -0
- package/extensions/bluebubbles/src/onboarding.ts +352 -0
- package/extensions/bluebubbles/src/probe.ts +135 -0
- package/extensions/bluebubbles/src/reactions.test.ts +392 -0
- package/extensions/bluebubbles/src/reactions.ts +188 -0
- package/extensions/bluebubbles/src/runtime.ts +14 -0
- package/extensions/bluebubbles/src/send.test.ts +808 -0
- package/extensions/bluebubbles/src/send.ts +467 -0
- package/extensions/bluebubbles/src/targets.test.ts +183 -0
- package/extensions/bluebubbles/src/targets.ts +422 -0
- package/extensions/bluebubbles/src/types.ts +127 -0
- package/extensions/copilot-proxy/README.md +24 -0
- package/extensions/copilot-proxy/index.ts +148 -0
- package/extensions/copilot-proxy/node_modules/.bin/openclaw +21 -0
- package/extensions/copilot-proxy/openclaw.plugin.json +9 -0
- package/extensions/copilot-proxy/package.json +14 -0
- package/extensions/diagnostics-otel/index.ts +15 -0
- package/extensions/diagnostics-otel/node_modules/.bin/openclaw +21 -0
- package/extensions/diagnostics-otel/openclaw.plugin.json +8 -0
- package/extensions/diagnostics-otel/package.json +27 -0
- package/extensions/diagnostics-otel/src/service.test.ts +226 -0
- package/extensions/diagnostics-otel/src/service.ts +635 -0
- package/extensions/discord/index.ts +17 -0
- package/extensions/discord/node_modules/.bin/openclaw +21 -0
- package/extensions/discord/openclaw.plugin.json +9 -0
- package/extensions/discord/package.json +14 -0
- package/extensions/discord/src/channel.ts +422 -0
- package/extensions/discord/src/runtime.ts +14 -0
- package/extensions/feishu/README.md +47 -0
- package/extensions/feishu/index.ts +15 -0
- package/extensions/feishu/node_modules/.bin/openclaw +21 -0
- package/extensions/feishu/openclaw.plugin.json +9 -0
- package/extensions/feishu/package.json +33 -0
- package/extensions/feishu/src/channel.ts +276 -0
- package/extensions/feishu/src/config-schema.ts +46 -0
- package/extensions/feishu/src/onboarding.ts +278 -0
- package/extensions/google-antigravity-auth/README.md +24 -0
- package/extensions/google-antigravity-auth/index.ts +461 -0
- package/extensions/google-antigravity-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/google-antigravity-auth/openclaw.plugin.json +9 -0
- package/extensions/google-antigravity-auth/package.json +14 -0
- package/extensions/google-gemini-cli-auth/README.md +35 -0
- package/extensions/google-gemini-cli-auth/index.ts +88 -0
- package/extensions/google-gemini-cli-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/google-gemini-cli-auth/oauth.test.ts +240 -0
- package/extensions/google-gemini-cli-auth/oauth.ts +662 -0
- package/extensions/google-gemini-cli-auth/openclaw.plugin.json +9 -0
- package/extensions/google-gemini-cli-auth/package.json +14 -0
- package/extensions/googlechat/index.ts +19 -0
- package/extensions/googlechat/node_modules/.bin/openclaw +21 -0
- package/extensions/googlechat/openclaw.plugin.json +9 -0
- package/extensions/googlechat/package.json +39 -0
- package/extensions/googlechat/src/accounts.ts +147 -0
- package/extensions/googlechat/src/actions.ts +181 -0
- package/extensions/googlechat/src/api.test.ts +61 -0
- package/extensions/googlechat/src/api.ts +282 -0
- package/extensions/googlechat/src/auth.ts +123 -0
- package/extensions/googlechat/src/channel.ts +583 -0
- package/extensions/googlechat/src/monitor.test.ts +22 -0
- package/extensions/googlechat/src/monitor.ts +949 -0
- package/extensions/googlechat/src/onboarding.ts +269 -0
- package/extensions/googlechat/src/runtime.ts +14 -0
- package/extensions/googlechat/src/targets.test.ts +32 -0
- package/extensions/googlechat/src/targets.ts +65 -0
- package/extensions/googlechat/src/types.config.ts +3 -0
- package/extensions/googlechat/src/types.ts +73 -0
- package/extensions/imessage/index.ts +17 -0
- package/extensions/imessage/node_modules/.bin/openclaw +21 -0
- package/extensions/imessage/openclaw.plugin.json +9 -0
- package/extensions/imessage/package.json +14 -0
- package/extensions/imessage/src/channel.ts +294 -0
- package/extensions/imessage/src/runtime.ts +14 -0
- package/extensions/line/index.ts +19 -0
- package/extensions/line/node_modules/.bin/openclaw +21 -0
- package/extensions/line/openclaw.plugin.json +9 -0
- package/extensions/line/package.json +29 -0
- package/extensions/line/src/card-command.ts +344 -0
- package/extensions/line/src/channel.logout.test.ts +99 -0
- package/extensions/line/src/channel.sendPayload.test.ts +306 -0
- package/extensions/line/src/channel.ts +780 -0
- package/extensions/line/src/runtime.ts +14 -0
- package/extensions/llm-task/README.md +97 -0
- package/extensions/llm-task/index.ts +6 -0
- package/extensions/llm-task/node_modules/.bin/openclaw +21 -0
- package/extensions/llm-task/openclaw.plugin.json +21 -0
- package/extensions/llm-task/package.json +14 -0
- package/extensions/llm-task/src/llm-task-tool.test.ts +138 -0
- package/extensions/llm-task/src/llm-task-tool.ts +245 -0
- package/extensions/lobster/README.md +75 -0
- package/extensions/lobster/SKILL.md +97 -0
- package/extensions/lobster/index.ts +14 -0
- package/extensions/lobster/node_modules/.bin/openclaw +21 -0
- package/extensions/lobster/openclaw.plugin.json +10 -0
- package/extensions/lobster/package.json +14 -0
- package/extensions/lobster/src/lobster-tool.test.ts +247 -0
- package/extensions/lobster/src/lobster-tool.ts +328 -0
- package/extensions/matrix/CHANGELOG.md +87 -0
- package/extensions/matrix/index.ts +17 -0
- package/extensions/matrix/node_modules/.bin/markdown-it +21 -0
- package/extensions/matrix/node_modules/.bin/openclaw +21 -0
- package/extensions/matrix/openclaw.plugin.json +9 -0
- package/extensions/matrix/package.json +36 -0
- package/extensions/matrix/src/actions.ts +195 -0
- package/extensions/matrix/src/channel.directory.test.ts +64 -0
- package/extensions/matrix/src/channel.ts +439 -0
- package/extensions/matrix/src/config-schema.ts +62 -0
- package/extensions/matrix/src/directory-live.ts +188 -0
- package/extensions/matrix/src/group-mentions.ts +66 -0
- package/extensions/matrix/src/matrix/accounts.test.ts +82 -0
- package/extensions/matrix/src/matrix/accounts.ts +65 -0
- package/extensions/matrix/src/matrix/actions/client.ts +57 -0
- package/extensions/matrix/src/matrix/actions/messages.ts +128 -0
- package/extensions/matrix/src/matrix/actions/pins.ts +76 -0
- package/extensions/matrix/src/matrix/actions/reactions.ts +96 -0
- package/extensions/matrix/src/matrix/actions/room.ts +85 -0
- package/extensions/matrix/src/matrix/actions/summary.ts +75 -0
- package/extensions/matrix/src/matrix/actions/types.ts +84 -0
- package/extensions/matrix/src/matrix/actions.ts +15 -0
- package/extensions/matrix/src/matrix/active-client.ts +11 -0
- package/extensions/matrix/src/matrix/client/config.ts +160 -0
- package/extensions/matrix/src/matrix/client/create-client.ts +123 -0
- package/extensions/matrix/src/matrix/client/logging.ts +36 -0
- package/extensions/matrix/src/matrix/client/runtime.ts +4 -0
- package/extensions/matrix/src/matrix/client/shared.ts +170 -0
- package/extensions/matrix/src/matrix/client/storage.ts +131 -0
- package/extensions/matrix/src/matrix/client/types.ts +34 -0
- package/extensions/matrix/src/matrix/client.test.ts +56 -0
- package/extensions/matrix/src/matrix/client.ts +5 -0
- package/extensions/matrix/src/matrix/credentials.ts +105 -0
- package/extensions/matrix/src/matrix/deps.ts +60 -0
- package/extensions/matrix/src/matrix/format.test.ts +33 -0
- package/extensions/matrix/src/matrix/format.ts +22 -0
- package/extensions/matrix/src/matrix/index.ts +11 -0
- package/extensions/matrix/src/matrix/monitor/allowlist.test.ts +45 -0
- package/extensions/matrix/src/matrix/monitor/allowlist.ts +103 -0
- package/extensions/matrix/src/matrix/monitor/auto-join.ts +71 -0
- package/extensions/matrix/src/matrix/monitor/direct.ts +104 -0
- package/extensions/matrix/src/matrix/monitor/events.ts +101 -0
- package/extensions/matrix/src/matrix/monitor/handler.ts +661 -0
- package/extensions/matrix/src/matrix/monitor/index.ts +338 -0
- package/extensions/matrix/src/matrix/monitor/location.ts +100 -0
- package/extensions/matrix/src/matrix/monitor/media.test.ts +102 -0
- package/extensions/matrix/src/matrix/monitor/media.ts +113 -0
- package/extensions/matrix/src/matrix/monitor/mentions.ts +31 -0
- package/extensions/matrix/src/matrix/monitor/replies.ts +97 -0
- package/extensions/matrix/src/matrix/monitor/room-info.ts +55 -0
- package/extensions/matrix/src/matrix/monitor/rooms.test.ts +39 -0
- package/extensions/matrix/src/matrix/monitor/rooms.ts +47 -0
- package/extensions/matrix/src/matrix/monitor/threads.ts +68 -0
- package/extensions/matrix/src/matrix/monitor/types.ts +39 -0
- package/extensions/matrix/src/matrix/poll-types.test.ts +21 -0
- package/extensions/matrix/src/matrix/poll-types.ts +166 -0
- package/extensions/matrix/src/matrix/probe.ts +70 -0
- package/extensions/matrix/src/matrix/send/client.ts +66 -0
- package/extensions/matrix/src/matrix/send/formatting.ts +89 -0
- package/extensions/matrix/src/matrix/send/media.ts +229 -0
- package/extensions/matrix/src/matrix/send/targets.test.ts +98 -0
- package/extensions/matrix/src/matrix/send/targets.ts +136 -0
- package/extensions/matrix/src/matrix/send/types.ts +109 -0
- package/extensions/matrix/src/matrix/send.test.ts +171 -0
- package/extensions/matrix/src/matrix/send.ts +260 -0
- package/extensions/matrix/src/onboarding.ts +449 -0
- package/extensions/matrix/src/outbound.ts +52 -0
- package/extensions/matrix/src/resolve-targets.test.ts +48 -0
- package/extensions/matrix/src/resolve-targets.ts +135 -0
- package/extensions/matrix/src/runtime.ts +14 -0
- package/extensions/matrix/src/tool-actions.ts +164 -0
- package/extensions/matrix/src/types.ts +95 -0
- package/extensions/mattermost/index.ts +17 -0
- package/extensions/mattermost/node_modules/.bin/openclaw +21 -0
- package/extensions/mattermost/openclaw.plugin.json +9 -0
- package/extensions/mattermost/package.json +28 -0
- package/extensions/mattermost/src/channel.test.ts +48 -0
- package/extensions/mattermost/src/channel.ts +337 -0
- package/extensions/mattermost/src/config-schema.ts +55 -0
- package/extensions/mattermost/src/group-mentions.ts +15 -0
- package/extensions/mattermost/src/mattermost/accounts.ts +128 -0
- package/extensions/mattermost/src/mattermost/client.ts +220 -0
- package/extensions/mattermost/src/mattermost/index.ts +9 -0
- package/extensions/mattermost/src/mattermost/monitor-helpers.ts +166 -0
- package/extensions/mattermost/src/mattermost/monitor.ts +987 -0
- package/extensions/mattermost/src/mattermost/probe.ts +74 -0
- package/extensions/mattermost/src/mattermost/send.ts +231 -0
- package/extensions/mattermost/src/normalize.ts +46 -0
- package/extensions/mattermost/src/onboarding-helpers.ts +44 -0
- package/extensions/mattermost/src/onboarding.ts +186 -0
- package/extensions/mattermost/src/runtime.ts +14 -0
- package/extensions/mattermost/src/types.ts +50 -0
- package/extensions/memory-core/index.ts +38 -0
- package/extensions/memory-core/node_modules/.bin/openclaw +21 -0
- package/extensions/memory-core/openclaw.plugin.json +9 -0
- package/extensions/memory-core/package.json +17 -0
- package/extensions/memory-lancedb/config.ts +139 -0
- package/extensions/memory-lancedb/index.test.ts +295 -0
- package/extensions/memory-lancedb/index.ts +608 -0
- package/extensions/memory-lancedb/node_modules/.bin/openai +21 -0
- package/extensions/memory-lancedb/node_modules/.bin/openclaw +21 -0
- package/extensions/memory-lancedb/openclaw.plugin.json +60 -0
- package/extensions/memory-lancedb/package.json +19 -0
- package/extensions/minimax-portal-auth/README.md +33 -0
- package/extensions/minimax-portal-auth/index.ts +155 -0
- package/extensions/minimax-portal-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/minimax-portal-auth/oauth.ts +247 -0
- package/extensions/minimax-portal-auth/openclaw.plugin.json +9 -0
- package/extensions/minimax-portal-auth/package.json +14 -0
- package/extensions/msteams/CHANGELOG.md +83 -0
- package/extensions/msteams/index.ts +17 -0
- package/extensions/msteams/node_modules/.bin/openclaw +21 -0
- package/extensions/msteams/openclaw.plugin.json +9 -0
- package/extensions/msteams/package.json +39 -0
- package/extensions/msteams/src/attachments/download.ts +283 -0
- package/extensions/msteams/src/attachments/graph.ts +353 -0
- package/extensions/msteams/src/attachments/html.ts +90 -0
- package/extensions/msteams/src/attachments/payload.ts +22 -0
- package/extensions/msteams/src/attachments/shared.ts +291 -0
- package/extensions/msteams/src/attachments/types.ts +37 -0
- package/extensions/msteams/src/attachments.test.ts +459 -0
- package/extensions/msteams/src/attachments.ts +18 -0
- package/extensions/msteams/src/channel.directory.test.ts +48 -0
- package/extensions/msteams/src/channel.ts +459 -0
- package/extensions/msteams/src/conversation-store-fs.test.ts +88 -0
- package/extensions/msteams/src/conversation-store-fs.ts +165 -0
- package/extensions/msteams/src/conversation-store-memory.ts +47 -0
- package/extensions/msteams/src/conversation-store.ts +41 -0
- package/extensions/msteams/src/directory-live.ts +205 -0
- package/extensions/msteams/src/errors.test.ts +45 -0
- package/extensions/msteams/src/errors.ts +190 -0
- package/extensions/msteams/src/file-consent-helpers.test.ts +243 -0
- package/extensions/msteams/src/file-consent-helpers.ts +73 -0
- package/extensions/msteams/src/file-consent.ts +126 -0
- package/extensions/msteams/src/graph-chat.ts +53 -0
- package/extensions/msteams/src/graph-upload.ts +453 -0
- package/extensions/msteams/src/inbound.test.ts +66 -0
- package/extensions/msteams/src/inbound.ts +48 -0
- package/extensions/msteams/src/index.ts +4 -0
- package/extensions/msteams/src/media-helpers.test.ts +189 -0
- package/extensions/msteams/src/media-helpers.ts +86 -0
- package/extensions/msteams/src/messenger.test.ts +248 -0
- package/extensions/msteams/src/messenger.ts +495 -0
- package/extensions/msteams/src/monitor-handler/inbound-media.ts +128 -0
- package/extensions/msteams/src/monitor-handler/message-handler.ts +640 -0
- package/extensions/msteams/src/monitor-handler.ts +162 -0
- package/extensions/msteams/src/monitor-types.ts +5 -0
- package/extensions/msteams/src/monitor.ts +295 -0
- package/extensions/msteams/src/onboarding.ts +431 -0
- package/extensions/msteams/src/outbound.ts +46 -0
- package/extensions/msteams/src/pending-uploads.ts +89 -0
- package/extensions/msteams/src/policy.test.ts +209 -0
- package/extensions/msteams/src/policy.ts +273 -0
- package/extensions/msteams/src/polls-store-memory.ts +32 -0
- package/extensions/msteams/src/polls-store.test.ts +38 -0
- package/extensions/msteams/src/polls.test.ts +72 -0
- package/extensions/msteams/src/polls.ts +315 -0
- package/extensions/msteams/src/probe.test.ts +58 -0
- package/extensions/msteams/src/probe.ts +107 -0
- package/extensions/msteams/src/reply-dispatcher.ts +130 -0
- package/extensions/msteams/src/resolve-allowlist.ts +297 -0
- package/extensions/msteams/src/runtime.ts +14 -0
- package/extensions/msteams/src/sdk-types.ts +19 -0
- package/extensions/msteams/src/sdk.ts +33 -0
- package/extensions/msteams/src/send-context.ts +164 -0
- package/extensions/msteams/src/send.ts +519 -0
- package/extensions/msteams/src/sent-message-cache.test.ts +15 -0
- package/extensions/msteams/src/sent-message-cache.ts +47 -0
- package/extensions/msteams/src/storage.ts +25 -0
- package/extensions/msteams/src/store-fs.ts +83 -0
- package/extensions/msteams/src/token.ts +19 -0
- package/extensions/nextcloud-talk/index.ts +17 -0
- package/extensions/nextcloud-talk/node_modules/.bin/openclaw +21 -0
- package/extensions/nextcloud-talk/openclaw.plugin.json +9 -0
- package/extensions/nextcloud-talk/package.json +33 -0
- package/extensions/nextcloud-talk/src/accounts.ts +174 -0
- package/extensions/nextcloud-talk/src/channel.ts +409 -0
- package/extensions/nextcloud-talk/src/config-schema.ts +78 -0
- package/extensions/nextcloud-talk/src/format.ts +79 -0
- package/extensions/nextcloud-talk/src/inbound.ts +317 -0
- package/extensions/nextcloud-talk/src/monitor.ts +246 -0
- package/extensions/nextcloud-talk/src/normalize.ts +39 -0
- package/extensions/nextcloud-talk/src/onboarding.ts +343 -0
- package/extensions/nextcloud-talk/src/policy.test.ts +33 -0
- package/extensions/nextcloud-talk/src/policy.ts +180 -0
- package/extensions/nextcloud-talk/src/room-info.ts +125 -0
- package/extensions/nextcloud-talk/src/runtime.ts +14 -0
- package/extensions/nextcloud-talk/src/send.ts +210 -0
- package/extensions/nextcloud-talk/src/signature.ts +72 -0
- package/extensions/nextcloud-talk/src/types.ts +179 -0
- package/extensions/nostr/CHANGELOG.md +74 -0
- package/extensions/nostr/README.md +136 -0
- package/extensions/nostr/index.ts +68 -0
- package/extensions/nostr/node_modules/.bin/openclaw +21 -0
- package/extensions/nostr/openclaw.plugin.json +9 -0
- package/extensions/nostr/package.json +34 -0
- package/extensions/nostr/src/channel.test.ts +151 -0
- package/extensions/nostr/src/channel.ts +353 -0
- package/extensions/nostr/src/config-schema.ts +90 -0
- package/extensions/nostr/src/metrics.ts +478 -0
- package/extensions/nostr/src/nostr-bus.fuzz.test.ts +533 -0
- package/extensions/nostr/src/nostr-bus.integration.test.ts +448 -0
- package/extensions/nostr/src/nostr-bus.test.ts +199 -0
- package/extensions/nostr/src/nostr-bus.ts +715 -0
- package/extensions/nostr/src/nostr-profile-http.test.ts +378 -0
- package/extensions/nostr/src/nostr-profile-http.ts +519 -0
- package/extensions/nostr/src/nostr-profile-import.test.ts +119 -0
- package/extensions/nostr/src/nostr-profile-import.ts +262 -0
- package/extensions/nostr/src/nostr-profile.fuzz.test.ts +477 -0
- package/extensions/nostr/src/nostr-profile.test.ts +410 -0
- package/extensions/nostr/src/nostr-profile.ts +277 -0
- package/extensions/nostr/src/nostr-state-store.test.ts +131 -0
- package/extensions/nostr/src/nostr-state-store.ts +226 -0
- package/extensions/nostr/src/runtime.ts +14 -0
- package/extensions/nostr/src/seen-tracker.ts +303 -0
- package/extensions/nostr/src/types.test.ts +157 -0
- package/extensions/nostr/src/types.ts +101 -0
- package/extensions/nostr/test/setup.ts +5 -0
- package/extensions/open-prose/README.md +25 -0
- package/extensions/open-prose/index.ts +5 -0
- package/extensions/open-prose/node_modules/.bin/openclaw +21 -0
- package/extensions/open-prose/openclaw.plugin.json +11 -0
- package/extensions/open-prose/package.json +14 -0
- package/extensions/open-prose/skills/prose/LICENSE +21 -0
- package/extensions/open-prose/skills/prose/SKILL.md +323 -0
- package/extensions/open-prose/skills/prose/alt-borges.md +141 -0
- package/extensions/open-prose/skills/prose/alts/arabian-nights.md +358 -0
- package/extensions/open-prose/skills/prose/alts/borges.md +360 -0
- package/extensions/open-prose/skills/prose/alts/folk.md +322 -0
- package/extensions/open-prose/skills/prose/alts/homer.md +346 -0
- package/extensions/open-prose/skills/prose/alts/kafka.md +373 -0
- package/extensions/open-prose/skills/prose/compiler.md +2971 -0
- package/extensions/open-prose/skills/prose/examples/01-hello-world.prose +4 -0
- package/extensions/open-prose/skills/prose/examples/02-research-and-summarize.prose +6 -0
- package/extensions/open-prose/skills/prose/examples/03-code-review.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/04-write-and-refine.prose +14 -0
- package/extensions/open-prose/skills/prose/examples/05-debug-issue.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/06-explain-codebase.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/07-refactor.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/08-blog-post.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/09-research-with-agents.prose +25 -0
- package/extensions/open-prose/skills/prose/examples/10-code-review-agents.prose +32 -0
- package/extensions/open-prose/skills/prose/examples/11-skills-and-imports.prose +27 -0
- package/extensions/open-prose/skills/prose/examples/12-secure-agent-permissions.prose +43 -0
- package/extensions/open-prose/skills/prose/examples/13-variables-and-context.prose +51 -0
- package/extensions/open-prose/skills/prose/examples/14-composition-blocks.prose +48 -0
- package/extensions/open-prose/skills/prose/examples/15-inline-sequences.prose +23 -0
- package/extensions/open-prose/skills/prose/examples/16-parallel-reviews.prose +19 -0
- package/extensions/open-prose/skills/prose/examples/17-parallel-research.prose +19 -0
- package/extensions/open-prose/skills/prose/examples/18-mixed-parallel-sequential.prose +36 -0
- package/extensions/open-prose/skills/prose/examples/19-advanced-parallel.prose +71 -0
- package/extensions/open-prose/skills/prose/examples/20-fixed-loops.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/21-pipeline-operations.prose +35 -0
- package/extensions/open-prose/skills/prose/examples/22-error-handling.prose +51 -0
- package/extensions/open-prose/skills/prose/examples/23-retry-with-backoff.prose +63 -0
- package/extensions/open-prose/skills/prose/examples/24-choice-blocks.prose +86 -0
- package/extensions/open-prose/skills/prose/examples/25-conditionals.prose +114 -0
- package/extensions/open-prose/skills/prose/examples/26-parameterized-blocks.prose +100 -0
- package/extensions/open-prose/skills/prose/examples/27-string-interpolation.prose +105 -0
- package/extensions/open-prose/skills/prose/examples/28-automated-pr-review.prose +37 -0
- package/extensions/open-prose/skills/prose/examples/28-gas-town.prose +1572 -0
- package/extensions/open-prose/skills/prose/examples/29-captains-chair.prose +218 -0
- package/extensions/open-prose/skills/prose/examples/30-captains-chair-simple.prose +42 -0
- package/extensions/open-prose/skills/prose/examples/31-captains-chair-with-memory.prose +145 -0
- package/extensions/open-prose/skills/prose/examples/33-pr-review-autofix.prose +168 -0
- package/extensions/open-prose/skills/prose/examples/34-content-pipeline.prose +204 -0
- package/extensions/open-prose/skills/prose/examples/35-feature-factory.prose +296 -0
- package/extensions/open-prose/skills/prose/examples/36-bug-hunter.prose +237 -0
- package/extensions/open-prose/skills/prose/examples/37-the-forge.prose +1474 -0
- package/extensions/open-prose/skills/prose/examples/38-skill-scan.prose +455 -0
- package/extensions/open-prose/skills/prose/examples/39-architect-by-simulation.prose +277 -0
- package/extensions/open-prose/skills/prose/examples/40-rlm-self-refine.prose +32 -0
- package/extensions/open-prose/skills/prose/examples/41-rlm-divide-conquer.prose +38 -0
- package/extensions/open-prose/skills/prose/examples/42-rlm-filter-recurse.prose +46 -0
- package/extensions/open-prose/skills/prose/examples/43-rlm-pairwise.prose +50 -0
- package/extensions/open-prose/skills/prose/examples/44-run-endpoint-ux-test.prose +261 -0
- package/extensions/open-prose/skills/prose/examples/45-plugin-release.prose +159 -0
- package/extensions/open-prose/skills/prose/examples/45-run-endpoint-ux-test-with-remediation.prose +637 -0
- package/extensions/open-prose/skills/prose/examples/46-run-endpoint-ux-test-fast.prose +148 -0
- package/extensions/open-prose/skills/prose/examples/46-workflow-crystallizer.prose +225 -0
- package/extensions/open-prose/skills/prose/examples/47-language-self-improvement.prose +356 -0
- package/extensions/open-prose/skills/prose/examples/48-habit-miner.prose +445 -0
- package/extensions/open-prose/skills/prose/examples/49-prose-run-retrospective.prose +210 -0
- package/extensions/open-prose/skills/prose/examples/README.md +391 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/README.md +22 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/iterative-refinement.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/parallel-review.prose +18 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/simple-pipeline.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/syntax/open-prose-syntax.prose +223 -0
- package/extensions/open-prose/skills/prose/guidance/antipatterns.md +951 -0
- package/extensions/open-prose/skills/prose/guidance/patterns.md +700 -0
- package/extensions/open-prose/skills/prose/guidance/system-prompt.md +180 -0
- package/extensions/open-prose/skills/prose/help.md +144 -0
- package/extensions/open-prose/skills/prose/lib/README.md +108 -0
- package/extensions/open-prose/skills/prose/lib/calibrator.prose +215 -0
- package/extensions/open-prose/skills/prose/lib/cost-analyzer.prose +174 -0
- package/extensions/open-prose/skills/prose/lib/error-forensics.prose +250 -0
- package/extensions/open-prose/skills/prose/lib/inspector.prose +196 -0
- package/extensions/open-prose/skills/prose/lib/profiler.prose +460 -0
- package/extensions/open-prose/skills/prose/lib/program-improver.prose +275 -0
- package/extensions/open-prose/skills/prose/lib/project-memory.prose +118 -0
- package/extensions/open-prose/skills/prose/lib/user-memory.prose +93 -0
- package/extensions/open-prose/skills/prose/lib/vm-improver.prose +243 -0
- package/extensions/open-prose/skills/prose/primitives/session.md +593 -0
- package/extensions/open-prose/skills/prose/prose.md +1237 -0
- package/extensions/open-prose/skills/prose/state/filesystem.md +498 -0
- package/extensions/open-prose/skills/prose/state/in-context.md +384 -0
- package/extensions/open-prose/skills/prose/state/postgres.md +880 -0
- package/extensions/open-prose/skills/prose/state/sqlite.md +574 -0
- package/extensions/qwen-portal-auth/README.md +24 -0
- package/extensions/qwen-portal-auth/index.ts +130 -0
- package/extensions/qwen-portal-auth/oauth.ts +190 -0
- package/extensions/qwen-portal-auth/openclaw.plugin.json +9 -0
- package/extensions/signal/index.ts +17 -0
- package/extensions/signal/node_modules/.bin/openclaw +21 -0
- package/extensions/signal/openclaw.plugin.json +9 -0
- package/extensions/signal/package.json +14 -0
- package/extensions/signal/src/channel.ts +315 -0
- package/extensions/signal/src/runtime.ts +14 -0
- package/extensions/slack/index.ts +17 -0
- package/extensions/slack/node_modules/.bin/openclaw +21 -0
- package/extensions/slack/openclaw.plugin.json +9 -0
- package/extensions/slack/package.json +14 -0
- package/extensions/slack/src/channel.ts +604 -0
- package/extensions/slack/src/runtime.ts +14 -0
- package/extensions/telegram/index.ts +17 -0
- package/extensions/telegram/node_modules/.bin/openclaw +21 -0
- package/extensions/telegram/openclaw.plugin.json +9 -0
- package/extensions/telegram/package.json +14 -0
- package/extensions/telegram/src/channel.ts +482 -0
- package/extensions/telegram/src/runtime.ts +14 -0
- package/extensions/tlon/README.md +5 -0
- package/extensions/tlon/index.ts +17 -0
- package/extensions/tlon/node_modules/.bin/openclaw +21 -0
- package/extensions/tlon/openclaw.plugin.json +9 -0
- package/extensions/tlon/package.json +33 -0
- package/extensions/tlon/src/channel.ts +392 -0
- package/extensions/tlon/src/config-schema.test.ts +31 -0
- package/extensions/tlon/src/config-schema.ts +43 -0
- package/extensions/tlon/src/monitor/discovery.ts +76 -0
- package/extensions/tlon/src/monitor/history.ts +90 -0
- package/extensions/tlon/src/monitor/index.ts +553 -0
- package/extensions/tlon/src/monitor/processed-messages.test.ts +23 -0
- package/extensions/tlon/src/monitor/processed-messages.ts +46 -0
- package/extensions/tlon/src/monitor/utils.ts +105 -0
- package/extensions/tlon/src/onboarding.ts +214 -0
- package/extensions/tlon/src/runtime.ts +14 -0
- package/extensions/tlon/src/targets.ts +89 -0
- package/extensions/tlon/src/types.ts +92 -0
- package/extensions/tlon/src/urbit/auth.ts +18 -0
- package/extensions/tlon/src/urbit/http-api.ts +38 -0
- package/extensions/tlon/src/urbit/send.test.ts +38 -0
- package/extensions/tlon/src/urbit/send.ts +131 -0
- package/extensions/tlon/src/urbit/sse-client.test.ts +40 -0
- package/extensions/tlon/src/urbit/sse-client.ts +395 -0
- package/extensions/twitch/CHANGELOG.md +45 -0
- package/extensions/twitch/README.md +89 -0
- package/extensions/twitch/index.ts +20 -0
- package/extensions/twitch/node_modules/.bin/openclaw +21 -0
- package/extensions/twitch/openclaw.plugin.json +9 -0
- package/extensions/twitch/package.json +20 -0
- package/extensions/twitch/src/access-control.test.ts +489 -0
- package/extensions/twitch/src/access-control.ts +166 -0
- package/extensions/twitch/src/actions.ts +173 -0
- package/extensions/twitch/src/client-manager-registry.ts +115 -0
- package/extensions/twitch/src/config-schema.ts +82 -0
- package/extensions/twitch/src/config.test.ts +87 -0
- package/extensions/twitch/src/config.ts +116 -0
- package/extensions/twitch/src/monitor.ts +261 -0
- package/extensions/twitch/src/onboarding.test.ts +311 -0
- package/extensions/twitch/src/onboarding.ts +417 -0
- package/extensions/twitch/src/outbound.test.ts +373 -0
- package/extensions/twitch/src/outbound.ts +184 -0
- package/extensions/twitch/src/plugin.test.ts +39 -0
- package/extensions/twitch/src/plugin.ts +274 -0
- package/extensions/twitch/src/probe.test.ts +195 -0
- package/extensions/twitch/src/probe.ts +120 -0
- package/extensions/twitch/src/resolver.ts +137 -0
- package/extensions/twitch/src/runtime.ts +14 -0
- package/extensions/twitch/src/send.test.ts +289 -0
- package/extensions/twitch/src/send.ts +136 -0
- package/extensions/twitch/src/status.test.ts +270 -0
- package/extensions/twitch/src/status.ts +178 -0
- package/extensions/twitch/src/token.test.ts +171 -0
- package/extensions/twitch/src/token.ts +91 -0
- package/extensions/twitch/src/twitch-client.test.ts +589 -0
- package/extensions/twitch/src/twitch-client.ts +277 -0
- package/extensions/twitch/src/types.ts +141 -0
- package/extensions/twitch/src/utils/markdown.ts +98 -0
- package/extensions/twitch/src/utils/twitch.ts +78 -0
- package/extensions/twitch/test/setup.ts +7 -0
- package/extensions/voice-call/CHANGELOG.md +109 -0
- package/extensions/voice-call/README.md +139 -0
- package/extensions/voice-call/index.ts +493 -0
- package/extensions/voice-call/node_modules/.bin/openclaw +21 -0
- package/extensions/voice-call/openclaw.plugin.json +559 -0
- package/extensions/voice-call/package.json +19 -0
- package/extensions/voice-call/src/allowlist.ts +19 -0
- package/extensions/voice-call/src/cli.ts +279 -0
- package/extensions/voice-call/src/config.test.ts +234 -0
- package/extensions/voice-call/src/config.ts +523 -0
- package/extensions/voice-call/src/core-bridge.ts +159 -0
- package/extensions/voice-call/src/manager/context.ts +21 -0
- package/extensions/voice-call/src/manager/events.ts +188 -0
- package/extensions/voice-call/src/manager/lookup.ts +35 -0
- package/extensions/voice-call/src/manager/outbound.ts +275 -0
- package/extensions/voice-call/src/manager/state.ts +48 -0
- package/extensions/voice-call/src/manager/store.ts +91 -0
- package/extensions/voice-call/src/manager/timers.ts +89 -0
- package/extensions/voice-call/src/manager/twiml.ts +9 -0
- package/extensions/voice-call/src/manager.test.ts +194 -0
- package/extensions/voice-call/src/manager.ts +887 -0
- package/extensions/voice-call/src/media-stream.test.ts +96 -0
- package/extensions/voice-call/src/media-stream.ts +411 -0
- package/extensions/voice-call/src/providers/base.ts +67 -0
- package/extensions/voice-call/src/providers/index.ts +10 -0
- package/extensions/voice-call/src/providers/mock.ts +165 -0
- package/extensions/voice-call/src/providers/plivo.test.ts +27 -0
- package/extensions/voice-call/src/providers/plivo.ts +515 -0
- package/extensions/voice-call/src/providers/stt-openai-realtime.ts +311 -0
- package/extensions/voice-call/src/providers/telnyx.ts +371 -0
- package/extensions/voice-call/src/providers/tts-openai.ts +259 -0
- package/extensions/voice-call/src/providers/twilio/api.ts +42 -0
- package/extensions/voice-call/src/providers/twilio/webhook.ts +32 -0
- package/extensions/voice-call/src/providers/twilio.test.ts +60 -0
- package/extensions/voice-call/src/providers/twilio.ts +626 -0
- package/extensions/voice-call/src/response-generator.ts +158 -0
- package/extensions/voice-call/src/runtime.ts +212 -0
- package/extensions/voice-call/src/telephony-audio.ts +90 -0
- package/extensions/voice-call/src/telephony-tts.ts +104 -0
- package/extensions/voice-call/src/tunnel.ts +314 -0
- package/extensions/voice-call/src/types.ts +272 -0
- package/extensions/voice-call/src/utils.ts +14 -0
- package/extensions/voice-call/src/voice-mapping.ts +67 -0
- package/extensions/voice-call/src/webhook-security.test.ts +377 -0
- package/extensions/voice-call/src/webhook-security.ts +689 -0
- package/extensions/voice-call/src/webhook.ts +491 -0
- package/extensions/whatsapp/index.ts +17 -0
- package/extensions/whatsapp/node_modules/.bin/openclaw +21 -0
- package/extensions/whatsapp/openclaw.plugin.json +9 -0
- package/extensions/whatsapp/package.json +14 -0
- package/extensions/whatsapp/src/channel.ts +508 -0
- package/extensions/whatsapp/src/runtime.ts +14 -0
- package/extensions/zalo/CHANGELOG.md +89 -0
- package/extensions/zalo/README.md +50 -0
- package/extensions/zalo/index.ts +19 -0
- package/extensions/zalo/node_modules/.bin/openclaw +21 -0
- package/extensions/zalo/openclaw.plugin.json +9 -0
- package/extensions/zalo/package.json +36 -0
- package/extensions/zalo/src/accounts.ts +80 -0
- package/extensions/zalo/src/actions.ts +67 -0
- package/extensions/zalo/src/api.ts +208 -0
- package/extensions/zalo/src/channel.directory.test.ts +43 -0
- package/extensions/zalo/src/channel.ts +414 -0
- package/extensions/zalo/src/config-schema.ts +24 -0
- package/extensions/zalo/src/monitor.ts +753 -0
- package/extensions/zalo/src/monitor.webhook.test.ts +73 -0
- package/extensions/zalo/src/onboarding.ts +401 -0
- package/extensions/zalo/src/probe.ts +46 -0
- package/extensions/zalo/src/proxy.ts +21 -0
- package/extensions/zalo/src/runtime.ts +14 -0
- package/extensions/zalo/src/send.ts +124 -0
- package/extensions/zalo/src/status-issues.ts +53 -0
- package/extensions/zalo/src/token.ts +63 -0
- package/extensions/zalo/src/types.ts +42 -0
- package/extensions/zalouser/CHANGELOG.md +61 -0
- package/extensions/zalouser/README.md +225 -0
- package/extensions/zalouser/index.ts +31 -0
- package/extensions/zalouser/node_modules/.bin/openclaw +21 -0
- package/extensions/zalouser/openclaw.plugin.json +9 -0
- package/extensions/zalouser/package.json +36 -0
- package/extensions/zalouser/src/accounts.ts +135 -0
- package/extensions/zalouser/src/channel.test.ts +18 -0
- package/extensions/zalouser/src/channel.ts +686 -0
- package/extensions/zalouser/src/config-schema.ts +27 -0
- package/extensions/zalouser/src/monitor.ts +590 -0
- package/extensions/zalouser/src/onboarding.ts +504 -0
- package/extensions/zalouser/src/probe.ts +28 -0
- package/extensions/zalouser/src/runtime.ts +14 -0
- package/extensions/zalouser/src/send.ts +160 -0
- package/extensions/zalouser/src/status-issues.test.ts +57 -0
- package/extensions/zalouser/src/status-issues.ts +89 -0
- package/extensions/zalouser/src/tool.ts +164 -0
- package/extensions/zalouser/src/types.ts +108 -0
- package/extensions/zalouser/src/zca.ts +202 -0
- package/openclaw.mjs +14 -0
- package/package.json +245 -0
- package/skills/1password/SKILL.md +70 -0
- package/skills/1password/references/cli-examples.md +29 -0
- package/skills/1password/references/get-started.md +17 -0
- package/skills/apple-notes/SKILL.md +77 -0
- package/skills/apple-reminders/SKILL.md +96 -0
- package/skills/bear-notes/SKILL.md +107 -0
- package/skills/bird/SKILL.md +224 -0
- package/skills/blogwatcher/SKILL.md +69 -0
- package/skills/blucli/SKILL.md +47 -0
- package/skills/bluebubbles/SKILL.md +131 -0
- package/skills/camsnap/SKILL.md +45 -0
- package/skills/canvas/SKILL.md +198 -0
- package/skills/clawhub/SKILL.md +77 -0
- package/skills/coding-agent/SKILL.md +284 -0
- package/skills/discord/SKILL.md +578 -0
- package/skills/eightctl/SKILL.md +50 -0
- package/skills/food-order/SKILL.md +48 -0
- package/skills/gemini/SKILL.md +43 -0
- package/skills/ghostly-projects/SKILL.md +160 -0
- package/skills/gifgrep/SKILL.md +79 -0
- package/skills/github/SKILL.md +77 -0
- package/skills/gog/SKILL.md +116 -0
- package/skills/goplaces/SKILL.md +52 -0
- package/skills/healthcheck/SKILL.md +245 -0
- package/skills/himalaya/SKILL.md +257 -0
- package/skills/himalaya/references/configuration.md +184 -0
- package/skills/himalaya/references/message-composition.md +199 -0
- package/skills/imsg/SKILL.md +74 -0
- package/skills/linear/SKILL.md +111 -0
- package/skills/linear/linear.sh +204 -0
- package/skills/local-places/SERVER_README.md +101 -0
- package/skills/local-places/SKILL.md +102 -0
- package/skills/local-places/pyproject.toml +21 -0
- package/skills/local-places/src/local_places/__init__.py +2 -0
- package/skills/local-places/src/local_places/google_places.py +314 -0
- package/skills/local-places/src/local_places/main.py +65 -0
- package/skills/local-places/src/local_places/schemas.py +107 -0
- package/skills/mcporter/SKILL.md +61 -0
- package/skills/model-usage/SKILL.md +69 -0
- package/skills/model-usage/references/codexbar-cli.md +33 -0
- package/skills/model-usage/scripts/model_usage.py +310 -0
- package/skills/nano-banana-pro/SKILL.md +58 -0
- package/skills/nano-banana-pro/scripts/generate_image.py +184 -0
- package/skills/nano-pdf/SKILL.md +38 -0
- package/skills/notion/SKILL.md +172 -0
- package/skills/obsidian/SKILL.md +81 -0
- package/skills/openai-image-gen/SKILL.md +89 -0
- package/skills/openai-image-gen/scripts/gen.py +240 -0
- package/skills/openai-whisper/SKILL.md +38 -0
- package/skills/openai-whisper-api/SKILL.md +52 -0
- package/skills/openai-whisper-api/scripts/transcribe.sh +85 -0
- package/skills/openhue/SKILL.md +51 -0
- package/skills/oracle/SKILL.md +125 -0
- package/skills/ordercli/SKILL.md +78 -0
- package/skills/peekaboo/SKILL.md +190 -0
- package/skills/sag/SKILL.md +87 -0
- package/skills/session-logs/SKILL.md +115 -0
- package/skills/sherpa-onnx-tts/SKILL.md +103 -0
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
- package/skills/skill-creator/SKILL.md +370 -0
- package/skills/skill-creator/license.txt +202 -0
- package/skills/skill-creator/scripts/init_skill.py +378 -0
- package/skills/skill-creator/scripts/package_skill.py +111 -0
- package/skills/skill-creator/scripts/quick_validate.py +101 -0
- package/skills/slack/SKILL.md +144 -0
- package/skills/songsee/SKILL.md +49 -0
- package/skills/sonoscli/SKILL.md +46 -0
- package/skills/spotify-player/SKILL.md +64 -0
- package/skills/summarize/SKILL.md +87 -0
- package/skills/things-mac/SKILL.md +86 -0
- package/skills/tmux/SKILL.md +135 -0
- package/skills/tmux/scripts/find-sessions.sh +112 -0
- package/skills/tmux/scripts/wait-for-text.sh +83 -0
- package/skills/trello/SKILL.md +95 -0
- package/skills/video-frames/SKILL.md +46 -0
- package/skills/video-frames/scripts/frame.sh +81 -0
- package/skills/voice-call/SKILL.md +45 -0
- package/skills/wacli/SKILL.md +72 -0
- package/skills/weather/SKILL.md +54 -0
|
@@ -0,0 +1,2542 @@
|
|
|
1
|
+
import { W as resolveGatewayPort, f as visibleWidth } from "./entry.js";
|
|
2
|
+
import { H as parseAgentSessionKey, N as normalizeAgentId, P as normalizeMainKey, c as resolveDefaultAgentId, k as buildAgentMainSessionKey } from "./agent-scope-C_O6Vpl0.js";
|
|
3
|
+
import { i as loadConfig, j as VERSION } from "./config-DfMIMT-f.js";
|
|
4
|
+
import { St as PROTOCOL_VERSION, t as GatewayClient } from "./client-DPqNOpK3.js";
|
|
5
|
+
import { m as GATEWAY_CLIENT_NAMES, p as GATEWAY_CLIENT_MODES } from "./message-channel-Cjsiqxok.js";
|
|
6
|
+
import { M as formatThinkingLevels, P as listThinkingLevelLabels, V as resolveResponseUsageMode, z as normalizeUsageDisplay } from "./pi-embedded-helpers-CT5VuLCb.js";
|
|
7
|
+
import { a as extractContentFromMessage, c as formatContextUsageLine, d as resolveFinalAssistantText, i as composeThinkingAndContent, l as formatTokens, n as formatAge, o as extractTextFromMessage, p as formatTokenCount, r as asString, s as extractThinkingFromMessage, u as isCommandMessage, v as listChatCommands, y as listChatCommandsForConfig } from "./channel-summary-B4G513Eb.js";
|
|
8
|
+
import { n as resolveToolDisplay, t as formatToolDetail } from "./tool-display-NYQnSpdo.js";
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import chalk from "chalk";
|
|
11
|
+
import { randomUUID } from "node:crypto";
|
|
12
|
+
import { Box, CombinedAutocompleteProvider, Container, Editor, Input, Key, Loader, Markdown, ProcessTerminal, SelectList, SettingsList, Spacer, TUI, Text, getEditorKeybindings, isKeyRelease, matchesKey, truncateToWidth } from "@mariozechner/pi-tui";
|
|
13
|
+
import { highlight, supportsLanguage } from "cli-highlight";
|
|
14
|
+
|
|
15
|
+
//#region src/tui/commands.ts
|
|
16
|
+
const VERBOSE_LEVELS = ["on", "off"];
|
|
17
|
+
const REASONING_LEVELS = ["on", "off"];
|
|
18
|
+
const ELEVATED_LEVELS = [
|
|
19
|
+
"on",
|
|
20
|
+
"off",
|
|
21
|
+
"ask",
|
|
22
|
+
"full"
|
|
23
|
+
];
|
|
24
|
+
const ACTIVATION_LEVELS = ["mention", "always"];
|
|
25
|
+
const USAGE_FOOTER_LEVELS = [
|
|
26
|
+
"off",
|
|
27
|
+
"tokens",
|
|
28
|
+
"full"
|
|
29
|
+
];
|
|
30
|
+
const COMMAND_ALIASES = { elev: "elevated" };
|
|
31
|
+
function parseCommand(input) {
|
|
32
|
+
const trimmed = input.replace(/^\//, "").trim();
|
|
33
|
+
if (!trimmed) return {
|
|
34
|
+
name: "",
|
|
35
|
+
args: ""
|
|
36
|
+
};
|
|
37
|
+
const [name, ...rest] = trimmed.split(/\s+/);
|
|
38
|
+
const normalized = name.toLowerCase();
|
|
39
|
+
return {
|
|
40
|
+
name: COMMAND_ALIASES[normalized] ?? normalized,
|
|
41
|
+
args: rest.join(" ").trim()
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function getSlashCommands(options = {}) {
|
|
45
|
+
const thinkLevels = listThinkingLevelLabels(options.provider, options.model);
|
|
46
|
+
const commands = [
|
|
47
|
+
{
|
|
48
|
+
name: "help",
|
|
49
|
+
description: "Show slash command help"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "status",
|
|
53
|
+
description: "Show gateway status summary"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "agent",
|
|
57
|
+
description: "Switch agent (or open picker)"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "agents",
|
|
61
|
+
description: "Open agent picker"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "session",
|
|
65
|
+
description: "Switch session (or open picker)"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "sessions",
|
|
69
|
+
description: "Open session picker"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "model",
|
|
73
|
+
description: "Set model (or open picker)"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "models",
|
|
77
|
+
description: "Open model picker"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "think",
|
|
81
|
+
description: "Set thinking level",
|
|
82
|
+
getArgumentCompletions: (prefix) => thinkLevels.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
|
83
|
+
value,
|
|
84
|
+
label: value
|
|
85
|
+
}))
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "verbose",
|
|
89
|
+
description: "Set verbose on/off",
|
|
90
|
+
getArgumentCompletions: (prefix) => VERBOSE_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
|
91
|
+
value,
|
|
92
|
+
label: value
|
|
93
|
+
}))
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "reasoning",
|
|
97
|
+
description: "Set reasoning on/off",
|
|
98
|
+
getArgumentCompletions: (prefix) => REASONING_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
|
99
|
+
value,
|
|
100
|
+
label: value
|
|
101
|
+
}))
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "usage",
|
|
105
|
+
description: "Toggle per-response usage line",
|
|
106
|
+
getArgumentCompletions: (prefix) => USAGE_FOOTER_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
|
107
|
+
value,
|
|
108
|
+
label: value
|
|
109
|
+
}))
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "elevated",
|
|
113
|
+
description: "Set elevated on/off/ask/full",
|
|
114
|
+
getArgumentCompletions: (prefix) => ELEVATED_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
|
115
|
+
value,
|
|
116
|
+
label: value
|
|
117
|
+
}))
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "elev",
|
|
121
|
+
description: "Alias for /elevated",
|
|
122
|
+
getArgumentCompletions: (prefix) => ELEVATED_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
|
123
|
+
value,
|
|
124
|
+
label: value
|
|
125
|
+
}))
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "activation",
|
|
129
|
+
description: "Set group activation",
|
|
130
|
+
getArgumentCompletions: (prefix) => ACTIVATION_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({
|
|
131
|
+
value,
|
|
132
|
+
label: value
|
|
133
|
+
}))
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "abort",
|
|
137
|
+
description: "Abort active run"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "new",
|
|
141
|
+
description: "Reset the session"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "reset",
|
|
145
|
+
description: "Reset the session"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "settings",
|
|
149
|
+
description: "Open settings"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "exit",
|
|
153
|
+
description: "Exit the TUI"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "quit",
|
|
157
|
+
description: "Exit the TUI"
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
const seen = new Set(commands.map((command) => command.name));
|
|
161
|
+
const gatewayCommands = options.cfg ? listChatCommandsForConfig(options.cfg) : listChatCommands();
|
|
162
|
+
for (const command of gatewayCommands) {
|
|
163
|
+
const aliases = command.textAliases.length > 0 ? command.textAliases : [`/${command.key}`];
|
|
164
|
+
for (const alias of aliases) {
|
|
165
|
+
const name = alias.replace(/^\//, "").trim();
|
|
166
|
+
if (!name || seen.has(name)) continue;
|
|
167
|
+
seen.add(name);
|
|
168
|
+
commands.push({
|
|
169
|
+
name,
|
|
170
|
+
description: command.description
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return commands;
|
|
175
|
+
}
|
|
176
|
+
function helpText(options = {}) {
|
|
177
|
+
return [
|
|
178
|
+
"Slash commands:",
|
|
179
|
+
"/help",
|
|
180
|
+
"/commands",
|
|
181
|
+
"/status",
|
|
182
|
+
"/agent <id> (or /agents)",
|
|
183
|
+
"/session <key> (or /sessions)",
|
|
184
|
+
"/model <provider/model> (or /models)",
|
|
185
|
+
`/think <${formatThinkingLevels(options.provider, options.model, "|")}>`,
|
|
186
|
+
"/verbose <on|off>",
|
|
187
|
+
"/reasoning <on|off>",
|
|
188
|
+
"/usage <off|tokens|full>",
|
|
189
|
+
"/elevated <on|off|ask|full>",
|
|
190
|
+
"/elev <on|off|ask|full>",
|
|
191
|
+
"/activation <mention|always>",
|
|
192
|
+
"/new or /reset",
|
|
193
|
+
"/abort",
|
|
194
|
+
"/settings",
|
|
195
|
+
"/exit"
|
|
196
|
+
].join("\n");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/tui/theme/syntax-theme.ts
|
|
201
|
+
/**
|
|
202
|
+
* Syntax highlighting theme for code blocks.
|
|
203
|
+
* Uses chalk functions to style different token types.
|
|
204
|
+
*/
|
|
205
|
+
function createSyntaxTheme(fallback) {
|
|
206
|
+
return {
|
|
207
|
+
keyword: chalk.hex("#C586C0"),
|
|
208
|
+
built_in: chalk.hex("#4EC9B0"),
|
|
209
|
+
type: chalk.hex("#4EC9B0"),
|
|
210
|
+
literal: chalk.hex("#569CD6"),
|
|
211
|
+
number: chalk.hex("#B5CEA8"),
|
|
212
|
+
string: chalk.hex("#CE9178"),
|
|
213
|
+
regexp: chalk.hex("#D16969"),
|
|
214
|
+
symbol: chalk.hex("#B5CEA8"),
|
|
215
|
+
class: chalk.hex("#4EC9B0"),
|
|
216
|
+
function: chalk.hex("#DCDCAA"),
|
|
217
|
+
title: chalk.hex("#DCDCAA"),
|
|
218
|
+
params: chalk.hex("#9CDCFE"),
|
|
219
|
+
comment: chalk.hex("#6A9955"),
|
|
220
|
+
doctag: chalk.hex("#608B4E"),
|
|
221
|
+
meta: chalk.hex("#9CDCFE"),
|
|
222
|
+
"meta-keyword": chalk.hex("#C586C0"),
|
|
223
|
+
"meta-string": chalk.hex("#CE9178"),
|
|
224
|
+
section: chalk.hex("#DCDCAA"),
|
|
225
|
+
tag: chalk.hex("#569CD6"),
|
|
226
|
+
name: chalk.hex("#9CDCFE"),
|
|
227
|
+
attr: chalk.hex("#9CDCFE"),
|
|
228
|
+
attribute: chalk.hex("#9CDCFE"),
|
|
229
|
+
variable: chalk.hex("#9CDCFE"),
|
|
230
|
+
bullet: chalk.hex("#D7BA7D"),
|
|
231
|
+
code: chalk.hex("#CE9178"),
|
|
232
|
+
emphasis: chalk.italic,
|
|
233
|
+
strong: chalk.bold,
|
|
234
|
+
formula: chalk.hex("#C586C0"),
|
|
235
|
+
link: chalk.hex("#4EC9B0"),
|
|
236
|
+
quote: chalk.hex("#6A9955"),
|
|
237
|
+
addition: chalk.hex("#B5CEA8"),
|
|
238
|
+
deletion: chalk.hex("#F44747"),
|
|
239
|
+
"selector-tag": chalk.hex("#D7BA7D"),
|
|
240
|
+
"selector-id": chalk.hex("#D7BA7D"),
|
|
241
|
+
"selector-class": chalk.hex("#D7BA7D"),
|
|
242
|
+
"selector-attr": chalk.hex("#D7BA7D"),
|
|
243
|
+
"selector-pseudo": chalk.hex("#D7BA7D"),
|
|
244
|
+
"template-tag": chalk.hex("#C586C0"),
|
|
245
|
+
"template-variable": chalk.hex("#9CDCFE"),
|
|
246
|
+
default: fallback
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region src/tui/theme/theme.ts
|
|
252
|
+
const palette = {
|
|
253
|
+
text: "#E8E3D5",
|
|
254
|
+
dim: "#7B7F87",
|
|
255
|
+
accent: "#F6C453",
|
|
256
|
+
accentSoft: "#F2A65A",
|
|
257
|
+
border: "#3C414B",
|
|
258
|
+
userBg: "#2B2F36",
|
|
259
|
+
userText: "#F3EEE0",
|
|
260
|
+
systemText: "#9BA3B2",
|
|
261
|
+
toolPendingBg: "#1F2A2F",
|
|
262
|
+
toolSuccessBg: "#1E2D23",
|
|
263
|
+
toolErrorBg: "#2F1F1F",
|
|
264
|
+
toolTitle: "#F6C453",
|
|
265
|
+
toolOutput: "#E1DACB",
|
|
266
|
+
quote: "#8CC8FF",
|
|
267
|
+
quoteBorder: "#3B4D6B",
|
|
268
|
+
code: "#F0C987",
|
|
269
|
+
codeBlock: "#1E232A",
|
|
270
|
+
codeBorder: "#343A45",
|
|
271
|
+
link: "#7DD3A5",
|
|
272
|
+
error: "#F97066",
|
|
273
|
+
success: "#7DD3A5"
|
|
274
|
+
};
|
|
275
|
+
const fg = (hex) => (text) => chalk.hex(hex)(text);
|
|
276
|
+
const bg = (hex) => (text) => chalk.bgHex(hex)(text);
|
|
277
|
+
const syntaxTheme = createSyntaxTheme(fg(palette.code));
|
|
278
|
+
/**
|
|
279
|
+
* Highlight code with syntax coloring.
|
|
280
|
+
* Returns an array of lines with ANSI escape codes.
|
|
281
|
+
*/
|
|
282
|
+
function highlightCode(code, lang) {
|
|
283
|
+
try {
|
|
284
|
+
return highlight(code, {
|
|
285
|
+
language: lang && supportsLanguage(lang) ? lang : void 0,
|
|
286
|
+
theme: syntaxTheme,
|
|
287
|
+
ignoreIllegals: true
|
|
288
|
+
}).split("\n");
|
|
289
|
+
} catch {
|
|
290
|
+
return code.split("\n").map((line) => fg(palette.code)(line));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const theme = {
|
|
294
|
+
fg: fg(palette.text),
|
|
295
|
+
dim: fg(palette.dim),
|
|
296
|
+
accent: fg(palette.accent),
|
|
297
|
+
accentSoft: fg(palette.accentSoft),
|
|
298
|
+
success: fg(palette.success),
|
|
299
|
+
error: fg(palette.error),
|
|
300
|
+
header: (text) => chalk.bold(fg(palette.accent)(text)),
|
|
301
|
+
system: fg(palette.systemText),
|
|
302
|
+
userBg: bg(palette.userBg),
|
|
303
|
+
userText: fg(palette.userText),
|
|
304
|
+
toolTitle: fg(palette.toolTitle),
|
|
305
|
+
toolOutput: fg(palette.toolOutput),
|
|
306
|
+
toolPendingBg: bg(palette.toolPendingBg),
|
|
307
|
+
toolSuccessBg: bg(palette.toolSuccessBg),
|
|
308
|
+
toolErrorBg: bg(palette.toolErrorBg),
|
|
309
|
+
border: fg(palette.border),
|
|
310
|
+
bold: (text) => chalk.bold(text),
|
|
311
|
+
italic: (text) => chalk.italic(text)
|
|
312
|
+
};
|
|
313
|
+
const markdownTheme = {
|
|
314
|
+
heading: (text) => chalk.bold(fg(palette.accent)(text)),
|
|
315
|
+
link: (text) => fg(palette.link)(text),
|
|
316
|
+
linkUrl: (text) => chalk.dim(text),
|
|
317
|
+
code: (text) => fg(palette.code)(text),
|
|
318
|
+
codeBlock: (text) => fg(palette.code)(text),
|
|
319
|
+
codeBlockBorder: (text) => fg(palette.codeBorder)(text),
|
|
320
|
+
quote: (text) => fg(palette.quote)(text),
|
|
321
|
+
quoteBorder: (text) => fg(palette.quoteBorder)(text),
|
|
322
|
+
hr: (text) => fg(palette.border)(text),
|
|
323
|
+
listBullet: (text) => fg(palette.accentSoft)(text),
|
|
324
|
+
bold: (text) => chalk.bold(text),
|
|
325
|
+
italic: (text) => chalk.italic(text),
|
|
326
|
+
strikethrough: (text) => chalk.strikethrough(text),
|
|
327
|
+
underline: (text) => chalk.underline(text),
|
|
328
|
+
highlightCode
|
|
329
|
+
};
|
|
330
|
+
const selectListTheme = {
|
|
331
|
+
selectedPrefix: (text) => fg(palette.accent)(text),
|
|
332
|
+
selectedText: (text) => chalk.bold(fg(palette.accent)(text)),
|
|
333
|
+
description: (text) => fg(palette.dim)(text),
|
|
334
|
+
scrollInfo: (text) => fg(palette.dim)(text),
|
|
335
|
+
noMatch: (text) => fg(palette.dim)(text)
|
|
336
|
+
};
|
|
337
|
+
const filterableSelectListTheme = {
|
|
338
|
+
...selectListTheme,
|
|
339
|
+
filterLabel: (text) => fg(palette.dim)(text)
|
|
340
|
+
};
|
|
341
|
+
const settingsListTheme = {
|
|
342
|
+
label: (text, selected) => selected ? chalk.bold(fg(palette.accent)(text)) : fg(palette.text)(text),
|
|
343
|
+
value: (text, selected) => selected ? fg(palette.accentSoft)(text) : fg(palette.dim)(text),
|
|
344
|
+
description: (text) => fg(palette.systemText)(text),
|
|
345
|
+
cursor: fg(palette.accent)("→ "),
|
|
346
|
+
hint: (text) => fg(palette.dim)(text)
|
|
347
|
+
};
|
|
348
|
+
const editorTheme = {
|
|
349
|
+
borderColor: (text) => fg(palette.border)(text),
|
|
350
|
+
selectList: selectListTheme
|
|
351
|
+
};
|
|
352
|
+
const searchableSelectListTheme = {
|
|
353
|
+
selectedPrefix: (text) => fg(palette.accent)(text),
|
|
354
|
+
selectedText: (text) => chalk.bold(fg(palette.accent)(text)),
|
|
355
|
+
description: (text) => fg(palette.dim)(text),
|
|
356
|
+
scrollInfo: (text) => fg(palette.dim)(text),
|
|
357
|
+
noMatch: (text) => fg(palette.dim)(text),
|
|
358
|
+
searchPrompt: (text) => fg(palette.accentSoft)(text),
|
|
359
|
+
searchInput: (text) => fg(palette.text)(text),
|
|
360
|
+
matchHighlight: (text) => chalk.bold(fg(palette.accent)(text))
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/tui/components/assistant-message.ts
|
|
365
|
+
var AssistantMessageComponent = class extends Container {
|
|
366
|
+
constructor(text) {
|
|
367
|
+
super();
|
|
368
|
+
this.body = new Markdown(text, 1, 0, markdownTheme, { color: (line) => theme.fg(line) });
|
|
369
|
+
this.addChild(new Spacer(1));
|
|
370
|
+
this.addChild(this.body);
|
|
371
|
+
}
|
|
372
|
+
setText(text) {
|
|
373
|
+
this.body.setText(text);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/tui/components/tool-execution.ts
|
|
379
|
+
const PREVIEW_LINES = 12;
|
|
380
|
+
function formatArgs(toolName, args) {
|
|
381
|
+
const detail = formatToolDetail(resolveToolDisplay({
|
|
382
|
+
name: toolName,
|
|
383
|
+
args
|
|
384
|
+
}));
|
|
385
|
+
if (detail) return detail;
|
|
386
|
+
if (!args || typeof args !== "object") return "";
|
|
387
|
+
try {
|
|
388
|
+
return JSON.stringify(args);
|
|
389
|
+
} catch {
|
|
390
|
+
return "";
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function extractText(result) {
|
|
394
|
+
if (!result?.content) return "";
|
|
395
|
+
const lines = [];
|
|
396
|
+
for (const entry of result.content) if (entry.type === "text" && entry.text) lines.push(entry.text);
|
|
397
|
+
else if (entry.type === "image") {
|
|
398
|
+
const mime = entry.mimeType ?? "image";
|
|
399
|
+
const size = entry.bytes ? ` ${Math.round(entry.bytes / 1024)}kb` : "";
|
|
400
|
+
const omitted = entry.omitted ? " (omitted)" : "";
|
|
401
|
+
lines.push(`[${mime}${size}${omitted}]`);
|
|
402
|
+
}
|
|
403
|
+
return lines.join("\n").trim();
|
|
404
|
+
}
|
|
405
|
+
var ToolExecutionComponent = class extends Container {
|
|
406
|
+
constructor(toolName, args) {
|
|
407
|
+
super();
|
|
408
|
+
this.expanded = false;
|
|
409
|
+
this.isError = false;
|
|
410
|
+
this.isPartial = true;
|
|
411
|
+
this.toolName = toolName;
|
|
412
|
+
this.args = args;
|
|
413
|
+
this.box = new Box(1, 1, (line) => theme.toolPendingBg(line));
|
|
414
|
+
this.header = new Text("", 0, 0);
|
|
415
|
+
this.argsLine = new Text("", 0, 0);
|
|
416
|
+
this.output = new Markdown("", 0, 0, markdownTheme, { color: (line) => theme.toolOutput(line) });
|
|
417
|
+
this.addChild(new Spacer(1));
|
|
418
|
+
this.addChild(this.box);
|
|
419
|
+
this.box.addChild(this.header);
|
|
420
|
+
this.box.addChild(this.argsLine);
|
|
421
|
+
this.box.addChild(this.output);
|
|
422
|
+
this.refresh();
|
|
423
|
+
}
|
|
424
|
+
setArgs(args) {
|
|
425
|
+
this.args = args;
|
|
426
|
+
this.refresh();
|
|
427
|
+
}
|
|
428
|
+
setExpanded(expanded) {
|
|
429
|
+
this.expanded = expanded;
|
|
430
|
+
this.refresh();
|
|
431
|
+
}
|
|
432
|
+
setResult(result, opts) {
|
|
433
|
+
this.result = result;
|
|
434
|
+
this.isPartial = false;
|
|
435
|
+
this.isError = Boolean(opts?.isError);
|
|
436
|
+
this.refresh();
|
|
437
|
+
}
|
|
438
|
+
setPartialResult(result) {
|
|
439
|
+
this.result = result;
|
|
440
|
+
this.isPartial = true;
|
|
441
|
+
this.refresh();
|
|
442
|
+
}
|
|
443
|
+
refresh() {
|
|
444
|
+
const bg = this.isPartial ? theme.toolPendingBg : this.isError ? theme.toolErrorBg : theme.toolSuccessBg;
|
|
445
|
+
this.box.setBgFn((line) => bg(line));
|
|
446
|
+
const display = resolveToolDisplay({
|
|
447
|
+
name: this.toolName,
|
|
448
|
+
args: this.args
|
|
449
|
+
});
|
|
450
|
+
const title = `${display.emoji} ${display.label}${this.isPartial ? " (running)" : ""}`;
|
|
451
|
+
this.header.setText(theme.toolTitle(theme.bold(title)));
|
|
452
|
+
const argLine = formatArgs(this.toolName, this.args);
|
|
453
|
+
this.argsLine.setText(argLine ? theme.dim(argLine) : theme.dim(" "));
|
|
454
|
+
const text = extractText(this.result) || (this.isPartial ? "…" : "");
|
|
455
|
+
if (!this.expanded && text) {
|
|
456
|
+
const lines = text.split("\n");
|
|
457
|
+
const preview = lines.length > PREVIEW_LINES ? `${lines.slice(0, PREVIEW_LINES).join("\n")}\n…` : text;
|
|
458
|
+
this.output.setText(preview);
|
|
459
|
+
} else this.output.setText(text);
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/tui/components/user-message.ts
|
|
465
|
+
var UserMessageComponent = class extends Container {
|
|
466
|
+
constructor(text) {
|
|
467
|
+
super();
|
|
468
|
+
this.body = new Markdown(text, 1, 1, markdownTheme, {
|
|
469
|
+
bgColor: (line) => theme.userBg(line),
|
|
470
|
+
color: (line) => theme.userText(line)
|
|
471
|
+
});
|
|
472
|
+
this.addChild(new Spacer(1));
|
|
473
|
+
this.addChild(this.body);
|
|
474
|
+
}
|
|
475
|
+
setText(text) {
|
|
476
|
+
this.body.setText(text);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region src/tui/components/chat-log.ts
|
|
482
|
+
var ChatLog = class extends Container {
|
|
483
|
+
constructor(..._args) {
|
|
484
|
+
super(..._args);
|
|
485
|
+
this.toolById = /* @__PURE__ */ new Map();
|
|
486
|
+
this.streamingRuns = /* @__PURE__ */ new Map();
|
|
487
|
+
this.toolsExpanded = false;
|
|
488
|
+
}
|
|
489
|
+
clearAll() {
|
|
490
|
+
this.clear();
|
|
491
|
+
this.toolById.clear();
|
|
492
|
+
this.streamingRuns.clear();
|
|
493
|
+
}
|
|
494
|
+
addSystem(text) {
|
|
495
|
+
this.addChild(new Spacer(1));
|
|
496
|
+
this.addChild(new Text(theme.system(text), 1, 0));
|
|
497
|
+
}
|
|
498
|
+
addUser(text) {
|
|
499
|
+
this.addChild(new UserMessageComponent(text));
|
|
500
|
+
}
|
|
501
|
+
resolveRunId(runId) {
|
|
502
|
+
return runId ?? "default";
|
|
503
|
+
}
|
|
504
|
+
startAssistant(text, runId) {
|
|
505
|
+
const component = new AssistantMessageComponent(text);
|
|
506
|
+
this.streamingRuns.set(this.resolveRunId(runId), component);
|
|
507
|
+
this.addChild(component);
|
|
508
|
+
return component;
|
|
509
|
+
}
|
|
510
|
+
updateAssistant(text, runId) {
|
|
511
|
+
const effectiveRunId = this.resolveRunId(runId);
|
|
512
|
+
const existing = this.streamingRuns.get(effectiveRunId);
|
|
513
|
+
if (!existing) {
|
|
514
|
+
this.startAssistant(text, runId);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
existing.setText(text);
|
|
518
|
+
}
|
|
519
|
+
finalizeAssistant(text, runId) {
|
|
520
|
+
const effectiveRunId = this.resolveRunId(runId);
|
|
521
|
+
const existing = this.streamingRuns.get(effectiveRunId);
|
|
522
|
+
if (existing) {
|
|
523
|
+
existing.setText(text);
|
|
524
|
+
this.streamingRuns.delete(effectiveRunId);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
this.addChild(new AssistantMessageComponent(text));
|
|
528
|
+
}
|
|
529
|
+
startTool(toolCallId, toolName, args) {
|
|
530
|
+
const existing = this.toolById.get(toolCallId);
|
|
531
|
+
if (existing) {
|
|
532
|
+
existing.setArgs(args);
|
|
533
|
+
return existing;
|
|
534
|
+
}
|
|
535
|
+
const component = new ToolExecutionComponent(toolName, args);
|
|
536
|
+
component.setExpanded(this.toolsExpanded);
|
|
537
|
+
this.toolById.set(toolCallId, component);
|
|
538
|
+
this.addChild(component);
|
|
539
|
+
return component;
|
|
540
|
+
}
|
|
541
|
+
updateToolArgs(toolCallId, args) {
|
|
542
|
+
const existing = this.toolById.get(toolCallId);
|
|
543
|
+
if (!existing) return;
|
|
544
|
+
existing.setArgs(args);
|
|
545
|
+
}
|
|
546
|
+
updateToolResult(toolCallId, result, opts) {
|
|
547
|
+
const existing = this.toolById.get(toolCallId);
|
|
548
|
+
if (!existing) return;
|
|
549
|
+
if (opts?.partial) {
|
|
550
|
+
existing.setPartialResult(result);
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
existing.setResult(result, { isError: opts?.isError });
|
|
554
|
+
}
|
|
555
|
+
setToolsExpanded(expanded) {
|
|
556
|
+
this.toolsExpanded = expanded;
|
|
557
|
+
for (const tool of this.toolById.values()) tool.setExpanded(expanded);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/tui/components/custom-editor.ts
|
|
563
|
+
var CustomEditor = class extends Editor {
|
|
564
|
+
handleInput(data) {
|
|
565
|
+
if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {
|
|
566
|
+
this.onAltEnter();
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
if (matchesKey(data, Key.ctrl("l")) && this.onCtrlL) {
|
|
570
|
+
this.onCtrlL();
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (matchesKey(data, Key.ctrl("o")) && this.onCtrlO) {
|
|
574
|
+
this.onCtrlO();
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
if (matchesKey(data, Key.ctrl("p")) && this.onCtrlP) {
|
|
578
|
+
this.onCtrlP();
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
if (matchesKey(data, Key.ctrl("g")) && this.onCtrlG) {
|
|
582
|
+
this.onCtrlG();
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
if (matchesKey(data, Key.ctrl("t")) && this.onCtrlT) {
|
|
586
|
+
this.onCtrlT();
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
if (matchesKey(data, Key.shift("tab")) && this.onShiftTab) {
|
|
590
|
+
this.onShiftTab();
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (matchesKey(data, Key.escape) && this.onEscape && !this.isShowingAutocomplete()) {
|
|
594
|
+
this.onEscape();
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
if (matchesKey(data, Key.ctrl("c")) && this.onCtrlC) {
|
|
598
|
+
this.onCtrlC();
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
if (matchesKey(data, Key.ctrl("d"))) {
|
|
602
|
+
if (this.getText().length === 0 && this.onCtrlD) this.onCtrlD();
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
super.handleInput(data);
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/tui/gateway-chat.ts
|
|
611
|
+
var GatewayChatClient = class {
|
|
612
|
+
constructor(opts) {
|
|
613
|
+
const resolved = resolveGatewayConnection(opts);
|
|
614
|
+
this.connection = resolved;
|
|
615
|
+
this.readyPromise = new Promise((resolve) => {
|
|
616
|
+
this.resolveReady = resolve;
|
|
617
|
+
});
|
|
618
|
+
this.client = new GatewayClient({
|
|
619
|
+
url: resolved.url,
|
|
620
|
+
token: resolved.token,
|
|
621
|
+
password: resolved.password,
|
|
622
|
+
clientName: GATEWAY_CLIENT_NAMES.GATEWAY_CLIENT,
|
|
623
|
+
clientDisplayName: "openclaw-tui",
|
|
624
|
+
clientVersion: VERSION,
|
|
625
|
+
platform: process.platform,
|
|
626
|
+
mode: GATEWAY_CLIENT_MODES.UI,
|
|
627
|
+
instanceId: randomUUID(),
|
|
628
|
+
minProtocol: PROTOCOL_VERSION,
|
|
629
|
+
maxProtocol: PROTOCOL_VERSION,
|
|
630
|
+
onHelloOk: (hello) => {
|
|
631
|
+
this.hello = hello;
|
|
632
|
+
this.resolveReady?.();
|
|
633
|
+
this.onConnected?.();
|
|
634
|
+
},
|
|
635
|
+
onEvent: (evt) => {
|
|
636
|
+
this.onEvent?.({
|
|
637
|
+
event: evt.event,
|
|
638
|
+
payload: evt.payload,
|
|
639
|
+
seq: evt.seq
|
|
640
|
+
});
|
|
641
|
+
},
|
|
642
|
+
onClose: (_code, reason) => {
|
|
643
|
+
this.onDisconnected?.(reason);
|
|
644
|
+
},
|
|
645
|
+
onGap: (info) => {
|
|
646
|
+
this.onGap?.(info);
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
start() {
|
|
651
|
+
this.client.start();
|
|
652
|
+
}
|
|
653
|
+
stop() {
|
|
654
|
+
this.client.stop();
|
|
655
|
+
}
|
|
656
|
+
async waitForReady() {
|
|
657
|
+
await this.readyPromise;
|
|
658
|
+
}
|
|
659
|
+
async sendChat(opts) {
|
|
660
|
+
const runId = randomUUID();
|
|
661
|
+
await this.client.request("chat.send", {
|
|
662
|
+
sessionKey: opts.sessionKey,
|
|
663
|
+
message: opts.message,
|
|
664
|
+
thinking: opts.thinking,
|
|
665
|
+
deliver: opts.deliver,
|
|
666
|
+
timeoutMs: opts.timeoutMs,
|
|
667
|
+
idempotencyKey: runId
|
|
668
|
+
});
|
|
669
|
+
return { runId };
|
|
670
|
+
}
|
|
671
|
+
async abortChat(opts) {
|
|
672
|
+
return await this.client.request("chat.abort", {
|
|
673
|
+
sessionKey: opts.sessionKey,
|
|
674
|
+
runId: opts.runId
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
async loadHistory(opts) {
|
|
678
|
+
return await this.client.request("chat.history", {
|
|
679
|
+
sessionKey: opts.sessionKey,
|
|
680
|
+
limit: opts.limit
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
async listSessions(opts) {
|
|
684
|
+
return await this.client.request("sessions.list", {
|
|
685
|
+
limit: opts?.limit,
|
|
686
|
+
activeMinutes: opts?.activeMinutes,
|
|
687
|
+
includeGlobal: opts?.includeGlobal,
|
|
688
|
+
includeUnknown: opts?.includeUnknown,
|
|
689
|
+
includeDerivedTitles: opts?.includeDerivedTitles,
|
|
690
|
+
includeLastMessage: opts?.includeLastMessage,
|
|
691
|
+
agentId: opts?.agentId
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
async listAgents() {
|
|
695
|
+
return await this.client.request("agents.list", {});
|
|
696
|
+
}
|
|
697
|
+
async patchSession(opts) {
|
|
698
|
+
return await this.client.request("sessions.patch", opts);
|
|
699
|
+
}
|
|
700
|
+
async resetSession(key) {
|
|
701
|
+
return await this.client.request("sessions.reset", { key });
|
|
702
|
+
}
|
|
703
|
+
async getStatus() {
|
|
704
|
+
return await this.client.request("status");
|
|
705
|
+
}
|
|
706
|
+
async listModels() {
|
|
707
|
+
const res = await this.client.request("models.list");
|
|
708
|
+
return Array.isArray(res?.models) ? res.models : [];
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
function resolveGatewayConnection(opts) {
|
|
712
|
+
const config = loadConfig();
|
|
713
|
+
const isRemoteMode = config.gateway?.mode === "remote";
|
|
714
|
+
const remote = isRemoteMode ? config.gateway?.remote : void 0;
|
|
715
|
+
const authToken = config.gateway?.auth?.token;
|
|
716
|
+
const localPort = resolveGatewayPort(config);
|
|
717
|
+
return {
|
|
718
|
+
url: (typeof opts.url === "string" && opts.url.trim().length > 0 ? opts.url.trim() : void 0) || (typeof remote?.url === "string" && remote.url.trim().length > 0 ? remote.url.trim() : void 0) || `ws://127.0.0.1:${localPort}`,
|
|
719
|
+
token: (typeof opts.token === "string" && opts.token.trim().length > 0 ? opts.token.trim() : void 0) || (isRemoteMode ? typeof remote?.token === "string" && remote.token.trim().length > 0 ? remote.token.trim() : void 0 : process.env.OPENCLAW_GATEWAY_TOKEN?.trim() || (typeof authToken === "string" && authToken.trim().length > 0 ? authToken.trim() : void 0)),
|
|
720
|
+
password: (typeof opts.password === "string" && opts.password.trim().length > 0 ? opts.password.trim() : void 0) || process.env.OPENCLAW_GATEWAY_PASSWORD?.trim() || (typeof remote?.password === "string" && remote.password.trim().length > 0 ? remote.password.trim() : void 0)
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
//#endregion
|
|
725
|
+
//#region src/utils/time-format.ts
|
|
726
|
+
function formatRelativeTime(timestamp) {
|
|
727
|
+
const diff = Date.now() - timestamp;
|
|
728
|
+
const seconds = Math.floor(diff / 1e3);
|
|
729
|
+
const minutes = Math.floor(seconds / 60);
|
|
730
|
+
const hours = Math.floor(minutes / 60);
|
|
731
|
+
const days = Math.floor(hours / 24);
|
|
732
|
+
if (seconds < 60) return "just now";
|
|
733
|
+
if (minutes < 60) return `${minutes}m ago`;
|
|
734
|
+
if (hours < 24) return `${hours}h ago`;
|
|
735
|
+
if (days === 1) return "Yesterday";
|
|
736
|
+
if (days < 7) return `${days}d ago`;
|
|
737
|
+
return new Date(timestamp).toLocaleDateString(void 0, {
|
|
738
|
+
month: "short",
|
|
739
|
+
day: "numeric"
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
//#endregion
|
|
744
|
+
//#region src/tui/components/fuzzy-filter.ts
|
|
745
|
+
/**
|
|
746
|
+
* Shared fuzzy filtering utilities for select list components.
|
|
747
|
+
*/
|
|
748
|
+
/**
|
|
749
|
+
* Word boundary characters for matching.
|
|
750
|
+
*/
|
|
751
|
+
const WORD_BOUNDARY_CHARS = /[\s\-_./:#@]/;
|
|
752
|
+
/**
|
|
753
|
+
* Check if position is at a word boundary.
|
|
754
|
+
*/
|
|
755
|
+
function isWordBoundary(text, index) {
|
|
756
|
+
return index === 0 || WORD_BOUNDARY_CHARS.test(text[index - 1] ?? "");
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Find index where query matches at a word boundary in text.
|
|
760
|
+
* Returns null if no match.
|
|
761
|
+
*/
|
|
762
|
+
function findWordBoundaryIndex(text, query) {
|
|
763
|
+
if (!query) return null;
|
|
764
|
+
const textLower = text.toLowerCase();
|
|
765
|
+
const queryLower = query.toLowerCase();
|
|
766
|
+
const maxIndex = textLower.length - queryLower.length;
|
|
767
|
+
if (maxIndex < 0) return null;
|
|
768
|
+
for (let i = 0; i <= maxIndex; i++) if (textLower.startsWith(queryLower, i) && isWordBoundary(textLower, i)) return i;
|
|
769
|
+
return null;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Fuzzy match with pre-lowercased inputs (avoids toLowerCase on every keystroke).
|
|
773
|
+
* Returns score (lower = better) or null if no match.
|
|
774
|
+
*/
|
|
775
|
+
function fuzzyMatchLower(queryLower, textLower) {
|
|
776
|
+
if (queryLower.length === 0) return 0;
|
|
777
|
+
if (queryLower.length > textLower.length) return null;
|
|
778
|
+
let queryIndex = 0;
|
|
779
|
+
let score = 0;
|
|
780
|
+
let lastMatchIndex = -1;
|
|
781
|
+
let consecutiveMatches = 0;
|
|
782
|
+
for (let i = 0; i < textLower.length && queryIndex < queryLower.length; i++) if (textLower[i] === queryLower[queryIndex]) {
|
|
783
|
+
const isAtWordBoundary = isWordBoundary(textLower, i);
|
|
784
|
+
if (lastMatchIndex === i - 1) {
|
|
785
|
+
consecutiveMatches++;
|
|
786
|
+
score -= consecutiveMatches * 5;
|
|
787
|
+
} else {
|
|
788
|
+
consecutiveMatches = 0;
|
|
789
|
+
if (lastMatchIndex >= 0) score += (i - lastMatchIndex - 1) * 2;
|
|
790
|
+
}
|
|
791
|
+
if (isAtWordBoundary) score -= 10;
|
|
792
|
+
score += i * .1;
|
|
793
|
+
lastMatchIndex = i;
|
|
794
|
+
queryIndex++;
|
|
795
|
+
}
|
|
796
|
+
return queryIndex < queryLower.length ? null : score;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Filter items using pre-lowercased searchTextLower field.
|
|
800
|
+
* Supports space-separated tokens (all must match).
|
|
801
|
+
*/
|
|
802
|
+
function fuzzyFilterLower(items, queryLower) {
|
|
803
|
+
const trimmed = queryLower.trim();
|
|
804
|
+
if (!trimmed) return items;
|
|
805
|
+
const tokens = trimmed.split(/\s+/).filter((t) => t.length > 0);
|
|
806
|
+
if (tokens.length === 0) return items;
|
|
807
|
+
const results = [];
|
|
808
|
+
for (const item of items) {
|
|
809
|
+
const text = item.searchTextLower ?? "";
|
|
810
|
+
let totalScore = 0;
|
|
811
|
+
let allMatch = true;
|
|
812
|
+
for (const token of tokens) {
|
|
813
|
+
const score = fuzzyMatchLower(token, text);
|
|
814
|
+
if (score !== null) totalScore += score;
|
|
815
|
+
else {
|
|
816
|
+
allMatch = false;
|
|
817
|
+
break;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
if (allMatch) results.push({
|
|
821
|
+
item,
|
|
822
|
+
score: totalScore
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
results.sort((a, b) => a.score - b.score);
|
|
826
|
+
return results.map((r) => r.item);
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Prepare items for fuzzy filtering by pre-computing lowercase search text.
|
|
830
|
+
*/
|
|
831
|
+
function prepareSearchItems(items) {
|
|
832
|
+
return items.map((item) => {
|
|
833
|
+
const parts = [];
|
|
834
|
+
if (item.label) parts.push(item.label);
|
|
835
|
+
if (item.description) parts.push(item.description);
|
|
836
|
+
if (item.searchText) parts.push(item.searchText);
|
|
837
|
+
return {
|
|
838
|
+
...item,
|
|
839
|
+
searchTextLower: parts.join(" ").toLowerCase()
|
|
840
|
+
};
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
//#endregion
|
|
845
|
+
//#region src/tui/components/filterable-select-list.ts
|
|
846
|
+
/**
|
|
847
|
+
* Combines text input filtering with a select list.
|
|
848
|
+
* User types to filter, arrows/j/k to navigate, Enter to select, Escape to clear/cancel.
|
|
849
|
+
*/
|
|
850
|
+
var FilterableSelectList = class {
|
|
851
|
+
constructor(items, maxVisible, theme) {
|
|
852
|
+
this.filterText = "";
|
|
853
|
+
this.allItems = prepareSearchItems(items);
|
|
854
|
+
this.maxVisible = maxVisible;
|
|
855
|
+
this.theme = theme;
|
|
856
|
+
this.input = new Input();
|
|
857
|
+
this.selectList = new SelectList(this.allItems, maxVisible, theme);
|
|
858
|
+
}
|
|
859
|
+
applyFilter() {
|
|
860
|
+
const queryLower = this.filterText.toLowerCase();
|
|
861
|
+
if (!queryLower.trim()) {
|
|
862
|
+
this.selectList = new SelectList(this.allItems, this.maxVisible, this.theme);
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
this.selectList = new SelectList(fuzzyFilterLower(this.allItems, queryLower), this.maxVisible, this.theme);
|
|
866
|
+
}
|
|
867
|
+
invalidate() {
|
|
868
|
+
this.input.invalidate();
|
|
869
|
+
this.selectList.invalidate();
|
|
870
|
+
}
|
|
871
|
+
render(width) {
|
|
872
|
+
const lines = [];
|
|
873
|
+
const filterLabel = this.theme.filterLabel("Filter: ");
|
|
874
|
+
const inputText = this.input.render(width - 8)[0] ?? "";
|
|
875
|
+
lines.push(filterLabel + inputText);
|
|
876
|
+
lines.push(chalk.dim("─".repeat(Math.max(0, width))));
|
|
877
|
+
const listLines = this.selectList.render(width);
|
|
878
|
+
lines.push(...listLines);
|
|
879
|
+
return lines;
|
|
880
|
+
}
|
|
881
|
+
handleInput(keyData) {
|
|
882
|
+
const allowVimNav = !this.filterText.trim();
|
|
883
|
+
if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
|
|
884
|
+
this.selectList.handleInput("\x1B[A");
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
|
|
888
|
+
this.selectList.handleInput("\x1B[B");
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
if (matchesKey(keyData, "enter")) {
|
|
892
|
+
const selected = this.selectList.getSelectedItem();
|
|
893
|
+
if (selected) this.onSelect?.(selected);
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
if (getEditorKeybindings().matches(keyData, "selectCancel")) {
|
|
897
|
+
if (this.filterText) {
|
|
898
|
+
this.filterText = "";
|
|
899
|
+
this.input.setValue("");
|
|
900
|
+
this.applyFilter();
|
|
901
|
+
} else this.onCancel?.();
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
const prevValue = this.input.getValue();
|
|
905
|
+
this.input.handleInput(keyData);
|
|
906
|
+
const newValue = this.input.getValue();
|
|
907
|
+
if (newValue !== prevValue) {
|
|
908
|
+
this.filterText = newValue;
|
|
909
|
+
this.applyFilter();
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
getSelectedItem() {
|
|
913
|
+
return this.selectList.getSelectedItem();
|
|
914
|
+
}
|
|
915
|
+
getFilterText() {
|
|
916
|
+
return this.filterText;
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region src/tui/components/searchable-select-list.ts
|
|
922
|
+
/**
|
|
923
|
+
* A select list with a search input at the top for fuzzy filtering.
|
|
924
|
+
*/
|
|
925
|
+
var SearchableSelectList = class {
|
|
926
|
+
constructor(items, maxVisible, theme) {
|
|
927
|
+
this.selectedIndex = 0;
|
|
928
|
+
this.regexCache = /* @__PURE__ */ new Map();
|
|
929
|
+
this.compareByScore = (a, b) => {
|
|
930
|
+
if (a.tier !== b.tier) return a.tier - b.tier;
|
|
931
|
+
if (a.score !== b.score) return a.score - b.score;
|
|
932
|
+
return this.getItemLabel(a.item).localeCompare(this.getItemLabel(b.item));
|
|
933
|
+
};
|
|
934
|
+
this.items = items;
|
|
935
|
+
this.filteredItems = items;
|
|
936
|
+
this.maxVisible = maxVisible;
|
|
937
|
+
this.theme = theme;
|
|
938
|
+
this.searchInput = new Input();
|
|
939
|
+
}
|
|
940
|
+
getCachedRegex(pattern) {
|
|
941
|
+
let regex = this.regexCache.get(pattern);
|
|
942
|
+
if (!regex) {
|
|
943
|
+
regex = new RegExp(this.escapeRegex(pattern), "gi");
|
|
944
|
+
this.regexCache.set(pattern, regex);
|
|
945
|
+
}
|
|
946
|
+
return regex;
|
|
947
|
+
}
|
|
948
|
+
updateFilter() {
|
|
949
|
+
const query = this.searchInput.getValue().trim();
|
|
950
|
+
if (!query) this.filteredItems = this.items;
|
|
951
|
+
else this.filteredItems = this.smartFilter(query);
|
|
952
|
+
this.selectedIndex = 0;
|
|
953
|
+
this.notifySelectionChange();
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Smart filtering that prioritizes:
|
|
957
|
+
* 1. Exact substring match in label (highest priority)
|
|
958
|
+
* 2. Word-boundary prefix match in label
|
|
959
|
+
* 3. Exact substring in description
|
|
960
|
+
* 4. Fuzzy match (lowest priority)
|
|
961
|
+
*/
|
|
962
|
+
smartFilter(query) {
|
|
963
|
+
const q = query.toLowerCase();
|
|
964
|
+
const scoredItems = [];
|
|
965
|
+
const fuzzyCandidates = [];
|
|
966
|
+
for (const item of this.items) {
|
|
967
|
+
const label = item.label.toLowerCase();
|
|
968
|
+
const desc = (item.description ?? "").toLowerCase();
|
|
969
|
+
const labelIndex = label.indexOf(q);
|
|
970
|
+
if (labelIndex !== -1) {
|
|
971
|
+
scoredItems.push({
|
|
972
|
+
item,
|
|
973
|
+
tier: 0,
|
|
974
|
+
score: labelIndex
|
|
975
|
+
});
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
const wordBoundaryIndex = findWordBoundaryIndex(label, q);
|
|
979
|
+
if (wordBoundaryIndex !== null) {
|
|
980
|
+
scoredItems.push({
|
|
981
|
+
item,
|
|
982
|
+
tier: 1,
|
|
983
|
+
score: wordBoundaryIndex
|
|
984
|
+
});
|
|
985
|
+
continue;
|
|
986
|
+
}
|
|
987
|
+
const descIndex = desc.indexOf(q);
|
|
988
|
+
if (descIndex !== -1) {
|
|
989
|
+
scoredItems.push({
|
|
990
|
+
item,
|
|
991
|
+
tier: 2,
|
|
992
|
+
score: descIndex
|
|
993
|
+
});
|
|
994
|
+
continue;
|
|
995
|
+
}
|
|
996
|
+
fuzzyCandidates.push(item);
|
|
997
|
+
}
|
|
998
|
+
scoredItems.sort(this.compareByScore);
|
|
999
|
+
const fuzzyMatches = fuzzyFilterLower(prepareSearchItems(fuzzyCandidates), q);
|
|
1000
|
+
return [...scoredItems.map((s) => s.item), ...fuzzyMatches];
|
|
1001
|
+
}
|
|
1002
|
+
escapeRegex(str) {
|
|
1003
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1004
|
+
}
|
|
1005
|
+
getItemLabel(item) {
|
|
1006
|
+
return item.label || item.value;
|
|
1007
|
+
}
|
|
1008
|
+
highlightMatch(text, query) {
|
|
1009
|
+
const tokens = query.trim().split(/\s+/).map((token) => token.toLowerCase()).filter((token) => token.length > 0);
|
|
1010
|
+
if (tokens.length === 0) return text;
|
|
1011
|
+
const uniqueTokens = Array.from(new Set(tokens)).toSorted((a, b) => b.length - a.length);
|
|
1012
|
+
let result = text;
|
|
1013
|
+
for (const token of uniqueTokens) {
|
|
1014
|
+
const regex = this.getCachedRegex(token);
|
|
1015
|
+
result = result.replace(regex, (match) => this.theme.matchHighlight(match));
|
|
1016
|
+
}
|
|
1017
|
+
return result;
|
|
1018
|
+
}
|
|
1019
|
+
setSelectedIndex(index) {
|
|
1020
|
+
this.selectedIndex = Math.max(0, Math.min(index, this.filteredItems.length - 1));
|
|
1021
|
+
}
|
|
1022
|
+
invalidate() {
|
|
1023
|
+
this.searchInput.invalidate();
|
|
1024
|
+
}
|
|
1025
|
+
render(width) {
|
|
1026
|
+
const lines = [];
|
|
1027
|
+
const prompt = this.theme.searchPrompt("search: ");
|
|
1028
|
+
const inputWidth = Math.max(1, width - visibleWidth(prompt));
|
|
1029
|
+
const inputText = this.searchInput.render(inputWidth)[0] ?? "";
|
|
1030
|
+
lines.push(`${prompt}${this.theme.searchInput(inputText)}`);
|
|
1031
|
+
lines.push("");
|
|
1032
|
+
const query = this.searchInput.getValue().trim();
|
|
1033
|
+
if (this.filteredItems.length === 0) {
|
|
1034
|
+
lines.push(this.theme.noMatch(" No matches"));
|
|
1035
|
+
return lines;
|
|
1036
|
+
}
|
|
1037
|
+
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible));
|
|
1038
|
+
const endIndex = Math.min(startIndex + this.maxVisible, this.filteredItems.length);
|
|
1039
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
1040
|
+
const item = this.filteredItems[i];
|
|
1041
|
+
if (!item) continue;
|
|
1042
|
+
const isSelected = i === this.selectedIndex;
|
|
1043
|
+
lines.push(this.renderItemLine(item, isSelected, width, query));
|
|
1044
|
+
}
|
|
1045
|
+
if (this.filteredItems.length > this.maxVisible) {
|
|
1046
|
+
const scrollInfo = `${this.selectedIndex + 1}/${this.filteredItems.length}`;
|
|
1047
|
+
lines.push(this.theme.scrollInfo(` ${scrollInfo}`));
|
|
1048
|
+
}
|
|
1049
|
+
return lines;
|
|
1050
|
+
}
|
|
1051
|
+
renderItemLine(item, isSelected, width, query) {
|
|
1052
|
+
const prefix = isSelected ? "→ " : " ";
|
|
1053
|
+
const prefixWidth = prefix.length;
|
|
1054
|
+
const displayValue = this.getItemLabel(item);
|
|
1055
|
+
if (item.description && width > 40) {
|
|
1056
|
+
const truncatedValue = truncateToWidth(displayValue, Math.min(30, width - prefixWidth - 4), "");
|
|
1057
|
+
const valueText = this.highlightMatch(truncatedValue, query);
|
|
1058
|
+
const spacingWidth = Math.max(1, 32 - visibleWidth(valueText));
|
|
1059
|
+
const spacing = " ".repeat(spacingWidth);
|
|
1060
|
+
const remainingWidth = width - (prefixWidth + visibleWidth(valueText) + spacing.length) - 2;
|
|
1061
|
+
if (remainingWidth > 10) {
|
|
1062
|
+
const truncatedDesc = truncateToWidth(item.description, remainingWidth, "");
|
|
1063
|
+
const highlightedDesc = this.highlightMatch(truncatedDesc, query);
|
|
1064
|
+
const line = `${prefix}${valueText}${spacing}${isSelected ? highlightedDesc : this.theme.description(highlightedDesc)}`;
|
|
1065
|
+
return isSelected ? this.theme.selectedText(line) : line;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
const truncatedValue = truncateToWidth(displayValue, width - prefixWidth - 2, "");
|
|
1069
|
+
const line = `${prefix}${this.highlightMatch(truncatedValue, query)}`;
|
|
1070
|
+
return isSelected ? this.theme.selectedText(line) : line;
|
|
1071
|
+
}
|
|
1072
|
+
handleInput(keyData) {
|
|
1073
|
+
if (isKeyRelease(keyData)) return;
|
|
1074
|
+
const allowVimNav = !this.searchInput.getValue().trim();
|
|
1075
|
+
if (matchesKey(keyData, "up") || matchesKey(keyData, "ctrl+p") || allowVimNav && keyData === "k") {
|
|
1076
|
+
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
1077
|
+
this.notifySelectionChange();
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
if (matchesKey(keyData, "down") || matchesKey(keyData, "ctrl+n") || allowVimNav && keyData === "j") {
|
|
1081
|
+
this.selectedIndex = Math.min(this.filteredItems.length - 1, this.selectedIndex + 1);
|
|
1082
|
+
this.notifySelectionChange();
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
if (matchesKey(keyData, "enter")) {
|
|
1086
|
+
const item = this.filteredItems[this.selectedIndex];
|
|
1087
|
+
if (item && this.onSelect) this.onSelect(item);
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
if (getEditorKeybindings().matches(keyData, "selectCancel")) {
|
|
1091
|
+
if (this.onCancel) this.onCancel();
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
const prevValue = this.searchInput.getValue();
|
|
1095
|
+
this.searchInput.handleInput(keyData);
|
|
1096
|
+
if (prevValue !== this.searchInput.getValue()) this.updateFilter();
|
|
1097
|
+
}
|
|
1098
|
+
notifySelectionChange() {
|
|
1099
|
+
const item = this.filteredItems[this.selectedIndex];
|
|
1100
|
+
if (item && this.onSelectionChange) this.onSelectionChange(item);
|
|
1101
|
+
}
|
|
1102
|
+
getSelectedItem() {
|
|
1103
|
+
return this.filteredItems[this.selectedIndex] ?? null;
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
//#endregion
|
|
1108
|
+
//#region src/tui/components/selectors.ts
|
|
1109
|
+
function createSearchableSelectList(items, maxVisible = 7) {
|
|
1110
|
+
return new SearchableSelectList(items, maxVisible, searchableSelectListTheme);
|
|
1111
|
+
}
|
|
1112
|
+
function createFilterableSelectList(items, maxVisible = 7) {
|
|
1113
|
+
return new FilterableSelectList(items, maxVisible, filterableSelectListTheme);
|
|
1114
|
+
}
|
|
1115
|
+
function createSettingsList(items, onChange, onCancel, maxVisible = 7) {
|
|
1116
|
+
return new SettingsList(items, maxVisible, settingsListTheme, onChange, onCancel);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
//#endregion
|
|
1120
|
+
//#region src/tui/tui-status-summary.ts
|
|
1121
|
+
function formatStatusSummary(summary) {
|
|
1122
|
+
const lines = [];
|
|
1123
|
+
lines.push("Gateway status");
|
|
1124
|
+
if (!summary.linkChannel) lines.push("Link channel: unknown");
|
|
1125
|
+
else {
|
|
1126
|
+
const linkLabel = summary.linkChannel.label ?? "Link channel";
|
|
1127
|
+
const linked = summary.linkChannel.linked === true;
|
|
1128
|
+
const authAge = linked && typeof summary.linkChannel.authAgeMs === "number" ? ` (last refreshed ${formatAge(summary.linkChannel.authAgeMs)})` : "";
|
|
1129
|
+
lines.push(`${linkLabel}: ${linked ? "linked" : "not linked"}${authAge}`);
|
|
1130
|
+
}
|
|
1131
|
+
const providerSummary = Array.isArray(summary.providerSummary) ? summary.providerSummary : [];
|
|
1132
|
+
if (providerSummary.length > 0) {
|
|
1133
|
+
lines.push("");
|
|
1134
|
+
lines.push("System:");
|
|
1135
|
+
for (const line of providerSummary) lines.push(` ${line}`);
|
|
1136
|
+
}
|
|
1137
|
+
const heartbeatAgents = summary.heartbeat?.agents ?? [];
|
|
1138
|
+
if (heartbeatAgents.length > 0) {
|
|
1139
|
+
const heartbeatParts = heartbeatAgents.map((agent) => {
|
|
1140
|
+
const agentId = agent.agentId ?? "unknown";
|
|
1141
|
+
if (!agent.enabled || !agent.everyMs) return `disabled (${agentId})`;
|
|
1142
|
+
return `${agent.every ?? "unknown"} (${agentId})`;
|
|
1143
|
+
});
|
|
1144
|
+
lines.push("");
|
|
1145
|
+
lines.push(`Heartbeat: ${heartbeatParts.join(", ")}`);
|
|
1146
|
+
}
|
|
1147
|
+
const sessionPaths = summary.sessions?.paths ?? [];
|
|
1148
|
+
if (sessionPaths.length === 1) lines.push(`Session store: ${sessionPaths[0]}`);
|
|
1149
|
+
else if (sessionPaths.length > 1) lines.push(`Session stores: ${sessionPaths.length}`);
|
|
1150
|
+
const defaults = summary.sessions?.defaults;
|
|
1151
|
+
const defaultModel = defaults?.model ?? "unknown";
|
|
1152
|
+
const defaultCtx = typeof defaults?.contextTokens === "number" ? ` (${formatTokenCount(defaults.contextTokens)} ctx)` : "";
|
|
1153
|
+
lines.push(`Default model: ${defaultModel}${defaultCtx}`);
|
|
1154
|
+
const sessionCount = summary.sessions?.count ?? 0;
|
|
1155
|
+
lines.push(`Active sessions: ${sessionCount}`);
|
|
1156
|
+
const recent = Array.isArray(summary.sessions?.recent) ? summary.sessions?.recent : [];
|
|
1157
|
+
if (recent.length > 0) {
|
|
1158
|
+
lines.push("Recent sessions:");
|
|
1159
|
+
for (const entry of recent) {
|
|
1160
|
+
const ageLabel = typeof entry.age === "number" ? formatAge(entry.age) : "no activity";
|
|
1161
|
+
const model = entry.model ?? "unknown";
|
|
1162
|
+
const usage = formatContextUsageLine({
|
|
1163
|
+
total: entry.totalTokens ?? null,
|
|
1164
|
+
context: entry.contextTokens ?? null,
|
|
1165
|
+
remaining: entry.remainingTokens ?? null,
|
|
1166
|
+
percent: entry.percentUsed ?? null
|
|
1167
|
+
});
|
|
1168
|
+
const flags = entry.flags?.length ? ` | flags: ${entry.flags.join(", ")}` : "";
|
|
1169
|
+
lines.push(`- ${entry.key}${entry.kind ? ` [${entry.kind}]` : ""} | ${ageLabel} | model ${model} | ${usage}${flags}`);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
const queued = Array.isArray(summary.queuedSystemEvents) ? summary.queuedSystemEvents : [];
|
|
1173
|
+
if (queued.length > 0) {
|
|
1174
|
+
const preview = queued.slice(0, 3).join(" | ");
|
|
1175
|
+
lines.push(`Queued system events (${queued.length}): ${preview}`);
|
|
1176
|
+
}
|
|
1177
|
+
return lines;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
//#endregion
|
|
1181
|
+
//#region src/tui/tui-command-handlers.ts
|
|
1182
|
+
function createCommandHandlers(context) {
|
|
1183
|
+
const { client, chatLog, tui, opts, state, deliverDefault, openOverlay, closeOverlay, refreshSessionInfo, loadHistory, setSession, refreshAgents, abortActive, setActivityStatus, formatSessionKey } = context;
|
|
1184
|
+
const setAgent = async (id) => {
|
|
1185
|
+
state.currentAgentId = normalizeAgentId(id);
|
|
1186
|
+
await setSession("");
|
|
1187
|
+
};
|
|
1188
|
+
const openModelSelector = async () => {
|
|
1189
|
+
try {
|
|
1190
|
+
const models = await client.listModels();
|
|
1191
|
+
if (models.length === 0) {
|
|
1192
|
+
chatLog.addSystem("no models available");
|
|
1193
|
+
tui.requestRender();
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
const selector = createSearchableSelectList(models.map((model) => ({
|
|
1197
|
+
value: `${model.provider}/${model.id}`,
|
|
1198
|
+
label: `${model.provider}/${model.id}`,
|
|
1199
|
+
description: model.name && model.name !== model.id ? model.name : ""
|
|
1200
|
+
})), 9);
|
|
1201
|
+
selector.onSelect = (item) => {
|
|
1202
|
+
(async () => {
|
|
1203
|
+
try {
|
|
1204
|
+
await client.patchSession({
|
|
1205
|
+
key: state.currentSessionKey,
|
|
1206
|
+
model: item.value
|
|
1207
|
+
});
|
|
1208
|
+
chatLog.addSystem(`model set to ${item.value}`);
|
|
1209
|
+
await refreshSessionInfo();
|
|
1210
|
+
} catch (err) {
|
|
1211
|
+
chatLog.addSystem(`model set failed: ${String(err)}`);
|
|
1212
|
+
}
|
|
1213
|
+
closeOverlay();
|
|
1214
|
+
tui.requestRender();
|
|
1215
|
+
})();
|
|
1216
|
+
};
|
|
1217
|
+
selector.onCancel = () => {
|
|
1218
|
+
closeOverlay();
|
|
1219
|
+
tui.requestRender();
|
|
1220
|
+
};
|
|
1221
|
+
openOverlay(selector);
|
|
1222
|
+
tui.requestRender();
|
|
1223
|
+
} catch (err) {
|
|
1224
|
+
chatLog.addSystem(`model list failed: ${String(err)}`);
|
|
1225
|
+
tui.requestRender();
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
const openAgentSelector = async () => {
|
|
1229
|
+
await refreshAgents();
|
|
1230
|
+
if (state.agents.length === 0) {
|
|
1231
|
+
chatLog.addSystem("no agents found");
|
|
1232
|
+
tui.requestRender();
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
const selector = createSearchableSelectList(state.agents.map((agent) => ({
|
|
1236
|
+
value: agent.id,
|
|
1237
|
+
label: agent.name ? `${agent.id} (${agent.name})` : agent.id,
|
|
1238
|
+
description: agent.id === state.agentDefaultId ? "default" : ""
|
|
1239
|
+
})), 9);
|
|
1240
|
+
selector.onSelect = (item) => {
|
|
1241
|
+
(async () => {
|
|
1242
|
+
closeOverlay();
|
|
1243
|
+
await setAgent(item.value);
|
|
1244
|
+
tui.requestRender();
|
|
1245
|
+
})();
|
|
1246
|
+
};
|
|
1247
|
+
selector.onCancel = () => {
|
|
1248
|
+
closeOverlay();
|
|
1249
|
+
tui.requestRender();
|
|
1250
|
+
};
|
|
1251
|
+
openOverlay(selector);
|
|
1252
|
+
tui.requestRender();
|
|
1253
|
+
};
|
|
1254
|
+
const openSessionSelector = async () => {
|
|
1255
|
+
try {
|
|
1256
|
+
const selector = createFilterableSelectList((await client.listSessions({
|
|
1257
|
+
includeGlobal: false,
|
|
1258
|
+
includeUnknown: false,
|
|
1259
|
+
includeDerivedTitles: true,
|
|
1260
|
+
includeLastMessage: true,
|
|
1261
|
+
agentId: state.currentAgentId
|
|
1262
|
+
})).sessions.map((session) => {
|
|
1263
|
+
const title = session.derivedTitle ?? session.displayName;
|
|
1264
|
+
const formattedKey = formatSessionKey(session.key);
|
|
1265
|
+
const label = title && title !== formattedKey ? `${title} (${formattedKey})` : formattedKey;
|
|
1266
|
+
const timePart = session.updatedAt ? formatRelativeTime(session.updatedAt) : "";
|
|
1267
|
+
const preview = session.lastMessagePreview?.replace(/\s+/g, " ").trim();
|
|
1268
|
+
const description = timePart && preview ? `${timePart} · ${preview}` : preview ?? timePart;
|
|
1269
|
+
return {
|
|
1270
|
+
value: session.key,
|
|
1271
|
+
label,
|
|
1272
|
+
description,
|
|
1273
|
+
searchText: [
|
|
1274
|
+
session.displayName,
|
|
1275
|
+
session.label,
|
|
1276
|
+
session.subject,
|
|
1277
|
+
session.sessionId,
|
|
1278
|
+
session.key,
|
|
1279
|
+
session.lastMessagePreview
|
|
1280
|
+
].filter(Boolean).join(" ")
|
|
1281
|
+
};
|
|
1282
|
+
}), 9);
|
|
1283
|
+
selector.onSelect = (item) => {
|
|
1284
|
+
(async () => {
|
|
1285
|
+
closeOverlay();
|
|
1286
|
+
await setSession(item.value);
|
|
1287
|
+
tui.requestRender();
|
|
1288
|
+
})();
|
|
1289
|
+
};
|
|
1290
|
+
selector.onCancel = () => {
|
|
1291
|
+
closeOverlay();
|
|
1292
|
+
tui.requestRender();
|
|
1293
|
+
};
|
|
1294
|
+
openOverlay(selector);
|
|
1295
|
+
tui.requestRender();
|
|
1296
|
+
} catch (err) {
|
|
1297
|
+
chatLog.addSystem(`sessions list failed: ${String(err)}`);
|
|
1298
|
+
tui.requestRender();
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
const openSettings = () => {
|
|
1302
|
+
openOverlay(createSettingsList([{
|
|
1303
|
+
id: "tools",
|
|
1304
|
+
label: "Tool output",
|
|
1305
|
+
currentValue: state.toolsExpanded ? "expanded" : "collapsed",
|
|
1306
|
+
values: ["collapsed", "expanded"]
|
|
1307
|
+
}, {
|
|
1308
|
+
id: "thinking",
|
|
1309
|
+
label: "Show thinking",
|
|
1310
|
+
currentValue: state.showThinking ? "on" : "off",
|
|
1311
|
+
values: ["off", "on"]
|
|
1312
|
+
}], (id, value) => {
|
|
1313
|
+
if (id === "tools") {
|
|
1314
|
+
state.toolsExpanded = value === "expanded";
|
|
1315
|
+
chatLog.setToolsExpanded(state.toolsExpanded);
|
|
1316
|
+
}
|
|
1317
|
+
if (id === "thinking") {
|
|
1318
|
+
state.showThinking = value === "on";
|
|
1319
|
+
loadHistory();
|
|
1320
|
+
}
|
|
1321
|
+
tui.requestRender();
|
|
1322
|
+
}, () => {
|
|
1323
|
+
closeOverlay();
|
|
1324
|
+
tui.requestRender();
|
|
1325
|
+
}));
|
|
1326
|
+
tui.requestRender();
|
|
1327
|
+
};
|
|
1328
|
+
const handleCommand = async (raw) => {
|
|
1329
|
+
const { name, args } = parseCommand(raw);
|
|
1330
|
+
if (!name) return;
|
|
1331
|
+
switch (name) {
|
|
1332
|
+
case "help":
|
|
1333
|
+
chatLog.addSystem(helpText({
|
|
1334
|
+
provider: state.sessionInfo.modelProvider,
|
|
1335
|
+
model: state.sessionInfo.model
|
|
1336
|
+
}));
|
|
1337
|
+
break;
|
|
1338
|
+
case "status":
|
|
1339
|
+
try {
|
|
1340
|
+
const status = await client.getStatus();
|
|
1341
|
+
if (typeof status === "string") {
|
|
1342
|
+
chatLog.addSystem(status);
|
|
1343
|
+
break;
|
|
1344
|
+
}
|
|
1345
|
+
if (status && typeof status === "object") {
|
|
1346
|
+
const lines = formatStatusSummary(status);
|
|
1347
|
+
for (const line of lines) chatLog.addSystem(line);
|
|
1348
|
+
break;
|
|
1349
|
+
}
|
|
1350
|
+
chatLog.addSystem("status: unknown response");
|
|
1351
|
+
} catch (err) {
|
|
1352
|
+
chatLog.addSystem(`status failed: ${String(err)}`);
|
|
1353
|
+
}
|
|
1354
|
+
break;
|
|
1355
|
+
case "agent":
|
|
1356
|
+
if (!args) await openAgentSelector();
|
|
1357
|
+
else await setAgent(args);
|
|
1358
|
+
break;
|
|
1359
|
+
case "agents":
|
|
1360
|
+
await openAgentSelector();
|
|
1361
|
+
break;
|
|
1362
|
+
case "session":
|
|
1363
|
+
if (!args) await openSessionSelector();
|
|
1364
|
+
else await setSession(args);
|
|
1365
|
+
break;
|
|
1366
|
+
case "sessions":
|
|
1367
|
+
await openSessionSelector();
|
|
1368
|
+
break;
|
|
1369
|
+
case "model":
|
|
1370
|
+
if (!args) await openModelSelector();
|
|
1371
|
+
else try {
|
|
1372
|
+
await client.patchSession({
|
|
1373
|
+
key: state.currentSessionKey,
|
|
1374
|
+
model: args
|
|
1375
|
+
});
|
|
1376
|
+
chatLog.addSystem(`model set to ${args}`);
|
|
1377
|
+
await refreshSessionInfo();
|
|
1378
|
+
} catch (err) {
|
|
1379
|
+
chatLog.addSystem(`model set failed: ${String(err)}`);
|
|
1380
|
+
}
|
|
1381
|
+
break;
|
|
1382
|
+
case "models":
|
|
1383
|
+
await openModelSelector();
|
|
1384
|
+
break;
|
|
1385
|
+
case "think":
|
|
1386
|
+
if (!args) {
|
|
1387
|
+
const levels = formatThinkingLevels(state.sessionInfo.modelProvider, state.sessionInfo.model, "|");
|
|
1388
|
+
chatLog.addSystem(`usage: /think <${levels}>`);
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
try {
|
|
1392
|
+
await client.patchSession({
|
|
1393
|
+
key: state.currentSessionKey,
|
|
1394
|
+
thinkingLevel: args
|
|
1395
|
+
});
|
|
1396
|
+
chatLog.addSystem(`thinking set to ${args}`);
|
|
1397
|
+
await refreshSessionInfo();
|
|
1398
|
+
} catch (err) {
|
|
1399
|
+
chatLog.addSystem(`think failed: ${String(err)}`);
|
|
1400
|
+
}
|
|
1401
|
+
break;
|
|
1402
|
+
case "verbose":
|
|
1403
|
+
if (!args) {
|
|
1404
|
+
chatLog.addSystem("usage: /verbose <on|off>");
|
|
1405
|
+
break;
|
|
1406
|
+
}
|
|
1407
|
+
try {
|
|
1408
|
+
await client.patchSession({
|
|
1409
|
+
key: state.currentSessionKey,
|
|
1410
|
+
verboseLevel: args
|
|
1411
|
+
});
|
|
1412
|
+
chatLog.addSystem(`verbose set to ${args}`);
|
|
1413
|
+
await refreshSessionInfo();
|
|
1414
|
+
} catch (err) {
|
|
1415
|
+
chatLog.addSystem(`verbose failed: ${String(err)}`);
|
|
1416
|
+
}
|
|
1417
|
+
break;
|
|
1418
|
+
case "reasoning":
|
|
1419
|
+
if (!args) {
|
|
1420
|
+
chatLog.addSystem("usage: /reasoning <on|off>");
|
|
1421
|
+
break;
|
|
1422
|
+
}
|
|
1423
|
+
try {
|
|
1424
|
+
await client.patchSession({
|
|
1425
|
+
key: state.currentSessionKey,
|
|
1426
|
+
reasoningLevel: args
|
|
1427
|
+
});
|
|
1428
|
+
chatLog.addSystem(`reasoning set to ${args}`);
|
|
1429
|
+
await refreshSessionInfo();
|
|
1430
|
+
} catch (err) {
|
|
1431
|
+
chatLog.addSystem(`reasoning failed: ${String(err)}`);
|
|
1432
|
+
}
|
|
1433
|
+
break;
|
|
1434
|
+
case "usage": {
|
|
1435
|
+
const normalized = args ? normalizeUsageDisplay(args) : void 0;
|
|
1436
|
+
if (args && !normalized) {
|
|
1437
|
+
chatLog.addSystem("usage: /usage <off|tokens|full>");
|
|
1438
|
+
break;
|
|
1439
|
+
}
|
|
1440
|
+
const currentRaw = state.sessionInfo.responseUsage;
|
|
1441
|
+
const current = resolveResponseUsageMode(currentRaw);
|
|
1442
|
+
const next = normalized ?? (current === "off" ? "tokens" : current === "tokens" ? "full" : "off");
|
|
1443
|
+
try {
|
|
1444
|
+
await client.patchSession({
|
|
1445
|
+
key: state.currentSessionKey,
|
|
1446
|
+
responseUsage: next === "off" ? null : next
|
|
1447
|
+
});
|
|
1448
|
+
chatLog.addSystem(`usage footer: ${next}`);
|
|
1449
|
+
await refreshSessionInfo();
|
|
1450
|
+
} catch (err) {
|
|
1451
|
+
chatLog.addSystem(`usage failed: ${String(err)}`);
|
|
1452
|
+
}
|
|
1453
|
+
break;
|
|
1454
|
+
}
|
|
1455
|
+
case "elevated":
|
|
1456
|
+
if (!args) {
|
|
1457
|
+
chatLog.addSystem("usage: /elevated <on|off|ask|full>");
|
|
1458
|
+
break;
|
|
1459
|
+
}
|
|
1460
|
+
if (![
|
|
1461
|
+
"on",
|
|
1462
|
+
"off",
|
|
1463
|
+
"ask",
|
|
1464
|
+
"full"
|
|
1465
|
+
].includes(args)) {
|
|
1466
|
+
chatLog.addSystem("usage: /elevated <on|off|ask|full>");
|
|
1467
|
+
break;
|
|
1468
|
+
}
|
|
1469
|
+
try {
|
|
1470
|
+
await client.patchSession({
|
|
1471
|
+
key: state.currentSessionKey,
|
|
1472
|
+
elevatedLevel: args
|
|
1473
|
+
});
|
|
1474
|
+
chatLog.addSystem(`elevated set to ${args}`);
|
|
1475
|
+
await refreshSessionInfo();
|
|
1476
|
+
} catch (err) {
|
|
1477
|
+
chatLog.addSystem(`elevated failed: ${String(err)}`);
|
|
1478
|
+
}
|
|
1479
|
+
break;
|
|
1480
|
+
case "activation":
|
|
1481
|
+
if (!args) {
|
|
1482
|
+
chatLog.addSystem("usage: /activation <mention|always>");
|
|
1483
|
+
break;
|
|
1484
|
+
}
|
|
1485
|
+
try {
|
|
1486
|
+
await client.patchSession({
|
|
1487
|
+
key: state.currentSessionKey,
|
|
1488
|
+
groupActivation: args === "always" ? "always" : "mention"
|
|
1489
|
+
});
|
|
1490
|
+
chatLog.addSystem(`activation set to ${args}`);
|
|
1491
|
+
await refreshSessionInfo();
|
|
1492
|
+
} catch (err) {
|
|
1493
|
+
chatLog.addSystem(`activation failed: ${String(err)}`);
|
|
1494
|
+
}
|
|
1495
|
+
break;
|
|
1496
|
+
case "new":
|
|
1497
|
+
case "reset":
|
|
1498
|
+
try {
|
|
1499
|
+
state.sessionInfo.inputTokens = null;
|
|
1500
|
+
state.sessionInfo.outputTokens = null;
|
|
1501
|
+
state.sessionInfo.totalTokens = null;
|
|
1502
|
+
tui.requestRender();
|
|
1503
|
+
await client.resetSession(state.currentSessionKey);
|
|
1504
|
+
chatLog.addSystem(`session ${state.currentSessionKey} reset`);
|
|
1505
|
+
await loadHistory();
|
|
1506
|
+
} catch (err) {
|
|
1507
|
+
chatLog.addSystem(`reset failed: ${String(err)}`);
|
|
1508
|
+
}
|
|
1509
|
+
break;
|
|
1510
|
+
case "abort":
|
|
1511
|
+
await abortActive();
|
|
1512
|
+
break;
|
|
1513
|
+
case "settings":
|
|
1514
|
+
openSettings();
|
|
1515
|
+
break;
|
|
1516
|
+
case "exit":
|
|
1517
|
+
case "quit":
|
|
1518
|
+
client.stop();
|
|
1519
|
+
tui.stop();
|
|
1520
|
+
process.exit(0);
|
|
1521
|
+
break;
|
|
1522
|
+
default:
|
|
1523
|
+
await sendMessage(raw);
|
|
1524
|
+
break;
|
|
1525
|
+
}
|
|
1526
|
+
tui.requestRender();
|
|
1527
|
+
};
|
|
1528
|
+
const sendMessage = async (text) => {
|
|
1529
|
+
try {
|
|
1530
|
+
chatLog.addUser(text);
|
|
1531
|
+
tui.requestRender();
|
|
1532
|
+
setActivityStatus("sending");
|
|
1533
|
+
const { runId } = await client.sendChat({
|
|
1534
|
+
sessionKey: state.currentSessionKey,
|
|
1535
|
+
message: text,
|
|
1536
|
+
thinking: opts.thinking,
|
|
1537
|
+
deliver: deliverDefault,
|
|
1538
|
+
timeoutMs: opts.timeoutMs
|
|
1539
|
+
});
|
|
1540
|
+
state.activeChatRunId = runId;
|
|
1541
|
+
setActivityStatus("waiting");
|
|
1542
|
+
} catch (err) {
|
|
1543
|
+
chatLog.addSystem(`send failed: ${String(err)}`);
|
|
1544
|
+
setActivityStatus("error");
|
|
1545
|
+
}
|
|
1546
|
+
tui.requestRender();
|
|
1547
|
+
};
|
|
1548
|
+
return {
|
|
1549
|
+
handleCommand,
|
|
1550
|
+
sendMessage,
|
|
1551
|
+
openModelSelector,
|
|
1552
|
+
openAgentSelector,
|
|
1553
|
+
openSessionSelector,
|
|
1554
|
+
openSettings,
|
|
1555
|
+
setAgent
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
//#endregion
|
|
1560
|
+
//#region src/tui/tui-stream-assembler.ts
|
|
1561
|
+
var TuiStreamAssembler = class {
|
|
1562
|
+
constructor() {
|
|
1563
|
+
this.runs = /* @__PURE__ */ new Map();
|
|
1564
|
+
}
|
|
1565
|
+
getOrCreateRun(runId) {
|
|
1566
|
+
let state = this.runs.get(runId);
|
|
1567
|
+
if (!state) {
|
|
1568
|
+
state = {
|
|
1569
|
+
thinkingText: "",
|
|
1570
|
+
contentText: "",
|
|
1571
|
+
displayText: ""
|
|
1572
|
+
};
|
|
1573
|
+
this.runs.set(runId, state);
|
|
1574
|
+
}
|
|
1575
|
+
return state;
|
|
1576
|
+
}
|
|
1577
|
+
updateRunState(state, message, showThinking) {
|
|
1578
|
+
const thinkingText = extractThinkingFromMessage(message);
|
|
1579
|
+
const contentText = extractContentFromMessage(message);
|
|
1580
|
+
if (thinkingText) state.thinkingText = thinkingText;
|
|
1581
|
+
if (contentText) state.contentText = contentText;
|
|
1582
|
+
state.displayText = composeThinkingAndContent({
|
|
1583
|
+
thinkingText: state.thinkingText,
|
|
1584
|
+
contentText: state.contentText,
|
|
1585
|
+
showThinking
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
ingestDelta(runId, message, showThinking) {
|
|
1589
|
+
const state = this.getOrCreateRun(runId);
|
|
1590
|
+
const previousDisplayText = state.displayText;
|
|
1591
|
+
this.updateRunState(state, message, showThinking);
|
|
1592
|
+
if (!state.displayText || state.displayText === previousDisplayText) return null;
|
|
1593
|
+
return state.displayText;
|
|
1594
|
+
}
|
|
1595
|
+
finalize(runId, message, showThinking) {
|
|
1596
|
+
const state = this.getOrCreateRun(runId);
|
|
1597
|
+
this.updateRunState(state, message, showThinking);
|
|
1598
|
+
const finalComposed = state.displayText;
|
|
1599
|
+
const finalText = resolveFinalAssistantText({
|
|
1600
|
+
finalText: finalComposed,
|
|
1601
|
+
streamedText: state.displayText
|
|
1602
|
+
});
|
|
1603
|
+
this.runs.delete(runId);
|
|
1604
|
+
return finalText;
|
|
1605
|
+
}
|
|
1606
|
+
drop(runId) {
|
|
1607
|
+
this.runs.delete(runId);
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
|
|
1611
|
+
//#endregion
|
|
1612
|
+
//#region src/tui/tui-event-handlers.ts
|
|
1613
|
+
function createEventHandlers(context) {
|
|
1614
|
+
const { chatLog, tui, state, setActivityStatus, refreshSessionInfo } = context;
|
|
1615
|
+
const finalizedRuns = /* @__PURE__ */ new Map();
|
|
1616
|
+
const sessionRuns = /* @__PURE__ */ new Map();
|
|
1617
|
+
let streamAssembler = new TuiStreamAssembler();
|
|
1618
|
+
let lastSessionKey = state.currentSessionKey;
|
|
1619
|
+
const pruneRunMap = (runs) => {
|
|
1620
|
+
if (runs.size <= 200) return;
|
|
1621
|
+
const keepUntil = Date.now() - 600 * 1e3;
|
|
1622
|
+
for (const [key, ts] of runs) {
|
|
1623
|
+
if (runs.size <= 150) break;
|
|
1624
|
+
if (ts < keepUntil) runs.delete(key);
|
|
1625
|
+
}
|
|
1626
|
+
if (runs.size > 200) for (const key of runs.keys()) {
|
|
1627
|
+
runs.delete(key);
|
|
1628
|
+
if (runs.size <= 150) break;
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
const syncSessionKey = () => {
|
|
1632
|
+
if (state.currentSessionKey === lastSessionKey) return;
|
|
1633
|
+
lastSessionKey = state.currentSessionKey;
|
|
1634
|
+
finalizedRuns.clear();
|
|
1635
|
+
sessionRuns.clear();
|
|
1636
|
+
streamAssembler = new TuiStreamAssembler();
|
|
1637
|
+
};
|
|
1638
|
+
const noteSessionRun = (runId) => {
|
|
1639
|
+
sessionRuns.set(runId, Date.now());
|
|
1640
|
+
pruneRunMap(sessionRuns);
|
|
1641
|
+
};
|
|
1642
|
+
const noteFinalizedRun = (runId) => {
|
|
1643
|
+
finalizedRuns.set(runId, Date.now());
|
|
1644
|
+
sessionRuns.delete(runId);
|
|
1645
|
+
streamAssembler.drop(runId);
|
|
1646
|
+
pruneRunMap(finalizedRuns);
|
|
1647
|
+
};
|
|
1648
|
+
const handleChatEvent = (payload) => {
|
|
1649
|
+
if (!payload || typeof payload !== "object") return;
|
|
1650
|
+
const evt = payload;
|
|
1651
|
+
syncSessionKey();
|
|
1652
|
+
if (evt.sessionKey !== state.currentSessionKey) return;
|
|
1653
|
+
if (finalizedRuns.has(evt.runId)) {
|
|
1654
|
+
if (evt.state === "delta") return;
|
|
1655
|
+
if (evt.state === "final") return;
|
|
1656
|
+
}
|
|
1657
|
+
noteSessionRun(evt.runId);
|
|
1658
|
+
if (!state.activeChatRunId) state.activeChatRunId = evt.runId;
|
|
1659
|
+
if (evt.state === "delta") {
|
|
1660
|
+
const displayText = streamAssembler.ingestDelta(evt.runId, evt.message, state.showThinking);
|
|
1661
|
+
if (!displayText) return;
|
|
1662
|
+
chatLog.updateAssistant(displayText, evt.runId);
|
|
1663
|
+
setActivityStatus("streaming");
|
|
1664
|
+
}
|
|
1665
|
+
if (evt.state === "final") {
|
|
1666
|
+
if (isCommandMessage(evt.message)) {
|
|
1667
|
+
const text = extractTextFromMessage(evt.message);
|
|
1668
|
+
if (text) chatLog.addSystem(text);
|
|
1669
|
+
streamAssembler.drop(evt.runId);
|
|
1670
|
+
noteFinalizedRun(evt.runId);
|
|
1671
|
+
state.activeChatRunId = null;
|
|
1672
|
+
setActivityStatus("idle");
|
|
1673
|
+
refreshSessionInfo?.();
|
|
1674
|
+
tui.requestRender();
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
const stopReason = evt.message && typeof evt.message === "object" && !Array.isArray(evt.message) ? typeof evt.message.stopReason === "string" ? evt.message.stopReason : "" : "";
|
|
1678
|
+
const finalText = streamAssembler.finalize(evt.runId, evt.message, state.showThinking);
|
|
1679
|
+
chatLog.finalizeAssistant(finalText, evt.runId);
|
|
1680
|
+
noteFinalizedRun(evt.runId);
|
|
1681
|
+
state.activeChatRunId = null;
|
|
1682
|
+
setActivityStatus(stopReason === "error" ? "error" : "idle");
|
|
1683
|
+
refreshSessionInfo?.();
|
|
1684
|
+
}
|
|
1685
|
+
if (evt.state === "aborted") {
|
|
1686
|
+
chatLog.addSystem("run aborted");
|
|
1687
|
+
streamAssembler.drop(evt.runId);
|
|
1688
|
+
sessionRuns.delete(evt.runId);
|
|
1689
|
+
state.activeChatRunId = null;
|
|
1690
|
+
setActivityStatus("aborted");
|
|
1691
|
+
refreshSessionInfo?.();
|
|
1692
|
+
}
|
|
1693
|
+
if (evt.state === "error") {
|
|
1694
|
+
chatLog.addSystem(`run error: ${evt.errorMessage ?? "unknown"}`);
|
|
1695
|
+
streamAssembler.drop(evt.runId);
|
|
1696
|
+
sessionRuns.delete(evt.runId);
|
|
1697
|
+
state.activeChatRunId = null;
|
|
1698
|
+
setActivityStatus("error");
|
|
1699
|
+
refreshSessionInfo?.();
|
|
1700
|
+
}
|
|
1701
|
+
tui.requestRender();
|
|
1702
|
+
};
|
|
1703
|
+
const handleAgentEvent = (payload) => {
|
|
1704
|
+
if (!payload || typeof payload !== "object") return;
|
|
1705
|
+
const evt = payload;
|
|
1706
|
+
syncSessionKey();
|
|
1707
|
+
const isActiveRun = evt.runId === state.activeChatRunId;
|
|
1708
|
+
if (!isActiveRun && !sessionRuns.has(evt.runId)) return;
|
|
1709
|
+
if (evt.stream === "tool") {
|
|
1710
|
+
const data = evt.data ?? {};
|
|
1711
|
+
const phase = asString(data.phase, "");
|
|
1712
|
+
const toolCallId = asString(data.toolCallId, "");
|
|
1713
|
+
const toolName = asString(data.name, "tool");
|
|
1714
|
+
if (!toolCallId) return;
|
|
1715
|
+
if (phase === "start") chatLog.startTool(toolCallId, toolName, data.args);
|
|
1716
|
+
else if (phase === "update") chatLog.updateToolResult(toolCallId, data.partialResult, { partial: true });
|
|
1717
|
+
else if (phase === "result") chatLog.updateToolResult(toolCallId, data.result, { isError: Boolean(data.isError) });
|
|
1718
|
+
tui.requestRender();
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
if (evt.stream === "lifecycle") {
|
|
1722
|
+
if (!isActiveRun) return;
|
|
1723
|
+
const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
|
|
1724
|
+
if (phase === "start") setActivityStatus("running");
|
|
1725
|
+
if (phase === "end") setActivityStatus("idle");
|
|
1726
|
+
if (phase === "error") setActivityStatus("error");
|
|
1727
|
+
tui.requestRender();
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1730
|
+
return {
|
|
1731
|
+
handleChatEvent,
|
|
1732
|
+
handleAgentEvent
|
|
1733
|
+
};
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
//#endregion
|
|
1737
|
+
//#region src/tui/tui-local-shell.ts
|
|
1738
|
+
function createLocalShellRunner(deps) {
|
|
1739
|
+
let localExecAsked = false;
|
|
1740
|
+
let localExecAllowed = false;
|
|
1741
|
+
const createSelector = deps.createSelector ?? createSearchableSelectList;
|
|
1742
|
+
const spawnCommand = deps.spawnCommand ?? spawn;
|
|
1743
|
+
const getCwd = deps.getCwd ?? (() => process.cwd());
|
|
1744
|
+
const env = deps.env ?? process.env;
|
|
1745
|
+
const maxChars = deps.maxOutputChars ?? 4e4;
|
|
1746
|
+
const ensureLocalExecAllowed = async () => {
|
|
1747
|
+
if (localExecAllowed) return true;
|
|
1748
|
+
if (localExecAsked) return false;
|
|
1749
|
+
localExecAsked = true;
|
|
1750
|
+
return await new Promise((resolve) => {
|
|
1751
|
+
deps.chatLog.addSystem("Allow local shell commands for this session?");
|
|
1752
|
+
deps.chatLog.addSystem("This runs commands on YOUR machine (not the gateway) and may delete files or reveal secrets.");
|
|
1753
|
+
deps.chatLog.addSystem("Select Yes/No (arrows + Enter), Esc to cancel.");
|
|
1754
|
+
const selector = createSelector([{
|
|
1755
|
+
value: "no",
|
|
1756
|
+
label: "No"
|
|
1757
|
+
}, {
|
|
1758
|
+
value: "yes",
|
|
1759
|
+
label: "Yes"
|
|
1760
|
+
}], 2);
|
|
1761
|
+
selector.onSelect = (item) => {
|
|
1762
|
+
deps.closeOverlay();
|
|
1763
|
+
if (item.value === "yes") {
|
|
1764
|
+
localExecAllowed = true;
|
|
1765
|
+
deps.chatLog.addSystem("local shell: enabled for this session");
|
|
1766
|
+
resolve(true);
|
|
1767
|
+
} else {
|
|
1768
|
+
deps.chatLog.addSystem("local shell: not enabled");
|
|
1769
|
+
resolve(false);
|
|
1770
|
+
}
|
|
1771
|
+
deps.tui.requestRender();
|
|
1772
|
+
};
|
|
1773
|
+
selector.onCancel = () => {
|
|
1774
|
+
deps.closeOverlay();
|
|
1775
|
+
deps.chatLog.addSystem("local shell: cancelled");
|
|
1776
|
+
deps.tui.requestRender();
|
|
1777
|
+
resolve(false);
|
|
1778
|
+
};
|
|
1779
|
+
deps.openOverlay(selector);
|
|
1780
|
+
deps.tui.requestRender();
|
|
1781
|
+
});
|
|
1782
|
+
};
|
|
1783
|
+
const runLocalShellLine = async (line) => {
|
|
1784
|
+
const cmd = line.slice(1);
|
|
1785
|
+
if (cmd === "") return;
|
|
1786
|
+
if (localExecAsked && !localExecAllowed) {
|
|
1787
|
+
deps.chatLog.addSystem("local shell: not enabled for this session");
|
|
1788
|
+
deps.tui.requestRender();
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
if (!await ensureLocalExecAllowed()) return;
|
|
1792
|
+
deps.chatLog.addSystem(`[local] $ ${cmd}`);
|
|
1793
|
+
deps.tui.requestRender();
|
|
1794
|
+
await new Promise((resolve) => {
|
|
1795
|
+
const child = spawnCommand(cmd, {
|
|
1796
|
+
shell: true,
|
|
1797
|
+
cwd: getCwd(),
|
|
1798
|
+
env
|
|
1799
|
+
});
|
|
1800
|
+
let stdout = "";
|
|
1801
|
+
let stderr = "";
|
|
1802
|
+
child.stdout.on("data", (buf) => {
|
|
1803
|
+
stdout += buf.toString("utf8");
|
|
1804
|
+
});
|
|
1805
|
+
child.stderr.on("data", (buf) => {
|
|
1806
|
+
stderr += buf.toString("utf8");
|
|
1807
|
+
});
|
|
1808
|
+
child.on("close", (code, signal) => {
|
|
1809
|
+
const combined = (stdout + (stderr ? (stdout ? "\n" : "") + stderr : "")).slice(0, maxChars).trimEnd();
|
|
1810
|
+
if (combined) for (const line of combined.split("\n")) deps.chatLog.addSystem(`[local] ${line}`);
|
|
1811
|
+
deps.chatLog.addSystem(`[local] exit ${code ?? "?"}${signal ? ` (signal ${String(signal)})` : ""}`);
|
|
1812
|
+
deps.tui.requestRender();
|
|
1813
|
+
resolve();
|
|
1814
|
+
});
|
|
1815
|
+
child.on("error", (err) => {
|
|
1816
|
+
deps.chatLog.addSystem(`[local] error: ${String(err)}`);
|
|
1817
|
+
deps.tui.requestRender();
|
|
1818
|
+
resolve();
|
|
1819
|
+
});
|
|
1820
|
+
});
|
|
1821
|
+
};
|
|
1822
|
+
return { runLocalShellLine };
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
//#endregion
|
|
1826
|
+
//#region src/tui/tui-overlays.ts
|
|
1827
|
+
function createOverlayHandlers(host, fallbackFocus) {
|
|
1828
|
+
const openOverlay = (component) => {
|
|
1829
|
+
host.showOverlay(component);
|
|
1830
|
+
};
|
|
1831
|
+
const closeOverlay = () => {
|
|
1832
|
+
if (host.hasOverlay()) {
|
|
1833
|
+
host.hideOverlay();
|
|
1834
|
+
return;
|
|
1835
|
+
}
|
|
1836
|
+
host.setFocus(fallbackFocus);
|
|
1837
|
+
};
|
|
1838
|
+
return {
|
|
1839
|
+
openOverlay,
|
|
1840
|
+
closeOverlay
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
//#endregion
|
|
1845
|
+
//#region src/tui/tui-session-actions.ts
|
|
1846
|
+
function createSessionActions(context) {
|
|
1847
|
+
const { client, chatLog, tui, opts, state, agentNames, initialSessionInput, initialSessionAgentId, resolveSessionKey, updateHeader, updateFooter, updateAutocompleteProvider, setActivityStatus } = context;
|
|
1848
|
+
let refreshSessionInfoPromise = null;
|
|
1849
|
+
const applyAgentsResult = (result) => {
|
|
1850
|
+
state.agentDefaultId = normalizeAgentId(result.defaultId);
|
|
1851
|
+
state.sessionMainKey = normalizeMainKey(result.mainKey);
|
|
1852
|
+
state.sessionScope = result.scope ?? state.sessionScope;
|
|
1853
|
+
state.agents = result.agents.map((agent) => ({
|
|
1854
|
+
id: normalizeAgentId(agent.id),
|
|
1855
|
+
name: agent.name?.trim() || void 0
|
|
1856
|
+
}));
|
|
1857
|
+
agentNames.clear();
|
|
1858
|
+
for (const agent of state.agents) if (agent.name) agentNames.set(agent.id, agent.name);
|
|
1859
|
+
if (!state.initialSessionApplied) {
|
|
1860
|
+
if (initialSessionAgentId) {
|
|
1861
|
+
if (state.agents.some((agent) => agent.id === initialSessionAgentId)) state.currentAgentId = initialSessionAgentId;
|
|
1862
|
+
} else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
|
|
1863
|
+
const nextSessionKey = resolveSessionKey(initialSessionInput);
|
|
1864
|
+
if (nextSessionKey !== state.currentSessionKey) state.currentSessionKey = nextSessionKey;
|
|
1865
|
+
state.initialSessionApplied = true;
|
|
1866
|
+
} else if (!state.agents.some((agent) => agent.id === state.currentAgentId)) state.currentAgentId = state.agents[0]?.id ?? normalizeAgentId(result.defaultId ?? state.currentAgentId);
|
|
1867
|
+
updateHeader();
|
|
1868
|
+
updateFooter();
|
|
1869
|
+
};
|
|
1870
|
+
const refreshAgents = async () => {
|
|
1871
|
+
try {
|
|
1872
|
+
applyAgentsResult(await client.listAgents());
|
|
1873
|
+
} catch (err) {
|
|
1874
|
+
chatLog.addSystem(`agents list failed: ${String(err)}`);
|
|
1875
|
+
}
|
|
1876
|
+
};
|
|
1877
|
+
const updateAgentFromSessionKey = (key) => {
|
|
1878
|
+
const parsed = parseAgentSessionKey(key);
|
|
1879
|
+
if (!parsed) return;
|
|
1880
|
+
const next = normalizeAgentId(parsed.agentId);
|
|
1881
|
+
if (next !== state.currentAgentId) state.currentAgentId = next;
|
|
1882
|
+
};
|
|
1883
|
+
const refreshSessionInfo = async () => {
|
|
1884
|
+
if (refreshSessionInfoPromise) return refreshSessionInfoPromise;
|
|
1885
|
+
refreshSessionInfoPromise = (async () => {
|
|
1886
|
+
try {
|
|
1887
|
+
const listAgentId = state.currentSessionKey === "global" || state.currentSessionKey === "unknown" ? void 0 : state.currentAgentId;
|
|
1888
|
+
const result = await client.listSessions({
|
|
1889
|
+
includeGlobal: false,
|
|
1890
|
+
includeUnknown: false,
|
|
1891
|
+
agentId: listAgentId
|
|
1892
|
+
});
|
|
1893
|
+
const entry = result.sessions.find((row) => {
|
|
1894
|
+
if (row.key === state.currentSessionKey) return true;
|
|
1895
|
+
return parseAgentSessionKey(row.key)?.rest === state.currentSessionKey;
|
|
1896
|
+
});
|
|
1897
|
+
state.sessionInfo = {
|
|
1898
|
+
thinkingLevel: entry?.thinkingLevel,
|
|
1899
|
+
verboseLevel: entry?.verboseLevel,
|
|
1900
|
+
reasoningLevel: entry?.reasoningLevel,
|
|
1901
|
+
model: entry?.model ?? result.defaults?.model ?? void 0,
|
|
1902
|
+
modelProvider: entry?.modelProvider ?? result.defaults?.modelProvider ?? void 0,
|
|
1903
|
+
contextTokens: entry?.contextTokens ?? result.defaults?.contextTokens,
|
|
1904
|
+
inputTokens: entry?.inputTokens ?? null,
|
|
1905
|
+
outputTokens: entry?.outputTokens ?? null,
|
|
1906
|
+
totalTokens: entry?.totalTokens ?? null,
|
|
1907
|
+
responseUsage: entry?.responseUsage,
|
|
1908
|
+
updatedAt: entry?.updatedAt ?? null,
|
|
1909
|
+
displayName: entry?.displayName
|
|
1910
|
+
};
|
|
1911
|
+
} catch (err) {
|
|
1912
|
+
chatLog.addSystem(`sessions list failed: ${String(err)}`);
|
|
1913
|
+
}
|
|
1914
|
+
updateAutocompleteProvider();
|
|
1915
|
+
updateFooter();
|
|
1916
|
+
tui.requestRender();
|
|
1917
|
+
})();
|
|
1918
|
+
try {
|
|
1919
|
+
await refreshSessionInfoPromise;
|
|
1920
|
+
} finally {
|
|
1921
|
+
refreshSessionInfoPromise = null;
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
const loadHistory = async () => {
|
|
1925
|
+
try {
|
|
1926
|
+
const record = await client.loadHistory({
|
|
1927
|
+
sessionKey: state.currentSessionKey,
|
|
1928
|
+
limit: opts.historyLimit ?? 200
|
|
1929
|
+
});
|
|
1930
|
+
state.currentSessionId = typeof record.sessionId === "string" ? record.sessionId : null;
|
|
1931
|
+
state.sessionInfo.thinkingLevel = record.thinkingLevel ?? state.sessionInfo.thinkingLevel;
|
|
1932
|
+
chatLog.clearAll();
|
|
1933
|
+
chatLog.addSystem(`session ${state.currentSessionKey}`);
|
|
1934
|
+
for (const entry of record.messages ?? []) {
|
|
1935
|
+
if (!entry || typeof entry !== "object") continue;
|
|
1936
|
+
const message = entry;
|
|
1937
|
+
if (isCommandMessage(message)) {
|
|
1938
|
+
const text = extractTextFromMessage(message);
|
|
1939
|
+
if (text) chatLog.addSystem(text);
|
|
1940
|
+
continue;
|
|
1941
|
+
}
|
|
1942
|
+
if (message.role === "user") {
|
|
1943
|
+
const text = extractTextFromMessage(message);
|
|
1944
|
+
if (text) chatLog.addUser(text);
|
|
1945
|
+
continue;
|
|
1946
|
+
}
|
|
1947
|
+
if (message.role === "assistant") {
|
|
1948
|
+
const text = extractTextFromMessage(message, { includeThinking: state.showThinking });
|
|
1949
|
+
if (text) chatLog.finalizeAssistant(text);
|
|
1950
|
+
continue;
|
|
1951
|
+
}
|
|
1952
|
+
if (message.role === "toolResult") {
|
|
1953
|
+
const toolCallId = asString(message.toolCallId, "");
|
|
1954
|
+
const toolName = asString(message.toolName, "tool");
|
|
1955
|
+
chatLog.startTool(toolCallId, toolName, {}).setResult({
|
|
1956
|
+
content: Array.isArray(message.content) ? message.content : [],
|
|
1957
|
+
details: typeof message.details === "object" && message.details ? message.details : void 0
|
|
1958
|
+
}, { isError: Boolean(message.isError) });
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
state.historyLoaded = true;
|
|
1962
|
+
} catch (err) {
|
|
1963
|
+
chatLog.addSystem(`history failed: ${String(err)}`);
|
|
1964
|
+
}
|
|
1965
|
+
await refreshSessionInfo();
|
|
1966
|
+
tui.requestRender();
|
|
1967
|
+
};
|
|
1968
|
+
const setSession = async (rawKey) => {
|
|
1969
|
+
const nextKey = resolveSessionKey(rawKey);
|
|
1970
|
+
updateAgentFromSessionKey(nextKey);
|
|
1971
|
+
state.currentSessionKey = nextKey;
|
|
1972
|
+
state.activeChatRunId = null;
|
|
1973
|
+
state.currentSessionId = null;
|
|
1974
|
+
state.historyLoaded = false;
|
|
1975
|
+
updateHeader();
|
|
1976
|
+
updateFooter();
|
|
1977
|
+
await loadHistory();
|
|
1978
|
+
};
|
|
1979
|
+
const abortActive = async () => {
|
|
1980
|
+
if (!state.activeChatRunId) {
|
|
1981
|
+
chatLog.addSystem("no active run");
|
|
1982
|
+
tui.requestRender();
|
|
1983
|
+
return;
|
|
1984
|
+
}
|
|
1985
|
+
try {
|
|
1986
|
+
await client.abortChat({
|
|
1987
|
+
sessionKey: state.currentSessionKey,
|
|
1988
|
+
runId: state.activeChatRunId
|
|
1989
|
+
});
|
|
1990
|
+
setActivityStatus("aborted");
|
|
1991
|
+
} catch (err) {
|
|
1992
|
+
chatLog.addSystem(`abort failed: ${String(err)}`);
|
|
1993
|
+
setActivityStatus("abort failed");
|
|
1994
|
+
}
|
|
1995
|
+
tui.requestRender();
|
|
1996
|
+
};
|
|
1997
|
+
return {
|
|
1998
|
+
applyAgentsResult,
|
|
1999
|
+
refreshAgents,
|
|
2000
|
+
refreshSessionInfo,
|
|
2001
|
+
loadHistory,
|
|
2002
|
+
setSession,
|
|
2003
|
+
abortActive
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
//#endregion
|
|
2008
|
+
//#region src/tui/tui-waiting.ts
|
|
2009
|
+
const defaultWaitingPhrases = [
|
|
2010
|
+
"flibbertigibbeting",
|
|
2011
|
+
"kerfuffling",
|
|
2012
|
+
"dillydallying",
|
|
2013
|
+
"twiddling thumbs",
|
|
2014
|
+
"noodling",
|
|
2015
|
+
"bamboozling",
|
|
2016
|
+
"moseying",
|
|
2017
|
+
"hobnobbing",
|
|
2018
|
+
"pondering",
|
|
2019
|
+
"conjuring"
|
|
2020
|
+
];
|
|
2021
|
+
function pickWaitingPhrase(tick, phrases = defaultWaitingPhrases) {
|
|
2022
|
+
return phrases[Math.floor(tick / 10) % phrases.length] ?? phrases[0] ?? "waiting";
|
|
2023
|
+
}
|
|
2024
|
+
function shimmerText(theme, text, tick) {
|
|
2025
|
+
const width = 6;
|
|
2026
|
+
const hi = (ch) => theme.bold(theme.accentSoft(ch));
|
|
2027
|
+
const pos = tick % (text.length + width);
|
|
2028
|
+
const start = Math.max(0, pos - width);
|
|
2029
|
+
const end = Math.min(text.length - 1, pos);
|
|
2030
|
+
let out = "";
|
|
2031
|
+
for (let i = 0; i < text.length; i++) {
|
|
2032
|
+
const ch = text[i];
|
|
2033
|
+
out += i >= start && i <= end ? hi(ch) : theme.dim(ch);
|
|
2034
|
+
}
|
|
2035
|
+
return out;
|
|
2036
|
+
}
|
|
2037
|
+
function buildWaitingStatusMessage(params) {
|
|
2038
|
+
const phrase = pickWaitingPhrase(params.tick, params.phrases);
|
|
2039
|
+
return `${shimmerText(params.theme, `${phrase}…`, params.tick)} • ${params.elapsed} | ${params.connectionStatus}`;
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
//#endregion
|
|
2043
|
+
//#region src/tui/tui.ts
|
|
2044
|
+
function createEditorSubmitHandler(params) {
|
|
2045
|
+
return (text) => {
|
|
2046
|
+
const raw = text;
|
|
2047
|
+
const value = raw.trim();
|
|
2048
|
+
params.editor.setText("");
|
|
2049
|
+
if (!value) return;
|
|
2050
|
+
if (raw.startsWith("!") && raw !== "!") {
|
|
2051
|
+
params.editor.addToHistory(raw);
|
|
2052
|
+
params.handleBangLine(raw);
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2055
|
+
params.editor.addToHistory(value);
|
|
2056
|
+
if (value.startsWith("/")) {
|
|
2057
|
+
params.handleCommand(value);
|
|
2058
|
+
return;
|
|
2059
|
+
}
|
|
2060
|
+
params.sendMessage(value);
|
|
2061
|
+
};
|
|
2062
|
+
}
|
|
2063
|
+
async function runTui(opts) {
|
|
2064
|
+
const config = loadConfig();
|
|
2065
|
+
const initialSessionInput = (opts.session ?? "").trim();
|
|
2066
|
+
let sessionScope = config.session?.scope ?? "per-sender";
|
|
2067
|
+
let sessionMainKey = normalizeMainKey(config.session?.mainKey);
|
|
2068
|
+
let agentDefaultId = resolveDefaultAgentId(config);
|
|
2069
|
+
let currentAgentId = agentDefaultId;
|
|
2070
|
+
let agents = [];
|
|
2071
|
+
const agentNames = /* @__PURE__ */ new Map();
|
|
2072
|
+
let currentSessionKey = "";
|
|
2073
|
+
let initialSessionApplied = false;
|
|
2074
|
+
let currentSessionId = null;
|
|
2075
|
+
let activeChatRunId = null;
|
|
2076
|
+
let historyLoaded = false;
|
|
2077
|
+
let isConnected = false;
|
|
2078
|
+
let wasDisconnected = false;
|
|
2079
|
+
let toolsExpanded = false;
|
|
2080
|
+
let showThinking = false;
|
|
2081
|
+
const deliverDefault = opts.deliver ?? false;
|
|
2082
|
+
const autoMessage = opts.message?.trim();
|
|
2083
|
+
let autoMessageSent = false;
|
|
2084
|
+
let sessionInfo = {};
|
|
2085
|
+
let lastCtrlCAt = 0;
|
|
2086
|
+
let activityStatus = "idle";
|
|
2087
|
+
let connectionStatus = "connecting";
|
|
2088
|
+
let statusTimeout = null;
|
|
2089
|
+
let statusTimer = null;
|
|
2090
|
+
let statusStartedAt = null;
|
|
2091
|
+
let lastActivityStatus = activityStatus;
|
|
2092
|
+
const state = {
|
|
2093
|
+
get agentDefaultId() {
|
|
2094
|
+
return agentDefaultId;
|
|
2095
|
+
},
|
|
2096
|
+
set agentDefaultId(value) {
|
|
2097
|
+
agentDefaultId = value;
|
|
2098
|
+
},
|
|
2099
|
+
get sessionMainKey() {
|
|
2100
|
+
return sessionMainKey;
|
|
2101
|
+
},
|
|
2102
|
+
set sessionMainKey(value) {
|
|
2103
|
+
sessionMainKey = value;
|
|
2104
|
+
},
|
|
2105
|
+
get sessionScope() {
|
|
2106
|
+
return sessionScope;
|
|
2107
|
+
},
|
|
2108
|
+
set sessionScope(value) {
|
|
2109
|
+
sessionScope = value;
|
|
2110
|
+
},
|
|
2111
|
+
get agents() {
|
|
2112
|
+
return agents;
|
|
2113
|
+
},
|
|
2114
|
+
set agents(value) {
|
|
2115
|
+
agents = value;
|
|
2116
|
+
},
|
|
2117
|
+
get currentAgentId() {
|
|
2118
|
+
return currentAgentId;
|
|
2119
|
+
},
|
|
2120
|
+
set currentAgentId(value) {
|
|
2121
|
+
currentAgentId = value;
|
|
2122
|
+
},
|
|
2123
|
+
get currentSessionKey() {
|
|
2124
|
+
return currentSessionKey;
|
|
2125
|
+
},
|
|
2126
|
+
set currentSessionKey(value) {
|
|
2127
|
+
currentSessionKey = value;
|
|
2128
|
+
},
|
|
2129
|
+
get currentSessionId() {
|
|
2130
|
+
return currentSessionId;
|
|
2131
|
+
},
|
|
2132
|
+
set currentSessionId(value) {
|
|
2133
|
+
currentSessionId = value;
|
|
2134
|
+
},
|
|
2135
|
+
get activeChatRunId() {
|
|
2136
|
+
return activeChatRunId;
|
|
2137
|
+
},
|
|
2138
|
+
set activeChatRunId(value) {
|
|
2139
|
+
activeChatRunId = value;
|
|
2140
|
+
},
|
|
2141
|
+
get historyLoaded() {
|
|
2142
|
+
return historyLoaded;
|
|
2143
|
+
},
|
|
2144
|
+
set historyLoaded(value) {
|
|
2145
|
+
historyLoaded = value;
|
|
2146
|
+
},
|
|
2147
|
+
get sessionInfo() {
|
|
2148
|
+
return sessionInfo;
|
|
2149
|
+
},
|
|
2150
|
+
set sessionInfo(value) {
|
|
2151
|
+
sessionInfo = value;
|
|
2152
|
+
},
|
|
2153
|
+
get initialSessionApplied() {
|
|
2154
|
+
return initialSessionApplied;
|
|
2155
|
+
},
|
|
2156
|
+
set initialSessionApplied(value) {
|
|
2157
|
+
initialSessionApplied = value;
|
|
2158
|
+
},
|
|
2159
|
+
get isConnected() {
|
|
2160
|
+
return isConnected;
|
|
2161
|
+
},
|
|
2162
|
+
set isConnected(value) {
|
|
2163
|
+
isConnected = value;
|
|
2164
|
+
},
|
|
2165
|
+
get autoMessageSent() {
|
|
2166
|
+
return autoMessageSent;
|
|
2167
|
+
},
|
|
2168
|
+
set autoMessageSent(value) {
|
|
2169
|
+
autoMessageSent = value;
|
|
2170
|
+
},
|
|
2171
|
+
get toolsExpanded() {
|
|
2172
|
+
return toolsExpanded;
|
|
2173
|
+
},
|
|
2174
|
+
set toolsExpanded(value) {
|
|
2175
|
+
toolsExpanded = value;
|
|
2176
|
+
},
|
|
2177
|
+
get showThinking() {
|
|
2178
|
+
return showThinking;
|
|
2179
|
+
},
|
|
2180
|
+
set showThinking(value) {
|
|
2181
|
+
showThinking = value;
|
|
2182
|
+
},
|
|
2183
|
+
get connectionStatus() {
|
|
2184
|
+
return connectionStatus;
|
|
2185
|
+
},
|
|
2186
|
+
set connectionStatus(value) {
|
|
2187
|
+
connectionStatus = value;
|
|
2188
|
+
},
|
|
2189
|
+
get activityStatus() {
|
|
2190
|
+
return activityStatus;
|
|
2191
|
+
},
|
|
2192
|
+
set activityStatus(value) {
|
|
2193
|
+
activityStatus = value;
|
|
2194
|
+
},
|
|
2195
|
+
get statusTimeout() {
|
|
2196
|
+
return statusTimeout;
|
|
2197
|
+
},
|
|
2198
|
+
set statusTimeout(value) {
|
|
2199
|
+
statusTimeout = value;
|
|
2200
|
+
},
|
|
2201
|
+
get lastCtrlCAt() {
|
|
2202
|
+
return lastCtrlCAt;
|
|
2203
|
+
},
|
|
2204
|
+
set lastCtrlCAt(value) {
|
|
2205
|
+
lastCtrlCAt = value;
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2208
|
+
const client = new GatewayChatClient({
|
|
2209
|
+
url: opts.url,
|
|
2210
|
+
token: opts.token,
|
|
2211
|
+
password: opts.password
|
|
2212
|
+
});
|
|
2213
|
+
const tui = new TUI(new ProcessTerminal());
|
|
2214
|
+
const header = new Text("", 1, 0);
|
|
2215
|
+
const statusContainer = new Container();
|
|
2216
|
+
const footer = new Text("", 1, 0);
|
|
2217
|
+
const chatLog = new ChatLog();
|
|
2218
|
+
const editor = new CustomEditor(tui, editorTheme);
|
|
2219
|
+
const root = new Container();
|
|
2220
|
+
root.addChild(header);
|
|
2221
|
+
root.addChild(chatLog);
|
|
2222
|
+
root.addChild(statusContainer);
|
|
2223
|
+
root.addChild(footer);
|
|
2224
|
+
root.addChild(editor);
|
|
2225
|
+
const updateAutocompleteProvider = () => {
|
|
2226
|
+
editor.setAutocompleteProvider(new CombinedAutocompleteProvider(getSlashCommands({
|
|
2227
|
+
cfg: config,
|
|
2228
|
+
provider: sessionInfo.modelProvider,
|
|
2229
|
+
model: sessionInfo.model
|
|
2230
|
+
}), process.cwd()));
|
|
2231
|
+
};
|
|
2232
|
+
tui.addChild(root);
|
|
2233
|
+
tui.setFocus(editor);
|
|
2234
|
+
const formatSessionKey = (key) => {
|
|
2235
|
+
if (key === "global" || key === "unknown") return key;
|
|
2236
|
+
return parseAgentSessionKey(key)?.rest ?? key;
|
|
2237
|
+
};
|
|
2238
|
+
const formatAgentLabel = (id) => {
|
|
2239
|
+
const name = agentNames.get(id);
|
|
2240
|
+
return name ? `${id} (${name})` : id;
|
|
2241
|
+
};
|
|
2242
|
+
const resolveSessionKey = (raw) => {
|
|
2243
|
+
const trimmed = (raw ?? "").trim();
|
|
2244
|
+
if (sessionScope === "global") return "global";
|
|
2245
|
+
if (!trimmed) return buildAgentMainSessionKey({
|
|
2246
|
+
agentId: currentAgentId,
|
|
2247
|
+
mainKey: sessionMainKey
|
|
2248
|
+
});
|
|
2249
|
+
if (trimmed === "global" || trimmed === "unknown") return trimmed;
|
|
2250
|
+
if (trimmed.startsWith("agent:")) return trimmed;
|
|
2251
|
+
return `agent:${currentAgentId}:${trimmed}`;
|
|
2252
|
+
};
|
|
2253
|
+
currentSessionKey = resolveSessionKey(initialSessionInput);
|
|
2254
|
+
const updateHeader = () => {
|
|
2255
|
+
const sessionLabel = formatSessionKey(currentSessionKey);
|
|
2256
|
+
const agentLabel = formatAgentLabel(currentAgentId);
|
|
2257
|
+
header.setText(theme.header(`openclaw tui - ${client.connection.url} - agent ${agentLabel} - session ${sessionLabel}`));
|
|
2258
|
+
};
|
|
2259
|
+
const busyStates = new Set([
|
|
2260
|
+
"sending",
|
|
2261
|
+
"waiting",
|
|
2262
|
+
"streaming",
|
|
2263
|
+
"running"
|
|
2264
|
+
]);
|
|
2265
|
+
let statusText = null;
|
|
2266
|
+
let statusLoader = null;
|
|
2267
|
+
const formatElapsed = (startMs) => {
|
|
2268
|
+
const totalSeconds = Math.max(0, Math.floor((Date.now() - startMs) / 1e3));
|
|
2269
|
+
if (totalSeconds < 60) return `${totalSeconds}s`;
|
|
2270
|
+
return `${Math.floor(totalSeconds / 60)}m ${totalSeconds % 60}s`;
|
|
2271
|
+
};
|
|
2272
|
+
const ensureStatusText = () => {
|
|
2273
|
+
if (statusText) return;
|
|
2274
|
+
statusContainer.clear();
|
|
2275
|
+
statusLoader?.stop();
|
|
2276
|
+
statusLoader = null;
|
|
2277
|
+
statusText = new Text("", 1, 0);
|
|
2278
|
+
statusContainer.addChild(statusText);
|
|
2279
|
+
};
|
|
2280
|
+
const ensureStatusLoader = () => {
|
|
2281
|
+
if (statusLoader) return;
|
|
2282
|
+
statusContainer.clear();
|
|
2283
|
+
statusText = null;
|
|
2284
|
+
statusLoader = new Loader(tui, (spinner) => theme.accent(spinner), (text) => theme.bold(theme.accentSoft(text)), "");
|
|
2285
|
+
statusContainer.addChild(statusLoader);
|
|
2286
|
+
};
|
|
2287
|
+
let waitingTick = 0;
|
|
2288
|
+
let waitingTimer = null;
|
|
2289
|
+
let waitingPhrase = null;
|
|
2290
|
+
const updateBusyStatusMessage = () => {
|
|
2291
|
+
if (!statusLoader || !statusStartedAt) return;
|
|
2292
|
+
const elapsed = formatElapsed(statusStartedAt);
|
|
2293
|
+
if (activityStatus === "waiting") {
|
|
2294
|
+
waitingTick++;
|
|
2295
|
+
statusLoader.setMessage(buildWaitingStatusMessage({
|
|
2296
|
+
theme,
|
|
2297
|
+
tick: waitingTick,
|
|
2298
|
+
elapsed,
|
|
2299
|
+
connectionStatus,
|
|
2300
|
+
phrases: waitingPhrase ? [waitingPhrase] : void 0
|
|
2301
|
+
}));
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2304
|
+
statusLoader.setMessage(`${activityStatus} • ${elapsed} | ${connectionStatus}`);
|
|
2305
|
+
};
|
|
2306
|
+
const startStatusTimer = () => {
|
|
2307
|
+
if (statusTimer) return;
|
|
2308
|
+
statusTimer = setInterval(() => {
|
|
2309
|
+
if (!busyStates.has(activityStatus)) return;
|
|
2310
|
+
updateBusyStatusMessage();
|
|
2311
|
+
}, 1e3);
|
|
2312
|
+
};
|
|
2313
|
+
const stopStatusTimer = () => {
|
|
2314
|
+
if (!statusTimer) return;
|
|
2315
|
+
clearInterval(statusTimer);
|
|
2316
|
+
statusTimer = null;
|
|
2317
|
+
};
|
|
2318
|
+
const startWaitingTimer = () => {
|
|
2319
|
+
if (waitingTimer) return;
|
|
2320
|
+
if (!waitingPhrase) waitingPhrase = defaultWaitingPhrases[Math.floor(Math.random() * defaultWaitingPhrases.length)] ?? defaultWaitingPhrases[0] ?? "waiting";
|
|
2321
|
+
waitingTick = 0;
|
|
2322
|
+
waitingTimer = setInterval(() => {
|
|
2323
|
+
if (activityStatus !== "waiting") return;
|
|
2324
|
+
updateBusyStatusMessage();
|
|
2325
|
+
}, 120);
|
|
2326
|
+
};
|
|
2327
|
+
const stopWaitingTimer = () => {
|
|
2328
|
+
if (!waitingTimer) return;
|
|
2329
|
+
clearInterval(waitingTimer);
|
|
2330
|
+
waitingTimer = null;
|
|
2331
|
+
waitingPhrase = null;
|
|
2332
|
+
};
|
|
2333
|
+
const renderStatus = () => {
|
|
2334
|
+
if (busyStates.has(activityStatus)) {
|
|
2335
|
+
if (!statusStartedAt || lastActivityStatus !== activityStatus) statusStartedAt = Date.now();
|
|
2336
|
+
ensureStatusLoader();
|
|
2337
|
+
if (activityStatus === "waiting") {
|
|
2338
|
+
stopStatusTimer();
|
|
2339
|
+
startWaitingTimer();
|
|
2340
|
+
} else {
|
|
2341
|
+
stopWaitingTimer();
|
|
2342
|
+
startStatusTimer();
|
|
2343
|
+
}
|
|
2344
|
+
updateBusyStatusMessage();
|
|
2345
|
+
} else {
|
|
2346
|
+
statusStartedAt = null;
|
|
2347
|
+
stopStatusTimer();
|
|
2348
|
+
stopWaitingTimer();
|
|
2349
|
+
statusLoader?.stop();
|
|
2350
|
+
statusLoader = null;
|
|
2351
|
+
ensureStatusText();
|
|
2352
|
+
const text = activityStatus ? `${connectionStatus} | ${activityStatus}` : connectionStatus;
|
|
2353
|
+
statusText?.setText(theme.dim(text));
|
|
2354
|
+
}
|
|
2355
|
+
lastActivityStatus = activityStatus;
|
|
2356
|
+
};
|
|
2357
|
+
const setConnectionStatus = (text, ttlMs) => {
|
|
2358
|
+
connectionStatus = text;
|
|
2359
|
+
renderStatus();
|
|
2360
|
+
if (statusTimeout) clearTimeout(statusTimeout);
|
|
2361
|
+
if (ttlMs && ttlMs > 0) statusTimeout = setTimeout(() => {
|
|
2362
|
+
connectionStatus = isConnected ? "connected" : "disconnected";
|
|
2363
|
+
renderStatus();
|
|
2364
|
+
}, ttlMs);
|
|
2365
|
+
};
|
|
2366
|
+
const setActivityStatus = (text) => {
|
|
2367
|
+
activityStatus = text;
|
|
2368
|
+
renderStatus();
|
|
2369
|
+
};
|
|
2370
|
+
const updateFooter = () => {
|
|
2371
|
+
const sessionKeyLabel = formatSessionKey(currentSessionKey);
|
|
2372
|
+
const sessionLabel = sessionInfo.displayName ? `${sessionKeyLabel} (${sessionInfo.displayName})` : sessionKeyLabel;
|
|
2373
|
+
const agentLabel = formatAgentLabel(currentAgentId);
|
|
2374
|
+
const modelLabel = sessionInfo.model ? sessionInfo.modelProvider ? `${sessionInfo.modelProvider}/${sessionInfo.model}` : sessionInfo.model : "unknown";
|
|
2375
|
+
const tokens = formatTokens(sessionInfo.totalTokens ?? null, sessionInfo.contextTokens ?? null);
|
|
2376
|
+
const think = sessionInfo.thinkingLevel ?? "off";
|
|
2377
|
+
const verbose = sessionInfo.verboseLevel ?? "off";
|
|
2378
|
+
const reasoning = sessionInfo.reasoningLevel ?? "off";
|
|
2379
|
+
const reasoningLabel = reasoning === "on" ? "reasoning" : reasoning === "stream" ? "reasoning:stream" : null;
|
|
2380
|
+
const footerParts = [
|
|
2381
|
+
`agent ${agentLabel}`,
|
|
2382
|
+
`session ${sessionLabel}`,
|
|
2383
|
+
modelLabel,
|
|
2384
|
+
think !== "off" ? `think ${think}` : null,
|
|
2385
|
+
verbose !== "off" ? `verbose ${verbose}` : null,
|
|
2386
|
+
reasoningLabel,
|
|
2387
|
+
tokens
|
|
2388
|
+
].filter(Boolean);
|
|
2389
|
+
footer.setText(theme.dim(footerParts.join(" | ")));
|
|
2390
|
+
};
|
|
2391
|
+
const { openOverlay, closeOverlay } = createOverlayHandlers(tui, editor);
|
|
2392
|
+
const { refreshAgents, refreshSessionInfo, loadHistory, setSession, abortActive } = createSessionActions({
|
|
2393
|
+
client,
|
|
2394
|
+
chatLog,
|
|
2395
|
+
tui,
|
|
2396
|
+
opts,
|
|
2397
|
+
state,
|
|
2398
|
+
agentNames,
|
|
2399
|
+
initialSessionInput,
|
|
2400
|
+
initialSessionAgentId: (() => {
|
|
2401
|
+
if (!initialSessionInput) return null;
|
|
2402
|
+
const parsed = parseAgentSessionKey(initialSessionInput);
|
|
2403
|
+
return parsed ? normalizeAgentId(parsed.agentId) : null;
|
|
2404
|
+
})(),
|
|
2405
|
+
resolveSessionKey,
|
|
2406
|
+
updateHeader,
|
|
2407
|
+
updateFooter,
|
|
2408
|
+
updateAutocompleteProvider,
|
|
2409
|
+
setActivityStatus
|
|
2410
|
+
});
|
|
2411
|
+
const { handleChatEvent, handleAgentEvent } = createEventHandlers({
|
|
2412
|
+
chatLog,
|
|
2413
|
+
tui,
|
|
2414
|
+
state,
|
|
2415
|
+
setActivityStatus,
|
|
2416
|
+
refreshSessionInfo
|
|
2417
|
+
});
|
|
2418
|
+
const { handleCommand, sendMessage, openModelSelector, openAgentSelector, openSessionSelector } = createCommandHandlers({
|
|
2419
|
+
client,
|
|
2420
|
+
chatLog,
|
|
2421
|
+
tui,
|
|
2422
|
+
opts,
|
|
2423
|
+
state,
|
|
2424
|
+
deliverDefault,
|
|
2425
|
+
openOverlay,
|
|
2426
|
+
closeOverlay,
|
|
2427
|
+
refreshSessionInfo,
|
|
2428
|
+
loadHistory,
|
|
2429
|
+
setSession,
|
|
2430
|
+
refreshAgents,
|
|
2431
|
+
abortActive,
|
|
2432
|
+
setActivityStatus,
|
|
2433
|
+
formatSessionKey
|
|
2434
|
+
});
|
|
2435
|
+
const { runLocalShellLine } = createLocalShellRunner({
|
|
2436
|
+
chatLog,
|
|
2437
|
+
tui,
|
|
2438
|
+
openOverlay,
|
|
2439
|
+
closeOverlay
|
|
2440
|
+
});
|
|
2441
|
+
updateAutocompleteProvider();
|
|
2442
|
+
editor.onSubmit = createEditorSubmitHandler({
|
|
2443
|
+
editor,
|
|
2444
|
+
handleCommand,
|
|
2445
|
+
sendMessage,
|
|
2446
|
+
handleBangLine: runLocalShellLine
|
|
2447
|
+
});
|
|
2448
|
+
editor.onEscape = () => {
|
|
2449
|
+
abortActive();
|
|
2450
|
+
};
|
|
2451
|
+
editor.onCtrlC = () => {
|
|
2452
|
+
const now = Date.now();
|
|
2453
|
+
if (editor.getText().trim().length > 0) {
|
|
2454
|
+
editor.setText("");
|
|
2455
|
+
setActivityStatus("cleared input");
|
|
2456
|
+
tui.requestRender();
|
|
2457
|
+
return;
|
|
2458
|
+
}
|
|
2459
|
+
if (now - lastCtrlCAt < 1e3) {
|
|
2460
|
+
client.stop();
|
|
2461
|
+
tui.stop();
|
|
2462
|
+
process.exit(0);
|
|
2463
|
+
}
|
|
2464
|
+
lastCtrlCAt = now;
|
|
2465
|
+
setActivityStatus("press ctrl+c again to exit");
|
|
2466
|
+
tui.requestRender();
|
|
2467
|
+
};
|
|
2468
|
+
editor.onCtrlD = () => {
|
|
2469
|
+
client.stop();
|
|
2470
|
+
tui.stop();
|
|
2471
|
+
process.exit(0);
|
|
2472
|
+
};
|
|
2473
|
+
editor.onCtrlO = () => {
|
|
2474
|
+
toolsExpanded = !toolsExpanded;
|
|
2475
|
+
chatLog.setToolsExpanded(toolsExpanded);
|
|
2476
|
+
setActivityStatus(toolsExpanded ? "tools expanded" : "tools collapsed");
|
|
2477
|
+
tui.requestRender();
|
|
2478
|
+
};
|
|
2479
|
+
editor.onCtrlL = () => {
|
|
2480
|
+
openModelSelector();
|
|
2481
|
+
};
|
|
2482
|
+
editor.onCtrlG = () => {
|
|
2483
|
+
openAgentSelector();
|
|
2484
|
+
};
|
|
2485
|
+
editor.onCtrlP = () => {
|
|
2486
|
+
openSessionSelector();
|
|
2487
|
+
};
|
|
2488
|
+
editor.onCtrlT = () => {
|
|
2489
|
+
showThinking = !showThinking;
|
|
2490
|
+
loadHistory();
|
|
2491
|
+
};
|
|
2492
|
+
client.onEvent = (evt) => {
|
|
2493
|
+
if (evt.event === "chat") handleChatEvent(evt.payload);
|
|
2494
|
+
if (evt.event === "agent") handleAgentEvent(evt.payload);
|
|
2495
|
+
};
|
|
2496
|
+
client.onConnected = () => {
|
|
2497
|
+
isConnected = true;
|
|
2498
|
+
const reconnected = wasDisconnected;
|
|
2499
|
+
wasDisconnected = false;
|
|
2500
|
+
setConnectionStatus("connected");
|
|
2501
|
+
(async () => {
|
|
2502
|
+
await refreshAgents();
|
|
2503
|
+
updateHeader();
|
|
2504
|
+
await loadHistory();
|
|
2505
|
+
setConnectionStatus(reconnected ? "gateway reconnected" : "gateway connected", 4e3);
|
|
2506
|
+
tui.requestRender();
|
|
2507
|
+
if (!autoMessageSent && autoMessage) {
|
|
2508
|
+
autoMessageSent = true;
|
|
2509
|
+
await sendMessage(autoMessage);
|
|
2510
|
+
}
|
|
2511
|
+
updateFooter();
|
|
2512
|
+
tui.requestRender();
|
|
2513
|
+
})();
|
|
2514
|
+
};
|
|
2515
|
+
client.onDisconnected = (reason) => {
|
|
2516
|
+
isConnected = false;
|
|
2517
|
+
wasDisconnected = true;
|
|
2518
|
+
historyLoaded = false;
|
|
2519
|
+
setConnectionStatus(`gateway disconnected: ${reason?.trim() ? reason.trim() : "closed"}`, 5e3);
|
|
2520
|
+
setActivityStatus("idle");
|
|
2521
|
+
updateFooter();
|
|
2522
|
+
tui.requestRender();
|
|
2523
|
+
};
|
|
2524
|
+
client.onGap = (info) => {
|
|
2525
|
+
setConnectionStatus(`event gap: expected ${info.expected}, got ${info.received}`, 5e3);
|
|
2526
|
+
tui.requestRender();
|
|
2527
|
+
};
|
|
2528
|
+
updateHeader();
|
|
2529
|
+
setConnectionStatus("connecting");
|
|
2530
|
+
updateFooter();
|
|
2531
|
+
tui.start();
|
|
2532
|
+
client.start();
|
|
2533
|
+
await new Promise((resolve) => {
|
|
2534
|
+
const finish = () => resolve();
|
|
2535
|
+
process.once("exit", finish);
|
|
2536
|
+
process.once("SIGINT", finish);
|
|
2537
|
+
process.once("SIGTERM", finish);
|
|
2538
|
+
});
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
//#endregion
|
|
2542
|
+
export { runTui as t };
|