@openclawcity/become 1.0.18 → 1.0.20

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
@@ -190,9 +190,49 @@ function restoreOpenClaw() {
190
190
  }
191
191
  }
192
192
  }
193
+ cleanLegacy();
193
194
  cleanState();
194
195
  restartGateway();
195
196
  }
197
+ function cleanLegacy() {
198
+ if ((0, import_node_fs2.existsSync)(OPENCLAW_CONFIG)) {
199
+ try {
200
+ const config = parseConfig((0, import_node_fs2.readFileSync)(OPENCLAW_CONFIG, "utf-8"));
201
+ let changed = false;
202
+ if (config.models?.providers?.become) {
203
+ delete config.models.providers.become;
204
+ changed = true;
205
+ }
206
+ const primary = config.agents?.defaults?.model?.primary ?? "";
207
+ if (primary.startsWith("become/")) {
208
+ config.agents.defaults.model.primary = "openrouter/" + primary.slice("become/".length);
209
+ changed = true;
210
+ }
211
+ for (const prov of Object.values(config.models?.providers ?? {})) {
212
+ if (prov && typeof prov === "object" && "_originalModel" in prov) {
213
+ delete prov._originalModel;
214
+ changed = true;
215
+ }
216
+ }
217
+ if (changed) (0, import_node_fs2.writeFileSync)(OPENCLAW_CONFIG, JSON.stringify(config, null, 2), "utf-8");
218
+ } catch {
219
+ }
220
+ }
221
+ try {
222
+ const clawConfig = parseConfig((0, import_node_fs2.readFileSync)(OPENCLAW_CONFIG, "utf-8"));
223
+ const modelsJsonPath = getModelsJsonPath(clawConfig);
224
+ if (modelsJsonPath && (0, import_node_fs2.existsSync)(modelsJsonPath)) {
225
+ const models = JSON.parse((0, import_node_fs2.readFileSync)(modelsJsonPath, "utf-8"));
226
+ let changed = false;
227
+ if (models.providers?.become) {
228
+ delete models.providers.become;
229
+ changed = true;
230
+ }
231
+ if (changed) (0, import_node_fs2.writeFileSync)(modelsJsonPath, JSON.stringify(models, null, 2), "utf-8");
232
+ }
233
+ } catch {
234
+ }
235
+ }
196
236
  function listOpenClawAgents() {
197
237
  if (!(0, import_node_fs2.existsSync)(OPENCLAW_CONFIG)) return [];
198
238
  try {
@@ -806,11 +846,17 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
806
846
  const upstreamHeaders = buildUpstreamHeaders(config, req.headers);
807
847
  const isStreaming = body.stream === true;
808
848
  const modifiedBody = JSON.stringify(body);
849
+ console.log(`[become] -> ${upstreamUrl} (${isStreaming ? "streaming" : "non-streaming"})`);
809
850
  const upstreamRes = await fetch(upstreamUrl, {
810
851
  method: "POST",
811
852
  headers: upstreamHeaders,
812
853
  body: modifiedBody
813
854
  });
855
+ console.log(`[become] <- ${upstreamRes.status} ${upstreamRes.statusText}`);
856
+ if (!upstreamRes.ok) {
857
+ const errBody = await upstreamRes.text().catch(() => "");
858
+ console.log(`[become] ERROR: ${errBody.slice(0, 500)}`);
859
+ }
814
860
  stats.requests_forwarded++;
815
861
  const responseHeaders = {};
816
862
  upstreamRes.headers.forEach((value, key) => {
@@ -847,6 +893,7 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
847
893
  }
848
894
  }
849
895
  } catch (err) {
896
+ console.log(`[become] EXCEPTION: ${err instanceof Error ? err.message : String(err)}`);
850
897
  const safeMessage = err instanceof Error && err.message === "Request body too large" ? "Request body too large" : "Failed to forward request to LLM";
851
898
  if (!res.headersSent) {
852
899
  res.writeHead(502, { "Content-Type": "application/json" });