@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.cjs CHANGED
@@ -154,10 +154,13 @@ function patchOpenClaw(config, agentId) {
154
154
  ]
155
155
  };
156
156
  (0, import_node_fs2.writeFileSync)(OPENCLAW_CONFIG, JSON.stringify(clawConfig, null, 2), "utf-8");
157
+ console.log("Restarting OpenClaw gateway...");
157
158
  try {
158
159
  (0, import_node_child_process.execSync)("openclaw gateway restart", { stdio: "pipe", timeout: 15e3 });
160
+ console.log("OpenClaw gateway restarted. Your agent is now routing through become.");
159
161
  } catch {
160
- console.log("Warning: Could not restart OpenClaw gateway. Restart it manually: openclaw gateway restart");
162
+ console.log("\n*** OpenClaw gateway needs a manual restart to pick up the new config. ***");
163
+ console.log("*** Run: openclaw gateway restart ***\n");
161
164
  }
162
165
  }
163
166
  function restoreOpenClaw() {
@@ -236,10 +239,13 @@ function readStateFile(path) {
236
239
  }
237
240
  }
238
241
  function restartGateway() {
242
+ console.log("Restarting OpenClaw gateway...");
239
243
  try {
240
244
  (0, import_node_child_process.execSync)("openclaw gateway restart", { stdio: "pipe", timeout: 15e3 });
245
+ console.log("OpenClaw gateway restarted.");
241
246
  } catch {
242
- console.log("Warning: Could not restart OpenClaw gateway. Restart it manually: openclaw gateway restart");
247
+ console.log("\n*** OpenClaw gateway needs a manual restart. ***");
248
+ console.log("*** Run: openclaw gateway restart ***\n");
243
249
  }
244
250
  }
245
251
 
@@ -764,16 +770,18 @@ function createProxyServer(config, analyzer) {
764
770
  return cachedSkills;
765
771
  }
766
772
  const server = (0, import_node_http.createServer)(async (req, res) => {
773
+ console.log(`[become] ${req.method} ${req.url}`);
767
774
  if (req.url === "/health" && req.method === "GET") {
768
775
  res.writeHead(200, { "Content-Type": "application/json" });
769
776
  res.end(JSON.stringify({ status: "ok", ...stats }));
770
777
  return;
771
778
  }
772
- const isOpenAI = req.url === "/v1/chat/completions";
773
- const isAnthropic = req.url === "/v1/messages";
774
- if (req.method !== "POST" || !isOpenAI && !isAnthropic) {
779
+ const url = req.url ?? "";
780
+ const isLLMRequest = req.method === "POST" && (url.includes("/chat/completions") || url.includes("/messages") || url === "/" || url.startsWith("/v1"));
781
+ if (!isLLMRequest) {
782
+ console.log(`[become] rejected: ${req.method} ${url}`);
775
783
  res.writeHead(404, { "Content-Type": "application/json" });
776
- res.end(JSON.stringify({ error: "Not found. Use POST /v1/chat/completions or /v1/messages" }));
784
+ res.end(JSON.stringify({ error: `Not an LLM endpoint: ${req.method} ${url}` }));
777
785
  return;
778
786
  }
779
787
  try {
@@ -1436,10 +1444,13 @@ function patchIronClaw(config) {
1436
1444
  patchDotEnv(IRONCLAW_ENV, {
1437
1445
  LLM_BASE_URL: `http://127.0.0.1:${config.proxy_port}/v1`
1438
1446
  });
1447
+ console.log("Restarting IronClaw...");
1439
1448
  try {
1440
1449
  (0, import_node_child_process2.execSync)("ironclaw service restart", { stdio: "pipe", timeout: 15e3 });
1450
+ console.log("IronClaw restarted.");
1441
1451
  } catch {
1442
- console.log("Warning: Could not restart IronClaw. Restart it manually: ironclaw service restart");
1452
+ console.log("\n*** IronClaw needs a manual restart. ***");
1453
+ console.log("*** Run: ironclaw service restart ***\n");
1443
1454
  }
1444
1455
  }
1445
1456
  function restoreIronClaw() {
@@ -1447,10 +1458,13 @@ function restoreIronClaw() {
1447
1458
  throw new Error("No backup found. Was become ever turned on?");
1448
1459
  }
1449
1460
  (0, import_node_fs5.copyFileSync)(BACKUP_PATH2, IRONCLAW_ENV);
1461
+ console.log("Restarting IronClaw...");
1450
1462
  try {
1451
1463
  (0, import_node_child_process2.execSync)("ironclaw service restart", { stdio: "pipe", timeout: 15e3 });
1464
+ console.log("IronClaw restarted.");
1452
1465
  } catch {
1453
- console.log("Warning: Could not restart IronClaw. Restart it manually: ironclaw service restart");
1466
+ console.log("\n*** IronClaw needs a manual restart. ***");
1467
+ console.log("*** Run: ironclaw service restart ***\n");
1454
1468
  }
1455
1469
  }
1456
1470
  function patchDotEnv(path, vars) {
@@ -1513,13 +1527,18 @@ function findNanoClawEnv() {
1513
1527
  return null;
1514
1528
  }
1515
1529
  function restartNanoClaw() {
1530
+ console.log("Restarting NanoClaw...");
1516
1531
  try {
1517
1532
  (0, import_node_child_process3.execSync)("launchctl kickstart -k gui/$(id -u)/ai.nanoclaw.agent", { stdio: "pipe", timeout: 15e3 });
1533
+ console.log("NanoClaw restarted.");
1518
1534
  } catch {
1519
1535
  try {
1520
1536
  (0, import_node_child_process3.execSync)("systemctl --user restart nanoclaw", { stdio: "pipe", timeout: 15e3 });
1537
+ console.log("NanoClaw restarted.");
1521
1538
  } catch {
1522
- console.log("Warning: Could not restart NanoClaw. Restart it manually.");
1539
+ console.log("\n*** NanoClaw needs a manual restart. ***");
1540
+ console.log("*** macOS: launchctl kickstart -k gui/$(id -u)/ai.nanoclaw.agent ***");
1541
+ console.log("*** Linux: systemctl --user restart nanoclaw ***\n");
1523
1542
  }
1524
1543
  }
1525
1544
  }
@@ -1587,12 +1606,26 @@ async function start() {
1587
1606
  become proxy running on localhost:${config.proxy_port}`);
1588
1607
  console.log(`become dashboard at http://localhost:${config.dashboard_port}`);
1589
1608
  console.log(`
1590
- Skills loaded: ${approved} approved, ${pending} pending`);
1609
+ Connected to: ${config.agent_type}${config.openclaw_agent_id ? ` (agent: ${config.openclaw_agent_id})` : ""}`);
1610
+ console.log(`Skills loaded: ${approved} approved, ${pending} pending`);
1591
1611
  console.log(`Trust rules: ${trustConfig.trusted.length} trusted, ${trustConfig.blocked.length} blocked`);
1592
1612
  console.log("\nYour agent is learning from other agents.");
1593
1613
  console.log("Dashboard: http://localhost:" + config.dashboard_port);
1594
- console.log("Ctrl+C to stop.\n");
1614
+ console.log("Ctrl+C to stop.");
1615
+ setTimeout(() => {
1616
+ if (proxy.stats.requests_forwarded === 0) {
1617
+ console.log("\nWaiting for first request from your agent...");
1618
+ console.log("(If nothing happens, make sure your agent is running and talking to other agents)");
1619
+ }
1620
+ }, 1e4);
1621
+ const activityInterval = setInterval(() => {
1622
+ const s = proxy.stats;
1623
+ if (s.requests_forwarded > 0) {
1624
+ console.log(`[become] ${s.requests_forwarded} requests forwarded, ${s.skills_injected} skills injected, ${s.lessons_extracted} lessons extracted`);
1625
+ }
1626
+ }, 6e4);
1595
1627
  const shutdown = async () => {
1628
+ clearInterval(activityInterval);
1596
1629
  console.log("\nShutting down...");
1597
1630
  try {
1598
1631
  turnOff();