@khalilgharbaoui/opencode-claude-code-plugin 0.44.0 → 0.45.0

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/index.js CHANGED
@@ -5897,7 +5897,7 @@ var PLUGIN_LOG_MESSAGES = /* @__PURE__ */ new Set([
5897
5897
  "two different skills share a name; bridging the one the nearest root claimed",
5898
5898
  "unknown permissionPreset; no preset applied and every permission setting is left exactly as configured",
5899
5899
  "unsupported file part data type",
5900
- "unsupported media type for Claude image block, skipping"
5900
+ "unsupported media type for Claude attachment block, skipping"
5901
5901
  ]);
5902
5902
 
5903
5903
  // src/diagnostic-bundle.ts
@@ -7253,7 +7253,7 @@ var baseCapabilities = {
7253
7253
  temperature: false,
7254
7254
  attachment: true,
7255
7255
  toolcall: true,
7256
- input: { text: true, audio: false, image: true, video: false, pdf: false },
7256
+ input: { text: true, audio: false, image: true, video: false, pdf: true },
7257
7257
  output: { text: true, audio: false, image: false, video: false, pdf: false },
7258
7258
  interleaved: false
7259
7259
  };
@@ -8010,13 +8010,14 @@ function stripContextReminders(prompt) {
8010
8010
  });
8011
8011
  return removed > 0 ? { prompt: out, removed } : { prompt, removed: 0 };
8012
8012
  }
8013
+ var PDF_MEDIA_TYPE = "application/pdf";
8013
8014
  var SUPPORTED_IMAGE_TYPES = /* @__PURE__ */ new Set([
8014
8015
  "image/jpeg",
8015
8016
  "image/png",
8016
8017
  "image/gif",
8017
8018
  "image/webp"
8018
8019
  ]);
8019
- function toImageBlock(part) {
8020
+ function toAttachmentBlock(part) {
8020
8021
  const raw = part.image ?? part.data ?? part.url ?? part.source?.data;
8021
8022
  if (!raw) {
8022
8023
  log.warn("file part without data, skipping");
@@ -8048,8 +8049,14 @@ function toImageBlock(part) {
8048
8049
  log.warn("unsupported file part data type", { dataType: typeof raw });
8049
8050
  return null;
8050
8051
  }
8052
+ if (resolvedMediaType.toLowerCase() === PDF_MEDIA_TYPE) {
8053
+ return {
8054
+ type: "document",
8055
+ source: { type: "base64", media_type: PDF_MEDIA_TYPE, data: base64 }
8056
+ };
8057
+ }
8051
8058
  if (!resolvedMediaType || !SUPPORTED_IMAGE_TYPES.has(resolvedMediaType)) {
8052
- log.warn("unsupported media type for Claude image block, skipping", {
8059
+ log.warn("unsupported media type for Claude attachment block, skipping", {
8053
8060
  mediaType: resolvedMediaType
8054
8061
  });
8055
8062
  return null;
@@ -8301,11 +8308,11 @@ Now continuing with the current message:
8301
8308
  content.push({ type: "text", text: part.text });
8302
8309
  }
8303
8310
  } else if (part.type === "file" || part.type === "image") {
8304
- const block = toImageBlock(part);
8311
+ const block = toAttachmentBlock(part);
8305
8312
  if (block) {
8306
8313
  content.push(block);
8307
8314
  } else {
8308
- log.debug("skipped non-image file part", {
8315
+ log.debug("skipped unsupported file part", {
8309
8316
  mediaType: part.mediaType
8310
8317
  });
8311
8318
  }
@@ -8365,7 +8372,7 @@ function getTrailingUserMessages(prompt, opts = {}) {
8365
8372
  if (part.type === "text") {
8366
8373
  if (part.text && part.text.trim()) blocks.push({ type: "text", text: part.text });
8367
8374
  } else if (part.type === "file" || part.type === "image") {
8368
- const block = toImageBlock(part);
8375
+ const block = toAttachmentBlock(part);
8369
8376
  if (block) blocks.push(block);
8370
8377
  }
8371
8378
  }
@@ -9780,12 +9787,14 @@ function decodeUserEnvelope(chunk, saveImage) {
9780
9787
  const images = [];
9781
9788
  let dropped = 0;
9782
9789
  for (const block of content) {
9783
- const extension = block?.type === "image" && block.source?.type === "base64" && typeof block.source.data === "string" ? IMAGE_EXTENSIONS[String(block.source.media_type).toLowerCase()] : void 0;
9790
+ const base64 = block?.source?.type === "base64" && typeof block.source.data === "string";
9791
+ const mediaType = String(block?.source?.media_type).toLowerCase();
9792
+ const extension = base64 && block.type === "image" ? IMAGE_EXTENSIONS[mediaType] : base64 && block.type === "document" && mediaType === "application/pdf" ? "pdf" : void 0;
9784
9793
  if (block?.type === "text" && typeof block.text === "string") {
9785
9794
  parts.push(block.text);
9786
9795
  } else if (extension && saveImage) {
9787
9796
  const file = saveImage(Buffer.from(block.source.data, "base64"), extension);
9788
- if (file) images.push(file);
9797
+ if (file) images.push(extension === "pdf" ? `@${file}` : file);
9789
9798
  else dropped++;
9790
9799
  } else if (block?.type === "tool_result") {
9791
9800
  const v = block.content;
@@ -9808,7 +9817,7 @@ ${text2}`
9808
9817
  }
9809
9818
  function stageImage(data, extension) {
9810
9819
  try {
9811
- const file = join10(pluginTmpDir(), `image-${randomUUID5()}.${extension}`);
9820
+ const file = join10(pluginTmpDir(), `attachment-${randomUUID5()}.${extension}`);
9812
9821
  writeFileSync5(file, data, { mode: 384, flag: "wx" });
9813
9822
  return file;
9814
9823
  } catch (err) {