hyperclaw 5.0.1 → 5.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 (137) hide show
  1. package/LICENSE +2 -1
  2. package/README.md +247 -32
  3. package/dist/a2ui-protocol-Gzm29Gaw.js +75 -0
  4. package/dist/agents-routing-Biy5ew4a.js +4 -0
  5. package/dist/agents-routing-CL3HQNoM.js +327 -0
  6. package/dist/api-keys-guide-ChbThbPj.js +149 -0
  7. package/dist/audit-NPIMmOSq.js +441 -0
  8. package/dist/bounty-tools-BUqUKjt0.js +211 -0
  9. package/dist/browser-tools-CxJY6pAn.js +5 -0
  10. package/dist/browser-tools-JZ9ji6AW.js +179 -0
  11. package/dist/chat-qVuqhlPu.js +258 -0
  12. package/dist/claw-tasks-B-8RRMdq.js +80 -0
  13. package/dist/connector-1x1rCBHz.js +162 -0
  14. package/dist/connector-B4jeCULG.js +305 -0
  15. package/dist/connector-B7qngfkT.js +286 -0
  16. package/dist/connector-B8BK0GBo.js +531 -0
  17. package/dist/connector-BE9eJs8-.js +182 -0
  18. package/dist/connector-BEe-DTGQ.js +189 -0
  19. package/dist/connector-BU7p5ZgB.js +167 -0
  20. package/dist/connector-BUzzq7Ij.js +568 -0
  21. package/dist/connector-BpDqLgnW.js +419 -0
  22. package/dist/connector-BpW88ut2.js +189 -0
  23. package/dist/connector-Bxv-gy8U.js +167 -0
  24. package/dist/connector-Bz14zcJv.js +213 -0
  25. package/dist/connector-C1zP5-5q.js +85 -0
  26. package/dist/connector-CAcpcovF.js +498 -0
  27. package/dist/connector-CJgVjS58.js +181 -0
  28. package/dist/connector-Cf53D6qV.js +425 -0
  29. package/dist/connector-CyHmlbNz.js +508 -0
  30. package/dist/connector-D22mJGVu.js +340 -0
  31. package/dist/connector-D6RtMmlL.js +225 -0
  32. package/dist/connector-D9EnT8A4.js +280 -0
  33. package/dist/connector-DNDwIh37.js +239 -0
  34. package/dist/connector-Di27MeO4.js +350 -0
  35. package/dist/connector-Do0BPiHt.js +194 -0
  36. package/dist/connector-DvLwOfJy.js +192 -0
  37. package/dist/connector-DvU83NSq.js +181 -0
  38. package/dist/connector-DxskpDc_.js +173 -0
  39. package/dist/connector-byy3eISx.js +552 -0
  40. package/dist/connector-vV89hsyd.js +218 -0
  41. package/dist/cost-tracker-fnaj_6M9.js +103 -0
  42. package/dist/credentials-store-BxijEirw.js +77 -0
  43. package/dist/credentials-store-CPkVO6-z.js +4 -0
  44. package/dist/cron-tasks-L0mz1yyU.js +82 -0
  45. package/dist/daemon-CNyunwkR.js +5 -0
  46. package/dist/daemon-CindY8OK.js +318 -0
  47. package/dist/delivery-DgiZcJBp.js +4 -0
  48. package/dist/delivery-otAU4alM.js +95 -0
  49. package/dist/destructive-gate-CA0DtA5K.js +101 -0
  50. package/dist/developer-keys-Cnd1kswV.js +127 -0
  51. package/dist/developer-keys-DENo3ZA6.js +8 -0
  52. package/dist/doctor-Dgjoc3DG.js +230 -0
  53. package/dist/doctor-RwsOhtAl.js +6 -0
  54. package/dist/engine-D_VeoZHw.js +305 -0
  55. package/dist/engine-JjRnhlsE.js +7 -0
  56. package/dist/env-resolve-BFJXWl94.js +115 -0
  57. package/dist/env-resolve-bDYssfih.js +10 -0
  58. package/dist/extraction-tools-DbxnxIco.js +5 -0
  59. package/dist/extraction-tools-Dg7AHS35.js +91 -0
  60. package/dist/form_data-CGAy4HE0.js +8657 -0
  61. package/dist/gmail-watch-setup-C3uSWznp.js +40 -0
  62. package/dist/health-DUjluWHQ.js +6 -0
  63. package/dist/health-DVfkpUQW.js +152 -0
  64. package/dist/heartbeat-engine-CrgL4mrP.js +83 -0
  65. package/dist/hub-BO6bj8Yj.js +515 -0
  66. package/dist/hub-Bu52YZqW.js +6 -0
  67. package/dist/hyperclawbot-BrcoYLOp.js +505 -0
  68. package/dist/inference-DHR82Gh7.js +6 -0
  69. package/dist/inference-DhA8jpfH.js +2692 -0
  70. package/dist/knowledge-graph-BrYpSgxW.js +131 -0
  71. package/dist/loader-9JqY6Nlq.js +4 -0
  72. package/dist/loader-Cjdd1kw4.js +400 -0
  73. package/dist/logger-DCT2l9GV.js +83 -0
  74. package/dist/manager-3cq3DydI.js +4 -0
  75. package/dist/manager-BUrFrPuq.js +117 -0
  76. package/dist/manager-Bi9UYyVR.js +105 -0
  77. package/dist/manager-Biz9ixWJ.js +40 -0
  78. package/dist/manager-CBUHJiY7.js +6 -0
  79. package/dist/manager-CVLLaKmq.js +218 -0
  80. package/dist/mcp-CUoTCMw-.js +139 -0
  81. package/dist/mcp-loader-BIz-450x.js +94 -0
  82. package/dist/memory-OL77OMOr.js +270 -0
  83. package/dist/memory-auto-D-L2q21G.js +306 -0
  84. package/dist/memory-auto-DTcy5VBy.js +5 -0
  85. package/dist/memory-gUi4VaIf.js +4 -0
  86. package/dist/memory-integration-B8RSN4pr.js +91 -0
  87. package/dist/moltbook-B-40gQOL.js +81 -0
  88. package/dist/node-TWxRm84k.js +222 -0
  89. package/dist/nodes-registry-DKRtsbNg.js +52 -0
  90. package/dist/oauth-flow-JCfporKq.js +150 -0
  91. package/dist/oauth-provider-4R0EJlsT.js +110 -0
  92. package/dist/observability-CDZmeHfa.js +89 -0
  93. package/dist/onboard-BVOtKQdh.js +3641 -0
  94. package/dist/onboard-CGNIw27w.js +11 -0
  95. package/dist/orchestrator-CcKx1Ovk.js +189 -0
  96. package/dist/orchestrator-DcFfDLTX.js +6 -0
  97. package/dist/osint-B6BZKQAD.js +277 -0
  98. package/dist/pairing-B6RArWhD.js +196 -0
  99. package/dist/pairing-BsQ08DLq.js +4 -0
  100. package/dist/pc-access-B0KocJNe.js +819 -0
  101. package/dist/pc-access-DkzmugZ7.js +8 -0
  102. package/dist/pending-approval-C_HkX1QL.js +22 -0
  103. package/dist/providers-DxiamZSL.js +5 -0
  104. package/dist/providers-Dy15rDb7.js +657 -0
  105. package/dist/reminders-store-CzUY0zYx.js +58 -0
  106. package/dist/renderer-ANNfXsHn.js +225 -0
  107. package/dist/rules-BSQwwAYC.js +103 -0
  108. package/dist/run-main.js +112 -117
  109. package/dist/runner-BHRSOPEU.js +1271 -0
  110. package/dist/security--oQObeJO.js +4 -0
  111. package/dist/security-wBOg0TA8.js +73 -0
  112. package/dist/server-CbTTpB5m.js +1255 -0
  113. package/dist/server-DP_bPzvI.js +4 -0
  114. package/dist/session-store-B09r5HgB.js +5 -0
  115. package/dist/session-store-DCTQIVur.js +113 -0
  116. package/dist/sessions-tools-BdlN6Pb6.js +95 -0
  117. package/dist/sessions-tools-JVLDKSJ_.js +5 -0
  118. package/dist/skill-loader-B5oeliGu.js +7 -0
  119. package/dist/skill-loader-Wf3brNOj.js +160 -0
  120. package/dist/skill-runtime-BGlvly2s.js +102 -0
  121. package/dist/skill-runtime-DhL2T76p.js +5 -0
  122. package/dist/src-BbPa6Q8p.js +63 -0
  123. package/dist/src-BeXtfkK2.js +458 -0
  124. package/dist/src-CGQjRI4N.js +20 -0
  125. package/dist/sub-agent-tools-CmE345s_.js +39 -0
  126. package/dist/theme-D0smfC_l.js +8 -0
  127. package/dist/theme-DajRRZbA.js +180 -0
  128. package/dist/tool-policy-DgNqFWYn.js +189 -0
  129. package/dist/tts-elevenlabs-JeFaGNJU.js +61 -0
  130. package/dist/update-check-BVEqHhFY.js +83 -0
  131. package/dist/vision-fky3elEo.js +121 -0
  132. package/dist/vision-tools-C8B3776g.js +5 -0
  133. package/dist/vision-tools-dwn9p4el.js +51 -0
  134. package/dist/voice-transcription-B6RtplmN.js +138 -0
  135. package/dist/website-watch-tools-B-jRAeTe.js +139 -0
  136. package/dist/website-watch-tools-BC9xAL67.js +5 -0
  137. package/package.json +1 -1
@@ -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,258 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_paths = require('./paths-AIyBxIzm.js');
3
+ require('./browser-tools-JZ9ji6AW.js');
4
+ require('./src-CGQjRI4N.js');
5
+ const require_engine = require('./engine-D_VeoZHw.js');
6
+ require('./extraction-tools-Dg7AHS35.js');
7
+ const require_inference = require('./inference-DhA8jpfH.js');
8
+ require('./memory-auto-D-L2q21G.js');
9
+ require('./orchestrator-CcKx1Ovk.js');
10
+ require('./pc-access-B0KocJNe.js');
11
+ require('./session-store-DCTQIVur.js');
12
+ require('./sessions-tools-BdlN6Pb6.js');
13
+ require('./skill-loader-Wf3brNOj.js');
14
+ require('./skill-runtime-BGlvly2s.js');
15
+ require('./vision-tools-dwn9p4el.js');
16
+ require('./website-watch-tools-B-jRAeTe.js');
17
+ const require_src$1 = require('./src-BeXtfkK2.js');
18
+ const chalk = require_chunk.__toESM(require("chalk"));
19
+ const ora = require_chunk.__toESM(require("ora"));
20
+ const fs_extra = require_chunk.__toESM(require("fs-extra"));
21
+ const readline = require_chunk.__toESM(require("readline"));
22
+
23
+ //#region src/cli/chat.ts
24
+ require_src$1.init_src();
25
+ const DIVIDER = chalk.default.gray(" " + "─".repeat(56));
26
+ function printHeader(model, sessionId) {
27
+ console.log();
28
+ console.log(DIVIDER);
29
+ console.log(chalk.default.bold.cyan(" 🦅 HYPERCLAW CHAT"));
30
+ console.log(chalk.default.gray(` Model: ${model} · Session: ${sessionId}`));
31
+ console.log(DIVIDER);
32
+ console.log(chalk.default.gray(" Type your message and press Enter."));
33
+ console.log(chalk.default.gray(" Commands: /exit /clear /model /skills /help"));
34
+ console.log(DIVIDER);
35
+ console.log();
36
+ }
37
+ function printHelp() {
38
+ console.log();
39
+ console.log(chalk.default.bold(" Commands:"));
40
+ console.log(` ${chalk.default.cyan("/exit")} — quit the chat`);
41
+ console.log(` ${chalk.default.cyan("/clear")} — clear conversation history`);
42
+ console.log(` ${chalk.default.cyan("/model")} — show current model`);
43
+ console.log(` ${chalk.default.cyan("/skills")} — list installed skills + how to add more`);
44
+ console.log(` ${chalk.default.cyan("/help")} — show this help`);
45
+ console.log();
46
+ console.log(chalk.default.gray(" Tip: you can also tell the agent to install a skill:"));
47
+ console.log(chalk.default.gray(" \"Install the web-search skill\" or paste a clawhub.ai link"));
48
+ console.log();
49
+ }
50
+ async function printSkills() {
51
+ console.log();
52
+ try {
53
+ const { loadSkills } = await Promise.resolve().then(() => require("./src-BbPa6Q8p.js"));
54
+ const skills = await loadSkills();
55
+ if (skills.length === 0) console.log(chalk.default.gray(" No skills installed yet."));
56
+ else {
57
+ console.log(chalk.default.bold(" Installed skills:"));
58
+ for (const s of skills) {
59
+ console.log(` ${chalk.default.cyan("•")} ${chalk.default.bold(s.title || s.id)} ${chalk.default.gray(`(${s.id})`)}`);
60
+ if (s.capabilities) console.log(chalk.default.gray(` ${s.capabilities}`));
61
+ }
62
+ }
63
+ } catch {
64
+ console.log(chalk.default.gray(" Could not load skills list."));
65
+ }
66
+ console.log();
67
+ console.log(chalk.default.bold(" How to add a skill:"));
68
+ console.log(` ${chalk.default.gray("1.")} Tell the agent: ${chalk.default.cyan("\"Install the web-search skill\"")}`);
69
+ console.log(` ${chalk.default.gray("2.")} Paste a link: ${chalk.default.cyan("\"Install this: https://clawhub.ai/user/skill-name\"")}`);
70
+ console.log(` ${chalk.default.gray("3.")} CLI (outside chat): ${chalk.default.cyan("hyperclaw skill install <name>")}`);
71
+ console.log(` ${chalk.default.gray("4.")} Re-run wizard: ${chalk.default.cyan("hyperclaw onboard")}`);
72
+ console.log();
73
+ }
74
+ function makeSessionId() {
75
+ return Math.random().toString(36).slice(2, 9);
76
+ }
77
+ async function runChat(opts) {
78
+ const cfg = await fs_extra.default.readJson(require_paths.getConfigPath()).catch(() => null);
79
+ if (!cfg) {
80
+ console.log(chalk.default.red("\n No configuration found. Run: hyperclaw onboard\n"));
81
+ return;
82
+ }
83
+ const { getProviderCredentialAsync } = await Promise.resolve().then(() => require("./env-resolve-bDYssfih.js"));
84
+ const apiKey = await getProviderCredentialAsync(cfg).catch(() => null);
85
+ const isLocal = [
86
+ "local",
87
+ "ollama",
88
+ "lmstudio"
89
+ ].includes(cfg?.provider?.providerId ?? "");
90
+ if (!apiKey && !isLocal) {
91
+ console.log(chalk.default.red("\n No API key configured. Run: hyperclaw config set-key\n"));
92
+ return;
93
+ }
94
+ const { getProvider } = await Promise.resolve().then(() => require("./providers-DxiamZSL.js"));
95
+ const providerMeta = getProvider(cfg?.provider?.providerId ?? "");
96
+ const CUSTOM_IDS = new Set([
97
+ "groq",
98
+ "mistral",
99
+ "deepseek",
100
+ "perplexity",
101
+ "huggingface",
102
+ "ollama",
103
+ "lmstudio",
104
+ "local",
105
+ "xai",
106
+ "openai",
107
+ "google",
108
+ "minimax",
109
+ "moonshot",
110
+ "qwen",
111
+ "zai",
112
+ "litellm",
113
+ "cloudflare",
114
+ "copilot",
115
+ "vercel-ai",
116
+ "opencode-zen"
117
+ ]);
118
+ const isAnthropicVariant = [
119
+ "anthropic",
120
+ "anthropic-oauth",
121
+ "anthropic-setup-token"
122
+ ].includes(cfg?.provider?.providerId ?? "");
123
+ const provider = isAnthropicVariant ? "anthropic" : cfg?.provider?.providerId === "custom" || isLocal || CUSTOM_IDS.has(cfg?.provider?.providerId ?? "") ? "custom" : "openrouter";
124
+ const rawModel = opts.model || cfg?.provider?.modelId || "claude-sonnet-4-5";
125
+ const model = rawModel.startsWith("ollama/") ? rawModel.slice(7) : rawModel;
126
+ const resolvedBaseUrl = cfg?.provider?.baseUrl || providerMeta?.baseUrl || (isLocal ? "http://localhost:11434/v1" : void 0);
127
+ const THINKING_BUDGET = {
128
+ high: 1e4,
129
+ medium: 4e3,
130
+ low: 1e3,
131
+ none: 0
132
+ };
133
+ const thinkingBudget = THINKING_BUDGET[opts.thinking ?? "none"] ?? 0;
134
+ const maxTokens = thinkingBudget > 0 ? thinkingBudget + 4096 : 4096;
135
+ const context = await require_engine.loadWorkspaceContext(opts.workspace) + await require_engine.loadSkillsContext();
136
+ const tools = await require_engine.resolveTools({
137
+ config: cfg,
138
+ source: "cli",
139
+ elevated: true,
140
+ daemonMode: false
141
+ });
142
+ const engineOpts = {
143
+ model,
144
+ apiKey,
145
+ provider,
146
+ system: context || void 0,
147
+ tools,
148
+ maxTokens,
149
+ onToken: () => {},
150
+ ...provider === "custom" ? { baseUrl: resolvedBaseUrl || "" } : {},
151
+ ...thinkingBudget > 0 && model.includes("claude") ? { thinking: { budget_tokens: thinkingBudget } } : {}
152
+ };
153
+ const sessionId = opts.sessionId ?? makeSessionId();
154
+ const messages = [];
155
+ printHeader(rawModel, sessionId);
156
+ const rl = readline.default.createInterface({
157
+ input: process.stdin,
158
+ output: process.stdout,
159
+ terminal: true
160
+ });
161
+ rl.on("SIGINT", () => {
162
+ console.log(chalk.default.gray("\n\n Bye!\n"));
163
+ rl.close();
164
+ process.exit(0);
165
+ });
166
+ const prompt = () => {
167
+ rl.question(chalk.default.bold.green(" You › "), async (input) => {
168
+ const text = input.trim();
169
+ if (!text) {
170
+ prompt();
171
+ return;
172
+ }
173
+ if ([
174
+ "/exit",
175
+ "/quit",
176
+ "/bye",
177
+ "exit",
178
+ "quit",
179
+ "bye"
180
+ ].includes(text.toLowerCase())) {
181
+ console.log(chalk.default.gray("\n Bye!\n"));
182
+ rl.close();
183
+ process.exit(0);
184
+ }
185
+ if (text === "/help") {
186
+ printHelp();
187
+ prompt();
188
+ return;
189
+ }
190
+ if (text === "/skills") {
191
+ await printSkills();
192
+ prompt();
193
+ return;
194
+ }
195
+ if (text === "/model") {
196
+ console.log(chalk.default.gray(`\n Model: ${rawModel}\n`));
197
+ prompt();
198
+ return;
199
+ }
200
+ if (text === "/clear") {
201
+ messages.length = 0;
202
+ console.log(chalk.default.gray("\n Conversation cleared.\n"));
203
+ prompt();
204
+ return;
205
+ }
206
+ messages.push({
207
+ role: "user",
208
+ content: text
209
+ });
210
+ const spinner = (0, ora.default)({
211
+ text: chalk.default.gray("Thinking..."),
212
+ color: "cyan",
213
+ prefixText: " "
214
+ }).start();
215
+ let responseText = "";
216
+ try {
217
+ const engine = new require_inference.InferenceEngine({
218
+ ...engineOpts,
219
+ onToken: (token) => {
220
+ if (spinner.isSpinning) spinner.stop();
221
+ process.stdout.write(token);
222
+ },
223
+ onToolCall: (name) => {
224
+ if (spinner.isSpinning) spinner.stop();
225
+ console.log(chalk.default.gray(`\n [tool: ${name}]`));
226
+ }
227
+ });
228
+ spinner.stop();
229
+ process.stdout.write(chalk.default.bold.blue("\n Agent › "));
230
+ const result = await engine.run(messages);
231
+ responseText = result.text || "";
232
+ if (!responseText && !result.text) process.stdout.write(chalk.default.gray("(empty)"));
233
+ console.log("\n");
234
+ if (result.usage) console.log(chalk.default.gray(` Tokens — in: ${result.usage.input} out: ${result.usage.output}\n`));
235
+ } catch (e) {
236
+ spinner.stop();
237
+ responseText = `Error: ${e.message}`;
238
+ console.log(chalk.default.red(`\n Error: ${e.message}\n`));
239
+ }
240
+ if (responseText) messages.push({
241
+ role: "assistant",
242
+ content: responseText
243
+ });
244
+ try {
245
+ const { AutoMemory } = await Promise.resolve().then(() => require("./src-BbPa6Q8p.js"));
246
+ const mem = new AutoMemory({ extractEveryNTurns: 3 });
247
+ mem.addTurn("user", text);
248
+ if (responseText) mem.addTurn("assistant", responseText);
249
+ mem.extract().catch(() => {});
250
+ } catch {}
251
+ prompt();
252
+ });
253
+ };
254
+ prompt();
255
+ }
256
+
257
+ //#endregion
258
+ exports.runChat = runChat;
@@ -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,162 @@
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/instagram/src/connector.ts
10
+ const STATE_FILE = path.default.join(os.default.homedir(), ".hyperclaw", "instagram-state.json");
11
+ function igReq(token, 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: "graph.facebook.com",
16
+ port: 443,
17
+ path: `/v18.0${endpoint}`,
18
+ method,
19
+ headers: {
20
+ "Authorization": `Bearer ${token}`,
21
+ ...payload ? {
22
+ "Content-Type": "application/json",
23
+ "Content-Length": Buffer.byteLength(payload)
24
+ } : {}
25
+ }
26
+ }, (res) => {
27
+ let data = "";
28
+ res.on("data", (c) => data += c);
29
+ res.on("end", () => {
30
+ try {
31
+ const r = JSON.parse(data);
32
+ if (r.error) reject(new Error(r.error.message));
33
+ else resolve(r);
34
+ } catch {
35
+ reject(new Error("Invalid JSON"));
36
+ }
37
+ });
38
+ });
39
+ req.on("error", reject);
40
+ if (payload) req.write(payload);
41
+ req.end();
42
+ });
43
+ }
44
+ var InstagramConnector = class extends events.EventEmitter {
45
+ config;
46
+ running = false;
47
+ processedIds = /* @__PURE__ */ new Set();
48
+ constructor(config) {
49
+ super();
50
+ this.config = {
51
+ dmPolicy: "allowlist",
52
+ allowFrom: [],
53
+ approvedPairings: [],
54
+ pendingPairings: {},
55
+ ...config
56
+ };
57
+ }
58
+ async connect() {
59
+ const info = await igReq(this.config.pageAccessToken, "GET", `/${this.config.instagramAccountId}?fields=name,username`);
60
+ await this.loadState();
61
+ this.running = true;
62
+ console.log(chalk.default.green(` 🦅 Instagram: @${info.username || info.name} connected`));
63
+ this.emit("connected", {
64
+ accountId: this.config.instagramAccountId,
65
+ username: info.username
66
+ });
67
+ }
68
+ disconnect() {
69
+ this.running = false;
70
+ }
71
+ verifyWebhook(mode, token, challenge) {
72
+ return mode === "subscribe" && token === this.config.verifyToken ? challenge : null;
73
+ }
74
+ async handleWebhook(body) {
75
+ let payload;
76
+ try {
77
+ payload = JSON.parse(body);
78
+ } catch {
79
+ return;
80
+ }
81
+ for (const entry of payload.entry || []) for (const messaging of entry.messaging || []) {
82
+ if (!messaging.message || messaging.message.is_echo) continue;
83
+ const msgId = messaging.message.mid;
84
+ if (this.processedIds.has(msgId)) continue;
85
+ this.processedIds.add(msgId);
86
+ const senderId = messaging.sender.id;
87
+ const text = messaging.message.text;
88
+ if (!text) continue;
89
+ const allowed = await this.checkDMPolicy(senderId, text);
90
+ if (!allowed) continue;
91
+ this.emit("message", {
92
+ id: msgId,
93
+ channelId: "instagram",
94
+ from: senderId,
95
+ chatId: senderId,
96
+ text,
97
+ timestamp: new Date(messaging.timestamp).toISOString(),
98
+ isDM: true
99
+ });
100
+ }
101
+ }
102
+ async checkDMPolicy(from, text) {
103
+ if (this.config.dmPolicy === "none") return false;
104
+ if (this.config.dmPolicy === "open") return true;
105
+ if (this.config.dmPolicy === "allowlist") {
106
+ if (this.config.allowFrom.includes(from)) return true;
107
+ await this.sendMessage(from, "🦅 HyperClaw: You are not on the allowlist.");
108
+ return false;
109
+ }
110
+ if (this.config.dmPolicy === "pairing") {
111
+ if (this.config.approvedPairings.includes(from)) return true;
112
+ const upper = text.trim().toUpperCase();
113
+ if (this.config.pendingPairings[upper]) {
114
+ this.config.approvedPairings.push(from);
115
+ delete this.config.pendingPairings[upper];
116
+ await this.saveState();
117
+ await this.sendMessage(from, "🦅 Paired! You can now send messages.");
118
+ return true;
119
+ }
120
+ const code = Array.from({ length: 6 }, () => "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"[Math.floor(Math.random() * 32)]).join("");
121
+ this.config.pendingPairings[code] = from;
122
+ await this.saveState();
123
+ await this.sendMessage(from, `🦅 HyperClaw Pairing\nCode: ${code}\nApprove: hyperclaw pairing approve instagram ${code}`);
124
+ return false;
125
+ }
126
+ return false;
127
+ }
128
+ async sendMessage(recipientId, text) {
129
+ await igReq(this.config.pageAccessToken, "POST", `/${this.config.instagramAccountId}/messages`, {
130
+ recipient: { id: recipientId },
131
+ message: { text: text.slice(0, 2e3) }
132
+ });
133
+ }
134
+ approvePairing(code) {
135
+ const upper = code.toUpperCase();
136
+ if (!this.config.pendingPairings[upper]) return false;
137
+ this.config.approvedPairings.push(this.config.pendingPairings[upper]);
138
+ delete this.config.pendingPairings[upper];
139
+ this.saveState();
140
+ return true;
141
+ }
142
+ async loadState() {
143
+ try {
144
+ const s = await fs_extra.default.readJson(STATE_FILE);
145
+ if (s.p) this.config.pendingPairings = s.p;
146
+ if (s.a) this.config.approvedPairings = s.a;
147
+ } catch {}
148
+ }
149
+ async saveState() {
150
+ await fs_extra.default.ensureDir(path.default.dirname(STATE_FILE));
151
+ await fs_extra.default.writeJson(STATE_FILE, {
152
+ p: this.config.pendingPairings,
153
+ a: this.config.approvedPairings
154
+ }, { spaces: 2 });
155
+ }
156
+ isRunning() {
157
+ return this.running;
158
+ }
159
+ };
160
+
161
+ //#endregion
162
+ exports.InstagramConnector = InstagramConnector;