hyperclaw 5.2.8 → 5.3.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 (160) hide show
  1. package/dist/a2ui-protocol-DEsfqO7h.js +75 -0
  2. package/dist/agents-routing-ChorJKFL.js +6 -0
  3. package/dist/agents-routing-Cpg20-1e.js +398 -0
  4. package/dist/api-key-validation-DgOBmp8Y.js +64 -0
  5. package/dist/api-keys-guide--73Bq0Ey.js +149 -0
  6. package/dist/audit-Dntx9fG9.js +445 -0
  7. package/dist/banner-B_rR7FPO.js +7 -0
  8. package/dist/banner-Bb7CderS.js +143 -0
  9. package/dist/banner-BbUkjcoX.js +7 -0
  10. package/dist/banner-DupxNjxh.js +143 -0
  11. package/dist/bounty-tools-Dn9Yq7V1.js +211 -0
  12. package/dist/browser-tools-CJ9M9o22.js +179 -0
  13. package/dist/browser-tools-CXxWxA1c.js +5 -0
  14. package/dist/chat-D1Zc73I5.js +513 -0
  15. package/dist/chat-TGA-UO46.js +536 -0
  16. package/dist/claw-tasks-ChqkHdFs.js +80 -0
  17. package/dist/config-Bzues-G2.js +7 -0
  18. package/dist/config-DGAAJ49A.js +261 -0
  19. package/dist/connector-1efnZgQN.js +566 -0
  20. package/dist/connector-B5q1_srT.js +286 -0
  21. package/dist/connector-BMFLJ4fr.js +508 -0
  22. package/dist/connector-BZYv9siY.js +189 -0
  23. package/dist/connector-B_XkXm-j.js +218 -0
  24. package/dist/connector-BkY1I6gf.js +189 -0
  25. package/dist/connector-C2Z3RN1z.js +350 -0
  26. package/dist/connector-C7aYvVzU.js +225 -0
  27. package/dist/connector-CXXYOyHw.js +164 -0
  28. package/dist/connector-Ca1J23HX.js +167 -0
  29. package/dist/connector-Cjqc656I.js +181 -0
  30. package/dist/connector-CluRienN.js +425 -0
  31. package/dist/connector-CuNz2eP-.js +305 -0
  32. package/dist/connector-DHL_oeHy.js +552 -0
  33. package/dist/connector-DJ79rd1L.js +173 -0
  34. package/dist/connector-DcLE6xCZ.js +239 -0
  35. package/dist/connector-DcyQTJnJ.js +162 -0
  36. package/dist/connector-DgyX9qSc.js +192 -0
  37. package/dist/connector-DnDXXZ7L.js +182 -0
  38. package/dist/connector-DqUslg-X.js +213 -0
  39. package/dist/connector-Duc-HmRZ.js +85 -0
  40. package/dist/connector-IV0QFer8.js +498 -0
  41. package/dist/connector-OnsLxE8G.js +194 -0
  42. package/dist/connector-UYu_TS0X.js +204 -0
  43. package/dist/connector-cCA5ffmp.js +340 -0
  44. package/dist/connector-fbNfx4_L.js +568 -0
  45. package/dist/connector-fi2vlwbO.js +276 -0
  46. package/dist/connector-l3LD8IDN.js +419 -0
  47. package/dist/cost-tracker-DCXDUzBI.js +103 -0
  48. package/dist/credentials-store-Bmm9e1SS.js +7 -0
  49. package/dist/credentials-store-D8ERbGR2.js +89 -0
  50. package/dist/cron-tasks-OQbgmenS.js +85 -0
  51. package/dist/daemon-BgT541y-.js +421 -0
  52. package/dist/daemon-aVX-WGz1.js +421 -0
  53. package/dist/daemon-iFmVBPXN.js +7 -0
  54. package/dist/daemon-iM7U3tDr.js +7 -0
  55. package/dist/delivery-Pko6sSkt.js +4 -0
  56. package/dist/delivery-hMHFRZwy.js +95 -0
  57. package/dist/destructive-gate-C2TrWsp2.js +101 -0
  58. package/dist/developer-keys-BWXHaWxY.js +127 -0
  59. package/dist/developer-keys-CzDxVczE.js +8 -0
  60. package/dist/device-auth-store-C1bCwXO2.js +7 -0
  61. package/dist/device-auth-store-DIZTOz4V.js +88 -0
  62. package/dist/doctor-C6nAGdH8.js +233 -0
  63. package/dist/doctor-mgWumA25.js +6 -0
  64. package/dist/engine-BGRTi0fo.js +327 -0
  65. package/dist/engine-BrDEACit.js +327 -0
  66. package/dist/engine-BvCEhaUn.js +7 -0
  67. package/dist/engine-DrsMsoLZ.js +7 -0
  68. package/dist/env-resolve-CHxjGo8u.js +151 -0
  69. package/dist/env-resolve-pIETNTpQ.js +10 -0
  70. package/dist/extraction-tools-BE6z_Yw5.js +91 -0
  71. package/dist/extraction-tools-CJsdyBST.js +5 -0
  72. package/dist/form_data-B2_0EoWj.js +8657 -0
  73. package/dist/gmail-watch-setup-1RGIHNdu.js +42 -0
  74. package/dist/health-BMUmUNoe.js +152 -0
  75. package/dist/health-C8n9RH5O.js +6 -0
  76. package/dist/heartbeat-engine-aRbab8a5.js +89 -0
  77. package/dist/hub-BJM2KXLO.js +6 -0
  78. package/dist/hub-Bb_dYECE.js +512 -0
  79. package/dist/hyperclawbot-CZ4DjvO-.js +516 -0
  80. package/dist/hyperclawbot-CgrV46DA.js +516 -0
  81. package/dist/inference-CFBkvLpE.js +2854 -0
  82. package/dist/inference-G4MbdErG.js +8 -0
  83. package/dist/knowledge-graph-9UNrsiIY.js +134 -0
  84. package/dist/loader-DIPs649t.js +410 -0
  85. package/dist/loader-Dq_cDlOW.js +6 -0
  86. package/dist/logger-CG38Idq4.js +86 -0
  87. package/dist/manager--wG9JdFW.js +120 -0
  88. package/dist/manager-BNc21xgG.js +6 -0
  89. package/dist/manager-DWJ7WZcY.js +250 -0
  90. package/dist/manager-DYfzqckn.js +35 -0
  91. package/dist/mcp-SsMEvl28.js +142 -0
  92. package/dist/mcp-loader-CVhiejBN.js +93 -0
  93. package/dist/mcp-loader-DLrp_oZJ.js +93 -0
  94. package/dist/memory-BCYvdqwo.js +273 -0
  95. package/dist/memory-BGgCBSx1.js +6 -0
  96. package/dist/memory-auto-Bh52cQJP.js +5 -0
  97. package/dist/memory-auto-BupvVwNd.js +306 -0
  98. package/dist/memory-integration-4oGqX6rr.js +91 -0
  99. package/dist/moltbook-B3DNdh40.js +81 -0
  100. package/dist/node-C4esBfbX.js +226 -0
  101. package/dist/nodes-registry-DLUZhEMS.js +52 -0
  102. package/dist/oauth-flow-BbLQTzZk.js +148 -0
  103. package/dist/oauth-provider-UZyG84s7.js +111 -0
  104. package/dist/observability-BtLyuxcz.js +89 -0
  105. package/dist/onboard-B3drurt-.js +3812 -0
  106. package/dist/onboard-CSJuvkMN.js +14 -0
  107. package/dist/onboard-DEwuHrMj.js +14 -0
  108. package/dist/onboard-eIxjVYKi.js +3812 -0
  109. package/dist/orchestrator-BXyIgAeH.js +189 -0
  110. package/dist/orchestrator-Cgj-8BbJ.js +189 -0
  111. package/dist/orchestrator-MLTc4NYu.js +6 -0
  112. package/dist/orchestrator-PLHfNTD6.js +6 -0
  113. package/dist/osint-Bsf6RGPv.js +283 -0
  114. package/dist/osint-CMyamX3_.js +283 -0
  115. package/dist/osint-chat-Ark94iFc.js +789 -0
  116. package/dist/osint-chat-D_6Fb27C.js +789 -0
  117. package/dist/pairing-2vAiDBjN.js +6 -0
  118. package/dist/pairing-B4NoBvyE.js +207 -0
  119. package/dist/pc-access-BLnc-DYp.js +858 -0
  120. package/dist/pc-access-CTNtG2LD.js +8 -0
  121. package/dist/pending-approval-C4ZaHHWl.js +22 -0
  122. package/dist/reminders-store-BixTWL1h.js +58 -0
  123. package/dist/renderer-B1ToXngl.js +228 -0
  124. package/dist/rules-Cqen1Mpt.js +106 -0
  125. package/dist/run-main.js +101 -95
  126. package/dist/runner-Cr1_mwnU.js +1274 -0
  127. package/dist/security-B4vH02lO.js +4 -0
  128. package/dist/security-HOOGCw5z.js +90 -0
  129. package/dist/server-B9rMYJwV.js +4 -0
  130. package/dist/server-CRhXiGI9.js +4 -0
  131. package/dist/server-DMC1wOsc.js +1365 -0
  132. package/dist/server-De4H45Ju.js +1365 -0
  133. package/dist/session-store-7sEPyV16.js +5 -0
  134. package/dist/session-store-Ce2QMSL_.js +141 -0
  135. package/dist/sessions-tools-CWr_pDtp.js +5 -0
  136. package/dist/sessions-tools-DKVu9aIN.js +95 -0
  137. package/dist/skill-loader-DK19Jm4e.js +7 -0
  138. package/dist/skill-loader-Dfs9VNM-.js +160 -0
  139. package/dist/skill-runtime-BeKh2rD_.js +5 -0
  140. package/dist/skill-runtime-CcpC2Zfc.js +104 -0
  141. package/dist/skill-runtime-CzsUymMA.js +104 -0
  142. package/dist/skill-runtime-DAP0Gs_7.js +5 -0
  143. package/dist/src-BxmkZ9RH.js +63 -0
  144. package/dist/src-CvJOtJlj.js +458 -0
  145. package/dist/src-DjTtmSRg.js +20 -0
  146. package/dist/src-cowbRb9x.js +63 -0
  147. package/dist/src-n_46LPDi.js +458 -0
  148. package/dist/sub-agent-tools-CIA8mqjv.js +39 -0
  149. package/dist/sub-agent-tools-q5JqEze_.js +39 -0
  150. package/dist/tool-policy-QXF3MMxu.js +189 -0
  151. package/dist/tts-elevenlabs-y6HGWWDS.js +64 -0
  152. package/dist/update-check-C4te7JmY.js +6 -0
  153. package/dist/update-check-GDue_it1.js +98 -0
  154. package/dist/vision-tools-CbVfyTZT.js +5 -0
  155. package/dist/vision-tools-DieVQp6s.js +51 -0
  156. package/dist/vision-u4kMThdo.js +167 -0
  157. package/dist/voice-transcription-DgON5qaF.js +170 -0
  158. package/dist/website-watch-tools-B8L_NgwT.js +5 -0
  159. package/dist/website-watch-tools-Drm5HjIX.js +176 -0
  160. package/package.json +1 -1
@@ -0,0 +1,189 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+
3
+ //#region src/infra/tool-policy.ts
4
+ function expandToToolNames(entries) {
5
+ const out = /* @__PURE__ */ new Set();
6
+ for (const e of entries) {
7
+ const key = e.toLowerCase().trim();
8
+ if (key === "*" || key === "") continue;
9
+ if (key.startsWith("group:")) {
10
+ const group = TOOL_GROUPS[key];
11
+ if (group) group.forEach((t) => out.add(t));
12
+ } else out.add(key);
13
+ }
14
+ return out;
15
+ }
16
+ function matchesPattern(toolName, pattern) {
17
+ const p = pattern.toLowerCase();
18
+ const t = toolName.toLowerCase();
19
+ if (p === "*" || p === t) return true;
20
+ if (p.endsWith("*")) {
21
+ const prefix = p.slice(0, -1);
22
+ return t.startsWith(prefix);
23
+ }
24
+ return false;
25
+ }
26
+ function isAllowed(toolName, allowSet, denySet, profileAllowSet) {
27
+ if (denySet.size > 0) {
28
+ for (const d of denySet) if (matchesPattern(toolName, d)) return false;
29
+ }
30
+ if (profileAllowSet && profileAllowSet.size > 0) {
31
+ let inProfile = false;
32
+ for (const a of profileAllowSet) if (matchesPattern(toolName, a)) {
33
+ inProfile = true;
34
+ break;
35
+ }
36
+ if (!inProfile) return false;
37
+ }
38
+ if (allowSet.size > 0) {
39
+ for (const a of allowSet) if (matchesPattern(toolName, a)) return true;
40
+ return false;
41
+ }
42
+ return true;
43
+ }
44
+ function applyToolPolicy(tools, config, context) {
45
+ if (!config) return tools;
46
+ let profile = config.profile ?? "full";
47
+ let allow = config.allow ?? [];
48
+ let deny = config.deny ?? [];
49
+ if (context?.provider && config.byProvider) {
50
+ const providerKey = context.provider + (context.model ? "/" + context.model : "");
51
+ const exact = config.byProvider[providerKey] ?? config.byProvider[context.provider];
52
+ if (exact) {
53
+ if (exact.profile) profile = exact.profile;
54
+ if (exact.allow?.length) allow = [...allow, ...exact.allow];
55
+ if (exact.deny?.length) deny = [...deny, ...exact.deny];
56
+ }
57
+ }
58
+ const denySet = expandToToolNames(deny);
59
+ const allowSet = expandToToolNames(allow);
60
+ const profileTools = profile === "full" ? null : new Set(PROFILE_TOOLS[profile]);
61
+ return tools.filter((t) => isAllowed(t.name, allowSet, denySet, profileTools));
62
+ }
63
+ /** For sandbox explain: return effective policy description. */
64
+ function describeToolPolicy(config, context) {
65
+ if (!config) return {
66
+ profile: "full",
67
+ allow: [],
68
+ deny: [],
69
+ source: "default"
70
+ };
71
+ let profile = config.profile ?? "full";
72
+ let allow = config.allow ?? [];
73
+ let deny = config.deny ?? [];
74
+ let source = "tools";
75
+ if (context?.provider && config.byProvider) {
76
+ const providerKey = context.provider + (context.model ? "/" + context.model : "");
77
+ const exact = config.byProvider[providerKey] ?? config.byProvider[context.provider];
78
+ if (exact) {
79
+ if (exact.profile) {
80
+ profile = exact.profile;
81
+ source = `tools.byProvider[${context.provider}]`;
82
+ }
83
+ if (exact.allow?.length) allow = [...allow, ...exact.allow];
84
+ if (exact.deny?.length) deny = [...deny, ...exact.deny];
85
+ }
86
+ }
87
+ return {
88
+ profile,
89
+ allow,
90
+ deny,
91
+ source
92
+ };
93
+ }
94
+ var TOOL_GROUPS, PROFILE_TOOLS;
95
+ var init_tool_policy = require_chunk.__esm({ "src/infra/tool-policy.ts"() {
96
+ TOOL_GROUPS = {
97
+ "group:fs": [
98
+ "read_file",
99
+ "write_file",
100
+ "edit_file",
101
+ "delete_file",
102
+ "list_directory"
103
+ ],
104
+ "group:runtime": ["run_shell", "kill_process"],
105
+ "group:sessions": [
106
+ "sessions_list",
107
+ "sessions_send",
108
+ "sessions_history"
109
+ ],
110
+ "group:memory": [
111
+ "read_memory",
112
+ "write_memory",
113
+ "memory_graph_add",
114
+ "memory_graph_query"
115
+ ],
116
+ "group:ui": [
117
+ "canvas_add",
118
+ "browser_snapshot",
119
+ "browser_action"
120
+ ],
121
+ "group:messaging": [
122
+ "sessions_send",
123
+ "sessions_list",
124
+ "sessions_history"
125
+ ],
126
+ "group:automation": [
127
+ "add_reminder",
128
+ "list_reminders",
129
+ "complete_reminder",
130
+ "watch_website_add",
131
+ "watch_website_check",
132
+ "watch_website_list"
133
+ ],
134
+ "group:pc": [
135
+ "run_shell",
136
+ "read_file",
137
+ "write_file",
138
+ "edit_file",
139
+ "list_directory",
140
+ "delete_file",
141
+ "kill_process",
142
+ "system_info",
143
+ "open",
144
+ "clipboard",
145
+ "search_files",
146
+ "screenshot",
147
+ "camera_capture",
148
+ "screen_record",
149
+ "contacts_list",
150
+ "calendar_events",
151
+ "photos_recent",
152
+ "app_updates",
153
+ "notify"
154
+ ],
155
+ "group:extraction": ["extract_pdf", "extract_spreadsheet"],
156
+ "group:vision": ["analyze_image"]
157
+ };
158
+ PROFILE_TOOLS = {
159
+ full: [],
160
+ messaging: [
161
+ "get_current_time",
162
+ "sessions_list",
163
+ "sessions_history",
164
+ "sessions_send",
165
+ "read_memory",
166
+ "write_memory"
167
+ ],
168
+ coding: [
169
+ ...TOOL_GROUPS["group:fs"],
170
+ ...TOOL_GROUPS["group:runtime"],
171
+ ...TOOL_GROUPS["group:sessions"],
172
+ ...TOOL_GROUPS["group:memory"],
173
+ "http_get",
174
+ "canvas_add",
175
+ "create_skill",
176
+ "get_current_time"
177
+ ],
178
+ minimal: [
179
+ "get_current_time",
180
+ "sessions_list",
181
+ "read_memory"
182
+ ]
183
+ };
184
+ } });
185
+
186
+ //#endregion
187
+ init_tool_policy();
188
+ exports.applyToolPolicy = applyToolPolicy;
189
+ exports.describeToolPolicy = describeToolPolicy;
@@ -0,0 +1,64 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const https = require_chunk.__toESM(require("https"));
3
+
4
+ //#region src/services/tts-elevenlabs.ts
5
+ const DEFAULT_VOICE = "21m00Tcm4TlvDq8ikWAM";
6
+ const DEFAULT_MODEL = "eleven_multilingual_v2";
7
+ function sanitizeForLog(value) {
8
+ return String(value ?? "").replace(/[\r\n\t]+/g, " ").replace(/[^\x20-\x7e]+/g, "?").slice(0, 200);
9
+ }
10
+ /**
11
+
12
+ * Convert text to speech via ElevenLabs API.
13
+
14
+ * Returns base64-encoded MP3 or null on error.
15
+
16
+ */
17
+ async function textToSpeech(text, opts) {
18
+ const voiceId = opts.voiceId || DEFAULT_VOICE;
19
+ const modelId = opts.modelId || DEFAULT_MODEL;
20
+ const format = opts.outputFormat || "mp3_22050_32";
21
+ const body = JSON.stringify({
22
+ text,
23
+ model_id: modelId
24
+ });
25
+ const path = `/v1/text-to-speech/${voiceId}?output_format=${format}`;
26
+ return new Promise((resolve) => {
27
+ const req = https.default.request({
28
+ hostname: "api.elevenlabs.io",
29
+ port: 443,
30
+ path,
31
+ method: "POST",
32
+ headers: {
33
+ "Content-Type": "application/json",
34
+ "xi-api-key": opts.apiKey,
35
+ "Content-Length": Buffer.byteLength(body)
36
+ }
37
+ }, (res) => {
38
+ const chunks = [];
39
+ res.on("data", (c) => chunks.push(c));
40
+ res.on("end", () => {
41
+ const buf = Buffer.concat(chunks);
42
+ if (res.statusCode !== 200) {
43
+ console.warn(`[tts] ElevenLabs error ${res.statusCode}: ${sanitizeForLog(buf.toString("utf8", 0, 200))}`);
44
+ resolve(null);
45
+ return;
46
+ }
47
+ resolve(buf.toString("base64"));
48
+ });
49
+ });
50
+ req.on("error", (e) => {
51
+ console.warn("[tts] ElevenLabs request error:", sanitizeForLog(e.message));
52
+ resolve(null);
53
+ });
54
+ req.setTimeout(3e4, () => {
55
+ req.destroy();
56
+ resolve(null);
57
+ });
58
+ req.write(body);
59
+ req.end();
60
+ });
61
+ }
62
+
63
+ //#endregion
64
+ exports.textToSpeech = textToSpeech;
@@ -0,0 +1,6 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_update_check = require('./update-check-GDue_it1.js');
3
+
4
+ exports.checkForUpdates = require_update_check.checkForUpdates;
5
+ exports.maybeShowUpdateNotice = require_update_check.maybeShowUpdateNotice;
6
+ exports.notifyUpdateAvailable = require_update_check.notifyUpdateAvailable;
@@ -0,0 +1,98 @@
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 https = require_chunk.__toESM(require("https"));
6
+
7
+ //#region src/infra/update-check.ts
8
+ const NPM_REGISTRY = "https://registry.npmjs.org";
9
+ const PACKAGE_NAME = "hyperclaw";
10
+ function parseVersion(v) {
11
+ const match = v.replace(/^v/, "").match(/^(\d+)\.(\d+)\.(\d+)/);
12
+ if (!match) return [
13
+ 0,
14
+ 0,
15
+ 0
16
+ ];
17
+ return [
18
+ parseInt(match[1], 10),
19
+ parseInt(match[2], 10),
20
+ parseInt(match[3], 10)
21
+ ];
22
+ }
23
+ function isNewer(latest, current) {
24
+ const a = parseVersion(latest);
25
+ const b = parseVersion(current);
26
+ for (let i = 0; i < 3; i++) {
27
+ if (a[i] > b[i]) return true;
28
+ if (a[i] < b[i]) return false;
29
+ }
30
+ return false;
31
+ }
32
+ async function checkForUpdates(currentVersion) {
33
+ if (process.env.HYPERCLAW_NO_UPDATE_CHECK === "1") return null;
34
+ return new Promise((resolve) => {
35
+ const req = https.default.get(`${NPM_REGISTRY}/${PACKAGE_NAME}/latest`, { timeout: 3e3 }, (res) => {
36
+ let data = "";
37
+ res.on("data", (chunk) => data += chunk);
38
+ res.on("end", () => {
39
+ try {
40
+ const json = JSON.parse(data);
41
+ const latest = json?.version;
42
+ if (!latest || typeof latest !== "string") {
43
+ resolve(null);
44
+ return;
45
+ }
46
+ resolve({
47
+ latest,
48
+ available: isNewer(latest, currentVersion)
49
+ });
50
+ } catch {
51
+ resolve(null);
52
+ }
53
+ });
54
+ });
55
+ req.on("error", () => resolve(null));
56
+ req.on("timeout", () => {
57
+ req.destroy();
58
+ resolve(null);
59
+ });
60
+ });
61
+ }
62
+ function notifyUpdateAvailable(current, latest) {
63
+ console.log(chalk.default.yellow(` 🦅 Update available: ${latest} (you have ${current})`));
64
+ console.log(chalk.default.gray(" Run: npm i -g hyperclaw\n"));
65
+ }
66
+ /** Fire-and-forget: check for updates and notify user if available. Call after banner/startup. */
67
+ function maybeShowUpdateNotice(skipInDaemon = false) {
68
+ if (skipInDaemon) return;
69
+ (async () => {
70
+ try {
71
+ const pkgPath = path.default.join(__dirname, "../package.json");
72
+ const pkg = await fs_extra.default.readJson(pkgPath).catch(() => null);
73
+ const current = pkg?.version ?? "0.0.0";
74
+ const result = await checkForUpdates(current);
75
+ if (result?.available) notifyUpdateAvailable(current, result.latest);
76
+ } catch {}
77
+ })().catch(() => {});
78
+ }
79
+
80
+ //#endregion
81
+ Object.defineProperty(exports, 'checkForUpdates', {
82
+ enumerable: true,
83
+ get: function () {
84
+ return checkForUpdates;
85
+ }
86
+ });
87
+ Object.defineProperty(exports, 'maybeShowUpdateNotice', {
88
+ enumerable: true,
89
+ get: function () {
90
+ return maybeShowUpdateNotice;
91
+ }
92
+ });
93
+ Object.defineProperty(exports, 'notifyUpdateAvailable', {
94
+ enumerable: true,
95
+ get: function () {
96
+ return notifyUpdateAvailable;
97
+ }
98
+ });
@@ -0,0 +1,5 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const require_vision_tools = require('./vision-tools-DieVQp6s.js');
3
+
4
+ require_vision_tools.init_vision_tools();
5
+ exports.getVisionTools = require_vision_tools.getVisionTools;
@@ -0,0 +1,51 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+
3
+ //#region packages/core/src/agent/vision-tools.ts
4
+ function getVisionTools(opts = {}) {
5
+ const { apiKey = "", provider = "anthropic" } = opts;
6
+ return [{
7
+ name: "analyze_image",
8
+ description: "Analyze an image using a vision model. Describe scenes, receipts, documents, photos. Supports file path, URL, or data URI.",
9
+ input_schema: {
10
+ type: "object",
11
+ properties: {
12
+ image: {
13
+ type: "string",
14
+ description: "Image path (~/path), URL (https://...), or data:image/...;base64,..."
15
+ },
16
+ prompt: {
17
+ type: "string",
18
+ description: "What to describe or extract (e.g. \"Describe this scene\", \"List items on this receipt\")"
19
+ }
20
+ },
21
+ required: ["image"]
22
+ },
23
+ handler: async (input) => {
24
+ if (!apiKey) return "Error: No API key configured for vision. Set provider.apiKey or run hyperclaw auth add.";
25
+ const image = input.image?.trim();
26
+ const prompt = input.prompt?.trim() || "Describe this image concisely.";
27
+ if (!image) return "Error: image is required";
28
+ try {
29
+ const { analyzeImage } = await Promise.resolve().then(() => require("./vision-u4kMThdo.js"));
30
+ return await analyzeImage(image, prompt, apiKey, provider);
31
+ } catch (e) {
32
+ return `Error: ${e.message}`;
33
+ }
34
+ }
35
+ }];
36
+ }
37
+ var init_vision_tools = require_chunk.__esm({ "packages/core/src/agent/vision-tools.ts"() {} });
38
+
39
+ //#endregion
40
+ Object.defineProperty(exports, 'getVisionTools', {
41
+ enumerable: true,
42
+ get: function () {
43
+ return getVisionTools;
44
+ }
45
+ });
46
+ Object.defineProperty(exports, 'init_vision_tools', {
47
+ enumerable: true,
48
+ get: function () {
49
+ return init_vision_tools;
50
+ }
51
+ });
@@ -0,0 +1,167 @@
1
+ const require_chunk = require('./chunk-jS-bbMI5.js');
2
+ const fs_extra = require_chunk.__toESM(require("fs-extra"));
3
+ const path = require_chunk.__toESM(require("path"));
4
+ const os = require_chunk.__toESM(require("os"));
5
+ const http = require_chunk.__toESM(require("http"));
6
+ const https = require_chunk.__toESM(require("https"));
7
+
8
+ //#region src/services/vision.ts
9
+ function inferImageMediaType(ext) {
10
+ return {
11
+ ".png": "image/png",
12
+ ".jpg": "image/jpeg",
13
+ ".jpeg": "image/jpeg",
14
+ ".gif": "image/gif",
15
+ ".webp": "image/webp"
16
+ }[ext] ?? "image/jpeg";
17
+ }
18
+ async function readValidatedImageFile(filePath) {
19
+ const resolvedPath = path.default.resolve(filePath.replace(/^~/, os.default.homedir()));
20
+ const ext = path.default.extname(resolvedPath).toLowerCase();
21
+ if (!ALLOWED_IMAGE_EXTENSIONS.has(ext)) throw new Error(`Unsupported image file type: ${ext || "unknown"}`);
22
+ const buf = await fs_extra.default.readFile(resolvedPath);
23
+ if (buf.length === 0) throw new Error("Image input is empty");
24
+ if (buf.length > MAX_IMAGE_BYTES) throw new Error(`Image input exceeds ${MAX_IMAGE_BYTES} bytes`);
25
+ return {
26
+ data: buf.toString("base64"),
27
+ mediaType: inferImageMediaType(ext)
28
+ };
29
+ }
30
+ async function fetchValidatedRemoteImage(urlString) {
31
+ const url = new URL(urlString);
32
+ if (!["http:", "https:"].includes(url.protocol)) throw new Error(`Unsupported image URL protocol: ${url.protocol}`);
33
+ const mod = url.protocol === "https:" ? https.default : http.default;
34
+ const buf = await new Promise((resolve, reject) => {
35
+ const req = mod.get(url, (res) => {
36
+ if ((res.statusCode ?? 0) >= 400) {
37
+ reject(new Error(`Image download failed with status ${res.statusCode}`));
38
+ res.resume();
39
+ return;
40
+ }
41
+ const contentLength = Number(res.headers["content-length"] ?? 0);
42
+ if (contentLength > MAX_IMAGE_BYTES) {
43
+ reject(new Error(`Image download exceeds ${MAX_IMAGE_BYTES} bytes`));
44
+ res.destroy();
45
+ return;
46
+ }
47
+ const chunks = [];
48
+ let total = 0;
49
+ res.on("data", (c) => {
50
+ total += c.length;
51
+ if (total > MAX_IMAGE_BYTES) {
52
+ req.destroy(new Error(`Image download exceeds ${MAX_IMAGE_BYTES} bytes`));
53
+ return;
54
+ }
55
+ chunks.push(c);
56
+ });
57
+ res.on("end", () => resolve(Buffer.concat(chunks)));
58
+ res.on("error", reject);
59
+ });
60
+ req.on("error", reject);
61
+ });
62
+ const pathnameExt = path.default.extname(url.pathname).toLowerCase();
63
+ return {
64
+ data: buf.toString("base64"),
65
+ mediaType: inferImageMediaType(ALLOWED_IMAGE_EXTENSIONS.has(pathnameExt) ? pathnameExt : ".jpg")
66
+ };
67
+ }
68
+ async function imageToBase64(input) {
69
+ const trimmed = input.trim();
70
+ if (trimmed.startsWith("data:")) {
71
+ const match = trimmed.match(/^data:(image\/[^;]+);base64,(.+)$/);
72
+ if (match) {
73
+ const buffer = Buffer.from(match[2], "base64");
74
+ if (buffer.length === 0) throw new Error("Image input is empty");
75
+ if (buffer.length > MAX_IMAGE_BYTES) throw new Error(`Image input exceeds ${MAX_IMAGE_BYTES} bytes`);
76
+ return {
77
+ data: match[2],
78
+ mediaType: match[1]
79
+ };
80
+ }
81
+ }
82
+ if (trimmed.startsWith("http")) return fetchValidatedRemoteImage(trimmed);
83
+ return readValidatedImageFile(trimmed);
84
+ }
85
+ async function analyzeImage(imageInput, prompt, apiKey, provider = "anthropic") {
86
+ const { data, mediaType } = await imageToBase64(imageInput);
87
+ const isAnthropic = provider === "anthropic";
88
+ const hostname = isAnthropic ? "api.anthropic.com" : "openrouter.ai";
89
+ const model = isAnthropic ? "claude-sonnet-4-20250514" : "openai/gpt-4o";
90
+ const body = {
91
+ model,
92
+ max_tokens: 1024,
93
+ messages: isAnthropic ? [{
94
+ role: "user",
95
+ content: [{
96
+ type: "image",
97
+ source: {
98
+ type: "base64",
99
+ media_type: mediaType,
100
+ data
101
+ }
102
+ }, {
103
+ type: "text",
104
+ text: prompt || "Describe this image."
105
+ }]
106
+ }] : [{
107
+ role: "user",
108
+ content: [{
109
+ type: "text",
110
+ text: "[Image attached] " + (prompt || "Describe this image.")
111
+ }, {
112
+ type: "image_url",
113
+ image_url: { url: `data:${mediaType};base64,${data}` }
114
+ }]
115
+ }]
116
+ };
117
+ if (isAnthropic) body.anthropic_version = "2023-06-01";
118
+ return new Promise((resolve, reject) => {
119
+ const payload = JSON.stringify(body);
120
+ const req = https.default.request({
121
+ hostname,
122
+ port: 443,
123
+ path: isAnthropic ? "/v1/messages" : "/api/v1/chat/completions",
124
+ method: "POST",
125
+ headers: {
126
+ "Authorization": `Bearer ${apiKey}`,
127
+ "Content-Type": "application/json",
128
+ ...isAnthropic ? { "anthropic-version": "2023-06-01" } : { "HTTP-Referer": "https://hyperclaw.ai" }
129
+ }
130
+ }, (res) => {
131
+ let raw = "";
132
+ res.on("data", (c) => raw += c);
133
+ res.on("end", () => {
134
+ try {
135
+ const j = JSON.parse(raw);
136
+ if (isAnthropic) {
137
+ const text = j.content?.[0]?.text;
138
+ resolve(text || j.error?.message || "(no description)");
139
+ } else {
140
+ const text = j.choices?.[0]?.message?.content;
141
+ resolve(text || j.error?.message || "(no description)");
142
+ }
143
+ } catch {
144
+ resolve(raw || "(parse error)");
145
+ }
146
+ });
147
+ });
148
+ req.on("error", reject);
149
+ req.write(payload);
150
+ req.end();
151
+ });
152
+ }
153
+ var MAX_IMAGE_BYTES, ALLOWED_IMAGE_EXTENSIONS;
154
+ var init_vision = require_chunk.__esm({ "src/services/vision.ts"() {
155
+ MAX_IMAGE_BYTES = 15 * 1024 * 1024;
156
+ ALLOWED_IMAGE_EXTENSIONS = new Set([
157
+ ".png",
158
+ ".jpg",
159
+ ".jpeg",
160
+ ".gif",
161
+ ".webp"
162
+ ]);
163
+ } });
164
+
165
+ //#endregion
166
+ init_vision();
167
+ exports.analyzeImage = analyzeImage;