remoteclaw 0.1.0-next.87fb2cd → 0.1.0-next.900e1cc
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/README.md +9 -7
- package/dist/accounts-Aqbb2_Fn.js +270 -0
- package/dist/accounts-CYi-JUU1.js +272 -0
- package/dist/accounts-CvHzFyp1.js +36 -0
- package/dist/accounts-D3fAPVzU.js +36 -0
- package/dist/accounts-DZmv4bXS.js +47 -0
- package/dist/accounts-Dde0z8df.js +32 -0
- package/dist/accounts-yC-Ql9rZ.js +47 -0
- package/dist/ack-reactions-D0rHiWIj.js +446 -0
- package/dist/ack-reactions-FeaFDjTY.js +446 -0
- package/dist/acp-cli-CE4tzu4O.js +1324 -0
- package/dist/acp-cli-_cks_Lvs.js +1318 -0
- package/dist/active-listener-DKYgax8D.js +37 -0
- package/dist/active-listener-K-gHEsyV.js +37 -0
- package/dist/agent-ChcyT80V.js +704 -0
- package/dist/agent-Cno0E2vO.js +703 -0
- package/dist/agent-helpers-Bzz_tiPK.js +400 -0
- package/dist/agent-helpers-D7NhvM9Z.js +400 -0
- package/dist/agent-scope-BrDeaWWf.js +116 -0
- package/dist/agent-scope-CJW7vnF8.js +114 -0
- package/dist/agents-CB6qRJ_-.js +760 -0
- package/dist/agents.config-Dg9ZQl-w.js +116 -0
- package/dist/agents.config-THRuzfs5.js +116 -0
- package/dist/audio-BZvgJdlv.js +43 -0
- package/dist/audio-preflight-CSxDYOk4.js +69 -0
- package/dist/audio-preflight-jt9fs20r.js +64 -0
- package/dist/audit-DN4K5QzN.js +3149 -0
- package/dist/audit-DQft5ak_.js +3149 -0
- package/dist/auth-BYtRHj--.js +448 -0
- package/dist/auth-CfNgYSQF.js +180 -0
- package/dist/auth-DQBj_DA7.js +448 -0
- package/dist/auth-EwcWsPDt.js +181 -0
- package/dist/banner-DSXqH9zp.js +294 -0
- package/dist/binaries-DPlY0cvi.js +13 -0
- package/dist/bindings-Cr-mXPiq.js +69 -0
- package/dist/bindings-Dr0bGRst.js +69 -0
- package/dist/bonjour-discovery-BKHQWWQn.js +378 -0
- package/dist/bonjour-discovery-D4g8uh38.js +378 -0
- package/dist/boot/handler.js +31 -58
- package/dist/browser-cli-BMGShNyH.js +1689 -0
- package/dist/browser-cli-D1CuRU5T.js +1694 -0
- package/dist/build-info.json +3 -3
- package/dist/call-DLhrOAO5.js +2827 -0
- package/dist/call-OUZMy2rk.js +2826 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/catalog-CMicVL2I.js +185 -0
- package/dist/catalog-CTjf0roq.js +185 -0
- package/dist/channel-account-context-5hI72gYX.js +550 -0
- package/dist/channel-account-context-rFlv9fcH.js +550 -0
- package/dist/channel-activity-C1EIGNu1.js +94 -0
- package/dist/channel-activity-CEM5YJQs.js +94 -0
- package/dist/channel-activity-hL4KZrCz.js +292 -0
- package/dist/channel-options-BjzJIaz2.js +33 -0
- package/dist/channel-options-WnbOqY6C.js +32 -0
- package/dist/channel-selection-ByShtuhp.js +51 -0
- package/dist/channel-selection-DRNp47md.js +51 -0
- package/dist/channel-web-BOTo8rxq.js +2136 -0
- package/dist/channel-web-ByzL55Dq.js +2134 -0
- package/dist/channels-cli-C0cQD-2U.js +1428 -0
- package/dist/channels-cli-DxKQXFhk.js +1423 -0
- package/dist/channels-status-issues-C-aMtk-n.js +18 -0
- package/dist/channels-status-issues-Pz2omjVp.js +18 -0
- package/dist/chat-envelope-CQkxqiAp.js +248 -0
- package/dist/chat-envelope-CY1yvCc-.js +248 -0
- package/dist/chrome-DDFOlPEf.js +1733 -0
- package/dist/chrome-DNikl4VQ.js +1732 -0
- package/dist/chunk-B7Qk7ACV.js +341 -0
- package/dist/chunk-C2vxqDKb.js +341 -0
- package/dist/clack-prompter-DxWF9EMV.js +122 -0
- package/dist/clack-prompter-UsUyNqRE.js +121 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-CkLlqB_E.js +127 -0
- package/dist/cli-DhG9D-Md.js +132 -0
- package/dist/clipboard-DrMbwy6W.js +31 -0
- package/dist/clipboard-DuI4jJgy.js +31 -0
- package/dist/command-format-5Mm4OX03.js +32 -0
- package/dist/command-format-LFmgWzKJ.js +18 -0
- package/dist/command-logger/handler.js +1 -1
- package/dist/command-registry-CgsvscuN.js +215 -0
- package/dist/commands-BSutwoQ9.js +41 -0
- package/dist/commands-CuX98AIv.js +41 -0
- package/dist/commands-registry-D8LoaUeU.js +892 -0
- package/dist/commands-registry-datKw4NJ.js +891 -0
- package/dist/common-0pVkAEMe.js +156 -0
- package/dist/common-nSRorWd3.js +156 -0
- package/dist/completion-cli-B7a95QTn.js +452 -0
- package/dist/completion-cli-niJGarCK.js +452 -0
- package/dist/config-CSkWl_q0.js +4225 -0
- package/dist/config-Z5vhysno.js +4223 -0
- package/dist/config-cli-CJppTZyQ.js +243 -0
- package/dist/config-cli-ChAgnw6Y.js +248 -0
- package/dist/config-guard-D2pPfuWT.js +75 -0
- package/dist/config-guard-DSMdtqh5.js +99 -0
- package/dist/config-validation-B_f7GMXB.js +18 -0
- package/dist/config-validation-Bgrd2M7q.js +18 -0
- package/dist/configure-CDzY1plT.js +891 -0
- package/dist/configure-DSkm6E6G.js +889 -0
- package/dist/constants-DNKY4Ei3.js +70 -0
- package/dist/constants-QiF_zDC2.js +70 -0
- package/dist/control-auth-ByLWpGmj.js +397 -0
- package/dist/control-auth-CMgYC6bI.js +397 -0
- package/dist/control-ui/assets/index-CuY3pfh1.js +7716 -0
- package/dist/control-ui/assets/index-CuY3pfh1.js.map +1 -0
- package/dist/control-ui/assets/index-D_fjkN3g.css +1 -0
- package/dist/control-ui/index.html +2 -2
- package/dist/control-ui-assets-Be7wYtPV.js +186 -0
- package/dist/control-ui-assets-x-FU54VZ.js +186 -0
- package/dist/conversation-label-CDH4rKMG.js +36 -0
- package/dist/conversation-label-tLwAlqLf.js +36 -0
- package/dist/cron-cli-BGvauKOQ.js +497 -0
- package/dist/cron-cli-UdG8AdsF.js +492 -0
- package/dist/daemon-cli-KNMfdVj-.js +1197 -0
- package/dist/daemon-cli-SZBvZblt.js +1199 -0
- package/dist/daemon-cli.js +42 -87
- package/dist/daemon-install-BTH9Hr-r.js +56 -0
- package/dist/daemon-install-CnUT0dtr.js +61 -0
- package/dist/daemon-install-helpers-C3AdCemv.js +463 -0
- package/dist/daemon-install-helpers-DsBl9bBo.js +463 -0
- package/dist/deliver-CiN6VwcX.js +481 -0
- package/dist/deliver-D07D18kt.js +481 -0
- package/dist/delivery-queue-CZOATijD.js +244 -0
- package/dist/devices-cli-COmVGO94.js +323 -0
- package/dist/devices-cli-c9Wz_pzF.js +318 -0
- package/dist/diagnostics-Bwm27ePU.js +46 -0
- package/dist/diagnostics-CIPDL1bH.js +46 -0
- package/dist/directory-cli-CV8H71eb.js +224 -0
- package/dist/directory-cli-Ck10mXCz.js +219 -0
- package/dist/dm-policy-shared-CUJow99p.js +22 -0
- package/dist/dm-policy-shared-cQeANZBI.js +22 -0
- package/dist/dns-cli-CRoAvkaQ.js +199 -0
- package/dist/dns-cli-U8TKnutF.js +204 -0
- package/dist/dock-CVCmU_Yv.js +929 -0
- package/dist/dock-Cj4PKiUh.js +928 -0
- package/dist/doctor-completion-CdevBv2E.js +92 -0
- package/dist/doctor-completion-inA4vFeO.js +92 -0
- package/dist/doctor-config-flow-B89ZE4Bk.js +1935 -0
- package/dist/doctor-config-flow-iPzjMVUg.js +1934 -0
- package/dist/enable-CqdyoDNA.js +59 -0
- package/dist/enable-DpHVKtoJ.js +59 -0
- package/dist/entry.js +1 -3
- package/dist/env-DUb5GiQe.js +60 -0
- package/dist/env-vars-CDr9IXFl.js +43 -0
- package/dist/env-vars-CLX_DBNR.js +43 -0
- package/dist/errors-24e316-U.js +35 -0
- package/dist/errors-CgC58q_F.js +35 -0
- package/dist/exec-D7Bp9Kzi.js +164 -0
- package/dist/exec-DLgyrvcf.js +164 -0
- package/dist/export-html/template.css +0 -36
- package/dist/export-html/template.js +1 -32
- package/dist/extensionAPI.js +1047 -134
- package/dist/fetch-CYi6j9LI.js +67 -0
- package/dist/fetch-Cw0TofAa.js +67 -0
- package/dist/file-lock-CkrYG1r7.js +107 -0
- package/dist/file-lock-DFd595E7.js +107 -0
- package/dist/fs-safe-Du75CIw7.js +98 -0
- package/dist/gateway-cli-CXtNIS0I.js +23734 -0
- package/dist/gateway-cli-CpwHWzY9.js +23739 -0
- package/dist/gateway-rpc-C3ziRxqz.js +28 -0
- package/dist/gateway-rpc-R1PZJva3.js +28 -0
- package/dist/gmail-setup-utils-CUTCdGWa.js +423 -0
- package/dist/gmail-setup-utils-uqZ7m5TH.js +422 -0
- package/dist/health-DwdaafZg.js +1417 -0
- package/dist/health-k9Uyail6.js +1414 -0
- package/dist/heartbeat-visibility-BIl8Riqu.js +125 -0
- package/dist/heartbeat-visibility-BLSzfpF1.js +125 -0
- package/dist/helpers-BPOeGmd1.js +10 -0
- package/dist/hook-runner-global-DVKhou29.js +527 -0
- package/dist/hooks-cli-BRfeaDRR.js +1219 -0
- package/dist/hooks-cli-C_MV_mgF.js +1224 -0
- package/dist/image-ops-Brp1SxLh.js +354 -0
- package/dist/image-ops-kUTMt_X-.js +354 -0
- package/dist/import-BOEhw_un.js +601 -0
- package/dist/import-sFDcR1JL.js +603 -0
- package/dist/inbound-context-BtA228jl.js +68 -0
- package/dist/inbound-context-CXKhKQz4.js +68 -0
- package/dist/inbound-path-policy-BurOAu44.js +90 -0
- package/dist/inbound-path-policy-Bv1SSBX0.js +90 -0
- package/dist/index.js +104 -102
- package/dist/inspect-BiW5KWS-.js +559 -0
- package/dist/inspect-DXr8ki5k.js +559 -0
- package/dist/installs-C83NIvWN.js +325 -0
- package/dist/installs-Cjh7Aon0.js +325 -0
- package/dist/ipv4-D1oXJaNu.js +46 -0
- package/dist/ipv4-D83xJ7X5.js +46 -0
- package/dist/ir-DSRvbFiq.js +940 -0
- package/dist/json-files-DW71C3QC.js +46 -0
- package/dist/loader-BJfGTU_k.js +22401 -0
- package/dist/loader-DQg3uo_2.js +22404 -0
- package/dist/local-roots-09zAPZxt.js +314 -0
- package/dist/local-roots-CJVCfYzc.js +313 -0
- package/dist/logger-ANaZk_PW.js +49 -0
- package/dist/login-BASSFCd8.js +61 -0
- package/dist/login-Diwrffhg.js +62 -0
- package/dist/login-qr-D62uNqK8.js +324 -0
- package/dist/login-qr-DMz0a5fd.js +329 -0
- package/dist/logs-cli-DDQs2cBR.js +240 -0
- package/dist/logs-cli-DOfyh2Yi.js +235 -0
- package/dist/markdown-tables--ARiu9Y1.js +29 -0
- package/dist/markdown-tables-CMPFjRFj.js +29 -0
- package/dist/media-DyXncdbb.js +940 -0
- package/dist/media-DyiZapYY.js +10452 -0
- package/dist/message-action-names-BnfElqpi.js +2521 -0
- package/dist/message-action-names-C_TV9lyY.js +2521 -0
- package/dist/message-channel-DF4I2vOK.js +91 -0
- package/dist/net-B7tLlwbU.js +225 -0
- package/dist/net-DE2kzvsY.js +225 -0
- package/dist/node-cli-BcYDUwDf.js +24 -0
- package/dist/nodes-cli-BOmTbFgD.js +1345 -0
- package/dist/nodes-cli-hqGTA4OO.js +1350 -0
- package/dist/nodes-screen-BbGQN2wt.js +250 -0
- package/dist/nodes-screen-id-Bb6Id.js +250 -0
- package/dist/note-BzfrQZI0.js +92 -0
- package/dist/note-xaYg6Lfa.js +92 -0
- package/dist/npm-registry-spec-V7j5Uas_.js +786 -0
- package/dist/npm-registry-spec-ja6-spul.js +786 -0
- package/dist/npm-resolution-DE1W1t6v.js +86 -0
- package/dist/npm-resolution-XRDZ0053.js +86 -0
- package/dist/onboard-B7x8JCXG.js +438 -0
- package/dist/onboard-BYTgC_5s.js +436 -0
- package/dist/onboard-channels-35YMU2Pp.js +2548 -0
- package/dist/onboard-channels-DzChgDkT.js +2547 -0
- package/dist/onboard-config-BeFaSbOY.js +39 -0
- package/dist/onboard-config-x054Cod3.js +39 -0
- package/dist/onboard-helpers-9_TBwBli.js +364 -0
- package/dist/onboard-helpers-DzoT97o-.js +363 -0
- package/dist/onboard-remote-BFU2wKgI.js +127 -0
- package/dist/onboard-remote-D2J_cv5n.js +127 -0
- package/dist/onboarding-BUG7enEb.js +586 -0
- package/dist/onboarding-ChOnGb8T.js +588 -0
- package/dist/onboarding.finalize-CNpdhW5E.js +403 -0
- package/dist/onboarding.finalize-U_eCxI9a.js +400 -0
- package/dist/onboarding.gateway-config-BaVZugTI.js +193 -0
- package/dist/onboarding.gateway-config-Bs6e-5-h.js +200 -0
- package/dist/outbound-6vgCW1Bp.js +220 -0
- package/dist/outbound-B34AeKpd.js +221 -0
- package/dist/outbound-attachment-9eMFwFrm.js +18 -0
- package/dist/outbound-attachment-D2QJXHUK.js +18 -0
- package/dist/outbound-attachment-e72S5Wk3.js +18 -0
- package/dist/pairing-cli-DDYb9ulI.js +129 -0
- package/dist/pairing-cli-KUiTqdZ_.js +124 -0
- package/dist/pairing-labels-B3ymC59s.js +9 -0
- package/dist/pairing-labels-_ahX1Iwx.js +9 -0
- package/dist/pairing-store-DAdsH-_X.js +459 -0
- package/dist/pairing-store-hEFX87_3.js +460 -0
- package/dist/path-env-DvGXF1PK.js +89 -0
- package/dist/path-env-nhpk9bHU.js +89 -0
- package/dist/path-safety-Bm08v8w8.js +14 -0
- package/dist/plugin-auto-enable-B-ZbQJGk.js +301 -0
- package/dist/plugin-auto-enable-BlO7PQGZ.js +302 -0
- package/dist/plugin-registry-BVJ8V2ZN.js +33 -0
- package/dist/plugin-registry-Bto_z6NU.js +33 -0
- package/dist/plugin-sdk/agents/agent-helpers.d.ts +0 -1
- package/dist/plugin-sdk/agents/agent-scope.d.ts +10 -0
- package/dist/plugin-sdk/agents/agent-types.d.ts +1 -6
- package/dist/plugin-sdk/agents/agent-utils.d.ts +0 -14
- package/dist/plugin-sdk/agents/provider-utils.d.ts +0 -1
- package/dist/plugin-sdk/agents/subagent-spawn.d.ts +0 -1
- package/dist/plugin-sdk/agents/tools/sessions-helpers.d.ts +0 -1
- package/dist/plugin-sdk/auth/constants.d.ts +15 -0
- package/dist/plugin-sdk/auth/display.d.ts +7 -0
- package/dist/plugin-sdk/auth/doctor.d.ts +8 -0
- package/dist/plugin-sdk/auth/env-injection.d.ts +40 -0
- package/dist/plugin-sdk/auth/index.d.ts +8 -0
- package/dist/plugin-sdk/auth/oauth.d.ts +13 -0
- package/dist/plugin-sdk/auth/paths.d.ts +3 -0
- package/dist/plugin-sdk/auth/profiles.d.ts +10 -0
- package/dist/plugin-sdk/auth/provider-auth.d.ts +38 -0
- package/dist/plugin-sdk/auth/session-override.d.ts +17 -0
- package/dist/plugin-sdk/auth/store.d.ts +7 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +0 -1
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-utils.d.ts +0 -2
- package/dist/plugin-sdk/auto-reply/reply/commands-status.d.ts +1 -4
- package/dist/plugin-sdk/auto-reply/reply/commands-types.d.ts +1 -4
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.auth.d.ts +1 -2
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.levels.d.ts +1 -7
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.params.d.ts +1 -4
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.parse.d.ts +1 -7
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.persist.d.ts +0 -1
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.shared.d.ts +1 -4
- package/dist/plugin-sdk/auto-reply/reply/directives.d.ts +3 -15
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-apply.d.ts +0 -1
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives.d.ts +1 -6
- package/dist/plugin-sdk/auto-reply/reply/get-reply-inline-actions.d.ts +1 -5
- package/dist/plugin-sdk/auto-reply/reply/get-reply-run.d.ts +1 -5
- package/dist/plugin-sdk/auto-reply/reply/queue/types.d.ts +1 -3
- package/dist/plugin-sdk/auto-reply/reply/response-prefix-template.d.ts +4 -6
- package/dist/plugin-sdk/auto-reply/reply/session-run-accounting.d.ts +0 -7
- package/dist/plugin-sdk/auto-reply/reply/session-updates.d.ts +0 -10
- package/dist/plugin-sdk/auto-reply/reply.d.ts +1 -1
- package/dist/plugin-sdk/auto-reply/status.d.ts +2 -6
- package/dist/plugin-sdk/auto-reply/thinking.d.ts +0 -11
- package/dist/plugin-sdk/auto-reply/types.d.ts +1 -2
- package/dist/plugin-sdk/commands/agent/session.d.ts +1 -2
- package/dist/plugin-sdk/config/defaults.d.ts +0 -1
- package/dist/plugin-sdk/config/sessions/types.d.ts +0 -8
- package/dist/plugin-sdk/config/types.agent-defaults.d.ts +28 -112
- package/dist/plugin-sdk/config/types.agents.d.ts +8 -0
- package/dist/plugin-sdk/config/types.messages.d.ts +1 -2
- package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +9 -66
- package/dist/plugin-sdk/config/zod-schema.agent-runtime.d.ts +5 -13
- package/dist/plugin-sdk/config/zod-schema.agents.d.ts +12 -76
- package/dist/plugin-sdk/config/zod-schema.d.ts +12 -76
- package/dist/plugin-sdk/daemon/constants.d.ts +2 -2
- package/dist/plugin-sdk/gateway/protocol/index.d.ts +1 -3
- package/dist/plugin-sdk/gateway/protocol/schema/sessions.d.ts +0 -2
- package/dist/plugin-sdk/gateway/session-utils.types.d.ts +0 -2
- package/dist/plugin-sdk/index.js +97 -124
- package/dist/plugin-sdk/infra/agent-events.d.ts +1 -1
- package/dist/plugin-sdk/infra/provider-usage.auth.d.ts +0 -1
- package/dist/plugin-sdk/infra/provider-usage.load.d.ts +0 -1
- package/dist/plugin-sdk/middleware/auth-key-retry.d.ts +31 -0
- package/dist/plugin-sdk/middleware/channel-bridge.d.ts +4 -0
- package/dist/plugin-sdk/middleware/error-classifier.d.ts +5 -0
- package/dist/plugin-sdk/middleware/media-resolver.d.ts +12 -0
- package/dist/plugin-sdk/middleware/runtime-factory.d.ts +42 -0
- package/dist/plugin-sdk/middleware/runtimes/codex.d.ts +1 -0
- package/dist/plugin-sdk/middleware/runtimes/opencode.d.ts +1 -0
- package/dist/plugin-sdk/middleware/types.d.ts +41 -1
- package/dist/plugin-sdk/plugins/types.d.ts +1 -1
- package/dist/plugins-7B167wIj.js +453 -0
- package/dist/plugins-C3RTS5Jy.js +455 -0
- package/dist/plugins-cli-CHbhuxR7.js +795 -0
- package/dist/plugins-cli-GUPk8IuX.js +800 -0
- package/dist/ports-B_lYgIyN.js +316 -0
- package/dist/ports-BrGekhfF.js +96 -0
- package/dist/ports-CU98RMVJ.js +96 -0
- package/dist/ports-C_5EshUM.js +370 -0
- package/dist/program-D8r3mFrH.js +246 -0
- package/dist/program-context-CSlz7kzp.js +474 -0
- package/dist/progress-gsZJl831.js +124 -0
- package/dist/prompt-select-styled-CuS4G72n.js +1650 -0
- package/dist/prompt-select-styled-DqtdYPll.js +1647 -0
- package/dist/provider-dispatcher-BsOoa4z4.js +660 -0
- package/dist/provider-dispatcher-Cn4VcFH5.js +659 -0
- package/dist/push-apns-EUvNahMw.js +713 -0
- package/dist/push-apns-xD9poCq1.js +711 -0
- package/dist/pw-ai-CQ_ErGyT.js +1908 -0
- package/dist/pw-ai-TvoT7tly.js +1912 -0
- package/dist/qr-cli-CserVCUj.js +349 -0
- package/dist/qr-cli-dSY8Jcjr.js +354 -0
- package/dist/redact-snapshot-C4RWjjs9.js +2016 -0
- package/dist/redact-snapshot-aZAJCPqx.js +2016 -0
- package/dist/register.agent-BwE2aFO7.js +1017 -0
- package/dist/register.agent-DwOgnYym.js +288 -0
- package/dist/register.configure-Ba8xQCRb.js +132 -0
- package/dist/register.configure-_tlAjnFW.js +126 -0
- package/dist/register.import-C--nBTJu.js +29 -0
- package/dist/register.import-CUqdK9cP.js +32 -0
- package/dist/register.maintenance-Ch7oCQ2l.js +496 -0
- package/dist/register.maintenance-Cw4IBMTp.js +499 -0
- package/dist/register.message-BXz6BEed.js +688 -0
- package/dist/register.message-DJ5PcBzu.js +683 -0
- package/dist/register.onboard-CTyhP6g0.js +259 -0
- package/dist/register.onboard-DguoyjHb.js +264 -0
- package/dist/register.setup-CNk7kQ44.js +116 -0
- package/dist/register.setup-DyYwwbK0.js +111 -0
- package/dist/register.status-health-sessions-7Wpl3o3c.js +666 -0
- package/dist/register.status-health-sessions-CSpCwMy1.js +425 -0
- package/dist/register.subclis-CrNdP6ot.js +267 -0
- package/dist/replies-10JzBkPW.js +136 -0
- package/dist/replies-BQusKLeB.js +136 -0
- package/dist/reply-C6vqeNRk.js +13681 -0
- package/dist/reply-D941sRe2.js +13678 -0
- package/dist/reply-directives-8s8hoVAG.js +182 -0
- package/dist/reply-directives-CmPgo60i.js +182 -0
- package/dist/reply-payloads-NlHsO4JU.js +527 -0
- package/dist/reply-prefix-Bto_wLwa.js +37 -0
- package/dist/reply-prefix-Dej_5SDE.js +37 -0
- package/dist/resolve-route-CKycdke1.js +249 -0
- package/dist/resolve-route-DlJHHITX.js +249 -0
- package/dist/response-prefix-template-CBr9RICF.js +134 -0
- package/dist/response-prefix-template-SN9HSK00.js +134 -0
- package/dist/retry-BMUvSHT-.js +77 -0
- package/dist/run-main-F7fA8Aky.js +304 -0
- package/dist/runner-DHV1DbSV.js +2289 -0
- package/dist/runner-GAXv51HH.js +2289 -0
- package/dist/runtime-guard-BMa-MbRw.js +60 -0
- package/dist/secure-random-B22q_Bpm.js +44 -0
- package/dist/security-cli-Dx0UYbhj.js +486 -0
- package/dist/security-cli-SZoU0VXF.js +480 -0
- package/dist/send-2UWyzHA4.js +492 -0
- package/dist/send-BD7xe6fW.js +2245 -0
- package/dist/send-BPZSuv8R.js +547 -0
- package/dist/send-BdbDK7Gm.js +1776 -0
- package/dist/send-C0a60RHn.js +349 -0
- package/dist/send-CVy5b1Z3.js +349 -0
- package/dist/send-CYI3ZSbp.js +29 -0
- package/dist/send-CpcI6kqW.js +11 -0
- package/dist/send-D64qEY1N.js +1779 -0
- package/dist/send-DHQ_PjNs.js +492 -0
- package/dist/send-DZR-_UV3.js +547 -0
- package/dist/send-DbkjaWxS.js +1174 -0
- package/dist/send-FePh9AL3.js +426 -0
- package/dist/send-Tc6nYSJQ.js +2245 -0
- package/dist/send-WsTzM5wz.js +332 -0
- package/dist/send-t33E5qpm.js +374 -0
- package/dist/server-BBFfC210.js +202 -0
- package/dist/server-DGtv7y52.js +207 -0
- package/dist/server-lifecycle-D8RSrfzE.js +2437 -0
- package/dist/server-lifecycle-_gBPCxJ8.js +2437 -0
- package/dist/server-node-events-BGCJK_yD.js +396 -0
- package/dist/server-node-events-DMudyzAr.js +391 -0
- package/dist/service-DZNs7x-w.js +670 -0
- package/dist/service-r8kPiYnQ.js +670 -0
- package/dist/session-DkLYlMBm.js +170 -0
- package/dist/session-assFIC3H.js +170 -0
- package/dist/session-cost-usage-Dtm3t6lF.js +627 -0
- package/dist/session-cost-usage-bMbCS0Yv.js +627 -0
- package/dist/session-dirs-C81oNyFN.js +947 -0
- package/dist/session-dirs-D0KbSK3q.js +947 -0
- package/dist/session-utils-BVFN0nL4.js +622 -0
- package/dist/session-utils-ZhX2v-OC.js +622 -0
- package/dist/sessions-3glPunYr.js +2569 -0
- package/dist/sessions-CkGvMwES.js +247 -0
- package/dist/shell-env-CsV_IkJj.js +163 -0
- package/dist/shell-env-hZW9j-Uc.js +163 -0
- package/dist/ssrf-DC0zFdz4.js +183 -0
- package/dist/ssrf-UNL0fUGf.js +183 -0
- package/dist/status-BAZ_MHrX.js +2061 -0
- package/dist/status-DSs2TLg8.js +2065 -0
- package/dist/status.update-954Fhbjr.js +79 -0
- package/dist/status.update-B2umkV3j.js +79 -0
- package/dist/store-BSc6aGZT.js +2571 -0
- package/dist/store-BhG9XHsF.js +64 -0
- package/dist/store-C2dbfXzu.js +53 -0
- package/dist/store-CzdZLRld.js +64 -0
- package/dist/subagent-registry-Cgqw7fX_.js +4856 -0
- package/dist/subagent-registry-DuM_Lj5f.js +4854 -0
- package/dist/subsystem-BgxIzx7w.js +1137 -0
- package/dist/system-cli-ChDx6W4P.js +72 -0
- package/dist/system-cli-DqtPt-83.js +77 -0
- package/dist/systemd-B_f-wDxc.js +547 -0
- package/dist/systemd-DXNd4qOC.js +547 -0
- package/dist/systemd-linger-1B4ULj46.js +75 -0
- package/dist/systemd-linger-BNoRZo8N.js +75 -0
- package/dist/table-CU9MUMy2.js +279 -0
- package/dist/tables-361UXJ4C.js +55 -0
- package/dist/tables-DK0bS_Of.js +55 -0
- package/dist/tables-DKUrXUwR.js +55 -0
- package/dist/tailnet-CB_Y1J-4.js +40 -0
- package/dist/tailnet-CIjiTkjf.js +40 -0
- package/dist/tailscale-CVH3JEAh.js +230 -0
- package/dist/tailscale-D9tfMGNs.js +230 -0
- package/dist/targets-B4rMyQFJ.js +53 -0
- package/dist/targets-BX9_lbJ2.js +220 -0
- package/dist/targets-BaPJE3_B.js +2448 -0
- package/dist/targets-BzeP3ZHj.js +650 -0
- package/dist/targets-m9B7js6g.js +2447 -0
- package/dist/targets-rdWlC6Y-.js +53 -0
- package/dist/targets-tDrl_ioQ.js +46 -0
- package/dist/targets-vYAaa-34.js +650 -0
- package/dist/thinking-dksVQLY3.js +88 -0
- package/dist/thinking-l-rrvZwu.js +88 -0
- package/dist/tool-display-DPxFoqpo.js +785 -0
- package/dist/tool-display-Kb0G4otf.js +785 -0
- package/dist/tool-images-CmLjncli.js +263 -0
- package/dist/tool-images-DFd3tVJP.js +263 -0
- package/dist/trash-B5GquK_R.js +125 -0
- package/dist/trash-CmkALnFO.js +125 -0
- package/dist/tui-BIcG2bzZ.js +3326 -0
- package/dist/tui-CC7CRvvX.js +3326 -0
- package/dist/tui-cli-HnK7v6FE.js +60 -0
- package/dist/tui-cli-TBlcCL9v.js +65 -0
- package/dist/update-Bemi0zlX.js +349 -0
- package/dist/update-CHtOiEVf.js +349 -0
- package/dist/update-cli--Vi9jWtP.js +1375 -0
- package/dist/update-cli-C-DC8AbE.js +1372 -0
- package/dist/usage-44NjC-BK.js +5336 -0
- package/dist/version-3QUZW8EP.js +52 -0
- package/dist/version-Ba6dSSl9.js +52 -0
- package/dist/web-Beg93X-5.js +3071 -0
- package/dist/web-C6vR1QMc.js +72 -0
- package/dist/web-uI1xGRV-.js +78 -0
- package/dist/webhooks-cli-CyTfI18g.js +330 -0
- package/dist/webhooks-cli-DW8P9jL_.js +335 -0
- package/dist/whatsapp-actions-CANxWPbG.js +130 -0
- package/dist/whatsapp-actions-DX_8e1lY.js +124 -0
- package/dist/workspace-BxtrYz-g.js +449 -0
- package/dist/workspace-QdYobHCO.js +447 -0
- package/dist/zod-schema-C1zZtGYm.js +2696 -0
- package/dist/zod-schema-CR7FaEW2.js +2696 -0
- package/extensions/matrix/src/matrix/monitor/replies.ts +0 -24
- package/extensions/mattermost/src/mattermost/monitor-helpers.ts +0 -1
- package/package.json +3 -3
- package/dist/accounts-B1aJFYXr.js +0 -272
- package/dist/accounts-BTXSfPWi.js +0 -270
- package/dist/accounts-Bexa80SB.js +0 -32
- package/dist/accounts-BxGS70Do.js +0 -36
- package/dist/accounts-CNY1TGj1.js +0 -47
- package/dist/accounts-Cl_cFv9X.js +0 -47
- package/dist/accounts-Dn9h7HHT.js +0 -36
- package/dist/ack-reactions-B11TAC2D.js +0 -446
- package/dist/ack-reactions-CDUSdN8O.js +0 -446
- package/dist/acp-cli-CA1xMmVo.js +0 -1320
- package/dist/acp-cli-Dr83tqAg.js +0 -1326
- package/dist/active-listener-VzhWW8W6.js +0 -37
- package/dist/active-listener-z0qVEcom.js +0 -37
- package/dist/agent-CFKgqSEH.js +0 -732
- package/dist/agent-D2RVoS5g.js +0 -731
- package/dist/agent-helpers-CTx5KKJu.js +0 -606
- package/dist/agent-helpers-D_9mS2Ti.js +0 -606
- package/dist/agent-scope-9WY5O-KK.js +0 -121
- package/dist/agent-scope-C50VuLKh.js +0 -119
- package/dist/agents-BBXCuDMp.js +0 -788
- package/dist/agents.config-BPGQ3Qyn.js +0 -116
- package/dist/agents.config-p3V3b9u6.js +0 -116
- package/dist/audio-DPOuhNq7.js +0 -43
- package/dist/audio-preflight-BwmCYeuM.js +0 -64
- package/dist/audio-preflight-Dj6hBcFR.js +0 -69
- package/dist/audit-DhIKIeXD.js +0 -3138
- package/dist/audit-qgtCT3ik.js +0 -3138
- package/dist/auth-C6VDYgb7.js +0 -448
- package/dist/auth-Deh9i9Eg.js +0 -448
- package/dist/auth-profiles-BquJGKLC.js +0 -279
- package/dist/auth-profiles-CeDgZz_7.js +0 -281
- package/dist/banner-HCssFZcB.js +0 -294
- package/dist/binaries-X6FW-wD4.js +0 -13
- package/dist/bindings-B582pDIa.js +0 -69
- package/dist/bindings-CRU_udk8.js +0 -69
- package/dist/bonjour-discovery-BtPaR8vb.js +0 -378
- package/dist/bonjour-discovery-DuhiIZZx.js +0 -378
- package/dist/browser-cli-HH45lxP0.js +0 -1687
- package/dist/browser-cli-TB-GNoZq.js +0 -1692
- package/dist/call-BbwtB9Y-.js +0 -2828
- package/dist/call-ByOzoLDI.js +0 -2829
- package/dist/catalog-BY7OPtnz.js +0 -185
- package/dist/catalog-BqO6yem_.js +0 -185
- package/dist/channel-account-context-CjXyzMXE.js +0 -550
- package/dist/channel-account-context-CvIDAtHS.js +0 -550
- package/dist/channel-activity-BeRrcCd8.js +0 -94
- package/dist/channel-activity-DTKGf3j5.js +0 -94
- package/dist/channel-activity-hPfValKp.js +0 -292
- package/dist/channel-options-BLdLu0xk.js +0 -33
- package/dist/channel-options-BQ61blla.js +0 -32
- package/dist/channel-selection-CJXZTxae.js +0 -51
- package/dist/channel-selection-NNPbxnyZ.js +0 -51
- package/dist/channel-web-D1_mlyPg.js +0 -2136
- package/dist/channel-web-DmhVkWbP.js +0 -2134
- package/dist/channels-cli-C4O8pp1S.js +0 -1426
- package/dist/channels-cli-DAu1TXTH.js +0 -1421
- package/dist/channels-status-issues-BDAHISWe.js +0 -18
- package/dist/channels-status-issues-DwRDzwrV.js +0 -18
- package/dist/chat-envelope-DEZ-5RY8.js +0 -248
- package/dist/chat-envelope-el7Uo-Fe.js +0 -248
- package/dist/chrome-CNDtczoM.js +0 -1733
- package/dist/chrome-CdcwZN9t.js +0 -1732
- package/dist/chunk-CSQfUhgF.js +0 -341
- package/dist/chunk-DAjFKt2g.js +0 -341
- package/dist/clack-prompter-CCFnKP_1.js +0 -121
- package/dist/clack-prompter-CabwzmG4.js +0 -122
- package/dist/cli-BuMX-jRY.js +0 -130
- package/dist/cli-Ci4DmAyk.js +0 -125
- package/dist/clipboard-B2j4qGIl.js +0 -31
- package/dist/clipboard-Dzkx6Q2K.js +0 -31
- package/dist/command-format-CVfo8I5f.js +0 -18
- package/dist/command-format-DgXcqxBt.js +0 -32
- package/dist/command-registry-DxsFXB5t.js +0 -215
- package/dist/commands-C2uNKRTf.js +0 -41
- package/dist/commands-CDonBOrw.js +0 -41
- package/dist/commands-registry-BvESmXoK.js +0 -893
- package/dist/commands-registry-CWJv6xe2.js +0 -892
- package/dist/common-Cp3rsBqx.js +0 -156
- package/dist/common-DSVmydhm.js +0 -156
- package/dist/completion-cli-B-X5nwdT.js +0 -452
- package/dist/completion-cli-DD3pVpPn.js +0 -452
- package/dist/config-BqY7k-L8.js +0 -6953
- package/dist/config-FHu9Bn4R.js +0 -6951
- package/dist/config-cli-CPH_PfVk.js +0 -241
- package/dist/config-cli-Czvt02PC.js +0 -246
- package/dist/config-guard-5oI2BiSY.js +0 -97
- package/dist/config-guard-cB5a_ANg.js +0 -75
- package/dist/config-validation-BPNyd9_3.js +0 -18
- package/dist/config-validation-J3cJ0OCa.js +0 -18
- package/dist/configure-Bi_9d94n.js +0 -889
- package/dist/configure-DiQaHI3s.js +0 -891
- package/dist/constants-BmRFoHl0.js +0 -67
- package/dist/constants-C9WPAluB.js +0 -67
- package/dist/control-auth-D0tpV3ts.js +0 -397
- package/dist/control-auth-q4zZXaoS.js +0 -397
- package/dist/control-ui/assets/index-B4ZM1lW1.js +0 -7738
- package/dist/control-ui/assets/index-B4ZM1lW1.js.map +0 -1
- package/dist/control-ui/assets/index-PED72sKF.css +0 -1
- package/dist/control-ui-assets-Cx_mw4D0.js +0 -186
- package/dist/control-ui-assets-D4yaD8jm.js +0 -186
- package/dist/conversation-label-C4SDz4sT.js +0 -36
- package/dist/conversation-label-D1frnvYe.js +0 -36
- package/dist/cron-cli-Bfh7ftYz.js +0 -495
- package/dist/cron-cli-C8j_uslU.js +0 -490
- package/dist/daemon-cli-DQFZB1yM.js +0 -1197
- package/dist/daemon-cli-lTsfNeDm.js +0 -1199
- package/dist/daemon-install-CcohRvKV.js +0 -55
- package/dist/daemon-install-DrTvAWhM.js +0 -60
- package/dist/daemon-install-helpers-CFGAfRlj.js +0 -462
- package/dist/daemon-install-helpers-DIUzSFG1.js +0 -462
- package/dist/defaults-B5KStIBg.js +0 -7
- package/dist/defaults-xUAL2Z-F.js +0 -7
- package/dist/deliver-912khjLK.js +0 -481
- package/dist/deliver-D78pwuPC.js +0 -481
- package/dist/delivery-queue-CxVRi4tw.js +0 -244
- package/dist/devices-cli-0qDhTgZR.js +0 -316
- package/dist/devices-cli-CstkYXzr.js +0 -321
- package/dist/diagnostics-HGkN467d.js +0 -46
- package/dist/diagnostics-VC0cz7kX.js +0 -46
- package/dist/directory-cli-5YXdoVdn.js +0 -217
- package/dist/directory-cli-duhBZl2c.js +0 -222
- package/dist/dm-policy-shared-BBfEyAN1.js +0 -22
- package/dist/dm-policy-shared-D8lgnmrC.js +0 -22
- package/dist/dns-cli-11CtErVU.js +0 -197
- package/dist/dns-cli-Sr6SB9ei.js +0 -202
- package/dist/dock-BqNINg7k.js +0 -928
- package/dist/dock-O8ArYwed.js +0 -929
- package/dist/doctor-completion-B1UlvZFx.js +0 -92
- package/dist/doctor-completion-C0j7b_f8.js +0 -92
- package/dist/doctor-config-flow-BVkHcvoj.js +0 -1933
- package/dist/doctor-config-flow-BiShkCxs.js +0 -1934
- package/dist/enable-DMIq6evt.js +0 -59
- package/dist/enable-ibNq4UWy.js +0 -59
- package/dist/env-Br2Bl6Ht.js +0 -60
- package/dist/env-vars-7aZqKPhk.js +0 -93
- package/dist/env-vars-CLGbxdpL.js +0 -93
- package/dist/errors-BpAidYqH.js +0 -35
- package/dist/errors-DZ199hOo.js +0 -35
- package/dist/exec-C6ACg_Mn.js +0 -164
- package/dist/exec-DkFE7lqU.js +0 -164
- package/dist/fetch-Bmv93nu9.js +0 -67
- package/dist/fetch-C6XKGA11.js +0 -67
- package/dist/file-lock-CIvloidc.js +0 -107
- package/dist/file-lock-CzBL_VIx.js +0 -107
- package/dist/fs-safe-DkBhNAc3.js +0 -98
- package/dist/gateway-cli-D4cDhvZx.js +0 -23747
- package/dist/gateway-cli-DuMjB8Ff.js +0 -23742
- package/dist/gateway-rpc-B4jTtupy.js +0 -28
- package/dist/gateway-rpc-Dq44SkOv.js +0 -28
- package/dist/gmail-setup-utils-BPmUIqso.js +0 -423
- package/dist/gmail-setup-utils-Cnx8A5pW.js +0 -422
- package/dist/health-SOuaKNRa.js +0 -1420
- package/dist/health-wr-JDHlc.js +0 -1423
- package/dist/heartbeat-visibility-BxkZjE5m.js +0 -125
- package/dist/heartbeat-visibility-ossI_l4t.js +0 -125
- package/dist/helpers-kkeXif0Q.js +0 -10
- package/dist/hook-runner-global-DJ14gXFP.js +0 -527
- package/dist/hooks-cli-BUTtESiX.js +0 -1217
- package/dist/hooks-cli-eqPYjw4l.js +0 -1222
- package/dist/image-ops-DRdKC0uO.js +0 -354
- package/dist/image-ops-DWytvdh_.js +0 -354
- package/dist/import-Be73VPF2.js +0 -170
- package/dist/import-DQ6NI4Fz.js +0 -168
- package/dist/inbound-context-CPkkQW0i.js +0 -68
- package/dist/inbound-context-DS_kpIYI.js +0 -68
- package/dist/inbound-path-policy-C_Qo8rqg.js +0 -250
- package/dist/inbound-path-policy-sdr5Ji0k.js +0 -250
- package/dist/inspect-B1Fq39RC.js +0 -559
- package/dist/inspect-Dt8hogS3.js +0 -559
- package/dist/installs-C8apg11p.js +0 -325
- package/dist/installs-pWdqG8HL.js +0 -325
- package/dist/ipv4--2WXMVtE.js +0 -46
- package/dist/ipv4-CDQpx1A7.js +0 -46
- package/dist/ir-Ch9FC9Z_.js +0 -940
- package/dist/json-files-DzpTak5i.js +0 -46
- package/dist/loader-Cuq-saEl.js +0 -22621
- package/dist/loader-u9FC6kYG.js +0 -22624
- package/dist/local-roots-BrH0Q63K.js +0 -313
- package/dist/local-roots-z2u_s7jG.js +0 -314
- package/dist/logger-pznB_IdT.js +0 -49
- package/dist/login-CYq-visu.js +0 -62
- package/dist/login-DOmWDMeP.js +0 -61
- package/dist/login-qr-CXU0wC5K.js +0 -322
- package/dist/login-qr-D85vVatX.js +0 -327
- package/dist/logs-cli-Cu2S08Y3.js +0 -238
- package/dist/logs-cli-D7ayUvz_.js +0 -233
- package/dist/markdown-tables-hhOWaw8L.js +0 -29
- package/dist/markdown-tables-jrnSPvZ6.js +0 -29
- package/dist/media-DN7yRfrH.js +0 -940
- package/dist/media-DOQIalam.js +0 -10492
- package/dist/message-action-names-Dk9kxwRd.js +0 -2521
- package/dist/message-action-names-EsOcuFpq.js +0 -2521
- package/dist/message-channel-BlYrtmIp.js +0 -91
- package/dist/net-Cg8AQeke.js +0 -225
- package/dist/net-D6D0wgcF.js +0 -225
- package/dist/node-cli-Q2-n3Fgv.js +0 -24
- package/dist/nodes-cli-BDq-4dHm.js +0 -1348
- package/dist/nodes-cli-C2SoKfCv.js +0 -1343
- package/dist/nodes-screen-Bmp1l9wY.js +0 -250
- package/dist/nodes-screen-Cw7Hv7M2.js +0 -250
- package/dist/note-DR8A0G5H.js +0 -92
- package/dist/note-Dlv4NmlQ.js +0 -92
- package/dist/npm-registry-spec-COvUzy5J.js +0 -786
- package/dist/npm-registry-spec-Cobb5KYR.js +0 -786
- package/dist/npm-resolution-BmgD7x45.js +0 -86
- package/dist/npm-resolution-DNYcV-Br.js +0 -86
- package/dist/onboard-Dy0q82Mj.js +0 -405
- package/dist/onboard-channels-9QS_7iph.js +0 -2548
- package/dist/onboard-channels-EH2wvu6Y.js +0 -2547
- package/dist/onboard-config-BCTthQ7J.js +0 -24
- package/dist/onboard-config-y-2cgT0V.js +0 -24
- package/dist/onboard-helpers-ChPmr3lh.js +0 -363
- package/dist/onboard-helpers-Jy3345Jk.js +0 -362
- package/dist/onboard-remote-CM6Yl1oL.js +0 -127
- package/dist/onboard-remote-Id80PV28.js +0 -127
- package/dist/onboard-uvDMehqu.js +0 -407
- package/dist/onboarding-BVtzeopT.js +0 -534
- package/dist/onboarding-DlXBAIDc.js +0 -532
- package/dist/onboarding.finalize-Dve-3p-y.js +0 -398
- package/dist/onboarding.finalize-GIK3ktiW.js +0 -401
- package/dist/onboarding.gateway-config-BCV5T35-.js +0 -198
- package/dist/onboarding.gateway-config-DW-09FX5.js +0 -191
- package/dist/outbound-CFfJC1j5.js +0 -220
- package/dist/outbound-CjFRpudN.js +0 -221
- package/dist/outbound-attachment-BxMSma9v.js +0 -18
- package/dist/outbound-attachment-DIiKB_mP.js +0 -18
- package/dist/outbound-attachment-o0seS0CP.js +0 -18
- package/dist/pairing-cli-BeydfoF9.js +0 -122
- package/dist/pairing-cli-GgwzEWJX.js +0 -127
- package/dist/pairing-labels-B_53dY5L.js +0 -9
- package/dist/pairing-labels-BiSZLitI.js +0 -9
- package/dist/pairing-store-BgAv4uN8.js +0 -460
- package/dist/pairing-store-CTkD51uW.js +0 -459
- package/dist/path-env-ErEKbxOI.js +0 -89
- package/dist/path-env-qRJbjJzj.js +0 -89
- package/dist/path-safety-juI2XbO1.js +0 -14
- package/dist/plugin-auto-enable-CloCFyTz.js +0 -302
- package/dist/plugin-auto-enable-DuPS9XiJ.js +0 -301
- package/dist/plugin-registry-D5QsH-IS.js +0 -33
- package/dist/plugin-registry-DnO3azwy.js +0 -33
- package/dist/plugin-sdk/agents/agent-helpers/thinking.d.ts +0 -5
- package/dist/plugin-sdk/agents/agent-paths.d.ts +0 -1
- package/dist/plugin-sdk/agents/auth-profiles/constants.d.ts +0 -16
- package/dist/plugin-sdk/agents/auth-profiles/display.d.ts +0 -7
- package/dist/plugin-sdk/agents/auth-profiles/doctor.d.ts +0 -8
- package/dist/plugin-sdk/agents/auth-profiles/oauth.d.ts +0 -14
- package/dist/plugin-sdk/agents/auth-profiles/paths.d.ts +0 -4
- package/dist/plugin-sdk/agents/auth-profiles/profiles.d.ts +0 -12
- package/dist/plugin-sdk/agents/auth-profiles/session-override.d.ts +0 -18
- package/dist/plugin-sdk/agents/auth-profiles/store.d.ts +0 -10
- package/dist/plugin-sdk/agents/auth-profiles.d.ts +0 -8
- package/dist/plugin-sdk/agents/defaults.d.ts +0 -3
- package/dist/plugin-sdk/agents/provider-auth.d.ts +0 -40
- package/dist/plugin-sdk/auto-reply/model-runtime.d.ts +0 -17
- package/dist/plugin-sdk/config/model-input.d.ts +0 -9
- package/dist/plugin-sdk/config/zod-schema.agent-model.d.ts +0 -5
- package/dist/plugin-sdk/sessions/model-overrides.d.ts +0 -14
- package/dist/plugin-sdk/telegram/reasoning-lane-coordinator.d.ts +0 -18
- package/dist/plugins-BXkDApVh.js +0 -455
- package/dist/plugins-BflZz0sp.js +0 -453
- package/dist/plugins-cli-Cf_RP_bn.js +0 -798
- package/dist/plugins-cli-DmbjYnO9.js +0 -793
- package/dist/ports-DIYJq-SY.js +0 -370
- package/dist/ports-DPL-Pzfh.js +0 -96
- package/dist/ports-NPqtlfp0.js +0 -316
- package/dist/ports-QMI4-F9m.js +0 -96
- package/dist/program-BaATq6CL.js +0 -244
- package/dist/program-context-C7b5MQbg.js +0 -474
- package/dist/progress--dapuyZA.js +0 -124
- package/dist/prompt-select-styled-BAsxl6hj.js +0 -1650
- package/dist/prompt-select-styled-aqjxCbwP.js +0 -1647
- package/dist/provider-dispatcher-B4QMe-I6.js +0 -659
- package/dist/provider-dispatcher-mAkRbPyH.js +0 -660
- package/dist/push-apns-CLmNS5AZ.js +0 -713
- package/dist/push-apns-DuG95AKC.js +0 -711
- package/dist/pw-ai-DuK87zsJ.js +0 -1906
- package/dist/pw-ai-ulOU3Ya1.js +0 -1910
- package/dist/qr-cli-9WQBnauO.js +0 -352
- package/dist/qr-cli-hSLixZCe.js +0 -347
- package/dist/redact-snapshot-BZYLIqe-.js +0 -2028
- package/dist/redact-snapshot-D2P_lRgf.js +0 -2028
- package/dist/register.agent-CquY2yLI.js +0 -286
- package/dist/register.agent-DZL_fw2K.js +0 -1043
- package/dist/register.configure-C2HjaKO0.js +0 -124
- package/dist/register.configure-D7Di47Lb.js +0 -130
- package/dist/register.import-Bs-UkOs-.js +0 -27
- package/dist/register.import-CaJ0DS1t.js +0 -30
- package/dist/register.maintenance-CslelbHK.js +0 -497
- package/dist/register.maintenance-Dd4fn6oX.js +0 -494
- package/dist/register.message-D2xmx0xB.js +0 -681
- package/dist/register.message-_Q8ehgQP.js +0 -686
- package/dist/register.onboard-BFSwh5g4.js +0 -262
- package/dist/register.onboard-CIupEYmX.js +0 -257
- package/dist/register.setup-7pk1r-54.js +0 -114
- package/dist/register.setup-Bm1Jtx0c.js +0 -109
- package/dist/register.status-health-sessions-C-Pbi-qq.js +0 -669
- package/dist/register.status-health-sessions-Cn4yWBWw.js +0 -423
- package/dist/register.subclis-DXmLofHX.js +0 -267
- package/dist/replies-BKrzM0QI.js +0 -136
- package/dist/replies-BkXDql3c.js +0 -136
- package/dist/reply-DSKC8kyS.js +0 -13897
- package/dist/reply-directives-CBeNSCHL.js +0 -182
- package/dist/reply-directives-CD2WycBM.js +0 -182
- package/dist/reply-n8KWtBQB.js +0 -13900
- package/dist/reply-payloads-CeL_cBnD.js +0 -527
- package/dist/reply-prefix-4zLS7A1Y.js +0 -38
- package/dist/reply-prefix-DBLCYiup.js +0 -38
- package/dist/resolve-route-BDGdM-l3.js +0 -249
- package/dist/resolve-route-CBVbY0xS.js +0 -249
- package/dist/response-prefix-template-CSxp9HN5.js +0 -136
- package/dist/response-prefix-template-up4REfuR.js +0 -136
- package/dist/retry-C81p7BZU.js +0 -77
- package/dist/run-main-CuA7VmAq.js +0 -320
- package/dist/runner-BbLPl1dz.js +0 -2294
- package/dist/runner-z92MWZ3m.js +0 -2294
- package/dist/runtime-guard-DZ_xuCc4.js +0 -60
- package/dist/secure-random-D2IOpBkk.js +0 -44
- package/dist/security-cli-BR3Y1FBJ.js +0 -484
- package/dist/security-cli-DP5QJpa5.js +0 -478
- package/dist/send-0uEtKwU_.js +0 -2245
- package/dist/send-B3O7bzYU.js +0 -1174
- package/dist/send-BWSo3i3H.js +0 -1778
- package/dist/send-BkSUAGj6.js +0 -349
- package/dist/send-Bx9bUGav.js +0 -492
- package/dist/send-CBGSXjfD.js +0 -2245
- package/dist/send-CRS-OcnW.js +0 -29
- package/dist/send-DPttDPIR.js +0 -374
- package/dist/send-D_DUQJ6H.js +0 -349
- package/dist/send-DyftOlFD.js +0 -332
- package/dist/send-Lij9A7lk.js +0 -547
- package/dist/send-YRVDWfSs.js +0 -547
- package/dist/send-dzS4fa9O.js +0 -492
- package/dist/send-uchxcHYC.js +0 -11
- package/dist/send-xUPOqzUr.js +0 -426
- package/dist/send-xnwty9cY.js +0 -1775
- package/dist/server-BE5lybcS.js +0 -205
- package/dist/server-LdLsvPPw.js +0 -200
- package/dist/server-lifecycle-B3Rdmq7-.js +0 -2437
- package/dist/server-lifecycle-CFmE_Adm.js +0 -2437
- package/dist/server-node-events-De4WZQQD.js +0 -393
- package/dist/server-node-events-d7eK4LBW.js +0 -398
- package/dist/service-BHos7oX8.js +0 -670
- package/dist/service-Bjqii5nW.js +0 -670
- package/dist/session-DBL5nHDy.js +0 -170
- package/dist/session-aUptxSVD.js +0 -170
- package/dist/session-cost-usage-DX09eTPU.js +0 -627
- package/dist/session-cost-usage-yYi525j3.js +0 -627
- package/dist/session-dirs-BADAi9Iz.js +0 -947
- package/dist/session-dirs-DdF6TDsE.js +0 -947
- package/dist/session-utils-CEtEq6bi.js +0 -625
- package/dist/session-utils-CiXbZkM2.js +0 -625
- package/dist/sessions--PykPynp.js +0 -2593
- package/dist/sessions-Bw4LRnSr.js +0 -252
- package/dist/ssrf-Ck9HDZpv.js +0 -183
- package/dist/ssrf-m7kFIobZ.js +0 -183
- package/dist/status-CrGLegI6.js +0 -2072
- package/dist/status-D_3sszaS.js +0 -2068
- package/dist/status.update-C55QM2xs.js +0 -79
- package/dist/status.update-CVnonGHu.js +0 -79
- package/dist/store-BPZo49zT.js +0 -64
- package/dist/store-C6w1sB5x.js +0 -53
- package/dist/store-DoOPG3rl.js +0 -2595
- package/dist/store-v3P-OWhi.js +0 -64
- package/dist/subagent-registry-C-xI2uK4.js +0 -4860
- package/dist/subagent-registry-Db4Ho_2Y.js +0 -4858
- package/dist/subsystem-CrJCqjAh.js +0 -1139
- package/dist/system-cli-CCKzF3uh.js +0 -75
- package/dist/system-cli-eAk5wVbP.js +0 -70
- package/dist/systemd-B5lyaCc3.js +0 -547
- package/dist/systemd-DSnlM3jX.js +0 -547
- package/dist/systemd-linger-DRPSEQVw.js +0 -75
- package/dist/systemd-linger-_0_-RY4v.js +0 -75
- package/dist/table-CpmqqcxJ.js +0 -279
- package/dist/tables-DI5LGEr1.js +0 -55
- package/dist/tables-D_PTzthR.js +0 -55
- package/dist/tables-DcQUNIvB.js +0 -55
- package/dist/tailnet-CEudzG0i.js +0 -40
- package/dist/tailnet-PnMrjwGT.js +0 -40
- package/dist/tailscale-Dbyahx0J.js +0 -230
- package/dist/tailscale-Dxyz13fn.js +0 -230
- package/dist/targets-B2vBpQdr.js +0 -2173
- package/dist/targets-B54vK3wc.js +0 -220
- package/dist/targets-CcTME3bp.js +0 -46
- package/dist/targets-Cm1X3IyA.js +0 -650
- package/dist/targets-CmC5m7Ey.js +0 -53
- package/dist/targets-D7OKVXMI.js +0 -650
- package/dist/targets-DB4vBpIQ.js +0 -2172
- package/dist/targets-DyybKefq.js +0 -53
- package/dist/tool-display-B-nr7cSF.js +0 -785
- package/dist/tool-display-Br6mwaJc.js +0 -785
- package/dist/tool-images-DVrUJEqc.js +0 -263
- package/dist/tool-images-kloBqxqK.js +0 -263
- package/dist/trash-DPi0aCCQ.js +0 -125
- package/dist/trash-DzrtBoP1.js +0 -125
- package/dist/tui-CyHwc2uX.js +0 -3392
- package/dist/tui-cHd20SZm.js +0 -3392
- package/dist/tui-cli-C7kQj9ef.js +0 -63
- package/dist/tui-cli-C9I18SfW.js +0 -58
- package/dist/update-DeQGoaIC.js +0 -349
- package/dist/update-IX7vdqA8.js +0 -349
- package/dist/update-cli-C52dmo3x.js +0 -1370
- package/dist/update-cli-DY_iE1E5.js +0 -1373
- package/dist/usage-B--dL37U.js +0 -5279
- package/dist/web-CMxp78WA.js +0 -76
- package/dist/web-DMweaNnG.js +0 -3065
- package/dist/web-Dquzwqf4.js +0 -70
- package/dist/webhooks-cli-BpZHQlVd.js +0 -328
- package/dist/webhooks-cli-CqFX8Ywl.js +0 -333
- package/dist/whatsapp-actions-C31Zdwez.js +0 -128
- package/dist/whatsapp-actions-DaA291Ya.js +0 -122
- package/dist/workspace-B4ZvVYT9.js +0 -447
- package/dist/workspace-B8qk__ff.js +0 -449
- /package/dist/{account-lookup-0KDSp5Mj.js → account-lookup-C0ndrpt-.js} +0 -0
- /package/dist/{account-lookup-zvANGr2x.js → account-lookup-R1ParPyR.js} +0 -0
- /package/dist/{ansi-D04X81yq.js → ansi-aRwLYlzD.js} +0 -0
- /package/dist/{api-BeQMq2iS.js → api-DSIfHPts.js} +0 -0
- /package/dist/{api-CxX8-gGz.js → api-DTwcrkBE.js} +0 -0
- /package/dist/{argv-Co-b9Zsc.js → argv-DW4MYBdJ.js} +0 -0
- /package/dist/{audio-VBcVDa08.js → audio-CgwsD4uc.js} +0 -0
- /package/dist/{brew-DbSbN8sD.js → brew-CBsS-Vq1.js} +0 -0
- /package/dist/{brew-C4zKZsHX.js → brew-DJvEvRfG.js} +0 -0
- /package/dist/{chat-type-CYPyHAj-.js → chat-type-BPBtOjer.js} +0 -0
- /package/dist/{chat-type-DKb2TlGZ.js → chat-type-CH3W-zKy.js} +0 -0
- /package/dist/{cleanup-utils-o2MM9xyf.js → cleanup-utils-yPa4b4YC.js} +0 -0
- /package/dist/{cleanup-utils-CwQvD73q.js → cleanup-utils-zWAqOnW8.js} +0 -0
- /package/dist/{cli-name-BicfmwQX.js → cli-name-3MdfbvIR.js} +0 -0
- /package/dist/{cli-name-C6rJGl18.js → cli-name-CpSGz3mA.js} +0 -0
- /package/dist/{cli-utils-BhXbz2UF.js → cli-utils-DLQmX9d8.js} +0 -0
- /package/dist/{cli-utils-DZe_rVkZ.js → cli-utils-DVWIt9Ob.js} +0 -0
- /package/dist/{client-C61M8zI3.js → client-D5m46AuY.js} +0 -0
- /package/dist/{client-DdpmATKq.js → client-Fi2k2G9Z.js} +0 -0
- /package/dist/{command-options-C4paWSGf.js → command-options-Eo_ESfC0.js} +0 -0
- /package/dist/{command-options-CA30lfLK.js → command-options-criepGrH.js} +0 -0
- /package/dist/{config-eval-CjGZtLwx.js → config-eval-DbGlbDlp.js} +0 -0
- /package/dist/{config-eval-H_wlEYIG.js → config-eval-Yxi-wJPE.js} +0 -0
- /package/dist/{constants-ChptG3d7.js → constants-BlFnttWm.js} +0 -0
- /package/dist/{constants-DY6b-_Wl.js → constants-wpkIJk8U.js} +0 -0
- /package/dist/{credentials-BHWUBHMd.js → credentials-Bqu9Xdfz.js} +0 -0
- /package/dist/{credentials-DFsi1_e8.js → credentials-DQ28n4lc.js} +0 -0
- /package/dist/{daemon-runtime-CvqE4ysg.js → daemon-runtime-aQhinwSL.js} +0 -0
- /package/dist/{dangerous-name-matching-BzmiLXmA.js → dangerous-name-matching-B4MRPcn-.js} +0 -0
- /package/dist/{dangerous-name-matching-DaVRgwer.js → dangerous-name-matching-UV0YfXlV.js} +0 -0
- /package/dist/{dangerous-tools-BOLoCRv4.js → dangerous-tools-BU0t3SUd.js} +0 -0
- /package/dist/{dangerous-tools-Baq7Q-i6.js → dangerous-tools-Ce1dELvv.js} +0 -0
- /package/dist/{delivery-queue-Cfa9Wmxp.js → delivery-queue-1d--YXgK.js} +0 -0
- /package/dist/{fetch-CEDsOiql.js → fetch-DNEsm4Ur.js} +0 -0
- /package/dist/{fetch-timeout-DTIN7CGM.js → fetch-timeout-jOIu9Xud.js} +0 -0
- /package/dist/{format-duration-CqUERz51.js → format-duration-DQ1Dl3YB.js} +0 -0
- /package/dist/{format-duration-Ct-yiwkS.js → format-duration-Oj8pTbYL.js} +0 -0
- /package/dist/{format-relative-79_Y1n2Y.js → format-relative-8dpVUfzZ.js} +0 -0
- /package/dist/{format-relative-CxLpEQOX.js → format-relative-Cywx6ldk.js} +0 -0
- /package/dist/{health-format-Bygse7KA.js → health-format-DsqB_lOC.js} +0 -0
- /package/dist/{health-format-B_QRD8Si.js → health-format-FHquW42d.js} +0 -0
- /package/dist/{heartbeat-wake-LGEgcXjs.js → heartbeat-wake-AkM9ZRL2.js} +0 -0
- /package/dist/{help-format-NNm_Ov4H.js → help-format-Ca9FzlcN.js} +0 -0
- /package/dist/{help-format-sqWgYEdL.js → help-format-D-X9bY8s.js} +0 -0
- /package/dist/{helpers-BAsMXprO.js → helpers-703bXVlF.js} +0 -0
- /package/dist/{helpers-DLgbkcEn.js → helpers-CpIyUra4.js} +0 -0
- /package/dist/{helpers-R7bU5IBz.js → helpers-D1ViXWK0.js} +0 -0
- /package/dist/{host-env-security-szwfmhC4.js → host-env-security-CbiODGvQ.js} +0 -0
- /package/dist/{input-provenance-Bn6thJNm.js → input-provenance-BgfeDgck.js} +0 -0
- /package/dist/{input-provenance-xUsSMOsz.js → input-provenance-duDehu0D.js} +0 -0
- /package/dist/{ip-C9q3Oq20.js → ip-kVgrMfw-.js} +0 -0
- /package/dist/{ip-D0zgNmBV.js → ip-o-YLqTzQ.js} +0 -0
- /package/dist/{is-main-DN8-sNR5.js → is-main-BE1Jih91.js} +0 -0
- /package/dist/{json-file-ChO_R9yh.js → json-file-DNead8D_.js} +0 -0
- /package/dist/{json-file-B7l5-Xhr.js → json-file-DY96R8LK.js} +0 -0
- /package/dist/{json-files-CmpYSF4G.js → json-files-CjOU2Hds.js} +0 -0
- /package/dist/{lanes-ByWMUgrz.js → lanes-3Hy9dOzA.js} +0 -0
- /package/dist/{lanes-cHJ5arWg.js → lanes-BmSbfjW9.js} +0 -0
- /package/dist/{links-Cm43Vcft.js → links-CPYVK7l1.js} +0 -0
- /package/dist/{links-Bz4V7R_p.js → links-NSE5DGnq.js} +0 -0
- /package/dist/{location-DBWCGNLq.js → location-BUhzov-a.js} +0 -0
- /package/dist/{location-GbZ0bBRU.js → location-C8XO7UyG.js} +0 -0
- /package/dist/{logger-DyL5G2DO.js → logger-DWcHNtdK.js} +0 -0
- /package/dist/{logger-BWMPnILd.js → logger-DsFoLpk4.js} +0 -0
- /package/dist/{logger-GvipVDfh.js → logger-n5cQNuVr.js} +0 -0
- /package/dist/{logging-D8-Kozjc.js → logging-BEw3xi9W.js} +0 -0
- /package/dist/{logging-D8R0sLY9.js → logging-DEDs-xX7.js} +0 -0
- /package/dist/{message-channel-uWMAiywE.js → message-channel-BHrK-j5D.js} +0 -0
- /package/dist/{mime-BS3jhcZE.js → mime-C4zhIbPz.js} +0 -0
- /package/dist/{mutable-allowlist-detectors-DiZDtmlZ.js → mutable-allowlist-detectors-DbdlW-cX.js} +0 -0
- /package/dist/{node-cli-Uf6lAntf.js → node-cli-BJEaXcTB.js} +0 -0
- /package/dist/{parse-log-line-enq8pduH.js → parse-log-line-DTl9swsB.js} +0 -0
- /package/dist/{parse-log-line-mz9TG6ig.js → parse-log-line-LEXRMnqc.js} +0 -0
- /package/dist/{parse-timeout-BMP8a0_a.js → parse-timeout-C7ggYYiO.js} +0 -0
- /package/dist/{parse-timeout-CDkco8kd.js → parse-timeout-o1QTe1VR.js} +0 -0
- /package/dist/{path-guards-CrQOUlsq.js → path-guards-lL3tZoxY.js} +0 -0
- /package/dist/{path-safety-DkT9RmTG.js → path-safety-CphcstYi.js} +0 -0
- /package/dist/plugin-sdk/{agents → auth}/api-key-rotation.d.ts +0 -0
- /package/dist/plugin-sdk/{agents/auth-profiles → auth}/types.d.ts +0 -0
- /package/dist/{plugins-allowlist-BbTQ5Z2k.js → plugins-allowlist-Cf3EjAjw.js} +0 -0
- /package/dist/{plugins-allowlist-C20oaESO.js → plugins-allowlist-Dml1TRY5.js} +0 -0
- /package/dist/{polls-B0CCBDeR.js → polls-DdY_LCOM.js} +0 -0
- /package/dist/{ports-lsof-Wteul3ju.js → ports-lsof-Dv4WDRbi.js} +0 -0
- /package/dist/{process-scoped-map-CV9kDvfG.js → process-scoped-map-C7KeadUK.js} +0 -0
- /package/dist/{process-scoped-map-PEvnG75N.js → process-scoped-map-CuVgan0a.js} +0 -0
- /package/dist/{program-context-jqeI5alP.js → program-context-Bqg7MHJh.js} +0 -0
- /package/dist/{progress-C1kUfYL-.js → progress-DSHP8RB4.js} +0 -0
- /package/dist/{prompt-Yn2yClg1.js → prompt-B2SgjtOJ.js} +0 -0
- /package/dist/{prompt-BVZVovoB.js → prompt-BXeXEH0o.js} +0 -0
- /package/dist/{prompt-style-D0LUnqXi.js → prompt-style-BzXtlA1Y.js} +0 -0
- /package/dist/{prompt-style-DjEYC_s-.js → prompt-style-D-ViRLW_.js} +0 -0
- /package/dist/{provider-utils-3JTMJroG.js → provider-utils-DiLhkKQp.js} +0 -0
- /package/dist/{proxy-DL3MD6-P.js → proxy-BUoQO1tr.js} +0 -0
- /package/dist/{proxy-DpNv2cSV.js → proxy-dRhp8Ykw.js} +0 -0
- /package/dist/{pw-ai-state-CGfLv6nV.js → pw-ai-state-Cg1RrEiW.js} +0 -0
- /package/dist/{pw-ai-state-Dynx20hr.js → pw-ai-state-DidjiYBK.js} +0 -0
- /package/dist/{redact-Dx1Fue21.js → redact-BlqmrEU3.js} +0 -0
- /package/dist/{redact-BsoXOV1y.js → redact-Cj9LoKIG.js} +0 -0
- /package/dist/{redact-identifier-CAagcfWA.js → redact-identifier-HyK89Sod.js} +0 -0
- /package/dist/{remoteclaw-root-C2HV2VeC.js → remoteclaw-root-CtzHY_u8.js} +0 -0
- /package/dist/{remoteclaw-root-DybYl8PL.js → remoteclaw-root-bO85B6Kq.js} +0 -0
- /package/dist/{render-CCLsW6Lz.js → render-DrBfVs0u.js} +0 -0
- /package/dist/{retry-CxXVRdes.js → retry-B19gMxS7.js} +0 -0
- /package/dist/{retry-DnqPAqWp.js → retry-CByUYDAZ.js} +0 -0
- /package/dist/{runtime-DJNp29jv.js → runtime-Ds3E9SqF.js} +0 -0
- /package/dist/{runtime-guard-U-ewY_QH.js → runtime-guard-D-cp6ZAE.js} +0 -0
- /package/dist/{secret-equal-BbHdTtqY.js → secret-equal-CF39pFqv.js} +0 -0
- /package/dist/{secret-equal-CXJEZiWb.js → secret-equal-D7A3Bol7.js} +0 -0
- /package/dist/{secure-random-CS2mSdTn.js → secure-random-BOP0UuZY.js} +0 -0
- /package/dist/{session-key-5YLnn_qf.js → session-key-BF-9YzxC.js} +0 -0
- /package/dist/{stagger-BXv_apuy.js → stagger-CjeisVRF.js} +0 -0
- /package/dist/{stagger-MI9gd2rQ.js → stagger-Cu9_3JD_.js} +0 -0
- /package/dist/{status-BmtCS3T1.js → status-DaSGMHlt.js} +0 -0
- /package/dist/{status-BrwHRn2B.js → status-bTdQW3Mt.js} +0 -0
- /package/dist/{strip-inbound-meta-DjKcSFaW.js → strip-inbound-meta-0cvL6itU.js} +0 -0
- /package/dist/{strip-inbound-meta-jy3bkUab.js → strip-inbound-meta-DuDjnGjC.js} +0 -0
- /package/dist/{subsystem-CDhxwtDd.js → subsystem-SgROXN1v.js} +0 -0
- /package/dist/{table-C1rdyYl9.js → table-iXOQchYB.js} +0 -0
- /package/dist/{target-errors-BDpPcwh5.js → target-errors-ChjvOMuV.js} +0 -0
- /package/dist/{targets-D-qLBpTA.js → targets-B_d_1z3N.js} +0 -0
- /package/dist/{targets-UncQvCVs.js → targets-BtGRUQMa.js} +0 -0
- /package/dist/{targets-C-2xwh9f.js → targets-CE4AYRI9.js} +0 -0
- /package/dist/{targets-JCISV-hS.js → targets-D3WkRcT8.js} +0 -0
- /package/dist/{targets-BMenhVHg.js → targets-D3r6Zgic.js} +0 -0
- /package/dist/{targets-D7PT_rdO.js → targets-WSwPflb6.js} +0 -0
- /package/dist/{text-format-oWqzVmah.js → text-format-CahQpVRb.js} +0 -0
- /package/dist/{tokens-qLtFu3nT.js → tokens-DAFBx5qr.js} +0 -0
- /package/dist/{tokens-B-jmvNR9.js → tokens-gcZ7MOvD.js} +0 -0
- /package/dist/{usage-BdhBT0Vz.js → usage-C1lHaofV.js} +0 -0
- /package/dist/{usage-BtQcAnf6.js → usage-CRJFqYf8.js} +0 -0
- /package/dist/{usage-format-C3mNLfhI.js → usage-format-Bs8DkQtr.js} +0 -0
- /package/dist/{usage-format-DAaPzr_z.js → usage-format-CRVpDVj1.js} +0 -0
- /package/dist/{widearea-dns-CsmBVbez.js → widearea-dns-C5Fr8Rr1.js} +0 -0
- /package/dist/{widearea-dns-BXGCmXnD.js → widearea-dns-fETWNpyh.js} +0 -0
- /package/dist/{workspace-BzPeZDew.js → workspace-BIiYRjA3.js} +0 -0
- /package/dist/{wsl-BCnYV9O0.js → wsl-Cs-gowFJ.js} +0 -0
- /package/dist/{wsl-B_sPlzWw.js → wsl-mFuShVrc.js} +0 -0
package/dist/call-ByOzoLDI.js
DELETED
|
@@ -1,2829 +0,0 @@
|
|
|
1
|
-
import { h as resolveStateDir, o as resolveConfigPath, u as resolveGatewayPort } from "./paths-BTaH3rLn.js";
|
|
2
|
-
import { _ as resolveUserPath, o as ensureDir$1, t as CONFIG_DIR, y as shortenHomeInString } from "./utils-C5daYcFn.js";
|
|
3
|
-
import { d as GATEWAY_CLIENT_IDS, f as GATEWAY_CLIENT_MODES, p as GATEWAY_CLIENT_NAMES } from "./message-channel-BlYrtmIp.js";
|
|
4
|
-
import { i as loadConfig } from "./config-BqY7k-L8.js";
|
|
5
|
-
import { n as logError, t as logDebug } from "./logger-pznB_IdT.js";
|
|
6
|
-
import { t as INPUT_PROVENANCE_KIND_VALUES } from "./input-provenance-Bn6thJNm.js";
|
|
7
|
-
import { n as readJsonFile, r as writeJsonAtomic, t as createAsyncLock } from "./json-files-CmpYSF4G.js";
|
|
8
|
-
import { t as safeEqualSecret } from "./secret-equal-BbHdTtqY.js";
|
|
9
|
-
import { i as isSecureWebSocketUrl, p as rawDataToString } from "./net-D6D0wgcF.js";
|
|
10
|
-
import { t as resolveGatewayCredentialsFromConfig } from "./credentials-DFsi1_e8.js";
|
|
11
|
-
import fs from "node:fs";
|
|
12
|
-
import path from "node:path";
|
|
13
|
-
import { promisify } from "node:util";
|
|
14
|
-
import fs$1 from "node:fs/promises";
|
|
15
|
-
import crypto, { X509Certificate, randomBytes, randomUUID } from "node:crypto";
|
|
16
|
-
import { execFile } from "node:child_process";
|
|
17
|
-
import AjvPkg from "ajv";
|
|
18
|
-
import { WebSocket as WebSocket$1 } from "ws";
|
|
19
|
-
import { Type } from "@sinclair/typebox";
|
|
20
|
-
|
|
21
|
-
//#region src/infra/device-identity.ts
|
|
22
|
-
function resolveDefaultIdentityPath() {
|
|
23
|
-
return path.join(resolveStateDir(), "identity", "device.json");
|
|
24
|
-
}
|
|
25
|
-
function ensureDir(filePath) {
|
|
26
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
27
|
-
}
|
|
28
|
-
const ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
|
|
29
|
-
function base64UrlEncode(buf) {
|
|
30
|
-
return buf.toString("base64").replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/g, "");
|
|
31
|
-
}
|
|
32
|
-
function base64UrlDecode(input) {
|
|
33
|
-
const normalized = input.replaceAll("-", "+").replaceAll("_", "/");
|
|
34
|
-
const padded = normalized + "=".repeat((4 - normalized.length % 4) % 4);
|
|
35
|
-
return Buffer.from(padded, "base64");
|
|
36
|
-
}
|
|
37
|
-
function derivePublicKeyRaw(publicKeyPem) {
|
|
38
|
-
const spki = crypto.createPublicKey(publicKeyPem).export({
|
|
39
|
-
type: "spki",
|
|
40
|
-
format: "der"
|
|
41
|
-
});
|
|
42
|
-
if (spki.length === ED25519_SPKI_PREFIX.length + 32 && spki.subarray(0, ED25519_SPKI_PREFIX.length).equals(ED25519_SPKI_PREFIX)) return spki.subarray(ED25519_SPKI_PREFIX.length);
|
|
43
|
-
return spki;
|
|
44
|
-
}
|
|
45
|
-
function fingerprintPublicKey(publicKeyPem) {
|
|
46
|
-
const raw = derivePublicKeyRaw(publicKeyPem);
|
|
47
|
-
return crypto.createHash("sha256").update(raw).digest("hex");
|
|
48
|
-
}
|
|
49
|
-
function generateIdentity() {
|
|
50
|
-
const { publicKey, privateKey } = crypto.generateKeyPairSync("ed25519");
|
|
51
|
-
const publicKeyPem = publicKey.export({
|
|
52
|
-
type: "spki",
|
|
53
|
-
format: "pem"
|
|
54
|
-
}).toString();
|
|
55
|
-
const privateKeyPem = privateKey.export({
|
|
56
|
-
type: "pkcs8",
|
|
57
|
-
format: "pem"
|
|
58
|
-
}).toString();
|
|
59
|
-
return {
|
|
60
|
-
deviceId: fingerprintPublicKey(publicKeyPem),
|
|
61
|
-
publicKeyPem,
|
|
62
|
-
privateKeyPem
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function loadOrCreateDeviceIdentity(filePath = resolveDefaultIdentityPath()) {
|
|
66
|
-
try {
|
|
67
|
-
if (fs.existsSync(filePath)) {
|
|
68
|
-
const raw = fs.readFileSync(filePath, "utf8");
|
|
69
|
-
const parsed = JSON.parse(raw);
|
|
70
|
-
if (parsed?.version === 1 && typeof parsed.deviceId === "string" && typeof parsed.publicKeyPem === "string" && typeof parsed.privateKeyPem === "string") {
|
|
71
|
-
const derivedId = fingerprintPublicKey(parsed.publicKeyPem);
|
|
72
|
-
if (derivedId && derivedId !== parsed.deviceId) {
|
|
73
|
-
const updated = {
|
|
74
|
-
...parsed,
|
|
75
|
-
deviceId: derivedId
|
|
76
|
-
};
|
|
77
|
-
fs.writeFileSync(filePath, `${JSON.stringify(updated, null, 2)}\n`, { mode: 384 });
|
|
78
|
-
try {
|
|
79
|
-
fs.chmodSync(filePath, 384);
|
|
80
|
-
} catch {}
|
|
81
|
-
return {
|
|
82
|
-
deviceId: derivedId,
|
|
83
|
-
publicKeyPem: parsed.publicKeyPem,
|
|
84
|
-
privateKeyPem: parsed.privateKeyPem
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
deviceId: parsed.deviceId,
|
|
89
|
-
publicKeyPem: parsed.publicKeyPem,
|
|
90
|
-
privateKeyPem: parsed.privateKeyPem
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
} catch {}
|
|
95
|
-
const identity = generateIdentity();
|
|
96
|
-
ensureDir(filePath);
|
|
97
|
-
const stored = {
|
|
98
|
-
version: 1,
|
|
99
|
-
deviceId: identity.deviceId,
|
|
100
|
-
publicKeyPem: identity.publicKeyPem,
|
|
101
|
-
privateKeyPem: identity.privateKeyPem,
|
|
102
|
-
createdAtMs: Date.now()
|
|
103
|
-
};
|
|
104
|
-
fs.writeFileSync(filePath, `${JSON.stringify(stored, null, 2)}\n`, { mode: 384 });
|
|
105
|
-
try {
|
|
106
|
-
fs.chmodSync(filePath, 384);
|
|
107
|
-
} catch {}
|
|
108
|
-
return identity;
|
|
109
|
-
}
|
|
110
|
-
function signDevicePayload(privateKeyPem, payload) {
|
|
111
|
-
const key = crypto.createPrivateKey(privateKeyPem);
|
|
112
|
-
return base64UrlEncode(crypto.sign(null, Buffer.from(payload, "utf8"), key));
|
|
113
|
-
}
|
|
114
|
-
function normalizeDevicePublicKeyBase64Url(publicKey) {
|
|
115
|
-
try {
|
|
116
|
-
if (publicKey.includes("BEGIN")) return base64UrlEncode(derivePublicKeyRaw(publicKey));
|
|
117
|
-
return base64UrlEncode(base64UrlDecode(publicKey));
|
|
118
|
-
} catch {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function deriveDeviceIdFromPublicKey(publicKey) {
|
|
123
|
-
try {
|
|
124
|
-
const raw = publicKey.includes("BEGIN") ? derivePublicKeyRaw(publicKey) : base64UrlDecode(publicKey);
|
|
125
|
-
return crypto.createHash("sha256").update(raw).digest("hex");
|
|
126
|
-
} catch {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function publicKeyRawBase64UrlFromPem(publicKeyPem) {
|
|
131
|
-
return base64UrlEncode(derivePublicKeyRaw(publicKeyPem));
|
|
132
|
-
}
|
|
133
|
-
function verifyDeviceSignature(publicKey, payload, signatureBase64Url) {
|
|
134
|
-
try {
|
|
135
|
-
const key = publicKey.includes("BEGIN") ? crypto.createPublicKey(publicKey) : crypto.createPublicKey({
|
|
136
|
-
key: Buffer.concat([ED25519_SPKI_PREFIX, base64UrlDecode(publicKey)]),
|
|
137
|
-
type: "spki",
|
|
138
|
-
format: "der"
|
|
139
|
-
});
|
|
140
|
-
const sig = (() => {
|
|
141
|
-
try {
|
|
142
|
-
return base64UrlDecode(signatureBase64Url);
|
|
143
|
-
} catch {
|
|
144
|
-
return Buffer.from(signatureBase64Url, "base64");
|
|
145
|
-
}
|
|
146
|
-
})();
|
|
147
|
-
return crypto.verify(null, Buffer.from(payload, "utf8"), key, sig);
|
|
148
|
-
} catch {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/infra/tls/fingerprint.ts
|
|
155
|
-
function normalizeFingerprint(input) {
|
|
156
|
-
return input.trim().replace(/^sha-?256\s*:?\s*/i, "").replace(/[^a-fA-F0-9]/g, "").toLowerCase();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
//#endregion
|
|
160
|
-
//#region src/infra/tls/gateway.ts
|
|
161
|
-
const execFileAsync = promisify(execFile);
|
|
162
|
-
async function fileExists(filePath) {
|
|
163
|
-
try {
|
|
164
|
-
await fs$1.access(filePath);
|
|
165
|
-
return true;
|
|
166
|
-
} catch {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
async function generateSelfSignedCert(params) {
|
|
171
|
-
const certDir = path.dirname(params.certPath);
|
|
172
|
-
const keyDir = path.dirname(params.keyPath);
|
|
173
|
-
await ensureDir$1(certDir);
|
|
174
|
-
if (keyDir !== certDir) await ensureDir$1(keyDir);
|
|
175
|
-
await execFileAsync("openssl", [
|
|
176
|
-
"req",
|
|
177
|
-
"-x509",
|
|
178
|
-
"-newkey",
|
|
179
|
-
"rsa:2048",
|
|
180
|
-
"-sha256",
|
|
181
|
-
"-days",
|
|
182
|
-
"3650",
|
|
183
|
-
"-nodes",
|
|
184
|
-
"-keyout",
|
|
185
|
-
params.keyPath,
|
|
186
|
-
"-out",
|
|
187
|
-
params.certPath,
|
|
188
|
-
"-subj",
|
|
189
|
-
"/CN=remoteclaw-gateway"
|
|
190
|
-
]);
|
|
191
|
-
await fs$1.chmod(params.keyPath, 384).catch(() => {});
|
|
192
|
-
await fs$1.chmod(params.certPath, 384).catch(() => {});
|
|
193
|
-
params.log?.info?.(`gateway tls: generated self-signed cert at ${shortenHomeInString(params.certPath)}`);
|
|
194
|
-
}
|
|
195
|
-
async function loadGatewayTlsRuntime(cfg, log) {
|
|
196
|
-
if (!cfg || cfg.enabled !== true) return {
|
|
197
|
-
enabled: false,
|
|
198
|
-
required: false
|
|
199
|
-
};
|
|
200
|
-
const autoGenerate = cfg.autoGenerate !== false;
|
|
201
|
-
const baseDir = path.join(CONFIG_DIR, "gateway", "tls");
|
|
202
|
-
const certPath = resolveUserPath(cfg.certPath ?? path.join(baseDir, "gateway-cert.pem"));
|
|
203
|
-
const keyPath = resolveUserPath(cfg.keyPath ?? path.join(baseDir, "gateway-key.pem"));
|
|
204
|
-
const caPath = cfg.caPath ? resolveUserPath(cfg.caPath) : void 0;
|
|
205
|
-
const hasCert = await fileExists(certPath);
|
|
206
|
-
const hasKey = await fileExists(keyPath);
|
|
207
|
-
if (!hasCert && !hasKey && autoGenerate) try {
|
|
208
|
-
await generateSelfSignedCert({
|
|
209
|
-
certPath,
|
|
210
|
-
keyPath,
|
|
211
|
-
log
|
|
212
|
-
});
|
|
213
|
-
} catch (err) {
|
|
214
|
-
return {
|
|
215
|
-
enabled: false,
|
|
216
|
-
required: true,
|
|
217
|
-
certPath,
|
|
218
|
-
keyPath,
|
|
219
|
-
error: `gateway tls: failed to generate cert (${String(err)})`
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
if (!await fileExists(certPath) || !await fileExists(keyPath)) return {
|
|
223
|
-
enabled: false,
|
|
224
|
-
required: true,
|
|
225
|
-
certPath,
|
|
226
|
-
keyPath,
|
|
227
|
-
error: "gateway tls: cert/key missing"
|
|
228
|
-
};
|
|
229
|
-
try {
|
|
230
|
-
const cert = await fs$1.readFile(certPath, "utf8");
|
|
231
|
-
const key = await fs$1.readFile(keyPath, "utf8");
|
|
232
|
-
const ca = caPath ? await fs$1.readFile(caPath, "utf8") : void 0;
|
|
233
|
-
const fingerprintSha256 = normalizeFingerprint(new X509Certificate(cert).fingerprint256 ?? "");
|
|
234
|
-
if (!fingerprintSha256) return {
|
|
235
|
-
enabled: false,
|
|
236
|
-
required: true,
|
|
237
|
-
certPath,
|
|
238
|
-
keyPath,
|
|
239
|
-
caPath,
|
|
240
|
-
error: "gateway tls: unable to compute certificate fingerprint"
|
|
241
|
-
};
|
|
242
|
-
return {
|
|
243
|
-
enabled: true,
|
|
244
|
-
required: true,
|
|
245
|
-
certPath,
|
|
246
|
-
keyPath,
|
|
247
|
-
caPath,
|
|
248
|
-
fingerprintSha256,
|
|
249
|
-
tlsOptions: {
|
|
250
|
-
cert,
|
|
251
|
-
key,
|
|
252
|
-
ca,
|
|
253
|
-
minVersion: "TLSv1.3"
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
} catch (err) {
|
|
257
|
-
return {
|
|
258
|
-
enabled: false,
|
|
259
|
-
required: true,
|
|
260
|
-
certPath,
|
|
261
|
-
keyPath,
|
|
262
|
-
caPath,
|
|
263
|
-
error: `gateway tls: failed to load cert (${String(err)})`
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region src/shared/device-auth.ts
|
|
270
|
-
function normalizeDeviceAuthRole(role) {
|
|
271
|
-
return role.trim();
|
|
272
|
-
}
|
|
273
|
-
function normalizeDeviceAuthScopes(scopes) {
|
|
274
|
-
if (!Array.isArray(scopes)) return [];
|
|
275
|
-
const out = /* @__PURE__ */ new Set();
|
|
276
|
-
for (const scope of scopes) {
|
|
277
|
-
const trimmed = scope.trim();
|
|
278
|
-
if (trimmed) out.add(trimmed);
|
|
279
|
-
}
|
|
280
|
-
return [...out].toSorted();
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
//#endregion
|
|
284
|
-
//#region src/infra/device-auth-store.ts
|
|
285
|
-
const DEVICE_AUTH_FILE = "device-auth.json";
|
|
286
|
-
function resolveDeviceAuthPath(env = process.env) {
|
|
287
|
-
return path.join(resolveStateDir(env), "identity", DEVICE_AUTH_FILE);
|
|
288
|
-
}
|
|
289
|
-
function readStore(filePath) {
|
|
290
|
-
try {
|
|
291
|
-
if (!fs.existsSync(filePath)) return null;
|
|
292
|
-
const raw = fs.readFileSync(filePath, "utf8");
|
|
293
|
-
const parsed = JSON.parse(raw);
|
|
294
|
-
if (parsed?.version !== 1 || typeof parsed.deviceId !== "string") return null;
|
|
295
|
-
if (!parsed.tokens || typeof parsed.tokens !== "object") return null;
|
|
296
|
-
return parsed;
|
|
297
|
-
} catch {
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function writeStore(filePath, store) {
|
|
302
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
303
|
-
fs.writeFileSync(filePath, `${JSON.stringify(store, null, 2)}\n`, { mode: 384 });
|
|
304
|
-
try {
|
|
305
|
-
fs.chmodSync(filePath, 384);
|
|
306
|
-
} catch {}
|
|
307
|
-
}
|
|
308
|
-
function loadDeviceAuthToken(params) {
|
|
309
|
-
const store = readStore(resolveDeviceAuthPath(params.env));
|
|
310
|
-
if (!store) return null;
|
|
311
|
-
if (store.deviceId !== params.deviceId) return null;
|
|
312
|
-
const role = normalizeDeviceAuthRole(params.role);
|
|
313
|
-
const entry = store.tokens[role];
|
|
314
|
-
if (!entry || typeof entry.token !== "string") return null;
|
|
315
|
-
return entry;
|
|
316
|
-
}
|
|
317
|
-
function storeDeviceAuthToken(params) {
|
|
318
|
-
const filePath = resolveDeviceAuthPath(params.env);
|
|
319
|
-
const existing = readStore(filePath);
|
|
320
|
-
const role = normalizeDeviceAuthRole(params.role);
|
|
321
|
-
const next = {
|
|
322
|
-
version: 1,
|
|
323
|
-
deviceId: params.deviceId,
|
|
324
|
-
tokens: existing && existing.deviceId === params.deviceId && existing.tokens ? { ...existing.tokens } : {}
|
|
325
|
-
};
|
|
326
|
-
const entry = {
|
|
327
|
-
token: params.token,
|
|
328
|
-
role,
|
|
329
|
-
scopes: normalizeDeviceAuthScopes(params.scopes),
|
|
330
|
-
updatedAtMs: Date.now()
|
|
331
|
-
};
|
|
332
|
-
next.tokens[role] = entry;
|
|
333
|
-
writeStore(filePath, next);
|
|
334
|
-
return entry;
|
|
335
|
-
}
|
|
336
|
-
function clearDeviceAuthToken(params) {
|
|
337
|
-
const filePath = resolveDeviceAuthPath(params.env);
|
|
338
|
-
const store = readStore(filePath);
|
|
339
|
-
if (!store || store.deviceId !== params.deviceId) return;
|
|
340
|
-
const role = normalizeDeviceAuthRole(params.role);
|
|
341
|
-
if (!store.tokens[role]) return;
|
|
342
|
-
const next = {
|
|
343
|
-
version: 1,
|
|
344
|
-
deviceId: store.deviceId,
|
|
345
|
-
tokens: { ...store.tokens }
|
|
346
|
-
};
|
|
347
|
-
delete next.tokens[role];
|
|
348
|
-
writeStore(filePath, next);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
//#endregion
|
|
352
|
-
//#region src/shared/operator-scope-compat.ts
|
|
353
|
-
const OPERATOR_ROLE = "operator";
|
|
354
|
-
const OPERATOR_ADMIN_SCOPE = "operator.admin";
|
|
355
|
-
const OPERATOR_READ_SCOPE = "operator.read";
|
|
356
|
-
const OPERATOR_WRITE_SCOPE = "operator.write";
|
|
357
|
-
const OPERATOR_SCOPE_PREFIX = "operator.";
|
|
358
|
-
function normalizeScopeList(scopes) {
|
|
359
|
-
const out = /* @__PURE__ */ new Set();
|
|
360
|
-
for (const scope of scopes) {
|
|
361
|
-
const trimmed = scope.trim();
|
|
362
|
-
if (trimmed) out.add(trimmed);
|
|
363
|
-
}
|
|
364
|
-
return [...out];
|
|
365
|
-
}
|
|
366
|
-
function operatorScopeSatisfied(requestedScope, granted) {
|
|
367
|
-
if (granted.has(OPERATOR_ADMIN_SCOPE) && requestedScope.startsWith(OPERATOR_SCOPE_PREFIX)) return true;
|
|
368
|
-
if (requestedScope === OPERATOR_READ_SCOPE) return granted.has(OPERATOR_READ_SCOPE) || granted.has(OPERATOR_WRITE_SCOPE);
|
|
369
|
-
if (requestedScope === OPERATOR_WRITE_SCOPE) return granted.has(OPERATOR_WRITE_SCOPE);
|
|
370
|
-
return granted.has(requestedScope);
|
|
371
|
-
}
|
|
372
|
-
function roleScopesAllow(params) {
|
|
373
|
-
const requested = normalizeScopeList(params.requestedScopes);
|
|
374
|
-
if (requested.length === 0) return true;
|
|
375
|
-
const allowed = normalizeScopeList(params.allowedScopes);
|
|
376
|
-
if (allowed.length === 0) return false;
|
|
377
|
-
const allowedSet = new Set(allowed);
|
|
378
|
-
if (params.role.trim() !== OPERATOR_ROLE) return requested.every((scope) => allowedSet.has(scope));
|
|
379
|
-
return requested.every((scope) => operatorScopeSatisfied(scope, allowedSet));
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
//#endregion
|
|
383
|
-
//#region src/infra/pairing-files.ts
|
|
384
|
-
function resolvePairingPaths(baseDir, subdir) {
|
|
385
|
-
const root = baseDir ?? resolveStateDir();
|
|
386
|
-
const dir = path.join(root, subdir);
|
|
387
|
-
return {
|
|
388
|
-
dir,
|
|
389
|
-
pendingPath: path.join(dir, "pending.json"),
|
|
390
|
-
pairedPath: path.join(dir, "paired.json")
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
function pruneExpiredPending(pendingById, nowMs, ttlMs) {
|
|
394
|
-
for (const [id, req] of Object.entries(pendingById)) if (nowMs - req.ts > ttlMs) delete pendingById[id];
|
|
395
|
-
}
|
|
396
|
-
async function upsertPendingPairingRequest(params) {
|
|
397
|
-
const existing = Object.values(params.pendingById).find(params.isExisting);
|
|
398
|
-
if (existing) return {
|
|
399
|
-
status: "pending",
|
|
400
|
-
request: existing,
|
|
401
|
-
created: false
|
|
402
|
-
};
|
|
403
|
-
const request = params.createRequest(params.isRepair);
|
|
404
|
-
params.pendingById[request.requestId] = request;
|
|
405
|
-
await params.persist();
|
|
406
|
-
return {
|
|
407
|
-
status: "pending",
|
|
408
|
-
request,
|
|
409
|
-
created: true
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
//#endregion
|
|
414
|
-
//#region src/infra/pairing-pending.ts
|
|
415
|
-
async function rejectPendingPairingRequest(params) {
|
|
416
|
-
const state = await params.loadState();
|
|
417
|
-
const pending = state.pendingById[params.requestId];
|
|
418
|
-
if (!pending) return null;
|
|
419
|
-
delete state.pendingById[params.requestId];
|
|
420
|
-
await params.persistState(state);
|
|
421
|
-
return {
|
|
422
|
-
requestId: params.requestId,
|
|
423
|
-
[params.idKey]: params.getId(pending)
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region src/infra/pairing-token.ts
|
|
429
|
-
const PAIRING_TOKEN_BYTES = 32;
|
|
430
|
-
function generatePairingToken() {
|
|
431
|
-
return randomBytes(PAIRING_TOKEN_BYTES).toString("base64url");
|
|
432
|
-
}
|
|
433
|
-
function verifyPairingToken(provided, expected) {
|
|
434
|
-
return safeEqualSecret(provided, expected);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
//#endregion
|
|
438
|
-
//#region src/infra/device-pairing.ts
|
|
439
|
-
const PENDING_TTL_MS = 300 * 1e3;
|
|
440
|
-
const withLock = createAsyncLock();
|
|
441
|
-
async function loadState(baseDir) {
|
|
442
|
-
const { pendingPath, pairedPath } = resolvePairingPaths(baseDir, "devices");
|
|
443
|
-
const [pending, paired] = await Promise.all([readJsonFile(pendingPath), readJsonFile(pairedPath)]);
|
|
444
|
-
const state = {
|
|
445
|
-
pendingById: pending ?? {},
|
|
446
|
-
pairedByDeviceId: paired ?? {}
|
|
447
|
-
};
|
|
448
|
-
pruneExpiredPending(state.pendingById, Date.now(), PENDING_TTL_MS);
|
|
449
|
-
return state;
|
|
450
|
-
}
|
|
451
|
-
async function persistState(state, baseDir) {
|
|
452
|
-
const { pendingPath, pairedPath } = resolvePairingPaths(baseDir, "devices");
|
|
453
|
-
await Promise.all([writeJsonAtomic(pendingPath, state.pendingById), writeJsonAtomic(pairedPath, state.pairedByDeviceId)]);
|
|
454
|
-
}
|
|
455
|
-
function normalizeDeviceId(deviceId) {
|
|
456
|
-
return deviceId.trim();
|
|
457
|
-
}
|
|
458
|
-
function normalizeRole(role) {
|
|
459
|
-
const trimmed = role?.trim();
|
|
460
|
-
return trimmed ? trimmed : null;
|
|
461
|
-
}
|
|
462
|
-
function mergeRoles(...items) {
|
|
463
|
-
const roles = /* @__PURE__ */ new Set();
|
|
464
|
-
for (const item of items) {
|
|
465
|
-
if (!item) continue;
|
|
466
|
-
if (Array.isArray(item)) for (const role of item) {
|
|
467
|
-
const trimmed = role.trim();
|
|
468
|
-
if (trimmed) roles.add(trimmed);
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
const trimmed = item.trim();
|
|
472
|
-
if (trimmed) roles.add(trimmed);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
if (roles.size === 0) return;
|
|
476
|
-
return [...roles];
|
|
477
|
-
}
|
|
478
|
-
function mergeScopes(...items) {
|
|
479
|
-
const scopes = /* @__PURE__ */ new Set();
|
|
480
|
-
for (const item of items) {
|
|
481
|
-
if (!item) continue;
|
|
482
|
-
for (const scope of item) {
|
|
483
|
-
const trimmed = scope.trim();
|
|
484
|
-
if (trimmed) scopes.add(trimmed);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
if (scopes.size === 0) return;
|
|
488
|
-
return [...scopes];
|
|
489
|
-
}
|
|
490
|
-
function mergePendingDevicePairingRequest(existing, incoming, isRepair) {
|
|
491
|
-
const existingRole = normalizeRole(existing.role);
|
|
492
|
-
const incomingRole = normalizeRole(incoming.role);
|
|
493
|
-
return {
|
|
494
|
-
...existing,
|
|
495
|
-
displayName: incoming.displayName ?? existing.displayName,
|
|
496
|
-
platform: incoming.platform ?? existing.platform,
|
|
497
|
-
clientId: incoming.clientId ?? existing.clientId,
|
|
498
|
-
clientMode: incoming.clientMode ?? existing.clientMode,
|
|
499
|
-
role: existingRole ?? incomingRole ?? void 0,
|
|
500
|
-
roles: mergeRoles(existing.roles, existing.role, incoming.role),
|
|
501
|
-
scopes: mergeScopes(existing.scopes, incoming.scopes),
|
|
502
|
-
remoteIp: incoming.remoteIp ?? existing.remoteIp,
|
|
503
|
-
silent: Boolean(existing.silent && incoming.silent),
|
|
504
|
-
isRepair: existing.isRepair || isRepair,
|
|
505
|
-
ts: Date.now()
|
|
506
|
-
};
|
|
507
|
-
}
|
|
508
|
-
function scopesAllow(requested, allowed) {
|
|
509
|
-
if (requested.length === 0) return true;
|
|
510
|
-
if (allowed.length === 0) return false;
|
|
511
|
-
const allowedSet = new Set(allowed);
|
|
512
|
-
return requested.every((scope) => allowedSet.has(scope));
|
|
513
|
-
}
|
|
514
|
-
const DEVICE_SCOPE_IMPLICATIONS = {
|
|
515
|
-
"operator.admin": [
|
|
516
|
-
"operator.read",
|
|
517
|
-
"operator.write",
|
|
518
|
-
"operator.approvals",
|
|
519
|
-
"operator.pairing"
|
|
520
|
-
],
|
|
521
|
-
"operator.write": ["operator.read"]
|
|
522
|
-
};
|
|
523
|
-
function expandScopeImplications(scopes) {
|
|
524
|
-
const expanded = new Set(scopes);
|
|
525
|
-
const queue = [...scopes];
|
|
526
|
-
while (queue.length > 0) {
|
|
527
|
-
const scope = queue.pop();
|
|
528
|
-
if (!scope) continue;
|
|
529
|
-
for (const impliedScope of DEVICE_SCOPE_IMPLICATIONS[scope] ?? []) if (!expanded.has(impliedScope)) {
|
|
530
|
-
expanded.add(impliedScope);
|
|
531
|
-
queue.push(impliedScope);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
return [...expanded];
|
|
535
|
-
}
|
|
536
|
-
function scopesAllowWithImplications(requested, allowed) {
|
|
537
|
-
return scopesAllow(expandScopeImplications(requested), expandScopeImplications(allowed));
|
|
538
|
-
}
|
|
539
|
-
function newToken() {
|
|
540
|
-
return generatePairingToken();
|
|
541
|
-
}
|
|
542
|
-
function getPairedDeviceFromState(state, deviceId) {
|
|
543
|
-
return state.pairedByDeviceId[normalizeDeviceId(deviceId)] ?? null;
|
|
544
|
-
}
|
|
545
|
-
function cloneDeviceTokens(device) {
|
|
546
|
-
return device.tokens ? { ...device.tokens } : {};
|
|
547
|
-
}
|
|
548
|
-
function buildDeviceAuthToken(params) {
|
|
549
|
-
return {
|
|
550
|
-
token: newToken(),
|
|
551
|
-
role: params.role,
|
|
552
|
-
scopes: params.scopes,
|
|
553
|
-
createdAtMs: params.existing?.createdAtMs ?? params.now,
|
|
554
|
-
rotatedAtMs: params.rotatedAtMs,
|
|
555
|
-
revokedAtMs: void 0,
|
|
556
|
-
lastUsedAtMs: params.existing?.lastUsedAtMs
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
async function listDevicePairing(baseDir) {
|
|
560
|
-
const state = await loadState(baseDir);
|
|
561
|
-
return {
|
|
562
|
-
pending: Object.values(state.pendingById).toSorted((a, b) => b.ts - a.ts),
|
|
563
|
-
paired: Object.values(state.pairedByDeviceId).toSorted((a, b) => b.approvedAtMs - a.approvedAtMs)
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
async function getPairedDevice(deviceId, baseDir) {
|
|
567
|
-
return (await loadState(baseDir)).pairedByDeviceId[normalizeDeviceId(deviceId)] ?? null;
|
|
568
|
-
}
|
|
569
|
-
async function requestDevicePairing(req, baseDir) {
|
|
570
|
-
return await withLock(async () => {
|
|
571
|
-
const state = await loadState(baseDir);
|
|
572
|
-
const deviceId = normalizeDeviceId(req.deviceId);
|
|
573
|
-
if (!deviceId) throw new Error("deviceId required");
|
|
574
|
-
const isRepair = Boolean(state.pairedByDeviceId[deviceId]);
|
|
575
|
-
const existing = Object.values(state.pendingById).find((pending) => pending.deviceId === deviceId);
|
|
576
|
-
if (existing) {
|
|
577
|
-
const merged = mergePendingDevicePairingRequest(existing, req, isRepair);
|
|
578
|
-
state.pendingById[existing.requestId] = merged;
|
|
579
|
-
await persistState(state, baseDir);
|
|
580
|
-
return {
|
|
581
|
-
status: "pending",
|
|
582
|
-
request: merged,
|
|
583
|
-
created: false
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
const request = {
|
|
587
|
-
requestId: randomUUID(),
|
|
588
|
-
deviceId,
|
|
589
|
-
publicKey: req.publicKey,
|
|
590
|
-
displayName: req.displayName,
|
|
591
|
-
platform: req.platform,
|
|
592
|
-
clientId: req.clientId,
|
|
593
|
-
clientMode: req.clientMode,
|
|
594
|
-
role: req.role,
|
|
595
|
-
roles: req.role ? [req.role] : void 0,
|
|
596
|
-
scopes: req.scopes,
|
|
597
|
-
remoteIp: req.remoteIp,
|
|
598
|
-
silent: req.silent,
|
|
599
|
-
isRepair,
|
|
600
|
-
ts: Date.now()
|
|
601
|
-
};
|
|
602
|
-
state.pendingById[request.requestId] = request;
|
|
603
|
-
await persistState(state, baseDir);
|
|
604
|
-
return {
|
|
605
|
-
status: "pending",
|
|
606
|
-
request,
|
|
607
|
-
created: true
|
|
608
|
-
};
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
async function approveDevicePairing(requestId, baseDir) {
|
|
612
|
-
return await withLock(async () => {
|
|
613
|
-
const state = await loadState(baseDir);
|
|
614
|
-
const pending = state.pendingById[requestId];
|
|
615
|
-
if (!pending) return null;
|
|
616
|
-
const now = Date.now();
|
|
617
|
-
const existing = state.pairedByDeviceId[pending.deviceId];
|
|
618
|
-
const roles = mergeRoles(existing?.roles, existing?.role, pending.roles, pending.role);
|
|
619
|
-
const approvedScopes = mergeScopes(existing?.approvedScopes ?? existing?.scopes, pending.scopes);
|
|
620
|
-
const tokens = existing?.tokens ? { ...existing.tokens } : {};
|
|
621
|
-
const roleForToken = normalizeRole(pending.role);
|
|
622
|
-
if (roleForToken) {
|
|
623
|
-
const existingToken = tokens[roleForToken];
|
|
624
|
-
const requestedScopes = normalizeDeviceAuthScopes(pending.scopes);
|
|
625
|
-
const nextScopes = requestedScopes.length > 0 ? requestedScopes : normalizeDeviceAuthScopes(existingToken?.scopes ?? approvedScopes ?? existing?.approvedScopes ?? existing?.scopes);
|
|
626
|
-
const now = Date.now();
|
|
627
|
-
tokens[roleForToken] = {
|
|
628
|
-
token: newToken(),
|
|
629
|
-
role: roleForToken,
|
|
630
|
-
scopes: nextScopes,
|
|
631
|
-
createdAtMs: existingToken?.createdAtMs ?? now,
|
|
632
|
-
rotatedAtMs: existingToken ? now : void 0,
|
|
633
|
-
revokedAtMs: void 0,
|
|
634
|
-
lastUsedAtMs: existingToken?.lastUsedAtMs
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
|
-
const device = {
|
|
638
|
-
deviceId: pending.deviceId,
|
|
639
|
-
publicKey: pending.publicKey,
|
|
640
|
-
displayName: pending.displayName,
|
|
641
|
-
platform: pending.platform,
|
|
642
|
-
clientId: pending.clientId,
|
|
643
|
-
clientMode: pending.clientMode,
|
|
644
|
-
role: pending.role,
|
|
645
|
-
roles,
|
|
646
|
-
scopes: approvedScopes,
|
|
647
|
-
approvedScopes,
|
|
648
|
-
remoteIp: pending.remoteIp,
|
|
649
|
-
tokens,
|
|
650
|
-
createdAtMs: existing?.createdAtMs ?? now,
|
|
651
|
-
approvedAtMs: now
|
|
652
|
-
};
|
|
653
|
-
delete state.pendingById[requestId];
|
|
654
|
-
state.pairedByDeviceId[device.deviceId] = device;
|
|
655
|
-
await persistState(state, baseDir);
|
|
656
|
-
return {
|
|
657
|
-
requestId,
|
|
658
|
-
device
|
|
659
|
-
};
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
async function rejectDevicePairing(requestId, baseDir) {
|
|
663
|
-
return await withLock(async () => {
|
|
664
|
-
return await rejectPendingPairingRequest({
|
|
665
|
-
requestId,
|
|
666
|
-
idKey: "deviceId",
|
|
667
|
-
loadState: () => loadState(baseDir),
|
|
668
|
-
persistState: (state) => persistState(state, baseDir),
|
|
669
|
-
getId: (pending) => pending.deviceId
|
|
670
|
-
});
|
|
671
|
-
});
|
|
672
|
-
}
|
|
673
|
-
async function removePairedDevice(deviceId, baseDir) {
|
|
674
|
-
return await withLock(async () => {
|
|
675
|
-
const state = await loadState(baseDir);
|
|
676
|
-
const normalized = normalizeDeviceId(deviceId);
|
|
677
|
-
if (!normalized || !state.pairedByDeviceId[normalized]) return null;
|
|
678
|
-
delete state.pairedByDeviceId[normalized];
|
|
679
|
-
await persistState(state, baseDir);
|
|
680
|
-
return { deviceId: normalized };
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
async function updatePairedDeviceMetadata(deviceId, patch, baseDir) {
|
|
684
|
-
return await withLock(async () => {
|
|
685
|
-
const state = await loadState(baseDir);
|
|
686
|
-
const existing = state.pairedByDeviceId[normalizeDeviceId(deviceId)];
|
|
687
|
-
if (!existing) return;
|
|
688
|
-
const roles = mergeRoles(existing.roles, existing.role, patch.role);
|
|
689
|
-
const scopes = mergeScopes(existing.scopes, patch.scopes);
|
|
690
|
-
state.pairedByDeviceId[deviceId] = {
|
|
691
|
-
...existing,
|
|
692
|
-
...patch,
|
|
693
|
-
deviceId: existing.deviceId,
|
|
694
|
-
createdAtMs: existing.createdAtMs,
|
|
695
|
-
approvedAtMs: existing.approvedAtMs,
|
|
696
|
-
approvedScopes: existing.approvedScopes,
|
|
697
|
-
role: patch.role ?? existing.role,
|
|
698
|
-
roles,
|
|
699
|
-
scopes
|
|
700
|
-
};
|
|
701
|
-
await persistState(state, baseDir);
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
function summarizeDeviceTokens(tokens) {
|
|
705
|
-
if (!tokens) return;
|
|
706
|
-
const summaries = Object.values(tokens).map((token) => ({
|
|
707
|
-
role: token.role,
|
|
708
|
-
scopes: token.scopes,
|
|
709
|
-
createdAtMs: token.createdAtMs,
|
|
710
|
-
rotatedAtMs: token.rotatedAtMs,
|
|
711
|
-
revokedAtMs: token.revokedAtMs,
|
|
712
|
-
lastUsedAtMs: token.lastUsedAtMs
|
|
713
|
-
})).toSorted((a, b) => a.role.localeCompare(b.role));
|
|
714
|
-
return summaries.length > 0 ? summaries : void 0;
|
|
715
|
-
}
|
|
716
|
-
async function verifyDeviceToken(params) {
|
|
717
|
-
return await withLock(async () => {
|
|
718
|
-
const state = await loadState(params.baseDir);
|
|
719
|
-
const device = getPairedDeviceFromState(state, params.deviceId);
|
|
720
|
-
if (!device) return {
|
|
721
|
-
ok: false,
|
|
722
|
-
reason: "device-not-paired"
|
|
723
|
-
};
|
|
724
|
-
const role = normalizeRole(params.role);
|
|
725
|
-
if (!role) return {
|
|
726
|
-
ok: false,
|
|
727
|
-
reason: "role-missing"
|
|
728
|
-
};
|
|
729
|
-
const entry = device.tokens?.[role];
|
|
730
|
-
if (!entry) return {
|
|
731
|
-
ok: false,
|
|
732
|
-
reason: "token-missing"
|
|
733
|
-
};
|
|
734
|
-
if (entry.revokedAtMs) return {
|
|
735
|
-
ok: false,
|
|
736
|
-
reason: "token-revoked"
|
|
737
|
-
};
|
|
738
|
-
if (!verifyPairingToken(params.token, entry.token)) return {
|
|
739
|
-
ok: false,
|
|
740
|
-
reason: "token-mismatch"
|
|
741
|
-
};
|
|
742
|
-
if (!roleScopesAllow({
|
|
743
|
-
role,
|
|
744
|
-
requestedScopes: normalizeDeviceAuthScopes(params.scopes),
|
|
745
|
-
allowedScopes: entry.scopes
|
|
746
|
-
})) return {
|
|
747
|
-
ok: false,
|
|
748
|
-
reason: "scope-mismatch"
|
|
749
|
-
};
|
|
750
|
-
entry.lastUsedAtMs = Date.now();
|
|
751
|
-
device.tokens ??= {};
|
|
752
|
-
device.tokens[role] = entry;
|
|
753
|
-
state.pairedByDeviceId[device.deviceId] = device;
|
|
754
|
-
await persistState(state, params.baseDir);
|
|
755
|
-
return { ok: true };
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
async function ensureDeviceToken(params) {
|
|
759
|
-
return await withLock(async () => {
|
|
760
|
-
const state = await loadState(params.baseDir);
|
|
761
|
-
const requestedScopes = normalizeDeviceAuthScopes(params.scopes);
|
|
762
|
-
const context = resolveDeviceTokenUpdateContext({
|
|
763
|
-
state,
|
|
764
|
-
deviceId: params.deviceId,
|
|
765
|
-
role: params.role
|
|
766
|
-
});
|
|
767
|
-
if (!context) return null;
|
|
768
|
-
const { device, role, tokens, existing } = context;
|
|
769
|
-
if (existing && !existing.revokedAtMs) {
|
|
770
|
-
if (roleScopesAllow({
|
|
771
|
-
role,
|
|
772
|
-
requestedScopes,
|
|
773
|
-
allowedScopes: existing.scopes
|
|
774
|
-
})) return existing;
|
|
775
|
-
}
|
|
776
|
-
const now = Date.now();
|
|
777
|
-
const next = buildDeviceAuthToken({
|
|
778
|
-
role,
|
|
779
|
-
scopes: requestedScopes,
|
|
780
|
-
existing,
|
|
781
|
-
now,
|
|
782
|
-
rotatedAtMs: existing ? now : void 0
|
|
783
|
-
});
|
|
784
|
-
tokens[role] = next;
|
|
785
|
-
device.tokens = tokens;
|
|
786
|
-
state.pairedByDeviceId[device.deviceId] = device;
|
|
787
|
-
await persistState(state, params.baseDir);
|
|
788
|
-
return next;
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
function resolveDeviceTokenUpdateContext(params) {
|
|
792
|
-
const device = getPairedDeviceFromState(params.state, params.deviceId);
|
|
793
|
-
if (!device) return null;
|
|
794
|
-
const role = normalizeRole(params.role);
|
|
795
|
-
if (!role) return null;
|
|
796
|
-
const tokens = cloneDeviceTokens(device);
|
|
797
|
-
return {
|
|
798
|
-
device,
|
|
799
|
-
role,
|
|
800
|
-
tokens,
|
|
801
|
-
existing: tokens[role]
|
|
802
|
-
};
|
|
803
|
-
}
|
|
804
|
-
async function rotateDeviceToken(params) {
|
|
805
|
-
return await withLock(async () => {
|
|
806
|
-
const state = await loadState(params.baseDir);
|
|
807
|
-
const context = resolveDeviceTokenUpdateContext({
|
|
808
|
-
state,
|
|
809
|
-
deviceId: params.deviceId,
|
|
810
|
-
role: params.role
|
|
811
|
-
});
|
|
812
|
-
if (!context) return null;
|
|
813
|
-
const { device, role, tokens, existing } = context;
|
|
814
|
-
const requestedScopes = normalizeDeviceAuthScopes(params.scopes ?? existing?.scopes ?? device.scopes);
|
|
815
|
-
if (!scopesAllowWithImplications(requestedScopes, normalizeDeviceAuthScopes(device.approvedScopes ?? device.scopes ?? existing?.scopes))) return null;
|
|
816
|
-
const now = Date.now();
|
|
817
|
-
const next = buildDeviceAuthToken({
|
|
818
|
-
role,
|
|
819
|
-
scopes: requestedScopes,
|
|
820
|
-
existing,
|
|
821
|
-
now,
|
|
822
|
-
rotatedAtMs: now
|
|
823
|
-
});
|
|
824
|
-
tokens[role] = next;
|
|
825
|
-
device.tokens = tokens;
|
|
826
|
-
state.pairedByDeviceId[device.deviceId] = device;
|
|
827
|
-
await persistState(state, params.baseDir);
|
|
828
|
-
return next;
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
async function revokeDeviceToken(params) {
|
|
832
|
-
return await withLock(async () => {
|
|
833
|
-
const state = await loadState(params.baseDir);
|
|
834
|
-
const device = state.pairedByDeviceId[normalizeDeviceId(params.deviceId)];
|
|
835
|
-
if (!device) return null;
|
|
836
|
-
const role = normalizeRole(params.role);
|
|
837
|
-
if (!role) return null;
|
|
838
|
-
if (!device.tokens?.[role]) return null;
|
|
839
|
-
const tokens = { ...device.tokens };
|
|
840
|
-
const entry = {
|
|
841
|
-
...tokens[role],
|
|
842
|
-
revokedAtMs: Date.now()
|
|
843
|
-
};
|
|
844
|
-
tokens[role] = entry;
|
|
845
|
-
device.tokens = tokens;
|
|
846
|
-
state.pairedByDeviceId[device.deviceId] = device;
|
|
847
|
-
await persistState(state, params.baseDir);
|
|
848
|
-
return entry;
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
async function clearDevicePairing(deviceId, baseDir) {
|
|
852
|
-
return await withLock(async () => {
|
|
853
|
-
const state = await loadState(baseDir);
|
|
854
|
-
const normalizedId = normalizeDeviceId(deviceId);
|
|
855
|
-
if (!state.pairedByDeviceId[normalizedId]) return false;
|
|
856
|
-
delete state.pairedByDeviceId[normalizedId];
|
|
857
|
-
await persistState(state, baseDir);
|
|
858
|
-
return true;
|
|
859
|
-
});
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
//#endregion
|
|
863
|
-
//#region src/gateway/device-auth.ts
|
|
864
|
-
function buildDeviceAuthPayload(params) {
|
|
865
|
-
const scopes = params.scopes.join(",");
|
|
866
|
-
const token = params.token ?? "";
|
|
867
|
-
return [
|
|
868
|
-
"v2",
|
|
869
|
-
params.deviceId,
|
|
870
|
-
params.clientId,
|
|
871
|
-
params.clientMode,
|
|
872
|
-
params.role,
|
|
873
|
-
scopes,
|
|
874
|
-
String(params.signedAtMs),
|
|
875
|
-
token,
|
|
876
|
-
params.nonce
|
|
877
|
-
].join("|");
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
//#endregion
|
|
881
|
-
//#region src/sessions/session-label.ts
|
|
882
|
-
const SESSION_LABEL_MAX_LENGTH = 64;
|
|
883
|
-
function parseSessionLabel(raw) {
|
|
884
|
-
if (typeof raw !== "string") return {
|
|
885
|
-
ok: false,
|
|
886
|
-
error: "invalid label: must be a string"
|
|
887
|
-
};
|
|
888
|
-
const trimmed = raw.trim();
|
|
889
|
-
if (!trimmed) return {
|
|
890
|
-
ok: false,
|
|
891
|
-
error: "invalid label: empty"
|
|
892
|
-
};
|
|
893
|
-
if (trimmed.length > SESSION_LABEL_MAX_LENGTH) return {
|
|
894
|
-
ok: false,
|
|
895
|
-
error: `invalid label: too long (max ${SESSION_LABEL_MAX_LENGTH})`
|
|
896
|
-
};
|
|
897
|
-
return {
|
|
898
|
-
ok: true,
|
|
899
|
-
label: trimmed
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
//#endregion
|
|
904
|
-
//#region src/gateway/protocol/schema/primitives.ts
|
|
905
|
-
const NonEmptyString = Type.String({ minLength: 1 });
|
|
906
|
-
const SessionLabelString = Type.String({
|
|
907
|
-
minLength: 1,
|
|
908
|
-
maxLength: SESSION_LABEL_MAX_LENGTH
|
|
909
|
-
});
|
|
910
|
-
const GatewayClientIdSchema = Type.Union(Object.values(GATEWAY_CLIENT_IDS).map((value) => Type.Literal(value)));
|
|
911
|
-
const GatewayClientModeSchema = Type.Union(Object.values(GATEWAY_CLIENT_MODES).map((value) => Type.Literal(value)));
|
|
912
|
-
|
|
913
|
-
//#endregion
|
|
914
|
-
//#region src/gateway/protocol/schema/agent.ts
|
|
915
|
-
const AgentEventSchema = Type.Object({
|
|
916
|
-
runId: NonEmptyString,
|
|
917
|
-
seq: Type.Integer({ minimum: 0 }),
|
|
918
|
-
stream: NonEmptyString,
|
|
919
|
-
ts: Type.Integer({ minimum: 0 }),
|
|
920
|
-
data: Type.Record(Type.String(), Type.Unknown())
|
|
921
|
-
}, { additionalProperties: false });
|
|
922
|
-
const SendParamsSchema = Type.Object({
|
|
923
|
-
to: NonEmptyString,
|
|
924
|
-
message: Type.Optional(Type.String()),
|
|
925
|
-
mediaUrl: Type.Optional(Type.String()),
|
|
926
|
-
mediaUrls: Type.Optional(Type.Array(Type.String())),
|
|
927
|
-
gifPlayback: Type.Optional(Type.Boolean()),
|
|
928
|
-
channel: Type.Optional(Type.String()),
|
|
929
|
-
accountId: Type.Optional(Type.String()),
|
|
930
|
-
threadId: Type.Optional(Type.String()),
|
|
931
|
-
sessionKey: Type.Optional(Type.String()),
|
|
932
|
-
idempotencyKey: NonEmptyString
|
|
933
|
-
}, { additionalProperties: false });
|
|
934
|
-
const PollParamsSchema = Type.Object({
|
|
935
|
-
to: NonEmptyString,
|
|
936
|
-
question: NonEmptyString,
|
|
937
|
-
options: Type.Array(NonEmptyString, {
|
|
938
|
-
minItems: 2,
|
|
939
|
-
maxItems: 12
|
|
940
|
-
}),
|
|
941
|
-
maxSelections: Type.Optional(Type.Integer({
|
|
942
|
-
minimum: 1,
|
|
943
|
-
maximum: 12
|
|
944
|
-
})),
|
|
945
|
-
durationSeconds: Type.Optional(Type.Integer({
|
|
946
|
-
minimum: 1,
|
|
947
|
-
maximum: 604800
|
|
948
|
-
})),
|
|
949
|
-
durationHours: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
950
|
-
silent: Type.Optional(Type.Boolean()),
|
|
951
|
-
isAnonymous: Type.Optional(Type.Boolean()),
|
|
952
|
-
threadId: Type.Optional(Type.String()),
|
|
953
|
-
channel: Type.Optional(Type.String()),
|
|
954
|
-
accountId: Type.Optional(Type.String()),
|
|
955
|
-
idempotencyKey: NonEmptyString
|
|
956
|
-
}, { additionalProperties: false });
|
|
957
|
-
const AgentParamsSchema = Type.Object({
|
|
958
|
-
message: NonEmptyString,
|
|
959
|
-
agentId: Type.Optional(NonEmptyString),
|
|
960
|
-
to: Type.Optional(Type.String()),
|
|
961
|
-
replyTo: Type.Optional(Type.String()),
|
|
962
|
-
sessionId: Type.Optional(Type.String()),
|
|
963
|
-
sessionKey: Type.Optional(Type.String()),
|
|
964
|
-
thinking: Type.Optional(Type.String()),
|
|
965
|
-
deliver: Type.Optional(Type.Boolean()),
|
|
966
|
-
attachments: Type.Optional(Type.Array(Type.Unknown())),
|
|
967
|
-
channel: Type.Optional(Type.String()),
|
|
968
|
-
replyChannel: Type.Optional(Type.String()),
|
|
969
|
-
accountId: Type.Optional(Type.String()),
|
|
970
|
-
replyAccountId: Type.Optional(Type.String()),
|
|
971
|
-
threadId: Type.Optional(Type.String()),
|
|
972
|
-
groupId: Type.Optional(Type.String()),
|
|
973
|
-
groupChannel: Type.Optional(Type.String()),
|
|
974
|
-
groupSpace: Type.Optional(Type.String()),
|
|
975
|
-
timeout: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
976
|
-
bestEffortDeliver: Type.Optional(Type.Boolean()),
|
|
977
|
-
lane: Type.Optional(Type.String()),
|
|
978
|
-
extraSystemPrompt: Type.Optional(Type.String()),
|
|
979
|
-
inputProvenance: Type.Optional(Type.Object({
|
|
980
|
-
kind: Type.String({ enum: [...INPUT_PROVENANCE_KIND_VALUES] }),
|
|
981
|
-
sourceSessionKey: Type.Optional(Type.String()),
|
|
982
|
-
sourceChannel: Type.Optional(Type.String()),
|
|
983
|
-
sourceTool: Type.Optional(Type.String())
|
|
984
|
-
}, { additionalProperties: false })),
|
|
985
|
-
idempotencyKey: NonEmptyString,
|
|
986
|
-
label: Type.Optional(SessionLabelString),
|
|
987
|
-
spawnedBy: Type.Optional(Type.String())
|
|
988
|
-
}, { additionalProperties: false });
|
|
989
|
-
const AgentIdentityParamsSchema = Type.Object({
|
|
990
|
-
agentId: Type.Optional(NonEmptyString),
|
|
991
|
-
sessionKey: Type.Optional(Type.String())
|
|
992
|
-
}, { additionalProperties: false });
|
|
993
|
-
const AgentIdentityResultSchema = Type.Object({
|
|
994
|
-
agentId: NonEmptyString,
|
|
995
|
-
name: Type.Optional(NonEmptyString),
|
|
996
|
-
avatar: Type.Optional(NonEmptyString),
|
|
997
|
-
emoji: Type.Optional(NonEmptyString)
|
|
998
|
-
}, { additionalProperties: false });
|
|
999
|
-
const AgentWaitParamsSchema = Type.Object({
|
|
1000
|
-
runId: NonEmptyString,
|
|
1001
|
-
timeoutMs: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
1002
|
-
}, { additionalProperties: false });
|
|
1003
|
-
const WakeParamsSchema = Type.Object({
|
|
1004
|
-
mode: Type.Union([Type.Literal("now"), Type.Literal("next-heartbeat")]),
|
|
1005
|
-
text: NonEmptyString
|
|
1006
|
-
}, { additionalProperties: false });
|
|
1007
|
-
|
|
1008
|
-
//#endregion
|
|
1009
|
-
//#region src/gateway/protocol/schema/agents-models-skills.ts
|
|
1010
|
-
const ModelChoiceSchema = Type.Object({
|
|
1011
|
-
id: NonEmptyString,
|
|
1012
|
-
name: NonEmptyString,
|
|
1013
|
-
provider: NonEmptyString,
|
|
1014
|
-
contextWindow: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
1015
|
-
reasoning: Type.Optional(Type.Boolean())
|
|
1016
|
-
}, { additionalProperties: false });
|
|
1017
|
-
const AgentSummarySchema = Type.Object({
|
|
1018
|
-
id: NonEmptyString,
|
|
1019
|
-
name: Type.Optional(NonEmptyString),
|
|
1020
|
-
identity: Type.Optional(Type.Object({
|
|
1021
|
-
name: Type.Optional(NonEmptyString),
|
|
1022
|
-
theme: Type.Optional(NonEmptyString),
|
|
1023
|
-
emoji: Type.Optional(NonEmptyString),
|
|
1024
|
-
avatar: Type.Optional(NonEmptyString),
|
|
1025
|
-
avatarUrl: Type.Optional(NonEmptyString)
|
|
1026
|
-
}, { additionalProperties: false }))
|
|
1027
|
-
}, { additionalProperties: false });
|
|
1028
|
-
const AgentsListParamsSchema = Type.Object({}, { additionalProperties: false });
|
|
1029
|
-
const AgentsListResultSchema = Type.Object({
|
|
1030
|
-
defaultId: NonEmptyString,
|
|
1031
|
-
mainKey: NonEmptyString,
|
|
1032
|
-
scope: Type.Union([Type.Literal("per-sender"), Type.Literal("global")]),
|
|
1033
|
-
agents: Type.Array(AgentSummarySchema)
|
|
1034
|
-
}, { additionalProperties: false });
|
|
1035
|
-
const AgentsCreateParamsSchema = Type.Object({
|
|
1036
|
-
name: NonEmptyString,
|
|
1037
|
-
workspace: NonEmptyString,
|
|
1038
|
-
emoji: Type.Optional(Type.String()),
|
|
1039
|
-
avatar: Type.Optional(Type.String())
|
|
1040
|
-
}, { additionalProperties: false });
|
|
1041
|
-
const AgentsCreateResultSchema = Type.Object({
|
|
1042
|
-
ok: Type.Literal(true),
|
|
1043
|
-
agentId: NonEmptyString,
|
|
1044
|
-
name: NonEmptyString,
|
|
1045
|
-
workspace: NonEmptyString
|
|
1046
|
-
}, { additionalProperties: false });
|
|
1047
|
-
const AgentsUpdateParamsSchema = Type.Object({
|
|
1048
|
-
agentId: NonEmptyString,
|
|
1049
|
-
name: Type.Optional(NonEmptyString),
|
|
1050
|
-
workspace: Type.Optional(NonEmptyString),
|
|
1051
|
-
model: Type.Optional(NonEmptyString),
|
|
1052
|
-
avatar: Type.Optional(Type.String())
|
|
1053
|
-
}, { additionalProperties: false });
|
|
1054
|
-
const AgentsUpdateResultSchema = Type.Object({
|
|
1055
|
-
ok: Type.Literal(true),
|
|
1056
|
-
agentId: NonEmptyString
|
|
1057
|
-
}, { additionalProperties: false });
|
|
1058
|
-
const AgentsDeleteParamsSchema = Type.Object({
|
|
1059
|
-
agentId: NonEmptyString,
|
|
1060
|
-
deleteFiles: Type.Optional(Type.Boolean())
|
|
1061
|
-
}, { additionalProperties: false });
|
|
1062
|
-
const AgentsDeleteResultSchema = Type.Object({
|
|
1063
|
-
ok: Type.Literal(true),
|
|
1064
|
-
agentId: NonEmptyString,
|
|
1065
|
-
removedBindings: Type.Integer({ minimum: 0 })
|
|
1066
|
-
}, { additionalProperties: false });
|
|
1067
|
-
const AgentsFileEntrySchema = Type.Object({
|
|
1068
|
-
name: NonEmptyString,
|
|
1069
|
-
path: NonEmptyString,
|
|
1070
|
-
missing: Type.Boolean(),
|
|
1071
|
-
size: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1072
|
-
updatedAtMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1073
|
-
content: Type.Optional(Type.String())
|
|
1074
|
-
}, { additionalProperties: false });
|
|
1075
|
-
const AgentsFilesListParamsSchema = Type.Object({ agentId: NonEmptyString }, { additionalProperties: false });
|
|
1076
|
-
const AgentsFilesListResultSchema = Type.Object({
|
|
1077
|
-
agentId: NonEmptyString,
|
|
1078
|
-
workspace: NonEmptyString,
|
|
1079
|
-
files: Type.Array(AgentsFileEntrySchema)
|
|
1080
|
-
}, { additionalProperties: false });
|
|
1081
|
-
const AgentsFilesGetParamsSchema = Type.Object({
|
|
1082
|
-
agentId: NonEmptyString,
|
|
1083
|
-
name: NonEmptyString
|
|
1084
|
-
}, { additionalProperties: false });
|
|
1085
|
-
const AgentsFilesGetResultSchema = Type.Object({
|
|
1086
|
-
agentId: NonEmptyString,
|
|
1087
|
-
workspace: NonEmptyString,
|
|
1088
|
-
file: AgentsFileEntrySchema
|
|
1089
|
-
}, { additionalProperties: false });
|
|
1090
|
-
const AgentsFilesSetParamsSchema = Type.Object({
|
|
1091
|
-
agentId: NonEmptyString,
|
|
1092
|
-
name: NonEmptyString,
|
|
1093
|
-
content: Type.String()
|
|
1094
|
-
}, { additionalProperties: false });
|
|
1095
|
-
const AgentsFilesSetResultSchema = Type.Object({
|
|
1096
|
-
ok: Type.Literal(true),
|
|
1097
|
-
agentId: NonEmptyString,
|
|
1098
|
-
workspace: NonEmptyString,
|
|
1099
|
-
file: AgentsFileEntrySchema
|
|
1100
|
-
}, { additionalProperties: false });
|
|
1101
|
-
const ModelsListParamsSchema = Type.Object({}, { additionalProperties: false });
|
|
1102
|
-
const ModelsListResultSchema = Type.Object({ models: Type.Array(ModelChoiceSchema) }, { additionalProperties: false });
|
|
1103
|
-
const ToolsCatalogParamsSchema = Type.Object({
|
|
1104
|
-
agentId: Type.Optional(NonEmptyString),
|
|
1105
|
-
includePlugins: Type.Optional(Type.Boolean())
|
|
1106
|
-
}, { additionalProperties: false });
|
|
1107
|
-
const ToolCatalogProfileSchema = Type.Object({
|
|
1108
|
-
id: Type.Union([
|
|
1109
|
-
Type.Literal("minimal"),
|
|
1110
|
-
Type.Literal("coding"),
|
|
1111
|
-
Type.Literal("messaging"),
|
|
1112
|
-
Type.Literal("full")
|
|
1113
|
-
]),
|
|
1114
|
-
label: NonEmptyString
|
|
1115
|
-
}, { additionalProperties: false });
|
|
1116
|
-
const ToolCatalogEntrySchema = Type.Object({
|
|
1117
|
-
id: NonEmptyString,
|
|
1118
|
-
label: NonEmptyString,
|
|
1119
|
-
description: Type.String(),
|
|
1120
|
-
source: Type.Union([Type.Literal("core"), Type.Literal("plugin")]),
|
|
1121
|
-
pluginId: Type.Optional(NonEmptyString),
|
|
1122
|
-
optional: Type.Optional(Type.Boolean()),
|
|
1123
|
-
defaultProfiles: Type.Array(Type.Union([
|
|
1124
|
-
Type.Literal("minimal"),
|
|
1125
|
-
Type.Literal("coding"),
|
|
1126
|
-
Type.Literal("messaging"),
|
|
1127
|
-
Type.Literal("full")
|
|
1128
|
-
]))
|
|
1129
|
-
}, { additionalProperties: false });
|
|
1130
|
-
const ToolCatalogGroupSchema = Type.Object({
|
|
1131
|
-
id: NonEmptyString,
|
|
1132
|
-
label: NonEmptyString,
|
|
1133
|
-
source: Type.Union([Type.Literal("core"), Type.Literal("plugin")]),
|
|
1134
|
-
pluginId: Type.Optional(NonEmptyString),
|
|
1135
|
-
tools: Type.Array(ToolCatalogEntrySchema)
|
|
1136
|
-
}, { additionalProperties: false });
|
|
1137
|
-
const ToolsCatalogResultSchema = Type.Object({
|
|
1138
|
-
agentId: NonEmptyString,
|
|
1139
|
-
profiles: Type.Array(ToolCatalogProfileSchema),
|
|
1140
|
-
groups: Type.Array(ToolCatalogGroupSchema)
|
|
1141
|
-
}, { additionalProperties: false });
|
|
1142
|
-
|
|
1143
|
-
//#endregion
|
|
1144
|
-
//#region src/gateway/protocol/schema/channels.ts
|
|
1145
|
-
const TalkModeParamsSchema = Type.Object({
|
|
1146
|
-
enabled: Type.Boolean(),
|
|
1147
|
-
phase: Type.Optional(Type.String())
|
|
1148
|
-
}, { additionalProperties: false });
|
|
1149
|
-
const TalkConfigParamsSchema = Type.Object({ includeSecrets: Type.Optional(Type.Boolean()) }, { additionalProperties: false });
|
|
1150
|
-
const TalkProviderConfigSchema = Type.Object({
|
|
1151
|
-
voiceId: Type.Optional(Type.String()),
|
|
1152
|
-
voiceAliases: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
1153
|
-
modelId: Type.Optional(Type.String()),
|
|
1154
|
-
outputFormat: Type.Optional(Type.String()),
|
|
1155
|
-
apiKey: Type.Optional(Type.String())
|
|
1156
|
-
}, { additionalProperties: true });
|
|
1157
|
-
const TalkConfigResultSchema = Type.Object({ config: Type.Object({
|
|
1158
|
-
talk: Type.Optional(Type.Object({
|
|
1159
|
-
provider: Type.Optional(Type.String()),
|
|
1160
|
-
providers: Type.Optional(Type.Record(Type.String(), TalkProviderConfigSchema)),
|
|
1161
|
-
voiceId: Type.Optional(Type.String()),
|
|
1162
|
-
voiceAliases: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
1163
|
-
modelId: Type.Optional(Type.String()),
|
|
1164
|
-
outputFormat: Type.Optional(Type.String()),
|
|
1165
|
-
apiKey: Type.Optional(Type.String()),
|
|
1166
|
-
interruptOnSpeech: Type.Optional(Type.Boolean())
|
|
1167
|
-
}, { additionalProperties: false })),
|
|
1168
|
-
session: Type.Optional(Type.Object({ mainKey: Type.Optional(Type.String()) }, { additionalProperties: false })),
|
|
1169
|
-
ui: Type.Optional(Type.Object({ seamColor: Type.Optional(Type.String()) }, { additionalProperties: false }))
|
|
1170
|
-
}, { additionalProperties: false }) }, { additionalProperties: false });
|
|
1171
|
-
const ChannelsStatusParamsSchema = Type.Object({
|
|
1172
|
-
probe: Type.Optional(Type.Boolean()),
|
|
1173
|
-
timeoutMs: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
1174
|
-
}, { additionalProperties: false });
|
|
1175
|
-
const ChannelAccountSnapshotSchema = Type.Object({
|
|
1176
|
-
accountId: NonEmptyString,
|
|
1177
|
-
name: Type.Optional(Type.String()),
|
|
1178
|
-
enabled: Type.Optional(Type.Boolean()),
|
|
1179
|
-
configured: Type.Optional(Type.Boolean()),
|
|
1180
|
-
linked: Type.Optional(Type.Boolean()),
|
|
1181
|
-
running: Type.Optional(Type.Boolean()),
|
|
1182
|
-
connected: Type.Optional(Type.Boolean()),
|
|
1183
|
-
reconnectAttempts: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1184
|
-
lastConnectedAt: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1185
|
-
lastError: Type.Optional(Type.String()),
|
|
1186
|
-
lastStartAt: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1187
|
-
lastStopAt: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1188
|
-
lastInboundAt: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1189
|
-
lastOutboundAt: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1190
|
-
lastProbeAt: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1191
|
-
mode: Type.Optional(Type.String()),
|
|
1192
|
-
dmPolicy: Type.Optional(Type.String()),
|
|
1193
|
-
allowFrom: Type.Optional(Type.Array(Type.String())),
|
|
1194
|
-
tokenSource: Type.Optional(Type.String()),
|
|
1195
|
-
botTokenSource: Type.Optional(Type.String()),
|
|
1196
|
-
appTokenSource: Type.Optional(Type.String()),
|
|
1197
|
-
baseUrl: Type.Optional(Type.String()),
|
|
1198
|
-
allowUnmentionedGroups: Type.Optional(Type.Boolean()),
|
|
1199
|
-
cliPath: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
1200
|
-
dbPath: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
1201
|
-
port: Type.Optional(Type.Union([Type.Integer({ minimum: 0 }), Type.Null()])),
|
|
1202
|
-
probe: Type.Optional(Type.Unknown()),
|
|
1203
|
-
audit: Type.Optional(Type.Unknown()),
|
|
1204
|
-
application: Type.Optional(Type.Unknown())
|
|
1205
|
-
}, { additionalProperties: true });
|
|
1206
|
-
const ChannelUiMetaSchema = Type.Object({
|
|
1207
|
-
id: NonEmptyString,
|
|
1208
|
-
label: NonEmptyString,
|
|
1209
|
-
detailLabel: NonEmptyString,
|
|
1210
|
-
systemImage: Type.Optional(Type.String())
|
|
1211
|
-
}, { additionalProperties: false });
|
|
1212
|
-
const ChannelsStatusResultSchema = Type.Object({
|
|
1213
|
-
ts: Type.Integer({ minimum: 0 }),
|
|
1214
|
-
channelOrder: Type.Array(NonEmptyString),
|
|
1215
|
-
channelLabels: Type.Record(NonEmptyString, NonEmptyString),
|
|
1216
|
-
channelDetailLabels: Type.Optional(Type.Record(NonEmptyString, NonEmptyString)),
|
|
1217
|
-
channelSystemImages: Type.Optional(Type.Record(NonEmptyString, NonEmptyString)),
|
|
1218
|
-
channelMeta: Type.Optional(Type.Array(ChannelUiMetaSchema)),
|
|
1219
|
-
channels: Type.Record(NonEmptyString, Type.Unknown()),
|
|
1220
|
-
channelAccounts: Type.Record(NonEmptyString, Type.Array(ChannelAccountSnapshotSchema)),
|
|
1221
|
-
channelDefaultAccountId: Type.Record(NonEmptyString, NonEmptyString)
|
|
1222
|
-
}, { additionalProperties: false });
|
|
1223
|
-
const ChannelsLogoutParamsSchema = Type.Object({
|
|
1224
|
-
channel: NonEmptyString,
|
|
1225
|
-
accountId: Type.Optional(Type.String())
|
|
1226
|
-
}, { additionalProperties: false });
|
|
1227
|
-
const WebLoginStartParamsSchema = Type.Object({
|
|
1228
|
-
force: Type.Optional(Type.Boolean()),
|
|
1229
|
-
timeoutMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1230
|
-
verbose: Type.Optional(Type.Boolean()),
|
|
1231
|
-
accountId: Type.Optional(Type.String())
|
|
1232
|
-
}, { additionalProperties: false });
|
|
1233
|
-
const WebLoginWaitParamsSchema = Type.Object({
|
|
1234
|
-
timeoutMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1235
|
-
accountId: Type.Optional(Type.String())
|
|
1236
|
-
}, { additionalProperties: false });
|
|
1237
|
-
|
|
1238
|
-
//#endregion
|
|
1239
|
-
//#region src/gateway/protocol/schema/config.ts
|
|
1240
|
-
const ConfigGetParamsSchema = Type.Object({}, { additionalProperties: false });
|
|
1241
|
-
const ConfigSetParamsSchema = Type.Object({
|
|
1242
|
-
raw: NonEmptyString,
|
|
1243
|
-
baseHash: Type.Optional(NonEmptyString)
|
|
1244
|
-
}, { additionalProperties: false });
|
|
1245
|
-
const ConfigApplyLikeParamsSchema = Type.Object({
|
|
1246
|
-
raw: NonEmptyString,
|
|
1247
|
-
baseHash: Type.Optional(NonEmptyString),
|
|
1248
|
-
sessionKey: Type.Optional(Type.String()),
|
|
1249
|
-
note: Type.Optional(Type.String()),
|
|
1250
|
-
restartDelayMs: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
1251
|
-
}, { additionalProperties: false });
|
|
1252
|
-
const ConfigApplyParamsSchema = ConfigApplyLikeParamsSchema;
|
|
1253
|
-
const ConfigPatchParamsSchema = ConfigApplyLikeParamsSchema;
|
|
1254
|
-
const ConfigSchemaParamsSchema = Type.Object({}, { additionalProperties: false });
|
|
1255
|
-
const UpdateRunParamsSchema = Type.Object({
|
|
1256
|
-
sessionKey: Type.Optional(Type.String()),
|
|
1257
|
-
note: Type.Optional(Type.String()),
|
|
1258
|
-
restartDelayMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1259
|
-
timeoutMs: Type.Optional(Type.Integer({ minimum: 1 }))
|
|
1260
|
-
}, { additionalProperties: false });
|
|
1261
|
-
const ConfigUiHintSchema = Type.Object({
|
|
1262
|
-
label: Type.Optional(Type.String()),
|
|
1263
|
-
help: Type.Optional(Type.String()),
|
|
1264
|
-
tags: Type.Optional(Type.Array(Type.String())),
|
|
1265
|
-
group: Type.Optional(Type.String()),
|
|
1266
|
-
order: Type.Optional(Type.Integer()),
|
|
1267
|
-
advanced: Type.Optional(Type.Boolean()),
|
|
1268
|
-
sensitive: Type.Optional(Type.Boolean()),
|
|
1269
|
-
placeholder: Type.Optional(Type.String()),
|
|
1270
|
-
itemTemplate: Type.Optional(Type.Unknown())
|
|
1271
|
-
}, { additionalProperties: false });
|
|
1272
|
-
const ConfigSchemaResponseSchema = Type.Object({
|
|
1273
|
-
schema: Type.Unknown(),
|
|
1274
|
-
uiHints: Type.Record(Type.String(), ConfigUiHintSchema),
|
|
1275
|
-
version: NonEmptyString,
|
|
1276
|
-
generatedAt: NonEmptyString
|
|
1277
|
-
}, { additionalProperties: false });
|
|
1278
|
-
|
|
1279
|
-
//#endregion
|
|
1280
|
-
//#region src/gateway/protocol/schema/cron.ts
|
|
1281
|
-
function cronAgentTurnPayloadSchema(params) {
|
|
1282
|
-
return Type.Object({
|
|
1283
|
-
kind: Type.Literal("agentTurn"),
|
|
1284
|
-
message: params.message,
|
|
1285
|
-
model: Type.Optional(Type.String()),
|
|
1286
|
-
thinking: Type.Optional(Type.String()),
|
|
1287
|
-
timeoutSeconds: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1288
|
-
allowUnsafeExternalContent: Type.Optional(Type.Boolean()),
|
|
1289
|
-
deliver: Type.Optional(Type.Boolean()),
|
|
1290
|
-
channel: Type.Optional(Type.String()),
|
|
1291
|
-
to: Type.Optional(Type.String()),
|
|
1292
|
-
bestEffortDeliver: Type.Optional(Type.Boolean())
|
|
1293
|
-
}, { additionalProperties: false });
|
|
1294
|
-
}
|
|
1295
|
-
const CronSessionTargetSchema = Type.Union([Type.Literal("main"), Type.Literal("isolated")]);
|
|
1296
|
-
const CronWakeModeSchema = Type.Union([Type.Literal("next-heartbeat"), Type.Literal("now")]);
|
|
1297
|
-
const CronRunStatusSchema = Type.Union([
|
|
1298
|
-
Type.Literal("ok"),
|
|
1299
|
-
Type.Literal("error"),
|
|
1300
|
-
Type.Literal("skipped")
|
|
1301
|
-
]);
|
|
1302
|
-
const CronSortDirSchema = Type.Union([Type.Literal("asc"), Type.Literal("desc")]);
|
|
1303
|
-
const CronJobsEnabledFilterSchema = Type.Union([
|
|
1304
|
-
Type.Literal("all"),
|
|
1305
|
-
Type.Literal("enabled"),
|
|
1306
|
-
Type.Literal("disabled")
|
|
1307
|
-
]);
|
|
1308
|
-
const CronJobsSortBySchema = Type.Union([
|
|
1309
|
-
Type.Literal("nextRunAtMs"),
|
|
1310
|
-
Type.Literal("updatedAtMs"),
|
|
1311
|
-
Type.Literal("name")
|
|
1312
|
-
]);
|
|
1313
|
-
const CronRunsStatusFilterSchema = Type.Union([
|
|
1314
|
-
Type.Literal("all"),
|
|
1315
|
-
Type.Literal("ok"),
|
|
1316
|
-
Type.Literal("error"),
|
|
1317
|
-
Type.Literal("skipped")
|
|
1318
|
-
]);
|
|
1319
|
-
const CronRunsStatusValueSchema = Type.Union([
|
|
1320
|
-
Type.Literal("ok"),
|
|
1321
|
-
Type.Literal("error"),
|
|
1322
|
-
Type.Literal("skipped")
|
|
1323
|
-
]);
|
|
1324
|
-
const CronDeliveryStatusSchema = Type.Union([
|
|
1325
|
-
Type.Literal("delivered"),
|
|
1326
|
-
Type.Literal("not-delivered"),
|
|
1327
|
-
Type.Literal("unknown"),
|
|
1328
|
-
Type.Literal("not-requested")
|
|
1329
|
-
]);
|
|
1330
|
-
const CronCommonOptionalFields = {
|
|
1331
|
-
agentId: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1332
|
-
sessionKey: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1333
|
-
description: Type.Optional(Type.String()),
|
|
1334
|
-
enabled: Type.Optional(Type.Boolean()),
|
|
1335
|
-
deleteAfterRun: Type.Optional(Type.Boolean())
|
|
1336
|
-
};
|
|
1337
|
-
function cronIdOrJobIdParams(extraFields) {
|
|
1338
|
-
return Type.Union([Type.Object({
|
|
1339
|
-
id: NonEmptyString,
|
|
1340
|
-
...extraFields
|
|
1341
|
-
}, { additionalProperties: false }), Type.Object({
|
|
1342
|
-
jobId: NonEmptyString,
|
|
1343
|
-
...extraFields
|
|
1344
|
-
}, { additionalProperties: false })]);
|
|
1345
|
-
}
|
|
1346
|
-
const CronRunLogJobIdSchema = Type.String({
|
|
1347
|
-
minLength: 1,
|
|
1348
|
-
pattern: "^[^/\\\\]+$"
|
|
1349
|
-
});
|
|
1350
|
-
const CronScheduleSchema = Type.Union([
|
|
1351
|
-
Type.Object({
|
|
1352
|
-
kind: Type.Literal("at"),
|
|
1353
|
-
at: NonEmptyString
|
|
1354
|
-
}, { additionalProperties: false }),
|
|
1355
|
-
Type.Object({
|
|
1356
|
-
kind: Type.Literal("every"),
|
|
1357
|
-
everyMs: Type.Integer({ minimum: 1 }),
|
|
1358
|
-
anchorMs: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
1359
|
-
}, { additionalProperties: false }),
|
|
1360
|
-
Type.Object({
|
|
1361
|
-
kind: Type.Literal("cron"),
|
|
1362
|
-
expr: NonEmptyString,
|
|
1363
|
-
tz: Type.Optional(Type.String()),
|
|
1364
|
-
staggerMs: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
1365
|
-
}, { additionalProperties: false })
|
|
1366
|
-
]);
|
|
1367
|
-
const CronPayloadSchema = Type.Union([Type.Object({
|
|
1368
|
-
kind: Type.Literal("systemEvent"),
|
|
1369
|
-
text: NonEmptyString
|
|
1370
|
-
}, { additionalProperties: false }), cronAgentTurnPayloadSchema({ message: NonEmptyString })]);
|
|
1371
|
-
const CronPayloadPatchSchema = Type.Union([Type.Object({
|
|
1372
|
-
kind: Type.Literal("systemEvent"),
|
|
1373
|
-
text: Type.Optional(NonEmptyString)
|
|
1374
|
-
}, { additionalProperties: false }), cronAgentTurnPayloadSchema({ message: Type.Optional(NonEmptyString) })]);
|
|
1375
|
-
const CronDeliverySharedProperties = {
|
|
1376
|
-
channel: Type.Optional(Type.Union([Type.Literal("last"), NonEmptyString])),
|
|
1377
|
-
bestEffort: Type.Optional(Type.Boolean())
|
|
1378
|
-
};
|
|
1379
|
-
const CronDeliveryNoopSchema = Type.Object({
|
|
1380
|
-
mode: Type.Literal("none"),
|
|
1381
|
-
...CronDeliverySharedProperties,
|
|
1382
|
-
to: Type.Optional(Type.String())
|
|
1383
|
-
}, { additionalProperties: false });
|
|
1384
|
-
const CronDeliveryAnnounceSchema = Type.Object({
|
|
1385
|
-
mode: Type.Literal("announce"),
|
|
1386
|
-
...CronDeliverySharedProperties,
|
|
1387
|
-
to: Type.Optional(Type.String())
|
|
1388
|
-
}, { additionalProperties: false });
|
|
1389
|
-
const CronDeliveryWebhookSchema = Type.Object({
|
|
1390
|
-
mode: Type.Literal("webhook"),
|
|
1391
|
-
...CronDeliverySharedProperties,
|
|
1392
|
-
to: NonEmptyString
|
|
1393
|
-
}, { additionalProperties: false });
|
|
1394
|
-
const CronDeliverySchema = Type.Union([
|
|
1395
|
-
CronDeliveryNoopSchema,
|
|
1396
|
-
CronDeliveryAnnounceSchema,
|
|
1397
|
-
CronDeliveryWebhookSchema
|
|
1398
|
-
]);
|
|
1399
|
-
const CronDeliveryPatchSchema = Type.Object({
|
|
1400
|
-
mode: Type.Optional(Type.Union([
|
|
1401
|
-
Type.Literal("none"),
|
|
1402
|
-
Type.Literal("announce"),
|
|
1403
|
-
Type.Literal("webhook")
|
|
1404
|
-
])),
|
|
1405
|
-
...CronDeliverySharedProperties,
|
|
1406
|
-
to: Type.Optional(Type.String())
|
|
1407
|
-
}, { additionalProperties: false });
|
|
1408
|
-
const CronJobStateSchema = Type.Object({
|
|
1409
|
-
nextRunAtMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1410
|
-
runningAtMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1411
|
-
lastRunAtMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1412
|
-
lastRunStatus: Type.Optional(CronRunStatusSchema),
|
|
1413
|
-
lastStatus: Type.Optional(CronRunStatusSchema),
|
|
1414
|
-
lastError: Type.Optional(Type.String()),
|
|
1415
|
-
lastDurationMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1416
|
-
consecutiveErrors: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1417
|
-
lastDelivered: Type.Optional(Type.Boolean()),
|
|
1418
|
-
lastDeliveryStatus: Type.Optional(CronDeliveryStatusSchema),
|
|
1419
|
-
lastDeliveryError: Type.Optional(Type.String())
|
|
1420
|
-
}, { additionalProperties: false });
|
|
1421
|
-
const CronJobSchema = Type.Object({
|
|
1422
|
-
id: NonEmptyString,
|
|
1423
|
-
agentId: Type.Optional(NonEmptyString),
|
|
1424
|
-
sessionKey: Type.Optional(NonEmptyString),
|
|
1425
|
-
name: NonEmptyString,
|
|
1426
|
-
description: Type.Optional(Type.String()),
|
|
1427
|
-
enabled: Type.Boolean(),
|
|
1428
|
-
deleteAfterRun: Type.Optional(Type.Boolean()),
|
|
1429
|
-
createdAtMs: Type.Integer({ minimum: 0 }),
|
|
1430
|
-
updatedAtMs: Type.Integer({ minimum: 0 }),
|
|
1431
|
-
schedule: CronScheduleSchema,
|
|
1432
|
-
sessionTarget: CronSessionTargetSchema,
|
|
1433
|
-
wakeMode: CronWakeModeSchema,
|
|
1434
|
-
payload: CronPayloadSchema,
|
|
1435
|
-
delivery: Type.Optional(CronDeliverySchema),
|
|
1436
|
-
state: CronJobStateSchema
|
|
1437
|
-
}, { additionalProperties: false });
|
|
1438
|
-
const CronListParamsSchema = Type.Object({
|
|
1439
|
-
includeDisabled: Type.Optional(Type.Boolean()),
|
|
1440
|
-
limit: Type.Optional(Type.Integer({
|
|
1441
|
-
minimum: 1,
|
|
1442
|
-
maximum: 200
|
|
1443
|
-
})),
|
|
1444
|
-
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1445
|
-
query: Type.Optional(Type.String()),
|
|
1446
|
-
enabled: Type.Optional(CronJobsEnabledFilterSchema),
|
|
1447
|
-
sortBy: Type.Optional(CronJobsSortBySchema),
|
|
1448
|
-
sortDir: Type.Optional(CronSortDirSchema)
|
|
1449
|
-
}, { additionalProperties: false });
|
|
1450
|
-
const CronStatusParamsSchema = Type.Object({}, { additionalProperties: false });
|
|
1451
|
-
const CronAddParamsSchema = Type.Object({
|
|
1452
|
-
name: NonEmptyString,
|
|
1453
|
-
...CronCommonOptionalFields,
|
|
1454
|
-
schedule: CronScheduleSchema,
|
|
1455
|
-
sessionTarget: CronSessionTargetSchema,
|
|
1456
|
-
wakeMode: CronWakeModeSchema,
|
|
1457
|
-
payload: CronPayloadSchema,
|
|
1458
|
-
delivery: Type.Optional(CronDeliverySchema)
|
|
1459
|
-
}, { additionalProperties: false });
|
|
1460
|
-
const CronJobPatchSchema = Type.Object({
|
|
1461
|
-
name: Type.Optional(NonEmptyString),
|
|
1462
|
-
...CronCommonOptionalFields,
|
|
1463
|
-
schedule: Type.Optional(CronScheduleSchema),
|
|
1464
|
-
sessionTarget: Type.Optional(CronSessionTargetSchema),
|
|
1465
|
-
wakeMode: Type.Optional(CronWakeModeSchema),
|
|
1466
|
-
payload: Type.Optional(CronPayloadPatchSchema),
|
|
1467
|
-
delivery: Type.Optional(CronDeliveryPatchSchema),
|
|
1468
|
-
state: Type.Optional(Type.Partial(CronJobStateSchema))
|
|
1469
|
-
}, { additionalProperties: false });
|
|
1470
|
-
const CronUpdateParamsSchema = cronIdOrJobIdParams({ patch: CronJobPatchSchema });
|
|
1471
|
-
const CronRemoveParamsSchema = cronIdOrJobIdParams({});
|
|
1472
|
-
const CronRunParamsSchema = cronIdOrJobIdParams({ mode: Type.Optional(Type.Union([Type.Literal("due"), Type.Literal("force")])) });
|
|
1473
|
-
const CronRunsParamsSchema = Type.Object({
|
|
1474
|
-
scope: Type.Optional(Type.Union([Type.Literal("job"), Type.Literal("all")])),
|
|
1475
|
-
id: Type.Optional(CronRunLogJobIdSchema),
|
|
1476
|
-
jobId: Type.Optional(CronRunLogJobIdSchema),
|
|
1477
|
-
limit: Type.Optional(Type.Integer({
|
|
1478
|
-
minimum: 1,
|
|
1479
|
-
maximum: 200
|
|
1480
|
-
})),
|
|
1481
|
-
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1482
|
-
statuses: Type.Optional(Type.Array(CronRunsStatusValueSchema, {
|
|
1483
|
-
minItems: 1,
|
|
1484
|
-
maxItems: 3
|
|
1485
|
-
})),
|
|
1486
|
-
status: Type.Optional(CronRunsStatusFilterSchema),
|
|
1487
|
-
deliveryStatuses: Type.Optional(Type.Array(CronDeliveryStatusSchema, {
|
|
1488
|
-
minItems: 1,
|
|
1489
|
-
maxItems: 4
|
|
1490
|
-
})),
|
|
1491
|
-
deliveryStatus: Type.Optional(CronDeliveryStatusSchema),
|
|
1492
|
-
query: Type.Optional(Type.String()),
|
|
1493
|
-
sortDir: Type.Optional(CronSortDirSchema)
|
|
1494
|
-
}, { additionalProperties: false });
|
|
1495
|
-
const CronRunLogEntrySchema = Type.Object({
|
|
1496
|
-
ts: Type.Integer({ minimum: 0 }),
|
|
1497
|
-
jobId: NonEmptyString,
|
|
1498
|
-
action: Type.Literal("finished"),
|
|
1499
|
-
status: Type.Optional(CronRunStatusSchema),
|
|
1500
|
-
error: Type.Optional(Type.String()),
|
|
1501
|
-
summary: Type.Optional(Type.String()),
|
|
1502
|
-
delivered: Type.Optional(Type.Boolean()),
|
|
1503
|
-
deliveryStatus: Type.Optional(CronDeliveryStatusSchema),
|
|
1504
|
-
deliveryError: Type.Optional(Type.String()),
|
|
1505
|
-
sessionId: Type.Optional(NonEmptyString),
|
|
1506
|
-
sessionKey: Type.Optional(NonEmptyString),
|
|
1507
|
-
runAtMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1508
|
-
durationMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1509
|
-
nextRunAtMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1510
|
-
model: Type.Optional(Type.String()),
|
|
1511
|
-
provider: Type.Optional(Type.String()),
|
|
1512
|
-
usage: Type.Optional(Type.Object({
|
|
1513
|
-
input_tokens: Type.Optional(Type.Number()),
|
|
1514
|
-
output_tokens: Type.Optional(Type.Number()),
|
|
1515
|
-
total_tokens: Type.Optional(Type.Number()),
|
|
1516
|
-
cache_read_tokens: Type.Optional(Type.Number()),
|
|
1517
|
-
cache_write_tokens: Type.Optional(Type.Number())
|
|
1518
|
-
}, { additionalProperties: false })),
|
|
1519
|
-
jobName: Type.Optional(Type.String())
|
|
1520
|
-
}, { additionalProperties: false });
|
|
1521
|
-
|
|
1522
|
-
//#endregion
|
|
1523
|
-
//#region src/gateway/protocol/schema/error-codes.ts
|
|
1524
|
-
const ErrorCodes = {
|
|
1525
|
-
NOT_LINKED: "NOT_LINKED",
|
|
1526
|
-
NOT_PAIRED: "NOT_PAIRED",
|
|
1527
|
-
AGENT_TIMEOUT: "AGENT_TIMEOUT",
|
|
1528
|
-
INVALID_REQUEST: "INVALID_REQUEST",
|
|
1529
|
-
UNAVAILABLE: "UNAVAILABLE"
|
|
1530
|
-
};
|
|
1531
|
-
function errorShape(code, message, opts) {
|
|
1532
|
-
return {
|
|
1533
|
-
code,
|
|
1534
|
-
message,
|
|
1535
|
-
...opts
|
|
1536
|
-
};
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
//#endregion
|
|
1540
|
-
//#region src/gateway/protocol/schema/devices.ts
|
|
1541
|
-
const DevicePairListParamsSchema = Type.Object({}, { additionalProperties: false });
|
|
1542
|
-
const DevicePairApproveParamsSchema = Type.Object({ requestId: NonEmptyString }, { additionalProperties: false });
|
|
1543
|
-
const DevicePairRejectParamsSchema = Type.Object({ requestId: NonEmptyString }, { additionalProperties: false });
|
|
1544
|
-
const DevicePairRemoveParamsSchema = Type.Object({ deviceId: NonEmptyString }, { additionalProperties: false });
|
|
1545
|
-
const DeviceTokenRotateParamsSchema = Type.Object({
|
|
1546
|
-
deviceId: NonEmptyString,
|
|
1547
|
-
role: NonEmptyString,
|
|
1548
|
-
scopes: Type.Optional(Type.Array(NonEmptyString))
|
|
1549
|
-
}, { additionalProperties: false });
|
|
1550
|
-
const DeviceTokenRevokeParamsSchema = Type.Object({
|
|
1551
|
-
deviceId: NonEmptyString,
|
|
1552
|
-
role: NonEmptyString
|
|
1553
|
-
}, { additionalProperties: false });
|
|
1554
|
-
const DevicePairRequestedEventSchema = Type.Object({
|
|
1555
|
-
requestId: NonEmptyString,
|
|
1556
|
-
deviceId: NonEmptyString,
|
|
1557
|
-
publicKey: NonEmptyString,
|
|
1558
|
-
displayName: Type.Optional(NonEmptyString),
|
|
1559
|
-
platform: Type.Optional(NonEmptyString),
|
|
1560
|
-
clientId: Type.Optional(NonEmptyString),
|
|
1561
|
-
clientMode: Type.Optional(NonEmptyString),
|
|
1562
|
-
role: Type.Optional(NonEmptyString),
|
|
1563
|
-
roles: Type.Optional(Type.Array(NonEmptyString)),
|
|
1564
|
-
scopes: Type.Optional(Type.Array(NonEmptyString)),
|
|
1565
|
-
remoteIp: Type.Optional(NonEmptyString),
|
|
1566
|
-
silent: Type.Optional(Type.Boolean()),
|
|
1567
|
-
isRepair: Type.Optional(Type.Boolean()),
|
|
1568
|
-
ts: Type.Integer({ minimum: 0 })
|
|
1569
|
-
}, { additionalProperties: false });
|
|
1570
|
-
const DevicePairResolvedEventSchema = Type.Object({
|
|
1571
|
-
requestId: NonEmptyString,
|
|
1572
|
-
deviceId: NonEmptyString,
|
|
1573
|
-
decision: NonEmptyString,
|
|
1574
|
-
ts: Type.Integer({ minimum: 0 })
|
|
1575
|
-
}, { additionalProperties: false });
|
|
1576
|
-
|
|
1577
|
-
//#endregion
|
|
1578
|
-
//#region src/gateway/protocol/schema/snapshot.ts
|
|
1579
|
-
const PresenceEntrySchema = Type.Object({
|
|
1580
|
-
host: Type.Optional(NonEmptyString),
|
|
1581
|
-
ip: Type.Optional(NonEmptyString),
|
|
1582
|
-
version: Type.Optional(NonEmptyString),
|
|
1583
|
-
platform: Type.Optional(NonEmptyString),
|
|
1584
|
-
deviceFamily: Type.Optional(NonEmptyString),
|
|
1585
|
-
modelIdentifier: Type.Optional(NonEmptyString),
|
|
1586
|
-
mode: Type.Optional(NonEmptyString),
|
|
1587
|
-
lastInputSeconds: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1588
|
-
reason: Type.Optional(NonEmptyString),
|
|
1589
|
-
tags: Type.Optional(Type.Array(NonEmptyString)),
|
|
1590
|
-
text: Type.Optional(Type.String()),
|
|
1591
|
-
ts: Type.Integer({ minimum: 0 }),
|
|
1592
|
-
deviceId: Type.Optional(NonEmptyString),
|
|
1593
|
-
roles: Type.Optional(Type.Array(NonEmptyString)),
|
|
1594
|
-
scopes: Type.Optional(Type.Array(NonEmptyString)),
|
|
1595
|
-
instanceId: Type.Optional(NonEmptyString)
|
|
1596
|
-
}, { additionalProperties: false });
|
|
1597
|
-
const HealthSnapshotSchema = Type.Any();
|
|
1598
|
-
const SessionDefaultsSchema = Type.Object({
|
|
1599
|
-
defaultAgentId: NonEmptyString,
|
|
1600
|
-
mainKey: NonEmptyString,
|
|
1601
|
-
mainSessionKey: NonEmptyString,
|
|
1602
|
-
scope: Type.Optional(NonEmptyString)
|
|
1603
|
-
}, { additionalProperties: false });
|
|
1604
|
-
const StateVersionSchema = Type.Object({
|
|
1605
|
-
presence: Type.Integer({ minimum: 0 }),
|
|
1606
|
-
health: Type.Integer({ minimum: 0 })
|
|
1607
|
-
}, { additionalProperties: false });
|
|
1608
|
-
const SnapshotSchema = Type.Object({
|
|
1609
|
-
presence: Type.Array(PresenceEntrySchema),
|
|
1610
|
-
health: HealthSnapshotSchema,
|
|
1611
|
-
stateVersion: StateVersionSchema,
|
|
1612
|
-
uptimeMs: Type.Integer({ minimum: 0 }),
|
|
1613
|
-
configPath: Type.Optional(NonEmptyString),
|
|
1614
|
-
stateDir: Type.Optional(NonEmptyString),
|
|
1615
|
-
sessionDefaults: Type.Optional(SessionDefaultsSchema),
|
|
1616
|
-
authMode: Type.Optional(Type.Union([
|
|
1617
|
-
Type.Literal("none"),
|
|
1618
|
-
Type.Literal("token"),
|
|
1619
|
-
Type.Literal("password"),
|
|
1620
|
-
Type.Literal("trusted-proxy")
|
|
1621
|
-
])),
|
|
1622
|
-
updateAvailable: Type.Optional(Type.Object({
|
|
1623
|
-
currentVersion: NonEmptyString,
|
|
1624
|
-
latestVersion: NonEmptyString,
|
|
1625
|
-
channel: NonEmptyString
|
|
1626
|
-
}))
|
|
1627
|
-
}, { additionalProperties: false });
|
|
1628
|
-
|
|
1629
|
-
//#endregion
|
|
1630
|
-
//#region src/gateway/protocol/schema/frames.ts
|
|
1631
|
-
const TickEventSchema = Type.Object({ ts: Type.Integer({ minimum: 0 }) }, { additionalProperties: false });
|
|
1632
|
-
const ShutdownEventSchema = Type.Object({
|
|
1633
|
-
reason: NonEmptyString,
|
|
1634
|
-
restartExpectedMs: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
1635
|
-
}, { additionalProperties: false });
|
|
1636
|
-
const ConnectParamsSchema = Type.Object({
|
|
1637
|
-
minProtocol: Type.Integer({ minimum: 1 }),
|
|
1638
|
-
maxProtocol: Type.Integer({ minimum: 1 }),
|
|
1639
|
-
client: Type.Object({
|
|
1640
|
-
id: GatewayClientIdSchema,
|
|
1641
|
-
displayName: Type.Optional(NonEmptyString),
|
|
1642
|
-
version: NonEmptyString,
|
|
1643
|
-
platform: NonEmptyString,
|
|
1644
|
-
deviceFamily: Type.Optional(NonEmptyString),
|
|
1645
|
-
modelIdentifier: Type.Optional(NonEmptyString),
|
|
1646
|
-
mode: GatewayClientModeSchema,
|
|
1647
|
-
instanceId: Type.Optional(NonEmptyString)
|
|
1648
|
-
}, { additionalProperties: false }),
|
|
1649
|
-
caps: Type.Optional(Type.Array(NonEmptyString, { default: [] })),
|
|
1650
|
-
commands: Type.Optional(Type.Array(NonEmptyString)),
|
|
1651
|
-
permissions: Type.Optional(Type.Record(NonEmptyString, Type.Boolean())),
|
|
1652
|
-
pathEnv: Type.Optional(Type.String()),
|
|
1653
|
-
role: Type.Optional(NonEmptyString),
|
|
1654
|
-
scopes: Type.Optional(Type.Array(NonEmptyString)),
|
|
1655
|
-
device: Type.Optional(Type.Object({
|
|
1656
|
-
id: NonEmptyString,
|
|
1657
|
-
publicKey: NonEmptyString,
|
|
1658
|
-
signature: NonEmptyString,
|
|
1659
|
-
signedAt: Type.Integer({ minimum: 0 }),
|
|
1660
|
-
nonce: NonEmptyString
|
|
1661
|
-
}, { additionalProperties: false })),
|
|
1662
|
-
auth: Type.Optional(Type.Object({
|
|
1663
|
-
token: Type.Optional(Type.String()),
|
|
1664
|
-
deviceToken: Type.Optional(Type.String()),
|
|
1665
|
-
password: Type.Optional(Type.String())
|
|
1666
|
-
}, { additionalProperties: false })),
|
|
1667
|
-
locale: Type.Optional(Type.String()),
|
|
1668
|
-
userAgent: Type.Optional(Type.String())
|
|
1669
|
-
}, { additionalProperties: false });
|
|
1670
|
-
const HelloOkSchema = Type.Object({
|
|
1671
|
-
type: Type.Literal("hello-ok"),
|
|
1672
|
-
protocol: Type.Integer({ minimum: 1 }),
|
|
1673
|
-
server: Type.Object({
|
|
1674
|
-
version: NonEmptyString,
|
|
1675
|
-
connId: NonEmptyString
|
|
1676
|
-
}, { additionalProperties: false }),
|
|
1677
|
-
features: Type.Object({
|
|
1678
|
-
methods: Type.Array(NonEmptyString),
|
|
1679
|
-
events: Type.Array(NonEmptyString)
|
|
1680
|
-
}, { additionalProperties: false }),
|
|
1681
|
-
snapshot: SnapshotSchema,
|
|
1682
|
-
canvasHostUrl: Type.Optional(NonEmptyString),
|
|
1683
|
-
auth: Type.Optional(Type.Object({
|
|
1684
|
-
deviceToken: NonEmptyString,
|
|
1685
|
-
role: NonEmptyString,
|
|
1686
|
-
scopes: Type.Array(NonEmptyString),
|
|
1687
|
-
issuedAtMs: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
1688
|
-
}, { additionalProperties: false })),
|
|
1689
|
-
policy: Type.Object({
|
|
1690
|
-
maxPayload: Type.Integer({ minimum: 1 }),
|
|
1691
|
-
maxBufferedBytes: Type.Integer({ minimum: 1 }),
|
|
1692
|
-
tickIntervalMs: Type.Integer({ minimum: 1 })
|
|
1693
|
-
}, { additionalProperties: false })
|
|
1694
|
-
}, { additionalProperties: false });
|
|
1695
|
-
const ErrorShapeSchema = Type.Object({
|
|
1696
|
-
code: NonEmptyString,
|
|
1697
|
-
message: NonEmptyString,
|
|
1698
|
-
details: Type.Optional(Type.Unknown()),
|
|
1699
|
-
retryable: Type.Optional(Type.Boolean()),
|
|
1700
|
-
retryAfterMs: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
1701
|
-
}, { additionalProperties: false });
|
|
1702
|
-
const RequestFrameSchema = Type.Object({
|
|
1703
|
-
type: Type.Literal("req"),
|
|
1704
|
-
id: NonEmptyString,
|
|
1705
|
-
method: NonEmptyString,
|
|
1706
|
-
params: Type.Optional(Type.Unknown())
|
|
1707
|
-
}, { additionalProperties: false });
|
|
1708
|
-
const ResponseFrameSchema = Type.Object({
|
|
1709
|
-
type: Type.Literal("res"),
|
|
1710
|
-
id: NonEmptyString,
|
|
1711
|
-
ok: Type.Boolean(),
|
|
1712
|
-
payload: Type.Optional(Type.Unknown()),
|
|
1713
|
-
error: Type.Optional(ErrorShapeSchema)
|
|
1714
|
-
}, { additionalProperties: false });
|
|
1715
|
-
const EventFrameSchema = Type.Object({
|
|
1716
|
-
type: Type.Literal("event"),
|
|
1717
|
-
event: NonEmptyString,
|
|
1718
|
-
payload: Type.Optional(Type.Unknown()),
|
|
1719
|
-
seq: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1720
|
-
stateVersion: Type.Optional(StateVersionSchema)
|
|
1721
|
-
}, { additionalProperties: false });
|
|
1722
|
-
const GatewayFrameSchema = Type.Union([
|
|
1723
|
-
RequestFrameSchema,
|
|
1724
|
-
ResponseFrameSchema,
|
|
1725
|
-
EventFrameSchema
|
|
1726
|
-
], { discriminator: "type" });
|
|
1727
|
-
|
|
1728
|
-
//#endregion
|
|
1729
|
-
//#region src/gateway/protocol/schema/logs-chat.ts
|
|
1730
|
-
const LogsTailParamsSchema = Type.Object({
|
|
1731
|
-
cursor: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1732
|
-
limit: Type.Optional(Type.Integer({
|
|
1733
|
-
minimum: 1,
|
|
1734
|
-
maximum: 5e3
|
|
1735
|
-
})),
|
|
1736
|
-
maxBytes: Type.Optional(Type.Integer({
|
|
1737
|
-
minimum: 1,
|
|
1738
|
-
maximum: 1e6
|
|
1739
|
-
}))
|
|
1740
|
-
}, { additionalProperties: false });
|
|
1741
|
-
const LogsTailResultSchema = Type.Object({
|
|
1742
|
-
file: NonEmptyString,
|
|
1743
|
-
cursor: Type.Integer({ minimum: 0 }),
|
|
1744
|
-
size: Type.Integer({ minimum: 0 }),
|
|
1745
|
-
lines: Type.Array(Type.String()),
|
|
1746
|
-
truncated: Type.Optional(Type.Boolean()),
|
|
1747
|
-
reset: Type.Optional(Type.Boolean())
|
|
1748
|
-
}, { additionalProperties: false });
|
|
1749
|
-
const ChatHistoryParamsSchema = Type.Object({
|
|
1750
|
-
sessionKey: NonEmptyString,
|
|
1751
|
-
limit: Type.Optional(Type.Integer({
|
|
1752
|
-
minimum: 1,
|
|
1753
|
-
maximum: 1e3
|
|
1754
|
-
}))
|
|
1755
|
-
}, { additionalProperties: false });
|
|
1756
|
-
const ChatSendParamsSchema = Type.Object({
|
|
1757
|
-
sessionKey: NonEmptyString,
|
|
1758
|
-
message: Type.String(),
|
|
1759
|
-
thinking: Type.Optional(Type.String()),
|
|
1760
|
-
deliver: Type.Optional(Type.Boolean()),
|
|
1761
|
-
attachments: Type.Optional(Type.Array(Type.Unknown())),
|
|
1762
|
-
timeoutMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1763
|
-
idempotencyKey: NonEmptyString
|
|
1764
|
-
}, { additionalProperties: false });
|
|
1765
|
-
const ChatAbortParamsSchema = Type.Object({
|
|
1766
|
-
sessionKey: NonEmptyString,
|
|
1767
|
-
runId: Type.Optional(NonEmptyString)
|
|
1768
|
-
}, { additionalProperties: false });
|
|
1769
|
-
const ChatInjectParamsSchema = Type.Object({
|
|
1770
|
-
sessionKey: NonEmptyString,
|
|
1771
|
-
message: NonEmptyString,
|
|
1772
|
-
label: Type.Optional(Type.String({ maxLength: 100 }))
|
|
1773
|
-
}, { additionalProperties: false });
|
|
1774
|
-
const ChatEventSchema = Type.Object({
|
|
1775
|
-
runId: NonEmptyString,
|
|
1776
|
-
sessionKey: NonEmptyString,
|
|
1777
|
-
seq: Type.Integer({ minimum: 0 }),
|
|
1778
|
-
state: Type.Union([
|
|
1779
|
-
Type.Literal("delta"),
|
|
1780
|
-
Type.Literal("final"),
|
|
1781
|
-
Type.Literal("aborted"),
|
|
1782
|
-
Type.Literal("error")
|
|
1783
|
-
]),
|
|
1784
|
-
message: Type.Optional(Type.Unknown()),
|
|
1785
|
-
errorMessage: Type.Optional(Type.String()),
|
|
1786
|
-
usage: Type.Optional(Type.Unknown()),
|
|
1787
|
-
stopReason: Type.Optional(Type.String())
|
|
1788
|
-
}, { additionalProperties: false });
|
|
1789
|
-
|
|
1790
|
-
//#endregion
|
|
1791
|
-
//#region src/gateway/protocol/schema/nodes.ts
|
|
1792
|
-
const NodePairRequestParamsSchema = Type.Object({
|
|
1793
|
-
nodeId: NonEmptyString,
|
|
1794
|
-
displayName: Type.Optional(NonEmptyString),
|
|
1795
|
-
platform: Type.Optional(NonEmptyString),
|
|
1796
|
-
version: Type.Optional(NonEmptyString),
|
|
1797
|
-
coreVersion: Type.Optional(NonEmptyString),
|
|
1798
|
-
uiVersion: Type.Optional(NonEmptyString),
|
|
1799
|
-
deviceFamily: Type.Optional(NonEmptyString),
|
|
1800
|
-
modelIdentifier: Type.Optional(NonEmptyString),
|
|
1801
|
-
caps: Type.Optional(Type.Array(NonEmptyString)),
|
|
1802
|
-
commands: Type.Optional(Type.Array(NonEmptyString)),
|
|
1803
|
-
remoteIp: Type.Optional(NonEmptyString),
|
|
1804
|
-
silent: Type.Optional(Type.Boolean())
|
|
1805
|
-
}, { additionalProperties: false });
|
|
1806
|
-
const NodePairListParamsSchema = Type.Object({}, { additionalProperties: false });
|
|
1807
|
-
const NodePairApproveParamsSchema = Type.Object({ requestId: NonEmptyString }, { additionalProperties: false });
|
|
1808
|
-
const NodePairRejectParamsSchema = Type.Object({ requestId: NonEmptyString }, { additionalProperties: false });
|
|
1809
|
-
const NodePairVerifyParamsSchema = Type.Object({
|
|
1810
|
-
nodeId: NonEmptyString,
|
|
1811
|
-
token: NonEmptyString
|
|
1812
|
-
}, { additionalProperties: false });
|
|
1813
|
-
const NodeRenameParamsSchema = Type.Object({
|
|
1814
|
-
nodeId: NonEmptyString,
|
|
1815
|
-
displayName: NonEmptyString
|
|
1816
|
-
}, { additionalProperties: false });
|
|
1817
|
-
const NodeListParamsSchema = Type.Object({}, { additionalProperties: false });
|
|
1818
|
-
const NodeDescribeParamsSchema = Type.Object({ nodeId: NonEmptyString }, { additionalProperties: false });
|
|
1819
|
-
const NodeInvokeParamsSchema = Type.Object({
|
|
1820
|
-
nodeId: NonEmptyString,
|
|
1821
|
-
command: NonEmptyString,
|
|
1822
|
-
params: Type.Optional(Type.Unknown()),
|
|
1823
|
-
timeoutMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1824
|
-
idempotencyKey: NonEmptyString
|
|
1825
|
-
}, { additionalProperties: false });
|
|
1826
|
-
const NodeInvokeResultParamsSchema = Type.Object({
|
|
1827
|
-
id: NonEmptyString,
|
|
1828
|
-
nodeId: NonEmptyString,
|
|
1829
|
-
ok: Type.Boolean(),
|
|
1830
|
-
payload: Type.Optional(Type.Unknown()),
|
|
1831
|
-
payloadJSON: Type.Optional(Type.String()),
|
|
1832
|
-
error: Type.Optional(Type.Object({
|
|
1833
|
-
code: Type.Optional(NonEmptyString),
|
|
1834
|
-
message: Type.Optional(NonEmptyString)
|
|
1835
|
-
}, { additionalProperties: false }))
|
|
1836
|
-
}, { additionalProperties: false });
|
|
1837
|
-
const NodeEventParamsSchema = Type.Object({
|
|
1838
|
-
event: NonEmptyString,
|
|
1839
|
-
payload: Type.Optional(Type.Unknown()),
|
|
1840
|
-
payloadJSON: Type.Optional(Type.String())
|
|
1841
|
-
}, { additionalProperties: false });
|
|
1842
|
-
const NodeInvokeRequestEventSchema = Type.Object({
|
|
1843
|
-
id: NonEmptyString,
|
|
1844
|
-
nodeId: NonEmptyString,
|
|
1845
|
-
command: NonEmptyString,
|
|
1846
|
-
paramsJSON: Type.Optional(Type.String()),
|
|
1847
|
-
timeoutMs: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
1848
|
-
idempotencyKey: Type.Optional(NonEmptyString)
|
|
1849
|
-
}, { additionalProperties: false });
|
|
1850
|
-
|
|
1851
|
-
//#endregion
|
|
1852
|
-
//#region src/gateway/protocol/schema/push.ts
|
|
1853
|
-
const ApnsEnvironmentSchema = Type.String({ enum: ["sandbox", "production"] });
|
|
1854
|
-
const PushTestParamsSchema = Type.Object({
|
|
1855
|
-
nodeId: NonEmptyString,
|
|
1856
|
-
title: Type.Optional(Type.String()),
|
|
1857
|
-
body: Type.Optional(Type.String()),
|
|
1858
|
-
environment: Type.Optional(ApnsEnvironmentSchema)
|
|
1859
|
-
}, { additionalProperties: false });
|
|
1860
|
-
const PushTestResultSchema = Type.Object({
|
|
1861
|
-
ok: Type.Boolean(),
|
|
1862
|
-
status: Type.Integer(),
|
|
1863
|
-
apnsId: Type.Optional(Type.String()),
|
|
1864
|
-
reason: Type.Optional(Type.String()),
|
|
1865
|
-
tokenSuffix: Type.String(),
|
|
1866
|
-
topic: Type.String(),
|
|
1867
|
-
environment: ApnsEnvironmentSchema
|
|
1868
|
-
}, { additionalProperties: false });
|
|
1869
|
-
|
|
1870
|
-
//#endregion
|
|
1871
|
-
//#region src/gateway/protocol/schema/sessions.ts
|
|
1872
|
-
const SessionsListParamsSchema = Type.Object({
|
|
1873
|
-
limit: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
1874
|
-
activeMinutes: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
1875
|
-
includeGlobal: Type.Optional(Type.Boolean()),
|
|
1876
|
-
includeUnknown: Type.Optional(Type.Boolean()),
|
|
1877
|
-
includeDerivedTitles: Type.Optional(Type.Boolean()),
|
|
1878
|
-
includeLastMessage: Type.Optional(Type.Boolean()),
|
|
1879
|
-
label: Type.Optional(SessionLabelString),
|
|
1880
|
-
spawnedBy: Type.Optional(NonEmptyString),
|
|
1881
|
-
agentId: Type.Optional(NonEmptyString),
|
|
1882
|
-
search: Type.Optional(Type.String())
|
|
1883
|
-
}, { additionalProperties: false });
|
|
1884
|
-
const SessionsPreviewParamsSchema = Type.Object({
|
|
1885
|
-
keys: Type.Array(NonEmptyString, { minItems: 1 }),
|
|
1886
|
-
limit: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
1887
|
-
maxChars: Type.Optional(Type.Integer({ minimum: 20 }))
|
|
1888
|
-
}, { additionalProperties: false });
|
|
1889
|
-
const SessionsResolveParamsSchema = Type.Object({
|
|
1890
|
-
key: Type.Optional(NonEmptyString),
|
|
1891
|
-
sessionId: Type.Optional(NonEmptyString),
|
|
1892
|
-
label: Type.Optional(SessionLabelString),
|
|
1893
|
-
agentId: Type.Optional(NonEmptyString),
|
|
1894
|
-
spawnedBy: Type.Optional(NonEmptyString),
|
|
1895
|
-
includeGlobal: Type.Optional(Type.Boolean()),
|
|
1896
|
-
includeUnknown: Type.Optional(Type.Boolean())
|
|
1897
|
-
}, { additionalProperties: false });
|
|
1898
|
-
const SessionsPatchParamsSchema = Type.Object({
|
|
1899
|
-
key: NonEmptyString,
|
|
1900
|
-
label: Type.Optional(Type.Union([SessionLabelString, Type.Null()])),
|
|
1901
|
-
thinkingLevel: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1902
|
-
verboseLevel: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1903
|
-
reasoningLevel: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1904
|
-
responseUsage: Type.Optional(Type.Union([
|
|
1905
|
-
Type.Literal("off"),
|
|
1906
|
-
Type.Literal("tokens"),
|
|
1907
|
-
Type.Literal("full"),
|
|
1908
|
-
Type.Literal("on"),
|
|
1909
|
-
Type.Null()
|
|
1910
|
-
])),
|
|
1911
|
-
elevatedLevel: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1912
|
-
execHost: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1913
|
-
execSecurity: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1914
|
-
execAsk: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1915
|
-
execNode: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1916
|
-
model: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1917
|
-
spawnedBy: Type.Optional(Type.Union([NonEmptyString, Type.Null()])),
|
|
1918
|
-
spawnDepth: Type.Optional(Type.Union([Type.Integer({ minimum: 0 }), Type.Null()])),
|
|
1919
|
-
sendPolicy: Type.Optional(Type.Union([
|
|
1920
|
-
Type.Literal("allow"),
|
|
1921
|
-
Type.Literal("deny"),
|
|
1922
|
-
Type.Null()
|
|
1923
|
-
])),
|
|
1924
|
-
groupActivation: Type.Optional(Type.Union([
|
|
1925
|
-
Type.Literal("mention"),
|
|
1926
|
-
Type.Literal("always"),
|
|
1927
|
-
Type.Null()
|
|
1928
|
-
]))
|
|
1929
|
-
}, { additionalProperties: false });
|
|
1930
|
-
const SessionsResetParamsSchema = Type.Object({
|
|
1931
|
-
key: NonEmptyString,
|
|
1932
|
-
reason: Type.Optional(Type.Union([Type.Literal("new"), Type.Literal("reset")]))
|
|
1933
|
-
}, { additionalProperties: false });
|
|
1934
|
-
const SessionsDeleteParamsSchema = Type.Object({
|
|
1935
|
-
key: NonEmptyString,
|
|
1936
|
-
deleteTranscript: Type.Optional(Type.Boolean()),
|
|
1937
|
-
emitLifecycleHooks: Type.Optional(Type.Boolean())
|
|
1938
|
-
}, { additionalProperties: false });
|
|
1939
|
-
const SessionsCompactParamsSchema = Type.Object({
|
|
1940
|
-
key: NonEmptyString,
|
|
1941
|
-
maxLines: Type.Optional(Type.Integer({ minimum: 1 }))
|
|
1942
|
-
}, { additionalProperties: false });
|
|
1943
|
-
const SessionsUsageParamsSchema = Type.Object({
|
|
1944
|
-
key: Type.Optional(NonEmptyString),
|
|
1945
|
-
startDate: Type.Optional(Type.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$" })),
|
|
1946
|
-
endDate: Type.Optional(Type.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$" })),
|
|
1947
|
-
mode: Type.Optional(Type.Union([
|
|
1948
|
-
Type.Literal("utc"),
|
|
1949
|
-
Type.Literal("gateway"),
|
|
1950
|
-
Type.Literal("specific")
|
|
1951
|
-
])),
|
|
1952
|
-
utcOffset: Type.Optional(Type.String({ pattern: "^UTC[+-]\\d{1,2}(?::[0-5]\\d)?$" })),
|
|
1953
|
-
limit: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
1954
|
-
includeContextWeight: Type.Optional(Type.Boolean())
|
|
1955
|
-
}, { additionalProperties: false });
|
|
1956
|
-
|
|
1957
|
-
//#endregion
|
|
1958
|
-
//#region src/gateway/protocol/schema/wizard.ts
|
|
1959
|
-
const WizardRunStatusSchema = Type.Union([
|
|
1960
|
-
Type.Literal("running"),
|
|
1961
|
-
Type.Literal("done"),
|
|
1962
|
-
Type.Literal("cancelled"),
|
|
1963
|
-
Type.Literal("error")
|
|
1964
|
-
]);
|
|
1965
|
-
const WizardStartParamsSchema = Type.Object({
|
|
1966
|
-
mode: Type.Optional(Type.Union([Type.Literal("local"), Type.Literal("remote")])),
|
|
1967
|
-
workspace: Type.Optional(Type.String())
|
|
1968
|
-
}, { additionalProperties: false });
|
|
1969
|
-
const WizardAnswerSchema = Type.Object({
|
|
1970
|
-
stepId: NonEmptyString,
|
|
1971
|
-
value: Type.Optional(Type.Unknown())
|
|
1972
|
-
}, { additionalProperties: false });
|
|
1973
|
-
const WizardNextParamsSchema = Type.Object({
|
|
1974
|
-
sessionId: NonEmptyString,
|
|
1975
|
-
answer: Type.Optional(WizardAnswerSchema)
|
|
1976
|
-
}, { additionalProperties: false });
|
|
1977
|
-
const WizardSessionIdParamsSchema = Type.Object({ sessionId: NonEmptyString }, { additionalProperties: false });
|
|
1978
|
-
const WizardCancelParamsSchema = WizardSessionIdParamsSchema;
|
|
1979
|
-
const WizardStatusParamsSchema = WizardSessionIdParamsSchema;
|
|
1980
|
-
const WizardStepOptionSchema = Type.Object({
|
|
1981
|
-
value: Type.Unknown(),
|
|
1982
|
-
label: NonEmptyString,
|
|
1983
|
-
hint: Type.Optional(Type.String())
|
|
1984
|
-
}, { additionalProperties: false });
|
|
1985
|
-
const WizardStepSchema = Type.Object({
|
|
1986
|
-
id: NonEmptyString,
|
|
1987
|
-
type: Type.Union([
|
|
1988
|
-
Type.Literal("note"),
|
|
1989
|
-
Type.Literal("select"),
|
|
1990
|
-
Type.Literal("text"),
|
|
1991
|
-
Type.Literal("confirm"),
|
|
1992
|
-
Type.Literal("multiselect"),
|
|
1993
|
-
Type.Literal("progress"),
|
|
1994
|
-
Type.Literal("action")
|
|
1995
|
-
]),
|
|
1996
|
-
title: Type.Optional(Type.String()),
|
|
1997
|
-
message: Type.Optional(Type.String()),
|
|
1998
|
-
options: Type.Optional(Type.Array(WizardStepOptionSchema)),
|
|
1999
|
-
initialValue: Type.Optional(Type.Unknown()),
|
|
2000
|
-
placeholder: Type.Optional(Type.String()),
|
|
2001
|
-
sensitive: Type.Optional(Type.Boolean()),
|
|
2002
|
-
executor: Type.Optional(Type.Union([Type.Literal("gateway"), Type.Literal("client")]))
|
|
2003
|
-
}, { additionalProperties: false });
|
|
2004
|
-
const WizardResultFields = {
|
|
2005
|
-
done: Type.Boolean(),
|
|
2006
|
-
step: Type.Optional(WizardStepSchema),
|
|
2007
|
-
status: Type.Optional(WizardRunStatusSchema),
|
|
2008
|
-
error: Type.Optional(Type.String())
|
|
2009
|
-
};
|
|
2010
|
-
const WizardNextResultSchema = Type.Object(WizardResultFields, { additionalProperties: false });
|
|
2011
|
-
const WizardStartResultSchema = Type.Object({
|
|
2012
|
-
sessionId: NonEmptyString,
|
|
2013
|
-
...WizardResultFields
|
|
2014
|
-
}, { additionalProperties: false });
|
|
2015
|
-
const WizardStatusResultSchema = Type.Object({
|
|
2016
|
-
status: WizardRunStatusSchema,
|
|
2017
|
-
error: Type.Optional(Type.String())
|
|
2018
|
-
}, { additionalProperties: false });
|
|
2019
|
-
|
|
2020
|
-
//#endregion
|
|
2021
|
-
//#region src/gateway/protocol/schema/protocol-schemas.ts
|
|
2022
|
-
const PROTOCOL_VERSION = 3;
|
|
2023
|
-
|
|
2024
|
-
//#endregion
|
|
2025
|
-
//#region src/gateway/protocol/index.ts
|
|
2026
|
-
const ajv = new AjvPkg({
|
|
2027
|
-
allErrors: true,
|
|
2028
|
-
strict: false,
|
|
2029
|
-
removeAdditional: false
|
|
2030
|
-
});
|
|
2031
|
-
const validateConnectParams = ajv.compile(ConnectParamsSchema);
|
|
2032
|
-
const validateRequestFrame = ajv.compile(RequestFrameSchema);
|
|
2033
|
-
const validateResponseFrame = ajv.compile(ResponseFrameSchema);
|
|
2034
|
-
const validateEventFrame = ajv.compile(EventFrameSchema);
|
|
2035
|
-
const validateSendParams = ajv.compile(SendParamsSchema);
|
|
2036
|
-
const validatePollParams = ajv.compile(PollParamsSchema);
|
|
2037
|
-
const validateAgentParams = ajv.compile(AgentParamsSchema);
|
|
2038
|
-
const validateAgentIdentityParams = ajv.compile(AgentIdentityParamsSchema);
|
|
2039
|
-
const validateAgentWaitParams = ajv.compile(AgentWaitParamsSchema);
|
|
2040
|
-
const validateWakeParams = ajv.compile(WakeParamsSchema);
|
|
2041
|
-
const validateAgentsListParams = ajv.compile(AgentsListParamsSchema);
|
|
2042
|
-
const validateAgentsCreateParams = ajv.compile(AgentsCreateParamsSchema);
|
|
2043
|
-
const validateAgentsUpdateParams = ajv.compile(AgentsUpdateParamsSchema);
|
|
2044
|
-
const validateAgentsDeleteParams = ajv.compile(AgentsDeleteParamsSchema);
|
|
2045
|
-
const validateAgentsFilesListParams = ajv.compile(AgentsFilesListParamsSchema);
|
|
2046
|
-
const validateAgentsFilesGetParams = ajv.compile(AgentsFilesGetParamsSchema);
|
|
2047
|
-
const validateAgentsFilesSetParams = ajv.compile(AgentsFilesSetParamsSchema);
|
|
2048
|
-
const validateNodePairRequestParams = ajv.compile(NodePairRequestParamsSchema);
|
|
2049
|
-
const validateNodePairListParams = ajv.compile(NodePairListParamsSchema);
|
|
2050
|
-
const validateNodePairApproveParams = ajv.compile(NodePairApproveParamsSchema);
|
|
2051
|
-
const validateNodePairRejectParams = ajv.compile(NodePairRejectParamsSchema);
|
|
2052
|
-
const validateNodePairVerifyParams = ajv.compile(NodePairVerifyParamsSchema);
|
|
2053
|
-
const validateNodeRenameParams = ajv.compile(NodeRenameParamsSchema);
|
|
2054
|
-
const validateNodeListParams = ajv.compile(NodeListParamsSchema);
|
|
2055
|
-
const validateNodeDescribeParams = ajv.compile(NodeDescribeParamsSchema);
|
|
2056
|
-
const validateNodeInvokeParams = ajv.compile(NodeInvokeParamsSchema);
|
|
2057
|
-
const validateNodeInvokeResultParams = ajv.compile(NodeInvokeResultParamsSchema);
|
|
2058
|
-
const validateNodeEventParams = ajv.compile(NodeEventParamsSchema);
|
|
2059
|
-
const validatePushTestParams = ajv.compile(PushTestParamsSchema);
|
|
2060
|
-
const validateSessionsListParams = ajv.compile(SessionsListParamsSchema);
|
|
2061
|
-
const validateSessionsPreviewParams = ajv.compile(SessionsPreviewParamsSchema);
|
|
2062
|
-
const validateSessionsResolveParams = ajv.compile(SessionsResolveParamsSchema);
|
|
2063
|
-
const validateSessionsPatchParams = ajv.compile(SessionsPatchParamsSchema);
|
|
2064
|
-
const validateSessionsResetParams = ajv.compile(SessionsResetParamsSchema);
|
|
2065
|
-
const validateSessionsDeleteParams = ajv.compile(SessionsDeleteParamsSchema);
|
|
2066
|
-
const validateSessionsCompactParams = ajv.compile(SessionsCompactParamsSchema);
|
|
2067
|
-
const validateSessionsUsageParams = ajv.compile(SessionsUsageParamsSchema);
|
|
2068
|
-
const validateConfigGetParams = ajv.compile(ConfigGetParamsSchema);
|
|
2069
|
-
const validateConfigSetParams = ajv.compile(ConfigSetParamsSchema);
|
|
2070
|
-
const validateConfigApplyParams = ajv.compile(ConfigApplyParamsSchema);
|
|
2071
|
-
const validateConfigPatchParams = ajv.compile(ConfigPatchParamsSchema);
|
|
2072
|
-
const validateConfigSchemaParams = ajv.compile(ConfigSchemaParamsSchema);
|
|
2073
|
-
const validateWizardStartParams = ajv.compile(WizardStartParamsSchema);
|
|
2074
|
-
const validateWizardNextParams = ajv.compile(WizardNextParamsSchema);
|
|
2075
|
-
const validateWizardCancelParams = ajv.compile(WizardCancelParamsSchema);
|
|
2076
|
-
const validateWizardStatusParams = ajv.compile(WizardStatusParamsSchema);
|
|
2077
|
-
const validateTalkModeParams = ajv.compile(TalkModeParamsSchema);
|
|
2078
|
-
const validateTalkConfigParams = ajv.compile(TalkConfigParamsSchema);
|
|
2079
|
-
const validateChannelsStatusParams = ajv.compile(ChannelsStatusParamsSchema);
|
|
2080
|
-
const validateChannelsLogoutParams = ajv.compile(ChannelsLogoutParamsSchema);
|
|
2081
|
-
const validateModelsListParams = ajv.compile(ModelsListParamsSchema);
|
|
2082
|
-
const validateToolsCatalogParams = ajv.compile(ToolsCatalogParamsSchema);
|
|
2083
|
-
const validateCronListParams = ajv.compile(CronListParamsSchema);
|
|
2084
|
-
const validateCronStatusParams = ajv.compile(CronStatusParamsSchema);
|
|
2085
|
-
const validateCronAddParams = ajv.compile(CronAddParamsSchema);
|
|
2086
|
-
const validateCronUpdateParams = ajv.compile(CronUpdateParamsSchema);
|
|
2087
|
-
const validateCronRemoveParams = ajv.compile(CronRemoveParamsSchema);
|
|
2088
|
-
const validateCronRunParams = ajv.compile(CronRunParamsSchema);
|
|
2089
|
-
const validateCronRunsParams = ajv.compile(CronRunsParamsSchema);
|
|
2090
|
-
const validateDevicePairListParams = ajv.compile(DevicePairListParamsSchema);
|
|
2091
|
-
const validateDevicePairApproveParams = ajv.compile(DevicePairApproveParamsSchema);
|
|
2092
|
-
const validateDevicePairRejectParams = ajv.compile(DevicePairRejectParamsSchema);
|
|
2093
|
-
const validateDevicePairRemoveParams = ajv.compile(DevicePairRemoveParamsSchema);
|
|
2094
|
-
const validateDeviceTokenRotateParams = ajv.compile(DeviceTokenRotateParamsSchema);
|
|
2095
|
-
const validateDeviceTokenRevokeParams = ajv.compile(DeviceTokenRevokeParamsSchema);
|
|
2096
|
-
const validateLogsTailParams = ajv.compile(LogsTailParamsSchema);
|
|
2097
|
-
const validateChatHistoryParams = ajv.compile(ChatHistoryParamsSchema);
|
|
2098
|
-
const validateChatSendParams = ajv.compile(ChatSendParamsSchema);
|
|
2099
|
-
const validateChatAbortParams = ajv.compile(ChatAbortParamsSchema);
|
|
2100
|
-
const validateChatInjectParams = ajv.compile(ChatInjectParamsSchema);
|
|
2101
|
-
const validateChatEvent = ajv.compile(ChatEventSchema);
|
|
2102
|
-
const validateUpdateRunParams = ajv.compile(UpdateRunParamsSchema);
|
|
2103
|
-
const validateWebLoginStartParams = ajv.compile(WebLoginStartParamsSchema);
|
|
2104
|
-
const validateWebLoginWaitParams = ajv.compile(WebLoginWaitParamsSchema);
|
|
2105
|
-
function formatValidationErrors(errors) {
|
|
2106
|
-
if (!errors?.length) return "unknown validation error";
|
|
2107
|
-
const parts = [];
|
|
2108
|
-
for (const err of errors) {
|
|
2109
|
-
const keyword = typeof err?.keyword === "string" ? err.keyword : "";
|
|
2110
|
-
const instancePath = typeof err?.instancePath === "string" ? err.instancePath : "";
|
|
2111
|
-
if (keyword === "additionalProperties") {
|
|
2112
|
-
const additionalProperty = (err?.params)?.additionalProperty;
|
|
2113
|
-
if (typeof additionalProperty === "string" && additionalProperty.trim()) {
|
|
2114
|
-
const where = instancePath ? `at ${instancePath}` : "at root";
|
|
2115
|
-
parts.push(`${where}: unexpected property '${additionalProperty}'`);
|
|
2116
|
-
continue;
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
const message = typeof err?.message === "string" && err.message.trim() ? err.message : "validation error";
|
|
2120
|
-
const where = instancePath ? `at ${instancePath}: ` : "";
|
|
2121
|
-
parts.push(`${where}${message}`);
|
|
2122
|
-
}
|
|
2123
|
-
const unique = Array.from(new Set(parts.filter((part) => part.trim())));
|
|
2124
|
-
if (!unique.length) return ajv.errorsText(errors, { separator: "; " }) || "unknown validation error";
|
|
2125
|
-
return unique.join("; ");
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
//#endregion
|
|
2129
|
-
//#region src/gateway/client.ts
|
|
2130
|
-
var GatewayClient = class {
|
|
2131
|
-
constructor(opts) {
|
|
2132
|
-
this.ws = null;
|
|
2133
|
-
this.pending = /* @__PURE__ */ new Map();
|
|
2134
|
-
this.backoffMs = 1e3;
|
|
2135
|
-
this.closed = false;
|
|
2136
|
-
this.lastSeq = null;
|
|
2137
|
-
this.connectNonce = null;
|
|
2138
|
-
this.connectSent = false;
|
|
2139
|
-
this.connectTimer = null;
|
|
2140
|
-
this.lastTick = null;
|
|
2141
|
-
this.tickIntervalMs = 3e4;
|
|
2142
|
-
this.tickTimer = null;
|
|
2143
|
-
this.opts = {
|
|
2144
|
-
...opts,
|
|
2145
|
-
deviceIdentity: opts.deviceIdentity ?? loadOrCreateDeviceIdentity()
|
|
2146
|
-
};
|
|
2147
|
-
}
|
|
2148
|
-
start() {
|
|
2149
|
-
if (this.closed) return;
|
|
2150
|
-
const url = this.opts.url ?? "ws://127.0.0.1:18789";
|
|
2151
|
-
if (this.opts.tlsFingerprint && !url.startsWith("wss://")) {
|
|
2152
|
-
this.opts.onConnectError?.(/* @__PURE__ */ new Error("gateway tls fingerprint requires wss:// gateway url"));
|
|
2153
|
-
return;
|
|
2154
|
-
}
|
|
2155
|
-
if (!isSecureWebSocketUrl(url)) {
|
|
2156
|
-
let displayHost = url;
|
|
2157
|
-
try {
|
|
2158
|
-
displayHost = new URL(url).hostname || url;
|
|
2159
|
-
} catch {}
|
|
2160
|
-
const error = /* @__PURE__ */ new Error(`SECURITY ERROR: Cannot connect to "${displayHost}" over plaintext ws://. Both credentials and chat data would be exposed to network interception. Use wss:// for remote URLs. Safe defaults: keep gateway.bind=loopback and connect via SSH tunnel (ssh -N -L 18789:127.0.0.1:18789 user@gateway-host), or use Tailscale Serve/Funnel. Run \`remoteclaw doctor --fix\` for guidance.`);
|
|
2161
|
-
this.opts.onConnectError?.(error);
|
|
2162
|
-
return;
|
|
2163
|
-
}
|
|
2164
|
-
const wsOptions = { maxPayload: 25 * 1024 * 1024 };
|
|
2165
|
-
if (url.startsWith("wss://") && this.opts.tlsFingerprint) {
|
|
2166
|
-
wsOptions.rejectUnauthorized = false;
|
|
2167
|
-
wsOptions.checkServerIdentity = ((_host, cert) => {
|
|
2168
|
-
const fingerprintValue = typeof cert === "object" && cert && "fingerprint256" in cert ? cert.fingerprint256 ?? "" : "";
|
|
2169
|
-
const fingerprint = normalizeFingerprint(typeof fingerprintValue === "string" ? fingerprintValue : "");
|
|
2170
|
-
const expected = normalizeFingerprint(this.opts.tlsFingerprint ?? "");
|
|
2171
|
-
if (!expected) return /* @__PURE__ */ new Error("gateway tls fingerprint missing");
|
|
2172
|
-
if (!fingerprint) return /* @__PURE__ */ new Error("gateway tls fingerprint unavailable");
|
|
2173
|
-
if (fingerprint !== expected) return /* @__PURE__ */ new Error("gateway tls fingerprint mismatch");
|
|
2174
|
-
});
|
|
2175
|
-
}
|
|
2176
|
-
this.ws = new WebSocket$1(url, wsOptions);
|
|
2177
|
-
this.ws.on("open", () => {
|
|
2178
|
-
if (url.startsWith("wss://") && this.opts.tlsFingerprint) {
|
|
2179
|
-
const tlsError = this.validateTlsFingerprint();
|
|
2180
|
-
if (tlsError) {
|
|
2181
|
-
this.opts.onConnectError?.(tlsError);
|
|
2182
|
-
this.ws?.close(1008, tlsError.message);
|
|
2183
|
-
return;
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
this.queueConnect();
|
|
2187
|
-
});
|
|
2188
|
-
this.ws.on("message", (data) => this.handleMessage(rawDataToString(data)));
|
|
2189
|
-
this.ws.on("close", (code, reason) => {
|
|
2190
|
-
const reasonText = rawDataToString(reason);
|
|
2191
|
-
this.ws = null;
|
|
2192
|
-
if (code === 1008 && reasonText.toLowerCase().includes("device token mismatch") && !this.opts.token && !this.opts.password && this.opts.deviceIdentity) {
|
|
2193
|
-
const deviceId = this.opts.deviceIdentity.deviceId;
|
|
2194
|
-
const role = this.opts.role ?? "operator";
|
|
2195
|
-
try {
|
|
2196
|
-
clearDeviceAuthToken({
|
|
2197
|
-
deviceId,
|
|
2198
|
-
role
|
|
2199
|
-
});
|
|
2200
|
-
clearDevicePairing(deviceId).catch((err) => {
|
|
2201
|
-
logDebug(`failed clearing stale device pairing for device ${deviceId}: ${String(err)}`);
|
|
2202
|
-
});
|
|
2203
|
-
logDebug(`cleared stale device-auth token for device ${deviceId}`);
|
|
2204
|
-
} catch (err) {
|
|
2205
|
-
logDebug(`failed clearing stale device-auth token for device ${deviceId}: ${String(err)}`);
|
|
2206
|
-
}
|
|
2207
|
-
}
|
|
2208
|
-
this.flushPendingErrors(/* @__PURE__ */ new Error(`gateway closed (${code}): ${reasonText}`));
|
|
2209
|
-
this.scheduleReconnect();
|
|
2210
|
-
this.opts.onClose?.(code, reasonText);
|
|
2211
|
-
});
|
|
2212
|
-
this.ws.on("error", (err) => {
|
|
2213
|
-
logDebug(`gateway client error: ${String(err)}`);
|
|
2214
|
-
if (!this.connectSent) this.opts.onConnectError?.(err instanceof Error ? err : new Error(String(err)));
|
|
2215
|
-
});
|
|
2216
|
-
}
|
|
2217
|
-
stop() {
|
|
2218
|
-
this.closed = true;
|
|
2219
|
-
if (this.tickTimer) {
|
|
2220
|
-
clearInterval(this.tickTimer);
|
|
2221
|
-
this.tickTimer = null;
|
|
2222
|
-
}
|
|
2223
|
-
this.ws?.close();
|
|
2224
|
-
this.ws = null;
|
|
2225
|
-
this.flushPendingErrors(/* @__PURE__ */ new Error("gateway client stopped"));
|
|
2226
|
-
}
|
|
2227
|
-
sendConnect() {
|
|
2228
|
-
if (this.connectSent) return;
|
|
2229
|
-
const nonce = this.connectNonce?.trim() ?? "";
|
|
2230
|
-
if (!nonce) {
|
|
2231
|
-
this.opts.onConnectError?.(/* @__PURE__ */ new Error("gateway connect challenge missing nonce"));
|
|
2232
|
-
this.ws?.close(1008, "connect challenge missing nonce");
|
|
2233
|
-
return;
|
|
2234
|
-
}
|
|
2235
|
-
this.connectSent = true;
|
|
2236
|
-
if (this.connectTimer) {
|
|
2237
|
-
clearTimeout(this.connectTimer);
|
|
2238
|
-
this.connectTimer = null;
|
|
2239
|
-
}
|
|
2240
|
-
const role = this.opts.role ?? "operator";
|
|
2241
|
-
const explicitGatewayToken = this.opts.token?.trim() || void 0;
|
|
2242
|
-
const explicitDeviceToken = this.opts.deviceToken?.trim() || void 0;
|
|
2243
|
-
const storedToken = this.opts.deviceIdentity ? loadDeviceAuthToken({
|
|
2244
|
-
deviceId: this.opts.deviceIdentity.deviceId,
|
|
2245
|
-
role
|
|
2246
|
-
})?.token : null;
|
|
2247
|
-
const resolvedDeviceToken = explicitDeviceToken ?? (!explicitGatewayToken ? storedToken ?? void 0 : void 0);
|
|
2248
|
-
const authToken = explicitGatewayToken ?? resolvedDeviceToken;
|
|
2249
|
-
const authPassword = this.opts.password?.trim() || void 0;
|
|
2250
|
-
const auth = authToken || authPassword || resolvedDeviceToken ? {
|
|
2251
|
-
token: authToken,
|
|
2252
|
-
deviceToken: resolvedDeviceToken,
|
|
2253
|
-
password: authPassword
|
|
2254
|
-
} : void 0;
|
|
2255
|
-
const signedAtMs = Date.now();
|
|
2256
|
-
const scopes = this.opts.scopes ?? ["operator.admin"];
|
|
2257
|
-
const device = (() => {
|
|
2258
|
-
if (!this.opts.deviceIdentity) return;
|
|
2259
|
-
const payload = buildDeviceAuthPayload({
|
|
2260
|
-
deviceId: this.opts.deviceIdentity.deviceId,
|
|
2261
|
-
clientId: this.opts.clientName ?? GATEWAY_CLIENT_NAMES.GATEWAY_CLIENT,
|
|
2262
|
-
clientMode: this.opts.mode ?? GATEWAY_CLIENT_MODES.BACKEND,
|
|
2263
|
-
role,
|
|
2264
|
-
scopes,
|
|
2265
|
-
signedAtMs,
|
|
2266
|
-
token: authToken ?? null,
|
|
2267
|
-
nonce
|
|
2268
|
-
});
|
|
2269
|
-
const signature = signDevicePayload(this.opts.deviceIdentity.privateKeyPem, payload);
|
|
2270
|
-
return {
|
|
2271
|
-
id: this.opts.deviceIdentity.deviceId,
|
|
2272
|
-
publicKey: publicKeyRawBase64UrlFromPem(this.opts.deviceIdentity.publicKeyPem),
|
|
2273
|
-
signature,
|
|
2274
|
-
signedAt: signedAtMs,
|
|
2275
|
-
nonce
|
|
2276
|
-
};
|
|
2277
|
-
})();
|
|
2278
|
-
const params = {
|
|
2279
|
-
minProtocol: this.opts.minProtocol ?? PROTOCOL_VERSION,
|
|
2280
|
-
maxProtocol: this.opts.maxProtocol ?? PROTOCOL_VERSION,
|
|
2281
|
-
client: {
|
|
2282
|
-
id: this.opts.clientName ?? GATEWAY_CLIENT_NAMES.GATEWAY_CLIENT,
|
|
2283
|
-
displayName: this.opts.clientDisplayName,
|
|
2284
|
-
version: this.opts.clientVersion ?? "dev",
|
|
2285
|
-
platform: this.opts.platform ?? process.platform,
|
|
2286
|
-
mode: this.opts.mode ?? GATEWAY_CLIENT_MODES.BACKEND,
|
|
2287
|
-
instanceId: this.opts.instanceId
|
|
2288
|
-
},
|
|
2289
|
-
caps: Array.isArray(this.opts.caps) ? this.opts.caps : [],
|
|
2290
|
-
commands: Array.isArray(this.opts.commands) ? this.opts.commands : void 0,
|
|
2291
|
-
permissions: this.opts.permissions && typeof this.opts.permissions === "object" ? this.opts.permissions : void 0,
|
|
2292
|
-
pathEnv: this.opts.pathEnv,
|
|
2293
|
-
auth,
|
|
2294
|
-
role,
|
|
2295
|
-
scopes,
|
|
2296
|
-
device
|
|
2297
|
-
};
|
|
2298
|
-
this.request("connect", params).then((helloOk) => {
|
|
2299
|
-
const authInfo = helloOk?.auth;
|
|
2300
|
-
if (authInfo?.deviceToken && this.opts.deviceIdentity) storeDeviceAuthToken({
|
|
2301
|
-
deviceId: this.opts.deviceIdentity.deviceId,
|
|
2302
|
-
role: authInfo.role ?? role,
|
|
2303
|
-
token: authInfo.deviceToken,
|
|
2304
|
-
scopes: authInfo.scopes ?? []
|
|
2305
|
-
});
|
|
2306
|
-
this.backoffMs = 1e3;
|
|
2307
|
-
this.tickIntervalMs = typeof helloOk.policy?.tickIntervalMs === "number" ? helloOk.policy.tickIntervalMs : 3e4;
|
|
2308
|
-
this.lastTick = Date.now();
|
|
2309
|
-
this.startTickWatch();
|
|
2310
|
-
this.opts.onHelloOk?.(helloOk);
|
|
2311
|
-
}).catch((err) => {
|
|
2312
|
-
this.opts.onConnectError?.(err instanceof Error ? err : new Error(String(err)));
|
|
2313
|
-
const msg = `gateway connect failed: ${String(err)}`;
|
|
2314
|
-
if (this.opts.mode === GATEWAY_CLIENT_MODES.PROBE) logDebug(msg);
|
|
2315
|
-
else logError(msg);
|
|
2316
|
-
this.ws?.close(1008, "connect failed");
|
|
2317
|
-
});
|
|
2318
|
-
}
|
|
2319
|
-
handleMessage(raw) {
|
|
2320
|
-
try {
|
|
2321
|
-
const parsed = JSON.parse(raw);
|
|
2322
|
-
if (validateEventFrame(parsed)) {
|
|
2323
|
-
const evt = parsed;
|
|
2324
|
-
if (evt.event === "connect.challenge") {
|
|
2325
|
-
const payload = evt.payload;
|
|
2326
|
-
const nonce = payload && typeof payload.nonce === "string" ? payload.nonce : null;
|
|
2327
|
-
if (!nonce || nonce.trim().length === 0) {
|
|
2328
|
-
this.opts.onConnectError?.(/* @__PURE__ */ new Error("gateway connect challenge missing nonce"));
|
|
2329
|
-
this.ws?.close(1008, "connect challenge missing nonce");
|
|
2330
|
-
return;
|
|
2331
|
-
}
|
|
2332
|
-
this.connectNonce = nonce.trim();
|
|
2333
|
-
this.sendConnect();
|
|
2334
|
-
return;
|
|
2335
|
-
}
|
|
2336
|
-
const seq = typeof evt.seq === "number" ? evt.seq : null;
|
|
2337
|
-
if (seq !== null) {
|
|
2338
|
-
if (this.lastSeq !== null && seq > this.lastSeq + 1) this.opts.onGap?.({
|
|
2339
|
-
expected: this.lastSeq + 1,
|
|
2340
|
-
received: seq
|
|
2341
|
-
});
|
|
2342
|
-
this.lastSeq = seq;
|
|
2343
|
-
}
|
|
2344
|
-
if (evt.event === "tick") this.lastTick = Date.now();
|
|
2345
|
-
this.opts.onEvent?.(evt);
|
|
2346
|
-
return;
|
|
2347
|
-
}
|
|
2348
|
-
if (validateResponseFrame(parsed)) {
|
|
2349
|
-
const pending = this.pending.get(parsed.id);
|
|
2350
|
-
if (!pending) return;
|
|
2351
|
-
const status = parsed.payload?.status;
|
|
2352
|
-
if (pending.expectFinal && status === "accepted") return;
|
|
2353
|
-
this.pending.delete(parsed.id);
|
|
2354
|
-
if (parsed.ok) pending.resolve(parsed.payload);
|
|
2355
|
-
else pending.reject(new Error(parsed.error?.message ?? "unknown error"));
|
|
2356
|
-
}
|
|
2357
|
-
} catch (err) {
|
|
2358
|
-
logDebug(`gateway client parse error: ${String(err)}`);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
queueConnect() {
|
|
2362
|
-
this.connectNonce = null;
|
|
2363
|
-
this.connectSent = false;
|
|
2364
|
-
const rawConnectDelayMs = this.opts.connectDelayMs;
|
|
2365
|
-
const connectChallengeTimeoutMs = typeof rawConnectDelayMs === "number" && Number.isFinite(rawConnectDelayMs) ? Math.max(250, Math.min(1e4, rawConnectDelayMs)) : 2e3;
|
|
2366
|
-
if (this.connectTimer) clearTimeout(this.connectTimer);
|
|
2367
|
-
this.connectTimer = setTimeout(() => {
|
|
2368
|
-
if (this.connectSent || this.ws?.readyState !== WebSocket$1.OPEN) return;
|
|
2369
|
-
this.opts.onConnectError?.(/* @__PURE__ */ new Error("gateway connect challenge timeout"));
|
|
2370
|
-
this.ws?.close(1008, "connect challenge timeout");
|
|
2371
|
-
}, connectChallengeTimeoutMs);
|
|
2372
|
-
}
|
|
2373
|
-
scheduleReconnect() {
|
|
2374
|
-
if (this.closed) return;
|
|
2375
|
-
if (this.tickTimer) {
|
|
2376
|
-
clearInterval(this.tickTimer);
|
|
2377
|
-
this.tickTimer = null;
|
|
2378
|
-
}
|
|
2379
|
-
const delay = this.backoffMs;
|
|
2380
|
-
this.backoffMs = Math.min(this.backoffMs * 2, 3e4);
|
|
2381
|
-
setTimeout(() => this.start(), delay).unref();
|
|
2382
|
-
}
|
|
2383
|
-
flushPendingErrors(err) {
|
|
2384
|
-
for (const [, p] of this.pending) p.reject(err);
|
|
2385
|
-
this.pending.clear();
|
|
2386
|
-
}
|
|
2387
|
-
startTickWatch() {
|
|
2388
|
-
if (this.tickTimer) clearInterval(this.tickTimer);
|
|
2389
|
-
const rawMinInterval = this.opts.tickWatchMinIntervalMs;
|
|
2390
|
-
const minInterval = typeof rawMinInterval === "number" && Number.isFinite(rawMinInterval) ? Math.max(1, Math.min(3e4, rawMinInterval)) : 1e3;
|
|
2391
|
-
const interval = Math.max(this.tickIntervalMs, minInterval);
|
|
2392
|
-
this.tickTimer = setInterval(() => {
|
|
2393
|
-
if (this.closed) return;
|
|
2394
|
-
if (!this.lastTick) return;
|
|
2395
|
-
if (Date.now() - this.lastTick > this.tickIntervalMs * 2) this.ws?.close(4e3, "tick timeout");
|
|
2396
|
-
}, interval);
|
|
2397
|
-
}
|
|
2398
|
-
validateTlsFingerprint() {
|
|
2399
|
-
if (!this.opts.tlsFingerprint || !this.ws) return null;
|
|
2400
|
-
const expected = normalizeFingerprint(this.opts.tlsFingerprint);
|
|
2401
|
-
if (!expected) return /* @__PURE__ */ new Error("gateway tls fingerprint missing");
|
|
2402
|
-
const socket = this.ws._socket;
|
|
2403
|
-
if (!socket || typeof socket.getPeerCertificate !== "function") return /* @__PURE__ */ new Error("gateway tls fingerprint unavailable");
|
|
2404
|
-
const fingerprint = normalizeFingerprint(socket.getPeerCertificate()?.fingerprint256 ?? "");
|
|
2405
|
-
if (!fingerprint) return /* @__PURE__ */ new Error("gateway tls fingerprint unavailable");
|
|
2406
|
-
if (fingerprint !== expected) return /* @__PURE__ */ new Error("gateway tls fingerprint mismatch");
|
|
2407
|
-
return null;
|
|
2408
|
-
}
|
|
2409
|
-
async request(method, params, opts) {
|
|
2410
|
-
if (!this.ws || this.ws.readyState !== WebSocket$1.OPEN) throw new Error("gateway not connected");
|
|
2411
|
-
const id = randomUUID();
|
|
2412
|
-
const frame = {
|
|
2413
|
-
type: "req",
|
|
2414
|
-
id,
|
|
2415
|
-
method,
|
|
2416
|
-
params
|
|
2417
|
-
};
|
|
2418
|
-
if (!validateRequestFrame(frame)) throw new Error(`invalid request frame: ${JSON.stringify(validateRequestFrame.errors, null, 2)}`);
|
|
2419
|
-
const expectFinal = opts?.expectFinal === true;
|
|
2420
|
-
const p = new Promise((resolve, reject) => {
|
|
2421
|
-
this.pending.set(id, {
|
|
2422
|
-
resolve: (value) => resolve(value),
|
|
2423
|
-
reject,
|
|
2424
|
-
expectFinal
|
|
2425
|
-
});
|
|
2426
|
-
});
|
|
2427
|
-
this.ws.send(JSON.stringify(frame));
|
|
2428
|
-
return p;
|
|
2429
|
-
}
|
|
2430
|
-
};
|
|
2431
|
-
|
|
2432
|
-
//#endregion
|
|
2433
|
-
//#region src/gateway/method-scopes.ts
|
|
2434
|
-
const ADMIN_SCOPE = "operator.admin";
|
|
2435
|
-
const READ_SCOPE = "operator.read";
|
|
2436
|
-
const WRITE_SCOPE = "operator.write";
|
|
2437
|
-
const APPROVALS_SCOPE = "operator.approvals";
|
|
2438
|
-
const PAIRING_SCOPE = "operator.pairing";
|
|
2439
|
-
const CLI_DEFAULT_OPERATOR_SCOPES = [
|
|
2440
|
-
ADMIN_SCOPE,
|
|
2441
|
-
READ_SCOPE,
|
|
2442
|
-
WRITE_SCOPE,
|
|
2443
|
-
APPROVALS_SCOPE,
|
|
2444
|
-
PAIRING_SCOPE
|
|
2445
|
-
];
|
|
2446
|
-
const NODE_ROLE_METHODS = new Set(["node.invoke.result", "node.event"]);
|
|
2447
|
-
const METHOD_SCOPE_GROUPS = {
|
|
2448
|
-
[APPROVALS_SCOPE]: [
|
|
2449
|
-
"exec.approval.request",
|
|
2450
|
-
"exec.approval.waitDecision",
|
|
2451
|
-
"exec.approval.resolve"
|
|
2452
|
-
],
|
|
2453
|
-
[PAIRING_SCOPE]: [
|
|
2454
|
-
"node.pair.request",
|
|
2455
|
-
"node.pair.list",
|
|
2456
|
-
"node.pair.approve",
|
|
2457
|
-
"node.pair.reject",
|
|
2458
|
-
"node.pair.verify",
|
|
2459
|
-
"device.pair.list",
|
|
2460
|
-
"device.pair.approve",
|
|
2461
|
-
"device.pair.reject",
|
|
2462
|
-
"device.pair.remove",
|
|
2463
|
-
"device.token.rotate",
|
|
2464
|
-
"device.token.revoke",
|
|
2465
|
-
"node.rename"
|
|
2466
|
-
],
|
|
2467
|
-
[READ_SCOPE]: [
|
|
2468
|
-
"health",
|
|
2469
|
-
"logs.tail",
|
|
2470
|
-
"channels.status",
|
|
2471
|
-
"status",
|
|
2472
|
-
"usage.status",
|
|
2473
|
-
"usage.cost",
|
|
2474
|
-
"tts.status",
|
|
2475
|
-
"tts.providers",
|
|
2476
|
-
"models.list",
|
|
2477
|
-
"tools.catalog",
|
|
2478
|
-
"plugin:tools:list",
|
|
2479
|
-
"agents.list",
|
|
2480
|
-
"agent.identity.get",
|
|
2481
|
-
"voicewake.get",
|
|
2482
|
-
"sessions.list",
|
|
2483
|
-
"sessions.preview",
|
|
2484
|
-
"sessions.resolve",
|
|
2485
|
-
"sessions.usage",
|
|
2486
|
-
"sessions.usage.timeseries",
|
|
2487
|
-
"sessions.usage.logs",
|
|
2488
|
-
"cron.list",
|
|
2489
|
-
"cron.status",
|
|
2490
|
-
"cron.runs",
|
|
2491
|
-
"system-presence",
|
|
2492
|
-
"last-heartbeat",
|
|
2493
|
-
"node.list",
|
|
2494
|
-
"node.describe",
|
|
2495
|
-
"chat.history",
|
|
2496
|
-
"config.get",
|
|
2497
|
-
"talk.config",
|
|
2498
|
-
"agents.files.list",
|
|
2499
|
-
"agents.files.get"
|
|
2500
|
-
],
|
|
2501
|
-
[WRITE_SCOPE]: [
|
|
2502
|
-
"send",
|
|
2503
|
-
"poll",
|
|
2504
|
-
"agent",
|
|
2505
|
-
"agent.wait",
|
|
2506
|
-
"wake",
|
|
2507
|
-
"talk.mode",
|
|
2508
|
-
"tts.enable",
|
|
2509
|
-
"tts.disable",
|
|
2510
|
-
"tts.convert",
|
|
2511
|
-
"tts.setProvider",
|
|
2512
|
-
"voicewake.set",
|
|
2513
|
-
"node.invoke",
|
|
2514
|
-
"sessions.spawn",
|
|
2515
|
-
"sessions.subagents",
|
|
2516
|
-
"chat.send",
|
|
2517
|
-
"chat.abort",
|
|
2518
|
-
"browser.request",
|
|
2519
|
-
"push.test",
|
|
2520
|
-
"hooks.tool.before",
|
|
2521
|
-
"hooks.tool.after",
|
|
2522
|
-
"plugin:tools:invoke",
|
|
2523
|
-
"message:send",
|
|
2524
|
-
"message:reply",
|
|
2525
|
-
"message:thread-reply",
|
|
2526
|
-
"message:broadcast",
|
|
2527
|
-
"message:sendAttachment",
|
|
2528
|
-
"message:sendWithEffect"
|
|
2529
|
-
],
|
|
2530
|
-
[ADMIN_SCOPE]: [
|
|
2531
|
-
"channels.logout",
|
|
2532
|
-
"agents.create",
|
|
2533
|
-
"agents.update",
|
|
2534
|
-
"agents.delete",
|
|
2535
|
-
"cron.add",
|
|
2536
|
-
"cron.update",
|
|
2537
|
-
"cron.remove",
|
|
2538
|
-
"cron.run",
|
|
2539
|
-
"sessions.patch",
|
|
2540
|
-
"sessions.reset",
|
|
2541
|
-
"sessions.delete",
|
|
2542
|
-
"sessions.compact",
|
|
2543
|
-
"connect",
|
|
2544
|
-
"chat.inject",
|
|
2545
|
-
"web.login.start",
|
|
2546
|
-
"web.login.wait",
|
|
2547
|
-
"set-heartbeats",
|
|
2548
|
-
"system-event",
|
|
2549
|
-
"agents.files.set",
|
|
2550
|
-
"message:delete",
|
|
2551
|
-
"message:react",
|
|
2552
|
-
"message:pin",
|
|
2553
|
-
"message:readMessages"
|
|
2554
|
-
]
|
|
2555
|
-
};
|
|
2556
|
-
const ADMIN_METHOD_PREFIXES = [
|
|
2557
|
-
"exec.approvals.",
|
|
2558
|
-
"config.",
|
|
2559
|
-
"wizard.",
|
|
2560
|
-
"update."
|
|
2561
|
-
];
|
|
2562
|
-
const METHOD_SCOPE_BY_NAME = new Map(Object.entries(METHOD_SCOPE_GROUPS).flatMap(([scope, methods]) => methods.map((method) => [method, scope])));
|
|
2563
|
-
function resolveScopedMethod(method) {
|
|
2564
|
-
const explicitScope = METHOD_SCOPE_BY_NAME.get(method);
|
|
2565
|
-
if (explicitScope) return explicitScope;
|
|
2566
|
-
if (ADMIN_METHOD_PREFIXES.some((prefix) => method.startsWith(prefix))) return ADMIN_SCOPE;
|
|
2567
|
-
}
|
|
2568
|
-
function isNodeRoleMethod(method) {
|
|
2569
|
-
return NODE_ROLE_METHODS.has(method);
|
|
2570
|
-
}
|
|
2571
|
-
function resolveRequiredOperatorScopeForMethod(method) {
|
|
2572
|
-
return resolveScopedMethod(method);
|
|
2573
|
-
}
|
|
2574
|
-
function resolveLeastPrivilegeOperatorScopesForMethod(method) {
|
|
2575
|
-
const requiredScope = resolveRequiredOperatorScopeForMethod(method);
|
|
2576
|
-
if (requiredScope) return [requiredScope];
|
|
2577
|
-
return [];
|
|
2578
|
-
}
|
|
2579
|
-
function authorizeOperatorScopesForMethod(method, scopes) {
|
|
2580
|
-
if (scopes.includes(ADMIN_SCOPE)) return { allowed: true };
|
|
2581
|
-
const requiredScope = resolveRequiredOperatorScopeForMethod(method) ?? ADMIN_SCOPE;
|
|
2582
|
-
if (requiredScope === READ_SCOPE) {
|
|
2583
|
-
if (scopes.includes(READ_SCOPE) || scopes.includes(WRITE_SCOPE)) return { allowed: true };
|
|
2584
|
-
return {
|
|
2585
|
-
allowed: false,
|
|
2586
|
-
missingScope: READ_SCOPE
|
|
2587
|
-
};
|
|
2588
|
-
}
|
|
2589
|
-
if (scopes.includes(requiredScope)) return { allowed: true };
|
|
2590
|
-
return {
|
|
2591
|
-
allowed: false,
|
|
2592
|
-
missingScope: requiredScope
|
|
2593
|
-
};
|
|
2594
|
-
}
|
|
2595
|
-
|
|
2596
|
-
//#endregion
|
|
2597
|
-
//#region src/gateway/call.ts
|
|
2598
|
-
function resolveExplicitGatewayAuth(opts) {
|
|
2599
|
-
return {
|
|
2600
|
-
token: typeof opts?.token === "string" && opts.token.trim().length > 0 ? opts.token.trim() : void 0,
|
|
2601
|
-
password: typeof opts?.password === "string" && opts.password.trim().length > 0 ? opts.password.trim() : void 0
|
|
2602
|
-
};
|
|
2603
|
-
}
|
|
2604
|
-
function ensureExplicitGatewayAuth(params) {
|
|
2605
|
-
if (!params.urlOverride) return;
|
|
2606
|
-
if (params.auth.token || params.auth.password) return;
|
|
2607
|
-
const message = [
|
|
2608
|
-
"gateway url override requires explicit credentials",
|
|
2609
|
-
params.errorHint,
|
|
2610
|
-
params.configPath ? `Config: ${params.configPath}` : void 0
|
|
2611
|
-
].filter(Boolean).join("\n");
|
|
2612
|
-
throw new Error(message);
|
|
2613
|
-
}
|
|
2614
|
-
function buildGatewayConnectionDetails(options = {}) {
|
|
2615
|
-
const config = options.config ?? loadConfig();
|
|
2616
|
-
const configPath = options.configPath ?? resolveConfigPath(process.env, resolveStateDir(process.env));
|
|
2617
|
-
const isRemoteMode = config.gateway?.mode === "remote";
|
|
2618
|
-
const remote = isRemoteMode ? config.gateway?.remote : void 0;
|
|
2619
|
-
const tlsEnabled = config.gateway?.tls?.enabled === true;
|
|
2620
|
-
const localPort = resolveGatewayPort(config);
|
|
2621
|
-
const bindMode = config.gateway?.bind ?? "loopback";
|
|
2622
|
-
const localUrl = `${tlsEnabled ? "wss" : "ws"}://127.0.0.1:${localPort}`;
|
|
2623
|
-
const urlOverride = typeof options.url === "string" && options.url.trim().length > 0 ? options.url.trim() : void 0;
|
|
2624
|
-
const remoteUrl = typeof remote?.url === "string" && remote.url.trim().length > 0 ? remote.url.trim() : void 0;
|
|
2625
|
-
const remoteMisconfigured = isRemoteMode && !urlOverride && !remoteUrl;
|
|
2626
|
-
const url = urlOverride || remoteUrl || localUrl;
|
|
2627
|
-
const urlSource = urlOverride ? "cli --url" : remoteUrl ? "config gateway.remote.url" : remoteMisconfigured ? "missing gateway.remote.url (fallback local)" : "local loopback";
|
|
2628
|
-
const remoteFallbackNote = remoteMisconfigured ? "Warn: gateway.mode=remote but gateway.remote.url is missing; set gateway.remote.url or switch gateway.mode=local." : void 0;
|
|
2629
|
-
const bindDetail = !urlOverride && !remoteUrl ? `Bind: ${bindMode}` : void 0;
|
|
2630
|
-
if (!isSecureWebSocketUrl(url)) throw new Error([
|
|
2631
|
-
`SECURITY ERROR: Gateway URL "${url}" uses plaintext ws:// to a non-loopback address.`,
|
|
2632
|
-
"Both credentials and chat data would be exposed to network interception.",
|
|
2633
|
-
`Source: ${urlSource}`,
|
|
2634
|
-
`Config: ${configPath}`,
|
|
2635
|
-
"Fix: Use wss:// for remote gateway URLs.",
|
|
2636
|
-
"Safe remote access defaults:",
|
|
2637
|
-
"- keep gateway.bind=loopback and use an SSH tunnel (ssh -N -L 18789:127.0.0.1:18789 user@gateway-host)",
|
|
2638
|
-
"- or use Tailscale Serve/Funnel for HTTPS remote access",
|
|
2639
|
-
"Doctor: remoteclaw doctor --fix",
|
|
2640
|
-
"Docs: https://docs.remoteclaw.org/gateway/remote"
|
|
2641
|
-
].join("\n"));
|
|
2642
|
-
return {
|
|
2643
|
-
url,
|
|
2644
|
-
urlSource,
|
|
2645
|
-
bindDetail,
|
|
2646
|
-
remoteFallbackNote,
|
|
2647
|
-
message: [
|
|
2648
|
-
`Gateway target: ${url}`,
|
|
2649
|
-
`Source: ${urlSource}`,
|
|
2650
|
-
`Config: ${configPath}`,
|
|
2651
|
-
bindDetail,
|
|
2652
|
-
remoteFallbackNote
|
|
2653
|
-
].filter(Boolean).join("\n")
|
|
2654
|
-
};
|
|
2655
|
-
}
|
|
2656
|
-
function trimToUndefined(value) {
|
|
2657
|
-
if (typeof value !== "string") return;
|
|
2658
|
-
const trimmed = value.trim();
|
|
2659
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
2660
|
-
}
|
|
2661
|
-
function resolveGatewayCallTimeout(timeoutValue) {
|
|
2662
|
-
const timeoutMs = typeof timeoutValue === "number" && Number.isFinite(timeoutValue) ? timeoutValue : 1e4;
|
|
2663
|
-
return {
|
|
2664
|
-
timeoutMs,
|
|
2665
|
-
safeTimerTimeoutMs: Math.max(1, Math.min(Math.floor(timeoutMs), 2147483647))
|
|
2666
|
-
};
|
|
2667
|
-
}
|
|
2668
|
-
function resolveGatewayCallContext(opts) {
|
|
2669
|
-
const config = opts.config ?? loadConfig();
|
|
2670
|
-
const configPath = opts.configPath ?? resolveConfigPath(process.env, resolveStateDir(process.env));
|
|
2671
|
-
const isRemoteMode = config.gateway?.mode === "remote";
|
|
2672
|
-
const remote = isRemoteMode ? config.gateway?.remote : void 0;
|
|
2673
|
-
return {
|
|
2674
|
-
config,
|
|
2675
|
-
configPath,
|
|
2676
|
-
isRemoteMode,
|
|
2677
|
-
remote,
|
|
2678
|
-
urlOverride: trimToUndefined(opts.url),
|
|
2679
|
-
remoteUrl: trimToUndefined(remote?.url),
|
|
2680
|
-
explicitAuth: resolveExplicitGatewayAuth({
|
|
2681
|
-
token: opts.token,
|
|
2682
|
-
password: opts.password
|
|
2683
|
-
})
|
|
2684
|
-
};
|
|
2685
|
-
}
|
|
2686
|
-
function ensureRemoteModeUrlConfigured(context) {
|
|
2687
|
-
if (!context.isRemoteMode || context.urlOverride || context.remoteUrl) return;
|
|
2688
|
-
throw new Error([
|
|
2689
|
-
"gateway remote mode misconfigured: gateway.remote.url missing",
|
|
2690
|
-
`Config: ${context.configPath}`,
|
|
2691
|
-
"Fix: set gateway.remote.url, or set gateway.mode=local."
|
|
2692
|
-
].join("\n"));
|
|
2693
|
-
}
|
|
2694
|
-
function resolveGatewayCredentials(context) {
|
|
2695
|
-
return resolveGatewayCredentialsFromConfig({
|
|
2696
|
-
cfg: context.config,
|
|
2697
|
-
env: process.env,
|
|
2698
|
-
explicitAuth: context.explicitAuth,
|
|
2699
|
-
urlOverride: context.urlOverride,
|
|
2700
|
-
remotePasswordPrecedence: "env-first"
|
|
2701
|
-
});
|
|
2702
|
-
}
|
|
2703
|
-
async function resolveGatewayTlsFingerprint(params) {
|
|
2704
|
-
const { opts, context, url } = params;
|
|
2705
|
-
const tlsRuntime = context.config.gateway?.tls?.enabled === true && !context.urlOverride && !context.remoteUrl && url.startsWith("wss://") ? await loadGatewayTlsRuntime(context.config.gateway?.tls) : void 0;
|
|
2706
|
-
const overrideTlsFingerprint = trimToUndefined(opts.tlsFingerprint);
|
|
2707
|
-
const remoteTlsFingerprint = context.isRemoteMode && !context.urlOverride && context.remoteUrl ? trimToUndefined(context.remote?.tlsFingerprint) : void 0;
|
|
2708
|
-
return overrideTlsFingerprint || remoteTlsFingerprint || (tlsRuntime?.enabled ? tlsRuntime.fingerprintSha256 : void 0);
|
|
2709
|
-
}
|
|
2710
|
-
function formatGatewayCloseError(code, reason, connectionDetails) {
|
|
2711
|
-
const reasonText = reason?.trim() || "no close reason";
|
|
2712
|
-
const hint = code === 1006 ? "abnormal closure (no close frame)" : code === 1e3 ? "normal closure" : "";
|
|
2713
|
-
return `gateway closed (${code}${hint ? ` ${hint}` : ""}): ${reasonText}\n${connectionDetails.message}`;
|
|
2714
|
-
}
|
|
2715
|
-
function formatGatewayTimeoutError(timeoutMs, connectionDetails) {
|
|
2716
|
-
return `gateway timeout after ${timeoutMs}ms\n${connectionDetails.message}`;
|
|
2717
|
-
}
|
|
2718
|
-
async function executeGatewayRequestWithScopes(params) {
|
|
2719
|
-
const { opts, scopes, url, token, password, tlsFingerprint, timeoutMs, safeTimerTimeoutMs } = params;
|
|
2720
|
-
return await new Promise((resolve, reject) => {
|
|
2721
|
-
let settled = false;
|
|
2722
|
-
let ignoreClose = false;
|
|
2723
|
-
const stop = (err, value) => {
|
|
2724
|
-
if (settled) return;
|
|
2725
|
-
settled = true;
|
|
2726
|
-
clearTimeout(timer);
|
|
2727
|
-
if (err) reject(err);
|
|
2728
|
-
else resolve(value);
|
|
2729
|
-
};
|
|
2730
|
-
const client = new GatewayClient({
|
|
2731
|
-
url,
|
|
2732
|
-
token,
|
|
2733
|
-
password,
|
|
2734
|
-
tlsFingerprint,
|
|
2735
|
-
instanceId: opts.instanceId ?? randomUUID(),
|
|
2736
|
-
clientName: opts.clientName ?? GATEWAY_CLIENT_NAMES.CLI,
|
|
2737
|
-
clientDisplayName: opts.clientDisplayName,
|
|
2738
|
-
clientVersion: opts.clientVersion ?? "dev",
|
|
2739
|
-
platform: opts.platform,
|
|
2740
|
-
mode: opts.mode ?? GATEWAY_CLIENT_MODES.CLI,
|
|
2741
|
-
role: "operator",
|
|
2742
|
-
scopes,
|
|
2743
|
-
deviceIdentity: loadOrCreateDeviceIdentity(),
|
|
2744
|
-
minProtocol: opts.minProtocol ?? PROTOCOL_VERSION,
|
|
2745
|
-
maxProtocol: opts.maxProtocol ?? PROTOCOL_VERSION,
|
|
2746
|
-
onHelloOk: async () => {
|
|
2747
|
-
try {
|
|
2748
|
-
const result = await client.request(opts.method, opts.params, { expectFinal: opts.expectFinal });
|
|
2749
|
-
ignoreClose = true;
|
|
2750
|
-
stop(void 0, result);
|
|
2751
|
-
client.stop();
|
|
2752
|
-
} catch (err) {
|
|
2753
|
-
ignoreClose = true;
|
|
2754
|
-
client.stop();
|
|
2755
|
-
stop(err);
|
|
2756
|
-
}
|
|
2757
|
-
},
|
|
2758
|
-
onClose: (code, reason) => {
|
|
2759
|
-
if (settled || ignoreClose) return;
|
|
2760
|
-
ignoreClose = true;
|
|
2761
|
-
client.stop();
|
|
2762
|
-
stop(new Error(formatGatewayCloseError(code, reason, params.connectionDetails)));
|
|
2763
|
-
}
|
|
2764
|
-
});
|
|
2765
|
-
const timer = setTimeout(() => {
|
|
2766
|
-
ignoreClose = true;
|
|
2767
|
-
client.stop();
|
|
2768
|
-
stop(new Error(formatGatewayTimeoutError(timeoutMs, params.connectionDetails)));
|
|
2769
|
-
}, safeTimerTimeoutMs);
|
|
2770
|
-
client.start();
|
|
2771
|
-
});
|
|
2772
|
-
}
|
|
2773
|
-
async function callGatewayWithScopes(opts, scopes) {
|
|
2774
|
-
const { timeoutMs, safeTimerTimeoutMs } = resolveGatewayCallTimeout(opts.timeoutMs);
|
|
2775
|
-
const context = resolveGatewayCallContext(opts);
|
|
2776
|
-
ensureExplicitGatewayAuth({
|
|
2777
|
-
urlOverride: context.urlOverride,
|
|
2778
|
-
auth: context.explicitAuth,
|
|
2779
|
-
errorHint: "Fix: pass --token or --password (or gatewayToken in tools).",
|
|
2780
|
-
configPath: context.configPath
|
|
2781
|
-
});
|
|
2782
|
-
ensureRemoteModeUrlConfigured(context);
|
|
2783
|
-
const connectionDetails = buildGatewayConnectionDetails({
|
|
2784
|
-
config: context.config,
|
|
2785
|
-
url: context.urlOverride,
|
|
2786
|
-
...opts.configPath ? { configPath: opts.configPath } : {}
|
|
2787
|
-
});
|
|
2788
|
-
const url = connectionDetails.url;
|
|
2789
|
-
const tlsFingerprint = await resolveGatewayTlsFingerprint({
|
|
2790
|
-
opts,
|
|
2791
|
-
context,
|
|
2792
|
-
url
|
|
2793
|
-
});
|
|
2794
|
-
const { token, password } = resolveGatewayCredentials(context);
|
|
2795
|
-
return await executeGatewayRequestWithScopes({
|
|
2796
|
-
opts,
|
|
2797
|
-
scopes,
|
|
2798
|
-
url,
|
|
2799
|
-
token,
|
|
2800
|
-
password,
|
|
2801
|
-
tlsFingerprint,
|
|
2802
|
-
timeoutMs,
|
|
2803
|
-
safeTimerTimeoutMs,
|
|
2804
|
-
connectionDetails
|
|
2805
|
-
});
|
|
2806
|
-
}
|
|
2807
|
-
async function callGatewayCli(opts) {
|
|
2808
|
-
return await callGatewayWithScopes(opts, Array.isArray(opts.scopes) ? opts.scopes : CLI_DEFAULT_OPERATOR_SCOPES);
|
|
2809
|
-
}
|
|
2810
|
-
async function callGatewayLeastPrivilege(opts) {
|
|
2811
|
-
return await callGatewayWithScopes(opts, resolveLeastPrivilegeOperatorScopesForMethod(opts.method));
|
|
2812
|
-
}
|
|
2813
|
-
async function callGateway(opts) {
|
|
2814
|
-
if (Array.isArray(opts.scopes)) return await callGatewayWithScopes(opts, opts.scopes);
|
|
2815
|
-
const callerMode = opts.mode ?? GATEWAY_CLIENT_MODES.BACKEND;
|
|
2816
|
-
const callerName = opts.clientName ?? GATEWAY_CLIENT_NAMES.GATEWAY_CLIENT;
|
|
2817
|
-
if (callerMode === GATEWAY_CLIENT_MODES.CLI || callerName === GATEWAY_CLIENT_NAMES.CLI) return await callGatewayCli(opts);
|
|
2818
|
-
return await callGatewayLeastPrivilege({
|
|
2819
|
-
...opts,
|
|
2820
|
-
mode: callerMode,
|
|
2821
|
-
clientName: callerName
|
|
2822
|
-
});
|
|
2823
|
-
}
|
|
2824
|
-
function randomIdempotencyKey() {
|
|
2825
|
-
return randomUUID();
|
|
2826
|
-
}
|
|
2827
|
-
|
|
2828
|
-
//#endregion
|
|
2829
|
-
export { validateNodeInvokeResultParams as $, upsertPendingPairingRequest as $t, validateConfigApplyParams as A, PROTOCOL_VERSION as At, validateCronRunsParams as B, rejectDevicePairing as Bt, validateAgentsUpdateParams as C, validateWakeParams as Ct, validateChatHistoryParams as D, validateWizardNextParams as Dt, validateChatAbortParams as E, validateWizardCancelParams as Et, validateConnectParams as F, buildDeviceAuthPayload as Ft, validateDevicePairRejectParams as G, summarizeDeviceTokens as Gt, validateCronUpdateParams as H, requestDevicePairing as Ht, validateCronAddParams as I, approveDevicePairing as It, validateDeviceTokenRotateParams as J, generatePairingToken as Jt, validateDevicePairRemoveParams as K, updatePairedDeviceMetadata as Kt, validateCronListParams as L, ensureDeviceToken as Lt, validateConfigPatchParams as M, errorShape as Mt, validateConfigSchemaParams as N, SESSION_LABEL_MAX_LENGTH as Nt, validateChatInjectParams as O, validateWizardStartParams as Ot, validateConfigSetParams as P, parseSessionLabel as Pt, validateNodeInvokeParams as Q, resolvePairingPaths as Qt, validateCronRemoveParams as R, getPairedDevice as Rt, validateAgentsListParams as S, validateUpdateRunParams as St, validateChannelsStatusParams as T, validateWebLoginWaitParams as Tt, validateDevicePairApproveParams as U, revokeDeviceToken as Ut, validateCronStatusParams as V, removePairedDevice as Vt, validateDevicePairListParams as W, rotateDeviceToken as Wt, validateNodeDescribeParams as X, rejectPendingPairingRequest as Xt, validateLogsTailParams as Y, verifyPairingToken as Yt, validateNodeEventParams as Z, pruneExpiredPending as Zt, validateAgentsCreateParams as _, validateSessionsResolveParams as _t, randomIdempotencyKey as a, validateNodePairVerifyParams as at, validateAgentsFilesListParams as b, validateTalkModeParams as bt, READ_SCOPE as c, validatePushTestParams as ct, resolveLeastPrivilegeOperatorScopesForMethod as d, validateSessionsCompactParams as dt, roleScopesAllow as en, validateNodeListParams as et, GatewayClient as f, validateSessionsDeleteParams as ft, validateAgentWaitParams as g, validateSessionsResetParams as gt, validateAgentParams as h, validateSessionsPreviewParams as ht, ensureExplicitGatewayAuth as i, verifyDeviceSignature as in, validateNodePairRequestParams as it, validateConfigGetParams as j, ErrorCodes as jt, validateChatSendParams as k, validateWizardStatusParams as kt, authorizeOperatorScopesForMethod as l, validateRequestFrame as lt, validateAgentIdentityParams as m, validateSessionsPatchParams as mt, callGateway as n, deriveDeviceIdFromPublicKey as nn, validateNodePairListParams as nt, resolveExplicitGatewayAuth as o, validateNodeRenameParams as ot, formatValidationErrors as p, validateSessionsListParams as pt, validateDeviceTokenRevokeParams as q, verifyDeviceToken as qt, callGatewayLeastPrivilege as r, normalizeDevicePublicKeyBase64Url as rn, validateNodePairRejectParams as rt, ADMIN_SCOPE as s, validatePollParams as st, buildGatewayConnectionDetails as t, loadGatewayTlsRuntime as tn, validateNodePairApproveParams as tt, isNodeRoleMethod as u, validateSendParams as ut, validateAgentsDeleteParams as v, validateSessionsUsageParams as vt, validateChannelsLogoutParams as w, validateWebLoginStartParams as wt, validateAgentsFilesSetParams as x, validateToolsCatalogParams as xt, validateAgentsFilesGetParams as y, validateTalkConfigParams as yt, validateCronRunParams as z, listDevicePairing as zt };
|