@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.
@@ -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 }` a full proxy URL, e.g. `http://user:pass@host:1080` or
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 an explicit `{ type, host, port, username?, password? }`.
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 absent a
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) NEVER
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 an existing `tokens.json` without it
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 credential-sync warning code (external-cli-sync).
68
+ * Machine-readable managed-account credential warning code.
69
69
  *
70
- * - `external-divergent`: the external CLI's native credential file (e.g.
71
- * `~/.claude/.credentials.json`) holds a DIFFERENT, fresher credential than
72
- * the stored account — the stored refresh token may have been rotated out.
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 = 'external-divergent' | 'external-not-rotated' | 'duplicate-token';
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
- /** Persisted credential-sync warning (external-cli-sync); cleared on a
95
- * successful refresh / import. */
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
- /** Persisted credential-sync warning (external-cli-sync); cleared on a
114
- * successful refresh / import. */
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 "账号 N" / "Account N". */
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 (CRS `parseInt(x,10) || 50`
147
- * parity). OPTIONAL — an existing `tokens.json` without it parses unchanged and
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 the selector's in-memory overlay is the authoritative live
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 an
162
- * existing `tokens.json` without it parses unchanged (no proxy direct). Its
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 + logical→actual remap (subscription-account-model-map).
169
- * CRS dual-format, OPTIONAL an existing `tokens.json` without it parses
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"]` an ALLOW-LIST: the account supports ONLY these
173
- * logical models (skip-only, no remap). In a ≥2-account pool the account is
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" }` the keys are the same allow-list AND
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 ≥2 accounts (the
180
- * same gate as account health) a sole account is never model-gated
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) an existing `tokens.json` without it parses
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 only a `hasPassword` presence flag plus a
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) editable in the
254
- * admin accounts view so an operator can order a pool. Absent default 50.
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 never selected (or the best-effort persist has not
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
- * Credential-sync warning for this account (external-cli-sync). Carries the
265
- * persisted code when one was recorded by a failed refresh, plus the
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) in-memory, never
271
- * persisted. Absent / `'healthy'` eligible; the rest mean the account is
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
- * no per-account proxy configured. The password is masked to a `hasPassword`
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 / logical→actual remap (subscription-account-model-map)
289
- * editable in the admin accounts view. Carried verbatim (secret-free model
290
- * ids are not token material): an array allow-list or an object logical→actual
291
- * map. Absent the account supports every model with no remap.
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
- * whether THIS account has a captured/frozen client identity in the in-memory
297
- * store. Present only when fingerprint replay is ENABLED (else absent the UI
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 never the headers.
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 }` a full proxy URL, e.g. `http://user:pass@host:1080` or
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 an explicit `{ type, host, port, username?, password? }`.
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 absent a
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) NEVER
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 an existing `tokens.json` without it
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 credential-sync warning code (external-cli-sync).
68
+ * Machine-readable managed-account credential warning code.
69
69
  *
70
- * - `external-divergent`: the external CLI's native credential file (e.g.
71
- * `~/.claude/.credentials.json`) holds a DIFFERENT, fresher credential than
72
- * the stored account — the stored refresh token may have been rotated out.
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 = 'external-divergent' | 'external-not-rotated' | 'duplicate-token';
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
- /** Persisted credential-sync warning (external-cli-sync); cleared on a
95
- * successful refresh / import. */
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
- /** Persisted credential-sync warning (external-cli-sync); cleared on a
114
- * successful refresh / import. */
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 "账号 N" / "Account N". */
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 (CRS `parseInt(x,10) || 50`
147
- * parity). OPTIONAL — an existing `tokens.json` without it parses unchanged and
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 the selector's in-memory overlay is the authoritative live
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 an
162
- * existing `tokens.json` without it parses unchanged (no proxy direct). Its
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 + logical→actual remap (subscription-account-model-map).
169
- * CRS dual-format, OPTIONAL an existing `tokens.json` without it parses
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"]` an ALLOW-LIST: the account supports ONLY these
173
- * logical models (skip-only, no remap). In a ≥2-account pool the account is
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" }` the keys are the same allow-list AND
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 ≥2 accounts (the
180
- * same gate as account health) a sole account is never model-gated
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) an existing `tokens.json` without it parses
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 only a `hasPassword` presence flag plus a
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) editable in the
254
- * admin accounts view so an operator can order a pool. Absent default 50.
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 never selected (or the best-effort persist has not
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
- * Credential-sync warning for this account (external-cli-sync). Carries the
265
- * persisted code when one was recorded by a failed refresh, plus the
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) in-memory, never
271
- * persisted. Absent / `'healthy'` eligible; the rest mean the account is
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
- * no per-account proxy configured. The password is masked to a `hasPassword`
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 / logical→actual remap (subscription-account-model-map)
289
- * editable in the admin accounts view. Carried verbatim (secret-free model
290
- * ids are not token material): an array allow-list or an object logical→actual
291
- * map. Absent the account supports every model with no remap.
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
- * whether THIS account has a captured/frozen client identity in the in-memory
297
- * store. Present only when fingerprint replay is ENABLED (else absent the UI
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 never the headers.
322
+ * `identityCaptured === true`. Coarse timestamp only never the headers.
306
323
  */
307
324
  identityCapturedAt?: string;
308
325
  };
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(audit_types_exports);
26
26
  var DEFAULT_AUDIT_CONFIG = {
27
27
  enabled: false,
28
28
  captureBodies: false,
29
- maxBodyBytes: 8192,
29
+ maxBodyBytes: -1,
30
30
  retentionDays: 7,
31
31
  trustForwardedFor: false
32
32
  };
@@ -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. NO field
23
- * ever holds key material, an upstream token, or an Authorization/api-key header.
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`, truncated to the
58
- * configured cap, and ALWAYS run through the secret-redaction pass first.
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` AND the response
63
- * was NON-streaming (a streaming response records metadata only), truncated +
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+truncated); default FALSE. */
77
+ /** Capture request/response bodies too (redacted and optionally truncated); default FALSE. */
78
78
  captureBodies: boolean;
79
- /** Per-body truncation cap in bytes; default 8192, clamped. */
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 };