@zenmux/rosetta-ai 1.0.39 → 1.0.40

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.
@@ -788,14 +788,18 @@ class ResponsesToMessagesConverter {
788
788
  else if (typed.type === "function_call_output") {
789
789
  flushAssistant();
790
790
  const output = typed.output;
791
- // Array content-part outputs are lossy: serialized as raw JSON rather than
792
- // unwrapping input_text/image/file parts. Acceptable since Anthropic tool_result
793
- // text expects a string and array outputs are rare on this path.
794
- const outputText = typeof output === "string" ? output : output == null ? "" : JSON.stringify(output);
791
+ // Preserve native content parts while keeping legacy JSON outputs and strings as text.
792
+ const isContentArray = Array.isArray(output) &&
793
+ output.length > 0 &&
794
+ output.every(part => part != null && ["input_text", "input_image", "input_file"].includes(part.type));
795
+ let content = output;
796
+ if (!isContentArray && typeof output !== "string") {
797
+ content = output == null ? "" : JSON.stringify(output);
798
+ }
795
799
  const toolResult = {
796
800
  type: "tool_result",
797
801
  tool_use_id: typed.call_id,
798
- content: [{ type: "text", text: outputText }],
802
+ content: this.convertInputContent(content),
799
803
  };
800
804
  // Anthropic requires parallel tool_results grouped in one user message,
801
805
  // so append to the prior user message if it already holds tool_results.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenmux/rosetta-ai",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "description": "Universal translator between AI provider protocols",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -60,4 +60,4 @@
60
60
  "typescript": "^6.0.2",
61
61
  "typescript-eslint": "^8.58.2"
62
62
  }
63
- }
63
+ }