supercompat 3.17.0 → 3.17.1

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.cjs CHANGED
@@ -5300,6 +5300,27 @@ var sanitizeContent = function(content) {
5300
5300
  if (!content) return content;
5301
5301
  return content.replace(ARTIFACT_TAGS, "").trim();
5302
5302
  };
5303
+ var convertScreenshotToolMessages = function(messages5) {
5304
+ return messages5.map(function(msg) {
5305
+ if (msg.role !== "tool" || typeof msg.content !== "string") return msg;
5306
+ try {
5307
+ var parsed = JSON.parse(msg.content);
5308
+ if (parsed.type === "computer_screenshot" && parsed.image_url) {
5309
+ return _object_spread_props(_object_spread({}, msg), {
5310
+ content: [
5311
+ {
5312
+ type: "image_url",
5313
+ image_url: {
5314
+ url: parsed.image_url
5315
+ }
5316
+ }
5317
+ ]
5318
+ });
5319
+ }
5320
+ } catch (unused) {}
5321
+ return msg;
5322
+ });
5323
+ };
5303
5324
  var post10 = function(param) {
5304
5325
  var openRouter = param.openRouter;
5305
5326
  return function(_url, options) {
@@ -5311,7 +5332,9 @@ var post10 = function(param) {
5311
5332
  body = JSON.parse(options.body);
5312
5333
  model = body.model;
5313
5334
  _transformTools = transformTools(body.tools, model), transformedTools = _transformTools.tools, computerUseConfig = _transformTools.computerUseConfig;
5314
- resultOptions = _object_spread({}, body, transformedTools.length > 0 ? {
5335
+ resultOptions = _object_spread({}, body, computerUseConfig && body.messages ? {
5336
+ messages: convertScreenshotToolMessages(body.messages)
5337
+ } : {}, transformedTools.length > 0 ? {
5315
5338
  tools: transformedTools
5316
5339
  } : {});
5317
5340
  if (!body.stream) return [
@@ -5860,21 +5883,6 @@ var serializeToolContent = function(param) {
5860
5883
  }
5861
5884
  return JSON.stringify(toolCall.function.output);
5862
5885
  }
5863
- if (typeof toolCall.function.output === "string") {
5864
- try {
5865
- var parsed = JSON.parse(toolCall.function.output);
5866
- if (parsed.type === "computer_screenshot" && parsed.image_url) {
5867
- return [
5868
- {
5869
- type: "image_url",
5870
- image_url: {
5871
- url: parsed.image_url
5872
- }
5873
- }
5874
- ];
5875
- }
5876
- } catch (unused) {}
5877
- }
5878
5886
  return (_toolCall_function_output = toolCall.function.output) !== null && _toolCall_function_output !== void 0 ? _toolCall_function_output : "";
5879
5887
  };
5880
5888
  var serializeToolCall = function(param) {