opencode-codex-multi-account 0.2.0 → 0.2.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.
- package/dist/index.js +31 -5
- package/dist/ui/auth-menu.d.ts +3 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2345,11 +2345,11 @@ function getUsageSummary(account) {
|
|
|
2345
2345
|
const parts = [];
|
|
2346
2346
|
const { five_hour, seven_day } = parsed.output;
|
|
2347
2347
|
if (five_hour) {
|
|
2348
|
-
const reset = five_hour.resets_at ? ` (resets ${formatTimeRemaining(five_hour.resets_at)})` : "";
|
|
2348
|
+
const reset = five_hour.utilization >= 100 && five_hour.resets_at ? ` (resets ${formatTimeRemaining(five_hour.resets_at)})` : "";
|
|
2349
2349
|
parts.push(`5h: ${five_hour.utilization.toFixed(0)}%${reset}`);
|
|
2350
2350
|
}
|
|
2351
2351
|
if (seven_day) {
|
|
2352
|
-
const reset = seven_day.resets_at ? ` (resets ${formatTimeRemaining(seven_day.resets_at)})` : "";
|
|
2352
|
+
const reset = seven_day.utilization >= 100 && seven_day.resets_at ? ` (resets ${formatTimeRemaining(seven_day.resets_at)})` : "";
|
|
2353
2353
|
parts.push(`7d: ${seven_day.utilization.toFixed(0)}%${reset}`);
|
|
2354
2354
|
}
|
|
2355
2355
|
return parts.length > 0 ? parts.join(", ") : "no usage data";
|
|
@@ -2408,6 +2408,16 @@ function getAccountStatus(account) {
|
|
|
2408
2408
|
if (account.isAuthDisabled) return "auth-disabled";
|
|
2409
2409
|
if (!account.enabled) return "disabled";
|
|
2410
2410
|
if (account.rateLimitResetAt && account.rateLimitResetAt > Date.now()) return "rate-limited";
|
|
2411
|
+
if (account.cachedUsage) {
|
|
2412
|
+
const now = Date.now();
|
|
2413
|
+
const usage = account.cachedUsage;
|
|
2414
|
+
const exhaustedTiers = [usage.five_hour, usage.seven_day].filter(
|
|
2415
|
+
(tier) => tier && tier.utilization >= 100 && tier.resets_at != null && Date.parse(tier.resets_at) > now
|
|
2416
|
+
);
|
|
2417
|
+
if (exhaustedTiers.length > 0) {
|
|
2418
|
+
return "rate-limited";
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2411
2421
|
return "active";
|
|
2412
2422
|
}
|
|
2413
2423
|
var STATUS_BADGE = {
|
|
@@ -2440,7 +2450,7 @@ async function showAuthMenu(accounts) {
|
|
|
2440
2450
|
while (true) {
|
|
2441
2451
|
const subtitle = `${accounts.length} account(s) registered`;
|
|
2442
2452
|
const result = await select(items, {
|
|
2443
|
-
message: "
|
|
2453
|
+
message: "Codex Multi-Auth",
|
|
2444
2454
|
subtitle
|
|
2445
2455
|
});
|
|
2446
2456
|
if (!result) return { type: "cancel" };
|
|
@@ -2527,8 +2537,8 @@ function printUsageEntry(name, entry, isLast) {
|
|
|
2527
2537
|
return;
|
|
2528
2538
|
}
|
|
2529
2539
|
const bar = createProgressBar(entry.utilization);
|
|
2530
|
-
const
|
|
2531
|
-
console.log(` ${connector} ${name.padEnd(16)} ${bar}${
|
|
2540
|
+
const resetInfo = entry.utilization >= 100 && entry.resets_at ? formatResetTime(entry.resets_at) : "";
|
|
2541
|
+
console.log(` ${connector} ${name.padEnd(16)} ${bar}${resetInfo}`);
|
|
2532
2542
|
}
|
|
2533
2543
|
function printQuotaReport(account, usage) {
|
|
2534
2544
|
const label = getAccountLabel(account);
|
|
@@ -3110,6 +3120,9 @@ var AccountRuntimeFactory = class {
|
|
|
3110
3120
|
};
|
|
3111
3121
|
|
|
3112
3122
|
// src/index.ts
|
|
3123
|
+
function formatResetTime2(resetAt) {
|
|
3124
|
+
return formatWaitTime(new Date(resetAt).getTime() - Date.now());
|
|
3125
|
+
}
|
|
3113
3126
|
var CodexMultiAuthPlugin = async (ctx) => {
|
|
3114
3127
|
const { client } = ctx;
|
|
3115
3128
|
await loadConfig();
|
|
@@ -3147,6 +3160,19 @@ var CodexMultiAuthPlugin = async (ctx) => {
|
|
|
3147
3160
|
const remaining = formatWaitTime(account.rateLimitResetAt - Date.now());
|
|
3148
3161
|
statusParts.push(`RATE LIMITED (resets in ${remaining})`);
|
|
3149
3162
|
}
|
|
3163
|
+
if (account.cachedUsage) {
|
|
3164
|
+
const usage2 = account.cachedUsage;
|
|
3165
|
+
const exhaustedTiers = [
|
|
3166
|
+
{ name: "5-hour", tier: usage2.five_hour },
|
|
3167
|
+
{ name: "7-day", tier: usage2.seven_day }
|
|
3168
|
+
].filter(({ tier }) => tier && tier.utilization >= 100);
|
|
3169
|
+
exhaustedTiers.forEach(({ name, tier }) => {
|
|
3170
|
+
if (tier && tier.resets_at) {
|
|
3171
|
+
const resetTime = formatResetTime2(tier.resets_at);
|
|
3172
|
+
statusParts.push(`USAGE EXHAUSTED (${name}, resets ${resetTime})`);
|
|
3173
|
+
}
|
|
3174
|
+
});
|
|
3175
|
+
}
|
|
3150
3176
|
lines.push(
|
|
3151
3177
|
`- **${label}**${marker}: ${statusParts.join(" | ")} | ${usage}`
|
|
3152
3178
|
);
|
package/dist/ui/auth-menu.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export type AuthMenuAction = {
|
|
|
13
13
|
type: "cancel";
|
|
14
14
|
};
|
|
15
15
|
export type AccountAction = "back" | "toggle" | "delete" | "retry-auth" | "cancel";
|
|
16
|
+
type AccountStatus = "active" | "rate-limited" | "auth-disabled" | "disabled";
|
|
17
|
+
export declare function getAccountStatus(account: ManagedAccount): AccountStatus;
|
|
16
18
|
export declare function showAuthMenu(accounts: ManagedAccount[]): Promise<AuthMenuAction>;
|
|
17
19
|
export declare function showManageAccounts(accounts: ManagedAccount[]): Promise<{
|
|
18
20
|
action: AccountAction;
|
|
@@ -23,3 +25,4 @@ export declare function showStrategySelect(current: AccountSelectionStrategy): P
|
|
|
23
25
|
export type AuthMethod = "browser" | "headless";
|
|
24
26
|
export declare function showMethodSelect(): Promise<AuthMethod | null>;
|
|
25
27
|
export declare function printQuotaError(account: ManagedAccount, error: string): void;
|
|
28
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-codex-multi-account",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "OpenCode plugin for Codex (OpenAI) multi-account management with automatic rate limit switching",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"directory": "packages/codex-multi-account"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"opencode-multi-account-core": "^0.2.
|
|
43
|
+
"opencode-multi-account-core": "^0.2.1",
|
|
44
44
|
"valibot": "^1.2.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|