hyperclaw 5.3.45 → 5.4.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 (51) hide show
  1. package/dist/banner-B2Qo91lq.js +143 -0
  2. package/dist/banner-CmNA9NKE.js +7 -0
  3. package/dist/banner-D3-Ik5d2.js +143 -0
  4. package/dist/banner-D3X8tQ-0.js +7 -0
  5. package/dist/chat-BGD9AWhr.js +523 -0
  6. package/dist/chat-D8wFNN4z.js +523 -0
  7. package/dist/daemon-D-klsy3i.js +7 -0
  8. package/dist/daemon-D_bYfHgn.js +421 -0
  9. package/dist/daemon-DcE6vcjH.js +421 -0
  10. package/dist/daemon-NFwpuo3L.js +7 -0
  11. package/dist/engine-B7Q4Vx-C.js +7 -0
  12. package/dist/engine-C-G3G-U7.js +7 -0
  13. package/dist/engine-DRpy9Y5O.js +327 -0
  14. package/dist/engine-DetHi9LP.js +327 -0
  15. package/dist/hyperclawbot-BqyZr2GM.js +516 -0
  16. package/dist/hyperclawbot-DTzP20Up.js +516 -0
  17. package/dist/mcp-loader-BAGRKfJz.js +93 -0
  18. package/dist/mcp-loader-Dt64EewT.js +93 -0
  19. package/dist/onboard-32d2Gsuy.js +14 -0
  20. package/dist/onboard-Cgj_CIrq.js +3812 -0
  21. package/dist/onboard-ChnsqU5z.js +14 -0
  22. package/dist/onboard-CjzqTYq3.js +3812 -0
  23. package/dist/orchestrator-Bcj7uc1F.js +189 -0
  24. package/dist/orchestrator-C7oLWNFW.js +6 -0
  25. package/dist/orchestrator-Cuyqncql.js +189 -0
  26. package/dist/orchestrator-CxlEm5li.js +6 -0
  27. package/dist/osint-ADgw_Gkd.js +283 -0
  28. package/dist/osint-B5j3IuJK.js +283 -0
  29. package/dist/osint-chat-BbH6eW8z.js +789 -0
  30. package/dist/osint-chat-xRP672b-.js +789 -0
  31. package/dist/run-main.js +28 -28
  32. package/dist/server-6TIyu0mb.js +4 -0
  33. package/dist/server-Da_jSrfS.js +4 -0
  34. package/dist/server-gai_RW1u.js +1356 -0
  35. package/dist/server-vbYKep6r.js +1356 -0
  36. package/dist/skill-runtime-CHQT7c1k.js +5 -0
  37. package/dist/skill-runtime-Cfd0OLkP.js +104 -0
  38. package/dist/skill-runtime-Dr0fimDf.js +5 -0
  39. package/dist/skill-runtime-DtO4i9vK.js +104 -0
  40. package/dist/src-CDLnbsLp.js +458 -0
  41. package/dist/src-D4VRanxB.js +458 -0
  42. package/dist/src-DK-ayUx7.js +63 -0
  43. package/dist/src-H1I7JC2E.js +63 -0
  44. package/dist/sub-agent-tools-BoMCZ6jz.js +39 -0
  45. package/dist/sub-agent-tools-Dla3ZB5N.js +39 -0
  46. package/package.json +145 -143
  47. package/scripts/fix-mojibake.mjs +166 -0
  48. package/static/web/assets/index-B5N1LHGR.css +1 -0
  49. package/static/web/assets/{index-BeAuHLb2.js → index-Bf8pf7Wg.js} +2 -2
  50. package/static/web/index.html +2 -2
  51. package/static/web/assets/index-D2RfO0dG.css +0 -1
@@ -0,0 +1,523 @@
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-DetHi9LP.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-Bcj7uc1F.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-Cfd0OLkP.js');
15
+ require('./vision-tools-DieVQp6s.js');
16
+ require('./website-watch-tools-Drm5HjIX.js');
17
+ const require_src$1 = require('./src-CDLnbsLp.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 child_process = require_chunk.__toESM(require("child_process"));
22
+ const readline = require_chunk.__toESM(require("readline"));
23
+ const marked = require_chunk.__toESM(require("marked"));
24
+ const marked_terminal = require_chunk.__toESM(require("marked-terminal"));
25
+
26
+ //#region src/cli/chat.ts
27
+ require_src$1.init_src();
28
+ marked.marked.setOptions({ renderer: new marked_terminal.default({ emoji: true }) });
29
+ function renderMarkdown(text) {
30
+ try {
31
+ const rendered = (0, marked.marked)(text);
32
+ return rendered.split("\n").map((l) => " " + l).join("\n").trimEnd();
33
+ } catch {
34
+ return " " + text;
35
+ }
36
+ }
37
+ const DIVIDER = chalk.default.gray(" " + "─".repeat(56));
38
+ function printHeader(model, sessionId) {
39
+ console.log();
40
+ console.log(DIVIDER);
41
+ console.log(chalk.default.bold.cyan(" 🦅 HYPERCLAW CHAT"));
42
+ console.log(chalk.default.gray(` Model: ${model} · Session: ${sessionId}`));
43
+ console.log(DIVIDER);
44
+ console.log(chalk.default.gray(" Type your message and press Enter."));
45
+ console.log(chalk.default.gray(" Commands: /exit /clear /model /prompt /skill add|remove|list /help"));
46
+ console.log(DIVIDER);
47
+ console.log();
48
+ }
49
+ function printHelp() {
50
+ console.log();
51
+ console.log(chalk.default.bold(" Commands:"));
52
+ console.log(` ${chalk.default.cyan("/exit")} — 🚪 quit the chat`);
53
+ console.log(` ${chalk.default.cyan("/clear")} — 🗑️ clear conversation history`);
54
+ console.log(` ${chalk.default.cyan("/model")} — 🤖 show / switch model`);
55
+ console.log(` ${chalk.default.cyan("/model <id>")} — 🤖 switch model (e.g. /model claude-sonnet-4-5)`);
56
+ console.log(` ${chalk.default.cyan("/prompt")} — 📝 show current session prompt`);
57
+ console.log(` ${chalk.default.cyan("/prompt <text>")} — 📝 add extra instructions for this session`);
58
+ console.log(` ${chalk.default.cyan("/prompt clear")} — 🧹 remove extra instructions`);
59
+ console.log(` ${chalk.default.cyan("/skills")} — 🧩 list installed skills`);
60
+ console.log(` ${chalk.default.cyan("/skill add <id>")} — ➕ activate a skill for this session`);
61
+ console.log(` ${chalk.default.cyan("/skill remove <id>")} — ➖ deactivate a skill`);
62
+ console.log(` ${chalk.default.cyan("/help")} — ❓ show this help`);
63
+ console.log();
64
+ console.log(chalk.default.gray(" 💡 Tips:"));
65
+ console.log(chalk.default.gray(" • Tell the agent: \"Install the web-search skill\""));
66
+ console.log(chalk.default.gray(" • Paste a skill link: \"Install this: https://clawhub.ai/user/skill-name\""));
67
+ console.log(chalk.default.gray(" • Set a session goal: /prompt You are a senior backend engineer. Be concise."));
68
+ console.log(chalk.default.gray(" • Add to memory: \"Remember that I prefer TypeScript\""));
69
+ console.log();
70
+ }
71
+ async function printSkills() {
72
+ console.log();
73
+ try {
74
+ const { loadSkills } = await Promise.resolve().then(() => require("./skill-loader-DK19Jm4e.js"));
75
+ const skills = await loadSkills();
76
+ if (skills.length === 0) console.log(chalk.default.gray(" No skills installed yet."));
77
+ else {
78
+ console.log(chalk.default.bold(" 🧩 Installed skills:"));
79
+ for (const s of skills) {
80
+ console.log(` ${chalk.default.cyan("🔹")} ${chalk.default.bold(s.title || s.id)} ${chalk.default.gray(`(${s.id})`)}`);
81
+ if (s.capabilities) console.log(chalk.default.gray(` ${s.capabilities}`));
82
+ }
83
+ }
84
+ } catch (e) {
85
+ console.log(chalk.default.gray(" Could not load skills list."));
86
+ console.log(chalk.default.gray(` ${(e?.message || String(e)).slice(0, 80)}`));
87
+ console.log(chalk.default.gray(" Run: hyperclaw doctor or hyperclaw hub to check setup."));
88
+ }
89
+ console.log();
90
+ console.log(chalk.default.bold(" How to add a skill:"));
91
+ console.log(` ${chalk.default.gray("1.")} Tell the agent: ${chalk.default.cyan("\"Install the web-search skill\"")}`);
92
+ console.log(` ${chalk.default.gray("2.")} Paste a link: ${chalk.default.cyan("\"Install this: https://clawhub.ai/user/skill-name\"")}`);
93
+ console.log(` ${chalk.default.gray("3.")} CLI (outside chat): ${chalk.default.cyan("hyperclaw skill install <name>")}`);
94
+ console.log(` ${chalk.default.gray("4.")} Re-run wizard: ${chalk.default.cyan("hyperclaw onboard")}`);
95
+ console.log();
96
+ }
97
+ async function interactiveChatUpdateCheck() {
98
+ try {
99
+ const { checkForUpdates, getCurrentVersion } = await Promise.resolve().then(() => require("./update-check-B-wd-tpa.js"));
100
+ const current = await getCurrentVersion();
101
+ const result = await checkForUpdates(current);
102
+ if (!result?.available) return;
103
+ const isWindows = process.platform === "win32";
104
+ const updateCmd = isWindows ? "npm install -g hyperclaw@latest" : "sudo npm install -g hyperclaw@latest";
105
+ console.log();
106
+ console.log(chalk.default.yellow(` 🦅 New version available! `) + chalk.default.bold.white(result.latest) + chalk.default.gray(` (you have ${current})`));
107
+ console.log(chalk.default.gray(` 📦 ${updateCmd}`));
108
+ console.log();
109
+ const inquirer = (await import("inquirer")).default;
110
+ const { choice } = await inquirer.prompt([{
111
+ type: "list",
112
+ name: "choice",
113
+ message: chalk.default.cyan("What would you like to do?"),
114
+ choices: [{
115
+ name: `🚀 Update now & restart chat ${chalk.default.gray("(recommended)")}`,
116
+ value: "update"
117
+ }, {
118
+ name: `⏭️ Skip — continue to chat`,
119
+ value: "skip"
120
+ }],
121
+ prefix: " ✨"
122
+ }]);
123
+ process.stdout.write("\n");
124
+ if (choice === "skip") {
125
+ console.log(chalk.default.gray(` ⏭️ Skipping — run: ${updateCmd} when ready.\n`));
126
+ return;
127
+ }
128
+ console.log(chalk.default.cyan(" ⏳ Updating HyperClaw...\n"));
129
+ const updateArgs = isWindows ? [
130
+ "install",
131
+ "-g",
132
+ "hyperclaw@latest"
133
+ ] : [
134
+ "npm",
135
+ "install",
136
+ "-g",
137
+ "hyperclaw@latest"
138
+ ];
139
+ const updateBin = isWindows ? "npm" : "sudo";
140
+ await new Promise((resolve) => {
141
+ const proc = (0, child_process.spawn)(updateBin, updateArgs, {
142
+ stdio: "inherit",
143
+ shell: true
144
+ });
145
+ proc.on("close", (code) => {
146
+ if (code === 0) {
147
+ console.log(chalk.default.green(`\n ✅ Updated to ${result.latest}! Restarting chat...\n`));
148
+ const newProc = (0, child_process.spawn)(process.argv[0], process.argv.slice(1), {
149
+ stdio: "inherit",
150
+ shell: false,
151
+ detached: false
152
+ });
153
+ newProc.on("close", (c) => process.exit(c ?? 0));
154
+ newProc.on("error", () => {
155
+ console.log(chalk.default.yellow(" ⚠️ Could not auto-restart. Run: hyperclaw chat\n"));
156
+ process.exit(0);
157
+ });
158
+ } else {
159
+ console.log(chalk.default.red(`\n ❌ Update failed (exit ${code}). Continuing with current version...\n`));
160
+ if (!isWindows) console.log(chalk.default.gray(" 💡 If you use nvm/fnm, try without sudo: npm install -g hyperclaw@latest\n"));
161
+ resolve();
162
+ }
163
+ });
164
+ proc.on("error", () => resolve());
165
+ });
166
+ } catch {}
167
+ }
168
+ function makeSessionId() {
169
+ const { randomBytes } = require("crypto");
170
+ return randomBytes(5).toString("hex");
171
+ }
172
+ async function runChat(opts) {
173
+ const cfg = await fs_extra.default.readJson(require_paths.getConfigPath()).catch(() => null);
174
+ if (!cfg) {
175
+ console.log(chalk.default.red("\n No configuration found.\n"));
176
+ console.log(chalk.default.gray(" Chat works without the gateway. Run: hyperclaw onboard\n"));
177
+ return;
178
+ }
179
+ const { getProviderCredentialAsync } = await Promise.resolve().then(() => require("./env-resolve-pIETNTpQ.js"));
180
+ const apiKey = await getProviderCredentialAsync(cfg).catch(() => null);
181
+ const isLocal = [
182
+ "local",
183
+ "ollama",
184
+ "lmstudio"
185
+ ].includes(cfg?.provider?.providerId ?? "");
186
+ if (!apiKey && !isLocal) {
187
+ console.log(chalk.default.red("\n No API key configured.\n"));
188
+ console.log(chalk.default.gray(" Chat uses your AI provider directly (no gateway needed). Run: hyperclaw config set-key\n"));
189
+ return;
190
+ }
191
+ const { getProvider } = await Promise.resolve().then(() => require("./providers-CFQC39vg.js"));
192
+ const providerMeta = getProvider(cfg?.provider?.providerId ?? "");
193
+ const CUSTOM_IDS = new Set([
194
+ "groq",
195
+ "mistral",
196
+ "deepseek",
197
+ "perplexity",
198
+ "huggingface",
199
+ "ollama",
200
+ "lmstudio",
201
+ "local",
202
+ "xai",
203
+ "openai",
204
+ "google",
205
+ "minimax",
206
+ "moonshot",
207
+ "qwen",
208
+ "zai",
209
+ "litellm",
210
+ "cloudflare",
211
+ "copilot",
212
+ "vercel-ai",
213
+ "opencode-zen"
214
+ ]);
215
+ const isAnthropicVariant = [
216
+ "anthropic",
217
+ "anthropic-oauth",
218
+ "anthropic-setup-token"
219
+ ].includes(cfg?.provider?.providerId ?? "");
220
+ const provider = isAnthropicVariant ? "anthropic" : cfg?.provider?.providerId === "custom" || isLocal || CUSTOM_IDS.has(cfg?.provider?.providerId ?? "") ? "custom" : "openrouter";
221
+ let rawModel = opts.model || cfg?.provider?.modelId || "claude-sonnet-4-5";
222
+ const model = rawModel.startsWith("ollama/") ? rawModel.slice(7) : rawModel;
223
+ const resolvedBaseUrl = cfg?.provider?.baseUrl || providerMeta?.baseUrl || (isLocal ? "http://localhost:11434/v1" : void 0);
224
+ const THINKING_BUDGET = {
225
+ high: 1e4,
226
+ medium: 4e3,
227
+ low: 1e3,
228
+ none: 0
229
+ };
230
+ const thinkingBudget = THINKING_BUDGET[opts.thinking ?? "none"] ?? 0;
231
+ const maxTokens = thinkingBudget > 0 ? thinkingBudget + 4096 : 4096;
232
+ const baseContext = await require_engine.loadWorkspaceContext(opts.workspace) + await require_engine.loadSkillsContext();
233
+ const tools = await require_engine.resolveTools({
234
+ config: cfg,
235
+ source: "cli",
236
+ elevated: true,
237
+ daemonMode: false
238
+ });
239
+ let sessionExtraPrompt = "";
240
+ const sessionActiveSkills = /* @__PURE__ */ new Map();
241
+ function buildSystemPrompt() {
242
+ let sys = baseContext;
243
+ if (sessionExtraPrompt) sys += `\n\n## Session Instructions\n${sessionExtraPrompt}`;
244
+ if (sessionActiveSkills.size > 0) {
245
+ sys += `\n\n## Session Skills\n`;
246
+ for (const [id, ctx] of sessionActiveSkills) sys += `### ${id}\n${ctx}\n\n`;
247
+ }
248
+ return sys || "";
249
+ }
250
+ const engineOpts = {
251
+ model,
252
+ apiKey,
253
+ provider,
254
+ system: buildSystemPrompt() || void 0,
255
+ tools,
256
+ maxTokens,
257
+ onToken: () => {},
258
+ ...provider === "custom" ? { baseUrl: resolvedBaseUrl || "" } : {},
259
+ ...thinkingBudget > 0 && model.includes("claude") ? { thinking: { budget_tokens: thinkingBudget } } : {}
260
+ };
261
+ const sessionId = opts.sessionId ?? makeSessionId();
262
+ const messages = [];
263
+ let autoMem = null;
264
+ try {
265
+ const { AutoMemory } = await Promise.resolve().then(() => require("./memory-auto-Bh52cQJP.js"));
266
+ autoMem = new AutoMemory({ extractEveryNTurns: 3 });
267
+ } catch {}
268
+ printHeader(rawModel, sessionId);
269
+ await interactiveChatUpdateCheck();
270
+ process.stdout.write("\x1B[0m");
271
+ if (process.stdin.isTTY) process.stdin.resume();
272
+ const rl = readline.default.createInterface({
273
+ input: process.stdin,
274
+ output: process.stdout,
275
+ terminal: true
276
+ });
277
+ rl.on("SIGINT", () => {
278
+ console.log(chalk.default.gray("\n\n Bye!\n"));
279
+ rl.close();
280
+ process.exit(0);
281
+ });
282
+ const daemonMode = opts.daemonMode ?? false;
283
+ const t = (await Promise.resolve().then(() => require("./theme-DdZT-Bq4.js"))).getTheme(daemonMode);
284
+ await new Promise((resolve) => {
285
+ rl.on("close", resolve);
286
+ const BOX_W = 60;
287
+ const TOP = t.a(" ╭" + "─".repeat(BOX_W) + "╮");
288
+ const BOT = t.a(" ╰" + "─".repeat(BOX_W) + "╯");
289
+ const INPUT_PROMPT = t.a(" │ ") + t.bold("❯ ");
290
+ const prompt = () => {
291
+ process.stdout.write("\n" + TOP + "\n");
292
+ rl.question(INPUT_PROMPT, (input) => {
293
+ process.stdout.write(BOT + "\n");
294
+ if (input === null || input === void 0) {
295
+ prompt();
296
+ return;
297
+ }
298
+ (async () => {
299
+ const text = input.trim();
300
+ if (!text) {
301
+ prompt();
302
+ return;
303
+ }
304
+ if ([
305
+ "/exit",
306
+ "/quit",
307
+ "/bye",
308
+ "exit",
309
+ "quit",
310
+ "bye"
311
+ ].includes(text.toLowerCase())) {
312
+ console.log(chalk.default.gray("\n Bye!\n"));
313
+ rl.close();
314
+ process.exit(0);
315
+ }
316
+ if (text === "/help") {
317
+ printHelp();
318
+ prompt();
319
+ return;
320
+ }
321
+ if (text === "/skills") {
322
+ await printSkills();
323
+ prompt();
324
+ return;
325
+ }
326
+ if (text === "/model" || text.startsWith("/model ")) {
327
+ const newModelArg = text.slice(7).trim().replace(/^<|>$/g, "");
328
+ if (newModelArg) {
329
+ rawModel = newModelArg;
330
+ engineOpts.model = rawModel.startsWith("ollama/") ? rawModel.slice(7) : rawModel;
331
+ console.log(chalk.default.green(`\n 🤖 Model switched to: ${chalk.default.bold(rawModel)}\n`));
332
+ } else if (providerMeta?.models?.length) {
333
+ rl.pause();
334
+ try {
335
+ const inquirer = (await import("inquirer")).default;
336
+ const defaultIdx = Math.max(0, providerMeta.models.findIndex((m) => m.id === rawModel));
337
+ const { selected } = await inquirer.prompt([{
338
+ type: "list",
339
+ name: "selected",
340
+ message: chalk.default.cyan("Select model") + chalk.default.gray(" (↑↓ arrows, Enter to confirm):"),
341
+ choices: providerMeta.models.map((m) => ({
342
+ name: `${m.id} ${chalk.default.gray(m.name)}`,
343
+ value: m.id,
344
+ short: m.id
345
+ })),
346
+ default: defaultIdx,
347
+ prefix: " "
348
+ }]);
349
+ rawModel = selected;
350
+ engineOpts.model = rawModel.startsWith("ollama/") ? rawModel.slice(7) : rawModel;
351
+ console.log(chalk.default.green(`\n 🤖 Model switched to: ${chalk.default.bold(rawModel)}\n`));
352
+ } catch {
353
+ console.log(chalk.default.gray("\n Selection failed. Use: /model <model-id> (e.g. claude-sonnet-4-5)\n"));
354
+ } finally {
355
+ rl.resume();
356
+ }
357
+ } else {
358
+ console.log(chalk.default.gray(`\n Current model: ${chalk.default.bold(rawModel)}`));
359
+ console.log(chalk.default.gray(" Use: /model <model-id>\n"));
360
+ }
361
+ prompt();
362
+ return;
363
+ }
364
+ if (text === "/clear") {
365
+ messages.length = 0;
366
+ console.log(chalk.default.gray("\n 🗑️ Conversation cleared.\n"));
367
+ prompt();
368
+ return;
369
+ }
370
+ if (text === "/prompt" || text.startsWith("/prompt ")) {
371
+ const arg = text.slice(7).trim();
372
+ if (!arg) {
373
+ console.log();
374
+ if (sessionExtraPrompt) {
375
+ console.log(chalk.default.bold(" 📝 Session prompt:"));
376
+ console.log(chalk.default.white(` ${sessionExtraPrompt.slice(0, 400)}${sessionExtraPrompt.length > 400 ? "…" : ""}`));
377
+ } else console.log(chalk.default.gray(" 📝 No extra prompt set. Use: /prompt <text>"));
378
+ console.log();
379
+ } else if (arg === "clear") {
380
+ sessionExtraPrompt = "";
381
+ engineOpts.system = buildSystemPrompt() || void 0;
382
+ console.log(chalk.default.green("\n 🧹 Extra prompt cleared.\n"));
383
+ } else {
384
+ sessionExtraPrompt = arg;
385
+ engineOpts.system = buildSystemPrompt() || void 0;
386
+ console.log(chalk.default.green(`\n ✅ Session prompt set: ${chalk.default.white(arg.slice(0, 60))}${arg.length > 60 ? "…" : ""}\n`));
387
+ }
388
+ prompt();
389
+ return;
390
+ }
391
+ if (text === "/skill" || text.startsWith("/skill ")) {
392
+ const arg = text.slice(6).trim();
393
+ const [subCmd, ...rest] = arg.split(/\s+/);
394
+ const skillId = rest.join(" ").trim();
395
+ if (!subCmd || subCmd === "list") {
396
+ await printSkills();
397
+ prompt();
398
+ return;
399
+ }
400
+ if (subCmd === "add") {
401
+ if (!skillId) {
402
+ console.log(chalk.default.gray("\n Usage: /skill add <skill-id>\n"));
403
+ prompt();
404
+ return;
405
+ }
406
+ try {
407
+ const { loadSkills } = await Promise.resolve().then(() => require("./skill-loader-DK19Jm4e.js"));
408
+ const allSkills = await loadSkills();
409
+ const found = allSkills.find((s) => s.id === skillId || (s.title ?? "").toLowerCase() === skillId.toLowerCase());
410
+ if (!found) console.log(chalk.default.yellow(`\n ⚠️ Skill "${skillId}" not found. Use /skills to list installed.\n`));
411
+ else {
412
+ const ctx = [
413
+ found.title ? `**${found.title}**` : found.id,
414
+ found.capabilities ? found.capabilities : "",
415
+ found.description ? found.description : ""
416
+ ].filter(Boolean).join("\n");
417
+ sessionActiveSkills.set(found.id, ctx);
418
+ engineOpts.system = buildSystemPrompt() || void 0;
419
+ console.log(chalk.default.green(`\n ✅ Skill activated: ${chalk.default.bold(found.title || found.id)}\n`));
420
+ }
421
+ } catch (e) {
422
+ console.log(chalk.default.red(`\n ❌ Error loading skills: ${e?.message || String(e)}\n`));
423
+ }
424
+ prompt();
425
+ return;
426
+ }
427
+ if (subCmd === "remove") {
428
+ if (!skillId) {
429
+ console.log(chalk.default.gray("\n Usage: /skill remove <skill-id>\n"));
430
+ prompt();
431
+ return;
432
+ }
433
+ if (sessionActiveSkills.has(skillId)) {
434
+ sessionActiveSkills.delete(skillId);
435
+ engineOpts.system = buildSystemPrompt() || void 0;
436
+ console.log(chalk.default.green(`\n ✅ Skill deactivated: ${skillId}\n`));
437
+ } else console.log(chalk.default.gray(`\n ℹ️ Skill "${skillId}" is not active in this session.\n`));
438
+ prompt();
439
+ return;
440
+ }
441
+ console.log(chalk.default.gray("\n ℹ️ Usage: /skill list | /skill add <id> | /skill remove <id>\n"));
442
+ prompt();
443
+ return;
444
+ }
445
+ messages.push({
446
+ role: "user",
447
+ content: text
448
+ });
449
+ console.log(chalk.default.gray(" " + "─".repeat(56)));
450
+ console.log(chalk.default.bold.green(" 💬 You › ") + chalk.default.white(text));
451
+ console.log(chalk.default.gray(" " + "─".repeat(56)));
452
+ let responseText = "";
453
+ let elapsed = 0;
454
+ let ticker;
455
+ const spinner = (0, ora.default)({
456
+ text: chalk.default.cyan(` 🤔 Thinking... (${elapsed}s • Ctrl+C to cancel)`),
457
+ prefixText: ""
458
+ }).start();
459
+ ticker = setInterval(() => {
460
+ elapsed++;
461
+ spinner.text = chalk.default.cyan(` 🤔 Thinking... (${elapsed}s • Ctrl+C to cancel)`);
462
+ }, 1e3);
463
+ try {
464
+ const engine = new require_inference.InferenceEngine({
465
+ ...engineOpts,
466
+ onToken: () => {
467
+ if (spinner.isSpinning) spinner.text = chalk.default.cyan(` 📥 Receiving... (${elapsed}s • Ctrl+C to cancel)`);
468
+ },
469
+ onToolCall: (name) => {
470
+ spinner.stop();
471
+ console.log(chalk.default.yellow(`\n 🔧 ${chalk.default.bold(name)}`));
472
+ spinner.start(chalk.default.cyan(` ⚙️ Working (${elapsed}s • Ctrl+C to cancel)`));
473
+ }
474
+ });
475
+ const result = await engine.run(messages);
476
+ responseText = result.text || "";
477
+ if (ticker) clearInterval(ticker);
478
+ spinner.stop();
479
+ console.log(chalk.default.bold.blue("\n 🦅 Agent ›"));
480
+ if (responseText) process.stdout.write(renderMarkdown(responseText));
481
+ else process.stdout.write(chalk.default.gray(" (empty — try rephrasing or check model/tools)"));
482
+ console.log("\n");
483
+ console.log(chalk.default.gray(" " + "─".repeat(56)));
484
+ if (result.usage) console.log(chalk.default.gray(` 📊 Tokens in: ${result.usage.input} out: ${result.usage.output} · ${rawModel}\n`));
485
+ else console.log();
486
+ } catch (e) {
487
+ if (ticker) clearInterval(ticker);
488
+ spinner.stop();
489
+ const msg = e?.message || String(e);
490
+ responseText = `Error: ${msg}`;
491
+ console.log(chalk.default.red(`\n Error: ${msg}\n`));
492
+ const hint = (() => {
493
+ if (/401|unauthorized|invalid.*key|authentication/i.test(msg)) return "🔑 Check API key: hyperclaw config set-key";
494
+ if (/429|rate.?limit|quota/i.test(msg)) return "⏱️ Rate limited. Wait a moment and retry.";
495
+ if (/500|503|service.?unavailable/i.test(msg)) return "🔌 Provider temporarily down. Try again later.";
496
+ if (/network|ECONNREFUSED|ETIMEDOUT|fetch failed/i.test(msg)) return "🌐 Network error. Check connection and base URL.";
497
+ if (/model|not found|invalid model/i.test(msg)) return "🤖 Try: /model <id> to switch model.";
498
+ return "🩺 Run: hyperclaw doctor for setup checks.";
499
+ })();
500
+ console.log(chalk.default.gray(` ${hint}\n`));
501
+ }
502
+ if (responseText) messages.push({
503
+ role: "assistant",
504
+ content: responseText
505
+ });
506
+ if (autoMem) {
507
+ autoMem.addTurn("user", text);
508
+ if (responseText) autoMem.addTurn("assistant", responseText);
509
+ autoMem.extract().catch(() => {});
510
+ }
511
+ prompt();
512
+ })().catch((err) => {
513
+ console.error(chalk.default.red("\n Unexpected error:"), err?.message || err);
514
+ prompt();
515
+ });
516
+ });
517
+ };
518
+ prompt();
519
+ });
520
+ }
521
+
522
+ //#endregion
523
+ exports.runChat = runChat;
@@ -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('./server-vbYKep6r.js');
5
+ const require_daemon = require('./daemon-DcE6vcjH.js');
6
+
7
+ exports.DaemonManager = require_daemon.DaemonManager;