@noxsoft/anima 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1260 -28
- package/dist/accounts-Bth3PpPD.js +260 -0
- package/dist/accounts-D8CPKNkN.js +259 -0
- package/dist/acp-cli-ByK6lS6c.js +1081 -0
- package/dist/acp-cli-CaQCjIw4.js +1084 -0
- package/dist/agent-BgIkqd3F.js +725 -0
- package/dist/agent-N5BDcge4.js +725 -0
- package/dist/agent-events-COH7NDW2.js +182 -0
- package/dist/agent-scope-CPphqq-U.js +452 -0
- package/dist/agent-scope-DZgptr9J.js +452 -0
- package/dist/agent-scope-cj2QCT6R.js +112 -0
- package/dist/agents-NEudYMdg.js +774 -0
- package/dist/agents.config-Bujs-NIy.js +182 -0
- package/dist/agents.config-jp7OLssr.js +182 -0
- package/dist/argv-BMZMiW7v.js +73 -0
- package/dist/audit-C-UJhfdv.js +2401 -0
- package/dist/audit-CeCO7SK5.js +2401 -0
- package/dist/auth-BNZsOHGF.js +648 -0
- package/dist/auth-DMPZWzEa.js +639 -0
- package/dist/auth-choice-5VnaGMD-.js +2681 -0
- package/dist/auth-choice-DA2k4vs8.js +2681 -0
- package/dist/auth-health-B7FqA26_.js +149 -0
- package/dist/auth-health-VO_MPqVX.js +149 -0
- package/dist/auth-profiles-BDrNYX_n.js +1564 -0
- package/dist/auth-profiles-CxSHydjn.js +2689 -0
- package/dist/banner-BtDZPRzi.js +294 -0
- package/dist/browser-cli-8yQMpxb8.js +1679 -0
- package/dist/browser-cli-Czg3JtDH.js +1676 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +16 -16
- package/dist/bundled/bootstrap-extra-files/handler.js +4 -4
- package/dist/bundled/command-logger/handler.js +1 -1
- package/dist/bundled/session-memory/handler.js +5 -5
- package/dist/call-BIzCaKZb.js +282 -0
- package/dist/call-BYDpTVCZ.js +282 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/catalog-CqKiUgu6.js +185 -0
- package/dist/catalog-DMfEg-oK.js +185 -0
- package/dist/channel-options-BrtCtyrT.js +32 -0
- package/dist/channel-options-CO21Gl8p.js +33 -0
- package/dist/channel-selection-Bbm1lq3P.js +51 -0
- package/dist/channel-selection-CqcX7Ocw.js +51 -0
- package/dist/channel-web-DrsT6OAE.js +2162 -0
- package/dist/channels-cli-Juyh1S6n.js +1304 -0
- package/dist/channels-cli-zNvi1m5c.js +1306 -0
- package/dist/channels-status-issues-CqzqshW4.js +18 -0
- package/dist/channels-status-issues-DdJdO866.js +18 -0
- package/dist/chrome-C4dOMO8z.js +1601 -0
- package/dist/chrome-DdcDzAtH.js +1629 -0
- package/dist/chrome-U3DRzjJD.js +1601 -0
- package/dist/chunk-D2nLsrEW.js +348 -0
- package/dist/clack-prompter-BI3RDW5w.js +92 -0
- package/dist/clack-prompter-Dwr1m_IZ.js +92 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-C3cpDaz8.js +99 -0
- package/dist/cli-CjWUGdGC.js +101 -0
- package/dist/cli-session-BVjY_XrW.js +5463 -0
- package/dist/cli-session-gtuYN2Iq.js +5408 -0
- package/dist/client-Dswwze5_.js +1692 -0
- package/dist/client-LRKFjo4A.js +1692 -0
- package/dist/clipboard-BZKS9O1u.js +31 -0
- package/dist/clipboard-DES8b1AM.js +31 -0
- package/dist/command-format-CP1YTNCl.js +52 -0
- package/dist/command-format-CVL4K5cj.js +52 -0
- package/dist/command-format-G6N2zghg.js +38 -0
- package/dist/command-registry-BBvNvysr.js +248 -0
- package/dist/commands-AZ3n8Y2c.js +726 -0
- package/dist/commands-BMnD_QRY.js +726 -0
- package/dist/commands-registry-cFqZ6Ib4.js +766 -0
- package/dist/commands-registry-q13H7ng5.js +766 -0
- package/dist/common-CX5458fH.js +287 -0
- package/dist/common-DJbnT8ws.js +287 -0
- package/dist/completion-cli-BADRBcIl.js +432 -0
- package/dist/completion-cli-DMQgiObF.js +431 -0
- package/dist/config-CU-Axg8P.js +5704 -0
- package/dist/config-DaqbUdkI.js +5705 -0
- package/dist/config-cli-BPlbwiuA.js +244 -0
- package/dist/config-cli-DXgZJkPU.js +247 -0
- package/dist/config-guard-Ba49JNds.js +76 -0
- package/dist/config-guard-Cu0qMKZJ.js +93 -0
- package/dist/config-kVVm5EYV.js +6523 -0
- package/dist/config-sync-CzLnLTXt.js +91 -0
- package/dist/config-sync-DuydxPWx.js +91 -0
- package/dist/configure-CHgacLyi.js +960 -0
- package/dist/configure-DfHXDa1L.js +959 -0
- package/dist/context-DzgXOckU.js +60 -0
- package/dist/control-service-8_wKHwBa.js +72 -0
- package/dist/control-service-BtL1Jto_.js +72 -0
- package/dist/cron-cli-BCzSR2c0.js +448 -0
- package/dist/cron-cli-CCWNkykU.js +451 -0
- package/dist/daemon-cli-Bjkbu9Vy.js +565 -0
- package/dist/daemon-cli-CmlHcC1J.js +566 -0
- package/dist/daemon-cli.js +16 -16
- package/dist/daemon-runtime-C0tz7VAC.js +460 -0
- package/dist/daemon-runtime-rUTqCVwJ.js +460 -0
- package/dist/deliver-BBggsviM.js +1097 -0
- package/dist/deliver-CePITOl8.js +1162 -0
- package/dist/deliver-DFnVaetP.js +1097 -0
- package/dist/delivery-queue-BJQK3oh5.js +220 -0
- package/dist/deps-CeEKhrp7.js +42 -0
- package/dist/devices-cli-DQrDMrZH.js +198 -0
- package/dist/devices-cli-Oe-A1Dv0.js +195 -0
- package/dist/diagnostics-DxMFrBLO.js +35 -0
- package/dist/diagnostics-m79ZlMmZ.js +35 -0
- package/dist/directory-cli-BL6h8cGF.js +246 -0
- package/dist/directory-cli-Cjgmi_sj.js +243 -0
- package/dist/dispatcher-DAFbQM-c.js +100 -0
- package/dist/dispatcher-DNd40gUn.js +100 -0
- package/dist/dist-CqDI82ei.js +929 -0
- package/dist/dist-DnHRxR5U.js +929 -0
- package/dist/dns-cli-CFtV3BXK.js +200 -0
- package/dist/dns-cli-NyIHvQ5S.js +197 -0
- package/dist/dock-BdXLb5oY.js +753 -0
- package/dist/dock-jYICmNcI.js +753 -0
- package/dist/docs-cli-CrOaIK_H.js +161 -0
- package/dist/docs-cli-D_cmJDSr.js +159 -0
- package/dist/doctor-BpGxKrBl.js +1815 -0
- package/dist/doctor-D12wNQPU.js +1813 -0
- package/dist/doctor-completion-DeOfofek.js +92 -0
- package/dist/doctor-completion-DwjqdEcK.js +92 -0
- package/dist/doctor-config-flow-BI3mpkbd.js +1232 -0
- package/dist/doctor-config-flow-wMHheFkC.js +1232 -0
- package/dist/engine-BCtL-AMw.js +563 -0
- package/dist/engine-Bk_UT413.js +563 -0
- package/dist/entry.js +5 -5
- package/dist/env-v6411I8h.js +32 -0
- package/dist/exec-B7sUS164.js +1167 -0
- package/dist/exec-approvals-CroGJRUg.js +1221 -0
- package/dist/exec-approvals-cli-BTxF_RsH.js +371 -0
- package/dist/exec-approvals-cli-n1gyGwH2.js +368 -0
- package/dist/exec-mhSykkaa.js +255 -0
- package/dist/extensionAPI.js +3 -3
- package/dist/frontmatter-BmHq0vRD.js +204 -0
- package/dist/gateway-cli-DDBadlrS.js +19971 -0
- package/dist/gateway-cli-IZNkOMBe.js +19972 -0
- package/dist/gateway-rpc-Dtx8HN-n.js +28 -0
- package/dist/gateway-rpc-L2PVSqGj.js +28 -0
- package/dist/github-copilot-auth-DKyqDaGU.js +1418 -0
- package/dist/github-copilot-auth-DXpOMSd3.js +1418 -0
- package/dist/gmail-setup-utils-BKNczIJ9.js +428 -0
- package/dist/gmail-setup-utils-co0ppccC.js +428 -0
- package/dist/health-Bm8ZTvC3.js +1253 -0
- package/dist/health-DUf1gt4E.js +1258 -0
- package/dist/health-format-BksT6F68.js +208 -0
- package/dist/health-format-uzh1xYLD.js +208 -0
- package/dist/heartbeat-visibility-1TJb1Zao.js +98 -0
- package/dist/heartbeat-visibility-CwodtdcX.js +98 -0
- package/dist/help-format-C6cv_aZp.js +17 -0
- package/dist/helpers-N-uSFKOn.js +10 -0
- package/dist/hooks-cli-1POsXqOl.js +993 -0
- package/dist/hooks-cli-BGjILbze.js +991 -0
- package/dist/hooks-status-DE07n5RC.js +356 -0
- package/dist/hooks-status-Du-d1jde.js +356 -0
- package/dist/image-ops-B_AYV3tp.js +541 -0
- package/dist/image-ops-Bp0C6Mvr.js +541 -0
- package/dist/index.js +82 -82
- package/dist/init-9A0s7bWG.js +122 -0
- package/dist/init-DoyCHJDC.js +122 -0
- package/dist/installs-D1C9wHAq.js +383 -0
- package/dist/installs-Dh4dHayM.js +383 -0
- package/dist/ipv4-DCItfaJo.js +1964 -0
- package/dist/ipv4-DSOUVx0i.js +1964 -0
- package/dist/lanes-BvSnHq2h.js +232 -0
- package/dist/lifecycle-core-BY4WIf9g.js +388 -0
- package/dist/lifecycle-core-TQKyXO-6.js +387 -0
- package/dist/links-CNu_8RZl.js +15 -0
- package/dist/links-D2tt2ouh.js +15 -0
- package/dist/llm-slug-generator.js +4 -4
- package/dist/logging-BIeRw0WR.js +15 -0
- package/dist/logging-C7lb3Vjc.js +15 -0
- package/dist/login-DXWKewA2.js +59 -0
- package/dist/login-Fhh4uWmf.js +61 -0
- package/dist/login-pPs3UO38.js +61 -0
- package/dist/login-qr-CevLD8cV.js +326 -0
- package/dist/login-qr-GF2JMIy-.js +323 -0
- package/dist/login-qr-ZYYKD6Yt.js +321 -0
- package/dist/logs-cli-CzXbX8HZ.js +242 -0
- package/dist/logs-cli-D9ngH9PF.js +245 -0
- package/dist/manager-BD5rA3w0.js +3244 -0
- package/dist/manager-BDPgBQSH.js +3246 -0
- package/dist/manager-DRWMWM--.js +3244 -0
- package/dist/manifest-registry-DbvPaBXY.js +748 -0
- package/dist/manifest-registry-kHX_MFa1.js +748 -0
- package/dist/markdown-tables-CqwihY2m.js +347 -0
- package/dist/markdown-tables-DJV7eAJZ.js +348 -0
- package/dist/media-lUqN-0O9.js +1342 -0
- package/dist/memory-cli-BLXSpgnN.js +868 -0
- package/dist/memory-cli-BcGVkkRJ.js +869 -0
- package/dist/message-channel-D_jIO87f.js +110 -0
- package/dist/migrate-BpVOar4L.js +157 -0
- package/dist/migrate-CkgGDkWy.js +157 -0
- package/dist/model-selection-Cqt6aJ0G.js +2691 -0
- package/dist/models-CExsNQPH.js +2510 -0
- package/dist/models-cli-Ba3Jmwev.js +2739 -0
- package/dist/models-cli-iDAlsbL2.js +258 -0
- package/dist/net-0A_zcaQD.js +218 -0
- package/dist/node-cli-ATmwCXIk.js +1319 -0
- package/dist/node-cli-DYFR_V25.js +1322 -0
- package/dist/node-service-CN4LqR1A.js +67 -0
- package/dist/node-service-CWt3MdSC.js +67 -0
- package/dist/nodes-cli-BeVmhTz3.js +1197 -0
- package/dist/nodes-cli-QeJIfa18.js +1200 -0
- package/dist/nodes-screen-DHyWAlla.js +234 -0
- package/dist/nodes-screen-qs3jRBPk.js +234 -0
- package/dist/note-CSlg2BnB.js +73 -0
- package/dist/note-Ctvglhp1.js +73 -0
- package/dist/npm-registry-spec-DQd4M22q.js +351 -0
- package/dist/npm-registry-spec-PxisIMts.js +351 -0
- package/dist/onboard-DeruD10m.js +1166 -0
- package/dist/onboard-SAcu5N6N.js +1165 -0
- package/dist/onboard-channels-C4iSfFXR.js +672 -0
- package/dist/onboard-channels-oVTVgoyg.js +672 -0
- package/dist/onboard-helpers-B8roRwLP.js +365 -0
- package/dist/onboard-helpers-Dgh26hgP.js +365 -0
- package/dist/onboarding-Bi-ac8we.js +911 -0
- package/dist/onboarding-C2gjB2u8.js +910 -0
- package/dist/orchestrator-DlbAYMQP.js +357 -0
- package/dist/orchestrator-DlwVRVDA.js +357 -0
- package/dist/outbound-CkKgc6iR.js +2062 -0
- package/dist/outbound-Vfm5yDh3.js +214 -0
- package/dist/outbound-bs_VK51X.js +214 -0
- package/dist/outbound-send-deps-DDjiMfEL.js +55 -0
- package/dist/pairing-cli-CJYeuEik.js +118 -0
- package/dist/pairing-cli-mqopHI8s.js +121 -0
- package/dist/pairing-store-BsXzUDPv.js +388 -0
- package/dist/pairing-store-DoNj00-X.js +388 -0
- package/dist/path-env-C_xpiG8l.js +89 -0
- package/dist/path-env-DSSMHu5A.js +89 -0
- package/dist/paths-B1vRVCad.js +126 -0
- package/dist/paths-BMuHNFxg.js +238 -0
- package/dist/paths-BXQQzXGQ.js +129 -0
- package/dist/paths-Buw_geoe.js +54 -0
- package/dist/paths-DA9WYabg.js +222 -0
- package/dist/paths-DfQGx0_k.js +129 -0
- package/dist/pi-auth-json-DOPW3e4X.js +78 -0
- package/dist/pi-auth-json-MruLmI_X.js +82 -0
- package/dist/pi-auth-json-lae_wwwo.js +80 -0
- package/dist/pi-model-discovery-7q0GxMrp.js +3 -0
- package/dist/pi-tools.policy-Csmla32P.js +200 -0
- package/dist/pi-tools.policy-xYdDLEv9.js +200 -0
- package/dist/plugin-auto-enable-CViVVWgg.js +282 -0
- package/dist/plugin-auto-enable-CjZ238UI.js +282 -0
- package/dist/plugin-registry-B4Aw2hzq.js +32 -0
- package/dist/plugin-registry-DW81arxW.js +32 -0
- package/dist/plugin-sdk/cli/cli-name.d.ts +1 -1
- package/dist/plugin-sdk/config/paths.d.ts +2 -2
- package/dist/plugin-sdk/index.js +7 -7
- package/dist/plugins-DhcGAPDB.js +38 -0
- package/dist/plugins-DtghNRtM.js +168 -0
- package/dist/plugins-cli-4vWTmOAb.js +736 -0
- package/dist/plugins-cli-CdTMbP0X.js +734 -0
- package/dist/polls-D6eCdatA.js +1343 -0
- package/dist/ports-BtZx-JKD.js +96 -0
- package/dist/ports-C8bKN8s0.js +96 -0
- package/dist/ports-DHiKnPRX.js +344 -0
- package/dist/ports-vd93M_Pt.js +317 -0
- package/dist/program-CX3aUVeb.js +176 -0
- package/dist/program-context-BPos0ivo.js +496 -0
- package/dist/progress-oiAjiiNi.js +133 -0
- package/dist/prompt-style-Cm4wOtKm.js +9 -0
- package/dist/pw-ai-4QbK5YFe.js +1865 -0
- package/dist/pw-ai-BWz3Cxt7.js +1868 -0
- package/dist/pw-ai-C83HBue2.js +1867 -0
- package/dist/qmd-manager-BcMeZiGD.js +938 -0
- package/dist/qmd-manager-CPypGJ0P.js +935 -0
- package/dist/qmd-manager-CRrSkfia.js +937 -0
- package/dist/register.agent-DDY8KJhn.js +265 -0
- package/dist/register.agent-DKawm-9d.js +1003 -0
- package/dist/register.anima-CEWUo29k.js +193 -0
- package/dist/register.anima-DBWz2rk_.js +193 -0
- package/dist/register.configure-BX67qV8k.js +103 -0
- package/dist/register.configure-CWsySuiq.js +101 -0
- package/dist/register.maintenance-0k-ZNhDg.js +543 -0
- package/dist/register.maintenance-BIwx1fzX.js +543 -0
- package/dist/register.message-CXPsoakA.js +657 -0
- package/dist/register.message-DA3jvfgI.js +660 -0
- package/dist/register.onboard-C4HG7Hqv.js +170 -0
- package/dist/register.onboard-GOpdif-j.js +170 -0
- package/dist/register.setup-B17vZT7C.js +175 -0
- package/dist/register.setup-GJyUDCqh.js +175 -0
- package/dist/register.status-health-sessions-D5876dGx.js +313 -0
- package/dist/register.status-health-sessions-lOewVIZR.js +142 -0
- package/dist/register.subclis-Dwnujj5C.js +255 -0
- package/dist/reply-CR5T_oQJ.js +32212 -0
- package/dist/reply-prefix-BcrS4Umd.js +100 -0
- package/dist/reply-prefix-Btb5o2NH.js +100 -0
- package/dist/reply-r089HuRA.js +32212 -0
- package/dist/routes-B4czFzIb.js +1820 -0
- package/dist/routes-ucJWAk5O.js +1820 -0
- package/dist/rpc-BnKxnQ0v.js +70 -0
- package/dist/rpc-DgE-xnyx.js +70 -0
- package/dist/run-main-B74kv84C.js +371 -0
- package/dist/runtime-guard-CKFdts2L.js +60 -0
- package/dist/sandbox-CJTS3er6.js +858 -0
- package/dist/sandbox-DBSiVHt_.js +859 -0
- package/dist/sandbox-cli-CrkjyU5M.js +461 -0
- package/dist/sandbox-cli-D1r5y6Sz.js +458 -0
- package/dist/security-cli-BZUdnkhn.js +462 -0
- package/dist/security-cli-DS09ebvA.js +465 -0
- package/dist/server-context-C0xZbYhg.js +824 -0
- package/dist/server-context-DVh2z7om.js +824 -0
- package/dist/server-node-events-bu9lpkMH.js +233 -0
- package/dist/server-node-events-i1Rrww31.js +231 -0
- package/dist/service-CJJwLEor.js +642 -0
- package/dist/service-DxLxBhaU.js +642 -0
- package/dist/service-audit-DB4Y3Ekp.js +488 -0
- package/dist/service-audit-M8y4TXVb.js +488 -0
- package/dist/session-CGxOLFs2.js +179 -0
- package/dist/session-DTTbdKb0.js +181 -0
- package/dist/session-cost-usage-FcdJl9c3.js +600 -0
- package/dist/session-cost-usage-qdfsGU2a.js +600 -0
- package/dist/session-yOhWcsD2.js +181 -0
- package/dist/sessions-B-Cu7JZq.js +1296 -0
- package/dist/sessions-BgLN4KFr.js +180 -0
- package/dist/sessions-CnRjwdVr.js +1296 -0
- package/dist/sessions-wRKla1Qh.js +2038 -0
- package/dist/shared-DS3UaJSP.js +66 -0
- package/dist/shared-DxNHzky3.js +77 -0
- package/dist/shared-Qpt4hUDi.js +66 -0
- package/dist/shared-kzrojZ1B.js +77 -0
- package/dist/skill-scanner-DLJji5Ye.js +263 -0
- package/dist/skills-BWFIEp4j.js +807 -0
- package/dist/skills-DV4zKdCx.js +808 -0
- package/dist/skills-cli-BY53ILm2.js +289 -0
- package/dist/skills-cli-CO3gxl8A.js +286 -0
- package/dist/skills-status-DX5pcqY3.js +166 -0
- package/dist/skills-status-zhcKzGkp.js +166 -0
- package/dist/sqlite-B6MojU1I.js +321 -0
- package/dist/sqlite-CuprTGR7.js +453 -0
- package/dist/sqlite-dzD-jMjs.js +368 -0
- package/dist/start-Cu3aLoSf.js +297 -0
- package/dist/start-Dz7tMAl8.js +296 -0
- package/dist/status-CaSxhxfV.js +2132 -0
- package/dist/status-D2C0JCX3.js +2137 -0
- package/dist/status-DlFMsQzh.js +27 -0
- package/dist/status-G0CITnKR.js +27 -0
- package/dist/status.update-CHjhVxJY.js +79 -0
- package/dist/status.update-DVFelehi.js +79 -0
- package/dist/subagent-registry-3Xb4el-8.js +14 -0
- package/dist/subagent-registry-CdSjz14I.js +2760 -0
- package/dist/subagent-registry-DNDhbHWi.js +2759 -0
- package/dist/subsystem-DfKstnEK.js +860 -0
- package/dist/system-cli-B5mt0FWa.js +82 -0
- package/dist/system-cli-Dg3UQ3Zz.js +79 -0
- package/dist/systemd-B43AvOGx.js +452 -0
- package/dist/systemd-RpPE0XGg.js +452 -0
- package/dist/systemd-hints-DMJT-Bbc.js +36 -0
- package/dist/systemd-hints-vRInKcz9.js +36 -0
- package/dist/systemd-linger-Dzyxqsod.js +75 -0
- package/dist/systemd-linger-EujbmI5A.js +75 -0
- package/dist/table-DhXHfRX2.js +279 -0
- package/dist/table-bWCLW-3P.js +279 -0
- package/dist/timeout-Ddn-5kAO.js +232 -0
- package/dist/tokens-3psI_Qk2.js +14 -0
- package/dist/tokens-BaM53PEx.js +14 -0
- package/dist/trash-Bmxs1Rnm.js +23 -0
- package/dist/trash-C39a6hKA.js +23 -0
- package/dist/tui-BHgBWhHE.js +3894 -0
- package/dist/tui-cli-B9Sq5-cC.js +50 -0
- package/dist/tui-cli-Dw7v4JoJ.js +47 -0
- package/dist/tui-mUwDwqvd.js +3894 -0
- package/dist/update-DF0GHG0j.js +317 -0
- package/dist/update-DoZLVjva.js +317 -0
- package/dist/update-check-Bt1dVPVN.js +400 -0
- package/dist/update-check-D5qAKes7.js +400 -0
- package/dist/update-cli-BNu2Oi7H.js +1105 -0
- package/dist/update-cli-D36AmALA.js +1105 -0
- package/dist/update-runner-CNQQaTwA.js +894 -0
- package/dist/update-runner-CvxZmbu-.js +894 -0
- package/dist/usage-BGCwNnjk.js +4516 -0
- package/dist/utils-DZ8pnOD5.js +243 -0
- package/dist/web-B5QG839O.js +46842 -0
- package/dist/web-Cmnvk9v0.js +2203 -0
- package/dist/web-Cv2KnTnL.js +63 -0
- package/dist/webhooks-cli-B6y89Pj_.js +319 -0
- package/dist/webhooks-cli-BDzHON4w.js +316 -0
- package/dist/whatsapp-actions-C_5MwVxM.js +45 -0
- package/dist/whatsapp-actions-hgYA12To.js +53 -0
- package/dist/whatsapp-actions-zTiVOoOV.js +49 -0
- package/dist/widearea-dns-BeIdnISJ.js +127 -0
- package/dist/widearea-dns-CF1gxpJ-.js +127 -0
- package/dist/workspace-DLna1IxR.js +649 -0
- package/dist/ws-log-Q4wO1Ztb.js +267 -0
- package/dist/ws-log-xF0kxDzp.js +267 -0
- package/package.json +1 -2
- package/dist/accounts-Cc5E4IDO.js +0 -260
- package/dist/accounts-CcVrwKqv.js +0 -259
- package/dist/acp-cli-DvphOKuh.js +0 -1081
- package/dist/acp-cli-p28pQ65a.js +0 -1084
- package/dist/agent-Cj7uDJaZ.js +0 -725
- package/dist/agent-Cuj9-2sT.js +0 -725
- package/dist/agent-events-BEBQsyE5.js +0 -182
- package/dist/agent-scope-BVf4aSwY.js +0 -112
- package/dist/agent-scope-OZi7lb8S.js +0 -452
- package/dist/agent-scope-V1bi9OYL.js +0 -452
- package/dist/agents-BUWqn_Ui.js +0 -774
- package/dist/agents.config-Dvo2ULxs.js +0 -182
- package/dist/agents.config-d6H0_3oj.js +0 -182
- package/dist/argv-DqUHKf0o.js +0 -73
- package/dist/audit-C6okOOSh.js +0 -2401
- package/dist/audit-VWjIdwC7.js +0 -2401
- package/dist/auth-91o2YM96.js +0 -648
- package/dist/auth-choice-CAmACV13.js +0 -2681
- package/dist/auth-choice-p3SeHPj2.js +0 -2681
- package/dist/auth-health-B_jXrWe6.js +0 -149
- package/dist/auth-health-DCicUKYR.js +0 -149
- package/dist/auth-lZ26wsbN.js +0 -639
- package/dist/auth-profiles-CCDD56dU.js +0 -1564
- package/dist/auth-profiles-DxI8L7bs.js +0 -2689
- package/dist/banner-Cohn04J6.js +0 -294
- package/dist/browser-cli-DANzjztE.js +0 -1676
- package/dist/browser-cli-WjsVH741.js +0 -1679
- package/dist/call-BAHvlu2G.js +0 -282
- package/dist/call-Ct7EGP_L.js +0 -282
- package/dist/catalog-BAayBt1L.js +0 -185
- package/dist/catalog-BNsf97BM.js +0 -185
- package/dist/channel-options-Dx9nPlX8.js +0 -33
- package/dist/channel-options-ZdvXrTGs.js +0 -32
- package/dist/channel-selection-CujyiWGM.js +0 -51
- package/dist/channel-selection-DfGpCyh2.js +0 -51
- package/dist/channel-web-CC0hkgkR.js +0 -2162
- package/dist/channels-cli-D7lNBpIb.js +0 -1304
- package/dist/channels-cli-DUPG8WDv.js +0 -1306
- package/dist/channels-status-issues-DBc1pU_R.js +0 -18
- package/dist/channels-status-issues-DjO9MHIG.js +0 -18
- package/dist/chrome-Bi6iZ5sG.js +0 -1601
- package/dist/chrome-DNSv7Cpy.js +0 -1629
- package/dist/chrome-DScZx4Lk.js +0 -1601
- package/dist/chunk-mxPVo000.js +0 -348
- package/dist/clack-prompter-B0kl7shw.js +0 -92
- package/dist/clack-prompter-B1YxZdRy.js +0 -92
- package/dist/cli-CfHUkOD0.js +0 -101
- package/dist/cli-ClMrIh6l.js +0 -99
- package/dist/cli-session-BkPTd9Pk.js +0 -5463
- package/dist/cli-session-Dd8DKb5a.js +0 -5408
- package/dist/client-C1avc0vD.js +0 -1692
- package/dist/client-CC94YZrT.js +0 -1692
- package/dist/clipboard-B2fBy8tG.js +0 -31
- package/dist/clipboard-BbGnZskJ.js +0 -31
- package/dist/command-format-Clp46jkj.js +0 -38
- package/dist/command-format-DELazozB.js +0 -52
- package/dist/command-format-SkzzRqR1.js +0 -52
- package/dist/command-registry-DZ4hkmA0.js +0 -248
- package/dist/commands-DtYZJSPn.js +0 -568
- package/dist/commands-Dujk1JmY.js +0 -568
- package/dist/commands-registry-Bd0xbvwG.js +0 -766
- package/dist/commands-registry-DYfRSVF3.js +0 -766
- package/dist/common-D6bu0zHC.js +0 -287
- package/dist/common-zW9Y2P1B.js +0 -287
- package/dist/completion-cli-tSe7Pmqm.js +0 -431
- package/dist/completion-cli-vn4IScs5.js +0 -432
- package/dist/config-C8rUDJXY.js +0 -5704
- package/dist/config-CLZ_XGVw.js +0 -6523
- package/dist/config-SY8M0kM_.js +0 -5705
- package/dist/config-cli-1V7D2Wsw.js +0 -247
- package/dist/config-cli-CjWEC81L.js +0 -244
- package/dist/config-guard-BW2gpKj_.js +0 -93
- package/dist/config-guard-BvxuzHpo.js +0 -76
- package/dist/config-sync-CoIIbEOe.js +0 -91
- package/dist/config-sync-DvAttep0.js +0 -91
- package/dist/configure-Bf0oupCE.js +0 -959
- package/dist/configure-DRM-7zFf.js +0 -960
- package/dist/context-D5iEFzv9.js +0 -60
- package/dist/control-service-C8m8F9pr.js +0 -72
- package/dist/control-service-DKotCWCg.js +0 -72
- package/dist/cron-cli-DB_FLYHD.js +0 -448
- package/dist/cron-cli-bxm5lrrO.js +0 -451
- package/dist/daemon-cli-1LsOnICv.js +0 -566
- package/dist/daemon-cli-CC2NrJ7a.js +0 -565
- package/dist/daemon-runtime-BXZhtBL9.js +0 -460
- package/dist/daemon-runtime-DW4USC7r.js +0 -460
- package/dist/deliver-B4HuPwJA.js +0 -1162
- package/dist/deliver-LiY5oL52.js +0 -1097
- package/dist/deliver-xrmk7xjh.js +0 -1097
- package/dist/delivery-queue-TnQykYsg.js +0 -220
- package/dist/deps-CMMOiOsF.js +0 -42
- package/dist/devices-cli-Be5he2SA.js +0 -195
- package/dist/devices-cli-z6ecoFe9.js +0 -198
- package/dist/diagnostics-Dj75aEHN.js +0 -35
- package/dist/diagnostics-DlIw6fqD.js +0 -35
- package/dist/directory-cli-CEy-0nxj.js +0 -243
- package/dist/directory-cli-DpzKcigr.js +0 -246
- package/dist/dispatcher-10Shiuz3.js +0 -100
- package/dist/dispatcher-3Jae6AiW.js +0 -100
- package/dist/dns-cli-Bat1pkc-.js +0 -200
- package/dist/dns-cli-NohNyEo0.js +0 -197
- package/dist/dock-DbxBBv30.js +0 -753
- package/dist/dock-cPBY4qGl.js +0 -753
- package/dist/docs-cli-BWp6p-Tq.js +0 -161
- package/dist/docs-cli-x22FnZfL.js +0 -159
- package/dist/doctor-BrT5m_on.js +0 -1815
- package/dist/doctor-Pp2HVnjM.js +0 -1813
- package/dist/doctor-completion-DNTimX9o.js +0 -92
- package/dist/doctor-completion-ylN9QAJ6.js +0 -92
- package/dist/doctor-config-flow-D1w3700T.js +0 -1232
- package/dist/doctor-config-flow-Dq50iE1R.js +0 -1232
- package/dist/engine-B9avUJL5.js +0 -563
- package/dist/engine-BiUQ25D4.js +0 -563
- package/dist/env-0lJfCPsw.js +0 -32
- package/dist/exec-BenD3A5l.js +0 -1167
- package/dist/exec-Bv3pyjeM.js +0 -255
- package/dist/exec-approvals-CdLmKX2R.js +0 -1221
- package/dist/exec-approvals-cli-DXfV6G8H.js +0 -368
- package/dist/exec-approvals-cli-J2cZs10o.js +0 -371
- package/dist/frontmatter-YijVi0FQ.js +0 -204
- package/dist/gateway-cli-DOAbA0pc.js +0 -19972
- package/dist/gateway-cli-QpWtBhQy.js +0 -19971
- package/dist/gateway-rpc-DJKBil9s.js +0 -28
- package/dist/gateway-rpc-DVterpLP.js +0 -28
- package/dist/github-copilot-auth-4IUFp669.js +0 -1418
- package/dist/github-copilot-auth-C9E0IROs.js +0 -1418
- package/dist/gmail-setup-utils-BPo_LkKI.js +0 -428
- package/dist/gmail-setup-utils-D3Yqgor7.js +0 -428
- package/dist/health-BeZnqp6m.js +0 -1258
- package/dist/health-Cn2OoVWZ.js +0 -1253
- package/dist/health-format-CdP99j3Y.js +0 -208
- package/dist/health-format-JEChH08S.js +0 -208
- package/dist/heartbeat-visibility-BL3WAchI.js +0 -98
- package/dist/heartbeat-visibility-CQ9QimI7.js +0 -98
- package/dist/help-format-Dl4bsrLI.js +0 -17
- package/dist/helpers-ZKNRexvX.js +0 -10
- package/dist/hooks-cli-D99hXt7K.js +0 -991
- package/dist/hooks-cli-DMB8RiEO.js +0 -993
- package/dist/hooks-status-B-e96dZj.js +0 -356
- package/dist/hooks-status-C_9sE0ox.js +0 -356
- package/dist/image-ops-Dlt3T7th.js +0 -541
- package/dist/image-ops-omlvdfah.js +0 -541
- package/dist/init-Bm04RagW.js +0 -122
- package/dist/init-CaJBf4p1.js +0 -122
- package/dist/installs-C2iMRBVz.js +0 -383
- package/dist/installs-D-cPGdCw.js +0 -383
- package/dist/ipv4-Bf7NS3QU.js +0 -1964
- package/dist/ipv4-wWNs8IH_.js +0 -1964
- package/dist/lanes-CNxj3tit.js +0 -232
- package/dist/lifecycle-core-B_7XRcvF.js +0 -388
- package/dist/lifecycle-core-By83PVAK.js +0 -387
- package/dist/links-BfjHVTB_.js +0 -15
- package/dist/links-DPGe0OHw.js +0 -15
- package/dist/logging-DB6BQmhi.js +0 -15
- package/dist/logging-mcb66J0p.js +0 -15
- package/dist/login-BDCg6D0N.js +0 -61
- package/dist/login-BDfnbjnZ.js +0 -59
- package/dist/login-BqH1itcg.js +0 -61
- package/dist/login-qr-CyOw3R4r.js +0 -321
- package/dist/login-qr-D8ECtb72.js +0 -323
- package/dist/login-qr-RnR7e4Bw.js +0 -326
- package/dist/logs-cli--j89L74J.js +0 -245
- package/dist/logs-cli-DpEMg_Gq.js +0 -242
- package/dist/manager-B4OyvcxT.js +0 -3244
- package/dist/manager-Cqc1CeH7.js +0 -3246
- package/dist/manager-DUyQPFvj.js +0 -3244
- package/dist/manifest-registry-CW1zCyRF.js +0 -748
- package/dist/manifest-registry-D4lM2RdV.js +0 -748
- package/dist/markdown-tables-BT1X6jqH.js +0 -347
- package/dist/markdown-tables-DHgOK2vI.js +0 -348
- package/dist/media-THyainiE.js +0 -1342
- package/dist/memory-cli-BKocCWXM.js +0 -868
- package/dist/memory-cli-Jmma-xI_.js +0 -869
- package/dist/message-channel-dSTVVCyX.js +0 -110
- package/dist/migrate-BR6iAIjO.js +0 -157
- package/dist/migrate-D0EcMs0f.js +0 -157
- package/dist/model-selection-YcSr9CgC.js +0 -2691
- package/dist/models-1vUQBVfw.js +0 -2510
- package/dist/models-cli-BK3BwUhL.js +0 -2739
- package/dist/models-cli-DECrM8oA.js +0 -258
- package/dist/net-B5lXhYLV.js +0 -218
- package/dist/node-cli-cLHUNpPD.js +0 -1319
- package/dist/node-cli-fO7Y132S.js +0 -1322
- package/dist/node-service-BFxHJsno.js +0 -67
- package/dist/node-service-DUnan4uK.js +0 -67
- package/dist/nodes-cli-BCq35E6N.js +0 -1200
- package/dist/nodes-cli-vD7MwAKP.js +0 -1197
- package/dist/nodes-screen-1YiLkqr5.js +0 -234
- package/dist/nodes-screen-DZeD8hE5.js +0 -234
- package/dist/note-Bi8Wb8DV.js +0 -73
- package/dist/note-uiuPxhyX.js +0 -73
- package/dist/npm-registry-spec-B-XIShkB.js +0 -351
- package/dist/npm-registry-spec-za3itb5Y.js +0 -351
- package/dist/onboard-Ds6w_sWo.js +0 -1165
- package/dist/onboard-SAVx3bp4.js +0 -1166
- package/dist/onboard-channels-Cg_EkBa4.js +0 -672
- package/dist/onboard-channels-D7NbA55V.js +0 -672
- package/dist/onboard-helpers-DO_hgZb9.js +0 -365
- package/dist/onboard-helpers-_XgJgeqh.js +0 -365
- package/dist/onboarding-3hLmDd0r.js +0 -911
- package/dist/onboarding-B4LKLsbU.js +0 -910
- package/dist/orchestrator-BKzmyBWy.js +0 -357
- package/dist/orchestrator-BN3QCz2s.js +0 -357
- package/dist/outbound-BgA9hNlP.js +0 -2062
- package/dist/outbound-CjdvVhUI.js +0 -214
- package/dist/outbound-DOGe6qb2.js +0 -214
- package/dist/outbound-send-deps-Du5aBpd7.js +0 -55
- package/dist/pairing-cli-2vnyg_Nd.js +0 -118
- package/dist/pairing-cli-BH1KQtNV.js +0 -121
- package/dist/pairing-store-DJz_9Gv0.js +0 -388
- package/dist/pairing-store-DmOzxcuk.js +0 -388
- package/dist/path-env-Bu6k0jDQ.js +0 -89
- package/dist/path-env-C0zQSjw8.js +0 -89
- package/dist/paths-BTc4nk-6.js +0 -126
- package/dist/paths-BgUi2Z2G.js +0 -54
- package/dist/paths-C6VCWKo3.js +0 -238
- package/dist/paths-CCxa0o9c.js +0 -222
- package/dist/paths-CxRf2rBG.js +0 -129
- package/dist/paths-hcX1Gqg5.js +0 -129
- package/dist/pi-auth-json-B68R7q7_.js +0 -82
- package/dist/pi-auth-json-CR0jXAgq.js +0 -78
- package/dist/pi-auth-json-ZYzi3nxs.js +0 -80
- package/dist/pi-model-discovery-Cxs4pvC2.js +0 -3
- package/dist/pi-tools.policy-D81U5xy0.js +0 -200
- package/dist/pi-tools.policy-DSHkkb5b.js +0 -200
- package/dist/plugin-auto-enable-CxF4bpDN.js +0 -282
- package/dist/plugin-auto-enable-jNaAeyEh.js +0 -282
- package/dist/plugin-registry-C7XWotZG.js +0 -32
- package/dist/plugin-registry-DcUCbGax.js +0 -32
- package/dist/plugins-B362e77G.js +0 -168
- package/dist/plugins-CmSUIUNi.js +0 -38
- package/dist/plugins-cli-BsCEnoQ7.js +0 -734
- package/dist/plugins-cli-QSIsMUG7.js +0 -736
- package/dist/polls-CItfB1H8.js +0 -1343
- package/dist/ports-BVLMN1Sr.js +0 -96
- package/dist/ports-CqLSlU6Z.js +0 -317
- package/dist/ports-D94CwCrv.js +0 -344
- package/dist/ports-D_NHthOz.js +0 -96
- package/dist/program-DkJHjI0R.js +0 -176
- package/dist/program-context-DnyGM2SC.js +0 -496
- package/dist/progress-Bek_GyWS.js +0 -133
- package/dist/prompt-style-lu0clOOE.js +0 -9
- package/dist/pw-ai-BLVMuSLv.js +0 -1867
- package/dist/pw-ai-DZJWEF_f.js +0 -1865
- package/dist/pw-ai-dzf-ptcn.js +0 -1868
- package/dist/qmd-manager-Cur_Ekn0.js +0 -937
- package/dist/qmd-manager-DNAUuwjK.js +0 -938
- package/dist/qmd-manager-DepEoASu.js +0 -935
- package/dist/register.agent-CSWvzOkR.js +0 -265
- package/dist/register.agent-UeH2NXmH.js +0 -1003
- package/dist/register.anima-DOdee0dh.js +0 -193
- package/dist/register.anima-HHDWsz6r.js +0 -193
- package/dist/register.configure-CSJFxdz9.js +0 -103
- package/dist/register.configure-D84Fvcz4.js +0 -101
- package/dist/register.maintenance-B3pvNbZb.js +0 -543
- package/dist/register.maintenance-BKVOwkw6.js +0 -543
- package/dist/register.message-BAO6CPl2.js +0 -657
- package/dist/register.message-OXoOKE_6.js +0 -660
- package/dist/register.onboard-BK_ixVmD.js +0 -170
- package/dist/register.onboard-cfCaPx6j.js +0 -170
- package/dist/register.setup-BGfDnzph.js +0 -175
- package/dist/register.setup-Y-Q74M-0.js +0 -175
- package/dist/register.status-health-sessions-CT14eitH.js +0 -142
- package/dist/register.status-health-sessions-TfZMzAUn.js +0 -313
- package/dist/register.subclis-BZwdlNHC.js +0 -255
- package/dist/reply-mlsExaZm.js +0 -32212
- package/dist/reply-prefix-B0CfR4bM.js +0 -100
- package/dist/reply-prefix-w4a39ybC.js +0 -100
- package/dist/reply-qalRISe_.js +0 -32212
- package/dist/routes-CENsHJyg.js +0 -1820
- package/dist/routes-DO0HqW2e.js +0 -1820
- package/dist/rpc-C0pjNhBi.js +0 -70
- package/dist/rpc-DZ44PIXE.js +0 -70
- package/dist/run-main-BMpKw8Mp.js +0 -371
- package/dist/runtime-guard-BSUFiAQV.js +0 -60
- package/dist/sandbox-BIGfMYEI.js +0 -858
- package/dist/sandbox-DxP3IpUP.js +0 -859
- package/dist/sandbox-cli-DtLGH8sL.js +0 -461
- package/dist/sandbox-cli-_Tg7lfJ_.js +0 -458
- package/dist/security-cli-BRwgbedo.js +0 -462
- package/dist/security-cli-D3bSuyZt.js +0 -465
- package/dist/server-context-49XFFxFg.js +0 -824
- package/dist/server-context-LrlgrZzS.js +0 -824
- package/dist/server-node-events-Dm52i7NW.js +0 -231
- package/dist/server-node-events-QX523UyF.js +0 -233
- package/dist/service-BNVpYcQe.js +0 -642
- package/dist/service-D56aMXUB.js +0 -642
- package/dist/service-audit-D0X_XAB2.js +0 -488
- package/dist/service-audit-qmf6XMmP.js +0 -488
- package/dist/session-CrQQLLhx.js +0 -179
- package/dist/session-LocsOOWJ.js +0 -181
- package/dist/session-Vlce2BAT.js +0 -181
- package/dist/session-cost-usage-BwiTZuKl.js +0 -600
- package/dist/session-cost-usage-DT9YNXTJ.js +0 -600
- package/dist/sessions-BfV53TbG.js +0 -1296
- package/dist/sessions-BimpX_km.js +0 -180
- package/dist/sessions-DcXpzig0.js +0 -1296
- package/dist/sessions-Wd18dukK.js +0 -2038
- package/dist/shared-Bsr69u_7.js +0 -77
- package/dist/shared-Cgly1vPb.js +0 -66
- package/dist/shared-JOo05hST.js +0 -66
- package/dist/shared-f7dvQsi7.js +0 -77
- package/dist/skill-scanner-CkaVLABv.js +0 -263
- package/dist/skills-B-G7UHOa.js +0 -808
- package/dist/skills-B5LQx4lT.js +0 -807
- package/dist/skills-cli-DUGe2ZWW.js +0 -286
- package/dist/skills-cli-DtOk0bvK.js +0 -289
- package/dist/skills-status-Clq9ZnYu.js +0 -166
- package/dist/skills-status-JQluhU-P.js +0 -166
- package/dist/sqlite-BukcjdJa.js +0 -321
- package/dist/sqlite-CGcOZZ0C.js +0 -368
- package/dist/sqlite-Ck6f9KWc.js +0 -453
- package/dist/start--xmSFepB.js +0 -372
- package/dist/start-BdlZbqrr.js +0 -371
- package/dist/status-BgoeFm6g.js +0 -2137
- package/dist/status-BjjDrUq7.js +0 -27
- package/dist/status-Ct0DgOZ-.js +0 -2132
- package/dist/status-RA_uNmK0.js +0 -27
- package/dist/status.update-BjOH3GlS.js +0 -79
- package/dist/status.update-DLU1qBf0.js +0 -79
- package/dist/subagent-registry-9RLdKxES.js +0 -2760
- package/dist/subagent-registry-Byuex3zp.js +0 -2759
- package/dist/subagent-registry-DOBunBYS.js +0 -14
- package/dist/subsystem-Dowf8fSU.js +0 -860
- package/dist/system-cli-C5oBpzni.js +0 -79
- package/dist/system-cli-DXNKD_Id.js +0 -82
- package/dist/systemd-BSrHDyeU.js +0 -452
- package/dist/systemd-By5xdSB4.js +0 -452
- package/dist/systemd-hints-BtjL_5Rh.js +0 -36
- package/dist/systemd-hints-sJmr6cjb.js +0 -36
- package/dist/systemd-linger-CTmV2Gci.js +0 -75
- package/dist/systemd-linger-CmyqQkeC.js +0 -75
- package/dist/table-BL0lJzsm.js +0 -279
- package/dist/table-DoiRPsn0.js +0 -279
- package/dist/timeout-CswI_K-U.js +0 -232
- package/dist/tokens-C-X7wDKj.js +0 -14
- package/dist/tokens-DkvqA72p.js +0 -14
- package/dist/trash-BJLK1vMn.js +0 -23
- package/dist/trash-_x5UZ94k.js +0 -23
- package/dist/tui-BHjxDFZC.js +0 -3894
- package/dist/tui-CgOocwN8.js +0 -3894
- package/dist/tui-cli-5ANH8dE5.js +0 -47
- package/dist/tui-cli-BQ4P-JW_.js +0 -50
- package/dist/update-LFgxHHPd.js +0 -317
- package/dist/update-TxptCqk7.js +0 -317
- package/dist/update-check-CWc7YXmc.js +0 -400
- package/dist/update-check-IhlWaui6.js +0 -400
- package/dist/update-cli-PtXU62w7.js +0 -1105
- package/dist/update-cli-Va0EtETG.js +0 -1105
- package/dist/update-runner-BLeKFkiB.js +0 -894
- package/dist/update-runner-Iuzpc-_y.js +0 -894
- package/dist/usage-ApGvBLVg.js +0 -4516
- package/dist/utils-Bsw__U-F.js +0 -243
- package/dist/web-B6_Ky60G.js +0 -63
- package/dist/web-EZLQEWXY.js +0 -46842
- package/dist/web-pec8YJUX.js +0 -2203
- package/dist/webhooks-cli-BYQKTHTp.js +0 -319
- package/dist/webhooks-cli-C2_xtsUQ.js +0 -316
- package/dist/whatsapp-actions-C72VCq8f.js +0 -49
- package/dist/whatsapp-actions-Ck9Uv0Nw.js +0 -45
- package/dist/whatsapp-actions-D0reTj2k.js +0 -53
- package/dist/widearea-dns-B6ocX23x.js +0 -127
- package/dist/widearea-dns-NsEUNYwz.js +0 -127
- package/dist/workspace-Dcfoy5JJ.js +0 -649
- package/dist/ws-log-N8R5MvGE.js +0 -267
- package/dist/ws-log-gwFxPxj5.js +0 -267
- /package/dist/{auto-update-CUeF99gI.js → auto-update-CpF0fycd.js} +0 -0
- /package/dist/{auto-update-cgkp9ZTJ.js → auto-update-DNWdO7uF.js} +0 -0
- /package/dist/{brew-CVZkr0GU.js → brew-nqf_MiE4.js} +0 -0
- /package/dist/{budget-DxYQSekw.js → budget-CPedI-qW.js} +0 -0
- /package/dist/{budget-BWBp8Res.js → budget-CRpvqDRX.js} +0 -0
- /package/dist/{cli-utils-DtAxdCte.js → cli-utils-C1YHVD4o.js} +0 -0
- /package/dist/{command-options-CSbuuqHr.js → command-options-BbponVnw.js} +0 -0
- /package/dist/{command-options-Cp1tf96a.js → command-options-s0gnvXnS.js} +0 -0
- /package/dist/{constants-O8yBqCBv.js → constants-Dhb6zSIV.js} +0 -0
- /package/dist/{dangerous-tools-5ObDWy1N.js → dangerous-tools-DGTtJ_JR.js} +0 -0
- /package/dist/{dangerous-tools-Jwr7jqNw.js → dangerous-tools-DxrfTOfT.js} +0 -0
- /package/dist/{delivery-queue-B6IHz4Ry.js → delivery-queue-Bxm0nzw7.js} +0 -0
- /package/dist/{display-BDOsXu8F.js → display-Jy3UdGzA.js} +0 -0
- /package/dist/{errors-CHow2wtt.js → errors-CKaCqKga.js} +0 -0
- /package/dist/{exec-BizYYQgP.js → exec-DDmuVVNq.js} +0 -0
- /package/dist/{format-Mq6iU0_5.js → format-ByEjgyTF.js} +0 -0
- /package/dist/{format-duration-DhWzz_5b.js → format-duration-Aaj5tjJd.js} +0 -0
- /package/dist/{format-relative-C6kUHuOj.js → format-relative-79_Y1n2Y.js} +0 -0
- /package/dist/{help-format-DUBI91Ti.js → help-format-BMKzarov.js} +0 -0
- /package/dist/{helpers-eJFa4K6r.js → helpers-DpEB9Mh0.js} +0 -0
- /package/dist/{helpers-DLgbkcEn.js → helpers-FMld9sBT.js} +0 -0
- /package/dist/{input-provenance-DJBdpeKk.js → input-provenance-Cy_KnBlP.js} +0 -0
- /package/dist/{is-main-Dt9DTcH1.js → is-main-yjaVwMtJ.js} +0 -0
- /package/dist/{loader-l2OBdJ8x.js → loader-Br7Vr0zn.js} +0 -0
- /package/dist/{loader-BoYxRfcW.js → loader-CkmOrXcC.js} +0 -0
- /package/dist/{logging-BdnOSVPD.js → logging-CY-Q5cwf.js} +0 -0
- /package/dist/{message-channel-w4F2b2F6.js → message-channel-dua8OOGJ.js} +0 -0
- /package/dist/{mime-B1ZoR53M.js → mime-CBg4KybI.js} +0 -0
- /package/dist/{model-param-b-DPwyNGn8.js → model-param-b-DW9f0NN8.js} +0 -0
- /package/dist/{node-match-8XZnaid6.js → node-match-BV8bTBd4.js} +0 -0
- /package/dist/{normalize-GDK8JTNW.js → normalize-_lmlBOW9.js} +0 -0
- /package/dist/{openclaw-root-C85WMnVV.js → openclaw-root-JPvmPTf7.js} +0 -0
- /package/dist/{outbound-send-deps-ANnAhImn.js → outbound-send-deps-BfUvuWGa.js} +0 -0
- /package/dist/{parse-6-2MDhdT.js → parse-CZRwKocn.js} +0 -0
- /package/dist/{parse-log-line-Bqh1SSzC.js → parse-log-line-CvrZEK6A.js} +0 -0
- /package/dist/{parse-log-line-DUZCjXbl.js → parse-log-line-mLdat0AH.js} +0 -0
- /package/dist/{parse-port-BKB9Exlg.js → parse-port-BSOOdo7I.js} +0 -0
- /package/dist/{parse-port-DrfvwwiL.js → parse-port-Y0NK62x1.js} +0 -0
- /package/dist/{parse-timeout-Di_tcEmi.js → parse-timeout-DVPQ3n9j.js} +0 -0
- /package/dist/{paths-DcVEkYX5.js → paths-DHjlJ6cn.js} +0 -0
- /package/dist/{pi-model-discovery-DsRqYJLy.js → pi-model-discovery-DzEIEgHL.js} +0 -0
- /package/dist/{plugins-CDJw924T.js → plugins-D6PBOdkn.js} +0 -0
- /package/dist/{program-context-Bvn8046-.js → program-context-Q1hkT73c.js} +0 -0
- /package/dist/{progress-CbZ2D53A.js → progress-C9Ha1NJh.js} +0 -0
- /package/dist/{prompt-style-DKy6qQxR.js → prompt-style-DQi8j03a.js} +0 -0
- /package/dist/{prompts-BI__va99.js → prompts-BEHxUC3w.js} +0 -0
- /package/dist/{prompts-_dDWkCAz.js → prompts-CSOhuiqe.js} +0 -0
- /package/dist/{queue-D_u34pbL.js → queue-BJGo7kAB.js} +0 -0
- /package/dist/{queue-PG591iID.js → queue-DYgUbdoq.js} +0 -0
- /package/dist/{redact-ClVwO7Nn.js → redact-CyKvdFrg.js} +0 -0
- /package/dist/{registry-Bs_DJK9E.js → registry-C5MAYD4V.js} +0 -0
- /package/dist/{registry-D_zlP1U-.js → registry-CRrXXVs0.js} +0 -0
- /package/dist/{requirements-BzZxj2Wu.js → requirements-CGkxTCu4.js} +0 -0
- /package/dist/{requirements-DIW1svgA.js → requirements-CIDaOcbO.js} +0 -0
- /package/dist/{runtime-guard-DeOXA_86.js → runtime-guard-nL3Lp8T-.js} +0 -0
- /package/dist/{secret-equal-Dghy3xsA.js → secret-equal-DJpmLXlG.js} +0 -0
- /package/dist/{send-BhAfdGII.js → send-CTcxgDDU.js} +0 -0
- /package/dist/{send-ga9udK1_.js → send-DPezUR3-.js} +0 -0
- /package/dist/{send-C2t9xpXI.js → send-DZQTaG7-.js} +0 -0
- /package/dist/{send-DigO-i9j.js → send-VDff2gra.js} +0 -0
- /package/dist/{send-Dz2BDHll.js → send-bgQNV8d1.js} +0 -0
- /package/dist/{session-key-BGiG_JcT.js → session-key-CQT-NR6w.js} +0 -0
- /package/dist/{shell-argv-CAq1mLa2.js → shell-argv-n9IueeJQ.js} +0 -0
- /package/dist/{skill-scanner-Coo4QoCd.js → skill-scanner-o6NgVMD9.js} +0 -0
- /package/dist/{status-CMnlcBVc.js → status-C53kTIXF.js} +0 -0
- /package/dist/{status-tDZPwewW.js → status-CZDDA_Sy.js} +0 -0
- /package/dist/{system-run-command-X9lDJIy0.js → system-run-command-BCjUffN9.js} +0 -0
- /package/dist/{system-run-command-DGk7dwQP.js → system-run-command-CqAqKL9K.js} +0 -0
- /package/dist/{tailnet-CuiNECdL.js → tailnet-Ciwjv243.js} +0 -0
- /package/dist/{templates-CeYJjVzw.js → templates-37RKpACb.js} +0 -0
- /package/dist/{templates-I3Z0xplD.js → templates-DPalk30o.js} +0 -0
- /package/dist/{thinking-BXEswx1X.js → thinking-2hxwmvTl.js} +0 -0
- /package/dist/{transcript-events-C1hdue6u.js → transcript-events-Bp7fGnwv.js} +0 -0
- /package/dist/{transcript-tools-DuyYOkUq.js → transcript-tools-D4Lbxlka.js} +0 -0
- /package/dist/{usage-format-BAirWUSO.js → usage-format-6Uar63S0.js} +0 -0
- /package/dist/{utils-C9sj30YY.js → utils-DT8uXjFS.js} +0 -0
- /package/dist/{wsl-CqyuRvtM.js → wsl-CrPvx2kZ.js} +0 -0
- /package/dist/{wsl-ymJYvc9Q.js → wsl-UvJ5dHah.js} +0 -0
|
@@ -0,0 +1,2038 @@
|
|
|
1
|
+
import { C as normalizeAccountId$1, T as normalizeMainKey, _ as DEFAULT_AGENT_ID, w as normalizeAgentId, y as buildAgentMainSessionKey } from "./workspace-DLna1IxR.js";
|
|
2
|
+
import { F as normalizeE164, S as requireActivePluginRegistry, _ as getChatChannelMeta, h as CHAT_CHANNEL_ORDER, k as escapeRegExp, l as createSubsystemLogger } from "./exec-B7sUS164.js";
|
|
3
|
+
import { T as resolveWhatsAppAccount, c as parseDurationMs, n as loadConfig, s as parseByteSize } from "./config-kVVm5EYV.js";
|
|
4
|
+
import { _ as listDeliverableMessageChannels, a as normalizeWhatsAppTarget, c as resolveSlackAccount, d as resolveDiscordAccount, l as resolveSlackReplyToMode, r as normalizeChannelId, s as resolveTelegramAccount, v as normalizeMessageChannel } from "./plugins-DtghNRtM.js";
|
|
5
|
+
import { n as resolveSessionFilePath, s as resolveStorePath, t as resolveDefaultSessionStorePath } from "./paths-B1vRVCad.js";
|
|
6
|
+
import { t as emitSessionTranscriptUpdate } from "./transcript-events-DW_H__a1.js";
|
|
7
|
+
import fs from "node:fs/promises";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import fsSync from "node:fs";
|
|
10
|
+
import crypto from "node:crypto";
|
|
11
|
+
import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent";
|
|
12
|
+
|
|
13
|
+
//#region src/auto-reply/tokens.ts
|
|
14
|
+
const HEARTBEAT_TOKEN = "HEARTBEAT_OK";
|
|
15
|
+
const SILENT_REPLY_TOKEN = "NO_REPLY";
|
|
16
|
+
function isSilentReplyText(text, token = SILENT_REPLY_TOKEN) {
|
|
17
|
+
if (!text) return false;
|
|
18
|
+
const escaped = escapeRegExp(token);
|
|
19
|
+
if (new RegExp(`^\\s*${escaped}(?=$|\\W)`).test(text)) return true;
|
|
20
|
+
return new RegExp(`\\b${escaped}\\b\\W*$`).test(text);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/config/sessions/group.ts
|
|
25
|
+
const getGroupSurfaces = () => new Set([...listDeliverableMessageChannels(), "webchat"]);
|
|
26
|
+
function normalizeGroupLabel(raw) {
|
|
27
|
+
const trimmed = raw?.trim().toLowerCase() ?? "";
|
|
28
|
+
if (!trimmed) return "";
|
|
29
|
+
return trimmed.replace(/\s+/g, "-").replace(/[^a-z0-9#@._+-]+/g, "-").replace(/-{2,}/g, "-").replace(/^[-.]+|[-.]+$/g, "");
|
|
30
|
+
}
|
|
31
|
+
function shortenGroupId(value) {
|
|
32
|
+
const trimmed = value?.trim() ?? "";
|
|
33
|
+
if (!trimmed) return "";
|
|
34
|
+
if (trimmed.length <= 14) return trimmed;
|
|
35
|
+
return `${trimmed.slice(0, 6)}...${trimmed.slice(-4)}`;
|
|
36
|
+
}
|
|
37
|
+
function buildGroupDisplayName(params) {
|
|
38
|
+
const providerKey = (params.provider?.trim().toLowerCase() || "group").trim();
|
|
39
|
+
const groupChannel = params.groupChannel?.trim();
|
|
40
|
+
const space = params.space?.trim();
|
|
41
|
+
const subject = params.subject?.trim();
|
|
42
|
+
const detail = (groupChannel && space ? `${space}${groupChannel.startsWith("#") ? "" : "#"}${groupChannel}` : groupChannel || subject || space || "") || "";
|
|
43
|
+
const fallbackId = params.id?.trim() || params.key;
|
|
44
|
+
const rawLabel = detail || fallbackId;
|
|
45
|
+
let token = normalizeGroupLabel(rawLabel);
|
|
46
|
+
if (!token) token = normalizeGroupLabel(shortenGroupId(rawLabel));
|
|
47
|
+
if (!params.groupChannel && token.startsWith("#")) token = token.replace(/^#+/, "");
|
|
48
|
+
if (token && !/^[@#]/.test(token) && !token.startsWith("g-") && !token.includes("#")) token = `g-${token}`;
|
|
49
|
+
return token ? `${providerKey}:${token}` : providerKey;
|
|
50
|
+
}
|
|
51
|
+
function resolveGroupSessionKey(ctx) {
|
|
52
|
+
const from = typeof ctx.From === "string" ? ctx.From.trim() : "";
|
|
53
|
+
const chatType = ctx.ChatType?.trim().toLowerCase();
|
|
54
|
+
const normalizedChatType = chatType === "channel" ? "channel" : chatType === "group" ? "group" : void 0;
|
|
55
|
+
const isWhatsAppGroupId = from.toLowerCase().endsWith("@g.us");
|
|
56
|
+
if (!(normalizedChatType === "group" || normalizedChatType === "channel" || from.includes(":group:") || from.includes(":channel:") || isWhatsAppGroupId)) return null;
|
|
57
|
+
const providerHint = ctx.Provider?.trim().toLowerCase();
|
|
58
|
+
const parts = from.split(":").filter(Boolean);
|
|
59
|
+
const head = parts[0]?.trim().toLowerCase() ?? "";
|
|
60
|
+
const headIsSurface = head ? getGroupSurfaces().has(head) : false;
|
|
61
|
+
const provider = headIsSurface ? head : providerHint ?? (isWhatsAppGroupId ? "whatsapp" : void 0);
|
|
62
|
+
if (!provider) return null;
|
|
63
|
+
const second = parts[1]?.trim().toLowerCase();
|
|
64
|
+
const secondIsKind = second === "group" || second === "channel";
|
|
65
|
+
const kind = secondIsKind ? second : from.includes(":channel:") || normalizedChatType === "channel" ? "channel" : "group";
|
|
66
|
+
const finalId = (headIsSurface ? secondIsKind ? parts.slice(2).join(":") : parts.slice(1).join(":") : from).trim().toLowerCase();
|
|
67
|
+
if (!finalId) return null;
|
|
68
|
+
return {
|
|
69
|
+
key: `${provider}:${kind}:${finalId}`,
|
|
70
|
+
channel: provider,
|
|
71
|
+
id: finalId,
|
|
72
|
+
chatType: kind === "channel" ? "channel" : "group"
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/channels/chat-type.ts
|
|
78
|
+
function normalizeChatType(raw) {
|
|
79
|
+
const value = raw?.trim().toLowerCase();
|
|
80
|
+
if (!value) return;
|
|
81
|
+
if (value === "direct" || value === "dm") return "direct";
|
|
82
|
+
if (value === "group") return "group";
|
|
83
|
+
if (value === "channel") return "channel";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/channels/conversation-label.ts
|
|
88
|
+
function extractConversationId(from) {
|
|
89
|
+
const trimmed = from?.trim();
|
|
90
|
+
if (!trimmed) return;
|
|
91
|
+
const parts = trimmed.split(":").filter(Boolean);
|
|
92
|
+
return parts.length > 0 ? parts[parts.length - 1] : trimmed;
|
|
93
|
+
}
|
|
94
|
+
function shouldAppendId(id) {
|
|
95
|
+
if (/^[0-9]+$/.test(id)) return true;
|
|
96
|
+
if (id.includes("@g.us")) return true;
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
function resolveConversationLabel(ctx) {
|
|
100
|
+
const explicit = ctx.ConversationLabel?.trim();
|
|
101
|
+
if (explicit) return explicit;
|
|
102
|
+
const threadLabel = ctx.ThreadLabel?.trim();
|
|
103
|
+
if (threadLabel) return threadLabel;
|
|
104
|
+
if (normalizeChatType(ctx.ChatType) === "direct") return ctx.SenderName?.trim() || ctx.From?.trim() || void 0;
|
|
105
|
+
const base = ctx.GroupChannel?.trim() || ctx.GroupSubject?.trim() || ctx.GroupSpace?.trim() || ctx.From?.trim() || "";
|
|
106
|
+
if (!base) return;
|
|
107
|
+
const id = extractConversationId(ctx.From);
|
|
108
|
+
if (!id) return base;
|
|
109
|
+
if (!shouldAppendId(id)) return base;
|
|
110
|
+
if (base === id) return base;
|
|
111
|
+
if (base.includes(id)) return base;
|
|
112
|
+
if (base.toLowerCase().includes(" id:")) return base;
|
|
113
|
+
if (base.startsWith("#") || base.startsWith("@")) return base;
|
|
114
|
+
return `${base} id:${id}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/config/group-policy.ts
|
|
119
|
+
function resolveChannelGroupConfig(groups, groupId, caseInsensitive = false) {
|
|
120
|
+
if (!groups) return;
|
|
121
|
+
const direct = groups[groupId];
|
|
122
|
+
if (direct) return direct;
|
|
123
|
+
if (!caseInsensitive) return;
|
|
124
|
+
const target = groupId.toLowerCase();
|
|
125
|
+
const matchedKey = Object.keys(groups).find((key) => key !== "*" && key.toLowerCase() === target);
|
|
126
|
+
if (!matchedKey) return;
|
|
127
|
+
return groups[matchedKey];
|
|
128
|
+
}
|
|
129
|
+
function normalizeSenderKey(value) {
|
|
130
|
+
const trimmed = value.trim();
|
|
131
|
+
if (!trimmed) return "";
|
|
132
|
+
return (trimmed.startsWith("@") ? trimmed.slice(1) : trimmed).toLowerCase();
|
|
133
|
+
}
|
|
134
|
+
function resolveToolsBySender(params) {
|
|
135
|
+
const toolsBySender = params.toolsBySender;
|
|
136
|
+
if (!toolsBySender) return;
|
|
137
|
+
const entries = Object.entries(toolsBySender);
|
|
138
|
+
if (entries.length === 0) return;
|
|
139
|
+
const normalized = /* @__PURE__ */ new Map();
|
|
140
|
+
let wildcard;
|
|
141
|
+
for (const [rawKey, policy] of entries) {
|
|
142
|
+
if (!policy) continue;
|
|
143
|
+
const key = normalizeSenderKey(rawKey);
|
|
144
|
+
if (!key) continue;
|
|
145
|
+
if (key === "*") {
|
|
146
|
+
wildcard = policy;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (!normalized.has(key)) normalized.set(key, policy);
|
|
150
|
+
}
|
|
151
|
+
const candidates = [];
|
|
152
|
+
const pushCandidate = (value) => {
|
|
153
|
+
const trimmed = value?.trim();
|
|
154
|
+
if (!trimmed) return;
|
|
155
|
+
candidates.push(trimmed);
|
|
156
|
+
};
|
|
157
|
+
pushCandidate(params.senderId);
|
|
158
|
+
pushCandidate(params.senderE164);
|
|
159
|
+
pushCandidate(params.senderUsername);
|
|
160
|
+
pushCandidate(params.senderName);
|
|
161
|
+
for (const candidate of candidates) {
|
|
162
|
+
const key = normalizeSenderKey(candidate);
|
|
163
|
+
if (!key) continue;
|
|
164
|
+
const match = normalized.get(key);
|
|
165
|
+
if (match) return match;
|
|
166
|
+
}
|
|
167
|
+
return wildcard;
|
|
168
|
+
}
|
|
169
|
+
function resolveChannelGroups(cfg, channel, accountId) {
|
|
170
|
+
const normalizedAccountId = normalizeAccountId$1(accountId);
|
|
171
|
+
const channelConfig = cfg.channels?.[channel];
|
|
172
|
+
if (!channelConfig) return;
|
|
173
|
+
return channelConfig.accounts?.[normalizedAccountId]?.groups ?? channelConfig.accounts?.[Object.keys(channelConfig.accounts ?? {}).find((key) => key.toLowerCase() === normalizedAccountId.toLowerCase()) ?? ""]?.groups ?? channelConfig.groups;
|
|
174
|
+
}
|
|
175
|
+
function resolveChannelGroupPolicy(params) {
|
|
176
|
+
const { cfg, channel } = params;
|
|
177
|
+
const groups = resolveChannelGroups(cfg, channel, params.accountId);
|
|
178
|
+
const allowlistEnabled = Boolean(groups && Object.keys(groups).length > 0);
|
|
179
|
+
const normalizedId = params.groupId?.trim();
|
|
180
|
+
const groupConfig = normalizedId ? resolveChannelGroupConfig(groups, normalizedId, params.groupIdCaseInsensitive) : void 0;
|
|
181
|
+
const defaultConfig = groups?.["*"];
|
|
182
|
+
return {
|
|
183
|
+
allowlistEnabled,
|
|
184
|
+
allowed: !allowlistEnabled || allowlistEnabled && Boolean(groups && Object.hasOwn(groups, "*")) || Boolean(groupConfig),
|
|
185
|
+
groupConfig,
|
|
186
|
+
defaultConfig
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function resolveChannelGroupRequireMention(params) {
|
|
190
|
+
const { requireMentionOverride, overrideOrder = "after-config" } = params;
|
|
191
|
+
const { groupConfig, defaultConfig } = resolveChannelGroupPolicy(params);
|
|
192
|
+
const configMention = typeof groupConfig?.requireMention === "boolean" ? groupConfig.requireMention : typeof defaultConfig?.requireMention === "boolean" ? defaultConfig.requireMention : void 0;
|
|
193
|
+
if (overrideOrder === "before-config" && typeof requireMentionOverride === "boolean") return requireMentionOverride;
|
|
194
|
+
if (typeof configMention === "boolean") return configMention;
|
|
195
|
+
if (overrideOrder !== "before-config" && typeof requireMentionOverride === "boolean") return requireMentionOverride;
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
function resolveChannelGroupToolsPolicy(params) {
|
|
199
|
+
const { groupConfig, defaultConfig } = resolveChannelGroupPolicy(params);
|
|
200
|
+
const groupSenderPolicy = resolveToolsBySender({
|
|
201
|
+
toolsBySender: groupConfig?.toolsBySender,
|
|
202
|
+
senderId: params.senderId,
|
|
203
|
+
senderName: params.senderName,
|
|
204
|
+
senderUsername: params.senderUsername,
|
|
205
|
+
senderE164: params.senderE164
|
|
206
|
+
});
|
|
207
|
+
if (groupSenderPolicy) return groupSenderPolicy;
|
|
208
|
+
if (groupConfig?.tools) return groupConfig.tools;
|
|
209
|
+
const defaultSenderPolicy = resolveToolsBySender({
|
|
210
|
+
toolsBySender: defaultConfig?.toolsBySender,
|
|
211
|
+
senderId: params.senderId,
|
|
212
|
+
senderName: params.senderName,
|
|
213
|
+
senderUsername: params.senderUsername,
|
|
214
|
+
senderE164: params.senderE164
|
|
215
|
+
});
|
|
216
|
+
if (defaultSenderPolicy) return defaultSenderPolicy;
|
|
217
|
+
if (defaultConfig?.tools) return defaultConfig.tools;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/imessage/accounts.ts
|
|
222
|
+
function resolveIMessageAccount(_p) {
|
|
223
|
+
return {
|
|
224
|
+
accountId: "default",
|
|
225
|
+
config: {}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/signal/accounts.ts
|
|
231
|
+
function resolveSignalAccount(_p) {
|
|
232
|
+
return {
|
|
233
|
+
accountId: "default",
|
|
234
|
+
config: {}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function listEnabledSignalAccounts(_cfg) {
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/slack/threading-tool-context.ts
|
|
243
|
+
function buildSlackThreadingToolContext(params) {
|
|
244
|
+
return {
|
|
245
|
+
currentChannelId: params?.context?.To?.trim() || void 0,
|
|
246
|
+
currentThreadTs: params?.context?.ReplyToId,
|
|
247
|
+
hasRepliedRef: params?.hasRepliedRef
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/channels/plugins/group-mentions.ts
|
|
253
|
+
function normalizeDiscordSlug(value) {
|
|
254
|
+
if (!value) return "";
|
|
255
|
+
let text = value.trim().toLowerCase();
|
|
256
|
+
if (!text) return "";
|
|
257
|
+
text = text.replace(/^[@#]+/, "");
|
|
258
|
+
text = text.replace(/[\s_]+/g, "-");
|
|
259
|
+
text = text.replace(/[^a-z0-9-]+/g, "-");
|
|
260
|
+
text = text.replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
|
261
|
+
return text;
|
|
262
|
+
}
|
|
263
|
+
function normalizeSlackSlug(raw) {
|
|
264
|
+
const trimmed = raw?.trim().toLowerCase() ?? "";
|
|
265
|
+
if (!trimmed) return "";
|
|
266
|
+
return trimmed.replace(/\s+/g, "-").replace(/[^a-z0-9#@._+-]+/g, "-").replace(/-{2,}/g, "-").replace(/^[-.]+|[-.]+$/g, "");
|
|
267
|
+
}
|
|
268
|
+
function parseTelegramGroupId(value) {
|
|
269
|
+
const raw = value?.trim() ?? "";
|
|
270
|
+
if (!raw) return {
|
|
271
|
+
chatId: void 0,
|
|
272
|
+
topicId: void 0
|
|
273
|
+
};
|
|
274
|
+
const parts = raw.split(":").filter(Boolean);
|
|
275
|
+
if (parts.length >= 3 && parts[1] === "topic" && /^-?\d+$/.test(parts[0]) && /^\d+$/.test(parts[2])) return {
|
|
276
|
+
chatId: parts[0],
|
|
277
|
+
topicId: parts[2]
|
|
278
|
+
};
|
|
279
|
+
if (parts.length >= 2 && /^-?\d+$/.test(parts[0]) && /^\d+$/.test(parts[1])) return {
|
|
280
|
+
chatId: parts[0],
|
|
281
|
+
topicId: parts[1]
|
|
282
|
+
};
|
|
283
|
+
return {
|
|
284
|
+
chatId: raw,
|
|
285
|
+
topicId: void 0
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function resolveTelegramRequireMention(params) {
|
|
289
|
+
const { cfg, chatId, topicId } = params;
|
|
290
|
+
if (!chatId) return;
|
|
291
|
+
const groupConfig = cfg.channels?.telegram?.groups?.[chatId];
|
|
292
|
+
const groupDefault = cfg.channels?.telegram?.groups?.["*"];
|
|
293
|
+
const topicConfig = topicId && groupConfig?.topics ? groupConfig.topics[topicId] : void 0;
|
|
294
|
+
const defaultTopicConfig = topicId && groupDefault?.topics ? groupDefault.topics[topicId] : void 0;
|
|
295
|
+
if (typeof topicConfig?.requireMention === "boolean") return topicConfig.requireMention;
|
|
296
|
+
if (typeof defaultTopicConfig?.requireMention === "boolean") return defaultTopicConfig.requireMention;
|
|
297
|
+
if (typeof groupConfig?.requireMention === "boolean") return groupConfig.requireMention;
|
|
298
|
+
if (typeof groupDefault?.requireMention === "boolean") return groupDefault.requireMention;
|
|
299
|
+
}
|
|
300
|
+
function resolveDiscordGuildEntry(guilds, groupSpace) {
|
|
301
|
+
if (!guilds || Object.keys(guilds).length === 0) return null;
|
|
302
|
+
const space = groupSpace?.trim() ?? "";
|
|
303
|
+
if (space && guilds[space]) return guilds[space];
|
|
304
|
+
const normalized = normalizeDiscordSlug(space);
|
|
305
|
+
if (normalized && guilds[normalized]) return guilds[normalized];
|
|
306
|
+
if (normalized) {
|
|
307
|
+
const match = Object.values(guilds).find((entry) => normalizeDiscordSlug(entry?.slug ?? void 0) === normalized);
|
|
308
|
+
if (match) return match;
|
|
309
|
+
}
|
|
310
|
+
return guilds["*"] ?? null;
|
|
311
|
+
}
|
|
312
|
+
function resolveTelegramGroupRequireMention(params) {
|
|
313
|
+
const { chatId, topicId } = parseTelegramGroupId(params.groupId);
|
|
314
|
+
const requireMention = resolveTelegramRequireMention({
|
|
315
|
+
cfg: params.cfg,
|
|
316
|
+
chatId,
|
|
317
|
+
topicId
|
|
318
|
+
});
|
|
319
|
+
if (typeof requireMention === "boolean") return requireMention;
|
|
320
|
+
return resolveChannelGroupRequireMention({
|
|
321
|
+
cfg: params.cfg,
|
|
322
|
+
channel: "telegram",
|
|
323
|
+
groupId: chatId ?? params.groupId,
|
|
324
|
+
accountId: params.accountId
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
function resolveWhatsAppGroupRequireMention(params) {
|
|
328
|
+
return resolveChannelGroupRequireMention({
|
|
329
|
+
cfg: params.cfg,
|
|
330
|
+
channel: "whatsapp",
|
|
331
|
+
groupId: params.groupId,
|
|
332
|
+
accountId: params.accountId
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
function resolveIMessageGroupRequireMention(params) {
|
|
336
|
+
return resolveChannelGroupRequireMention({
|
|
337
|
+
cfg: params.cfg,
|
|
338
|
+
channel: "imessage",
|
|
339
|
+
groupId: params.groupId,
|
|
340
|
+
accountId: params.accountId
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
function resolveDiscordGroupRequireMention(params) {
|
|
344
|
+
const guildEntry = resolveDiscordGuildEntry(params.cfg.channels?.discord?.guilds, params.groupSpace);
|
|
345
|
+
const channelEntries = guildEntry?.channels;
|
|
346
|
+
if (channelEntries && Object.keys(channelEntries).length > 0) {
|
|
347
|
+
const groupChannel = params.groupChannel;
|
|
348
|
+
const channelSlug = normalizeDiscordSlug(groupChannel);
|
|
349
|
+
const entry = (params.groupId ? channelEntries[params.groupId] : void 0) ?? (channelSlug ? channelEntries[channelSlug] ?? channelEntries[`#${channelSlug}`] : void 0) ?? (groupChannel ? channelEntries[normalizeDiscordSlug(groupChannel)] : void 0);
|
|
350
|
+
if (entry && typeof entry.requireMention === "boolean") return entry.requireMention;
|
|
351
|
+
}
|
|
352
|
+
if (typeof guildEntry?.requireMention === "boolean") return guildEntry.requireMention;
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
function resolveGoogleChatGroupRequireMention(params) {
|
|
356
|
+
return resolveChannelGroupRequireMention({
|
|
357
|
+
cfg: params.cfg,
|
|
358
|
+
channel: "googlechat",
|
|
359
|
+
groupId: params.groupId,
|
|
360
|
+
accountId: params.accountId
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function resolveGoogleChatGroupToolPolicy(params) {
|
|
364
|
+
return resolveChannelGroupToolsPolicy({
|
|
365
|
+
cfg: params.cfg,
|
|
366
|
+
channel: "googlechat",
|
|
367
|
+
groupId: params.groupId,
|
|
368
|
+
accountId: params.accountId,
|
|
369
|
+
senderId: params.senderId,
|
|
370
|
+
senderName: params.senderName,
|
|
371
|
+
senderUsername: params.senderUsername,
|
|
372
|
+
senderE164: params.senderE164
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
function resolveSlackGroupRequireMention(params) {
|
|
376
|
+
const channels = resolveSlackAccount({
|
|
377
|
+
cfg: params.cfg,
|
|
378
|
+
accountId: params.accountId
|
|
379
|
+
}).channels ?? {};
|
|
380
|
+
if (Object.keys(channels).length === 0) return true;
|
|
381
|
+
const channelId = params.groupId?.trim();
|
|
382
|
+
const channelName = params.groupChannel?.replace(/^#/, "");
|
|
383
|
+
const normalizedName = normalizeSlackSlug(channelName);
|
|
384
|
+
const candidates = [
|
|
385
|
+
channelId ?? "",
|
|
386
|
+
channelName ? `#${channelName}` : "",
|
|
387
|
+
channelName ?? "",
|
|
388
|
+
normalizedName
|
|
389
|
+
].filter(Boolean);
|
|
390
|
+
let matched;
|
|
391
|
+
for (const candidate of candidates) if (candidate && channels[candidate]) {
|
|
392
|
+
matched = channels[candidate];
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
const fallback = channels["*"];
|
|
396
|
+
const resolved = matched ?? fallback;
|
|
397
|
+
if (typeof resolved?.requireMention === "boolean") return resolved.requireMention;
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
function resolveTelegramGroupToolPolicy(params) {
|
|
401
|
+
const { chatId } = parseTelegramGroupId(params.groupId);
|
|
402
|
+
return resolveChannelGroupToolsPolicy({
|
|
403
|
+
cfg: params.cfg,
|
|
404
|
+
channel: "telegram",
|
|
405
|
+
groupId: chatId ?? params.groupId,
|
|
406
|
+
accountId: params.accountId,
|
|
407
|
+
senderId: params.senderId,
|
|
408
|
+
senderName: params.senderName,
|
|
409
|
+
senderUsername: params.senderUsername,
|
|
410
|
+
senderE164: params.senderE164
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
function resolveWhatsAppGroupToolPolicy(params) {
|
|
414
|
+
return resolveChannelGroupToolsPolicy({
|
|
415
|
+
cfg: params.cfg,
|
|
416
|
+
channel: "whatsapp",
|
|
417
|
+
groupId: params.groupId,
|
|
418
|
+
accountId: params.accountId,
|
|
419
|
+
senderId: params.senderId,
|
|
420
|
+
senderName: params.senderName,
|
|
421
|
+
senderUsername: params.senderUsername,
|
|
422
|
+
senderE164: params.senderE164
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function resolveIMessageGroupToolPolicy(params) {
|
|
426
|
+
return resolveChannelGroupToolsPolicy({
|
|
427
|
+
cfg: params.cfg,
|
|
428
|
+
channel: "imessage",
|
|
429
|
+
groupId: params.groupId,
|
|
430
|
+
accountId: params.accountId,
|
|
431
|
+
senderId: params.senderId,
|
|
432
|
+
senderName: params.senderName,
|
|
433
|
+
senderUsername: params.senderUsername,
|
|
434
|
+
senderE164: params.senderE164
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
function resolveDiscordGroupToolPolicy(params) {
|
|
438
|
+
const guildEntry = resolveDiscordGuildEntry(params.cfg.channels?.discord?.guilds, params.groupSpace);
|
|
439
|
+
const channelEntries = guildEntry?.channels;
|
|
440
|
+
if (channelEntries && Object.keys(channelEntries).length > 0) {
|
|
441
|
+
const groupChannel = params.groupChannel;
|
|
442
|
+
const channelSlug = normalizeDiscordSlug(groupChannel);
|
|
443
|
+
const entry = (params.groupId ? channelEntries[params.groupId] : void 0) ?? (channelSlug ? channelEntries[channelSlug] ?? channelEntries[`#${channelSlug}`] : void 0) ?? (groupChannel ? channelEntries[normalizeDiscordSlug(groupChannel)] : void 0);
|
|
444
|
+
const senderPolicy = resolveToolsBySender({
|
|
445
|
+
toolsBySender: entry?.toolsBySender,
|
|
446
|
+
senderId: params.senderId,
|
|
447
|
+
senderName: params.senderName,
|
|
448
|
+
senderUsername: params.senderUsername,
|
|
449
|
+
senderE164: params.senderE164
|
|
450
|
+
});
|
|
451
|
+
if (senderPolicy) return senderPolicy;
|
|
452
|
+
if (entry?.tools) return entry.tools;
|
|
453
|
+
}
|
|
454
|
+
const guildSenderPolicy = resolveToolsBySender({
|
|
455
|
+
toolsBySender: guildEntry?.toolsBySender,
|
|
456
|
+
senderId: params.senderId,
|
|
457
|
+
senderName: params.senderName,
|
|
458
|
+
senderUsername: params.senderUsername,
|
|
459
|
+
senderE164: params.senderE164
|
|
460
|
+
});
|
|
461
|
+
if (guildSenderPolicy) return guildSenderPolicy;
|
|
462
|
+
if (guildEntry?.tools) return guildEntry.tools;
|
|
463
|
+
}
|
|
464
|
+
function resolveSlackGroupToolPolicy(params) {
|
|
465
|
+
const channels = resolveSlackAccount({
|
|
466
|
+
cfg: params.cfg,
|
|
467
|
+
accountId: params.accountId
|
|
468
|
+
}).channels ?? {};
|
|
469
|
+
if (Object.keys(channels).length === 0) return;
|
|
470
|
+
const channelId = params.groupId?.trim();
|
|
471
|
+
const channelName = params.groupChannel?.replace(/^#/, "");
|
|
472
|
+
const normalizedName = normalizeSlackSlug(channelName);
|
|
473
|
+
const candidates = [
|
|
474
|
+
channelId ?? "",
|
|
475
|
+
channelName ? `#${channelName}` : "",
|
|
476
|
+
channelName ?? "",
|
|
477
|
+
normalizedName
|
|
478
|
+
].filter(Boolean);
|
|
479
|
+
let matched;
|
|
480
|
+
for (const candidate of candidates) if (candidate && channels[candidate]) {
|
|
481
|
+
matched = channels[candidate];
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
const resolved = matched ?? channels["*"];
|
|
485
|
+
const senderPolicy = resolveToolsBySender({
|
|
486
|
+
toolsBySender: resolved?.toolsBySender,
|
|
487
|
+
senderId: params.senderId,
|
|
488
|
+
senderName: params.senderName,
|
|
489
|
+
senderUsername: params.senderUsername,
|
|
490
|
+
senderE164: params.senderE164
|
|
491
|
+
});
|
|
492
|
+
if (senderPolicy) return senderPolicy;
|
|
493
|
+
if (resolved?.tools) return resolved.tools;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region src/channels/dock.ts
|
|
498
|
+
const formatLower = (allowFrom) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean).map((entry) => entry.toLowerCase());
|
|
499
|
+
const DOCKS = {
|
|
500
|
+
telegram: {
|
|
501
|
+
id: "telegram",
|
|
502
|
+
capabilities: {
|
|
503
|
+
chatTypes: [
|
|
504
|
+
"direct",
|
|
505
|
+
"group",
|
|
506
|
+
"channel",
|
|
507
|
+
"thread"
|
|
508
|
+
],
|
|
509
|
+
nativeCommands: true,
|
|
510
|
+
blockStreaming: true
|
|
511
|
+
},
|
|
512
|
+
outbound: { textChunkLimit: 4e3 },
|
|
513
|
+
config: {
|
|
514
|
+
resolveAllowFrom: ({ cfg, accountId }) => (resolveTelegramAccount({
|
|
515
|
+
cfg,
|
|
516
|
+
accountId
|
|
517
|
+
}).config.allowFrom ?? []).map((entry) => String(entry)),
|
|
518
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean).map((entry) => entry.replace(/^(telegram|tg):/i, "")).map((entry) => entry.toLowerCase())
|
|
519
|
+
},
|
|
520
|
+
groups: {
|
|
521
|
+
resolveRequireMention: resolveTelegramGroupRequireMention,
|
|
522
|
+
resolveToolPolicy: resolveTelegramGroupToolPolicy
|
|
523
|
+
},
|
|
524
|
+
threading: {
|
|
525
|
+
resolveReplyToMode: ({ cfg }) => cfg.channels?.telegram?.replyToMode ?? "off",
|
|
526
|
+
buildToolContext: ({ context, hasRepliedRef }) => {
|
|
527
|
+
const threadId = context.MessageThreadId ?? context.ReplyToId;
|
|
528
|
+
return {
|
|
529
|
+
currentChannelId: context.To?.trim() || void 0,
|
|
530
|
+
currentThreadTs: threadId != null ? String(threadId) : void 0,
|
|
531
|
+
hasRepliedRef
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
whatsapp: {
|
|
537
|
+
id: "whatsapp",
|
|
538
|
+
capabilities: {
|
|
539
|
+
chatTypes: ["direct", "group"],
|
|
540
|
+
polls: true,
|
|
541
|
+
reactions: true,
|
|
542
|
+
media: true
|
|
543
|
+
},
|
|
544
|
+
commands: {
|
|
545
|
+
enforceOwnerForCommands: true,
|
|
546
|
+
skipWhenConfigEmpty: true
|
|
547
|
+
},
|
|
548
|
+
outbound: { textChunkLimit: 4e3 },
|
|
549
|
+
config: {
|
|
550
|
+
resolveAllowFrom: ({ cfg, accountId }) => resolveWhatsAppAccount({
|
|
551
|
+
cfg,
|
|
552
|
+
accountId
|
|
553
|
+
}).allowFrom ?? [],
|
|
554
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter((entry) => Boolean(entry)).map((entry) => entry === "*" ? entry : normalizeWhatsAppTarget(entry)).filter((entry) => Boolean(entry))
|
|
555
|
+
},
|
|
556
|
+
groups: {
|
|
557
|
+
resolveRequireMention: resolveWhatsAppGroupRequireMention,
|
|
558
|
+
resolveToolPolicy: resolveWhatsAppGroupToolPolicy,
|
|
559
|
+
resolveGroupIntroHint: () => "WhatsApp IDs: SenderId is the participant JID (group participant id)."
|
|
560
|
+
},
|
|
561
|
+
mentions: { stripPatterns: ({ ctx }) => {
|
|
562
|
+
const selfE164 = (ctx.To ?? "").replace(/^whatsapp:/, "");
|
|
563
|
+
if (!selfE164) return [];
|
|
564
|
+
const escaped = escapeRegExp(selfE164);
|
|
565
|
+
return [escaped, `@${escaped}`];
|
|
566
|
+
} },
|
|
567
|
+
threading: { buildToolContext: ({ context, hasRepliedRef }) => {
|
|
568
|
+
return {
|
|
569
|
+
currentChannelId: context.From?.trim() || context.To?.trim() || void 0,
|
|
570
|
+
currentThreadTs: context.ReplyToId,
|
|
571
|
+
hasRepliedRef
|
|
572
|
+
};
|
|
573
|
+
} }
|
|
574
|
+
},
|
|
575
|
+
discord: {
|
|
576
|
+
id: "discord",
|
|
577
|
+
capabilities: {
|
|
578
|
+
chatTypes: [
|
|
579
|
+
"direct",
|
|
580
|
+
"channel",
|
|
581
|
+
"thread"
|
|
582
|
+
],
|
|
583
|
+
polls: true,
|
|
584
|
+
reactions: true,
|
|
585
|
+
media: true,
|
|
586
|
+
nativeCommands: true,
|
|
587
|
+
threads: true
|
|
588
|
+
},
|
|
589
|
+
outbound: { textChunkLimit: 2e3 },
|
|
590
|
+
streaming: { blockStreamingCoalesceDefaults: {
|
|
591
|
+
minChars: 1500,
|
|
592
|
+
idleMs: 1e3
|
|
593
|
+
} },
|
|
594
|
+
elevated: { allowFromFallback: ({ cfg }) => cfg.channels?.discord?.allowFrom ?? cfg.channels?.discord?.dm?.allowFrom },
|
|
595
|
+
config: {
|
|
596
|
+
resolveAllowFrom: ({ cfg, accountId }) => {
|
|
597
|
+
const account = resolveDiscordAccount({
|
|
598
|
+
cfg,
|
|
599
|
+
accountId
|
|
600
|
+
});
|
|
601
|
+
return (account.config.allowFrom ?? account.config.dm?.allowFrom ?? []).map((entry) => String(entry));
|
|
602
|
+
},
|
|
603
|
+
formatAllowFrom: ({ allowFrom }) => formatLower(allowFrom)
|
|
604
|
+
},
|
|
605
|
+
groups: {
|
|
606
|
+
resolveRequireMention: resolveDiscordGroupRequireMention,
|
|
607
|
+
resolveToolPolicy: resolveDiscordGroupToolPolicy
|
|
608
|
+
},
|
|
609
|
+
mentions: { stripPatterns: () => ["<@!?\\d+>"] },
|
|
610
|
+
threading: {
|
|
611
|
+
resolveReplyToMode: ({ cfg }) => cfg.channels?.discord?.replyToMode ?? "off",
|
|
612
|
+
buildToolContext: ({ context, hasRepliedRef }) => ({
|
|
613
|
+
currentChannelId: context.To?.trim() || void 0,
|
|
614
|
+
currentThreadTs: context.ReplyToId,
|
|
615
|
+
hasRepliedRef
|
|
616
|
+
})
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
irc: {
|
|
620
|
+
id: "irc",
|
|
621
|
+
capabilities: {
|
|
622
|
+
chatTypes: ["direct", "group"],
|
|
623
|
+
media: true,
|
|
624
|
+
blockStreaming: true
|
|
625
|
+
},
|
|
626
|
+
outbound: { textChunkLimit: 350 },
|
|
627
|
+
streaming: { blockStreamingCoalesceDefaults: {
|
|
628
|
+
minChars: 300,
|
|
629
|
+
idleMs: 1e3
|
|
630
|
+
} },
|
|
631
|
+
config: {
|
|
632
|
+
resolveAllowFrom: ({ cfg, accountId }) => {
|
|
633
|
+
const channel = cfg.channels?.irc;
|
|
634
|
+
const normalized = normalizeAccountId$1(accountId);
|
|
635
|
+
return ((channel?.accounts?.[normalized] ?? channel?.accounts?.[Object.keys(channel?.accounts ?? {}).find((key) => key.toLowerCase() === normalized.toLowerCase()) ?? ""])?.allowFrom ?? channel?.allowFrom ?? []).map((entry) => String(entry));
|
|
636
|
+
},
|
|
637
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean).map((entry) => entry.replace(/^irc:/i, "").replace(/^user:/i, "").toLowerCase())
|
|
638
|
+
},
|
|
639
|
+
groups: {
|
|
640
|
+
resolveRequireMention: ({ cfg, accountId, groupId }) => {
|
|
641
|
+
if (!groupId) return true;
|
|
642
|
+
return resolveChannelGroupRequireMention({
|
|
643
|
+
cfg,
|
|
644
|
+
channel: "irc",
|
|
645
|
+
groupId,
|
|
646
|
+
accountId,
|
|
647
|
+
groupIdCaseInsensitive: true
|
|
648
|
+
});
|
|
649
|
+
},
|
|
650
|
+
resolveToolPolicy: ({ cfg, accountId, groupId, senderId, senderName, senderUsername }) => {
|
|
651
|
+
if (!groupId) return;
|
|
652
|
+
return resolveChannelGroupToolsPolicy({
|
|
653
|
+
cfg,
|
|
654
|
+
channel: "irc",
|
|
655
|
+
groupId,
|
|
656
|
+
accountId,
|
|
657
|
+
groupIdCaseInsensitive: true,
|
|
658
|
+
senderId,
|
|
659
|
+
senderName,
|
|
660
|
+
senderUsername
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
googlechat: {
|
|
666
|
+
id: "googlechat",
|
|
667
|
+
capabilities: {
|
|
668
|
+
chatTypes: [
|
|
669
|
+
"direct",
|
|
670
|
+
"group",
|
|
671
|
+
"thread"
|
|
672
|
+
],
|
|
673
|
+
reactions: true,
|
|
674
|
+
media: true,
|
|
675
|
+
threads: true,
|
|
676
|
+
blockStreaming: true
|
|
677
|
+
},
|
|
678
|
+
outbound: { textChunkLimit: 4e3 },
|
|
679
|
+
config: {
|
|
680
|
+
resolveAllowFrom: ({ cfg, accountId }) => {
|
|
681
|
+
const channel = cfg.channels?.googlechat;
|
|
682
|
+
const normalized = normalizeAccountId$1(accountId);
|
|
683
|
+
return ((channel?.accounts?.[normalized] ?? channel?.accounts?.[Object.keys(channel?.accounts ?? {}).find((key) => key.toLowerCase() === normalized.toLowerCase()) ?? ""])?.dm?.allowFrom ?? channel?.dm?.allowFrom ?? []).map((entry) => String(entry));
|
|
684
|
+
},
|
|
685
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean).map((entry) => entry.replace(/^(googlechat|google-chat|gchat):/i, "").replace(/^user:/i, "").replace(/^users\//i, "").toLowerCase())
|
|
686
|
+
},
|
|
687
|
+
groups: {
|
|
688
|
+
resolveRequireMention: resolveGoogleChatGroupRequireMention,
|
|
689
|
+
resolveToolPolicy: resolveGoogleChatGroupToolPolicy
|
|
690
|
+
},
|
|
691
|
+
threading: {
|
|
692
|
+
resolveReplyToMode: ({ cfg }) => cfg.channels?.googlechat?.replyToMode ?? "off",
|
|
693
|
+
buildToolContext: ({ context, hasRepliedRef }) => {
|
|
694
|
+
const threadId = context.MessageThreadId ?? context.ReplyToId;
|
|
695
|
+
return {
|
|
696
|
+
currentChannelId: context.To?.trim() || void 0,
|
|
697
|
+
currentThreadTs: threadId != null ? String(threadId) : void 0,
|
|
698
|
+
hasRepliedRef
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
slack: {
|
|
704
|
+
id: "slack",
|
|
705
|
+
capabilities: {
|
|
706
|
+
chatTypes: [
|
|
707
|
+
"direct",
|
|
708
|
+
"channel",
|
|
709
|
+
"thread"
|
|
710
|
+
],
|
|
711
|
+
reactions: true,
|
|
712
|
+
media: true,
|
|
713
|
+
nativeCommands: true,
|
|
714
|
+
threads: true
|
|
715
|
+
},
|
|
716
|
+
outbound: { textChunkLimit: 4e3 },
|
|
717
|
+
streaming: { blockStreamingCoalesceDefaults: {
|
|
718
|
+
minChars: 1500,
|
|
719
|
+
idleMs: 1e3
|
|
720
|
+
} },
|
|
721
|
+
config: {
|
|
722
|
+
resolveAllowFrom: ({ cfg, accountId }) => {
|
|
723
|
+
const account = resolveSlackAccount({
|
|
724
|
+
cfg,
|
|
725
|
+
accountId
|
|
726
|
+
});
|
|
727
|
+
return (account.config.allowFrom ?? account.dm?.allowFrom ?? []).map((entry) => String(entry));
|
|
728
|
+
},
|
|
729
|
+
formatAllowFrom: ({ allowFrom }) => formatLower(allowFrom)
|
|
730
|
+
},
|
|
731
|
+
groups: {
|
|
732
|
+
resolveRequireMention: resolveSlackGroupRequireMention,
|
|
733
|
+
resolveToolPolicy: resolveSlackGroupToolPolicy
|
|
734
|
+
},
|
|
735
|
+
mentions: { stripPatterns: () => ["<@[^>]+>"] },
|
|
736
|
+
threading: {
|
|
737
|
+
resolveReplyToMode: ({ cfg, accountId, chatType }) => resolveSlackReplyToMode(resolveSlackAccount({
|
|
738
|
+
cfg,
|
|
739
|
+
accountId
|
|
740
|
+
}), chatType),
|
|
741
|
+
allowExplicitReplyTagsWhenOff: true,
|
|
742
|
+
buildToolContext: (params) => buildSlackThreadingToolContext(params)
|
|
743
|
+
}
|
|
744
|
+
},
|
|
745
|
+
signal: {
|
|
746
|
+
id: "signal",
|
|
747
|
+
capabilities: {
|
|
748
|
+
chatTypes: ["direct", "group"],
|
|
749
|
+
reactions: true,
|
|
750
|
+
media: true
|
|
751
|
+
},
|
|
752
|
+
outbound: { textChunkLimit: 4e3 },
|
|
753
|
+
streaming: { blockStreamingCoalesceDefaults: {
|
|
754
|
+
minChars: 1500,
|
|
755
|
+
idleMs: 1e3
|
|
756
|
+
} },
|
|
757
|
+
config: {
|
|
758
|
+
resolveAllowFrom: ({ cfg, accountId }) => (resolveSignalAccount({
|
|
759
|
+
cfg,
|
|
760
|
+
accountId
|
|
761
|
+
}).config.allowFrom ?? []).map((entry) => String(entry)),
|
|
762
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean).map((entry) => entry === "*" ? "*" : normalizeE164(entry.replace(/^signal:/i, ""))).filter(Boolean)
|
|
763
|
+
},
|
|
764
|
+
threading: { buildToolContext: ({ context, hasRepliedRef }) => {
|
|
765
|
+
return {
|
|
766
|
+
currentChannelId: (context.ChatType?.toLowerCase() === "direct" ? context.From ?? context.To : context.To)?.trim() || void 0,
|
|
767
|
+
currentThreadTs: context.ReplyToId,
|
|
768
|
+
hasRepliedRef
|
|
769
|
+
};
|
|
770
|
+
} }
|
|
771
|
+
},
|
|
772
|
+
imessage: {
|
|
773
|
+
id: "imessage",
|
|
774
|
+
capabilities: {
|
|
775
|
+
chatTypes: ["direct", "group"],
|
|
776
|
+
reactions: true,
|
|
777
|
+
media: true
|
|
778
|
+
},
|
|
779
|
+
outbound: { textChunkLimit: 4e3 },
|
|
780
|
+
config: {
|
|
781
|
+
resolveAllowFrom: ({ cfg, accountId }) => (resolveIMessageAccount({
|
|
782
|
+
cfg,
|
|
783
|
+
accountId
|
|
784
|
+
}).config.allowFrom ?? []).map((entry) => String(entry)),
|
|
785
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean)
|
|
786
|
+
},
|
|
787
|
+
groups: {
|
|
788
|
+
resolveRequireMention: resolveIMessageGroupRequireMention,
|
|
789
|
+
resolveToolPolicy: resolveIMessageGroupToolPolicy
|
|
790
|
+
},
|
|
791
|
+
threading: { buildToolContext: ({ context, hasRepliedRef }) => {
|
|
792
|
+
return {
|
|
793
|
+
currentChannelId: (context.ChatType?.toLowerCase() === "direct" ? context.From ?? context.To : context.To)?.trim() || void 0,
|
|
794
|
+
currentThreadTs: context.ReplyToId,
|
|
795
|
+
hasRepliedRef
|
|
796
|
+
};
|
|
797
|
+
} }
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
function buildDockFromPlugin(plugin) {
|
|
801
|
+
return {
|
|
802
|
+
id: plugin.id,
|
|
803
|
+
capabilities: plugin.capabilities,
|
|
804
|
+
commands: plugin.commands,
|
|
805
|
+
outbound: plugin.outbound?.textChunkLimit ? { textChunkLimit: plugin.outbound.textChunkLimit } : void 0,
|
|
806
|
+
streaming: plugin.streaming ? { blockStreamingCoalesceDefaults: plugin.streaming.blockStreamingCoalesceDefaults } : void 0,
|
|
807
|
+
elevated: plugin.elevated,
|
|
808
|
+
config: plugin.config ? {
|
|
809
|
+
resolveAllowFrom: plugin.config.resolveAllowFrom,
|
|
810
|
+
formatAllowFrom: plugin.config.formatAllowFrom
|
|
811
|
+
} : void 0,
|
|
812
|
+
groups: plugin.groups,
|
|
813
|
+
mentions: plugin.mentions,
|
|
814
|
+
threading: plugin.threading,
|
|
815
|
+
agentPrompt: plugin.agentPrompt
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
function listPluginDockEntries() {
|
|
819
|
+
const registry = requireActivePluginRegistry();
|
|
820
|
+
const entries = [];
|
|
821
|
+
const seen = /* @__PURE__ */ new Set();
|
|
822
|
+
for (const entry of registry.channels) {
|
|
823
|
+
const plugin = entry.plugin;
|
|
824
|
+
const id = String(plugin.id).trim();
|
|
825
|
+
if (!id || seen.has(id)) continue;
|
|
826
|
+
seen.add(id);
|
|
827
|
+
if (CHAT_CHANNEL_ORDER.includes(plugin.id)) continue;
|
|
828
|
+
const dock = entry.dock ?? buildDockFromPlugin(plugin);
|
|
829
|
+
entries.push({
|
|
830
|
+
id: plugin.id,
|
|
831
|
+
dock,
|
|
832
|
+
order: plugin.meta.order
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
return entries;
|
|
836
|
+
}
|
|
837
|
+
function listChannelDocks() {
|
|
838
|
+
const baseEntries = CHAT_CHANNEL_ORDER.map((id) => ({
|
|
839
|
+
id,
|
|
840
|
+
dock: DOCKS[id],
|
|
841
|
+
order: getChatChannelMeta(id).order
|
|
842
|
+
}));
|
|
843
|
+
const pluginEntries = listPluginDockEntries();
|
|
844
|
+
const combined = [...baseEntries, ...pluginEntries];
|
|
845
|
+
combined.sort((a, b) => {
|
|
846
|
+
const indexA = CHAT_CHANNEL_ORDER.indexOf(a.id);
|
|
847
|
+
const indexB = CHAT_CHANNEL_ORDER.indexOf(b.id);
|
|
848
|
+
const orderA = a.order ?? (indexA === -1 ? 999 : indexA);
|
|
849
|
+
const orderB = b.order ?? (indexB === -1 ? 999 : indexB);
|
|
850
|
+
if (orderA !== orderB) return orderA - orderB;
|
|
851
|
+
return String(a.id).localeCompare(String(b.id));
|
|
852
|
+
});
|
|
853
|
+
return combined.map((entry) => entry.dock);
|
|
854
|
+
}
|
|
855
|
+
function getChannelDock(id) {
|
|
856
|
+
const core = DOCKS[id];
|
|
857
|
+
if (core) return core;
|
|
858
|
+
const pluginEntry = requireActivePluginRegistry().channels.find((entry) => entry.plugin.id === id);
|
|
859
|
+
if (!pluginEntry) return;
|
|
860
|
+
return pluginEntry.dock ?? buildDockFromPlugin(pluginEntry.plugin);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
//#endregion
|
|
864
|
+
//#region src/config/sessions/metadata.ts
|
|
865
|
+
const mergeOrigin = (existing, next) => {
|
|
866
|
+
if (!existing && !next) return;
|
|
867
|
+
const merged = existing ? { ...existing } : {};
|
|
868
|
+
if (next?.label) merged.label = next.label;
|
|
869
|
+
if (next?.provider) merged.provider = next.provider;
|
|
870
|
+
if (next?.surface) merged.surface = next.surface;
|
|
871
|
+
if (next?.chatType) merged.chatType = next.chatType;
|
|
872
|
+
if (next?.from) merged.from = next.from;
|
|
873
|
+
if (next?.to) merged.to = next.to;
|
|
874
|
+
if (next?.accountId) merged.accountId = next.accountId;
|
|
875
|
+
if (next?.threadId != null && next.threadId !== "") merged.threadId = next.threadId;
|
|
876
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
877
|
+
};
|
|
878
|
+
function deriveSessionOrigin(ctx) {
|
|
879
|
+
const label = resolveConversationLabel(ctx)?.trim();
|
|
880
|
+
const provider = normalizeMessageChannel(typeof ctx.OriginatingChannel === "string" && ctx.OriginatingChannel || ctx.Surface || ctx.Provider);
|
|
881
|
+
const surface = ctx.Surface?.trim().toLowerCase();
|
|
882
|
+
const chatType = normalizeChatType(ctx.ChatType) ?? void 0;
|
|
883
|
+
const from = ctx.From?.trim();
|
|
884
|
+
const to = (typeof ctx.OriginatingTo === "string" ? ctx.OriginatingTo : ctx.To)?.trim() ?? void 0;
|
|
885
|
+
const accountId = ctx.AccountId?.trim();
|
|
886
|
+
const threadId = ctx.MessageThreadId ?? void 0;
|
|
887
|
+
const origin = {};
|
|
888
|
+
if (label) origin.label = label;
|
|
889
|
+
if (provider) origin.provider = provider;
|
|
890
|
+
if (surface) origin.surface = surface;
|
|
891
|
+
if (chatType) origin.chatType = chatType;
|
|
892
|
+
if (from) origin.from = from;
|
|
893
|
+
if (to) origin.to = to;
|
|
894
|
+
if (accountId) origin.accountId = accountId;
|
|
895
|
+
if (threadId != null && threadId !== "") origin.threadId = threadId;
|
|
896
|
+
return Object.keys(origin).length > 0 ? origin : void 0;
|
|
897
|
+
}
|
|
898
|
+
function deriveGroupSessionPatch(params) {
|
|
899
|
+
const resolution = params.groupResolution ?? resolveGroupSessionKey(params.ctx);
|
|
900
|
+
if (!resolution?.channel) return null;
|
|
901
|
+
const channel = resolution.channel;
|
|
902
|
+
const subject = params.ctx.GroupSubject?.trim();
|
|
903
|
+
const space = params.ctx.GroupSpace?.trim();
|
|
904
|
+
const explicitChannel = params.ctx.GroupChannel?.trim();
|
|
905
|
+
const normalizedChannel = normalizeChannelId(channel);
|
|
906
|
+
const isChannelProvider = Boolean(normalizedChannel && getChannelDock(normalizedChannel)?.capabilities.chatTypes.includes("channel"));
|
|
907
|
+
const nextGroupChannel = explicitChannel ?? ((resolution.chatType === "channel" || isChannelProvider) && subject && subject.startsWith("#") ? subject : void 0);
|
|
908
|
+
const nextSubject = nextGroupChannel ? void 0 : subject;
|
|
909
|
+
const patch = {
|
|
910
|
+
chatType: resolution.chatType ?? "group",
|
|
911
|
+
channel,
|
|
912
|
+
groupId: resolution.id
|
|
913
|
+
};
|
|
914
|
+
if (nextSubject) patch.subject = nextSubject;
|
|
915
|
+
if (nextGroupChannel) patch.groupChannel = nextGroupChannel;
|
|
916
|
+
if (space) patch.space = space;
|
|
917
|
+
const displayName = buildGroupDisplayName({
|
|
918
|
+
provider: channel,
|
|
919
|
+
subject: nextSubject ?? params.existing?.subject,
|
|
920
|
+
groupChannel: nextGroupChannel ?? params.existing?.groupChannel,
|
|
921
|
+
space: space ?? params.existing?.space,
|
|
922
|
+
id: resolution.id,
|
|
923
|
+
key: params.sessionKey
|
|
924
|
+
});
|
|
925
|
+
if (displayName) patch.displayName = displayName;
|
|
926
|
+
return patch;
|
|
927
|
+
}
|
|
928
|
+
function deriveSessionMetaPatch(params) {
|
|
929
|
+
const groupPatch = deriveGroupSessionPatch(params);
|
|
930
|
+
const origin = deriveSessionOrigin(params.ctx);
|
|
931
|
+
if (!groupPatch && !origin) return null;
|
|
932
|
+
const patch = groupPatch ? { ...groupPatch } : {};
|
|
933
|
+
const mergedOrigin = mergeOrigin(params.existing?.origin, origin);
|
|
934
|
+
if (mergedOrigin) patch.origin = mergedOrigin;
|
|
935
|
+
return Object.keys(patch).length > 0 ? patch : null;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region src/config/sessions/main-session.ts
|
|
940
|
+
function resolveMainSessionKey(cfg) {
|
|
941
|
+
if (cfg?.session?.scope === "global") return "global";
|
|
942
|
+
const agents = cfg?.agents?.list ?? [];
|
|
943
|
+
return buildAgentMainSessionKey({
|
|
944
|
+
agentId: normalizeAgentId(agents.find((agent) => agent?.default)?.id ?? agents[0]?.id ?? DEFAULT_AGENT_ID),
|
|
945
|
+
mainKey: normalizeMainKey(cfg?.session?.mainKey)
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
function resolveAgentMainSessionKey(params) {
|
|
949
|
+
const mainKey = normalizeMainKey(params.cfg?.session?.mainKey);
|
|
950
|
+
return buildAgentMainSessionKey({
|
|
951
|
+
agentId: params.agentId,
|
|
952
|
+
mainKey
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
function resolveExplicitAgentSessionKey(params) {
|
|
956
|
+
const agentId = params.agentId?.trim();
|
|
957
|
+
if (!agentId) return;
|
|
958
|
+
return resolveAgentMainSessionKey({
|
|
959
|
+
cfg: params.cfg,
|
|
960
|
+
agentId
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
function canonicalizeMainSessionAlias(params) {
|
|
964
|
+
const raw = params.sessionKey.trim();
|
|
965
|
+
if (!raw) return raw;
|
|
966
|
+
const agentId = normalizeAgentId(params.agentId);
|
|
967
|
+
const mainKey = normalizeMainKey(params.cfg?.session?.mainKey);
|
|
968
|
+
const agentMainSessionKey = buildAgentMainSessionKey({
|
|
969
|
+
agentId,
|
|
970
|
+
mainKey
|
|
971
|
+
});
|
|
972
|
+
const agentMainAliasKey = buildAgentMainSessionKey({
|
|
973
|
+
agentId,
|
|
974
|
+
mainKey: "main"
|
|
975
|
+
});
|
|
976
|
+
const isMainAlias = raw === "main" || raw === mainKey || raw === agentMainSessionKey || raw === agentMainAliasKey;
|
|
977
|
+
if (params.cfg?.session?.scope === "global" && isMainAlias) return "global";
|
|
978
|
+
if (isMainAlias) return agentMainSessionKey;
|
|
979
|
+
return raw;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
//#endregion
|
|
983
|
+
//#region src/config/sessions/types.ts
|
|
984
|
+
function mergeSessionEntry(existing, patch) {
|
|
985
|
+
const sessionId = patch.sessionId ?? existing?.sessionId ?? crypto.randomUUID();
|
|
986
|
+
const updatedAt = Math.max(existing?.updatedAt ?? 0, patch.updatedAt ?? 0, Date.now());
|
|
987
|
+
if (!existing) return {
|
|
988
|
+
...patch,
|
|
989
|
+
sessionId,
|
|
990
|
+
updatedAt
|
|
991
|
+
};
|
|
992
|
+
return {
|
|
993
|
+
...existing,
|
|
994
|
+
...patch,
|
|
995
|
+
sessionId,
|
|
996
|
+
updatedAt
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
function resolveFreshSessionTotalTokens(entry) {
|
|
1000
|
+
const total = entry?.totalTokens;
|
|
1001
|
+
if (typeof total !== "number" || !Number.isFinite(total) || total < 0) return;
|
|
1002
|
+
if (entry?.totalTokensFresh === false) return;
|
|
1003
|
+
return total;
|
|
1004
|
+
}
|
|
1005
|
+
const DEFAULT_RESET_TRIGGERS = ["/new", "/reset"];
|
|
1006
|
+
const DEFAULT_IDLE_MINUTES = 60;
|
|
1007
|
+
|
|
1008
|
+
//#endregion
|
|
1009
|
+
//#region src/config/sessions/reset.ts
|
|
1010
|
+
const DEFAULT_RESET_MODE = "daily";
|
|
1011
|
+
const DEFAULT_RESET_AT_HOUR = 4;
|
|
1012
|
+
const THREAD_SESSION_MARKERS = [":thread:", ":topic:"];
|
|
1013
|
+
const GROUP_SESSION_MARKERS = [":group:", ":channel:"];
|
|
1014
|
+
function isThreadSessionKey(sessionKey) {
|
|
1015
|
+
const normalized = (sessionKey ?? "").toLowerCase();
|
|
1016
|
+
if (!normalized) return false;
|
|
1017
|
+
return THREAD_SESSION_MARKERS.some((marker) => normalized.includes(marker));
|
|
1018
|
+
}
|
|
1019
|
+
function resolveSessionResetType(params) {
|
|
1020
|
+
if (params.isThread || isThreadSessionKey(params.sessionKey)) return "thread";
|
|
1021
|
+
if (params.isGroup) return "group";
|
|
1022
|
+
const normalized = (params.sessionKey ?? "").toLowerCase();
|
|
1023
|
+
if (GROUP_SESSION_MARKERS.some((marker) => normalized.includes(marker))) return "group";
|
|
1024
|
+
return "direct";
|
|
1025
|
+
}
|
|
1026
|
+
function resolveThreadFlag(params) {
|
|
1027
|
+
if (params.messageThreadId != null) return true;
|
|
1028
|
+
if (params.threadLabel?.trim()) return true;
|
|
1029
|
+
if (params.threadStarterBody?.trim()) return true;
|
|
1030
|
+
if (params.parentSessionKey?.trim()) return true;
|
|
1031
|
+
return isThreadSessionKey(params.sessionKey);
|
|
1032
|
+
}
|
|
1033
|
+
function resolveDailyResetAtMs(now, atHour) {
|
|
1034
|
+
const normalizedAtHour = normalizeResetAtHour(atHour);
|
|
1035
|
+
const resetAt = new Date(now);
|
|
1036
|
+
resetAt.setHours(normalizedAtHour, 0, 0, 0);
|
|
1037
|
+
if (now < resetAt.getTime()) resetAt.setDate(resetAt.getDate() - 1);
|
|
1038
|
+
return resetAt.getTime();
|
|
1039
|
+
}
|
|
1040
|
+
function resolveSessionResetPolicy(params) {
|
|
1041
|
+
const sessionCfg = params.sessionCfg;
|
|
1042
|
+
const baseReset = params.resetOverride ?? sessionCfg?.reset;
|
|
1043
|
+
const typeReset = params.resetOverride ? void 0 : sessionCfg?.resetByType?.[params.resetType] ?? (params.resetType === "direct" ? (sessionCfg?.resetByType)?.dm : void 0);
|
|
1044
|
+
const hasExplicitReset = Boolean(baseReset || sessionCfg?.resetByType);
|
|
1045
|
+
const legacyIdleMinutes = params.resetOverride ? void 0 : sessionCfg?.idleMinutes;
|
|
1046
|
+
const mode = typeReset?.mode ?? baseReset?.mode ?? (!hasExplicitReset && legacyIdleMinutes != null ? "idle" : DEFAULT_RESET_MODE);
|
|
1047
|
+
const atHour = normalizeResetAtHour(typeReset?.atHour ?? baseReset?.atHour ?? DEFAULT_RESET_AT_HOUR);
|
|
1048
|
+
const idleMinutesRaw = typeReset?.idleMinutes ?? baseReset?.idleMinutes ?? legacyIdleMinutes;
|
|
1049
|
+
let idleMinutes;
|
|
1050
|
+
if (idleMinutesRaw != null) {
|
|
1051
|
+
const normalized = Math.floor(idleMinutesRaw);
|
|
1052
|
+
if (Number.isFinite(normalized)) idleMinutes = Math.max(normalized, 1);
|
|
1053
|
+
} else if (mode === "idle") idleMinutes = DEFAULT_IDLE_MINUTES;
|
|
1054
|
+
return {
|
|
1055
|
+
mode,
|
|
1056
|
+
atHour,
|
|
1057
|
+
idleMinutes
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
function resolveChannelResetConfig(params) {
|
|
1061
|
+
const resetByChannel = params.sessionCfg?.resetByChannel;
|
|
1062
|
+
if (!resetByChannel) return;
|
|
1063
|
+
const normalized = normalizeMessageChannel(params.channel);
|
|
1064
|
+
const fallback = params.channel?.trim().toLowerCase();
|
|
1065
|
+
const key = normalized ?? fallback;
|
|
1066
|
+
if (!key) return;
|
|
1067
|
+
return resetByChannel[key] ?? resetByChannel[key.toLowerCase()];
|
|
1068
|
+
}
|
|
1069
|
+
function evaluateSessionFreshness(params) {
|
|
1070
|
+
const dailyResetAt = params.policy.mode === "daily" ? resolveDailyResetAtMs(params.now, params.policy.atHour) : void 0;
|
|
1071
|
+
const idleExpiresAt = params.policy.idleMinutes != null ? params.updatedAt + params.policy.idleMinutes * 6e4 : void 0;
|
|
1072
|
+
const staleDaily = dailyResetAt != null && params.updatedAt < dailyResetAt;
|
|
1073
|
+
const staleIdle = idleExpiresAt != null && params.now > idleExpiresAt;
|
|
1074
|
+
return {
|
|
1075
|
+
fresh: !(staleDaily || staleIdle),
|
|
1076
|
+
dailyResetAt,
|
|
1077
|
+
idleExpiresAt
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
function normalizeResetAtHour(value) {
|
|
1081
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_RESET_AT_HOUR;
|
|
1082
|
+
const normalized = Math.floor(value);
|
|
1083
|
+
if (!Number.isFinite(normalized)) return DEFAULT_RESET_AT_HOUR;
|
|
1084
|
+
if (normalized < 0) return 0;
|
|
1085
|
+
if (normalized > 23) return 23;
|
|
1086
|
+
return normalized;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
//#endregion
|
|
1090
|
+
//#region src/config/sessions/session-key.ts
|
|
1091
|
+
function deriveSessionKey(scope, ctx) {
|
|
1092
|
+
if (scope === "global") return "global";
|
|
1093
|
+
const resolvedGroup = resolveGroupSessionKey(ctx);
|
|
1094
|
+
if (resolvedGroup) return resolvedGroup.key;
|
|
1095
|
+
return (ctx.From ? normalizeE164(ctx.From) : "") || "unknown";
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Resolve the session key with a canonical direct-chat bucket (default: "main").
|
|
1099
|
+
* All non-group direct chats collapse to this bucket; groups stay isolated.
|
|
1100
|
+
*/
|
|
1101
|
+
function resolveSessionKey(scope, ctx, mainKey) {
|
|
1102
|
+
const explicit = ctx.SessionKey?.trim();
|
|
1103
|
+
if (explicit) return explicit.toLowerCase();
|
|
1104
|
+
const raw = deriveSessionKey(scope, ctx);
|
|
1105
|
+
if (scope === "global") return raw;
|
|
1106
|
+
const canonical = buildAgentMainSessionKey({
|
|
1107
|
+
agentId: DEFAULT_AGENT_ID,
|
|
1108
|
+
mainKey: normalizeMainKey(mainKey)
|
|
1109
|
+
});
|
|
1110
|
+
if (!(raw.includes(":group:") || raw.includes(":channel:"))) return canonical;
|
|
1111
|
+
return `agent:${DEFAULT_AGENT_ID}:${raw}`;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
//#endregion
|
|
1115
|
+
//#region src/agents/session-write-lock.ts
|
|
1116
|
+
const CLEANUP_SIGNALS = [
|
|
1117
|
+
"SIGINT",
|
|
1118
|
+
"SIGTERM",
|
|
1119
|
+
"SIGQUIT",
|
|
1120
|
+
"SIGABRT"
|
|
1121
|
+
];
|
|
1122
|
+
const CLEANUP_STATE_KEY = Symbol.for("anima.sessionWriteLockCleanupState");
|
|
1123
|
+
const HELD_LOCKS_KEY = Symbol.for("anima.sessionWriteLockHeldLocks");
|
|
1124
|
+
function resolveHeldLocks() {
|
|
1125
|
+
const proc = process;
|
|
1126
|
+
if (!proc[HELD_LOCKS_KEY]) proc[HELD_LOCKS_KEY] = /* @__PURE__ */ new Map();
|
|
1127
|
+
return proc[HELD_LOCKS_KEY];
|
|
1128
|
+
}
|
|
1129
|
+
const HELD_LOCKS = resolveHeldLocks();
|
|
1130
|
+
function resolveCleanupState() {
|
|
1131
|
+
const proc = process;
|
|
1132
|
+
if (!proc[CLEANUP_STATE_KEY]) proc[CLEANUP_STATE_KEY] = {
|
|
1133
|
+
registered: false,
|
|
1134
|
+
cleanupHandlers: /* @__PURE__ */ new Map()
|
|
1135
|
+
};
|
|
1136
|
+
return proc[CLEANUP_STATE_KEY];
|
|
1137
|
+
}
|
|
1138
|
+
function isAlive(pid) {
|
|
1139
|
+
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
1140
|
+
try {
|
|
1141
|
+
process.kill(pid, 0);
|
|
1142
|
+
return true;
|
|
1143
|
+
} catch {
|
|
1144
|
+
return false;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Synchronously release all held locks.
|
|
1149
|
+
* Used during process exit when async operations aren't reliable.
|
|
1150
|
+
*/
|
|
1151
|
+
function releaseAllLocksSync() {
|
|
1152
|
+
for (const [sessionFile, held] of HELD_LOCKS) {
|
|
1153
|
+
try {
|
|
1154
|
+
if (typeof held.handle.close === "function") held.handle.close().catch(() => {});
|
|
1155
|
+
} catch {}
|
|
1156
|
+
try {
|
|
1157
|
+
fsSync.rmSync(held.lockPath, { force: true });
|
|
1158
|
+
} catch {}
|
|
1159
|
+
HELD_LOCKS.delete(sessionFile);
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
function handleTerminationSignal(signal) {
|
|
1163
|
+
releaseAllLocksSync();
|
|
1164
|
+
const cleanupState = resolveCleanupState();
|
|
1165
|
+
if (process.listenerCount(signal) === 1) {
|
|
1166
|
+
const handler = cleanupState.cleanupHandlers.get(signal);
|
|
1167
|
+
if (handler) {
|
|
1168
|
+
process.off(signal, handler);
|
|
1169
|
+
cleanupState.cleanupHandlers.delete(signal);
|
|
1170
|
+
}
|
|
1171
|
+
try {
|
|
1172
|
+
process.kill(process.pid, signal);
|
|
1173
|
+
} catch {}
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
function registerCleanupHandlers() {
|
|
1177
|
+
const cleanupState = resolveCleanupState();
|
|
1178
|
+
if (!cleanupState.registered) {
|
|
1179
|
+
cleanupState.registered = true;
|
|
1180
|
+
process.on("exit", () => {
|
|
1181
|
+
releaseAllLocksSync();
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
for (const signal of CLEANUP_SIGNALS) {
|
|
1185
|
+
if (cleanupState.cleanupHandlers.has(signal)) continue;
|
|
1186
|
+
try {
|
|
1187
|
+
const handler = () => handleTerminationSignal(signal);
|
|
1188
|
+
cleanupState.cleanupHandlers.set(signal, handler);
|
|
1189
|
+
process.on(signal, handler);
|
|
1190
|
+
} catch {}
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
async function readLockPayload(lockPath) {
|
|
1194
|
+
try {
|
|
1195
|
+
const raw = await fs.readFile(lockPath, "utf8");
|
|
1196
|
+
const parsed = JSON.parse(raw);
|
|
1197
|
+
if (typeof parsed.pid !== "number") return null;
|
|
1198
|
+
if (typeof parsed.createdAt !== "string") return null;
|
|
1199
|
+
return {
|
|
1200
|
+
pid: parsed.pid,
|
|
1201
|
+
createdAt: parsed.createdAt
|
|
1202
|
+
};
|
|
1203
|
+
} catch {
|
|
1204
|
+
return null;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
async function acquireSessionWriteLock(params) {
|
|
1208
|
+
registerCleanupHandlers();
|
|
1209
|
+
const timeoutMs = params.timeoutMs ?? 1e4;
|
|
1210
|
+
const staleMs = params.staleMs ?? 1800 * 1e3;
|
|
1211
|
+
const sessionFile = path.resolve(params.sessionFile);
|
|
1212
|
+
const sessionDir = path.dirname(sessionFile);
|
|
1213
|
+
await fs.mkdir(sessionDir, { recursive: true });
|
|
1214
|
+
let normalizedDir = sessionDir;
|
|
1215
|
+
try {
|
|
1216
|
+
normalizedDir = await fs.realpath(sessionDir);
|
|
1217
|
+
} catch {}
|
|
1218
|
+
const normalizedSessionFile = path.join(normalizedDir, path.basename(sessionFile));
|
|
1219
|
+
const lockPath = `${normalizedSessionFile}.lock`;
|
|
1220
|
+
const held = HELD_LOCKS.get(normalizedSessionFile);
|
|
1221
|
+
if (held) {
|
|
1222
|
+
held.count += 1;
|
|
1223
|
+
return { release: async () => {
|
|
1224
|
+
const current = HELD_LOCKS.get(normalizedSessionFile);
|
|
1225
|
+
if (!current) return;
|
|
1226
|
+
current.count -= 1;
|
|
1227
|
+
if (current.count > 0) return;
|
|
1228
|
+
HELD_LOCKS.delete(normalizedSessionFile);
|
|
1229
|
+
await current.handle.close();
|
|
1230
|
+
await fs.rm(current.lockPath, { force: true });
|
|
1231
|
+
} };
|
|
1232
|
+
}
|
|
1233
|
+
const startedAt = Date.now();
|
|
1234
|
+
let attempt = 0;
|
|
1235
|
+
while (Date.now() - startedAt < timeoutMs) {
|
|
1236
|
+
attempt += 1;
|
|
1237
|
+
try {
|
|
1238
|
+
const handle = await fs.open(lockPath, "wx");
|
|
1239
|
+
await handle.writeFile(JSON.stringify({
|
|
1240
|
+
pid: process.pid,
|
|
1241
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1242
|
+
}, null, 2), "utf8");
|
|
1243
|
+
HELD_LOCKS.set(normalizedSessionFile, {
|
|
1244
|
+
count: 1,
|
|
1245
|
+
handle,
|
|
1246
|
+
lockPath
|
|
1247
|
+
});
|
|
1248
|
+
return { release: async () => {
|
|
1249
|
+
const current = HELD_LOCKS.get(normalizedSessionFile);
|
|
1250
|
+
if (!current) return;
|
|
1251
|
+
current.count -= 1;
|
|
1252
|
+
if (current.count > 0) return;
|
|
1253
|
+
HELD_LOCKS.delete(normalizedSessionFile);
|
|
1254
|
+
await current.handle.close();
|
|
1255
|
+
await fs.rm(current.lockPath, { force: true });
|
|
1256
|
+
} };
|
|
1257
|
+
} catch (err) {
|
|
1258
|
+
if (err.code !== "EEXIST") throw err;
|
|
1259
|
+
const payload = await readLockPayload(lockPath);
|
|
1260
|
+
const createdAt = payload?.createdAt ? Date.parse(payload.createdAt) : NaN;
|
|
1261
|
+
const stale = !Number.isFinite(createdAt) || Date.now() - createdAt > staleMs;
|
|
1262
|
+
const alive = payload?.pid ? isAlive(payload.pid) : false;
|
|
1263
|
+
if (stale || !alive) {
|
|
1264
|
+
await fs.rm(lockPath, { force: true });
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
const delay = Math.min(1e3, 50 * attempt);
|
|
1268
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
const payload = await readLockPayload(lockPath);
|
|
1272
|
+
const owner = payload?.pid ? `pid=${payload.pid}` : "unknown";
|
|
1273
|
+
throw new Error(`session file locked (timeout ${timeoutMs}ms): ${owner} ${lockPath}`);
|
|
1274
|
+
}
|
|
1275
|
+
const __testing = {
|
|
1276
|
+
cleanupSignals: [...CLEANUP_SIGNALS],
|
|
1277
|
+
handleTerminationSignal,
|
|
1278
|
+
releaseAllLocksSync
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
//#endregion
|
|
1282
|
+
//#region src/utils/account-id.ts
|
|
1283
|
+
function normalizeAccountId(value) {
|
|
1284
|
+
if (typeof value !== "string") return;
|
|
1285
|
+
return value.trim() || void 0;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
//#endregion
|
|
1289
|
+
//#region src/utils/delivery-context.ts
|
|
1290
|
+
function normalizeDeliveryContext(context) {
|
|
1291
|
+
if (!context) return;
|
|
1292
|
+
const channel = typeof context.channel === "string" ? normalizeMessageChannel(context.channel) ?? context.channel.trim() : void 0;
|
|
1293
|
+
const to = typeof context.to === "string" ? context.to.trim() : void 0;
|
|
1294
|
+
const accountId = normalizeAccountId(context.accountId);
|
|
1295
|
+
const threadId = typeof context.threadId === "number" && Number.isFinite(context.threadId) ? Math.trunc(context.threadId) : typeof context.threadId === "string" ? context.threadId.trim() : void 0;
|
|
1296
|
+
const normalizedThreadId = typeof threadId === "string" ? threadId ? threadId : void 0 : threadId;
|
|
1297
|
+
if (!channel && !to && !accountId && normalizedThreadId == null) return;
|
|
1298
|
+
const normalized = {
|
|
1299
|
+
channel: channel || void 0,
|
|
1300
|
+
to: to || void 0,
|
|
1301
|
+
accountId
|
|
1302
|
+
};
|
|
1303
|
+
if (normalizedThreadId != null) normalized.threadId = normalizedThreadId;
|
|
1304
|
+
return normalized;
|
|
1305
|
+
}
|
|
1306
|
+
function normalizeSessionDeliveryFields(source) {
|
|
1307
|
+
if (!source) return {
|
|
1308
|
+
deliveryContext: void 0,
|
|
1309
|
+
lastChannel: void 0,
|
|
1310
|
+
lastTo: void 0,
|
|
1311
|
+
lastAccountId: void 0,
|
|
1312
|
+
lastThreadId: void 0
|
|
1313
|
+
};
|
|
1314
|
+
const merged = mergeDeliveryContext(normalizeDeliveryContext({
|
|
1315
|
+
channel: source.lastChannel ?? source.channel,
|
|
1316
|
+
to: source.lastTo,
|
|
1317
|
+
accountId: source.lastAccountId,
|
|
1318
|
+
threadId: source.lastThreadId
|
|
1319
|
+
}), normalizeDeliveryContext(source.deliveryContext));
|
|
1320
|
+
if (!merged) return {
|
|
1321
|
+
deliveryContext: void 0,
|
|
1322
|
+
lastChannel: void 0,
|
|
1323
|
+
lastTo: void 0,
|
|
1324
|
+
lastAccountId: void 0,
|
|
1325
|
+
lastThreadId: void 0
|
|
1326
|
+
};
|
|
1327
|
+
return {
|
|
1328
|
+
deliveryContext: merged,
|
|
1329
|
+
lastChannel: merged.channel,
|
|
1330
|
+
lastTo: merged.to,
|
|
1331
|
+
lastAccountId: merged.accountId,
|
|
1332
|
+
lastThreadId: merged.threadId
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
function deliveryContextFromSession(entry) {
|
|
1336
|
+
if (!entry) return;
|
|
1337
|
+
return normalizeSessionDeliveryFields({
|
|
1338
|
+
channel: entry.channel,
|
|
1339
|
+
lastChannel: entry.lastChannel,
|
|
1340
|
+
lastTo: entry.lastTo,
|
|
1341
|
+
lastAccountId: entry.lastAccountId,
|
|
1342
|
+
lastThreadId: entry.lastThreadId ?? entry.deliveryContext?.threadId ?? entry.origin?.threadId,
|
|
1343
|
+
deliveryContext: entry.deliveryContext
|
|
1344
|
+
}).deliveryContext;
|
|
1345
|
+
}
|
|
1346
|
+
function mergeDeliveryContext(primary, fallback) {
|
|
1347
|
+
const normalizedPrimary = normalizeDeliveryContext(primary);
|
|
1348
|
+
const normalizedFallback = normalizeDeliveryContext(fallback);
|
|
1349
|
+
if (!normalizedPrimary && !normalizedFallback) return;
|
|
1350
|
+
return normalizeDeliveryContext({
|
|
1351
|
+
channel: normalizedPrimary?.channel ?? normalizedFallback?.channel,
|
|
1352
|
+
to: normalizedPrimary?.to ?? normalizedFallback?.to,
|
|
1353
|
+
accountId: normalizedPrimary?.accountId ?? normalizedFallback?.accountId,
|
|
1354
|
+
threadId: normalizedPrimary?.threadId ?? normalizedFallback?.threadId
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
function deliveryContextKey(context) {
|
|
1358
|
+
const normalized = normalizeDeliveryContext(context);
|
|
1359
|
+
if (!normalized?.channel || !normalized?.to) return;
|
|
1360
|
+
const threadId = normalized.threadId != null && normalized.threadId !== "" ? String(normalized.threadId) : "";
|
|
1361
|
+
return `${normalized.channel}|${normalized.to}|${normalized.accountId ?? ""}|${threadId}`;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
//#endregion
|
|
1365
|
+
//#region src/config/cache-utils.ts
|
|
1366
|
+
function resolveCacheTtlMs(params) {
|
|
1367
|
+
const { envValue, defaultTtlMs } = params;
|
|
1368
|
+
if (envValue) {
|
|
1369
|
+
const parsed = Number.parseInt(envValue, 10);
|
|
1370
|
+
if (Number.isFinite(parsed) && parsed >= 0) return parsed;
|
|
1371
|
+
}
|
|
1372
|
+
return defaultTtlMs;
|
|
1373
|
+
}
|
|
1374
|
+
function isCacheEnabled(ttlMs) {
|
|
1375
|
+
return ttlMs > 0;
|
|
1376
|
+
}
|
|
1377
|
+
function getFileMtimeMs(filePath) {
|
|
1378
|
+
try {
|
|
1379
|
+
return fsSync.statSync(filePath).mtimeMs;
|
|
1380
|
+
} catch {
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
//#endregion
|
|
1386
|
+
//#region src/config/sessions/store.ts
|
|
1387
|
+
const log = createSubsystemLogger("sessions/store");
|
|
1388
|
+
const SESSION_STORE_CACHE = /* @__PURE__ */ new Map();
|
|
1389
|
+
const DEFAULT_SESSION_STORE_TTL_MS = 45e3;
|
|
1390
|
+
function isSessionStoreRecord(value) {
|
|
1391
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1392
|
+
}
|
|
1393
|
+
function getSessionStoreTtl() {
|
|
1394
|
+
return resolveCacheTtlMs({
|
|
1395
|
+
envValue: process.env.ANIMA_SESSION_CACHE_TTL_MS,
|
|
1396
|
+
defaultTtlMs: DEFAULT_SESSION_STORE_TTL_MS
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
function isSessionStoreCacheEnabled() {
|
|
1400
|
+
return isCacheEnabled(getSessionStoreTtl());
|
|
1401
|
+
}
|
|
1402
|
+
function isSessionStoreCacheValid(entry) {
|
|
1403
|
+
const now = Date.now();
|
|
1404
|
+
const ttl = getSessionStoreTtl();
|
|
1405
|
+
return now - entry.loadedAt <= ttl;
|
|
1406
|
+
}
|
|
1407
|
+
function invalidateSessionStoreCache(storePath) {
|
|
1408
|
+
SESSION_STORE_CACHE.delete(storePath);
|
|
1409
|
+
}
|
|
1410
|
+
function normalizeSessionEntryDelivery(entry) {
|
|
1411
|
+
const normalized = normalizeSessionDeliveryFields({
|
|
1412
|
+
channel: entry.channel,
|
|
1413
|
+
lastChannel: entry.lastChannel,
|
|
1414
|
+
lastTo: entry.lastTo,
|
|
1415
|
+
lastAccountId: entry.lastAccountId,
|
|
1416
|
+
lastThreadId: entry.lastThreadId ?? entry.deliveryContext?.threadId ?? entry.origin?.threadId,
|
|
1417
|
+
deliveryContext: entry.deliveryContext
|
|
1418
|
+
});
|
|
1419
|
+
const nextDelivery = normalized.deliveryContext;
|
|
1420
|
+
const sameDelivery = (entry.deliveryContext?.channel ?? void 0) === nextDelivery?.channel && (entry.deliveryContext?.to ?? void 0) === nextDelivery?.to && (entry.deliveryContext?.accountId ?? void 0) === nextDelivery?.accountId && (entry.deliveryContext?.threadId ?? void 0) === nextDelivery?.threadId;
|
|
1421
|
+
const sameLast = entry.lastChannel === normalized.lastChannel && entry.lastTo === normalized.lastTo && entry.lastAccountId === normalized.lastAccountId && entry.lastThreadId === normalized.lastThreadId;
|
|
1422
|
+
if (sameDelivery && sameLast) return entry;
|
|
1423
|
+
return {
|
|
1424
|
+
...entry,
|
|
1425
|
+
deliveryContext: nextDelivery,
|
|
1426
|
+
lastChannel: normalized.lastChannel,
|
|
1427
|
+
lastTo: normalized.lastTo,
|
|
1428
|
+
lastAccountId: normalized.lastAccountId,
|
|
1429
|
+
lastThreadId: normalized.lastThreadId
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
function removeThreadFromDeliveryContext(context) {
|
|
1433
|
+
if (!context || context.threadId == null) return context;
|
|
1434
|
+
const next = { ...context };
|
|
1435
|
+
delete next.threadId;
|
|
1436
|
+
return next;
|
|
1437
|
+
}
|
|
1438
|
+
function normalizeSessionStore(store) {
|
|
1439
|
+
for (const [key, entry] of Object.entries(store)) {
|
|
1440
|
+
if (!entry) continue;
|
|
1441
|
+
const normalized = normalizeSessionEntryDelivery(entry);
|
|
1442
|
+
if (normalized !== entry) store[key] = normalized;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
function loadSessionStore(storePath, opts = {}) {
|
|
1446
|
+
if (!opts.skipCache && isSessionStoreCacheEnabled()) {
|
|
1447
|
+
const cached = SESSION_STORE_CACHE.get(storePath);
|
|
1448
|
+
if (cached && isSessionStoreCacheValid(cached)) {
|
|
1449
|
+
if (getFileMtimeMs(storePath) === cached.mtimeMs) return structuredClone(cached.store);
|
|
1450
|
+
invalidateSessionStoreCache(storePath);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
let store = {};
|
|
1454
|
+
let mtimeMs = getFileMtimeMs(storePath);
|
|
1455
|
+
try {
|
|
1456
|
+
const raw = fsSync.readFileSync(storePath, "utf-8");
|
|
1457
|
+
const parsed = JSON.parse(raw);
|
|
1458
|
+
if (isSessionStoreRecord(parsed)) store = parsed;
|
|
1459
|
+
mtimeMs = getFileMtimeMs(storePath) ?? mtimeMs;
|
|
1460
|
+
} catch {}
|
|
1461
|
+
for (const entry of Object.values(store)) {
|
|
1462
|
+
if (!entry || typeof entry !== "object") continue;
|
|
1463
|
+
const rec = entry;
|
|
1464
|
+
if (typeof rec.channel !== "string" && typeof rec.provider === "string") {
|
|
1465
|
+
rec.channel = rec.provider;
|
|
1466
|
+
delete rec.provider;
|
|
1467
|
+
}
|
|
1468
|
+
if (typeof rec.lastChannel !== "string" && typeof rec.lastProvider === "string") {
|
|
1469
|
+
rec.lastChannel = rec.lastProvider;
|
|
1470
|
+
delete rec.lastProvider;
|
|
1471
|
+
}
|
|
1472
|
+
if (typeof rec.groupChannel !== "string" && typeof rec.room === "string") {
|
|
1473
|
+
rec.groupChannel = rec.room;
|
|
1474
|
+
delete rec.room;
|
|
1475
|
+
} else if ("room" in rec) delete rec.room;
|
|
1476
|
+
}
|
|
1477
|
+
if (!opts.skipCache && isSessionStoreCacheEnabled()) SESSION_STORE_CACHE.set(storePath, {
|
|
1478
|
+
store: structuredClone(store),
|
|
1479
|
+
loadedAt: Date.now(),
|
|
1480
|
+
storePath,
|
|
1481
|
+
mtimeMs
|
|
1482
|
+
});
|
|
1483
|
+
return structuredClone(store);
|
|
1484
|
+
}
|
|
1485
|
+
function readSessionUpdatedAt(params) {
|
|
1486
|
+
try {
|
|
1487
|
+
return loadSessionStore(params.storePath)[params.sessionKey]?.updatedAt;
|
|
1488
|
+
} catch {
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
const DEFAULT_SESSION_PRUNE_AFTER_MS = 720 * 60 * 60 * 1e3;
|
|
1493
|
+
const DEFAULT_SESSION_MAX_ENTRIES = 500;
|
|
1494
|
+
const DEFAULT_SESSION_ROTATE_BYTES = 10485760;
|
|
1495
|
+
const DEFAULT_SESSION_MAINTENANCE_MODE = "warn";
|
|
1496
|
+
function resolvePruneAfterMs(maintenance) {
|
|
1497
|
+
const raw = maintenance?.pruneAfter ?? maintenance?.pruneDays;
|
|
1498
|
+
if (raw === void 0 || raw === null || raw === "") return DEFAULT_SESSION_PRUNE_AFTER_MS;
|
|
1499
|
+
try {
|
|
1500
|
+
return parseDurationMs(String(raw).trim(), { defaultUnit: "d" });
|
|
1501
|
+
} catch {
|
|
1502
|
+
return DEFAULT_SESSION_PRUNE_AFTER_MS;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
function resolveRotateBytes(maintenance) {
|
|
1506
|
+
const raw = maintenance?.rotateBytes;
|
|
1507
|
+
if (raw === void 0 || raw === null || raw === "") return DEFAULT_SESSION_ROTATE_BYTES;
|
|
1508
|
+
try {
|
|
1509
|
+
return parseByteSize(String(raw).trim(), { defaultUnit: "b" });
|
|
1510
|
+
} catch {
|
|
1511
|
+
return DEFAULT_SESSION_ROTATE_BYTES;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Resolve maintenance settings from anima.json (`session.maintenance`).
|
|
1516
|
+
* Falls back to built-in defaults when config is missing or unset.
|
|
1517
|
+
*/
|
|
1518
|
+
function resolveMaintenanceConfig() {
|
|
1519
|
+
let maintenance;
|
|
1520
|
+
try {
|
|
1521
|
+
maintenance = loadConfig().session?.maintenance;
|
|
1522
|
+
} catch {}
|
|
1523
|
+
return {
|
|
1524
|
+
mode: maintenance?.mode ?? DEFAULT_SESSION_MAINTENANCE_MODE,
|
|
1525
|
+
pruneAfterMs: resolvePruneAfterMs(maintenance),
|
|
1526
|
+
maxEntries: maintenance?.maxEntries ?? DEFAULT_SESSION_MAX_ENTRIES,
|
|
1527
|
+
rotateBytes: resolveRotateBytes(maintenance)
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Remove entries whose `updatedAt` is older than the configured threshold.
|
|
1532
|
+
* Entries without `updatedAt` are kept (cannot determine staleness).
|
|
1533
|
+
* Mutates `store` in-place.
|
|
1534
|
+
*/
|
|
1535
|
+
function pruneStaleEntries(store, overrideMaxAgeMs, opts = {}) {
|
|
1536
|
+
const maxAgeMs = overrideMaxAgeMs ?? resolveMaintenanceConfig().pruneAfterMs;
|
|
1537
|
+
const cutoffMs = Date.now() - maxAgeMs;
|
|
1538
|
+
let pruned = 0;
|
|
1539
|
+
for (const [key, entry] of Object.entries(store)) if (entry?.updatedAt != null && entry.updatedAt < cutoffMs) {
|
|
1540
|
+
delete store[key];
|
|
1541
|
+
pruned++;
|
|
1542
|
+
}
|
|
1543
|
+
if (pruned > 0 && opts.log !== false) log.info("pruned stale session entries", {
|
|
1544
|
+
pruned,
|
|
1545
|
+
maxAgeMs
|
|
1546
|
+
});
|
|
1547
|
+
return pruned;
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
* Cap the store to the N most recently updated entries.
|
|
1551
|
+
* Entries without `updatedAt` are sorted last (removed first when over limit).
|
|
1552
|
+
* Mutates `store` in-place.
|
|
1553
|
+
*/
|
|
1554
|
+
function getEntryUpdatedAt(entry) {
|
|
1555
|
+
return entry?.updatedAt ?? Number.NEGATIVE_INFINITY;
|
|
1556
|
+
}
|
|
1557
|
+
function getActiveSessionMaintenanceWarning(params) {
|
|
1558
|
+
const activeSessionKey = params.activeSessionKey.trim();
|
|
1559
|
+
if (!activeSessionKey) return null;
|
|
1560
|
+
const activeEntry = params.store[activeSessionKey];
|
|
1561
|
+
if (!activeEntry) return null;
|
|
1562
|
+
const cutoffMs = (params.nowMs ?? Date.now()) - params.pruneAfterMs;
|
|
1563
|
+
const wouldPrune = activeEntry.updatedAt != null ? activeEntry.updatedAt < cutoffMs : false;
|
|
1564
|
+
const keys = Object.keys(params.store);
|
|
1565
|
+
const wouldCap = keys.length > params.maxEntries && keys.toSorted((a, b) => getEntryUpdatedAt(params.store[b]) - getEntryUpdatedAt(params.store[a])).slice(params.maxEntries).includes(activeSessionKey);
|
|
1566
|
+
if (!wouldPrune && !wouldCap) return null;
|
|
1567
|
+
return {
|
|
1568
|
+
activeSessionKey,
|
|
1569
|
+
activeUpdatedAt: activeEntry.updatedAt,
|
|
1570
|
+
totalEntries: keys.length,
|
|
1571
|
+
pruneAfterMs: params.pruneAfterMs,
|
|
1572
|
+
maxEntries: params.maxEntries,
|
|
1573
|
+
wouldPrune,
|
|
1574
|
+
wouldCap
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
function capEntryCount(store, overrideMax, opts = {}) {
|
|
1578
|
+
const maxEntries = overrideMax ?? resolveMaintenanceConfig().maxEntries;
|
|
1579
|
+
const keys = Object.keys(store);
|
|
1580
|
+
if (keys.length <= maxEntries) return 0;
|
|
1581
|
+
const toRemove = keys.toSorted((a, b) => {
|
|
1582
|
+
const aTime = getEntryUpdatedAt(store[a]);
|
|
1583
|
+
return getEntryUpdatedAt(store[b]) - aTime;
|
|
1584
|
+
}).slice(maxEntries);
|
|
1585
|
+
for (const key of toRemove) delete store[key];
|
|
1586
|
+
if (opts.log !== false) log.info("capped session entry count", {
|
|
1587
|
+
removed: toRemove.length,
|
|
1588
|
+
maxEntries
|
|
1589
|
+
});
|
|
1590
|
+
return toRemove.length;
|
|
1591
|
+
}
|
|
1592
|
+
async function getSessionFileSize(storePath) {
|
|
1593
|
+
try {
|
|
1594
|
+
return (await fsSync.promises.stat(storePath)).size;
|
|
1595
|
+
} catch {
|
|
1596
|
+
return null;
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Rotate the sessions file if it exceeds the configured size threshold.
|
|
1601
|
+
* Renames the current file to `sessions.json.bak.{timestamp}` and cleans up
|
|
1602
|
+
* old rotation backups, keeping only the 3 most recent `.bak.*` files.
|
|
1603
|
+
*/
|
|
1604
|
+
async function rotateSessionFile(storePath, overrideBytes) {
|
|
1605
|
+
const maxBytes = overrideBytes ?? resolveMaintenanceConfig().rotateBytes;
|
|
1606
|
+
const fileSize = await getSessionFileSize(storePath);
|
|
1607
|
+
if (fileSize == null) return false;
|
|
1608
|
+
if (fileSize <= maxBytes) return false;
|
|
1609
|
+
const backupPath = `${storePath}.bak.${Date.now()}`;
|
|
1610
|
+
try {
|
|
1611
|
+
await fsSync.promises.rename(storePath, backupPath);
|
|
1612
|
+
log.info("rotated session store file", {
|
|
1613
|
+
backupPath: path.basename(backupPath),
|
|
1614
|
+
sizeBytes: fileSize
|
|
1615
|
+
});
|
|
1616
|
+
} catch {
|
|
1617
|
+
return false;
|
|
1618
|
+
}
|
|
1619
|
+
try {
|
|
1620
|
+
const dir = path.dirname(storePath);
|
|
1621
|
+
const baseName = path.basename(storePath);
|
|
1622
|
+
const backups = (await fsSync.promises.readdir(dir)).filter((f) => f.startsWith(`${baseName}.bak.`)).toSorted().toReversed();
|
|
1623
|
+
const maxBackups = 3;
|
|
1624
|
+
if (backups.length > maxBackups) {
|
|
1625
|
+
const toDelete = backups.slice(maxBackups);
|
|
1626
|
+
for (const old of toDelete) await fsSync.promises.unlink(path.join(dir, old)).catch(() => void 0);
|
|
1627
|
+
log.info("cleaned up old session store backups", { deleted: toDelete.length });
|
|
1628
|
+
}
|
|
1629
|
+
} catch {}
|
|
1630
|
+
return true;
|
|
1631
|
+
}
|
|
1632
|
+
async function saveSessionStoreUnlocked(storePath, store, opts) {
|
|
1633
|
+
invalidateSessionStoreCache(storePath);
|
|
1634
|
+
normalizeSessionStore(store);
|
|
1635
|
+
if (!opts?.skipMaintenance) {
|
|
1636
|
+
const maintenance = resolveMaintenanceConfig();
|
|
1637
|
+
if (maintenance.mode === "warn") {
|
|
1638
|
+
const activeSessionKey = opts?.activeSessionKey?.trim();
|
|
1639
|
+
if (activeSessionKey) {
|
|
1640
|
+
const warning = getActiveSessionMaintenanceWarning({
|
|
1641
|
+
store,
|
|
1642
|
+
activeSessionKey,
|
|
1643
|
+
pruneAfterMs: maintenance.pruneAfterMs,
|
|
1644
|
+
maxEntries: maintenance.maxEntries
|
|
1645
|
+
});
|
|
1646
|
+
if (warning) {
|
|
1647
|
+
log.warn("session maintenance would evict active session; skipping enforcement", {
|
|
1648
|
+
activeSessionKey: warning.activeSessionKey,
|
|
1649
|
+
wouldPrune: warning.wouldPrune,
|
|
1650
|
+
wouldCap: warning.wouldCap,
|
|
1651
|
+
pruneAfterMs: warning.pruneAfterMs,
|
|
1652
|
+
maxEntries: warning.maxEntries
|
|
1653
|
+
});
|
|
1654
|
+
await opts?.onWarn?.(warning);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
} else {
|
|
1658
|
+
pruneStaleEntries(store, maintenance.pruneAfterMs);
|
|
1659
|
+
capEntryCount(store, maintenance.maxEntries);
|
|
1660
|
+
await rotateSessionFile(storePath, maintenance.rotateBytes);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
await fsSync.promises.mkdir(path.dirname(storePath), { recursive: true });
|
|
1664
|
+
const json = JSON.stringify(store, null, 2);
|
|
1665
|
+
if (process.platform === "win32") {
|
|
1666
|
+
try {
|
|
1667
|
+
await fsSync.promises.writeFile(storePath, json, "utf-8");
|
|
1668
|
+
} catch (err) {
|
|
1669
|
+
if ((err && typeof err === "object" && "code" in err ? String(err.code) : null) === "ENOENT") return;
|
|
1670
|
+
throw err;
|
|
1671
|
+
}
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
const tmp = `${storePath}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
1675
|
+
try {
|
|
1676
|
+
await fsSync.promises.writeFile(tmp, json, {
|
|
1677
|
+
mode: 384,
|
|
1678
|
+
encoding: "utf-8"
|
|
1679
|
+
});
|
|
1680
|
+
await fsSync.promises.rename(tmp, storePath);
|
|
1681
|
+
await fsSync.promises.chmod(storePath, 384);
|
|
1682
|
+
} catch (err) {
|
|
1683
|
+
if ((err && typeof err === "object" && "code" in err ? String(err.code) : null) === "ENOENT") {
|
|
1684
|
+
try {
|
|
1685
|
+
await fsSync.promises.mkdir(path.dirname(storePath), { recursive: true });
|
|
1686
|
+
await fsSync.promises.writeFile(storePath, json, {
|
|
1687
|
+
mode: 384,
|
|
1688
|
+
encoding: "utf-8"
|
|
1689
|
+
});
|
|
1690
|
+
await fsSync.promises.chmod(storePath, 384);
|
|
1691
|
+
} catch (err2) {
|
|
1692
|
+
if ((err2 && typeof err2 === "object" && "code" in err2 ? String(err2.code) : null) === "ENOENT") return;
|
|
1693
|
+
throw err2;
|
|
1694
|
+
}
|
|
1695
|
+
return;
|
|
1696
|
+
}
|
|
1697
|
+
throw err;
|
|
1698
|
+
} finally {
|
|
1699
|
+
await fsSync.promises.rm(tmp, { force: true });
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
async function updateSessionStore(storePath, mutator, opts) {
|
|
1703
|
+
return await withSessionStoreLock(storePath, async () => {
|
|
1704
|
+
const store = loadSessionStore(storePath, { skipCache: true });
|
|
1705
|
+
const result = await mutator(store);
|
|
1706
|
+
await saveSessionStoreUnlocked(storePath, store, opts);
|
|
1707
|
+
return result;
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
const LOCK_QUEUES = /* @__PURE__ */ new Map();
|
|
1711
|
+
function lockTimeoutError(storePath) {
|
|
1712
|
+
return /* @__PURE__ */ new Error(`timeout waiting for session store lock: ${storePath}`);
|
|
1713
|
+
}
|
|
1714
|
+
function getOrCreateLockQueue(storePath) {
|
|
1715
|
+
const existing = LOCK_QUEUES.get(storePath);
|
|
1716
|
+
if (existing) return existing;
|
|
1717
|
+
const created = {
|
|
1718
|
+
running: false,
|
|
1719
|
+
pending: []
|
|
1720
|
+
};
|
|
1721
|
+
LOCK_QUEUES.set(storePath, created);
|
|
1722
|
+
return created;
|
|
1723
|
+
}
|
|
1724
|
+
function removePendingTask(queue, task) {
|
|
1725
|
+
const idx = queue.pending.indexOf(task);
|
|
1726
|
+
if (idx >= 0) queue.pending.splice(idx, 1);
|
|
1727
|
+
}
|
|
1728
|
+
async function drainSessionStoreLockQueue(storePath) {
|
|
1729
|
+
const queue = LOCK_QUEUES.get(storePath);
|
|
1730
|
+
if (!queue || queue.running) return;
|
|
1731
|
+
queue.running = true;
|
|
1732
|
+
try {
|
|
1733
|
+
while (queue.pending.length > 0) {
|
|
1734
|
+
const task = queue.pending.shift();
|
|
1735
|
+
if (!task || task.timedOut) continue;
|
|
1736
|
+
if (task.timer) clearTimeout(task.timer);
|
|
1737
|
+
task.started = true;
|
|
1738
|
+
const remainingTimeoutMs = task.timeoutAt != null ? Math.max(0, task.timeoutAt - Date.now()) : Number.POSITIVE_INFINITY;
|
|
1739
|
+
if (task.timeoutAt != null && remainingTimeoutMs <= 0) {
|
|
1740
|
+
task.timedOut = true;
|
|
1741
|
+
task.reject(lockTimeoutError(storePath));
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
let lock;
|
|
1745
|
+
let result;
|
|
1746
|
+
let failed;
|
|
1747
|
+
let hasFailure = false;
|
|
1748
|
+
try {
|
|
1749
|
+
lock = await acquireSessionWriteLock({
|
|
1750
|
+
sessionFile: storePath,
|
|
1751
|
+
timeoutMs: remainingTimeoutMs,
|
|
1752
|
+
staleMs: task.staleMs
|
|
1753
|
+
});
|
|
1754
|
+
result = await task.fn();
|
|
1755
|
+
} catch (err) {
|
|
1756
|
+
hasFailure = true;
|
|
1757
|
+
failed = err;
|
|
1758
|
+
} finally {
|
|
1759
|
+
await lock?.release().catch(() => void 0);
|
|
1760
|
+
}
|
|
1761
|
+
if (hasFailure) {
|
|
1762
|
+
task.reject(failed);
|
|
1763
|
+
continue;
|
|
1764
|
+
}
|
|
1765
|
+
task.resolve(result);
|
|
1766
|
+
}
|
|
1767
|
+
} finally {
|
|
1768
|
+
queue.running = false;
|
|
1769
|
+
if (queue.pending.length === 0) LOCK_QUEUES.delete(storePath);
|
|
1770
|
+
else queueMicrotask(() => {
|
|
1771
|
+
drainSessionStoreLockQueue(storePath);
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
async function withSessionStoreLock(storePath, fn, opts = {}) {
|
|
1776
|
+
const timeoutMs = opts.timeoutMs ?? 1e4;
|
|
1777
|
+
const staleMs = opts.staleMs ?? 3e4;
|
|
1778
|
+
opts.pollIntervalMs;
|
|
1779
|
+
const hasTimeout = timeoutMs > 0 && Number.isFinite(timeoutMs);
|
|
1780
|
+
const timeoutAt = hasTimeout ? Date.now() + timeoutMs : void 0;
|
|
1781
|
+
const queue = getOrCreateLockQueue(storePath);
|
|
1782
|
+
return await new Promise((resolve, reject) => {
|
|
1783
|
+
const task = {
|
|
1784
|
+
fn: async () => await fn(),
|
|
1785
|
+
resolve: (value) => resolve(value),
|
|
1786
|
+
reject,
|
|
1787
|
+
timeoutAt,
|
|
1788
|
+
staleMs,
|
|
1789
|
+
started: false,
|
|
1790
|
+
timedOut: false
|
|
1791
|
+
};
|
|
1792
|
+
if (hasTimeout) task.timer = setTimeout(() => {
|
|
1793
|
+
if (task.started || task.timedOut) return;
|
|
1794
|
+
task.timedOut = true;
|
|
1795
|
+
removePendingTask(queue, task);
|
|
1796
|
+
reject(lockTimeoutError(storePath));
|
|
1797
|
+
}, timeoutMs);
|
|
1798
|
+
queue.pending.push(task);
|
|
1799
|
+
drainSessionStoreLockQueue(storePath);
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
async function updateSessionStoreEntry(params) {
|
|
1803
|
+
const { storePath, sessionKey, update } = params;
|
|
1804
|
+
return await withSessionStoreLock(storePath, async () => {
|
|
1805
|
+
const store = loadSessionStore(storePath);
|
|
1806
|
+
const existing = store[sessionKey];
|
|
1807
|
+
if (!existing) return null;
|
|
1808
|
+
const patch = await update(existing);
|
|
1809
|
+
if (!patch) return existing;
|
|
1810
|
+
const next = mergeSessionEntry(existing, patch);
|
|
1811
|
+
store[sessionKey] = next;
|
|
1812
|
+
await saveSessionStoreUnlocked(storePath, store, { activeSessionKey: sessionKey });
|
|
1813
|
+
return next;
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
async function recordSessionMetaFromInbound(params) {
|
|
1817
|
+
const { storePath, sessionKey, ctx } = params;
|
|
1818
|
+
const createIfMissing = params.createIfMissing ?? true;
|
|
1819
|
+
return await updateSessionStore(storePath, (store) => {
|
|
1820
|
+
const existing = store[sessionKey];
|
|
1821
|
+
const patch = deriveSessionMetaPatch({
|
|
1822
|
+
ctx,
|
|
1823
|
+
sessionKey,
|
|
1824
|
+
existing,
|
|
1825
|
+
groupResolution: params.groupResolution
|
|
1826
|
+
});
|
|
1827
|
+
if (!patch) return existing ?? null;
|
|
1828
|
+
if (!existing && !createIfMissing) return null;
|
|
1829
|
+
const next = mergeSessionEntry(existing, patch);
|
|
1830
|
+
store[sessionKey] = next;
|
|
1831
|
+
return next;
|
|
1832
|
+
}, { activeSessionKey: sessionKey });
|
|
1833
|
+
}
|
|
1834
|
+
async function updateLastRoute(params) {
|
|
1835
|
+
const { storePath, sessionKey, channel, to, accountId, threadId, ctx } = params;
|
|
1836
|
+
return await withSessionStoreLock(storePath, async () => {
|
|
1837
|
+
const store = loadSessionStore(storePath);
|
|
1838
|
+
const existing = store[sessionKey];
|
|
1839
|
+
const now = Date.now();
|
|
1840
|
+
const explicitContext = normalizeDeliveryContext(params.deliveryContext);
|
|
1841
|
+
const inlineContext = normalizeDeliveryContext({
|
|
1842
|
+
channel,
|
|
1843
|
+
to,
|
|
1844
|
+
accountId,
|
|
1845
|
+
threadId
|
|
1846
|
+
});
|
|
1847
|
+
const mergedInput = mergeDeliveryContext(explicitContext, inlineContext);
|
|
1848
|
+
const explicitDeliveryContext = params.deliveryContext;
|
|
1849
|
+
const explicitThreadValue = (explicitDeliveryContext != null && Object.prototype.hasOwnProperty.call(explicitDeliveryContext, "threadId") ? explicitDeliveryContext.threadId : void 0) ?? (threadId != null && threadId !== "" ? threadId : void 0);
|
|
1850
|
+
const merged = mergeDeliveryContext(mergedInput, Boolean(explicitContext?.channel || explicitContext?.to || inlineContext?.channel || inlineContext?.to) && explicitThreadValue == null ? removeThreadFromDeliveryContext(deliveryContextFromSession(existing)) : deliveryContextFromSession(existing));
|
|
1851
|
+
const normalized = normalizeSessionDeliveryFields({ deliveryContext: {
|
|
1852
|
+
channel: merged?.channel,
|
|
1853
|
+
to: merged?.to,
|
|
1854
|
+
accountId: merged?.accountId,
|
|
1855
|
+
threadId: merged?.threadId
|
|
1856
|
+
} });
|
|
1857
|
+
const metaPatch = ctx ? deriveSessionMetaPatch({
|
|
1858
|
+
ctx,
|
|
1859
|
+
sessionKey,
|
|
1860
|
+
existing,
|
|
1861
|
+
groupResolution: params.groupResolution
|
|
1862
|
+
}) : null;
|
|
1863
|
+
const basePatch = {
|
|
1864
|
+
updatedAt: Math.max(existing?.updatedAt ?? 0, now),
|
|
1865
|
+
deliveryContext: normalized.deliveryContext,
|
|
1866
|
+
lastChannel: normalized.lastChannel,
|
|
1867
|
+
lastTo: normalized.lastTo,
|
|
1868
|
+
lastAccountId: normalized.lastAccountId,
|
|
1869
|
+
lastThreadId: normalized.lastThreadId
|
|
1870
|
+
};
|
|
1871
|
+
const next = mergeSessionEntry(existing, metaPatch ? {
|
|
1872
|
+
...basePatch,
|
|
1873
|
+
...metaPatch
|
|
1874
|
+
} : basePatch);
|
|
1875
|
+
store[sessionKey] = next;
|
|
1876
|
+
await saveSessionStoreUnlocked(storePath, store, { activeSessionKey: sessionKey });
|
|
1877
|
+
return next;
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
//#endregion
|
|
1882
|
+
//#region src/config/sessions/transcript.ts
|
|
1883
|
+
function stripQuery(value) {
|
|
1884
|
+
const noHash = value.split("#")[0] ?? value;
|
|
1885
|
+
return noHash.split("?")[0] ?? noHash;
|
|
1886
|
+
}
|
|
1887
|
+
function extractFileNameFromMediaUrl(value) {
|
|
1888
|
+
const trimmed = value.trim();
|
|
1889
|
+
if (!trimmed) return null;
|
|
1890
|
+
const cleaned = stripQuery(trimmed);
|
|
1891
|
+
try {
|
|
1892
|
+
const parsed = new URL(cleaned);
|
|
1893
|
+
const base = path.basename(parsed.pathname);
|
|
1894
|
+
if (!base) return null;
|
|
1895
|
+
try {
|
|
1896
|
+
return decodeURIComponent(base);
|
|
1897
|
+
} catch {
|
|
1898
|
+
return base;
|
|
1899
|
+
}
|
|
1900
|
+
} catch {
|
|
1901
|
+
const base = path.basename(cleaned);
|
|
1902
|
+
if (!base || base === "/" || base === ".") return null;
|
|
1903
|
+
return base;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
function resolveMirroredTranscriptText(params) {
|
|
1907
|
+
const mediaUrls = params.mediaUrls?.filter((url) => url && url.trim()) ?? [];
|
|
1908
|
+
if (mediaUrls.length > 0) {
|
|
1909
|
+
const names = mediaUrls.map((url) => extractFileNameFromMediaUrl(url)).filter((name) => Boolean(name && name.trim()));
|
|
1910
|
+
if (names.length > 0) return names.join(", ");
|
|
1911
|
+
return "media";
|
|
1912
|
+
}
|
|
1913
|
+
const trimmed = (params.text ?? "").trim();
|
|
1914
|
+
return trimmed ? trimmed : null;
|
|
1915
|
+
}
|
|
1916
|
+
async function ensureSessionHeader(params) {
|
|
1917
|
+
if (fsSync.existsSync(params.sessionFile)) return;
|
|
1918
|
+
await fsSync.promises.mkdir(path.dirname(params.sessionFile), { recursive: true });
|
|
1919
|
+
const header = {
|
|
1920
|
+
type: "session",
|
|
1921
|
+
version: CURRENT_SESSION_VERSION,
|
|
1922
|
+
id: params.sessionId,
|
|
1923
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1924
|
+
cwd: process.cwd()
|
|
1925
|
+
};
|
|
1926
|
+
await fsSync.promises.writeFile(params.sessionFile, `${JSON.stringify(header)}\n`, "utf-8");
|
|
1927
|
+
}
|
|
1928
|
+
async function appendAssistantMessageToSessionTranscript(params) {
|
|
1929
|
+
const sessionKey = params.sessionKey.trim();
|
|
1930
|
+
if (!sessionKey) return {
|
|
1931
|
+
ok: false,
|
|
1932
|
+
reason: "missing sessionKey"
|
|
1933
|
+
};
|
|
1934
|
+
const mirrorText = resolveMirroredTranscriptText({
|
|
1935
|
+
text: params.text,
|
|
1936
|
+
mediaUrls: params.mediaUrls
|
|
1937
|
+
});
|
|
1938
|
+
if (!mirrorText) return {
|
|
1939
|
+
ok: false,
|
|
1940
|
+
reason: "empty text"
|
|
1941
|
+
};
|
|
1942
|
+
const storePath = params.storePath ?? resolveDefaultSessionStorePath(params.agentId);
|
|
1943
|
+
const entry = loadSessionStore(storePath, { skipCache: true })[sessionKey];
|
|
1944
|
+
if (!entry?.sessionId) return {
|
|
1945
|
+
ok: false,
|
|
1946
|
+
reason: `unknown sessionKey: ${sessionKey}`
|
|
1947
|
+
};
|
|
1948
|
+
let sessionFile;
|
|
1949
|
+
try {
|
|
1950
|
+
sessionFile = resolveSessionFilePath(entry.sessionId, entry, {
|
|
1951
|
+
agentId: params.agentId,
|
|
1952
|
+
sessionsDir: path.dirname(storePath)
|
|
1953
|
+
});
|
|
1954
|
+
} catch (err) {
|
|
1955
|
+
return {
|
|
1956
|
+
ok: false,
|
|
1957
|
+
reason: err instanceof Error ? err.message : String(err)
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
await ensureSessionHeader({
|
|
1961
|
+
sessionFile,
|
|
1962
|
+
sessionId: entry.sessionId
|
|
1963
|
+
});
|
|
1964
|
+
SessionManager.open(sessionFile).appendMessage({
|
|
1965
|
+
role: "assistant",
|
|
1966
|
+
content: [{
|
|
1967
|
+
type: "text",
|
|
1968
|
+
text: mirrorText
|
|
1969
|
+
}],
|
|
1970
|
+
api: "openai-responses",
|
|
1971
|
+
provider: "anima",
|
|
1972
|
+
model: "delivery-mirror",
|
|
1973
|
+
usage: {
|
|
1974
|
+
input: 0,
|
|
1975
|
+
output: 0,
|
|
1976
|
+
cacheRead: 0,
|
|
1977
|
+
cacheWrite: 0,
|
|
1978
|
+
totalTokens: 0,
|
|
1979
|
+
cost: {
|
|
1980
|
+
input: 0,
|
|
1981
|
+
output: 0,
|
|
1982
|
+
cacheRead: 0,
|
|
1983
|
+
cacheWrite: 0,
|
|
1984
|
+
total: 0
|
|
1985
|
+
}
|
|
1986
|
+
},
|
|
1987
|
+
stopReason: "stop",
|
|
1988
|
+
timestamp: Date.now()
|
|
1989
|
+
});
|
|
1990
|
+
if (!entry.sessionFile || entry.sessionFile !== sessionFile) await updateSessionStore(storePath, (current) => {
|
|
1991
|
+
current[sessionKey] = {
|
|
1992
|
+
...entry,
|
|
1993
|
+
sessionFile
|
|
1994
|
+
};
|
|
1995
|
+
}, { activeSessionKey: sessionKey });
|
|
1996
|
+
emitSessionTranscriptUpdate(sessionFile);
|
|
1997
|
+
return {
|
|
1998
|
+
ok: true,
|
|
1999
|
+
sessionFile
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
//#endregion
|
|
2004
|
+
//#region src/config/sessions/delivery-info.ts
|
|
2005
|
+
/**
|
|
2006
|
+
* Extract deliveryContext and threadId from a sessionKey.
|
|
2007
|
+
* Supports both :thread: (most channels) and :topic: (Telegram).
|
|
2008
|
+
*/
|
|
2009
|
+
function extractDeliveryInfo(sessionKey) {
|
|
2010
|
+
if (!sessionKey) return {
|
|
2011
|
+
deliveryContext: void 0,
|
|
2012
|
+
threadId: void 0
|
|
2013
|
+
};
|
|
2014
|
+
const topicIndex = sessionKey.lastIndexOf(":topic:");
|
|
2015
|
+
const threadIndex = sessionKey.lastIndexOf(":thread:");
|
|
2016
|
+
const markerIndex = Math.max(topicIndex, threadIndex);
|
|
2017
|
+
const marker = topicIndex > threadIndex ? ":topic:" : ":thread:";
|
|
2018
|
+
const baseSessionKey = markerIndex === -1 ? sessionKey : sessionKey.slice(0, markerIndex);
|
|
2019
|
+
const threadId = (markerIndex === -1 ? void 0 : sessionKey.slice(markerIndex + marker.length))?.trim() || void 0;
|
|
2020
|
+
let deliveryContext;
|
|
2021
|
+
try {
|
|
2022
|
+
const store = loadSessionStore(resolveStorePath(loadConfig().session?.store));
|
|
2023
|
+
let entry = store[sessionKey];
|
|
2024
|
+
if (!entry?.deliveryContext && markerIndex !== -1 && baseSessionKey) entry = store[baseSessionKey];
|
|
2025
|
+
if (entry?.deliveryContext) deliveryContext = {
|
|
2026
|
+
channel: entry.deliveryContext.channel,
|
|
2027
|
+
to: entry.deliveryContext.to,
|
|
2028
|
+
accountId: entry.deliveryContext.accountId
|
|
2029
|
+
};
|
|
2030
|
+
} catch {}
|
|
2031
|
+
return {
|
|
2032
|
+
deliveryContext,
|
|
2033
|
+
threadId
|
|
2034
|
+
};
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
//#endregion
|
|
2038
|
+
export { listChannelDocks as A, HEARTBEAT_TOKEN as B, resolveFreshSessionTotalTokens as C, resolveMainSessionKey as D, resolveExplicitAgentSessionKey as E, resolveChannelGroupRequireMention as F, isSilentReplyText as H, resolveChannelGroupToolsPolicy as I, resolveConversationLabel as L, resolveSignalAccount as M, resolveIMessageAccount as N, deriveSessionMetaPatch as O, resolveChannelGroupPolicy as P, normalizeChatType as R, DEFAULT_RESET_TRIGGERS as S, resolveAgentMainSessionKey as T, SILENT_REPLY_TOKEN as V, evaluateSessionFreshness as _, readSessionUpdatedAt as a, resolveSessionResetType as b, updateSessionStore as c, deliveryContextKey as d, mergeDeliveryContext as f, resolveSessionKey as g, normalizeAccountId as h, loadSessionStore as i, listEnabledSignalAccounts as j, getChannelDock as k, updateSessionStoreEntry as l, normalizeSessionDeliveryFields as m, appendAssistantMessageToSessionTranscript as n, recordSessionMetaFromInbound as o, normalizeDeliveryContext as p, resolveMirroredTranscriptText as r, updateLastRoute as s, extractDeliveryInfo as t, deliveryContextFromSession as u, resolveChannelResetConfig as v, canonicalizeMainSessionAlias as w, resolveThreadFlag as x, resolveSessionResetPolicy as y, resolveGroupSessionKey as z };
|