@mmmbuto/zai-codex-bridge 0.1.4 → 0.1.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server.js +26 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmmbuto/zai-codex-bridge",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Local proxy that translates OpenAI Responses API format to Z.AI Chat Completions format for Codex",
5
5
  "main": "src/server.js",
6
6
  "bin": {
package/src/server.js CHANGED
@@ -71,25 +71,34 @@ function translateResponsesToChat(request) {
71
71
  });
72
72
  }
73
73
 
74
- // Add messages from input array
75
- if (request.input && Array.isArray(request.input)) {
76
- for (const item of request.input) {
77
- const msg = {
78
- role: item.role,
79
- content: flattenContent(item.content)
80
- };
81
-
82
- // Handle tool calls if present
83
- if (item.tool_calls && Array.isArray(item.tool_calls)) {
84
- msg.tool_calls = item.tool_calls;
85
- }
74
+ // Handle input: can be string (simple user message) or array (message history)
75
+ if (request.input) {
76
+ if (typeof request.input === 'string') {
77
+ // Simple string input -> user message
78
+ messages.push({
79
+ role: 'user',
80
+ content: request.input
81
+ });
82
+ } else if (Array.isArray(request.input)) {
83
+ // Array of message objects
84
+ for (const item of request.input) {
85
+ const msg = {
86
+ role: item.role,
87
+ content: flattenContent(item.content)
88
+ };
89
+
90
+ // Handle tool calls if present
91
+ if (item.tool_calls && Array.isArray(item.tool_calls)) {
92
+ msg.tool_calls = item.tool_calls;
93
+ }
86
94
 
87
- // Handle tool call ID for tool responses
88
- if (item.tool_call_id) {
89
- msg.tool_call_id = item.tool_call_id;
90
- }
95
+ // Handle tool call ID for tool responses
96
+ if (item.tool_call_id) {
97
+ msg.tool_call_id = item.tool_call_id;
98
+ }
91
99
 
92
- messages.push(msg);
100
+ messages.push(msg);
101
+ }
93
102
  }
94
103
  }
95
104