@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.cjs CHANGED
@@ -146,10 +146,30 @@ function patchOpenClaw(config) {
146
146
  `Provider "${providerName}" not found in models.json or openclaw.json. Your model is "${primaryModel}" which needs a "${providerName}" provider.`
147
147
  );
148
148
  }
149
- const originalUrl = provider.baseUrl;
149
+ let originalUrl = provider.baseUrl;
150
150
  if (!originalUrl) {
151
151
  throw new Error(`Provider "${providerName}" has no baseUrl`);
152
152
  }
153
+ if (originalUrl.includes("127.0.0.1") || originalUrl.includes("localhost")) {
154
+ if ((0, import_node_fs2.existsSync)(BACKUP_PATH)) {
155
+ try {
156
+ const backupRaw = (0, import_node_fs2.readFileSync)(BACKUP_PATH, "utf-8");
157
+ } catch {
158
+ }
159
+ }
160
+ const savedUrl = readSafe(ORIGINAL_URL_PATH);
161
+ if (savedUrl && !savedUrl.includes("127.0.0.1")) {
162
+ originalUrl = savedUrl;
163
+ console.log(` recovered original URL from state: ${originalUrl}`);
164
+ } else {
165
+ throw new Error(
166
+ `Provider "${providerName}" baseUrl is already pointing to localhost (${originalUrl}).
167
+ This means become was previously connected but not properly restored.
168
+ Fix manually: set the baseUrl back to the real provider URL in:
169
+ ${modelsSource === "models.json" ? getModelsJsonPath(clawConfig) : OPENCLAW_CONFIG}`
170
+ );
171
+ }
172
+ }
153
173
  (0, import_node_fs2.writeFileSync)(BACKUP_PATH, raw, "utf-8");
154
174
  (0, import_node_fs2.writeFileSync)(ORIGINAL_URL_PATH, originalUrl, "utf-8");
155
175
  (0, import_node_fs2.writeFileSync)(PATCHED_PROVIDER_PATH, `${providerName}:${modelsSource}`, "utf-8");
@@ -757,9 +777,12 @@ Rules:
757
777
  - Max 3 lessons per conversation
758
778
  - If no real learning happened, return []`;
759
779
  try {
780
+ console.log(`[become] extracting lessons from ${agentId} (${detection.exchangeType}), text length: ${exchangeText.length}`);
760
781
  const response = await this.analyzer.analyze(prompt);
761
782
  const lessons = this.parseLessons(response);
783
+ console.log(`[become] LLM returned ${lessons.length} lessons`);
762
784
  for (const lesson of lessons.slice(0, 3)) {
785
+ console.log(`[become] saving lesson: ${lesson.skill} (confidence: ${lesson.confidence})`);
763
786
  const saved = this.store.savePending({
764
787
  name: lesson.skill,
765
788
  instruction: lesson.instruction.slice(0, 500),
@@ -769,13 +792,18 @@ Rules:
769
792
  created_at: (/* @__PURE__ */ new Date()).toISOString()
770
793
  });
771
794
  if (saved) {
795
+ console.log(`[become] lesson saved: ${saved.id}`);
772
796
  this.trust.recordLesson(agentId);
773
797
  if (trustLevel === "trusted") {
774
798
  this.store.approve(saved.id);
799
+ console.log(`[become] auto-approved (trusted agent)`);
775
800
  }
801
+ } else {
802
+ console.log(`[become] lesson NOT saved (duplicate or store error)`);
776
803
  }
777
804
  }
778
- } catch {
805
+ } catch (err) {
806
+ console.log(`[become] extraction error: ${err instanceof Error ? err.message : String(err)}`);
779
807
  }
780
808
  }
781
809
  parseLessons(response) {
@@ -1895,21 +1923,30 @@ async function start() {
1895
1923
  max_skills_per_call: config.max_skills_per_call,
1896
1924
  auto_extract: config.auto_extract
1897
1925
  };
1898
- if (config.state !== "on") {
1899
- try {
1900
- turnOn();
1901
- } catch (e) {
1902
- console.error("Warning: could not auto-connect agent:", e instanceof Error ? e.message : e);
1903
- }
1926
+ try {
1927
+ turnOn();
1928
+ } catch (e) {
1929
+ console.error("Warning: could not connect agent:", e instanceof Error ? e.message : e);
1904
1930
  }
1905
1931
  const originalUrlPath = (0, import_node_path7.join)((0, import_node_os5.homedir)(), ".become", "state", "original_base_url.txt");
1906
- let originalUpstreamUrl;
1932
+ let upstreamUrl = config.llm_base_url;
1907
1933
  if ((0, import_node_fs7.existsSync)(originalUrlPath)) {
1908
1934
  const saved = (0, import_node_fs7.readFileSync)(originalUrlPath, "utf-8").trim();
1909
- if (saved) originalUpstreamUrl = saved;
1935
+ if (saved) upstreamUrl = saved;
1936
+ }
1937
+ if (upstreamUrl.includes("127.0.0.1") || upstreamUrl.includes("localhost")) {
1938
+ const port = config.proxy_port.toString();
1939
+ if (upstreamUrl.includes(`:${port}`)) {
1940
+ console.error(`
1941
+ FATAL: upstream URL ${upstreamUrl} points to the become proxy itself.`);
1942
+ console.error("This would cause an infinite loop. Aborting.");
1943
+ console.error("Run `become off` to restore your config, then `become start` again.\n");
1944
+ process.exit(1);
1945
+ }
1910
1946
  }
1947
+ console.log(`[become] upstream: ${upstreamUrl}`);
1911
1948
  const analyzer = createAnalyzer(config);
1912
- const proxy = createProxyServer(proxyConfig, analyzer, originalUpstreamUrl);
1949
+ const proxy = createProxyServer(proxyConfig, analyzer, upstreamUrl);
1913
1950
  await proxy.listen();
1914
1951
  const dashboard = createDashboardServer({
1915
1952
  store: proxy.store,