@spacebar_ai/moldclaw-core 2026.3.43 → 2026.3.44
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/dist/accounts-5qY-dKca.d.ts +103 -0
- package/dist/accounts-SqdHz2ZP.js +114 -0
- package/dist/acp-cli-E6bcNqiE.js +2093 -0
- package/dist/actions.runtime-BU_XMuLk.js +119 -0
- package/dist/actions.runtime-CY5h8lqH.js +133 -0
- package/dist/agent-scope-lZlwP1At.js +208 -0
- package/dist/agents-C4SkadR1.js +853 -0
- package/dist/agents-RfwqGCzE.js +222 -0
- package/dist/agents.config-CX9CPNfP.js +17 -0
- package/dist/agents.config-DF9Zwn9n.js +121 -0
- package/dist/allow-list-3WSjz1zl.js +81 -0
- package/dist/allowlist-DNbDjFjw.js +142 -0
- package/dist/api-BEOpJ7dR.js +117 -0
- package/dist/audit-CpJz_eu6.js +787 -0
- package/dist/audit-CpfSjvyo.js +54 -0
- package/dist/audit-channel.collect.runtime-BeGotloZ.js +605 -0
- package/dist/audit-channel.runtime-BJDZ7ETt.js +121 -0
- package/dist/audit-extra.async-C2G0mqmk.js +813 -0
- package/dist/audit-membership-runtime-B1FqJsPV.js +162 -0
- package/dist/audit.deep.runtime-DyL9O_sU.js +25 -0
- package/dist/audit.nondeep.runtime-C6jFgJfH.js +832 -0
- package/dist/audit.runtime-Dnlsn23e.js +118 -0
- package/dist/auth-Ch3Rchm4.js +101 -0
- package/dist/auth-choice-CEFSlnLT.js +122 -0
- package/dist/auth-choice-CVCef-eU.js +268 -0
- package/dist/auth-choice-Cez-pXrg.js +507 -0
- package/dist/auth-choice-options-DO78mvPe.js +123 -0
- package/dist/auth-choice-prompt-CUkC7Mmb.js +36 -0
- package/dist/auth-choice-prompt-DCuQRiVl.js +115 -0
- package/dist/auth-choice.apply-helpers-BhbNIV8X.js +66 -0
- package/dist/auth-choice.plugin-providers.runtime-4BhqvEw_.js +119 -0
- package/dist/auth-profiles-smABVXzp.js +128040 -0
- package/dist/auth-profiles.runtime-Cr-ojtTc.js +116 -0
- package/dist/banner-CojBHPWr.js +342 -0
- package/dist/bluebubbles-BnLsj2Fy.d.ts +6 -0
- package/dist/bluebubbles-CVk7M3Bl.js +64 -0
- package/dist/bot-DdyrB2z9.d.ts +478 -0
- package/dist/brave-w4Fo8WZ3.js +24 -0
- package/dist/browser-cli-DWFs3P_i.js +1494 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.d.ts +1 -1
- package/dist/bundled/boot-md/handler.js +35 -35
- package/dist/bundled/bootstrap-extra-files/handler.d.ts +1 -1
- package/dist/bundled/bootstrap-extra-files/handler.js +1 -1
- package/dist/bundled/command-logger/handler.d.ts +1 -1
- package/dist/bundled/session-memory/handler.d.ts +1 -1
- package/dist/bundled/session-memory/handler.js +36 -36
- package/dist/call-Do7wTSr7.js +39 -0
- package/dist/call-gdDAt07d.js +640 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/channel-B26pkce0.js +214 -0
- package/dist/channel-BJHp0AQC.js +352 -0
- package/dist/channel-BKFOv51P.js +4681 -0
- package/dist/channel-BNgpOY8v.js +538 -0
- package/dist/channel-BcQAAo2P.js +226 -0
- package/dist/channel-BvNdnhbx.js +1598 -0
- package/dist/channel-C1Rda3Jd.js +306 -0
- package/dist/channel-C87DG-F7.js +803 -0
- package/dist/channel-CIip0kvZ.js +619 -0
- package/dist/channel-CTPxoT_E2.js +316 -0
- package/dist/channel-CklaCzUG.js +562 -0
- package/dist/channel-CoJnAdLs.js +920 -0
- package/dist/channel-D3tafL1_.js +949 -0
- package/dist/channel-DFMrP2uu.js +542 -0
- package/dist/channel-DMd5cJQe.js +397 -0
- package/dist/channel-Dm34kxAJ.js +207 -0
- package/dist/channel-DmwF9udn.js +1321 -0
- package/dist/channel-account-context-Bjur9nlh.js +103 -0
- package/dist/channel-bGnST659.js +943 -0
- package/dist/channel-hIgbkTZf.js +575 -0
- package/dist/channel-m_TGrDKo.js +497 -0
- package/dist/channel-options-DoUPBMa8.js +50 -0
- package/dist/channel-plugin-ids-TZIY4hFs.js +26 -0
- package/dist/channel-summary-qD54bOBO.js +111 -0
- package/dist/channel.runtime-B0H04Dkk.js +199 -0
- package/dist/channel.runtime-BU1f3NkV.js +418 -0
- package/dist/channel.runtime-Bj1sfLep.js +4011 -0
- package/dist/channel.runtime-BtPAAJc3.js +870 -0
- package/dist/channel.runtime-Bx-10m_j.js +171 -0
- package/dist/channel.runtime-CI_TBywQ.js +179 -0
- package/dist/channel.runtime-CSLj14-Z.js +182 -0
- package/dist/channel.runtime-D-lTSYAd.js +404 -0
- package/dist/channel.runtime-DJqIOSji.js +127 -0
- package/dist/channel.runtime-Ec8aQ9V2.js +241 -0
- package/dist/channel.runtime-ax5a1jBm.js +218 -0
- package/dist/channel.setup-B-ncdYLT.js +9 -0
- package/dist/channel.setup-BY4bh5dm.js +9 -0
- package/dist/channel.setup-BovsdMnL.js +57 -0
- package/dist/channel.setup-CXzXA25h.js +6 -0
- package/dist/channel.setup-DcZUEufN.js +8 -0
- package/dist/channel.setup-E6zceRsE.js +8 -0
- package/dist/channel.setup-Pc7nGbdX.js +11 -0
- package/dist/channels/plugins/actions/discord.d.ts +2 -2
- package/dist/channels/plugins/actions/discord.js +35 -35
- package/dist/channels/plugins/actions/signal.d.ts +1 -1
- package/dist/channels/plugins/actions/signal.js +35 -35
- package/dist/channels/plugins/actions/telegram.d.ts +2 -2
- package/dist/channels/plugins/actions/telegram.js +35 -35
- package/dist/channels/plugins/agent-tools/whatsapp-login.d.ts +3 -3
- package/dist/channels/plugins/agent-tools/whatsapp-login.js +35 -35
- package/dist/channels-CPtE5ND6.js +404 -0
- package/dist/channels-Cj8ZolHI.js +1118 -0
- package/dist/channels-cli-D2sKrntt.js +291 -0
- package/dist/channels-status-issues-CzIHODg2.js +16 -0
- package/dist/clawbot-cli-BcwEDmUn.js +118 -0
- package/dist/cleanup-utils-D0L17RsX.js +96 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-BvGVPKnD.js +154 -0
- package/dist/command-registry-CADQzTAg.js +14 -0
- package/dist/command-registry-ktiJNAJd.js +242 -0
- package/dist/command-secret-gateway-CXp10RTM.js +111 -0
- package/dist/compact.runtime-DyKL-Iar.js +116 -0
- package/dist/completion-cli-Bz4STrpt.js +17 -0
- package/dist/completion-cli-pVda2OFb.js +445 -0
- package/dist/config-BbvDRSYp.js +31 -0
- package/dist/config-CwBv71QC.js +44 -0
- package/dist/config-cli-Y0uXHbOw.js +678 -0
- package/dist/config-guard-BpW5g7JE.js +118 -0
- package/dist/config-validation-B-vLIsbo.js +262 -0
- package/dist/config-value-DT3-5958.js +132 -0
- package/dist/configure-B9U-jCqP.js +1100 -0
- package/dist/configure-BJ3Wrs5b.js +243 -0
- package/dist/control-ui-assets-C1YDYi82.js +232 -0
- package/dist/control-ui-shared-Dm5Dh0Lo.js +29 -0
- package/dist/core-BwKq3krw.js +150 -0
- package/dist/core-hjBwfDsW.d.ts +87 -0
- package/dist/cron-cli-DTDgfoMh.js +639 -0
- package/dist/daemon-cli-C-dkAXR1.js +339 -0
- package/dist/daemon-install-Oy0Q5pMF.js +180 -0
- package/dist/deliver-DNGnDqF9.js +111 -0
- package/dist/deliver-runtime-CCNZIhET.js +111 -0
- package/dist/device-id-cli-XvwZbIyC.js +52 -0
- package/dist/device-identity-IG5DngWM.js +365 -0
- package/dist/devices-cli-DIsxj4xp.js +342 -0
- package/dist/diagnostic-DTPopFvh.js +310 -0
- package/dist/directory-cli-DTSY3Ktr.js +311 -0
- package/dist/directory-config-helpers-DpFcAbmo.d.ts +38 -0
- package/dist/directory.static-CBRAUwUW.js +44 -0
- package/dist/discord-CrgxhEWw.js +114 -0
- package/dist/discovery-DrG7wmAR.js +48 -0
- package/dist/dm-policy-shared-DKoGdUpY.d.ts +95 -0
- package/dist/dns-cli-BJiz6CLK.js +217 -0
- package/dist/docs-cli-Dq2Yi5qO.js +174 -0
- package/dist/doctor-completion-D3GeVcFP.js +90 -0
- package/dist/doctor-config-flow-B1cMjr8h.js +112 -0
- package/dist/doctor-config-flow-BUe7JpV3.js +2437 -0
- package/dist/enable-Bc8bCuVe.js +24 -0
- package/dist/entry.js +4 -4
- package/dist/exec-approvals-cli-kLAev6bP.js +421 -0
- package/dist/extensions/acpx/index.d.ts +1 -1
- package/dist/extensions/amazon-bedrock/index.d.ts +1 -1
- package/dist/extensions/amazon-bedrock/index.js +4 -4
- package/dist/extensions/anthropic/index.d.ts +1 -1
- package/dist/extensions/anthropic/index.js +35 -35
- package/dist/extensions/bluebubbles/index.d.ts +1 -1
- package/dist/extensions/bluebubbles/index.js +39 -39
- package/dist/extensions/bluebubbles/setup-entry.d.ts +2 -2
- package/dist/extensions/bluebubbles/setup-entry.js +39 -39
- package/dist/extensions/brave/index.d.ts +1 -1
- package/dist/extensions/brave/index.js +5 -5
- package/dist/extensions/byteplus/index.d.ts +1 -1
- package/dist/extensions/byteplus/index.js +35 -35
- package/dist/extensions/cloudflare-ai-gateway/index.d.ts +1 -1
- package/dist/extensions/cloudflare-ai-gateway/index.js +36 -36
- package/dist/extensions/copilot-proxy/index.d.ts +1 -1
- package/dist/extensions/copilot-proxy/index.js +4 -4
- package/dist/extensions/device-pair/index.d.ts +1 -1
- package/dist/extensions/device-pair/index.js +4 -4
- package/dist/extensions/diagnostics-otel/index.d.ts +1 -1
- package/dist/extensions/diagnostics-otel/index.js +4 -4
- package/dist/extensions/diffs/index.d.ts +1 -1
- package/dist/extensions/discord/index.d.ts +1 -1
- package/dist/extensions/discord/index.js +40 -40
- package/dist/extensions/discord/setup-entry.d.ts +1 -1
- package/dist/extensions/discord/setup-entry.js +38 -38
- package/dist/extensions/elevenlabs/index.d.ts +1 -1
- package/dist/extensions/elevenlabs/index.js +35 -35
- package/dist/extensions/feishu/index.d.ts +2 -2
- package/dist/extensions/feishu/index.js +40 -40
- package/dist/extensions/feishu/setup-entry.d.ts +2 -2
- package/dist/extensions/feishu/setup-entry.js +37 -37
- package/dist/extensions/firecrawl/index.d.ts +1 -1
- package/dist/extensions/firecrawl/index.js +35 -35
- package/dist/extensions/github-copilot/index.d.ts +1 -1
- package/dist/extensions/github-copilot/index.js +35 -35
- package/dist/extensions/google/index.d.ts +1 -1
- package/dist/extensions/google/index.js +35 -35
- package/dist/extensions/googlechat/index.d.ts +1 -1
- package/dist/extensions/googlechat/index.js +38 -38
- package/dist/extensions/googlechat/setup-entry.d.ts +1 -1
- package/dist/extensions/googlechat/setup-entry.js +38 -38
- package/dist/extensions/huggingface/index.d.ts +1 -1
- package/dist/extensions/huggingface/index.js +35 -35
- package/dist/extensions/imessage/index.d.ts +1 -1
- package/dist/extensions/imessage/index.js +39 -39
- package/dist/extensions/imessage/setup-entry.d.ts +1 -1
- package/dist/extensions/imessage/setup-entry.js +39 -39
- package/dist/extensions/irc/index.d.ts +1 -1
- package/dist/extensions/irc/index.js +38 -38
- package/dist/extensions/irc/setup-entry.d.ts +2 -2
- package/dist/extensions/irc/setup-entry.js +38 -38
- package/dist/extensions/kakao-talkchannel/index.d.ts +1 -1
- package/dist/extensions/kakao-talkchannel/index.js +4 -4
- package/dist/extensions/kilocode/index.d.ts +1 -1
- package/dist/extensions/kilocode/index.js +35 -35
- package/dist/extensions/kimi-coding/index.d.ts +1 -1
- package/dist/extensions/kimi-coding/index.js +35 -35
- package/dist/extensions/line/index.d.ts +1 -1
- package/dist/extensions/line/index.js +37 -37
- package/dist/extensions/line/setup-entry.d.ts +1 -1
- package/dist/extensions/line/setup-entry.js +37 -37
- package/dist/extensions/llm-task/index.d.ts +1 -1
- package/dist/extensions/llm-task/index.js +35 -35
- package/dist/extensions/lobster/index.d.ts +1 -1
- package/dist/extensions/lobster/index.js +4 -4
- package/dist/extensions/matrix/index.d.ts +1 -1
- package/dist/extensions/matrix/index.js +40 -40
- package/dist/extensions/matrix/setup-entry.d.ts +2 -2
- package/dist/extensions/matrix/setup-entry.js +40 -40
- package/dist/extensions/mattermost/index.d.ts +1 -1
- package/dist/extensions/mattermost/index.js +37 -37
- package/dist/extensions/mattermost/setup-entry.d.ts +2 -2
- package/dist/extensions/mattermost/setup-entry.js +37 -37
- package/dist/extensions/memory-core/index.d.ts +1 -1
- package/dist/extensions/memory-core/index.js +4 -4
- package/dist/extensions/memory-lancedb/index.d.ts +1 -1
- package/dist/extensions/memory-lancedb/index.js +4 -4
- package/dist/extensions/microsoft/index.d.ts +1 -1
- package/dist/extensions/microsoft/index.js +35 -35
- package/dist/extensions/minimax/index.d.ts +1 -1
- package/dist/extensions/minimax/index.js +35 -35
- package/dist/extensions/mistral/index.d.ts +1 -1
- package/dist/extensions/mistral/index.js +35 -35
- package/dist/extensions/modelstudio/index.d.ts +1 -1
- package/dist/extensions/modelstudio/index.js +35 -35
- package/dist/extensions/moonshot/index.d.ts +1 -1
- package/dist/extensions/moonshot/index.js +35 -35
- package/dist/extensions/msteams/index.d.ts +1 -1
- package/dist/extensions/msteams/index.js +40 -40
- package/dist/extensions/msteams/setup-entry.d.ts +1 -1
- package/dist/extensions/msteams/setup-entry.js +40 -40
- package/dist/extensions/nextcloud-talk/index.d.ts +1 -1
- package/dist/extensions/nextcloud-talk/index.js +37 -37
- package/dist/extensions/nextcloud-talk/setup-entry.d.ts +2 -2
- package/dist/extensions/nextcloud-talk/setup-entry.js +37 -37
- package/dist/extensions/nostr/index.d.ts +1 -1
- package/dist/extensions/nostr/index.js +37 -37
- package/dist/extensions/nostr/setup-entry.d.ts +1 -1
- package/dist/extensions/nostr/setup-entry.js +37 -37
- package/dist/extensions/nvidia/index.d.ts +1 -1
- package/dist/extensions/nvidia/index.js +4 -4
- package/dist/extensions/ollama/index.d.ts +1 -1
- package/dist/extensions/ollama/index.js +7 -7
- package/dist/extensions/open-prose/index.d.ts +1 -1
- package/dist/extensions/open-prose/index.js +4 -4
- package/dist/extensions/openai/index.d.ts +1 -1
- package/dist/extensions/openai/index.js +35 -35
- package/dist/extensions/opencode/index.d.ts +1 -1
- package/dist/extensions/opencode/index.js +35 -35
- package/dist/extensions/opencode-go/index.d.ts +1 -1
- package/dist/extensions/opencode-go/index.js +35 -35
- package/dist/extensions/openrouter/index.d.ts +1 -1
- package/dist/extensions/openrouter/index.js +35 -35
- package/dist/extensions/openshell/index.d.ts +1 -1
- package/dist/extensions/openshell/index.js +35 -35
- package/dist/extensions/perplexity/index.d.ts +1 -1
- package/dist/extensions/perplexity/index.js +5 -5
- package/dist/extensions/phone-control/index.d.ts +1 -1
- package/dist/extensions/phone-control/index.js +4 -4
- package/dist/extensions/qianfan/index.d.ts +1 -1
- package/dist/extensions/qianfan/index.js +35 -35
- package/dist/extensions/qwen-portal-auth/index.d.ts +1 -1
- package/dist/extensions/qwen-portal-auth/index.js +35 -35
- package/dist/extensions/sglang/index.d.ts +1 -1
- package/dist/extensions/sglang/index.js +35 -35
- package/dist/extensions/signal/index.d.ts +1 -1
- package/dist/extensions/signal/index.js +38 -38
- package/dist/extensions/signal/setup-entry.d.ts +1 -1
- package/dist/extensions/signal/setup-entry.js +38 -38
- package/dist/extensions/slack/index.d.ts +1 -1
- package/dist/extensions/slack/index.js +39 -39
- package/dist/extensions/slack/setup-entry.d.ts +1 -1
- package/dist/extensions/slack/setup-entry.js +38 -38
- package/dist/extensions/synology-chat/index.d.ts +1 -1
- package/dist/extensions/synology-chat/index.js +37 -37
- package/dist/extensions/synology-chat/setup-entry.d.ts +1 -1
- package/dist/extensions/synology-chat/setup-entry.js +37 -37
- package/dist/extensions/synthetic/index.d.ts +1 -1
- package/dist/extensions/synthetic/index.js +35 -35
- package/dist/extensions/talk-voice/index.d.ts +1 -1
- package/dist/extensions/talk-voice/index.js +35 -35
- package/dist/extensions/telegram/index.d.ts +1 -1
- package/dist/extensions/telegram/index.js +38 -38
- package/dist/extensions/telegram/setup-entry.d.ts +1 -1
- package/dist/extensions/telegram/setup-entry.js +37 -37
- package/dist/extensions/thread-ownership/index.d.ts +1 -1
- package/dist/extensions/thread-ownership/index.js +4 -4
- package/dist/extensions/tlon/index.d.ts +1 -1
- package/dist/extensions/tlon/index.js +37 -37
- package/dist/extensions/tlon/setup-entry.d.ts +1 -1
- package/dist/extensions/tlon/setup-entry.js +37 -37
- package/dist/extensions/together/index.d.ts +1 -1
- package/dist/extensions/together/index.js +35 -35
- package/dist/extensions/twitch/index.d.ts +2 -2
- package/dist/extensions/twitch/index.js +37 -37
- package/dist/extensions/venice/index.d.ts +1 -1
- package/dist/extensions/venice/index.js +35 -35
- package/dist/extensions/vercel-ai-gateway/index.d.ts +1 -1
- package/dist/extensions/vercel-ai-gateway/index.js +36 -36
- package/dist/extensions/vllm/index.d.ts +1 -1
- package/dist/extensions/vllm/index.js +35 -35
- package/dist/extensions/voice-call/index.d.ts +1 -1
- package/dist/extensions/voice-call/index.js +35 -35
- package/dist/extensions/volcengine/index.d.ts +1 -1
- package/dist/extensions/volcengine/index.js +35 -35
- package/dist/extensions/whatsapp/index.d.ts +1 -1
- package/dist/extensions/whatsapp/index.js +38 -38
- package/dist/extensions/whatsapp/setup-entry.d.ts +1 -1
- package/dist/extensions/whatsapp/setup-entry.js +38 -38
- package/dist/extensions/xai/index.d.ts +1 -1
- package/dist/extensions/xai/index.js +35 -35
- package/dist/extensions/xiaomi/index.d.ts +1 -1
- package/dist/extensions/xiaomi/index.js +35 -35
- package/dist/extensions/zai/index.d.ts +1 -1
- package/dist/extensions/zai/index.js +35 -35
- package/dist/extensions/zalo/index.d.ts +1 -1
- package/dist/extensions/zalo/index.js +39 -39
- package/dist/extensions/zalo/setup-entry.d.ts +1 -1
- package/dist/extensions/zalo/setup-entry.js +39 -39
- package/dist/extensions/zalouser/index.d.ts +1 -1
- package/dist/extensions/zalouser/index.js +40 -40
- package/dist/extensions/zalouser/setup-entry.d.ts +1 -1
- package/dist/extensions/zalouser/setup-entry.js +40 -40
- package/dist/feishu-fIcnHDTd.d.ts +36 -0
- package/dist/gateway-cli-0c-8h93_.js +26437 -0
- package/dist/gateway-install-token-1PwJvrBY.js +163 -0
- package/dist/gateway-rpc-C0Vk51W7.js +26 -0
- package/dist/gateway-runtime-CBm3CCoA.js +69 -0
- package/dist/git-commit-BTWXFY41.js +177 -0
- package/dist/git-commit-D6GTN5Yt.js +2 -0
- package/dist/googlechat-BQr4xgoZ.js +307 -0
- package/dist/googlechat-BvwsCVKl.d.ts +12 -0
- package/dist/group-access-DpiQnd-G.d.ts +61 -0
- package/dist/health-6yZQGADY.js +113 -0
- package/dist/health-C9DYGyRe.js +570 -0
- package/dist/heartbeat-summary-Dct2lqJj.js +57 -0
- package/dist/help-CtwSApfq.js +81 -0
- package/dist/hooks-9gokOxZ5.d.ts +6 -0
- package/dist/hooks-cli-BegKzHZT.js +1000 -0
- package/dist/hooks-status-Bm_pGORf.js +78 -0
- package/dist/http-registry-D-S6a1Na.d.ts +20 -0
- package/dist/identity-file-Diub2a0t.js +60 -0
- package/dist/image-generation-CbIVzmAR.d.ts +9 -0
- package/dist/imessage-Bgok9kfl.js +31 -0
- package/dist/imessage-VIHePprL.js +115 -0
- package/dist/inbound-reply-dispatch-B53GAGWq.js +71 -0
- package/dist/inbound-reply-dispatch-n7U3qg15.d.ts +72 -0
- package/dist/index.js +2 -2
- package/dist/install-target-oz1pjfHH.js +574 -0
- package/dist/installs-CUFm5V8a.js +532 -0
- package/dist/io-BaBxjB1v.js +9739 -0
- package/dist/io-CgHb1Jld.js +29 -0
- package/dist/irc-CaRKzGvW.js +672 -0
- package/dist/library-C5SNBCMb.js +112 -0
- package/dist/lifecycle-core-Dn8PK6nk.js +382 -0
- package/dist/line/accounts.d.ts +2 -2
- package/dist/line/send.d.ts +1 -1
- package/dist/line/send.js +7 -7
- package/dist/line/template-messages.d.ts +1 -1
- package/dist/line-B5QFpgN_.d.ts +75 -0
- package/dist/line-fePrrQOD.js +530 -0
- package/dist/llm-slug-generator-hKae3XDA.js +67 -0
- package/dist/llm-slug-generator.d.ts +1 -1
- package/dist/llm-slug-generator.js +36 -36
- package/dist/logging-CdisccbY.js +13 -0
- package/dist/logging-LKQSgX1d.js +30 -0
- package/dist/login-qr-C1YWh4nE.js +233 -0
- package/dist/login-qr-WFluMDMb.js +112 -0
- package/dist/logs-cli-CNzOvZ2d.js +256 -0
- package/dist/manager-runtime-DgMhLTkR.js +111 -0
- package/dist/manager.runtime-hUWgpPt2.js +715 -0
- package/dist/manifest-registry-CS_p1OBQ.js +1329 -0
- package/dist/matrix-43_RGLZN.d.ts +68 -0
- package/dist/matrix-CCFxHfxa.js +1269 -0
- package/dist/matrix-DWs_qIkJ.js +1495 -0
- package/dist/mcp-cli-Ci2jvv3s.js +87 -0
- package/dist/media-understanding.runtime-Cdr6iTW6.js +116 -0
- package/dist/memory-cli-LZbyF0Iu.js +111 -0
- package/dist/memory-search-BHhETk6u.js +17 -0
- package/dist/memory-search-tTD5o_rU.js +204 -0
- package/dist/method-scopes-B2ZKSsxQ.js +2452 -0
- package/dist/model-auth-markers-LqZ4qhrZ.d.ts +20 -0
- package/dist/model-picker-CTR5mo4v.js +112 -0
- package/dist/model-picker-DG4z_dBs.js +390 -0
- package/dist/model-picker.runtime-DMQ9Pj9_.js +125 -0
- package/dist/model-selection-bBBxfXdb.js +653 -0
- package/dist/model-suppression.runtime-BVG75tZ7.js +116 -0
- package/dist/models-BjkVLfgw.js +2514 -0
- package/dist/models-ZO01Q4cx.js +118 -0
- package/dist/models-cli-DemdF-bm.js +309 -0
- package/dist/models-config-B2Jja8ua.js +111 -0
- package/dist/models-config.providers.discovery-puxTsH39.d.ts +18 -0
- package/dist/moldclaw-root-Cb6HRlUO.js +92 -0
- package/dist/monitor-BP4idxJD.js +782 -0
- package/dist/monitor-B_eP8Eim.js +772 -0
- package/dist/monitor-CRHYNl5J.js +3468 -0
- package/dist/monitor-Ci1Xg4g3.js +113 -0
- package/dist/monitor-DEodDl3z.js +6823 -0
- package/dist/monitor-DJlNKuMz.js +115 -0
- package/dist/monitor-DvFwDS9w.js +3076 -0
- package/dist/monitor-shared--cEjSf8s.js +444 -0
- package/dist/msteams-CV2a8uE8.js +852 -0
- package/dist/node-cli-Of2g7DSd.js +2503 -0
- package/dist/node-resolve-BYC2FbO2.js +835 -0
- package/dist/nodes-cli-CPHM6Upj.js +1380 -0
- package/dist/nostr-BFKRoOlz.d.ts +7 -0
- package/dist/nostr-lHpcBzz4.js +8744 -0
- package/dist/npm-resolution-kqHN85wB.js +60 -0
- package/dist/oauth-env-CLG8KOrz.js +10 -0
- package/dist/onboard-BON0C360.js +48 -0
- package/dist/onboard-CRkIBgOI.js +589 -0
- package/dist/onboard-DsKI17iq.js +25 -0
- package/dist/onboard-channels-BY3IbBBf.js +1241 -0
- package/dist/onboard-channels-CLKdRxvW.js +205 -0
- package/dist/onboard-custom-BjPrMo_R.js +571 -0
- package/dist/onboard-custom-DqcPiZBN.js +114 -0
- package/dist/onboard-helpers-BkrOY5OE.js +113 -0
- package/dist/onboard-helpers-DiSRTpZC.js +335 -0
- package/dist/onboard-hooks-pzEPZAvl.js +72 -0
- package/dist/onboard-remote-ChyLC6Dk.js +181 -0
- package/dist/onboard-remote-DHmK9ntl.js +117 -0
- package/dist/onboard-search-BgA3jEMW.js +302 -0
- package/dist/onboard-skills-BMo_NvnW.js +133 -0
- package/dist/onboard-skills-Bba-Z2p8.js +117 -0
- package/dist/outbound-media-BHD4aJEX.d.ts +11 -0
- package/dist/outbound-media-DSno0N82.js +11 -0
- package/dist/pairing-access-CzHpaM0R.d.ts +21 -0
- package/dist/pairing-cli-CmklqK0q.js +217 -0
- package/dist/perplexity-CXwMDD3u.js +24 -0
- package/dist/persistent-dedupe-B9vrAf8t.d.ts +26 -0
- package/dist/pi-model-discovery-runtime-BrK7tcaO.js +111 -0
- package/dist/pi-tools.before-tool-call.runtime-C5yLUogH.js +381 -0
- package/dist/plugin-install-C4AWJIFP.js +117 -0
- package/dist/plugin-install-CB3J1hfV.js +184 -0
- package/dist/plugin-install-plan-7itZiegi.js +49 -0
- package/dist/plugin-registry-DX_GFoiz.js +113 -0
- package/dist/plugin-registry-e3cxTtvb.js +49 -0
- package/dist/plugin-sdk/account-resolution.js +35 -35
- package/dist/plugin-sdk/acp-runtime.js +35 -35
- package/dist/plugin-sdk/agent-runtime.js +35 -35
- package/dist/plugin-sdk/bluebubbles.js +37 -37
- package/dist/plugin-sdk/channel-config-helpers.js +35 -35
- package/dist/plugin-sdk/channel-policy.js +35 -35
- package/dist/plugin-sdk/channel-runtime.js +35 -35
- package/dist/plugin-sdk/compat.js +36 -36
- package/dist/plugin-sdk/config-runtime.js +35 -35
- package/dist/plugin-sdk/conversation-runtime.js +35 -35
- package/dist/plugin-sdk/copilot-proxy.js +4 -4
- package/dist/plugin-sdk/core.js +4 -4
- package/dist/plugin-sdk/device-pair.js +4 -4
- package/dist/plugin-sdk/discord.js +35 -35
- package/dist/plugin-sdk/feishu.js +35 -35
- package/dist/plugin-sdk/gateway-runtime.js +10 -10
- package/dist/plugin-sdk/googlechat.js +37 -37
- package/dist/plugin-sdk/image-generation-runtime.js +35 -35
- package/dist/plugin-sdk/image-generation.js +35 -35
- package/dist/plugin-sdk/imessage.js +36 -36
- package/dist/plugin-sdk/index.js +35 -35
- package/dist/plugin-sdk/infra-runtime.js +35 -35
- package/dist/plugin-sdk/irc.js +37 -37
- package/dist/plugin-sdk/line.js +36 -36
- package/dist/plugin-sdk/llm-task.js +35 -35
- package/dist/plugin-sdk/lobster.js +4 -4
- package/dist/plugin-sdk/matrix.js +37 -37
- package/dist/plugin-sdk/mattermost.js +36 -36
- package/dist/plugin-sdk/media-runtime.js +35 -35
- package/dist/plugin-sdk/media-understanding-runtime.js +35 -35
- package/dist/plugin-sdk/media-understanding.js +35 -35
- package/dist/plugin-sdk/memory-lancedb.js +4 -4
- package/dist/plugin-sdk/minimax-portal-auth.js +4 -4
- package/dist/plugin-sdk/msteams.js +38 -38
- package/dist/plugin-sdk/nextcloud-talk.js +36 -36
- package/dist/plugin-sdk/nostr.js +36 -36
- package/dist/plugin-sdk/ollama-setup.js +9 -9
- package/dist/plugin-sdk/open-prose.js +4 -4
- package/dist/plugin-sdk/phone-control.js +4 -4
- package/dist/plugin-sdk/plugin-runtime.js +35 -35
- package/dist/plugin-sdk/provider-auth.js +35 -35
- package/dist/plugin-sdk/provider-models.js +5 -5
- package/dist/plugin-sdk/provider-onboard.js +4 -4
- package/dist/plugin-sdk/provider-setup.js +39 -39
- package/dist/plugin-sdk/provider-stream.js +4 -4
- package/dist/plugin-sdk/provider-usage.js +4 -4
- package/dist/plugin-sdk/qwen-portal-auth.js +35 -35
- package/dist/plugin-sdk/reply-history.js +35 -35
- package/dist/plugin-sdk/reply-runtime.js +35 -35
- package/dist/plugin-sdk/routing.js +3 -3
- package/dist/plugin-sdk/sandbox.js +35 -35
- package/dist/plugin-sdk/security-runtime.js +35 -35
- package/dist/plugin-sdk/self-hosted-provider-setup.js +37 -37
- package/dist/plugin-sdk/setup.js +35 -35
- package/dist/plugin-sdk/signal.js +35 -35
- package/dist/plugin-sdk/slack.js +35 -35
- package/dist/plugin-sdk/speech-runtime.js +35 -35
- package/dist/plugin-sdk/speech.js +35 -35
- package/dist/plugin-sdk/src/secrets/secure-file-store.d.ts +26 -0
- package/dist/plugin-sdk/src/subscription/provider.d.ts +5 -3
- package/dist/plugin-sdk/synology-chat.js +36 -36
- package/dist/plugin-sdk/talk-voice.js +4 -4
- package/dist/plugin-sdk/telegram.js +35 -35
- package/dist/plugin-sdk/text-runtime.js +7 -7
- package/dist/plugin-sdk/thread-ownership.js +4 -4
- package/dist/plugin-sdk/tlon.js +36 -36
- package/dist/plugin-sdk/twitch.js +35 -35
- package/dist/plugin-sdk/voice-call.js +35 -35
- package/dist/plugin-sdk/whatsapp.js +35 -35
- package/dist/plugin-sdk/zalo.js +38 -38
- package/dist/plugin-sdk/zalouser.js +38 -38
- package/dist/plugins/runtime/index.d.ts +1 -1
- package/dist/plugins/runtime/index.js +35 -35
- package/dist/plugins-DF5FaTO0.js +111 -0
- package/dist/plugins-cli-CvTJemqC.js +917 -0
- package/dist/policy-CNXISK_a.js +143 -0
- package/dist/preflight-audio.runtime-RP000oxo.js +116 -0
- package/dist/probe-BkM5pykD.js +21 -0
- package/dist/probe-DKbRTJv5.js +1793 -0
- package/dist/probe-DkrfRsjU.js +47 -0
- package/dist/probe-DpcJ0WeP.js +129 -0
- package/dist/probe-auth-BcNjX8hy.js +40 -0
- package/dist/probe-auth-DhuAb8ls.js +48 -0
- package/dist/probe-wciBj-aL.js +6329 -0
- package/dist/program-C8-p0mW5.js +253 -0
- package/dist/prompt-select-styled-DH0pVoc0.js +2673 -0
- package/dist/provider-api-key-auth.runtime-CAFeIQ1u.js +121 -0
- package/dist/provider-auth-choice-CB_HzdTl.js +126 -0
- package/dist/provider-auth-choice-helpers-hzDkh3f1.js +48 -0
- package/dist/provider-auth-choice-preference-BHCXvNSE.js +189 -0
- package/dist/provider-auth-choice.runtime-Dx4ms2C5.js +123 -0
- package/dist/provider-auth-choices-0KaDNPBQ.js +57 -0
- package/dist/provider-auth-guidance-BaAUiNr_.js +34 -0
- package/dist/provider-auth-result-Bto1bYtS.d.ts +18 -0
- package/dist/provider-models-DxOmeToO.d.ts +867 -0
- package/dist/provider-models-xnyxy6mO.js +2113 -0
- package/dist/provider-ollama-setup-DBYK__ov.d.ts +32 -0
- package/dist/provider-ollama-setup-QzgCxj44.js +314 -0
- package/dist/provider-onboard-B9ionepI.js +139 -0
- package/dist/provider-onboard-CURxJ_UX.d.ts +40 -0
- package/dist/provider-runtime.runtime-4xwmsl5L.js +111 -0
- package/dist/provider-self-hosted-setup-BHd24EDG.js +182 -0
- package/dist/provider-self-hosted-setup-qeY8BYSy.d.ts +61 -0
- package/dist/provider-stream-Chz_EFw3.js +512 -0
- package/dist/provider-usage-C11Q7UwS.js +111 -0
- package/dist/provider-usage-kxemdMp2.js +633 -0
- package/dist/provider-wizard-CanJoxNC.js +152 -0
- package/dist/push-apns-Dsajnm8C.js +1038 -0
- package/dist/pw-ai-DUe4BbH2.js +1867 -0
- package/dist/qmd-manager-CAAFp7qK.js +1570 -0
- package/dist/qr-cli-Bu2jqTPY.js +113 -0
- package/dist/qr-cli-Bu9Z-X48.js +369 -0
- package/dist/reactions-Cpfum4iU.js +281 -0
- package/dist/read-only-account-inspect.discord.runtime-BK0LaMgC.js +116 -0
- package/dist/read-only-account-inspect.slack.runtime-DgKiC5wT.js +116 -0
- package/dist/read-only-account-inspect.telegram.runtime-mxfgFVOU.js +116 -0
- package/dist/redact-snapshot-DD8A4tdd.js +2663 -0
- package/dist/register.agent-DU4FtrU2.js +439 -0
- package/dist/register.backup-8nOYtJqg.js +625 -0
- package/dist/register.configure-DmtecqIH.js +252 -0
- package/dist/register.maintenance-Dir3ulKP.js +574 -0
- package/dist/register.message-Cfl-f3Ju.js +709 -0
- package/dist/register.onboard-Bv7WVzEi.js +192 -0
- package/dist/register.setup-BIyeI8RY.js +212 -0
- package/dist/register.status-health-sessions-C69WQcF4.js +498 -0
- package/dist/register.subclis-B_4KCgTd.js +315 -0
- package/dist/register.subclis-BeXsmgBL.js +13 -0
- package/dist/replies-DdcFUmki.js +110 -0
- package/dist/resolve-channels-DRZqPV5o.js +226 -0
- package/dist/resolve-channels-DxW1kqxA.js +262 -0
- package/dist/resolve-route-DdX-HBVt.js +538 -0
- package/dist/resolve-users-rgCQvkLs.js +143 -0
- package/dist/root-help-QAkoA7GD.js +32 -0
- package/dist/routes-CcJNnwTF.js +7097 -0
- package/dist/rpc-DDUAlBbH.js +67 -0
- package/dist/run-main-D9ci5pn7.js +424 -0
- package/dist/runtime-Bitmi8Er.d.ts +26 -0
- package/dist/runtime-discord-ops.runtime-T4sf7aRB.js +9078 -0
- package/dist/runtime-slack-ops.runtime-BQpP48mC.js +4556 -0
- package/dist/runtime-telegram-ops.runtime-cVO5dqOp.js +133 -0
- package/dist/runtime-whatsapp-login.runtime-DtNx0dSY.js +114 -0
- package/dist/runtime-whatsapp-outbound.runtime-Bw47QbFK.js +117 -0
- package/dist/sandbox-cli-DsFwjbjC.js +535 -0
- package/dist/search-manager-BRAK8fEe.js +16 -0
- package/dist/search-manager-BS5Db0A6.js +386 -0
- package/dist/secrets-cli-D3J46TJp.js +2070 -0
- package/dist/security-cli-B866M9cB.js +575 -0
- package/dist/send-B1pX9_Oc.js +283 -0
- package/dist/send-B2RrLg83.js +100 -0
- package/dist/send-DFnV__Aq.js +1025 -0
- package/dist/send-DZIH6CJt.js +629 -0
- package/dist/send-sl9WnKbW.js +631 -0
- package/dist/server-node-events-BT6egg20.js +506 -0
- package/dist/server-zI_K-D05.js +107 -0
- package/dist/sessions-C8kiAcoJ.js +112 -0
- package/dist/sessions-DLBpp52_.js +218 -0
- package/dist/setup-C7eOzMiC.js +387 -0
- package/dist/setup-CFIMq-Pz.d.ts +37 -0
- package/dist/setup-binary-CcAv8NXz.js +406 -0
- package/dist/setup-browser-C4eRV3h6.js +70 -0
- package/dist/setup-core-BnR486P-.js +143 -0
- package/dist/setup-core-CIswIiu5.js +166 -0
- package/dist/setup-core-CcbcrXXg.js +47 -0
- package/dist/setup-core-nZSw5BSv.js +205 -0
- package/dist/setup-surface-C5iSpT4M.js +490 -0
- package/dist/setup-wizard-helpers-r0J6l8ST.d.ts +203 -0
- package/dist/setup.finalize-adiRfo0U.js +522 -0
- package/dist/setup.gateway-config-BwFWKDfT.js +343 -0
- package/dist/shared-12TimyeF.js +182 -0
- package/dist/shared-9EWO34-k.js +298 -0
- package/dist/shared-B4vUbaRR.js +75 -0
- package/dist/shared-bNWpW3Dd.js +96 -0
- package/dist/shared-lU1y5dvS.js +102 -0
- package/dist/signal-DBlETRu9.js +114 -0
- package/dist/skills-Bio8GwTE.js +20 -0
- package/dist/skills-DE_MXFSN.js +853 -0
- package/dist/skills-cli-BGuW-tKw.js +292 -0
- package/dist/skills-install--rnorIoJ.js +763 -0
- package/dist/skills-status-B08PtBc_.js +21 -0
- package/dist/skills-status-CzM008aB.js +169 -0
- package/dist/slack-C4T53Nc-.js +114 -0
- package/dist/slash-commands.runtime-B7fsD8Be.js +128 -0
- package/dist/slash-dispatch.runtime-t0PAX4vQ.js +141 -0
- package/dist/slash-skill-commands.runtime-DIhPnEfR.js +116 -0
- package/dist/src-DrDirlvw.js +1701 -0
- package/dist/status-Bld14WSA.js +131 -0
- package/dist/status-CgeO4RuH.js +43 -0
- package/dist/status-HlvixAOq.js +606 -0
- package/dist/status-Rom_Lf3c.js +1599 -0
- package/dist/status-TwbMH6Am.js +126 -0
- package/dist/status-json-DMW7cmuK.js +288 -0
- package/dist/status.link-channel-V4LkB6Gq.js +143 -0
- package/dist/status.scan.deps.runtime-BE3X-dcP.js +126 -0
- package/dist/status.scan.runtime-BxVY4mty.js +119 -0
- package/dist/status.summary-CzLM0vVr.js +592 -0
- package/dist/status.summary.runtime-BSBnHZ1Q.js +118 -0
- package/dist/status.update-BxblMS7P.js +77 -0
- package/dist/subagent-orphan-recovery-BpRPryEj.js +307 -0
- package/dist/subagent-registry-runtime-DYYU5p3X.js +111 -0
- package/dist/subscription-CpFdxuFS.js +33 -0
- package/dist/subscription-DaA1urx-.js +102 -0
- package/dist/subscription-cli-Bvto9EmO.js +134 -0
- package/dist/synology-chat-3nwk-Nj0.js +297 -0
- package/dist/system-cli-BvNps8sl.js +94 -0
- package/dist/telegram/audit.d.ts +1 -1
- package/dist/telegram/audit.js +1 -1
- package/dist/telegram/token.d.ts +1 -1
- package/dist/telegram/token.js +35 -35
- package/dist/telegram-RtKXoEsF.js +114 -0
- package/dist/text-chunking-BD5mQe2R.js +84 -0
- package/dist/text-chunking-DDUU_vAF.d.ts +79 -0
- package/dist/tlon-z-kYmJE-.js +433 -0
- package/dist/tui-cli-CzSK08Rh.js +137 -0
- package/dist/tui-wV7R1Tlc.js +3834 -0
- package/dist/types-2H_e7eWT.d.ts +45 -0
- package/dist/types-ZKnGUchG.d.ts +22692 -0
- package/dist/types.base-BFiQZ4J9.d.ts +188 -0
- package/dist/ui-BWVHreeR.js +31 -0
- package/dist/update-D1Wgh1Tj.js +1036 -0
- package/dist/update-cli-CZh99uyY.js +1503 -0
- package/dist/update-offset-store-D5xTdUr0.js +112 -0
- package/dist/update-runner-GbKfoCHs.js +1496 -0
- package/dist/upsert-with-lock-BZU7Le8n.js +33 -0
- package/dist/usage-Czgwvg0h.js +115 -0
- package/dist/web-CMczmL90.js +112 -0
- package/dist/web-shared-B5Q0mIJq.d.ts +45 -0
- package/dist/webhook-request-guards-CsKDhZJr.d.ts +76 -0
- package/dist/webhook-targets-BSmFtesN.js +181 -0
- package/dist/webhook-targets-CjxuEE9C.d.ts +106 -0
- package/dist/webhooks-cli-Wl9y6AWW.js +350 -0
- package/dist/whatsapp-VzRW8MdR.js +114 -0
- package/dist/whatsapp-actions-Cg1Wxv8W.js +167 -0
- package/dist/workspace-DJ_S272u.js +484 -0
- package/dist/workspace-DbZSqjw0.js +289 -0
- package/dist/workspace-cli-D93DLmAh.js +154 -0
- package/dist/workspace-dirs-CGeIPpGN.js +2003 -0
- package/dist/zalo-CK2dlGmu.d.ts +9 -0
- package/dist/zalo-Db7s2boL.js +415 -0
- package/dist/zalouser-Jh5YTJX3.js +30911 -0
- package/extensions/discord/src/monitor/allow-list.ts +8 -1
- package/extensions/discord/src/monitor/message-handler.preflight.ts +4 -1
- package/package.json +1 -1
- package/dist/accounts-CS8U4v8C.js +0 -114
- package/dist/accounts-gLr-Udmt.d.ts +0 -103
- package/dist/acp-cli-BGT0jXcC.js +0 -2093
- package/dist/actions.runtime-BfckTw6c.js +0 -119
- package/dist/actions.runtime-Cl9mBfqH.js +0 -133
- package/dist/agent-scope-C-YmLnnb.js +0 -208
- package/dist/agents-CydD54p8.js +0 -222
- package/dist/agents-DpQsZO6O.js +0 -853
- package/dist/agents.config-XU7IsYE-.js +0 -121
- package/dist/agents.config-ssoQXuvF.js +0 -17
- package/dist/allow-list-Cfn6lmMK.js +0 -81
- package/dist/allowlist-CCYXVpM9.js +0 -142
- package/dist/api-BoXoFKxy.js +0 -117
- package/dist/audit-Bv05N5o9.js +0 -787
- package/dist/audit-CIWW1Aqm.js +0 -54
- package/dist/audit-channel.collect.runtime-Bi7yrdcO.js +0 -605
- package/dist/audit-channel.runtime-C_NDweiW.js +0 -121
- package/dist/audit-extra.async-Dp7OKSXg.js +0 -813
- package/dist/audit-membership-runtime-B8FQ6VtN.js +0 -162
- package/dist/audit.deep.runtime-CXhobL6b.js +0 -25
- package/dist/audit.nondeep.runtime-CrEm3T16.js +0 -832
- package/dist/audit.runtime-CJPKj1Zg.js +0 -118
- package/dist/auth-Byfp0flq.js +0 -101
- package/dist/auth-choice-BgOjdeXN.js +0 -507
- package/dist/auth-choice-CD1Heq0M.js +0 -122
- package/dist/auth-choice-ePNfg0iQ.js +0 -268
- package/dist/auth-choice-options-BlewQWI0.js +0 -123
- package/dist/auth-choice-prompt-BP2b6aXz.js +0 -36
- package/dist/auth-choice-prompt-Cmwl4n97.js +0 -115
- package/dist/auth-choice.apply-helpers-Dq-nxuuX.js +0 -66
- package/dist/auth-choice.plugin-providers.runtime-B23kOUzQ.js +0 -119
- package/dist/auth-profiles-1kPLbBwI.js +0 -127823
- package/dist/auth-profiles.runtime-DAfSjku1.js +0 -116
- package/dist/banner-DeOsobLO.js +0 -342
- package/dist/bluebubbles-BsLGedBM.js +0 -64
- package/dist/bluebubbles-U2sAfO4_.d.ts +0 -6
- package/dist/bot-DW12K3bO.d.ts +0 -478
- package/dist/brave-BoWimrLe.js +0 -24
- package/dist/browser-cli-D_S3wEYE.js +0 -1494
- package/dist/call-ByEzDJ1_.js +0 -640
- package/dist/call-CHCWVg-O.js +0 -39
- package/dist/channel-3VC0oOMu.js +0 -214
- package/dist/channel-B9fCBPiS.js +0 -207
- package/dist/channel-B9q775cM.js +0 -562
- package/dist/channel-BG3UK54j.js +0 -803
- package/dist/channel-BRQAdMML.js +0 -352
- package/dist/channel-BmlLp933.js +0 -1321
- package/dist/channel-By6KvdTG.js +0 -920
- package/dist/channel-C8rRsdf6.js +0 -226
- package/dist/channel-CLEDBbXE.js +0 -943
- package/dist/channel-CMvBAG7o.js +0 -306
- package/dist/channel-CmlxxjHY.js +0 -1598
- package/dist/channel-CqG6_xN0.js +0 -949
- package/dist/channel-DNueHKs92.js +0 -316
- package/dist/channel-DUtyN7BX.js +0 -4681
- package/dist/channel-DWD6GrfZ.js +0 -538
- package/dist/channel-DaRYMYzj.js +0 -619
- package/dist/channel-Dj6BgLp8.js +0 -575
- package/dist/channel-account-context-Ba3u5D21.js +0 -103
- package/dist/channel-crabk6Em.js +0 -542
- package/dist/channel-i8uqQaK2.js +0 -497
- package/dist/channel-options-xljvwHS2.js +0 -50
- package/dist/channel-plugin-ids-DAgknSG4.js +0 -26
- package/dist/channel-summary-dHTMCG75.js +0 -111
- package/dist/channel-xVWQ96Ni.js +0 -397
- package/dist/channel.runtime-B6PoZ4BV.js +0 -182
- package/dist/channel.runtime-BPZmo57e.js +0 -404
- package/dist/channel.runtime-B_1uGR-U.js +0 -199
- package/dist/channel.runtime-BiXnPU0d.js +0 -218
- package/dist/channel.runtime-BpvDc9sv.js +0 -870
- package/dist/channel.runtime-CUua3W80.js +0 -418
- package/dist/channel.runtime-CaCBTd0A.js +0 -179
- package/dist/channel.runtime-D0FfYvUj.js +0 -4011
- package/dist/channel.runtime-DhoJtpvJ.js +0 -241
- package/dist/channel.runtime-Kj9EXNE0.js +0 -127
- package/dist/channel.runtime-r4tPuPyh.js +0 -171
- package/dist/channel.setup-B7d_grfe.js +0 -6
- package/dist/channel.setup-C0vu1fhi.js +0 -9
- package/dist/channel.setup-CAI0FNHj.js +0 -11
- package/dist/channel.setup-CkDVwv5R.js +0 -57
- package/dist/channel.setup-Cpd00YqQ.js +0 -8
- package/dist/channel.setup-DbBz1-WT.js +0 -9
- package/dist/channel.setup-GZnAvD9g.js +0 -8
- package/dist/channels-5H484RSw.js +0 -1118
- package/dist/channels-BnPudfyx.js +0 -404
- package/dist/channels-cli-WIC-QeH_.js +0 -291
- package/dist/channels-status-issues-RDmzovJU.js +0 -16
- package/dist/clawbot-cli-BgutNwf8.js +0 -118
- package/dist/cleanup-utils-DBl1Aij1.js +0 -96
- package/dist/cli-1P7u6zqu.js +0 -154
- package/dist/command-registry-B8jovrws.js +0 -232
- package/dist/command-registry-DtDl1FVm.js +0 -14
- package/dist/command-secret-gateway-BgUo3FxJ.js +0 -111
- package/dist/compact.runtime-CXbXM0AU.js +0 -116
- package/dist/completion-cli-Cik_owAE.js +0 -17
- package/dist/completion-cli-RU3P2RSl.js +0 -445
- package/dist/config-5HUpB1L1.js +0 -31
- package/dist/config-cli-QHaUHoZI.js +0 -433
- package/dist/config-guard-C9Sn3pE-.js +0 -118
- package/dist/config-sW57gztj.js +0 -44
- package/dist/config-validation-5LkjIKNt.js +0 -262
- package/dist/config-value-CtTWALxG.js +0 -132
- package/dist/configure-BmR2TPLf.js +0 -243
- package/dist/configure-DaLN-5xM.js +0 -1100
- package/dist/control-ui-assets-CH3MYmAo.js +0 -232
- package/dist/control-ui-shared-CA77PTml.js +0 -29
- package/dist/core-CvDzLs7B.js +0 -150
- package/dist/core-dPA4nFkn.d.ts +0 -87
- package/dist/cron-cli-tguLpzyq.js +0 -639
- package/dist/daemon-cli-ptosOkL8.js +0 -339
- package/dist/daemon-install-DzU4EnVa.js +0 -180
- package/dist/deliver-DwxFoHM3.js +0 -111
- package/dist/deliver-runtime-DOdDyaPI.js +0 -111
- package/dist/device-id-cli-GopvlxxZ.js +0 -52
- package/dist/device-identity-CRfhC3_s.js +0 -365
- package/dist/devices-cli-ain7ESqU.js +0 -342
- package/dist/diagnostic-D96Xaqrj.js +0 -310
- package/dist/directory-cli-fh1UxGgY.js +0 -311
- package/dist/directory-config-helpers-CpU1oflo.d.ts +0 -38
- package/dist/directory.static-CKjJUNGl.js +0 -44
- package/dist/discord-CflhwDEM.js +0 -114
- package/dist/discovery-x0ZqY4AB.js +0 -48
- package/dist/dm-policy-shared-73A52W6E.d.ts +0 -95
- package/dist/dns-cli-DCHyKjGf.js +0 -217
- package/dist/docs-cli-D3OoqYSP.js +0 -174
- package/dist/doctor-completion-Bq2eP87s.js +0 -90
- package/dist/doctor-config-flow-D8XRG9Ku.js +0 -2437
- package/dist/doctor-config-flow-DGiF1HGc.js +0 -112
- package/dist/enable-0QSF4YGH.js +0 -24
- package/dist/exec-approvals-cli-Bncym0Gd.js +0 -421
- package/dist/feishu-B5JDcyF9.d.ts +0 -36
- package/dist/gateway-cli-DYscsmA-.js +0 -26437
- package/dist/gateway-install-token-CNv17ac9.js +0 -163
- package/dist/gateway-rpc-BGC1Rxvg.js +0 -26
- package/dist/gateway-runtime-D89mSQPB.js +0 -69
- package/dist/git-commit-CeLH5Ozm.js +0 -2
- package/dist/git-commit-DUKRiCP-.js +0 -177
- package/dist/googlechat-BgXeXjd1.js +0 -307
- package/dist/googlechat-De-T7C31.d.ts +0 -12
- package/dist/group-access-Deh1tVNr.d.ts +0 -61
- package/dist/health-BEjzWwaB.js +0 -570
- package/dist/health-FjqrWQL6.js +0 -113
- package/dist/heartbeat-summary-CfdSA9M1.js +0 -57
- package/dist/help-BZeVprq1.js +0 -81
- package/dist/hooks-B5pYs_d7.d.ts +0 -6
- package/dist/hooks-cli-B7uGJs2O.js +0 -1000
- package/dist/hooks-status-CfceaUSg.js +0 -78
- package/dist/http-registry-C-KXqwnj.d.ts +0 -20
- package/dist/identity-file-sshkKKIr.js +0 -60
- package/dist/image-generation-CafM5hZh.d.ts +0 -9
- package/dist/imessage-BcV3WGx_.js +0 -31
- package/dist/imessage-Dhje7Ty-.js +0 -115
- package/dist/inbound-reply-dispatch-C73_7SOl.js +0 -71
- package/dist/inbound-reply-dispatch-DmL0KWLe.d.ts +0 -72
- package/dist/install-target-D7NRhfzc.js +0 -574
- package/dist/installs-Bj6jblqc.js +0 -532
- package/dist/io-CMfWWPXQ.js +0 -9738
- package/dist/io-CV844hAM.js +0 -29
- package/dist/irc-DKi1fDYI.js +0 -672
- package/dist/library-rygTG3oA.js +0 -112
- package/dist/lifecycle-core-BPlvShWY.js +0 -382
- package/dist/line-CGsemKWJ.js +0 -530
- package/dist/line-CKU3ER-n.d.ts +0 -75
- package/dist/llm-slug-generator-DlhVyMqT.js +0 -67
- package/dist/logging-5wu9k6w4.js +0 -30
- package/dist/logging-CxP9suT8.js +0 -13
- package/dist/login-qr-BcDsiwHs.js +0 -233
- package/dist/login-qr-Y8pJ5yV4.js +0 -112
- package/dist/logs-cli-XI9oVXpH.js +0 -256
- package/dist/manager-runtime-DkIlXBhD.js +0 -111
- package/dist/manager.runtime-Q0q2rJCC.js +0 -715
- package/dist/manifest-registry-DAd0SRAP.js +0 -1329
- package/dist/matrix-BI0DBBrG.js +0 -1495
- package/dist/matrix-DiABGjJR.js +0 -1269
- package/dist/matrix-fC6NrFM5.d.ts +0 -68
- package/dist/mcp-cli-BOyn_DLL.js +0 -87
- package/dist/media-understanding.runtime-DjUa7Dka.js +0 -116
- package/dist/memory-cli-CJd_vl-Y.js +0 -111
- package/dist/memory-search-CEEItIFR.js +0 -17
- package/dist/memory-search-Cv1SBrn7.js +0 -204
- package/dist/method-scopes-CQE7-bZ-.js +0 -2452
- package/dist/model-auth-markers-B1bbs9Qd.d.ts +0 -20
- package/dist/model-picker-D6_89XHg.js +0 -112
- package/dist/model-picker-Svaw-APs.js +0 -390
- package/dist/model-picker.runtime-Chi9nV7A.js +0 -125
- package/dist/model-selection-hL8i1Jbs.js +0 -653
- package/dist/model-suppression.runtime-DjWJZ0X-.js +0 -116
- package/dist/models-7qj1dG_W.js +0 -118
- package/dist/models-BPOB_xJF.js +0 -2514
- package/dist/models-cli-DdlOVUjS.js +0 -309
- package/dist/models-config-CBqUS-jX.js +0 -111
- package/dist/models-config.providers.discovery-BKB5JH9M.d.ts +0 -18
- package/dist/moldclaw-root-D6PbhbZk.js +0 -88
- package/dist/monitor-BPYhkEqF.js +0 -782
- package/dist/monitor-BuTcQ24j.js +0 -3468
- package/dist/monitor-CuXvNhFh.js +0 -113
- package/dist/monitor-D-TqSIHF.js +0 -6823
- package/dist/monitor-DRSgo9u2.js +0 -3076
- package/dist/monitor-DcHch39z.js +0 -772
- package/dist/monitor-DsHBMrXp.js +0 -115
- package/dist/monitor-shared-CL8T4gt1.js +0 -444
- package/dist/msteams-7FMwTvQG.js +0 -852
- package/dist/node-cli-BCjaSCZM.js +0 -2503
- package/dist/node-resolve-D5Hvcgyx.js +0 -835
- package/dist/nodes-cli-Dd_SNbkt.js +0 -1380
- package/dist/nostr-D8scBiYq.d.ts +0 -7
- package/dist/nostr-DBTFTxKs.js +0 -8744
- package/dist/npm-resolution-CYfb3MHG.js +0 -60
- package/dist/oauth-env-zPt5RywA.js +0 -10
- package/dist/onboard-BEFQQeig.js +0 -25
- package/dist/onboard-CJHNyxJh.js +0 -48
- package/dist/onboard-D_3UeLEN.js +0 -589
- package/dist/onboard-channels-B_JL0Djc.js +0 -1241
- package/dist/onboard-channels-CqZzHt2C.js +0 -205
- package/dist/onboard-custom-CER3Ggbq.js +0 -571
- package/dist/onboard-custom-bNRdGECb.js +0 -114
- package/dist/onboard-helpers-BK0Hsb7Y.js +0 -335
- package/dist/onboard-helpers-CXZ5RPoR.js +0 -113
- package/dist/onboard-hooks-1NsxEDjH.js +0 -72
- package/dist/onboard-remote-DuKhC_7W.js +0 -117
- package/dist/onboard-remote-OwRcDuB3.js +0 -181
- package/dist/onboard-search-Cy8dOq2W.js +0 -302
- package/dist/onboard-skills-D5phRa6r.js +0 -117
- package/dist/onboard-skills-c9qWCNe9.js +0 -133
- package/dist/outbound-media-CgNYEQWb.d.ts +0 -11
- package/dist/outbound-media-DYRO2vTD.js +0 -11
- package/dist/pairing-access-Dsiu5Mvl.d.ts +0 -21
- package/dist/pairing-cli-BOnv0TYn.js +0 -217
- package/dist/perplexity-EZwC3y2b.js +0 -24
- package/dist/persistent-dedupe-DMLOqJ23.d.ts +0 -26
- package/dist/pi-model-discovery-runtime-BToY3A6K.js +0 -111
- package/dist/pi-tools.before-tool-call.runtime-D_acPtld.js +0 -381
- package/dist/plugin-install-CgJpSjYd.js +0 -184
- package/dist/plugin-install-Cl1A4EF6.js +0 -117
- package/dist/plugin-install-plan-Dc2Z4DeU.js +0 -49
- package/dist/plugin-registry-B1UaWrQD.js +0 -49
- package/dist/plugin-registry-Cy8biwnn.js +0 -113
- package/dist/plugins-CXwvg50F.js +0 -111
- package/dist/plugins-cli-Uvzp2aYV.js +0 -917
- package/dist/policy-DsMBbEe7.js +0 -143
- package/dist/preflight-audio.runtime-hWsZIYvc.js +0 -116
- package/dist/probe-CNsSf1Uf.js +0 -6329
- package/dist/probe-CqOIrPhb.js +0 -47
- package/dist/probe-DH6gDw-h.js +0 -129
- package/dist/probe-DM16PLf4.js +0 -21
- package/dist/probe-DvAEEWYr.js +0 -1793
- package/dist/probe-auth-COfgCble.js +0 -48
- package/dist/probe-auth-I_5TX1Eh.js +0 -40
- package/dist/program-Dz80sgTU.js +0 -253
- package/dist/prompt-select-styled-wQehwFxK.js +0 -2673
- package/dist/provider-api-key-auth.runtime-BR9GU4ya.js +0 -121
- package/dist/provider-auth-choice-CdhA84kr.js +0 -126
- package/dist/provider-auth-choice-helpers-kabp_0zA.js +0 -48
- package/dist/provider-auth-choice-preference-se3zAM_2.js +0 -189
- package/dist/provider-auth-choice.runtime-BMc8-xNQ.js +0 -123
- package/dist/provider-auth-choices-CYsCViGi.js +0 -57
- package/dist/provider-auth-guidance-CMjUWlNf.js +0 -34
- package/dist/provider-auth-result-Cw6qIhO-.d.ts +0 -18
- package/dist/provider-models-BCId_Lfu.js +0 -2113
- package/dist/provider-models-Ok-DrSiY.d.ts +0 -867
- package/dist/provider-ollama-setup-B6XJZ0So.js +0 -314
- package/dist/provider-ollama-setup-lGDdTl0b.d.ts +0 -32
- package/dist/provider-onboard-CSPi7jOK.d.ts +0 -40
- package/dist/provider-onboard-Ca0TaNud.js +0 -139
- package/dist/provider-runtime.runtime-DwwkHw_7.js +0 -111
- package/dist/provider-self-hosted-setup-BEKLVGpj.js +0 -182
- package/dist/provider-self-hosted-setup-Df91By-J.d.ts +0 -61
- package/dist/provider-stream-DrUD69ai.js +0 -512
- package/dist/provider-usage-BgKHCnjr.js +0 -111
- package/dist/provider-usage-D8EZpFz9.js +0 -633
- package/dist/provider-wizard-DMdb-zj_.js +0 -152
- package/dist/push-apns-BPH6d4VV.js +0 -1038
- package/dist/pw-ai-DttfldtL.js +0 -1867
- package/dist/qmd-manager-CybcDUfk.js +0 -1570
- package/dist/qr-cli-8NcmJ8Ft.js +0 -369
- package/dist/qr-cli-DWe0Our3.js +0 -113
- package/dist/reactions-D6N0LR16.js +0 -281
- package/dist/read-only-account-inspect.discord.runtime-CqUWTRfl.js +0 -116
- package/dist/read-only-account-inspect.slack.runtime-9-jpln3q.js +0 -116
- package/dist/read-only-account-inspect.telegram.runtime-EKPI1D7n.js +0 -116
- package/dist/redact-snapshot-DwJEIVk9.js +0 -2663
- package/dist/register.agent-D3YdDirP.js +0 -439
- package/dist/register.backup-dR27qCuo.js +0 -625
- package/dist/register.configure-BjFhkkka.js +0 -252
- package/dist/register.maintenance-DiMQJIOa.js +0 -574
- package/dist/register.message-CdZsKYH1.js +0 -709
- package/dist/register.onboard-B0rV1eaO.js +0 -192
- package/dist/register.setup-wKMvohzo.js +0 -212
- package/dist/register.status-health-sessions-BJ68m6pt.js +0 -498
- package/dist/register.subclis-CnnrWt2a.js +0 -315
- package/dist/register.subclis-lSvTkC6z.js +0 -13
- package/dist/replies-BABt9b48.js +0 -110
- package/dist/resolve-channels-BqZFl2Ux.js +0 -262
- package/dist/resolve-channels-DjQLXb7B.js +0 -226
- package/dist/resolve-route-CSHDsa_m.js +0 -538
- package/dist/resolve-users-BG6HaSR5.js +0 -143
- package/dist/root-help-ohmaCyC_.js +0 -32
- package/dist/routes-4k2kpvoT.js +0 -7097
- package/dist/rpc-Cnwn4Q6L.js +0 -67
- package/dist/run-main-VYlacKA0.js +0 -424
- package/dist/runtime-D61jzMiI.d.ts +0 -26
- package/dist/runtime-discord-ops.runtime-DafrU-rI.js +0 -9078
- package/dist/runtime-slack-ops.runtime-CdXBKXwd.js +0 -4556
- package/dist/runtime-telegram-ops.runtime-B12sF7gE.js +0 -133
- package/dist/runtime-whatsapp-login.runtime-CqEudH37.js +0 -114
- package/dist/runtime-whatsapp-outbound.runtime-D5m2qyn-.js +0 -117
- package/dist/sandbox-cli-CHJiEWXB.js +0 -535
- package/dist/search-manager-BtNC3-i_.js +0 -16
- package/dist/search-manager-C7J7B3_a.js +0 -386
- package/dist/secrets-cli-C6yIWBbN.js +0 -2070
- package/dist/security-cli-BVu9BkjD.js +0 -575
- package/dist/send-BSreC7rr.js +0 -631
- package/dist/send-BsLHQG_B.js +0 -1025
- package/dist/send-BuNhp8PH.js +0 -283
- package/dist/send-DOCswVar.js +0 -100
- package/dist/send-Dl0LLErk.js +0 -629
- package/dist/server-node-events-Bq2067EG.js +0 -506
- package/dist/server-y38L7N5H.js +0 -107
- package/dist/sessions-BV8gXURR.js +0 -112
- package/dist/sessions-dl1Kc-Ci.js +0 -218
- package/dist/setup-BSPXdMuK.d.ts +0 -37
- package/dist/setup-DGszQH0_.js +0 -387
- package/dist/setup-binary-C17YnmA8.js +0 -406
- package/dist/setup-browser-CPx-nEsr.js +0 -70
- package/dist/setup-core-BByHN1ME.js +0 -143
- package/dist/setup-core-C0KPlBmL.js +0 -47
- package/dist/setup-core-Cq37G6of.js +0 -166
- package/dist/setup-core-uO84_Y75.js +0 -205
- package/dist/setup-surface-BEMi7Rmb.js +0 -490
- package/dist/setup-wizard-helpers-Ck9wDR0b.d.ts +0 -203
- package/dist/setup.finalize-BzPBa8zW.js +0 -522
- package/dist/setup.gateway-config-DdwkF-8e.js +0 -343
- package/dist/shared-BCw4SKjB.js +0 -96
- package/dist/shared-CjNzsULP.js +0 -75
- package/dist/shared-Cu1BE7ZE.js +0 -298
- package/dist/shared-DSClmyUn.js +0 -182
- package/dist/shared-DyJdGH6y.js +0 -102
- package/dist/signal-Dyv4NZsB.js +0 -114
- package/dist/skills-CbB5b27M.js +0 -853
- package/dist/skills-CnfI7Szw.js +0 -20
- package/dist/skills-cli-CavB1f_3.js +0 -292
- package/dist/skills-install-B1OBdgd0.js +0 -763
- package/dist/skills-status-B3gAmIbW.js +0 -169
- package/dist/skills-status-DrHhFgU9.js +0 -21
- package/dist/slack-BRzqnoAz.js +0 -114
- package/dist/slash-commands.runtime-BK88kgds.js +0 -128
- package/dist/slash-dispatch.runtime-COGywwJE.js +0 -141
- package/dist/slash-skill-commands.runtime-Ti4brxgh.js +0 -116
- package/dist/src-DUR6OQxI.js +0 -1701
- package/dist/status-C6dgQY9a.js +0 -131
- package/dist/status-CNK0Q7QH.js +0 -606
- package/dist/status-DBcX0DSC.js +0 -43
- package/dist/status-DKgFgbwv.js +0 -1599
- package/dist/status-Wn5lhNAc.js +0 -126
- package/dist/status-json-D2EkWqAl.js +0 -288
- package/dist/status.link-channel-D3ULIdEa.js +0 -143
- package/dist/status.scan.deps.runtime-BsjWTAm4.js +0 -126
- package/dist/status.scan.runtime-D4HbzROD.js +0 -119
- package/dist/status.summary-C3YxPrDK.js +0 -592
- package/dist/status.summary.runtime-DAkXPSaK.js +0 -118
- package/dist/status.update-B4NnN9P1.js +0 -77
- package/dist/subagent-orphan-recovery-QiQEBv36.js +0 -307
- package/dist/subagent-registry-runtime-BJatPQFK.js +0 -111
- package/dist/subscription-BhZORXN9.js +0 -100
- package/dist/subscription-QEUjQRMv.js +0 -33
- package/dist/subscription-cli-HrULlAgc.js +0 -134
- package/dist/synology-chat-DB76GWMN.js +0 -297
- package/dist/system-cli-D8jDwWuL.js +0 -94
- package/dist/telegram-BHiiqKkQ.js +0 -114
- package/dist/text-chunking-Baonm9Lu.js +0 -84
- package/dist/text-chunking-DzB11ONk.d.ts +0 -79
- package/dist/tlon-DLESxNgD.js +0 -433
- package/dist/tui-C75zi2Cl.js +0 -3834
- package/dist/tui-cli-DFwx5e6i.js +0 -137
- package/dist/types-BKldC9YN.d.ts +0 -22692
- package/dist/types-MeyueBE0.d.ts +0 -45
- package/dist/types.base-Cw0-zIvE.d.ts +0 -188
- package/dist/ui-B55NOIB6.js +0 -31
- package/dist/update--ojavYQ4.js +0 -1036
- package/dist/update-cli-Cvj5aWYM.js +0 -1503
- package/dist/update-offset-store-upatuWwX.js +0 -112
- package/dist/update-runner-DHkY_-76.js +0 -1496
- package/dist/upsert-with-lock-C171GLaR.js +0 -33
- package/dist/usage-N3bxnbmt.js +0 -115
- package/dist/web-RdvT7gKa.js +0 -112
- package/dist/web-shared-C2qHVxw1.d.ts +0 -45
- package/dist/webhook-request-guards-CosLyl01.d.ts +0 -76
- package/dist/webhook-targets-Bfnag-du.js +0 -181
- package/dist/webhook-targets-DP_EkQa4.d.ts +0 -106
- package/dist/webhooks-cli-ZpnXrq7G.js +0 -350
- package/dist/whatsapp-DNTAyZHt.js +0 -114
- package/dist/whatsapp-actions-o1zKQzKZ.js +0 -167
- package/dist/workspace-CpWi5wPr.js +0 -479
- package/dist/workspace-Ii7aRS7c.js +0 -289
- package/dist/workspace-dirs-x10McA9t.js +0 -2003
- package/dist/zalo-C9OQRYRw.d.ts +0 -9
- package/dist/zalo-zm_bYCKg.js +0 -415
- package/dist/zalouser-CvVEUvc5.js +0 -30911
- /package/dist/{account-id-B3YSn4hl.d.ts → account-id-B8ce6G_4.d.ts} +0 -0
- /package/dist/{acpx-CnNv70m2.d.ts → acpx-Ci50I9T2.d.ts} +0 -0
- /package/dist/{agent-media-payload-DE2pEcsz.d.ts → agent-media-payload-en-gS5p6.d.ts} +0 -0
- /package/dist/{allow-from-DPpHnT2A.d.ts → allow-from-cMeQ47Ot.d.ts} +0 -0
- /package/dist/{allowlist-resolution-CLFiZ6nE.d.ts → allowlist-resolution-DoAWbfXV.d.ts} +0 -0
- /package/dist/{bluebubbles-Duhu-Jer.d.ts → bluebubbles-C6yYmUl0.d.ts} +0 -0
- /package/dist/{boolean-param-BhFjB3gp.d.ts → boolean-param-CdO2TFTk.d.ts} +0 -0
- /package/dist/{channel-config-schema-DnnVMdjR.d.ts → channel-config-schema-Chp38wel.d.ts} +0 -0
- /package/dist/{channel-policy-Baq-Z06b.d.ts → channel-policy-g2h6AbYQ.d.ts} +0 -0
- /package/dist/{chat-type-DpiBgwuG.d.ts → chat-type-BLt59pPT.d.ts} +0 -0
- /package/dist/{command-format-vi4xq8e8.d.ts → command-format-BDJC05Jp.d.ts} +0 -0
- /package/dist/{diffs-DK7fVSDo.d.ts → diffs-D_iNKCyn.d.ts} +0 -0
- /package/dist/{directory-runtime-BTLPaysA.d.ts → directory-runtime-DhMex6HY.d.ts} +0 -0
- /package/dist/{exec-C01wtBHu.d.ts → exec-pjfUY4KM.d.ts} +0 -0
- /package/dist/{gaxios-fetch-compat-wZ38b3w3.js → gaxios-fetch-compat-B_vtINdV.js} +0 -0
- /package/dist/{history-CwXuP2TW.d.ts → history-aqSS5VGQ.d.ts} +0 -0
- /package/dist/{inbound-envelope-SggrBs9m.d.ts → inbound-envelope-C5hWuZod.d.ts} +0 -0
- /package/dist/{index-apAZHsDo.d.ts → index-DXVQFYGX.d.ts} +0 -0
- /package/dist/{json-store-r75IZGk9.d.ts → json-store-UnqQ5aV3.d.ts} +0 -0
- /package/dist/{keyed-async-queue-DHIr7yNe.d.ts → keyed-async-queue-guucpLw3.d.ts} +0 -0
- /package/dist/{links-HeQ3r_L0.d.ts → links-Bar0meEK.d.ts} +0 -0
- /package/dist/{markdown-to-line-CDb4Jy3V.d.ts → markdown-to-line-D8uH_KOj.d.ts} +0 -0
- /package/dist/{mattermost-DtCsxpgg.d.ts → mattermost-xl7jAFJL.d.ts} +0 -0
- /package/dist/{net-BATPDwdQ.d.ts → net-rGOKGds6.d.ts} +0 -0
- /package/dist/{nextcloud-talk-Bb2wHOwp.d.ts → nextcloud-talk-De2CZ9dV.d.ts} +0 -0
- /package/dist/{oauth-utils-u567CLT0.d.ts → oauth-utils-DzN1AlEH.d.ts} +0 -0
- /package/dist/{parse-finite-number-l3tNlrZh.d.ts → parse-finite-number-odgyqhi0.d.ts} +0 -0
- /package/dist/{provider-usage.types-C6061OVN.d.ts → provider-usage.types-EDE9o-H_.d.ts} +0 -0
- /package/dist/{reply-history-BDsFnZFl.d.ts → reply-history-CVuU31xe.d.ts} +0 -0
- /package/dist/{reply-payload-CCvM4W9u.d.ts → reply-payload-CHkpBYwL.d.ts} +0 -0
- /package/dist/{request-url-C54l4-xC.d.ts → request-url-DHisbiHY.d.ts} +0 -0
- /package/dist/{run-command-D3RqWcHu.d.ts → run-command-y0Cndsb1.d.ts} +0 -0
- /package/dist/{secret-input-schema-BLBt-NAP.d.ts → secret-input-schema-b1vpYDQN.d.ts} +0 -0
- /package/dist/{session-key-BQ2-bR-9.d.ts → session-key-DTHQl57f.d.ts} +0 -0
- /package/dist/{ssh-config-C4mcH9Ly.js → ssh-config-hEHBfU2_.js} +0 -0
- /package/dist/{testing-DLkhGsoz.d.ts → testing-DszuZXgK.d.ts} +0 -0
- /package/dist/{thinking-DRkjX18p.d.ts → thinking-IwXTGSeT.d.ts} +0 -0
- /package/dist/{tool-send-CMMD1uDu.d.ts → tool-send-DWHRmKpz.d.ts} +0 -0
- /package/dist/{vllm-defaults-CcGuf4hL.d.ts → vllm-defaults-CrxZgE6-.d.ts} +0 -0
- /package/dist/{wait-Daog8bxM.d.ts → wait-wDWw_MTI.d.ts} +0 -0
- /package/dist/{webhook-memory-guards-C5MrExwT.d.ts → webhook-memory-guards-DreORuJy.d.ts} +0 -0
- /package/dist/{windows-spawn-j2l-dqu8.d.ts → windows-spawn-BIzH92x2.d.ts} +0 -0
- /package/dist/{zod-schema.agent-runtime-krMrBnIn.d.ts → zod-schema.agent-runtime-CP2rmis3.d.ts} +0 -0
- /package/dist/{zod-schema.core-BNDieZDZ.d.ts → zod-schema.core-Foi1tYwi.d.ts} +0 -0
package/dist/monitor-DRSgo9u2.js
DELETED
|
@@ -1,3076 +0,0 @@
|
|
|
1
|
-
import { Ah as createScopedPairingAccess, Hg as logAckFailure, Nd as resolveDmGroupAccessWithLists, Od as DM_GROUP_ACCESS_REASON, Oh as issuePairingChallenge, Ug as logInboundDrop, Uw as resolveControlCommandGate, Wg as logTypingFailure, bh as readWebhookBodyOrReject, gT as mapAllowFromEntries, kd as readStoreAllowFromForDmPolicy, nh as resolveChannelMediaMaxBytes, oS as resolveAckReaction, r_ as recordPendingHistoryEntryIfEnabled, sg as createReplyPrefixOptions, t_ as evictOldHistoryKeys, vh as createWebhookInFlightLimiter, wv as stripMarkdown } from "./auth-profiles-1kPLbBwI.js";
|
|
2
|
-
import { c as normalizeResolvedSecretInputString, l as normalizeSecretInputString } from "./types.secrets-Ca-9L8vU.js";
|
|
3
|
-
import { t as parseFiniteNumber } from "./parse-finite-number-U5TetQpk.js";
|
|
4
|
-
import { t as resolveRequestUrl } from "./request-url-Dr0KbLMK.js";
|
|
5
|
-
import { a as resolveWebhookTargetWithAuthOrRejectSync, c as normalizeWebhookPath, n as registerWebhookTargetWithPluginRoute, s as withResolvedWebhookRequestPipeline } from "./webhook-targets-Bfnag-du.js";
|
|
6
|
-
import { a as isAllowedBlueBubblesSender, b as blueBubblesFetchWithTimeout, d as fetchBlueBubblesServerInfo, f as getCachedBlueBubblesPrivateApiStatus, i as formatBlueBubblesChatTarget, m as isBlueBubblesPrivateApiStatusEnabled, p as isBlueBubblesPrivateApiEnabled, r as extractHandleFromChatGuid, s as normalizeBlueBubblesHandle, u as parseBlueBubblesTarget, v as resolveBlueBubblesAccount, x as buildBlueBubblesApiUrl } from "./monitor-shared-CL8T4gt1.js";
|
|
7
|
-
import { r as warnBlueBubbles, t as getBlueBubblesRuntime } from "./runtime-hOlyZ3ru.js";
|
|
8
|
-
import { fileURLToPath } from "node:url";
|
|
9
|
-
import { constants } from "node:fs";
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
import os from "node:os";
|
|
12
|
-
import fs$1 from "node:fs/promises";
|
|
13
|
-
import crypto, { createHash, timingSafeEqual } from "node:crypto";
|
|
14
|
-
//#region extensions/bluebubbles/src/account-resolve.ts
|
|
15
|
-
function resolveBlueBubblesServerAccount(params) {
|
|
16
|
-
const account = resolveBlueBubblesAccount({
|
|
17
|
-
cfg: params.cfg ?? {},
|
|
18
|
-
accountId: params.accountId
|
|
19
|
-
});
|
|
20
|
-
const baseUrl = normalizeResolvedSecretInputString({
|
|
21
|
-
value: params.serverUrl,
|
|
22
|
-
path: "channels.bluebubbles.serverUrl"
|
|
23
|
-
}) || normalizeResolvedSecretInputString({
|
|
24
|
-
value: account.config.serverUrl,
|
|
25
|
-
path: `channels.bluebubbles.accounts.${account.accountId}.serverUrl`
|
|
26
|
-
});
|
|
27
|
-
const password = normalizeResolvedSecretInputString({
|
|
28
|
-
value: params.password,
|
|
29
|
-
path: "channels.bluebubbles.password"
|
|
30
|
-
}) || normalizeResolvedSecretInputString({
|
|
31
|
-
value: account.config.password,
|
|
32
|
-
path: `channels.bluebubbles.accounts.${account.accountId}.password`
|
|
33
|
-
});
|
|
34
|
-
if (!baseUrl) throw new Error("BlueBubbles serverUrl is required");
|
|
35
|
-
if (!password) throw new Error("BlueBubbles password is required");
|
|
36
|
-
return {
|
|
37
|
-
baseUrl,
|
|
38
|
-
password,
|
|
39
|
-
accountId: account.accountId,
|
|
40
|
-
allowPrivateNetwork: account.config.allowPrivateNetwork === true
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region extensions/bluebubbles/src/multipart.ts
|
|
45
|
-
function concatUint8Arrays(parts) {
|
|
46
|
-
const totalLength = parts.reduce((acc, part) => acc + part.length, 0);
|
|
47
|
-
const body = new Uint8Array(totalLength);
|
|
48
|
-
let offset = 0;
|
|
49
|
-
for (const part of parts) {
|
|
50
|
-
body.set(part, offset);
|
|
51
|
-
offset += part.length;
|
|
52
|
-
}
|
|
53
|
-
return body;
|
|
54
|
-
}
|
|
55
|
-
async function postMultipartFormData(params) {
|
|
56
|
-
const body = Buffer.from(concatUint8Arrays(params.parts));
|
|
57
|
-
return await blueBubblesFetchWithTimeout(params.url, {
|
|
58
|
-
method: "POST",
|
|
59
|
-
headers: { "Content-Type": `multipart/form-data; boundary=${params.boundary}` },
|
|
60
|
-
body
|
|
61
|
-
}, params.timeoutMs);
|
|
62
|
-
}
|
|
63
|
-
async function assertMultipartActionOk(response, action) {
|
|
64
|
-
if (response.ok) return;
|
|
65
|
-
const errorText = await response.text().catch(() => "");
|
|
66
|
-
throw new Error(`BlueBubbles ${action} failed (${response.status}): ${errorText || "unknown"}`);
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region extensions/bluebubbles/src/send-helpers.ts
|
|
70
|
-
function resolveBlueBubblesSendTarget(raw) {
|
|
71
|
-
const parsed = parseBlueBubblesTarget(raw);
|
|
72
|
-
if (parsed.kind === "handle") return {
|
|
73
|
-
kind: "handle",
|
|
74
|
-
address: normalizeBlueBubblesHandle(parsed.to),
|
|
75
|
-
service: parsed.service
|
|
76
|
-
};
|
|
77
|
-
if (parsed.kind === "chat_id") return {
|
|
78
|
-
kind: "chat_id",
|
|
79
|
-
chatId: parsed.chatId
|
|
80
|
-
};
|
|
81
|
-
if (parsed.kind === "chat_guid") return {
|
|
82
|
-
kind: "chat_guid",
|
|
83
|
-
chatGuid: parsed.chatGuid
|
|
84
|
-
};
|
|
85
|
-
return {
|
|
86
|
-
kind: "chat_identifier",
|
|
87
|
-
chatIdentifier: parsed.chatIdentifier
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function extractBlueBubblesMessageId(payload) {
|
|
91
|
-
if (!payload || typeof payload !== "object") return "unknown";
|
|
92
|
-
const asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
93
|
-
const record = payload;
|
|
94
|
-
const roots = [
|
|
95
|
-
record,
|
|
96
|
-
asRecord(record.data),
|
|
97
|
-
asRecord(record.result),
|
|
98
|
-
asRecord(record.payload),
|
|
99
|
-
asRecord(record.message),
|
|
100
|
-
Array.isArray(record.data) ? asRecord(record.data[0]) : null
|
|
101
|
-
];
|
|
102
|
-
for (const root of roots) {
|
|
103
|
-
if (!root) continue;
|
|
104
|
-
const candidates = [
|
|
105
|
-
root.message_id,
|
|
106
|
-
root.messageId,
|
|
107
|
-
root.messageGuid,
|
|
108
|
-
root.message_guid,
|
|
109
|
-
root.guid,
|
|
110
|
-
root.id,
|
|
111
|
-
root.uuid
|
|
112
|
-
];
|
|
113
|
-
for (const candidate of candidates) {
|
|
114
|
-
if (typeof candidate === "string" && candidate.trim()) return candidate.trim();
|
|
115
|
-
if (typeof candidate === "number" && Number.isFinite(candidate)) return String(candidate);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return "unknown";
|
|
119
|
-
}
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region extensions/bluebubbles/src/send.ts
|
|
122
|
-
/** Maps short effect names to full Apple effect IDs */
|
|
123
|
-
const EFFECT_MAP = {
|
|
124
|
-
slam: "com.apple.MobileSMS.expressivesend.impact",
|
|
125
|
-
loud: "com.apple.MobileSMS.expressivesend.loud",
|
|
126
|
-
gentle: "com.apple.MobileSMS.expressivesend.gentle",
|
|
127
|
-
invisible: "com.apple.MobileSMS.expressivesend.invisibleink",
|
|
128
|
-
"invisible-ink": "com.apple.MobileSMS.expressivesend.invisibleink",
|
|
129
|
-
"invisible ink": "com.apple.MobileSMS.expressivesend.invisibleink",
|
|
130
|
-
invisibleink: "com.apple.MobileSMS.expressivesend.invisibleink",
|
|
131
|
-
echo: "com.apple.messages.effect.CKEchoEffect",
|
|
132
|
-
spotlight: "com.apple.messages.effect.CKSpotlightEffect",
|
|
133
|
-
balloons: "com.apple.messages.effect.CKHappyBirthdayEffect",
|
|
134
|
-
confetti: "com.apple.messages.effect.CKConfettiEffect",
|
|
135
|
-
love: "com.apple.messages.effect.CKHeartEffect",
|
|
136
|
-
heart: "com.apple.messages.effect.CKHeartEffect",
|
|
137
|
-
hearts: "com.apple.messages.effect.CKHeartEffect",
|
|
138
|
-
lasers: "com.apple.messages.effect.CKLasersEffect",
|
|
139
|
-
fireworks: "com.apple.messages.effect.CKFireworksEffect",
|
|
140
|
-
celebration: "com.apple.messages.effect.CKSparklesEffect"
|
|
141
|
-
};
|
|
142
|
-
function resolveEffectId(raw) {
|
|
143
|
-
if (!raw) return;
|
|
144
|
-
const trimmed = raw.trim().toLowerCase();
|
|
145
|
-
if (EFFECT_MAP[trimmed]) return EFFECT_MAP[trimmed];
|
|
146
|
-
const normalized = trimmed.replace(/[\s_]+/g, "-");
|
|
147
|
-
if (EFFECT_MAP[normalized]) return EFFECT_MAP[normalized];
|
|
148
|
-
const compact = trimmed.replace(/[\s_-]+/g, "");
|
|
149
|
-
if (EFFECT_MAP[compact]) return EFFECT_MAP[compact];
|
|
150
|
-
return raw;
|
|
151
|
-
}
|
|
152
|
-
function resolvePrivateApiDecision(params) {
|
|
153
|
-
const { privateApiStatus, wantsReplyThread, wantsEffect } = params;
|
|
154
|
-
const needsPrivateApi = wantsReplyThread || wantsEffect;
|
|
155
|
-
const canUsePrivateApi = needsPrivateApi && isBlueBubblesPrivateApiStatusEnabled(privateApiStatus);
|
|
156
|
-
const throwEffectDisabledError = wantsEffect && privateApiStatus === false;
|
|
157
|
-
if (!needsPrivateApi || privateApiStatus !== null) return {
|
|
158
|
-
canUsePrivateApi,
|
|
159
|
-
throwEffectDisabledError
|
|
160
|
-
};
|
|
161
|
-
return {
|
|
162
|
-
canUsePrivateApi,
|
|
163
|
-
throwEffectDisabledError,
|
|
164
|
-
warningMessage: `Private API status unknown; sending without ${[wantsReplyThread ? "reply threading" : null, wantsEffect ? "message effects" : null].filter(Boolean).join(" + ")}. Run a status probe to restore private-api features.`
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
async function parseBlueBubblesMessageResponse(res) {
|
|
168
|
-
const body = await res.text();
|
|
169
|
-
if (!body) return { messageId: "ok" };
|
|
170
|
-
try {
|
|
171
|
-
return { messageId: extractBlueBubblesMessageId(JSON.parse(body)) };
|
|
172
|
-
} catch {
|
|
173
|
-
return { messageId: "ok" };
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function extractChatGuid(chat) {
|
|
177
|
-
const candidates = [
|
|
178
|
-
chat.chatGuid,
|
|
179
|
-
chat.guid,
|
|
180
|
-
chat.chat_guid,
|
|
181
|
-
chat.identifier,
|
|
182
|
-
chat.chatIdentifier,
|
|
183
|
-
chat.chat_identifier
|
|
184
|
-
];
|
|
185
|
-
for (const candidate of candidates) if (typeof candidate === "string" && candidate.trim()) return candidate.trim();
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
function extractChatId(chat) {
|
|
189
|
-
const candidates = [
|
|
190
|
-
chat.chatId,
|
|
191
|
-
chat.id,
|
|
192
|
-
chat.chat_id
|
|
193
|
-
];
|
|
194
|
-
for (const candidate of candidates) if (typeof candidate === "number" && Number.isFinite(candidate)) return candidate;
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
function extractChatIdentifierFromChatGuid$1(chatGuid) {
|
|
198
|
-
const parts = chatGuid.split(";");
|
|
199
|
-
if (parts.length < 3) return null;
|
|
200
|
-
const identifier = parts[2]?.trim();
|
|
201
|
-
return identifier ? identifier : null;
|
|
202
|
-
}
|
|
203
|
-
function extractParticipantAddresses(chat) {
|
|
204
|
-
const raw = (Array.isArray(chat.participants) ? chat.participants : null) ?? (Array.isArray(chat.handles) ? chat.handles : null) ?? (Array.isArray(chat.participantHandles) ? chat.participantHandles : null);
|
|
205
|
-
if (!raw) return [];
|
|
206
|
-
const out = [];
|
|
207
|
-
for (const entry of raw) {
|
|
208
|
-
if (typeof entry === "string") {
|
|
209
|
-
out.push(entry);
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
if (entry && typeof entry === "object") {
|
|
213
|
-
const record = entry;
|
|
214
|
-
const candidate = typeof record.address === "string" && record.address || typeof record.handle === "string" && record.handle || typeof record.id === "string" && record.id || typeof record.identifier === "string" && record.identifier;
|
|
215
|
-
if (candidate) out.push(candidate);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return out;
|
|
219
|
-
}
|
|
220
|
-
async function queryChats(params) {
|
|
221
|
-
const res = await blueBubblesFetchWithTimeout(buildBlueBubblesApiUrl({
|
|
222
|
-
baseUrl: params.baseUrl,
|
|
223
|
-
path: "/api/v1/chat/query",
|
|
224
|
-
password: params.password
|
|
225
|
-
}), {
|
|
226
|
-
method: "POST",
|
|
227
|
-
headers: { "Content-Type": "application/json" },
|
|
228
|
-
body: JSON.stringify({
|
|
229
|
-
limit: params.limit,
|
|
230
|
-
offset: params.offset,
|
|
231
|
-
with: ["participants"]
|
|
232
|
-
})
|
|
233
|
-
}, params.timeoutMs);
|
|
234
|
-
if (!res.ok) return [];
|
|
235
|
-
const payload = await res.json().catch(() => null);
|
|
236
|
-
const data = payload && typeof payload.data !== "undefined" ? payload.data : null;
|
|
237
|
-
return Array.isArray(data) ? data : [];
|
|
238
|
-
}
|
|
239
|
-
async function resolveChatGuidForTarget(params) {
|
|
240
|
-
if (params.target.kind === "chat_guid") return params.target.chatGuid;
|
|
241
|
-
const normalizedHandle = params.target.kind === "handle" ? normalizeBlueBubblesHandle(params.target.address) : "";
|
|
242
|
-
const targetChatId = params.target.kind === "chat_id" ? params.target.chatId : null;
|
|
243
|
-
const targetChatIdentifier = params.target.kind === "chat_identifier" ? params.target.chatIdentifier : null;
|
|
244
|
-
const limit = 500;
|
|
245
|
-
let participantMatch = null;
|
|
246
|
-
for (let offset = 0; offset < 5e3; offset += limit) {
|
|
247
|
-
const chats = await queryChats({
|
|
248
|
-
baseUrl: params.baseUrl,
|
|
249
|
-
password: params.password,
|
|
250
|
-
timeoutMs: params.timeoutMs,
|
|
251
|
-
offset,
|
|
252
|
-
limit
|
|
253
|
-
});
|
|
254
|
-
if (chats.length === 0) break;
|
|
255
|
-
for (const chat of chats) {
|
|
256
|
-
if (targetChatId != null) {
|
|
257
|
-
const chatId = extractChatId(chat);
|
|
258
|
-
if (chatId != null && chatId === targetChatId) return extractChatGuid(chat);
|
|
259
|
-
}
|
|
260
|
-
if (targetChatIdentifier) {
|
|
261
|
-
const guid = extractChatGuid(chat);
|
|
262
|
-
if (guid) {
|
|
263
|
-
if (guid === targetChatIdentifier) return guid;
|
|
264
|
-
const guidIdentifier = extractChatIdentifierFromChatGuid$1(guid);
|
|
265
|
-
if (guidIdentifier && guidIdentifier === targetChatIdentifier) return guid;
|
|
266
|
-
}
|
|
267
|
-
const identifier = typeof chat.identifier === "string" ? chat.identifier : typeof chat.chatIdentifier === "string" ? chat.chatIdentifier : typeof chat.chat_identifier === "string" ? chat.chat_identifier : "";
|
|
268
|
-
if (identifier && identifier === targetChatIdentifier) return guid ?? extractChatGuid(chat);
|
|
269
|
-
}
|
|
270
|
-
if (normalizedHandle) {
|
|
271
|
-
const guid = extractChatGuid(chat);
|
|
272
|
-
const directHandle = guid ? extractHandleFromChatGuid(guid) : null;
|
|
273
|
-
if (directHandle && directHandle === normalizedHandle) return guid;
|
|
274
|
-
if (!participantMatch && guid) {
|
|
275
|
-
if (guid.includes(";-;")) {
|
|
276
|
-
if (extractParticipantAddresses(chat).map((entry) => normalizeBlueBubblesHandle(entry)).includes(normalizedHandle)) participantMatch = guid;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return participantMatch;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Creates a new chat (DM) and optionally sends an initial message.
|
|
286
|
-
* Requires Private API to be enabled in BlueBubbles.
|
|
287
|
-
*/
|
|
288
|
-
async function createNewChatWithMessage(params) {
|
|
289
|
-
const url = buildBlueBubblesApiUrl({
|
|
290
|
-
baseUrl: params.baseUrl,
|
|
291
|
-
path: "/api/v1/chat/new",
|
|
292
|
-
password: params.password
|
|
293
|
-
});
|
|
294
|
-
const payload = {
|
|
295
|
-
addresses: [params.address],
|
|
296
|
-
message: params.message,
|
|
297
|
-
tempGuid: `temp-${crypto.randomUUID()}`
|
|
298
|
-
};
|
|
299
|
-
const res = await blueBubblesFetchWithTimeout(url, {
|
|
300
|
-
method: "POST",
|
|
301
|
-
headers: { "Content-Type": "application/json" },
|
|
302
|
-
body: JSON.stringify(payload)
|
|
303
|
-
}, params.timeoutMs);
|
|
304
|
-
if (!res.ok) {
|
|
305
|
-
const errorText = await res.text();
|
|
306
|
-
if (res.status === 400 || res.status === 403 || errorText.toLowerCase().includes("private api")) throw new Error(`BlueBubbles send failed: Cannot create new chat - Private API must be enabled. Original error: ${errorText || res.status}`);
|
|
307
|
-
throw new Error(`BlueBubbles create chat failed (${res.status}): ${errorText || "unknown"}`);
|
|
308
|
-
}
|
|
309
|
-
return parseBlueBubblesMessageResponse(res);
|
|
310
|
-
}
|
|
311
|
-
async function sendMessageBlueBubbles(to, text, opts = {}) {
|
|
312
|
-
const trimmedText = text ?? "";
|
|
313
|
-
if (!trimmedText.trim()) throw new Error("BlueBubbles send requires text");
|
|
314
|
-
const strippedText = stripMarkdown(trimmedText);
|
|
315
|
-
if (!strippedText.trim()) throw new Error("BlueBubbles send requires text (message was empty after markdown removal)");
|
|
316
|
-
const account = resolveBlueBubblesAccount({
|
|
317
|
-
cfg: opts.cfg ?? {},
|
|
318
|
-
accountId: opts.accountId
|
|
319
|
-
});
|
|
320
|
-
const baseUrl = normalizeSecretInputString(opts.serverUrl) || normalizeSecretInputString(account.config.serverUrl);
|
|
321
|
-
const password = normalizeSecretInputString(opts.password) || normalizeSecretInputString(account.config.password);
|
|
322
|
-
if (!baseUrl) throw new Error("BlueBubbles serverUrl is required");
|
|
323
|
-
if (!password) throw new Error("BlueBubbles password is required");
|
|
324
|
-
const privateApiStatus = getCachedBlueBubblesPrivateApiStatus(account.accountId);
|
|
325
|
-
const target = resolveBlueBubblesSendTarget(to);
|
|
326
|
-
const chatGuid = await resolveChatGuidForTarget({
|
|
327
|
-
baseUrl,
|
|
328
|
-
password,
|
|
329
|
-
timeoutMs: opts.timeoutMs,
|
|
330
|
-
target
|
|
331
|
-
});
|
|
332
|
-
if (!chatGuid) {
|
|
333
|
-
if (target.kind === "handle") return createNewChatWithMessage({
|
|
334
|
-
baseUrl,
|
|
335
|
-
password,
|
|
336
|
-
address: target.address,
|
|
337
|
-
message: strippedText,
|
|
338
|
-
timeoutMs: opts.timeoutMs
|
|
339
|
-
});
|
|
340
|
-
throw new Error("BlueBubbles send failed: chatGuid not found for target. Use a chat_guid target or ensure the chat exists.");
|
|
341
|
-
}
|
|
342
|
-
const effectId = resolveEffectId(opts.effectId);
|
|
343
|
-
const wantsReplyThread = Boolean(opts.replyToMessageGuid?.trim());
|
|
344
|
-
const privateApiDecision = resolvePrivateApiDecision({
|
|
345
|
-
privateApiStatus,
|
|
346
|
-
wantsReplyThread,
|
|
347
|
-
wantsEffect: Boolean(effectId)
|
|
348
|
-
});
|
|
349
|
-
if (privateApiDecision.throwEffectDisabledError) throw new Error("BlueBubbles send failed: reply/effect requires Private API, but it is disabled on the BlueBubbles server.");
|
|
350
|
-
if (privateApiDecision.warningMessage) warnBlueBubbles(privateApiDecision.warningMessage);
|
|
351
|
-
const payload = {
|
|
352
|
-
chatGuid,
|
|
353
|
-
tempGuid: crypto.randomUUID(),
|
|
354
|
-
message: strippedText
|
|
355
|
-
};
|
|
356
|
-
if (privateApiDecision.canUsePrivateApi) payload.method = "private-api";
|
|
357
|
-
if (wantsReplyThread && privateApiDecision.canUsePrivateApi) {
|
|
358
|
-
payload.selectedMessageGuid = opts.replyToMessageGuid;
|
|
359
|
-
payload.partIndex = typeof opts.replyToPartIndex === "number" ? opts.replyToPartIndex : 0;
|
|
360
|
-
}
|
|
361
|
-
if (effectId && privateApiDecision.canUsePrivateApi) payload.effectId = effectId;
|
|
362
|
-
const res = await blueBubblesFetchWithTimeout(buildBlueBubblesApiUrl({
|
|
363
|
-
baseUrl,
|
|
364
|
-
path: "/api/v1/message/text",
|
|
365
|
-
password
|
|
366
|
-
}), {
|
|
367
|
-
method: "POST",
|
|
368
|
-
headers: { "Content-Type": "application/json" },
|
|
369
|
-
body: JSON.stringify(payload)
|
|
370
|
-
}, opts.timeoutMs);
|
|
371
|
-
if (!res.ok) {
|
|
372
|
-
const errorText = await res.text();
|
|
373
|
-
throw new Error(`BlueBubbles send failed (${res.status}): ${errorText || "unknown"}`);
|
|
374
|
-
}
|
|
375
|
-
return parseBlueBubblesMessageResponse(res);
|
|
376
|
-
}
|
|
377
|
-
//#endregion
|
|
378
|
-
//#region extensions/bluebubbles/src/attachments.ts
|
|
379
|
-
const DEFAULT_ATTACHMENT_MAX_BYTES = 8 * 1024 * 1024;
|
|
380
|
-
const AUDIO_MIME_MP3 = new Set(["audio/mpeg", "audio/mp3"]);
|
|
381
|
-
const AUDIO_MIME_CAF = new Set(["audio/x-caf", "audio/caf"]);
|
|
382
|
-
function sanitizeFilename(input, fallback) {
|
|
383
|
-
const trimmed = input?.trim() ?? "";
|
|
384
|
-
return ((trimmed ? path.basename(trimmed) : "") || fallback).replace(/[\r\n"\\]/g, "_");
|
|
385
|
-
}
|
|
386
|
-
function ensureExtension(filename, extension, fallbackBase) {
|
|
387
|
-
const currentExt = path.extname(filename);
|
|
388
|
-
if (currentExt.toLowerCase() === extension) return filename;
|
|
389
|
-
return `${(currentExt ? filename.slice(0, -currentExt.length) : filename) || fallbackBase}${extension}`;
|
|
390
|
-
}
|
|
391
|
-
function resolveVoiceInfo(filename, contentType) {
|
|
392
|
-
const normalizedType = contentType?.trim().toLowerCase();
|
|
393
|
-
const extension = path.extname(filename).toLowerCase();
|
|
394
|
-
const isMp3 = extension === ".mp3" || (normalizedType ? AUDIO_MIME_MP3.has(normalizedType) : false);
|
|
395
|
-
const isCaf = extension === ".caf" || (normalizedType ? AUDIO_MIME_CAF.has(normalizedType) : false);
|
|
396
|
-
return {
|
|
397
|
-
isAudio: isMp3 || isCaf || Boolean(normalizedType?.startsWith("audio/")),
|
|
398
|
-
isMp3,
|
|
399
|
-
isCaf
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
function resolveAccount$3(params) {
|
|
403
|
-
return resolveBlueBubblesServerAccount(params);
|
|
404
|
-
}
|
|
405
|
-
function safeExtractHostname(url) {
|
|
406
|
-
try {
|
|
407
|
-
return new URL(url).hostname.trim() || void 0;
|
|
408
|
-
} catch {
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
function readMediaFetchErrorCode(error) {
|
|
413
|
-
if (!error || typeof error !== "object") return;
|
|
414
|
-
const code = error.code;
|
|
415
|
-
return code === "max_bytes" || code === "http_error" || code === "fetch_failed" ? code : void 0;
|
|
416
|
-
}
|
|
417
|
-
async function downloadBlueBubblesAttachment(attachment, opts = {}) {
|
|
418
|
-
const guid = attachment.guid?.trim();
|
|
419
|
-
if (!guid) throw new Error("BlueBubbles attachment guid is required");
|
|
420
|
-
const { baseUrl, password, allowPrivateNetwork } = resolveAccount$3(opts);
|
|
421
|
-
const url = buildBlueBubblesApiUrl({
|
|
422
|
-
baseUrl,
|
|
423
|
-
path: `/api/v1/attachment/${encodeURIComponent(guid)}/download`,
|
|
424
|
-
password
|
|
425
|
-
});
|
|
426
|
-
const maxBytes = typeof opts.maxBytes === "number" ? opts.maxBytes : DEFAULT_ATTACHMENT_MAX_BYTES;
|
|
427
|
-
const trustedHostname = safeExtractHostname(baseUrl);
|
|
428
|
-
try {
|
|
429
|
-
const fetched = await getBlueBubblesRuntime().channel.media.fetchRemoteMedia({
|
|
430
|
-
url,
|
|
431
|
-
filePathHint: attachment.transferName ?? attachment.guid ?? "attachment",
|
|
432
|
-
maxBytes,
|
|
433
|
-
ssrfPolicy: allowPrivateNetwork ? { allowPrivateNetwork: true } : trustedHostname ? { allowedHostnames: [trustedHostname] } : void 0,
|
|
434
|
-
fetchImpl: async (input, init) => await blueBubblesFetchWithTimeout(resolveRequestUrl(input), {
|
|
435
|
-
...init,
|
|
436
|
-
method: init?.method ?? "GET"
|
|
437
|
-
}, opts.timeoutMs)
|
|
438
|
-
});
|
|
439
|
-
return {
|
|
440
|
-
buffer: new Uint8Array(fetched.buffer),
|
|
441
|
-
contentType: fetched.contentType ?? attachment.mimeType ?? void 0
|
|
442
|
-
};
|
|
443
|
-
} catch (error) {
|
|
444
|
-
if (readMediaFetchErrorCode(error) === "max_bytes") throw new Error(`BlueBubbles attachment too large (limit ${maxBytes} bytes)`);
|
|
445
|
-
const text = error instanceof Error ? error.message : String(error);
|
|
446
|
-
throw new Error(`BlueBubbles attachment download failed: ${text}`);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Send an attachment via BlueBubbles API.
|
|
451
|
-
* Supports sending media files (images, videos, audio, documents) to a chat.
|
|
452
|
-
* When asVoice is true, expects MP3/CAF audio and marks it as an iMessage voice memo.
|
|
453
|
-
*/
|
|
454
|
-
async function sendBlueBubblesAttachment(params) {
|
|
455
|
-
const { to, caption, replyToMessageGuid, replyToPartIndex, asVoice, opts = {} } = params;
|
|
456
|
-
let { buffer, filename, contentType } = params;
|
|
457
|
-
const wantsVoice = asVoice === true;
|
|
458
|
-
const fallbackName = wantsVoice ? "Audio Message" : "attachment";
|
|
459
|
-
filename = sanitizeFilename(filename, fallbackName);
|
|
460
|
-
contentType = contentType?.trim() || void 0;
|
|
461
|
-
const { baseUrl, password, accountId } = resolveAccount$3(opts);
|
|
462
|
-
const privateApiStatus = getCachedBlueBubblesPrivateApiStatus(accountId);
|
|
463
|
-
const privateApiEnabled = isBlueBubblesPrivateApiStatusEnabled(privateApiStatus);
|
|
464
|
-
const isAudioMessage = wantsVoice;
|
|
465
|
-
if (isAudioMessage) {
|
|
466
|
-
const voiceInfo = resolveVoiceInfo(filename, contentType);
|
|
467
|
-
if (!voiceInfo.isAudio) throw new Error("BlueBubbles voice messages require audio media (mp3 or caf).");
|
|
468
|
-
if (voiceInfo.isMp3) {
|
|
469
|
-
filename = ensureExtension(filename, ".mp3", fallbackName);
|
|
470
|
-
contentType = contentType ?? "audio/mpeg";
|
|
471
|
-
} else if (voiceInfo.isCaf) {
|
|
472
|
-
filename = ensureExtension(filename, ".caf", fallbackName);
|
|
473
|
-
contentType = contentType ?? "audio/x-caf";
|
|
474
|
-
} else throw new Error("BlueBubbles voice messages require mp3 or caf audio (convert before sending).");
|
|
475
|
-
}
|
|
476
|
-
const target = resolveBlueBubblesSendTarget(to);
|
|
477
|
-
const chatGuid = await resolveChatGuidForTarget({
|
|
478
|
-
baseUrl,
|
|
479
|
-
password,
|
|
480
|
-
timeoutMs: opts.timeoutMs,
|
|
481
|
-
target
|
|
482
|
-
});
|
|
483
|
-
if (!chatGuid) throw new Error("BlueBubbles attachment send failed: chatGuid not found for target. Use a chat_guid target or ensure the chat exists.");
|
|
484
|
-
const url = buildBlueBubblesApiUrl({
|
|
485
|
-
baseUrl,
|
|
486
|
-
path: "/api/v1/message/attachment",
|
|
487
|
-
password
|
|
488
|
-
});
|
|
489
|
-
const boundary = `----BlueBubblesFormBoundary${crypto.randomUUID().replace(/-/g, "")}`;
|
|
490
|
-
const parts = [];
|
|
491
|
-
const encoder = new TextEncoder();
|
|
492
|
-
const addField = (name, value) => {
|
|
493
|
-
parts.push(encoder.encode(`--${boundary}\r\n`));
|
|
494
|
-
parts.push(encoder.encode(`Content-Disposition: form-data; name="${name}"\r\n\r\n`));
|
|
495
|
-
parts.push(encoder.encode(`${value}\r\n`));
|
|
496
|
-
};
|
|
497
|
-
const addFile = (name, fileBuffer, fileName, mimeType) => {
|
|
498
|
-
parts.push(encoder.encode(`--${boundary}\r\n`));
|
|
499
|
-
parts.push(encoder.encode(`Content-Disposition: form-data; name="${name}"; filename="${fileName}"\r\n`));
|
|
500
|
-
parts.push(encoder.encode(`Content-Type: ${mimeType ?? "application/octet-stream"}\r\n\r\n`));
|
|
501
|
-
parts.push(fileBuffer);
|
|
502
|
-
parts.push(encoder.encode("\r\n"));
|
|
503
|
-
};
|
|
504
|
-
addFile("attachment", buffer, filename, contentType);
|
|
505
|
-
addField("chatGuid", chatGuid);
|
|
506
|
-
addField("name", filename);
|
|
507
|
-
addField("tempGuid", `temp-${Date.now()}-${crypto.randomUUID().slice(0, 8)}`);
|
|
508
|
-
if (privateApiEnabled) addField("method", "private-api");
|
|
509
|
-
if (isAudioMessage) addField("isAudioMessage", "true");
|
|
510
|
-
const trimmedReplyTo = replyToMessageGuid?.trim();
|
|
511
|
-
if (trimmedReplyTo && privateApiEnabled) {
|
|
512
|
-
addField("selectedMessageGuid", trimmedReplyTo);
|
|
513
|
-
addField("partIndex", typeof replyToPartIndex === "number" ? String(replyToPartIndex) : "0");
|
|
514
|
-
} else if (trimmedReplyTo && privateApiStatus === null) warnBlueBubbles("Private API status unknown; sending attachment without reply threading metadata. Run a status probe to restore private-api reply features.");
|
|
515
|
-
if (caption) {
|
|
516
|
-
addField("message", caption);
|
|
517
|
-
addField("text", caption);
|
|
518
|
-
addField("caption", caption);
|
|
519
|
-
}
|
|
520
|
-
parts.push(encoder.encode(`--${boundary}--\r\n`));
|
|
521
|
-
const res = await postMultipartFormData({
|
|
522
|
-
url,
|
|
523
|
-
boundary,
|
|
524
|
-
parts,
|
|
525
|
-
timeoutMs: opts.timeoutMs ?? 6e4
|
|
526
|
-
});
|
|
527
|
-
await assertMultipartActionOk(res, "attachment send");
|
|
528
|
-
const responseBody = await res.text();
|
|
529
|
-
if (!responseBody) return { messageId: "ok" };
|
|
530
|
-
try {
|
|
531
|
-
return { messageId: extractBlueBubblesMessageId(JSON.parse(responseBody)) };
|
|
532
|
-
} catch {
|
|
533
|
-
return { messageId: "ok" };
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
//#endregion
|
|
537
|
-
//#region extensions/bluebubbles/src/chat.ts
|
|
538
|
-
function resolveAccount$2(params) {
|
|
539
|
-
return resolveBlueBubblesServerAccount(params);
|
|
540
|
-
}
|
|
541
|
-
function assertPrivateApiEnabled(accountId, feature) {
|
|
542
|
-
if (getCachedBlueBubblesPrivateApiStatus(accountId) === false) throw new Error(`BlueBubbles ${feature} requires Private API, but it is disabled on the BlueBubbles server.`);
|
|
543
|
-
}
|
|
544
|
-
function resolvePartIndex(partIndex) {
|
|
545
|
-
return typeof partIndex === "number" ? partIndex : 0;
|
|
546
|
-
}
|
|
547
|
-
async function sendBlueBubblesChatEndpointRequest(params) {
|
|
548
|
-
const trimmed = params.chatGuid.trim();
|
|
549
|
-
if (!trimmed) return;
|
|
550
|
-
const { baseUrl, password, accountId } = resolveAccount$2(params.opts);
|
|
551
|
-
if (getCachedBlueBubblesPrivateApiStatus(accountId) === false) return;
|
|
552
|
-
await assertMultipartActionOk(await blueBubblesFetchWithTimeout(buildBlueBubblesApiUrl({
|
|
553
|
-
baseUrl,
|
|
554
|
-
path: `/api/v1/chat/${encodeURIComponent(trimmed)}/${params.endpoint}`,
|
|
555
|
-
password
|
|
556
|
-
}), { method: params.method }, params.opts.timeoutMs), params.action);
|
|
557
|
-
}
|
|
558
|
-
async function sendPrivateApiJsonRequest(params) {
|
|
559
|
-
const { baseUrl, password, accountId } = resolveAccount$2(params.opts);
|
|
560
|
-
assertPrivateApiEnabled(accountId, params.feature);
|
|
561
|
-
const url = buildBlueBubblesApiUrl({
|
|
562
|
-
baseUrl,
|
|
563
|
-
path: params.path,
|
|
564
|
-
password
|
|
565
|
-
});
|
|
566
|
-
const request = { method: params.method };
|
|
567
|
-
if (params.payload !== void 0) {
|
|
568
|
-
request.headers = { "Content-Type": "application/json" };
|
|
569
|
-
request.body = JSON.stringify(params.payload);
|
|
570
|
-
}
|
|
571
|
-
await assertMultipartActionOk(await blueBubblesFetchWithTimeout(url, request, params.opts.timeoutMs), params.action);
|
|
572
|
-
}
|
|
573
|
-
async function markBlueBubblesChatRead(chatGuid, opts = {}) {
|
|
574
|
-
await sendBlueBubblesChatEndpointRequest({
|
|
575
|
-
chatGuid,
|
|
576
|
-
opts,
|
|
577
|
-
endpoint: "read",
|
|
578
|
-
method: "POST",
|
|
579
|
-
action: "read"
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
async function sendBlueBubblesTyping(chatGuid, typing, opts = {}) {
|
|
583
|
-
await sendBlueBubblesChatEndpointRequest({
|
|
584
|
-
chatGuid,
|
|
585
|
-
opts,
|
|
586
|
-
endpoint: "typing",
|
|
587
|
-
method: typing ? "POST" : "DELETE",
|
|
588
|
-
action: "typing"
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* Edit a message via BlueBubbles API.
|
|
593
|
-
* Requires macOS 13 (Ventura) or higher with Private API enabled.
|
|
594
|
-
*/
|
|
595
|
-
async function editBlueBubblesMessage(messageGuid, newText, opts = {}) {
|
|
596
|
-
const trimmedGuid = messageGuid.trim();
|
|
597
|
-
if (!trimmedGuid) throw new Error("BlueBubbles edit requires messageGuid");
|
|
598
|
-
const trimmedText = newText.trim();
|
|
599
|
-
if (!trimmedText) throw new Error("BlueBubbles edit requires newText");
|
|
600
|
-
await sendPrivateApiJsonRequest({
|
|
601
|
-
opts,
|
|
602
|
-
feature: "edit",
|
|
603
|
-
action: "edit",
|
|
604
|
-
method: "POST",
|
|
605
|
-
path: `/api/v1/message/${encodeURIComponent(trimmedGuid)}/edit`,
|
|
606
|
-
payload: {
|
|
607
|
-
editedMessage: trimmedText,
|
|
608
|
-
backwardsCompatibilityMessage: opts.backwardsCompatMessage ?? `Edited to: ${trimmedText}`,
|
|
609
|
-
partIndex: resolvePartIndex(opts.partIndex)
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Unsend (retract) a message via BlueBubbles API.
|
|
615
|
-
* Requires macOS 13 (Ventura) or higher with Private API enabled.
|
|
616
|
-
*/
|
|
617
|
-
async function unsendBlueBubblesMessage(messageGuid, opts = {}) {
|
|
618
|
-
const trimmedGuid = messageGuid.trim();
|
|
619
|
-
if (!trimmedGuid) throw new Error("BlueBubbles unsend requires messageGuid");
|
|
620
|
-
await sendPrivateApiJsonRequest({
|
|
621
|
-
opts,
|
|
622
|
-
feature: "unsend",
|
|
623
|
-
action: "unsend",
|
|
624
|
-
method: "POST",
|
|
625
|
-
path: `/api/v1/message/${encodeURIComponent(trimmedGuid)}/unsend`,
|
|
626
|
-
payload: { partIndex: resolvePartIndex(opts.partIndex) }
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* Rename a group chat via BlueBubbles API.
|
|
631
|
-
*/
|
|
632
|
-
async function renameBlueBubblesChat(chatGuid, displayName, opts = {}) {
|
|
633
|
-
const trimmedGuid = chatGuid.trim();
|
|
634
|
-
if (!trimmedGuid) throw new Error("BlueBubbles rename requires chatGuid");
|
|
635
|
-
await sendPrivateApiJsonRequest({
|
|
636
|
-
opts,
|
|
637
|
-
feature: "renameGroup",
|
|
638
|
-
action: "rename",
|
|
639
|
-
method: "PUT",
|
|
640
|
-
path: `/api/v1/chat/${encodeURIComponent(trimmedGuid)}`,
|
|
641
|
-
payload: { displayName }
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
/**
|
|
645
|
-
* Add a participant to a group chat via BlueBubbles API.
|
|
646
|
-
*/
|
|
647
|
-
async function addBlueBubblesParticipant(chatGuid, address, opts = {}) {
|
|
648
|
-
const trimmedGuid = chatGuid.trim();
|
|
649
|
-
if (!trimmedGuid) throw new Error("BlueBubbles addParticipant requires chatGuid");
|
|
650
|
-
const trimmedAddress = address.trim();
|
|
651
|
-
if (!trimmedAddress) throw new Error("BlueBubbles addParticipant requires address");
|
|
652
|
-
await sendPrivateApiJsonRequest({
|
|
653
|
-
opts,
|
|
654
|
-
feature: "addParticipant",
|
|
655
|
-
action: "addParticipant",
|
|
656
|
-
method: "POST",
|
|
657
|
-
path: `/api/v1/chat/${encodeURIComponent(trimmedGuid)}/participant`,
|
|
658
|
-
payload: { address: trimmedAddress }
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
/**
|
|
662
|
-
* Remove a participant from a group chat via BlueBubbles API.
|
|
663
|
-
*/
|
|
664
|
-
async function removeBlueBubblesParticipant(chatGuid, address, opts = {}) {
|
|
665
|
-
const trimmedGuid = chatGuid.trim();
|
|
666
|
-
if (!trimmedGuid) throw new Error("BlueBubbles removeParticipant requires chatGuid");
|
|
667
|
-
const trimmedAddress = address.trim();
|
|
668
|
-
if (!trimmedAddress) throw new Error("BlueBubbles removeParticipant requires address");
|
|
669
|
-
await sendPrivateApiJsonRequest({
|
|
670
|
-
opts,
|
|
671
|
-
feature: "removeParticipant",
|
|
672
|
-
action: "removeParticipant",
|
|
673
|
-
method: "DELETE",
|
|
674
|
-
path: `/api/v1/chat/${encodeURIComponent(trimmedGuid)}/participant`,
|
|
675
|
-
payload: { address: trimmedAddress }
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
/**
|
|
679
|
-
* Leave a group chat via BlueBubbles API.
|
|
680
|
-
*/
|
|
681
|
-
async function leaveBlueBubblesChat(chatGuid, opts = {}) {
|
|
682
|
-
const trimmedGuid = chatGuid.trim();
|
|
683
|
-
if (!trimmedGuid) throw new Error("BlueBubbles leaveChat requires chatGuid");
|
|
684
|
-
await sendPrivateApiJsonRequest({
|
|
685
|
-
opts,
|
|
686
|
-
feature: "leaveGroup",
|
|
687
|
-
action: "leaveChat",
|
|
688
|
-
method: "POST",
|
|
689
|
-
path: `/api/v1/chat/${encodeURIComponent(trimmedGuid)}/leave`
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
/**
|
|
693
|
-
* Set a group chat's icon/photo via BlueBubbles API.
|
|
694
|
-
* Requires Private API to be enabled.
|
|
695
|
-
*/
|
|
696
|
-
async function setGroupIconBlueBubbles(chatGuid, buffer, filename, opts = {}) {
|
|
697
|
-
const trimmedGuid = chatGuid.trim();
|
|
698
|
-
if (!trimmedGuid) throw new Error("BlueBubbles setGroupIcon requires chatGuid");
|
|
699
|
-
if (!buffer || buffer.length === 0) throw new Error("BlueBubbles setGroupIcon requires image buffer");
|
|
700
|
-
const { baseUrl, password, accountId } = resolveAccount$2(opts);
|
|
701
|
-
assertPrivateApiEnabled(accountId, "setGroupIcon");
|
|
702
|
-
const url = buildBlueBubblesApiUrl({
|
|
703
|
-
baseUrl,
|
|
704
|
-
path: `/api/v1/chat/${encodeURIComponent(trimmedGuid)}/icon`,
|
|
705
|
-
password
|
|
706
|
-
});
|
|
707
|
-
const boundary = `----BlueBubblesFormBoundary${crypto.randomUUID().replace(/-/g, "")}`;
|
|
708
|
-
const parts = [];
|
|
709
|
-
const encoder = new TextEncoder();
|
|
710
|
-
const safeFilename = path.basename(filename).replace(/[\r\n"\\]/g, "_") || "icon.png";
|
|
711
|
-
parts.push(encoder.encode(`--${boundary}\r\n`));
|
|
712
|
-
parts.push(encoder.encode(`Content-Disposition: form-data; name="icon"; filename="${safeFilename}"\r\n`));
|
|
713
|
-
parts.push(encoder.encode(`Content-Type: ${opts.contentType ?? "application/octet-stream"}\r\n\r\n`));
|
|
714
|
-
parts.push(buffer);
|
|
715
|
-
parts.push(encoder.encode("\r\n"));
|
|
716
|
-
parts.push(encoder.encode(`--${boundary}--\r\n`));
|
|
717
|
-
await assertMultipartActionOk(await postMultipartFormData({
|
|
718
|
-
url,
|
|
719
|
-
boundary,
|
|
720
|
-
parts,
|
|
721
|
-
timeoutMs: opts.timeoutMs ?? 6e4
|
|
722
|
-
}), "setGroupIcon");
|
|
723
|
-
}
|
|
724
|
-
//#endregion
|
|
725
|
-
//#region extensions/bluebubbles/src/monitor-debounce.ts
|
|
726
|
-
/**
|
|
727
|
-
* Default debounce window for inbound message coalescing (ms).
|
|
728
|
-
* This helps combine URL text + link preview balloon messages that BlueBubbles
|
|
729
|
-
* sends as separate webhook events when no explicit inbound debounce config exists.
|
|
730
|
-
*/
|
|
731
|
-
const DEFAULT_INBOUND_DEBOUNCE_MS = 500;
|
|
732
|
-
/**
|
|
733
|
-
* Combines multiple debounced messages into a single message for processing.
|
|
734
|
-
* Used when multiple webhook events arrive within the debounce window.
|
|
735
|
-
*/
|
|
736
|
-
function combineDebounceEntries(entries) {
|
|
737
|
-
if (entries.length === 0) throw new Error("Cannot combine empty entries");
|
|
738
|
-
if (entries.length === 1) return entries[0].message;
|
|
739
|
-
const first = entries[0].message;
|
|
740
|
-
const seenTexts = /* @__PURE__ */ new Set();
|
|
741
|
-
const textParts = [];
|
|
742
|
-
for (const entry of entries) {
|
|
743
|
-
const text = entry.message.text.trim();
|
|
744
|
-
if (!text) continue;
|
|
745
|
-
const normalizedText = text.toLowerCase();
|
|
746
|
-
if (seenTexts.has(normalizedText)) continue;
|
|
747
|
-
seenTexts.add(normalizedText);
|
|
748
|
-
textParts.push(text);
|
|
749
|
-
}
|
|
750
|
-
const allAttachments = entries.flatMap((e) => e.message.attachments ?? []);
|
|
751
|
-
const timestamps = entries.map((e) => e.message.timestamp).filter((t) => typeof t === "number");
|
|
752
|
-
const latestTimestamp = timestamps.length > 0 ? Math.max(...timestamps) : first.timestamp;
|
|
753
|
-
const messageIds = entries.map((e) => e.message.messageId).filter((id) => Boolean(id));
|
|
754
|
-
const entryWithReply = entries.find((e) => e.message.replyToId);
|
|
755
|
-
return {
|
|
756
|
-
...first,
|
|
757
|
-
text: textParts.join(" "),
|
|
758
|
-
attachments: allAttachments.length > 0 ? allAttachments : first.attachments,
|
|
759
|
-
timestamp: latestTimestamp,
|
|
760
|
-
messageId: messageIds[0] ?? first.messageId,
|
|
761
|
-
replyToId: entryWithReply?.message.replyToId ?? first.replyToId,
|
|
762
|
-
replyToBody: entryWithReply?.message.replyToBody ?? first.replyToBody,
|
|
763
|
-
replyToSender: entryWithReply?.message.replyToSender ?? first.replyToSender,
|
|
764
|
-
balloonBundleId: void 0
|
|
765
|
-
};
|
|
766
|
-
}
|
|
767
|
-
function resolveBlueBubblesDebounceMs(config, core) {
|
|
768
|
-
const inbound = config.messages?.inbound;
|
|
769
|
-
if (!(typeof inbound?.debounceMs === "number" || typeof inbound?.byChannel?.bluebubbles === "number")) return DEFAULT_INBOUND_DEBOUNCE_MS;
|
|
770
|
-
return core.channel.debounce.resolveInboundDebounceMs({
|
|
771
|
-
cfg: config,
|
|
772
|
-
channel: "bluebubbles"
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
function createBlueBubblesDebounceRegistry(params) {
|
|
776
|
-
const targetDebouncers = /* @__PURE__ */ new Map();
|
|
777
|
-
return {
|
|
778
|
-
getOrCreateDebouncer: (target) => {
|
|
779
|
-
const existing = targetDebouncers.get(target);
|
|
780
|
-
if (existing) return existing;
|
|
781
|
-
const { account, config, runtime, core } = target;
|
|
782
|
-
const debouncer = core.channel.debounce.createInboundDebouncer({
|
|
783
|
-
debounceMs: resolveBlueBubblesDebounceMs(config, core),
|
|
784
|
-
buildKey: (entry) => {
|
|
785
|
-
const msg = entry.message;
|
|
786
|
-
const balloonBundleId = msg.balloonBundleId?.trim();
|
|
787
|
-
const associatedMessageGuid = msg.associatedMessageGuid?.trim();
|
|
788
|
-
if (balloonBundleId && associatedMessageGuid) return `bluebubbles:${account.accountId}:balloon:${associatedMessageGuid}`;
|
|
789
|
-
const messageId = msg.messageId?.trim();
|
|
790
|
-
if (messageId) return `bluebubbles:${account.accountId}:msg:${messageId}`;
|
|
791
|
-
const chatKey = msg.chatGuid?.trim() ?? msg.chatIdentifier?.trim() ?? (msg.chatId ? String(msg.chatId) : "dm");
|
|
792
|
-
return `bluebubbles:${account.accountId}:${chatKey}:${msg.senderId}`;
|
|
793
|
-
},
|
|
794
|
-
shouldDebounce: (entry) => {
|
|
795
|
-
const msg = entry.message;
|
|
796
|
-
if (msg.fromMe) return false;
|
|
797
|
-
if (core.channel.text.hasControlCommand(msg.text, config)) return false;
|
|
798
|
-
return true;
|
|
799
|
-
},
|
|
800
|
-
onFlush: async (entries) => {
|
|
801
|
-
if (entries.length === 0) return;
|
|
802
|
-
const flushTarget = entries[0].target;
|
|
803
|
-
if (entries.length === 1) {
|
|
804
|
-
await params.processMessage(entries[0].message, flushTarget);
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
const combined = combineDebounceEntries(entries);
|
|
808
|
-
if (core.logging.shouldLogVerbose()) {
|
|
809
|
-
const count = entries.length;
|
|
810
|
-
const preview = combined.text.slice(0, 50);
|
|
811
|
-
runtime.log?.(`[bluebubbles] coalesced ${count} messages: "${preview}${combined.text.length > 50 ? "..." : ""}"`);
|
|
812
|
-
}
|
|
813
|
-
await params.processMessage(combined, flushTarget);
|
|
814
|
-
},
|
|
815
|
-
onError: (err) => {
|
|
816
|
-
runtime.error?.(`[${account.accountId}] [bluebubbles] debounce flush failed: ${String(err)}`);
|
|
817
|
-
}
|
|
818
|
-
});
|
|
819
|
-
targetDebouncers.set(target, debouncer);
|
|
820
|
-
return debouncer;
|
|
821
|
-
},
|
|
822
|
-
removeDebouncer: (target) => {
|
|
823
|
-
targetDebouncers.delete(target);
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
//#endregion
|
|
828
|
-
//#region extensions/bluebubbles/src/monitor-normalize.ts
|
|
829
|
-
function asRecord$1(value) {
|
|
830
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
831
|
-
}
|
|
832
|
-
function readString(record, key) {
|
|
833
|
-
if (!record) return;
|
|
834
|
-
const value = record[key];
|
|
835
|
-
return typeof value === "string" ? value : void 0;
|
|
836
|
-
}
|
|
837
|
-
function readNumber(record, key) {
|
|
838
|
-
if (!record) return;
|
|
839
|
-
const value = record[key];
|
|
840
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
841
|
-
}
|
|
842
|
-
function readBoolean(record, key) {
|
|
843
|
-
if (!record) return;
|
|
844
|
-
const value = record[key];
|
|
845
|
-
return typeof value === "boolean" ? value : void 0;
|
|
846
|
-
}
|
|
847
|
-
function readNumberLike(record, key) {
|
|
848
|
-
if (!record) return;
|
|
849
|
-
return parseFiniteNumber(record[key]);
|
|
850
|
-
}
|
|
851
|
-
function extractAttachments(message) {
|
|
852
|
-
const raw = message["attachments"];
|
|
853
|
-
if (!Array.isArray(raw)) return [];
|
|
854
|
-
const out = [];
|
|
855
|
-
for (const entry of raw) {
|
|
856
|
-
const record = asRecord$1(entry);
|
|
857
|
-
if (!record) continue;
|
|
858
|
-
out.push({
|
|
859
|
-
guid: readString(record, "guid"),
|
|
860
|
-
uti: readString(record, "uti"),
|
|
861
|
-
mimeType: readString(record, "mimeType") ?? readString(record, "mime_type"),
|
|
862
|
-
transferName: readString(record, "transferName") ?? readString(record, "transfer_name"),
|
|
863
|
-
totalBytes: readNumberLike(record, "totalBytes") ?? readNumberLike(record, "total_bytes"),
|
|
864
|
-
height: readNumberLike(record, "height"),
|
|
865
|
-
width: readNumberLike(record, "width"),
|
|
866
|
-
originalROWID: readNumberLike(record, "originalROWID") ?? readNumberLike(record, "rowid")
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
return out;
|
|
870
|
-
}
|
|
871
|
-
function buildAttachmentPlaceholder(attachments) {
|
|
872
|
-
if (attachments.length === 0) return "";
|
|
873
|
-
const mimeTypes = attachments.map((entry) => entry.mimeType ?? "");
|
|
874
|
-
const allImages = mimeTypes.every((entry) => entry.startsWith("image/"));
|
|
875
|
-
const allVideos = mimeTypes.every((entry) => entry.startsWith("video/"));
|
|
876
|
-
const allAudio = mimeTypes.every((entry) => entry.startsWith("audio/"));
|
|
877
|
-
const tag = allImages ? "<media:image>" : allVideos ? "<media:video>" : allAudio ? "<media:audio>" : "<media:attachment>";
|
|
878
|
-
const label = allImages ? "image" : allVideos ? "video" : allAudio ? "audio" : "file";
|
|
879
|
-
const suffix = attachments.length === 1 ? label : `${label}s`;
|
|
880
|
-
return `${tag} (${attachments.length} ${suffix})`;
|
|
881
|
-
}
|
|
882
|
-
function buildMessagePlaceholder(message) {
|
|
883
|
-
const attachmentPlaceholder = buildAttachmentPlaceholder(message.attachments ?? []);
|
|
884
|
-
if (attachmentPlaceholder) return attachmentPlaceholder;
|
|
885
|
-
if (message.balloonBundleId) return "<media:sticker>";
|
|
886
|
-
return "";
|
|
887
|
-
}
|
|
888
|
-
function formatReplyTag(message) {
|
|
889
|
-
const rawId = message.replyToShortId || message.replyToId;
|
|
890
|
-
if (!rawId) return null;
|
|
891
|
-
return `[[reply_to:${rawId}]]`;
|
|
892
|
-
}
|
|
893
|
-
function extractReplyMetadata(message) {
|
|
894
|
-
const replyRecord = asRecord$1(message["replyTo"] ?? message["reply_to"] ?? message["replyToMessage"] ?? message["reply_to_message"] ?? message["repliedMessage"] ?? message["quotedMessage"] ?? message["associatedMessage"] ?? message["reply"]);
|
|
895
|
-
const replyHandle = asRecord$1(replyRecord?.["handle"]) ?? asRecord$1(replyRecord?.["sender"]) ?? null;
|
|
896
|
-
const replySenderRaw = readString(replyHandle, "address") ?? readString(replyHandle, "handle") ?? readString(replyHandle, "id") ?? readString(replyRecord, "senderId") ?? readString(replyRecord, "sender") ?? readString(replyRecord, "from");
|
|
897
|
-
const normalizedSender = replySenderRaw ? normalizeBlueBubblesHandle(replySenderRaw) || replySenderRaw.trim() : void 0;
|
|
898
|
-
const replyToBody = readString(replyRecord, "text") ?? readString(replyRecord, "body") ?? readString(replyRecord, "message") ?? readString(replyRecord, "subject") ?? void 0;
|
|
899
|
-
const directReplyId = readString(message, "replyToMessageGuid") ?? readString(message, "replyToGuid") ?? readString(message, "replyGuid") ?? readString(message, "selectedMessageGuid") ?? readString(message, "selectedMessageId") ?? readString(message, "replyToMessageId") ?? readString(message, "replyId") ?? readString(replyRecord, "guid") ?? readString(replyRecord, "id") ?? readString(replyRecord, "messageId");
|
|
900
|
-
const associatedType = readNumberLike(message, "associatedMessageType") ?? readNumberLike(message, "associated_message_type");
|
|
901
|
-
const associatedGuid = readString(message, "associatedMessageGuid") ?? readString(message, "associated_message_guid") ?? readString(message, "associatedMessageId");
|
|
902
|
-
const isReactionAssociation = typeof associatedType === "number" && REACTION_TYPE_MAP.has(associatedType);
|
|
903
|
-
const replyToId = directReplyId ?? (!isReactionAssociation ? associatedGuid : void 0);
|
|
904
|
-
const threadOriginatorGuid = readString(message, "threadOriginatorGuid");
|
|
905
|
-
const messageGuid = readString(message, "guid");
|
|
906
|
-
return {
|
|
907
|
-
replyToId: (replyToId ?? (!replyToId && threadOriginatorGuid && threadOriginatorGuid !== messageGuid ? threadOriginatorGuid : void 0))?.trim() || void 0,
|
|
908
|
-
replyToBody: replyToBody?.trim() || void 0,
|
|
909
|
-
replyToSender: normalizedSender || void 0
|
|
910
|
-
};
|
|
911
|
-
}
|
|
912
|
-
function readFirstChatRecord(message) {
|
|
913
|
-
const chats = message["chats"];
|
|
914
|
-
if (!Array.isArray(chats) || chats.length === 0) return null;
|
|
915
|
-
const first = chats[0];
|
|
916
|
-
return asRecord$1(first);
|
|
917
|
-
}
|
|
918
|
-
function extractSenderInfo(message) {
|
|
919
|
-
const handleValue = message.handle ?? message.sender;
|
|
920
|
-
const handle = asRecord$1(handleValue) ?? (typeof handleValue === "string" ? { address: handleValue } : null);
|
|
921
|
-
const senderId = (readString(handle, "address") ?? readString(handle, "handle") ?? readString(handle, "id") ?? readString(message, "senderId") ?? readString(message, "sender") ?? readString(message, "from") ?? "").trim();
|
|
922
|
-
const senderName = readString(handle, "displayName") ?? readString(handle, "name") ?? readString(message, "senderName") ?? void 0;
|
|
923
|
-
return {
|
|
924
|
-
senderId,
|
|
925
|
-
senderIdExplicit: Boolean(senderId),
|
|
926
|
-
senderName
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
|
-
function extractChatContext(message) {
|
|
930
|
-
const chat = asRecord$1(message.chat) ?? asRecord$1(message.conversation) ?? null;
|
|
931
|
-
const chatFromList = readFirstChatRecord(message);
|
|
932
|
-
const chatGuid = readString(message, "chatGuid") ?? readString(message, "chat_guid") ?? readString(chat, "chatGuid") ?? readString(chat, "chat_guid") ?? readString(chat, "guid") ?? readString(chatFromList, "chatGuid") ?? readString(chatFromList, "chat_guid") ?? readString(chatFromList, "guid");
|
|
933
|
-
const chatIdentifier = readString(message, "chatIdentifier") ?? readString(message, "chat_identifier") ?? readString(chat, "chatIdentifier") ?? readString(chat, "chat_identifier") ?? readString(chat, "identifier") ?? readString(chatFromList, "chatIdentifier") ?? readString(chatFromList, "chat_identifier") ?? readString(chatFromList, "identifier") ?? extractChatIdentifierFromChatGuid(chatGuid);
|
|
934
|
-
const chatId = readNumberLike(message, "chatId") ?? readNumberLike(message, "chat_id") ?? readNumberLike(chat, "chatId") ?? readNumberLike(chat, "chat_id") ?? readNumberLike(chat, "id") ?? readNumberLike(chatFromList, "chatId") ?? readNumberLike(chatFromList, "chat_id") ?? readNumberLike(chatFromList, "id");
|
|
935
|
-
const chatName = readString(message, "chatName") ?? readString(chat, "displayName") ?? readString(chat, "name") ?? readString(chatFromList, "displayName") ?? readString(chatFromList, "name") ?? void 0;
|
|
936
|
-
const chatParticipants = chat ? chat["participants"] : void 0;
|
|
937
|
-
const messageParticipants = message["participants"];
|
|
938
|
-
const chatsParticipants = chatFromList ? chatFromList["participants"] : void 0;
|
|
939
|
-
const participants = Array.isArray(chatParticipants) ? chatParticipants : Array.isArray(messageParticipants) ? messageParticipants : Array.isArray(chatsParticipants) ? chatsParticipants : [];
|
|
940
|
-
const participantsCount = participants.length;
|
|
941
|
-
const groupFromChatGuid = resolveGroupFlagFromChatGuid(chatGuid);
|
|
942
|
-
const explicitIsGroup = readBoolean(message, "isGroup") ?? readBoolean(message, "is_group") ?? readBoolean(chat, "isGroup") ?? readBoolean(message, "group");
|
|
943
|
-
return {
|
|
944
|
-
chatGuid,
|
|
945
|
-
chatIdentifier,
|
|
946
|
-
chatId,
|
|
947
|
-
chatName,
|
|
948
|
-
isGroup: typeof groupFromChatGuid === "boolean" ? groupFromChatGuid : explicitIsGroup ?? participantsCount > 2,
|
|
949
|
-
participants
|
|
950
|
-
};
|
|
951
|
-
}
|
|
952
|
-
function normalizeParticipantEntry(entry) {
|
|
953
|
-
if (typeof entry === "string" || typeof entry === "number") {
|
|
954
|
-
const raw = String(entry).trim();
|
|
955
|
-
if (!raw) return null;
|
|
956
|
-
const normalized = normalizeBlueBubblesHandle(raw) || raw;
|
|
957
|
-
return normalized ? { id: normalized } : null;
|
|
958
|
-
}
|
|
959
|
-
const record = asRecord$1(entry);
|
|
960
|
-
if (!record) return null;
|
|
961
|
-
const nestedHandle = asRecord$1(record["handle"]) ?? asRecord$1(record["sender"]) ?? asRecord$1(record["contact"]) ?? null;
|
|
962
|
-
const idRaw = readString(record, "address") ?? readString(record, "handle") ?? readString(record, "id") ?? readString(record, "phoneNumber") ?? readString(record, "phone_number") ?? readString(record, "email") ?? readString(nestedHandle, "address") ?? readString(nestedHandle, "handle") ?? readString(nestedHandle, "id");
|
|
963
|
-
const nameRaw = readString(record, "displayName") ?? readString(record, "name") ?? readString(record, "title") ?? readString(nestedHandle, "displayName") ?? readString(nestedHandle, "name");
|
|
964
|
-
const normalizedId = idRaw ? normalizeBlueBubblesHandle(idRaw) || idRaw.trim() : "";
|
|
965
|
-
if (!normalizedId) return null;
|
|
966
|
-
return {
|
|
967
|
-
id: normalizedId,
|
|
968
|
-
name: nameRaw?.trim() || void 0
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
function normalizeParticipantList(raw) {
|
|
972
|
-
if (!Array.isArray(raw) || raw.length === 0) return [];
|
|
973
|
-
const seen = /* @__PURE__ */ new Set();
|
|
974
|
-
const output = [];
|
|
975
|
-
for (const entry of raw) {
|
|
976
|
-
const normalized = normalizeParticipantEntry(entry);
|
|
977
|
-
if (!normalized?.id) continue;
|
|
978
|
-
const key = normalized.id.toLowerCase();
|
|
979
|
-
if (seen.has(key)) continue;
|
|
980
|
-
seen.add(key);
|
|
981
|
-
output.push(normalized);
|
|
982
|
-
}
|
|
983
|
-
return output;
|
|
984
|
-
}
|
|
985
|
-
function formatGroupMembers(params) {
|
|
986
|
-
const seen = /* @__PURE__ */ new Set();
|
|
987
|
-
const ordered = [];
|
|
988
|
-
for (const entry of params.participants ?? []) {
|
|
989
|
-
if (!entry?.id) continue;
|
|
990
|
-
const key = entry.id.toLowerCase();
|
|
991
|
-
if (seen.has(key)) continue;
|
|
992
|
-
seen.add(key);
|
|
993
|
-
ordered.push(entry);
|
|
994
|
-
}
|
|
995
|
-
if (ordered.length === 0 && params.fallback?.id) ordered.push(params.fallback);
|
|
996
|
-
if (ordered.length === 0) return;
|
|
997
|
-
return ordered.map((entry) => entry.name ? `${entry.name} (${entry.id})` : entry.id).join(", ");
|
|
998
|
-
}
|
|
999
|
-
function resolveGroupFlagFromChatGuid(chatGuid) {
|
|
1000
|
-
const guid = chatGuid?.trim();
|
|
1001
|
-
if (!guid) return;
|
|
1002
|
-
const parts = guid.split(";");
|
|
1003
|
-
if (parts.length >= 3) {
|
|
1004
|
-
if (parts[1] === "+") return true;
|
|
1005
|
-
if (parts[1] === "-") return false;
|
|
1006
|
-
}
|
|
1007
|
-
if (guid.includes(";+;")) return true;
|
|
1008
|
-
if (guid.includes(";-;")) return false;
|
|
1009
|
-
}
|
|
1010
|
-
function extractChatIdentifierFromChatGuid(chatGuid) {
|
|
1011
|
-
const guid = chatGuid?.trim();
|
|
1012
|
-
if (!guid) return;
|
|
1013
|
-
const parts = guid.split(";");
|
|
1014
|
-
if (parts.length < 3) return;
|
|
1015
|
-
return parts[2]?.trim() || void 0;
|
|
1016
|
-
}
|
|
1017
|
-
function formatGroupAllowlistEntry(params) {
|
|
1018
|
-
const guid = params.chatGuid?.trim();
|
|
1019
|
-
if (guid) return `chat_guid:${guid}`;
|
|
1020
|
-
const chatId = params.chatId;
|
|
1021
|
-
if (typeof chatId === "number" && Number.isFinite(chatId)) return `chat_id:${chatId}`;
|
|
1022
|
-
const identifier = params.chatIdentifier?.trim();
|
|
1023
|
-
if (identifier) return `chat_identifier:${identifier}`;
|
|
1024
|
-
return null;
|
|
1025
|
-
}
|
|
1026
|
-
const REACTION_TYPE_MAP = new Map([
|
|
1027
|
-
[2e3, {
|
|
1028
|
-
emoji: "❤️",
|
|
1029
|
-
action: "added"
|
|
1030
|
-
}],
|
|
1031
|
-
[2001, {
|
|
1032
|
-
emoji: "👍",
|
|
1033
|
-
action: "added"
|
|
1034
|
-
}],
|
|
1035
|
-
[2002, {
|
|
1036
|
-
emoji: "👎",
|
|
1037
|
-
action: "added"
|
|
1038
|
-
}],
|
|
1039
|
-
[2003, {
|
|
1040
|
-
emoji: "😂",
|
|
1041
|
-
action: "added"
|
|
1042
|
-
}],
|
|
1043
|
-
[2004, {
|
|
1044
|
-
emoji: "‼️",
|
|
1045
|
-
action: "added"
|
|
1046
|
-
}],
|
|
1047
|
-
[2005, {
|
|
1048
|
-
emoji: "❓",
|
|
1049
|
-
action: "added"
|
|
1050
|
-
}],
|
|
1051
|
-
[3e3, {
|
|
1052
|
-
emoji: "❤️",
|
|
1053
|
-
action: "removed"
|
|
1054
|
-
}],
|
|
1055
|
-
[3001, {
|
|
1056
|
-
emoji: "👍",
|
|
1057
|
-
action: "removed"
|
|
1058
|
-
}],
|
|
1059
|
-
[3002, {
|
|
1060
|
-
emoji: "👎",
|
|
1061
|
-
action: "removed"
|
|
1062
|
-
}],
|
|
1063
|
-
[3003, {
|
|
1064
|
-
emoji: "😂",
|
|
1065
|
-
action: "removed"
|
|
1066
|
-
}],
|
|
1067
|
-
[3004, {
|
|
1068
|
-
emoji: "‼️",
|
|
1069
|
-
action: "removed"
|
|
1070
|
-
}],
|
|
1071
|
-
[3005, {
|
|
1072
|
-
emoji: "❓",
|
|
1073
|
-
action: "removed"
|
|
1074
|
-
}]
|
|
1075
|
-
]);
|
|
1076
|
-
const TAPBACK_TEXT_MAP = new Map([
|
|
1077
|
-
["loved", {
|
|
1078
|
-
emoji: "❤️",
|
|
1079
|
-
action: "added"
|
|
1080
|
-
}],
|
|
1081
|
-
["liked", {
|
|
1082
|
-
emoji: "👍",
|
|
1083
|
-
action: "added"
|
|
1084
|
-
}],
|
|
1085
|
-
["disliked", {
|
|
1086
|
-
emoji: "👎",
|
|
1087
|
-
action: "added"
|
|
1088
|
-
}],
|
|
1089
|
-
["laughed at", {
|
|
1090
|
-
emoji: "😂",
|
|
1091
|
-
action: "added"
|
|
1092
|
-
}],
|
|
1093
|
-
["emphasized", {
|
|
1094
|
-
emoji: "‼️",
|
|
1095
|
-
action: "added"
|
|
1096
|
-
}],
|
|
1097
|
-
["questioned", {
|
|
1098
|
-
emoji: "❓",
|
|
1099
|
-
action: "added"
|
|
1100
|
-
}],
|
|
1101
|
-
["removed a heart from", {
|
|
1102
|
-
emoji: "❤️",
|
|
1103
|
-
action: "removed"
|
|
1104
|
-
}],
|
|
1105
|
-
["removed a like from", {
|
|
1106
|
-
emoji: "👍",
|
|
1107
|
-
action: "removed"
|
|
1108
|
-
}],
|
|
1109
|
-
["removed a dislike from", {
|
|
1110
|
-
emoji: "👎",
|
|
1111
|
-
action: "removed"
|
|
1112
|
-
}],
|
|
1113
|
-
["removed a laugh from", {
|
|
1114
|
-
emoji: "😂",
|
|
1115
|
-
action: "removed"
|
|
1116
|
-
}],
|
|
1117
|
-
["removed an emphasis from", {
|
|
1118
|
-
emoji: "‼️",
|
|
1119
|
-
action: "removed"
|
|
1120
|
-
}],
|
|
1121
|
-
["removed a question from", {
|
|
1122
|
-
emoji: "❓",
|
|
1123
|
-
action: "removed"
|
|
1124
|
-
}]
|
|
1125
|
-
]);
|
|
1126
|
-
const TAPBACK_EMOJI_REGEX = /(?:\p{Regional_Indicator}{2})|(?:[0-9#*]\uFE0F?\u20E3)|(?:\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?(?:\p{Emoji_Modifier})?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\uFE0E)?(?:\p{Emoji_Modifier})?)*)/u;
|
|
1127
|
-
function extractFirstEmoji(text) {
|
|
1128
|
-
const match = text.match(TAPBACK_EMOJI_REGEX);
|
|
1129
|
-
return match ? match[0] : null;
|
|
1130
|
-
}
|
|
1131
|
-
function extractQuotedTapbackText(text) {
|
|
1132
|
-
const match = text.match(/[“"]([^”"]+)[”"]/s);
|
|
1133
|
-
return match ? match[1] : null;
|
|
1134
|
-
}
|
|
1135
|
-
function isTapbackAssociatedType(type) {
|
|
1136
|
-
return typeof type === "number" && Number.isFinite(type) && type >= 2e3 && type < 4e3;
|
|
1137
|
-
}
|
|
1138
|
-
function resolveTapbackActionHint(type) {
|
|
1139
|
-
if (typeof type !== "number" || !Number.isFinite(type)) return;
|
|
1140
|
-
if (type >= 3e3 && type < 4e3) return "removed";
|
|
1141
|
-
if (type >= 2e3 && type < 3e3) return "added";
|
|
1142
|
-
}
|
|
1143
|
-
function resolveTapbackContext(message) {
|
|
1144
|
-
const associatedType = message.associatedMessageType;
|
|
1145
|
-
const hasTapbackType = isTapbackAssociatedType(associatedType);
|
|
1146
|
-
const hasTapbackMarker = Boolean(message.associatedMessageEmoji) || Boolean(message.isTapback);
|
|
1147
|
-
if (!hasTapbackType && !hasTapbackMarker) return null;
|
|
1148
|
-
const replyToId = message.associatedMessageGuid?.trim() || message.replyToId?.trim() || void 0;
|
|
1149
|
-
const actionHint = resolveTapbackActionHint(associatedType);
|
|
1150
|
-
return {
|
|
1151
|
-
emojiHint: message.associatedMessageEmoji?.trim() || REACTION_TYPE_MAP.get(associatedType ?? -1)?.emoji,
|
|
1152
|
-
actionHint,
|
|
1153
|
-
replyToId
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1156
|
-
function parseTapbackText(params) {
|
|
1157
|
-
const trimmed = params.text.trim();
|
|
1158
|
-
const lower = trimmed.toLowerCase();
|
|
1159
|
-
if (!trimmed) return null;
|
|
1160
|
-
const parseLeadingReactionAction = (prefix, defaultAction) => {
|
|
1161
|
-
if (!lower.startsWith(prefix)) return null;
|
|
1162
|
-
const emoji = extractFirstEmoji(trimmed) ?? params.emojiHint;
|
|
1163
|
-
if (!emoji) return null;
|
|
1164
|
-
const quotedText = extractQuotedTapbackText(trimmed);
|
|
1165
|
-
if (params.requireQuoted && !quotedText) return null;
|
|
1166
|
-
const fallback = trimmed.slice(prefix.length).trim();
|
|
1167
|
-
return {
|
|
1168
|
-
emoji,
|
|
1169
|
-
action: params.actionHint ?? defaultAction,
|
|
1170
|
-
quotedText: quotedText ?? fallback
|
|
1171
|
-
};
|
|
1172
|
-
};
|
|
1173
|
-
for (const [pattern, { emoji, action }] of TAPBACK_TEXT_MAP) if (lower.startsWith(pattern)) {
|
|
1174
|
-
const afterPattern = trimmed.slice(pattern.length).trim();
|
|
1175
|
-
if (params.requireQuoted) {
|
|
1176
|
-
const strictMatch = afterPattern.match(/^[“"](.+)[”"]$/s);
|
|
1177
|
-
if (!strictMatch) return null;
|
|
1178
|
-
return {
|
|
1179
|
-
emoji,
|
|
1180
|
-
action,
|
|
1181
|
-
quotedText: strictMatch[1]
|
|
1182
|
-
};
|
|
1183
|
-
}
|
|
1184
|
-
return {
|
|
1185
|
-
emoji,
|
|
1186
|
-
action,
|
|
1187
|
-
quotedText: extractQuotedTapbackText(afterPattern) ?? extractQuotedTapbackText(trimmed) ?? afterPattern
|
|
1188
|
-
};
|
|
1189
|
-
}
|
|
1190
|
-
const reacted = parseLeadingReactionAction("reacted", "added");
|
|
1191
|
-
if (reacted) return reacted;
|
|
1192
|
-
const removed = parseLeadingReactionAction("removed", "removed");
|
|
1193
|
-
if (removed) return removed;
|
|
1194
|
-
return null;
|
|
1195
|
-
}
|
|
1196
|
-
function extractMessagePayload(payload) {
|
|
1197
|
-
const parseRecord = (value) => {
|
|
1198
|
-
const record = asRecord$1(value);
|
|
1199
|
-
if (record) return record;
|
|
1200
|
-
if (Array.isArray(value)) {
|
|
1201
|
-
for (const entry of value) {
|
|
1202
|
-
const parsedEntry = parseRecord(entry);
|
|
1203
|
-
if (parsedEntry) return parsedEntry;
|
|
1204
|
-
}
|
|
1205
|
-
return null;
|
|
1206
|
-
}
|
|
1207
|
-
if (typeof value !== "string") return null;
|
|
1208
|
-
const trimmed = value.trim();
|
|
1209
|
-
if (!trimmed) return null;
|
|
1210
|
-
try {
|
|
1211
|
-
return parseRecord(JSON.parse(trimmed));
|
|
1212
|
-
} catch {
|
|
1213
|
-
return null;
|
|
1214
|
-
}
|
|
1215
|
-
};
|
|
1216
|
-
const data = parseRecord(payload.data ?? payload.payload ?? payload.event);
|
|
1217
|
-
const message = parseRecord(payload.message ?? data?.message ?? data);
|
|
1218
|
-
if (message) return message;
|
|
1219
|
-
return null;
|
|
1220
|
-
}
|
|
1221
|
-
function normalizeWebhookMessage(payload) {
|
|
1222
|
-
const message = extractMessagePayload(payload);
|
|
1223
|
-
if (!message) return null;
|
|
1224
|
-
const text = readString(message, "text") ?? readString(message, "body") ?? readString(message, "subject") ?? "";
|
|
1225
|
-
const { senderId, senderIdExplicit, senderName } = extractSenderInfo(message);
|
|
1226
|
-
const { chatGuid, chatIdentifier, chatId, chatName, isGroup, participants } = extractChatContext(message);
|
|
1227
|
-
const normalizedParticipants = normalizeParticipantList(participants);
|
|
1228
|
-
const fromMe = readBoolean(message, "isFromMe") ?? readBoolean(message, "is_from_me");
|
|
1229
|
-
const messageId = readString(message, "guid") ?? readString(message, "id") ?? readString(message, "messageId") ?? void 0;
|
|
1230
|
-
const balloonBundleId = readString(message, "balloonBundleId");
|
|
1231
|
-
const associatedMessageGuid = readString(message, "associatedMessageGuid") ?? readString(message, "associated_message_guid") ?? readString(message, "associatedMessageId") ?? void 0;
|
|
1232
|
-
const associatedMessageType = readNumberLike(message, "associatedMessageType") ?? readNumberLike(message, "associated_message_type");
|
|
1233
|
-
const associatedMessageEmoji = readString(message, "associatedMessageEmoji") ?? readString(message, "associated_message_emoji") ?? readString(message, "reactionEmoji") ?? readString(message, "reaction_emoji") ?? void 0;
|
|
1234
|
-
const isTapback = readBoolean(message, "isTapback") ?? readBoolean(message, "is_tapback") ?? readBoolean(message, "tapback") ?? void 0;
|
|
1235
|
-
const timestampRaw = readNumber(message, "date") ?? readNumber(message, "dateCreated") ?? readNumber(message, "timestamp");
|
|
1236
|
-
const timestamp = typeof timestampRaw === "number" ? timestampRaw > 0xe8d4a51000 ? timestampRaw : timestampRaw * 1e3 : void 0;
|
|
1237
|
-
const senderFallbackFromChatGuid = !senderIdExplicit && !isGroup && chatGuid ? extractHandleFromChatGuid(chatGuid) : null;
|
|
1238
|
-
const normalizedSender = normalizeBlueBubblesHandle(senderId || senderFallbackFromChatGuid || "");
|
|
1239
|
-
if (!normalizedSender) return null;
|
|
1240
|
-
const replyMetadata = extractReplyMetadata(message);
|
|
1241
|
-
return {
|
|
1242
|
-
text,
|
|
1243
|
-
senderId: normalizedSender,
|
|
1244
|
-
senderIdExplicit,
|
|
1245
|
-
senderName,
|
|
1246
|
-
messageId,
|
|
1247
|
-
timestamp,
|
|
1248
|
-
isGroup,
|
|
1249
|
-
chatId,
|
|
1250
|
-
chatGuid,
|
|
1251
|
-
chatIdentifier,
|
|
1252
|
-
chatName,
|
|
1253
|
-
fromMe,
|
|
1254
|
-
attachments: extractAttachments(message),
|
|
1255
|
-
balloonBundleId,
|
|
1256
|
-
associatedMessageGuid,
|
|
1257
|
-
associatedMessageType,
|
|
1258
|
-
associatedMessageEmoji,
|
|
1259
|
-
isTapback,
|
|
1260
|
-
participants: normalizedParticipants,
|
|
1261
|
-
replyToId: replyMetadata.replyToId,
|
|
1262
|
-
replyToBody: replyMetadata.replyToBody,
|
|
1263
|
-
replyToSender: replyMetadata.replyToSender
|
|
1264
|
-
};
|
|
1265
|
-
}
|
|
1266
|
-
function normalizeWebhookReaction(payload) {
|
|
1267
|
-
const message = extractMessagePayload(payload);
|
|
1268
|
-
if (!message) return null;
|
|
1269
|
-
const associatedGuid = readString(message, "associatedMessageGuid") ?? readString(message, "associated_message_guid") ?? readString(message, "associatedMessageId");
|
|
1270
|
-
const associatedType = readNumberLike(message, "associatedMessageType") ?? readNumberLike(message, "associated_message_type");
|
|
1271
|
-
if (!associatedGuid || associatedType === void 0) return null;
|
|
1272
|
-
const mapping = REACTION_TYPE_MAP.get(associatedType);
|
|
1273
|
-
const emoji = ((readString(message, "associatedMessageEmoji") ?? readString(message, "associated_message_emoji") ?? readString(message, "reactionEmoji") ?? readString(message, "reaction_emoji"))?.trim() || mapping?.emoji) ?? `reaction:${associatedType}`;
|
|
1274
|
-
const action = mapping?.action ?? resolveTapbackActionHint(associatedType) ?? "added";
|
|
1275
|
-
const { senderId, senderIdExplicit, senderName } = extractSenderInfo(message);
|
|
1276
|
-
const { chatGuid, chatIdentifier, chatId, chatName, isGroup } = extractChatContext(message);
|
|
1277
|
-
const fromMe = readBoolean(message, "isFromMe") ?? readBoolean(message, "is_from_me");
|
|
1278
|
-
const timestampRaw = readNumberLike(message, "date") ?? readNumberLike(message, "dateCreated") ?? readNumberLike(message, "timestamp");
|
|
1279
|
-
const timestamp = typeof timestampRaw === "number" ? timestampRaw > 0xe8d4a51000 ? timestampRaw : timestampRaw * 1e3 : void 0;
|
|
1280
|
-
const senderFallbackFromChatGuid = !senderIdExplicit && !isGroup && chatGuid ? extractHandleFromChatGuid(chatGuid) : null;
|
|
1281
|
-
const normalizedSender = normalizeBlueBubblesHandle(senderId || senderFallbackFromChatGuid || "");
|
|
1282
|
-
if (!normalizedSender) return null;
|
|
1283
|
-
return {
|
|
1284
|
-
action,
|
|
1285
|
-
emoji,
|
|
1286
|
-
senderId: normalizedSender,
|
|
1287
|
-
senderIdExplicit,
|
|
1288
|
-
senderName,
|
|
1289
|
-
messageId: associatedGuid,
|
|
1290
|
-
timestamp,
|
|
1291
|
-
isGroup,
|
|
1292
|
-
chatId,
|
|
1293
|
-
chatGuid,
|
|
1294
|
-
chatIdentifier,
|
|
1295
|
-
chatName,
|
|
1296
|
-
fromMe
|
|
1297
|
-
};
|
|
1298
|
-
}
|
|
1299
|
-
//#endregion
|
|
1300
|
-
//#region extensions/bluebubbles/src/history.ts
|
|
1301
|
-
function resolveAccount$1(params) {
|
|
1302
|
-
return resolveBlueBubblesServerAccount(params);
|
|
1303
|
-
}
|
|
1304
|
-
const MAX_HISTORY_FETCH_LIMIT = 100;
|
|
1305
|
-
const HISTORY_SCAN_MULTIPLIER = 8;
|
|
1306
|
-
const MAX_HISTORY_SCAN_MESSAGES = 500;
|
|
1307
|
-
const MAX_HISTORY_BODY_CHARS = 2e3;
|
|
1308
|
-
function clampHistoryLimit(limit) {
|
|
1309
|
-
if (!Number.isFinite(limit)) return 0;
|
|
1310
|
-
const normalized = Math.floor(limit);
|
|
1311
|
-
if (normalized <= 0) return 0;
|
|
1312
|
-
return Math.min(normalized, MAX_HISTORY_FETCH_LIMIT);
|
|
1313
|
-
}
|
|
1314
|
-
function truncateHistoryBody$1(text) {
|
|
1315
|
-
if (text.length <= MAX_HISTORY_BODY_CHARS) return text;
|
|
1316
|
-
return `${text.slice(0, MAX_HISTORY_BODY_CHARS).trimEnd()}...`;
|
|
1317
|
-
}
|
|
1318
|
-
/**
|
|
1319
|
-
* Fetch message history from BlueBubbles API for a specific chat.
|
|
1320
|
-
* This provides the initial backfill for both group chats and DMs.
|
|
1321
|
-
*/
|
|
1322
|
-
async function fetchBlueBubblesHistory(chatIdentifier, limit, opts = {}) {
|
|
1323
|
-
const effectiveLimit = clampHistoryLimit(limit);
|
|
1324
|
-
if (!chatIdentifier.trim() || effectiveLimit <= 0) return {
|
|
1325
|
-
entries: [],
|
|
1326
|
-
resolved: true
|
|
1327
|
-
};
|
|
1328
|
-
let baseUrl;
|
|
1329
|
-
let password;
|
|
1330
|
-
try {
|
|
1331
|
-
({baseUrl, password} = resolveAccount$1(opts));
|
|
1332
|
-
} catch {
|
|
1333
|
-
return {
|
|
1334
|
-
entries: [],
|
|
1335
|
-
resolved: false
|
|
1336
|
-
};
|
|
1337
|
-
}
|
|
1338
|
-
const possiblePaths = [
|
|
1339
|
-
`/api/v1/chat/${encodeURIComponent(chatIdentifier)}/messages?limit=${effectiveLimit}&sort=DESC`,
|
|
1340
|
-
`/api/v1/messages?chatGuid=${encodeURIComponent(chatIdentifier)}&limit=${effectiveLimit}`,
|
|
1341
|
-
`/api/v1/chat/${encodeURIComponent(chatIdentifier)}/message?limit=${effectiveLimit}`
|
|
1342
|
-
];
|
|
1343
|
-
for (const path of possiblePaths) try {
|
|
1344
|
-
const res = await blueBubblesFetchWithTimeout(buildBlueBubblesApiUrl({
|
|
1345
|
-
baseUrl,
|
|
1346
|
-
path,
|
|
1347
|
-
password
|
|
1348
|
-
}), { method: "GET" }, opts.timeoutMs ?? 1e4);
|
|
1349
|
-
if (!res.ok) continue;
|
|
1350
|
-
const data = await res.json().catch(() => null);
|
|
1351
|
-
if (!data) continue;
|
|
1352
|
-
let messages = [];
|
|
1353
|
-
if (Array.isArray(data)) messages = data;
|
|
1354
|
-
else if (data.data && Array.isArray(data.data)) messages = data.data;
|
|
1355
|
-
else if (data.messages && Array.isArray(data.messages)) messages = data.messages;
|
|
1356
|
-
else continue;
|
|
1357
|
-
const historyEntries = [];
|
|
1358
|
-
const maxScannedMessages = Math.min(Math.max(effectiveLimit * HISTORY_SCAN_MULTIPLIER, effectiveLimit), MAX_HISTORY_SCAN_MESSAGES);
|
|
1359
|
-
for (let i = 0; i < messages.length && i < maxScannedMessages; i++) {
|
|
1360
|
-
const msg = messages[i];
|
|
1361
|
-
const text = msg.text?.trim();
|
|
1362
|
-
if (!text) continue;
|
|
1363
|
-
const sender = msg.is_from_me ? "me" : msg.sender?.display_name || msg.sender?.address || msg.handle_id || "Unknown";
|
|
1364
|
-
const timestamp = msg.date_created || msg.date_delivered;
|
|
1365
|
-
historyEntries.push({
|
|
1366
|
-
sender,
|
|
1367
|
-
body: truncateHistoryBody$1(text),
|
|
1368
|
-
timestamp,
|
|
1369
|
-
messageId: msg.guid
|
|
1370
|
-
});
|
|
1371
|
-
}
|
|
1372
|
-
historyEntries.sort((a, b) => {
|
|
1373
|
-
return (a.timestamp || 0) - (b.timestamp || 0);
|
|
1374
|
-
});
|
|
1375
|
-
return {
|
|
1376
|
-
entries: historyEntries.slice(0, effectiveLimit),
|
|
1377
|
-
resolved: true
|
|
1378
|
-
};
|
|
1379
|
-
} catch (error) {
|
|
1380
|
-
continue;
|
|
1381
|
-
}
|
|
1382
|
-
return {
|
|
1383
|
-
entries: [],
|
|
1384
|
-
resolved: false
|
|
1385
|
-
};
|
|
1386
|
-
}
|
|
1387
|
-
//#endregion
|
|
1388
|
-
//#region extensions/bluebubbles/src/media-send.ts
|
|
1389
|
-
const HTTP_URL_RE = /^https?:\/\//i;
|
|
1390
|
-
const MB = 1024 * 1024;
|
|
1391
|
-
function assertMediaWithinLimit(sizeBytes, maxBytes) {
|
|
1392
|
-
if (typeof maxBytes !== "number" || maxBytes <= 0) return;
|
|
1393
|
-
if (sizeBytes <= maxBytes) return;
|
|
1394
|
-
const maxLabel = (maxBytes / MB).toFixed(0);
|
|
1395
|
-
const sizeLabel = (sizeBytes / MB).toFixed(2);
|
|
1396
|
-
throw new Error(`Media exceeds ${maxLabel}MB limit (got ${sizeLabel}MB)`);
|
|
1397
|
-
}
|
|
1398
|
-
function resolveLocalMediaPath(source) {
|
|
1399
|
-
if (!source.startsWith("file://")) return source;
|
|
1400
|
-
try {
|
|
1401
|
-
return fileURLToPath(source);
|
|
1402
|
-
} catch {
|
|
1403
|
-
throw new Error(`Invalid file:// URL: ${source}`);
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
function expandHomePath(input) {
|
|
1407
|
-
if (input === "~") return os.homedir();
|
|
1408
|
-
if (input.startsWith("~/") || input.startsWith(`~${path.sep}`)) return path.join(os.homedir(), input.slice(2));
|
|
1409
|
-
return input;
|
|
1410
|
-
}
|
|
1411
|
-
function resolveConfiguredPath(input) {
|
|
1412
|
-
const trimmed = input.trim();
|
|
1413
|
-
if (!trimmed) throw new Error("Empty mediaLocalRoots entry is not allowed");
|
|
1414
|
-
if (trimmed.startsWith("file://")) {
|
|
1415
|
-
let parsed;
|
|
1416
|
-
try {
|
|
1417
|
-
parsed = fileURLToPath(trimmed);
|
|
1418
|
-
} catch {
|
|
1419
|
-
throw new Error(`Invalid file:// URL in mediaLocalRoots: ${input}`);
|
|
1420
|
-
}
|
|
1421
|
-
if (!path.isAbsolute(parsed)) throw new Error(`mediaLocalRoots entries must be absolute paths: ${input}`);
|
|
1422
|
-
return parsed;
|
|
1423
|
-
}
|
|
1424
|
-
const resolved = expandHomePath(trimmed);
|
|
1425
|
-
if (!path.isAbsolute(resolved)) throw new Error(`mediaLocalRoots entries must be absolute paths: ${input}`);
|
|
1426
|
-
return resolved;
|
|
1427
|
-
}
|
|
1428
|
-
function isPathInsideRoot(candidate, root) {
|
|
1429
|
-
const normalizedCandidate = path.normalize(candidate);
|
|
1430
|
-
const normalizedRoot = path.normalize(root);
|
|
1431
|
-
const rootWithSep = normalizedRoot.endsWith(path.sep) ? normalizedRoot : normalizedRoot + path.sep;
|
|
1432
|
-
if (process.platform === "win32") {
|
|
1433
|
-
const candidateLower = normalizedCandidate.toLowerCase();
|
|
1434
|
-
const rootLower = normalizedRoot.toLowerCase();
|
|
1435
|
-
const rootWithSepLower = rootWithSep.toLowerCase();
|
|
1436
|
-
return candidateLower === rootLower || candidateLower.startsWith(rootWithSepLower);
|
|
1437
|
-
}
|
|
1438
|
-
return normalizedCandidate === normalizedRoot || normalizedCandidate.startsWith(rootWithSep);
|
|
1439
|
-
}
|
|
1440
|
-
function resolveMediaLocalRoots(params) {
|
|
1441
|
-
return (resolveBlueBubblesAccount({
|
|
1442
|
-
cfg: params.cfg,
|
|
1443
|
-
accountId: params.accountId
|
|
1444
|
-
}).config.mediaLocalRoots ?? []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
1445
|
-
}
|
|
1446
|
-
async function assertLocalMediaPathAllowed(params) {
|
|
1447
|
-
if (params.localRoots.length === 0) throw new Error(`Local BlueBubbles media paths are disabled by default. Set channels.bluebubbles.mediaLocalRoots${params.accountId ? ` or channels.bluebubbles.accounts.${params.accountId}.mediaLocalRoots` : ""} to explicitly allow local file directories.`);
|
|
1448
|
-
const resolvedLocalPath = path.resolve(params.localPath);
|
|
1449
|
-
const supportsNoFollow = process.platform !== "win32" && "O_NOFOLLOW" in constants;
|
|
1450
|
-
const openFlags = constants.O_RDONLY | (supportsNoFollow ? constants.O_NOFOLLOW : 0);
|
|
1451
|
-
for (const rootEntry of params.localRoots) {
|
|
1452
|
-
const resolvedRootInput = resolveConfiguredPath(rootEntry);
|
|
1453
|
-
const relativeToRoot = path.relative(resolvedRootInput, resolvedLocalPath);
|
|
1454
|
-
if (relativeToRoot.startsWith("..") || path.isAbsolute(relativeToRoot) || relativeToRoot === "") continue;
|
|
1455
|
-
let rootReal;
|
|
1456
|
-
try {
|
|
1457
|
-
rootReal = await fs$1.realpath(resolvedRootInput);
|
|
1458
|
-
} catch {
|
|
1459
|
-
rootReal = path.resolve(resolvedRootInput);
|
|
1460
|
-
}
|
|
1461
|
-
const candidatePath = path.resolve(rootReal, relativeToRoot);
|
|
1462
|
-
if (!isPathInsideRoot(candidatePath, rootReal)) continue;
|
|
1463
|
-
let handle = null;
|
|
1464
|
-
try {
|
|
1465
|
-
handle = await fs$1.open(candidatePath, openFlags);
|
|
1466
|
-
const realPath = await fs$1.realpath(candidatePath);
|
|
1467
|
-
if (!isPathInsideRoot(realPath, rootReal)) continue;
|
|
1468
|
-
const stat = await handle.stat();
|
|
1469
|
-
if (!stat.isFile()) continue;
|
|
1470
|
-
const realStat = await fs$1.stat(realPath);
|
|
1471
|
-
if (stat.ino !== realStat.ino || stat.dev !== realStat.dev) continue;
|
|
1472
|
-
return {
|
|
1473
|
-
data: await handle.readFile(),
|
|
1474
|
-
realPath,
|
|
1475
|
-
sizeBytes: stat.size
|
|
1476
|
-
};
|
|
1477
|
-
} catch {
|
|
1478
|
-
continue;
|
|
1479
|
-
} finally {
|
|
1480
|
-
if (handle) await handle.close().catch(() => {});
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
throw new Error(`Local media path is not under any configured mediaLocalRoots entry: ${params.localPath}`);
|
|
1484
|
-
}
|
|
1485
|
-
function resolveFilenameFromSource(source) {
|
|
1486
|
-
if (!source) return;
|
|
1487
|
-
if (source.startsWith("file://")) try {
|
|
1488
|
-
return path.basename(fileURLToPath(source)) || void 0;
|
|
1489
|
-
} catch {
|
|
1490
|
-
return;
|
|
1491
|
-
}
|
|
1492
|
-
if (HTTP_URL_RE.test(source)) try {
|
|
1493
|
-
return path.basename(new URL(source).pathname) || void 0;
|
|
1494
|
-
} catch {
|
|
1495
|
-
return;
|
|
1496
|
-
}
|
|
1497
|
-
return path.basename(source) || void 0;
|
|
1498
|
-
}
|
|
1499
|
-
async function sendBlueBubblesMedia(params) {
|
|
1500
|
-
const { cfg, to, mediaUrl, mediaPath, mediaBuffer, contentType, filename, caption, replyToId, accountId, asVoice } = params;
|
|
1501
|
-
const core = getBlueBubblesRuntime();
|
|
1502
|
-
const maxBytes = resolveChannelMediaMaxBytes({
|
|
1503
|
-
cfg,
|
|
1504
|
-
resolveChannelLimitMb: ({ cfg, accountId }) => cfg.channels?.bluebubbles?.accounts?.[accountId]?.mediaMaxMb ?? cfg.channels?.bluebubbles?.mediaMaxMb,
|
|
1505
|
-
accountId
|
|
1506
|
-
});
|
|
1507
|
-
const mediaLocalRoots = resolveMediaLocalRoots({
|
|
1508
|
-
cfg,
|
|
1509
|
-
accountId
|
|
1510
|
-
});
|
|
1511
|
-
let buffer;
|
|
1512
|
-
let resolvedContentType = contentType ?? void 0;
|
|
1513
|
-
let resolvedFilename = filename ?? void 0;
|
|
1514
|
-
if (mediaBuffer) {
|
|
1515
|
-
assertMediaWithinLimit(mediaBuffer.byteLength, maxBytes);
|
|
1516
|
-
buffer = mediaBuffer;
|
|
1517
|
-
if (!resolvedContentType) {
|
|
1518
|
-
const hint = mediaPath ?? mediaUrl;
|
|
1519
|
-
resolvedContentType = await core.media.detectMime({
|
|
1520
|
-
buffer: Buffer.isBuffer(mediaBuffer) ? mediaBuffer : Buffer.from(mediaBuffer),
|
|
1521
|
-
filePath: hint
|
|
1522
|
-
}) ?? void 0;
|
|
1523
|
-
}
|
|
1524
|
-
if (!resolvedFilename) resolvedFilename = resolveFilenameFromSource(mediaPath ?? mediaUrl);
|
|
1525
|
-
} else {
|
|
1526
|
-
const source = mediaPath ?? mediaUrl;
|
|
1527
|
-
if (!source) throw new Error("BlueBubbles media delivery requires mediaUrl, mediaPath, or mediaBuffer.");
|
|
1528
|
-
if (HTTP_URL_RE.test(source)) {
|
|
1529
|
-
const fetched = await core.channel.media.fetchRemoteMedia({
|
|
1530
|
-
url: source,
|
|
1531
|
-
maxBytes: typeof maxBytes === "number" && maxBytes > 0 ? maxBytes : void 0
|
|
1532
|
-
});
|
|
1533
|
-
buffer = fetched.buffer;
|
|
1534
|
-
resolvedContentType = resolvedContentType ?? fetched.contentType ?? void 0;
|
|
1535
|
-
resolvedFilename = resolvedFilename ?? fetched.fileName;
|
|
1536
|
-
} else {
|
|
1537
|
-
const localFile = await assertLocalMediaPathAllowed({
|
|
1538
|
-
localPath: expandHomePath(resolveLocalMediaPath(source)),
|
|
1539
|
-
localRoots: mediaLocalRoots,
|
|
1540
|
-
accountId
|
|
1541
|
-
});
|
|
1542
|
-
if (typeof maxBytes === "number" && maxBytes > 0) assertMediaWithinLimit(localFile.sizeBytes, maxBytes);
|
|
1543
|
-
const data = localFile.data;
|
|
1544
|
-
assertMediaWithinLimit(data.byteLength, maxBytes);
|
|
1545
|
-
buffer = new Uint8Array(data);
|
|
1546
|
-
if (!resolvedContentType) resolvedContentType = await core.media.detectMime({
|
|
1547
|
-
buffer: data,
|
|
1548
|
-
filePath: localFile.realPath
|
|
1549
|
-
}) ?? void 0;
|
|
1550
|
-
if (!resolvedFilename) resolvedFilename = resolveFilenameFromSource(localFile.realPath);
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
const replyToMessageGuid = replyToId?.trim() ? resolveBlueBubblesMessageId(replyToId.trim(), { requireKnownShortId: true }) : void 0;
|
|
1554
|
-
const attachmentResult = await sendBlueBubblesAttachment({
|
|
1555
|
-
to,
|
|
1556
|
-
buffer,
|
|
1557
|
-
filename: resolvedFilename ?? "attachment",
|
|
1558
|
-
contentType: resolvedContentType ?? void 0,
|
|
1559
|
-
replyToMessageGuid,
|
|
1560
|
-
asVoice,
|
|
1561
|
-
opts: {
|
|
1562
|
-
cfg,
|
|
1563
|
-
accountId
|
|
1564
|
-
}
|
|
1565
|
-
});
|
|
1566
|
-
const trimmedCaption = caption?.trim();
|
|
1567
|
-
if (trimmedCaption) await sendMessageBlueBubbles(to, trimmedCaption, {
|
|
1568
|
-
cfg,
|
|
1569
|
-
accountId,
|
|
1570
|
-
replyToMessageGuid
|
|
1571
|
-
});
|
|
1572
|
-
return attachmentResult;
|
|
1573
|
-
}
|
|
1574
|
-
//#endregion
|
|
1575
|
-
//#region extensions/bluebubbles/src/monitor-reply-cache.ts
|
|
1576
|
-
const REPLY_CACHE_MAX = 2e3;
|
|
1577
|
-
const REPLY_CACHE_TTL_MS = 360 * 60 * 1e3;
|
|
1578
|
-
const blueBubblesReplyCacheByMessageId = /* @__PURE__ */ new Map();
|
|
1579
|
-
const blueBubblesShortIdToUuid = /* @__PURE__ */ new Map();
|
|
1580
|
-
const blueBubblesUuidToShortId = /* @__PURE__ */ new Map();
|
|
1581
|
-
let blueBubblesShortIdCounter = 0;
|
|
1582
|
-
function trimOrUndefined$2(value) {
|
|
1583
|
-
const trimmed = value?.trim();
|
|
1584
|
-
return trimmed ? trimmed : void 0;
|
|
1585
|
-
}
|
|
1586
|
-
function generateShortId() {
|
|
1587
|
-
blueBubblesShortIdCounter += 1;
|
|
1588
|
-
return String(blueBubblesShortIdCounter);
|
|
1589
|
-
}
|
|
1590
|
-
function rememberBlueBubblesReplyCache(entry) {
|
|
1591
|
-
const messageId = entry.messageId.trim();
|
|
1592
|
-
if (!messageId) return {
|
|
1593
|
-
...entry,
|
|
1594
|
-
shortId: ""
|
|
1595
|
-
};
|
|
1596
|
-
let shortId = blueBubblesUuidToShortId.get(messageId);
|
|
1597
|
-
if (!shortId) {
|
|
1598
|
-
shortId = generateShortId();
|
|
1599
|
-
blueBubblesShortIdToUuid.set(shortId, messageId);
|
|
1600
|
-
blueBubblesUuidToShortId.set(messageId, shortId);
|
|
1601
|
-
}
|
|
1602
|
-
const fullEntry = {
|
|
1603
|
-
...entry,
|
|
1604
|
-
messageId,
|
|
1605
|
-
shortId
|
|
1606
|
-
};
|
|
1607
|
-
blueBubblesReplyCacheByMessageId.delete(messageId);
|
|
1608
|
-
blueBubblesReplyCacheByMessageId.set(messageId, fullEntry);
|
|
1609
|
-
const cutoff = Date.now() - REPLY_CACHE_TTL_MS;
|
|
1610
|
-
for (const [key, value] of blueBubblesReplyCacheByMessageId) {
|
|
1611
|
-
if (value.timestamp < cutoff) {
|
|
1612
|
-
blueBubblesReplyCacheByMessageId.delete(key);
|
|
1613
|
-
if (value.shortId) {
|
|
1614
|
-
blueBubblesShortIdToUuid.delete(value.shortId);
|
|
1615
|
-
blueBubblesUuidToShortId.delete(key);
|
|
1616
|
-
}
|
|
1617
|
-
continue;
|
|
1618
|
-
}
|
|
1619
|
-
break;
|
|
1620
|
-
}
|
|
1621
|
-
while (blueBubblesReplyCacheByMessageId.size > REPLY_CACHE_MAX) {
|
|
1622
|
-
const oldest = blueBubblesReplyCacheByMessageId.keys().next().value;
|
|
1623
|
-
if (!oldest) break;
|
|
1624
|
-
const oldEntry = blueBubblesReplyCacheByMessageId.get(oldest);
|
|
1625
|
-
blueBubblesReplyCacheByMessageId.delete(oldest);
|
|
1626
|
-
if (oldEntry?.shortId) {
|
|
1627
|
-
blueBubblesShortIdToUuid.delete(oldEntry.shortId);
|
|
1628
|
-
blueBubblesUuidToShortId.delete(oldest);
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
return fullEntry;
|
|
1632
|
-
}
|
|
1633
|
-
/**
|
|
1634
|
-
* Resolves a short message ID (e.g., "1", "2") to a full BlueBubbles GUID.
|
|
1635
|
-
* Returns the input unchanged if it's already a GUID or not found in the mapping.
|
|
1636
|
-
*/
|
|
1637
|
-
function resolveBlueBubblesMessageId(shortOrUuid, opts) {
|
|
1638
|
-
const trimmed = shortOrUuid.trim();
|
|
1639
|
-
if (!trimmed) return trimmed;
|
|
1640
|
-
if (/^\d+$/.test(trimmed)) {
|
|
1641
|
-
const uuid = blueBubblesShortIdToUuid.get(trimmed);
|
|
1642
|
-
if (uuid) return uuid;
|
|
1643
|
-
if (opts?.requireKnownShortId) throw new Error(`BlueBubbles short message id "${trimmed}" is no longer available. Use MessageSidFull.`);
|
|
1644
|
-
}
|
|
1645
|
-
return trimmed;
|
|
1646
|
-
}
|
|
1647
|
-
/**
|
|
1648
|
-
* Gets the short ID for a message GUID, if one exists.
|
|
1649
|
-
*/
|
|
1650
|
-
function getShortIdForUuid(uuid) {
|
|
1651
|
-
return blueBubblesUuidToShortId.get(uuid.trim());
|
|
1652
|
-
}
|
|
1653
|
-
function resolveReplyContextFromCache(params) {
|
|
1654
|
-
const replyToId = params.replyToId.trim();
|
|
1655
|
-
if (!replyToId) return null;
|
|
1656
|
-
const cached = blueBubblesReplyCacheByMessageId.get(replyToId);
|
|
1657
|
-
if (!cached) return null;
|
|
1658
|
-
if (cached.accountId !== params.accountId) return null;
|
|
1659
|
-
const cutoff = Date.now() - REPLY_CACHE_TTL_MS;
|
|
1660
|
-
if (cached.timestamp < cutoff) {
|
|
1661
|
-
blueBubblesReplyCacheByMessageId.delete(replyToId);
|
|
1662
|
-
return null;
|
|
1663
|
-
}
|
|
1664
|
-
const chatGuid = trimOrUndefined$2(params.chatGuid);
|
|
1665
|
-
const chatIdentifier = trimOrUndefined$2(params.chatIdentifier);
|
|
1666
|
-
const cachedChatGuid = trimOrUndefined$2(cached.chatGuid);
|
|
1667
|
-
const cachedChatIdentifier = trimOrUndefined$2(cached.chatIdentifier);
|
|
1668
|
-
const chatId = typeof params.chatId === "number" ? params.chatId : void 0;
|
|
1669
|
-
const cachedChatId = typeof cached.chatId === "number" ? cached.chatId : void 0;
|
|
1670
|
-
if (chatGuid && cachedChatGuid && chatGuid !== cachedChatGuid) return null;
|
|
1671
|
-
if (!chatGuid && chatIdentifier && cachedChatIdentifier && chatIdentifier !== cachedChatIdentifier) return null;
|
|
1672
|
-
if (!chatGuid && !chatIdentifier && chatId && cachedChatId && chatId !== cachedChatId) return null;
|
|
1673
|
-
return cached;
|
|
1674
|
-
}
|
|
1675
|
-
//#endregion
|
|
1676
|
-
//#region extensions/bluebubbles/src/monitor-self-chat-cache.ts
|
|
1677
|
-
const SELF_CHAT_TTL_MS = 1e4;
|
|
1678
|
-
const MAX_SELF_CHAT_CACHE_ENTRIES = 512;
|
|
1679
|
-
const CLEANUP_MIN_INTERVAL_MS = 1e3;
|
|
1680
|
-
const MAX_SELF_CHAT_BODY_CHARS = 32768;
|
|
1681
|
-
const cache = /* @__PURE__ */ new Map();
|
|
1682
|
-
let lastCleanupAt = 0;
|
|
1683
|
-
function normalizeBody(body) {
|
|
1684
|
-
if (!body) return null;
|
|
1685
|
-
const normalized = (body.length > MAX_SELF_CHAT_BODY_CHARS ? body.slice(0, MAX_SELF_CHAT_BODY_CHARS) : body).replace(/\r\n?/g, "\n").trim();
|
|
1686
|
-
return normalized ? normalized : null;
|
|
1687
|
-
}
|
|
1688
|
-
function isUsableTimestamp(timestamp) {
|
|
1689
|
-
return typeof timestamp === "number" && Number.isFinite(timestamp);
|
|
1690
|
-
}
|
|
1691
|
-
function digestText(text) {
|
|
1692
|
-
return createHash("sha256").update(text).digest("base64url");
|
|
1693
|
-
}
|
|
1694
|
-
function trimOrUndefined$1(value) {
|
|
1695
|
-
const trimmed = value?.trim();
|
|
1696
|
-
return trimmed ? trimmed : void 0;
|
|
1697
|
-
}
|
|
1698
|
-
function resolveCanonicalChatTarget(parts) {
|
|
1699
|
-
const handleFromGuid = parts.chatGuid ? extractHandleFromChatGuid(parts.chatGuid) : null;
|
|
1700
|
-
if (handleFromGuid) return handleFromGuid;
|
|
1701
|
-
const normalizedIdentifier = normalizeBlueBubblesHandle(parts.chatIdentifier ?? "");
|
|
1702
|
-
if (normalizedIdentifier) return normalizedIdentifier;
|
|
1703
|
-
return trimOrUndefined$1(parts.chatGuid) ?? trimOrUndefined$1(parts.chatIdentifier) ?? (typeof parts.chatId === "number" ? String(parts.chatId) : null);
|
|
1704
|
-
}
|
|
1705
|
-
function buildScope(parts) {
|
|
1706
|
-
const target = resolveCanonicalChatTarget(parts) ?? parts.senderId;
|
|
1707
|
-
return `${parts.accountId}:${target}`;
|
|
1708
|
-
}
|
|
1709
|
-
function cleanupExpired(now = Date.now()) {
|
|
1710
|
-
if (lastCleanupAt !== 0 && now >= lastCleanupAt && now - lastCleanupAt < CLEANUP_MIN_INTERVAL_MS) return;
|
|
1711
|
-
lastCleanupAt = now;
|
|
1712
|
-
for (const [key, seenAt] of cache.entries()) if (now - seenAt > SELF_CHAT_TTL_MS) cache.delete(key);
|
|
1713
|
-
}
|
|
1714
|
-
function enforceSizeCap() {
|
|
1715
|
-
while (cache.size > MAX_SELF_CHAT_CACHE_ENTRIES) {
|
|
1716
|
-
const oldestKey = cache.keys().next().value;
|
|
1717
|
-
if (typeof oldestKey !== "string") break;
|
|
1718
|
-
cache.delete(oldestKey);
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
function buildKey(lookup) {
|
|
1722
|
-
const body = normalizeBody(lookup.body);
|
|
1723
|
-
if (!body || !isUsableTimestamp(lookup.timestamp)) return null;
|
|
1724
|
-
return `${buildScope(lookup)}:${lookup.timestamp}:${digestText(body)}`;
|
|
1725
|
-
}
|
|
1726
|
-
function rememberBlueBubblesSelfChatCopy(lookup) {
|
|
1727
|
-
cleanupExpired();
|
|
1728
|
-
const key = buildKey(lookup);
|
|
1729
|
-
if (!key) return;
|
|
1730
|
-
cache.set(key, Date.now());
|
|
1731
|
-
enforceSizeCap();
|
|
1732
|
-
}
|
|
1733
|
-
function hasBlueBubblesSelfChatCopy(lookup) {
|
|
1734
|
-
cleanupExpired();
|
|
1735
|
-
const key = buildKey(lookup);
|
|
1736
|
-
if (!key) return false;
|
|
1737
|
-
const seenAt = cache.get(key);
|
|
1738
|
-
return typeof seenAt === "number" && Date.now() - seenAt <= SELF_CHAT_TTL_MS;
|
|
1739
|
-
}
|
|
1740
|
-
//#endregion
|
|
1741
|
-
//#region extensions/bluebubbles/src/reactions.ts
|
|
1742
|
-
const REACTION_TYPES = new Set([
|
|
1743
|
-
"love",
|
|
1744
|
-
"like",
|
|
1745
|
-
"dislike",
|
|
1746
|
-
"laugh",
|
|
1747
|
-
"emphasize",
|
|
1748
|
-
"question"
|
|
1749
|
-
]);
|
|
1750
|
-
const REACTION_ALIASES = new Map([
|
|
1751
|
-
["heart", "love"],
|
|
1752
|
-
["love", "love"],
|
|
1753
|
-
["❤", "love"],
|
|
1754
|
-
["❤️", "love"],
|
|
1755
|
-
["red_heart", "love"],
|
|
1756
|
-
["thumbs_up", "like"],
|
|
1757
|
-
["thumbsup", "like"],
|
|
1758
|
-
["thumbs-up", "like"],
|
|
1759
|
-
["thumbsup", "like"],
|
|
1760
|
-
["like", "like"],
|
|
1761
|
-
["thumb", "like"],
|
|
1762
|
-
["ok", "like"],
|
|
1763
|
-
["thumbs_down", "dislike"],
|
|
1764
|
-
["thumbsdown", "dislike"],
|
|
1765
|
-
["thumbs-down", "dislike"],
|
|
1766
|
-
["dislike", "dislike"],
|
|
1767
|
-
["boo", "dislike"],
|
|
1768
|
-
["no", "dislike"],
|
|
1769
|
-
["haha", "laugh"],
|
|
1770
|
-
["lol", "laugh"],
|
|
1771
|
-
["lmao", "laugh"],
|
|
1772
|
-
["rofl", "laugh"],
|
|
1773
|
-
["😂", "laugh"],
|
|
1774
|
-
["🤣", "laugh"],
|
|
1775
|
-
["xd", "laugh"],
|
|
1776
|
-
["laugh", "laugh"],
|
|
1777
|
-
["emphasis", "emphasize"],
|
|
1778
|
-
["emphasize", "emphasize"],
|
|
1779
|
-
["exclaim", "emphasize"],
|
|
1780
|
-
["!!", "emphasize"],
|
|
1781
|
-
["‼", "emphasize"],
|
|
1782
|
-
["‼️", "emphasize"],
|
|
1783
|
-
["❗", "emphasize"],
|
|
1784
|
-
["important", "emphasize"],
|
|
1785
|
-
["bang", "emphasize"],
|
|
1786
|
-
["question", "question"],
|
|
1787
|
-
["?", "question"],
|
|
1788
|
-
["❓", "question"],
|
|
1789
|
-
["❔", "question"],
|
|
1790
|
-
["ask", "question"],
|
|
1791
|
-
["loved", "love"],
|
|
1792
|
-
["liked", "like"],
|
|
1793
|
-
["disliked", "dislike"],
|
|
1794
|
-
["laughed", "laugh"],
|
|
1795
|
-
["emphasized", "emphasize"],
|
|
1796
|
-
["questioned", "question"],
|
|
1797
|
-
["fire", "love"],
|
|
1798
|
-
["🔥", "love"],
|
|
1799
|
-
["wow", "emphasize"],
|
|
1800
|
-
["!", "emphasize"],
|
|
1801
|
-
["heart_eyes", "love"],
|
|
1802
|
-
["smile", "laugh"],
|
|
1803
|
-
["smiley", "laugh"],
|
|
1804
|
-
["happy", "laugh"],
|
|
1805
|
-
["joy", "laugh"]
|
|
1806
|
-
]);
|
|
1807
|
-
const REACTION_EMOJIS = new Map([
|
|
1808
|
-
["❤️", "love"],
|
|
1809
|
-
["❤", "love"],
|
|
1810
|
-
["♥️", "love"],
|
|
1811
|
-
["♥", "love"],
|
|
1812
|
-
["😍", "love"],
|
|
1813
|
-
["💕", "love"],
|
|
1814
|
-
["👍", "like"],
|
|
1815
|
-
["👌", "like"],
|
|
1816
|
-
["👎", "dislike"],
|
|
1817
|
-
["🙅", "dislike"],
|
|
1818
|
-
["😂", "laugh"],
|
|
1819
|
-
["🤣", "laugh"],
|
|
1820
|
-
["😆", "laugh"],
|
|
1821
|
-
["😁", "laugh"],
|
|
1822
|
-
["😹", "laugh"],
|
|
1823
|
-
["‼️", "emphasize"],
|
|
1824
|
-
["‼", "emphasize"],
|
|
1825
|
-
["!!", "emphasize"],
|
|
1826
|
-
["❗", "emphasize"],
|
|
1827
|
-
["❕", "emphasize"],
|
|
1828
|
-
["!", "emphasize"],
|
|
1829
|
-
["❓", "question"],
|
|
1830
|
-
["❔", "question"],
|
|
1831
|
-
["?", "question"]
|
|
1832
|
-
]);
|
|
1833
|
-
function resolveAccount(params) {
|
|
1834
|
-
return resolveBlueBubblesServerAccount(params);
|
|
1835
|
-
}
|
|
1836
|
-
function normalizeBlueBubblesReactionInput(emoji, remove) {
|
|
1837
|
-
const trimmed = emoji.trim();
|
|
1838
|
-
if (!trimmed) throw new Error("BlueBubbles reaction requires an emoji or name.");
|
|
1839
|
-
let raw = trimmed.toLowerCase();
|
|
1840
|
-
if (raw.startsWith("-")) raw = raw.slice(1);
|
|
1841
|
-
const aliased = REACTION_ALIASES.get(raw) ?? raw;
|
|
1842
|
-
const mapped = REACTION_EMOJIS.get(trimmed) ?? REACTION_EMOJIS.get(raw) ?? aliased;
|
|
1843
|
-
if (!REACTION_TYPES.has(mapped)) throw new Error(`Unsupported BlueBubbles reaction: ${trimmed}`);
|
|
1844
|
-
return remove ? `-${mapped}` : mapped;
|
|
1845
|
-
}
|
|
1846
|
-
async function sendBlueBubblesReaction(params) {
|
|
1847
|
-
const chatGuid = params.chatGuid.trim();
|
|
1848
|
-
const messageGuid = params.messageGuid.trim();
|
|
1849
|
-
if (!chatGuid) throw new Error("BlueBubbles reaction requires chatGuid.");
|
|
1850
|
-
if (!messageGuid) throw new Error("BlueBubbles reaction requires messageGuid.");
|
|
1851
|
-
const reaction = normalizeBlueBubblesReactionInput(params.emoji, params.remove);
|
|
1852
|
-
const { baseUrl, password, accountId } = resolveAccount(params.opts ?? {});
|
|
1853
|
-
if (getCachedBlueBubblesPrivateApiStatus(accountId) === false) throw new Error("BlueBubbles reaction requires Private API, but it is disabled on the BlueBubbles server.");
|
|
1854
|
-
const url = buildBlueBubblesApiUrl({
|
|
1855
|
-
baseUrl,
|
|
1856
|
-
path: "/api/v1/message/react",
|
|
1857
|
-
password
|
|
1858
|
-
});
|
|
1859
|
-
const payload = {
|
|
1860
|
-
chatGuid,
|
|
1861
|
-
selectedMessageGuid: messageGuid,
|
|
1862
|
-
reaction,
|
|
1863
|
-
partIndex: typeof params.partIndex === "number" ? params.partIndex : 0
|
|
1864
|
-
};
|
|
1865
|
-
const res = await blueBubblesFetchWithTimeout(url, {
|
|
1866
|
-
method: "POST",
|
|
1867
|
-
headers: { "Content-Type": "application/json" },
|
|
1868
|
-
body: JSON.stringify(payload)
|
|
1869
|
-
}, params.opts?.timeoutMs);
|
|
1870
|
-
if (!res.ok) {
|
|
1871
|
-
const errorText = await res.text();
|
|
1872
|
-
throw new Error(`BlueBubbles reaction failed (${res.status}): ${errorText || "unknown"}`);
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
//#endregion
|
|
1876
|
-
//#region extensions/bluebubbles/src/monitor-processing.ts
|
|
1877
|
-
const DEFAULT_TEXT_LIMIT = 4e3;
|
|
1878
|
-
const invalidAckReactions = /* @__PURE__ */ new Set();
|
|
1879
|
-
const REPLY_DIRECTIVE_TAG_RE = /\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+)\s*\]\]/gi;
|
|
1880
|
-
const PENDING_OUTBOUND_MESSAGE_ID_TTL_MS = 120 * 1e3;
|
|
1881
|
-
const pendingOutboundMessageIds = [];
|
|
1882
|
-
let pendingOutboundMessageIdCounter = 0;
|
|
1883
|
-
function trimOrUndefined(value) {
|
|
1884
|
-
const trimmed = value?.trim();
|
|
1885
|
-
return trimmed ? trimmed : void 0;
|
|
1886
|
-
}
|
|
1887
|
-
function normalizeSnippet(value) {
|
|
1888
|
-
return stripMarkdown(value).replace(/\s+/g, " ").trim().toLowerCase();
|
|
1889
|
-
}
|
|
1890
|
-
function isBlueBubblesSelfChatMessage(message, isGroup) {
|
|
1891
|
-
if (isGroup || !message.senderIdExplicit) return false;
|
|
1892
|
-
const chatHandle = (message.chatGuid ? extractHandleFromChatGuid(message.chatGuid) : null) ?? normalizeBlueBubblesHandle(message.chatIdentifier ?? "");
|
|
1893
|
-
return Boolean(chatHandle) && chatHandle === message.senderId;
|
|
1894
|
-
}
|
|
1895
|
-
function prunePendingOutboundMessageIds(now = Date.now()) {
|
|
1896
|
-
const cutoff = now - PENDING_OUTBOUND_MESSAGE_ID_TTL_MS;
|
|
1897
|
-
for (let i = pendingOutboundMessageIds.length - 1; i >= 0; i--) if (pendingOutboundMessageIds[i].createdAt < cutoff) pendingOutboundMessageIds.splice(i, 1);
|
|
1898
|
-
}
|
|
1899
|
-
function rememberPendingOutboundMessageId(entry) {
|
|
1900
|
-
prunePendingOutboundMessageIds();
|
|
1901
|
-
pendingOutboundMessageIdCounter += 1;
|
|
1902
|
-
const snippetRaw = entry.snippet.trim();
|
|
1903
|
-
const snippetNorm = normalizeSnippet(snippetRaw);
|
|
1904
|
-
pendingOutboundMessageIds.push({
|
|
1905
|
-
id: pendingOutboundMessageIdCounter,
|
|
1906
|
-
accountId: entry.accountId,
|
|
1907
|
-
sessionKey: entry.sessionKey,
|
|
1908
|
-
outboundTarget: entry.outboundTarget,
|
|
1909
|
-
chatGuid: trimOrUndefined(entry.chatGuid),
|
|
1910
|
-
chatIdentifier: trimOrUndefined(entry.chatIdentifier),
|
|
1911
|
-
chatId: typeof entry.chatId === "number" ? entry.chatId : void 0,
|
|
1912
|
-
snippetRaw,
|
|
1913
|
-
snippetNorm,
|
|
1914
|
-
isMediaSnippet: snippetRaw.toLowerCase().startsWith("<media:"),
|
|
1915
|
-
createdAt: Date.now()
|
|
1916
|
-
});
|
|
1917
|
-
return pendingOutboundMessageIdCounter;
|
|
1918
|
-
}
|
|
1919
|
-
function forgetPendingOutboundMessageId(id) {
|
|
1920
|
-
const index = pendingOutboundMessageIds.findIndex((entry) => entry.id === id);
|
|
1921
|
-
if (index >= 0) pendingOutboundMessageIds.splice(index, 1);
|
|
1922
|
-
}
|
|
1923
|
-
function chatsMatch(left, right) {
|
|
1924
|
-
const leftGuid = trimOrUndefined(left.chatGuid);
|
|
1925
|
-
const rightGuid = trimOrUndefined(right.chatGuid);
|
|
1926
|
-
if (leftGuid && rightGuid) return leftGuid === rightGuid;
|
|
1927
|
-
const leftIdentifier = trimOrUndefined(left.chatIdentifier);
|
|
1928
|
-
const rightIdentifier = trimOrUndefined(right.chatIdentifier);
|
|
1929
|
-
if (leftIdentifier && rightIdentifier) return leftIdentifier === rightIdentifier;
|
|
1930
|
-
const leftChatId = typeof left.chatId === "number" ? left.chatId : void 0;
|
|
1931
|
-
const rightChatId = typeof right.chatId === "number" ? right.chatId : void 0;
|
|
1932
|
-
if (leftChatId !== void 0 && rightChatId !== void 0) return leftChatId === rightChatId;
|
|
1933
|
-
return false;
|
|
1934
|
-
}
|
|
1935
|
-
function consumePendingOutboundMessageId(params) {
|
|
1936
|
-
prunePendingOutboundMessageIds();
|
|
1937
|
-
const bodyNorm = normalizeSnippet(params.body);
|
|
1938
|
-
const isMediaBody = params.body.trim().toLowerCase().startsWith("<media:");
|
|
1939
|
-
for (let i = 0; i < pendingOutboundMessageIds.length; i++) {
|
|
1940
|
-
const entry = pendingOutboundMessageIds[i];
|
|
1941
|
-
if (entry.accountId !== params.accountId) continue;
|
|
1942
|
-
if (!chatsMatch(entry, params)) continue;
|
|
1943
|
-
if (entry.snippetNorm && entry.snippetNorm === bodyNorm) {
|
|
1944
|
-
pendingOutboundMessageIds.splice(i, 1);
|
|
1945
|
-
return entry;
|
|
1946
|
-
}
|
|
1947
|
-
if (entry.isMediaSnippet && isMediaBody) {
|
|
1948
|
-
pendingOutboundMessageIds.splice(i, 1);
|
|
1949
|
-
return entry;
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
return null;
|
|
1953
|
-
}
|
|
1954
|
-
function logVerbose(core, runtime, message) {
|
|
1955
|
-
if (core.logging.shouldLogVerbose()) runtime.log?.(`[bluebubbles] ${message}`);
|
|
1956
|
-
}
|
|
1957
|
-
function logGroupAllowlistHint(params) {
|
|
1958
|
-
const log = params.runtime.log ?? console.log;
|
|
1959
|
-
const nameHint = params.chatName ? ` (group name: ${params.chatName})` : "";
|
|
1960
|
-
const accountHint = params.accountId ? ` (or channels.bluebubbles.accounts.${params.accountId}.groupAllowFrom)` : "";
|
|
1961
|
-
if (params.entry) {
|
|
1962
|
-
log(`[bluebubbles] group message blocked (${params.reason}). Allow this group by adding "${params.entry}" to channels.bluebubbles.groupAllowFrom${nameHint}.`);
|
|
1963
|
-
log(`[bluebubbles] add to config: channels.bluebubbles.groupAllowFrom=["${params.entry}"]${accountHint}.`);
|
|
1964
|
-
return;
|
|
1965
|
-
}
|
|
1966
|
-
log(`[bluebubbles] group message blocked (${params.reason}). Allow groups by setting channels.bluebubbles.groupPolicy="open" or adding a group id to channels.bluebubbles.groupAllowFrom${accountHint}${nameHint}.`);
|
|
1967
|
-
}
|
|
1968
|
-
function resolveBlueBubblesAckReaction(params) {
|
|
1969
|
-
const raw = resolveAckReaction(params.cfg, params.agentId).trim();
|
|
1970
|
-
if (!raw) return null;
|
|
1971
|
-
try {
|
|
1972
|
-
normalizeBlueBubblesReactionInput(raw);
|
|
1973
|
-
return raw;
|
|
1974
|
-
} catch {
|
|
1975
|
-
const key = raw.toLowerCase();
|
|
1976
|
-
if (!invalidAckReactions.has(key)) {
|
|
1977
|
-
invalidAckReactions.add(key);
|
|
1978
|
-
logVerbose(params.core, params.runtime, `ack reaction skipped (unsupported for BlueBubbles): ${raw}`);
|
|
1979
|
-
}
|
|
1980
|
-
return null;
|
|
1981
|
-
}
|
|
1982
|
-
}
|
|
1983
|
-
/**
|
|
1984
|
-
* In-memory rolling history map keyed by account + chat identifier.
|
|
1985
|
-
* Populated from incoming messages during the session.
|
|
1986
|
-
* API backfill is attempted until one fetch resolves (or retries are exhausted).
|
|
1987
|
-
*/
|
|
1988
|
-
const chatHistories = /* @__PURE__ */ new Map();
|
|
1989
|
-
const historyBackfills = /* @__PURE__ */ new Map();
|
|
1990
|
-
const HISTORY_BACKFILL_BASE_DELAY_MS = 5e3;
|
|
1991
|
-
const HISTORY_BACKFILL_MAX_DELAY_MS = 120 * 1e3;
|
|
1992
|
-
const HISTORY_BACKFILL_MAX_ATTEMPTS = 6;
|
|
1993
|
-
const HISTORY_BACKFILL_RETRY_WINDOW_MS = 1800 * 1e3;
|
|
1994
|
-
const MAX_STORED_HISTORY_ENTRY_CHARS = 2e3;
|
|
1995
|
-
const MAX_INBOUND_HISTORY_ENTRY_CHARS = 1200;
|
|
1996
|
-
const MAX_INBOUND_HISTORY_TOTAL_CHARS = 12e3;
|
|
1997
|
-
function buildAccountScopedHistoryKey(accountId, historyIdentifier) {
|
|
1998
|
-
return `${accountId}\u0000${historyIdentifier}`;
|
|
1999
|
-
}
|
|
2000
|
-
function historyDedupKey(entry) {
|
|
2001
|
-
const messageId = entry.messageId?.trim();
|
|
2002
|
-
if (messageId) return `id:${messageId}`;
|
|
2003
|
-
return `fallback:${entry.sender}\u0000${entry.body}\u0000${entry.timestamp ?? ""}`;
|
|
2004
|
-
}
|
|
2005
|
-
function truncateHistoryBody(body, maxChars) {
|
|
2006
|
-
const trimmed = body.trim();
|
|
2007
|
-
if (!trimmed) return "";
|
|
2008
|
-
if (trimmed.length <= maxChars) return trimmed;
|
|
2009
|
-
return `${trimmed.slice(0, maxChars).trimEnd()}...`;
|
|
2010
|
-
}
|
|
2011
|
-
function mergeHistoryEntries(params) {
|
|
2012
|
-
if (params.limit <= 0) return [];
|
|
2013
|
-
const merged = [];
|
|
2014
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2015
|
-
const appendUnique = (entry) => {
|
|
2016
|
-
const key = historyDedupKey(entry);
|
|
2017
|
-
if (seen.has(key)) return;
|
|
2018
|
-
seen.add(key);
|
|
2019
|
-
merged.push(entry);
|
|
2020
|
-
};
|
|
2021
|
-
for (const entry of params.apiEntries) appendUnique(entry);
|
|
2022
|
-
for (const entry of params.currentEntries) appendUnique(entry);
|
|
2023
|
-
if (merged.length <= params.limit) return merged;
|
|
2024
|
-
return merged.slice(merged.length - params.limit);
|
|
2025
|
-
}
|
|
2026
|
-
function pruneHistoryBackfillState() {
|
|
2027
|
-
for (const key of historyBackfills.keys()) if (!chatHistories.has(key)) historyBackfills.delete(key);
|
|
2028
|
-
}
|
|
2029
|
-
function markHistoryBackfillResolved(historyKey) {
|
|
2030
|
-
const state = historyBackfills.get(historyKey);
|
|
2031
|
-
if (state) {
|
|
2032
|
-
state.resolved = true;
|
|
2033
|
-
historyBackfills.set(historyKey, state);
|
|
2034
|
-
return;
|
|
2035
|
-
}
|
|
2036
|
-
historyBackfills.set(historyKey, {
|
|
2037
|
-
attempts: 0,
|
|
2038
|
-
firstAttemptAt: Date.now(),
|
|
2039
|
-
nextAttemptAt: Number.POSITIVE_INFINITY,
|
|
2040
|
-
resolved: true
|
|
2041
|
-
});
|
|
2042
|
-
}
|
|
2043
|
-
function planHistoryBackfillAttempt(historyKey, now) {
|
|
2044
|
-
const existing = historyBackfills.get(historyKey);
|
|
2045
|
-
if (existing?.resolved) return null;
|
|
2046
|
-
if (existing && now - existing.firstAttemptAt > HISTORY_BACKFILL_RETRY_WINDOW_MS) {
|
|
2047
|
-
markHistoryBackfillResolved(historyKey);
|
|
2048
|
-
return null;
|
|
2049
|
-
}
|
|
2050
|
-
if (existing && existing.attempts >= HISTORY_BACKFILL_MAX_ATTEMPTS) {
|
|
2051
|
-
markHistoryBackfillResolved(historyKey);
|
|
2052
|
-
return null;
|
|
2053
|
-
}
|
|
2054
|
-
if (existing && now < existing.nextAttemptAt) return null;
|
|
2055
|
-
const attempts = (existing?.attempts ?? 0) + 1;
|
|
2056
|
-
const state = {
|
|
2057
|
-
attempts,
|
|
2058
|
-
firstAttemptAt: existing?.firstAttemptAt ?? now,
|
|
2059
|
-
nextAttemptAt: now + Math.min(HISTORY_BACKFILL_BASE_DELAY_MS * 2 ** (attempts - 1), HISTORY_BACKFILL_MAX_DELAY_MS),
|
|
2060
|
-
resolved: false
|
|
2061
|
-
};
|
|
2062
|
-
historyBackfills.set(historyKey, state);
|
|
2063
|
-
return state;
|
|
2064
|
-
}
|
|
2065
|
-
function buildInboundHistorySnapshot(params) {
|
|
2066
|
-
if (params.limit <= 0 || params.entries.length === 0) return;
|
|
2067
|
-
const recent = params.entries.slice(-params.limit);
|
|
2068
|
-
const selected = [];
|
|
2069
|
-
let remainingChars = MAX_INBOUND_HISTORY_TOTAL_CHARS;
|
|
2070
|
-
for (let i = recent.length - 1; i >= 0; i--) {
|
|
2071
|
-
const entry = recent[i];
|
|
2072
|
-
const body = truncateHistoryBody(entry.body, MAX_INBOUND_HISTORY_ENTRY_CHARS);
|
|
2073
|
-
if (!body) continue;
|
|
2074
|
-
if (selected.length > 0 && body.length > remainingChars) break;
|
|
2075
|
-
selected.push({
|
|
2076
|
-
sender: entry.sender,
|
|
2077
|
-
body,
|
|
2078
|
-
timestamp: entry.timestamp
|
|
2079
|
-
});
|
|
2080
|
-
remainingChars -= body.length;
|
|
2081
|
-
if (remainingChars <= 0) break;
|
|
2082
|
-
}
|
|
2083
|
-
if (selected.length === 0) return;
|
|
2084
|
-
selected.reverse();
|
|
2085
|
-
return selected;
|
|
2086
|
-
}
|
|
2087
|
-
async function processMessage(message, target) {
|
|
2088
|
-
const { account, config, runtime, core, statusSink } = target;
|
|
2089
|
-
const pairing = createScopedPairingAccess({
|
|
2090
|
-
core,
|
|
2091
|
-
channel: "bluebubbles",
|
|
2092
|
-
accountId: account.accountId
|
|
2093
|
-
});
|
|
2094
|
-
const privateApiEnabled = isBlueBubblesPrivateApiEnabled(account.accountId);
|
|
2095
|
-
const groupFlag = resolveGroupFlagFromChatGuid(message.chatGuid);
|
|
2096
|
-
const isGroup = typeof groupFlag === "boolean" ? groupFlag : message.isGroup;
|
|
2097
|
-
const text = message.text.trim();
|
|
2098
|
-
const attachments = message.attachments ?? [];
|
|
2099
|
-
const placeholder = buildMessagePlaceholder(message);
|
|
2100
|
-
const tapbackContext = resolveTapbackContext(message);
|
|
2101
|
-
const tapbackParsed = parseTapbackText({
|
|
2102
|
-
text,
|
|
2103
|
-
emojiHint: tapbackContext?.emojiHint,
|
|
2104
|
-
actionHint: tapbackContext?.actionHint,
|
|
2105
|
-
requireQuoted: !tapbackContext
|
|
2106
|
-
});
|
|
2107
|
-
const isTapbackMessage = Boolean(tapbackParsed);
|
|
2108
|
-
const rawBody = tapbackParsed ? tapbackParsed.action === "removed" ? `removed ${tapbackParsed.emoji} reaction` : `reacted with ${tapbackParsed.emoji}` : text || placeholder;
|
|
2109
|
-
const isSelfChatMessage = isBlueBubblesSelfChatMessage(message, isGroup);
|
|
2110
|
-
const selfChatLookup = {
|
|
2111
|
-
accountId: account.accountId,
|
|
2112
|
-
chatGuid: message.chatGuid,
|
|
2113
|
-
chatIdentifier: message.chatIdentifier,
|
|
2114
|
-
chatId: message.chatId,
|
|
2115
|
-
senderId: message.senderId,
|
|
2116
|
-
body: rawBody,
|
|
2117
|
-
timestamp: message.timestamp
|
|
2118
|
-
};
|
|
2119
|
-
const cacheMessageId = message.messageId?.trim();
|
|
2120
|
-
const confirmedOutboundCacheEntry = cacheMessageId ? resolveReplyContextFromCache({
|
|
2121
|
-
accountId: account.accountId,
|
|
2122
|
-
replyToId: cacheMessageId,
|
|
2123
|
-
chatGuid: message.chatGuid,
|
|
2124
|
-
chatIdentifier: message.chatIdentifier,
|
|
2125
|
-
chatId: message.chatId
|
|
2126
|
-
}) : null;
|
|
2127
|
-
let messageShortId;
|
|
2128
|
-
const cacheInboundMessage = () => {
|
|
2129
|
-
if (!cacheMessageId) return;
|
|
2130
|
-
messageShortId = rememberBlueBubblesReplyCache({
|
|
2131
|
-
accountId: account.accountId,
|
|
2132
|
-
messageId: cacheMessageId,
|
|
2133
|
-
chatGuid: message.chatGuid,
|
|
2134
|
-
chatIdentifier: message.chatIdentifier,
|
|
2135
|
-
chatId: message.chatId,
|
|
2136
|
-
senderLabel: message.fromMe ? "me" : message.senderId,
|
|
2137
|
-
body: rawBody,
|
|
2138
|
-
timestamp: message.timestamp ?? Date.now()
|
|
2139
|
-
}).shortId;
|
|
2140
|
-
};
|
|
2141
|
-
if (message.fromMe) {
|
|
2142
|
-
cacheInboundMessage();
|
|
2143
|
-
const confirmedAssistantOutbound = confirmedOutboundCacheEntry?.senderLabel === "me" && normalizeSnippet(confirmedOutboundCacheEntry.body ?? "") === normalizeSnippet(rawBody);
|
|
2144
|
-
if (isSelfChatMessage && confirmedAssistantOutbound) rememberBlueBubblesSelfChatCopy(selfChatLookup);
|
|
2145
|
-
if (cacheMessageId) {
|
|
2146
|
-
const pending = consumePendingOutboundMessageId({
|
|
2147
|
-
accountId: account.accountId,
|
|
2148
|
-
chatGuid: message.chatGuid,
|
|
2149
|
-
chatIdentifier: message.chatIdentifier,
|
|
2150
|
-
chatId: message.chatId,
|
|
2151
|
-
body: rawBody
|
|
2152
|
-
});
|
|
2153
|
-
if (pending) {
|
|
2154
|
-
const displayId = getShortIdForUuid(cacheMessageId) || cacheMessageId;
|
|
2155
|
-
const previewSource = pending.snippetRaw || rawBody;
|
|
2156
|
-
const preview = previewSource ? ` "${previewSource.slice(0, 12)}${previewSource.length > 12 ? "…" : ""}"` : "";
|
|
2157
|
-
core.system.enqueueSystemEvent(`Assistant sent${preview} [message_id:${displayId}]`, {
|
|
2158
|
-
sessionKey: pending.sessionKey,
|
|
2159
|
-
contextKey: `bluebubbles:outbound:${pending.outboundTarget}:${cacheMessageId}`
|
|
2160
|
-
});
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
return;
|
|
2164
|
-
}
|
|
2165
|
-
if (isSelfChatMessage && hasBlueBubblesSelfChatCopy(selfChatLookup)) {
|
|
2166
|
-
logVerbose(core, runtime, `drop: reflected self-chat duplicate sender=${message.senderId}`);
|
|
2167
|
-
return;
|
|
2168
|
-
}
|
|
2169
|
-
if (!rawBody) {
|
|
2170
|
-
logVerbose(core, runtime, `drop: empty text sender=${message.senderId}`);
|
|
2171
|
-
return;
|
|
2172
|
-
}
|
|
2173
|
-
logVerbose(core, runtime, `msg sender=${message.senderId} group=${isGroup} textLen=${text.length} attachments=${attachments.length} chatGuid=${message.chatGuid ?? ""} chatId=${message.chatId ?? ""}`);
|
|
2174
|
-
const dmPolicy = account.config.dmPolicy ?? "pairing";
|
|
2175
|
-
const groupPolicy = account.config.groupPolicy ?? "allowlist";
|
|
2176
|
-
const configuredAllowFrom = mapAllowFromEntries(account.config.allowFrom);
|
|
2177
|
-
const storeAllowFrom = await readStoreAllowFromForDmPolicy({
|
|
2178
|
-
provider: "bluebubbles",
|
|
2179
|
-
accountId: account.accountId,
|
|
2180
|
-
dmPolicy,
|
|
2181
|
-
readStore: pairing.readStoreForDmPolicy
|
|
2182
|
-
});
|
|
2183
|
-
const accessDecision = resolveDmGroupAccessWithLists({
|
|
2184
|
-
isGroup,
|
|
2185
|
-
dmPolicy,
|
|
2186
|
-
groupPolicy,
|
|
2187
|
-
allowFrom: configuredAllowFrom,
|
|
2188
|
-
groupAllowFrom: account.config.groupAllowFrom,
|
|
2189
|
-
storeAllowFrom,
|
|
2190
|
-
isSenderAllowed: (allowFrom) => isAllowedBlueBubblesSender({
|
|
2191
|
-
allowFrom,
|
|
2192
|
-
sender: message.senderId,
|
|
2193
|
-
chatId: message.chatId ?? void 0,
|
|
2194
|
-
chatGuid: message.chatGuid ?? void 0,
|
|
2195
|
-
chatIdentifier: message.chatIdentifier ?? void 0
|
|
2196
|
-
})
|
|
2197
|
-
});
|
|
2198
|
-
const effectiveAllowFrom = accessDecision.effectiveAllowFrom;
|
|
2199
|
-
const effectiveGroupAllowFrom = accessDecision.effectiveGroupAllowFrom;
|
|
2200
|
-
const groupAllowEntry = formatGroupAllowlistEntry({
|
|
2201
|
-
chatGuid: message.chatGuid,
|
|
2202
|
-
chatId: message.chatId ?? void 0,
|
|
2203
|
-
chatIdentifier: message.chatIdentifier ?? void 0
|
|
2204
|
-
});
|
|
2205
|
-
const groupName = message.chatName?.trim() || void 0;
|
|
2206
|
-
if (accessDecision.decision !== "allow") {
|
|
2207
|
-
if (isGroup) {
|
|
2208
|
-
if (accessDecision.reasonCode === DM_GROUP_ACCESS_REASON.GROUP_POLICY_DISABLED) {
|
|
2209
|
-
logVerbose(core, runtime, "Blocked BlueBubbles group message (groupPolicy=disabled)");
|
|
2210
|
-
logGroupAllowlistHint({
|
|
2211
|
-
runtime,
|
|
2212
|
-
reason: "groupPolicy=disabled",
|
|
2213
|
-
entry: groupAllowEntry,
|
|
2214
|
-
chatName: groupName,
|
|
2215
|
-
accountId: account.accountId
|
|
2216
|
-
});
|
|
2217
|
-
return;
|
|
2218
|
-
}
|
|
2219
|
-
if (accessDecision.reasonCode === DM_GROUP_ACCESS_REASON.GROUP_POLICY_EMPTY_ALLOWLIST) {
|
|
2220
|
-
logVerbose(core, runtime, "Blocked BlueBubbles group message (no allowlist)");
|
|
2221
|
-
logGroupAllowlistHint({
|
|
2222
|
-
runtime,
|
|
2223
|
-
reason: "groupPolicy=allowlist (empty allowlist)",
|
|
2224
|
-
entry: groupAllowEntry,
|
|
2225
|
-
chatName: groupName,
|
|
2226
|
-
accountId: account.accountId
|
|
2227
|
-
});
|
|
2228
|
-
return;
|
|
2229
|
-
}
|
|
2230
|
-
if (accessDecision.reasonCode === DM_GROUP_ACCESS_REASON.GROUP_POLICY_NOT_ALLOWLISTED) {
|
|
2231
|
-
logVerbose(core, runtime, `Blocked BlueBubbles sender ${message.senderId} (not in groupAllowFrom)`);
|
|
2232
|
-
logVerbose(core, runtime, `drop: group sender not allowed sender=${message.senderId} allowFrom=${effectiveGroupAllowFrom.join(",")}`);
|
|
2233
|
-
logGroupAllowlistHint({
|
|
2234
|
-
runtime,
|
|
2235
|
-
reason: "groupPolicy=allowlist (not allowlisted)",
|
|
2236
|
-
entry: groupAllowEntry,
|
|
2237
|
-
chatName: groupName,
|
|
2238
|
-
accountId: account.accountId
|
|
2239
|
-
});
|
|
2240
|
-
return;
|
|
2241
|
-
}
|
|
2242
|
-
return;
|
|
2243
|
-
}
|
|
2244
|
-
if (accessDecision.reasonCode === DM_GROUP_ACCESS_REASON.DM_POLICY_DISABLED) {
|
|
2245
|
-
logVerbose(core, runtime, `Blocked BlueBubbles DM from ${message.senderId}`);
|
|
2246
|
-
logVerbose(core, runtime, `drop: dmPolicy disabled sender=${message.senderId}`);
|
|
2247
|
-
return;
|
|
2248
|
-
}
|
|
2249
|
-
if (accessDecision.decision === "pairing") {
|
|
2250
|
-
await issuePairingChallenge({
|
|
2251
|
-
channel: "bluebubbles",
|
|
2252
|
-
senderId: message.senderId,
|
|
2253
|
-
senderIdLine: `Your BlueBubbles sender id: ${message.senderId}`,
|
|
2254
|
-
meta: { name: message.senderName },
|
|
2255
|
-
upsertPairingRequest: pairing.upsertPairingRequest,
|
|
2256
|
-
onCreated: () => {
|
|
2257
|
-
runtime.log?.(`[bluebubbles] pairing request sender=${message.senderId} created=true`);
|
|
2258
|
-
logVerbose(core, runtime, `bluebubbles pairing request sender=${message.senderId}`);
|
|
2259
|
-
},
|
|
2260
|
-
sendPairingReply: async (text) => {
|
|
2261
|
-
await sendMessageBlueBubbles(message.senderId, text, {
|
|
2262
|
-
cfg: config,
|
|
2263
|
-
accountId: account.accountId
|
|
2264
|
-
});
|
|
2265
|
-
statusSink?.({ lastOutboundAt: Date.now() });
|
|
2266
|
-
},
|
|
2267
|
-
onReplyError: (err) => {
|
|
2268
|
-
logVerbose(core, runtime, `bluebubbles pairing reply failed for ${message.senderId}: ${String(err)}`);
|
|
2269
|
-
runtime.error?.(`[bluebubbles] pairing reply failed sender=${message.senderId}: ${String(err)}`);
|
|
2270
|
-
}
|
|
2271
|
-
});
|
|
2272
|
-
return;
|
|
2273
|
-
}
|
|
2274
|
-
logVerbose(core, runtime, `Blocked unauthorized BlueBubbles sender ${message.senderId} (dmPolicy=${dmPolicy})`);
|
|
2275
|
-
logVerbose(core, runtime, `drop: dm sender not allowed sender=${message.senderId} allowFrom=${effectiveAllowFrom.join(",")}`);
|
|
2276
|
-
return;
|
|
2277
|
-
}
|
|
2278
|
-
const chatId = message.chatId ?? void 0;
|
|
2279
|
-
const chatGuid = message.chatGuid ?? void 0;
|
|
2280
|
-
const chatIdentifier = message.chatIdentifier ?? void 0;
|
|
2281
|
-
const peerId = isGroup ? chatGuid ?? chatIdentifier ?? (chatId ? String(chatId) : "group") : message.senderId;
|
|
2282
|
-
const route = core.channel.routing.resolveAgentRoute({
|
|
2283
|
-
cfg: config,
|
|
2284
|
-
channel: "bluebubbles",
|
|
2285
|
-
accountId: account.accountId,
|
|
2286
|
-
peer: {
|
|
2287
|
-
kind: isGroup ? "group" : "direct",
|
|
2288
|
-
id: peerId
|
|
2289
|
-
}
|
|
2290
|
-
});
|
|
2291
|
-
const messageText = text;
|
|
2292
|
-
const mentionRegexes = core.channel.mentions.buildMentionRegexes(config, route.agentId);
|
|
2293
|
-
const wasMentioned = isGroup ? core.channel.mentions.matchesMentionPatterns(messageText, mentionRegexes) : true;
|
|
2294
|
-
const canDetectMention = mentionRegexes.length > 0;
|
|
2295
|
-
const requireMention = core.channel.groups.resolveRequireMention({
|
|
2296
|
-
cfg: config,
|
|
2297
|
-
channel: "bluebubbles",
|
|
2298
|
-
groupId: peerId,
|
|
2299
|
-
accountId: account.accountId
|
|
2300
|
-
});
|
|
2301
|
-
const useAccessGroups = config.commands?.useAccessGroups !== false;
|
|
2302
|
-
const hasControlCmd = core.channel.text.hasControlCommand(messageText, config);
|
|
2303
|
-
const commandDmAllowFrom = isGroup ? configuredAllowFrom : effectiveAllowFrom;
|
|
2304
|
-
const ownerAllowedForCommands = commandDmAllowFrom.length > 0 ? isAllowedBlueBubblesSender({
|
|
2305
|
-
allowFrom: commandDmAllowFrom,
|
|
2306
|
-
sender: message.senderId,
|
|
2307
|
-
chatId: message.chatId ?? void 0,
|
|
2308
|
-
chatGuid: message.chatGuid ?? void 0,
|
|
2309
|
-
chatIdentifier: message.chatIdentifier ?? void 0
|
|
2310
|
-
}) : false;
|
|
2311
|
-
const groupAllowedForCommands = effectiveGroupAllowFrom.length > 0 ? isAllowedBlueBubblesSender({
|
|
2312
|
-
allowFrom: effectiveGroupAllowFrom,
|
|
2313
|
-
sender: message.senderId,
|
|
2314
|
-
chatId: message.chatId ?? void 0,
|
|
2315
|
-
chatGuid: message.chatGuid ?? void 0,
|
|
2316
|
-
chatIdentifier: message.chatIdentifier ?? void 0
|
|
2317
|
-
}) : false;
|
|
2318
|
-
const commandGate = resolveControlCommandGate({
|
|
2319
|
-
useAccessGroups,
|
|
2320
|
-
authorizers: [{
|
|
2321
|
-
configured: commandDmAllowFrom.length > 0,
|
|
2322
|
-
allowed: ownerAllowedForCommands
|
|
2323
|
-
}, {
|
|
2324
|
-
configured: effectiveGroupAllowFrom.length > 0,
|
|
2325
|
-
allowed: groupAllowedForCommands
|
|
2326
|
-
}],
|
|
2327
|
-
allowTextCommands: true,
|
|
2328
|
-
hasControlCommand: hasControlCmd
|
|
2329
|
-
});
|
|
2330
|
-
const commandAuthorized = commandGate.commandAuthorized;
|
|
2331
|
-
if (isGroup && commandGate.shouldBlock) {
|
|
2332
|
-
logInboundDrop({
|
|
2333
|
-
log: (msg) => logVerbose(core, runtime, msg),
|
|
2334
|
-
channel: "bluebubbles",
|
|
2335
|
-
reason: "control command (unauthorized)",
|
|
2336
|
-
target: message.senderId
|
|
2337
|
-
});
|
|
2338
|
-
return;
|
|
2339
|
-
}
|
|
2340
|
-
const shouldBypassMention = isGroup && requireMention && !wasMentioned && commandAuthorized && hasControlCmd;
|
|
2341
|
-
const effectiveWasMentioned = wasMentioned || shouldBypassMention;
|
|
2342
|
-
if (isGroup && requireMention && canDetectMention && !wasMentioned && !shouldBypassMention) {
|
|
2343
|
-
logVerbose(core, runtime, `bluebubbles: skipping group message (no mention)`);
|
|
2344
|
-
return;
|
|
2345
|
-
}
|
|
2346
|
-
cacheInboundMessage();
|
|
2347
|
-
const baseUrl = normalizeSecretInputString(account.config.serverUrl);
|
|
2348
|
-
const password = normalizeSecretInputString(account.config.password);
|
|
2349
|
-
const maxBytes = account.config.mediaMaxMb && account.config.mediaMaxMb > 0 ? account.config.mediaMaxMb * 1024 * 1024 : 8 * 1024 * 1024;
|
|
2350
|
-
let mediaUrls = [];
|
|
2351
|
-
let mediaPaths = [];
|
|
2352
|
-
let mediaTypes = [];
|
|
2353
|
-
if (attachments.length > 0) if (!baseUrl || !password) logVerbose(core, runtime, "attachment download skipped (missing serverUrl/password)");
|
|
2354
|
-
else for (const attachment of attachments) {
|
|
2355
|
-
if (!attachment.guid) continue;
|
|
2356
|
-
if (attachment.totalBytes && attachment.totalBytes > maxBytes) {
|
|
2357
|
-
logVerbose(core, runtime, `attachment too large guid=${attachment.guid} bytes=${attachment.totalBytes}`);
|
|
2358
|
-
continue;
|
|
2359
|
-
}
|
|
2360
|
-
try {
|
|
2361
|
-
const downloaded = await downloadBlueBubblesAttachment(attachment, {
|
|
2362
|
-
cfg: config,
|
|
2363
|
-
accountId: account.accountId,
|
|
2364
|
-
maxBytes
|
|
2365
|
-
});
|
|
2366
|
-
const saved = await core.channel.media.saveMediaBuffer(Buffer.from(downloaded.buffer), downloaded.contentType, "inbound", maxBytes);
|
|
2367
|
-
mediaPaths.push(saved.path);
|
|
2368
|
-
mediaUrls.push(saved.path);
|
|
2369
|
-
if (saved.contentType) mediaTypes.push(saved.contentType);
|
|
2370
|
-
} catch (err) {
|
|
2371
|
-
logVerbose(core, runtime, `attachment download failed guid=${attachment.guid} err=${String(err)}`);
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
let replyToId = message.replyToId;
|
|
2375
|
-
let replyToBody = message.replyToBody;
|
|
2376
|
-
let replyToSender = message.replyToSender;
|
|
2377
|
-
let replyToShortId;
|
|
2378
|
-
if (isTapbackMessage && tapbackContext?.replyToId) replyToId = tapbackContext.replyToId;
|
|
2379
|
-
if (replyToId) {
|
|
2380
|
-
const cached = resolveReplyContextFromCache({
|
|
2381
|
-
accountId: account.accountId,
|
|
2382
|
-
replyToId,
|
|
2383
|
-
chatGuid: message.chatGuid,
|
|
2384
|
-
chatIdentifier: message.chatIdentifier,
|
|
2385
|
-
chatId: message.chatId
|
|
2386
|
-
});
|
|
2387
|
-
if (cached) {
|
|
2388
|
-
if (!replyToBody && cached.body) replyToBody = cached.body;
|
|
2389
|
-
if (!replyToSender && cached.senderLabel) replyToSender = cached.senderLabel;
|
|
2390
|
-
replyToShortId = cached.shortId;
|
|
2391
|
-
if (core.logging.shouldLogVerbose()) {
|
|
2392
|
-
const preview = (cached.body ?? "").replace(/\s+/g, " ").slice(0, 120);
|
|
2393
|
-
logVerbose(core, runtime, `reply-context cache hit replyToId=${replyToId} sender=${replyToSender ?? ""} body="${preview}"`);
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
}
|
|
2397
|
-
if (replyToId && !replyToShortId) replyToShortId = getShortIdForUuid(replyToId);
|
|
2398
|
-
const replyTag = formatReplyTag({
|
|
2399
|
-
replyToId,
|
|
2400
|
-
replyToShortId
|
|
2401
|
-
});
|
|
2402
|
-
const baseBody = replyTag ? isTapbackMessage ? `${rawBody} ${replyTag}` : `${replyTag} ${rawBody}` : rawBody;
|
|
2403
|
-
const senderLabel = message.senderName || `user:${message.senderId}`;
|
|
2404
|
-
const fromLabel = isGroup ? `${message.chatName?.trim() || "Group"} id:${peerId}` : senderLabel !== message.senderId ? `${senderLabel} id:${message.senderId}` : senderLabel;
|
|
2405
|
-
const groupSubject = isGroup ? message.chatName?.trim() || void 0 : void 0;
|
|
2406
|
-
const groupMembers = isGroup ? formatGroupMembers({
|
|
2407
|
-
participants: message.participants,
|
|
2408
|
-
fallback: message.senderId ? {
|
|
2409
|
-
id: message.senderId,
|
|
2410
|
-
name: message.senderName
|
|
2411
|
-
} : void 0
|
|
2412
|
-
}) : void 0;
|
|
2413
|
-
const storePath = core.channel.session.resolveStorePath(config.session?.store, { agentId: route.agentId });
|
|
2414
|
-
const envelopeOptions = core.channel.reply.resolveEnvelopeFormatOptions(config);
|
|
2415
|
-
const previousTimestamp = core.channel.session.readSessionUpdatedAt({
|
|
2416
|
-
storePath,
|
|
2417
|
-
sessionKey: route.sessionKey
|
|
2418
|
-
});
|
|
2419
|
-
const body = core.channel.reply.formatInboundEnvelope({
|
|
2420
|
-
channel: "BlueBubbles",
|
|
2421
|
-
from: fromLabel,
|
|
2422
|
-
timestamp: message.timestamp,
|
|
2423
|
-
previousTimestamp,
|
|
2424
|
-
envelope: envelopeOptions,
|
|
2425
|
-
body: baseBody,
|
|
2426
|
-
chatType: isGroup ? "group" : "direct",
|
|
2427
|
-
sender: {
|
|
2428
|
-
name: message.senderName || void 0,
|
|
2429
|
-
id: message.senderId
|
|
2430
|
-
}
|
|
2431
|
-
});
|
|
2432
|
-
let chatGuidForActions = chatGuid;
|
|
2433
|
-
if (!chatGuidForActions && baseUrl && password) {
|
|
2434
|
-
const resolveTarget = isGroup && (chatId || chatIdentifier) ? chatId ? {
|
|
2435
|
-
kind: "chat_id",
|
|
2436
|
-
chatId
|
|
2437
|
-
} : {
|
|
2438
|
-
kind: "chat_identifier",
|
|
2439
|
-
chatIdentifier: chatIdentifier ?? ""
|
|
2440
|
-
} : {
|
|
2441
|
-
kind: "handle",
|
|
2442
|
-
address: message.senderId
|
|
2443
|
-
};
|
|
2444
|
-
if (resolveTarget.kind !== "chat_identifier" || resolveTarget.chatIdentifier) chatGuidForActions = await resolveChatGuidForTarget({
|
|
2445
|
-
baseUrl,
|
|
2446
|
-
password,
|
|
2447
|
-
target: resolveTarget
|
|
2448
|
-
}) ?? void 0;
|
|
2449
|
-
}
|
|
2450
|
-
const ackReactionScope = config.messages?.ackReactionScope ?? "group-mentions";
|
|
2451
|
-
const removeAckAfterReply = config.messages?.removeAckAfterReply ?? false;
|
|
2452
|
-
const ackReactionValue = resolveBlueBubblesAckReaction({
|
|
2453
|
-
cfg: config,
|
|
2454
|
-
agentId: route.agentId,
|
|
2455
|
-
core,
|
|
2456
|
-
runtime
|
|
2457
|
-
});
|
|
2458
|
-
const shouldAckReaction = () => Boolean(ackReactionValue && core.channel.reactions.shouldAckReaction({
|
|
2459
|
-
scope: ackReactionScope,
|
|
2460
|
-
isDirect: !isGroup,
|
|
2461
|
-
isGroup,
|
|
2462
|
-
isMentionableGroup: isGroup,
|
|
2463
|
-
requireMention: Boolean(requireMention),
|
|
2464
|
-
canDetectMention,
|
|
2465
|
-
effectiveWasMentioned,
|
|
2466
|
-
shouldBypassMention
|
|
2467
|
-
}));
|
|
2468
|
-
const ackMessageId = message.messageId?.trim() || "";
|
|
2469
|
-
const ackReactionPromise = shouldAckReaction() && ackMessageId && chatGuidForActions && ackReactionValue ? sendBlueBubblesReaction({
|
|
2470
|
-
chatGuid: chatGuidForActions,
|
|
2471
|
-
messageGuid: ackMessageId,
|
|
2472
|
-
emoji: ackReactionValue,
|
|
2473
|
-
opts: {
|
|
2474
|
-
cfg: config,
|
|
2475
|
-
accountId: account.accountId
|
|
2476
|
-
}
|
|
2477
|
-
}).then(() => true, (err) => {
|
|
2478
|
-
logVerbose(core, runtime, `ack reaction failed chatGuid=${chatGuidForActions} msg=${ackMessageId}: ${String(err)}`);
|
|
2479
|
-
return false;
|
|
2480
|
-
}) : null;
|
|
2481
|
-
const sendReadReceipts = account.config.sendReadReceipts !== false;
|
|
2482
|
-
if (chatGuidForActions && baseUrl && password && sendReadReceipts) try {
|
|
2483
|
-
await markBlueBubblesChatRead(chatGuidForActions, {
|
|
2484
|
-
cfg: config,
|
|
2485
|
-
accountId: account.accountId
|
|
2486
|
-
});
|
|
2487
|
-
logVerbose(core, runtime, `marked read chatGuid=${chatGuidForActions}`);
|
|
2488
|
-
} catch (err) {
|
|
2489
|
-
runtime.error?.(`[bluebubbles] mark read failed: ${String(err)}`);
|
|
2490
|
-
}
|
|
2491
|
-
else if (!sendReadReceipts) logVerbose(core, runtime, "mark read skipped (sendReadReceipts=false)");
|
|
2492
|
-
else logVerbose(core, runtime, "mark read skipped (missing chatGuid or credentials)");
|
|
2493
|
-
const outboundTarget = isGroup ? formatBlueBubblesChatTarget({
|
|
2494
|
-
chatId,
|
|
2495
|
-
chatGuid: chatGuidForActions ?? chatGuid,
|
|
2496
|
-
chatIdentifier
|
|
2497
|
-
}) || peerId : chatGuidForActions ? formatBlueBubblesChatTarget({ chatGuid: chatGuidForActions }) : message.senderId;
|
|
2498
|
-
const maybeEnqueueOutboundMessageId = (messageId, snippet) => {
|
|
2499
|
-
const trimmed = messageId?.trim();
|
|
2500
|
-
if (!trimmed || trimmed === "ok" || trimmed === "unknown") return false;
|
|
2501
|
-
const displayId = rememberBlueBubblesReplyCache({
|
|
2502
|
-
accountId: account.accountId,
|
|
2503
|
-
messageId: trimmed,
|
|
2504
|
-
chatGuid: chatGuidForActions ?? chatGuid,
|
|
2505
|
-
chatIdentifier,
|
|
2506
|
-
chatId,
|
|
2507
|
-
senderLabel: "me",
|
|
2508
|
-
body: snippet ?? "",
|
|
2509
|
-
timestamp: Date.now()
|
|
2510
|
-
}).shortId || trimmed;
|
|
2511
|
-
const preview = snippet ? ` "${snippet.slice(0, 12)}${snippet.length > 12 ? "…" : ""}"` : "";
|
|
2512
|
-
core.system.enqueueSystemEvent(`Assistant sent${preview} [message_id:${displayId}]`, {
|
|
2513
|
-
sessionKey: route.sessionKey,
|
|
2514
|
-
contextKey: `bluebubbles:outbound:${outboundTarget}:${trimmed}`
|
|
2515
|
-
});
|
|
2516
|
-
return true;
|
|
2517
|
-
};
|
|
2518
|
-
const sanitizeReplyDirectiveText = (value) => {
|
|
2519
|
-
if (privateApiEnabled) return value;
|
|
2520
|
-
return value.replace(REPLY_DIRECTIVE_TAG_RE, " ").replace(/[ \t]+/g, " ").trim();
|
|
2521
|
-
};
|
|
2522
|
-
const historyLimit = isGroup ? account.config.historyLimit ?? 0 : account.config.dmHistoryLimit ?? 0;
|
|
2523
|
-
const historyIdentifier = chatGuid || chatIdentifier || (chatId ? String(chatId) : null) || (isGroup ? null : message.senderId) || "";
|
|
2524
|
-
const historyKey = historyIdentifier ? buildAccountScopedHistoryKey(account.accountId, historyIdentifier) : "";
|
|
2525
|
-
if (historyKey && historyLimit > 0) {
|
|
2526
|
-
const nowMs = Date.now();
|
|
2527
|
-
const senderLabel = message.fromMe ? "me" : message.senderName || message.senderId;
|
|
2528
|
-
const normalizedHistoryBody = truncateHistoryBody(text, MAX_STORED_HISTORY_ENTRY_CHARS);
|
|
2529
|
-
const currentEntries = recordPendingHistoryEntryIfEnabled({
|
|
2530
|
-
historyMap: chatHistories,
|
|
2531
|
-
limit: historyLimit,
|
|
2532
|
-
historyKey,
|
|
2533
|
-
entry: normalizedHistoryBody ? {
|
|
2534
|
-
sender: senderLabel,
|
|
2535
|
-
body: normalizedHistoryBody,
|
|
2536
|
-
timestamp: message.timestamp ?? nowMs,
|
|
2537
|
-
messageId: message.messageId ?? void 0
|
|
2538
|
-
} : null
|
|
2539
|
-
});
|
|
2540
|
-
pruneHistoryBackfillState();
|
|
2541
|
-
const backfillAttempt = planHistoryBackfillAttempt(historyKey, nowMs);
|
|
2542
|
-
if (backfillAttempt) try {
|
|
2543
|
-
const backfillResult = await fetchBlueBubblesHistory(historyIdentifier, historyLimit, {
|
|
2544
|
-
cfg: config,
|
|
2545
|
-
accountId: account.accountId
|
|
2546
|
-
});
|
|
2547
|
-
if (backfillResult.resolved) markHistoryBackfillResolved(historyKey);
|
|
2548
|
-
if (backfillResult.entries.length > 0) {
|
|
2549
|
-
const apiEntries = [];
|
|
2550
|
-
for (const entry of backfillResult.entries) {
|
|
2551
|
-
const body = truncateHistoryBody(entry.body, MAX_STORED_HISTORY_ENTRY_CHARS);
|
|
2552
|
-
if (!body) continue;
|
|
2553
|
-
apiEntries.push({
|
|
2554
|
-
sender: entry.sender,
|
|
2555
|
-
body,
|
|
2556
|
-
timestamp: entry.timestamp,
|
|
2557
|
-
messageId: entry.messageId
|
|
2558
|
-
});
|
|
2559
|
-
}
|
|
2560
|
-
const merged = mergeHistoryEntries({
|
|
2561
|
-
apiEntries,
|
|
2562
|
-
currentEntries: currentEntries.length > 0 ? currentEntries : chatHistories.get(historyKey) ?? [],
|
|
2563
|
-
limit: historyLimit
|
|
2564
|
-
});
|
|
2565
|
-
if (chatHistories.has(historyKey)) chatHistories.delete(historyKey);
|
|
2566
|
-
chatHistories.set(historyKey, merged);
|
|
2567
|
-
evictOldHistoryKeys(chatHistories);
|
|
2568
|
-
logVerbose(core, runtime, `backfilled ${backfillResult.entries.length} history messages for ${isGroup ? "group" : "DM"}: ${historyIdentifier}`);
|
|
2569
|
-
} else if (!backfillResult.resolved) {
|
|
2570
|
-
const remainingAttempts = HISTORY_BACKFILL_MAX_ATTEMPTS - backfillAttempt.attempts;
|
|
2571
|
-
const nextBackoffMs = Math.max(backfillAttempt.nextAttemptAt - nowMs, 0);
|
|
2572
|
-
logVerbose(core, runtime, `history backfill unresolved for ${historyIdentifier}; retries left=${Math.max(remainingAttempts, 0)} next_in_ms=${nextBackoffMs}`);
|
|
2573
|
-
}
|
|
2574
|
-
} catch (err) {
|
|
2575
|
-
const remainingAttempts = HISTORY_BACKFILL_MAX_ATTEMPTS - backfillAttempt.attempts;
|
|
2576
|
-
const nextBackoffMs = Math.max(backfillAttempt.nextAttemptAt - nowMs, 0);
|
|
2577
|
-
logVerbose(core, runtime, `history backfill failed for ${historyIdentifier}: ${String(err)} (retries left=${Math.max(remainingAttempts, 0)} next_in_ms=${nextBackoffMs})`);
|
|
2578
|
-
}
|
|
2579
|
-
}
|
|
2580
|
-
let inboundHistory;
|
|
2581
|
-
if (historyKey && historyLimit > 0) {
|
|
2582
|
-
const entries = chatHistories.get(historyKey);
|
|
2583
|
-
if (entries && entries.length > 0) inboundHistory = buildInboundHistorySnapshot({
|
|
2584
|
-
entries,
|
|
2585
|
-
limit: historyLimit
|
|
2586
|
-
});
|
|
2587
|
-
}
|
|
2588
|
-
const commandBody = messageText.trim();
|
|
2589
|
-
const ctxPayload = core.channel.reply.finalizeInboundContext({
|
|
2590
|
-
Body: body,
|
|
2591
|
-
BodyForAgent: rawBody,
|
|
2592
|
-
InboundHistory: inboundHistory,
|
|
2593
|
-
RawBody: rawBody,
|
|
2594
|
-
CommandBody: commandBody,
|
|
2595
|
-
BodyForCommands: commandBody,
|
|
2596
|
-
MediaUrl: mediaUrls[0],
|
|
2597
|
-
MediaUrls: mediaUrls.length > 0 ? mediaUrls : void 0,
|
|
2598
|
-
MediaPath: mediaPaths[0],
|
|
2599
|
-
MediaPaths: mediaPaths.length > 0 ? mediaPaths : void 0,
|
|
2600
|
-
MediaType: mediaTypes[0],
|
|
2601
|
-
MediaTypes: mediaTypes.length > 0 ? mediaTypes : void 0,
|
|
2602
|
-
From: isGroup ? `group:${peerId}` : `bluebubbles:${message.senderId}`,
|
|
2603
|
-
To: `bluebubbles:${outboundTarget}`,
|
|
2604
|
-
SessionKey: route.sessionKey,
|
|
2605
|
-
AccountId: route.accountId,
|
|
2606
|
-
ChatType: isGroup ? "group" : "direct",
|
|
2607
|
-
ConversationLabel: fromLabel,
|
|
2608
|
-
ReplyToId: replyToShortId || replyToId,
|
|
2609
|
-
ReplyToIdFull: replyToId,
|
|
2610
|
-
ReplyToBody: replyToBody,
|
|
2611
|
-
ReplyToSender: replyToSender,
|
|
2612
|
-
GroupSubject: groupSubject,
|
|
2613
|
-
GroupMembers: groupMembers,
|
|
2614
|
-
SenderName: message.senderName || void 0,
|
|
2615
|
-
SenderId: message.senderId,
|
|
2616
|
-
Provider: "bluebubbles",
|
|
2617
|
-
Surface: "bluebubbles",
|
|
2618
|
-
MessageSid: messageShortId || message.messageId,
|
|
2619
|
-
MessageSidFull: message.messageId,
|
|
2620
|
-
Timestamp: message.timestamp,
|
|
2621
|
-
OriginatingChannel: "bluebubbles",
|
|
2622
|
-
OriginatingTo: `bluebubbles:${outboundTarget}`,
|
|
2623
|
-
WasMentioned: effectiveWasMentioned,
|
|
2624
|
-
CommandAuthorized: commandAuthorized
|
|
2625
|
-
});
|
|
2626
|
-
let sentMessage = false;
|
|
2627
|
-
let streamingActive = false;
|
|
2628
|
-
let typingRestartTimer;
|
|
2629
|
-
const typingRestartDelayMs = 150;
|
|
2630
|
-
const clearTypingRestartTimer = () => {
|
|
2631
|
-
if (typingRestartTimer) {
|
|
2632
|
-
clearTimeout(typingRestartTimer);
|
|
2633
|
-
typingRestartTimer = void 0;
|
|
2634
|
-
}
|
|
2635
|
-
};
|
|
2636
|
-
const restartTypingSoon = () => {
|
|
2637
|
-
if (!streamingActive || !chatGuidForActions || !baseUrl || !password) return;
|
|
2638
|
-
clearTypingRestartTimer();
|
|
2639
|
-
typingRestartTimer = setTimeout(() => {
|
|
2640
|
-
typingRestartTimer = void 0;
|
|
2641
|
-
if (!streamingActive) return;
|
|
2642
|
-
sendBlueBubblesTyping(chatGuidForActions, true, {
|
|
2643
|
-
cfg: config,
|
|
2644
|
-
accountId: account.accountId
|
|
2645
|
-
}).catch((err) => {
|
|
2646
|
-
runtime.error?.(`[bluebubbles] typing restart failed: ${String(err)}`);
|
|
2647
|
-
});
|
|
2648
|
-
}, typingRestartDelayMs);
|
|
2649
|
-
};
|
|
2650
|
-
try {
|
|
2651
|
-
const { onModelSelected, ...prefixOptions } = createReplyPrefixOptions({
|
|
2652
|
-
cfg: config,
|
|
2653
|
-
agentId: route.agentId,
|
|
2654
|
-
channel: "bluebubbles",
|
|
2655
|
-
accountId: account.accountId
|
|
2656
|
-
});
|
|
2657
|
-
await core.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
2658
|
-
ctx: ctxPayload,
|
|
2659
|
-
cfg: config,
|
|
2660
|
-
dispatcherOptions: {
|
|
2661
|
-
...prefixOptions,
|
|
2662
|
-
deliver: async (payload, info) => {
|
|
2663
|
-
const rawReplyToId = privateApiEnabled && typeof payload.replyToId === "string" ? payload.replyToId.trim() : "";
|
|
2664
|
-
const replyToMessageGuid = rawReplyToId ? resolveBlueBubblesMessageId(rawReplyToId, { requireKnownShortId: true }) : "";
|
|
2665
|
-
const mediaList = payload.mediaUrls?.length ? payload.mediaUrls : payload.mediaUrl ? [payload.mediaUrl] : [];
|
|
2666
|
-
if (mediaList.length > 0) {
|
|
2667
|
-
const tableMode = core.channel.text.resolveMarkdownTableMode({
|
|
2668
|
-
cfg: config,
|
|
2669
|
-
channel: "bluebubbles",
|
|
2670
|
-
accountId: account.accountId
|
|
2671
|
-
});
|
|
2672
|
-
const text = sanitizeReplyDirectiveText(core.channel.text.convertMarkdownTables(payload.text ?? "", tableMode));
|
|
2673
|
-
let first = true;
|
|
2674
|
-
for (const mediaUrl of mediaList) {
|
|
2675
|
-
const caption = first ? text : void 0;
|
|
2676
|
-
first = false;
|
|
2677
|
-
const cachedBody = (caption ?? "").trim() || "<media:attachment>";
|
|
2678
|
-
const pendingId = rememberPendingOutboundMessageId({
|
|
2679
|
-
accountId: account.accountId,
|
|
2680
|
-
sessionKey: route.sessionKey,
|
|
2681
|
-
outboundTarget,
|
|
2682
|
-
chatGuid: chatGuidForActions ?? chatGuid,
|
|
2683
|
-
chatIdentifier,
|
|
2684
|
-
chatId,
|
|
2685
|
-
snippet: cachedBody
|
|
2686
|
-
});
|
|
2687
|
-
let result;
|
|
2688
|
-
try {
|
|
2689
|
-
result = await sendBlueBubblesMedia({
|
|
2690
|
-
cfg: config,
|
|
2691
|
-
to: outboundTarget,
|
|
2692
|
-
mediaUrl,
|
|
2693
|
-
caption: caption ?? void 0,
|
|
2694
|
-
replyToId: replyToMessageGuid || null,
|
|
2695
|
-
accountId: account.accountId
|
|
2696
|
-
});
|
|
2697
|
-
} catch (err) {
|
|
2698
|
-
forgetPendingOutboundMessageId(pendingId);
|
|
2699
|
-
throw err;
|
|
2700
|
-
}
|
|
2701
|
-
if (maybeEnqueueOutboundMessageId(result.messageId, cachedBody)) forgetPendingOutboundMessageId(pendingId);
|
|
2702
|
-
sentMessage = true;
|
|
2703
|
-
statusSink?.({ lastOutboundAt: Date.now() });
|
|
2704
|
-
if (info.kind === "block") restartTypingSoon();
|
|
2705
|
-
}
|
|
2706
|
-
return;
|
|
2707
|
-
}
|
|
2708
|
-
const textLimit = account.config.textChunkLimit && account.config.textChunkLimit > 0 ? account.config.textChunkLimit : DEFAULT_TEXT_LIMIT;
|
|
2709
|
-
const chunkMode = account.config.chunkMode ?? "length";
|
|
2710
|
-
const tableMode = core.channel.text.resolveMarkdownTableMode({
|
|
2711
|
-
cfg: config,
|
|
2712
|
-
channel: "bluebubbles",
|
|
2713
|
-
accountId: account.accountId
|
|
2714
|
-
});
|
|
2715
|
-
const text = sanitizeReplyDirectiveText(core.channel.text.convertMarkdownTables(payload.text ?? "", tableMode));
|
|
2716
|
-
const chunks = chunkMode === "newline" ? core.channel.text.chunkTextWithMode(text, textLimit, chunkMode) : core.channel.text.chunkMarkdownText(text, textLimit);
|
|
2717
|
-
if (!chunks.length && text) chunks.push(text);
|
|
2718
|
-
if (!chunks.length) return;
|
|
2719
|
-
for (const chunk of chunks) {
|
|
2720
|
-
const pendingId = rememberPendingOutboundMessageId({
|
|
2721
|
-
accountId: account.accountId,
|
|
2722
|
-
sessionKey: route.sessionKey,
|
|
2723
|
-
outboundTarget,
|
|
2724
|
-
chatGuid: chatGuidForActions ?? chatGuid,
|
|
2725
|
-
chatIdentifier,
|
|
2726
|
-
chatId,
|
|
2727
|
-
snippet: chunk
|
|
2728
|
-
});
|
|
2729
|
-
let result;
|
|
2730
|
-
try {
|
|
2731
|
-
result = await sendMessageBlueBubbles(outboundTarget, chunk, {
|
|
2732
|
-
cfg: config,
|
|
2733
|
-
accountId: account.accountId,
|
|
2734
|
-
replyToMessageGuid: replyToMessageGuid || void 0
|
|
2735
|
-
});
|
|
2736
|
-
} catch (err) {
|
|
2737
|
-
forgetPendingOutboundMessageId(pendingId);
|
|
2738
|
-
throw err;
|
|
2739
|
-
}
|
|
2740
|
-
if (maybeEnqueueOutboundMessageId(result.messageId, chunk)) forgetPendingOutboundMessageId(pendingId);
|
|
2741
|
-
sentMessage = true;
|
|
2742
|
-
statusSink?.({ lastOutboundAt: Date.now() });
|
|
2743
|
-
if (info.kind === "block") restartTypingSoon();
|
|
2744
|
-
}
|
|
2745
|
-
},
|
|
2746
|
-
onReplyStart: async () => {
|
|
2747
|
-
if (!chatGuidForActions) return;
|
|
2748
|
-
if (!baseUrl || !password) return;
|
|
2749
|
-
streamingActive = true;
|
|
2750
|
-
clearTypingRestartTimer();
|
|
2751
|
-
try {
|
|
2752
|
-
await sendBlueBubblesTyping(chatGuidForActions, true, {
|
|
2753
|
-
cfg: config,
|
|
2754
|
-
accountId: account.accountId
|
|
2755
|
-
});
|
|
2756
|
-
} catch (err) {
|
|
2757
|
-
runtime.error?.(`[bluebubbles] typing start failed: ${String(err)}`);
|
|
2758
|
-
}
|
|
2759
|
-
},
|
|
2760
|
-
onIdle: async () => {
|
|
2761
|
-
if (!chatGuidForActions) return;
|
|
2762
|
-
if (!baseUrl || !password) return;
|
|
2763
|
-
},
|
|
2764
|
-
onError: (err, info) => {
|
|
2765
|
-
runtime.error?.(`BlueBubbles ${info.kind} reply failed: ${String(err)}`);
|
|
2766
|
-
}
|
|
2767
|
-
},
|
|
2768
|
-
replyOptions: {
|
|
2769
|
-
onModelSelected,
|
|
2770
|
-
disableBlockStreaming: typeof account.config.blockStreaming === "boolean" ? !account.config.blockStreaming : void 0
|
|
2771
|
-
}
|
|
2772
|
-
});
|
|
2773
|
-
} finally {
|
|
2774
|
-
const shouldStopTyping = Boolean(chatGuidForActions && baseUrl && password) && (streamingActive || !sentMessage);
|
|
2775
|
-
streamingActive = false;
|
|
2776
|
-
clearTypingRestartTimer();
|
|
2777
|
-
if (sentMessage && chatGuidForActions && ackMessageId) core.channel.reactions.removeAckReactionAfterReply({
|
|
2778
|
-
removeAfterReply: removeAckAfterReply,
|
|
2779
|
-
ackReactionPromise,
|
|
2780
|
-
ackReactionValue: ackReactionValue ?? null,
|
|
2781
|
-
remove: () => sendBlueBubblesReaction({
|
|
2782
|
-
chatGuid: chatGuidForActions,
|
|
2783
|
-
messageGuid: ackMessageId,
|
|
2784
|
-
emoji: ackReactionValue ?? "",
|
|
2785
|
-
remove: true,
|
|
2786
|
-
opts: {
|
|
2787
|
-
cfg: config,
|
|
2788
|
-
accountId: account.accountId
|
|
2789
|
-
}
|
|
2790
|
-
}),
|
|
2791
|
-
onError: (err) => {
|
|
2792
|
-
logAckFailure({
|
|
2793
|
-
log: (msg) => logVerbose(core, runtime, msg),
|
|
2794
|
-
channel: "bluebubbles",
|
|
2795
|
-
target: `${chatGuidForActions}/${ackMessageId}`,
|
|
2796
|
-
error: err
|
|
2797
|
-
});
|
|
2798
|
-
}
|
|
2799
|
-
});
|
|
2800
|
-
if (shouldStopTyping && chatGuidForActions) sendBlueBubblesTyping(chatGuidForActions, false, {
|
|
2801
|
-
cfg: config,
|
|
2802
|
-
accountId: account.accountId
|
|
2803
|
-
}).catch((err) => {
|
|
2804
|
-
logTypingFailure({
|
|
2805
|
-
log: (msg) => logVerbose(core, runtime, msg),
|
|
2806
|
-
channel: "bluebubbles",
|
|
2807
|
-
action: "stop",
|
|
2808
|
-
target: chatGuidForActions,
|
|
2809
|
-
error: err
|
|
2810
|
-
});
|
|
2811
|
-
});
|
|
2812
|
-
}
|
|
2813
|
-
}
|
|
2814
|
-
async function processReaction(reaction, target) {
|
|
2815
|
-
const { account, config, runtime, core } = target;
|
|
2816
|
-
const pairing = createScopedPairingAccess({
|
|
2817
|
-
core,
|
|
2818
|
-
channel: "bluebubbles",
|
|
2819
|
-
accountId: account.accountId
|
|
2820
|
-
});
|
|
2821
|
-
if (reaction.fromMe) return;
|
|
2822
|
-
const dmPolicy = account.config.dmPolicy ?? "pairing";
|
|
2823
|
-
const groupPolicy = account.config.groupPolicy ?? "allowlist";
|
|
2824
|
-
const storeAllowFrom = await readStoreAllowFromForDmPolicy({
|
|
2825
|
-
provider: "bluebubbles",
|
|
2826
|
-
accountId: account.accountId,
|
|
2827
|
-
dmPolicy,
|
|
2828
|
-
readStore: pairing.readStoreForDmPolicy
|
|
2829
|
-
});
|
|
2830
|
-
if (resolveDmGroupAccessWithLists({
|
|
2831
|
-
isGroup: reaction.isGroup,
|
|
2832
|
-
dmPolicy,
|
|
2833
|
-
groupPolicy,
|
|
2834
|
-
allowFrom: account.config.allowFrom,
|
|
2835
|
-
groupAllowFrom: account.config.groupAllowFrom,
|
|
2836
|
-
storeAllowFrom,
|
|
2837
|
-
isSenderAllowed: (allowFrom) => isAllowedBlueBubblesSender({
|
|
2838
|
-
allowFrom,
|
|
2839
|
-
sender: reaction.senderId,
|
|
2840
|
-
chatId: reaction.chatId ?? void 0,
|
|
2841
|
-
chatGuid: reaction.chatGuid ?? void 0,
|
|
2842
|
-
chatIdentifier: reaction.chatIdentifier ?? void 0
|
|
2843
|
-
})
|
|
2844
|
-
}).decision !== "allow") return;
|
|
2845
|
-
const chatId = reaction.chatId ?? void 0;
|
|
2846
|
-
const chatGuid = reaction.chatGuid ?? void 0;
|
|
2847
|
-
const chatIdentifier = reaction.chatIdentifier ?? void 0;
|
|
2848
|
-
const peerId = reaction.isGroup ? chatGuid ?? chatIdentifier ?? (chatId ? String(chatId) : "group") : reaction.senderId;
|
|
2849
|
-
const route = core.channel.routing.resolveAgentRoute({
|
|
2850
|
-
cfg: config,
|
|
2851
|
-
channel: "bluebubbles",
|
|
2852
|
-
accountId: account.accountId,
|
|
2853
|
-
peer: {
|
|
2854
|
-
kind: reaction.isGroup ? "group" : "direct",
|
|
2855
|
-
id: peerId
|
|
2856
|
-
}
|
|
2857
|
-
});
|
|
2858
|
-
const senderLabel = reaction.senderName || reaction.senderId;
|
|
2859
|
-
const chatLabel = reaction.isGroup ? ` in group:${peerId}` : "";
|
|
2860
|
-
const messageDisplayId = getShortIdForUuid(reaction.messageId) || reaction.messageId;
|
|
2861
|
-
const text = reaction.action === "removed" ? `${senderLabel} removed ${reaction.emoji} reaction [[reply_to:${messageDisplayId}]]${chatLabel}` : `${senderLabel} reacted with ${reaction.emoji} [[reply_to:${messageDisplayId}]]${chatLabel}`;
|
|
2862
|
-
core.system.enqueueSystemEvent(text, {
|
|
2863
|
-
sessionKey: route.sessionKey,
|
|
2864
|
-
contextKey: `bluebubbles:reaction:${reaction.action}:${peerId}:${reaction.messageId}:${reaction.senderId}:${reaction.emoji}`
|
|
2865
|
-
});
|
|
2866
|
-
logVerbose(core, runtime, `reaction event enqueued: ${text}`);
|
|
2867
|
-
}
|
|
2868
|
-
//#endregion
|
|
2869
|
-
//#region extensions/bluebubbles/src/monitor.ts
|
|
2870
|
-
const webhookTargets = /* @__PURE__ */ new Map();
|
|
2871
|
-
const webhookInFlightLimiter = createWebhookInFlightLimiter();
|
|
2872
|
-
const debounceRegistry = createBlueBubblesDebounceRegistry({ processMessage });
|
|
2873
|
-
function registerBlueBubblesWebhookTarget(target) {
|
|
2874
|
-
const registered = registerWebhookTargetWithPluginRoute({
|
|
2875
|
-
targetsByPath: webhookTargets,
|
|
2876
|
-
target,
|
|
2877
|
-
route: {
|
|
2878
|
-
auth: "plugin",
|
|
2879
|
-
match: "exact",
|
|
2880
|
-
pluginId: "bluebubbles",
|
|
2881
|
-
source: "bluebubbles-webhook",
|
|
2882
|
-
accountId: target.account.accountId,
|
|
2883
|
-
log: target.runtime.log,
|
|
2884
|
-
handler: async (req, res) => {
|
|
2885
|
-
if (!await handleBlueBubblesWebhookRequest(req, res) && !res.headersSent) {
|
|
2886
|
-
res.statusCode = 404;
|
|
2887
|
-
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
2888
|
-
res.end("Not Found");
|
|
2889
|
-
}
|
|
2890
|
-
}
|
|
2891
|
-
}
|
|
2892
|
-
});
|
|
2893
|
-
return () => {
|
|
2894
|
-
registered.unregister();
|
|
2895
|
-
debounceRegistry.removeDebouncer(registered.target);
|
|
2896
|
-
};
|
|
2897
|
-
}
|
|
2898
|
-
function parseBlueBubblesWebhookPayload(rawBody) {
|
|
2899
|
-
const trimmed = rawBody.trim();
|
|
2900
|
-
if (!trimmed) return {
|
|
2901
|
-
ok: false,
|
|
2902
|
-
error: "empty payload"
|
|
2903
|
-
};
|
|
2904
|
-
try {
|
|
2905
|
-
return {
|
|
2906
|
-
ok: true,
|
|
2907
|
-
value: JSON.parse(trimmed)
|
|
2908
|
-
};
|
|
2909
|
-
} catch {
|
|
2910
|
-
const params = new URLSearchParams(rawBody);
|
|
2911
|
-
const payload = params.get("payload") ?? params.get("data") ?? params.get("message");
|
|
2912
|
-
if (!payload) return {
|
|
2913
|
-
ok: false,
|
|
2914
|
-
error: "invalid json"
|
|
2915
|
-
};
|
|
2916
|
-
try {
|
|
2917
|
-
return {
|
|
2918
|
-
ok: true,
|
|
2919
|
-
value: JSON.parse(payload)
|
|
2920
|
-
};
|
|
2921
|
-
} catch (error) {
|
|
2922
|
-
return {
|
|
2923
|
-
ok: false,
|
|
2924
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2925
|
-
};
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
function asRecord(value) {
|
|
2930
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
2931
|
-
}
|
|
2932
|
-
function maskSecret(value) {
|
|
2933
|
-
if (value.length <= 6) return "***";
|
|
2934
|
-
return `${value.slice(0, 2)}***${value.slice(-2)}`;
|
|
2935
|
-
}
|
|
2936
|
-
function normalizeAuthToken(raw) {
|
|
2937
|
-
const value = raw.trim();
|
|
2938
|
-
if (!value) return "";
|
|
2939
|
-
if (value.toLowerCase().startsWith("bearer ")) return value.slice(7).trim();
|
|
2940
|
-
return value;
|
|
2941
|
-
}
|
|
2942
|
-
function safeEqualSecret(aRaw, bRaw) {
|
|
2943
|
-
const a = normalizeAuthToken(aRaw);
|
|
2944
|
-
const b = normalizeAuthToken(bRaw);
|
|
2945
|
-
if (!a || !b) return false;
|
|
2946
|
-
const bufA = Buffer.from(a, "utf8");
|
|
2947
|
-
const bufB = Buffer.from(b, "utf8");
|
|
2948
|
-
if (bufA.length !== bufB.length) return false;
|
|
2949
|
-
return timingSafeEqual(bufA, bufB);
|
|
2950
|
-
}
|
|
2951
|
-
async function handleBlueBubblesWebhookRequest(req, res) {
|
|
2952
|
-
return await withResolvedWebhookRequestPipeline({
|
|
2953
|
-
req,
|
|
2954
|
-
res,
|
|
2955
|
-
targetsByPath: webhookTargets,
|
|
2956
|
-
allowMethods: ["POST"],
|
|
2957
|
-
inFlightLimiter: webhookInFlightLimiter,
|
|
2958
|
-
handle: async ({ path, targets }) => {
|
|
2959
|
-
const url = new URL(req.url ?? "/", "http://localhost");
|
|
2960
|
-
const guidParam = url.searchParams.get("guid") ?? url.searchParams.get("password");
|
|
2961
|
-
const headerToken = req.headers["x-guid"] ?? req.headers["x-password"] ?? req.headers["x-bluebubbles-guid"] ?? req.headers["authorization"];
|
|
2962
|
-
const guid = (Array.isArray(headerToken) ? headerToken[0] : headerToken) ?? guidParam ?? "";
|
|
2963
|
-
const target = resolveWebhookTargetWithAuthOrRejectSync({
|
|
2964
|
-
targets,
|
|
2965
|
-
res,
|
|
2966
|
-
isMatch: (target) => {
|
|
2967
|
-
return safeEqualSecret(guid, target.account.config.password?.trim() ?? "");
|
|
2968
|
-
}
|
|
2969
|
-
});
|
|
2970
|
-
if (!target) {
|
|
2971
|
-
console.warn(`[bluebubbles] webhook rejected: status=${res.statusCode} path=${path} guid=${maskSecret(url.searchParams.get("guid") ?? url.searchParams.get("password") ?? "")}`);
|
|
2972
|
-
return true;
|
|
2973
|
-
}
|
|
2974
|
-
const body = await readWebhookBodyOrReject({
|
|
2975
|
-
req,
|
|
2976
|
-
res,
|
|
2977
|
-
profile: "post-auth",
|
|
2978
|
-
invalidBodyMessage: "invalid payload"
|
|
2979
|
-
});
|
|
2980
|
-
if (!body.ok) {
|
|
2981
|
-
console.warn(`[bluebubbles] webhook rejected: status=${res.statusCode}`);
|
|
2982
|
-
return true;
|
|
2983
|
-
}
|
|
2984
|
-
const parsed = parseBlueBubblesWebhookPayload(body.value);
|
|
2985
|
-
if (!parsed.ok) {
|
|
2986
|
-
res.statusCode = 400;
|
|
2987
|
-
res.end(parsed.error);
|
|
2988
|
-
console.warn(`[bluebubbles] webhook rejected: ${parsed.error}`);
|
|
2989
|
-
return true;
|
|
2990
|
-
}
|
|
2991
|
-
const payload = asRecord(parsed.value) ?? {};
|
|
2992
|
-
const firstTarget = targets[0];
|
|
2993
|
-
if (firstTarget) logVerbose(firstTarget.core, firstTarget.runtime, `webhook received path=${path} keys=${Object.keys(payload).join(",") || "none"}`);
|
|
2994
|
-
const eventTypeRaw = payload.type;
|
|
2995
|
-
const eventType = typeof eventTypeRaw === "string" ? eventTypeRaw.trim() : "";
|
|
2996
|
-
if (eventType && !new Set([
|
|
2997
|
-
"new-message",
|
|
2998
|
-
"updated-message",
|
|
2999
|
-
"message-reaction",
|
|
3000
|
-
"reaction"
|
|
3001
|
-
]).has(eventType)) {
|
|
3002
|
-
res.statusCode = 200;
|
|
3003
|
-
res.end("ok");
|
|
3004
|
-
if (firstTarget) logVerbose(firstTarget.core, firstTarget.runtime, `webhook ignored type=${eventType}`);
|
|
3005
|
-
return true;
|
|
3006
|
-
}
|
|
3007
|
-
const reaction = normalizeWebhookReaction(payload);
|
|
3008
|
-
if ((eventType === "updated-message" || eventType === "message-reaction" || eventType === "reaction") && !reaction) {
|
|
3009
|
-
res.statusCode = 200;
|
|
3010
|
-
res.end("ok");
|
|
3011
|
-
if (firstTarget) logVerbose(firstTarget.core, firstTarget.runtime, `webhook ignored ${eventType || "event"} without reaction`);
|
|
3012
|
-
return true;
|
|
3013
|
-
}
|
|
3014
|
-
const message = reaction ? null : normalizeWebhookMessage(payload);
|
|
3015
|
-
if (!message && !reaction) {
|
|
3016
|
-
res.statusCode = 400;
|
|
3017
|
-
res.end("invalid payload");
|
|
3018
|
-
console.warn("[bluebubbles] webhook rejected: unable to parse message payload");
|
|
3019
|
-
return true;
|
|
3020
|
-
}
|
|
3021
|
-
target.statusSink?.({ lastInboundAt: Date.now() });
|
|
3022
|
-
if (reaction) processReaction(reaction, target).catch((err) => {
|
|
3023
|
-
target.runtime.error?.(`[${target.account.accountId}] BlueBubbles reaction failed: ${String(err)}`);
|
|
3024
|
-
});
|
|
3025
|
-
else if (message) debounceRegistry.getOrCreateDebouncer(target).enqueue({
|
|
3026
|
-
message,
|
|
3027
|
-
target
|
|
3028
|
-
}).catch((err) => {
|
|
3029
|
-
target.runtime.error?.(`[${target.account.accountId}] BlueBubbles webhook failed: ${String(err)}`);
|
|
3030
|
-
});
|
|
3031
|
-
res.statusCode = 200;
|
|
3032
|
-
res.end("ok");
|
|
3033
|
-
if (reaction) {
|
|
3034
|
-
if (firstTarget) logVerbose(firstTarget.core, firstTarget.runtime, `webhook accepted reaction sender=${reaction.senderId} msg=${reaction.messageId} action=${reaction.action}`);
|
|
3035
|
-
} else if (message) {
|
|
3036
|
-
if (firstTarget) logVerbose(firstTarget.core, firstTarget.runtime, `webhook accepted sender=${message.senderId} group=${message.isGroup} chatGuid=${message.chatGuid ?? ""} chatId=${message.chatId ?? ""}`);
|
|
3037
|
-
}
|
|
3038
|
-
return true;
|
|
3039
|
-
}
|
|
3040
|
-
});
|
|
3041
|
-
}
|
|
3042
|
-
async function monitorBlueBubblesProvider(options) {
|
|
3043
|
-
const { account, config, runtime, abortSignal, statusSink } = options;
|
|
3044
|
-
const core = getBlueBubblesRuntime();
|
|
3045
|
-
const path = options.webhookPath?.trim() || "/bluebubbles-webhook";
|
|
3046
|
-
const serverInfo = await fetchBlueBubblesServerInfo({
|
|
3047
|
-
baseUrl: account.baseUrl,
|
|
3048
|
-
password: account.config.password,
|
|
3049
|
-
accountId: account.accountId,
|
|
3050
|
-
timeoutMs: 5e3
|
|
3051
|
-
}).catch(() => null);
|
|
3052
|
-
if (serverInfo?.os_version) runtime.log?.(`[${account.accountId}] BlueBubbles server macOS ${serverInfo.os_version}`);
|
|
3053
|
-
if (typeof serverInfo?.private_api === "boolean") runtime.log?.(`[${account.accountId}] BlueBubbles Private API ${serverInfo.private_api ? "enabled" : "disabled"}`);
|
|
3054
|
-
const unregister = registerBlueBubblesWebhookTarget({
|
|
3055
|
-
account,
|
|
3056
|
-
config,
|
|
3057
|
-
runtime,
|
|
3058
|
-
core,
|
|
3059
|
-
path,
|
|
3060
|
-
statusSink
|
|
3061
|
-
});
|
|
3062
|
-
return await new Promise((resolve) => {
|
|
3063
|
-
const stop = () => {
|
|
3064
|
-
unregister();
|
|
3065
|
-
resolve();
|
|
3066
|
-
};
|
|
3067
|
-
if (abortSignal?.aborted) {
|
|
3068
|
-
stop();
|
|
3069
|
-
return;
|
|
3070
|
-
}
|
|
3071
|
-
abortSignal?.addEventListener("abort", stop, { once: true });
|
|
3072
|
-
runtime.log?.(`[${account.accountId}] BlueBubbles webhook listening on ${normalizeWebhookPath(path)}`);
|
|
3073
|
-
});
|
|
3074
|
-
}
|
|
3075
|
-
//#endregion
|
|
3076
|
-
export { addBlueBubblesParticipant as a, removeBlueBubblesParticipant as c, unsendBlueBubblesMessage as d, sendBlueBubblesAttachment as f, sendBlueBubblesMedia as i, renameBlueBubblesChat as l, sendMessageBlueBubbles as m, sendBlueBubblesReaction as n, editBlueBubblesMessage as o, resolveChatGuidForTarget as p, resolveBlueBubblesMessageId as r, leaveBlueBubblesChat as s, monitorBlueBubblesProvider as t, setGroupIconBlueBubbles as u };
|