pi-opencode-go-provider 1.1.60 → 1.1.62

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.
package/config.ts CHANGED
@@ -10,6 +10,7 @@ import fs from "node:fs";
10
10
  import path from "node:path";
11
11
  import { getAgentDir } from "@earendil-works/pi-coding-agent";
12
12
  import { GLYPH_MODES, type GlyphMode } from "./glyphs.ts";
13
+ import { updateSettingsFile } from "./settings-file.ts";
13
14
 
14
15
  export const PROVIDER_ID = "opencode-go";
15
16
  export const CONFIG_BASENAME = "opencode-go-provider.json";
@@ -123,19 +124,13 @@ export function readUsageConfig(env: NodeJS.ProcessEnv = process.env): UsageConf
123
124
  /** Merge a patch into the config file, preserving unrelated keys. */
124
125
  export function writeUsageConfig(patch: Partial<UsageConfig>): boolean {
125
126
  try {
126
- const file = configPath();
127
- let document: Record<string, unknown> = {};
128
- try {
129
- const parsed: unknown = JSON.parse(fs.readFileSync(file, "utf8"));
130
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
131
- document = parsed as Record<string, unknown>;
127
+ updateSettingsFile(configPath(), (document) => {
128
+ const usage = document.usage;
129
+ if (usage !== undefined && (!usage || typeof usage !== "object" || Array.isArray(usage))) {
130
+ throw new Error("Expected a usage settings object");
132
131
  }
133
- } catch {
134
- document = {};
135
- }
136
- document.usage = { ...readFileUsage(), ...patch };
137
- fs.mkdirSync(path.dirname(file), { recursive: true });
138
- fs.writeFileSync(file, `${JSON.stringify(document, null, 2)}\n`);
132
+ return { ...document, usage: { ...usage, ...patch } };
133
+ });
139
134
  return true;
140
135
  } catch {
141
136
  return false;
package/models.json CHANGED
@@ -1,17 +1,17 @@
1
1
  [
2
2
  {
3
- "id": "gemini-4-argon",
4
- "name": "Gemini 4 Argon",
5
- "api": "openai-completions",
6
- "baseUrl": "https://opencode.ai/zen/go/v1",
3
+ "id": "qwen4-max",
4
+ "name": "Qwen4 Max",
5
+ "api": "anthropic-messages",
6
+ "baseUrl": "https://opencode.ai/zen/go",
7
7
  "reasoning": true,
8
8
  "thinkingLevelMap": {
9
9
  "off": null,
10
10
  "minimal": null,
11
11
  "low": "low",
12
- "medium": "medium",
12
+ "medium": null,
13
13
  "high": "high",
14
- "xhigh": null,
14
+ "xhigh": "xhigh",
15
15
  "max": null
16
16
  },
17
17
  "input": [
@@ -19,19 +19,19 @@
19
19
  "image"
20
20
  ],
21
21
  "cost": {
22
- "input": 2,
23
- "output": 10,
24
- "cacheRead": 0.1,
25
- "cacheWrite": 0
22
+ "input": 1.5,
23
+ "output": 4.5,
24
+ "cacheRead": 0.075,
25
+ "cacheWrite": 1.875
26
26
  },
27
- "contextWindow": 1048576,
28
- "maxTokens": 65536
27
+ "contextWindow": 1000000,
28
+ "maxTokens": 262144
29
29
  },
30
30
  {
31
- "id": "gpt-5.6-luna",
32
- "name": "GPT-5.6 Luna",
33
- "api": "openai-completions",
34
- "baseUrl": "https://opencode.ai/zen/go/v1",
31
+ "id": "claude-haiku-5-5",
32
+ "name": "Claude Haiku 5.5",
33
+ "api": "anthropic-messages",
34
+ "baseUrl": "https://opencode.ai/zen/go",
35
35
  "reasoning": true,
36
36
  "thinkingLevelMap": {
37
37
  "off": null,
@@ -47,106 +47,133 @@
47
47
  "image"
48
48
  ],
49
49
  "cost": {
50
- "input": 0.2,
51
- "output": 1.2,
52
- "cacheRead": 0.02,
53
- "cacheWrite": 0.25
50
+ "input": 0.1,
51
+ "output": 0.5,
52
+ "cacheRead": 0.01,
53
+ "cacheWrite": 0.125
54
54
  },
55
- "contextWindow": 1050000,
55
+ "contextWindow": 1000000,
56
56
  "maxTokens": 128000
57
57
  },
58
58
  {
59
- "id": "kimi-k3",
60
- "name": "Kimi K3",
59
+ "id": "mimo-v2.5",
60
+ "name": "MiMo V2.5",
61
61
  "api": "openai-completions",
62
62
  "baseUrl": "https://opencode.ai/zen/go/v1",
63
63
  "reasoning": true,
64
- "thinkingLevelMap": {
65
- "off": null,
66
- "minimal": null,
67
- "low": null,
68
- "medium": null,
69
- "high": null,
70
- "xhigh": null,
71
- "max": "max"
64
+ "input": [
65
+ "text",
66
+ "image"
67
+ ],
68
+ "cost": {
69
+ "input": 0.14,
70
+ "output": 0.28,
71
+ "cacheRead": 0.0028,
72
+ "cacheWrite": 0
72
73
  },
74
+ "contextWindow": 1000000,
75
+ "maxTokens": 128000
76
+ },
77
+ {
78
+ "id": "longcat-2.5-free",
79
+ "name": "LongCat 2.5 Free",
80
+ "api": "openai-completions",
81
+ "baseUrl": "https://opencode.ai/zen/go/v1",
82
+ "reasoning": true,
73
83
  "input": [
74
84
  "text",
75
85
  "image"
76
86
  ],
77
87
  "cost": {
78
- "input": 3,
79
- "output": 15,
80
- "cacheRead": 0.3,
81
- "cacheWrite": 3
88
+ "input": 0,
89
+ "output": 0,
90
+ "cacheRead": 0,
91
+ "cacheWrite": 0
82
92
  },
83
- "contextWindow": 1048576,
84
- "maxTokens": 1048576
93
+ "contextWindow": 1000000,
94
+ "maxTokens": 262144
85
95
  },
86
96
  {
87
- "id": "hy4-preview",
88
- "name": "Hy4 preview",
97
+ "id": "beam-free",
98
+ "name": "Beam Free",
89
99
  "api": "openai-completions",
90
100
  "baseUrl": "https://opencode.ai/zen/go/v1",
91
101
  "reasoning": true,
92
102
  "thinkingLevelMap": {
93
103
  "off": null,
94
104
  "minimal": null,
95
- "low": null,
96
- "medium": null,
105
+ "low": "low",
106
+ "medium": "medium",
97
107
  "high": "high",
98
- "xhigh": null,
99
- "max": null
108
+ "xhigh": "xhigh",
109
+ "max": "max"
100
110
  },
101
111
  "input": [
102
112
  "text"
103
113
  ],
104
114
  "cost": {
105
- "input": 0.834,
106
- "output": 2.501,
107
- "cacheRead": 0.042,
115
+ "input": 0,
116
+ "output": 0,
117
+ "cacheRead": 0,
108
118
  "cacheWrite": 0
109
119
  },
110
- "contextWindow": 1024000,
111
- "maxTokens": 64000
120
+ "contextWindow": 1048576,
121
+ "maxTokens": 131072
112
122
  },
113
123
  {
114
- "id": "qwen3.7-plus",
115
- "name": "Qwen3.7 Plus",
116
- "api": "anthropic-messages",
117
- "baseUrl": "https://opencode.ai/zen/go",
124
+ "id": "step-5-preview",
125
+ "name": "Step 5 Preview",
126
+ "api": "openai-completions",
127
+ "baseUrl": "https://opencode.ai/zen/go/v1",
118
128
  "reasoning": true,
129
+ "thinkingLevelMap": {
130
+ "off": null,
131
+ "minimal": null,
132
+ "low": "low",
133
+ "medium": "medium",
134
+ "high": "high",
135
+ "xhigh": null,
136
+ "max": null
137
+ },
119
138
  "input": [
120
139
  "text",
121
140
  "image"
122
141
  ],
123
142
  "cost": {
124
- "input": 0.4,
125
- "output": 1.6,
126
- "cacheRead": 0.04,
127
- "cacheWrite": 0.5
143
+ "input": 1,
144
+ "output": 2.7,
145
+ "cacheRead": 0.1,
146
+ "cacheWrite": 0
128
147
  },
129
148
  "contextWindow": 1000000,
130
149
  "maxTokens": 65536
131
150
  },
132
151
  {
133
- "id": "mimo-v2.6-flash",
134
- "name": "MiMo-V2.6-Flash",
152
+ "id": "hy3",
153
+ "name": "Hy3",
135
154
  "api": "openai-completions",
136
155
  "baseUrl": "https://opencode.ai/zen/go/v1",
137
156
  "reasoning": true,
157
+ "thinkingLevelMap": {
158
+ "off": null,
159
+ "minimal": null,
160
+ "low": "low",
161
+ "medium": null,
162
+ "high": "high",
163
+ "xhigh": null,
164
+ "max": null
165
+ },
138
166
  "input": [
139
- "text",
140
- "image"
167
+ "text"
141
168
  ],
142
169
  "cost": {
143
170
  "input": 0.14,
144
- "output": 0.28,
145
- "cacheRead": 0.0028,
171
+ "output": 0.58,
172
+ "cacheRead": 0.035,
146
173
  "cacheWrite": 0
147
174
  },
148
- "contextWindow": 1048576,
149
- "maxTokens": 131072
175
+ "contextWindow": 256000,
176
+ "maxTokens": 128000
150
177
  },
151
178
  {
152
179
  "id": "muse-spark-1.3-contributor",
@@ -177,36 +204,27 @@
177
204
  "maxTokens": 131072
178
205
  },
179
206
  {
180
- "id": "gpt-6-luna",
181
- "name": "GPT-6 Luna",
207
+ "id": "mimo-v2.6-pro",
208
+ "name": "MiMo-V2.6-Pro",
182
209
  "api": "openai-completions",
183
210
  "baseUrl": "https://opencode.ai/zen/go/v1",
184
211
  "reasoning": true,
185
- "thinkingLevelMap": {
186
- "off": null,
187
- "minimal": null,
188
- "low": "low",
189
- "medium": "medium",
190
- "high": "high",
191
- "xhigh": "xhigh",
192
- "max": "max"
193
- },
194
212
  "input": [
195
213
  "text",
196
214
  "image"
197
215
  ],
198
216
  "cost": {
199
- "input": 0.1,
200
- "output": 0.5,
201
- "cacheRead": 0.01,
202
- "cacheWrite": 0.125
217
+ "input": 0.435,
218
+ "output": 0.87,
219
+ "cacheRead": 0.003625,
220
+ "cacheWrite": 0
203
221
  },
204
- "contextWindow": 1050000,
205
- "maxTokens": 128000
222
+ "contextWindow": 1048576,
223
+ "maxTokens": 131072
206
224
  },
207
225
  {
208
- "id": "beam-free",
209
- "name": "Beam Free",
226
+ "id": "kimi-k3.1-pro",
227
+ "name": "Kimi K3.1 Pro",
210
228
  "api": "openai-completions",
211
229
  "baseUrl": "https://opencode.ai/zen/go/v1",
212
230
  "reasoning": true,
@@ -214,26 +232,27 @@
214
232
  "off": null,
215
233
  "minimal": null,
216
234
  "low": "low",
217
- "medium": "medium",
235
+ "medium": null,
218
236
  "high": "high",
219
- "xhigh": "xhigh",
237
+ "xhigh": null,
220
238
  "max": "max"
221
239
  },
222
240
  "input": [
223
- "text"
241
+ "text",
242
+ "image"
224
243
  ],
225
244
  "cost": {
226
- "input": 0,
227
- "output": 0,
228
- "cacheRead": 0,
229
- "cacheWrite": 0
245
+ "input": 2,
246
+ "output": 10,
247
+ "cacheRead": 0.2,
248
+ "cacheWrite": 2
230
249
  },
231
250
  "contextWindow": 1048576,
232
- "maxTokens": 131072
251
+ "maxTokens": 1048576
233
252
  },
234
253
  {
235
- "id": "glm-5.3-flash",
236
- "name": "GLM-5.3-Flash",
254
+ "id": "deepseek-v4.1-flash",
255
+ "name": "DeepSeek V4.1 Flash 1017",
237
256
  "api": "openai-completions",
238
257
  "baseUrl": "https://opencode.ai/zen/go/v1",
239
258
  "reasoning": true,
@@ -252,16 +271,16 @@
252
271
  ],
253
272
  "cost": {
254
273
  "input": 0.15,
255
- "output": 0.5,
256
- "cacheRead": 0.03,
274
+ "output": 0.6,
275
+ "cacheRead": 0.003,
257
276
  "cacheWrite": 0
258
277
  },
259
278
  "contextWindow": 1000000,
260
- "maxTokens": 131072
279
+ "maxTokens": 384000
261
280
  },
262
281
  {
263
- "id": "hy4",
264
- "name": "Hy4",
282
+ "id": "hy4-preview",
283
+ "name": "Hy4 preview",
265
284
  "api": "openai-completions",
266
285
  "baseUrl": "https://opencode.ai/zen/go/v1",
267
286
  "reasoning": true,
@@ -275,8 +294,7 @@
275
294
  "max": null
276
295
  },
277
296
  "input": [
278
- "text",
279
- "image"
297
+ "text"
280
298
  ],
281
299
  "cost": {
282
300
  "input": 0.834,
@@ -284,36 +302,63 @@
284
302
  "cacheRead": 0.042,
285
303
  "cacheWrite": 0
286
304
  },
287
- "contextWindow": 1048576,
288
- "maxTokens": 65536
305
+ "contextWindow": 1024000,
306
+ "maxTokens": 64000
289
307
  },
290
308
  {
291
- "id": "minimax-m3",
292
- "name": "MiniMax-M3",
293
- "api": "anthropic-messages",
294
- "baseUrl": "https://opencode.ai/zen/go",
309
+ "id": "hy4-flash-free",
310
+ "name": "Hy4 flash Free",
311
+ "api": "openai-completions",
312
+ "baseUrl": "https://opencode.ai/zen/go/v1",
295
313
  "reasoning": true,
314
+ "thinkingLevelMap": {
315
+ "off": null,
316
+ "minimal": null,
317
+ "low": null,
318
+ "medium": null,
319
+ "high": "high",
320
+ "xhigh": null,
321
+ "max": null
322
+ },
296
323
  "input": [
297
324
  "text",
298
325
  "image"
299
326
  ],
300
327
  "cost": {
301
- "input": 0.3,
302
- "output": 1.2,
303
- "cacheRead": 0.06,
328
+ "input": 0,
329
+ "output": 0,
330
+ "cacheRead": 0,
304
331
  "cacheWrite": 0
305
332
  },
306
- "contextWindow": 1000000,
307
- "maxTokens": 131072
333
+ "contextWindow": 1048576,
334
+ "maxTokens": 65536
308
335
  },
309
336
  {
310
- "id": "claude-haiku-5-5",
311
- "name": "Claude Haiku 5.5",
312
- "api": "anthropic-messages",
313
- "baseUrl": "https://opencode.ai/zen/go",
314
- "reasoning": true,
315
- "thinkingLevelMap": {
316
- "off": null,
337
+ "id": "iceman-contributor-free",
338
+ "name": "Iceman Contributor Free",
339
+ "api": "openai-completions",
340
+ "baseUrl": "https://opencode.ai/zen/go/v1",
341
+ "reasoning": true,
342
+ "input": [
343
+ "text"
344
+ ],
345
+ "cost": {
346
+ "input": 0,
347
+ "output": 0,
348
+ "cacheRead": 0,
349
+ "cacheWrite": 0
350
+ },
351
+ "contextWindow": 262144,
352
+ "maxTokens": 131072
353
+ },
354
+ {
355
+ "id": "gpt-6-luna",
356
+ "name": "GPT-6 Luna",
357
+ "api": "openai-completions",
358
+ "baseUrl": "https://opencode.ai/zen/go/v1",
359
+ "reasoning": true,
360
+ "thinkingLevelMap": {
361
+ "off": null,
317
362
  "minimal": null,
318
363
  "low": "low",
319
364
  "medium": "medium",
@@ -331,51 +376,51 @@
331
376
  "cacheRead": 0.01,
332
377
  "cacheWrite": 0.125
333
378
  },
334
- "contextWindow": 1000000,
379
+ "contextWindow": 1050000,
335
380
  "maxTokens": 128000
336
381
  },
337
382
  {
338
- "id": "qwen4-max",
339
- "name": "Qwen4 Max",
340
- "api": "anthropic-messages",
341
- "baseUrl": "https://opencode.ai/zen/go",
383
+ "id": "kimi-k3",
384
+ "name": "Kimi K3",
385
+ "api": "openai-completions",
386
+ "baseUrl": "https://opencode.ai/zen/go/v1",
342
387
  "reasoning": true,
343
388
  "thinkingLevelMap": {
344
389
  "off": null,
345
390
  "minimal": null,
346
- "low": "low",
391
+ "low": null,
347
392
  "medium": null,
348
- "high": "high",
349
- "xhigh": "xhigh",
350
- "max": null
393
+ "high": null,
394
+ "xhigh": null,
395
+ "max": "max"
351
396
  },
352
397
  "input": [
353
398
  "text",
354
399
  "image"
355
400
  ],
356
401
  "cost": {
357
- "input": 1.5,
358
- "output": 4.5,
359
- "cacheRead": 0.075,
360
- "cacheWrite": 1.875
402
+ "input": 3,
403
+ "output": 15,
404
+ "cacheRead": 0.3,
405
+ "cacheWrite": 3
361
406
  },
362
- "contextWindow": 1000000,
363
- "maxTokens": 262144
407
+ "contextWindow": 1048576,
408
+ "maxTokens": 1048576
364
409
  },
365
410
  {
366
- "id": "qwen3.8-flash",
367
- "name": "Qwen3.8 Flash",
368
- "api": "anthropic-messages",
369
- "baseUrl": "https://opencode.ai/zen/go",
411
+ "id": "glm-5.3-flash",
412
+ "name": "GLM-5.3-Flash",
413
+ "api": "openai-completions",
414
+ "baseUrl": "https://opencode.ai/zen/go/v1",
370
415
  "reasoning": true,
371
416
  "thinkingLevelMap": {
372
417
  "off": null,
373
418
  "minimal": null,
374
419
  "low": "low",
375
- "medium": "medium",
376
- "high": null,
377
- "xhigh": "xhigh",
378
- "max": null
420
+ "medium": null,
421
+ "high": "high",
422
+ "xhigh": null,
423
+ "max": "max"
379
424
  },
380
425
  "input": [
381
426
  "text",
@@ -383,24 +428,24 @@
383
428
  ],
384
429
  "cost": {
385
430
  "input": 0.15,
386
- "output": 0.47,
387
- "cacheRead": 0.016,
388
- "cacheWrite": 0.2
431
+ "output": 0.5,
432
+ "cacheRead": 0.03,
433
+ "cacheWrite": 0
389
434
  },
390
435
  "contextWindow": 1000000,
391
436
  "maxTokens": 131072
392
437
  },
393
438
  {
394
- "id": "step-5-preview",
395
- "name": "Step 5 Preview",
439
+ "id": "hy4",
440
+ "name": "Hy4",
396
441
  "api": "openai-completions",
397
442
  "baseUrl": "https://opencode.ai/zen/go/v1",
398
443
  "reasoning": true,
399
444
  "thinkingLevelMap": {
400
445
  "off": null,
401
446
  "minimal": null,
402
- "low": "low",
403
- "medium": "medium",
447
+ "low": null,
448
+ "medium": null,
404
449
  "high": "high",
405
450
  "xhigh": null,
406
451
  "max": null
@@ -410,67 +455,96 @@
410
455
  "image"
411
456
  ],
412
457
  "cost": {
413
- "input": 1,
414
- "output": 2.7,
415
- "cacheRead": 0.1,
458
+ "input": 0.834,
459
+ "output": 2.501,
460
+ "cacheRead": 0.042,
416
461
  "cacheWrite": 0
417
462
  },
418
- "contextWindow": 1000000,
463
+ "contextWindow": 1048576,
419
464
  "maxTokens": 65536
420
465
  },
421
466
  {
422
- "id": "iceman-contributor-free",
423
- "name": "Iceman Contributor Free",
424
- "api": "openai-completions",
425
- "baseUrl": "https://opencode.ai/zen/go/v1",
467
+ "id": "qwen3.8-flash",
468
+ "name": "Qwen3.8 Flash",
469
+ "api": "anthropic-messages",
470
+ "baseUrl": "https://opencode.ai/zen/go",
426
471
  "reasoning": true,
472
+ "thinkingLevelMap": {
473
+ "off": null,
474
+ "minimal": null,
475
+ "low": "low",
476
+ "medium": "medium",
477
+ "high": null,
478
+ "xhigh": "xhigh",
479
+ "max": null
480
+ },
427
481
  "input": [
428
- "text"
482
+ "text",
483
+ "image"
429
484
  ],
430
485
  "cost": {
431
- "input": 0,
432
- "output": 0,
433
- "cacheRead": 0,
434
- "cacheWrite": 0
486
+ "input": 0.15,
487
+ "output": 0.47,
488
+ "cacheRead": 0.016,
489
+ "cacheWrite": 0.2
435
490
  },
436
- "contextWindow": 262144,
491
+ "contextWindow": 1000000,
437
492
  "maxTokens": 131072
438
493
  },
439
494
  {
440
- "id": "mimo-v2.5-pro",
441
- "name": "MiMo V2.5 Pro",
495
+ "id": "gemini-4-argon",
496
+ "name": "Gemini 4 Argon",
442
497
  "api": "openai-completions",
443
498
  "baseUrl": "https://opencode.ai/zen/go/v1",
444
499
  "reasoning": true,
500
+ "thinkingLevelMap": {
501
+ "off": null,
502
+ "minimal": null,
503
+ "low": "low",
504
+ "medium": "medium",
505
+ "high": "high",
506
+ "xhigh": null,
507
+ "max": null
508
+ },
445
509
  "input": [
446
- "text"
510
+ "text",
511
+ "image"
447
512
  ],
448
513
  "cost": {
449
- "input": 0.435,
450
- "output": 0.87,
451
- "cacheRead": 0.003625,
514
+ "input": 2,
515
+ "output": 10,
516
+ "cacheRead": 0.1,
452
517
  "cacheWrite": 0
453
518
  },
454
519
  "contextWindow": 1048576,
455
- "maxTokens": 128000
520
+ "maxTokens": 65536
456
521
  },
457
522
  {
458
- "id": "mimo-v2.6-pro",
459
- "name": "MiMo-V2.6-Pro",
460
- "api": "openai-completions",
461
- "baseUrl": "https://opencode.ai/zen/go/v1",
523
+ "id": "qwen3.8-max",
524
+ "name": "Qwen3.8 Max",
525
+ "api": "anthropic-messages",
526
+ "baseUrl": "https://opencode.ai/zen/go",
462
527
  "reasoning": true,
528
+ "thinkingLevelMap": {
529
+ "off": null,
530
+ "minimal": null,
531
+ "low": "low",
532
+ "medium": "medium",
533
+ "high": null,
534
+ "xhigh": "xhigh",
535
+ "max": null
536
+ },
463
537
  "input": [
464
538
  "text",
465
539
  "image"
466
540
  ],
467
541
  "cost": {
468
- "input": 0.435,
469
- "output": 0.87,
470
- "cacheRead": 0.003625,
471
- "cacheWrite": 0
542
+ "input": 2,
543
+ "output": 6,
544
+ "cacheRead": 0.25,
545
+ "cacheWrite": 2.5
472
546
  },
473
- "contextWindow": 1048576,
547
+ "contextWindow": 1000000,
474
548
  "maxTokens": 131072
475
549
  },
476
550
  {
@@ -501,36 +575,8 @@
501
575
  "maxTokens": 131072
502
576
  },
503
577
  {
504
- "id": "muse-spark-1.2-contributor",
505
- "name": "Muse Spark 1.2 Contributor",
506
- "api": "openai-completions",
507
- "baseUrl": "https://opencode.ai/zen/go/v1",
508
- "reasoning": true,
509
- "thinkingLevelMap": {
510
- "off": null,
511
- "minimal": "minimal",
512
- "low": "low",
513
- "medium": "medium",
514
- "high": "high",
515
- "xhigh": "xhigh",
516
- "max": null
517
- },
518
- "input": [
519
- "text",
520
- "image"
521
- ],
522
- "cost": {
523
- "input": 0.1,
524
- "output": 0.2,
525
- "cacheRead": 0.002,
526
- "cacheWrite": 0
527
- },
528
- "contextWindow": 1048576,
529
- "maxTokens": 131072
530
- },
531
- {
532
- "id": "hy4-flash-free",
533
- "name": "Hy4 flash Free",
578
+ "id": "deepseek-v4-pro",
579
+ "name": "DeepSeek V4 Pro",
534
580
  "api": "openai-completions",
535
581
  "baseUrl": "https://opencode.ai/zen/go/v1",
536
582
  "reasoning": true,
@@ -541,24 +587,23 @@
541
587
  "medium": null,
542
588
  "high": "high",
543
589
  "xhigh": null,
544
- "max": null
590
+ "max": "max"
545
591
  },
546
592
  "input": [
547
- "text",
548
- "image"
593
+ "text"
549
594
  ],
550
595
  "cost": {
551
- "input": 0,
552
- "output": 0,
553
- "cacheRead": 0,
596
+ "input": 0.66,
597
+ "output": 1.98,
598
+ "cacheRead": 0.022,
554
599
  "cacheWrite": 0
555
600
  },
556
- "contextWindow": 1048576,
557
- "maxTokens": 65536
601
+ "contextWindow": 1000000,
602
+ "maxTokens": 384000
558
603
  },
559
604
  {
560
- "id": "minimax-m3.1-flash",
561
- "name": "MiniMax M3.1 Flash",
605
+ "id": "gpt-5.6-luna",
606
+ "name": "GPT-5.6 Luna",
562
607
  "api": "openai-completions",
563
608
  "baseUrl": "https://opencode.ai/zen/go/v1",
564
609
  "reasoning": true,
@@ -576,64 +621,36 @@
576
621
  "image"
577
622
  ],
578
623
  "cost": {
579
- "input": 0.15,
580
- "output": 0.6,
581
- "cacheRead": 0.015,
582
- "cacheWrite": 0
583
- },
584
- "contextWindow": 1000000,
585
- "maxTokens": 512000
586
- },
587
- {
588
- "id": "kimi-k2.7-code",
589
- "name": "Kimi K2.7 Code",
590
- "api": "openai-completions",
591
- "baseUrl": "https://opencode.ai/zen/go/v1",
592
- "reasoning": true,
593
- "input": [
594
- "text",
595
- "image"
596
- ],
597
- "cost": {
598
- "input": 0.95,
599
- "output": 4,
600
- "cacheRead": 0.19,
601
- "cacheWrite": 0
624
+ "input": 0.2,
625
+ "output": 1.2,
626
+ "cacheRead": 0.02,
627
+ "cacheWrite": 0.25
602
628
  },
603
- "contextWindow": 262144,
604
- "maxTokens": 262144
629
+ "contextWindow": 1050000,
630
+ "maxTokens": 128000
605
631
  },
606
632
  {
607
- "id": "qwen3.8-max",
608
- "name": "Qwen3.8 Max",
633
+ "id": "minimax-m3",
634
+ "name": "MiniMax-M3",
609
635
  "api": "anthropic-messages",
610
636
  "baseUrl": "https://opencode.ai/zen/go",
611
637
  "reasoning": true,
612
- "thinkingLevelMap": {
613
- "off": null,
614
- "minimal": null,
615
- "low": "low",
616
- "medium": "medium",
617
- "high": null,
618
- "xhigh": "xhigh",
619
- "max": null
620
- },
621
638
  "input": [
622
639
  "text",
623
640
  "image"
624
641
  ],
625
642
  "cost": {
626
- "input": 2,
627
- "output": 6,
628
- "cacheRead": 0.25,
629
- "cacheWrite": 2.5
643
+ "input": 0.3,
644
+ "output": 1.2,
645
+ "cacheRead": 0.06,
646
+ "cacheWrite": 0
630
647
  },
631
648
  "contextWindow": 1000000,
632
649
  "maxTokens": 131072
633
650
  },
634
651
  {
635
- "id": "grok-4.7",
636
- "name": "Grok 4.7",
652
+ "id": "minimax-m3.1-flash",
653
+ "name": "MiniMax M3.1 Flash",
637
654
  "api": "openai-completions",
638
655
  "baseUrl": "https://opencode.ai/zen/go/v1",
639
656
  "reasoning": true,
@@ -644,66 +661,38 @@
644
661
  "medium": "medium",
645
662
  "high": "high",
646
663
  "xhigh": "xhigh",
647
- "max": null
664
+ "max": "max"
648
665
  },
649
666
  "input": [
650
667
  "text",
651
668
  "image"
652
669
  ],
653
670
  "cost": {
654
- "input": 2,
655
- "output": 6,
656
- "cacheRead": 0.5,
671
+ "input": 0.15,
672
+ "output": 0.6,
673
+ "cacheRead": 0.015,
657
674
  "cacheWrite": 0
658
675
  },
659
- "contextWindow": 500000,
660
- "maxTokens": 500000
676
+ "contextWindow": 1000000,
677
+ "maxTokens": 512000
661
678
  },
662
679
  {
663
- "id": "hy3",
664
- "name": "Hy3",
680
+ "id": "longcat-2.0",
681
+ "name": "LongCat-2.0",
665
682
  "api": "openai-completions",
666
683
  "baseUrl": "https://opencode.ai/zen/go/v1",
667
684
  "reasoning": true,
668
- "thinkingLevelMap": {
669
- "off": null,
670
- "minimal": null,
671
- "low": "low",
672
- "medium": null,
673
- "high": "high",
674
- "xhigh": null,
675
- "max": null
676
- },
677
685
  "input": [
678
686
  "text"
679
687
  ],
680
688
  "cost": {
681
- "input": 0.14,
682
- "output": 0.58,
683
- "cacheRead": 0.035,
684
- "cacheWrite": 0
685
- },
686
- "contextWindow": 256000,
687
- "maxTokens": 128000
688
- },
689
- {
690
- "id": "mimo-v2.5",
691
- "name": "MiMo V2.5",
692
- "api": "openai-completions",
693
- "baseUrl": "https://opencode.ai/zen/go/v1",
694
- "reasoning": true,
695
- "input": [
696
- "text",
697
- "image"
698
- ],
699
- "cost": {
700
- "input": 0.14,
701
- "output": 0.28,
702
- "cacheRead": 0.0028,
689
+ "input": 0.3,
690
+ "output": 1.2,
691
+ "cacheRead": 0.006,
703
692
  "cacheWrite": 0
704
693
  },
705
694
  "contextWindow": 1000000,
706
- "maxTokens": 128000
695
+ "maxTokens": 131072
707
696
  },
708
697
  {
709
698
  "id": "glm-5.3",
@@ -733,123 +722,134 @@
733
722
  "maxTokens": 131072
734
723
  },
735
724
  {
736
- "id": "deepseek-v4-pro",
737
- "name": "DeepSeek V4 Pro",
725
+ "id": "kimi-k2.7-code",
726
+ "name": "Kimi K2.7 Code",
738
727
  "api": "openai-completions",
739
728
  "baseUrl": "https://opencode.ai/zen/go/v1",
740
729
  "reasoning": true,
741
- "thinkingLevelMap": {
742
- "off": null,
743
- "minimal": null,
744
- "low": null,
745
- "medium": null,
746
- "high": "high",
747
- "xhigh": null,
748
- "max": "max"
749
- },
750
730
  "input": [
751
- "text"
731
+ "text",
732
+ "image"
752
733
  ],
753
734
  "cost": {
754
- "input": 0.66,
755
- "output": 1.98,
756
- "cacheRead": 0.022,
735
+ "input": 0.95,
736
+ "output": 4,
737
+ "cacheRead": 0.19,
757
738
  "cacheWrite": 0
758
739
  },
759
- "contextWindow": 1000000,
760
- "maxTokens": 384000
740
+ "contextWindow": 262144,
741
+ "maxTokens": 262144
761
742
  },
762
743
  {
763
- "id": "longcat-2.0",
764
- "name": "LongCat-2.0",
744
+ "id": "grok-4.7",
745
+ "name": "Grok 4.7",
765
746
  "api": "openai-completions",
766
747
  "baseUrl": "https://opencode.ai/zen/go/v1",
767
748
  "reasoning": true,
749
+ "thinkingLevelMap": {
750
+ "off": null,
751
+ "minimal": null,
752
+ "low": "low",
753
+ "medium": "medium",
754
+ "high": "high",
755
+ "xhigh": "xhigh",
756
+ "max": null
757
+ },
768
758
  "input": [
769
- "text"
759
+ "text",
760
+ "image"
770
761
  ],
771
762
  "cost": {
772
- "input": 0.3,
773
- "output": 1.2,
774
- "cacheRead": 0.006,
763
+ "input": 2,
764
+ "output": 6,
765
+ "cacheRead": 0.5,
775
766
  "cacheWrite": 0
776
767
  },
777
- "contextWindow": 1000000,
778
- "maxTokens": 131072
768
+ "contextWindow": 500000,
769
+ "maxTokens": 500000
779
770
  },
780
771
  {
781
- "id": "kimi-k3.1-pro",
782
- "name": "Kimi K3.1 Pro",
772
+ "id": "muse-spark-1.2-contributor",
773
+ "name": "Muse Spark 1.2 Contributor",
783
774
  "api": "openai-completions",
784
775
  "baseUrl": "https://opencode.ai/zen/go/v1",
785
776
  "reasoning": true,
786
777
  "thinkingLevelMap": {
787
778
  "off": null,
788
- "minimal": null,
779
+ "minimal": "minimal",
789
780
  "low": "low",
790
- "medium": null,
781
+ "medium": "medium",
791
782
  "high": "high",
792
- "xhigh": null,
793
- "max": "max"
783
+ "xhigh": "xhigh",
784
+ "max": null
794
785
  },
795
786
  "input": [
796
787
  "text",
797
788
  "image"
798
789
  ],
799
790
  "cost": {
800
- "input": 2,
801
- "output": 10,
802
- "cacheRead": 0.2,
803
- "cacheWrite": 2
791
+ "input": 0.1,
792
+ "output": 0.2,
793
+ "cacheRead": 0.002,
794
+ "cacheWrite": 0
804
795
  },
805
796
  "contextWindow": 1048576,
806
- "maxTokens": 1048576
797
+ "maxTokens": 131072
807
798
  },
808
799
  {
809
- "id": "deepseek-v4.1-flash",
810
- "name": "DeepSeek V4.1 Flash 1017",
800
+ "id": "mimo-v2.6-flash",
801
+ "name": "MiMo-V2.6-Flash",
811
802
  "api": "openai-completions",
812
803
  "baseUrl": "https://opencode.ai/zen/go/v1",
813
804
  "reasoning": true,
814
- "thinkingLevelMap": {
815
- "off": null,
816
- "minimal": null,
817
- "low": "low",
818
- "medium": null,
819
- "high": "high",
820
- "xhigh": null,
821
- "max": "max"
822
- },
823
805
  "input": [
824
806
  "text",
825
807
  "image"
826
808
  ],
827
809
  "cost": {
828
- "input": 0.15,
829
- "output": 0.6,
830
- "cacheRead": 0.003,
810
+ "input": 0.14,
811
+ "output": 0.28,
812
+ "cacheRead": 0.0028,
831
813
  "cacheWrite": 0
832
814
  },
833
- "contextWindow": 1000000,
834
- "maxTokens": 384000
815
+ "contextWindow": 1048576,
816
+ "maxTokens": 131072
835
817
  },
836
818
  {
837
- "id": "longcat-2.5-free",
838
- "name": "LongCat 2.5 Free",
819
+ "id": "mimo-v2.5-pro",
820
+ "name": "MiMo V2.5 Pro",
839
821
  "api": "openai-completions",
840
822
  "baseUrl": "https://opencode.ai/zen/go/v1",
841
823
  "reasoning": true,
824
+ "input": [
825
+ "text"
826
+ ],
827
+ "cost": {
828
+ "input": 0.435,
829
+ "output": 0.87,
830
+ "cacheRead": 0.003625,
831
+ "cacheWrite": 0
832
+ },
833
+ "contextWindow": 1048576,
834
+ "maxTokens": 128000
835
+ },
836
+ {
837
+ "id": "qwen3.7-plus",
838
+ "name": "Qwen3.7 Plus",
839
+ "api": "anthropic-messages",
840
+ "baseUrl": "https://opencode.ai/zen/go",
841
+ "reasoning": true,
842
842
  "input": [
843
843
  "text",
844
844
  "image"
845
845
  ],
846
846
  "cost": {
847
- "input": 0,
848
- "output": 0,
849
- "cacheRead": 0,
850
- "cacheWrite": 0
847
+ "input": 0.4,
848
+ "output": 1.6,
849
+ "cacheRead": 0.04,
850
+ "cacheWrite": 0.5
851
851
  },
852
852
  "contextWindow": 1000000,
853
- "maxTokens": 262144
853
+ "maxTokens": 65536
854
854
  }
855
855
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-opencode-go-provider",
3
- "version": "1.1.60",
3
+ "version": "1.1.62",
4
4
  "description": "Opencode Go provider extension for pi - Fast, efficient GLM, Kimi, and MiniMax models through the opencode.ai API",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -0,0 +1,80 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { performance } from "node:perf_hooks";
5
+
6
+ const errorCode = (error: unknown) => (error as NodeJS.ErrnoException)?.code;
7
+
8
+ function resolveTarget(file: string): string {
9
+ fs.mkdirSync(path.dirname(file), { recursive: true });
10
+ try {
11
+ return fs.realpathSync(file);
12
+ } catch (error) {
13
+ if (errorCode(error) !== "ENOENT") throw error;
14
+ // Do not replace a dangling symlink with a regular file.
15
+ if (fs.lstatSync(file, { throwIfNoEntry: false })) throw error;
16
+ return path.join(fs.realpathSync(path.dirname(file)), path.basename(file));
17
+ }
18
+ }
19
+
20
+ function readSettings(file: string): { document: Record<string, unknown>; mode?: number } {
21
+ const stat = fs.statSync(file, { throwIfNoEntry: false });
22
+ if (!stat) return { document: {} };
23
+ if (!stat.isFile()) throw new Error(`Not a settings file: ${file}`);
24
+ const document: unknown = JSON.parse(fs.readFileSync(file, "utf8"));
25
+ if (!document || typeof document !== "object" || Array.isArray(document)) {
26
+ throw new Error(`Expected a settings object in ${file}`);
27
+ }
28
+ return { document: document as Record<string, unknown>, mode: stat.mode & 0o777 };
29
+ }
30
+
31
+ function publish(file: string, document: Record<string, unknown>, mode?: number): void {
32
+ const temporary = path.join(path.dirname(file), `.${path.basename(file)}.${randomUUID()}.tmp`);
33
+ const fd = fs.openSync(temporary, "wx", mode ?? 0o600);
34
+ try {
35
+ try {
36
+ fs.writeFileSync(fd, JSON.stringify(document, null, 2) + "\n", "utf8");
37
+ if (mode !== undefined) fs.fchmodSync(fd, mode);
38
+ } finally {
39
+ fs.closeSync(fd);
40
+ }
41
+ fs.renameSync(temporary, file);
42
+ } catch (error) {
43
+ try { fs.unlinkSync(temporary); } catch { /* preserve the original error */ }
44
+ throw error;
45
+ }
46
+ }
47
+
48
+ /** Serialize cooperating writers around read, update and atomic publication. */
49
+ export function updateSettingsFile(
50
+ file: string,
51
+ update: (document: Record<string, unknown>) => Record<string, unknown>,
52
+ ): Record<string, unknown> {
53
+ const target = resolveTarget(file);
54
+ const lock = path.join(path.dirname(target), `.${path.basename(target)}.write.lock`);
55
+ const deadline = performance.now() + 500;
56
+ let fd: number;
57
+ for (;;) {
58
+ try {
59
+ fd = fs.openSync(lock, "wx", 0o600);
60
+ break;
61
+ } catch (error) {
62
+ if (errorCode(error) !== "EEXIST") throw error;
63
+ if (performance.now() >= deadline) {
64
+ // Never steal a lock from a paused writer. After a crash, remove it only
65
+ // after confirming the owner recorded inside the lock is no longer running.
66
+ throw new Error(`Settings write lock is busy: ${lock}`);
67
+ }
68
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10);
69
+ }
70
+ }
71
+ try {
72
+ fs.writeFileSync(fd, `${process.pid}\n`, "utf8");
73
+ const { document, mode } = readSettings(target);
74
+ const next = update(document);
75
+ publish(target, next, mode);
76
+ return next;
77
+ } finally {
78
+ try { fs.closeSync(fd); } finally { fs.unlinkSync(lock); }
79
+ }
80
+ }
@@ -0,0 +1,102 @@
1
+ import assert from "node:assert/strict";
2
+ import { execFile } from "node:child_process";
3
+ import fs from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { promisify } from "node:util";
7
+ import { test } from "node:test";
8
+ import { writeUsageConfig } from "../config.ts";
9
+ import { updateSettingsFile } from "../settings-file.ts";
10
+
11
+ const exec = promisify(execFile);
12
+ const moduleUrl = new URL("../settings-file.ts", import.meta.url).href;
13
+
14
+ function scratch() {
15
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), "provider-settings-"));
16
+ return { directory, file: path.join(directory, "settings.json"), clean: () => fs.rmSync(directory, { recursive: true, force: true }) };
17
+ }
18
+
19
+ test("independent processes merge changes into the same settings document", async () => {
20
+ const { directory, file, clean } = scratch();
21
+ try {
22
+ const long = "x".repeat(64 * 1024);
23
+ updateSettingsFile(file, () => ({ untouched: long }));
24
+ const script = `
25
+ import { updateSettingsFile } from ${JSON.stringify(moduleUrl)};
26
+ const [file, field] = process.argv.slice(1);
27
+ updateSettingsFile(file, current => {
28
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
29
+ return { ...current, [field]: true };
30
+ });
31
+ `;
32
+ const commands = ["session", "account", "glyphs"].map((field) =>
33
+ exec(process.execPath, ["--input-type=module", "--eval", script, file, field], { timeout: 3000 }),
34
+ );
35
+ const results = await Promise.allSettled(commands);
36
+ for (const result of results) if (result.status === "rejected") throw result.reason;
37
+ assert.deepEqual(JSON.parse(fs.readFileSync(file, "utf8")), { untouched: long, session: true, account: true, glyphs: true });
38
+ assert.deepEqual(fs.readdirSync(directory), ["settings.json"]);
39
+ } finally {
40
+ clean();
41
+ }
42
+ });
43
+
44
+ test("an open reader keeps its old snapshot and a symlink still points at the updated target", { skip: process.platform === "win32" }, () => {
45
+ const { directory, file, clean } = scratch();
46
+ try {
47
+ fs.writeFileSync(file, JSON.stringify({ old: "x".repeat(4_096) }));
48
+ fs.chmodSync(file, 0o640);
49
+ const alias = path.join(directory, "alias.json");
50
+ fs.symlinkSync("settings.json", alias);
51
+ const fd = fs.openSync(file, "r");
52
+ try {
53
+ updateSettingsFile(alias, () => ({ next: true }));
54
+ assert.equal(JSON.parse(fs.readFileSync(fd, "utf8")).old.length, 4_096);
55
+ } finally {
56
+ fs.closeSync(fd);
57
+ }
58
+ assert.deepEqual(JSON.parse(fs.readFileSync(alias, "utf8")), { next: true });
59
+ assert.equal(fs.readlinkSync(alias), "settings.json");
60
+ assert.equal(fs.statSync(file).mode & 0o777, 0o640);
61
+ } finally {
62
+ clean();
63
+ }
64
+ });
65
+
66
+ test("invalid existing JSON is not overwritten and the lock is released", () => {
67
+ const { directory, file, clean } = scratch();
68
+ try {
69
+ fs.writeFileSync(file, "{partial");
70
+ assert.throws(() => updateSettingsFile(file, () => ({ next: true })), SyntaxError);
71
+ assert.equal(fs.readFileSync(file, "utf8"), "{partial");
72
+ assert.deepEqual(fs.readdirSync(directory), ["settings.json"]);
73
+ fs.writeFileSync(file, "{}");
74
+ assert.deepEqual(updateSettingsFile(file, () => ({ next: true })), { next: true });
75
+ } finally {
76
+ clean();
77
+ }
78
+ });
79
+
80
+ test("usage changes preserve other settings and refuse invalid config", () => {
81
+ const { directory, clean } = scratch();
82
+ const originalAgentDir = process.env.PI_CODING_AGENT_DIR;
83
+ process.env.PI_CODING_AGENT_DIR = directory;
84
+ try {
85
+ const file = path.join(directory, "opencode-go-provider.json");
86
+ const existing = { usage: { manual: true }, unrelated: { keep: true } };
87
+ fs.writeFileSync(file, JSON.stringify(existing));
88
+ assert.equal(writeUsageConfig({ glyphs: "ascii" }), true);
89
+ assert.equal(writeUsageConfig({ enabled: false }), true);
90
+ assert.deepEqual(JSON.parse(fs.readFileSync(file, "utf8")), {
91
+ ...existing,
92
+ usage: { ...existing.usage, glyphs: "ascii", enabled: false },
93
+ });
94
+ fs.writeFileSync(file, "{partial");
95
+ assert.equal(writeUsageConfig({ enabled: false }), false);
96
+ assert.equal(fs.readFileSync(file, "utf8"), "{partial");
97
+ } finally {
98
+ if (originalAgentDir === undefined) delete process.env.PI_CODING_AGENT_DIR;
99
+ else process.env.PI_CODING_AGENT_DIR = originalAgentDir;
100
+ clean();
101
+ }
102
+ });