openmagic 0.39.0 → 0.41.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/cli.js CHANGED
@@ -1485,6 +1485,8 @@ async function chatAnthropic(model, apiKey, messages, context, onChunk, onDone,
1485
1485
  if (msg.role === "user" && typeof msg.content === "string" && i === lastUserIdx) {
1486
1486
  const enrichedContent = buildUserMessage(msg.content, buildContextParts(context));
1487
1487
  if (context.screenshot) {
1488
+ const mimeMatch = context.screenshot.match(/^data:(image\/[a-z+]+);base64,/);
1489
+ const mediaType = mimeMatch?.[1] || "image/jpeg";
1488
1490
  const base64Data = context.screenshot.replace(
1489
1491
  /^data:image\/\w+;base64,/,
1490
1492
  ""
@@ -1497,7 +1499,7 @@ async function chatAnthropic(model, apiKey, messages, context, onChunk, onDone,
1497
1499
  type: "image",
1498
1500
  source: {
1499
1501
  type: "base64",
1500
- media_type: "image/png",
1502
+ media_type: mediaType,
1501
1503
  data: base64Data
1502
1504
  }
1503
1505
  }
@@ -1601,13 +1603,15 @@ async function chatGoogle(model, apiKey, messages, context, onChunk, onDone, onE
1601
1603
  { text: enrichedContent }
1602
1604
  ];
1603
1605
  if (context.screenshot) {
1606
+ const mimeMatch = context.screenshot.match(/^data:(image\/[a-z+]+);base64,/);
1607
+ const mimeType = mimeMatch?.[1] || "image/jpeg";
1604
1608
  const base64Data = context.screenshot.replace(
1605
1609
  /^data:image\/\w+;base64,/,
1606
1610
  ""
1607
1611
  );
1608
1612
  parts.push({
1609
1613
  inline_data: {
1610
- mime_type: "image/png",
1614
+ mime_type: mimeType,
1611
1615
  data: base64Data
1612
1616
  }
1613
1617
  });