hyperclaw 4.0.1 → 4.0.2

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 (148) hide show
  1. package/README.md +7 -4
  2. package/dist/a2ui-protocol-CT_jDEU9.js +75 -0
  3. package/dist/agents-routing-683Q2JGp.js +129 -0
  4. package/dist/agents-routing-BpZBswBH.js +4 -0
  5. package/dist/api-keys-guide-Dq5Obbp4.js +149 -0
  6. package/dist/audit-BYxPlnTQ.js +248 -0
  7. package/dist/bounty-tools-C6LyzxM-.js +211 -0
  8. package/dist/browser-tools-CQBSbIuO.js +5 -0
  9. package/dist/browser-tools-YQmwRLLM.js +179 -0
  10. package/dist/claw-tasks-BRLUvFRD.js +80 -0
  11. package/dist/connector-3HnyH8fn.js +167 -0
  12. package/dist/connector-6PMZo5Ky.js +189 -0
  13. package/dist/connector-B6eoF3DD.js +181 -0
  14. package/dist/connector-B9tLG8UZ.js +196 -0
  15. package/dist/connector-BOlqjXWP.js +182 -0
  16. package/dist/connector-BP8zsbP8.js +189 -0
  17. package/dist/connector-BPoSevxp.js +286 -0
  18. package/dist/connector-BRHj773i.js +163 -0
  19. package/dist/connector-BToxU-jV.js +267 -0
  20. package/dist/connector-BliDVsJQ.js +239 -0
  21. package/dist/connector-Bv6s9oP7.js +88 -0
  22. package/dist/connector-By5wWGTR.js +343 -0
  23. package/dist/connector-C1BaFFgN.js +213 -0
  24. package/dist/connector-CRRWY5Wv.js +167 -0
  25. package/dist/connector-CXPQVGyI.js +85 -0
  26. package/dist/connector-Cdk1CXKi.js +194 -0
  27. package/dist/connector-CwlgFgjx.js +181 -0
  28. package/dist/connector-DFchk6l7.js +178 -0
  29. package/dist/connector-DKw7tRAy.js +192 -0
  30. package/dist/connector-DRv1ahC_.js +2 -2
  31. package/dist/connector-DU63KW94.js +165 -0
  32. package/dist/connector-Dbvb1Cj9.js +280 -0
  33. package/dist/connector-DcZdQcgR.js +173 -0
  34. package/dist/connector-DxKL8VvZ.js +182 -0
  35. package/dist/connector-T_YdZtzv.js +162 -0
  36. package/dist/connector-i4gOS9xL.js +154 -0
  37. package/dist/connector-rHXE1ZD2.js +167 -0
  38. package/dist/connector-wdUXChwa.js +172 -0
  39. package/dist/cost-tracker-pVE15Yq4.js +103 -0
  40. package/dist/credentials-store-BvnMPJwi.js +4 -0
  41. package/dist/credentials-store-sb-TRLwR.js +77 -0
  42. package/dist/cron-tasks-BvDFNyiE.js +82 -0
  43. package/dist/delivery-D5Z98EVq.js +95 -0
  44. package/dist/delivery-DCOXhXEO.js +5 -0
  45. package/dist/destructive-gate-m-dWqUFg.js +101 -0
  46. package/dist/developer-keys-JaJK3T27.js +127 -0
  47. package/dist/developer-keys-kyqmtWK3.js +8 -0
  48. package/dist/doctor-3oi89QIc.js +175 -0
  49. package/dist/doctor-Cf1XSfp9.js +4 -0
  50. package/dist/engine-B4eMiTgl.js +7 -0
  51. package/dist/engine-B8M7dYul.js +7 -0
  52. package/dist/engine-BhT-1M9W.js +256 -0
  53. package/dist/engine-D49jnSd_.js +256 -0
  54. package/dist/env-resolve-DWOQ45jG.js +9 -0
  55. package/dist/env-resolve-szSWl0UF.js +94 -0
  56. package/dist/extraction-tools-D3qDFBJ1.js +91 -0
  57. package/dist/extraction-tools-DLr_AEwq.js +5 -0
  58. package/dist/form_data-B_hIUrxU.js +8657 -0
  59. package/dist/gmail-watch-setup-Czt8rXaX.js +40 -0
  60. package/dist/heartbeat-engine-CRqfPcFM.js +83 -0
  61. package/dist/hub-DTsqe5Bt.js +6 -0
  62. package/dist/hub-FrPTA33j.js +515 -0
  63. package/dist/hyperclawbot-D9KCtc4P.js +480 -0
  64. package/dist/hyperclawbot-Dw27pJo4.js +480 -0
  65. package/dist/inference-CTWJeX9Q.js +922 -0
  66. package/dist/inference-ix607p7k.js +6 -0
  67. package/dist/knowledge-graph-DqA-Fztl.js +131 -0
  68. package/dist/loader-CISCqBto.js +400 -0
  69. package/dist/loader-CYMQ8VOS.js +4 -0
  70. package/dist/logger-8tEtAd3y.js +83 -0
  71. package/dist/manager-CPjeRe-6.js +4 -0
  72. package/dist/manager-Cwzj7w5R.js +105 -0
  73. package/dist/manager-DLmZI-9R.js +6 -0
  74. package/dist/manager-DSGhn5i3.js +117 -0
  75. package/dist/manager-DgyF52mg.js +218 -0
  76. package/dist/manager-Dm8nrMFx.js +40 -0
  77. package/dist/mcp-B_9Ber63.js +139 -0
  78. package/dist/mcp-loader-DSM5UiFG.js +94 -0
  79. package/dist/mcp-loader-j5ZLLw5O.js +94 -0
  80. package/dist/memory-BI1kPkAN.js +4 -0
  81. package/dist/memory-BVFGkxxK.js +270 -0
  82. package/dist/memory-auto-Bc7euou4.js +306 -0
  83. package/dist/memory-auto-DPfbkMVt.js +5 -0
  84. package/dist/memory-integration-DZExqWr4.js +91 -0
  85. package/dist/moltbook-B6ZeGN5_.js +81 -0
  86. package/dist/node-pwL6O_KX.js +222 -0
  87. package/dist/nodes-registry-CsPm_-CJ.js +52 -0
  88. package/dist/oauth-flow-CpWlgvNB.js +150 -0
  89. package/dist/oauth-provider-BZb6qOw5.js +110 -0
  90. package/dist/observability-B43YvNQV.js +89 -0
  91. package/dist/onboard-Bd_wsYdi.js +4086 -0
  92. package/dist/onboard-CAN7x3me.js +3026 -0
  93. package/dist/onboard-DnegOHMh.js +4 -4
  94. package/dist/onboard-RYtDlYBw.js +9 -0
  95. package/dist/onboard-aTwlQs-4.js +9 -0
  96. package/dist/orchestrator-BSp2M5EU.js +189 -0
  97. package/dist/orchestrator-C7ko5tWa.js +6 -0
  98. package/dist/orchestrator-DfPkIx2Z.js +6 -0
  99. package/dist/orchestrator-NJQsmiBE.js +189 -0
  100. package/dist/pairing-DU0_J28n.js +87 -0
  101. package/dist/pairing-DWllbSbO.js +4 -0
  102. package/dist/pc-access-Ly-uA8mn.js +8 -0
  103. package/dist/pc-access-NxBvTrRj.js +819 -0
  104. package/dist/pending-approval-DIHvwwWS.js +22 -0
  105. package/dist/puppeteer-2o3QOwAy.js +2 -2
  106. package/dist/puppeteer-BYTMp3BI.js +2 -2
  107. package/dist/puppeteer-DQ45qwWk.js +2 -2
  108. package/dist/reminders-store-D79qdfN0.js +58 -0
  109. package/dist/renderer-pqlDRKbH.js +225 -0
  110. package/dist/rules-BooT_qFP.js +103 -0
  111. package/dist/run-main.js +289 -1031
  112. package/dist/runner-D1rjuMTJ.js +810 -0
  113. package/dist/sdk/index.js +2 -2
  114. package/dist/sdk/index.mjs +2 -2
  115. package/dist/security-C-5URby1.js +73 -0
  116. package/dist/security-_xve79aq.js +4 -0
  117. package/dist/server-0kgyELx4.js +1047 -0
  118. package/dist/server-BIuTobTC.js +4 -0
  119. package/dist/server-BRlCEjyT.js +1047 -0
  120. package/dist/server-CCI1hv45.js +2 -2
  121. package/dist/server-DU9POoWc.js +4 -0
  122. package/dist/session-store-CujxByI6.js +113 -0
  123. package/dist/session-store-qpJUg2M1.js +5 -0
  124. package/dist/sessions-tools-CB2qbwIk.js +5 -0
  125. package/dist/sessions-tools-DHMaTZIs.js +95 -0
  126. package/dist/skill-loader-BkceKkIg.js +7 -0
  127. package/dist/skill-loader-DhgIwK4J.js +159 -0
  128. package/dist/skill-runtime--LqxWrp5.js +102 -0
  129. package/dist/skill-runtime-C5l0Tgt-.js +5 -0
  130. package/dist/skill-runtime-DsXK_HYG.js +102 -0
  131. package/dist/skill-runtime-IVTiqrMR.js +5 -0
  132. package/dist/src-BEVLgaF1.js +63 -0
  133. package/dist/src-Bgu_OxTQ.js +458 -0
  134. package/dist/src-Bq-oKt7Z.js +458 -0
  135. package/dist/src-DWCUhnD4.js +20 -0
  136. package/dist/src-cfRTjFef.js +63 -0
  137. package/dist/sub-agent-tools-BD9DF8_g.js +39 -0
  138. package/dist/sub-agent-tools-V7b3T9_s.js +39 -0
  139. package/dist/tool-policy-DNvNRnve.js +189 -0
  140. package/dist/tts-elevenlabs-BUOGKL-k.js +61 -0
  141. package/dist/update-check-BD4qH7Am.js +81 -0
  142. package/dist/vision-DRq-f-Dj.js +121 -0
  143. package/dist/vision-tools-CFZEpQKm.js +5 -0
  144. package/dist/vision-tools-CQnBI9aa.js +51 -0
  145. package/dist/voice-transcription-CgWq54hn.js +138 -0
  146. package/dist/website-watch-tools-Bk_TnwuE.js +5 -0
  147. package/dist/website-watch-tools-DraMPxdl.js +139 -0
  148. package/package.json +1 -1
@@ -0,0 +1,211 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_env_resolve = require('./env-resolve-szSWl0UF.js');
3
+ const https = require_chunk.__toESM(require("https"));
4
+
5
+ //#region packages/core/src/agent/bounty-tools.ts
6
+ function fetchJson(url, auth) {
7
+ return new Promise((resolve, reject) => {
8
+ const u = new URL(url);
9
+ const opts = {
10
+ hostname: u.hostname,
11
+ port: 443,
12
+ path: u.pathname + u.search,
13
+ method: "GET",
14
+ headers: { "Accept": "application/json" }
15
+ };
16
+ if (auth) {
17
+ const h = opts.headers;
18
+ if (auth.startsWith("Basic ") || auth.startsWith("Token ") || auth.startsWith("Bearer ")) h["Authorization"] = auth;
19
+ else h["Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`;
20
+ }
21
+ https.default.get(opts, (res) => {
22
+ let data = "";
23
+ res.on("data", (c) => data += c);
24
+ res.on("end", () => {
25
+ try {
26
+ resolve(JSON.parse(data || "{}"));
27
+ } catch {
28
+ resolve({});
29
+ }
30
+ });
31
+ }).on("error", reject);
32
+ });
33
+ }
34
+ function getBountyTools(cfg) {
35
+ const hackeroneKey = require_env_resolve.resolveServiceApiKey("hackerone", cfg);
36
+ const bugcrowdKey = require_env_resolve.resolveServiceApiKey("bugcrowd", cfg);
37
+ const synackKey = require_env_resolve.resolveServiceApiKey("synack", cfg);
38
+ const tools = [];
39
+ if (hackeroneKey) tools.push({
40
+ name: "hackerone_list_programs",
41
+ description: "List HackerOne programs you have access to. Use for bug bounty research.",
42
+ input_schema: {
43
+ type: "object",
44
+ properties: { limit: {
45
+ type: "string",
46
+ description: "Max programs (default 20)"
47
+ } }
48
+ },
49
+ handler: async (input) => {
50
+ try {
51
+ const auth = Buffer.from(hackeroneKey.includes(":") ? hackeroneKey : `:${hackeroneKey}`).toString("base64");
52
+ const body = await fetchJson("https://api.hackerone.com/v1/hackers/programs", `Basic ${auth}`);
53
+ const progs = body.data || [];
54
+ const limit = parseInt(input.limit || "20", 10);
55
+ return progs.slice(0, limit).map((p) => {
56
+ const attrs = p.attributes;
57
+ return `- ${attrs?.name || p.id} (${attrs?.state || "?"})`;
58
+ }).join("\n") || "No programs found.";
59
+ } catch (e) {
60
+ return `Error: ${e.message}. Check HackerOne API key (username:token).`;
61
+ }
62
+ }
63
+ });
64
+ if (bugcrowdKey) tools.push({
65
+ name: "bugcrowd_list_programs",
66
+ description: "List Bugcrowd programs. Use for bug bounty research.",
67
+ input_schema: {
68
+ type: "object",
69
+ properties: { limit: {
70
+ type: "string",
71
+ description: "Max programs (default 20)"
72
+ } }
73
+ },
74
+ handler: async (input) => {
75
+ try {
76
+ const auth = bugcrowdKey.startsWith("Token ") ? bugcrowdKey : `Token ${bugcrowdKey}`;
77
+ const body = await fetchJson("https://api.bugcrowd.com/programs", auth);
78
+ const progs = (body && typeof body === "object" && "data" in body ? body.data : body) || [];
79
+ const arr = Array.isArray(progs) ? progs : [progs];
80
+ const limit = parseInt(input.limit || "20", 10);
81
+ return arr.slice(0, limit).map((p) => {
82
+ const attrs = p.attributes;
83
+ const name = attrs?.name || p.name || p.id || "?";
84
+ const links = p.links;
85
+ const linkUrl = links?.self || p.url || "";
86
+ return `- ${name} ${linkUrl ? `(${linkUrl})` : ""}`;
87
+ }).join("\n") || JSON.stringify(body).slice(0, 500);
88
+ } catch (e) {
89
+ return `Error: ${e.message}. Check Bugcrowd API token.`;
90
+ }
91
+ }
92
+ });
93
+ if (synackKey) tools.push({
94
+ name: "synack_list_targets",
95
+ description: "List Synack targets you have access to. Use for bug bounty research.",
96
+ input_schema: {
97
+ type: "object",
98
+ properties: {}
99
+ },
100
+ handler: async () => {
101
+ try {
102
+ const body = await fetchJson("https://api.synack.com/api/targets", `Bearer ${synackKey}`);
103
+ const targets = body.targets || body || [];
104
+ const arr = Array.isArray(targets) ? targets : [targets];
105
+ return arr.slice(0, 20).map((t) => `- ${t.name || t.slug || t.id || "?"}`).join("\n") || "No targets or check Synack API.";
106
+ } catch (e) {
107
+ return `Error: ${e.message}. Check Synack API token.`;
108
+ }
109
+ }
110
+ });
111
+ const apiKeys = cfg?.skills?.apiKeys ?? {};
112
+ const genericServiceIds = Object.keys(apiKeys).filter((id) => !KNOWN_BOUNTY_SERVICES.includes(id.toLowerCase()));
113
+ if (genericServiceIds.length > 0) tools.push({
114
+ name: "call_service_api",
115
+ description: `Call external API for services with configured keys. Available: ${genericServiceIds.join(", ")}. Use when the user needs to query an API for a service they've added (Stripe, GitHub, custom APIs, etc).`,
116
+ input_schema: {
117
+ type: "object",
118
+ properties: {
119
+ service_id: {
120
+ type: "string",
121
+ description: `Service id from configured keys: ${genericServiceIds.join(", ")}`
122
+ },
123
+ url: {
124
+ type: "string",
125
+ description: "Full API URL (e.g. https://api.example.com/v1/resource) or path if baseUrl configured"
126
+ },
127
+ method: {
128
+ type: "string",
129
+ description: "HTTP method",
130
+ enum: [
131
+ "GET",
132
+ "POST",
133
+ "PUT",
134
+ "PATCH",
135
+ "DELETE"
136
+ ]
137
+ },
138
+ body: {
139
+ type: "object",
140
+ description: "Request body for POST/PUT/PATCH (optional)"
141
+ }
142
+ },
143
+ required: ["service_id", "url"]
144
+ },
145
+ handler: async (input) => {
146
+ const serviceId = String(input.service_id || "").trim().toLowerCase();
147
+ const url = String(input.url || "");
148
+ const method = String(input.method || "GET").toUpperCase();
149
+ const key = require_env_resolve.resolveServiceApiKey(serviceId, cfg);
150
+ if (!key) return `Error: No API key for service "${serviceId}". Configure via: hyperclaw config set-service-key ${serviceId} <key>`;
151
+ if (!url || !url.startsWith("http")) return "Error: url must be a full URL (https://...).";
152
+ try {
153
+ const body = await genericHttpRequest(url, method, key, input.body);
154
+ return typeof body === "string" ? body : JSON.stringify(body, null, 2).slice(0, 8e3);
155
+ } catch (e) {
156
+ return `Error: ${e.message}`;
157
+ }
158
+ }
159
+ });
160
+ return tools;
161
+ }
162
+ function genericHttpRequest(url, method, apiKey, body) {
163
+ return new Promise((resolve, reject) => {
164
+ const u = new URL(url);
165
+ const authHeader = apiKey.startsWith("Bearer ") || apiKey.startsWith("Token ") || apiKey.startsWith("Basic ") ? apiKey : `Bearer ${apiKey}`;
166
+ const bodyStr = body && method !== "GET" ? JSON.stringify(body) : void 0;
167
+ const opts = {
168
+ hostname: u.hostname,
169
+ port: u.port || 443,
170
+ path: u.pathname + u.search,
171
+ method,
172
+ headers: {
173
+ "Accept": "application/json",
174
+ "Authorization": authHeader,
175
+ ...bodyStr ? {
176
+ "Content-Type": "application/json",
177
+ "Content-Length": Buffer.byteLength(bodyStr)
178
+ } : {}
179
+ }
180
+ };
181
+ const req = https.default.request(opts, (res) => {
182
+ let data = "";
183
+ res.on("data", (c) => {
184
+ data += c.toString();
185
+ });
186
+ res.on("end", () => {
187
+ try {
188
+ resolve(JSON.parse(data || "{}"));
189
+ } catch {
190
+ resolve(data || "{}");
191
+ }
192
+ });
193
+ });
194
+ req.on("error", reject);
195
+ if (bodyStr) req.write(bodyStr);
196
+ req.end();
197
+ });
198
+ }
199
+ var KNOWN_BOUNTY_SERVICES;
200
+ var init_bounty_tools = require_chunk.__esm({ "packages/core/src/agent/bounty-tools.ts"() {
201
+ require_env_resolve.init_env_resolve();
202
+ KNOWN_BOUNTY_SERVICES = [
203
+ "hackerone",
204
+ "bugcrowd",
205
+ "synack"
206
+ ];
207
+ } });
208
+
209
+ //#endregion
210
+ init_bounty_tools();
211
+ exports.getBountyTools = getBountyTools;
@@ -0,0 +1,5 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_browser_tools = require('./browser-tools-YQmwRLLM.js');
3
+
4
+ require_browser_tools.init_browser_tools();
5
+ exports.getBrowserTools = require_browser_tools.getBrowserTools;
@@ -0,0 +1,179 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+
3
+ //#region packages/core/src/agent/browser-tools.ts
4
+ async function getBrowser() {
5
+ try {
6
+ const puppeteer = await import("puppeteer").catch(() => null);
7
+ if (!puppeteer) return null;
8
+ if (!sharedBrowser || !sharedBrowser.connected) {
9
+ const execPath = process.env.PUPPETEER_EXECUTABLE_PATH;
10
+ sharedBrowser = await puppeteer.default.launch({
11
+ headless: true,
12
+ executablePath: execPath || void 0,
13
+ args: [
14
+ "--no-sandbox",
15
+ "--disable-setuid-sandbox",
16
+ "--disable-dev-shm-usage"
17
+ ]
18
+ });
19
+ sharedPage = await sharedBrowser.newPage();
20
+ await sharedPage.setViewport({
21
+ width: 1280,
22
+ height: 800
23
+ });
24
+ await sharedPage.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
25
+ }
26
+ return {
27
+ browser: sharedBrowser,
28
+ page: sharedPage
29
+ };
30
+ } catch {
31
+ return null;
32
+ }
33
+ }
34
+ function getBrowserTools() {
35
+ return [{
36
+ name: "browser_snapshot",
37
+ description: "Capture a snapshot of the current browser page (DOM, text, links). Use before interacting. Pass url to navigate first.",
38
+ input_schema: {
39
+ type: "object",
40
+ properties: { url: {
41
+ type: "string",
42
+ description: "URL to navigate to before snapshot (optional if already on page)"
43
+ } },
44
+ required: []
45
+ },
46
+ handler: async (input) => {
47
+ const bw = await getBrowser();
48
+ if (!bw) return BROWSER_SETUP;
49
+ const { page } = bw;
50
+ try {
51
+ if (input.url) await page.goto(input.url, {
52
+ waitUntil: "domcontentloaded",
53
+ timeout: 15e3
54
+ });
55
+ const snapshot = await page.evaluate(() => {
56
+ const text = document.body?.innerText?.slice(0, 12e3) || "";
57
+ const links = Array.from(document.querySelectorAll("a[href]")).map((a) => ({
58
+ text: (a.textContent || "").trim().slice(0, 80),
59
+ href: a.getAttribute("href")
60
+ })).filter((l) => l.href?.startsWith("http")).slice(0, 50);
61
+ const title = document.title || "";
62
+ const url = window.location.href;
63
+ return JSON.stringify({
64
+ title,
65
+ url,
66
+ text,
67
+ links
68
+ });
69
+ });
70
+ return snapshot;
71
+ } catch (e) {
72
+ return `Browser snapshot error: ${e.message}`;
73
+ }
74
+ }
75
+ }, {
76
+ name: "browser_action",
77
+ description: "Perform an action in the browser: click, type, scroll, navigate. Use after browser_snapshot.",
78
+ input_schema: {
79
+ type: "object",
80
+ properties: {
81
+ action: {
82
+ type: "string",
83
+ description: "Action: click, type, scroll, navigate",
84
+ enum: [
85
+ "click",
86
+ "type",
87
+ "scroll",
88
+ "navigate"
89
+ ]
90
+ },
91
+ selector: {
92
+ type: "string",
93
+ description: "CSS selector or link text to match (for click/type)"
94
+ },
95
+ value: {
96
+ type: "string",
97
+ description: "For type: text to type. For navigate: URL. For scroll: \"up\" or \"down\""
98
+ }
99
+ },
100
+ required: ["action"]
101
+ },
102
+ handler: async (input) => {
103
+ const action = String(input?.action ?? "");
104
+ const selector = input?.selector;
105
+ const value = input?.value;
106
+ const bw = await getBrowser();
107
+ if (!bw) return BROWSER_SETUP;
108
+ const { page } = bw;
109
+ try {
110
+ switch (action) {
111
+ case "navigate":
112
+ if (!value) return "navigate requires value (URL)";
113
+ await page.goto(value, {
114
+ waitUntil: "domcontentloaded",
115
+ timeout: 15e3
116
+ });
117
+ return `Navigated to ${value}`;
118
+ case "click":
119
+ if (!selector) return "click requires selector";
120
+ const sel = selector.trim();
121
+ const isCss = /^[#.\w\[\]="'\s-:>+~]+$/.test(sel) && (sel.includes("#") || sel.includes(".") || sel.includes("[") || /^[a-z][a-z0-9]*$/i.test(sel));
122
+ if (isCss) {
123
+ await page.waitForSelector(sel, { timeout: 5e3 });
124
+ await page.click(sel);
125
+ return `Clicked ${sel}`;
126
+ }
127
+ const safe = sel.replace(/["']/g, "").slice(0, 100);
128
+ const xpath = `//a[contains(text(),"${safe}")]`;
129
+ const [el] = await page.$x(xpath);
130
+ if (el) {
131
+ await el.click();
132
+ return `Clicked link "${sel}"`;
133
+ }
134
+ const btnXpath = `//button[contains(text(),"${safe}")]`;
135
+ const [btn] = await page.$x(btnXpath);
136
+ if (btn) {
137
+ await btn.click();
138
+ return `Clicked button "${sel}"`;
139
+ }
140
+ throw new Error(`Element not found: ${sel}`);
141
+ case "type":
142
+ if (!selector) return "type requires selector";
143
+ await page.waitForSelector(selector, { timeout: 5e3 });
144
+ await page.type(selector, value || "");
145
+ return `Typed "${value || ""}" into ${selector}`;
146
+ case "scroll":
147
+ const dir = (value || "down").toLowerCase();
148
+ await page.evaluate((d) => {
149
+ window.scrollBy(0, d === "up" ? -400 : 400);
150
+ }, dir);
151
+ return `Scrolled ${dir}`;
152
+ default: return `Unknown action: ${action}`;
153
+ }
154
+ } catch (e) {
155
+ return `Browser action error: ${e.message}`;
156
+ }
157
+ }
158
+ }];
159
+ }
160
+ var BROWSER_SETUP, sharedBrowser, sharedPage;
161
+ var init_browser_tools = require_chunk.__esm({ "packages/core/src/agent/browser-tools.ts"() {
162
+ BROWSER_SETUP = "Browser control requires Puppeteer. Install: npm i puppeteer. Then enable in config: browser.enabled: true";
163
+ sharedBrowser = null;
164
+ sharedPage = null;
165
+ } });
166
+
167
+ //#endregion
168
+ Object.defineProperty(exports, 'getBrowserTools', {
169
+ enumerable: true,
170
+ get: function () {
171
+ return getBrowserTools;
172
+ }
173
+ });
174
+ Object.defineProperty(exports, 'init_browser_tools', {
175
+ enumerable: true,
176
+ get: function () {
177
+ return init_browser_tools;
178
+ }
179
+ });
@@ -0,0 +1,80 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const https = require_chunk.__toESM(require("https"));
3
+
4
+ //#region src/services/claw-tasks.ts
5
+ /** List open bounties. */
6
+ async function listBounties(limit = 20, status = "open") {
7
+ if (!CLAW_TASKS_API) return [];
8
+ try {
9
+ const q = new URLSearchParams({ limit: String(limit) });
10
+ if (status === "open") q.set("status", "open");
11
+ const body = await fetchJson(`${CLAW_TASKS_API}/api/bounties?${q}`);
12
+ return Array.isArray(body.bounties) ? body.bounties : [];
13
+ } catch {
14
+ return [];
15
+ }
16
+ }
17
+ /** Claim a bounty (requires agent auth). */
18
+ async function claimBounty(bountyId, agentToken) {
19
+ if (!CLAW_TASKS_API) return null;
20
+ try {
21
+ const body = await postJson(`${CLAW_TASKS_API}/api/bounties/${encodeURIComponent(bountyId)}/claim`, {}, agentToken);
22
+ return body.bounty || null;
23
+ } catch {
24
+ return null;
25
+ }
26
+ }
27
+ function fetchJson(url) {
28
+ return new Promise((resolve, reject) => {
29
+ https.default.get(url, (res) => {
30
+ let data = "";
31
+ res.on("data", (c) => data += c);
32
+ res.on("end", () => {
33
+ try {
34
+ resolve(JSON.parse(data));
35
+ } catch {
36
+ reject(new Error("Invalid JSON"));
37
+ }
38
+ });
39
+ }).on("error", reject);
40
+ });
41
+ }
42
+ function postJson(url, payload, token) {
43
+ return new Promise((resolve, reject) => {
44
+ const u = new URL(url);
45
+ const body = JSON.stringify(payload);
46
+ const req = https.default.request({
47
+ hostname: u.hostname,
48
+ port: 443,
49
+ path: u.pathname,
50
+ method: "POST",
51
+ headers: {
52
+ "Content-Type": "application/json",
53
+ "Content-Length": Buffer.byteLength(body),
54
+ ...token ? { Authorization: `Bearer ${token}` } : {}
55
+ }
56
+ }, (res) => {
57
+ let data = "";
58
+ res.on("data", (c) => data += c);
59
+ res.on("end", () => {
60
+ try {
61
+ resolve(JSON.parse(data || "{}"));
62
+ } catch {
63
+ resolve({});
64
+ }
65
+ });
66
+ });
67
+ req.on("error", reject);
68
+ req.write(body);
69
+ req.end();
70
+ });
71
+ }
72
+ var CLAW_TASKS_API;
73
+ var init_claw_tasks = require_chunk.__esm({ "src/services/claw-tasks.ts"() {
74
+ CLAW_TASKS_API = process.env.CLAW_TASKS_API_URL || "";
75
+ } });
76
+
77
+ //#endregion
78
+ init_claw_tasks();
79
+ exports.claimBounty = claimBounty;
80
+ exports.listBounties = listBounties;
@@ -0,0 +1,167 @@
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 https = require_chunk.__toESM(require("https"));
7
+ const events = require_chunk.__toESM(require("events"));
8
+
9
+ //#region extensions/zalo-personal/src/connector.ts
10
+ const STATE_FILE = path.default.join(os.default.homedir(), ".hyperclaw", "zalo-personal-state.json");
11
+ function zaloWebReq(cookie, method, endpoint, body) {
12
+ return new Promise((resolve, reject) => {
13
+ const payload = body ? JSON.stringify(body) : null;
14
+ const req = https.default.request({
15
+ hostname: "chat.zalo.me",
16
+ port: 443,
17
+ path: `/api${endpoint}`,
18
+ method,
19
+ headers: {
20
+ "Cookie": cookie,
21
+ "Referer": "https://chat.zalo.me/",
22
+ "User-Agent": "Mozilla/5.0 (compatible; HyperClaw/4.0)",
23
+ ...payload ? {
24
+ "Content-Type": "application/json",
25
+ "Content-Length": Buffer.byteLength(payload)
26
+ } : {}
27
+ }
28
+ }, (res) => {
29
+ let data = "";
30
+ res.on("data", (c) => data += c);
31
+ res.on("end", () => {
32
+ try {
33
+ resolve(JSON.parse(data));
34
+ } catch {
35
+ resolve({ raw: data });
36
+ }
37
+ });
38
+ });
39
+ req.on("error", reject);
40
+ if (payload) req.write(payload);
41
+ req.end();
42
+ });
43
+ }
44
+ var ZaloPersonalConnector = class extends events.EventEmitter {
45
+ config;
46
+ running = false;
47
+ ws = null;
48
+ userId = "";
49
+ constructor(config) {
50
+ super();
51
+ this.config = {
52
+ imei: require("crypto").randomUUID(),
53
+ dmPolicy: "allowlist",
54
+ allowFrom: [],
55
+ approvedPairings: [],
56
+ pendingPairings: {},
57
+ ...config
58
+ };
59
+ }
60
+ async connect() {
61
+ const profile = await zaloWebReq(this.config.cookie, "GET", "/profile");
62
+ this.userId = profile?.data?.userId || profile?.userId || "";
63
+ await this.loadState();
64
+ this.running = true;
65
+ console.log(chalk.default.green(` 🦅 Zalo Personal: ${profile?.data?.displayName || this.userId} connected`));
66
+ this.emit("connected", { userId: this.userId });
67
+ this.startPolling();
68
+ }
69
+ async startPolling() {
70
+ while (this.running) try {
71
+ const msgs = await zaloWebReq(this.config.cookie, "GET", `/message/fetchlatestmsg?last_msg_id=0&limit=20`);
72
+ for (const msg of msgs?.data?.msgs || []) {
73
+ if (msg.fromUid === this.userId) continue;
74
+ if (!msg.msgId || !msg.content) continue;
75
+ const from = msg.fromUid;
76
+ const text = msg.content;
77
+ const allowed = await this.checkDMPolicy(from, text);
78
+ if (!allowed) continue;
79
+ this.emit("message", {
80
+ id: msg.msgId,
81
+ channelId: "zalo-personal",
82
+ from,
83
+ chatId: msg.toUid || from,
84
+ text,
85
+ timestamp: new Date(parseInt(msg.ts || "0")).toISOString(),
86
+ isDM: true
87
+ });
88
+ }
89
+ await new Promise((r) => setTimeout(r, 3e3));
90
+ } catch (e) {
91
+ if (this.running) {
92
+ console.log(chalk.default.yellow(` ⚠ Zalo Personal: ${e.message}`));
93
+ await new Promise((r) => setTimeout(r, 5e3));
94
+ }
95
+ }
96
+ }
97
+ async checkDMPolicy(from, text) {
98
+ if (this.config.dmPolicy === "none") return false;
99
+ if (this.config.dmPolicy === "open") return true;
100
+ if (this.config.dmPolicy === "allowlist") {
101
+ if (this.config.allowFrom.includes(from)) return true;
102
+ await this.sendMessage(from, "🦅 HyperClaw: Not on allowlist.");
103
+ return false;
104
+ }
105
+ if (this.config.dmPolicy === "pairing") {
106
+ if (this.config.approvedPairings.includes(from)) return true;
107
+ const upper = text.trim().toUpperCase();
108
+ if (this.config.pendingPairings[upper]) {
109
+ this.config.approvedPairings.push(from);
110
+ delete this.config.pendingPairings[upper];
111
+ await this.saveState();
112
+ await this.sendMessage(from, "🦅 Paired!");
113
+ this.emit("pairing:approved", {
114
+ userId: from,
115
+ channelId: "zalo-personal"
116
+ });
117
+ return true;
118
+ }
119
+ const code = Array.from({ length: 6 }, () => "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"[Math.floor(Math.random() * 32)]).join("");
120
+ this.config.pendingPairings[code] = from;
121
+ await this.saveState();
122
+ await this.sendMessage(from, `🦅 Mã ghép đôi: ${code}\nXác nhận: hyperclaw pairing approve zalo-personal ${code}`);
123
+ return false;
124
+ }
125
+ return false;
126
+ }
127
+ async sendMessage(toUid, text) {
128
+ await zaloWebReq(this.config.cookie, "POST", "/message/sendmsg", {
129
+ toid: toUid,
130
+ msg: text.slice(0, 2e3),
131
+ imei: this.config.imei,
132
+ type: 1
133
+ });
134
+ }
135
+ disconnect() {
136
+ this.running = false;
137
+ this.ws?.close();
138
+ }
139
+ approvePairing(code) {
140
+ const upper = code.toUpperCase();
141
+ if (!this.config.pendingPairings[upper]) return false;
142
+ this.config.approvedPairings.push(this.config.pendingPairings[upper]);
143
+ delete this.config.pendingPairings[upper];
144
+ this.saveState();
145
+ return true;
146
+ }
147
+ async loadState() {
148
+ try {
149
+ const s = await fs_extra.default.readJson(STATE_FILE);
150
+ if (s.p) this.config.pendingPairings = s.p;
151
+ if (s.a) this.config.approvedPairings = s.a;
152
+ } catch {}
153
+ }
154
+ async saveState() {
155
+ await fs_extra.default.ensureDir(path.default.dirname(STATE_FILE));
156
+ await fs_extra.default.writeJson(STATE_FILE, {
157
+ p: this.config.pendingPairings,
158
+ a: this.config.approvedPairings
159
+ }, { spaces: 2 });
160
+ }
161
+ isRunning() {
162
+ return this.running;
163
+ }
164
+ };
165
+
166
+ //#endregion
167
+ exports.ZaloPersonalConnector = ZaloPersonalConnector;