opencode-codex-multi-account 0.2.7 → 0.2.9
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.d.ts +28 -4
- package/dist/index.js +154 -1952
- package/dist/index.js.map +1 -0
- package/package.json +3 -3
- package/dist/account-manager.d.ts +0 -2
- package/dist/account-store.d.ts +0 -2
- package/dist/auth-handler.d.ts +0 -20
- package/dist/claims.d.ts +0 -1
- package/dist/config.d.ts +0 -2
- package/dist/constants.d.ts +0 -32
- package/dist/executor.d.ts +0 -2
- package/dist/oauth.d.ts +0 -37
- package/dist/proactive-refresh.d.ts +0 -2
- package/dist/rate-limit.d.ts +0 -2
- package/dist/request-transform.d.ts +0 -2
- package/dist/runtime-factory.d.ts +0 -18
- package/dist/storage.d.ts +0 -1
- package/dist/token.d.ts +0 -4
- package/dist/types.d.ts +0 -216
- package/dist/ui/ansi.d.ts +0 -1
- package/dist/ui/auth-menu.d.ts +0 -28
- package/dist/ui/confirm.d.ts +0 -1
- package/dist/ui/select.d.ts +0 -1
- package/dist/usage.d.ts +0 -25
- package/dist/utils.d.ts +0 -1
package/dist/types.d.ts
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const OAuthCredentialsSchema: v.ObjectSchema<{
|
|
3
|
-
readonly type: v.LiteralSchema<"oauth", undefined>;
|
|
4
|
-
readonly refresh: v.StringSchema<undefined>;
|
|
5
|
-
readonly access: v.StringSchema<undefined>;
|
|
6
|
-
readonly expires: v.NumberSchema<undefined>;
|
|
7
|
-
}, undefined>;
|
|
8
|
-
export declare const UsageLimitEntrySchema: v.ObjectSchema<{
|
|
9
|
-
readonly utilization: v.NumberSchema<undefined>;
|
|
10
|
-
readonly resets_at: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
11
|
-
}, undefined>;
|
|
12
|
-
export declare const UsageLimitsSchema: v.ObjectSchema<{
|
|
13
|
-
readonly five_hour: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
14
|
-
readonly utilization: v.NumberSchema<undefined>;
|
|
15
|
-
readonly resets_at: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
16
|
-
}, undefined>, undefined>, null>;
|
|
17
|
-
readonly seven_day: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
18
|
-
readonly utilization: v.NumberSchema<undefined>;
|
|
19
|
-
readonly resets_at: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
20
|
-
}, undefined>, undefined>, null>;
|
|
21
|
-
readonly seven_day_sonnet: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
22
|
-
readonly utilization: v.NumberSchema<undefined>;
|
|
23
|
-
readonly resets_at: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
24
|
-
}, undefined>, undefined>, null>;
|
|
25
|
-
}, undefined>;
|
|
26
|
-
export declare const CredentialRefreshPatchSchema: v.ObjectSchema<{
|
|
27
|
-
readonly accessToken: v.StringSchema<undefined>;
|
|
28
|
-
readonly expiresAt: v.NumberSchema<undefined>;
|
|
29
|
-
readonly refreshToken: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
30
|
-
readonly uuid: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
31
|
-
readonly accountId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
32
|
-
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
33
|
-
}, undefined>;
|
|
34
|
-
export declare const StoredAccountSchema: v.ObjectSchema<{
|
|
35
|
-
readonly uuid: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
36
|
-
readonly accountId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
37
|
-
readonly label: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
38
|
-
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
39
|
-
readonly planTier: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
40
|
-
readonly refreshToken: v.StringSchema<undefined>;
|
|
41
|
-
readonly accessToken: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
42
|
-
readonly expiresAt: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
43
|
-
readonly addedAt: v.NumberSchema<undefined>;
|
|
44
|
-
readonly lastUsed: v.NumberSchema<undefined>;
|
|
45
|
-
readonly enabled: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
46
|
-
readonly rateLimitResetAt: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
47
|
-
readonly cachedUsage: v.OptionalSchema<v.ObjectSchema<{
|
|
48
|
-
readonly five_hour: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
49
|
-
readonly utilization: v.NumberSchema<undefined>;
|
|
50
|
-
readonly resets_at: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
51
|
-
}, undefined>, undefined>, null>;
|
|
52
|
-
readonly seven_day: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
53
|
-
readonly utilization: v.NumberSchema<undefined>;
|
|
54
|
-
readonly resets_at: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
55
|
-
}, undefined>, undefined>, null>;
|
|
56
|
-
readonly seven_day_sonnet: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
57
|
-
readonly utilization: v.NumberSchema<undefined>;
|
|
58
|
-
readonly resets_at: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
59
|
-
}, undefined>, undefined>, null>;
|
|
60
|
-
}, undefined>, undefined>;
|
|
61
|
-
readonly cachedUsageAt: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
62
|
-
readonly consecutiveAuthFailures: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
63
|
-
readonly isAuthDisabled: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
64
|
-
readonly authDisabledReason: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
65
|
-
}, undefined>;
|
|
66
|
-
export declare const AccountStorageSchema: v.ObjectSchema<{
|
|
67
|
-
readonly version: v.LiteralSchema<1, undefined>;
|
|
68
|
-
readonly accounts: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
69
|
-
readonly uuid: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
70
|
-
readonly accountId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
71
|
-
readonly label: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
72
|
-
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
73
|
-
readonly planTier: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
74
|
-
readonly refreshToken: v.StringSchema<undefined>;
|
|
75
|
-
readonly accessToken: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
76
|
-
readonly expiresAt: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
77
|
-
readonly addedAt: v.NumberSchema<undefined>;
|
|
78
|
-
readonly lastUsed: v.NumberSchema<undefined>;
|
|
79
|
-
readonly enabled: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
80
|
-
readonly rateLimitResetAt: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
81
|
-
readonly cachedUsage: v.OptionalSchema<v.ObjectSchema<{
|
|
82
|
-
readonly five_hour: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
83
|
-
readonly utilization: v.NumberSchema<undefined>;
|
|
84
|
-
readonly resets_at: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
85
|
-
}, undefined>, undefined>, null>;
|
|
86
|
-
readonly seven_day: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
87
|
-
readonly utilization: v.NumberSchema<undefined>;
|
|
88
|
-
readonly resets_at: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
89
|
-
}, undefined>, undefined>, null>;
|
|
90
|
-
readonly seven_day_sonnet: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
91
|
-
readonly utilization: v.NumberSchema<undefined>;
|
|
92
|
-
readonly resets_at: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
93
|
-
}, undefined>, undefined>, null>;
|
|
94
|
-
}, undefined>, undefined>;
|
|
95
|
-
readonly cachedUsageAt: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
96
|
-
readonly consecutiveAuthFailures: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
97
|
-
readonly isAuthDisabled: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
98
|
-
readonly authDisabledReason: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
99
|
-
}, undefined>, undefined>, readonly []>;
|
|
100
|
-
readonly activeAccountUuid: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
101
|
-
}, undefined>;
|
|
102
|
-
/** OpenAI /oauth/token response */
|
|
103
|
-
export declare const TokenResponseSchema: v.ObjectSchema<{
|
|
104
|
-
readonly id_token: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
105
|
-
readonly access_token: v.StringSchema<undefined>;
|
|
106
|
-
readonly refresh_token: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
107
|
-
readonly expires_in: v.NumberSchema<undefined>;
|
|
108
|
-
}, undefined>;
|
|
109
|
-
export type OAuthCredentials = v.InferOutput<typeof OAuthCredentialsSchema>;
|
|
110
|
-
export type UsageLimitEntry = v.InferOutput<typeof UsageLimitEntrySchema>;
|
|
111
|
-
export type UsageLimits = v.InferOutput<typeof UsageLimitsSchema>;
|
|
112
|
-
export type CredentialRefreshPatch = v.InferOutput<typeof CredentialRefreshPatchSchema>;
|
|
113
|
-
export type StoredAccount = v.InferOutput<typeof StoredAccountSchema>;
|
|
114
|
-
export type AccountStorage = v.InferOutput<typeof AccountStorageSchema>;
|
|
115
|
-
export type TokenResponse = v.InferOutput<typeof TokenResponseSchema>;
|
|
116
|
-
export declare const AccountSelectionStrategySchema: v.PicklistSchema<["sticky", "round-robin", "hybrid"], undefined>;
|
|
117
|
-
export type AccountSelectionStrategy = v.InferOutput<typeof AccountSelectionStrategySchema>;
|
|
118
|
-
export declare const PluginConfigSchema: v.ObjectSchema<{
|
|
119
|
-
/** sticky: same account until failure, round-robin: rotate every request, hybrid: health+usage scoring */
|
|
120
|
-
readonly account_selection_strategy: v.OptionalSchema<v.PicklistSchema<["sticky", "round-robin", "hybrid"], undefined>, "sticky">;
|
|
121
|
-
/** Use cross-process claim file to distribute parallel sessions across accounts */
|
|
122
|
-
readonly cross_process_claims: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
123
|
-
/** Skip account when any usage tier utilization >= this % (100 = disabled) */
|
|
124
|
-
readonly soft_quota_threshold_percent: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 100, undefined>]>, 100>;
|
|
125
|
-
/** Minimum backoff after rate limit (ms) */
|
|
126
|
-
readonly rate_limit_min_backoff_ms: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>, 30000>;
|
|
127
|
-
/** Default retry-after when header is missing (ms) */
|
|
128
|
-
readonly default_retry_after_ms: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>, 60000>;
|
|
129
|
-
/** Consecutive auth failures before disabling account */
|
|
130
|
-
readonly max_consecutive_auth_failures: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, 3>;
|
|
131
|
-
/** Backoff after token refresh failure (ms) */
|
|
132
|
-
readonly token_failure_backoff_ms: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>, 30000>;
|
|
133
|
-
/** Enable proactive background token refresh */
|
|
134
|
-
readonly proactive_refresh: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
135
|
-
/** Seconds before expiry to trigger proactive refresh (default 30 min) */
|
|
136
|
-
readonly proactive_refresh_buffer_seconds: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 60, undefined>]>, 1800>;
|
|
137
|
-
/** Interval between background refresh checks in seconds (default 5 min) */
|
|
138
|
-
readonly proactive_refresh_interval_seconds: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 30, undefined>]>, 300>;
|
|
139
|
-
/** Suppress toast notifications */
|
|
140
|
-
readonly quiet_mode: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
141
|
-
/** Enable debug logging */
|
|
142
|
-
readonly debug: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
143
|
-
}, undefined>;
|
|
144
|
-
export type PluginConfig = v.InferOutput<typeof PluginConfigSchema>;
|
|
145
|
-
export interface OriginalAuthHook {
|
|
146
|
-
methods?: Array<{
|
|
147
|
-
authorize?: (inputs?: Record<string, string>) => Promise<unknown>;
|
|
148
|
-
}>;
|
|
149
|
-
loader: (getAuth: () => Promise<unknown>, provider: unknown) => Promise<{
|
|
150
|
-
apiKey: string;
|
|
151
|
-
fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
152
|
-
}>;
|
|
153
|
-
}
|
|
154
|
-
export type TokenRefreshResult = {
|
|
155
|
-
ok: true;
|
|
156
|
-
patch: CredentialRefreshPatch;
|
|
157
|
-
} | {
|
|
158
|
-
ok: false;
|
|
159
|
-
permanent: boolean;
|
|
160
|
-
status?: number;
|
|
161
|
-
};
|
|
162
|
-
export interface ManagedAccount {
|
|
163
|
-
index: number;
|
|
164
|
-
uuid?: string;
|
|
165
|
-
accountId?: string;
|
|
166
|
-
label?: string;
|
|
167
|
-
email?: string;
|
|
168
|
-
planTier?: string;
|
|
169
|
-
refreshToken: string;
|
|
170
|
-
accessToken?: string;
|
|
171
|
-
expiresAt?: number;
|
|
172
|
-
addedAt: number;
|
|
173
|
-
lastUsed: number;
|
|
174
|
-
enabled: boolean;
|
|
175
|
-
rateLimitResetAt?: number;
|
|
176
|
-
last429At?: number;
|
|
177
|
-
cachedUsage?: UsageLimits;
|
|
178
|
-
cachedUsageAt?: number;
|
|
179
|
-
consecutiveAuthFailures: number;
|
|
180
|
-
isAuthDisabled: boolean;
|
|
181
|
-
authDisabledReason?: string;
|
|
182
|
-
}
|
|
183
|
-
export interface PluginClient {
|
|
184
|
-
auth: {
|
|
185
|
-
set: (params: {
|
|
186
|
-
path: {
|
|
187
|
-
id: string;
|
|
188
|
-
};
|
|
189
|
-
body: {
|
|
190
|
-
type: string;
|
|
191
|
-
refresh: string;
|
|
192
|
-
access: string;
|
|
193
|
-
expires: number;
|
|
194
|
-
};
|
|
195
|
-
}) => Promise<void>;
|
|
196
|
-
};
|
|
197
|
-
tui: {
|
|
198
|
-
showToast: (params: {
|
|
199
|
-
body: {
|
|
200
|
-
title?: string;
|
|
201
|
-
message: string;
|
|
202
|
-
variant: "info" | "warning" | "success" | "error";
|
|
203
|
-
};
|
|
204
|
-
}) => Promise<void>;
|
|
205
|
-
};
|
|
206
|
-
app: {
|
|
207
|
-
log: (params: {
|
|
208
|
-
body: {
|
|
209
|
-
service: string;
|
|
210
|
-
level: "debug" | "info" | "warn" | "error";
|
|
211
|
-
message: string;
|
|
212
|
-
extra?: Record<string, unknown>;
|
|
213
|
-
};
|
|
214
|
-
}) => Promise<void>;
|
|
215
|
-
};
|
|
216
|
-
}
|
package/dist/ui/ansi.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ANSI, isTTY, parseKey, type KeyAction, } from "opencode-multi-account-core";
|
package/dist/ui/auth-menu.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { AccountSelectionStrategy, ManagedAccount, UsageLimits } from "../types";
|
|
2
|
-
export type AuthMenuAction = {
|
|
3
|
-
type: "add";
|
|
4
|
-
} | {
|
|
5
|
-
type: "check-quotas";
|
|
6
|
-
} | {
|
|
7
|
-
type: "manage";
|
|
8
|
-
} | {
|
|
9
|
-
type: "load-balancing";
|
|
10
|
-
} | {
|
|
11
|
-
type: "delete-all";
|
|
12
|
-
} | {
|
|
13
|
-
type: "cancel";
|
|
14
|
-
};
|
|
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;
|
|
18
|
-
export declare function showAuthMenu(accounts: ManagedAccount[]): Promise<AuthMenuAction>;
|
|
19
|
-
export declare function showManageAccounts(accounts: ManagedAccount[]): Promise<{
|
|
20
|
-
action: AccountAction;
|
|
21
|
-
account?: ManagedAccount;
|
|
22
|
-
}>;
|
|
23
|
-
export declare function printQuotaReport(account: ManagedAccount, usage: UsageLimits): void;
|
|
24
|
-
export declare function showStrategySelect(current: AccountSelectionStrategy): Promise<AccountSelectionStrategy | null>;
|
|
25
|
-
export type AuthMethod = "browser" | "headless";
|
|
26
|
-
export declare function showMethodSelect(): Promise<AuthMethod | null>;
|
|
27
|
-
export declare function printQuotaError(account: ManagedAccount, error: string): void;
|
|
28
|
-
export {};
|
package/dist/ui/confirm.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { confirm } from "opencode-multi-account-core";
|
package/dist/ui/select.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { select, type MenuItem, type SelectOptions, } from "opencode-multi-account-core";
|
package/dist/usage.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ManagedAccount, UsageLimits } from "./types";
|
|
2
|
-
export type ProfileData = {
|
|
3
|
-
email?: string;
|
|
4
|
-
planTier: string;
|
|
5
|
-
};
|
|
6
|
-
export type FetchUsageResult = {
|
|
7
|
-
ok: true;
|
|
8
|
-
data: UsageLimits;
|
|
9
|
-
planType?: string;
|
|
10
|
-
} | {
|
|
11
|
-
ok: false;
|
|
12
|
-
reason: string;
|
|
13
|
-
};
|
|
14
|
-
export type FetchProfileResult = {
|
|
15
|
-
ok: true;
|
|
16
|
-
data: ProfileData;
|
|
17
|
-
} | {
|
|
18
|
-
ok: false;
|
|
19
|
-
reason: string;
|
|
20
|
-
};
|
|
21
|
-
export declare function fetchUsage(accessToken: string, accountId?: string): Promise<FetchUsageResult>;
|
|
22
|
-
export declare function derivePlanTier(planType: string): string;
|
|
23
|
-
export declare function fetchProfile(accessToken: string): FetchProfileResult;
|
|
24
|
-
export declare function getUsageSummary(account: ManagedAccount): string;
|
|
25
|
-
export declare function getPlanLabel(account: ManagedAccount): string;
|
package/dist/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createMinimalClient, debugLog, formatWaitTime, getAccountLabel, getConfigDir, getErrorCode, showToast, sleep, } from "opencode-multi-account-core";
|