@zenmux/rosetta-ai 1.0.27 → 1.0.28

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.
@@ -17,10 +17,13 @@ class ChatCompletionToGeminiConverter {
17
17
  systemParts.push({ text });
18
18
  }
19
19
  else if (msg.role === "user") {
20
- contents.push({
21
- role: "user",
22
- parts: this.convertUserParts(msg.content),
23
- });
20
+ const parts = this.convertUserParts(msg.content);
21
+ if (parts.length > 0) {
22
+ contents.push({
23
+ role: "user",
24
+ parts,
25
+ });
26
+ }
24
27
  }
25
28
  else if (msg.role === "assistant") {
26
29
  for (const toolCall of msg.tool_calls ?? []) {
@@ -28,10 +31,13 @@ class ChatCompletionToGeminiConverter {
28
31
  toolCallNames.set(toolCall.id, toolCall.function.name);
29
32
  }
30
33
  }
31
- contents.push({
32
- role: "model",
33
- parts: this.convertAssistantParts(msg),
34
- });
34
+ const parts = this.convertAssistantParts(msg);
35
+ if (parts.length > 0) {
36
+ contents.push({
37
+ role: "model",
38
+ parts,
39
+ });
40
+ }
35
41
  }
36
42
  else if (msg.role === "tool") {
37
43
  this.appendToolResponse(contents, msg, toolCallNames.get(msg.tool_call_id));
@@ -323,6 +329,15 @@ class ChatCompletionToGeminiConverter {
323
329
  }
324
330
  }
325
331
  }
332
+ // Responses reasoning history is represented as the non-standard
333
+ // reasoning_content field in Chat Completions. The legacy conversion sent
334
+ // standalone reasoning summaries to Gemini as ordinary model text.
335
+ if (parts.length === 0) {
336
+ const reasoningContent = msg.reasoning_content;
337
+ if (typeof reasoningContent === "string" && reasoningContent.length > 0) {
338
+ parts.push({ text: reasoningContent });
339
+ }
340
+ }
326
341
  return parts;
327
342
  }
328
343
  appendToolResponse(contents, msg, functionName) {
@@ -842,18 +842,22 @@ class ResponsesToChatCompletionConverter {
842
842
  }
843
843
  else if (typed.role === "assistant") {
844
844
  const textParts = [];
845
- if (Array.isArray(typed.content)) {
845
+ if (typeof typed.content === "string") {
846
+ textParts.push(typed.content);
847
+ }
848
+ else if (Array.isArray(typed.content)) {
846
849
  for (const part of typed.content) {
847
- if (part.type === "output_text")
850
+ if (part.type === "output_text" || part.type === "input_text") {
848
851
  textParts.push(part.text);
852
+ }
849
853
  }
850
854
  }
851
- const msg = {
852
- role: "assistant",
853
- };
854
- if (textParts.length > 0)
855
- msg.content = textParts.join("");
856
- messages.push(msg);
855
+ if (textParts.length > 0) {
856
+ messages.push({
857
+ role: "assistant",
858
+ content: textParts.join(""),
859
+ });
860
+ }
857
861
  }
858
862
  }
859
863
  else if (typed.type === "reasoning") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenmux/rosetta-ai",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "description": "Universal translator between AI provider protocols",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",