@openclawcity/become 1.0.23 → 1.0.25

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
@@ -107,10 +107,30 @@ function patchOpenClaw(config) {
107
107
  `Provider "${providerName}" not found in models.json or openclaw.json. Your model is "${primaryModel}" which needs a "${providerName}" provider.`
108
108
  );
109
109
  }
110
- const originalUrl = provider.baseUrl;
110
+ let originalUrl = provider.baseUrl;
111
111
  if (!originalUrl) {
112
112
  throw new Error(`Provider "${providerName}" has no baseUrl`);
113
113
  }
114
+ if (originalUrl.includes("127.0.0.1") || originalUrl.includes("localhost")) {
115
+ if (existsSync2(BACKUP_PATH)) {
116
+ try {
117
+ const backupRaw = readFileSync2(BACKUP_PATH, "utf-8");
118
+ } catch {
119
+ }
120
+ }
121
+ const savedUrl = readSafe(ORIGINAL_URL_PATH);
122
+ if (savedUrl && !savedUrl.includes("127.0.0.1")) {
123
+ originalUrl = savedUrl;
124
+ console.log(` recovered original URL from state: ${originalUrl}`);
125
+ } else {
126
+ throw new Error(
127
+ `Provider "${providerName}" baseUrl is already pointing to localhost (${originalUrl}).
128
+ This means become was previously connected but not properly restored.
129
+ Fix manually: set the baseUrl back to the real provider URL in:
130
+ ${modelsSource === "models.json" ? getModelsJsonPath(clawConfig) : OPENCLAW_CONFIG}`
131
+ );
132
+ }
133
+ }
114
134
  writeFileSync2(BACKUP_PATH, raw, "utf-8");
115
135
  writeFileSync2(ORIGINAL_URL_PATH, originalUrl, "utf-8");
116
136
  writeFileSync2(PATCHED_PROVIDER_PATH, `${providerName}:${modelsSource}`, "utf-8");
@@ -718,9 +738,12 @@ Rules:
718
738
  - Max 3 lessons per conversation
719
739
  - If no real learning happened, return []`;
720
740
  try {
741
+ console.log(`[become] extracting lessons from ${agentId} (${detection.exchangeType}), text length: ${exchangeText.length}`);
721
742
  const response = await this.analyzer.analyze(prompt);
722
743
  const lessons = this.parseLessons(response);
744
+ console.log(`[become] LLM returned ${lessons.length} lessons`);
723
745
  for (const lesson of lessons.slice(0, 3)) {
746
+ console.log(`[become] saving lesson: ${lesson.skill} (confidence: ${lesson.confidence})`);
724
747
  const saved = this.store.savePending({
725
748
  name: lesson.skill,
726
749
  instruction: lesson.instruction.slice(0, 500),
@@ -730,13 +753,18 @@ Rules:
730
753
  created_at: (/* @__PURE__ */ new Date()).toISOString()
731
754
  });
732
755
  if (saved) {
756
+ console.log(`[become] lesson saved: ${saved.id}`);
733
757
  this.trust.recordLesson(agentId);
734
758
  if (trustLevel === "trusted") {
735
759
  this.store.approve(saved.id);
760
+ console.log(`[become] auto-approved (trusted agent)`);
736
761
  }
762
+ } else {
763
+ console.log(`[become] lesson NOT saved (duplicate or store error)`);
737
764
  }
738
765
  }
739
- } catch {
766
+ } catch (err) {
767
+ console.log(`[become] extraction error: ${err instanceof Error ? err.message : String(err)}`);
740
768
  }
741
769
  }
742
770
  parseLessons(response) {
@@ -1856,21 +1884,30 @@ async function start() {
1856
1884
  max_skills_per_call: config.max_skills_per_call,
1857
1885
  auto_extract: config.auto_extract
1858
1886
  };
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
- }
1887
+ try {
1888
+ turnOn();
1889
+ } catch (e) {
1890
+ console.error("Warning: could not connect agent:", e instanceof Error ? e.message : e);
1865
1891
  }
1866
1892
  const originalUrlPath = join7(homedir5(), ".become", "state", "original_base_url.txt");
1867
- let originalUpstreamUrl;
1893
+ let upstreamUrl = config.llm_base_url;
1868
1894
  if (existsSync7(originalUrlPath)) {
1869
1895
  const saved = readFileSync7(originalUrlPath, "utf-8").trim();
1870
- if (saved) originalUpstreamUrl = saved;
1896
+ if (saved) upstreamUrl = saved;
1897
+ }
1898
+ if (upstreamUrl.includes("127.0.0.1") || upstreamUrl.includes("localhost")) {
1899
+ const port = config.proxy_port.toString();
1900
+ if (upstreamUrl.includes(`:${port}`)) {
1901
+ console.error(`
1902
+ FATAL: upstream URL ${upstreamUrl} points to the become proxy itself.`);
1903
+ console.error("This would cause an infinite loop. Aborting.");
1904
+ console.error("Run `become off` to restore your config, then `become start` again.\n");
1905
+ process.exit(1);
1906
+ }
1871
1907
  }
1908
+ console.log(`[become] upstream: ${upstreamUrl}`);
1872
1909
  const analyzer = createAnalyzer(config);
1873
- const proxy = createProxyServer(proxyConfig, analyzer, originalUpstreamUrl);
1910
+ const proxy = createProxyServer(proxyConfig, analyzer, upstreamUrl);
1874
1911
  await proxy.listen();
1875
1912
  const dashboard = createDashboardServer({
1876
1913
  store: proxy.store,