opencode-anthropic-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 CHANGED
@@ -2019,11 +2019,11 @@ function getUsageSummary(account) {
2019
2019
  const parts = [];
2020
2020
  const { five_hour, seven_day } = account.cachedUsage;
2021
2021
  if (five_hour) {
2022
- const reset = five_hour.resets_at ? ` (resets ${formatTimeRemaining(five_hour.resets_at)})` : "";
2022
+ const reset = five_hour.utilization >= 100 && five_hour.resets_at ? ` (resets ${formatTimeRemaining(five_hour.resets_at)})` : "";
2023
2023
  parts.push(`5h: ${five_hour.utilization.toFixed(0)}%${reset}`);
2024
2024
  }
2025
2025
  if (seven_day) {
2026
- const reset = seven_day.resets_at ? ` (resets ${formatTimeRemaining(seven_day.resets_at)})` : "";
2026
+ const reset = seven_day.utilization >= 100 && seven_day.resets_at ? ` (resets ${formatTimeRemaining(seven_day.resets_at)})` : "";
2027
2027
  parts.push(`7d: ${seven_day.utilization.toFixed(0)}%${reset}`);
2028
2028
  }
2029
2029
  return parts.length > 0 ? parts.join(", ") : "no data";
@@ -2079,6 +2079,16 @@ function getAccountStatus(account) {
2079
2079
  if (account.isAuthDisabled) return "auth-disabled";
2080
2080
  if (!account.enabled) return "disabled";
2081
2081
  if (account.rateLimitResetAt && account.rateLimitResetAt > Date.now()) return "rate-limited";
2082
+ if (account.cachedUsage) {
2083
+ const now = Date.now();
2084
+ const usage = account.cachedUsage;
2085
+ const exhaustedTiers = [usage.five_hour, usage.seven_day].filter(
2086
+ (tier) => tier && tier.utilization >= 100 && tier.resets_at != null && Date.parse(tier.resets_at) > now
2087
+ );
2088
+ if (exhaustedTiers.length > 0) {
2089
+ return "rate-limited";
2090
+ }
2091
+ }
2082
2092
  return "active";
2083
2093
  }
2084
2094
  var STATUS_BADGE = {
@@ -2198,7 +2208,7 @@ function printUsageEntry(name, entry, isLast) {
2198
2208
  return;
2199
2209
  }
2200
2210
  const bar = createProgressBar(entry.utilization);
2201
- const reset = formatResetTime(entry.resets_at);
2211
+ const reset = entry.utilization >= 100 && entry.resets_at ? formatResetTime(entry.resets_at) : "";
2202
2212
  console.log(` ${connector} ${name.padEnd(16)} ${bar}${reset}`);
2203
2213
  }
2204
2214
  function printQuotaReport(account, usage) {
@@ -2725,6 +2735,16 @@ var ClaudeMultiAuthPlugin = async (ctx) => {
2725
2735
  const remaining = formatWaitTime(account.rateLimitResetAt - Date.now());
2726
2736
  statusParts.push(`RATE LIMITED (resets in ${remaining})`);
2727
2737
  }
2738
+ if (account.cachedUsage) {
2739
+ const now = Date.now();
2740
+ const usage2 = account.cachedUsage;
2741
+ const exhaustedTiers = [usage2.five_hour, usage2.seven_day].filter(
2742
+ (tier) => tier && tier.utilization >= 100 && tier.resets_at != null && Date.parse(tier.resets_at) > now
2743
+ );
2744
+ if (exhaustedTiers.length > 0) {
2745
+ statusParts.push("USAGE EXHAUSTED");
2746
+ }
2747
+ }
2728
2748
  lines.push(
2729
2749
  `- **${label}**${planBadge}${marker}: ${statusParts.join(" | ")} | ${usage}`
2730
2750
  );
@@ -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;
@@ -21,3 +23,4 @@ export declare function showManageAccounts(accounts: ManagedAccount[]): Promise<
21
23
  export declare function printQuotaReport(account: ManagedAccount, usage: UsageLimits): void;
22
24
  export declare function showStrategySelect(current: AccountSelectionStrategy): Promise<AccountSelectionStrategy | null>;
23
25
  export declare function printQuotaError(account: ManagedAccount, error: string): void;
26
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-anthropic-multi-account",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "OpenCode plugin for Anthropic multi-account management with automatic rate limit switching",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -39,7 +39,7 @@
39
39
  "directory": "packages/anthropic-multi-account"
40
40
  },
41
41
  "dependencies": {
42
- "opencode-multi-account-core": "^0.2.0",
42
+ "opencode-multi-account-core": "^0.2.1",
43
43
  "opencode-anthropic-auth": "^0.0.13",
44
44
  "valibot": "^1.2.0"
45
45
  },