@openclawcity/become 1.0.19 → 1.0.23

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
@@ -807,11 +807,17 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
807
807
  const upstreamHeaders = buildUpstreamHeaders(config, req.headers);
808
808
  const isStreaming = body.stream === true;
809
809
  const modifiedBody = JSON.stringify(body);
810
+ console.log(`[become] -> ${upstreamUrl} (${isStreaming ? "streaming" : "non-streaming"})`);
810
811
  const upstreamRes = await fetch(upstreamUrl, {
811
812
  method: "POST",
812
813
  headers: upstreamHeaders,
813
814
  body: modifiedBody
814
815
  });
816
+ console.log(`[become] <- ${upstreamRes.status} ${upstreamRes.statusText}`);
817
+ if (!upstreamRes.ok) {
818
+ const errBody = await upstreamRes.text().catch(() => "");
819
+ console.log(`[become] ERROR: ${errBody.slice(0, 500)}`);
820
+ }
815
821
  stats.requests_forwarded++;
816
822
  const responseHeaders = {};
817
823
  upstreamRes.headers.forEach((value, key) => {
@@ -848,6 +854,7 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
848
854
  }
849
855
  }
850
856
  } catch (err) {
857
+ console.log(`[become] EXCEPTION: ${err instanceof Error ? err.message : String(err)}`);
851
858
  const safeMessage = err instanceof Error && err.message === "Request body too large" ? "Request body too large" : "Failed to forward request to LLM";
852
859
  if (!res.headersSent) {
853
860
  res.writeHead(502, { "Content-Type": "application/json" });
@@ -1442,6 +1449,7 @@ import { homedir as homedir3 } from "os";
1442
1449
  import { execSync as execSync2 } from "child_process";
1443
1450
  var IRONCLAW_ENV = join5(process.env.IRONCLAW_BASE_DIR ?? join5(homedir3(), ".ironclaw"), ".env");
1444
1451
  var BACKUP_PATH2 = join5(homedir3(), ".become", "state", "original_ironclaw.env");
1452
+ var ORIGINAL_URL_PATH2 = join5(homedir3(), ".become", "state", "original_base_url.txt");
1445
1453
  function patchIronClaw(config) {
1446
1454
  if (!existsSync5(IRONCLAW_ENV)) {
1447
1455
  throw new Error(`IronClaw .env not found at ${IRONCLAW_ENV}`);
@@ -1473,6 +1481,12 @@ function patchIronClaw(config) {
1473
1481
  vars["LLM_BASE_URL"] = proxyUrl;
1474
1482
  break;
1475
1483
  }
1484
+ const urlVarName = Object.keys(vars)[0];
1485
+ const originalUrlMatch = content.match(new RegExp(`^${urlVarName}=(.+)$`, "m"));
1486
+ const originalUrl = originalUrlMatch?.[1]?.trim() ?? "";
1487
+ if (originalUrl) {
1488
+ writeFileSync5(ORIGINAL_URL_PATH2, originalUrl, "utf-8");
1489
+ }
1476
1490
  patchDotEnv(IRONCLAW_ENV, vars);
1477
1491
  console.log(` backend: ${backend}`);
1478
1492
  console.log(` patched: ${Object.keys(vars).join(", ")} -> localhost:${config.proxy_port}`);
@@ -1534,6 +1548,7 @@ import { homedir as homedir4 } from "os";
1534
1548
  import { execSync as execSync3 } from "child_process";
1535
1549
  var BACKUP_PATH3 = join6(homedir4(), ".become", "state", "original_nanoclaw.env");
1536
1550
  var PATCHED_ENV_PATH_FILE = join6(homedir4(), ".become", "state", "nanoclaw_env_path.txt");
1551
+ var ORIGINAL_URL_PATH3 = join6(homedir4(), ".become", "state", "original_base_url.txt");
1537
1552
  var NANOCLAW_URL_VAR = "ANTHROPIC_BASE_URL";
1538
1553
  function patchNanoClaw(config) {
1539
1554
  const envPath = findNanoClawEnv();
@@ -1551,6 +1566,12 @@ Set ${NANOCLAW_URL_VAR}=http://127.0.0.1:${config.proxy_port} manually in your N
1551
1566
  mkdirSync6(join6(homedir4(), ".become", "state"), { recursive: true });
1552
1567
  copyFileSync2(envPath, BACKUP_PATH3);
1553
1568
  writeFileSync6(PATCHED_ENV_PATH_FILE, envPath, "utf-8");
1569
+ const content = readFileSync6(envPath, "utf-8");
1570
+ const originalMatch = content.match(new RegExp(`^${NANOCLAW_URL_VAR}=(.+)$`, "m"));
1571
+ const originalUrl = originalMatch?.[1]?.trim() ?? "";
1572
+ if (originalUrl) {
1573
+ writeFileSync6(ORIGINAL_URL_PATH3, originalUrl, "utf-8");
1574
+ }
1554
1575
  patchDotEnv2(envPath, {
1555
1576
  [NANOCLAW_URL_VAR]: `http://127.0.0.1:${config.proxy_port}`
1556
1577
  });
@@ -1835,6 +1856,13 @@ async function start() {
1835
1856
  max_skills_per_call: config.max_skills_per_call,
1836
1857
  auto_extract: config.auto_extract
1837
1858
  };
1859
+ if (config.state !== "on") {
1860
+ try {
1861
+ turnOn();
1862
+ } catch (e) {
1863
+ console.error("Warning: could not auto-connect agent:", e instanceof Error ? e.message : e);
1864
+ }
1865
+ }
1838
1866
  const originalUrlPath = join7(homedir5(), ".become", "state", "original_base_url.txt");
1839
1867
  let originalUpstreamUrl;
1840
1868
  if (existsSync7(originalUrlPath)) {
@@ -1865,13 +1893,6 @@ async function start() {
1865
1893
  }
1866
1894
  });
1867
1895
  await dashboard.listen(config.dashboard_port);
1868
- if (config.state !== "on") {
1869
- try {
1870
- turnOn();
1871
- } catch (e) {
1872
- console.error("Warning: could not auto-connect agent:", e instanceof Error ? e.message : e);
1873
- }
1874
- }
1875
1896
  const approved = proxy.store.listApproved().length;
1876
1897
  const pending = proxy.store.listPending().length;
1877
1898
  const trustConfig = proxy.trust.getConfig();