@omnicross/contracts 0.1.5 → 0.1.7
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/account-tokens-types.d.cts +72 -55
- package/dist/account-tokens-types.d.ts +72 -55
- package/dist/audit-types.cjs +1 -1
- package/dist/audit-types.d.cts +17 -10
- package/dist/audit-types.d.ts +17 -10
- package/dist/audit-types.js +1 -1
- package/dist/canonical-models.cjs +11 -0
- package/dist/canonical-models.js +11 -0
- package/dist/index.cjs +105 -114
- package/dist/index.d.cts +59 -4
- package/dist/index.d.ts +59 -4
- package/dist/index.js +104 -114
- package/dist/pricing-types.cjs +5 -2
- package/dist/pricing-types.d.cts +16 -1
- package/dist/pricing-types.d.ts +16 -1
- package/dist/pricing-types.js +3 -1
- package/dist/provider-presets/index.cjs +90 -113
- package/dist/provider-presets/index.js +90 -113
- package/dist/subscription-types.d.cts +8 -13
- package/dist/subscription-types.d.ts +8 -13
- package/dist/usage-stats-types.d.cts +16 -1
- package/dist/usage-stats-types.d.ts +16 -1
- package/dist/webhook-types.d.cts +1 -1
- package/dist/webhook-types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -12,13 +12,13 @@ import { OpenCodeGoTokenConfig } from './subscription-types.cjs';
|
|
|
12
12
|
/**
|
|
13
13
|
* Upstream proxy descriptor (upstream-proxy). Routes an outbound upstream call
|
|
14
14
|
* through an http/https or socks5 proxy. Two interchangeable shapes:
|
|
15
|
-
* - `{ url }`
|
|
15
|
+
* - `{ url }` a full proxy URL, e.g. `http://user:pass@host:1080` or
|
|
16
16
|
* `socks5://host:1080` (userinfo carries basic-auth).
|
|
17
|
-
* - structured
|
|
17
|
+
* - structured an explicit `{ type, host, port, username, password }`.
|
|
18
18
|
*
|
|
19
19
|
* `username`/`password` are SECRETS: encrypted at rest via the same envelope as
|
|
20
20
|
* other credentials, masked in every sanitized/admin view, and never logged
|
|
21
|
-
* (logs carry at most `host:port`). Additive everywhere it appears
|
|
21
|
+
* (logs carry at most `host:port`). Additive everywhere it appears absent a
|
|
22
22
|
* direct (non-proxied) call, byte-identical to before proxy support.
|
|
23
23
|
*/
|
|
24
24
|
type ProxyConfig = {
|
|
@@ -35,9 +35,9 @@ type ProxyConfig = {
|
|
|
35
35
|
* The frozen fingerprint headers a real Claude Code client sent for this account,
|
|
36
36
|
* captured + replayed so relayed traffic presents a stable identity across
|
|
37
37
|
* restarts. NON-secret metadata: it holds ONLY whitelisted fingerprint headers
|
|
38
|
-
* (`x-stainless-*` / user-agent / anthropic-beta / x-app / CC headers)
|
|
38
|
+
* (`x-stainless-*` / user-agent / anthropic-beta / x-app / CC headers) NEVER
|
|
39
39
|
* `authorization` / `x-api-key` / `cookie` (excluded at capture AND at
|
|
40
|
-
* store-normalize). Additive + OPTIONAL
|
|
40
|
+
* store-normalize). Additive + OPTIONAL an existing `tokens.json` without it
|
|
41
41
|
* parses unchanged (the account re-captures from a real client). Because it is
|
|
42
42
|
* non-secret it lives on the entry OUTSIDE the encrypted `tokens` block and is
|
|
43
43
|
* not walked by the secrets encryptor.
|
|
@@ -65,17 +65,13 @@ type SubscriptionLevel = 'Free' | 'Pro' | 'Max';
|
|
|
65
65
|
*/
|
|
66
66
|
type TokenStatus = 'unconfigured' | 'authorized' | 'configured' | 'expired' | 'error';
|
|
67
67
|
/**
|
|
68
|
-
* Machine-readable
|
|
68
|
+
* Machine-readable managed-account credential warning code.
|
|
69
69
|
*
|
|
70
|
-
* -
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* - `external-not-rotated`: a refresh failed and the external file holds the
|
|
74
|
-
* SAME dead credential — a genuine revocation, re-login is required.
|
|
75
|
-
* - `duplicate-token`: two accounts of one provider share the same credential —
|
|
76
|
-
* refreshing one will invalidate the other (single-use refresh tokens).
|
|
70
|
+
* `duplicate-token` means two managed accounts of one provider share the same
|
|
71
|
+
* credential. Native CLI credential files are not compared by normal account
|
|
72
|
+
* listing or refresh paths.
|
|
77
73
|
*/
|
|
78
|
-
type SyncWarningCode = '
|
|
74
|
+
type SyncWarningCode = 'duplicate-token';
|
|
79
75
|
/**
|
|
80
76
|
* Claude token configuration
|
|
81
77
|
*/
|
|
@@ -91,8 +87,8 @@ type ClaudeTokenConfig = {
|
|
|
91
87
|
setupTokenExpiresAt?: string;
|
|
92
88
|
lastRefreshedAt?: string;
|
|
93
89
|
errorMessage?: string;
|
|
94
|
-
/**
|
|
95
|
-
*
|
|
90
|
+
/** Managed-account credential warning; duplicate-token may be projected on
|
|
91
|
+
* account listing. */
|
|
96
92
|
syncWarning?: SyncWarningCode;
|
|
97
93
|
};
|
|
98
94
|
/**
|
|
@@ -110,8 +106,8 @@ type CodexTokenConfig = {
|
|
|
110
106
|
organizationId?: string;
|
|
111
107
|
lastRefreshedAt?: string;
|
|
112
108
|
errorMessage?: string;
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
109
|
+
/** Managed-account credential warning; duplicate-token may be projected on
|
|
110
|
+
* account listing. */
|
|
115
111
|
syncWarning?: SyncWarningCode;
|
|
116
112
|
};
|
|
117
113
|
/**
|
|
@@ -137,47 +133,53 @@ type GeminiTokenConfig = {
|
|
|
137
133
|
type SubscriptionAccountEntry<TConfig> = {
|
|
138
134
|
/** Stable, generated id (`crypto.randomUUID()`). */
|
|
139
135
|
id: string;
|
|
140
|
-
/** User-supplied label; default "
|
|
136
|
+
/** User-supplied label; default "N" / "Account N". */
|
|
141
137
|
label?: string;
|
|
138
|
+
/** Whether the scheduler may select this account. Absent on legacy rows means true. */
|
|
139
|
+
enabled?: boolean;
|
|
140
|
+
/** Operator-defined account-pool group. Absent rows are presented in their provider group. */
|
|
141
|
+
group?: string;
|
|
142
|
+
/** Searchable operator metadata. Tags are non-secret and normalized on write. */
|
|
143
|
+
tags?: string[];
|
|
142
144
|
/** ISO creation timestamp. */
|
|
143
145
|
createdAt?: string;
|
|
144
146
|
/**
|
|
145
147
|
* Scheduling precedence in the account pool (subscription-account-scheduling).
|
|
146
|
-
* Lower = higher precedence; default `50` when absent
|
|
147
|
-
*
|
|
148
|
+
* Lower = higher precedence; default `50` when absent. OPTIONAL: an existing
|
|
149
|
+
* `tokens.json` without it parses unchanged and
|
|
148
150
|
* every account defaults to 50.
|
|
149
151
|
*/
|
|
150
152
|
priority?: number;
|
|
151
153
|
/**
|
|
152
154
|
* ISO timestamp of the last time this account was selected to serve a request
|
|
153
155
|
* (subscription-account-scheduling LRU tie-break input). OPTIONAL, best-effort
|
|
154
|
-
* throttled persist
|
|
156
|
+
* throttled persist the selector's in-memory overlay is the authoritative live
|
|
155
157
|
* value; an account without it sorts as least-recently-used (timestamp `0`).
|
|
156
158
|
*/
|
|
157
159
|
lastUsedAt?: string;
|
|
158
160
|
/**
|
|
159
161
|
* Per-account upstream proxy override (upstream-proxy). When set, this
|
|
160
162
|
* account's relay + OAuth-refresh traffic is routed through this proxy,
|
|
161
|
-
* WINNING over the per-provider and global proxy layers. OPTIONAL
|
|
162
|
-
* existing `tokens.json` without it parses unchanged (no proxy
|
|
163
|
+
* WINNING over the per-provider and global proxy layers. OPTIONAL an
|
|
164
|
+
* existing `tokens.json` without it parses unchanged (no proxy direct). Its
|
|
163
165
|
* `password` is a secret: encrypted at rest by the tokens `SecretBox` walker
|
|
164
166
|
* and masked in the sanitized view.
|
|
165
167
|
*/
|
|
166
168
|
proxy?: ProxyConfig;
|
|
167
169
|
/**
|
|
168
|
-
* Per-account model support +
|
|
169
|
-
*
|
|
170
|
+
* Per-account model support + logicaltual remap (subscription-account-model-map).
|
|
171
|
+
* Supports both allow-list and logical-to-actual mapping formats. OPTIONAL: an existing `tokens.json` without it parses
|
|
170
172
|
* unchanged (the account supports every model and never remaps, byte-identical
|
|
171
173
|
* to before this change):
|
|
172
|
-
* - **array** `["a","b"]`
|
|
173
|
-
* logical models (skip-only, no remap). In a
|
|
174
|
+
* - **array** `["a","b"]` an ALLOW-LIST: the account supports ONLY these
|
|
175
|
+
* logical models (skip-only, no remap). In a -account pool the account is
|
|
174
176
|
* routed AROUND for any other model.
|
|
175
|
-
* - **object** `{ "a": "X", "b": "Y" }`
|
|
177
|
+
* - **object** `{ "a": "X", "b": "Y" }` the keys are the same allow-list AND
|
|
176
178
|
* each value is the account's ACTUAL upstream model, so a selected account
|
|
177
179
|
* remaps the logical model to its actual model on the outbound request.
|
|
178
180
|
*
|
|
179
|
-
* Model-support filtering only applies when the provider has
|
|
180
|
-
* same gate as account health)
|
|
181
|
+
* Model-support filtering only applies when the provider has accounts (the
|
|
182
|
+
* same gate as account health) a sole account is never model-gated
|
|
181
183
|
* (never-strand; the upstream stays authoritative). A sole account that must
|
|
182
184
|
* serve a logical model AS a different actual model uses the OBJECT map (remap),
|
|
183
185
|
* not skip.
|
|
@@ -186,7 +188,7 @@ type SubscriptionAccountEntry<TConfig> = {
|
|
|
186
188
|
/**
|
|
187
189
|
* Persisted per-account client fingerprint identity (subscription-client-
|
|
188
190
|
* fingerprint #7, P2). OPTIONAL, additive, NON-secret metadata (kept OUTSIDE the
|
|
189
|
-
* encrypted `tokens` block)
|
|
191
|
+
* encrypted `tokens` block) an existing `tokens.json` without it parses
|
|
190
192
|
* unchanged. Written through by the daemon on a first-seen freeze / TTL refresh;
|
|
191
193
|
* seeded back into the in-memory identity store at boot so a claude account's
|
|
192
194
|
* replayed identity survives restart.
|
|
@@ -220,7 +222,7 @@ type AccountTokensConfig = {
|
|
|
220
222
|
};
|
|
221
223
|
/**
|
|
222
224
|
* Secret-free view of a per-account/global/provider proxy (upstream-proxy). The
|
|
223
|
-
* password is NEVER carried
|
|
225
|
+
* password is NEVER carried only a `hasPassword` presence flag plus a
|
|
224
226
|
* display-safe `host:port` endpoint (userinfo stripped). Rendered in the admin
|
|
225
227
|
* accounts view.
|
|
226
228
|
*/
|
|
@@ -241,6 +243,12 @@ type SanitizedProxyConfig = {
|
|
|
241
243
|
type SubscriptionAccountSanitized = {
|
|
242
244
|
id: string;
|
|
243
245
|
label?: string;
|
|
246
|
+
/** Explicit scheduling switch. Legacy rows are projected as enabled. */
|
|
247
|
+
enabled: boolean;
|
|
248
|
+
/** Effective group (provider id when the persisted group is absent). */
|
|
249
|
+
group: string;
|
|
250
|
+
/** Searchable non-secret operator tags. */
|
|
251
|
+
tags: string[];
|
|
244
252
|
status: TokenStatus;
|
|
245
253
|
authMethod?: string;
|
|
246
254
|
subscriptionLevel?: string;
|
|
@@ -249,60 +257,69 @@ type SubscriptionAccountSanitized = {
|
|
|
249
257
|
isSetupToken?: boolean;
|
|
250
258
|
hasAccessToken: boolean;
|
|
251
259
|
isActive: boolean;
|
|
260
|
+
/** Derived current eligibility after operator, live-health, and allowance gates. */
|
|
261
|
+
schedulable: boolean;
|
|
262
|
+
/** Read-only allowance policy projection. Absent on older daemons. */
|
|
263
|
+
allowanceAction?: 'normal' | 'demote' | 'pause' | 'ignore';
|
|
264
|
+
/** Priority after the allowance policy's optional demotion penalty. */
|
|
265
|
+
allowanceEffectivePriority?: number;
|
|
266
|
+
/** Highest fresh allowance-window consumption used for this decision. */
|
|
267
|
+
allowanceUsedPercent?: number;
|
|
268
|
+
/** Known reset/deadline associated with the allowance decision. */
|
|
269
|
+
allowanceResumeAt?: string;
|
|
270
|
+
/** Redacted and bounded credential diagnostic, when the provider recorded one. */
|
|
271
|
+
errorMessage?: string;
|
|
252
272
|
/**
|
|
253
|
-
* Scheduling precedence (subscription-account-scheduling)
|
|
254
|
-
* admin accounts view so an operator can order a pool. Absent
|
|
273
|
+
* Scheduling precedence (subscription-account-scheduling) editable in the
|
|
274
|
+
* admin accounts view so an operator can order a pool. Absent default 50.
|
|
255
275
|
*/
|
|
256
276
|
priority?: number;
|
|
257
277
|
/**
|
|
258
278
|
* ISO timestamp of the last scheduler selection (display-only in the admin
|
|
259
|
-
* accounts view). Absent
|
|
279
|
+
* accounts view). Absent never selected (or the best-effort persist has not
|
|
260
280
|
* yet flushed).
|
|
261
281
|
*/
|
|
262
282
|
lastUsedAt?: string;
|
|
263
283
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* list-time computed codes (`external-divergent` / `duplicate-token`).
|
|
284
|
+
* Managed-account credential warning. The daemon retains duplicate-token
|
|
285
|
+
* warnings without consulting native CLI credential files.
|
|
267
286
|
*/
|
|
268
287
|
syncWarning?: SyncWarningCode;
|
|
269
288
|
/**
|
|
270
|
-
* Live scheduling-health state (subscription-account-health)
|
|
271
|
-
* persisted. Absent / `'healthy'`
|
|
289
|
+
* Live scheduling-health state (subscription-account-health) in-memory, never
|
|
290
|
+
* persisted. Absent / `'healthy'` eligible; the rest mean the account is
|
|
272
291
|
* currently excluded from the pool (multi-account) or would surface the
|
|
273
292
|
* upstream's error (single-account). Secret-free.
|
|
274
293
|
*/
|
|
275
|
-
health?: 'healthy' | 'rate_limited' | 'overloaded' | 'transient' | 'blocked';
|
|
294
|
+
health?: 'healthy' | 'rate_limited' | 'overloaded' | 'transient' | 'quota_exhausted' | 'blocked';
|
|
276
295
|
/**
|
|
277
296
|
* ISO instant the current health cooldown elapses (absent for healthy /
|
|
278
|
-
* permanently-blocked). Lets the admin view render "rate-limited until
|
|
297
|
+
* permanently-blocked). Lets the admin view render "rate-limited until .
|
|
279
298
|
*/
|
|
280
299
|
cooldownUntil?: string;
|
|
281
300
|
/**
|
|
282
|
-
* Secret-free view of this account's proxy override (upstream-proxy). Absent
|
|
283
|
-
*
|
|
284
|
-
* flag — never returned.
|
|
301
|
+
* Secret-free view of this account's proxy override (upstream-proxy). Absent * no per-account proxy configured. The password is masked to a `hasPassword`
|
|
302
|
+
* flag never returned.
|
|
285
303
|
*/
|
|
286
304
|
proxy?: SanitizedProxyConfig;
|
|
287
305
|
/**
|
|
288
|
-
* Per-account model support /
|
|
289
|
-
*
|
|
290
|
-
* ids are not token material): an array allow-list or an object
|
|
291
|
-
* map. Absent
|
|
306
|
+
* Per-account model support / logicaltual remap (subscription-account-model-map)
|
|
307
|
+
* editable in the admin accounts view. Carried verbatim (secret-free model
|
|
308
|
+
* ids are not token material): an array allow-list or an object logicaltual
|
|
309
|
+
* map. Absent the account supports every model with no remap.
|
|
292
310
|
*/
|
|
293
311
|
supportedModels?: string[] | Record<string, string>;
|
|
294
312
|
/**
|
|
295
|
-
* COARSE client-fingerprint status (subscription-client-fingerprint #7, D7)
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* shows nothing). Secret-free by construction: it is a BOOLEAN only — the raw
|
|
313
|
+
* COARSE client-fingerprint status (subscription-client-fingerprint #7, D7) * whether THIS account has a captured/frozen client identity in the in-memory
|
|
314
|
+
* store. Present only when fingerprint replay is ENABLED (else absent the UI
|
|
315
|
+
* shows nothing). Secret-free by construction: it is a BOOLEAN only the raw
|
|
299
316
|
* captured headers are NEVER surfaced here (nor in any admin view).
|
|
300
317
|
*/
|
|
301
318
|
identityCaptured?: boolean;
|
|
302
319
|
/**
|
|
303
320
|
* ISO instant this account's fingerprint identity was frozen / last TTL-refreshed
|
|
304
321
|
* (subscription-client-fingerprint #7, D7). Present only alongside
|
|
305
|
-
* `identityCaptured === true`. Coarse timestamp only
|
|
322
|
+
* `identityCaptured === true`. Coarse timestamp only never the headers.
|
|
306
323
|
*/
|
|
307
324
|
identityCapturedAt?: string;
|
|
308
325
|
};
|
|
@@ -12,13 +12,13 @@ import { OpenCodeGoTokenConfig } from './subscription-types.js';
|
|
|
12
12
|
/**
|
|
13
13
|
* Upstream proxy descriptor (upstream-proxy). Routes an outbound upstream call
|
|
14
14
|
* through an http/https or socks5 proxy. Two interchangeable shapes:
|
|
15
|
-
* - `{ url }`
|
|
15
|
+
* - `{ url }` a full proxy URL, e.g. `http://user:pass@host:1080` or
|
|
16
16
|
* `socks5://host:1080` (userinfo carries basic-auth).
|
|
17
|
-
* - structured
|
|
17
|
+
* - structured an explicit `{ type, host, port, username, password }`.
|
|
18
18
|
*
|
|
19
19
|
* `username`/`password` are SECRETS: encrypted at rest via the same envelope as
|
|
20
20
|
* other credentials, masked in every sanitized/admin view, and never logged
|
|
21
|
-
* (logs carry at most `host:port`). Additive everywhere it appears
|
|
21
|
+
* (logs carry at most `host:port`). Additive everywhere it appears absent a
|
|
22
22
|
* direct (non-proxied) call, byte-identical to before proxy support.
|
|
23
23
|
*/
|
|
24
24
|
type ProxyConfig = {
|
|
@@ -35,9 +35,9 @@ type ProxyConfig = {
|
|
|
35
35
|
* The frozen fingerprint headers a real Claude Code client sent for this account,
|
|
36
36
|
* captured + replayed so relayed traffic presents a stable identity across
|
|
37
37
|
* restarts. NON-secret metadata: it holds ONLY whitelisted fingerprint headers
|
|
38
|
-
* (`x-stainless-*` / user-agent / anthropic-beta / x-app / CC headers)
|
|
38
|
+
* (`x-stainless-*` / user-agent / anthropic-beta / x-app / CC headers) NEVER
|
|
39
39
|
* `authorization` / `x-api-key` / `cookie` (excluded at capture AND at
|
|
40
|
-
* store-normalize). Additive + OPTIONAL
|
|
40
|
+
* store-normalize). Additive + OPTIONAL an existing `tokens.json` without it
|
|
41
41
|
* parses unchanged (the account re-captures from a real client). Because it is
|
|
42
42
|
* non-secret it lives on the entry OUTSIDE the encrypted `tokens` block and is
|
|
43
43
|
* not walked by the secrets encryptor.
|
|
@@ -65,17 +65,13 @@ type SubscriptionLevel = 'Free' | 'Pro' | 'Max';
|
|
|
65
65
|
*/
|
|
66
66
|
type TokenStatus = 'unconfigured' | 'authorized' | 'configured' | 'expired' | 'error';
|
|
67
67
|
/**
|
|
68
|
-
* Machine-readable
|
|
68
|
+
* Machine-readable managed-account credential warning code.
|
|
69
69
|
*
|
|
70
|
-
* -
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* - `external-not-rotated`: a refresh failed and the external file holds the
|
|
74
|
-
* SAME dead credential — a genuine revocation, re-login is required.
|
|
75
|
-
* - `duplicate-token`: two accounts of one provider share the same credential —
|
|
76
|
-
* refreshing one will invalidate the other (single-use refresh tokens).
|
|
70
|
+
* `duplicate-token` means two managed accounts of one provider share the same
|
|
71
|
+
* credential. Native CLI credential files are not compared by normal account
|
|
72
|
+
* listing or refresh paths.
|
|
77
73
|
*/
|
|
78
|
-
type SyncWarningCode = '
|
|
74
|
+
type SyncWarningCode = 'duplicate-token';
|
|
79
75
|
/**
|
|
80
76
|
* Claude token configuration
|
|
81
77
|
*/
|
|
@@ -91,8 +87,8 @@ type ClaudeTokenConfig = {
|
|
|
91
87
|
setupTokenExpiresAt?: string;
|
|
92
88
|
lastRefreshedAt?: string;
|
|
93
89
|
errorMessage?: string;
|
|
94
|
-
/**
|
|
95
|
-
*
|
|
90
|
+
/** Managed-account credential warning; duplicate-token may be projected on
|
|
91
|
+
* account listing. */
|
|
96
92
|
syncWarning?: SyncWarningCode;
|
|
97
93
|
};
|
|
98
94
|
/**
|
|
@@ -110,8 +106,8 @@ type CodexTokenConfig = {
|
|
|
110
106
|
organizationId?: string;
|
|
111
107
|
lastRefreshedAt?: string;
|
|
112
108
|
errorMessage?: string;
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
109
|
+
/** Managed-account credential warning; duplicate-token may be projected on
|
|
110
|
+
* account listing. */
|
|
115
111
|
syncWarning?: SyncWarningCode;
|
|
116
112
|
};
|
|
117
113
|
/**
|
|
@@ -137,47 +133,53 @@ type GeminiTokenConfig = {
|
|
|
137
133
|
type SubscriptionAccountEntry<TConfig> = {
|
|
138
134
|
/** Stable, generated id (`crypto.randomUUID()`). */
|
|
139
135
|
id: string;
|
|
140
|
-
/** User-supplied label; default "
|
|
136
|
+
/** User-supplied label; default "N" / "Account N". */
|
|
141
137
|
label?: string;
|
|
138
|
+
/** Whether the scheduler may select this account. Absent on legacy rows means true. */
|
|
139
|
+
enabled?: boolean;
|
|
140
|
+
/** Operator-defined account-pool group. Absent rows are presented in their provider group. */
|
|
141
|
+
group?: string;
|
|
142
|
+
/** Searchable operator metadata. Tags are non-secret and normalized on write. */
|
|
143
|
+
tags?: string[];
|
|
142
144
|
/** ISO creation timestamp. */
|
|
143
145
|
createdAt?: string;
|
|
144
146
|
/**
|
|
145
147
|
* Scheduling precedence in the account pool (subscription-account-scheduling).
|
|
146
|
-
* Lower = higher precedence; default `50` when absent
|
|
147
|
-
*
|
|
148
|
+
* Lower = higher precedence; default `50` when absent. OPTIONAL: an existing
|
|
149
|
+
* `tokens.json` without it parses unchanged and
|
|
148
150
|
* every account defaults to 50.
|
|
149
151
|
*/
|
|
150
152
|
priority?: number;
|
|
151
153
|
/**
|
|
152
154
|
* ISO timestamp of the last time this account was selected to serve a request
|
|
153
155
|
* (subscription-account-scheduling LRU tie-break input). OPTIONAL, best-effort
|
|
154
|
-
* throttled persist
|
|
156
|
+
* throttled persist the selector's in-memory overlay is the authoritative live
|
|
155
157
|
* value; an account without it sorts as least-recently-used (timestamp `0`).
|
|
156
158
|
*/
|
|
157
159
|
lastUsedAt?: string;
|
|
158
160
|
/**
|
|
159
161
|
* Per-account upstream proxy override (upstream-proxy). When set, this
|
|
160
162
|
* account's relay + OAuth-refresh traffic is routed through this proxy,
|
|
161
|
-
* WINNING over the per-provider and global proxy layers. OPTIONAL
|
|
162
|
-
* existing `tokens.json` without it parses unchanged (no proxy
|
|
163
|
+
* WINNING over the per-provider and global proxy layers. OPTIONAL an
|
|
164
|
+
* existing `tokens.json` without it parses unchanged (no proxy direct). Its
|
|
163
165
|
* `password` is a secret: encrypted at rest by the tokens `SecretBox` walker
|
|
164
166
|
* and masked in the sanitized view.
|
|
165
167
|
*/
|
|
166
168
|
proxy?: ProxyConfig;
|
|
167
169
|
/**
|
|
168
|
-
* Per-account model support +
|
|
169
|
-
*
|
|
170
|
+
* Per-account model support + logicaltual remap (subscription-account-model-map).
|
|
171
|
+
* Supports both allow-list and logical-to-actual mapping formats. OPTIONAL: an existing `tokens.json` without it parses
|
|
170
172
|
* unchanged (the account supports every model and never remaps, byte-identical
|
|
171
173
|
* to before this change):
|
|
172
|
-
* - **array** `["a","b"]`
|
|
173
|
-
* logical models (skip-only, no remap). In a
|
|
174
|
+
* - **array** `["a","b"]` an ALLOW-LIST: the account supports ONLY these
|
|
175
|
+
* logical models (skip-only, no remap). In a -account pool the account is
|
|
174
176
|
* routed AROUND for any other model.
|
|
175
|
-
* - **object** `{ "a": "X", "b": "Y" }`
|
|
177
|
+
* - **object** `{ "a": "X", "b": "Y" }` the keys are the same allow-list AND
|
|
176
178
|
* each value is the account's ACTUAL upstream model, so a selected account
|
|
177
179
|
* remaps the logical model to its actual model on the outbound request.
|
|
178
180
|
*
|
|
179
|
-
* Model-support filtering only applies when the provider has
|
|
180
|
-
* same gate as account health)
|
|
181
|
+
* Model-support filtering only applies when the provider has accounts (the
|
|
182
|
+
* same gate as account health) a sole account is never model-gated
|
|
181
183
|
* (never-strand; the upstream stays authoritative). A sole account that must
|
|
182
184
|
* serve a logical model AS a different actual model uses the OBJECT map (remap),
|
|
183
185
|
* not skip.
|
|
@@ -186,7 +188,7 @@ type SubscriptionAccountEntry<TConfig> = {
|
|
|
186
188
|
/**
|
|
187
189
|
* Persisted per-account client fingerprint identity (subscription-client-
|
|
188
190
|
* fingerprint #7, P2). OPTIONAL, additive, NON-secret metadata (kept OUTSIDE the
|
|
189
|
-
* encrypted `tokens` block)
|
|
191
|
+
* encrypted `tokens` block) an existing `tokens.json` without it parses
|
|
190
192
|
* unchanged. Written through by the daemon on a first-seen freeze / TTL refresh;
|
|
191
193
|
* seeded back into the in-memory identity store at boot so a claude account's
|
|
192
194
|
* replayed identity survives restart.
|
|
@@ -220,7 +222,7 @@ type AccountTokensConfig = {
|
|
|
220
222
|
};
|
|
221
223
|
/**
|
|
222
224
|
* Secret-free view of a per-account/global/provider proxy (upstream-proxy). The
|
|
223
|
-
* password is NEVER carried
|
|
225
|
+
* password is NEVER carried only a `hasPassword` presence flag plus a
|
|
224
226
|
* display-safe `host:port` endpoint (userinfo stripped). Rendered in the admin
|
|
225
227
|
* accounts view.
|
|
226
228
|
*/
|
|
@@ -241,6 +243,12 @@ type SanitizedProxyConfig = {
|
|
|
241
243
|
type SubscriptionAccountSanitized = {
|
|
242
244
|
id: string;
|
|
243
245
|
label?: string;
|
|
246
|
+
/** Explicit scheduling switch. Legacy rows are projected as enabled. */
|
|
247
|
+
enabled: boolean;
|
|
248
|
+
/** Effective group (provider id when the persisted group is absent). */
|
|
249
|
+
group: string;
|
|
250
|
+
/** Searchable non-secret operator tags. */
|
|
251
|
+
tags: string[];
|
|
244
252
|
status: TokenStatus;
|
|
245
253
|
authMethod?: string;
|
|
246
254
|
subscriptionLevel?: string;
|
|
@@ -249,60 +257,69 @@ type SubscriptionAccountSanitized = {
|
|
|
249
257
|
isSetupToken?: boolean;
|
|
250
258
|
hasAccessToken: boolean;
|
|
251
259
|
isActive: boolean;
|
|
260
|
+
/** Derived current eligibility after operator, live-health, and allowance gates. */
|
|
261
|
+
schedulable: boolean;
|
|
262
|
+
/** Read-only allowance policy projection. Absent on older daemons. */
|
|
263
|
+
allowanceAction?: 'normal' | 'demote' | 'pause' | 'ignore';
|
|
264
|
+
/** Priority after the allowance policy's optional demotion penalty. */
|
|
265
|
+
allowanceEffectivePriority?: number;
|
|
266
|
+
/** Highest fresh allowance-window consumption used for this decision. */
|
|
267
|
+
allowanceUsedPercent?: number;
|
|
268
|
+
/** Known reset/deadline associated with the allowance decision. */
|
|
269
|
+
allowanceResumeAt?: string;
|
|
270
|
+
/** Redacted and bounded credential diagnostic, when the provider recorded one. */
|
|
271
|
+
errorMessage?: string;
|
|
252
272
|
/**
|
|
253
|
-
* Scheduling precedence (subscription-account-scheduling)
|
|
254
|
-
* admin accounts view so an operator can order a pool. Absent
|
|
273
|
+
* Scheduling precedence (subscription-account-scheduling) editable in the
|
|
274
|
+
* admin accounts view so an operator can order a pool. Absent default 50.
|
|
255
275
|
*/
|
|
256
276
|
priority?: number;
|
|
257
277
|
/**
|
|
258
278
|
* ISO timestamp of the last scheduler selection (display-only in the admin
|
|
259
|
-
* accounts view). Absent
|
|
279
|
+
* accounts view). Absent never selected (or the best-effort persist has not
|
|
260
280
|
* yet flushed).
|
|
261
281
|
*/
|
|
262
282
|
lastUsedAt?: string;
|
|
263
283
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* list-time computed codes (`external-divergent` / `duplicate-token`).
|
|
284
|
+
* Managed-account credential warning. The daemon retains duplicate-token
|
|
285
|
+
* warnings without consulting native CLI credential files.
|
|
267
286
|
*/
|
|
268
287
|
syncWarning?: SyncWarningCode;
|
|
269
288
|
/**
|
|
270
|
-
* Live scheduling-health state (subscription-account-health)
|
|
271
|
-
* persisted. Absent / `'healthy'`
|
|
289
|
+
* Live scheduling-health state (subscription-account-health) in-memory, never
|
|
290
|
+
* persisted. Absent / `'healthy'` eligible; the rest mean the account is
|
|
272
291
|
* currently excluded from the pool (multi-account) or would surface the
|
|
273
292
|
* upstream's error (single-account). Secret-free.
|
|
274
293
|
*/
|
|
275
|
-
health?: 'healthy' | 'rate_limited' | 'overloaded' | 'transient' | 'blocked';
|
|
294
|
+
health?: 'healthy' | 'rate_limited' | 'overloaded' | 'transient' | 'quota_exhausted' | 'blocked';
|
|
276
295
|
/**
|
|
277
296
|
* ISO instant the current health cooldown elapses (absent for healthy /
|
|
278
|
-
* permanently-blocked). Lets the admin view render "rate-limited until
|
|
297
|
+
* permanently-blocked). Lets the admin view render "rate-limited until .
|
|
279
298
|
*/
|
|
280
299
|
cooldownUntil?: string;
|
|
281
300
|
/**
|
|
282
|
-
* Secret-free view of this account's proxy override (upstream-proxy). Absent
|
|
283
|
-
*
|
|
284
|
-
* flag — never returned.
|
|
301
|
+
* Secret-free view of this account's proxy override (upstream-proxy). Absent * no per-account proxy configured. The password is masked to a `hasPassword`
|
|
302
|
+
* flag never returned.
|
|
285
303
|
*/
|
|
286
304
|
proxy?: SanitizedProxyConfig;
|
|
287
305
|
/**
|
|
288
|
-
* Per-account model support /
|
|
289
|
-
*
|
|
290
|
-
* ids are not token material): an array allow-list or an object
|
|
291
|
-
* map. Absent
|
|
306
|
+
* Per-account model support / logicaltual remap (subscription-account-model-map)
|
|
307
|
+
* editable in the admin accounts view. Carried verbatim (secret-free model
|
|
308
|
+
* ids are not token material): an array allow-list or an object logicaltual
|
|
309
|
+
* map. Absent the account supports every model with no remap.
|
|
292
310
|
*/
|
|
293
311
|
supportedModels?: string[] | Record<string, string>;
|
|
294
312
|
/**
|
|
295
|
-
* COARSE client-fingerprint status (subscription-client-fingerprint #7, D7)
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* shows nothing). Secret-free by construction: it is a BOOLEAN only — the raw
|
|
313
|
+
* COARSE client-fingerprint status (subscription-client-fingerprint #7, D7) * whether THIS account has a captured/frozen client identity in the in-memory
|
|
314
|
+
* store. Present only when fingerprint replay is ENABLED (else absent the UI
|
|
315
|
+
* shows nothing). Secret-free by construction: it is a BOOLEAN only the raw
|
|
299
316
|
* captured headers are NEVER surfaced here (nor in any admin view).
|
|
300
317
|
*/
|
|
301
318
|
identityCaptured?: boolean;
|
|
302
319
|
/**
|
|
303
320
|
* ISO instant this account's fingerprint identity was frozen / last TTL-refreshed
|
|
304
321
|
* (subscription-client-fingerprint #7, D7). Present only alongside
|
|
305
|
-
* `identityCaptured === true`. Coarse timestamp only
|
|
322
|
+
* `identityCaptured === true`. Coarse timestamp only never the headers.
|
|
306
323
|
*/
|
|
307
324
|
identityCapturedAt?: string;
|
|
308
325
|
};
|
package/dist/audit-types.cjs
CHANGED
package/dist/audit-types.d.cts
CHANGED
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
/**
|
|
20
20
|
* One per-request audit entry (design D1). The metadata fields are recorded
|
|
21
21
|
* whenever audit is `enabled`; the two body snapshots are present ONLY when
|
|
22
|
-
* `captureBodies` is ALSO on, and always after truncation + redaction.
|
|
23
|
-
* ever holds key material, an upstream token, or an
|
|
22
|
+
* `captureBodies` is ALSO on, and always after optional truncation + redaction.
|
|
23
|
+
* NO field ever holds key material, an upstream token, or an
|
|
24
|
+
* Authorization/api-key header.
|
|
24
25
|
*/
|
|
25
26
|
interface AuditRecord {
|
|
26
27
|
/** Unique record id (a generated request id — NOT any secret). */
|
|
@@ -54,14 +55,13 @@ interface AuditRecord {
|
|
|
54
55
|
/** Sanitized error message (present only on a failed relay). */
|
|
55
56
|
error?: string;
|
|
56
57
|
/**
|
|
57
|
-
* Request body snapshot — present ONLY when `captureBodies`,
|
|
58
|
-
* configured cap, and ALWAYS run through
|
|
58
|
+
* Request body snapshot — present ONLY when `captureBodies`, optionally
|
|
59
|
+
* truncated to the configured cap, and ALWAYS run through secret redaction.
|
|
59
60
|
*/
|
|
60
61
|
requestBody?: string;
|
|
61
62
|
/**
|
|
62
|
-
* Response body snapshot — present ONLY when `captureBodies
|
|
63
|
-
*
|
|
64
|
-
* redacted like `requestBody`.
|
|
63
|
+
* Response body snapshot — present ONLY when `captureBodies`; streaming
|
|
64
|
+
* responses are included. Optionally truncated + redacted like `requestBody`.
|
|
65
65
|
*/
|
|
66
66
|
responseBody?: string;
|
|
67
67
|
}
|
|
@@ -74,9 +74,9 @@ interface AuditRecord {
|
|
|
74
74
|
interface AuditConfig {
|
|
75
75
|
/** Master switch; default FALSE (zero regression). */
|
|
76
76
|
enabled: boolean;
|
|
77
|
-
/** Capture request/response bodies too (redacted
|
|
77
|
+
/** Capture request/response bodies too (redacted and optionally truncated); default FALSE. */
|
|
78
78
|
captureBodies: boolean;
|
|
79
|
-
/** Per-body truncation cap in bytes; default
|
|
79
|
+
/** Per-body truncation cap in bytes. `-1` disables truncation; default `-1`. */
|
|
80
80
|
maxBodyBytes: number;
|
|
81
81
|
/** TTL retention in days; default 7, clamped `[1, 365]`. */
|
|
82
82
|
retentionDays: number;
|
|
@@ -94,5 +94,12 @@ declare const DEFAULT_AUDIT_CONFIG: AuditConfig;
|
|
|
94
94
|
interface AuditQueryResult {
|
|
95
95
|
records: AuditRecord[];
|
|
96
96
|
}
|
|
97
|
+
/** Metadata-only aggregate for an audit time window (body payloads are never returned). */
|
|
98
|
+
interface AuditStats {
|
|
99
|
+
requestCount: number;
|
|
100
|
+
errorCount: number;
|
|
101
|
+
/** False when the store could not produce an exact aggregate. */
|
|
102
|
+
complete: boolean;
|
|
103
|
+
}
|
|
97
104
|
|
|
98
|
-
export { type AuditConfig, type AuditQueryResult, type AuditRecord, DEFAULT_AUDIT_CONFIG };
|
|
105
|
+
export { type AuditConfig, type AuditQueryResult, type AuditRecord, type AuditStats, DEFAULT_AUDIT_CONFIG };
|