oc-codex-multi-auth 6.22.0 → 6.24.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.
Files changed (120) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +793 -729
  3. package/assets/icon.svg +7 -7
  4. package/assets/opencode-logo-ornate-dark.svg +18 -18
  5. package/assets/readme-hero.svg +31 -31
  6. package/config/README.md +197 -177
  7. package/config/minimal-opencode.json +14 -14
  8. package/config/opencode-legacy.json +1346 -1496
  9. package/config/opencode-modern.json +466 -555
  10. package/dist/index.d.ts +7 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +37 -19
  13. package/dist/index.js.map +1 -1
  14. package/dist/lib/accounts/warm-request.d.ts.map +1 -1
  15. package/dist/lib/accounts/warm-request.js +9 -11
  16. package/dist/lib/accounts/warm-request.js.map +1 -1
  17. package/dist/lib/codex-usage.d.ts +35 -0
  18. package/dist/lib/codex-usage.d.ts.map +1 -1
  19. package/dist/lib/codex-usage.js +51 -0
  20. package/dist/lib/codex-usage.js.map +1 -1
  21. package/dist/lib/config.d.ts +5 -3
  22. package/dist/lib/config.d.ts.map +1 -1
  23. package/dist/lib/config.js +2 -0
  24. package/dist/lib/config.js.map +1 -1
  25. package/dist/lib/constants.d.ts +13 -0
  26. package/dist/lib/constants.d.ts.map +1 -1
  27. package/dist/lib/constants.js +13 -0
  28. package/dist/lib/constants.js.map +1 -1
  29. package/dist/lib/context-overflow.js +10 -10
  30. package/dist/lib/desktop-notifications.js +6 -6
  31. package/dist/lib/oauth-success.js +202 -202
  32. package/dist/lib/opencode-v2-provider.d.ts +2 -0
  33. package/dist/lib/opencode-v2-provider.d.ts.map +1 -0
  34. package/dist/lib/opencode-v2-provider.js +4 -0
  35. package/dist/lib/opencode-v2-provider.js.map +1 -0
  36. package/dist/lib/opencode-v2-rpc.d.ts +27 -0
  37. package/dist/lib/opencode-v2-rpc.d.ts.map +1 -0
  38. package/dist/lib/opencode-v2-rpc.js +16 -0
  39. package/dist/lib/opencode-v2-rpc.js.map +1 -0
  40. package/dist/lib/opencode-v2-status.d.ts +17 -0
  41. package/dist/lib/opencode-v2-status.d.ts.map +1 -0
  42. package/dist/lib/opencode-v2-status.js +91 -0
  43. package/dist/lib/opencode-v2-status.js.map +1 -0
  44. package/dist/lib/opencode-v2-tui.d.ts +4 -0
  45. package/dist/lib/opencode-v2-tui.d.ts.map +1 -0
  46. package/dist/lib/opencode-v2-tui.js +105 -0
  47. package/dist/lib/opencode-v2-tui.js.map +1 -0
  48. package/dist/lib/opencode-v2.d.ts +11 -0
  49. package/dist/lib/opencode-v2.d.ts.map +1 -0
  50. package/dist/lib/opencode-v2.js +235 -0
  51. package/dist/lib/opencode-v2.js.map +1 -0
  52. package/dist/lib/prompts/codex-opencode-bridge.js +67 -67
  53. package/dist/lib/prompts/codex.d.ts +12 -2
  54. package/dist/lib/prompts/codex.d.ts.map +1 -1
  55. package/dist/lib/prompts/codex.js +126 -91
  56. package/dist/lib/prompts/codex.js.map +1 -1
  57. package/dist/lib/quota-capacity.d.ts +4 -0
  58. package/dist/lib/quota-capacity.d.ts.map +1 -0
  59. package/dist/lib/quota-capacity.js +45 -0
  60. package/dist/lib/quota-capacity.js.map +1 -0
  61. package/dist/lib/quota-overview.d.ts +13 -27
  62. package/dist/lib/quota-overview.d.ts.map +1 -1
  63. package/dist/lib/quota-overview.js +59 -99
  64. package/dist/lib/quota-overview.js.map +1 -1
  65. package/dist/lib/quota-recovery.d.ts +5 -0
  66. package/dist/lib/quota-recovery.d.ts.map +1 -0
  67. package/dist/lib/quota-recovery.js +66 -0
  68. package/dist/lib/quota-recovery.js.map +1 -0
  69. package/dist/lib/request/fetch-helpers.d.ts +1 -1
  70. package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
  71. package/dist/lib/request/fetch-helpers.js +85 -51
  72. package/dist/lib/request/fetch-helpers.js.map +1 -1
  73. package/dist/lib/request/helpers/model-map.d.ts +10 -0
  74. package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
  75. package/dist/lib/request/helpers/model-map.js +39 -11
  76. package/dist/lib/request/helpers/model-map.js.map +1 -1
  77. package/dist/lib/request/helpers/responses-lite.d.ts.map +1 -1
  78. package/dist/lib/request/helpers/responses-lite.js +4 -1
  79. package/dist/lib/request/helpers/responses-lite.js.map +1 -1
  80. package/dist/lib/request/request-transformer.d.ts.map +1 -1
  81. package/dist/lib/request/request-transformer.js +37 -15
  82. package/dist/lib/request/request-transformer.js.map +1 -1
  83. package/dist/lib/schemas.d.ts +9 -1
  84. package/dist/lib/schemas.d.ts.map +1 -1
  85. package/dist/lib/schemas.js +3 -2
  86. package/dist/lib/schemas.js.map +1 -1
  87. package/dist/lib/storage/state.d.ts +8 -0
  88. package/dist/lib/storage/state.d.ts.map +1 -1
  89. package/dist/lib/storage/state.js +47 -20
  90. package/dist/lib/storage/state.js.map +1 -1
  91. package/dist/lib/tools/codex-limits.d.ts.map +1 -1
  92. package/dist/lib/tools/codex-limits.js +49 -3
  93. package/dist/lib/tools/codex-limits.js.map +1 -1
  94. package/dist/lib/tui-quota-cache.d.ts +1 -0
  95. package/dist/lib/tui-quota-cache.d.ts.map +1 -1
  96. package/dist/lib/tui-quota-cache.js +2 -0
  97. package/dist/lib/tui-quota-cache.js.map +1 -1
  98. package/dist/lib/tui-quota-overview.d.ts.map +1 -1
  99. package/dist/lib/tui-quota-overview.js +4 -0
  100. package/dist/lib/tui-quota-overview.js.map +1 -1
  101. package/dist/lib/tui-status-slot.d.ts +3 -0
  102. package/dist/lib/tui-status-slot.d.ts.map +1 -0
  103. package/dist/lib/tui-status-slot.js +27 -0
  104. package/dist/lib/tui-status-slot.js.map +1 -0
  105. package/dist/lib/tui-status.d.ts +1 -0
  106. package/dist/lib/tui-status.d.ts.map +1 -1
  107. package/dist/lib/tui-status.js +1 -0
  108. package/dist/lib/tui-status.js.map +1 -1
  109. package/dist/tui.d.ts +10 -3
  110. package/dist/tui.d.ts.map +1 -1
  111. package/dist/tui.js +22 -1
  112. package/dist/tui.js.map +1 -1
  113. package/package.json +157 -155
  114. package/scripts/audit-dev-allowlist.js +114 -114
  115. package/scripts/clean-dist.js +27 -27
  116. package/scripts/copy-oauth-success.js +47 -47
  117. package/scripts/install-oc-codex-multi-auth-core.js +2092 -2003
  118. package/scripts/install-oc-codex-multi-auth.js +37 -37
  119. package/scripts/test-all-models.sh +260 -260
  120. package/scripts/validate-model-map.sh +97 -97
@@ -1,12 +1,12 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import { logDebug, logWarn } from "./logger.js";
3
3
  const DELIVERY_TIMEOUT_MS = 10_000;
4
- const MACOS_NOTIFICATION_SCRIPT = `
5
- function run(argv) {
6
- const app = Application.currentApplication();
7
- app.includeStandardAdditions = true;
8
- app.displayNotification(argv[1], { withTitle: argv[0] });
9
- }
4
+ const MACOS_NOTIFICATION_SCRIPT = `
5
+ function run(argv) {
6
+ const app = Application.currentApplication();
7
+ app.includeStandardAdditions = true;
8
+ app.displayNotification(argv[1], { withTitle: argv[0] });
9
+ }
10
10
  `.trim();
11
11
  const executeFile = (file, args, options, callback) => {
12
12
  return execFile(file, args, options, (error) => callback(error));
@@ -1,206 +1,206 @@
1
1
  export function renderOAuthSuccessHtml(styleNonce) {
2
- return `<!doctype html>
3
- <html lang="en">
4
- <head>
5
- <meta charset="utf-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1">
7
- <meta name="color-scheme" content="dark">
8
- <title>OpenCode - Authentication complete</title>
9
- <style nonce="${styleNonce}">
10
- :root {
11
- color-scheme: dark;
12
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
13
- font-synthesis: none;
14
- }
15
-
16
- * {
17
- box-sizing: border-box;
18
- }
19
-
20
- body {
21
- min-width: 320px;
22
- min-height: 100vh;
23
- margin: 0;
24
- display: grid;
25
- place-items: center;
26
- padding: 32px 20px;
27
- background:
28
- radial-gradient(circle at 50% 0%, rgba(42, 195, 126, 0.12), transparent 38rem),
29
- #080b0a;
30
- color: #f2f5f3;
31
- }
32
-
33
- main {
34
- width: min(100%, 540px);
35
- }
36
-
37
- .brand {
38
- display: flex;
39
- margin: 0 0 24px 0;
40
- justify-content: center;
41
- }
42
-
43
- .brand svg {
44
- height: 22px;
45
- width: auto;
46
- }
47
-
48
- .card {
49
- position: relative;
50
- overflow: hidden;
51
- padding: 44px;
52
- border: 1px solid #26312c;
53
- border-radius: 20px;
54
- background: linear-gradient(145deg, rgba(22, 28, 25, 0.98), rgba(13, 17, 15, 0.98));
55
- box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
56
- }
57
-
58
- .card::before {
59
- content: "";
60
- position: absolute;
61
- inset: 0 0 auto;
62
- height: 1px;
63
- background: linear-gradient(90deg, transparent, rgba(86, 224, 157, 0.7), transparent);
64
- }
65
-
66
- .success-icon {
67
- width: 58px;
68
- height: 58px;
69
- display: grid;
70
- place-items: center;
71
- margin-bottom: 28px;
72
- border: 1px solid rgba(86, 224, 157, 0.45);
73
- border-radius: 16px;
74
- background: rgba(42, 195, 126, 0.1);
75
- color: #56e09d;
76
- box-shadow: inset 0 0 28px rgba(42, 195, 126, 0.08);
77
- }
78
-
79
- .success-icon svg {
80
- width: 28px;
81
- height: 28px;
82
- }
83
-
84
- h1 {
85
- margin: 0;
86
- font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
87
- font-size: clamp(28px, 6vw, 38px);
88
- font-weight: 650;
89
- letter-spacing: -0.035em;
90
- line-height: 1.12;
91
- }
92
-
93
- .lead {
94
- margin: 16px 0 0;
95
- color: #aeb8b3;
96
- font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
97
- font-size: 17px;
98
- line-height: 1.6;
99
- }
100
-
101
- .status {
102
- display: flex;
103
- align-items: center;
104
- gap: 12px;
105
- margin-top: 30px;
106
- padding: 15px 16px;
107
- border: 1px solid #29362f;
108
- border-radius: 12px;
109
- background: #0b100d;
110
- color: #c9d2cd;
111
- font-size: 13px;
112
- line-height: 1.5;
113
- }
114
-
115
- .status-dot {
116
- width: 8px;
117
- height: 8px;
118
- flex: 0 0 auto;
119
- border-radius: 50%;
120
- background: #56e09d;
121
- box-shadow: 0 0 0 4px rgba(86, 224, 157, 0.1);
122
- }
123
-
124
- .next-step {
125
- margin: 24px 0 0;
126
- color: #7f8c85;
127
- font-size: 13px;
128
- line-height: 1.6;
129
- }
130
-
131
- .next-step strong {
132
- color: #b9c3be;
133
- font-weight: 600;
134
- }
135
-
136
- @media (max-width: 520px) {
137
- body {
138
- padding: 24px 16px;
139
- }
140
-
141
- .card {
142
- padding: 32px 24px;
143
- border-radius: 16px;
144
- }
145
-
146
- .success-icon {
147
- width: 52px;
148
- height: 52px;
149
- margin-bottom: 24px;
150
- }
151
- }
152
-
153
- @media (prefers-reduced-motion: reduce) {
154
- *, *::before, *::after {
155
- scroll-behavior: auto !important;
156
- animation-duration: 0.01ms !important;
157
- animation-iteration-count: 1 !important;
158
- }
159
- }
160
- </style>
161
- </head>
162
- <body>
163
- <main>
164
- <div class="brand" aria-label="OpenCode">
165
- <svg width="234" height="42" viewBox="0 0 234 42" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
166
- <path d="M18 30H6V18H18V30Z" fill="#4B4646"/>
167
- <path d="M18 12H6V30H18V12ZM24 36H0V6H24V36Z" fill="#B7B1B1"/>
168
- <path d="M48 30H36V18H48V30Z" fill="#4B4646"/>
169
- <path d="M36 30H48V12H36V30ZM54 36H36V42H30V6H54V36Z" fill="#B7B1B1"/>
170
- <path d="M84 24V30H66V24H84Z" fill="#4B4646"/>
171
- <path d="M84 24H66V30H84V36H60V6H84V24ZM66 18H78V12H66V18Z" fill="#B7B1B1"/>
172
- <path d="M108 36H96V18H108V36Z" fill="#4B4646"/>
173
- <path d="M108 12H96V36H90V6H108V12ZM114 36H108V12H114V36Z" fill="#B7B1B1"/>
174
- <path d="M144 30H126V18H144V30Z" fill="#4B4646"/>
175
- <path d="M144 12H126V30H144V36H120V6H144V12Z" fill="#F1ECEC"/>
176
- <path d="M168 30H156V18H168V30Z" fill="#4B4646"/>
177
- <path d="M168 12H156V30H168V12ZM174 36H150V6H174V36Z" fill="#F1ECEC"/>
178
- <path d="M198 30H186V18H198V30Z" fill="#4B4646"/>
179
- <path d="M198 12H186V30H198V12ZM204 36H180V6H198V0H204V36Z" fill="#F1ECEC"/>
180
- <path d="M234 24V30H216V24H234Z" fill="#4B4646"/>
181
- <path d="M216 12V18H228V12H216ZM234 24H216V30H234V36H210V6H234V24Z" fill="#F1ECEC"/>
182
- </svg>
183
- </div>
184
-
185
- <section class="card" aria-labelledby="success-title">
186
- <div class="success-icon" aria-hidden="true">
187
- <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
188
- <path d="M5 12.5 9.25 17 19 7" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"/>
189
- </svg>
190
- </div>
191
-
192
- <h1 id="success-title">Authentication complete</h1>
193
- <p class="lead">Your OpenAI account is connected securely and ready to use with OpenCode.</p>
194
-
195
- <div class="status" role="status">
196
- <span class="status-dot" aria-hidden="true"></span>
197
- <span>Credentials encrypted and stored</span>
198
- </div>
199
-
200
- <p class="next-step"><strong>You can close this tab.</strong> Return to your terminal to continue.</p>
201
- </section>
202
- </main>
203
- </body>
2
+ return `<!doctype html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <meta name="color-scheme" content="dark">
8
+ <title>OpenCode - Authentication complete</title>
9
+ <style nonce="${styleNonce}">
10
+ :root {
11
+ color-scheme: dark;
12
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
13
+ font-synthesis: none;
14
+ }
15
+
16
+ * {
17
+ box-sizing: border-box;
18
+ }
19
+
20
+ body {
21
+ min-width: 320px;
22
+ min-height: 100vh;
23
+ margin: 0;
24
+ display: grid;
25
+ place-items: center;
26
+ padding: 32px 20px;
27
+ background:
28
+ radial-gradient(circle at 50% 0%, rgba(42, 195, 126, 0.12), transparent 38rem),
29
+ #080b0a;
30
+ color: #f2f5f3;
31
+ }
32
+
33
+ main {
34
+ width: min(100%, 540px);
35
+ }
36
+
37
+ .brand {
38
+ display: flex;
39
+ margin: 0 0 24px 0;
40
+ justify-content: center;
41
+ }
42
+
43
+ .brand svg {
44
+ height: 22px;
45
+ width: auto;
46
+ }
47
+
48
+ .card {
49
+ position: relative;
50
+ overflow: hidden;
51
+ padding: 44px;
52
+ border: 1px solid #26312c;
53
+ border-radius: 20px;
54
+ background: linear-gradient(145deg, rgba(22, 28, 25, 0.98), rgba(13, 17, 15, 0.98));
55
+ box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
56
+ }
57
+
58
+ .card::before {
59
+ content: "";
60
+ position: absolute;
61
+ inset: 0 0 auto;
62
+ height: 1px;
63
+ background: linear-gradient(90deg, transparent, rgba(86, 224, 157, 0.7), transparent);
64
+ }
65
+
66
+ .success-icon {
67
+ width: 58px;
68
+ height: 58px;
69
+ display: grid;
70
+ place-items: center;
71
+ margin-bottom: 28px;
72
+ border: 1px solid rgba(86, 224, 157, 0.45);
73
+ border-radius: 16px;
74
+ background: rgba(42, 195, 126, 0.1);
75
+ color: #56e09d;
76
+ box-shadow: inset 0 0 28px rgba(42, 195, 126, 0.08);
77
+ }
78
+
79
+ .success-icon svg {
80
+ width: 28px;
81
+ height: 28px;
82
+ }
83
+
84
+ h1 {
85
+ margin: 0;
86
+ font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
87
+ font-size: clamp(28px, 6vw, 38px);
88
+ font-weight: 650;
89
+ letter-spacing: -0.035em;
90
+ line-height: 1.12;
91
+ }
92
+
93
+ .lead {
94
+ margin: 16px 0 0;
95
+ color: #aeb8b3;
96
+ font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
97
+ font-size: 17px;
98
+ line-height: 1.6;
99
+ }
100
+
101
+ .status {
102
+ display: flex;
103
+ align-items: center;
104
+ gap: 12px;
105
+ margin-top: 30px;
106
+ padding: 15px 16px;
107
+ border: 1px solid #29362f;
108
+ border-radius: 12px;
109
+ background: #0b100d;
110
+ color: #c9d2cd;
111
+ font-size: 13px;
112
+ line-height: 1.5;
113
+ }
114
+
115
+ .status-dot {
116
+ width: 8px;
117
+ height: 8px;
118
+ flex: 0 0 auto;
119
+ border-radius: 50%;
120
+ background: #56e09d;
121
+ box-shadow: 0 0 0 4px rgba(86, 224, 157, 0.1);
122
+ }
123
+
124
+ .next-step {
125
+ margin: 24px 0 0;
126
+ color: #7f8c85;
127
+ font-size: 13px;
128
+ line-height: 1.6;
129
+ }
130
+
131
+ .next-step strong {
132
+ color: #b9c3be;
133
+ font-weight: 600;
134
+ }
135
+
136
+ @media (max-width: 520px) {
137
+ body {
138
+ padding: 24px 16px;
139
+ }
140
+
141
+ .card {
142
+ padding: 32px 24px;
143
+ border-radius: 16px;
144
+ }
145
+
146
+ .success-icon {
147
+ width: 52px;
148
+ height: 52px;
149
+ margin-bottom: 24px;
150
+ }
151
+ }
152
+
153
+ @media (prefers-reduced-motion: reduce) {
154
+ *, *::before, *::after {
155
+ scroll-behavior: auto !important;
156
+ animation-duration: 0.01ms !important;
157
+ animation-iteration-count: 1 !important;
158
+ }
159
+ }
160
+ </style>
161
+ </head>
162
+ <body>
163
+ <main>
164
+ <div class="brand" aria-label="OpenCode">
165
+ <svg width="234" height="42" viewBox="0 0 234 42" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
166
+ <path d="M18 30H6V18H18V30Z" fill="#4B4646"/>
167
+ <path d="M18 12H6V30H18V12ZM24 36H0V6H24V36Z" fill="#B7B1B1"/>
168
+ <path d="M48 30H36V18H48V30Z" fill="#4B4646"/>
169
+ <path d="M36 30H48V12H36V30ZM54 36H36V42H30V6H54V36Z" fill="#B7B1B1"/>
170
+ <path d="M84 24V30H66V24H84Z" fill="#4B4646"/>
171
+ <path d="M84 24H66V30H84V36H60V6H84V24ZM66 18H78V12H66V18Z" fill="#B7B1B1"/>
172
+ <path d="M108 36H96V18H108V36Z" fill="#4B4646"/>
173
+ <path d="M108 12H96V36H90V6H108V12ZM114 36H108V12H114V36Z" fill="#B7B1B1"/>
174
+ <path d="M144 30H126V18H144V30Z" fill="#4B4646"/>
175
+ <path d="M144 12H126V30H144V36H120V6H144V12Z" fill="#F1ECEC"/>
176
+ <path d="M168 30H156V18H168V30Z" fill="#4B4646"/>
177
+ <path d="M168 12H156V30H168V12ZM174 36H150V6H174V36Z" fill="#F1ECEC"/>
178
+ <path d="M198 30H186V18H198V30Z" fill="#4B4646"/>
179
+ <path d="M198 12H186V30H198V12ZM204 36H180V6H198V0H204V36Z" fill="#F1ECEC"/>
180
+ <path d="M234 24V30H216V24H234Z" fill="#4B4646"/>
181
+ <path d="M216 12V18H228V12H216ZM234 24H216V30H234V36H210V6H234V24Z" fill="#F1ECEC"/>
182
+ </svg>
183
+ </div>
184
+
185
+ <section class="card" aria-labelledby="success-title">
186
+ <div class="success-icon" aria-hidden="true">
187
+ <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
188
+ <path d="M5 12.5 9.25 17 19 7" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"/>
189
+ </svg>
190
+ </div>
191
+
192
+ <h1 id="success-title">Authentication complete</h1>
193
+ <p class="lead">Your OpenAI account is connected securely and ready to use with OpenCode.</p>
194
+
195
+ <div class="status" role="status">
196
+ <span class="status-dot" aria-hidden="true"></span>
197
+ <span>Credentials encrypted and stored</span>
198
+ </div>
199
+
200
+ <p class="next-step"><strong>You can close this tab.</strong> Return to your terminal to continue.</p>
201
+ </section>
202
+ </main>
203
+ </body>
204
204
  </html>`;
205
205
  }
206
206
  // Retained for the standalone HTML artifact generated by the package build.
@@ -0,0 +1,2 @@
1
+ export { createOpenAI } from "@ai-sdk/openai";
2
+ //# sourceMappingURL=opencode-v2-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-v2-provider.d.ts","sourceRoot":"","sources":["../../lib/opencode-v2-provider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ // A distinct package identity keeps V2 from replacing this transport with its
2
+ // native OpenAI driver before the multi-account fetch hook can be installed.
3
+ export { createOpenAI } from "@ai-sdk/openai";
4
+ //# sourceMappingURL=opencode-v2-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-v2-provider.js","sourceRoot":"","sources":["../../lib/opencode-v2-provider.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ export declare const CodexStatusRpc: {
3
+ readonly id: "oc-codex-multi-auth";
4
+ readonly methods: {
5
+ readonly status: {
6
+ readonly input: z.ZodObject<{
7
+ width: z.ZodNumber;
8
+ }, z.core.$strip>;
9
+ readonly output: z.ZodObject<{
10
+ text: z.ZodString;
11
+ details: z.ZodString;
12
+ showFor: z.ZodEnum<{
13
+ always: "always";
14
+ "codex-models": "codex-models";
15
+ }>;
16
+ accounts: z.ZodArray<z.ZodObject<{
17
+ index: z.ZodNumber;
18
+ label: z.ZodString;
19
+ active: z.ZodBoolean;
20
+ enabled: z.ZodBoolean;
21
+ }, z.core.$strip>>;
22
+ }, z.core.$strip>;
23
+ };
24
+ };
25
+ readonly events: {};
26
+ };
27
+ //# sourceMappingURL=opencode-v2-rpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-v2-rpc.d.ts","sourceRoot":"","sources":["../../lib/opencode-v2-rpc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;CAYzB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Rpc } from "@opencode/plugin/rpc";
2
+ import { z } from "zod";
3
+ export const CodexStatusRpc = Rpc.define({
4
+ id: "oc-codex-multi-auth",
5
+ methods: {
6
+ status: {
7
+ input: z.object({ width: z.number().int().min(1).max(1000) }),
8
+ output: z.object({
9
+ text: z.string(), details: z.string(), showFor: z.enum(["always", "codex-models"]),
10
+ accounts: z.array(z.object({ index: z.number().int(), label: z.string(), active: z.boolean(), enabled: z.boolean() })),
11
+ }),
12
+ },
13
+ },
14
+ events: {},
15
+ });
16
+ //# sourceMappingURL=opencode-v2-rpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-v2-rpc.js","sourceRoot":"","sources":["../../lib/opencode-v2-rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC;IACxC,EAAE,EAAE,qBAAqB;IACzB,OAAO,EAAE;QACR,MAAM,EAAE;YACP,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7D,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;gBAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;gBAClF,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;aACtH,CAAC;SACF;KACD;IACD,MAAM,EAAE,EAAE;CACV,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /** Test hook: forget when each pool was last fetched. */
2
+ export declare function resetV2StatusThrottle(): void;
3
+ /** Format on the server so remote TUIs never need access to credentials. */
4
+ export declare function readV2Status({ width }: {
5
+ width: number;
6
+ }): Promise<{
7
+ text: string;
8
+ accounts: {
9
+ index: number;
10
+ label: string;
11
+ active: boolean;
12
+ enabled: boolean;
13
+ }[];
14
+ details: string;
15
+ showFor: import("./config.js").QuotaStatusAudience;
16
+ }>;
17
+ //# sourceMappingURL=opencode-v2-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-v2-status.d.ts","sourceRoot":"","sources":["../../lib/opencode-v2-status.ts"],"names":[],"mappings":"AAcA,yDAAyD;AACzD,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAwBD,4EAA4E;AAC5E,wBAAsB,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;GAkD9D"}
@@ -0,0 +1,91 @@
1
+ import { getCodexTuiMaskEmail, getCodexTuiMaskEmailInQuotaDetails, getQuotaDisplay, getQuotaStatus, loadPluginConfig } from "./config.js";
2
+ import { fetchTuiQuotaOverview, toQuotaOverviewAccounts } from "./tui-quota-overview.js";
3
+ import { readTuiQuotaSnapshot, readTuiQuotaOverviewSnapshot, isFreshTuiQuotaSnapshot, TUI_QUOTA_OVERVIEW_CACHE_FILE } from "./tui-quota-cache.js";
4
+ import { formatPromptStatusText, formatQuotaDetailsText, formatQuotaOverviewStatusLines, formatQuotaResetsStatusLines } from "./tui-status.js";
5
+ import { dirname, join } from "node:path";
6
+ import { getStoragePath, loadAccounts } from "./storage.js";
7
+ import { createUsageAccountFingerprint } from "./codex-usage.js";
8
+ import { resolveDisplayEmail } from "./account-display.js";
9
+ /** Same cadence as the V1 prompt status poll. */
10
+ const OVERVIEW_REFRESH_INTERVAL_MS = 5 * 60 * 1000;
11
+ const lastOverviewAttempt = new Map();
12
+ /** Test hook: forget when each pool was last fetched. */
13
+ export function resetV2StatusThrottle() {
14
+ lastOverviewAttempt.clear();
15
+ }
16
+ /**
17
+ * The TUI asks for status every two seconds, and a pool snapshot can stay stale
18
+ * indefinitely (a failing account keeps its older reading and fetch time). Gate
19
+ * the network pass on the last attempt, not the last success, so a stale cache
20
+ * reads the file instead of re-fetching every account on every poll. The last
21
+ * fetched snapshot is kept in memory too: if writing it to the cache failed,
22
+ * the file is older and must not win.
23
+ */
24
+ async function loadPoolOverview(cachePath) {
25
+ const now = Date.now();
26
+ const last = lastOverviewAttempt.get(cachePath);
27
+ if (last !== undefined && now - last.at < OVERVIEW_REFRESH_INTERVAL_MS) {
28
+ const cached = await readTuiQuotaOverviewSnapshot(cachePath);
29
+ if (!last.snapshot)
30
+ return cached;
31
+ return cached && cached.fetchedAt >= last.snapshot.fetchedAt ? cached : last.snapshot;
32
+ }
33
+ const entry = { at: now, snapshot: undefined };
34
+ lastOverviewAttempt.set(cachePath, entry);
35
+ entry.snapshot = await fetchTuiQuotaOverview({ cachePath, now });
36
+ return entry.snapshot;
37
+ }
38
+ /** Format on the server so remote TUIs never need access to credentials. */
39
+ export async function readV2Status({ width }) {
40
+ const config = loadPluginConfig();
41
+ const status = getQuotaStatus(config);
42
+ const quotaDisplay = getQuotaDisplay(config);
43
+ const maskEmail = getCodexTuiMaskEmail(config);
44
+ const snapshot = await readTuiQuotaSnapshot();
45
+ const pool = await loadAccounts();
46
+ const owned = snapshot && pool?.accounts.some((account) => createUsageAccountFingerprint(account) === snapshot.fingerprint);
47
+ let quota = snapshot && owned
48
+ ? { ...snapshot, type: "ready", stale: !isFreshTuiQuotaSnapshot(snapshot) }
49
+ : { type: pool?.accounts.length ? "unavailable" : "missing" };
50
+ const wantsPool = status.screens.some((screen) => screen !== "active");
51
+ const overview = pool?.accounts.length && (wantsPool || quota.type !== "ready" || quota.stale)
52
+ ? await loadPoolOverview(join(dirname(getStoragePath()), TUI_QUOTA_OVERVIEW_CACHE_FILE))
53
+ : null;
54
+ const active = pool?.accounts[pool.activeIndex];
55
+ const usage = active && overview?.accounts.find((account) => account.fingerprint === createUsageAccountFingerprint(active));
56
+ if (usage && overview) {
57
+ quota = { type: "ready", limits: usage.limits, stale: !isFreshTuiQuotaSnapshot(overview),
58
+ source: "usage", fetchedAt: overview.fetchedAt, accountIndex: pool ? pool.activeIndex + 1 : undefined,
59
+ accountCount: pool?.accounts.length, accountEmail: active.email, accountLabel: active.accountLabel,
60
+ planType: usage.planType };
61
+ }
62
+ const activeText = formatPromptStatusText({ quota, width, quotaDisplay, maskEmail });
63
+ const renderScreen = (screen) => {
64
+ if (screen === "active" || !overview)
65
+ return activeText;
66
+ const format = screen === "resets" ? formatQuotaResetsStatusLines : formatQuotaOverviewStatusLines;
67
+ return format({
68
+ accounts: toQuotaOverviewAccounts(overview), width, availableChars: width, maxRows: status.rows,
69
+ resetsMinUsedPercent: status.resetsMinUsedPercent,
70
+ options: { ...status, names: status.accountNames, mode: quotaDisplay, maskEmail },
71
+ }).join("\n");
72
+ };
73
+ // Like V1, rotate only among screens with something to say: the resets
74
+ // screen is empty until the pool is spent and must not blank the line.
75
+ const rendered = status.screens.map(renderScreen).filter((text) => text.length > 0);
76
+ const text = rendered.length > 0
77
+ ? rendered[Math.floor(Date.now() / status.rotateMs) % rendered.length] ?? ""
78
+ : "";
79
+ return {
80
+ text,
81
+ accounts: (pool?.accounts ?? []).map((account, index) => ({
82
+ index: index + 1,
83
+ label: account.accountLabel?.trim() || resolveDisplayEmail(account.email, maskEmail) || `Account ${index + 1}`,
84
+ active: index === pool?.activeIndex,
85
+ enabled: account.enabled !== false,
86
+ })),
87
+ details: formatQuotaDetailsText(quota, Date.now(), { quotaDisplay, maskEmail: getCodexTuiMaskEmailInQuotaDetails(config) }),
88
+ showFor: status.showFor,
89
+ };
90
+ }
91
+ //# sourceMappingURL=opencode-v2-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-v2-status.js","sourceRoot":"","sources":["../../lib/opencode-v2-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1I,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAClJ,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,4BAA4B,EAA2B,MAAM,iBAAiB,CAAC;AACxK,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,iDAAiD;AACjD,MAAM,4BAA4B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEnD,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAkD,CAAC;AAEtF,yDAAyD;AACzD,MAAM,UAAU,qBAAqB;IACpC,mBAAmB,CAAC,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,gBAAgB,CAAC,SAAiB;IAChD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,IAAI,GAAG,mBAAm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IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;QAC5E,CAAC,CAAC,EAAE,CAAC;IACN,OAAO;QACN,IAAI;QACJ,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACzD,KAAK,EAAE,KAAK,GAAG,CAAC;YAChB,KAAK,EAAE,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,mBAAmB,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,WAAW,KAAK,GAAG,CAAC,EAAE;YAC9G,MAAM,EAAE,KAAK,KAAK,IAAI,EAAE,WAAW;YACnC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,KAAK;SAClC,CAAC,CAAC;QACH,OAAO,EAAE,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,kCAAkC,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3H,OAAO,EAAE,MAAM,CAAC,OAAO;KACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from "@opencode/plugin/tui";
2
+ /** Register quota and account views; return a disposer for the V2 TUI slots. */
3
+ export declare function setupV2Tui(context: Plugin.Context): () => void;
4
+ //# sourceMappingURL=opencode-v2-tui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-v2-tui.d.ts","sourceRoot":"","sources":["../../lib/opencode-v2-tui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAKnD,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,cA+FjD"}