@blockrun/clawrouter 0.12.31 → 0.12.32
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 +19 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5887,14 +5887,29 @@ async function startProxy(options) {
|
|
|
5887
5887
|
await mkdir3(IMAGE_DIR, { recursive: true });
|
|
5888
5888
|
const port2 = server.address()?.port ?? 8402;
|
|
5889
5889
|
for (const img of result.data) {
|
|
5890
|
-
const
|
|
5891
|
-
if (
|
|
5892
|
-
const [, mimeType, b64] =
|
|
5890
|
+
const dataUriMatch = img.url?.match(/^data:(image\/\w+);base64,(.+)$/);
|
|
5891
|
+
if (dataUriMatch) {
|
|
5892
|
+
const [, mimeType, b64] = dataUriMatch;
|
|
5893
5893
|
const ext = mimeType === "image/jpeg" ? "jpg" : mimeType.split("/")[1] ?? "png";
|
|
5894
5894
|
const filename = `${Date.now()}-${Math.random().toString(36).slice(2, 10)}.${ext}`;
|
|
5895
5895
|
await writeFile2(join5(IMAGE_DIR, filename), Buffer.from(b64, "base64"));
|
|
5896
5896
|
img.url = `http://localhost:${port2}/images/${filename}`;
|
|
5897
5897
|
console.log(`[ClawRouter] Image saved \u2192 ${img.url}`);
|
|
5898
|
+
} else if (img.url?.startsWith("https://") || img.url?.startsWith("http://")) {
|
|
5899
|
+
try {
|
|
5900
|
+
const imgResp = await fetch(img.url);
|
|
5901
|
+
if (imgResp.ok) {
|
|
5902
|
+
const contentType = imgResp.headers.get("content-type") ?? "image/png";
|
|
5903
|
+
const ext = contentType.includes("jpeg") || contentType.includes("jpg") ? "jpg" : contentType.includes("webp") ? "webp" : "png";
|
|
5904
|
+
const filename = `${Date.now()}-${Math.random().toString(36).slice(2, 10)}.${ext}`;
|
|
5905
|
+
const buf = Buffer.from(await imgResp.arrayBuffer());
|
|
5906
|
+
await writeFile2(join5(IMAGE_DIR, filename), buf);
|
|
5907
|
+
img.url = `http://localhost:${port2}/images/${filename}`;
|
|
5908
|
+
console.log(`[ClawRouter] Image downloaded & saved \u2192 ${img.url}`);
|
|
5909
|
+
}
|
|
5910
|
+
} catch (downloadErr) {
|
|
5911
|
+
console.warn(`[ClawRouter] Failed to download image, using original URL: ${downloadErr instanceof Error ? downloadErr.message : String(downloadErr)}`);
|
|
5912
|
+
}
|
|
5898
5913
|
}
|
|
5899
5914
|
}
|
|
5900
5915
|
}
|
|
@@ -7899,7 +7914,7 @@ ClawRouter Partner APIs (v${VERSION})
|
|
|
7899
7914
|
wallet,
|
|
7900
7915
|
port: args.port,
|
|
7901
7916
|
onReady: (port) => {
|
|
7902
|
-
console.log(`[ClawRouter] Proxy listening on http://127.0.0.1:${port}`);
|
|
7917
|
+
console.log(`[ClawRouter] v${VERSION} | Proxy listening on http://127.0.0.1:${port}`);
|
|
7903
7918
|
console.log(`[ClawRouter] Health check: http://127.0.0.1:${port}/health`);
|
|
7904
7919
|
},
|
|
7905
7920
|
onError: (error) => {
|