@clawos-dev/clawd 0.2.15-beta.19.b74cefe → 0.2.16-beta.20.fe1f54d
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 +33 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -15867,12 +15867,44 @@ function buildSpawnEnv(ctxEnv, base = process.env) {
|
|
|
15867
15867
|
...ctxEnv ?? {}
|
|
15868
15868
|
};
|
|
15869
15869
|
}
|
|
15870
|
+
var ATTACHMENT_RE = /\[attachment:(image|file):([^\]]+)\]/g;
|
|
15871
|
+
function tryParseBase64DataUrl(url) {
|
|
15872
|
+
const m = url.match(/^data:([^;,]+);base64,(.+)$/);
|
|
15873
|
+
if (!m) return null;
|
|
15874
|
+
return { mediaType: m[1], data: m[2] };
|
|
15875
|
+
}
|
|
15876
|
+
function buildStdinContent(rawText) {
|
|
15877
|
+
const blocks = [];
|
|
15878
|
+
let leftover = rawText;
|
|
15879
|
+
for (const match of rawText.matchAll(ATTACHMENT_RE)) {
|
|
15880
|
+
const [marker, kind, url] = match;
|
|
15881
|
+
const dataUrl = tryParseBase64DataUrl(url);
|
|
15882
|
+
if (!dataUrl) continue;
|
|
15883
|
+
if (kind === "image" && dataUrl.mediaType.startsWith("image/")) {
|
|
15884
|
+
blocks.push({
|
|
15885
|
+
type: "image",
|
|
15886
|
+
source: { type: "base64", media_type: dataUrl.mediaType, data: dataUrl.data }
|
|
15887
|
+
});
|
|
15888
|
+
leftover = leftover.replace(marker, "");
|
|
15889
|
+
} else if (kind === "file" && dataUrl.mediaType === "application/pdf") {
|
|
15890
|
+
blocks.push({
|
|
15891
|
+
type: "document",
|
|
15892
|
+
source: { type: "base64", media_type: "application/pdf", data: dataUrl.data }
|
|
15893
|
+
});
|
|
15894
|
+
leftover = leftover.replace(marker, "");
|
|
15895
|
+
}
|
|
15896
|
+
}
|
|
15897
|
+
const trimmed = leftover.trim();
|
|
15898
|
+
if (trimmed) blocks.push({ type: "text", text: trimmed });
|
|
15899
|
+
return blocks;
|
|
15900
|
+
}
|
|
15870
15901
|
function encodeClaudeStdin(text) {
|
|
15902
|
+
const content = buildStdinContent(text);
|
|
15871
15903
|
const frame = {
|
|
15872
15904
|
type: "user",
|
|
15873
15905
|
message: {
|
|
15874
15906
|
role: "user",
|
|
15875
|
-
content: [{ type: "text", text }]
|
|
15907
|
+
content: content.length > 0 ? content : [{ type: "text", text }]
|
|
15876
15908
|
}
|
|
15877
15909
|
};
|
|
15878
15910
|
return JSON.stringify(frame) + "\n";
|
package/package.json
CHANGED