@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.js CHANGED
@@ -151,9 +151,49 @@ function restoreOpenClaw() {
151
151
  }
152
152
  }
153
153
  }
154
+ cleanLegacy();
154
155
  cleanState();
155
156
  restartGateway();
156
157
  }
158
+ function cleanLegacy() {
159
+ if (existsSync2(OPENCLAW_CONFIG)) {
160
+ try {
161
+ const config = parseConfig(readFileSync2(OPENCLAW_CONFIG, "utf-8"));
162
+ let changed = false;
163
+ if (config.models?.providers?.become) {
164
+ delete config.models.providers.become;
165
+ changed = true;
166
+ }
167
+ const primary = config.agents?.defaults?.model?.primary ?? "";
168
+ if (primary.startsWith("become/")) {
169
+ config.agents.defaults.model.primary = "openrouter/" + primary.slice("become/".length);
170
+ changed = true;
171
+ }
172
+ for (const prov of Object.values(config.models?.providers ?? {})) {
173
+ if (prov && typeof prov === "object" && "_originalModel" in prov) {
174
+ delete prov._originalModel;
175
+ changed = true;
176
+ }
177
+ }
178
+ if (changed) writeFileSync2(OPENCLAW_CONFIG, JSON.stringify(config, null, 2), "utf-8");
179
+ } catch {
180
+ }
181
+ }
182
+ try {
183
+ const clawConfig = parseConfig(readFileSync2(OPENCLAW_CONFIG, "utf-8"));
184
+ const modelsJsonPath = getModelsJsonPath(clawConfig);
185
+ if (modelsJsonPath && existsSync2(modelsJsonPath)) {
186
+ const models = JSON.parse(readFileSync2(modelsJsonPath, "utf-8"));
187
+ let changed = false;
188
+ if (models.providers?.become) {
189
+ delete models.providers.become;
190
+ changed = true;
191
+ }
192
+ if (changed) writeFileSync2(modelsJsonPath, JSON.stringify(models, null, 2), "utf-8");
193
+ }
194
+ } catch {
195
+ }
196
+ }
157
197
  function listOpenClawAgents() {
158
198
  if (!existsSync2(OPENCLAW_CONFIG)) return [];
159
199
  try {
@@ -767,11 +807,17 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
767
807
  const upstreamHeaders = buildUpstreamHeaders(config, req.headers);
768
808
  const isStreaming = body.stream === true;
769
809
  const modifiedBody = JSON.stringify(body);
810
+ console.log(`[become] -> ${upstreamUrl} (${isStreaming ? "streaming" : "non-streaming"})`);
770
811
  const upstreamRes = await fetch(upstreamUrl, {
771
812
  method: "POST",
772
813
  headers: upstreamHeaders,
773
814
  body: modifiedBody
774
815
  });
816
+ console.log(`[become] <- ${upstreamRes.status} ${upstreamRes.statusText}`);
817
+ if (!upstreamRes.ok) {
818
+ const errBody = await upstreamRes.text().catch(() => "");
819
+ console.log(`[become] ERROR: ${errBody.slice(0, 500)}`);
820
+ }
775
821
  stats.requests_forwarded++;
776
822
  const responseHeaders = {};
777
823
  upstreamRes.headers.forEach((value, key) => {
@@ -808,6 +854,7 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
808
854
  }
809
855
  }
810
856
  } catch (err) {
857
+ console.log(`[become] EXCEPTION: ${err instanceof Error ? err.message : String(err)}`);
811
858
  const safeMessage = err instanceof Error && err.message === "Request body too large" ? "Request body too large" : "Failed to forward request to LLM";
812
859
  if (!res.headersSent) {
813
860
  res.writeHead(502, { "Content-Type": "application/json" });