@openclawcity/become 1.0.24 → 1.0.26
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 +47 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +47 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.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");
|
|
@@ -842,6 +862,14 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
|
|
|
842
862
|
const rawBody = await readBody(req);
|
|
843
863
|
const body = JSON.parse(rawBody);
|
|
844
864
|
const messages = body.messages;
|
|
865
|
+
if (Array.isArray(messages)) {
|
|
866
|
+
for (const m of messages) {
|
|
867
|
+
if (m.role === "user" || m.role === "system") {
|
|
868
|
+
const preview = typeof m.content === "string" ? m.content.slice(0, 200) : "(non-string)";
|
|
869
|
+
console.log(`[become] msg ${m.role}${m.name ? ` name=${m.name}` : ""}: ${preview.replace(/\n/g, "\\n")}`);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
}
|
|
845
873
|
if (Array.isArray(messages)) {
|
|
846
874
|
const skills = getSkills().slice(0, config.max_skills_per_call);
|
|
847
875
|
if (skills.length > 0) {
|
|
@@ -1903,21 +1931,30 @@ async function start() {
|
|
|
1903
1931
|
max_skills_per_call: config.max_skills_per_call,
|
|
1904
1932
|
auto_extract: config.auto_extract
|
|
1905
1933
|
};
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
console.error("Warning: could not auto-connect agent:", e instanceof Error ? e.message : e);
|
|
1911
|
-
}
|
|
1934
|
+
try {
|
|
1935
|
+
turnOn();
|
|
1936
|
+
} catch (e) {
|
|
1937
|
+
console.error("Warning: could not connect agent:", e instanceof Error ? e.message : e);
|
|
1912
1938
|
}
|
|
1913
1939
|
const originalUrlPath = (0, import_node_path7.join)((0, import_node_os5.homedir)(), ".become", "state", "original_base_url.txt");
|
|
1914
|
-
let
|
|
1940
|
+
let upstreamUrl = config.llm_base_url;
|
|
1915
1941
|
if ((0, import_node_fs7.existsSync)(originalUrlPath)) {
|
|
1916
1942
|
const saved = (0, import_node_fs7.readFileSync)(originalUrlPath, "utf-8").trim();
|
|
1917
|
-
if (saved)
|
|
1943
|
+
if (saved) upstreamUrl = saved;
|
|
1944
|
+
}
|
|
1945
|
+
if (upstreamUrl.includes("127.0.0.1") || upstreamUrl.includes("localhost")) {
|
|
1946
|
+
const port = config.proxy_port.toString();
|
|
1947
|
+
if (upstreamUrl.includes(`:${port}`)) {
|
|
1948
|
+
console.error(`
|
|
1949
|
+
FATAL: upstream URL ${upstreamUrl} points to the become proxy itself.`);
|
|
1950
|
+
console.error("This would cause an infinite loop. Aborting.");
|
|
1951
|
+
console.error("Run `become off` to restore your config, then `become start` again.\n");
|
|
1952
|
+
process.exit(1);
|
|
1953
|
+
}
|
|
1918
1954
|
}
|
|
1955
|
+
console.log(`[become] upstream: ${upstreamUrl}`);
|
|
1919
1956
|
const analyzer = createAnalyzer(config);
|
|
1920
|
-
const proxy = createProxyServer(proxyConfig, analyzer,
|
|
1957
|
+
const proxy = createProxyServer(proxyConfig, analyzer, upstreamUrl);
|
|
1921
1958
|
await proxy.listen();
|
|
1922
1959
|
const dashboard = createDashboardServer({
|
|
1923
1960
|
store: proxy.store,
|