@openclawcity/become 1.0.9 → 1.0.12

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/cli.js CHANGED
@@ -115,10 +115,13 @@ function patchOpenClaw(config, agentId) {
115
115
  ]
116
116
  };
117
117
  writeFileSync2(OPENCLAW_CONFIG, JSON.stringify(clawConfig, null, 2), "utf-8");
118
+ console.log("Restarting OpenClaw gateway...");
118
119
  try {
119
120
  execSync("openclaw gateway restart", { stdio: "pipe", timeout: 15e3 });
121
+ console.log("OpenClaw gateway restarted. Your agent is now routing through become.");
120
122
  } catch {
121
- console.log("Warning: Could not restart OpenClaw gateway. Restart it manually: openclaw gateway restart");
123
+ console.log("\n*** OpenClaw gateway needs a manual restart to pick up the new config. ***");
124
+ console.log("*** Run: openclaw gateway restart ***\n");
122
125
  }
123
126
  }
124
127
  function restoreOpenClaw() {
@@ -197,10 +200,13 @@ function readStateFile(path) {
197
200
  }
198
201
  }
199
202
  function restartGateway() {
203
+ console.log("Restarting OpenClaw gateway...");
200
204
  try {
201
205
  execSync("openclaw gateway restart", { stdio: "pipe", timeout: 15e3 });
206
+ console.log("OpenClaw gateway restarted.");
202
207
  } catch {
203
- console.log("Warning: Could not restart OpenClaw gateway. Restart it manually: openclaw gateway restart");
208
+ console.log("\n*** OpenClaw gateway needs a manual restart. ***");
209
+ console.log("*** Run: openclaw gateway restart ***\n");
204
210
  }
205
211
  }
206
212
 
@@ -725,16 +731,18 @@ function createProxyServer(config, analyzer) {
725
731
  return cachedSkills;
726
732
  }
727
733
  const server = createServer(async (req, res) => {
734
+ console.log(`[become] ${req.method} ${req.url}`);
728
735
  if (req.url === "/health" && req.method === "GET") {
729
736
  res.writeHead(200, { "Content-Type": "application/json" });
730
737
  res.end(JSON.stringify({ status: "ok", ...stats }));
731
738
  return;
732
739
  }
733
- const isOpenAI = req.url === "/v1/chat/completions";
734
- const isAnthropic = req.url === "/v1/messages";
735
- if (req.method !== "POST" || !isOpenAI && !isAnthropic) {
740
+ const url = req.url ?? "";
741
+ const isLLMRequest = req.method === "POST" && (url.includes("/chat/completions") || url.includes("/messages") || url === "/" || url.startsWith("/v1"));
742
+ if (!isLLMRequest) {
743
+ console.log(`[become] rejected: ${req.method} ${url}`);
736
744
  res.writeHead(404, { "Content-Type": "application/json" });
737
- res.end(JSON.stringify({ error: "Not found. Use POST /v1/chat/completions or /v1/messages" }));
745
+ res.end(JSON.stringify({ error: `Not an LLM endpoint: ${req.method} ${url}` }));
738
746
  return;
739
747
  }
740
748
  try {
@@ -1397,10 +1405,13 @@ function patchIronClaw(config) {
1397
1405
  patchDotEnv(IRONCLAW_ENV, {
1398
1406
  LLM_BASE_URL: `http://127.0.0.1:${config.proxy_port}/v1`
1399
1407
  });
1408
+ console.log("Restarting IronClaw...");
1400
1409
  try {
1401
1410
  execSync2("ironclaw service restart", { stdio: "pipe", timeout: 15e3 });
1411
+ console.log("IronClaw restarted.");
1402
1412
  } catch {
1403
- console.log("Warning: Could not restart IronClaw. Restart it manually: ironclaw service restart");
1413
+ console.log("\n*** IronClaw needs a manual restart. ***");
1414
+ console.log("*** Run: ironclaw service restart ***\n");
1404
1415
  }
1405
1416
  }
1406
1417
  function restoreIronClaw() {
@@ -1408,10 +1419,13 @@ function restoreIronClaw() {
1408
1419
  throw new Error("No backup found. Was become ever turned on?");
1409
1420
  }
1410
1421
  copyFileSync(BACKUP_PATH2, IRONCLAW_ENV);
1422
+ console.log("Restarting IronClaw...");
1411
1423
  try {
1412
1424
  execSync2("ironclaw service restart", { stdio: "pipe", timeout: 15e3 });
1425
+ console.log("IronClaw restarted.");
1413
1426
  } catch {
1414
- console.log("Warning: Could not restart IronClaw. Restart it manually: ironclaw service restart");
1427
+ console.log("\n*** IronClaw needs a manual restart. ***");
1428
+ console.log("*** Run: ironclaw service restart ***\n");
1415
1429
  }
1416
1430
  }
1417
1431
  function patchDotEnv(path, vars) {
@@ -1474,13 +1488,18 @@ function findNanoClawEnv() {
1474
1488
  return null;
1475
1489
  }
1476
1490
  function restartNanoClaw() {
1491
+ console.log("Restarting NanoClaw...");
1477
1492
  try {
1478
1493
  execSync3("launchctl kickstart -k gui/$(id -u)/ai.nanoclaw.agent", { stdio: "pipe", timeout: 15e3 });
1494
+ console.log("NanoClaw restarted.");
1479
1495
  } catch {
1480
1496
  try {
1481
1497
  execSync3("systemctl --user restart nanoclaw", { stdio: "pipe", timeout: 15e3 });
1498
+ console.log("NanoClaw restarted.");
1482
1499
  } catch {
1483
- console.log("Warning: Could not restart NanoClaw. Restart it manually.");
1500
+ console.log("\n*** NanoClaw needs a manual restart. ***");
1501
+ console.log("*** macOS: launchctl kickstart -k gui/$(id -u)/ai.nanoclaw.agent ***");
1502
+ console.log("*** Linux: systemctl --user restart nanoclaw ***\n");
1484
1503
  }
1485
1504
  }
1486
1505
  }
@@ -1548,12 +1567,26 @@ async function start() {
1548
1567
  become proxy running on localhost:${config.proxy_port}`);
1549
1568
  console.log(`become dashboard at http://localhost:${config.dashboard_port}`);
1550
1569
  console.log(`
1551
- Skills loaded: ${approved} approved, ${pending} pending`);
1570
+ Connected to: ${config.agent_type}${config.openclaw_agent_id ? ` (agent: ${config.openclaw_agent_id})` : ""}`);
1571
+ console.log(`Skills loaded: ${approved} approved, ${pending} pending`);
1552
1572
  console.log(`Trust rules: ${trustConfig.trusted.length} trusted, ${trustConfig.blocked.length} blocked`);
1553
1573
  console.log("\nYour agent is learning from other agents.");
1554
1574
  console.log("Dashboard: http://localhost:" + config.dashboard_port);
1555
- console.log("Ctrl+C to stop.\n");
1575
+ console.log("Ctrl+C to stop.");
1576
+ setTimeout(() => {
1577
+ if (proxy.stats.requests_forwarded === 0) {
1578
+ console.log("\nWaiting for first request from your agent...");
1579
+ console.log("(If nothing happens, make sure your agent is running and talking to other agents)");
1580
+ }
1581
+ }, 1e4);
1582
+ const activityInterval = setInterval(() => {
1583
+ const s = proxy.stats;
1584
+ if (s.requests_forwarded > 0) {
1585
+ console.log(`[become] ${s.requests_forwarded} requests forwarded, ${s.skills_injected} skills injected, ${s.lessons_extracted} lessons extracted`);
1586
+ }
1587
+ }, 6e4);
1556
1588
  const shutdown = async () => {
1589
+ clearInterval(activityInterval);
1557
1590
  console.log("\nShutting down...");
1558
1591
  try {
1559
1592
  turnOff();