hyperclaw 4.0.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -4
- package/dist/a2ui-protocol-CT_jDEU9.js +75 -0
- package/dist/a2ui-protocol-CfBI44-Q.js +75 -0
- package/dist/agents-routing-683Q2JGp.js +129 -0
- package/dist/agents-routing-BpZBswBH.js +4 -0
- package/dist/agents-routing-ChHiZp36.js +327 -0
- package/dist/agents-routing-ChqZ6l2S.js +4 -0
- package/dist/api-keys-guide-BCcOl0Q7.js +149 -0
- package/dist/api-keys-guide-Dq5Obbp4.js +149 -0
- package/dist/audit-BYxPlnTQ.js +248 -0
- package/dist/audit-BaIiyWFu.js +441 -0
- package/dist/bounty-tools-C6LyzxM-.js +211 -0
- package/dist/bounty-tools-DWudyZie.js +211 -0
- package/dist/browser-tools-BsTeGMnX.js +5 -0
- package/dist/browser-tools-CQBSbIuO.js +5 -0
- package/dist/browser-tools-D8_rLe2p.js +179 -0
- package/dist/browser-tools-YQmwRLLM.js +179 -0
- package/dist/claw-tasks-BRLUvFRD.js +80 -0
- package/dist/claw-tasks-CgTsiNE8.js +80 -0
- package/dist/connector-3HnyH8fn.js +167 -0
- package/dist/connector-5N0-X_xs.js +194 -0
- package/dist/connector-6PMZo5Ky.js +189 -0
- package/dist/connector-B3v0qcXg.js +425 -0
- package/dist/connector-B6eoF3DD.js +181 -0
- package/dist/connector-B8R3iBY1.js +280 -0
- package/dist/connector-B9tLG8UZ.js +196 -0
- package/dist/connector-BAM-08NN.js +189 -0
- package/dist/connector-BC8FIVu4.js +181 -0
- package/dist/connector-BDmwwaVc.js +213 -0
- package/dist/connector-BGjbBy69.js +225 -0
- package/dist/connector-BO2SRzfG.js +218 -0
- package/dist/connector-BOlqjXWP.js +182 -0
- package/dist/connector-BP8zsbP8.js +189 -0
- package/dist/connector-BPoSevxp.js +286 -0
- package/dist/connector-BRHj773i.js +163 -0
- package/dist/connector-BToxU-jV.js +267 -0
- package/dist/connector-BfXky0L3.js +167 -0
- package/dist/connector-BiiSJpx3.js +192 -0
- package/dist/connector-BliDVsJQ.js +239 -0
- package/dist/connector-BnDmIhIu.js +85 -0
- package/dist/connector-Bv6s9oP7.js +88 -0
- package/dist/connector-By5wWGTR.js +343 -0
- package/dist/connector-C1BaFFgN.js +213 -0
- package/dist/connector-C1HSoUyk.js +189 -0
- package/dist/connector-CKQHZOXg.js +568 -0
- package/dist/connector-CRRWY5Wv.js +167 -0
- package/dist/connector-CRl-iidy.js +239 -0
- package/dist/connector-CXPQVGyI.js +85 -0
- package/dist/connector-Cdk1CXKi.js +194 -0
- package/dist/connector-Ci9glMD-.js +340 -0
- package/dist/connector-CjtZIEDj.js +181 -0
- package/dist/connector-Ck6JtOsX.js +531 -0
- package/dist/connector-CwlgFgjx.js +181 -0
- package/dist/connector-D8Kelee0.js +286 -0
- package/dist/connector-DAnRJ0oP.js +162 -0
- package/dist/connector-DFchk6l7.js +178 -0
- package/dist/connector-DKw7tRAy.js +192 -0
- package/dist/connector-DRv1ahC_.js +2 -2
- package/dist/connector-DU63KW94.js +165 -0
- package/dist/connector-DXTp5PE8.js +508 -0
- package/dist/connector-Dbvb1Cj9.js +280 -0
- package/dist/connector-DcZdQcgR.js +173 -0
- package/dist/connector-Dih6dUPP.js +173 -0
- package/dist/connector-DqTH_tPX.js +182 -0
- package/dist/connector-DrnEiiyP.js +419 -0
- package/dist/connector-DtR5GGTX.js +167 -0
- package/dist/connector-DxKL8VvZ.js +182 -0
- package/dist/connector-T_YdZtzv.js +162 -0
- package/dist/connector-Tky_qS_K.js +350 -0
- package/dist/connector-ZSc3oTTy.js +305 -0
- package/dist/connector-i4gOS9xL.js +154 -0
- package/dist/connector-rHXE1ZD2.js +167 -0
- package/dist/connector-sW5yhU1m.js +498 -0
- package/dist/connector-u3ICd3Ic.js +552 -0
- package/dist/connector-wdUXChwa.js +172 -0
- package/dist/cost-tracker-DD9wtWsr.js +103 -0
- package/dist/cost-tracker-pVE15Yq4.js +103 -0
- package/dist/credentials-store-BvnMPJwi.js +4 -0
- package/dist/credentials-store-C6ir0Dae.js +4 -0
- package/dist/credentials-store-H13LqOwJ.js +77 -0
- package/dist/credentials-store-sb-TRLwR.js +77 -0
- package/dist/cron-tasks-Bli7Kzd2.js +82 -0
- package/dist/cron-tasks-BvDFNyiE.js +82 -0
- package/dist/daemon-Bg4GtCmc.js +318 -0
- package/dist/daemon-DhmwY8k4.js +5 -0
- package/dist/delivery-BmIYy9VQ.js +4 -0
- package/dist/delivery-D5Z98EVq.js +95 -0
- package/dist/delivery-DCOXhXEO.js +5 -0
- package/dist/delivery-pWUPBp1F.js +95 -0
- package/dist/destructive-gate-D6vWOdEl.js +101 -0
- package/dist/destructive-gate-m-dWqUFg.js +101 -0
- package/dist/developer-keys-CPWT7Q6S.js +8 -0
- package/dist/developer-keys-DrrcUqFa.js +127 -0
- package/dist/developer-keys-JaJK3T27.js +127 -0
- package/dist/developer-keys-kyqmtWK3.js +8 -0
- package/dist/doctor-3oi89QIc.js +175 -0
- package/dist/doctor-BvCe8BBk.js +230 -0
- package/dist/doctor-Cf1XSfp9.js +4 -0
- package/dist/doctor-CxyPLYsJ.js +6 -0
- package/dist/engine-B4eMiTgl.js +7 -0
- package/dist/engine-B8M7dYul.js +7 -0
- package/dist/engine-BhT-1M9W.js +256 -0
- package/dist/engine-CEDSqXfw.js +256 -0
- package/dist/engine-D49jnSd_.js +256 -0
- package/dist/engine-Da4JMNpI.js +7 -0
- package/dist/env-resolve-CiXbWYwe.js +10 -0
- package/dist/env-resolve-CmGWhWXJ.js +115 -0
- package/dist/env-resolve-DWOQ45jG.js +9 -0
- package/dist/env-resolve-szSWl0UF.js +94 -0
- package/dist/extraction-tools-D3qDFBJ1.js +91 -0
- package/dist/extraction-tools-DLr_AEwq.js +5 -0
- package/dist/extraction-tools-HOZstZ0y.js +91 -0
- package/dist/extraction-tools-m4lmAv7l.js +5 -0
- package/dist/form_data-B_hIUrxU.js +8657 -0
- package/dist/form_data-Cz040rio.js +8657 -0
- package/dist/gmail-watch-setup-Czt8rXaX.js +40 -0
- package/dist/gmail-watch-setup-Du7DVV7S.js +40 -0
- package/dist/health-B-asI__D.js +6 -0
- package/dist/health-Ds2YlpTB.js +152 -0
- package/dist/heartbeat-engine-BYT5ayQH.js +83 -0
- package/dist/heartbeat-engine-CRqfPcFM.js +83 -0
- package/dist/hub-D0XwdjM-.js +515 -0
- package/dist/hub-DTsqe5Bt.js +6 -0
- package/dist/hub-FrPTA33j.js +515 -0
- package/dist/hub-LiD5Iztb.js +6 -0
- package/dist/hyperclawbot-D9KCtc4P.js +480 -0
- package/dist/hyperclawbot-Dw27pJo4.js +480 -0
- package/dist/hyperclawbot-zvczQgKx.js +505 -0
- package/dist/inference-BKVkBREb.js +6 -0
- package/dist/inference-CTWJeX9Q.js +922 -0
- package/dist/inference-DCXH4Q3x.js +922 -0
- package/dist/inference-ix607p7k.js +6 -0
- package/dist/knowledge-graph-DqA-Fztl.js +131 -0
- package/dist/knowledge-graph-iBG76fvm.js +131 -0
- package/dist/loader-CC45xGpC.js +4 -0
- package/dist/loader-CISCqBto.js +400 -0
- package/dist/loader-CYMQ8VOS.js +4 -0
- package/dist/loader-CnEdOyjT.js +400 -0
- package/dist/logger-8tEtAd3y.js +83 -0
- package/dist/logger-ybOp7VOC.js +83 -0
- package/dist/manager-03ipO9R0.js +105 -0
- package/dist/manager-BpDfbDjg.js +117 -0
- package/dist/manager-Bxl0sqlh.js +4 -0
- package/dist/manager-CPjeRe-6.js +4 -0
- package/dist/manager-CrVDn6eN.js +6 -0
- package/dist/manager-Cwzj7w5R.js +105 -0
- package/dist/manager-DLmZI-9R.js +6 -0
- package/dist/manager-DSGhn5i3.js +117 -0
- package/dist/manager-DgyF52mg.js +218 -0
- package/dist/manager-Dm8nrMFx.js +40 -0
- package/dist/manager-FCgF1plu.js +218 -0
- package/dist/manager-rgCsaWT1.js +40 -0
- package/dist/mcp-B_9Ber63.js +139 -0
- package/dist/mcp-CfoSU4Uz.js +139 -0
- package/dist/mcp-loader-DSM5UiFG.js +94 -0
- package/dist/mcp-loader-DkRBsLpk.js +94 -0
- package/dist/mcp-loader-j5ZLLw5O.js +94 -0
- package/dist/memory-BI1kPkAN.js +4 -0
- package/dist/memory-BVFGkxxK.js +270 -0
- package/dist/memory-BlHL7JCO.js +4 -0
- package/dist/memory-DsS_eFvJ.js +270 -0
- package/dist/memory-auto-Bc7euou4.js +306 -0
- package/dist/memory-auto-BkvtSFUw.js +5 -0
- package/dist/memory-auto-Bnz_-1wP.js +306 -0
- package/dist/memory-auto-DPfbkMVt.js +5 -0
- package/dist/memory-integration-DZExqWr4.js +91 -0
- package/dist/memory-integration-cSYkZyEo.js +91 -0
- package/dist/moltbook-B6ZeGN5_.js +81 -0
- package/dist/moltbook-BtLDZTfM.js +81 -0
- package/dist/node-Dw2Gi-cP.js +222 -0
- package/dist/node-pwL6O_KX.js +222 -0
- package/dist/nodes-registry-B8dmrlLv.js +52 -0
- package/dist/nodes-registry-CsPm_-CJ.js +52 -0
- package/dist/oauth-flow-CpWlgvNB.js +150 -0
- package/dist/oauth-flow-DQPvMHRH.js +150 -0
- package/dist/oauth-provider-BZb6qOw5.js +110 -0
- package/dist/oauth-provider-Uo4Nib_c.js +110 -0
- package/dist/observability-B43YvNQV.js +89 -0
- package/dist/observability-BV-Yx0V9.js +89 -0
- package/dist/onboard-0WoDxbv_.js +10 -0
- package/dist/onboard-BXNXCQp4.js +4070 -0
- package/dist/onboard-Bd_wsYdi.js +4086 -0
- package/dist/onboard-CAN7x3me.js +3026 -0
- package/dist/onboard-DnegOHMh.js +4 -4
- package/dist/onboard-RYtDlYBw.js +9 -0
- package/dist/onboard-aTwlQs-4.js +9 -0
- package/dist/orchestrator-BSp2M5EU.js +189 -0
- package/dist/orchestrator-C7ko5tWa.js +6 -0
- package/dist/orchestrator-DfPkIx2Z.js +6 -0
- package/dist/orchestrator-DmnEvMaL.js +189 -0
- package/dist/orchestrator-NJQsmiBE.js +189 -0
- package/dist/orchestrator-RI3bpqqc.js +6 -0
- package/dist/pairing-6iM27aD8.js +196 -0
- package/dist/pairing-DU0_J28n.js +87 -0
- package/dist/pairing-DWllbSbO.js +4 -0
- package/dist/pairing-dGoiGepK.js +4 -0
- package/dist/pc-access-CgCsYrpt.js +8 -0
- package/dist/pc-access-Ly-uA8mn.js +8 -0
- package/dist/pc-access-NxBvTrRj.js +819 -0
- package/dist/pc-access-_iH2aorG.js +819 -0
- package/dist/pending-approval-CUXjysAo.js +22 -0
- package/dist/pending-approval-DIHvwwWS.js +22 -0
- package/dist/puppeteer-2o3QOwAy.js +2 -2
- package/dist/puppeteer-BYTMp3BI.js +2 -2
- package/dist/puppeteer-DQ45qwWk.js +2 -2
- package/dist/reminders-store-D79qdfN0.js +58 -0
- package/dist/reminders-store-Drjed_-h.js +58 -0
- package/dist/renderer-BVQrd0_g.js +225 -0
- package/dist/renderer-pqlDRKbH.js +225 -0
- package/dist/rules-BE4GV6cV.js +103 -0
- package/dist/rules-BooT_qFP.js +103 -0
- package/dist/run-main.js +1649 -1227
- package/dist/runner-D1rjuMTJ.js +810 -0
- package/dist/runner-DatMMYYE.js +1271 -0
- package/dist/sdk/index.js +2 -2
- package/dist/sdk/index.mjs +2 -2
- package/dist/security-BqNyT4ID.js +4 -0
- package/dist/security-C-5URby1.js +73 -0
- package/dist/security-_xve79aq.js +4 -0
- package/dist/security-tpgqPWWH.js +73 -0
- package/dist/server-0kgyELx4.js +1047 -0
- package/dist/server-BIuTobTC.js +4 -0
- package/dist/server-BRlCEjyT.js +1047 -0
- package/dist/server-CCI1hv45.js +2 -2
- package/dist/server-D4wVHiX9.js +4 -0
- package/dist/server-DU9POoWc.js +4 -0
- package/dist/server-Dh3JlBFB.js +1255 -0
- package/dist/session-store-BUiPz0Vv.js +5 -0
- package/dist/session-store-CujxByI6.js +113 -0
- package/dist/session-store-is4B6qmD.js +113 -0
- package/dist/session-store-qpJUg2M1.js +5 -0
- package/dist/sessions-tools-CB2qbwIk.js +5 -0
- package/dist/sessions-tools-CbUTFe4i.js +5 -0
- package/dist/sessions-tools-CeqD7iil.js +95 -0
- package/dist/sessions-tools-DHMaTZIs.js +95 -0
- package/dist/skill-loader-BaNLVmJy.js +7 -0
- package/dist/skill-loader-BkceKkIg.js +7 -0
- package/dist/skill-loader-DhgIwK4J.js +159 -0
- package/dist/skill-loader-HgpF6Vqs.js +159 -0
- package/dist/skill-runtime--LqxWrp5.js +102 -0
- package/dist/skill-runtime-C5l0Tgt-.js +5 -0
- package/dist/skill-runtime-CJN24QPW.js +102 -0
- package/dist/skill-runtime-DsXK_HYG.js +102 -0
- package/dist/skill-runtime-IVTiqrMR.js +5 -0
- package/dist/skill-runtime-w1ig_lcw.js +5 -0
- package/dist/src-BEVLgaF1.js +63 -0
- package/dist/src-Bgu_OxTQ.js +458 -0
- package/dist/src-Bq-oKt7Z.js +458 -0
- package/dist/src-BxPHKO5x.js +63 -0
- package/dist/src-DIc-L2IG.js +20 -0
- package/dist/src-DWCUhnD4.js +20 -0
- package/dist/src-cfRTjFef.js +63 -0
- package/dist/src-g_rNx5rh.js +458 -0
- package/dist/sub-agent-tools-BD9DF8_g.js +39 -0
- package/dist/sub-agent-tools-CHQoHz9c.js +39 -0
- package/dist/sub-agent-tools-V7b3T9_s.js +39 -0
- package/dist/theme-DcxwcUgZ.js +180 -0
- package/dist/theme-cx0fkgWC.js +8 -0
- package/dist/tool-policy-CNT-mF2Z.js +189 -0
- package/dist/tool-policy-DNvNRnve.js +189 -0
- package/dist/tts-elevenlabs-BRosZv-f.js +61 -0
- package/dist/tts-elevenlabs-BUOGKL-k.js +61 -0
- package/dist/update-check-BD4qH7Am.js +81 -0
- package/dist/update-check-C2Dz85wJ.js +81 -0
- package/dist/vision-BMmiIKy7.js +121 -0
- package/dist/vision-DRq-f-Dj.js +121 -0
- package/dist/vision-tools-CFZEpQKm.js +5 -0
- package/dist/vision-tools-CQnBI9aa.js +51 -0
- package/dist/vision-tools-DVuYc17I.js +51 -0
- package/dist/vision-tools-U3YC4L-g.js +5 -0
- package/dist/voice-transcription-B555DbWR.js +138 -0
- package/dist/voice-transcription-CgWq54hn.js +138 -0
- package/dist/website-watch-tools-Bk_TnwuE.js +5 -0
- package/dist/website-watch-tools-DFMrJU-R.js +139 -0
- package/dist/website-watch-tools-DraMPxdl.js +139 -0
- package/dist/website-watch-tools-Du3W5sN7.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,810 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const require_paths = require('./paths-AIyBxIzm.js');
|
|
3
|
+
const require_paths$1 = require('./paths-DPovhojT.js');
|
|
4
|
+
const require_delivery = require('./delivery-D5Z98EVq.js');
|
|
5
|
+
const fs_extra = require_chunk.__toESM(require("fs-extra"));
|
|
6
|
+
const path = require_chunk.__toESM(require("path"));
|
|
7
|
+
const http = require_chunk.__toESM(require("http"));
|
|
8
|
+
|
|
9
|
+
//#region src/channels/runner.ts
|
|
10
|
+
require_paths$1.init_paths();
|
|
11
|
+
const HC_DIR = require_paths.getHyperClawDir();
|
|
12
|
+
const connectors = [];
|
|
13
|
+
let emailConnectorRef = null;
|
|
14
|
+
const webhookConnectors = {};
|
|
15
|
+
async function startChannelRunners(opts) {
|
|
16
|
+
const port = opts.port;
|
|
17
|
+
const baseUrl = `http://${opts.bind || "127.0.0.1"}:${port}`;
|
|
18
|
+
const authToken = opts.authToken || "";
|
|
19
|
+
let cfg = {};
|
|
20
|
+
try {
|
|
21
|
+
cfg = await fs_extra.default.readJson(require_paths.getConfigPath());
|
|
22
|
+
} catch {}
|
|
23
|
+
let channelConfigs = {};
|
|
24
|
+
let configChannels = [];
|
|
25
|
+
try {
|
|
26
|
+
const configPath = path.default.join(HC_DIR, "config.json");
|
|
27
|
+
if (await fs_extra.default.pathExists(configPath)) {
|
|
28
|
+
const c2 = await fs_extra.default.readJson(configPath);
|
|
29
|
+
channelConfigs = c2.channelConfigs || {};
|
|
30
|
+
configChannels = Array.isArray(c2.channels) ? c2.channels : [];
|
|
31
|
+
}
|
|
32
|
+
} catch {}
|
|
33
|
+
const enabledIds = (cfg.gateway?.enabledChannels?.length ? cfg.gateway.enabledChannels : configChannels) || [];
|
|
34
|
+
const ids = Array.isArray(enabledIds) ? enabledIds : [];
|
|
35
|
+
if (ids.length === 0) return { stop: async () => {} };
|
|
36
|
+
const wrap = (c) => {
|
|
37
|
+
const ty = c.sendTyping;
|
|
38
|
+
return {
|
|
39
|
+
sendMessage: (id, t) => c.sendMessage(String(id), t),
|
|
40
|
+
sendTyping: ty ? (id) => ty(String(id)) : void 0
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const handleMsg = async (msg, conn, channelId) => {
|
|
44
|
+
try {
|
|
45
|
+
conn.sendTyping?.(msg.chatId).catch(() => {});
|
|
46
|
+
const { enrichVoiceNote, withRetry } = await Promise.resolve().then(() => require("./delivery-DCOXhXEO.js"));
|
|
47
|
+
const text = await enrichVoiceNote(msg);
|
|
48
|
+
const response = await withRetry(() => postChat(baseUrl, text, channelId, authToken), { onRetry: (n, err) => console.error(`[channels] ${channelId} agent retry ${n}: ${err.message}`) });
|
|
49
|
+
const chunks = require_delivery.chunkForChannel(response, channelId);
|
|
50
|
+
for (const chunk of chunks) await withRetry(() => conn.sendMessage(msg.chatId, chunk), { onRetry: (n, err) => console.error(`[channels] ${channelId} send retry ${n}: ${err.message}`) });
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.error(`[channels] ${channelId} error: ${e.message}`);
|
|
53
|
+
await conn.sendMessage(msg.chatId, `Error: ${e.message}`).catch(() => {});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
for (const id of ids) {
|
|
57
|
+
const chCfg = cfg.channels?.[id] || channelConfigs[id];
|
|
58
|
+
const dmObj = chCfg?.dmPolicy;
|
|
59
|
+
const dmPolicy = (typeof dmObj === "object" ? dmObj?.policy : dmObj) || "pairing";
|
|
60
|
+
const allowFrom = chCfg?.allowFrom || (typeof dmObj === "object" ? dmObj?.allowFrom : []) || [];
|
|
61
|
+
const allowFromArr = Array.isArray(allowFrom) ? allowFrom : [];
|
|
62
|
+
if (id === "telegram") {
|
|
63
|
+
const token = chCfg?.token || chCfg?.botToken || process.env.TELEGRAM_BOT_TOKEN;
|
|
64
|
+
if (!token) continue;
|
|
65
|
+
try {
|
|
66
|
+
const { TelegramConnector } = await Promise.resolve().then(() => require("./connector-Dbvb1Cj9.js"));
|
|
67
|
+
const conn = new TelegramConnector(token, {
|
|
68
|
+
dmPolicy,
|
|
69
|
+
allowFrom: allowFromArr,
|
|
70
|
+
pendingPairings: {},
|
|
71
|
+
approvedPairings: []
|
|
72
|
+
});
|
|
73
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "telegram"));
|
|
74
|
+
await conn.connect();
|
|
75
|
+
connectors.push({ stop: async () => {
|
|
76
|
+
await conn.disconnect();
|
|
77
|
+
} });
|
|
78
|
+
} catch (e) {
|
|
79
|
+
console.error(`[channels] Telegram failed to start: ${e.message}`);
|
|
80
|
+
}
|
|
81
|
+
} else if (id === "discord") {
|
|
82
|
+
const token = chCfg?.token || process.env.DISCORD_BOT_TOKEN;
|
|
83
|
+
if (!token) continue;
|
|
84
|
+
try {
|
|
85
|
+
const { DiscordConnector } = await Promise.resolve().then(() => require("./connector-By5wWGTR.js"));
|
|
86
|
+
const conn = new DiscordConnector(token, {
|
|
87
|
+
dmPolicy,
|
|
88
|
+
allowFrom: allowFromArr,
|
|
89
|
+
pendingPairings: {},
|
|
90
|
+
approvedPairings: []
|
|
91
|
+
});
|
|
92
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "discord"));
|
|
93
|
+
await conn.connect();
|
|
94
|
+
connectors.push({ stop: async () => {
|
|
95
|
+
await conn.disconnect();
|
|
96
|
+
} });
|
|
97
|
+
} catch (e) {
|
|
98
|
+
console.error(`[channels] Discord failed to start: ${e.message}`);
|
|
99
|
+
}
|
|
100
|
+
} else if (id === "slack") {
|
|
101
|
+
const botToken = chCfg?.botToken || chCfg?.token || process.env.SLACK_BOT_TOKEN;
|
|
102
|
+
const signingSecret = chCfg?.signingSecret || process.env.SLACK_SIGNING_SECRET;
|
|
103
|
+
if (!botToken || !signingSecret) continue;
|
|
104
|
+
try {
|
|
105
|
+
const { SlackConnector } = await Promise.resolve().then(() => require("./connector-B9tLG8UZ.js"));
|
|
106
|
+
const conn = new SlackConnector({
|
|
107
|
+
botToken,
|
|
108
|
+
signingSecret,
|
|
109
|
+
dmPolicy,
|
|
110
|
+
allowFrom: allowFromArr,
|
|
111
|
+
approvedPairings: [],
|
|
112
|
+
pendingPairings: {}
|
|
113
|
+
});
|
|
114
|
+
conn.on("message", (msg) => {
|
|
115
|
+
const send = (id$1, t) => conn.sendMessage(String(id$1), t, msg.threadTs);
|
|
116
|
+
const typing = conn.sendTyping ? (id$1) => conn.sendTyping(String(id$1)) : void 0;
|
|
117
|
+
handleMsg({
|
|
118
|
+
chatId: msg.chatId,
|
|
119
|
+
text: msg.text
|
|
120
|
+
}, {
|
|
121
|
+
sendMessage: send,
|
|
122
|
+
sendTyping: typing
|
|
123
|
+
}, "slack");
|
|
124
|
+
});
|
|
125
|
+
await conn.connect();
|
|
126
|
+
webhookConnectors["slack"] = {
|
|
127
|
+
handleWebhook: async (body, opts$1) => await conn.handleWebhook(body, opts$1?.signature ?? "", opts$1?.timestamp ?? "") ?? void 0,
|
|
128
|
+
verifyWebhook: void 0
|
|
129
|
+
};
|
|
130
|
+
connectors.push({ stop: async () => {} });
|
|
131
|
+
} catch (e) {
|
|
132
|
+
console.error(`[channels] Slack failed to start: ${e.message}`);
|
|
133
|
+
}
|
|
134
|
+
} else if (id === "signal") {
|
|
135
|
+
const signalCliUrl = chCfg?.signalCliUrl || process.env.SIGNAL_CLI_URL || "http://localhost:8080";
|
|
136
|
+
const phoneNumber = chCfg?.phoneNumber || chCfg?.token || process.env.SIGNAL_PHONE_NUMBER;
|
|
137
|
+
if (!phoneNumber) continue;
|
|
138
|
+
try {
|
|
139
|
+
const { SignalConnector } = await Promise.resolve().then(() => require("./connector-CRRWY5Wv.js"));
|
|
140
|
+
const conn = new SignalConnector({
|
|
141
|
+
signalCliUrl,
|
|
142
|
+
phoneNumber,
|
|
143
|
+
dmPolicy,
|
|
144
|
+
allowFrom: allowFromArr,
|
|
145
|
+
approvedPairings: [],
|
|
146
|
+
pendingPairings: {}
|
|
147
|
+
});
|
|
148
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "signal"));
|
|
149
|
+
await conn.connect();
|
|
150
|
+
connectors.push({ stop: async () => {
|
|
151
|
+
conn.disconnect();
|
|
152
|
+
} });
|
|
153
|
+
} catch (e) {
|
|
154
|
+
console.error(`[channels] Signal failed to start: ${e.message}`);
|
|
155
|
+
}
|
|
156
|
+
} else if (id === "matrix") {
|
|
157
|
+
const homeserver = chCfg?.homeserver || chCfg?.homeserverUrl || process.env.MATRIX_HOMESERVER;
|
|
158
|
+
const accessToken = chCfg?.accessToken || chCfg?.token || process.env.MATRIX_ACCESS_TOKEN;
|
|
159
|
+
const userId = chCfg?.userId || process.env.MATRIX_USER_ID;
|
|
160
|
+
if (!homeserver || !accessToken || !userId) continue;
|
|
161
|
+
try {
|
|
162
|
+
const { MatrixConnector } = await Promise.resolve().then(() => require("./connector-DU63KW94.js"));
|
|
163
|
+
const conn = new MatrixConnector({
|
|
164
|
+
homeserver,
|
|
165
|
+
accessToken,
|
|
166
|
+
userId,
|
|
167
|
+
dmPolicy,
|
|
168
|
+
allowFrom: allowFromArr,
|
|
169
|
+
approvedPairings: [],
|
|
170
|
+
pendingPairings: {}
|
|
171
|
+
});
|
|
172
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "matrix"));
|
|
173
|
+
await conn.connect();
|
|
174
|
+
connectors.push({ stop: async () => {
|
|
175
|
+
conn.disconnect();
|
|
176
|
+
} });
|
|
177
|
+
} catch (e) {
|
|
178
|
+
console.error(`[channels] Matrix failed to start: ${e.message}`);
|
|
179
|
+
}
|
|
180
|
+
} else if (id === "nostr") {
|
|
181
|
+
const privateKeyHex = chCfg?.privateKeyHex || process.env.NOSTR_PRIVATE_KEY;
|
|
182
|
+
const relays = chCfg?.relays || (process.env.NOSTR_RELAYS || "wss://relay.damus.io,wss://nos.lol").split(",");
|
|
183
|
+
if (!privateKeyHex || !Array.isArray(relays) || relays.length === 0) continue;
|
|
184
|
+
try {
|
|
185
|
+
const { NostrConnector } = await Promise.resolve().then(() => require("./connector-DKw7tRAy.js"));
|
|
186
|
+
const conn = new NostrConnector({
|
|
187
|
+
privateKeyHex,
|
|
188
|
+
relays,
|
|
189
|
+
dmPolicy,
|
|
190
|
+
allowFrom: allowFromArr,
|
|
191
|
+
approvedPairings: [],
|
|
192
|
+
pendingPairings: {}
|
|
193
|
+
});
|
|
194
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "nostr"));
|
|
195
|
+
await conn.connect();
|
|
196
|
+
connectors.push({ stop: async () => {
|
|
197
|
+
conn.disconnect();
|
|
198
|
+
} });
|
|
199
|
+
} catch (e) {
|
|
200
|
+
console.error(`[channels] Nostr failed to start: ${e.message}`);
|
|
201
|
+
}
|
|
202
|
+
} else if (id === "line") {
|
|
203
|
+
const channelAccessToken = chCfg?.channelAccessToken || chCfg?.token || process.env.LINE_CHANNEL_ACCESS_TOKEN;
|
|
204
|
+
const channelSecret = chCfg?.channelSecret || process.env.LINE_CHANNEL_SECRET;
|
|
205
|
+
if (!channelAccessToken || !channelSecret) continue;
|
|
206
|
+
try {
|
|
207
|
+
const { LINEConnector } = await Promise.resolve().then(() => require("./connector-DFchk6l7.js"));
|
|
208
|
+
const conn = new LINEConnector({
|
|
209
|
+
channelAccessToken,
|
|
210
|
+
channelSecret,
|
|
211
|
+
dmPolicy,
|
|
212
|
+
allowFrom: allowFromArr,
|
|
213
|
+
approvedPairings: [],
|
|
214
|
+
pendingPairings: {}
|
|
215
|
+
});
|
|
216
|
+
conn.on("message", async (msg) => {
|
|
217
|
+
const send = (id$1, t) => msg.replyToken ? conn.replyMessage(msg.replyToken, t) : conn.pushMessage(String(id$1), t);
|
|
218
|
+
await handleMsg({
|
|
219
|
+
chatId: msg.chatId,
|
|
220
|
+
text: msg.text
|
|
221
|
+
}, { sendMessage: send }, "line");
|
|
222
|
+
});
|
|
223
|
+
await conn.connect();
|
|
224
|
+
webhookConnectors["line"] = {
|
|
225
|
+
handleWebhook: (body, opts$1) => conn.handleWebhook(body, opts$1?.signature ?? ""),
|
|
226
|
+
verifyWebhook: void 0
|
|
227
|
+
};
|
|
228
|
+
connectors.push({ stop: async () => {
|
|
229
|
+
conn.disconnect();
|
|
230
|
+
} });
|
|
231
|
+
} catch (e) {
|
|
232
|
+
console.error(`[channels] LINE failed to start: ${e.message}`);
|
|
233
|
+
}
|
|
234
|
+
} else if (id === "feishu" || id === "lark") {
|
|
235
|
+
const appId = chCfg?.appId || process.env.FEISHU_APP_ID;
|
|
236
|
+
const appSecret = chCfg?.appSecret || process.env.FEISHU_APP_SECRET;
|
|
237
|
+
if (!appId || !appSecret) continue;
|
|
238
|
+
try {
|
|
239
|
+
const { FeishuConnector } = await Promise.resolve().then(() => require("./connector-C1BaFFgN.js"));
|
|
240
|
+
const conn = new FeishuConnector({
|
|
241
|
+
appId,
|
|
242
|
+
appSecret,
|
|
243
|
+
dmPolicy,
|
|
244
|
+
allowFrom: allowFromArr,
|
|
245
|
+
approvedPairings: [],
|
|
246
|
+
pendingPairings: {}
|
|
247
|
+
});
|
|
248
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "feishu"));
|
|
249
|
+
await conn.connect();
|
|
250
|
+
const feishuHandler = {
|
|
251
|
+
handleWebhook: async (body) => {
|
|
252
|
+
const ch = conn.handleChallenge?.(body);
|
|
253
|
+
if (ch) return ch;
|
|
254
|
+
await conn.handleWebhook(body);
|
|
255
|
+
},
|
|
256
|
+
verifyWebhook: void 0
|
|
257
|
+
};
|
|
258
|
+
webhookConnectors["feishu"] = feishuHandler;
|
|
259
|
+
if (id === "lark") webhookConnectors["lark"] = feishuHandler;
|
|
260
|
+
connectors.push({ stop: async () => {
|
|
261
|
+
conn.disconnect();
|
|
262
|
+
} });
|
|
263
|
+
} catch (e) {
|
|
264
|
+
console.error(`[channels] Feishu failed to start: ${e.message}`);
|
|
265
|
+
}
|
|
266
|
+
} else if (id === "msteams" || id === "teams") {
|
|
267
|
+
const appId = chCfg?.appId || process.env.MSTEAMS_APP_ID;
|
|
268
|
+
const appPassword = chCfg?.appPassword || chCfg?.password || process.env.MSTEAMS_APP_PASSWORD;
|
|
269
|
+
if (!appId || !appPassword) continue;
|
|
270
|
+
try {
|
|
271
|
+
const { MSTeamsConnector } = await Promise.resolve().then(() => require("./connector-6PMZo5Ky.js"));
|
|
272
|
+
const conn = new MSTeamsConnector({
|
|
273
|
+
appId,
|
|
274
|
+
appPassword,
|
|
275
|
+
dmPolicy,
|
|
276
|
+
allowFrom: allowFromArr,
|
|
277
|
+
approvedPairings: [],
|
|
278
|
+
pendingPairings: {}
|
|
279
|
+
});
|
|
280
|
+
conn.on("message", (msg) => {
|
|
281
|
+
const m = msg;
|
|
282
|
+
const send = (id$1, t) => conn.reply(m.serviceUrl, String(id$1), m.activity, t);
|
|
283
|
+
handleMsg(msg, { sendMessage: send }, "msteams");
|
|
284
|
+
});
|
|
285
|
+
await conn.connect();
|
|
286
|
+
webhookConnectors["msteams"] = {
|
|
287
|
+
handleWebhook: (body) => conn.handleWebhook(body),
|
|
288
|
+
verifyWebhook: void 0
|
|
289
|
+
};
|
|
290
|
+
connectors.push({ stop: async () => {
|
|
291
|
+
conn.disconnect();
|
|
292
|
+
} });
|
|
293
|
+
} catch (e) {
|
|
294
|
+
console.error(`[channels] MS Teams failed to start: ${e.message}`);
|
|
295
|
+
}
|
|
296
|
+
} else if (id === "bluebubbles" || id === "imessage") {
|
|
297
|
+
const serverUrl = chCfg?.serverUrl || process.env.BLUEBUBBLES_SERVER_URL;
|
|
298
|
+
const password = chCfg?.password || process.env.BLUEBUBBLES_PASSWORD;
|
|
299
|
+
if (!serverUrl || !password) continue;
|
|
300
|
+
try {
|
|
301
|
+
const { BlueBubblesConnector } = await Promise.resolve().then(() => require("./connector-B6eoF3DD.js"));
|
|
302
|
+
const conn = new BlueBubblesConnector({
|
|
303
|
+
serverUrl,
|
|
304
|
+
password,
|
|
305
|
+
dmPolicy,
|
|
306
|
+
allowFrom: allowFromArr,
|
|
307
|
+
approvedPairings: [],
|
|
308
|
+
pendingPairings: {}
|
|
309
|
+
});
|
|
310
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "bluebubbles"));
|
|
311
|
+
await conn.connect();
|
|
312
|
+
connectors.push({ stop: async () => {
|
|
313
|
+
conn.disconnect();
|
|
314
|
+
} });
|
|
315
|
+
} catch (e) {
|
|
316
|
+
console.error(`[channels] BlueBubbles failed to start: ${e.message}`);
|
|
317
|
+
}
|
|
318
|
+
} else if (id === "imessage-native" && process.platform === "darwin") try {
|
|
319
|
+
const { IMessageNativeConnector } = await Promise.resolve().then(() => require("./connector-i4gOS9xL.js"));
|
|
320
|
+
const conn = new IMessageNativeConnector({
|
|
321
|
+
dmPolicy,
|
|
322
|
+
allowFrom: allowFromArr,
|
|
323
|
+
approvedPairings: [],
|
|
324
|
+
pendingPairings: {}
|
|
325
|
+
});
|
|
326
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "imessage-native"));
|
|
327
|
+
await conn.connect();
|
|
328
|
+
connectors.push({ stop: async () => {
|
|
329
|
+
conn.disconnect();
|
|
330
|
+
} });
|
|
331
|
+
} catch (e) {
|
|
332
|
+
console.error(`[channels] imessage-native failed: ${e.message}. Install imsg (github.com/steipete/imsg) and grant Full Disk Access + Automation.`);
|
|
333
|
+
}
|
|
334
|
+
else if (id === "instagram") {
|
|
335
|
+
const pageAccessToken = chCfg?.pageAccessToken || chCfg?.token || process.env.INSTAGRAM_PAGE_ACCESS_TOKEN;
|
|
336
|
+
const instagramAccountId = chCfg?.instagramAccountId || chCfg?.instagramAccountID || process.env.INSTAGRAM_ACCOUNT_ID;
|
|
337
|
+
const verifyToken = chCfg?.verifyToken || process.env.INSTAGRAM_VERIFY_TOKEN || "hyperclaw";
|
|
338
|
+
if (!pageAccessToken || !instagramAccountId) continue;
|
|
339
|
+
try {
|
|
340
|
+
const { InstagramConnector } = await Promise.resolve().then(() => require("./connector-T_YdZtzv.js"));
|
|
341
|
+
const conn = new InstagramConnector({
|
|
342
|
+
pageAccessToken,
|
|
343
|
+
instagramAccountId,
|
|
344
|
+
verifyToken,
|
|
345
|
+
dmPolicy,
|
|
346
|
+
allowFrom: allowFromArr,
|
|
347
|
+
approvedPairings: [],
|
|
348
|
+
pendingPairings: {}
|
|
349
|
+
});
|
|
350
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "instagram"));
|
|
351
|
+
await conn.connect();
|
|
352
|
+
webhookConnectors["instagram"] = {
|
|
353
|
+
handleWebhook: (body) => conn.handleWebhook(body),
|
|
354
|
+
verifyWebhook: (mode, token, challenge) => conn.verifyWebhook(mode, token, challenge)
|
|
355
|
+
};
|
|
356
|
+
connectors.push({ stop: async () => {
|
|
357
|
+
conn.disconnect();
|
|
358
|
+
} });
|
|
359
|
+
} catch (e) {
|
|
360
|
+
console.error(`[channels] Instagram failed: ${e.message}`);
|
|
361
|
+
}
|
|
362
|
+
} else if (id === "messenger") {
|
|
363
|
+
const pageAccessToken = chCfg?.pageAccessToken || chCfg?.token || process.env.MESSENGER_PAGE_ACCESS_TOKEN;
|
|
364
|
+
const verifyToken = chCfg?.verifyToken || process.env.MESSENGER_VERIFY_TOKEN || "hyperclaw";
|
|
365
|
+
const appSecret = chCfg?.appSecret || process.env.MESSENGER_APP_SECRET;
|
|
366
|
+
const pageId = chCfg?.pageId || chCfg?.page_id || process.env.MESSENGER_PAGE_ID;
|
|
367
|
+
if (!pageAccessToken || !verifyToken || !appSecret || !pageId) continue;
|
|
368
|
+
try {
|
|
369
|
+
const { MessengerConnector } = await Promise.resolve().then(() => require("./connector-DcZdQcgR.js"));
|
|
370
|
+
const conn = new MessengerConnector({
|
|
371
|
+
pageAccessToken,
|
|
372
|
+
verifyToken,
|
|
373
|
+
appSecret,
|
|
374
|
+
pageId,
|
|
375
|
+
dmPolicy,
|
|
376
|
+
allowFrom: allowFromArr,
|
|
377
|
+
approvedPairings: [],
|
|
378
|
+
pendingPairings: {}
|
|
379
|
+
});
|
|
380
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "messenger"));
|
|
381
|
+
await conn.connect();
|
|
382
|
+
webhookConnectors["messenger"] = {
|
|
383
|
+
handleWebhook: async (body, opts$1) => {
|
|
384
|
+
await conn.handleWebhook(body, opts$1?.signature ?? "");
|
|
385
|
+
},
|
|
386
|
+
verifyWebhook: (mode, token, challenge) => conn.verifyWebhook(mode, token, challenge)
|
|
387
|
+
};
|
|
388
|
+
connectors.push({ stop: async () => {
|
|
389
|
+
conn.disconnect();
|
|
390
|
+
} });
|
|
391
|
+
} catch (e) {
|
|
392
|
+
console.error(`[channels] Messenger failed: ${e.message}`);
|
|
393
|
+
}
|
|
394
|
+
} else if (id === "twitter") {
|
|
395
|
+
const bearerToken = chCfg?.bearerToken || process.env.TWITTER_BEARER_TOKEN;
|
|
396
|
+
const apiKey = chCfg?.apiKey || process.env.TWITTER_API_KEY;
|
|
397
|
+
const apiSecret = chCfg?.apiSecret || process.env.TWITTER_API_SECRET;
|
|
398
|
+
const accessToken = chCfg?.accessToken || process.env.TWITTER_ACCESS_TOKEN;
|
|
399
|
+
const accessTokenSecret = chCfg?.accessTokenSecret || process.env.TWITTER_ACCESS_TOKEN_SECRET;
|
|
400
|
+
if (!bearerToken || !apiKey || !apiSecret || !accessToken || !accessTokenSecret) continue;
|
|
401
|
+
try {
|
|
402
|
+
const { TwitterConnector } = await Promise.resolve().then(() => require("./connector-CwlgFgjx.js"));
|
|
403
|
+
const conn = new TwitterConnector({
|
|
404
|
+
bearerToken,
|
|
405
|
+
apiKey,
|
|
406
|
+
apiSecret,
|
|
407
|
+
accessToken,
|
|
408
|
+
accessTokenSecret,
|
|
409
|
+
dmPolicy,
|
|
410
|
+
allowFrom: allowFromArr,
|
|
411
|
+
approvedPairings: [],
|
|
412
|
+
pendingPairings: {}
|
|
413
|
+
});
|
|
414
|
+
conn.on("message", (msg) => handleMsg(msg, wrap({ sendMessage: (id$1, t) => conn.sendDM(id$1, t) }), "twitter"));
|
|
415
|
+
await conn.connect();
|
|
416
|
+
webhookConnectors["twitter"] = {
|
|
417
|
+
handleWebhook: (body) => conn.handleWebhook(body),
|
|
418
|
+
verifyWebhook: (mode, token) => conn.handleCRC ? conn.handleCRC(token) : null
|
|
419
|
+
};
|
|
420
|
+
connectors.push({ stop: async () => {
|
|
421
|
+
conn.disconnect();
|
|
422
|
+
} });
|
|
423
|
+
} catch (e) {
|
|
424
|
+
console.error(`[channels] Twitter failed: ${e.message}`);
|
|
425
|
+
}
|
|
426
|
+
} else if (id === "viber") {
|
|
427
|
+
const authToken$1 = chCfg?.authToken || chCfg?.token || process.env.VIBER_AUTH_TOKEN;
|
|
428
|
+
const botName = chCfg?.botName || chCfg?.bot_name || "HyperClaw";
|
|
429
|
+
const webhookUrl = chCfg?.webhookUrl || process.env.VIBER_WEBHOOK_URL || `${baseUrl}/webhook/viber`;
|
|
430
|
+
if (!authToken$1) continue;
|
|
431
|
+
try {
|
|
432
|
+
const { ViberConnector } = await Promise.resolve().then(() => require("./connector-BOlqjXWP.js"));
|
|
433
|
+
const conn = new ViberConnector({
|
|
434
|
+
authToken: authToken$1,
|
|
435
|
+
botName,
|
|
436
|
+
webhookUrl,
|
|
437
|
+
dmPolicy,
|
|
438
|
+
allowFrom: allowFromArr,
|
|
439
|
+
approvedPairings: [],
|
|
440
|
+
pendingPairings: {}
|
|
441
|
+
});
|
|
442
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "viber"));
|
|
443
|
+
await conn.connect();
|
|
444
|
+
webhookConnectors["viber"] = {
|
|
445
|
+
handleWebhook: async (body, opts$1) => {
|
|
446
|
+
await conn.handleWebhook(body, opts$1?.signature ?? "");
|
|
447
|
+
},
|
|
448
|
+
verifyWebhook: void 0
|
|
449
|
+
};
|
|
450
|
+
connectors.push({ stop: async () => {
|
|
451
|
+
conn.disconnect();
|
|
452
|
+
} });
|
|
453
|
+
} catch (e) {
|
|
454
|
+
console.error(`[channels] Viber failed: ${e.message}`);
|
|
455
|
+
}
|
|
456
|
+
} else if (id === "zalo-personal") {
|
|
457
|
+
const cookie = chCfg?.cookie || process.env.ZALO_PERSONAL_COOKIE;
|
|
458
|
+
if (!cookie) continue;
|
|
459
|
+
try {
|
|
460
|
+
const { ZaloPersonalConnector } = await Promise.resolve().then(() => require("./connector-3HnyH8fn.js"));
|
|
461
|
+
const conn = new ZaloPersonalConnector({
|
|
462
|
+
cookie,
|
|
463
|
+
dmPolicy,
|
|
464
|
+
allowFrom: allowFromArr,
|
|
465
|
+
approvedPairings: [],
|
|
466
|
+
pendingPairings: {}
|
|
467
|
+
});
|
|
468
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "zalo-personal"));
|
|
469
|
+
await conn.connect();
|
|
470
|
+
connectors.push({ stop: async () => {
|
|
471
|
+
conn.disconnect();
|
|
472
|
+
} });
|
|
473
|
+
} catch (e) {
|
|
474
|
+
console.error(`[channels] Zalo Personal failed: ${e.message}`);
|
|
475
|
+
}
|
|
476
|
+
} else if (id === "zalo") {
|
|
477
|
+
const appId = chCfg?.appId || process.env.ZALO_APP_ID;
|
|
478
|
+
const appSecret = chCfg?.appSecret || process.env.ZALO_APP_SECRET;
|
|
479
|
+
const oaAccessToken = chCfg?.oaAccessToken || chCfg?.token || process.env.ZALO_OA_ACCESS_TOKEN;
|
|
480
|
+
if (!appId || !appSecret || !oaAccessToken) continue;
|
|
481
|
+
try {
|
|
482
|
+
const { ZaloConnector } = await Promise.resolve().then(() => require("./connector-BRHj773i.js"));
|
|
483
|
+
const conn = new ZaloConnector({
|
|
484
|
+
appId,
|
|
485
|
+
appSecret,
|
|
486
|
+
oaAccessToken,
|
|
487
|
+
dmPolicy,
|
|
488
|
+
allowFrom: allowFromArr,
|
|
489
|
+
approvedPairings: [],
|
|
490
|
+
pendingPairings: {}
|
|
491
|
+
});
|
|
492
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "zalo"));
|
|
493
|
+
await conn.connect();
|
|
494
|
+
webhookConnectors["zalo"] = {
|
|
495
|
+
handleWebhook: (body) => conn.handleWebhook(body),
|
|
496
|
+
verifyWebhook: void 0
|
|
497
|
+
};
|
|
498
|
+
connectors.push({ stop: async () => {
|
|
499
|
+
conn.disconnect();
|
|
500
|
+
} });
|
|
501
|
+
} catch (e) {
|
|
502
|
+
console.error(`[channels] Zalo failed to start: ${e.message}`);
|
|
503
|
+
}
|
|
504
|
+
} else if (id === "email") {
|
|
505
|
+
const imapHost = chCfg?.imapHost || process.env.EMAIL_IMAP_HOST;
|
|
506
|
+
const imapPort = chCfg?.imapPort ?? parseInt(process.env.EMAIL_IMAP_PORT || "993", 10);
|
|
507
|
+
const smtpHost = chCfg?.smtpHost || process.env.EMAIL_SMTP_HOST;
|
|
508
|
+
const smtpPort = chCfg?.smtpPort ?? parseInt(process.env.EMAIL_SMTP_PORT || "587", 10);
|
|
509
|
+
const username = chCfg?.username || process.env.EMAIL_USERNAME;
|
|
510
|
+
const password = chCfg?.password || process.env.EMAIL_PASSWORD;
|
|
511
|
+
if (!imapHost || !smtpHost || !username || !password) continue;
|
|
512
|
+
try {
|
|
513
|
+
const { EmailConnector } = await Promise.resolve().then(() => require("./connector-BPoSevxp.js"));
|
|
514
|
+
const conn = new EmailConnector({
|
|
515
|
+
imapHost,
|
|
516
|
+
imapPort,
|
|
517
|
+
smtpHost,
|
|
518
|
+
smtpPort,
|
|
519
|
+
username,
|
|
520
|
+
password,
|
|
521
|
+
pollIntervalMs: 3e4,
|
|
522
|
+
inboxFolder: "INBOX",
|
|
523
|
+
markAsRead: true,
|
|
524
|
+
subjectPrefix: "",
|
|
525
|
+
fromAllowlist: allowFromArr
|
|
526
|
+
});
|
|
527
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "email"));
|
|
528
|
+
await conn.connect();
|
|
529
|
+
emailConnectorRef = conn;
|
|
530
|
+
webhookConnectors["gmail-pubsub"] = {
|
|
531
|
+
handleWebhook: async (body) => {
|
|
532
|
+
try {
|
|
533
|
+
const json = JSON.parse(body || "{}");
|
|
534
|
+
if (json.message?.data) emailConnectorRef?.triggerPoll?.();
|
|
535
|
+
} catch {}
|
|
536
|
+
},
|
|
537
|
+
verifyWebhook: void 0
|
|
538
|
+
};
|
|
539
|
+
connectors.push({ stop: async () => {
|
|
540
|
+
conn.disconnect();
|
|
541
|
+
emailConnectorRef = null;
|
|
542
|
+
delete webhookConnectors["gmail-pubsub"];
|
|
543
|
+
} });
|
|
544
|
+
} catch (e) {
|
|
545
|
+
console.error(`[channels] Email failed to start: ${e.message}`);
|
|
546
|
+
}
|
|
547
|
+
} else if (id === "sms") {
|
|
548
|
+
const accountSid = chCfg?.accountSid || process.env.TWILIO_ACCOUNT_SID;
|
|
549
|
+
const authToken$1 = chCfg?.authToken || process.env.TWILIO_AUTH_TOKEN;
|
|
550
|
+
const fromNumber = chCfg?.fromNumber || process.env.TWILIO_FROM_NUMBER;
|
|
551
|
+
if (!accountSid || !authToken$1 || !fromNumber) continue;
|
|
552
|
+
try {
|
|
553
|
+
const { SMSConnector } = await Promise.resolve().then(() => require("./connector-BP8zsbP8.js"));
|
|
554
|
+
const conn = new SMSConnector({
|
|
555
|
+
accountSid,
|
|
556
|
+
authToken: authToken$1,
|
|
557
|
+
fromNumber,
|
|
558
|
+
dmPolicy,
|
|
559
|
+
allowFrom: allowFromArr,
|
|
560
|
+
approvedPairings: [],
|
|
561
|
+
pendingPairings: {}
|
|
562
|
+
});
|
|
563
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "sms"));
|
|
564
|
+
await conn.connect();
|
|
565
|
+
webhookConnectors["sms"] = {
|
|
566
|
+
handleWebhook: (body, opts$1) => conn.handleWebhook(body, opts$1?.twilioSignature ?? "", opts$1?.webhookUrl ?? ""),
|
|
567
|
+
verifyWebhook: void 0
|
|
568
|
+
};
|
|
569
|
+
connectors.push({ stop: async () => {
|
|
570
|
+
conn.disconnect();
|
|
571
|
+
} });
|
|
572
|
+
} catch (e) {
|
|
573
|
+
console.error(`[channels] SMS failed to start: ${e.message}`);
|
|
574
|
+
}
|
|
575
|
+
} else if (id === "whatsapp-baileys") try {
|
|
576
|
+
const { WhatsAppBaileysConnector } = await Promise.resolve().then(() => require("./connector-rHXE1ZD2.js"));
|
|
577
|
+
const conn = new WhatsAppBaileysConnector({
|
|
578
|
+
dmPolicy,
|
|
579
|
+
allowFrom: allowFromArr,
|
|
580
|
+
approvedPairings: [],
|
|
581
|
+
pendingPairings: {}
|
|
582
|
+
});
|
|
583
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "whatsapp-baileys"));
|
|
584
|
+
await conn.connect();
|
|
585
|
+
connectors.push({ stop: () => {
|
|
586
|
+
conn.disconnect();
|
|
587
|
+
return Promise.resolve();
|
|
588
|
+
} });
|
|
589
|
+
} catch (e) {
|
|
590
|
+
console.error(`[channels] WhatsApp Baileys failed: ${e.message}. Install: npm install @whiskeysockets/baileys`);
|
|
591
|
+
}
|
|
592
|
+
else if (id === "whatsapp") {
|
|
593
|
+
const phoneNumberId = chCfg?.phoneNumberId || process.env.WHATSAPP_PHONE_NUMBER_ID;
|
|
594
|
+
const accessToken = chCfg?.accessToken || chCfg?.token || process.env.WHATSAPP_ACCESS_TOKEN;
|
|
595
|
+
const verifyToken = chCfg?.verifyToken || process.env.WHATSAPP_VERIFY_TOKEN || "hyperclaw-verify";
|
|
596
|
+
if (!phoneNumberId || !accessToken) continue;
|
|
597
|
+
try {
|
|
598
|
+
const { WhatsAppConnector } = await Promise.resolve().then(() => require("./connector-Cdk1CXKi.js"));
|
|
599
|
+
const conn = new WhatsAppConnector({
|
|
600
|
+
phoneNumberId,
|
|
601
|
+
accessToken,
|
|
602
|
+
verifyToken,
|
|
603
|
+
dmPolicy,
|
|
604
|
+
allowFrom: allowFromArr
|
|
605
|
+
});
|
|
606
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "whatsapp"));
|
|
607
|
+
await conn.connect();
|
|
608
|
+
webhookConnectors["whatsapp"] = {
|
|
609
|
+
handleWebhook: (body) => conn.handleWebhook(body),
|
|
610
|
+
verifyWebhook: (mode, token, challenge) => conn.verifyWebhook(mode, token, challenge)
|
|
611
|
+
};
|
|
612
|
+
connectors.push({ stop: () => {
|
|
613
|
+
conn.disconnect();
|
|
614
|
+
return Promise.resolve();
|
|
615
|
+
} });
|
|
616
|
+
} catch (e) {
|
|
617
|
+
console.error(`[channels] WhatsApp failed to start: ${e.message}`);
|
|
618
|
+
}
|
|
619
|
+
} else if (id === "irc") {
|
|
620
|
+
const server = chCfg?.server || process.env.IRC_SERVER;
|
|
621
|
+
const nick = chCfg?.nick || process.env.IRC_NICK || "hyperclaw";
|
|
622
|
+
const channels = (chCfg?.channels || process.env.IRC_CHANNELS || "").split(",").filter(Boolean).map((c) => c.trim());
|
|
623
|
+
if (!server) continue;
|
|
624
|
+
try {
|
|
625
|
+
const { IrcConnector } = await Promise.resolve().then(() => require("./connector-Bv6s9oP7.js"));
|
|
626
|
+
const conn = new IrcConnector({
|
|
627
|
+
server,
|
|
628
|
+
nick,
|
|
629
|
+
channels,
|
|
630
|
+
dmPolicy,
|
|
631
|
+
allowFrom: allowFromArr
|
|
632
|
+
});
|
|
633
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "irc"));
|
|
634
|
+
await conn.connect();
|
|
635
|
+
connectors.push({ stop: async () => {
|
|
636
|
+
await conn.disconnect();
|
|
637
|
+
} });
|
|
638
|
+
} catch (e) {
|
|
639
|
+
console.error(`[channels] IRC failed to start: ${e.message}`);
|
|
640
|
+
}
|
|
641
|
+
} else if (id === "mattermost") {
|
|
642
|
+
const serverUrl = chCfg?.serverUrl || process.env.MATTERMOST_SERVER_URL;
|
|
643
|
+
const token = chCfg?.token || process.env.MATTERMOST_TOKEN;
|
|
644
|
+
const webhookToken = chCfg?.webhookToken || process.env.MATTERMOST_WEBHOOK_TOKEN;
|
|
645
|
+
if (!serverUrl || !token || !webhookToken) continue;
|
|
646
|
+
try {
|
|
647
|
+
const { MattermostConnector } = await Promise.resolve().then(() => require("./connector-DxKL8VvZ.js"));
|
|
648
|
+
const conn = new MattermostConnector({
|
|
649
|
+
serverUrl,
|
|
650
|
+
token,
|
|
651
|
+
webhookToken,
|
|
652
|
+
dmPolicy,
|
|
653
|
+
allowFrom: allowFromArr,
|
|
654
|
+
approvedPairings: [],
|
|
655
|
+
pendingPairings: {}
|
|
656
|
+
});
|
|
657
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "mattermost"));
|
|
658
|
+
await conn.connect();
|
|
659
|
+
webhookConnectors["mattermost"] = {
|
|
660
|
+
handleWebhook: async (body, opts$1) => {
|
|
661
|
+
await conn.handleWebhook(body, opts$1 ? { contentType: opts$1.contentType } : void 0);
|
|
662
|
+
},
|
|
663
|
+
verifyWebhook: void 0
|
|
664
|
+
};
|
|
665
|
+
connectors.push({ stop: async () => {
|
|
666
|
+
conn.disconnect();
|
|
667
|
+
} });
|
|
668
|
+
} catch (e) {
|
|
669
|
+
console.error(`[channels] Mattermost failed to start: ${e.message}`);
|
|
670
|
+
}
|
|
671
|
+
} else if (id === "gchat" || id === "google-chat") try {
|
|
672
|
+
const { GoogleChatConnector } = await Promise.resolve().then(() => require("./connector-CXPQVGyI.js"));
|
|
673
|
+
const conn = new GoogleChatConnector({ baseUrl });
|
|
674
|
+
await conn.connect();
|
|
675
|
+
webhookConnectors["gchat"] = {
|
|
676
|
+
handleWebhook: (body) => conn.handleWebhook(body),
|
|
677
|
+
verifyWebhook: void 0
|
|
678
|
+
};
|
|
679
|
+
if (id === "google-chat") webhookConnectors["google-chat"] = webhookConnectors["gchat"];
|
|
680
|
+
connectors.push({ stop: async () => {
|
|
681
|
+
conn.disconnect();
|
|
682
|
+
} });
|
|
683
|
+
} catch (e) {
|
|
684
|
+
console.error(`[channels] Google Chat failed to start: ${e.message}`);
|
|
685
|
+
}
|
|
686
|
+
else if (id === "synology-chat") {
|
|
687
|
+
const incomingWebhookUrl = chCfg?.incomingWebhookUrl || chCfg?.token || process.env.SYNOLOGY_CHAT_WEBHOOK_URL;
|
|
688
|
+
const webhookToken = chCfg?.webhookToken || process.env.SYNOLOGY_CHAT_OUTGOING_TOKEN;
|
|
689
|
+
const webhookPort = chCfg?.webhookPort || process.env.SYNOLOGY_CHAT_WEBHOOK_PORT;
|
|
690
|
+
if (!incomingWebhookUrl) continue;
|
|
691
|
+
try {
|
|
692
|
+
const { SynologyChatConnector } = await Promise.resolve().then(() => require("./connector-wdUXChwa.js"));
|
|
693
|
+
const conn = new SynologyChatConnector({
|
|
694
|
+
incomingWebhookUrl,
|
|
695
|
+
webhookToken,
|
|
696
|
+
...webhookPort ? { webhookPort: Number(webhookPort) } : {}
|
|
697
|
+
});
|
|
698
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "synology-chat"));
|
|
699
|
+
await conn.connect();
|
|
700
|
+
connectors.push({ stop: async () => {
|
|
701
|
+
conn.disconnect();
|
|
702
|
+
} });
|
|
703
|
+
} catch (e) {
|
|
704
|
+
console.error(`[channels] Synology Chat failed to start: ${e.message}`);
|
|
705
|
+
}
|
|
706
|
+
} else if (id === "twitch") {
|
|
707
|
+
const username = chCfg?.username || process.env.TWITCH_BOT_USERNAME;
|
|
708
|
+
const oauthToken = chCfg?.oauthToken || chCfg?.token || process.env.TWITCH_OAUTH_TOKEN;
|
|
709
|
+
const channels = String(chCfg?.channels || process.env.TWITCH_CHANNELS || "").split(",").map((c) => c.trim()).filter(Boolean);
|
|
710
|
+
if (!username || !oauthToken || channels.length === 0) continue;
|
|
711
|
+
try {
|
|
712
|
+
const { TwitchConnector } = await Promise.resolve().then(() => require("./connector-BliDVsJQ.js"));
|
|
713
|
+
const conn = new TwitchConnector({
|
|
714
|
+
username,
|
|
715
|
+
oauthToken,
|
|
716
|
+
channels
|
|
717
|
+
});
|
|
718
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "twitch"));
|
|
719
|
+
await conn.connect();
|
|
720
|
+
connectors.push({ stop: async () => {
|
|
721
|
+
await conn.disconnect();
|
|
722
|
+
} });
|
|
723
|
+
} catch (e) {
|
|
724
|
+
console.error(`[channels] Twitch failed to start: ${e.message}`);
|
|
725
|
+
}
|
|
726
|
+
} else if (id === "tlon") {
|
|
727
|
+
const shipUrl = chCfg?.shipUrl || process.env.TLON_SHIP_URL;
|
|
728
|
+
const ship = chCfg?.ship || process.env.TLON_SHIP;
|
|
729
|
+
const code = chCfg?.code || chCfg?.token || process.env.TLON_CODE;
|
|
730
|
+
const group = chCfg?.group || process.env.TLON_GROUP;
|
|
731
|
+
if (!shipUrl || !ship || !code) continue;
|
|
732
|
+
try {
|
|
733
|
+
const { TlonConnector } = await Promise.resolve().then(() => require("./connector-BToxU-jV.js"));
|
|
734
|
+
const conn = new TlonConnector({
|
|
735
|
+
shipUrl,
|
|
736
|
+
ship,
|
|
737
|
+
code,
|
|
738
|
+
...group ? { group } : {}
|
|
739
|
+
});
|
|
740
|
+
conn.on("message", (msg) => handleMsg(msg, wrap(conn), "tlon"));
|
|
741
|
+
await conn.connect();
|
|
742
|
+
connectors.push({ stop: async () => {
|
|
743
|
+
conn.disconnect();
|
|
744
|
+
} });
|
|
745
|
+
} catch (e) {
|
|
746
|
+
console.error(`[channels] Tlon failed to start: ${e.message}`);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return {
|
|
751
|
+
stop: async () => {
|
|
752
|
+
for (const c of connectors) await c.stop().catch(() => {});
|
|
753
|
+
connectors.length = 0;
|
|
754
|
+
emailConnectorRef = null;
|
|
755
|
+
Object.keys(webhookConnectors).forEach((k) => delete webhookConnectors[k]);
|
|
756
|
+
},
|
|
757
|
+
handleWebhook: async (channelId, body, opts$1) => {
|
|
758
|
+
const h = webhookConnectors[channelId];
|
|
759
|
+
if (h) {
|
|
760
|
+
const result = await h.handleWebhook(body, opts$1);
|
|
761
|
+
return result;
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
verifyWebhook: (channelId, mode, token, challenge) => {
|
|
765
|
+
const h = webhookConnectors[channelId];
|
|
766
|
+
return h?.verifyWebhook ? h.verifyWebhook(mode, token, challenge) : null;
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
function postChat(baseUrl, message, source, authToken) {
|
|
771
|
+
return new Promise((resolve, reject) => {
|
|
772
|
+
const payload = JSON.stringify({ message });
|
|
773
|
+
const headers = {
|
|
774
|
+
"Content-Type": "application/json",
|
|
775
|
+
"Content-Length": String(Buffer.byteLength(payload))
|
|
776
|
+
};
|
|
777
|
+
if (source) headers["X-HyperClaw-Source"] = source;
|
|
778
|
+
if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
|
|
779
|
+
const url = new URL(`${baseUrl}/api/chat`);
|
|
780
|
+
const req = http.default.request({
|
|
781
|
+
hostname: url.hostname,
|
|
782
|
+
port: url.port || 80,
|
|
783
|
+
path: url.pathname,
|
|
784
|
+
method: "POST",
|
|
785
|
+
headers
|
|
786
|
+
}, (res) => {
|
|
787
|
+
let data = "";
|
|
788
|
+
res.on("data", (c) => data += c);
|
|
789
|
+
res.on("end", () => {
|
|
790
|
+
try {
|
|
791
|
+
const j = JSON.parse(data);
|
|
792
|
+
if (j.error) reject(new Error(j.error));
|
|
793
|
+
else resolve(j.response || "");
|
|
794
|
+
} catch {
|
|
795
|
+
reject(new Error("Invalid response"));
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
});
|
|
799
|
+
req.on("error", reject);
|
|
800
|
+
req.setTimeout(6e4, () => {
|
|
801
|
+
req.destroy();
|
|
802
|
+
reject(new Error("Timeout"));
|
|
803
|
+
});
|
|
804
|
+
req.write(payload);
|
|
805
|
+
req.end();
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
//#endregion
|
|
810
|
+
exports.startChannelRunners = startChannelRunners;
|