@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.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
|
-
|
|
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");
|
|
@@ -1864,21 +1884,30 @@ async function start() {
|
|
|
1864
1884
|
max_skills_per_call: config.max_skills_per_call,
|
|
1865
1885
|
auto_extract: config.auto_extract
|
|
1866
1886
|
};
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
console.error("Warning: could not auto-connect agent:", e instanceof Error ? e.message : e);
|
|
1872
|
-
}
|
|
1887
|
+
try {
|
|
1888
|
+
turnOn();
|
|
1889
|
+
} catch (e) {
|
|
1890
|
+
console.error("Warning: could not connect agent:", e instanceof Error ? e.message : e);
|
|
1873
1891
|
}
|
|
1874
1892
|
const originalUrlPath = join7(homedir5(), ".become", "state", "original_base_url.txt");
|
|
1875
|
-
let
|
|
1893
|
+
let upstreamUrl = config.llm_base_url;
|
|
1876
1894
|
if (existsSync7(originalUrlPath)) {
|
|
1877
1895
|
const saved = readFileSync7(originalUrlPath, "utf-8").trim();
|
|
1878
|
-
if (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
|
+
}
|
|
1879
1907
|
}
|
|
1908
|
+
console.log(`[become] upstream: ${upstreamUrl}`);
|
|
1880
1909
|
const analyzer = createAnalyzer(config);
|
|
1881
|
-
const proxy = createProxyServer(proxyConfig, analyzer,
|
|
1910
|
+
const proxy = createProxyServer(proxyConfig, analyzer, upstreamUrl);
|
|
1882
1911
|
await proxy.listen();
|
|
1883
1912
|
const dashboard = createDashboardServer({
|
|
1884
1913
|
store: proxy.store,
|