@marsapi/cli 0.0.136 → 0.0.137

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.
@@ -10,7 +10,7 @@
10
10
  "claude": [
11
11
  {
12
12
  "description": "100 万上下文 | 高强度推理 | 长时 Agent | SWE-bench Verified 95%",
13
- "group": "grp_6eg2dq9ywgrg",
13
+ "group": "grp_rld6af0zorqd",
14
14
  "group_name": "",
15
15
  "hidden": false,
16
16
  "id": "claude-fable-5",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  {
21
21
  "description": "100 万上下文 | 12.8 万输出 | 自适应思考常开 | 长时 Agent 与多步研究",
22
- "group": "grp_pzxnceygmqlp",
22
+ "group": "grp_6eg2dq9ywgrg",
23
23
  "group_name": "",
24
24
  "hidden": false,
25
25
  "id": "claude-fable-5-1",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  {
30
30
  "description": "轻量档 | 低延迟 | 高频短任务",
31
- "group": "grp_irydsgijuckh",
31
+ "group": "grp_6eg2dq9ywgrg",
32
32
  "group_name": "",
33
33
  "hidden": false,
34
34
  "id": "claude-haiku-4-5-20251001",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  {
39
39
  "description": "100 万上下文 | 12.8 万输出 | 低延迟 | 高频轻量任务",
40
- "group": "grp_rld6af0zorqd",
40
+ "group": "grp_6co8aqwefsoh",
41
41
  "group_name": "",
42
42
  "hidden": false,
43
43
  "id": "claude-haiku-5-5",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  {
48
48
  "description": "100 万上下文 | 推理 | 编程 | 长上下文不加价",
49
- "group": "grp_6eg2dq9ywgrg",
49
+ "group": "grp_irydsgijuckh",
50
50
  "group_name": "",
51
51
  "hidden": false,
52
52
  "id": "claude-opus-4-6",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  {
57
57
  "description": "100 万上下文 | 推理 | 编程 | 长上下文不加价",
58
- "group": "grp_6eg2dq9ywgrg",
58
+ "group": "grp_6co8aqwefsoh",
59
59
  "group_name": "",
60
60
  "hidden": false,
61
61
  "id": "claude-opus-4-7",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  {
66
66
  "description": "100 万上下文 | 推理 | 编程 | 长上下文不加价",
67
- "group": "grp_6co8aqwefsoh",
67
+ "group": "grp_6eg2dq9ywgrg",
68
68
  "group_name": "",
69
69
  "hidden": false,
70
70
  "id": "claude-opus-4-8",
@@ -73,7 +73,7 @@
73
73
  },
74
74
  {
75
75
  "description": "100 万上下文 | 12.8 万输出 | 自适应思考五档 | Agent 编程",
76
- "group": "grp_6eg2dq9ywgrg",
76
+ "group": "grp_irydsgijuckh",
77
77
  "group_name": "",
78
78
  "hidden": false,
79
79
  "id": "claude-opus-5",
@@ -91,7 +91,7 @@
91
91
  },
92
92
  {
93
93
  "description": "100 万上下文 | Agent 编程 | 长上下文不加价",
94
- "group": "grp_6eg2dq9ywgrg",
94
+ "group": "grp_pzxnceygmqlp",
95
95
  "group_name": "",
96
96
  "hidden": false,
97
97
  "id": "claude-sonnet-4-6",
@@ -100,7 +100,7 @@
100
100
  },
101
101
  {
102
102
  "description": "100 万上下文 | Agent 编程 | 工具调用 | 知识工作",
103
- "group": "grp_6eg2dq9ywgrg",
103
+ "group": "grp_pzxnceygmqlp",
104
104
  "group_name": "",
105
105
  "hidden": false,
106
106
  "id": "claude-sonnet-5",
@@ -109,7 +109,7 @@
109
109
  },
110
110
  {
111
111
  "description": "100 万上下文 | 12.8 万输出 | Agent 编程 | 知识工作",
112
- "group": "grp_6eg2dq9ywgrg",
112
+ "group": "grp_6lyxfgbs440g",
113
113
  "group_name": "",
114
114
  "hidden": false,
115
115
  "id": "claude-sonnet-5-5",
@@ -120,7 +120,7 @@
120
120
  "codex": [
121
121
  {
122
122
  "description": "100 万上下文 | 12.8 万输出 | 复杂专业负载",
123
- "group": "grp_irydsgijuckh",
123
+ "group": "grp_bsbtt432saoq",
124
124
  "group_name": "",
125
125
  "hidden": false,
126
126
  "id": "gpt-5.5",
@@ -138,7 +138,7 @@
138
138
  },
139
139
  {
140
140
  "description": "105 万上下文 | 12.8 万输出 | 前沿档",
141
- "group": "grp_6co8aqwefsoh",
141
+ "group": "grp_mb5v069lpnze",
142
142
  "group_name": "",
143
143
  "hidden": false,
144
144
  "id": "gpt-5.6-sol",
@@ -156,7 +156,7 @@
156
156
  },
157
157
  {
158
158
  "description": "105 万上下文 | 12.8 万输出 | 思考强度至 max | 计算机操作 / 编码 / 科学基准接近饱和",
159
- "group": "grp_irydsgijuckh",
159
+ "group": "grp_bsbtt432saoq",
160
160
  "group_name": "",
161
161
  "hidden": false,
162
162
  "id": "gpt-6-astra",
@@ -165,7 +165,7 @@
165
165
  },
166
166
  {
167
167
  "description": "转发至 gpt-6-sol | 实际由 gpt-6-sol 响应 | 105 万上下文 | 12.8 万输出",
168
- "group": "grp_irydsgijuckh",
168
+ "group": "grp_squ2qzjnehps",
169
169
  "group_name": "",
170
170
  "hidden": false,
171
171
  "id": "gpt-6-luna",
@@ -174,7 +174,7 @@
174
174
  },
175
175
  {
176
176
  "description": "105 万上下文 | 12.8 万输出 | 复杂编程与 Agent 工作流",
177
- "group": "grp_mb5v069lpnze",
177
+ "group": "grp_irydsgijuckh",
178
178
  "group_name": "",
179
179
  "hidden": false,
180
180
  "id": "gpt-6-sol",
@@ -183,7 +183,7 @@
183
183
  },
184
184
  {
185
185
  "description": "105 万上下文 | 12.8 万输出 | 文字与图像输入 | 工具调用、联网搜索、结构化输出 | 工具调用使用 Responses API",
186
- "group": "grp_irydsgijuckh",
186
+ "group": "grp_mb5v069lpnze",
187
187
  "group_name": "",
188
188
  "hidden": false,
189
189
  "id": "gpt-6.1-sol",
@@ -239,7 +239,7 @@
239
239
  },
240
240
  {
241
241
  "description": "Gemini 3.1 Pro 预览版 | 约 100 万上下文 | 深度推理 | 文本、图像、音视频输入",
242
- "group": "grp_3pi5kyqkp51b",
242
+ "group": "grp_z5khwusxuh2j",
243
243
  "group_name": "",
244
244
  "hidden": false,
245
245
  "id": "gemini-3.1-pro-preview",
@@ -275,7 +275,7 @@
275
275
  },
276
276
  {
277
277
  "description": "推理与编码 | HLE-Verified 54.9% | 长文档工作流",
278
- "group": "grp_3pi5kyqkp51b",
278
+ "group": "grp_z5khwusxuh2j",
279
279
  "group_name": "",
280
280
  "hidden": false,
281
281
  "id": "gemini-3.8-flash",
@@ -304,7 +304,7 @@
304
304
  "grok": [
305
305
  {
306
306
  "description": "50 万上下文 | 1.5 万亿参数 MoE | 编码与 Agent",
307
- "group": "grp_irydsgijuckh",
307
+ "group": "grp_l34dwliv4yas",
308
308
  "group_name": "",
309
309
  "hidden": false,
310
310
  "id": "grok-4.5",
@@ -10,7 +10,7 @@
10
10
  "claude": [
11
11
  {
12
12
  "description": "100 万上下文 | 高强度推理 | 长时 Agent | SWE-bench Verified 95%",
13
- "group": "grp_6eg2dq9ywgrg",
13
+ "group": "grp_rld6af0zorqd",
14
14
  "group_name": "",
15
15
  "hidden": false,
16
16
  "id": "claude-fable-5",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  {
21
21
  "description": "100 万上下文 | 12.8 万输出 | 自适应思考常开 | 长时 Agent 与多步研究",
22
- "group": "grp_pzxnceygmqlp",
22
+ "group": "grp_6eg2dq9ywgrg",
23
23
  "group_name": "",
24
24
  "hidden": false,
25
25
  "id": "claude-fable-5-1",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  {
30
30
  "description": "轻量档 | 低延迟 | 高频短任务",
31
- "group": "grp_irydsgijuckh",
31
+ "group": "grp_6eg2dq9ywgrg",
32
32
  "group_name": "",
33
33
  "hidden": false,
34
34
  "id": "claude-haiku-4-5-20251001",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  {
39
39
  "description": "100 万上下文 | 12.8 万输出 | 低延迟 | 高频轻量任务",
40
- "group": "grp_rld6af0zorqd",
40
+ "group": "grp_6co8aqwefsoh",
41
41
  "group_name": "",
42
42
  "hidden": false,
43
43
  "id": "claude-haiku-5-5",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  {
48
48
  "description": "100 万上下文 | 推理 | 编程 | 长上下文不加价",
49
- "group": "grp_6eg2dq9ywgrg",
49
+ "group": "grp_irydsgijuckh",
50
50
  "group_name": "",
51
51
  "hidden": false,
52
52
  "id": "claude-opus-4-6",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  {
57
57
  "description": "100 万上下文 | 推理 | 编程 | 长上下文不加价",
58
- "group": "grp_6eg2dq9ywgrg",
58
+ "group": "grp_6co8aqwefsoh",
59
59
  "group_name": "",
60
60
  "hidden": false,
61
61
  "id": "claude-opus-4-7",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  {
66
66
  "description": "100 万上下文 | 推理 | 编程 | 长上下文不加价",
67
- "group": "grp_6co8aqwefsoh",
67
+ "group": "grp_6eg2dq9ywgrg",
68
68
  "group_name": "",
69
69
  "hidden": false,
70
70
  "id": "claude-opus-4-8",
@@ -73,7 +73,7 @@
73
73
  },
74
74
  {
75
75
  "description": "100 万上下文 | 12.8 万输出 | 自适应思考五档 | Agent 编程",
76
- "group": "grp_6eg2dq9ywgrg",
76
+ "group": "grp_irydsgijuckh",
77
77
  "group_name": "",
78
78
  "hidden": false,
79
79
  "id": "claude-opus-5",
@@ -91,7 +91,7 @@
91
91
  },
92
92
  {
93
93
  "description": "100 万上下文 | Agent 编程 | 长上下文不加价",
94
- "group": "grp_6eg2dq9ywgrg",
94
+ "group": "grp_pzxnceygmqlp",
95
95
  "group_name": "",
96
96
  "hidden": false,
97
97
  "id": "claude-sonnet-4-6",
@@ -100,7 +100,7 @@
100
100
  },
101
101
  {
102
102
  "description": "100 万上下文 | Agent 编程 | 工具调用 | 知识工作",
103
- "group": "grp_6eg2dq9ywgrg",
103
+ "group": "grp_pzxnceygmqlp",
104
104
  "group_name": "",
105
105
  "hidden": false,
106
106
  "id": "claude-sonnet-5",
@@ -109,7 +109,7 @@
109
109
  },
110
110
  {
111
111
  "description": "100 万上下文 | 12.8 万输出 | Agent 编程 | 知识工作",
112
- "group": "grp_6eg2dq9ywgrg",
112
+ "group": "grp_6lyxfgbs440g",
113
113
  "group_name": "",
114
114
  "hidden": false,
115
115
  "id": "claude-sonnet-5-5",
@@ -120,7 +120,7 @@
120
120
  "codex": [
121
121
  {
122
122
  "description": "100 万上下文 | 12.8 万输出 | 复杂专业负载",
123
- "group": "grp_irydsgijuckh",
123
+ "group": "grp_bsbtt432saoq",
124
124
  "group_name": "",
125
125
  "hidden": false,
126
126
  "id": "gpt-5.5",
@@ -138,7 +138,7 @@
138
138
  },
139
139
  {
140
140
  "description": "105 万上下文 | 12.8 万输出 | 前沿档",
141
- "group": "grp_6co8aqwefsoh",
141
+ "group": "grp_mb5v069lpnze",
142
142
  "group_name": "",
143
143
  "hidden": false,
144
144
  "id": "gpt-5.6-sol",
@@ -156,7 +156,7 @@
156
156
  },
157
157
  {
158
158
  "description": "105 万上下文 | 12.8 万输出 | 思考强度至 max | 计算机操作 / 编码 / 科学基准接近饱和",
159
- "group": "grp_irydsgijuckh",
159
+ "group": "grp_bsbtt432saoq",
160
160
  "group_name": "",
161
161
  "hidden": false,
162
162
  "id": "gpt-6-astra",
@@ -165,7 +165,7 @@
165
165
  },
166
166
  {
167
167
  "description": "转发至 gpt-6-sol | 实际由 gpt-6-sol 响应 | 105 万上下文 | 12.8 万输出",
168
- "group": "grp_irydsgijuckh",
168
+ "group": "grp_squ2qzjnehps",
169
169
  "group_name": "",
170
170
  "hidden": false,
171
171
  "id": "gpt-6-luna",
@@ -174,7 +174,7 @@
174
174
  },
175
175
  {
176
176
  "description": "105 万上下文 | 12.8 万输出 | 复杂编程与 Agent 工作流",
177
- "group": "grp_mb5v069lpnze",
177
+ "group": "grp_irydsgijuckh",
178
178
  "group_name": "",
179
179
  "hidden": false,
180
180
  "id": "gpt-6-sol",
@@ -183,7 +183,7 @@
183
183
  },
184
184
  {
185
185
  "description": "105 万上下文 | 12.8 万输出 | 文字与图像输入 | 工具调用、联网搜索、结构化输出 | 工具调用使用 Responses API",
186
- "group": "grp_irydsgijuckh",
186
+ "group": "grp_mb5v069lpnze",
187
187
  "group_name": "",
188
188
  "hidden": false,
189
189
  "id": "gpt-6.1-sol",
@@ -239,7 +239,7 @@
239
239
  },
240
240
  {
241
241
  "description": "Gemini 3.1 Pro 预览版 | 约 100 万上下文 | 深度推理 | 文本、图像、音视频输入",
242
- "group": "grp_3pi5kyqkp51b",
242
+ "group": "grp_z5khwusxuh2j",
243
243
  "group_name": "",
244
244
  "hidden": false,
245
245
  "id": "gemini-3.1-pro-preview",
@@ -275,7 +275,7 @@
275
275
  },
276
276
  {
277
277
  "description": "推理与编码 | HLE-Verified 54.9% | 长文档工作流",
278
- "group": "grp_3pi5kyqkp51b",
278
+ "group": "grp_z5khwusxuh2j",
279
279
  "group_name": "",
280
280
  "hidden": false,
281
281
  "id": "gemini-3.8-flash",
@@ -304,7 +304,7 @@
304
304
  "grok": [
305
305
  {
306
306
  "description": "50 万上下文 | 1.5 万亿参数 MoE | 编码与 Agent",
307
- "group": "grp_irydsgijuckh",
307
+ "group": "grp_l34dwliv4yas",
308
308
  "group_name": "",
309
309
  "hidden": false,
310
310
  "id": "grok-4.5",
@@ -1 +1 @@
1
- import{spawnSync as t}from"child_process";import{existsSync as o,mkdtempSync as e,readFileSync as n,realpathSync as s,rmSync as r,statSync as i,writeFileSync as c}from"fs";import{tmpdir as l}from"os";import{delimiter as a,dirname as u,isAbsolute as d,join as p}from"path";import*as f from"@iarna/toml";import{fileURLToPath as m}from"url";import{logger as _}from"../../utils/logger.js";import{getCodexRules as x,compareVersions as g}from"../model-registry.js";import{autoCompactTokens as w,modelBlurb as h,prettyModelName as y}from"../gateway-models.js";import{codexHome as b,toolHome as C}from"./types.js";import{brandEnv as v,CLI_NAME as M,PROVIDER_KEY as A}from"../brand.js";const j=u(m(import.meta.url));export const CODEX_CATALOG_FILE=`${A}-model-catalog.json`;export const codexCatalogPath=()=>p(b(),CODEX_CATALOG_FILE);function O(){const t=v("CODEX_BIN");if(void 0!==t)return t.trim()?[t.trim()]:[];const o=["codex"];if("win32"===process.platform){const t=process.env.LOCALAPPDATA||p(C(),"AppData","Local");o.push(p(t,"Programs","OpenAI","Codex","bin","codex.exe"))}else o.push(p(C(),".local","bin","codex"));if("darwin"===process.platform)for(const t of["/Applications",p(C(),"Applications")])o.push(p(t,"ChatGPT.app/Contents/Resources/codex-cli/bin/codex")),o.push(p(t,"Codex.app/Contents/Resources/codex"));return o}function $(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function E(t){try{const o=JSON.parse(t),e=$(o)&&Array.isArray(o.models)?o.models.filter($):[];return e.length>0?e:null}catch{return null}}function k(o,e,n){const s={encoding:"utf-8",timeout:2e4,maxBuffer:67108864,windowsHide:!0,stdio:["ignore","pipe","pipe"],...n?{env:n}:{}};return"win32"!==process.platform||"codex"!==o&&!/\.cmd$/i.test(o)?t(o,e,s):t(["codex"===o?"codex":`"${o}"`,...e].join(" "),{...s,shell:!0})}function P(t){const o=k(t,["debug","models","--bundled"]);if(0===o.status&&o.stdout){const t=E(o.stdout);if(t)return t}return(o.error||0!==o.status)&&_.logError("loadBundledCodexModels",o.error??new Error(`${t} exited ${o.status}`)),null}export function loadBundledCodexModels(t){if(t)return P(t);for(const t of O()){if("codex"!==t&&!o(t))continue;const e=P(t);if(e)return e}return null}function B(t){try{return i(t).isFile()}catch{return!1}}export function installedCodexBinaries(){const t=[],o=O();if(o.includes("codex")){const o="win32"===process.platform?["codex.exe","codex.cmd"]:["codex"];for(const e of(process.env.PATH??"").split(a))if(e&&d(e))for(const n of o)t.push(p(e,n))}t.push(...o.filter(t=>"codex"!==t));const e=new Set,n=[];for(const o of t){if(!B(o))continue;let t=o;try{t=s(o)}catch{}const r="win32"===process.platform?t.toLowerCase():t;e.has(r)||(e.add(r),n.push(o))}return n}export function codexBinaryVersion(t){const o=`${k(t,["--version"]).stdout??""}`.match(/(\d+)\.(\d+)\.(\d+)/);return o?o[0]:null}export function catalogRejections(t,o=installedCodexBinaries()){if(0===o.length)return[];const n=e(p(l(),`${M}-codex-`)),s=[];try{c(p(n,"config.toml"),f.stringify({model_catalog_json:t}));for(const t of o){const o=k(t,["debug","models"],{...process.env,CODEX_HOME:n});if(0===o.status)continue;const e=`${o.stderr??""}\n${o.stdout??""}`,r=e.split(/\r?\n/).find(t=>t.includes("model_catalog_json"));r?s.push({bin:t,version:codexBinaryVersion(t),error:r.trim()}):_.logError("catalogRejections",o.error??new Error(`${t} exited ${o.status}: ${e.trim().slice(0,500)}`))}}finally{r(n,{recursive:!0,force:!0})}return s}export function loadPreviousCodexModels(){const t=L()?.filter(t=>!S(t));return t&&t.length>0?t:null}export function previousGatewayModelIds(){return(L()??[]).filter(S).map(t=>String(t.slug))}function L(){return o(codexCatalogPath())?E(n(codexCatalogPath(),"utf-8")):null}function S(t){return"number"==typeof t.priority&&t.priority>=1e3}let T=null;function D(){if(null!==T)return T;const t=[p(j,"..","..","..","codex-base-instructions.md"),p(j,"..","..","codex-base-instructions.md"),p(j,"codex-base-instructions.md")],e=t.find(t=>o(t));if(!e)throw new Error(`codex-base-instructions.md not found, searched: ${t.join(", ")}`);return T=n(e,"utf-8"),T}function F(t){return"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0}function I(t,o,e,n){const s=e?t:Math.min(t,o);return{window:s,compact:w(s,n)}}function W(t,o,e,n){const{standardContextWindow:s}=x();let r=F(t.contextWindow)??s;n&&t.id.startsWith("claude-")&&(r=n.has(t.id)?Math.max(r,1e6):Math.min(r,2e5));const{window:i,compact:c}=I(r,s,e,F(t.autoCompactTokens));return{slug:t.id,display_name:t.name||y(t.id),description:h(t.description,{millionContext:i>=1e6})??null,supported_reasoning_levels:[],shell_type:"unified_exec",visibility:"list",supported_in_api:!0,priority:o,additional_speed_tiers:[],service_tiers:[],availability_nux:null,upgrade:null,model_messages:{instructions_template:D()},base_instructions:D(),supports_reasoning_summaries:!0,supports_parallel_tool_calls:!1,prefer_websockets:!1,include_skills_usage_instructions:!1,include_plugin_usage_instructions:!1,include_apps_usage_instructions:!1,default_reasoning_summary:"auto",support_verbosity:!1,default_verbosity:null,apply_patch_tool_type:null,web_search_tool_type:"text",truncation_policy:{mode:"bytes",limit:1e4},supports_image_detail_original:!1,context_window:i,max_context_window:i,auto_compact_token_limit:c,effective_context_window_percent:95,experimental_supported_tools:[],input_modalities:["text","image"],supports_search_tool:!1,supports_experimental_context:!1,use_responses_lite:!1,supports_reasoning_effort_updates:!1,node_repl_auto_review_required:!1,node_repl_disabled:!1}}const G={supports_parallel_tool_calls:!0,supports_reasoning_summaries:!0};export function fillFromOlderEntries(t,o){const e=new Map(o.map(t=>[t.slug,t])),n=new Map;for(const t of o)for(const[o,e]of Object.entries(t))n.has(o)||n.set(o,e);return t.map(t=>{const o=e.get(t.slug),s={...t};for(const[t,e]of n)t in s||(s[t]=o&&t in o?o[t]:e);return s})}function R(t,o,e){if("list"!==(t=function(t){const o=Object.keys(G).filter(o=>!(o in t));return 0===o.length?t:{...t,...Object.fromEntries(o.map(t=>[t,G[t]]))}}(t)).visibility)return t;const n=F(t.context_window);if(!n)return t;const s=F(t.max_context_window)??n,r=e?Math.min(F(o?.contextWindow)??s,s):n,{window:i,compact:c}=I(r,n,!0,F(o?.autoCompactTokens));return{...t,context_window:i,auto_compact_token_limit:c}}export function buildCodexCatalog(t){const{bundled:o,specs:e,oneMillion:n,selectedModel:s}=t,r=t.claudeOneMillion?new Set(t.claudeOneMillion):void 0,i=t.keyModels?new Set(t.keyModels):null,c=new Set(t.gatewayAvailable),l=t=>!i||i.has(t)||t===s,a=t=>c.has(t)||t===s,u=new Map(e.map(t=>[t.id,t])),d=[],p=new Set;for(const t of o){const o="string"==typeof t.slug?t.slug:"";o&&!p.has(o)&&("list"!==t.visibility||l(o))&&(p.add(o),d.push(R(t,u.get(o),n)))}const f=[...e];s&&!u.has(s)&&f.push({id:s});const m=function(t){const o=new Map;for(const e of t){const t=/^claude-([a-z]+)-(.+)$/.exec(e);if(!t)continue;const n=t[2].split("-").filter(t=>/^\d{1,2}$/.test(t)).join("."),s=o.get(t[1]);(!s||g(n,s.version)>0)&&o.set(t[1],{id:e,version:n})}return new Set([...o.values()].map(t=>t.id))}(f.map(t=>t.id).filter(a));for(const t of f)!p.has(t.id)&&a(t.id)&&(t.id.startsWith("claude-")&&!m.has(t.id)&&t.id!==s||(p.add(t.id),d.push(W(t,1e3+d.length,n,r))));return{models:d}}
1
+ import{spawnSync as t}from"child_process";import{existsSync as o,mkdtempSync as e,readFileSync as n,realpathSync as i,rmSync as r,statSync as s,writeFileSync as c}from"fs";import{tmpdir as l}from"os";import{delimiter as u,dirname as a,isAbsolute as d,join as p}from"path";import*as f from"@iarna/toml";import{fileURLToPath as m}from"url";import{logger as _}from"../../utils/logger.js";import{getCodexRules as x,compareVersions as g}from"../model-registry.js";import{autoCompactTokens as h,modelBlurb as w,prettyModelName as y}from"../gateway-models.js";import{codexHome as b,toolHome as v}from"./types.js";import{brandEnv as C,CLI_NAME as M,PROVIDER_KEY as j}from"../brand.js";const A=a(m(import.meta.url));export const CODEX_CATALOG_FILE=`${j}-model-catalog.json`;export const codexCatalogPath=()=>p(b(),CODEX_CATALOG_FILE);function O(){const t=C("CODEX_BIN");if(void 0!==t)return t.trim()?[t.trim()]:[];const o=["codex"];if("win32"===process.platform){const t=process.env.LOCALAPPDATA||p(v(),"AppData","Local");o.push(p(t,"Programs","OpenAI","Codex","bin","codex.exe"))}else o.push(p(v(),".local","bin","codex"));if("darwin"===process.platform)for(const t of["/Applications",p(v(),"Applications")])o.push(p(t,"ChatGPT.app/Contents/Resources/codex-cli/bin/codex")),o.push(p(t,"Codex.app/Contents/Resources/codex"));return o}function E(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function $(t){try{const o=JSON.parse(t),e=E(o)&&Array.isArray(o.models)?o.models.filter(E):[];return e.length>0?e:null}catch{return null}}function k(o,e,n){const i={encoding:"utf-8",timeout:2e4,maxBuffer:67108864,windowsHide:!0,stdio:["ignore","pipe","pipe"],...n?{env:n}:{}};return"win32"!==process.platform||"codex"!==o&&!/\.cmd$/i.test(o)?t(o,e,i):t(["codex"===o?"codex":`"${o}"`,...e].join(" "),{...i,shell:!0})}function P(t){const o=k(t,["debug","models","--bundled"]);if(0===o.status&&o.stdout){const t=$(o.stdout);if(t)return t}return(o.error||0!==o.status)&&_.logError("loadBundledCodexModels",o.error??new Error(`${t} exited ${o.status}`)),null}export function loadBundledCodexModels(t){if(t)return P(t);for(const t of O()){if("codex"!==t&&!o(t))continue;const e=P(t);if(e)return e}return null}function B(t){try{return s(t).isFile()}catch{return!1}}export function installedCodexBinaries(){const t=[],o=O();if(o.includes("codex")){const o="win32"===process.platform?["codex.exe","codex.cmd"]:["codex"];for(const e of(process.env.PATH??"").split(u))if(e&&d(e))for(const n of o)t.push(p(e,n))}t.push(...o.filter(t=>"codex"!==t));const e=new Set,n=[];for(const o of t){if(!B(o))continue;let t=o;try{t=i(o)}catch{}const r="win32"===process.platform?t.toLowerCase():t;e.has(r)||(e.add(r),n.push(o))}return n}export function codexBinaryVersion(t){const o=`${k(t,["--version"]).stdout??""}`.match(/(\d+)\.(\d+)\.(\d+)/);return o?o[0]:null}export function catalogRejections(t,o=installedCodexBinaries()){if(0===o.length)return[];const n=e(p(l(),`${M}-codex-`)),i=[];try{c(p(n,"config.toml"),f.stringify({model_catalog_json:t}));for(const t of o){const o=k(t,["debug","models"],{...process.env,CODEX_HOME:n});if(0===o.status)continue;const e=`${o.stderr??""}\n${o.stdout??""}`,r=e.split(/\r?\n/).find(t=>t.includes("model_catalog_json"));r?i.push({bin:t,version:codexBinaryVersion(t),error:r.trim()}):_.logError("catalogRejections",o.error??new Error(`${t} exited ${o.status}: ${e.trim().slice(0,500)}`))}}finally{r(n,{recursive:!0,force:!0})}return i}export function loadPreviousCodexModels(){const t=L()?.filter(t=>!S(t));return t&&t.length>0?t:null}export function previousGatewayModelIds(){return(L()??[]).filter(S).map(t=>String(t.slug))}function L(){return o(codexCatalogPath())?$(n(codexCatalogPath(),"utf-8")):null}function S(t){return"number"==typeof t.priority&&t.priority>=1e3}let T=null;function W(){if(null!==T)return T;const t=[p(A,"..","..","..","codex-base-instructions.md"),p(A,"..","..","codex-base-instructions.md"),p(A,"codex-base-instructions.md")],e=t.find(t=>o(t));if(!e)throw new Error(`codex-base-instructions.md not found, searched: ${t.join(", ")}`);return T=n(e,"utf-8"),T}function D(t){return"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0}function F(t,o,e,n){const i=e?t:Math.min(t,o);return{window:i,compact:h(i,n)}}function I(t,o,e,n){const{standardContextWindow:i}=x();let r=D(t.contextWindow)??i;n&&t.id.startsWith("claude-")&&(r=n.has(t.id)?Math.max(r,1e6):Math.min(r,2e5));const{window:s,compact:c}=F(r,i,e,D(t.autoCompactTokens));return{slug:t.id,display_name:t.name||y(t.id),description:w(t.description,{millionContext:s>=1e6})??null,supported_reasoning_levels:[],shell_type:"unified_exec",visibility:"list",supported_in_api:!0,priority:o,additional_speed_tiers:[],service_tiers:[],availability_nux:null,upgrade:null,model_messages:{instructions_template:W()},base_instructions:W(),supports_reasoning_summaries:!0,supports_parallel_tool_calls:!1,prefer_websockets:!1,include_skills_usage_instructions:!1,include_plugin_usage_instructions:!1,include_apps_usage_instructions:!1,default_reasoning_summary:"auto",support_verbosity:!1,default_verbosity:null,apply_patch_tool_type:null,web_search_tool_type:"text",truncation_policy:{mode:"bytes",limit:1e4},supports_image_detail_original:!1,context_window:s,max_context_window:s,auto_compact_token_limit:c,effective_context_window_percent:95,experimental_supported_tools:[],input_modalities:["text","image"],supports_search_tool:!1,supports_experimental_context:!1,use_responses_lite:!1,supports_reasoning_effort_updates:!1,node_repl_auto_review_required:!1,node_repl_disabled:!1}}const G={supports_parallel_tool_calls:!0,supports_reasoning_summaries:!0};export function fillFromOlderEntries(t,o){const e=new Map(o.map(t=>[t.slug,t])),n=new Map;for(const t of o)for(const[o,e]of Object.entries(t))n.has(o)||n.set(o,e);return t.map(t=>{const o=e.get(t.slug),i={...t};for(const[t,e]of n)t in i||(i[t]=o&&t in o?o[t]:e);return i})}function R(t,o,e){if("list"!==(t=function(t){const o=Object.keys(G).filter(o=>!(o in t));return 0===o.length?t:{...t,...Object.fromEntries(o.map(t=>[t,G[t]]))}}(t)).visibility)return t;const n=D(t.context_window);if(!n)return t;const i=D(t.max_context_window)??n,r=e?Math.min(D(o?.contextWindow)??i,i):n,{window:s,compact:c}=F(r,n,!0,D(o?.autoCompactTokens));return{...t,context_window:s,auto_compact_token_limit:c}}function X(t,o){if(!t.startsWith("gpt-"))return;let e,n=4;for(const i of o){const o="string"==typeof i.slug?i.slug:"";if(!o.startsWith("gpt-")||"list"!==i.visibility)continue;let r=0;for(;r<o.length&&o[r]===t[r];)r++;r>n&&(e=i,n=r)}return e}function H(t,o,e,n){return R({...t,...Object.fromEntries(["slug","display_name","description","priority"].map(t=>[t,o[t]])),upgrade:null,availability_nux:null},e,n)}export function buildCodexCatalog(t){const{bundled:o,specs:e,oneMillion:n,selectedModel:i}=t,r=t.claudeOneMillion?new Set(t.claudeOneMillion):void 0,s=t.keyModels?new Set(t.keyModels):null,c=new Set(t.gatewayAvailable),l=t=>!s||s.has(t)||t===i,u=t=>c.has(t)||t===i,a=new Map(e.map(t=>[t.id,t])),d=[],p=new Set;for(const t of o){const o="string"==typeof t.slug?t.slug:"";o&&!p.has(o)&&("list"!==t.visibility||l(o))&&(p.add(o),d.push(R(t,a.get(o),n)))}const f=[...e];i&&!a.has(i)&&f.push({id:i});const m=function(t){const o=new Map;for(const e of t){const t=/^claude-([a-z]+)-(.+)$/.exec(e);if(!t)continue;const n=t[2].split("-").filter(t=>/^\d{1,2}$/.test(t)).join("."),i=o.get(t[1]);(!i||g(n,i.version)>0)&&o.set(t[1],{id:e,version:n})}return new Set([...o.values()].map(t=>t.id))}(f.map(t=>t.id).filter(u));for(const t of f){if(p.has(t.id)||!u(t.id))continue;if(t.id.startsWith("claude-")&&!m.has(t.id)&&t.id!==i)continue;p.add(t.id);const e=I(t,1e3+d.length,n,r),s=X(t.id,o);d.push(s?H(s,e,t,n):e)}return{models:d}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marsapi/cli",
3
- "version": "0.0.136",
3
+ "version": "0.0.137",
4
4
  "description": "Configure Claude Code, Codex, Grok Build and other coding tools for Mars AI with one command",
5
5
  "main": "dist/index.js",
6
6
  "bin": {