@openclawcity/become 1.0.24 → 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 +39 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +39 -10
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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");
|
|
@@ -1903,21 +1923,30 @@ async function start() {
|
|
|
1903
1923
|
max_skills_per_call: config.max_skills_per_call,
|
|
1904
1924
|
auto_extract: config.auto_extract
|
|
1905
1925
|
};
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
console.error("Warning: could not auto-connect agent:", e instanceof Error ? e.message : e);
|
|
1911
|
-
}
|
|
1926
|
+
try {
|
|
1927
|
+
turnOn();
|
|
1928
|
+
} catch (e) {
|
|
1929
|
+
console.error("Warning: could not connect agent:", e instanceof Error ? e.message : e);
|
|
1912
1930
|
}
|
|
1913
1931
|
const originalUrlPath = (0, import_node_path7.join)((0, import_node_os5.homedir)(), ".become", "state", "original_base_url.txt");
|
|
1914
|
-
let
|
|
1932
|
+
let upstreamUrl = config.llm_base_url;
|
|
1915
1933
|
if ((0, import_node_fs7.existsSync)(originalUrlPath)) {
|
|
1916
1934
|
const saved = (0, import_node_fs7.readFileSync)(originalUrlPath, "utf-8").trim();
|
|
1917
|
-
if (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
|
+
}
|
|
1918
1946
|
}
|
|
1947
|
+
console.log(`[become] upstream: ${upstreamUrl}`);
|
|
1919
1948
|
const analyzer = createAnalyzer(config);
|
|
1920
|
-
const proxy = createProxyServer(proxyConfig, analyzer,
|
|
1949
|
+
const proxy = createProxyServer(proxyConfig, analyzer, upstreamUrl);
|
|
1921
1950
|
await proxy.listen();
|
|
1922
1951
|
const dashboard = createDashboardServer({
|
|
1923
1952
|
store: proxy.store,
|