better-opencode-openai-codex-auth 0.1.1 → 0.1.3

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 (78) hide show
  1. package/README.md +24 -0
  2. package/config/README.md +19 -93
  3. package/config/opencode-modern.json +149 -42
  4. package/dist/index.d.ts +0 -12
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +215 -109
  7. package/dist/index.js.map +1 -1
  8. package/dist/lib/account-pool.d.ts +29 -3
  9. package/dist/lib/account-pool.d.ts.map +1 -1
  10. package/dist/lib/account-pool.js +211 -44
  11. package/dist/lib/account-pool.js.map +1 -1
  12. package/dist/lib/auth/auth.d.ts +55 -4
  13. package/dist/lib/auth/auth.d.ts.map +1 -1
  14. package/dist/lib/auth/auth.js +142 -13
  15. package/dist/lib/auth/auth.js.map +1 -1
  16. package/dist/lib/auth/server.d.ts.map +1 -1
  17. package/dist/lib/auth/server.js +12 -8
  18. package/dist/lib/auth/server.js.map +1 -1
  19. package/dist/lib/auth/ui/account-menu.d.ts +50 -0
  20. package/dist/lib/auth/ui/account-menu.d.ts.map +1 -0
  21. package/dist/lib/auth/ui/account-menu.js +258 -0
  22. package/dist/lib/auth/ui/account-menu.js.map +1 -0
  23. package/dist/lib/auth/ui/ansi.d.ts +23 -0
  24. package/dist/lib/auth/ui/ansi.d.ts.map +1 -0
  25. package/dist/lib/auth/ui/ansi.js +37 -0
  26. package/dist/lib/auth/ui/ansi.js.map +1 -0
  27. package/dist/lib/auth/ui/confirm.d.ts +2 -0
  28. package/dist/lib/auth/ui/confirm.d.ts.map +1 -0
  29. package/dist/lib/auth/ui/confirm.js +8 -0
  30. package/dist/lib/auth/ui/confirm.js.map +1 -0
  31. package/dist/lib/auth/ui/select.d.ts +21 -0
  32. package/dist/lib/auth/ui/select.d.ts.map +1 -0
  33. package/dist/lib/auth/ui/select.js +208 -0
  34. package/dist/lib/auth/ui/select.js.map +1 -0
  35. package/dist/lib/config.d.ts.map +1 -1
  36. package/dist/lib/config.js +13 -4
  37. package/dist/lib/config.js.map +1 -1
  38. package/dist/lib/constants.d.ts +76 -3
  39. package/dist/lib/constants.d.ts.map +1 -1
  40. package/dist/lib/constants.js +80 -3
  41. package/dist/lib/constants.js.map +1 -1
  42. package/dist/lib/logger.d.ts +6 -0
  43. package/dist/lib/logger.d.ts.map +1 -1
  44. package/dist/lib/logger.js +11 -2
  45. package/dist/lib/logger.js.map +1 -1
  46. package/dist/lib/prompts/codex.d.ts +1 -1
  47. package/dist/lib/prompts/codex.d.ts.map +1 -1
  48. package/dist/lib/prompts/codex.js +15 -2
  49. package/dist/lib/prompts/codex.js.map +1 -1
  50. package/dist/lib/refresh-queue.d.ts +56 -0
  51. package/dist/lib/refresh-queue.d.ts.map +1 -0
  52. package/dist/lib/refresh-queue.js +148 -0
  53. package/dist/lib/refresh-queue.js.map +1 -0
  54. package/dist/lib/request/fetch-helpers.d.ts +2 -1
  55. package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
  56. package/dist/lib/request/fetch-helpers.js +25 -5
  57. package/dist/lib/request/fetch-helpers.js.map +1 -1
  58. package/dist/lib/request/helpers/input-utils.d.ts.map +1 -1
  59. package/dist/lib/request/helpers/input-utils.js +12 -10
  60. package/dist/lib/request/helpers/input-utils.js.map +1 -1
  61. package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
  62. package/dist/lib/request/helpers/model-map.js +14 -1
  63. package/dist/lib/request/helpers/model-map.js.map +1 -1
  64. package/dist/lib/request/request-transformer.d.ts.map +1 -1
  65. package/dist/lib/request/request-transformer.js +33 -29
  66. package/dist/lib/request/request-transformer.js.map +1 -1
  67. package/dist/lib/request/response-handler.d.ts.map +1 -1
  68. package/dist/lib/request/response-handler.js +17 -13
  69. package/dist/lib/request/response-handler.js.map +1 -1
  70. package/dist/lib/schemas.d.ts +85 -0
  71. package/dist/lib/schemas.d.ts.map +1 -0
  72. package/dist/lib/schemas.js +93 -0
  73. package/dist/lib/schemas.js.map +1 -0
  74. package/dist/lib/types.d.ts +18 -2
  75. package/dist/lib/types.d.ts.map +1 -1
  76. package/package.json +6 -7
  77. package/scripts/install-opencode-codex-auth.js +7 -27
  78. package/config/opencode-legacy.json +0 -571
@@ -11,15 +11,12 @@ const PLUGIN_NAME = "better-opencode-openai-codex-auth";
11
11
  const args = new Set(process.argv.slice(2));
12
12
 
13
13
  if (args.has("--help") || args.has("-h")) {
14
- console.log(`Usage: ${PLUGIN_NAME} [--modern|--legacy] [--uninstall] [--all] [--dry-run] [--no-cache-clear]\n\n` +
14
+ console.log(`Usage: ${PLUGIN_NAME} [--uninstall] [--all] [--dry-run] [--no-cache-clear]\n\n` +
15
15
  "Default behavior:\n" +
16
- " - Installs/updates global config at ~/.config/opencode/opencode.jsonc (falls back to .json)\n" +
17
- " - Uses modern config (variants) by default\n" +
16
+ " - Installs/updates global config at ~/.config/opencode/opencode.jsonc\n" +
18
17
  " - Ensures plugin is unpinned (latest)\n" +
19
18
  " - Clears OpenCode plugin cache\n\n" +
20
19
  "Options:\n" +
21
- " --modern Force modern config (default)\n" +
22
- " --legacy Use legacy config (older OpenCode versions)\n" +
23
20
  " --uninstall Remove plugin + OpenAI config entries from global config\n" +
24
21
  " --all With --uninstall, also remove tokens, logs, and cached instructions\n" +
25
22
  " --dry-run Show actions without writing\n" +
@@ -28,8 +25,6 @@ if (args.has("--help") || args.has("-h")) {
28
25
  process.exit(0);
29
26
  }
30
27
 
31
- const useLegacy = args.has("--legacy");
32
- const useModern = args.has("--modern") || !useLegacy;
33
28
  const uninstallRequested = args.has("--uninstall") || args.has("--all");
34
29
  const uninstallAll = args.has("--all");
35
30
  const dryRun = args.has("--dry-run");
@@ -37,11 +32,7 @@ const skipCacheClear = args.has("--no-cache-clear");
37
32
 
38
33
  const scriptDir = dirname(fileURLToPath(import.meta.url));
39
34
  const repoRoot = resolve(scriptDir, "..");
40
- const templatePath = join(
41
- repoRoot,
42
- "config",
43
- useLegacy ? "opencode-legacy.json" : "opencode-modern.json"
44
- );
35
+ const templatePath = join(repoRoot, "config", "opencode-modern.json");
45
36
 
46
37
  const configDir = join(homedir(), ".config", "opencode");
47
38
  const configPathJson = join(configDir, "opencode.json");
@@ -117,19 +108,10 @@ function mergeOpenAIConfig(existingOpenAI, templateOpenAI) {
117
108
  }
118
109
 
119
110
  async function getKnownModelIds() {
120
- const legacyTemplate = await readJson(
121
- join(repoRoot, "config", "opencode-legacy.json"),
122
- );
123
111
  const modernTemplate = await readJson(
124
112
  join(repoRoot, "config", "opencode-modern.json"),
125
113
  );
126
- const legacyModels = Object.keys(
127
- legacyTemplate?.provider?.openai?.models || {},
128
- );
129
- const modernModels = Object.keys(
130
- modernTemplate?.provider?.openai?.models || {},
131
- );
132
- return new Set([...legacyModels, ...modernModels]);
114
+ return new Set(Object.keys(modernTemplate?.provider?.openai?.models || {}));
133
115
  }
134
116
 
135
117
  function formatJson(obj) {
@@ -407,7 +389,7 @@ async function main() {
407
389
  }
408
390
 
409
391
  if (dryRun) {
410
- log(`[dry-run] Would write ${configPath} using ${useLegacy ? "legacy" : "modern"} config`);
392
+ log(`[dry-run] Would write ${configPath}`);
411
393
  } else {
412
394
  await mkdir(configDir, { recursive: true });
413
395
  if (nextContent && configExists) {
@@ -415,16 +397,14 @@ async function main() {
415
397
  } else {
416
398
  await writeFile(configPath, formatJson(nextConfig), "utf-8");
417
399
  }
418
- log(`Wrote ${configPath} (${useLegacy ? "legacy" : "modern"} config)`);
400
+ log(`Wrote ${configPath}`);
419
401
  }
420
402
 
421
403
  await clearCache();
422
404
 
423
405
  log("\nDone. Restart OpenCode to (re)install the plugin.");
424
406
  log("Example: opencode");
425
- if (useLegacy) {
426
- log("Note: Legacy config requires OpenCode v1.0.209 or older.");
427
- }
407
+
428
408
  }
429
409
 
430
410
  main().catch((error) => {
@@ -1,571 +0,0 @@
1
- {
2
- "$schema": "https://opencode.ai/config.json",
3
- "plugin": [
4
- "better-opencode-openai-codex-auth"
5
- ],
6
- "provider": {
7
- "openai": {
8
- "options": {
9
- "reasoningEffort": "medium",
10
- "reasoningSummary": "auto",
11
- "textVerbosity": "medium",
12
- "include": [
13
- "reasoning.encrypted_content"
14
- ],
15
- "store": false
16
- },
17
- "models": {
18
- "gpt-5.2-none": {
19
- "name": "GPT 5.2 None (OAuth)",
20
- "limit": {
21
- "context": 272000,
22
- "output": 128000
23
- },
24
- "modalities": {
25
- "input": [
26
- "text",
27
- "image"
28
- ],
29
- "output": [
30
- "text"
31
- ]
32
- },
33
- "options": {
34
- "reasoningEffort": "none",
35
- "reasoningSummary": "auto",
36
- "textVerbosity": "medium",
37
- "include": [
38
- "reasoning.encrypted_content"
39
- ],
40
- "store": false
41
- }
42
- },
43
- "gpt-5.2-low": {
44
- "name": "GPT 5.2 Low (OAuth)",
45
- "limit": {
46
- "context": 272000,
47
- "output": 128000
48
- },
49
- "modalities": {
50
- "input": [
51
- "text",
52
- "image"
53
- ],
54
- "output": [
55
- "text"
56
- ]
57
- },
58
- "options": {
59
- "reasoningEffort": "low",
60
- "reasoningSummary": "auto",
61
- "textVerbosity": "medium",
62
- "include": [
63
- "reasoning.encrypted_content"
64
- ],
65
- "store": false
66
- }
67
- },
68
- "gpt-5.2-medium": {
69
- "name": "GPT 5.2 Medium (OAuth)",
70
- "limit": {
71
- "context": 272000,
72
- "output": 128000
73
- },
74
- "modalities": {
75
- "input": [
76
- "text",
77
- "image"
78
- ],
79
- "output": [
80
- "text"
81
- ]
82
- },
83
- "options": {
84
- "reasoningEffort": "medium",
85
- "reasoningSummary": "auto",
86
- "textVerbosity": "medium",
87
- "include": [
88
- "reasoning.encrypted_content"
89
- ],
90
- "store": false
91
- }
92
- },
93
- "gpt-5.2-high": {
94
- "name": "GPT 5.2 High (OAuth)",
95
- "limit": {
96
- "context": 272000,
97
- "output": 128000
98
- },
99
- "modalities": {
100
- "input": [
101
- "text",
102
- "image"
103
- ],
104
- "output": [
105
- "text"
106
- ]
107
- },
108
- "options": {
109
- "reasoningEffort": "high",
110
- "reasoningSummary": "detailed",
111
- "textVerbosity": "medium",
112
- "include": [
113
- "reasoning.encrypted_content"
114
- ],
115
- "store": false
116
- }
117
- },
118
- "gpt-5.2-xhigh": {
119
- "name": "GPT 5.2 Extra High (OAuth)",
120
- "limit": {
121
- "context": 272000,
122
- "output": 128000
123
- },
124
- "modalities": {
125
- "input": [
126
- "text",
127
- "image"
128
- ],
129
- "output": [
130
- "text"
131
- ]
132
- },
133
- "options": {
134
- "reasoningEffort": "xhigh",
135
- "reasoningSummary": "detailed",
136
- "textVerbosity": "medium",
137
- "include": [
138
- "reasoning.encrypted_content"
139
- ],
140
- "store": false
141
- }
142
- },
143
- "gpt-5.2-codex-low": {
144
- "name": "GPT 5.2 Codex Low (OAuth)",
145
- "limit": {
146
- "context": 272000,
147
- "output": 128000
148
- },
149
- "modalities": {
150
- "input": [
151
- "text",
152
- "image"
153
- ],
154
- "output": [
155
- "text"
156
- ]
157
- },
158
- "options": {
159
- "reasoningEffort": "low",
160
- "reasoningSummary": "auto",
161
- "textVerbosity": "medium",
162
- "include": [
163
- "reasoning.encrypted_content"
164
- ],
165
- "store": false
166
- }
167
- },
168
- "gpt-5.2-codex-medium": {
169
- "name": "GPT 5.2 Codex Medium (OAuth)",
170
- "limit": {
171
- "context": 272000,
172
- "output": 128000
173
- },
174
- "modalities": {
175
- "input": [
176
- "text",
177
- "image"
178
- ],
179
- "output": [
180
- "text"
181
- ]
182
- },
183
- "options": {
184
- "reasoningEffort": "medium",
185
- "reasoningSummary": "auto",
186
- "textVerbosity": "medium",
187
- "include": [
188
- "reasoning.encrypted_content"
189
- ],
190
- "store": false
191
- }
192
- },
193
- "gpt-5.2-codex-high": {
194
- "name": "GPT 5.2 Codex High (OAuth)",
195
- "limit": {
196
- "context": 272000,
197
- "output": 128000
198
- },
199
- "modalities": {
200
- "input": [
201
- "text",
202
- "image"
203
- ],
204
- "output": [
205
- "text"
206
- ]
207
- },
208
- "options": {
209
- "reasoningEffort": "high",
210
- "reasoningSummary": "detailed",
211
- "textVerbosity": "medium",
212
- "include": [
213
- "reasoning.encrypted_content"
214
- ],
215
- "store": false
216
- }
217
- },
218
- "gpt-5.2-codex-xhigh": {
219
- "name": "GPT 5.2 Codex Extra High (OAuth)",
220
- "limit": {
221
- "context": 272000,
222
- "output": 128000
223
- },
224
- "modalities": {
225
- "input": [
226
- "text",
227
- "image"
228
- ],
229
- "output": [
230
- "text"
231
- ]
232
- },
233
- "options": {
234
- "reasoningEffort": "xhigh",
235
- "reasoningSummary": "detailed",
236
- "textVerbosity": "medium",
237
- "include": [
238
- "reasoning.encrypted_content"
239
- ],
240
- "store": false
241
- }
242
- },
243
- "gpt-5.1-codex-max-low": {
244
- "name": "GPT 5.1 Codex Max Low (OAuth)",
245
- "limit": {
246
- "context": 272000,
247
- "output": 128000
248
- },
249
- "modalities": {
250
- "input": [
251
- "text",
252
- "image"
253
- ],
254
- "output": [
255
- "text"
256
- ]
257
- },
258
- "options": {
259
- "reasoningEffort": "low",
260
- "reasoningSummary": "detailed",
261
- "textVerbosity": "medium",
262
- "include": [
263
- "reasoning.encrypted_content"
264
- ],
265
- "store": false
266
- }
267
- },
268
- "gpt-5.1-codex-max-medium": {
269
- "name": "GPT 5.1 Codex Max Medium (OAuth)",
270
- "limit": {
271
- "context": 272000,
272
- "output": 128000
273
- },
274
- "modalities": {
275
- "input": [
276
- "text",
277
- "image"
278
- ],
279
- "output": [
280
- "text"
281
- ]
282
- },
283
- "options": {
284
- "reasoningEffort": "medium",
285
- "reasoningSummary": "detailed",
286
- "textVerbosity": "medium",
287
- "include": [
288
- "reasoning.encrypted_content"
289
- ],
290
- "store": false
291
- }
292
- },
293
- "gpt-5.1-codex-max-high": {
294
- "name": "GPT 5.1 Codex Max High (OAuth)",
295
- "limit": {
296
- "context": 272000,
297
- "output": 128000
298
- },
299
- "modalities": {
300
- "input": [
301
- "text",
302
- "image"
303
- ],
304
- "output": [
305
- "text"
306
- ]
307
- },
308
- "options": {
309
- "reasoningEffort": "high",
310
- "reasoningSummary": "detailed",
311
- "textVerbosity": "medium",
312
- "include": [
313
- "reasoning.encrypted_content"
314
- ],
315
- "store": false
316
- }
317
- },
318
- "gpt-5.1-codex-max-xhigh": {
319
- "name": "GPT 5.1 Codex Max Extra High (OAuth)",
320
- "limit": {
321
- "context": 272000,
322
- "output": 128000
323
- },
324
- "modalities": {
325
- "input": [
326
- "text",
327
- "image"
328
- ],
329
- "output": [
330
- "text"
331
- ]
332
- },
333
- "options": {
334
- "reasoningEffort": "xhigh",
335
- "reasoningSummary": "detailed",
336
- "textVerbosity": "medium",
337
- "include": [
338
- "reasoning.encrypted_content"
339
- ],
340
- "store": false
341
- }
342
- },
343
- "gpt-5.1-codex-low": {
344
- "name": "GPT 5.1 Codex Low (OAuth)",
345
- "limit": {
346
- "context": 272000,
347
- "output": 128000
348
- },
349
- "modalities": {
350
- "input": [
351
- "text",
352
- "image"
353
- ],
354
- "output": [
355
- "text"
356
- ]
357
- },
358
- "options": {
359
- "reasoningEffort": "low",
360
- "reasoningSummary": "auto",
361
- "textVerbosity": "medium",
362
- "include": [
363
- "reasoning.encrypted_content"
364
- ],
365
- "store": false
366
- }
367
- },
368
- "gpt-5.1-codex-medium": {
369
- "name": "GPT 5.1 Codex Medium (OAuth)",
370
- "limit": {
371
- "context": 272000,
372
- "output": 128000
373
- },
374
- "modalities": {
375
- "input": [
376
- "text",
377
- "image"
378
- ],
379
- "output": [
380
- "text"
381
- ]
382
- },
383
- "options": {
384
- "reasoningEffort": "medium",
385
- "reasoningSummary": "auto",
386
- "textVerbosity": "medium",
387
- "include": [
388
- "reasoning.encrypted_content"
389
- ],
390
- "store": false
391
- }
392
- },
393
- "gpt-5.1-codex-high": {
394
- "name": "GPT 5.1 Codex High (OAuth)",
395
- "limit": {
396
- "context": 272000,
397
- "output": 128000
398
- },
399
- "modalities": {
400
- "input": [
401
- "text",
402
- "image"
403
- ],
404
- "output": [
405
- "text"
406
- ]
407
- },
408
- "options": {
409
- "reasoningEffort": "high",
410
- "reasoningSummary": "detailed",
411
- "textVerbosity": "medium",
412
- "include": [
413
- "reasoning.encrypted_content"
414
- ],
415
- "store": false
416
- }
417
- },
418
- "gpt-5.1-codex-mini-medium": {
419
- "name": "GPT 5.1 Codex Mini Medium (OAuth)",
420
- "limit": {
421
- "context": 272000,
422
- "output": 128000
423
- },
424
- "modalities": {
425
- "input": [
426
- "text",
427
- "image"
428
- ],
429
- "output": [
430
- "text"
431
- ]
432
- },
433
- "options": {
434
- "reasoningEffort": "medium",
435
- "reasoningSummary": "auto",
436
- "textVerbosity": "medium",
437
- "include": [
438
- "reasoning.encrypted_content"
439
- ],
440
- "store": false
441
- }
442
- },
443
- "gpt-5.1-codex-mini-high": {
444
- "name": "GPT 5.1 Codex Mini High (OAuth)",
445
- "limit": {
446
- "context": 272000,
447
- "output": 128000
448
- },
449
- "modalities": {
450
- "input": [
451
- "text",
452
- "image"
453
- ],
454
- "output": [
455
- "text"
456
- ]
457
- },
458
- "options": {
459
- "reasoningEffort": "high",
460
- "reasoningSummary": "detailed",
461
- "textVerbosity": "medium",
462
- "include": [
463
- "reasoning.encrypted_content"
464
- ],
465
- "store": false
466
- }
467
- },
468
- "gpt-5.1-none": {
469
- "name": "GPT 5.1 None (OAuth)",
470
- "limit": {
471
- "context": 272000,
472
- "output": 128000
473
- },
474
- "modalities": {
475
- "input": [
476
- "text",
477
- "image"
478
- ],
479
- "output": [
480
- "text"
481
- ]
482
- },
483
- "options": {
484
- "reasoningEffort": "none",
485
- "reasoningSummary": "auto",
486
- "textVerbosity": "medium",
487
- "include": [
488
- "reasoning.encrypted_content"
489
- ],
490
- "store": false
491
- }
492
- },
493
- "gpt-5.1-low": {
494
- "name": "GPT 5.1 Low (OAuth)",
495
- "limit": {
496
- "context": 272000,
497
- "output": 128000
498
- },
499
- "modalities": {
500
- "input": [
501
- "text",
502
- "image"
503
- ],
504
- "output": [
505
- "text"
506
- ]
507
- },
508
- "options": {
509
- "reasoningEffort": "low",
510
- "reasoningSummary": "auto",
511
- "textVerbosity": "low",
512
- "include": [
513
- "reasoning.encrypted_content"
514
- ],
515
- "store": false
516
- }
517
- },
518
- "gpt-5.1-medium": {
519
- "name": "GPT 5.1 Medium (OAuth)",
520
- "limit": {
521
- "context": 272000,
522
- "output": 128000
523
- },
524
- "modalities": {
525
- "input": [
526
- "text",
527
- "image"
528
- ],
529
- "output": [
530
- "text"
531
- ]
532
- },
533
- "options": {
534
- "reasoningEffort": "medium",
535
- "reasoningSummary": "auto",
536
- "textVerbosity": "medium",
537
- "include": [
538
- "reasoning.encrypted_content"
539
- ],
540
- "store": false
541
- }
542
- },
543
- "gpt-5.1-high": {
544
- "name": "GPT 5.1 High (OAuth)",
545
- "limit": {
546
- "context": 272000,
547
- "output": 128000
548
- },
549
- "modalities": {
550
- "input": [
551
- "text",
552
- "image"
553
- ],
554
- "output": [
555
- "text"
556
- ]
557
- },
558
- "options": {
559
- "reasoningEffort": "high",
560
- "reasoningSummary": "detailed",
561
- "textVerbosity": "high",
562
- "include": [
563
- "reasoning.encrypted_content"
564
- ],
565
- "store": false
566
- }
567
- }
568
- }
569
- }
570
- }
571
- }