opencode-auth-load-balancer 0.5.0 → 0.5.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 +3 -2
- package/dist/refresh.d.ts +1 -1
- package/dist/types.d.ts +7 -3
- package/dist/usage-refresh.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13168,7 +13168,8 @@ async function commitRefresh(accountId, attempt, next) {
|
|
|
13168
13168
|
return tokensOf(stored);
|
|
13169
13169
|
applyTokensTo(stored, next);
|
|
13170
13170
|
stored.tokenGen = attempt.gen + 1;
|
|
13171
|
-
stored.disabledReason
|
|
13171
|
+
if (stored.disabledReason !== MANUAL_DISABLED_REASON)
|
|
13172
|
+
stored.disabledReason = null;
|
|
13172
13173
|
return next;
|
|
13173
13174
|
});
|
|
13174
13175
|
}
|
|
@@ -14721,7 +14722,7 @@ async function refreshUsage(adapters, now, poolSnapshot) {
|
|
|
14721
14722
|
let stale;
|
|
14722
14723
|
for (const account of pool.accounts) {
|
|
14723
14724
|
aliveIds?.add(account.id);
|
|
14724
|
-
if (account.disabledReason)
|
|
14725
|
+
if (account.disabledReason && account.disabledReason !== MANUAL_DISABLED_REASON)
|
|
14725
14726
|
continue;
|
|
14726
14727
|
if (account.usage.capturedAt !== 0 && now - account.usage.capturedAt <= USAGE_REFRESH_TTL_MS)
|
|
14727
14728
|
continue;
|
package/dist/refresh.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderAdapter } from './providers/types';
|
|
2
|
-
import type
|
|
2
|
+
import { type PoolAccount } from './types';
|
|
3
3
|
export declare function needsRefresh(account: PoolAccount, now: number): boolean;
|
|
4
4
|
/**
|
|
5
5
|
* Ensure the account has a fresh access token, refreshing if needed. The rotated
|
package/dist/types.d.ts
CHANGED
|
@@ -87,7 +87,9 @@ export interface PoolAccount {
|
|
|
87
87
|
* written on a revoked refresh token (`src/refresh.ts`), and the manual
|
|
88
88
|
* `MANUAL_DISABLED_REASON` sentinel written by the disable action (TUI menu /
|
|
89
89
|
* `auth_lb_disable` tool). The dashboards distinguish the two to render
|
|
90
|
-
* `disabled` (a user turned it off) vs `re-login` (needs a fresh OAuth login)
|
|
90
|
+
* `disabled` (a user turned it off) vs `re-login` (needs a fresh OAuth login),
|
|
91
|
+
* and the usage poll skips only `re-login` — a disabled account's usage stays
|
|
92
|
+
* current.
|
|
91
93
|
*/
|
|
92
94
|
disabledReason: string | null;
|
|
93
95
|
}
|
|
@@ -96,8 +98,10 @@ export interface PoolAccount {
|
|
|
96
98
|
* sidebar menu and the `auth_lb_disable` tool), distinct from the automatic
|
|
97
99
|
* `invalid_grant: re-login required (…)` reason `src/refresh.ts` writes when a
|
|
98
100
|
* refresh token is revoked. Both are non-null so `isAvailable` skips the
|
|
99
|
-
* account; the value is kept distinct
|
|
100
|
-
*
|
|
101
|
+
* account; the value is kept distinct so the dashboards can render `disabled`
|
|
102
|
+
* (a user turned it off) rather than `re-login` (needs a fresh login), and so
|
|
103
|
+
* the usage poll keeps refreshing a disabled account (its credential still
|
|
104
|
+
* works) without a successful token rotation ever re-enabling it.
|
|
101
105
|
*/
|
|
102
106
|
export declare const MANUAL_DISABLED_REASON = "manually disabled";
|
|
103
107
|
/**
|
package/dist/usage-refresh.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderAdapter } from './providers/types';
|
|
2
|
-
import type
|
|
2
|
+
import { type PoolFile } from './types';
|
|
3
3
|
export declare const USAGE_REFRESH_TTL_MS: number;
|
|
4
4
|
/**
|
|
5
5
|
* Max lifetime of a TRANSIENT (non-quota) cooldown. fetch.ts cools a thrown
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-auth-load-balancer",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Load-balance opencode requests across multiple Anthropic (Claude) and OpenAI (Codex) OAuth accounts and Kimi Code subscriptions, weighted primarily by weekly usage with drain-before-reset scheduling.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|