hyperclaw 5.2.7 → 5.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a2ui-protocol-DEsfqO7h.js +75 -0
- package/dist/agents-routing-Cee7wrfi.js +398 -0
- package/dist/agents-routing-ChorJKFL.js +6 -0
- package/dist/agents-routing-Cpg20-1e.js +398 -0
- package/dist/agents-routing-uNzqjgOr.js +6 -0
- package/dist/api-key-validation-DgOBmp8Y.js +64 -0
- package/dist/api-key-validation-DydlUth1.js +64 -0
- package/dist/api-keys-guide--73Bq0Ey.js +149 -0
- package/dist/api-keys-guide-DqRGa4x7.js +149 -0
- package/dist/audit-CX5poVMR.js +445 -0
- package/dist/audit-Dntx9fG9.js +445 -0
- package/dist/banner-B_rR7FPO.js +7 -0
- package/dist/banner-Bb7CderS.js +143 -0
- package/dist/bounty-tools-BoU1NN5N.js +211 -0
- package/dist/bounty-tools-Dn9Yq7V1.js +211 -0
- package/dist/browser-tools-CJ9M9o22.js +179 -0
- package/dist/browser-tools-CXxWxA1c.js +5 -0
- package/dist/chat-C07wF0mM.js +494 -0
- package/dist/chat-D1Zc73I5.js +513 -0
- package/dist/claw-tasks-BLqd1a0Q.js +80 -0
- package/dist/claw-tasks-ChqkHdFs.js +80 -0
- package/dist/config-BlLlJ6Er.js +7 -0
- package/dist/config-Bzues-G2.js +7 -0
- package/dist/config-DGAAJ49A.js +261 -0
- package/dist/config-SgDxKyfV.js +261 -0
- package/dist/connector-1efnZgQN.js +566 -0
- package/dist/connector-B5q1_srT.js +286 -0
- package/dist/connector-BMFLJ4fr.js +508 -0
- package/dist/connector-BZYv9siY.js +189 -0
- package/dist/connector-B_XkXm-j.js +218 -0
- package/dist/connector-BkY1I6gf.js +189 -0
- package/dist/connector-C2Z3RN1z.js +350 -0
- package/dist/connector-C7aYvVzU.js +225 -0
- package/dist/connector-CXXYOyHw.js +164 -0
- package/dist/connector-Ca1J23HX.js +167 -0
- package/dist/connector-Cjqc656I.js +181 -0
- package/dist/connector-CluRienN.js +425 -0
- package/dist/connector-CuNz2eP-.js +305 -0
- package/dist/connector-DHL_oeHy.js +552 -0
- package/dist/connector-DJ79rd1L.js +173 -0
- package/dist/connector-DcLE6xCZ.js +239 -0
- package/dist/connector-DcyQTJnJ.js +162 -0
- package/dist/connector-DgyX9qSc.js +192 -0
- package/dist/connector-DnDXXZ7L.js +182 -0
- package/dist/connector-DqUslg-X.js +213 -0
- package/dist/connector-Duc-HmRZ.js +85 -0
- package/dist/connector-IV0QFer8.js +498 -0
- package/dist/connector-OnsLxE8G.js +194 -0
- package/dist/connector-UYu_TS0X.js +204 -0
- package/dist/connector-cCA5ffmp.js +340 -0
- package/dist/connector-fbNfx4_L.js +568 -0
- package/dist/connector-fi2vlwbO.js +276 -0
- package/dist/connector-l3LD8IDN.js +419 -0
- package/dist/cost-tracker-CgEXyEtz.js +103 -0
- package/dist/cost-tracker-DCXDUzBI.js +103 -0
- package/dist/credentials-store-1LDtNReY.js +89 -0
- package/dist/credentials-store-BFxEJR00.js +7 -0
- package/dist/credentials-store-Bmm9e1SS.js +7 -0
- package/dist/credentials-store-D8ERbGR2.js +89 -0
- package/dist/cron-tasks-1E6wKpTv.js +85 -0
- package/dist/cron-tasks-OQbgmenS.js +85 -0
- package/dist/daemon-B13UIqvL.js +7 -0
- package/dist/daemon-CzOW-1PS.js +421 -0
- package/dist/daemon-aVX-WGz1.js +421 -0
- package/dist/daemon-iFmVBPXN.js +7 -0
- package/dist/delivery-B8YGmrq5.js +4 -0
- package/dist/delivery-DWsU6gx-.js +95 -0
- package/dist/delivery-Pko6sSkt.js +4 -0
- package/dist/delivery-hMHFRZwy.js +95 -0
- package/dist/destructive-gate-C2TrWsp2.js +101 -0
- package/dist/destructive-gate-bnkroJWG.js +101 -0
- package/dist/developer-keys-BWXHaWxY.js +127 -0
- package/dist/developer-keys-CzDxVczE.js +8 -0
- package/dist/device-auth-store-C1bCwXO2.js +7 -0
- package/dist/device-auth-store-DIZTOz4V.js +88 -0
- package/dist/doctor-C6nAGdH8.js +233 -0
- package/dist/doctor-mgWumA25.js +6 -0
- package/dist/engine-BGRTi0fo.js +327 -0
- package/dist/engine-BvCEhaUn.js +7 -0
- package/dist/engine-ByQ-0sWM.js +7 -0
- package/dist/engine-gnMjO743.js +327 -0
- package/dist/env-resolve-BdagnXhK.js +151 -0
- package/dist/env-resolve-CHxjGo8u.js +151 -0
- package/dist/env-resolve-NEtsGacw.js +10 -0
- package/dist/env-resolve-pIETNTpQ.js +10 -0
- package/dist/extraction-tools-BE6z_Yw5.js +91 -0
- package/dist/extraction-tools-CJsdyBST.js +5 -0
- package/dist/form_data-B2_0EoWj.js +8657 -0
- package/dist/gmail-watch-setup-1RGIHNdu.js +42 -0
- package/dist/gmail-watch-setup-Brkj94Sy.js +42 -0
- package/dist/health-BMUmUNoe.js +152 -0
- package/dist/health-C8n9RH5O.js +6 -0
- package/dist/heartbeat-engine-D6oSpgxx.js +89 -0
- package/dist/heartbeat-engine-aRbab8a5.js +89 -0
- package/dist/hub-BJM2KXLO.js +6 -0
- package/dist/hub-Bb_dYECE.js +512 -0
- package/dist/hyperclawbot-CgrV46DA.js +516 -0
- package/dist/hyperclawbot-DzP_v3iA.js +516 -0
- package/dist/inference-BHJFPEKL.js +8 -0
- package/dist/inference-CFBkvLpE.js +2854 -0
- package/dist/inference-G4MbdErG.js +8 -0
- package/dist/inference-vweXyh27.js +2854 -0
- package/dist/knowledge-graph-9UNrsiIY.js +134 -0
- package/dist/knowledge-graph-yeMPBPP8.js +134 -0
- package/dist/loader-BXYJl25e.js +6 -0
- package/dist/loader-DIPs649t.js +410 -0
- package/dist/loader-Dq_cDlOW.js +6 -0
- package/dist/loader-gTdKBwiI.js +410 -0
- package/dist/logger-C3ZCDSkc.js +86 -0
- package/dist/logger-CG38Idq4.js +86 -0
- package/dist/manager--wG9JdFW.js +120 -0
- package/dist/manager-BI3izlRG.js +120 -0
- package/dist/manager-BNc21xgG.js +6 -0
- package/dist/manager-CQ3MWNHY.js +250 -0
- package/dist/manager-DWJ7WZcY.js +250 -0
- package/dist/manager-DYfzqckn.js +35 -0
- package/dist/mcp-CklaYr_6.js +142 -0
- package/dist/mcp-SsMEvl28.js +142 -0
- package/dist/mcp-loader-9v8eUsNI.js +93 -0
- package/dist/mcp-loader-DLrp_oZJ.js +93 -0
- package/dist/memory-BCYvdqwo.js +273 -0
- package/dist/memory-BGgCBSx1.js +6 -0
- package/dist/memory-auto-Bh52cQJP.js +5 -0
- package/dist/memory-auto-Bow9u_L7.js +306 -0
- package/dist/memory-auto-BupvVwNd.js +306 -0
- package/dist/memory-auto-CgBAI8mm.js +5 -0
- package/dist/memory-integration-4oGqX6rr.js +91 -0
- package/dist/memory-integration-CveUEI3V.js +91 -0
- package/dist/moltbook-B3DNdh40.js +81 -0
- package/dist/moltbook-xP7VXKlX.js +81 -0
- package/dist/node-C4esBfbX.js +226 -0
- package/dist/node-urDjajMt.js +226 -0
- package/dist/nodes-registry-Cd4eWw80.js +52 -0
- package/dist/nodes-registry-DLUZhEMS.js +52 -0
- package/dist/oauth-flow-BbLQTzZk.js +148 -0
- package/dist/oauth-flow-Bt-LaRHV.js +148 -0
- package/dist/oauth-provider-CVTKgj35.js +111 -0
- package/dist/oauth-provider-UZyG84s7.js +111 -0
- package/dist/observability-BtLyuxcz.js +89 -0
- package/dist/observability-lwYm4aoB.js +89 -0
- package/dist/onboard-B3drurt-.js +3812 -0
- package/dist/onboard-BV5Poocl.js +13 -0
- package/dist/onboard-DEwuHrMj.js +14 -0
- package/dist/onboard-UiynbNQy.js +3909 -0
- package/dist/orchestrator-BXyIgAeH.js +189 -0
- package/dist/orchestrator-DMZkAVa5.js +189 -0
- package/dist/orchestrator-MLTc4NYu.js +6 -0
- package/dist/orchestrator-rVGu7yYr.js +6 -0
- package/dist/osint-Bsf6RGPv.js +283 -0
- package/dist/osint-chat-Ark94iFc.js +789 -0
- package/dist/osint-chat-Hn8qpsC1.js +836 -0
- package/dist/osint-f9DeXT6j.js +283 -0
- package/dist/pairing-2vAiDBjN.js +6 -0
- package/dist/pairing-B4NoBvyE.js +207 -0
- package/dist/pc-access-BLnc-DYp.js +858 -0
- package/dist/pc-access-CTNtG2LD.js +8 -0
- package/dist/pending-approval-C4ZaHHWl.js +22 -0
- package/dist/pending-approval-CHUZ_qT6.js +22 -0
- package/dist/reminders-store-BixTWL1h.js +58 -0
- package/dist/renderer-B1ToXngl.js +228 -0
- package/dist/rules-Cqen1Mpt.js +106 -0
- package/dist/run-main.js +98 -94
- package/dist/runner-B9xANekJ.js +1274 -0
- package/dist/runner-Cr1_mwnU.js +1274 -0
- package/dist/security--17Fxo5Z.js +4 -0
- package/dist/security-B4vH02lO.js +4 -0
- package/dist/security-DP1qtJfL.js +90 -0
- package/dist/security-HOOGCw5z.js +90 -0
- package/dist/server-CRhXiGI9.js +4 -0
- package/dist/server-DUDXqJSo.js +1365 -0
- package/dist/server-De4H45Ju.js +1365 -0
- package/dist/server-ha59nA8a.js +4 -0
- package/dist/session-store-7sEPyV16.js +5 -0
- package/dist/session-store-Ce2QMSL_.js +141 -0
- package/dist/sessions-tools-CWr_pDtp.js +5 -0
- package/dist/sessions-tools-DKVu9aIN.js +95 -0
- package/dist/skill-loader-DK19Jm4e.js +7 -0
- package/dist/skill-loader-Dfs9VNM-.js +160 -0
- package/dist/skill-runtime-BRp2D8Jb.js +5 -0
- package/dist/skill-runtime-BeKh2rD_.js +5 -0
- package/dist/skill-runtime-C8bNwKwz.js +104 -0
- package/dist/skill-runtime-CcpC2Zfc.js +104 -0
- package/dist/src-B8LzGLSY.js +63 -0
- package/dist/src-BxmkZ9RH.js +63 -0
- package/dist/src-DUoc6_kn.js +458 -0
- package/dist/src-DjTtmSRg.js +20 -0
- package/dist/src-n_46LPDi.js +458 -0
- package/dist/sub-agent-tools-CldaMfd5.js +39 -0
- package/dist/sub-agent-tools-q5JqEze_.js +39 -0
- package/dist/tool-policy-DtGf3Ifq.js +189 -0
- package/dist/tool-policy-QXF3MMxu.js +189 -0
- package/dist/tts-elevenlabs-1zWD3QJw.js +64 -0
- package/dist/tts-elevenlabs-y6HGWWDS.js +64 -0
- package/dist/update-check-C4te7JmY.js +6 -0
- package/dist/update-check-GDue_it1.js +98 -0
- package/dist/vision-DV2ubVjr.js +167 -0
- package/dist/vision-tools-Cb86uMdh.js +5 -0
- package/dist/vision-tools-CbVfyTZT.js +5 -0
- package/dist/vision-tools-DieVQp6s.js +51 -0
- package/dist/vision-tools-DlnxaZjg.js +51 -0
- package/dist/vision-u4kMThdo.js +167 -0
- package/dist/voice-transcription-BolTT_HG.js +170 -0
- package/dist/voice-transcription-DgON5qaF.js +170 -0
- package/dist/website-watch-tools-B8L_NgwT.js +5 -0
- package/dist/website-watch-tools-Drm5HjIX.js +176 -0
- package/package.json +4 -1
- package/static/chat.html +9 -3
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
const require_paths = require('./paths-AIyBxIzm.js');
|
|
3
|
+
require('./browser-tools-CJ9M9o22.js');
|
|
4
|
+
require('./src-DjTtmSRg.js');
|
|
5
|
+
const require_engine = require('./engine-BGRTi0fo.js');
|
|
6
|
+
require('./extraction-tools-BE6z_Yw5.js');
|
|
7
|
+
const require_inference = require('./inference-CFBkvLpE.js');
|
|
8
|
+
require('./memory-auto-BupvVwNd.js');
|
|
9
|
+
require('./orchestrator-BXyIgAeH.js');
|
|
10
|
+
require('./pc-access-BLnc-DYp.js');
|
|
11
|
+
require('./session-store-Ce2QMSL_.js');
|
|
12
|
+
require('./sessions-tools-DKVu9aIN.js');
|
|
13
|
+
require('./skill-loader-Dfs9VNM-.js');
|
|
14
|
+
require('./skill-runtime-CcpC2Zfc.js');
|
|
15
|
+
require('./vision-tools-DieVQp6s.js');
|
|
16
|
+
require('./website-watch-tools-Drm5HjIX.js');
|
|
17
|
+
const require_src$1 = require('./src-n_46LPDi.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 path = require_chunk.__toESM(require("path"));
|
|
22
|
+
const child_process = require_chunk.__toESM(require("child_process"));
|
|
23
|
+
const readline = require_chunk.__toESM(require("readline"));
|
|
24
|
+
const marked = require_chunk.__toESM(require("marked"));
|
|
25
|
+
const marked_terminal = require_chunk.__toESM(require("marked-terminal"));
|
|
26
|
+
|
|
27
|
+
//#region src/cli/chat.ts
|
|
28
|
+
require_src$1.init_src();
|
|
29
|
+
marked.marked.setOptions({ renderer: new marked_terminal.default({ emoji: true }) });
|
|
30
|
+
function renderMarkdown(text) {
|
|
31
|
+
try {
|
|
32
|
+
const rendered = (0, marked.marked)(text);
|
|
33
|
+
return rendered.split("\n").map((l) => " " + l).join("\n").trimEnd();
|
|
34
|
+
} catch {
|
|
35
|
+
return " " + text;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const DIVIDER = chalk.default.gray(" " + "─".repeat(56));
|
|
39
|
+
function printHeader(model, sessionId) {
|
|
40
|
+
console.log();
|
|
41
|
+
console.log(DIVIDER);
|
|
42
|
+
console.log(chalk.default.bold.cyan(" 🦅 HYPERCLAW CHAT"));
|
|
43
|
+
console.log(chalk.default.gray(` Model: ${model} · Session: ${sessionId}`));
|
|
44
|
+
console.log(DIVIDER);
|
|
45
|
+
console.log(chalk.default.gray(" Type your message and press Enter."));
|
|
46
|
+
console.log(chalk.default.gray(" Commands: /exit /clear /model /prompt /skill add|remove|list /help"));
|
|
47
|
+
console.log(DIVIDER);
|
|
48
|
+
console.log();
|
|
49
|
+
}
|
|
50
|
+
function printHelp() {
|
|
51
|
+
console.log();
|
|
52
|
+
console.log(chalk.default.bold(" Commands:"));
|
|
53
|
+
console.log(` ${chalk.default.cyan("/exit")} — 🚪 quit the chat`);
|
|
54
|
+
console.log(` ${chalk.default.cyan("/clear")} — 🗑️ clear conversation history`);
|
|
55
|
+
console.log(` ${chalk.default.cyan("/model")} — 🤖 show / switch model`);
|
|
56
|
+
console.log(` ${chalk.default.cyan("/model <id>")} — 🤖 switch model (e.g. /model claude-sonnet-4-5)`);
|
|
57
|
+
console.log(` ${chalk.default.cyan("/prompt")} — 📝 show current session prompt`);
|
|
58
|
+
console.log(` ${chalk.default.cyan("/prompt <text>")} — 📝 add extra instructions for this session`);
|
|
59
|
+
console.log(` ${chalk.default.cyan("/prompt clear")} — 🧹 remove extra instructions`);
|
|
60
|
+
console.log(` ${chalk.default.cyan("/skills")} — 🧩 list installed skills`);
|
|
61
|
+
console.log(` ${chalk.default.cyan("/skill add <id>")} — ➕ activate a skill for this session`);
|
|
62
|
+
console.log(` ${chalk.default.cyan("/skill remove <id>")} — ➖ deactivate a skill`);
|
|
63
|
+
console.log(` ${chalk.default.cyan("/help")} — ❓ show this help`);
|
|
64
|
+
console.log();
|
|
65
|
+
console.log(chalk.default.gray(" 💡 Tips:"));
|
|
66
|
+
console.log(chalk.default.gray(" • Tell the agent: \"Install the web-search skill\""));
|
|
67
|
+
console.log(chalk.default.gray(" • Paste a skill link: \"Install this: https://clawhub.ai/user/skill-name\""));
|
|
68
|
+
console.log(chalk.default.gray(" • Set a session goal: /prompt You are a senior backend engineer. Be concise."));
|
|
69
|
+
console.log(chalk.default.gray(" • Add to memory: \"Remember that I prefer TypeScript\""));
|
|
70
|
+
console.log();
|
|
71
|
+
}
|
|
72
|
+
async function printSkills() {
|
|
73
|
+
console.log();
|
|
74
|
+
try {
|
|
75
|
+
const { loadSkills } = await Promise.resolve().then(() => require("./skill-loader-DK19Jm4e.js"));
|
|
76
|
+
const skills = await loadSkills();
|
|
77
|
+
if (skills.length === 0) console.log(chalk.default.gray(" No skills installed yet."));
|
|
78
|
+
else {
|
|
79
|
+
console.log(chalk.default.bold(" 🧩 Installed skills:"));
|
|
80
|
+
for (const s of skills) {
|
|
81
|
+
console.log(` ${chalk.default.cyan("🔹")} ${chalk.default.bold(s.title || s.id)} ${chalk.default.gray(`(${s.id})`)}`);
|
|
82
|
+
if (s.capabilities) console.log(chalk.default.gray(` ${s.capabilities}`));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.log(chalk.default.gray(" Could not load skills list."));
|
|
87
|
+
console.log(chalk.default.gray(` ${(e?.message || String(e)).slice(0, 80)}`));
|
|
88
|
+
console.log(chalk.default.gray(" Run: hyperclaw doctor or hyperclaw hub to check setup."));
|
|
89
|
+
}
|
|
90
|
+
console.log();
|
|
91
|
+
console.log(chalk.default.bold(" How to add a skill:"));
|
|
92
|
+
console.log(` ${chalk.default.gray("1.")} Tell the agent: ${chalk.default.cyan("\"Install the web-search skill\"")}`);
|
|
93
|
+
console.log(` ${chalk.default.gray("2.")} Paste a link: ${chalk.default.cyan("\"Install this: https://clawhub.ai/user/skill-name\"")}`);
|
|
94
|
+
console.log(` ${chalk.default.gray("3.")} CLI (outside chat): ${chalk.default.cyan("hyperclaw skill install <name>")}`);
|
|
95
|
+
console.log(` ${chalk.default.gray("4.")} Re-run wizard: ${chalk.default.cyan("hyperclaw onboard")}`);
|
|
96
|
+
console.log();
|
|
97
|
+
}
|
|
98
|
+
async function interactiveChatUpdateCheck() {
|
|
99
|
+
try {
|
|
100
|
+
const { checkForUpdates } = await Promise.resolve().then(() => require("./update-check-C4te7JmY.js"));
|
|
101
|
+
let current = "0.0.0";
|
|
102
|
+
try {
|
|
103
|
+
const pkgPath = require.resolve("hyperclaw/package.json");
|
|
104
|
+
const pkg = await fs_extra.default.readJson(pkgPath).catch(() => null);
|
|
105
|
+
current = pkg?.version ?? "0.0.0";
|
|
106
|
+
} catch {
|
|
107
|
+
const pkgPath = path.default.join(__dirname, "../../package.json");
|
|
108
|
+
const pkg = await fs_extra.default.readJson(pkgPath).catch(() => null);
|
|
109
|
+
current = pkg?.version ?? "0.0.0";
|
|
110
|
+
}
|
|
111
|
+
const result = await checkForUpdates(current);
|
|
112
|
+
if (!result?.available) return;
|
|
113
|
+
console.log();
|
|
114
|
+
console.log(chalk.default.yellow(` 🦅 New version available! `) + chalk.default.bold.white(result.latest) + chalk.default.gray(` (you have ${current})`));
|
|
115
|
+
const isWindows = process.platform === "win32";
|
|
116
|
+
const updateCmd = isWindows ? "npm install -g hyperclaw@latest" : "sudo npm install -g hyperclaw@latest";
|
|
117
|
+
console.log(chalk.default.gray(` 📦 ${updateCmd}`));
|
|
118
|
+
console.log();
|
|
119
|
+
const inquirer = (await import("inquirer")).default;
|
|
120
|
+
const { choice } = await inquirer.prompt([{
|
|
121
|
+
type: "list",
|
|
122
|
+
name: "choice",
|
|
123
|
+
message: chalk.default.cyan("What would you like to do?"),
|
|
124
|
+
choices: [{
|
|
125
|
+
name: `🚀 Update now ${chalk.default.gray("(recommended)")}`,
|
|
126
|
+
value: "update"
|
|
127
|
+
}, {
|
|
128
|
+
name: `⏭️ Skip for later`,
|
|
129
|
+
value: "skip"
|
|
130
|
+
}],
|
|
131
|
+
prefix: " ✨"
|
|
132
|
+
}]);
|
|
133
|
+
if (choice === "skip") {
|
|
134
|
+
console.log(chalk.default.gray(`\n ⏭️ Skipping — run: ${updateCmd} when ready.\n`));
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
console.log(chalk.default.cyan("\n ⏳ Updating HyperClaw...\n"));
|
|
138
|
+
const updateArgs = isWindows ? [
|
|
139
|
+
"install",
|
|
140
|
+
"-g",
|
|
141
|
+
"hyperclaw@latest"
|
|
142
|
+
] : [
|
|
143
|
+
"npm",
|
|
144
|
+
"install",
|
|
145
|
+
"-g",
|
|
146
|
+
"hyperclaw@latest"
|
|
147
|
+
];
|
|
148
|
+
const updateBin = isWindows ? "npm" : "sudo";
|
|
149
|
+
await new Promise((resolve) => {
|
|
150
|
+
const proc = (0, child_process.spawn)(updateBin, updateArgs, {
|
|
151
|
+
stdio: "inherit",
|
|
152
|
+
shell: true
|
|
153
|
+
});
|
|
154
|
+
proc.on("close", (code) => {
|
|
155
|
+
if (code === 0) console.log(chalk.default.green(`\n ✅ Updated to ${result.latest} — starting chat...\n`));
|
|
156
|
+
else {
|
|
157
|
+
console.log(chalk.default.red(`\n ❌ Update failed (exit ${code}). Starting chat anyway...\n`));
|
|
158
|
+
if (!isWindows) console.log(chalk.default.gray(" 💡 If you use nvm/fnm, try without sudo: npm install -g hyperclaw@latest\n"));
|
|
159
|
+
}
|
|
160
|
+
resolve();
|
|
161
|
+
});
|
|
162
|
+
proc.on("error", () => resolve());
|
|
163
|
+
});
|
|
164
|
+
} catch {}
|
|
165
|
+
}
|
|
166
|
+
function makeSessionId() {
|
|
167
|
+
const { randomBytes } = require("crypto");
|
|
168
|
+
return randomBytes(5).toString("hex");
|
|
169
|
+
}
|
|
170
|
+
async function runChat(opts) {
|
|
171
|
+
const cfg = await fs_extra.default.readJson(require_paths.getConfigPath()).catch(() => null);
|
|
172
|
+
if (!cfg) {
|
|
173
|
+
console.log(chalk.default.red("\n No configuration found.\n"));
|
|
174
|
+
console.log(chalk.default.gray(" Chat works without the gateway. Run: hyperclaw onboard\n"));
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const { getProviderCredentialAsync } = await Promise.resolve().then(() => require("./env-resolve-pIETNTpQ.js"));
|
|
178
|
+
const apiKey = await getProviderCredentialAsync(cfg).catch(() => null);
|
|
179
|
+
const isLocal = [
|
|
180
|
+
"local",
|
|
181
|
+
"ollama",
|
|
182
|
+
"lmstudio"
|
|
183
|
+
].includes(cfg?.provider?.providerId ?? "");
|
|
184
|
+
if (!apiKey && !isLocal) {
|
|
185
|
+
console.log(chalk.default.red("\n No API key configured.\n"));
|
|
186
|
+
console.log(chalk.default.gray(" Chat uses your AI provider directly (no gateway needed). Run: hyperclaw config set-key\n"));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const { getProvider } = await Promise.resolve().then(() => require("./providers-CFQC39vg.js"));
|
|
190
|
+
const providerMeta = getProvider(cfg?.provider?.providerId ?? "");
|
|
191
|
+
const CUSTOM_IDS = new Set([
|
|
192
|
+
"groq",
|
|
193
|
+
"mistral",
|
|
194
|
+
"deepseek",
|
|
195
|
+
"perplexity",
|
|
196
|
+
"huggingface",
|
|
197
|
+
"ollama",
|
|
198
|
+
"lmstudio",
|
|
199
|
+
"local",
|
|
200
|
+
"xai",
|
|
201
|
+
"openai",
|
|
202
|
+
"google",
|
|
203
|
+
"minimax",
|
|
204
|
+
"moonshot",
|
|
205
|
+
"qwen",
|
|
206
|
+
"zai",
|
|
207
|
+
"litellm",
|
|
208
|
+
"cloudflare",
|
|
209
|
+
"copilot",
|
|
210
|
+
"vercel-ai",
|
|
211
|
+
"opencode-zen"
|
|
212
|
+
]);
|
|
213
|
+
const isAnthropicVariant = [
|
|
214
|
+
"anthropic",
|
|
215
|
+
"anthropic-oauth",
|
|
216
|
+
"anthropic-setup-token"
|
|
217
|
+
].includes(cfg?.provider?.providerId ?? "");
|
|
218
|
+
const provider = isAnthropicVariant ? "anthropic" : cfg?.provider?.providerId === "custom" || isLocal || CUSTOM_IDS.has(cfg?.provider?.providerId ?? "") ? "custom" : "openrouter";
|
|
219
|
+
let rawModel = opts.model || cfg?.provider?.modelId || "claude-sonnet-4-5";
|
|
220
|
+
const model = rawModel.startsWith("ollama/") ? rawModel.slice(7) : rawModel;
|
|
221
|
+
const resolvedBaseUrl = cfg?.provider?.baseUrl || providerMeta?.baseUrl || (isLocal ? "http://localhost:11434/v1" : void 0);
|
|
222
|
+
const THINKING_BUDGET = {
|
|
223
|
+
high: 1e4,
|
|
224
|
+
medium: 4e3,
|
|
225
|
+
low: 1e3,
|
|
226
|
+
none: 0
|
|
227
|
+
};
|
|
228
|
+
const thinkingBudget = THINKING_BUDGET[opts.thinking ?? "none"] ?? 0;
|
|
229
|
+
const maxTokens = thinkingBudget > 0 ? thinkingBudget + 4096 : 4096;
|
|
230
|
+
const baseContext = await require_engine.loadWorkspaceContext(opts.workspace) + await require_engine.loadSkillsContext();
|
|
231
|
+
const tools = await require_engine.resolveTools({
|
|
232
|
+
config: cfg,
|
|
233
|
+
source: "cli",
|
|
234
|
+
elevated: true,
|
|
235
|
+
daemonMode: false
|
|
236
|
+
});
|
|
237
|
+
let sessionExtraPrompt = "";
|
|
238
|
+
const sessionActiveSkills = /* @__PURE__ */ new Map();
|
|
239
|
+
function buildSystemPrompt() {
|
|
240
|
+
let sys = baseContext;
|
|
241
|
+
if (sessionExtraPrompt) sys += `\n\n## Session Instructions\n${sessionExtraPrompt}`;
|
|
242
|
+
if (sessionActiveSkills.size > 0) {
|
|
243
|
+
sys += `\n\n## Session Skills\n`;
|
|
244
|
+
for (const [id, ctx] of sessionActiveSkills) sys += `### ${id}\n${ctx}\n\n`;
|
|
245
|
+
}
|
|
246
|
+
return sys || "";
|
|
247
|
+
}
|
|
248
|
+
const engineOpts = {
|
|
249
|
+
model,
|
|
250
|
+
apiKey,
|
|
251
|
+
provider,
|
|
252
|
+
system: buildSystemPrompt() || void 0,
|
|
253
|
+
tools,
|
|
254
|
+
maxTokens,
|
|
255
|
+
onToken: () => {},
|
|
256
|
+
...provider === "custom" ? { baseUrl: resolvedBaseUrl || "" } : {},
|
|
257
|
+
...thinkingBudget > 0 && model.includes("claude") ? { thinking: { budget_tokens: thinkingBudget } } : {}
|
|
258
|
+
};
|
|
259
|
+
const sessionId = opts.sessionId ?? makeSessionId();
|
|
260
|
+
const messages = [];
|
|
261
|
+
let autoMem = null;
|
|
262
|
+
try {
|
|
263
|
+
const { AutoMemory } = await Promise.resolve().then(() => require("./memory-auto-Bh52cQJP.js"));
|
|
264
|
+
autoMem = new AutoMemory({ extractEveryNTurns: 3 });
|
|
265
|
+
} catch {}
|
|
266
|
+
printHeader(rawModel, sessionId);
|
|
267
|
+
await interactiveChatUpdateCheck();
|
|
268
|
+
if (process.stdin.isTTY) process.stdin.resume();
|
|
269
|
+
const rl = readline.default.createInterface({
|
|
270
|
+
input: process.stdin,
|
|
271
|
+
output: process.stdout,
|
|
272
|
+
terminal: true
|
|
273
|
+
});
|
|
274
|
+
rl.on("SIGINT", () => {
|
|
275
|
+
console.log(chalk.default.gray("\n\n Bye!\n"));
|
|
276
|
+
rl.close();
|
|
277
|
+
process.exit(0);
|
|
278
|
+
});
|
|
279
|
+
await new Promise((resolve) => {
|
|
280
|
+
rl.on("close", resolve);
|
|
281
|
+
const INPUT_PROMPT = chalk.default.gray(" Message HyperClaw — type and press Enter to send › ");
|
|
282
|
+
const prompt = () => {
|
|
283
|
+
rl.question(INPUT_PROMPT, (input) => {
|
|
284
|
+
if (input === null || input === void 0) {
|
|
285
|
+
prompt();
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
(async () => {
|
|
289
|
+
const text = input.trim();
|
|
290
|
+
if (!text) {
|
|
291
|
+
prompt();
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if ([
|
|
295
|
+
"/exit",
|
|
296
|
+
"/quit",
|
|
297
|
+
"/bye",
|
|
298
|
+
"exit",
|
|
299
|
+
"quit",
|
|
300
|
+
"bye"
|
|
301
|
+
].includes(text.toLowerCase())) {
|
|
302
|
+
console.log(chalk.default.gray("\n Bye!\n"));
|
|
303
|
+
rl.close();
|
|
304
|
+
process.exit(0);
|
|
305
|
+
}
|
|
306
|
+
if (text === "/help") {
|
|
307
|
+
printHelp();
|
|
308
|
+
prompt();
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (text === "/skills") {
|
|
312
|
+
await printSkills();
|
|
313
|
+
prompt();
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (text === "/model" || text.startsWith("/model ")) {
|
|
317
|
+
const newModelArg = text.slice(7).trim().replace(/^<|>$/g, "");
|
|
318
|
+
if (newModelArg) {
|
|
319
|
+
rawModel = newModelArg;
|
|
320
|
+
engineOpts.model = rawModel.startsWith("ollama/") ? rawModel.slice(7) : rawModel;
|
|
321
|
+
console.log(chalk.default.green(`\n 🤖 Model switched to: ${chalk.default.bold(rawModel)}\n`));
|
|
322
|
+
} else if (providerMeta?.models?.length) {
|
|
323
|
+
rl.pause();
|
|
324
|
+
try {
|
|
325
|
+
const inquirer = (await import("inquirer")).default;
|
|
326
|
+
const defaultIdx = Math.max(0, providerMeta.models.findIndex((m) => m.id === rawModel));
|
|
327
|
+
const { selected } = await inquirer.prompt([{
|
|
328
|
+
type: "list",
|
|
329
|
+
name: "selected",
|
|
330
|
+
message: chalk.default.cyan("Select model") + chalk.default.gray(" (↑↓ arrows, Enter to confirm):"),
|
|
331
|
+
choices: providerMeta.models.map((m) => ({
|
|
332
|
+
name: `${m.id} ${chalk.default.gray(m.name)}`,
|
|
333
|
+
value: m.id,
|
|
334
|
+
short: m.id
|
|
335
|
+
})),
|
|
336
|
+
default: defaultIdx,
|
|
337
|
+
prefix: " "
|
|
338
|
+
}]);
|
|
339
|
+
rawModel = selected;
|
|
340
|
+
engineOpts.model = rawModel.startsWith("ollama/") ? rawModel.slice(7) : rawModel;
|
|
341
|
+
console.log(chalk.default.green(`\n 🤖 Model switched to: ${chalk.default.bold(rawModel)}\n`));
|
|
342
|
+
} catch {
|
|
343
|
+
console.log(chalk.default.gray("\n Selection failed. Use: /model <model-id> (e.g. claude-sonnet-4-5)\n"));
|
|
344
|
+
} finally {
|
|
345
|
+
rl.resume();
|
|
346
|
+
}
|
|
347
|
+
} else {
|
|
348
|
+
console.log(chalk.default.gray(`\n Current model: ${chalk.default.bold(rawModel)}`));
|
|
349
|
+
console.log(chalk.default.gray(" Use: /model <model-id>\n"));
|
|
350
|
+
}
|
|
351
|
+
prompt();
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (text === "/clear") {
|
|
355
|
+
messages.length = 0;
|
|
356
|
+
console.log(chalk.default.gray("\n 🗑️ Conversation cleared.\n"));
|
|
357
|
+
prompt();
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (text === "/prompt" || text.startsWith("/prompt ")) {
|
|
361
|
+
const arg = text.slice(7).trim();
|
|
362
|
+
if (!arg) {
|
|
363
|
+
console.log();
|
|
364
|
+
if (sessionExtraPrompt) {
|
|
365
|
+
console.log(chalk.default.bold(" 📝 Session prompt:"));
|
|
366
|
+
console.log(chalk.default.white(` ${sessionExtraPrompt.slice(0, 400)}${sessionExtraPrompt.length > 400 ? "…" : ""}`));
|
|
367
|
+
} else console.log(chalk.default.gray(" 📝 No extra prompt set. Use: /prompt <text>"));
|
|
368
|
+
console.log();
|
|
369
|
+
} else if (arg === "clear") {
|
|
370
|
+
sessionExtraPrompt = "";
|
|
371
|
+
engineOpts.system = buildSystemPrompt() || void 0;
|
|
372
|
+
console.log(chalk.default.green("\n 🧹 Extra prompt cleared.\n"));
|
|
373
|
+
} else {
|
|
374
|
+
sessionExtraPrompt = arg;
|
|
375
|
+
engineOpts.system = buildSystemPrompt() || void 0;
|
|
376
|
+
console.log(chalk.default.green(`\n ✅ Session prompt set: ${chalk.default.white(arg.slice(0, 60))}${arg.length > 60 ? "…" : ""}\n`));
|
|
377
|
+
}
|
|
378
|
+
prompt();
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (text === "/skill" || text.startsWith("/skill ")) {
|
|
382
|
+
const arg = text.slice(6).trim();
|
|
383
|
+
const [subCmd, ...rest] = arg.split(/\s+/);
|
|
384
|
+
const skillId = rest.join(" ").trim();
|
|
385
|
+
if (!subCmd || subCmd === "list") {
|
|
386
|
+
await printSkills();
|
|
387
|
+
prompt();
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
if (subCmd === "add") {
|
|
391
|
+
if (!skillId) {
|
|
392
|
+
console.log(chalk.default.gray("\n Usage: /skill add <skill-id>\n"));
|
|
393
|
+
prompt();
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
try {
|
|
397
|
+
const { loadSkills } = await Promise.resolve().then(() => require("./skill-loader-DK19Jm4e.js"));
|
|
398
|
+
const allSkills = await loadSkills();
|
|
399
|
+
const found = allSkills.find((s) => s.id === skillId || (s.title ?? "").toLowerCase() === skillId.toLowerCase());
|
|
400
|
+
if (!found) console.log(chalk.default.yellow(`\n ⚠️ Skill "${skillId}" not found. Use /skills to list installed.\n`));
|
|
401
|
+
else {
|
|
402
|
+
const ctx = [
|
|
403
|
+
found.title ? `**${found.title}**` : found.id,
|
|
404
|
+
found.capabilities ? found.capabilities : "",
|
|
405
|
+
found.description ? found.description : ""
|
|
406
|
+
].filter(Boolean).join("\n");
|
|
407
|
+
sessionActiveSkills.set(found.id, ctx);
|
|
408
|
+
engineOpts.system = buildSystemPrompt() || void 0;
|
|
409
|
+
console.log(chalk.default.green(`\n ✅ Skill activated: ${chalk.default.bold(found.title || found.id)}\n`));
|
|
410
|
+
}
|
|
411
|
+
} catch (e) {
|
|
412
|
+
console.log(chalk.default.red(`\n ❌ Error loading skills: ${e?.message || String(e)}\n`));
|
|
413
|
+
}
|
|
414
|
+
prompt();
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
if (subCmd === "remove") {
|
|
418
|
+
if (!skillId) {
|
|
419
|
+
console.log(chalk.default.gray("\n Usage: /skill remove <skill-id>\n"));
|
|
420
|
+
prompt();
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (sessionActiveSkills.has(skillId)) {
|
|
424
|
+
sessionActiveSkills.delete(skillId);
|
|
425
|
+
engineOpts.system = buildSystemPrompt() || void 0;
|
|
426
|
+
console.log(chalk.default.green(`\n ✅ Skill deactivated: ${skillId}\n`));
|
|
427
|
+
} else console.log(chalk.default.gray(`\n ℹ️ Skill "${skillId}" is not active in this session.\n`));
|
|
428
|
+
prompt();
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
console.log(chalk.default.gray("\n ℹ️ Usage: /skill list | /skill add <id> | /skill remove <id>\n"));
|
|
432
|
+
prompt();
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
messages.push({
|
|
436
|
+
role: "user",
|
|
437
|
+
content: text
|
|
438
|
+
});
|
|
439
|
+
console.log(chalk.default.gray(" " + "─".repeat(56)));
|
|
440
|
+
console.log(chalk.default.bold.green(" 💬 You › ") + chalk.default.white(text));
|
|
441
|
+
console.log(chalk.default.gray(" " + "─".repeat(56)));
|
|
442
|
+
let responseText = "";
|
|
443
|
+
let elapsed = 0;
|
|
444
|
+
let ticker;
|
|
445
|
+
const spinner = (0, ora.default)({
|
|
446
|
+
text: chalk.default.cyan(` 🤔 Thinking... (${elapsed}s • Ctrl+C to cancel)`),
|
|
447
|
+
prefixText: ""
|
|
448
|
+
}).start();
|
|
449
|
+
ticker = setInterval(() => {
|
|
450
|
+
elapsed++;
|
|
451
|
+
spinner.text = chalk.default.cyan(` 🤔 Thinking... (${elapsed}s • Ctrl+C to cancel)`);
|
|
452
|
+
}, 1e3);
|
|
453
|
+
try {
|
|
454
|
+
const engine = new require_inference.InferenceEngine({
|
|
455
|
+
...engineOpts,
|
|
456
|
+
onToken: () => {
|
|
457
|
+
if (spinner.isSpinning) spinner.text = chalk.default.cyan(` 📥 Receiving... (${elapsed}s • Ctrl+C to cancel)`);
|
|
458
|
+
},
|
|
459
|
+
onToolCall: (name) => {
|
|
460
|
+
spinner.stop();
|
|
461
|
+
console.log(chalk.default.yellow(`\n 🔧 ${chalk.default.bold(name)}`));
|
|
462
|
+
spinner.start(chalk.default.cyan(` ⚙️ Working (${elapsed}s • Ctrl+C to cancel)`));
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
const result = await engine.run(messages);
|
|
466
|
+
responseText = result.text || "";
|
|
467
|
+
if (ticker) clearInterval(ticker);
|
|
468
|
+
spinner.stop();
|
|
469
|
+
console.log(chalk.default.bold.blue("\n 🦅 Agent ›"));
|
|
470
|
+
if (responseText) process.stdout.write(renderMarkdown(responseText));
|
|
471
|
+
else process.stdout.write(chalk.default.gray(" (empty — try rephrasing or check model/tools)"));
|
|
472
|
+
console.log("\n");
|
|
473
|
+
console.log(chalk.default.gray(" " + "─".repeat(56)));
|
|
474
|
+
if (result.usage) console.log(chalk.default.gray(` 📊 Tokens in: ${result.usage.input} out: ${result.usage.output} · ${rawModel}\n`));
|
|
475
|
+
else console.log();
|
|
476
|
+
} catch (e) {
|
|
477
|
+
if (ticker) clearInterval(ticker);
|
|
478
|
+
spinner.stop();
|
|
479
|
+
const msg = e?.message || String(e);
|
|
480
|
+
responseText = `Error: ${msg}`;
|
|
481
|
+
console.log(chalk.default.red(`\n Error: ${msg}\n`));
|
|
482
|
+
const hint = (() => {
|
|
483
|
+
if (/401|unauthorized|invalid.*key|authentication/i.test(msg)) return "🔑 Check API key: hyperclaw config set-key";
|
|
484
|
+
if (/429|rate.?limit|quota/i.test(msg)) return "⏱️ Rate limited. Wait a moment and retry.";
|
|
485
|
+
if (/500|503|service.?unavailable/i.test(msg)) return "🔌 Provider temporarily down. Try again later.";
|
|
486
|
+
if (/network|ECONNREFUSED|ETIMEDOUT|fetch failed/i.test(msg)) return "🌐 Network error. Check connection and base URL.";
|
|
487
|
+
if (/model|not found|invalid model/i.test(msg)) return "🤖 Try: /model <id> to switch model.";
|
|
488
|
+
return "🩺 Run: hyperclaw doctor for setup checks.";
|
|
489
|
+
})();
|
|
490
|
+
console.log(chalk.default.gray(` ${hint}\n`));
|
|
491
|
+
}
|
|
492
|
+
if (responseText) messages.push({
|
|
493
|
+
role: "assistant",
|
|
494
|
+
content: responseText
|
|
495
|
+
});
|
|
496
|
+
if (autoMem) {
|
|
497
|
+
autoMem.addTurn("user", text);
|
|
498
|
+
if (responseText) autoMem.addTurn("assistant", responseText);
|
|
499
|
+
autoMem.extract().catch(() => {});
|
|
500
|
+
}
|
|
501
|
+
prompt();
|
|
502
|
+
})().catch((err) => {
|
|
503
|
+
console.error(chalk.default.red("\n Unexpected error:"), err?.message || err);
|
|
504
|
+
prompt();
|
|
505
|
+
});
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
prompt();
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
//#endregion
|
|
513
|
+
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,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,7 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
require('./paths-AIyBxIzm.js');
|
|
3
|
+
require('./paths-DPovhojT.js');
|
|
4
|
+
require('./env-resolve-BdagnXhK.js');
|
|
5
|
+
const require_config = require('./config-SgDxKyfV.js');
|
|
6
|
+
|
|
7
|
+
exports.ConfigStore = require_config.ConfigStore;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-jS-bbMI5.js');
|
|
2
|
+
require('./paths-AIyBxIzm.js');
|
|
3
|
+
require('./paths-DPovhojT.js');
|
|
4
|
+
require('./env-resolve-CHxjGo8u.js');
|
|
5
|
+
const require_config = require('./config-DGAAJ49A.js');
|
|
6
|
+
|
|
7
|
+
exports.ConfigStore = require_config.ConfigStore;
|