@modelprofile.com/authswitch 2.2.0 → 2.3.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.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/accounts.d.ts +3 -0
- package/dist_ts/accounts.js +37 -1
- package/dist_ts/classes.accountlist.d.ts +4 -0
- package/dist_ts/classes.accountlist.js +18 -12
- package/dist_ts/classes.cli.d.ts +5 -0
- package/dist_ts/classes.cli.js +31 -8
- package/dist_ts/classes.limits.d.ts +24 -0
- package/dist_ts/classes.limits.js +178 -0
- package/dist_ts/interfaces.list.d.ts +51 -0
- package/package.json +2 -2
- package/readme.md +80 -7
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/accounts.ts +29 -0
- package/ts/classes.accountlist.ts +22 -10
- package/ts/classes.cli.ts +28 -7
- package/ts/classes.limits.ts +187 -0
- package/ts/interfaces.list.ts +55 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import { compactSince, compactUntil, orderedUsageWindows } from './accounts.js';
|
|
3
|
+
import { consoleHeading, consoleTable } from './classes.accountlist.js';
|
|
4
|
+
import { dim, plainText } from './formatting.js';
|
|
5
|
+
const UNAVAILABLE = 'n/a';
|
|
6
|
+
const NONE = 'none';
|
|
7
|
+
/**
|
|
8
|
+
* Provider naming stays data-driven.
|
|
9
|
+
*
|
|
10
|
+
* A harness that owns exactly one credential slot is its own provider; one that owns several (an
|
|
11
|
+
* OpenCode installation with an OpenAI and an Anthropic login) has to say which slot a row is about.
|
|
12
|
+
*/
|
|
13
|
+
const providerName = (harnessArg, accountArg) => {
|
|
14
|
+
const slots = new Set(harnessArg.accounts.map(account => account.slotId).filter((slot) => slot !== undefined));
|
|
15
|
+
return accountArg?.slotId !== undefined && slots.size > 1
|
|
16
|
+
? `${plainText(harnessArg.label)} / ${plainText(accountArg.slotId)}`
|
|
17
|
+
: plainText(harnessArg.label);
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Why an account contributes no numbers.
|
|
21
|
+
*
|
|
22
|
+
* The provider's own explanation is preferred over ours, and a failed lookup is never presented as a
|
|
23
|
+
* missing capability: the two have different fixes.
|
|
24
|
+
*/
|
|
25
|
+
const missingLimitReason = (accountArg) => {
|
|
26
|
+
if (accountArg.status.problems.length)
|
|
27
|
+
return accountArg.status.problems.map(plainText).join(' ');
|
|
28
|
+
const availability = accountArg.status.facts.filter(fact => fact.section === 'Availability').map(fact => plainText(fact.value));
|
|
29
|
+
if (accountArg.status.summary?.usageWindows === undefined) {
|
|
30
|
+
return availability[0] ?? 'This login does not expose a usage or quota API.';
|
|
31
|
+
}
|
|
32
|
+
return 'The provider reported no usage window for this account.';
|
|
33
|
+
};
|
|
34
|
+
const accountKeys = (harnessArg, accountArg) => ({
|
|
35
|
+
harnessId: harnessArg.id,
|
|
36
|
+
provider: providerName(harnessArg, accountArg),
|
|
37
|
+
account: plainText(accountArg.label),
|
|
38
|
+
accountId: accountArg.id,
|
|
39
|
+
...(accountArg.slotId === undefined ? {} : { slotId: plainText(accountArg.slotId) }),
|
|
40
|
+
});
|
|
41
|
+
const harnessProblem = (harnessArg) => harnessArg.problems.length ? harnessArg.problems.map(plainText).join(' ') : null;
|
|
42
|
+
/** Provider then account, keeping each account's windows in the order the adapter ranked them. */
|
|
43
|
+
const byProviderThenAccount = (rowsArg) => [...rowsArg].sort((left, right) => left.provider.localeCompare(right.provider)
|
|
44
|
+
|| (left.account ?? '').localeCompare(right.account ?? ''));
|
|
45
|
+
const noteFor = (rowArg) => rowArg.unavailableReason === null ? null
|
|
46
|
+
: `${rowArg.provider}${rowArg.account === null ? '' : ` · ${rowArg.account}`}: ${rowArg.unavailableReason}`;
|
|
47
|
+
const collectNotes = (rowsArg) => [...new Set(rowsArg.map(noteFor).filter((note) => note !== null))];
|
|
48
|
+
/**
|
|
49
|
+
* One row per account and limit type, projected from the account list.
|
|
50
|
+
*
|
|
51
|
+
* Nothing here talks to a provider: the list is already the read-only, per-account-isolated lookup,
|
|
52
|
+
* so a single failing account costs its own rows a number and nothing else.
|
|
53
|
+
*/
|
|
54
|
+
export const accountLimits = (listArg) => {
|
|
55
|
+
const now = Date.parse(listArg.generatedAt);
|
|
56
|
+
const rows = [];
|
|
57
|
+
for (const harness of listArg.harnesses) {
|
|
58
|
+
const problem = harnessProblem(harness);
|
|
59
|
+
const empty = {
|
|
60
|
+
limitType: null, scope: null, windowSeconds: null, usedPercent: null, resetAt: null, resetsIn: UNAVAILABLE,
|
|
61
|
+
};
|
|
62
|
+
if (problem !== null) {
|
|
63
|
+
rows.push({ harnessId: harness.id, provider: providerName(harness), account: null, accountId: null, isActive: false, ...empty, unavailableReason: problem });
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (!harness.accounts.length) {
|
|
67
|
+
rows.push({ harnessId: harness.id, provider: providerName(harness), account: null, accountId: null, isActive: false, ...empty,
|
|
68
|
+
unavailableReason: harness.saveUnavailableReason === null ? 'No accounts are known for this harness.' : plainText(harness.saveUnavailableReason) });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
for (const account of harness.accounts) {
|
|
72
|
+
const windows = orderedUsageWindows(account.status.summary?.usageWindows);
|
|
73
|
+
if (!windows.length) {
|
|
74
|
+
rows.push({ ...accountKeys(harness, account), isActive: account.isActive, ...empty, unavailableReason: missingLimitReason(account) });
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
for (const window of windows) {
|
|
78
|
+
rows.push({
|
|
79
|
+
...accountKeys(harness, account), isActive: account.isActive,
|
|
80
|
+
limitType: plainText(window.label), scope: window.scope ?? 'account', windowSeconds: window.durationSeconds,
|
|
81
|
+
usedPercent: window.usedPercent, resetAt: window.resetAt, resetsIn: compactUntil(window.resetAt, now, UNAVAILABLE),
|
|
82
|
+
unavailableReason: null,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const limits = byProviderThenAccount(rows);
|
|
88
|
+
return { schemaVersion: 1, generatedAt: listArg.generatedAt, complete: listArg.complete, limits, notes: collectNotes(limits) };
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* One row per active credential slot.
|
|
92
|
+
*
|
|
93
|
+
* A harness with no active login still gets a row: "nothing is active here" is an answer, and
|
|
94
|
+
* silently dropping the provider would read as "this provider does not exist".
|
|
95
|
+
*/
|
|
96
|
+
export const activeAccounts = (listArg) => {
|
|
97
|
+
const now = Date.parse(listArg.generatedAt);
|
|
98
|
+
const rows = [];
|
|
99
|
+
for (const harness of listArg.harnesses) {
|
|
100
|
+
const problem = harnessProblem(harness);
|
|
101
|
+
if (problem !== null) {
|
|
102
|
+
rows.push({ harnessId: harness.id, provider: providerName(harness), account: null, accountId: null, savedAt: null, savedAgo: UNAVAILABLE, source: 'none', unavailableReason: problem });
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const active = harness.accounts.filter(account => account.isActive);
|
|
106
|
+
if (!active.length) {
|
|
107
|
+
const stashed = harness.accounts.filter(account => account.isStashed);
|
|
108
|
+
rows.push({
|
|
109
|
+
harnessId: harness.id, provider: providerName(harness), account: null, accountId: null,
|
|
110
|
+
savedAt: null, savedAgo: UNAVAILABLE, source: stashed.length ? 'stash only' : 'none',
|
|
111
|
+
unavailableReason: harness.saveUnavailableReason !== null ? plainText(harness.saveUnavailableReason)
|
|
112
|
+
: stashed.length ? `No login is active; ${stashed.length} saved account(s) can be activated with authswitch ${plainText(harness.id)} use.`
|
|
113
|
+
: `No login is active and none is saved. ${plainText(harness.loginHint)}`,
|
|
114
|
+
});
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
for (const account of active) {
|
|
118
|
+
rows.push({
|
|
119
|
+
...accountKeys(harness, account),
|
|
120
|
+
savedAt: account.savedAt, savedAgo: compactSince(account.savedAt, now, UNAVAILABLE),
|
|
121
|
+
source: 'credential file',
|
|
122
|
+
unavailableReason: account.isStashed ? null : 'This active login is not saved yet; authswitch cannot restore it after a switch.',
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const active = byProviderThenAccount(rows);
|
|
127
|
+
return { schemaVersion: 1, generatedAt: listArg.generatedAt, complete: listArg.complete, active, notes: collectNotes(active) };
|
|
128
|
+
};
|
|
129
|
+
const percent = (rowArg) => rowArg.usedPercent === null ? UNAVAILABLE : `${rowArg.usedPercent}%`;
|
|
130
|
+
/** Condensed presentation for `authswitch limits` and `authswitch active`. */
|
|
131
|
+
export class CondensedRenderer {
|
|
132
|
+
out;
|
|
133
|
+
constructor(out) {
|
|
134
|
+
this.out = out;
|
|
135
|
+
}
|
|
136
|
+
notes(notesArg, prefixArg) {
|
|
137
|
+
if (!notesArg.length)
|
|
138
|
+
return;
|
|
139
|
+
process.stdout.write('\n');
|
|
140
|
+
for (const note of notesArg)
|
|
141
|
+
process.stdout.write(`${dim(`${prefixArg}${note}`)}\n`);
|
|
142
|
+
}
|
|
143
|
+
async renderLimits(limitsArg) {
|
|
144
|
+
consoleHeading('Account limits');
|
|
145
|
+
if (!limitsArg.limits.length) {
|
|
146
|
+
process.stdout.write(`${dim('No harnesses registered.')}\n`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
await consoleTable(this.out, limitsArg.limits, [
|
|
150
|
+
{ key: 'provider', title: 'Provider', value: row => row.provider },
|
|
151
|
+
{ key: 'account', title: 'Account', value: row => row.account ?? UNAVAILABLE, style: row => ({ bold: row.isActive }) },
|
|
152
|
+
{ key: 'limit', title: 'Limit type', value: row => row.limitType ?? UNAVAILABLE },
|
|
153
|
+
{ key: 'used', title: 'Used %', value: percent, align: 'right',
|
|
154
|
+
style: row => ({ foreground: row.usedPercent === null ? 'orange' : row.usedPercent >= 100 ? 'red' : undefined }) },
|
|
155
|
+
{ key: 'reset', title: 'Resets in', value: row => row.resetsIn, align: 'right' },
|
|
156
|
+
]);
|
|
157
|
+
this.notes(limitsArg.notes, 'n/a — ');
|
|
158
|
+
}
|
|
159
|
+
async renderActive(activeArg) {
|
|
160
|
+
consoleHeading('Active accounts');
|
|
161
|
+
if (!activeArg.active.length) {
|
|
162
|
+
process.stdout.write(`${dim('No harnesses registered.')}\n`);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
await consoleTable(this.out, activeArg.active, [
|
|
166
|
+
{ key: 'provider', title: 'Provider', value: row => row.provider },
|
|
167
|
+
{ key: 'account', title: 'Account', value: row => row.account ?? NONE,
|
|
168
|
+
style: row => ({ bold: row.account !== null, foreground: row.account === null ? 'orange' : undefined }) },
|
|
169
|
+
// The absolute timestamp stays in --json; one screen is worth more here than one more column.
|
|
170
|
+
{ key: 'saved', title: 'Saved', value: row => row.savedAt === null ? (row.account === null ? UNAVAILABLE : 'not saved') : `${row.savedAgo} ago`, align: 'right',
|
|
171
|
+
style: row => ({ foreground: row.savedAt === null && row.account !== null ? 'orange' : undefined }) },
|
|
172
|
+
{ key: 'source', title: 'Source', value: row => row.source,
|
|
173
|
+
style: row => ({ foreground: row.source === 'credential file' ? 'green' : 'orange' }) },
|
|
174
|
+
]);
|
|
175
|
+
this.notes(activeArg.notes, 'note — ');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5saW1pdHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9jbGFzc2VzLmxpbWl0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGNBQWMsQ0FBQztBQUN4QyxPQUFPLEVBQUUsWUFBWSxFQUFFLFlBQVksRUFBRSxtQkFBbUIsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUNoRixPQUFPLEVBQUUsY0FBYyxFQUFFLFlBQVksRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBRXhFLE9BQU8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0FBQyxDQUFDO0lBQ3pDLENBQUM7Q0FDRiJ9
|
|
@@ -17,3 +17,54 @@ export interface IHarnessAccountList {
|
|
|
17
17
|
/** A state lookup failure is distinct from an empty account list. */
|
|
18
18
|
problems: string[];
|
|
19
19
|
}
|
|
20
|
+
/** Credential-free, versioned output of limits --json. One entry per account and limit type. */
|
|
21
|
+
export interface IAccountLimits {
|
|
22
|
+
schemaVersion: 1;
|
|
23
|
+
generatedAt: string;
|
|
24
|
+
complete: boolean;
|
|
25
|
+
limits: IAccountLimitRow[];
|
|
26
|
+
/** Why a row has no numbers. Never a substitute for a value. */
|
|
27
|
+
notes: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface IAccountLimitRow {
|
|
30
|
+
harnessId: string;
|
|
31
|
+
/** Harness label, qualified by the credential slot when the harness owns several. */
|
|
32
|
+
provider: string;
|
|
33
|
+
/** The account's public label, which is its email wherever the provider reports one. */
|
|
34
|
+
account: string | null;
|
|
35
|
+
accountId: string | null;
|
|
36
|
+
slotId?: string;
|
|
37
|
+
isActive: boolean;
|
|
38
|
+
/** The provider's own window name, or null when no limit data is available. */
|
|
39
|
+
limitType: string | null;
|
|
40
|
+
scope: 'account' | 'feature' | null;
|
|
41
|
+
windowSeconds: number | null;
|
|
42
|
+
/** Never inferred: null means the provider reported no percentage, not zero usage. */
|
|
43
|
+
usedPercent: number | null;
|
|
44
|
+
resetAt: string | null;
|
|
45
|
+
/** Human countdown for the same `resetAt`, relative to `generatedAt`. */
|
|
46
|
+
resetsIn: string;
|
|
47
|
+
unavailableReason: string | null;
|
|
48
|
+
}
|
|
49
|
+
/** Credential-free, versioned output of active --json. One entry per active credential slot. */
|
|
50
|
+
export interface IActiveAccounts {
|
|
51
|
+
schemaVersion: 1;
|
|
52
|
+
generatedAt: string;
|
|
53
|
+
complete: boolean;
|
|
54
|
+
active: IActiveAccountRow[];
|
|
55
|
+
notes: string[];
|
|
56
|
+
}
|
|
57
|
+
export interface IActiveAccountRow {
|
|
58
|
+
harnessId: string;
|
|
59
|
+
provider: string;
|
|
60
|
+
account: string | null;
|
|
61
|
+
accountId: string | null;
|
|
62
|
+
slotId?: string;
|
|
63
|
+
/** When authswitch last saved this login; null when it was never stashed. */
|
|
64
|
+
savedAt: string | null;
|
|
65
|
+
/** Human elapsed time for the same `savedAt`, relative to `generatedAt`. */
|
|
66
|
+
savedAgo: string;
|
|
67
|
+
/** Where the shown account comes from. Whether it is also saved is the `savedAt` field's answer. */
|
|
68
|
+
source: 'credential file' | 'stash only' | 'none';
|
|
69
|
+
unavailableReason: string | null;
|
|
70
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modelprofile.com/authswitch",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
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",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@git.zone/tsbuild": "^4.4.3",
|
|
27
27
|
"@git.zone/tsrun": "^2.0.6",
|
|
28
|
-
"@git.zone/tstest": "^6.
|
|
28
|
+
"@git.zone/tstest": "^6.1.1",
|
|
29
29
|
"@types/node": "26.5.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
package/readme.md
CHANGED
|
@@ -16,11 +16,7 @@ Remote control makes that worse. A ChatGPT client pairs with the local Codex app
|
|
|
16
16
|
|
|
17
17
|
## Install
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
pnpm config set @modelprofile.com:registry https://verdaccio.lossless.digital
|
|
23
|
-
```
|
|
19
|
+
The package is published to npmjs:
|
|
24
20
|
|
|
25
21
|
```bash
|
|
26
22
|
pnpm install -g @modelprofile.com/authswitch
|
|
@@ -57,6 +53,8 @@ authswitch --tui # full-screen account management
|
|
|
57
53
|
authswitch codex --tui # start the dashboard on Codex
|
|
58
54
|
authswitch list # all known accounts across registered harnesses, with live status
|
|
59
55
|
authswitch list --json # complete account/status document for scripts
|
|
56
|
+
authswitch limits # every account and limit type: used % and reset countdown
|
|
57
|
+
authswitch active # which account each provider is using right now
|
|
60
58
|
authswitch codex stash # save the active credential under its account email
|
|
61
59
|
authswitch codex list # Codex accounts, including an unsaved active login, with live status
|
|
62
60
|
authswitch codex use [email] # activate one; prompts when no email is given
|
|
@@ -310,12 +308,87 @@ marked unverified. Renewal/cancellation dates are shown only when an adapter can
|
|
|
310
308
|
provide live billing data. Codex uses the desktop app's account-check endpoint for
|
|
311
309
|
automatic renewal, explicit renewal/cancellation dates and subscription expiry.
|
|
312
310
|
|
|
311
|
+
### Condensed views
|
|
312
|
+
|
|
313
|
+
`authswitch limits` answers "how much is left, and when does it come back" in one
|
|
314
|
+
table. It is one row per account **and** limit type, sorted by provider and then by
|
|
315
|
+
account email, with a two-unit countdown (`2h 13m`, `3d 4h`, `45m`, `<1m`, `due`):
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
Account limits
|
|
319
|
+
┌──────────────────────┬─────────────────────────┬───────────────────────┬────────┬───────────────┐
|
|
320
|
+
│ Provider │ Account │ Limit type │ Used % │ Resets in │
|
|
321
|
+
├──────────────────────┼─────────────────────────┼───────────────────────┼────────┼───────────────┤
|
|
322
|
+
│ Claude Code │ phil@example.com │ Claude weekly │ 88% │ 4d 3h │
|
|
323
|
+
│ Claude Code │ phil@example.com │ Claude five-hour │ 63% │ 1h 2m │
|
|
324
|
+
│ Claude Code │ phil@example.com │ Opus weekly │ 100% │ 4d 3h │
|
|
325
|
+
│ Codex │ alice@example.com │ Codex secondary │ 12% │ 3d 4h │
|
|
326
|
+
│ Codex │ alice@example.com │ Codex primary │ 37% │ 2h 13m │
|
|
327
|
+
│ Codex │ alice@example.com │ Code review secondary │ 100% │ 3h 59m │
|
|
328
|
+
│ Codex │ bob@example.com │ n/a │ n/a │ n/a │
|
|
329
|
+
│ OpenCode / anthropic │ anthropic API key 20e75 │ n/a │ n/a │ n/a │
|
|
330
|
+
│ │ 1c3b707 │ │ │ │
|
|
331
|
+
│ OpenCode / openai │ alice@example.com │ Codex primary │ 0% │ not scheduled │
|
|
332
|
+
└──────────────────────┴─────────────────────────┴───────────────────────┴────────┴───────────────┘
|
|
333
|
+
|
|
334
|
+
n/a — Codex · bob@example.com: Subscription and limits: Login expired or was rejected.
|
|
335
|
+
n/a — OpenCode / anthropic · anthropic API key 20e751c3b707: This provider login does not expose a supported subscription or quota API.
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
A number is never invented. An account whose provider exposes no quota API, whose
|
|
339
|
+
lookup failed, or whose login cannot be read shows `n/a` in **Used %** and
|
|
340
|
+
**Resets in**, and the footnote under the table says why — one line per distinct
|
|
341
|
+
reason. A provider is never dropped from the table for lacking data, and one failed
|
|
342
|
+
account never blanks another's numbers. `not scheduled` means the provider reported
|
|
343
|
+
usage without a reset deadline; it is not the same as `n/a`.
|
|
344
|
+
|
|
345
|
+
Limit types are the provider's own window names, ordered general-before-feature and
|
|
346
|
+
weekly-first within an account. The provider column names the harness, qualified by
|
|
347
|
+
the credential slot when a harness owns several (`OpenCode / openai`).
|
|
348
|
+
|
|
349
|
+
`authswitch active` answers "what am I logged in as" for every harness at once:
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
Active accounts
|
|
353
|
+
┌──────────────────────┬────────────────────────────────┬────────────┬─────────────────┐
|
|
354
|
+
│ Provider │ Account │ Saved │ Source │
|
|
355
|
+
├──────────────────────┼────────────────────────────────┼────────────┼─────────────────┤
|
|
356
|
+
│ Claude Code │ phil@example.com │ 45m ago │ credential file │
|
|
357
|
+
│ Codex │ alice@example.com │ 2h 13m ago │ credential file │
|
|
358
|
+
│ Flex │ none │ n/a │ none │
|
|
359
|
+
│ OpenCode / anthropic │ anthropic API key 20e751c3b707 │ 30d ago │ credential file │
|
|
360
|
+
│ OpenCode / openai │ alice@example.com │ not saved │ credential file │
|
|
361
|
+
└──────────────────────┴────────────────────────────────┴────────────┴─────────────────┘
|
|
362
|
+
|
|
363
|
+
note — OpenCode / openai · alice@example.com: This active login is not saved yet; authswitch cannot restore it after a switch.
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Source** is where the shown login comes from: `credential file` is the harness's
|
|
367
|
+
own live credential, `stash only` means nothing is active and only saved copies
|
|
368
|
+
exist, `none` means neither. **Saved** is how long ago `authswitch` last saved that
|
|
369
|
+
login, or `not saved` — which is also the warning that a switch could not bring it
|
|
370
|
+
back. A harness with no active login keeps its row and explains itself in a note.
|
|
371
|
+
|
|
372
|
+
Both commands accept a harness qualifier (`authswitch claude limits`) and `--json`.
|
|
373
|
+
Both are read-only: they never activate, save or clear a login, they need no harness
|
|
374
|
+
stopped, and every provider lookup is bounded by the same 10-second timeout and
|
|
375
|
+
isolated per account as `authswitch list`.
|
|
376
|
+
|
|
313
377
|
### JSON output
|
|
314
378
|
|
|
315
379
|
`authswitch list --json`, `authswitch codex list --json`, and the `ls` alias write
|
|
316
380
|
one JSON document to stdout, with no color, tables or progress messages. `--json`
|
|
317
|
-
may appear before or after the command and requires `list
|
|
318
|
-
combined with a mutation or interactive mode. Unknown
|
|
381
|
+
may appear before or after the command and requires `list`, `ls`, `limits` or
|
|
382
|
+
`active`. It cannot be combined with a mutation or interactive mode. Unknown
|
|
383
|
+
arguments to these commands exit with 2.
|
|
384
|
+
|
|
385
|
+
`limits --json` emits `IAccountLimits` and `active --json` emits `IActiveAccounts`:
|
|
386
|
+
the same rows as the tables, plus the machine-readable fields the tables condense —
|
|
387
|
+
`accountId`, `slotId`, `scope`, `windowSeconds`, the ISO `resetAt` beside the human
|
|
388
|
+
`resetsIn`, the ISO `savedAt` beside the human `savedAgo`, and the per-row
|
|
389
|
+
`unavailableReason` that the footnotes summarise. Both carry `schemaVersion: 1`, the
|
|
390
|
+
shared `generatedAt` snapshot every countdown is relative to, and `complete`, which
|
|
391
|
+
is false when any account or harness could not be read.
|
|
319
392
|
|
|
320
393
|
The exported `IAccountList` contract contains:
|
|
321
394
|
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/accounts.ts
CHANGED
|
@@ -19,6 +19,35 @@ export const until = (timestampArg: string | null, nowArg: number): string => {
|
|
|
19
19
|
const hours = Math.floor(minutes % 1440 / 60);
|
|
20
20
|
return [days ? `${days}d` : '', hours ? `${hours}h` : '', minutes % 60 ? `${minutes % 60}min` : ''].filter(Boolean).join(' ');
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* A two-unit countdown for condensed tables: `2h 13m`, `3d 4h`, `45m`.
|
|
24
|
+
*
|
|
25
|
+
* `until` stays the long form used by the list view and the TUI. This one trades the third unit for
|
|
26
|
+
* a column that never wraps, and it never invents a deadline: an unknown or unparseable timestamp is
|
|
27
|
+
* reported as such rather than as zero time remaining.
|
|
28
|
+
*/
|
|
29
|
+
const twoUnits = (millisecondsArg: number): string => {
|
|
30
|
+
const minutes = Math.floor(millisecondsArg / 60000);
|
|
31
|
+
const days = Math.floor(minutes / 1440);
|
|
32
|
+
const hours = Math.floor(minutes % 1440 / 60);
|
|
33
|
+
if (days) return hours ? `${days}d ${hours}h` : `${days}d`;
|
|
34
|
+
if (hours) return minutes % 60 ? `${hours}h ${minutes % 60}m` : `${hours}h`;
|
|
35
|
+
return `${minutes}m`;
|
|
36
|
+
};
|
|
37
|
+
export const compactUntil = (timestampArg: string | null, nowArg: number, unavailableArg = 'n/a'): string => {
|
|
38
|
+
if (timestampArg === null) return 'not scheduled';
|
|
39
|
+
const remaining = Date.parse(timestampArg) - nowArg;
|
|
40
|
+
if (!Number.isFinite(remaining)) return unavailableArg;
|
|
41
|
+
if (remaining <= 0) return 'due';
|
|
42
|
+
return remaining < 60000 ? '<1m' : twoUnits(remaining);
|
|
43
|
+
};
|
|
44
|
+
/** The same two-unit form for a past timestamp, for "saved 3d 4h ago". */
|
|
45
|
+
export const compactSince = (timestampArg: string | null, nowArg: number, unavailableArg = 'n/a'): string => {
|
|
46
|
+
if (timestampArg === null) return unavailableArg;
|
|
47
|
+
const elapsed = nowArg - Date.parse(timestampArg);
|
|
48
|
+
if (!Number.isFinite(elapsed)) return unavailableArg;
|
|
49
|
+
return elapsed < 60000 ? 'just now' : twoUnits(elapsed);
|
|
50
|
+
};
|
|
22
51
|
export const accountPlan = (rowArg: IAccountRow): string => {
|
|
23
52
|
const subscription = rowArg.status?.summary?.subscription;
|
|
24
53
|
return subscription ? `${plainText(subscription.plan)}${subscription.source === 'stored' ? ' (stored; unverified)' : ' (live)'}` : rowArg.status ? 'Unavailable' : 'Loading';
|
|
@@ -49,21 +49,33 @@ export const readAccountList = async (harnessesArg: IAuthHarness[]): Promise<IAc
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
export const consoleWidth = (): number => process.stdout.columns ?? 100;
|
|
53
|
+
export const consoleHeading = (textArg: string): void => { process.stdout.write(`\n${bold(textArg)}\n`); };
|
|
54
|
+
|
|
55
|
+
/** One table implementation for every command, including the label-per-line fallback on narrow terminals. */
|
|
56
|
+
export const consoleTable = async <TRow>(
|
|
57
|
+
outArg: plugins.smartconsole.SmartConsole,
|
|
58
|
+
rowsArg: TRow[],
|
|
59
|
+
columnsArg: plugins.smartconsole.IBackendTableColumn<TRow>[],
|
|
60
|
+
): Promise<void> => {
|
|
61
|
+
if (!rowsArg.length) return;
|
|
62
|
+
if (consoleWidth() < 40) {
|
|
63
|
+
for (const row of rowsArg) {
|
|
64
|
+
process.stdout.write(columnsArg.map(column => ` ${column.title}: ${String(column.value(row) ?? 'Unavailable').replace(/\n/g, '\n ')}`).join('\n') + '\n\n');
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
await outArg.table(rowsArg, { columns: columnsArg, overflow: 'wrap', theme: { header: { bold: true, foreground: 'cyan' }, border: { dim: true } } });
|
|
69
|
+
};
|
|
70
|
+
|
|
52
71
|
/** Shared, provider-independent list presentation. Adapters supply grouping metadata. */
|
|
53
72
|
export class AccountListRenderer {
|
|
54
73
|
constructor(private readonly out: plugins.smartconsole.SmartConsole) {}
|
|
55
|
-
private get width(): number { return
|
|
56
|
-
private heading(textArg: string): void {
|
|
74
|
+
private get width(): number { return consoleWidth(); }
|
|
75
|
+
private heading(textArg: string): void { consoleHeading(textArg); }
|
|
57
76
|
|
|
58
77
|
private async table<TRow>(rowsArg: TRow[], columnsArg: plugins.smartconsole.IBackendTableColumn<TRow>[]): Promise<void> {
|
|
59
|
-
|
|
60
|
-
if (this.width < 40) {
|
|
61
|
-
for (const row of rowsArg) {
|
|
62
|
-
process.stdout.write(columnsArg.map(column => ` ${column.title}: ${String(column.value(row) ?? 'Unavailable').replace(/\n/g, '\n ')}`).join('\n') + '\n\n');
|
|
63
|
-
}
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
await this.out.table(rowsArg, { columns: columnsArg, overflow: 'wrap', theme: { header: { bold: true, foreground: 'cyan' }, border: { dim: true } } });
|
|
78
|
+
await consoleTable(this.out, rowsArg, columnsArg);
|
|
67
79
|
}
|
|
68
80
|
|
|
69
81
|
public async render(listArg: IAccountList): Promise<void> {
|
package/ts/classes.cli.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ClaudeCodeHarness } from './classes.claudecodeharness.js';
|
|
|
6
6
|
import { AuthSwitchTui } from './classes.tui.js';
|
|
7
7
|
import { AglAuthSwitchCoordinator, AuthSwitchOperations, type TAuthSwitchCoordinator, type TAuthSwitchMutation } from './classes.operations.js';
|
|
8
8
|
import { AccountListRenderer, readAccountList } from './classes.accountlist.js';
|
|
9
|
+
import { accountLimits, activeAccounts, CondensedRenderer } from './classes.limits.js';
|
|
9
10
|
import { duration, orderedUsageWindows, until } from './accounts.js';
|
|
10
11
|
import { defaultPreusePrompt, PreuseError, validatePreuseOptions } from './preuse.js';
|
|
11
12
|
import type { CodexSwitcher } from './classes.codexswitcher.js';
|
|
@@ -14,7 +15,9 @@ import { bold, dim, green, orange, plainText, red } from './formatting.js';
|
|
|
14
15
|
|
|
15
16
|
const canPrompt = (): boolean =>
|
|
16
17
|
process.stdin.isTTY === true && process.stdout.isTTY === true && !process.env.CI;
|
|
17
|
-
const COMMANDS = ['login', 'stash', 'list', 'ls', 'use', 'preuse', 'current', 'drop', 'rm', 'doctor'];
|
|
18
|
+
const COMMANDS = ['login', 'stash', 'list', 'ls', 'limits', 'active', 'use', 'preuse', 'current', 'drop', 'rm', 'doctor'];
|
|
19
|
+
/** Read-only overviews that work across every registered harness and support --json. */
|
|
20
|
+
const OVERVIEW_COMMANDS = ['list', 'ls', 'limits', 'active'];
|
|
18
21
|
|
|
19
22
|
/** Harness-independent command routing and interactive account management. */
|
|
20
23
|
export class AuthSwitchCli {
|
|
@@ -48,6 +51,8 @@ ${bold('Usage')}
|
|
|
48
51
|
authswitch list list all accounts with live subscription, usage and resets
|
|
49
52
|
authswitch <harness> list list accounts for one harness
|
|
50
53
|
authswitch list --json print all account information as JSON
|
|
54
|
+
authswitch limits one row per account and limit type: used % and reset countdown
|
|
55
|
+
authswitch active one row per provider: which account is in use, and since when
|
|
51
56
|
authswitch <harness> preuse <account> [--prompt <text>] [--model <id>]
|
|
52
57
|
send one prompt through that account without switching
|
|
53
58
|
authswitch <harness> stash [account/provider] [--keep]
|
|
@@ -68,7 +73,7 @@ ${bold('Options')}
|
|
|
68
73
|
-v, --version show the version
|
|
69
74
|
-i, --interactive open the guided account manager
|
|
70
75
|
--tui open the terminal management dashboard
|
|
71
|
-
--json JSON output for list / ls only
|
|
76
|
+
--json JSON output for list / ls / limits / active only
|
|
72
77
|
|
|
73
78
|
Preuse consumes the selected account's quota. Its default prompt is:
|
|
74
79
|
"${defaultPreusePrompt}"
|
|
@@ -97,8 +102,8 @@ ${bold('Environment')}
|
|
|
97
102
|
args.splice(args.indexOf('--json'), 1);
|
|
98
103
|
const route = [...args];
|
|
99
104
|
if (this.harnesses.has(route[0])) route.shift();
|
|
100
|
-
if (route.length !== 1 || !
|
|
101
|
-
process.stderr.write(
|
|
105
|
+
if (route.length !== 1 || !OVERVIEW_COMMANDS.includes(route[0])) {
|
|
106
|
+
process.stderr.write(`--json requires ${OVERVIEW_COMMANDS.join(', ')}, optionally qualified by a harness.\n`);
|
|
102
107
|
return 2;
|
|
103
108
|
}
|
|
104
109
|
}
|
|
@@ -130,9 +135,12 @@ ${bold('Environment')}
|
|
|
130
135
|
process.stderr.write(`${red('unknown harness or command')} "${plainText(first)}"\n\n${this.usage()}\n`);
|
|
131
136
|
return 2;
|
|
132
137
|
}
|
|
133
|
-
if (
|
|
134
|
-
if (args.length) { process.stderr.write(
|
|
135
|
-
|
|
138
|
+
if (OVERVIEW_COMMANDS.includes(command)) {
|
|
139
|
+
if (args.length) { process.stderr.write(`${command} accepts only --json; optionally put a harness before ${command}.\n`); return 2; }
|
|
140
|
+
const harnesses = harness ? [harness] : [...this.harnesses.values()];
|
|
141
|
+
return command === 'limits' || command === 'active'
|
|
142
|
+
? await this.commandCondensed(command, harnesses, json)
|
|
143
|
+
: await this.commandList(harnesses, json);
|
|
136
144
|
}
|
|
137
145
|
if (!harness) {
|
|
138
146
|
harness = await this.selectHarness();
|
|
@@ -426,6 +434,19 @@ ${bold('Environment')}
|
|
|
426
434
|
return outcomeArg.problems.length === 0 ? 0 : 1;
|
|
427
435
|
}
|
|
428
436
|
|
|
437
|
+
/**
|
|
438
|
+
* The condensed views are projections of the same read-only account list, so a provider is queried
|
|
439
|
+
* once, per account, with the same bounded timeouts and per-account failure isolation as `list`.
|
|
440
|
+
*/
|
|
441
|
+
private async commandCondensed(commandArg: 'limits' | 'active', harnessesArg: IAuthHarness[], jsonArg: boolean): Promise<number> {
|
|
442
|
+
const list = await readAccountList(harnessesArg);
|
|
443
|
+
const document = commandArg === 'limits' ? accountLimits(list) : activeAccounts(list);
|
|
444
|
+
if (jsonArg) process.stdout.write(`${JSON.stringify(document, null, 2)}\n`);
|
|
445
|
+
else if ('limits' in document) await new CondensedRenderer(this.out).renderLimits(document);
|
|
446
|
+
else await new CondensedRenderer(this.out).renderActive(document);
|
|
447
|
+
return document.complete ? 0 : 1;
|
|
448
|
+
}
|
|
449
|
+
|
|
429
450
|
private async commandList(harnessesArg: IAuthHarness[], jsonArg = false): Promise<number> {
|
|
430
451
|
const list = await readAccountList(harnessesArg);
|
|
431
452
|
if (jsonArg) process.stdout.write(`${JSON.stringify(list, null, 2)}\n`);
|