mimo2codex 0.1.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.
@@ -0,0 +1,381 @@
1
+ import { log } from "../util/log.js";
2
+ // Per MiMo docs (https://platform.xiaomimimo.com/docs/zh-CN/usage-guide/multimodal-understanding/image-understanding),
3
+ // only `mimo-v2.5` and `mimo-v2-omni` (and *-omni* variants) accept image
4
+ // input. The other v2.5 variants (mimo-v2.5-pro, mimo-v2.5-pro[1m],
5
+ // mimo-v2-flash, …) return 404 "No endpoints found that support image input"
6
+ // when given image_url parts.
7
+ function modelSupportsImages(model) {
8
+ // Strip the optional context-window suffix like [1m]
9
+ const base = model.replace(/\[[^\]]*\]$/, "").toLowerCase();
10
+ if (base.includes("omni"))
11
+ return true;
12
+ if (base === "mimo-v2.5")
13
+ return true;
14
+ return false;
15
+ }
16
+ function partsToChatContent(parts, ctx) {
17
+ if (typeof parts === "string")
18
+ return parts;
19
+ const out = [];
20
+ let droppedImages = 0;
21
+ for (const p of parts) {
22
+ if (p.type === "input_text" || p.type === "output_text") {
23
+ // Defensive: Codex/clients sometimes send malformed text parts where
24
+ // `text` is missing or non-string. Coerce to "" and drop empties —
25
+ // MiMo's parser rejects parts where `text` is missing/empty with
26
+ // "Param Incorrect: `text` is not set".
27
+ const text = typeof p.text === "string" ? p.text : "";
28
+ if (text.length === 0)
29
+ continue;
30
+ out.push({ type: "text", text });
31
+ }
32
+ else if (p.type === "input_image") {
33
+ if (ctx.supportsImages) {
34
+ out.push({ type: "image_url", image_url: { url: p.image_url, detail: p.detail } });
35
+ }
36
+ else {
37
+ droppedImages++;
38
+ }
39
+ }
40
+ else if (p.type === "input_file") {
41
+ // MiMo doesn't natively support file inputs in chat completions.
42
+ // Drop the part but leave the message intact.
43
+ log.warn("dropped input_file part — MiMo chat API does not accept file inputs");
44
+ }
45
+ // Unknown part types (e.g. summary_text in some Responses variants) are
46
+ // silently skipped — they'd cause MiMo to 400 if forwarded as-is.
47
+ }
48
+ if (droppedImages > 0) {
49
+ log.warn(`dropped ${droppedImages} image part(s) — model "${ctx.model}" does not support image input (use mimo-v2.5 or mimo-v2-omni for vision)`);
50
+ // Add a short inline note so the model knows context was lost.
51
+ out.push({
52
+ type: "text",
53
+ text: `[${droppedImages} image attachment${droppedImages > 1 ? "s" : ""} omitted: this model does not support image input. Switch to mimo-v2.5 or mimo-v2-omni for vision tasks.]`,
54
+ });
55
+ }
56
+ // MiMo's image-understanding API REQUIRES at least one `text` part in the
57
+ // content array whenever `image_url` parts are present. Otherwise it 400s
58
+ // with "Param Incorrect: `text` is not set" (yes, even though OpenAI's
59
+ // chat API doesn't require this). Codex sometimes sends image-only user
60
+ // messages (paste-and-send), so we add an empty fallback to satisfy the
61
+ // schema. The image alone is usually enough context for the model.
62
+ const hasImage = out.some((p) => p.type === "image_url");
63
+ const hasText = out.some((p) => p.type === "text");
64
+ if (hasImage && !hasText) {
65
+ out.push({ type: "text", text: " " });
66
+ }
67
+ // If the message is purely text, collapse to a string for cleaner upstream payloads.
68
+ if (out.length > 0 && out.every((p) => p.type === "text")) {
69
+ return out.map((p) => p.text).join("");
70
+ }
71
+ if (out.length === 0)
72
+ return "";
73
+ return out;
74
+ }
75
+ function messageItemToChat(item, ctx) {
76
+ const role = item.role === "developer" ? "system" : item.role;
77
+ const content = partsToChatContent(item.content, ctx);
78
+ if (role === "assistant") {
79
+ return { role: "assistant", content: typeof content === "string" ? content : "" };
80
+ }
81
+ return { role, content };
82
+ }
83
+ // Schema for Codex's `local_shell` builtin tool, mapped to a regular function
84
+ // tool that MiMo (and any chat-completions-only provider) can understand.
85
+ // Codex registers handlers for both `local_shell` (builtin) and `shell`
86
+ // (function), so emitting `shell` tool_calls back to it just works.
87
+ const LOCAL_SHELL_FN = {
88
+ type: "function",
89
+ function: {
90
+ name: "shell",
91
+ description: "Execute a shell command on the local machine. Returns stdout, stderr and exit code.",
92
+ parameters: {
93
+ type: "object",
94
+ properties: {
95
+ command: {
96
+ type: "array",
97
+ items: { type: "string" },
98
+ description: "Argv array, e.g. [\"ls\", \"-la\"]. The first element is the program; remaining elements are arguments.",
99
+ },
100
+ workdir: {
101
+ type: "string",
102
+ description: "Working directory to run the command in (optional).",
103
+ },
104
+ timeout_ms: {
105
+ type: "number",
106
+ description: "Timeout in milliseconds (optional, default 30000).",
107
+ },
108
+ },
109
+ required: ["command"],
110
+ },
111
+ strict: null,
112
+ },
113
+ };
114
+ // Tools that exist server-side at OpenAI but have no equivalent at MiMo.
115
+ // We drop them silently (only log at debug level) — there's nothing a chat
116
+ // completions provider can do with them. NOTE: web_search and
117
+ // web_search_preview are NOT in this list — MiMo has its own native
118
+ // web_search builtin (requires the Web Search Plugin to be activated in
119
+ // the MiMo console: https://platform.xiaomimimo.com/#/console/plugin).
120
+ const SERVER_SIDE_TOOLS = new Set([
121
+ "code_interpreter",
122
+ "file_search",
123
+ "image_generation",
124
+ "computer_use_preview",
125
+ "computer_use",
126
+ ]);
127
+ // Track tool types we've already warned about so we don't spam the log on
128
+ // every request (Codex re-sends the full tool list each turn).
129
+ const warnedTypes = new Set();
130
+ function warnOnce(toolType, msg) {
131
+ if (warnedTypes.has(toolType))
132
+ return;
133
+ warnedTypes.add(toolType);
134
+ log.warn(msg);
135
+ }
136
+ // Returns one or more ChatTools (a `namespace` wrapper can expand to many),
137
+ // or null if the tool is unrecognized / unsupported.
138
+ function toolToChat(t) {
139
+ // 1. Standard OpenAI function tool — pass through.
140
+ if (t.type === "function") {
141
+ const ft = t;
142
+ if (!ft.name) {
143
+ log.debug("dropping function tool with no name");
144
+ return null;
145
+ }
146
+ return {
147
+ type: "function",
148
+ function: {
149
+ name: ft.name,
150
+ description: ft.description,
151
+ parameters: ft.parameters,
152
+ strict: ft.strict ?? null,
153
+ },
154
+ };
155
+ }
156
+ // 2. Codex's `local_shell` builtin → emit as a regular `shell` function tool
157
+ // with the canonical schema (see LOCAL_SHELL_FN above). Codex's tool router
158
+ // accepts both names.
159
+ if (t.type === "local_shell") {
160
+ return LOCAL_SHELL_FN;
161
+ }
162
+ // 2.5. OpenAI's `web_search` / `web_search_preview` → MiMo's native `web_search`.
163
+ // MiMo's format is similar (user_location + a few extras like max_keyword,
164
+ // force_search, limit). OpenAI's `search_context_size` has no MiMo
165
+ // equivalent — drop it. The MiMo Web Search Plugin must be activated
166
+ // in the user's console for this to actually work upstream.
167
+ if (t.type === "web_search" || t.type === "web_search_preview") {
168
+ const w = t;
169
+ const tool = { type: "web_search" };
170
+ if (w.user_location)
171
+ tool.user_location = w.user_location;
172
+ if (typeof w.max_keyword === "number")
173
+ tool.max_keyword = w.max_keyword;
174
+ if (typeof w.force_search === "boolean")
175
+ tool.force_search = w.force_search;
176
+ if (typeof w.limit === "number")
177
+ tool.limit = w.limit;
178
+ return tool;
179
+ }
180
+ // 3. Codex / OpenAI `custom` tool — freeform tool, often used for grammar-
181
+ // constrained outputs. We can't enforce the grammar at MiMo, but we can
182
+ // forward the name + description as a parameter-less function so the
183
+ // model can still call it. Format here:
184
+ // { type: "custom", name, description?, format?: { type: "grammar" | "text", ... } }
185
+ if (t.type === "custom") {
186
+ const ct = t;
187
+ if (!ct.name) {
188
+ log.debug("dropping custom tool with no name");
189
+ return null;
190
+ }
191
+ const formatType = ct.format?.type;
192
+ const desc = (ct.description ?? "") +
193
+ (formatType
194
+ ? ` (originally a "${formatType}"-format custom tool; output should follow that format).`
195
+ : "");
196
+ return {
197
+ type: "function",
198
+ function: {
199
+ name: ct.name,
200
+ description: desc.trim() || undefined,
201
+ // Permissive schema since we don't know the original input shape.
202
+ parameters: {
203
+ type: "object",
204
+ properties: {
205
+ input: {
206
+ type: "string",
207
+ description: "Input text for the tool.",
208
+ },
209
+ },
210
+ additionalProperties: true,
211
+ },
212
+ strict: null,
213
+ },
214
+ };
215
+ }
216
+ // 4. `namespace` wrapper — Codex bundles MCP / grouped tools under this. Shape
217
+ // we've seen in the wild:
218
+ // { type: "namespace", name?: string, tools?: Tool[] }
219
+ // Recurse into nested tools and flatten. If there's no nested array, drop.
220
+ if (t.type === "namespace") {
221
+ const ns = t;
222
+ if (!Array.isArray(ns.tools) || ns.tools.length === 0) {
223
+ log.debug(`dropping "namespace" tool ${ns.name ? `"${ns.name}"` : ""} with no nested tools`);
224
+ return null;
225
+ }
226
+ const nested = [];
227
+ for (const inner of ns.tools) {
228
+ const r = toolToChat(inner);
229
+ if (Array.isArray(r))
230
+ nested.push(...r);
231
+ else if (r)
232
+ nested.push(r);
233
+ }
234
+ return nested.length > 0 ? nested : null;
235
+ }
236
+ // 5. Server-side tools that only OpenAI/Azure can fulfill — silently drop.
237
+ if (SERVER_SIDE_TOOLS.has(t.type)) {
238
+ log.debug(`dropping server-side tool "${t.type}" — no MiMo equivalent (only OpenAI/Azure can fulfill)`);
239
+ return null;
240
+ }
241
+ // 6. Truly unknown — warn once per type so we get a heads-up but don't spam.
242
+ warnOnce(t.type, `dropping unsupported tool type "${t.type}" — please open an issue if this should be translated`);
243
+ return null;
244
+ }
245
+ function toolChoiceToChat(tc) {
246
+ if (tc === undefined)
247
+ return undefined;
248
+ if (typeof tc === "string")
249
+ return tc;
250
+ if (tc.type === "function") {
251
+ const name = tc.function?.name ?? tc.name;
252
+ if (!name)
253
+ return undefined;
254
+ return { type: "function", function: { name } };
255
+ }
256
+ return undefined;
257
+ }
258
+ function flushAssistant(messages, state) {
259
+ const hasReasoning = state.pendingReasoning !== null;
260
+ const hasTools = state.pendingToolCalls.length > 0;
261
+ const hasText = state.pendingAssistantText !== null;
262
+ if (!hasReasoning && !hasTools && !hasText)
263
+ return;
264
+ const msg = { role: "assistant", content: hasText ? state.pendingAssistantText : null };
265
+ if (hasTools)
266
+ msg.tool_calls = state.pendingToolCalls;
267
+ if (hasReasoning)
268
+ msg.reasoning_content = state.pendingReasoning;
269
+ messages.push(msg);
270
+ state.pendingReasoning = null;
271
+ state.pendingToolCalls = [];
272
+ state.pendingAssistantText = null;
273
+ }
274
+ function inputItemsToMessages(items, ctx) {
275
+ const out = [];
276
+ const state = {
277
+ pendingReasoning: null,
278
+ pendingToolCalls: [],
279
+ pendingAssistantText: null,
280
+ };
281
+ for (const item of items) {
282
+ switch (item.type) {
283
+ case "message": {
284
+ if (item.role === "assistant") {
285
+ // Assistant message — fold into pending so reasoning_content can join it.
286
+ const content = partsToChatContent(item.content, ctx);
287
+ state.pendingAssistantText =
288
+ typeof content === "string" ? content : "";
289
+ // If assistant message comes alone (without preceding reasoning or
290
+ // following tool_calls), flush immediately so we keep ordering.
291
+ flushAssistant(out, state);
292
+ }
293
+ else {
294
+ flushAssistant(out, state);
295
+ out.push(messageItemToChat(item, ctx));
296
+ }
297
+ break;
298
+ }
299
+ case "reasoning": {
300
+ flushAssistant(out, state);
301
+ const text = item.summary
302
+ .filter((s) => s.type === "summary_text")
303
+ .map((s) => s.text)
304
+ .join("");
305
+ state.pendingReasoning = text;
306
+ break;
307
+ }
308
+ case "function_call": {
309
+ state.pendingToolCalls.push({
310
+ id: item.call_id,
311
+ type: "function",
312
+ function: { name: item.name, arguments: item.arguments },
313
+ });
314
+ break;
315
+ }
316
+ case "function_call_output": {
317
+ flushAssistant(out, state);
318
+ out.push({
319
+ role: "tool",
320
+ tool_call_id: item.call_id,
321
+ content: item.output,
322
+ });
323
+ break;
324
+ }
325
+ }
326
+ }
327
+ flushAssistant(out, state);
328
+ return out;
329
+ }
330
+ export function reqToChat(req) {
331
+ const messages = [];
332
+ const ctx = {
333
+ model: req.model,
334
+ supportsImages: modelSupportsImages(req.model),
335
+ };
336
+ if (req.instructions) {
337
+ messages.push({ role: "system", content: req.instructions });
338
+ }
339
+ if (typeof req.input === "string") {
340
+ messages.push({ role: "user", content: req.input });
341
+ }
342
+ else if (Array.isArray(req.input)) {
343
+ for (const m of inputItemsToMessages(req.input, ctx)) {
344
+ messages.push(m);
345
+ }
346
+ }
347
+ const chat = {
348
+ model: req.model,
349
+ messages,
350
+ stream: req.stream ?? false,
351
+ };
352
+ if (req.tools && req.tools.length > 0) {
353
+ const mapped = [];
354
+ for (const t of req.tools) {
355
+ const r = toolToChat(t);
356
+ if (Array.isArray(r))
357
+ mapped.push(...r);
358
+ else if (r)
359
+ mapped.push(r);
360
+ }
361
+ if (mapped.length > 0)
362
+ chat.tools = mapped;
363
+ }
364
+ const tc = toolChoiceToChat(req.tool_choice);
365
+ if (tc !== undefined)
366
+ chat.tool_choice = tc;
367
+ if (req.parallel_tool_calls !== undefined) {
368
+ chat.parallel_tool_calls = req.parallel_tool_calls;
369
+ }
370
+ if (req.temperature !== undefined && req.temperature !== null) {
371
+ chat.temperature = req.temperature;
372
+ }
373
+ if (req.top_p !== undefined && req.top_p !== null) {
374
+ chat.top_p = req.top_p;
375
+ }
376
+ if (req.max_output_tokens !== undefined && req.max_output_tokens !== null) {
377
+ chat.max_completion_tokens = req.max_output_tokens;
378
+ }
379
+ return chat;
380
+ }
381
+ //# sourceMappingURL=reqToChat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reqToChat.js","sourceRoot":"","sources":["../../src/translate/reqToChat.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,uHAAuH;AACvH,0EAA0E;AAC1E,oEAAoE;AACpE,6EAA6E;AAC7E,8BAA8B;AAC9B,SAAS,mBAAmB,CAAC,KAAa;IACxC,qDAAqD;IACrD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5D,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IACtC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAsC,EACtC,GAA+C;IAE/C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE5C,MAAM,GAAG,GAAsB,EAAE,CAAC;IAClC,IA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AAmB,CAAC;IACrD,CAAC;IACD,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,GAAG,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;IACrC,CAAC;IACD,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAClD,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IACzB,CAAC;IACD,IAAI,GAAG,CAAC,iBAAiB,KAAK,SAAS,IAAI,GAAG,CAAC,iBAAiB,KAAK,IAAI,EAAE,CAAC;QAC1E,IAAI,CAAC,qBAAqB,GAAG,GAAG,CAAC,iBAAiB,CAAC;IACrD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,94 @@
1
+ import { newFunctionCallId, newMessageId, newReasoningId, newResponseId, } from "../util/ids.js";
2
+ function mapUsage(u) {
3
+ if (!u)
4
+ return null;
5
+ const out = {
6
+ input_tokens: u.prompt_tokens,
7
+ output_tokens: u.completion_tokens,
8
+ total_tokens: u.total_tokens,
9
+ };
10
+ if (u.prompt_tokens_details?.cached_tokens !== undefined) {
11
+ out.input_tokens_details = { cached_tokens: u.prompt_tokens_details.cached_tokens };
12
+ }
13
+ if (u.completion_tokens_details?.reasoning_tokens !== undefined) {
14
+ out.output_tokens_details = {
15
+ reasoning_tokens: u.completion_tokens_details.reasoning_tokens,
16
+ };
17
+ }
18
+ return out;
19
+ }
20
+ export function respToResponses(chat, req, opts) {
21
+ const choice = chat.choices[0];
22
+ const message = choice?.message;
23
+ const output = [];
24
+ if (opts.exposeReasoning && message?.reasoning_content) {
25
+ output.push({
26
+ type: "reasoning",
27
+ id: newReasoningId(),
28
+ summary: [{ type: "summary_text", text: message.reasoning_content }],
29
+ encrypted_content: null,
30
+ status: "completed",
31
+ });
32
+ }
33
+ if (message?.content) {
34
+ // Translate MiMo annotations (url_citation with url/title/summary) into
35
+ // Codex-shape annotations on the output_text content part. Codex displays
36
+ // these as inline citations.
37
+ const annotations = message.annotations?.map((a) => ({
38
+ type: a.type ?? "url_citation",
39
+ url: a.url ?? "",
40
+ title: a.title ?? "",
41
+ ...(a.summary !== undefined ? { snippet: a.summary } : {}),
42
+ })) ?? [];
43
+ output.push({
44
+ type: "message",
45
+ id: newMessageId(),
46
+ role: "assistant",
47
+ status: "completed",
48
+ content: [
49
+ { type: "output_text", text: message.content, annotations },
50
+ ],
51
+ });
52
+ }
53
+ if (message?.tool_calls && message.tool_calls.length > 0) {
54
+ for (const tc of message.tool_calls) {
55
+ output.push({
56
+ type: "function_call",
57
+ id: newFunctionCallId(),
58
+ call_id: tc.id,
59
+ name: tc.function.name,
60
+ arguments: tc.function.arguments,
61
+ status: "completed",
62
+ });
63
+ }
64
+ }
65
+ const finishReason = choice?.finish_reason ?? "stop";
66
+ const incomplete = finishReason === "length" ? { reason: "max_output_tokens" } : null;
67
+ return {
68
+ id: newResponseId(),
69
+ object: "response",
70
+ created_at: chat.created,
71
+ status: incomplete ? "incomplete" : "completed",
72
+ model: chat.model,
73
+ output,
74
+ usage: mapUsage(chat.usage),
75
+ parallel_tool_calls: req.parallel_tool_calls ?? true,
76
+ tool_choice: req.tool_choice ?? "auto",
77
+ reasoning: {
78
+ effort: req.reasoning?.effort ?? null,
79
+ summary: req.reasoning?.summary ?? null,
80
+ },
81
+ text: req.text?.format ? { format: req.text.format } : { format: { type: "text" } },
82
+ incomplete_details: incomplete,
83
+ error: null,
84
+ metadata: req.metadata ?? null,
85
+ previous_response_id: req.previous_response_id ?? null,
86
+ instructions: req.instructions ?? null,
87
+ temperature: req.temperature ?? null,
88
+ top_p: req.top_p ?? null,
89
+ max_output_tokens: req.max_output_tokens ?? null,
90
+ tools: req.tools ?? [],
91
+ truncation: "disabled",
92
+ };
93
+ }
94
+ //# sourceMappingURL=respToResponses.js.map
@@ -0,0 +1 @@
1
+ {"version":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