blun-king-cli 2.1.1 → 2.2.1

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 (2) hide show
  1. package/bin/blun.js +104 -10
  2. package/package.json +1 -1
package/bin/blun.js CHANGED
@@ -1375,19 +1375,62 @@ function cmdPermissions(args) {
1375
1375
 
1376
1376
  // ── Agent Loop (CLI wrapper) ──
1377
1377
  async function cmdAgent(args) {
1378
- if (!args) { printError("Usage: /agent <goal>"); return; }
1378
+ if (!args) { printError("Usage: /agent <goal> — runs autonomously until done"); return; }
1379
1379
  try {
1380
1380
  printUserMessage(args);
1381
- process.stdout.write(C.dim + " " + BOX.bot + " working autonomously..." + C.reset);
1382
- var resp = await apiCall("POST", "/agent", { goal: args, verbose: true });
1383
- process.stdout.write("\r" + " ".repeat(50) + "\r");
1384
- if (resp.status !== 200) { printError(resp.data.error || "Error"); return; }
1385
- var d = resp.data;
1386
- var meta = d.steps_executed + " steps" + (d.files.length > 0 ? " " + BOX.dot + " " + d.files.length + " files" : "");
1387
- printAnswer(d.answer, meta);
1388
- if (d.files.length > 0) {
1381
+ var maxLoops = 20;
1382
+ var loop = 0;
1383
+ var totalFiles = [];
1384
+ var lastAnswer = "";
1385
+ var goal = args;
1386
+ var context = [];
1387
+
1388
+ while (loop < maxLoops) {
1389
+ loop++;
1390
+ // Phase indicator
1391
+ var phase = loop === 1 ? "planning" : "step " + loop;
1392
+ process.stdout.write("\r\x1b[K" + C.dim + " " + BOX.bot + " [" + phase + "/" + maxLoops + "] working..." + C.reset);
1393
+
1394
+ var resp = await apiCall("POST", "/agent", {
1395
+ goal: goal,
1396
+ context: context.slice(-5),
1397
+ verbose: false
1398
+ });
1399
+ process.stdout.write("\r\x1b[K");
1400
+
1401
+ if (resp.status !== 200) {
1402
+ printError("Step " + loop + " failed: " + (resp.data.error || "Error"));
1403
+ break;
1404
+ }
1405
+
1406
+ var d = resp.data;
1407
+ lastAnswer = d.answer || "";
1408
+ if (d.files && d.files.length > 0) totalFiles = totalFiles.concat(d.files);
1409
+ context.push({ step: loop, answer: lastAnswer.slice(0, 500), files: (d.files || []).length });
1410
+
1411
+ // Check if the agent says it's done
1412
+ var doneSignals = ["done", "complete", "finished", "fertig", "erledigt", "all steps", "nothing left"];
1413
+ var isDone = doneSignals.some(function(s) { return lastAnswer.toLowerCase().includes(s); });
1414
+
1415
+ // Show brief step result
1416
+ console.log(C.dim + " [" + loop + "] " + C.reset + C.green + (d.steps_executed || 1) + " steps" +
1417
+ (d.files && d.files.length > 0 ? ", " + d.files.length + " files" : "") + C.reset +
1418
+ (isDone ? C.yellow + " ✓ done" + C.reset : ""));
1419
+
1420
+ if (isDone) break;
1421
+
1422
+ // Feed result back as next goal
1423
+ goal = "Continue with the original goal: " + args + "\n\nLast step result: " + lastAnswer.slice(0, 1000) +
1424
+ "\n\nWhat is the next step? If everything is done, say 'done'.";
1425
+ }
1426
+
1427
+ // Final summary
1428
+ console.log("");
1429
+ var meta = loop + " loops" + (totalFiles.length > 0 ? " " + BOX.dot + " " + totalFiles.length + " files total" : "");
1430
+ printAnswer(lastAnswer, meta);
1431
+ if (totalFiles.length > 0) {
1389
1432
  console.log(C.green + " Files:" + C.reset);
1390
- d.files.forEach(function(f) { console.log(" " + C.brightCyan + f.name + C.reset + " " + config.api.base_url + f.download); });
1433
+ totalFiles.forEach(function(f) { console.log(" " + C.brightCyan + f.name + C.reset + " \u2192 " + config.api.base_url + f.download); });
1391
1434
  console.log("");
1392
1435
  }
1393
1436
  } catch(e) { printError(e.message); }
@@ -2415,6 +2458,57 @@ async function main() {
2415
2458
  return;
2416
2459
  }
2417
2460
 
2461
+ // Ctrl+V — paste (check clipboard for image)
2462
+ if (key === "\x16") {
2463
+ (async function() {
2464
+ try {
2465
+ var imgPath = path.join(os.tmpdir(), "blun_paste_" + Date.now() + ".png");
2466
+ var isWin = process.platform === "win32";
2467
+ if (isWin) {
2468
+ var psCmd = "powershell -NoProfile -Command \"$img = Get-Clipboard -Format Image; if($img){ $img.Save('" + imgPath.replace(/\\/g, "\\\\") + "'); Write-Output 'OK' } else { Write-Output 'NO' }\"";
2469
+ var psResult = require("child_process").execSync(psCmd, { encoding: "utf8", timeout: 5000 }).trim();
2470
+ if (psResult === "OK" && fs.existsSync(imgPath)) {
2471
+ eraseUI();
2472
+ printInfo("Image pasted from clipboard");
2473
+ var imgData = fs.readFileSync(imgPath).toString("base64");
2474
+ var prompt = inputBuffer.trim() || "Describe this image";
2475
+ processing = true;
2476
+ var resp = await apiCall("POST", "/chat", {
2477
+ message: prompt,
2478
+ image: imgData,
2479
+ history: chatHistory.slice(-10)
2480
+ });
2481
+ if (resp.status === 200) {
2482
+ chatHistory.push({ role: "user", content: "[image] " + prompt });
2483
+ chatHistory.push({ role: "assistant", content: resp.data.answer });
2484
+ printAnswer(resp.data.answer, "vision");
2485
+ } else {
2486
+ printError(resp.data.error || "Vision error");
2487
+ }
2488
+ inputBuffer = "";
2489
+ cursorPos = 0;
2490
+ processing = false;
2491
+ drawPrompt();
2492
+ try { fs.unlinkSync(imgPath); } catch(e) {}
2493
+ return;
2494
+ }
2495
+ }
2496
+ // No image — just paste text from clipboard
2497
+ if (isWin) {
2498
+ var clipText = require("child_process").execSync("powershell -NoProfile -Command Get-Clipboard", { encoding: "utf8", timeout: 3000 }).trim();
2499
+ if (clipText) {
2500
+ inputBuffer += clipText;
2501
+ cursorPos = inputBuffer.length;
2502
+ refreshUI();
2503
+ }
2504
+ }
2505
+ } catch(e) {
2506
+ // Fallback: ignore paste errors
2507
+ }
2508
+ })();
2509
+ return;
2510
+ }
2511
+
2418
2512
  // Tab — autocomplete from menu
2419
2513
  if (key === "\t") {
2420
2514
  if (menuVisible && menuItems.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
4
4
  "description": "BLUN King CLI — Premium KI Console",
5
5
  "bin": {
6
6
  "blun": "./bin/blun.js"