@modelprofile.com/authswitch 9.2.0 → 10.0.1

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 (81) hide show
  1. package/dist_ts/00_commitinfo_data.js +2 -2
  2. package/dist_ts/authority-contract.d.ts +52 -6
  3. package/dist_ts/authority-contract.js +1 -1
  4. package/dist_ts/classes.authoritybroker.d.ts +20 -4
  5. package/dist_ts/classes.authoritybroker.js +44 -8
  6. package/dist_ts/classes.authoritycli.d.ts +4 -1
  7. package/dist_ts/classes.authoritycli.js +42 -7
  8. package/dist_ts/classes.authorityclient.d.ts +9 -1
  9. package/dist_ts/classes.authorityclient.js +9 -3
  10. package/dist_ts/classes.authoritydaemon.js +8 -5
  11. package/dist_ts/classes.authoritydatabase.d.ts +6 -2
  12. package/dist_ts/classes.authoritydatabase.js +13 -6
  13. package/dist_ts/classes.authorityimport.d.ts +4 -4
  14. package/dist_ts/classes.authorityimport.js +8 -7
  15. package/dist_ts/classes.authoritymodels.d.ts +11 -3
  16. package/dist_ts/classes.authoritymodels.js +43 -13
  17. package/dist_ts/classes.authoritypreuse.d.ts +8 -2
  18. package/dist_ts/classes.authoritypreuse.js +27 -17
  19. package/dist_ts/classes.authorityusage.d.ts +4 -3
  20. package/dist_ts/classes.authorityusage.js +3 -5
  21. package/dist_ts/classes.claudeauthority.d.ts +5 -0
  22. package/dist_ts/classes.claudeauthority.js +47 -4
  23. package/dist_ts/classes.claudecodelocks.d.ts +6 -0
  24. package/dist_ts/classes.claudecodelocks.js +30 -2
  25. package/dist_ts/classes.claudenative.d.ts +37 -2
  26. package/dist_ts/classes.claudenative.js +142 -13
  27. package/dist_ts/classes.cli.js +3 -5
  28. package/dist_ts/classes.codexpreuse.d.ts +14 -3
  29. package/dist_ts/classes.codexpreuse.js +127 -44
  30. package/dist_ts/classes.codexstatus.js +44 -95
  31. package/dist_ts/classes.login.d.ts +20 -10
  32. package/dist_ts/classes.login.js +14 -13
  33. package/dist_ts/classes.openaiprovider.d.ts +53 -0
  34. package/dist_ts/classes.openaiprovider.js +340 -0
  35. package/dist_ts/classes.opencodeharness.js +3 -2
  36. package/dist_ts/classes.service.js +3 -5
  37. package/dist_ts/index.d.ts +2 -0
  38. package/dist_ts/index.js +3 -1
  39. package/dist_ts/interfaces.openai.d.ts +118 -0
  40. package/dist_ts/interfaces.openai.js +3 -0
  41. package/dist_ts/openaiauth.d.ts +76 -0
  42. package/dist_ts/openaiauth.js +371 -0
  43. package/dist_ts/openaiusage.d.ts +59 -0
  44. package/dist_ts/openaiusage.js +222 -0
  45. package/dist_ts/plugins.d.ts +1 -3
  46. package/dist_ts/plugins.js +2 -4
  47. package/dist_ts/preuse.d.ts +50 -0
  48. package/dist_ts/preuse.js +63 -4
  49. package/dist_ts/ts_migration/legacysources/shared.js +4 -3
  50. package/openai-codex-license.txt +201 -0
  51. package/package.json +6 -4
  52. package/readme.md +102 -15
  53. package/third-party-notices.md +29 -0
  54. package/ts/00_commitinfo_data.ts +1 -1
  55. package/ts/authority-contract.ts +56 -8
  56. package/ts/classes.authoritybroker.ts +52 -13
  57. package/ts/classes.authoritycli.ts +48 -6
  58. package/ts/classes.authorityclient.ts +11 -3
  59. package/ts/classes.authoritydaemon.ts +7 -4
  60. package/ts/classes.authoritydatabase.ts +14 -6
  61. package/ts/classes.authorityimport.ts +12 -12
  62. package/ts/classes.authoritymodels.ts +42 -14
  63. package/ts/classes.authoritypreuse.ts +30 -17
  64. package/ts/classes.authorityusage.ts +8 -9
  65. package/ts/classes.claudeauthority.ts +37 -3
  66. package/ts/classes.claudecodelocks.ts +31 -1
  67. package/ts/classes.claudenative.ts +161 -14
  68. package/ts/classes.cli.ts +3 -3
  69. package/ts/classes.codexpreuse.ts +130 -40
  70. package/ts/classes.codexstatus.ts +40 -73
  71. package/ts/classes.login.ts +34 -21
  72. package/ts/classes.openaiprovider.ts +365 -0
  73. package/ts/classes.opencodeharness.ts +3 -2
  74. package/ts/classes.service.ts +3 -4
  75. package/ts/index.ts +2 -0
  76. package/ts/interfaces.openai.ts +142 -0
  77. package/ts/openaiauth.ts +422 -0
  78. package/ts/openaiusage.ts +247 -0
  79. package/ts/plugins.ts +1 -3
  80. package/ts/preuse.ts +88 -3
  81. package/ts/ts_migration/legacysources/shared.ts +4 -3
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 OpenAI
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelprofile.com/authswitch",
3
- "version": "9.2.0",
3
+ "version": "10.0.1",
4
4
  "private": false,
5
5
  "description": "Manage Codex, OpenCode and Claude Code accounts with guided switching and live usage status",
6
6
  "main": "dist_ts/index.js",
@@ -66,8 +66,8 @@
66
66
  "@api.global/typedrequest-interfaces": "7.1.0",
67
67
  "@lossless.org/client": "1.6.0",
68
68
  "@lossless.org/nosqldb": "10.6.0",
69
- "@modelprofile.com/flexharness-models": "^9.0.0",
70
- "@modelprofile.com/flexharness-providers": "^9.0.0",
69
+ "@modelprofile.com/flexharness-models": "^9.3.1",
70
+ "@modelprofile.com/flexharness-providers": "^9.3.1",
71
71
  "@modelprofile.com/mcp-crossharness": "5.6.0",
72
72
  "@push.rocks/smartconsole": "^1.3.0",
73
73
  "@push.rocks/smartdaemon": "2.7.2",
@@ -79,7 +79,9 @@
79
79
  "ts/**/*",
80
80
  "dist_ts/**/*",
81
81
  "cli.js",
82
- "readme.md"
82
+ "readme.md",
83
+ "third-party-notices.md",
84
+ "openai-codex-license.txt"
83
85
  ],
84
86
  "browserslist": [
85
87
  "last 1 chrome versions"
package/readme.md CHANGED
@@ -29,8 +29,8 @@ Node.js 24 or newer is required.
29
29
  The package also exports a typed client for a per-user authswitch authority daemon. Its
30
30
  SmartData registry stores account identity separately from sealed refresh grants, runtime
31
31
  bindings, durable device-operation receipts, Codex enrollment records, and native-handoff and migration journals. A daemon
32
- owns OpenAI device login, targeted reauthentication, and proactive refresh for grants
33
- added through this API. Management snapshots expose separate account and login rows,
32
+ owns OpenAI device login, targeted reauthentication, proactive refresh, and, on request,
33
+ revocation at removal for grants added through this API. Management snapshots expose separate account and login rows,
34
34
  including each login's purpose, owner, health, problem and available actions; neither
35
35
  snapshots nor events contain credentials. A login that a native tool refreshes also names
36
36
  that tool -- `ownerTool` is `claude_code`, `codex` or `opencode`, and `null` exactly when no
@@ -139,6 +139,27 @@ those runtimes: their holder stops them and releases the bindings first -- by ca
139
139
  it no longer holds one -- so a removal never strands a runtime whose next access would fail. Managed Codex
140
140
  bindings are the daemon's own; removal drains managed Codex as before and then takes them with the account.
141
141
 
142
+ Removing an account never reaches the network unless the caller asks. `removeAccount(accountId,
143
+ expectedRevision, { revoke: true })` (`revoke: true` on `authswitch.authority.remove`, `--revoke` on the
144
+ command line) also revokes the ChatGPT sign-in the authority held for that account at OpenAI (`/oauth/revoke`,
145
+ the request Codex sends when it logs out). The revocation runs after the removal committed and is best effort,
146
+ like Codex's: the account is removed either way. The revocations get at most 10 seconds in all, so a revoking
147
+ removal answers within the 35 seconds the client allows any request. The answer carries `revoked`: `yes` when
148
+ OpenAI confirmed it, `failed` when it did not, or not within those 10 seconds (the sign-in may still be valid
149
+ there, and the daemon's log says so without the token), `not_applicable` when the authority held no ChatGPT sign-in of its own for the account (a login a
150
+ native tool refreshes is that tool's), and `not_requested` without `revoke`. A daemon older than this client
151
+ refuses `revoke` as an invalid request before changing anything.
152
+
153
+ **A revocation is irreversible, and authswitch cannot tell whether another tool still refreshes from the
154
+ same sign-in.** A token is opaque; the import ledger records of each source only its kind, a hash of its
155
+ location, a digest of its bytes and the account and login it resolved to; and a login does not record
156
+ whether its current sign-in came from an import or from a device sign-in the authority ran itself. The same
157
+ ChatGPT identity turning up both as an imported copy and as a native Codex store proves the same account, not
158
+ the same sign-in, so no check can tell a shared sign-in from two independent ones. Revoking an imported
159
+ login can therefore sign out a native Codex, OpenCode or other home that still runs on that sign-in. Ask for
160
+ `revoke` only for a sign-in made through `account add openai` or `account reauth`, or when every other copy
161
+ of it should stop working too.
162
+
142
163
  Every route on either socket answers in one of three ways: a result, a **refusal**, or a fault. A refusal
143
164
  is an answer -- the daemon completed its check, nothing was left half-done, and its message says what the
144
165
  owner does instead -- so it crosses the wire marked, with the message verbatim beside
@@ -218,6 +239,7 @@ The authority CLI uses that daemon surface without constructing the legacy nativ
218
239
  authswitch account list [--json]
219
240
  authswitch account add openai [--json]
220
241
  authswitch account reauth <account-id> <login-id> [--json]
242
+ authswitch account remove <account-id> [--revoke] [--json]
221
243
  authswitch account operation get <operation-id> [--json]
222
244
  authswitch account operation cancel <operation-id> [--json]
223
245
  authswitch account operation resume <operation-id> [--json]
@@ -243,6 +265,12 @@ receipts until completion. `account operation resume` polls only the supplied du
243
265
  response is lost, the fixed diagnostic reports the caller-generated operation ID and exact resume
244
266
  command; the CLI does not replay the start request.
245
267
 
268
+ `account remove` removes one authority account by the id `account list` shows, at the revision it
269
+ reads just before, and prints the removal and what happened to its ChatGPT sign-in; `--json` prints the
270
+ daemon's answer, `{ account, revoked }`. `--revoke` asks for the revocation described under removal above,
271
+ with the same caveat: authswitch cannot tell whether another tool still runs on that sign-in. The command
272
+ exits nonzero when OpenAI did not confirm a requested revocation, although the account is removed.
273
+
246
274
  `account preuse` sends one quota-consuming prompt through the exact managed OpenAI account and
247
275
  login IDs. The default prompt is `Write 2000 words about strawberries.`; `--prompt` replaces it
248
276
  and `--model` requests one exact model. `--all` freezes one consistent authority snapshot, walks
@@ -253,11 +281,15 @@ reported as skipped with the snapshot revision, login revision, stored health, p
253
281
  observation time; no request or operation ID is created for that skip.
254
282
 
255
283
  Preuse operations run sequentially and are never retried automatically. Every terminal receipt
256
- advances an `--all` run, including `not_sent` and `outcome_unknown`, while any attempted operation
284
+ advances an `--all` run, including `not_sent`, `refused` and `outcome_unknown`, while any attempted operation
257
285
  that does not complete makes the final exit status nonzero. Snapshot-ineligible skips alone do not
258
286
  make an otherwise successful batch fail. Running `--all` again is a new quota-consuming run with
259
287
  new operation IDs. Use `account preuse operation resume` to continue observing an existing receipt.
260
- Only the explicit `cancel` command asks the daemon to cancel one.
288
+ Only the explicit `cancel` command asks the daemon to cancel one. A receipt stopped by a limit
289
+ carries it as `limit` (`{ kind, window, resetsAt }`); a sent request that failed for another stated
290
+ reason is `outcome_unknown` with problem `request_uncertain` and carries its cause as `failure`
291
+ (`{ kind, status, providerCode }`, for example `{ "kind": "http", "status": 503, "providerCode": null }`),
292
+ never the provider's text. Human output prints both as sentences.
261
293
 
262
294
  For `account add`, `account reauth` and `account operation resume`, `--json` writes JSON Lines:
263
295
  each line is one complete operation receipt, and unchanged revisions are omitted. `account
@@ -300,10 +332,21 @@ been adopted. Until a verified `claude_native` import has adopted one, every Cla
300
332
  `CLAUDE_CONFIG_DIR` that is not an absolute path is refused when the daemon starts, because the same
301
333
  variable also decides which file the import would read; it is never resolved against a working directory.
302
334
 
303
- A switch is only attempted when the host can prove Claude Code uses that native login: exactly the
304
- verified Claude Code release, a subscriber login in the store, no credential override in the
305
- environment, no managed or local settings selecting another auth source, and no scoped Claude session
306
- running. Anything else refuses and leaves both logins where they were. A move that reaches the home and
335
+ A switch is only attempted when the host can prove Claude Code uses that native login: Claude Code
336
+ 2.1.273 or newer installed, a subscriber login in the store, no credential override in the environment
337
+ (including the remote well-known token files), no managed or local settings selecting another auth source,
338
+ and every Claude Code session running in that home on a verified release -- one whose lock table, live
339
+ credential pickup and refresh compare-and-swap were read from its bundle, currently 2.1.273 and 2.1.282.
340
+ An installed release above 2.1.273 that is not verified is proven by Claude Code's own answer instead:
341
+ `claude auth status --json` must report the claude.ai login of the outgoing account -- its organization and
342
+ email, the only account identifiers it names -- read from this home and with no API key, before the write,
343
+ and of the incoming account after it. That path runs only while
344
+ no Claude Code session runs in the home. If Claude Code does not report the incoming login after the
345
+ write, or the proof fails for any other reason, the exact outgoing bytes are written back while the locks
346
+ are provably still held and the handoff is aborted with `problem: unsupported_effective_auth`; when they
347
+ cannot be, the home is quarantined. A write whose proof never ran is proven by the reconcile that finds it
348
+ before it can commit. Anything else refuses and leaves
349
+ both logins where they were. A move that reaches the home and
307
350
  then cannot complete that proof is quarantined with `problem: unsupported_effective_auth`, and the
308
351
  handoff's optional `proofFailure` names which condition failed -- `unsupported_release`, `subscription`,
309
352
  `override`, `settings`, `profile`, `profile_unreadable` or `running_session` -- so an owner is told what
@@ -401,6 +444,10 @@ model catalog, then commits `request_may_have_started` immediately before FlexHa
401
444
  inference with retries disabled. Reusing the UUID with the same request returns its durable receipt; changing
402
445
  the target, prompt or requested model is rejected. A crash, cancellation or shutdown after the
403
446
  marker remains `outcome_unknown` and is never replayed. Before-marker refusals are `not_sent`.
447
+ A reached usage limit is named in the receipt: `problem` is `usage_limit` or `rate_limit` and `limit`
448
+ carries `{ kind, window, resetsAt }` (null otherwise). The account's usage reading stops the prompt
449
+ before the marker (`not_sent`); a provider that refuses the prompt with a limit before it begins to
450
+ answer settles it `refused`, a terminal state in which nothing was consumed.
404
451
  Only the request hash, selected model, timing and safe token counts are stored; the prompt,
405
452
  generated prose and credentials are absent from persistence and management responses. Account
406
453
  removal and targeted reauthentication refuse while that account has an active preuse request.
@@ -613,7 +660,7 @@ copy's own tokens, and nothing else. `preuse` remains a Codex capability.
613
660
 
614
661
  **Claude Code picks a switch up live.** A running session re-reads its credential
615
662
  file whenever the file changes, before its next request, and reloads `.claude.json`
616
- when that changes (verified against Claude Code 2.1.273). So `use`, `stash` and a
663
+ when that changes (verified against Claude Code 2.1.273 and 2.1.282). So `use`, `stash` and a
617
664
  backend activation never ask for Claude Code to be stopped and never suggest a
618
665
  restart; a switch reports `Running Claude Code sessions use it from their next
619
666
  request.` What authswitch must not do is write in the middle of that session's own
@@ -679,6 +726,22 @@ the new account without changing the active native login. Ctrl-C cancels login.
679
726
  Select the saved account with `use` when ready to switch. Claude Code and other
680
727
  OpenCode providers retain their native login commands.
681
728
 
729
+ ### The ChatGPT sign-in
730
+
731
+ authswitch runs the ChatGPT sign-in itself, as the one party that signs in and
732
+ refreshes: the device code and its poll, the authorization-code exchange, the
733
+ refresh-token grant, the revocation, the claims of the tokens, and the account's
734
+ `wham/usage` limits. `AuthSwitchOpenAiProvider` is that provider -- `beginLogin`,
735
+ `refreshCredential` (one shared request per refresh token, so a rotating grant is
736
+ sent once), `revokeCredential`, `inspectCredential` and `getAccountRateLimits` --
737
+ and `interfaces.openai` holds its types. It holds no credential of its own. The
738
+ protocol is the one Codex's own login uses, adapted from OpenAI Codex (Apache-2.0;
739
+ see `third-party-notices.md`), and every failure is a fixed message that carries no
740
+ response body, token or header. Inference with a login's access is not auth:
741
+ FlexHarness's `/openai` module serves it from `{ accessToken, accountId,
742
+ isFedrampAccount }` alone, which is exactly what the authority's `resolveAccess`
743
+ answers.
744
+
682
745
  ### Hosted account management
683
746
 
684
747
  `AuthSwitchService` exposes credential-free account lists, login capabilities,
@@ -689,9 +752,12 @@ ID and `cancel` cancels a pending login. Operations outlive a disconnected clien
689
752
  and completed results remain available for ten minutes. Call `close()` during
690
753
  host shutdown. The host must authenticate and authorize every request.
691
754
 
692
- Login requests identify the harness, provider and supported flow explicitly.
693
- `AuthSwitchLogin` is the backend login owner and accepts additional provider
694
- adapters. Its credential-bearing completion is for backend storage only.
755
+ Login requests identify the harness, provider and flow explicitly; the one flow is
756
+ `device`, which needs no browser on the machine that signs in. `AuthSwitchLogin` is
757
+ the backend login owner. Its default provider is `AuthSwitchOpenAiProvider`,
758
+ authswitch's own ChatGPT sign-in (see "The ChatGPT sign-in"), and it accepts any
759
+ other provider that implements `IAuthLoginProvider`. Its credential-bearing
760
+ completion is for backend storage only.
695
761
  When an enclosing registry owns an injected adapter, construct it with
696
762
  `{ disposeProviders: false }` as the second argument and dispose that registry
697
763
  after closing the login service.
@@ -943,9 +1009,28 @@ prompt, the same window the single-account reset table lists first. An account
943
1009
  that sent no prompt has no model, token count or deadline of its own, and says so
944
1010
  rather than showing a zero. `Skipped` is a refusal the adapter stated before any
945
1011
  request -- an API-key login, a missing or expired credential, a model catalog
946
- that could not be read -- so nothing was consumed for it. `Failed` and
947
- `Interrupted` may both have consumed tokens and are never retried; `Not run` is
948
- an account the interruption never reached.
1012
+ that could not be read, a usage limit the account has reached -- so nothing was
1013
+ consumed for it. `Failed` and `Interrupted` may both have consumed tokens and are
1014
+ never retried; `Not run` is an account the interruption never reached. Every
1015
+ account that did not complete prints its reason, and a `Failed` one always names
1016
+ its cause without the provider's text: a limit, a rejected token, the 180-second
1017
+ deadline, a cancellation, an answer that ended unfinished, an HTTP error status
1018
+ (`the provider answered HTTP 503`), an answer that could not be read, an error the answer stream reported with the
1019
+ provider's error code, a connection that failed before any answer, or an error
1020
+ that names no cause.
1021
+
1022
+ Before it sends anything, Codex preuse reads the account's usage (`wham/usage`).
1023
+ When the account's limit is reached, the account is `Skipped` with the window and
1024
+ its reset in local time, for example `Weekly usage limit reached, resets in 16h
1025
+ 46min (2026-09-27 05:12). No preuse prompt was sent.` A reading that fails
1026
+ decides nothing: the prompt is sent and the provider's own answer counts, except a
1027
+ rejected token, which is refused before sending as the catalog read refuses it.
1028
+ When the provider still refuses the prompt with a usage or rate limit before it
1029
+ begins to answer -- a 429 naming `usage_limit_reached`, or a stream that fails with
1030
+ it before its first output -- the reason names that limit and says that no tokens
1031
+ were consumed. A limit reported after the answer began is named the same way, with
1032
+ its window and reset, and says that tokens may already have been consumed: the
1033
+ provider had begun to answer.
949
1034
 
950
1035
  The guide (`authswitch`, `authswitch -i`) offers **Preuse an account or all
951
1036
  accounts (consumes quota)** for a harness that supports it. It asks which account
@@ -1679,6 +1764,8 @@ The test suite builds a fixture `CODEX_HOME` with a real SQLite state database a
1679
1764
 
1680
1765
  This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the repository license file.
1681
1766
 
1767
+ The ChatGPT sign-in and usage-limit code is adapted from OpenAI Codex, which is licensed under the Apache License, Version 2.0. Its notices are in `third-party-notices.md` and its license in `openai-codex-license.txt`; both ship with the package.
1768
+
1682
1769
  **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
1683
1770
 
1684
1771
  ### Trademarks
@@ -0,0 +1,29 @@
1
+ # Third-Party Notices
2
+
3
+ ## OpenAI Codex
4
+
5
+ OpenAI Codex
6
+ Copyright 2025 OpenAI
7
+
8
+ The OpenAI ChatGPT device sign-in, authorization-code exchange, refresh-token and
9
+ revocation protocol, the token claims, and the `wham/usage` account rate-limit
10
+ wire contract in this package are adapted in TypeScript from OpenAI Codex
11
+ (https://github.com/openai/codex). They were first adapted from rust-v0.146.1,
12
+ commit `79b4f03d35962b005b007a015113b38930711665`, and re-verified against
13
+ rust-v0.157.0, commit `00c972ed5d6ff6499317fd41b7f23605b8e6850d`
14
+ (`codex-rs/login/src/device_code_auth.rs`, `codex-rs/login/src/auth/manager.rs`,
15
+ `codex-rs/login/src/auth/revoke.rs`, `codex-rs/login/src/oauth/client.rs`,
16
+ `codex-rs/backend-client/src/client.rs` and the rate-limit models in
17
+ `codex-rs/codex-backend-openapi-models/src/models/`).
18
+
19
+ The adapted files, and their compiled counterparts in `dist_ts/`, are marked
20
+ with a header and contain modifications and integration work copyright 2026
21
+ Task Venture Capital GmbH:
22
+
23
+ - `ts/openaiauth.ts`
24
+ - `ts/openaiusage.ts`
25
+ - `ts/classes.openaiprovider.ts`
26
+ - `ts/interfaces.openai.ts`
27
+
28
+ OpenAI Codex is licensed under the Apache License, Version 2.0. A verbatim copy
29
+ of the upstream license is distributed in [openai-codex-license.txt](./openai-codex-license.txt).
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@modelprofile.com/authswitch',
6
- version: '9.2.0',
6
+ version: '10.0.1',
7
7
  description: 'Manage Codex, OpenCode and Claude Code accounts with guided switching and live usage status'
8
8
  }
@@ -357,9 +357,8 @@ export interface IAuthSwitchAccountEvent {
357
357
  accountId: string;
358
358
  }
359
359
 
360
- export type TAuthSwitchLoginPrompt =
361
- | { flow: 'device'; verificationUrl: string; userCode: string }
362
- | { flow: 'browser'; authUrl: string };
360
+ /** What a device sign-in shows the person signing in; the authority signs in with a device code only. */
361
+ export type TAuthSwitchLoginPrompt = { flow: 'device'; verificationUrl: string; userCode: string };
363
362
 
364
363
  export interface IAuthSwitchOperation {
365
364
  id: string;
@@ -377,7 +376,38 @@ export interface IAuthSwitchOperation {
377
376
  revision: number;
378
377
  }
379
378
 
380
- /** Credential-free receipt for one exact, never-replayed quota-consuming request. */
379
+ /**
380
+ * A limit that kept a preuse prompt from being answered: `usage_limit` is the account's quota, spent until it
381
+ * resets, `rate_limit` a short throttle. `window` names the window by its length (`weekly`, `five-hour`) and
382
+ * `resetsAt` is an ISO time; either is null when neither the usage reading nor the provider stated it.
383
+ */
384
+ export interface IAuthSwitchPreuseLimit {
385
+ kind: 'usage_limit' | 'rate_limit';
386
+ window: string | null;
387
+ resetsAt: string | null;
388
+ }
389
+
390
+ /**
391
+ * Why a sent preuse prompt failed without a limit, never with the provider's text. `http` is an answer with an
392
+ * HTTP error status; `stream` an error the answer stream reported after it began, with the
393
+ * machine-readable code the error states and no status, since its answer was a success; `response` an answer that could not be read; `network` a connection
394
+ * that failed before any answer; `aborted` an abort that was neither a cancellation nor the deadline; `unknown`
395
+ * anything else. `status` and `providerCode` are null when the failure did not state them.
396
+ */
397
+ export interface IAuthSwitchPreuseFailure {
398
+ kind: 'http' | 'stream' | 'response' | 'network' | 'aborted' | 'unknown';
399
+ status: number | null;
400
+ providerCode: string | null;
401
+ }
402
+
403
+ /**
404
+ * Credential-free receipt for one exact, never-replayed quota-consuming request.
405
+ *
406
+ * `not_sent` with `usage_limit` is an account whose own usage reading showed a reached limit, so nothing was
407
+ * sent; `refused` is a prompt the provider refused with a limit before it began to answer, so nothing was
408
+ * consumed. `limit` describes the limit whenever `problem` is `usage_limit` or `rate_limit`, and is null otherwise.
409
+ * `failure` names the cause of a `request_uncertain` request when it failed with one, and is null otherwise.
410
+ */
381
411
  export interface IAuthSwitchPreuseOperation {
382
412
  id: string;
383
413
  accountId: string;
@@ -385,11 +415,13 @@ export interface IAuthSwitchPreuseOperation {
385
415
  purpose: 'openai_managed';
386
416
  requestedModel: string | null;
387
417
  model: string | null;
388
- state: 'preparing' | 'request_may_have_started' | 'complete' | 'not_sent' | 'outcome_unknown';
418
+ state: 'preparing' | 'request_may_have_started' | 'complete' | 'not_sent' | 'refused' | 'outcome_unknown';
389
419
  result: { inputTokens: number | null; outputTokens: number | null; totalTokens: number | null } | null;
390
420
  problem: 'none' | 'target_unavailable' | 'access_unavailable' | 'catalog_unavailable'
391
421
  | 'account_busy' | 'cancelled' | 'authority_closing' | 'interrupted'
392
- | 'request_uncertain';
422
+ | 'request_uncertain' | 'usage_limit' | 'rate_limit';
423
+ limit: IAuthSwitchPreuseLimit | null;
424
+ failure: IAuthSwitchPreuseFailure | null;
393
425
  createdAt: string;
394
426
  updatedAt: string;
395
427
  finishedAt: string | null;
@@ -549,10 +581,26 @@ export interface IReq_AuthSwitchGetBinding extends ITypedRequest {
549
581
  response: { binding: IAuthSwitchBinding | null };
550
582
  }
551
583
 
584
+ /**
585
+ * What a removal did about the account's ChatGPT sign-in at OpenAI:
586
+ * - `not_requested`: the caller did not ask; nothing reached the network.
587
+ * - `yes`: OpenAI confirmed the revocation.
588
+ * - `failed`: OpenAI did not confirm it, or not within the 10 seconds a removal's revocations are given in all;
589
+ * the sign-in may still be valid there. The account is removed anyway.
590
+ * - `not_applicable`: the authority held no ChatGPT sign-in of its own for the account.
591
+ */
592
+ export type TAuthSwitchRevocation = 'not_requested' | 'yes' | 'failed' | 'not_applicable';
593
+
594
+ /**
595
+ * Removes an account. With `revoke: true` the authority also revokes, after the removal committed, the ChatGPT
596
+ * sign-in it held for the account, and `revoked` says whether OpenAI confirmed it. The revocations take at most 10
597
+ * seconds in all, so a revoking removal answers within a request's usual 35 seconds. A revocation is irreversible
598
+ * and reaches everything that still refreshes from that sign-in, which the authority cannot see: see the readme.
599
+ */
552
600
  export interface IReq_AuthSwitchRemoveAccount extends ITypedRequest {
553
601
  method: 'authswitch.authority.remove';
554
- request: { accountId: string; expectedRevision: number };
555
- response: { account: IAuthSwitchAccount };
602
+ request: { accountId: string; expectedRevision: number; revoke?: true };
603
+ response: { account: IAuthSwitchAccount; revoked: TAuthSwitchRevocation };
556
604
  }
557
605
 
558
606
  /** Runtime capability is returned only to trusted backend callers; do not expose this response in a browser API. */