@clawos-dev/clawd 0.2.16 → 0.2.17-beta.22.f8f4156

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.
Files changed (2) hide show
  1. package/dist/cli.cjs +36 -13
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -15873,25 +15873,48 @@ function tryParseBase64DataUrl(url) {
15873
15873
  if (!m) return null;
15874
15874
  return { mediaType: m[1], data: m[2] };
15875
15875
  }
15876
+ var IMAGE_EXT_MIME = {
15877
+ png: "image/png",
15878
+ jpg: "image/jpeg",
15879
+ jpeg: "image/jpeg",
15880
+ gif: "image/gif",
15881
+ webp: "image/webp"
15882
+ };
15883
+ function tryParseHttpImageUrl(url) {
15884
+ if (!/^https?:\/\//i.test(url)) return null;
15885
+ const pathOnly = url.split(/[?#]/, 1)[0];
15886
+ const ext = pathOnly.split(".").pop()?.toLowerCase();
15887
+ if (!ext || !(ext in IMAGE_EXT_MIME)) return null;
15888
+ return { url };
15889
+ }
15876
15890
  function buildStdinContent(rawText) {
15877
15891
  const blocks = [];
15878
15892
  let leftover = rawText;
15879
15893
  for (const match of rawText.matchAll(ATTACHMENT_RE)) {
15880
15894
  const [marker, kind, url] = match;
15881
15895
  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, "");
15896
+ if (dataUrl) {
15897
+ if (kind === "image" && dataUrl.mediaType.startsWith("image/")) {
15898
+ blocks.push({
15899
+ type: "image",
15900
+ source: { type: "base64", media_type: dataUrl.mediaType, data: dataUrl.data }
15901
+ });
15902
+ leftover = leftover.replace(marker, "");
15903
+ } else if (kind === "file" && dataUrl.mediaType === "application/pdf") {
15904
+ blocks.push({
15905
+ type: "document",
15906
+ source: { type: "base64", media_type: "application/pdf", data: dataUrl.data }
15907
+ });
15908
+ leftover = leftover.replace(marker, "");
15909
+ }
15910
+ continue;
15911
+ }
15912
+ if (kind === "image") {
15913
+ const httpImg = tryParseHttpImageUrl(url);
15914
+ if (httpImg) {
15915
+ blocks.push({ type: "image", source: { type: "url", url: httpImg.url } });
15916
+ leftover = leftover.replace(marker, "");
15917
+ }
15895
15918
  }
15896
15919
  }
15897
15920
  const trimmed = leftover.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.16",
3
+ "version": "0.2.17-beta.22.f8f4156",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",