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.
Files changed (277) hide show
  1. package/README.md +58 -4
  2. package/dist/a2ui-protocol-CT_jDEU9.js +75 -0
  3. package/dist/a2ui-protocol-CfBI44-Q.js +75 -0
  4. package/dist/agents-routing-683Q2JGp.js +129 -0
  5. package/dist/agents-routing-BpZBswBH.js +4 -0
  6. package/dist/agents-routing-ChHiZp36.js +327 -0
  7. package/dist/agents-routing-ChqZ6l2S.js +4 -0
  8. package/dist/api-keys-guide-BCcOl0Q7.js +149 -0
  9. package/dist/api-keys-guide-Dq5Obbp4.js +149 -0
  10. package/dist/audit-BYxPlnTQ.js +248 -0
  11. package/dist/audit-BaIiyWFu.js +441 -0
  12. package/dist/bounty-tools-C6LyzxM-.js +211 -0
  13. package/dist/bounty-tools-DWudyZie.js +211 -0
  14. package/dist/browser-tools-BsTeGMnX.js +5 -0
  15. package/dist/browser-tools-CQBSbIuO.js +5 -0
  16. package/dist/browser-tools-D8_rLe2p.js +179 -0
  17. package/dist/browser-tools-YQmwRLLM.js +179 -0
  18. package/dist/claw-tasks-BRLUvFRD.js +80 -0
  19. package/dist/claw-tasks-CgTsiNE8.js +80 -0
  20. package/dist/connector-3HnyH8fn.js +167 -0
  21. package/dist/connector-5N0-X_xs.js +194 -0
  22. package/dist/connector-6PMZo5Ky.js +189 -0
  23. package/dist/connector-B3v0qcXg.js +425 -0
  24. package/dist/connector-B6eoF3DD.js +181 -0
  25. package/dist/connector-B8R3iBY1.js +280 -0
  26. package/dist/connector-B9tLG8UZ.js +196 -0
  27. package/dist/connector-BAM-08NN.js +189 -0
  28. package/dist/connector-BC8FIVu4.js +181 -0
  29. package/dist/connector-BDmwwaVc.js +213 -0
  30. package/dist/connector-BGjbBy69.js +225 -0
  31. package/dist/connector-BO2SRzfG.js +218 -0
  32. package/dist/connector-BOlqjXWP.js +182 -0
  33. package/dist/connector-BP8zsbP8.js +189 -0
  34. package/dist/connector-BPoSevxp.js +286 -0
  35. package/dist/connector-BRHj773i.js +163 -0
  36. package/dist/connector-BToxU-jV.js +267 -0
  37. package/dist/connector-BfXky0L3.js +167 -0
  38. package/dist/connector-BiiSJpx3.js +192 -0
  39. package/dist/connector-BliDVsJQ.js +239 -0
  40. package/dist/connector-BnDmIhIu.js +85 -0
  41. package/dist/connector-Bv6s9oP7.js +88 -0
  42. package/dist/connector-By5wWGTR.js +343 -0
  43. package/dist/connector-C1BaFFgN.js +213 -0
  44. package/dist/connector-C1HSoUyk.js +189 -0
  45. package/dist/connector-CKQHZOXg.js +568 -0
  46. package/dist/connector-CRRWY5Wv.js +167 -0
  47. package/dist/connector-CRl-iidy.js +239 -0
  48. package/dist/connector-CXPQVGyI.js +85 -0
  49. package/dist/connector-Cdk1CXKi.js +194 -0
  50. package/dist/connector-Ci9glMD-.js +340 -0
  51. package/dist/connector-CjtZIEDj.js +181 -0
  52. package/dist/connector-Ck6JtOsX.js +531 -0
  53. package/dist/connector-CwlgFgjx.js +181 -0
  54. package/dist/connector-D8Kelee0.js +286 -0
  55. package/dist/connector-DAnRJ0oP.js +162 -0
  56. package/dist/connector-DFchk6l7.js +178 -0
  57. package/dist/connector-DKw7tRAy.js +192 -0
  58. package/dist/connector-DRv1ahC_.js +2 -2
  59. package/dist/connector-DU63KW94.js +165 -0
  60. package/dist/connector-DXTp5PE8.js +508 -0
  61. package/dist/connector-Dbvb1Cj9.js +280 -0
  62. package/dist/connector-DcZdQcgR.js +173 -0
  63. package/dist/connector-Dih6dUPP.js +173 -0
  64. package/dist/connector-DqTH_tPX.js +182 -0
  65. package/dist/connector-DrnEiiyP.js +419 -0
  66. package/dist/connector-DtR5GGTX.js +167 -0
  67. package/dist/connector-DxKL8VvZ.js +182 -0
  68. package/dist/connector-T_YdZtzv.js +162 -0
  69. package/dist/connector-Tky_qS_K.js +350 -0
  70. package/dist/connector-ZSc3oTTy.js +305 -0
  71. package/dist/connector-i4gOS9xL.js +154 -0
  72. package/dist/connector-rHXE1ZD2.js +167 -0
  73. package/dist/connector-sW5yhU1m.js +498 -0
  74. package/dist/connector-u3ICd3Ic.js +552 -0
  75. package/dist/connector-wdUXChwa.js +172 -0
  76. package/dist/cost-tracker-DD9wtWsr.js +103 -0
  77. package/dist/cost-tracker-pVE15Yq4.js +103 -0
  78. package/dist/credentials-store-BvnMPJwi.js +4 -0
  79. package/dist/credentials-store-C6ir0Dae.js +4 -0
  80. package/dist/credentials-store-H13LqOwJ.js +77 -0
  81. package/dist/credentials-store-sb-TRLwR.js +77 -0
  82. package/dist/cron-tasks-Bli7Kzd2.js +82 -0
  83. package/dist/cron-tasks-BvDFNyiE.js +82 -0
  84. package/dist/daemon-Bg4GtCmc.js +318 -0
  85. package/dist/daemon-DhmwY8k4.js +5 -0
  86. package/dist/delivery-BmIYy9VQ.js +4 -0
  87. package/dist/delivery-D5Z98EVq.js +95 -0
  88. package/dist/delivery-DCOXhXEO.js +5 -0
  89. package/dist/delivery-pWUPBp1F.js +95 -0
  90. package/dist/destructive-gate-D6vWOdEl.js +101 -0
  91. package/dist/destructive-gate-m-dWqUFg.js +101 -0
  92. package/dist/developer-keys-CPWT7Q6S.js +8 -0
  93. package/dist/developer-keys-DrrcUqFa.js +127 -0
  94. package/dist/developer-keys-JaJK3T27.js +127 -0
  95. package/dist/developer-keys-kyqmtWK3.js +8 -0
  96. package/dist/doctor-3oi89QIc.js +175 -0
  97. package/dist/doctor-BvCe8BBk.js +230 -0
  98. package/dist/doctor-Cf1XSfp9.js +4 -0
  99. package/dist/doctor-CxyPLYsJ.js +6 -0
  100. package/dist/engine-B4eMiTgl.js +7 -0
  101. package/dist/engine-B8M7dYul.js +7 -0
  102. package/dist/engine-BhT-1M9W.js +256 -0
  103. package/dist/engine-CEDSqXfw.js +256 -0
  104. package/dist/engine-D49jnSd_.js +256 -0
  105. package/dist/engine-Da4JMNpI.js +7 -0
  106. package/dist/env-resolve-CiXbWYwe.js +10 -0
  107. package/dist/env-resolve-CmGWhWXJ.js +115 -0
  108. package/dist/env-resolve-DWOQ45jG.js +9 -0
  109. package/dist/env-resolve-szSWl0UF.js +94 -0
  110. package/dist/extraction-tools-D3qDFBJ1.js +91 -0
  111. package/dist/extraction-tools-DLr_AEwq.js +5 -0
  112. package/dist/extraction-tools-HOZstZ0y.js +91 -0
  113. package/dist/extraction-tools-m4lmAv7l.js +5 -0
  114. package/dist/form_data-B_hIUrxU.js +8657 -0
  115. package/dist/form_data-Cz040rio.js +8657 -0
  116. package/dist/gmail-watch-setup-Czt8rXaX.js +40 -0
  117. package/dist/gmail-watch-setup-Du7DVV7S.js +40 -0
  118. package/dist/health-B-asI__D.js +6 -0
  119. package/dist/health-Ds2YlpTB.js +152 -0
  120. package/dist/heartbeat-engine-BYT5ayQH.js +83 -0
  121. package/dist/heartbeat-engine-CRqfPcFM.js +83 -0
  122. package/dist/hub-D0XwdjM-.js +515 -0
  123. package/dist/hub-DTsqe5Bt.js +6 -0
  124. package/dist/hub-FrPTA33j.js +515 -0
  125. package/dist/hub-LiD5Iztb.js +6 -0
  126. package/dist/hyperclawbot-D9KCtc4P.js +480 -0
  127. package/dist/hyperclawbot-Dw27pJo4.js +480 -0
  128. package/dist/hyperclawbot-zvczQgKx.js +505 -0
  129. package/dist/inference-BKVkBREb.js +6 -0
  130. package/dist/inference-CTWJeX9Q.js +922 -0
  131. package/dist/inference-DCXH4Q3x.js +922 -0
  132. package/dist/inference-ix607p7k.js +6 -0
  133. package/dist/knowledge-graph-DqA-Fztl.js +131 -0
  134. package/dist/knowledge-graph-iBG76fvm.js +131 -0
  135. package/dist/loader-CC45xGpC.js +4 -0
  136. package/dist/loader-CISCqBto.js +400 -0
  137. package/dist/loader-CYMQ8VOS.js +4 -0
  138. package/dist/loader-CnEdOyjT.js +400 -0
  139. package/dist/logger-8tEtAd3y.js +83 -0
  140. package/dist/logger-ybOp7VOC.js +83 -0
  141. package/dist/manager-03ipO9R0.js +105 -0
  142. package/dist/manager-BpDfbDjg.js +117 -0
  143. package/dist/manager-Bxl0sqlh.js +4 -0
  144. package/dist/manager-CPjeRe-6.js +4 -0
  145. package/dist/manager-CrVDn6eN.js +6 -0
  146. package/dist/manager-Cwzj7w5R.js +105 -0
  147. package/dist/manager-DLmZI-9R.js +6 -0
  148. package/dist/manager-DSGhn5i3.js +117 -0
  149. package/dist/manager-DgyF52mg.js +218 -0
  150. package/dist/manager-Dm8nrMFx.js +40 -0
  151. package/dist/manager-FCgF1plu.js +218 -0
  152. package/dist/manager-rgCsaWT1.js +40 -0
  153. package/dist/mcp-B_9Ber63.js +139 -0
  154. package/dist/mcp-CfoSU4Uz.js +139 -0
  155. package/dist/mcp-loader-DSM5UiFG.js +94 -0
  156. package/dist/mcp-loader-DkRBsLpk.js +94 -0
  157. package/dist/mcp-loader-j5ZLLw5O.js +94 -0
  158. package/dist/memory-BI1kPkAN.js +4 -0
  159. package/dist/memory-BVFGkxxK.js +270 -0
  160. package/dist/memory-BlHL7JCO.js +4 -0
  161. package/dist/memory-DsS_eFvJ.js +270 -0
  162. package/dist/memory-auto-Bc7euou4.js +306 -0
  163. package/dist/memory-auto-BkvtSFUw.js +5 -0
  164. package/dist/memory-auto-Bnz_-1wP.js +306 -0
  165. package/dist/memory-auto-DPfbkMVt.js +5 -0
  166. package/dist/memory-integration-DZExqWr4.js +91 -0
  167. package/dist/memory-integration-cSYkZyEo.js +91 -0
  168. package/dist/moltbook-B6ZeGN5_.js +81 -0
  169. package/dist/moltbook-BtLDZTfM.js +81 -0
  170. package/dist/node-Dw2Gi-cP.js +222 -0
  171. package/dist/node-pwL6O_KX.js +222 -0
  172. package/dist/nodes-registry-B8dmrlLv.js +52 -0
  173. package/dist/nodes-registry-CsPm_-CJ.js +52 -0
  174. package/dist/oauth-flow-CpWlgvNB.js +150 -0
  175. package/dist/oauth-flow-DQPvMHRH.js +150 -0
  176. package/dist/oauth-provider-BZb6qOw5.js +110 -0
  177. package/dist/oauth-provider-Uo4Nib_c.js +110 -0
  178. package/dist/observability-B43YvNQV.js +89 -0
  179. package/dist/observability-BV-Yx0V9.js +89 -0
  180. package/dist/onboard-0WoDxbv_.js +10 -0
  181. package/dist/onboard-BXNXCQp4.js +4070 -0
  182. package/dist/onboard-Bd_wsYdi.js +4086 -0
  183. package/dist/onboard-CAN7x3me.js +3026 -0
  184. package/dist/onboard-DnegOHMh.js +4 -4
  185. package/dist/onboard-RYtDlYBw.js +9 -0
  186. package/dist/onboard-aTwlQs-4.js +9 -0
  187. package/dist/orchestrator-BSp2M5EU.js +189 -0
  188. package/dist/orchestrator-C7ko5tWa.js +6 -0
  189. package/dist/orchestrator-DfPkIx2Z.js +6 -0
  190. package/dist/orchestrator-DmnEvMaL.js +189 -0
  191. package/dist/orchestrator-NJQsmiBE.js +189 -0
  192. package/dist/orchestrator-RI3bpqqc.js +6 -0
  193. package/dist/pairing-6iM27aD8.js +196 -0
  194. package/dist/pairing-DU0_J28n.js +87 -0
  195. package/dist/pairing-DWllbSbO.js +4 -0
  196. package/dist/pairing-dGoiGepK.js +4 -0
  197. package/dist/pc-access-CgCsYrpt.js +8 -0
  198. package/dist/pc-access-Ly-uA8mn.js +8 -0
  199. package/dist/pc-access-NxBvTrRj.js +819 -0
  200. package/dist/pc-access-_iH2aorG.js +819 -0
  201. package/dist/pending-approval-CUXjysAo.js +22 -0
  202. package/dist/pending-approval-DIHvwwWS.js +22 -0
  203. package/dist/puppeteer-2o3QOwAy.js +2 -2
  204. package/dist/puppeteer-BYTMp3BI.js +2 -2
  205. package/dist/puppeteer-DQ45qwWk.js +2 -2
  206. package/dist/reminders-store-D79qdfN0.js +58 -0
  207. package/dist/reminders-store-Drjed_-h.js +58 -0
  208. package/dist/renderer-BVQrd0_g.js +225 -0
  209. package/dist/renderer-pqlDRKbH.js +225 -0
  210. package/dist/rules-BE4GV6cV.js +103 -0
  211. package/dist/rules-BooT_qFP.js +103 -0
  212. package/dist/run-main.js +1649 -1227
  213. package/dist/runner-D1rjuMTJ.js +810 -0
  214. package/dist/runner-DatMMYYE.js +1271 -0
  215. package/dist/sdk/index.js +2 -2
  216. package/dist/sdk/index.mjs +2 -2
  217. package/dist/security-BqNyT4ID.js +4 -0
  218. package/dist/security-C-5URby1.js +73 -0
  219. package/dist/security-_xve79aq.js +4 -0
  220. package/dist/security-tpgqPWWH.js +73 -0
  221. package/dist/server-0kgyELx4.js +1047 -0
  222. package/dist/server-BIuTobTC.js +4 -0
  223. package/dist/server-BRlCEjyT.js +1047 -0
  224. package/dist/server-CCI1hv45.js +2 -2
  225. package/dist/server-D4wVHiX9.js +4 -0
  226. package/dist/server-DU9POoWc.js +4 -0
  227. package/dist/server-Dh3JlBFB.js +1255 -0
  228. package/dist/session-store-BUiPz0Vv.js +5 -0
  229. package/dist/session-store-CujxByI6.js +113 -0
  230. package/dist/session-store-is4B6qmD.js +113 -0
  231. package/dist/session-store-qpJUg2M1.js +5 -0
  232. package/dist/sessions-tools-CB2qbwIk.js +5 -0
  233. package/dist/sessions-tools-CbUTFe4i.js +5 -0
  234. package/dist/sessions-tools-CeqD7iil.js +95 -0
  235. package/dist/sessions-tools-DHMaTZIs.js +95 -0
  236. package/dist/skill-loader-BaNLVmJy.js +7 -0
  237. package/dist/skill-loader-BkceKkIg.js +7 -0
  238. package/dist/skill-loader-DhgIwK4J.js +159 -0
  239. package/dist/skill-loader-HgpF6Vqs.js +159 -0
  240. package/dist/skill-runtime--LqxWrp5.js +102 -0
  241. package/dist/skill-runtime-C5l0Tgt-.js +5 -0
  242. package/dist/skill-runtime-CJN24QPW.js +102 -0
  243. package/dist/skill-runtime-DsXK_HYG.js +102 -0
  244. package/dist/skill-runtime-IVTiqrMR.js +5 -0
  245. package/dist/skill-runtime-w1ig_lcw.js +5 -0
  246. package/dist/src-BEVLgaF1.js +63 -0
  247. package/dist/src-Bgu_OxTQ.js +458 -0
  248. package/dist/src-Bq-oKt7Z.js +458 -0
  249. package/dist/src-BxPHKO5x.js +63 -0
  250. package/dist/src-DIc-L2IG.js +20 -0
  251. package/dist/src-DWCUhnD4.js +20 -0
  252. package/dist/src-cfRTjFef.js +63 -0
  253. package/dist/src-g_rNx5rh.js +458 -0
  254. package/dist/sub-agent-tools-BD9DF8_g.js +39 -0
  255. package/dist/sub-agent-tools-CHQoHz9c.js +39 -0
  256. package/dist/sub-agent-tools-V7b3T9_s.js +39 -0
  257. package/dist/theme-DcxwcUgZ.js +180 -0
  258. package/dist/theme-cx0fkgWC.js +8 -0
  259. package/dist/tool-policy-CNT-mF2Z.js +189 -0
  260. package/dist/tool-policy-DNvNRnve.js +189 -0
  261. package/dist/tts-elevenlabs-BRosZv-f.js +61 -0
  262. package/dist/tts-elevenlabs-BUOGKL-k.js +61 -0
  263. package/dist/update-check-BD4qH7Am.js +81 -0
  264. package/dist/update-check-C2Dz85wJ.js +81 -0
  265. package/dist/vision-BMmiIKy7.js +121 -0
  266. package/dist/vision-DRq-f-Dj.js +121 -0
  267. package/dist/vision-tools-CFZEpQKm.js +5 -0
  268. package/dist/vision-tools-CQnBI9aa.js +51 -0
  269. package/dist/vision-tools-DVuYc17I.js +51 -0
  270. package/dist/vision-tools-U3YC4L-g.js +5 -0
  271. package/dist/voice-transcription-B555DbWR.js +138 -0
  272. package/dist/voice-transcription-CgWq54hn.js +138 -0
  273. package/dist/website-watch-tools-Bk_TnwuE.js +5 -0
  274. package/dist/website-watch-tools-DFMrJU-R.js +139 -0
  275. package/dist/website-watch-tools-DraMPxdl.js +139 -0
  276. package/dist/website-watch-tools-Du3W5sN7.js +5 -0
  277. package/package.json +1 -1
@@ -0,0 +1,239 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const chalk = require_chunk.__toESM(require("chalk"));
3
+ const fs_extra = require_chunk.__toESM(require("fs-extra"));
4
+ const path = require_chunk.__toESM(require("path"));
5
+ const os = require_chunk.__toESM(require("os"));
6
+ const ws = require_chunk.__toESM(require("ws"));
7
+ const events = require_chunk.__toESM(require("events"));
8
+
9
+ //#region extensions/twitch/src/connector.ts
10
+ const STATE_FILE = path.default.join(os.default.homedir(), ".hyperclaw", "twitch-state.json");
11
+ const TWITCH_IRC_WS = "wss://irc-ws.chat.twitch.tv:443";
12
+ var TwitchConnector = class extends events.EventEmitter {
13
+ config;
14
+ ws = null;
15
+ running = false;
16
+ reconnectDelay = 1e3;
17
+ pingInterval = null;
18
+ constructor(config) {
19
+ super();
20
+ this.config = {
21
+ commandPrefix: "!",
22
+ whispers: true,
23
+ dmPolicy: "pairing",
24
+ allowFrom: [],
25
+ approvedPairings: [],
26
+ pendingPairings: {},
27
+ modsBypass: true,
28
+ ...config
29
+ };
30
+ }
31
+ async connect() {
32
+ await this.loadState();
33
+ await this.doConnect();
34
+ }
35
+ doConnect() {
36
+ return new Promise((resolve, reject) => {
37
+ const ws$1 = new ws.WebSocket(TWITCH_IRC_WS);
38
+ this.ws = ws$1;
39
+ ws$1.once("open", () => {
40
+ ws$1.send("CAP REQ :twitch.tv/membership twitch.tv/tags twitch.tv/commands");
41
+ ws$1.send(`PASS ${this.config.oauthToken}`);
42
+ ws$1.send(`NICK ${this.config.username}`);
43
+ for (const ch of this.config.channels) ws$1.send(`JOIN #${ch.replace(/^#/, "").toLowerCase()}`);
44
+ this.running = true;
45
+ this.reconnectDelay = 1e3;
46
+ this.pingInterval = setInterval(() => ws$1.send("PING :tmi.twitch.tv"), 6e4);
47
+ console.log(chalk.default.green(` 🦅 Twitch: connected as ${this.config.username}, joined ${this.config.channels.join(", ")}`));
48
+ this.emit("connected", { username: this.config.username });
49
+ resolve();
50
+ });
51
+ ws$1.on("message", async (raw) => {
52
+ const lines = raw.toString().split("\r\n").filter(Boolean);
53
+ for (const line of lines) await this.handleLine(line);
54
+ });
55
+ ws$1.on("close", () => {
56
+ if (this.pingInterval) {
57
+ clearInterval(this.pingInterval);
58
+ this.pingInterval = null;
59
+ }
60
+ if (this.running) {
61
+ console.log(chalk.default.yellow(` ⚠ Twitch: disconnected, reconnecting in ${this.reconnectDelay}ms`));
62
+ setTimeout(() => {
63
+ this.reconnectDelay = Math.min(this.reconnectDelay * 2, 3e4);
64
+ this.doConnect();
65
+ }, this.reconnectDelay);
66
+ }
67
+ });
68
+ ws$1.on("error", (err) => {
69
+ console.log(chalk.default.yellow(` ⚠ Twitch: ${err.message}`));
70
+ if (!this.running) reject(err);
71
+ });
72
+ });
73
+ }
74
+ disconnect() {
75
+ this.running = false;
76
+ if (this.pingInterval) {
77
+ clearInterval(this.pingInterval);
78
+ this.pingInterval = null;
79
+ }
80
+ this.ws?.close();
81
+ this.ws = null;
82
+ }
83
+ async handleLine(line) {
84
+ if (line === "PING :tmi.twitch.tv") {
85
+ this.ws?.send("PONG :tmi.twitch.tv");
86
+ return;
87
+ }
88
+ const tags = this.parseTags(line);
89
+ const parsed = this.parseIRC(line);
90
+ if (!parsed) return;
91
+ const { command, prefix, params, trailing } = parsed;
92
+ const username = prefix?.split("!")[0]?.toLowerCase() || "";
93
+ if (username === this.config.username.toLowerCase()) return;
94
+ if (command === "PRIVMSG") {
95
+ const channel = params[0];
96
+ const text = trailing || "";
97
+ const isWhisper = false;
98
+ if (this.config.commandPrefix && !text.startsWith(this.config.commandPrefix) && !isWhisper) return;
99
+ const body = this.config.commandPrefix ? text.slice(this.config.commandPrefix.length).trim() : text;
100
+ if (!body) return;
101
+ const isMod = tags["mod"] === "1" || tags["badges"]?.includes("broadcaster");
102
+ const allowed = await this.checkPolicy(username, channel, body, isMod);
103
+ if (!allowed) return;
104
+ this.emit("message", {
105
+ id: tags["id"] || `twitch-${Date.now()}`,
106
+ channelId: "twitch",
107
+ from: username,
108
+ displayName: tags["display-name"] || username,
109
+ chatId: channel,
110
+ text: body,
111
+ timestamp: tags["tmi-sent-ts"] ? new Date(Number(tags["tmi-sent-ts"])).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
112
+ isDM: false,
113
+ isMod
114
+ });
115
+ return;
116
+ }
117
+ if (command === "WHISPER" && this.config.whispers) {
118
+ const text = trailing || "";
119
+ if (!text) return;
120
+ const allowed = await this.checkPolicy(username, "whisper", text, false);
121
+ if (!allowed) return;
122
+ this.emit("message", {
123
+ id: `twitch-whisper-${Date.now()}`,
124
+ channelId: "twitch",
125
+ from: username,
126
+ displayName: tags["display-name"] || username,
127
+ chatId: `whisper:${username}`,
128
+ text,
129
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
130
+ isDM: true,
131
+ isMod: false
132
+ });
133
+ }
134
+ }
135
+ async checkPolicy(username, chatId, text, isMod) {
136
+ if (this.config.dmPolicy === "none") return false;
137
+ if (this.config.dmPolicy === "open") return true;
138
+ if (this.config.modsBypass && isMod) return true;
139
+ if (this.config.dmPolicy === "allowlist") {
140
+ if (this.config.allowFrom.includes(username)) return true;
141
+ await this.sendChat(chatId, `@${username} You are not on the allowlist.`);
142
+ return false;
143
+ }
144
+ if (this.config.dmPolicy === "pairing") {
145
+ if (this.config.approvedPairings.includes(username)) return true;
146
+ const upper = text.trim().toUpperCase();
147
+ if (this.config.pendingPairings[upper]) {
148
+ this.config.approvedPairings.push(username);
149
+ delete this.config.pendingPairings[upper];
150
+ await this.saveState();
151
+ await this.sendChat(chatId, `@${username} Paired! You can now talk to the assistant.`);
152
+ return true;
153
+ }
154
+ const code = Array.from({ length: 6 }, () => "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"[Math.floor(Math.random() * 32)]).join("");
155
+ this.config.pendingPairings[code] = username;
156
+ await this.saveState();
157
+ await this.sendChat(chatId, `@${username} Pairing required. Code: ${code} — approve: hyperclaw pairing approve twitch ${code}`);
158
+ return false;
159
+ }
160
+ return false;
161
+ }
162
+ async sendChat(channel, text) {
163
+ if (!this.ws || this.ws.readyState !== ws.WebSocket.OPEN) return;
164
+ const ch = channel.startsWith("#") ? channel : `#${channel}`;
165
+ const chunks = text.match(/.{1,490}/g) || [text];
166
+ for (const chunk of chunks) {
167
+ this.ws.send(`PRIVMSG ${ch} :${chunk}`);
168
+ await new Promise((r) => setTimeout(r, 150));
169
+ }
170
+ }
171
+ async sendWhisper(username, text) {
172
+ if (!this.ws || this.ws.readyState !== ws.WebSocket.OPEN) return;
173
+ const ch = `#${this.config.channels[0]?.replace(/^#/, "") || this.config.username}`;
174
+ this.ws.send(`PRIVMSG ${ch} :/w ${username} ${text}`);
175
+ }
176
+ approvePairing(code) {
177
+ const upper = code.toUpperCase();
178
+ if (!this.config.pendingPairings[upper]) return false;
179
+ this.config.approvedPairings.push(this.config.pendingPairings[upper]);
180
+ delete this.config.pendingPairings[upper];
181
+ this.saveState();
182
+ return true;
183
+ }
184
+ parseTags(line) {
185
+ if (!line.startsWith("@")) return {};
186
+ const tagStr = line.slice(1, line.indexOf(" "));
187
+ const tags = {};
188
+ for (const part of tagStr.split(";")) {
189
+ const [k, v] = part.split("=");
190
+ if (k) tags[k] = v || "";
191
+ }
192
+ return tags;
193
+ }
194
+ parseIRC(line) {
195
+ let rest = line.startsWith("@") ? line.slice(line.indexOf(" ") + 1) : line;
196
+ let prefix;
197
+ if (rest.startsWith(":")) {
198
+ const spaceIdx = rest.indexOf(" ");
199
+ prefix = rest.slice(1, spaceIdx);
200
+ rest = rest.slice(spaceIdx + 1);
201
+ }
202
+ const trailingIdx = rest.indexOf(" :");
203
+ let trailing;
204
+ if (trailingIdx !== -1) {
205
+ trailing = rest.slice(trailingIdx + 2);
206
+ rest = rest.slice(0, trailingIdx);
207
+ }
208
+ const parts = rest.trim().split(" ");
209
+ const command = parts[0];
210
+ const params = parts.slice(1).filter(Boolean);
211
+ if (!command) return null;
212
+ return {
213
+ command,
214
+ prefix,
215
+ params,
216
+ trailing
217
+ };
218
+ }
219
+ async loadState() {
220
+ try {
221
+ const s = await fs_extra.default.readJson(STATE_FILE);
222
+ if (s.p) this.config.pendingPairings = s.p;
223
+ if (s.a) this.config.approvedPairings = s.a;
224
+ } catch {}
225
+ }
226
+ async saveState() {
227
+ await fs_extra.default.ensureDir(path.default.dirname(STATE_FILE));
228
+ await fs_extra.default.writeJson(STATE_FILE, {
229
+ p: this.config.pendingPairings,
230
+ a: this.config.approvedPairings
231
+ }, { spaces: 2 });
232
+ }
233
+ isRunning() {
234
+ return this.running;
235
+ }
236
+ };
237
+
238
+ //#endregion
239
+ exports.TwitchConnector = TwitchConnector;
@@ -0,0 +1,85 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const chalk = require_chunk.__toESM(require("chalk"));
3
+ const http = require_chunk.__toESM(require("http"));
4
+ const events = require_chunk.__toESM(require("events"));
5
+
6
+ //#region extensions/google-chat/src/connector.ts
7
+ var GoogleChatConnector = class extends events.EventEmitter {
8
+ config;
9
+ constructor(config) {
10
+ super();
11
+ this.config = config;
12
+ }
13
+ async connect() {
14
+ console.log(chalk.default.green(` 🦅 Google Chat: HTTP app listening at ${this.config.baseUrl}/webhook/gchat`));
15
+ this.emit("connected", {});
16
+ }
17
+ disconnect() {}
18
+ /**
19
+
20
+ * Handle incoming Chat event. Returns JSON string for sync reply, or void.
21
+
22
+ */
23
+ async handleWebhook(body) {
24
+ let event;
25
+ try {
26
+ event = JSON.parse(body);
27
+ } catch {
28
+ return;
29
+ }
30
+ const type = event.type;
31
+ if (type === "ADDED_TO_SPACE" || type === "REMOVED_FROM_SPACE") return JSON.stringify({ text: type === "ADDED_TO_SPACE" ? "🦅 HyperClaw connected." : "Goodbye." });
32
+ if (type !== "MESSAGE") return;
33
+ const msg = event.message;
34
+ const text = (msg?.argumentText || msg?.text || "").trim();
35
+ if (!text) return JSON.stringify({ text: "" });
36
+ const spaceName = event.space?.name || "unknown";
37
+ const userName = event.user?.displayName || event.user?.name || "User";
38
+ try {
39
+ const response = await this.postChat(text);
40
+ return JSON.stringify({ text: response || "(no response)" });
41
+ } catch (e) {
42
+ console.error(chalk.default.yellow(` ⚠ Google Chat: ${e.message}`));
43
+ return JSON.stringify({ text: `Error: ${e.message}` });
44
+ }
45
+ }
46
+ postChat(message) {
47
+ return new Promise((resolve, reject) => {
48
+ const payload = JSON.stringify({ message });
49
+ const url = new URL(`${this.config.baseUrl}/api/chat`);
50
+ const req = http.default.request({
51
+ hostname: url.hostname,
52
+ port: url.port || 80,
53
+ path: url.pathname,
54
+ method: "POST",
55
+ headers: {
56
+ "Content-Type": "application/json",
57
+ "Content-Length": String(Buffer.byteLength(payload)),
58
+ "X-HyperClaw-Source": "gchat"
59
+ }
60
+ }, (res) => {
61
+ let data = "";
62
+ res.on("data", (c) => data += c);
63
+ res.on("end", () => {
64
+ try {
65
+ const j = JSON.parse(data);
66
+ if (j.error) reject(new Error(j.error));
67
+ else resolve(j.response || "");
68
+ } catch {
69
+ reject(new Error("Invalid response"));
70
+ }
71
+ });
72
+ });
73
+ req.on("error", reject);
74
+ req.setTimeout(6e4, () => {
75
+ req.destroy();
76
+ reject(new Error("Timeout"));
77
+ });
78
+ req.write(payload);
79
+ req.end();
80
+ });
81
+ }
82
+ };
83
+
84
+ //#endregion
85
+ exports.GoogleChatConnector = GoogleChatConnector;
@@ -0,0 +1,88 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const chalk = require_chunk.__toESM(require("chalk"));
3
+ const events = require_chunk.__toESM(require("events"));
4
+ const irc = require_chunk.__toESM(require("irc"));
5
+
6
+ //#region extensions/irc/src/connector.ts
7
+ var IrcConnector = class extends events.EventEmitter {
8
+ client = null;
9
+ config;
10
+ constructor(config) {
11
+ super();
12
+ this.config = {
13
+ channels: [],
14
+ dmPolicy: "pairing",
15
+ allowFrom: [],
16
+ ...config
17
+ };
18
+ }
19
+ async connect() {
20
+ return new Promise((resolve, reject) => {
21
+ const channels = (this.config.channels || []).map((c) => c.startsWith("#") ? c : `#${c}`);
22
+ this.client = new irc.default.Client(this.config.server, this.config.nick, {
23
+ channels,
24
+ autoConnect: true,
25
+ debug: false,
26
+ showErrors: true,
27
+ stripColors: true
28
+ });
29
+ this.client.on("registered", () => {
30
+ console.log(chalk.default.green(` 🦅 IRC: ${this.config.nick} on ${this.config.server} connected`));
31
+ this.emit("connected", {
32
+ server: this.config.server,
33
+ nick: this.config.nick
34
+ });
35
+ resolve();
36
+ });
37
+ this.client.on("error", (err) => {
38
+ console.log(chalk.default.yellow(` ⚠ IRC error: ${err.message}`));
39
+ reject(err);
40
+ });
41
+ this.client.on("message", (from, to, message) => {
42
+ const isChannel = to.startsWith("#");
43
+ const chatId = isChannel ? to : from;
44
+ const text = message.trim();
45
+ if (!text) return;
46
+ if (!isChannel && this.config.dmPolicy === "none") return;
47
+ if (!isChannel && this.config.dmPolicy === "allowlist" && this.config.allowFrom?.length) {
48
+ if (!this.config.allowFrom.includes(from)) return;
49
+ }
50
+ this.emit("message", {
51
+ chatId,
52
+ text,
53
+ from,
54
+ to,
55
+ isChannel
56
+ });
57
+ });
58
+ this.client.on("pm", (from, message) => {
59
+ const text = message.trim();
60
+ if (!text) return;
61
+ if (this.config.dmPolicy === "allowlist" && this.config.allowFrom?.length) {
62
+ if (!this.config.allowFrom.includes(from)) return;
63
+ }
64
+ this.emit("message", {
65
+ chatId: from,
66
+ text,
67
+ from,
68
+ to: from,
69
+ isChannel: false
70
+ });
71
+ });
72
+ });
73
+ }
74
+ async sendMessage(chatId, text) {
75
+ if (!this.client) throw new Error("IRC not connected");
76
+ const lines = text.split("\n").filter(Boolean);
77
+ for (const line of lines) this.client.say(chatId, line);
78
+ }
79
+ async disconnect() {
80
+ if (this.client) {
81
+ this.client.disconnect();
82
+ this.client = null;
83
+ }
84
+ }
85
+ };
86
+
87
+ //#endregion
88
+ exports.IrcConnector = IrcConnector;