@omnicross/core 0.1.6 → 0.1.8
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/ApiConverter.cjs +2 -2
- package/dist/ApiConverter.js +1 -1
- package/dist/{ProviderProxy-C-xqrkKi.d.ts → ProviderProxy--ROec6VI.d.ts} +22 -3
- package/dist/{ProviderProxy-CnMQYN59.d.cts → ProviderProxy-QdwNV6l1.d.cts} +22 -3
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +4 -3
- package/dist/auth/GeminiCodeAssistProjectResolver.js +3 -2
- package/dist/{chunk-3Z5BQZFM.cjs → chunk-235MXAGX.cjs} +3 -1
- package/dist/{chunk-SQYVORNP.cjs → chunk-26K6T2YS.cjs} +1520 -523
- package/dist/{chunk-DLXZEZWO.cjs → chunk-2E42SAW3.cjs} +42 -4
- package/dist/{chunk-7AK7B36B.cjs → chunk-2Z4XM3H5.cjs} +6 -6
- package/dist/{chunk-OEWZUX4G.js → chunk-32O35CIF.js} +9 -20
- package/dist/chunk-3SCOLIPT.cjs +63 -0
- package/dist/{chunk-SYQF7OIR.js → chunk-3WD4HTR2.js} +2 -0
- package/dist/{chunk-AT7B7SOZ.js → chunk-5NJLQ6T6.js} +21 -10
- package/dist/chunk-5RSZYQJH.cjs +62 -0
- package/dist/{chunk-IFXJ2BG7.js → chunk-7C7DET6S.js} +51 -6
- package/dist/{chunk-SNYBEXLB.cjs → chunk-EPN67EGP.cjs} +6 -1
- package/dist/chunk-FU7EAR73.js +62 -0
- package/dist/{chunk-UX7VWA46.js → chunk-FXR6N3SR.js} +39 -1
- package/dist/{chunk-WYTEQ4Q5.cjs → chunk-GDIXXKF2.cjs} +21 -10
- package/dist/{chunk-WB6PH56J.js → chunk-GFIZ6LQI.js} +12 -8
- package/dist/chunk-GL6XM527.js +61 -0
- package/dist/{chunk-EJLH6NFT.cjs → chunk-J3QQ6JS5.cjs} +12 -8
- package/dist/{chunk-VRFBB5DB.js → chunk-MYYR3HZL.js} +4 -4
- package/dist/{chunk-YJVHCHQX.js → chunk-N7OOJI5V.js} +46 -2
- package/dist/chunk-NKVZ6Z3Y.cjs +61 -0
- package/dist/chunk-OTZC4TNH.cjs +79 -0
- package/dist/{chunk-6VUQPOV3.cjs → chunk-OVQBNVSV.cjs} +10 -21
- package/dist/{chunk-4VLRHHFE.cjs → chunk-OXHNSZ53.cjs} +9 -11
- package/dist/{chunk-6CL5HTPQ.js → chunk-PEGTIPB3.js} +8 -10
- package/dist/chunk-PO3XB56Z.js +79 -0
- package/dist/{chunk-UDCC7EMR.js → chunk-QYC54PMG.js} +1242 -245
- package/dist/{chunk-SIZQQD6T.js → chunk-RJ5ZGNI3.js} +42 -5
- package/dist/{chunk-KCVJWJST.cjs → chunk-RJUONLUQ.cjs} +47 -10
- package/dist/{chunk-BPKCU575.js → chunk-UAPBLNN2.js} +6 -1
- package/dist/{chunk-UNWKG6EI.cjs → chunk-XPIOJQS2.cjs} +51 -6
- package/dist/chunk-XXFYLL7R.js +63 -0
- package/dist/{chunk-YK57NMIF.cjs → chunk-YWL7YZWS.cjs} +47 -3
- package/dist/completion/ApiKeyPoolService.cjs +32 -1
- package/dist/completion/ApiKeyPoolService.d.cts +17 -1
- package/dist/completion/ApiKeyPoolService.d.ts +17 -1
- package/dist/completion/ApiKeyPoolService.js +31 -0
- package/dist/completion/CompletionService.cjs +23 -19
- package/dist/completion/CompletionService.d.cts +1 -0
- package/dist/completion/CompletionService.d.ts +1 -0
- package/dist/completion/CompletionService.js +22 -18
- package/dist/completion.cjs +23 -19
- package/dist/completion.d.cts +1 -0
- package/dist/completion.d.ts +1 -0
- package/dist/completion.js +22 -18
- package/dist/index.cjs +81 -21
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +82 -22
- package/dist/outbound-api/auditCapture.cjs +2 -2
- package/dist/outbound-api/auditCapture.d.cts +3 -4
- package/dist/outbound-api/auditCapture.d.ts +3 -4
- package/dist/outbound-api/auditCapture.js +1 -1
- package/dist/outbound-api/routeResolver.d.cts +4 -3
- package/dist/outbound-api/routeResolver.d.ts +4 -3
- package/dist/outbound-api/subscriptionRegistryPort.d.cts +1 -0
- package/dist/outbound-api/subscriptionRegistryPort.d.ts +1 -0
- package/dist/outbound-api/types.d.cts +3 -2
- package/dist/outbound-api/types.d.ts +3 -2
- package/dist/outbound-api.cjs +23 -19
- package/dist/outbound-api.d.cts +8 -6
- package/dist/outbound-api.d.ts +8 -6
- package/dist/outbound-api.js +22 -18
- package/dist/pipeline/AccountAllowanceScheduling.d.cts +3 -2
- package/dist/pipeline/AccountAllowanceScheduling.d.ts +3 -2
- package/dist/pipeline/AccountRouteActivity.cjs +10 -0
- package/dist/pipeline/AccountRouteActivity.d.cts +61 -0
- package/dist/pipeline/AccountRouteActivity.d.ts +61 -0
- package/dist/pipeline/AccountRouteActivity.js +10 -0
- package/dist/pipeline/ServerOverloadCounter.cjs +16 -0
- package/dist/pipeline/ServerOverloadCounter.d.cts +77 -0
- package/dist/pipeline/ServerOverloadCounter.d.ts +77 -0
- package/dist/pipeline/ServerOverloadCounter.js +16 -0
- package/dist/pipeline/SubscriptionAccountHealth.cjs +4 -2
- package/dist/pipeline/SubscriptionAccountHealth.d.cts +32 -3
- package/dist/pipeline/SubscriptionAccountHealth.d.ts +32 -3
- package/dist/pipeline/SubscriptionAccountHealth.js +3 -1
- package/dist/pipeline/upstreamFetch.cjs +4 -3
- package/dist/pipeline/upstreamFetch.d.cts +35 -6
- package/dist/pipeline/upstreamFetch.d.ts +35 -6
- package/dist/pipeline/upstreamFetch.js +3 -2
- package/dist/pipeline/upstreamTrace.cjs +4 -2
- package/dist/pipeline/upstreamTrace.d.cts +22 -8
- package/dist/pipeline/upstreamTrace.d.ts +22 -8
- package/dist/pipeline/upstreamTrace.js +3 -1
- package/dist/ports.d.cts +2 -2
- package/dist/ports.d.ts +2 -2
- package/dist/provider-proxy/ProviderProxy.cjs +23 -19
- package/dist/provider-proxy/ProviderProxy.d.cts +2 -1
- package/dist/provider-proxy/ProviderProxy.d.ts +2 -1
- package/dist/provider-proxy/ProviderProxy.js +22 -18
- package/dist/provider-proxy/identity/codexCliHeaders.cjs +10 -0
- package/dist/provider-proxy/identity/codexCliHeaders.d.cts +45 -0
- package/dist/provider-proxy/identity/codexCliHeaders.d.ts +45 -0
- package/dist/provider-proxy/identity/codexCliHeaders.js +10 -0
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +23 -19
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +11 -1
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +11 -1
- package/dist/provider-proxy/ingress/providerProxyShared.js +22 -18
- package/dist/provider-proxy/matchText.cjs +2 -2
- package/dist/provider-proxy/matchText.d.cts +1 -3
- package/dist/provider-proxy/matchText.d.ts +1 -3
- package/dist/provider-proxy/matchText.js +1 -1
- package/dist/provider-proxy/types.d.cts +20 -1
- package/dist/provider-proxy/types.d.ts +20 -1
- package/dist/provider-proxy.cjs +79 -19
- package/dist/provider-proxy.d.cts +255 -8
- package/dist/provider-proxy.d.ts +255 -8
- package/dist/provider-proxy.js +80 -20
- package/dist/{routeResolver-CHTv_Bs5.d.ts → routeResolver-C0mkkZaM.d.ts} +1 -1
- package/dist/{routeResolver-kepxnfcC.d.cts → routeResolver-CVFE8KKe.d.cts} +1 -1
- package/dist/transformer/transformers/AnthropicTransformer.cjs +3 -2
- package/dist/transformer/transformers/AnthropicTransformer.js +2 -1
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -2
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -1
- package/dist/transformer/transformers.cjs +7 -6
- package/dist/transformer/transformers.js +6 -5
- package/dist/transformer.cjs +9 -8
- package/dist/transformer.js +8 -7
- package/dist/{types-hsoKrVQS.d.ts → types-BB8pxk_3.d.ts} +40 -1
- package/dist/{types-H3wGZSOo.d.cts → types-C2MwkLah.d.cts} +40 -1
- package/dist/usage/pricing-engine.cjs +2 -2
- package/dist/usage/pricing-engine.d.cts +20 -0
- package/dist/usage/pricing-engine.d.ts +20 -0
- package/dist/usage/pricing-engine.js +1 -1
- package/dist/usage/usage-recorder.cjs +2 -2
- package/dist/usage/usage-recorder.d.cts +11 -1
- package/dist/usage/usage-recorder.d.ts +11 -1
- package/dist/usage/usage-recorder.js +1 -1
- package/dist/usage.cjs +3 -3
- package/dist/usage.js +2 -2
- package/package.json +1 -1
package/dist/outbound-api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VoucherConfig } from '@omnicross/contracts/voucher-types';
|
|
2
|
-
import { c as EndpointRoutingConfig, G as GatewayBinding, U as UserMessageQueueConfig, b as ConcurrencyQueueConfig, n as OutboundApiDeps, r as OutboundApiServerStatus, t as OutboundFormatUrls, A as AccountProbeConfig, a as AllowanceSchedulingConfig, F as FingerprintConfig, q as OutboundApiServerConfig, m as ModelPrefixTargets, x as OutboundProxyConfig, s as OutboundEndpoint, R as RequestRole, Q as ModelRef, k as KindMappedEndpoint, l as ModelKind, O as OutboundKeyDb, o as OutboundApiKeyCreated } from './types-
|
|
3
|
-
export { C as ChatDispatchMode, E as ENDPOINT_MODEL_KINDS, d as GatewayBindingFallback, e as GatewayBindingKeyScope, f as GatewayBindingModelMode, g as GatewayBindingTarget, h as GatewayModelMapping, K as KeySpendReader, i as KeySpendSeeder, j as KeySpendTracker, M as MessagesModelKind, p as OutboundApiKeyInfo, u as OutboundKeyActivationMode, v as OutboundKeyDbRow, w as OutboundKeyPolicy, y as ResponsesModelKind, V as VoucherCreateInput, z as VoucherDb, B as computeVoucherGrant, D as generateVoucherCode, H as hashVoucherCode, I as newVoucherId, J as startOfLocalDay, L as startOfLocalWeek, N as toVoucherInfo, P as voucherCodePrefix } from './types-
|
|
2
|
+
import { c as EndpointRoutingConfig, G as GatewayBinding, U as UserMessageQueueConfig, b as ConcurrencyQueueConfig, n as OutboundApiDeps, r as OutboundApiServerStatus, t as OutboundFormatUrls, A as AccountProbeConfig, a as AllowanceSchedulingConfig, F as FingerprintConfig, q as OutboundApiServerConfig, m as ModelPrefixTargets, x as OutboundProxyConfig, s as OutboundEndpoint, R as RequestRole, Q as ModelRef, k as KindMappedEndpoint, l as ModelKind, O as OutboundKeyDb, o as OutboundApiKeyCreated } from './types-BB8pxk_3.js';
|
|
3
|
+
export { C as ChatDispatchMode, E as ENDPOINT_MODEL_KINDS, d as GatewayBindingFallback, e as GatewayBindingKeyScope, f as GatewayBindingModelMode, g as GatewayBindingTarget, h as GatewayModelMapping, K as KeySpendReader, i as KeySpendSeeder, j as KeySpendTracker, M as MessagesModelKind, p as OutboundApiKeyInfo, u as OutboundKeyActivationMode, v as OutboundKeyDbRow, w as OutboundKeyPolicy, y as ResponsesModelKind, V as VoucherCreateInput, z as VoucherDb, B as computeVoucherGrant, D as generateVoucherCode, H as hashVoucherCode, I as newVoucherId, J as startOfLocalDay, L as startOfLocalWeek, N as toVoucherInfo, P as voucherCodePrefix } from './types-BB8pxk_3.js';
|
|
4
4
|
import { ProxyConfig } from '@omnicross/contracts/account-tokens-types';
|
|
5
5
|
import { AuditConfig } from '@omnicross/contracts/audit-types';
|
|
6
6
|
import { BillingConfig } from '@omnicross/contracts/billing-types';
|
|
@@ -12,7 +12,7 @@ import { K as KeyCostLimits, M as ModelRestriction } from './keyPolicy-zdWTu3CQ.
|
|
|
12
12
|
export { a as KeyExpiryInput, b as KeyExpiryResult, c as KeySpend, Q as QuotaDecision, d as checkKeyQuota, e as computeKeyExpiry } from './keyPolicy-zdWTu3CQ.js';
|
|
13
13
|
import http from 'node:http';
|
|
14
14
|
import { IngressFormat } from './provider-proxy/types.js';
|
|
15
|
-
export { S as SUBSCRIPTION_PROVIDER_IDS, e as endpointSupportsSubscription, i as isSubscriptionProviderId, p as parseModelRef, a as pickModelRefFromList, r as resolveRoute } from './routeResolver-
|
|
15
|
+
export { S as SUBSCRIPTION_PROVIDER_IDS, e as endpointSupportsSubscription, i as isSubscriptionProviderId, p as parseModelRef, a as pickModelRefFromList, r as resolveRoute } from './routeResolver-C0mkkZaM.js';
|
|
16
16
|
export { BoundAccountFallbackPolicy, BoundAccountSelectionError, BoundAccountSelectionFailureReason, boundAccountSelectionMessage, isBoundAccountSelectionError } from './pipeline/BoundAccountSelectionError.js';
|
|
17
17
|
import '@omnicross/contracts/health-logging-types';
|
|
18
18
|
import './logger-4GvQNzhE.js';
|
|
@@ -20,8 +20,9 @@ import './ports/provider-config-source.js';
|
|
|
20
20
|
import '@omnicross/contracts/llm-config';
|
|
21
21
|
import './transformer/types.js';
|
|
22
22
|
import './transformer/TransformerService.js';
|
|
23
|
-
import './ProviderProxy
|
|
23
|
+
import './ProviderProxy--ROec6VI.js';
|
|
24
24
|
import '@omnicross/contracts/completion-types';
|
|
25
|
+
import '@omnicross/contracts/usage-stats-types';
|
|
25
26
|
import '@omnicross/contracts/subscription-types';
|
|
26
27
|
import '@omnicross/contracts/usage-types';
|
|
27
28
|
import './completion/ApiKeyPoolService.js';
|
|
@@ -195,8 +196,9 @@ declare function normalizeAccountProbe(raw: Partial<OutboundApiServerConfig> | u
|
|
|
195
196
|
* Fill + range-CLAMP the request-audit segment to the frozen defaults
|
|
196
197
|
* (request-audit-log, design D2). Lenient like the other segment normalizers:
|
|
197
198
|
* `enabled`/`captureBodies`/`trustForwardedFor` coerce to booleans (default
|
|
198
|
-
* false)
|
|
199
|
-
* `[1, 365]`. Default (all-off) ⇒
|
|
199
|
+
* false). `maxBodyBytes:-1` means unlimited; other finite values clamp to
|
|
200
|
+
* `[0, 1_048_576]`. `retentionDays` clamps to `[1, 365]`. Default (all-off) ⇒
|
|
201
|
+
* no capture ⇒ zero regression.
|
|
200
202
|
*/
|
|
201
203
|
declare function normalizeAudit(raw: Partial<OutboundApiServerConfig> | undefined | null): AuditConfig;
|
|
202
204
|
/**
|
package/dist/outbound-api.js
CHANGED
|
@@ -63,29 +63,33 @@ import {
|
|
|
63
63
|
verifyKey,
|
|
64
64
|
verifyPresentedKey,
|
|
65
65
|
voucherCodePrefix
|
|
66
|
-
} from "./chunk-
|
|
67
|
-
import "./chunk-WB6PH56J.js";
|
|
66
|
+
} from "./chunk-QYC54PMG.js";
|
|
68
67
|
import "./chunk-VVEHS2LI.js";
|
|
69
68
|
import "./chunk-46RLHI7D.js";
|
|
70
|
-
import "./chunk-
|
|
71
|
-
import "./chunk-
|
|
72
|
-
import "./chunk-DK4A7DLE.js";
|
|
73
|
-
import "./chunk-VRFBB5DB.js";
|
|
69
|
+
import "./chunk-MYYR3HZL.js";
|
|
70
|
+
import "./chunk-PEGTIPB3.js";
|
|
74
71
|
import "./chunk-LVUCAWMK.js";
|
|
75
|
-
import "./chunk-
|
|
72
|
+
import "./chunk-32O35CIF.js";
|
|
73
|
+
import "./chunk-FU7EAR73.js";
|
|
76
74
|
import "./chunk-LB6EBS6Y.js";
|
|
77
|
-
import "./chunk-6CL5HTPQ.js";
|
|
78
75
|
import "./chunk-7VU7V2E4.js";
|
|
79
|
-
import "./chunk-
|
|
80
|
-
import "./chunk-
|
|
81
|
-
import "./chunk-
|
|
76
|
+
import "./chunk-FXR6N3SR.js";
|
|
77
|
+
import "./chunk-UAPBLNN2.js";
|
|
78
|
+
import "./chunk-WNKWAEUR.js";
|
|
79
|
+
import "./chunk-MZNPGW5Q.js";
|
|
80
|
+
import "./chunk-DK4A7DLE.js";
|
|
81
|
+
import "./chunk-XXFYLL7R.js";
|
|
82
82
|
import "./chunk-XTEI64OU.js";
|
|
83
83
|
import "./chunk-XX6NQJMA.js";
|
|
84
|
+
import "./chunk-GFIZ6LQI.js";
|
|
85
|
+
import "./chunk-OE6TDIWW.js";
|
|
86
|
+
import "./chunk-DRWHTIIZ.js";
|
|
87
|
+
import "./chunk-JWC6APFQ.js";
|
|
84
88
|
import "./chunk-5ERIZW3D.js";
|
|
85
|
-
import "./chunk-
|
|
89
|
+
import "./chunk-PO3XB56Z.js";
|
|
90
|
+
import "./chunk-N7OOJI5V.js";
|
|
86
91
|
import "./chunk-23S5OPIO.js";
|
|
87
92
|
import "./chunk-AVYJ4YBN.js";
|
|
88
|
-
import "./chunk-OE6TDIWW.js";
|
|
89
93
|
import "./chunk-OPRS4IQZ.js";
|
|
90
94
|
import {
|
|
91
95
|
BoundAccountSelectionError,
|
|
@@ -94,7 +98,6 @@ import {
|
|
|
94
98
|
} from "./chunk-2JYRIADS.js";
|
|
95
99
|
import "./chunk-DE2SRBFZ.js";
|
|
96
100
|
import "./chunk-ZY6KU6P3.js";
|
|
97
|
-
import "./chunk-JWC6APFQ.js";
|
|
98
101
|
import {
|
|
99
102
|
beginBillingCapture
|
|
100
103
|
} from "./chunk-WLYIIEAF.js";
|
|
@@ -123,19 +126,20 @@ import {
|
|
|
123
126
|
import "./chunk-H5JUT3KV.js";
|
|
124
127
|
import {
|
|
125
128
|
beginAuditCapture
|
|
126
|
-
} from "./chunk-
|
|
129
|
+
} from "./chunk-7C7DET6S.js";
|
|
127
130
|
import {
|
|
128
131
|
AUDIT_REDACTED,
|
|
129
132
|
redactAuditText
|
|
130
133
|
} from "./chunk-K5NM7VAH.js";
|
|
131
134
|
import "./chunk-WNY4WMRF.js";
|
|
132
135
|
import "./chunk-OZFM4X3S.js";
|
|
133
|
-
import "./chunk-
|
|
136
|
+
import "./chunk-5NJLQ6T6.js";
|
|
134
137
|
import "./chunk-N5T4M4GU.js";
|
|
135
138
|
import "./chunk-TOVPMMHM.js";
|
|
136
|
-
import "./chunk-
|
|
137
|
-
import "./chunk-
|
|
139
|
+
import "./chunk-RJ5ZGNI3.js";
|
|
140
|
+
import "./chunk-3WD4HTR2.js";
|
|
138
141
|
import "./chunk-MKF46GNZ.js";
|
|
142
|
+
import "./chunk-GL6XM527.js";
|
|
139
143
|
import "./chunk-CDHS2QDC.js";
|
|
140
144
|
import "./chunk-Y7FO65VT.js";
|
|
141
145
|
import "./chunk-FMOBD2OQ.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SubscriptionProviderId } from '@omnicross/contracts/subscription-types';
|
|
2
|
-
import { a as AllowanceSchedulingConfig } from '../types-
|
|
2
|
+
import { a as AllowanceSchedulingConfig } from '../types-C2MwkLah.cjs';
|
|
3
3
|
import { AccountAllowanceStore } from './AccountAllowanceStore.cjs';
|
|
4
4
|
import '@omnicross/contracts/account-tokens-types';
|
|
5
5
|
import '@omnicross/contracts/audit-types';
|
|
@@ -12,10 +12,11 @@ import '../ports/provider-config-source.cjs';
|
|
|
12
12
|
import '@omnicross/contracts/llm-config';
|
|
13
13
|
import '../transformer/types.cjs';
|
|
14
14
|
import '../transformer/TransformerService.cjs';
|
|
15
|
-
import '../ProviderProxy-
|
|
15
|
+
import '../ProviderProxy-QdwNV6l1.cjs';
|
|
16
16
|
import '../provider-proxy/types.cjs';
|
|
17
17
|
import 'node:http';
|
|
18
18
|
import '@omnicross/contracts/completion-types';
|
|
19
|
+
import '@omnicross/contracts/usage-stats-types';
|
|
19
20
|
import '@omnicross/contracts/usage-types';
|
|
20
21
|
import '../completion/ApiKeyPoolService.cjs';
|
|
21
22
|
import './AuthSource.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SubscriptionProviderId } from '@omnicross/contracts/subscription-types';
|
|
2
|
-
import { a as AllowanceSchedulingConfig } from '../types-
|
|
2
|
+
import { a as AllowanceSchedulingConfig } from '../types-BB8pxk_3.js';
|
|
3
3
|
import { AccountAllowanceStore } from './AccountAllowanceStore.js';
|
|
4
4
|
import '@omnicross/contracts/account-tokens-types';
|
|
5
5
|
import '@omnicross/contracts/audit-types';
|
|
@@ -12,10 +12,11 @@ import '../ports/provider-config-source.js';
|
|
|
12
12
|
import '@omnicross/contracts/llm-config';
|
|
13
13
|
import '../transformer/types.js';
|
|
14
14
|
import '../transformer/TransformerService.js';
|
|
15
|
-
import '../ProviderProxy
|
|
15
|
+
import '../ProviderProxy--ROec6VI.js';
|
|
16
16
|
import '../provider-proxy/types.js';
|
|
17
17
|
import 'node:http';
|
|
18
18
|
import '@omnicross/contracts/completion-types';
|
|
19
|
+
import '@omnicross/contracts/usage-stats-types';
|
|
19
20
|
import '@omnicross/contracts/usage-types';
|
|
20
21
|
import '../completion/ApiKeyPoolService.js';
|
|
21
22
|
import './AuthSource.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkNKVZ6Z3Ycjs = require('../chunk-NKVZ6Z3Y.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.ACCOUNT_ROUTE_ACTIVITY_LIMIT = _chunkNKVZ6Z3Ycjs.ACCOUNT_ROUTE_ACTIVITY_LIMIT; exports.AccountRouteActivityStore = _chunkNKVZ6Z3Ycjs.AccountRouteActivityStore; exports.getSharedAccountRouteActivity = _chunkNKVZ6Z3Ycjs.getSharedAccountRouteActivity;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded, metadata-only history of subscription account routing decisions.
|
|
3
|
+
*
|
|
4
|
+
* Records are created at the shared upstream fetch seam, after authentication has
|
|
5
|
+
* reported the account that will actually serve the request. The store is
|
|
6
|
+
* intentionally process-local: it is useful for live operator diagnostics without
|
|
7
|
+
* turning session/account affinity into a durable tracking database.
|
|
8
|
+
*/
|
|
9
|
+
declare const ACCOUNT_ROUTE_ACTIVITY_LIMIT = 300;
|
|
10
|
+
type AccountRouteEndpoint = 'responses' | 'messages';
|
|
11
|
+
type AccountRouteSessionSource = 'session-header' | 'thread-header' | 'body-session-id' | 'body-thread-id' | 'prompt-cache-key' | 'content-fingerprint' | 'api-key-fallback' | 'none';
|
|
12
|
+
type AccountRouteAffinity = 'new' | 'sticky' | 'switched' | 'untracked';
|
|
13
|
+
interface AccountRouteActivityInput {
|
|
14
|
+
providerId: string;
|
|
15
|
+
accountId: string;
|
|
16
|
+
endpoint: AccountRouteEndpoint;
|
|
17
|
+
sessionKey?: string;
|
|
18
|
+
sessionSource: AccountRouteSessionSource;
|
|
19
|
+
model: string;
|
|
20
|
+
status: number;
|
|
21
|
+
durationMs: number;
|
|
22
|
+
ts?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Post-hoc error observed AFTER the upstream status was recorded — e.g. a
|
|
25
|
+
* `200` whose SSE body carries a `response.failed` server-overload event.
|
|
26
|
+
* Never known at `record()` time; set later via {@link amend}. Absent on
|
|
27
|
+
* healthy responses.
|
|
28
|
+
*/
|
|
29
|
+
streamError?: string;
|
|
30
|
+
}
|
|
31
|
+
interface AccountRouteActivityRecord extends AccountRouteActivityInput {
|
|
32
|
+
id: string;
|
|
33
|
+
ts: number;
|
|
34
|
+
affinity: AccountRouteAffinity;
|
|
35
|
+
previousAccountId?: string;
|
|
36
|
+
}
|
|
37
|
+
interface AccountRouteActivityQuery {
|
|
38
|
+
providerId?: string;
|
|
39
|
+
accountId?: string;
|
|
40
|
+
sessionKey?: string;
|
|
41
|
+
limit?: number;
|
|
42
|
+
}
|
|
43
|
+
declare class AccountRouteActivityStore {
|
|
44
|
+
private readonly records;
|
|
45
|
+
private sequence;
|
|
46
|
+
record(input: AccountRouteActivityInput): AccountRouteActivityRecord;
|
|
47
|
+
list(query?: AccountRouteActivityQuery): AccountRouteActivityRecord[];
|
|
48
|
+
clear(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Backfill a field on an already-recorded entry. Used to annotate a record
|
|
51
|
+
* AFTER the upstream body streams — e.g. a `200` whose SSE body carries a
|
|
52
|
+
* `response.failed` overload event is only detectable mid-relay, long after
|
|
53
|
+
* `record()` stamped the 200 status. `patch` is intentionally narrow: only
|
|
54
|
+
* post-hoc-observable fields belong here, never the routing-decision fields.
|
|
55
|
+
* No-op when the id has already aged out of the bounded ring.
|
|
56
|
+
*/
|
|
57
|
+
amend(id: string, patch: Partial<Pick<AccountRouteActivityRecord, 'streamError'>>): void;
|
|
58
|
+
}
|
|
59
|
+
declare function getSharedAccountRouteActivity(): AccountRouteActivityStore;
|
|
60
|
+
|
|
61
|
+
export { ACCOUNT_ROUTE_ACTIVITY_LIMIT, type AccountRouteActivityInput, type AccountRouteActivityQuery, type AccountRouteActivityRecord, AccountRouteActivityStore, type AccountRouteAffinity, type AccountRouteEndpoint, type AccountRouteSessionSource, getSharedAccountRouteActivity };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded, metadata-only history of subscription account routing decisions.
|
|
3
|
+
*
|
|
4
|
+
* Records are created at the shared upstream fetch seam, after authentication has
|
|
5
|
+
* reported the account that will actually serve the request. The store is
|
|
6
|
+
* intentionally process-local: it is useful for live operator diagnostics without
|
|
7
|
+
* turning session/account affinity into a durable tracking database.
|
|
8
|
+
*/
|
|
9
|
+
declare const ACCOUNT_ROUTE_ACTIVITY_LIMIT = 300;
|
|
10
|
+
type AccountRouteEndpoint = 'responses' | 'messages';
|
|
11
|
+
type AccountRouteSessionSource = 'session-header' | 'thread-header' | 'body-session-id' | 'body-thread-id' | 'prompt-cache-key' | 'content-fingerprint' | 'api-key-fallback' | 'none';
|
|
12
|
+
type AccountRouteAffinity = 'new' | 'sticky' | 'switched' | 'untracked';
|
|
13
|
+
interface AccountRouteActivityInput {
|
|
14
|
+
providerId: string;
|
|
15
|
+
accountId: string;
|
|
16
|
+
endpoint: AccountRouteEndpoint;
|
|
17
|
+
sessionKey?: string;
|
|
18
|
+
sessionSource: AccountRouteSessionSource;
|
|
19
|
+
model: string;
|
|
20
|
+
status: number;
|
|
21
|
+
durationMs: number;
|
|
22
|
+
ts?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Post-hoc error observed AFTER the upstream status was recorded — e.g. a
|
|
25
|
+
* `200` whose SSE body carries a `response.failed` server-overload event.
|
|
26
|
+
* Never known at `record()` time; set later via {@link amend}. Absent on
|
|
27
|
+
* healthy responses.
|
|
28
|
+
*/
|
|
29
|
+
streamError?: string;
|
|
30
|
+
}
|
|
31
|
+
interface AccountRouteActivityRecord extends AccountRouteActivityInput {
|
|
32
|
+
id: string;
|
|
33
|
+
ts: number;
|
|
34
|
+
affinity: AccountRouteAffinity;
|
|
35
|
+
previousAccountId?: string;
|
|
36
|
+
}
|
|
37
|
+
interface AccountRouteActivityQuery {
|
|
38
|
+
providerId?: string;
|
|
39
|
+
accountId?: string;
|
|
40
|
+
sessionKey?: string;
|
|
41
|
+
limit?: number;
|
|
42
|
+
}
|
|
43
|
+
declare class AccountRouteActivityStore {
|
|
44
|
+
private readonly records;
|
|
45
|
+
private sequence;
|
|
46
|
+
record(input: AccountRouteActivityInput): AccountRouteActivityRecord;
|
|
47
|
+
list(query?: AccountRouteActivityQuery): AccountRouteActivityRecord[];
|
|
48
|
+
clear(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Backfill a field on an already-recorded entry. Used to annotate a record
|
|
51
|
+
* AFTER the upstream body streams — e.g. a `200` whose SSE body carries a
|
|
52
|
+
* `response.failed` overload event is only detectable mid-relay, long after
|
|
53
|
+
* `record()` stamped the 200 status. `patch` is intentionally narrow: only
|
|
54
|
+
* post-hoc-observable fields belong here, never the routing-decision fields.
|
|
55
|
+
* No-op when the id has already aged out of the bounded ring.
|
|
56
|
+
*/
|
|
57
|
+
amend(id: string, patch: Partial<Pick<AccountRouteActivityRecord, 'streamError'>>): void;
|
|
58
|
+
}
|
|
59
|
+
declare function getSharedAccountRouteActivity(): AccountRouteActivityStore;
|
|
60
|
+
|
|
61
|
+
export { ACCOUNT_ROUTE_ACTIVITY_LIMIT, type AccountRouteActivityInput, type AccountRouteActivityQuery, type AccountRouteActivityRecord, AccountRouteActivityStore, type AccountRouteAffinity, type AccountRouteEndpoint, type AccountRouteSessionSource, getSharedAccountRouteActivity };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkOTZC4TNHcjs = require('../chunk-OTZC4TNH.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.OVERLOAD_ENTRY_TTL_MS = _chunkOTZC4TNHcjs.OVERLOAD_ENTRY_TTL_MS; exports.OVERLOAD_RECENT_LIMIT = _chunkOTZC4TNHcjs.OVERLOAD_RECENT_LIMIT; exports.ServerOverloadCounterStore = _chunkOTZC4TNHcjs.ServerOverloadCounterStore; exports.__resetSharedOverloadCounterForTests = _chunkOTZC4TNHcjs.__resetSharedOverloadCounterForTests; exports.getSharedOverloadCounter = _chunkOTZC4TNHcjs.getSharedOverloadCounter; exports.setSharedOverloadCounter = _chunkOTZC4TNHcjs.setSharedOverloadCounter;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AccountRouteEndpoint } from './AccountRouteActivity.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ServerOverloadCounter — a bounded, metadata-only tally of Codex server-
|
|
5
|
+
* overload events (`response.failed` with `error.code` `server_is_overloaded` /
|
|
6
|
+
* `slow_down`) per provider+account+endpoint.
|
|
7
|
+
*
|
|
8
|
+
* WHY a dedicated store (not derived from {@link AccountRouteActivity}): those
|
|
9
|
+
* 200-status overloads are invisible at the route-activity HTTP-status layer, and
|
|
10
|
+
* the route-activity ring (300 rows) can be pushed out by normal traffic before
|
|
11
|
+
* an operator notices. This counter ACCUMULATES across the ring and keeps a
|
|
12
|
+
* bounded recent-timestamp ring for a trend sparkline, so "how often is account X
|
|
13
|
+
* being overloaded, and is it worsening" stays answerable.
|
|
14
|
+
*
|
|
15
|
+
* Overload is account-INDEPENDENT server capacity (retrying on another account is
|
|
16
|
+
* pointless), so — unlike {@link SubscriptionAccountHealth} — this store only
|
|
17
|
+
* OBSERVES; it never gates scheduling. It carries no secrets, only counts + epoch
|
|
18
|
+
* timestamps. In-memory (cleared on restart), same as the other pipeline stores.
|
|
19
|
+
*
|
|
20
|
+
* Shaped like `SubscriptionAccountHealth`: an in-memory `Map`, an injectable
|
|
21
|
+
* `now` clock, no external deps, opaque `providerId\0accountId\0endpoint` keys.
|
|
22
|
+
*
|
|
23
|
+
* @module pipeline/ServerOverloadCounter
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Bounded recent-event ring per entry — the sparkline's data source. */
|
|
27
|
+
declare const OVERLOAD_RECENT_LIMIT = 64;
|
|
28
|
+
/**
|
|
29
|
+
* Entries with no event in this window are pruned on read, so the map cannot
|
|
30
|
+
* grow unbounded across a long-lived process with many transient accounts.
|
|
31
|
+
*/
|
|
32
|
+
declare const OVERLOAD_ENTRY_TTL_MS: number;
|
|
33
|
+
interface OverloadRecordInput {
|
|
34
|
+
providerId: string;
|
|
35
|
+
accountId: string;
|
|
36
|
+
endpoint: AccountRouteEndpoint;
|
|
37
|
+
/** Epoch-ms of the event. Omit to use the clock default. */
|
|
38
|
+
now?: number;
|
|
39
|
+
}
|
|
40
|
+
interface OverloadCounterEntry {
|
|
41
|
+
providerId: string;
|
|
42
|
+
accountId: string;
|
|
43
|
+
endpoint: AccountRouteEndpoint;
|
|
44
|
+
/** Lifetime count of overload events for this key (since first observed). */
|
|
45
|
+
count: number;
|
|
46
|
+
firstTs: number;
|
|
47
|
+
lastTs: number;
|
|
48
|
+
/** Most-recent-first epoch-ms events, capped at {@link OVERLOAD_RECENT_LIMIT}. */
|
|
49
|
+
recent: number[];
|
|
50
|
+
}
|
|
51
|
+
interface OverloadCounterQuery {
|
|
52
|
+
providerId?: string;
|
|
53
|
+
accountId?: string;
|
|
54
|
+
}
|
|
55
|
+
declare class ServerOverloadCounterStore {
|
|
56
|
+
private readonly entries;
|
|
57
|
+
/**
|
|
58
|
+
* Record one overload event. Creates the entry on first sight, then bumps
|
|
59
|
+
* `count`, `lastTs`, and prepends the event to the bounded `recent` ring.
|
|
60
|
+
*/
|
|
61
|
+
recordOverload(input: OverloadRecordInput, now?: number): OverloadCounterEntry;
|
|
62
|
+
/**
|
|
63
|
+
* Snapshot all (optionally filtered) entries, pruning stale ones first. Returns
|
|
64
|
+
* copies — callers (admin API → JSON) never see the live mutable entries.
|
|
65
|
+
*/
|
|
66
|
+
list(query?: OverloadCounterQuery, now?: number): OverloadCounterEntry[];
|
|
67
|
+
clear(): void;
|
|
68
|
+
}
|
|
69
|
+
declare function getSharedOverloadCounter(): ServerOverloadCounterStore;
|
|
70
|
+
/**
|
|
71
|
+
* TEST SEAM — swap the singleton (e.g. with a fresh instance). Mirrors the
|
|
72
|
+
* `setShared…`/`__reset…ForTests` discipline of the sibling pipeline stores.
|
|
73
|
+
*/
|
|
74
|
+
declare function setSharedOverloadCounter(instance: ServerOverloadCounterStore): void;
|
|
75
|
+
declare function __resetSharedOverloadCounterForTests(): void;
|
|
76
|
+
|
|
77
|
+
export { OVERLOAD_ENTRY_TTL_MS, OVERLOAD_RECENT_LIMIT, type OverloadCounterEntry, type OverloadCounterQuery, type OverloadRecordInput, ServerOverloadCounterStore, __resetSharedOverloadCounterForTests, getSharedOverloadCounter, setSharedOverloadCounter };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AccountRouteEndpoint } from './AccountRouteActivity.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ServerOverloadCounter — a bounded, metadata-only tally of Codex server-
|
|
5
|
+
* overload events (`response.failed` with `error.code` `server_is_overloaded` /
|
|
6
|
+
* `slow_down`) per provider+account+endpoint.
|
|
7
|
+
*
|
|
8
|
+
* WHY a dedicated store (not derived from {@link AccountRouteActivity}): those
|
|
9
|
+
* 200-status overloads are invisible at the route-activity HTTP-status layer, and
|
|
10
|
+
* the route-activity ring (300 rows) can be pushed out by normal traffic before
|
|
11
|
+
* an operator notices. This counter ACCUMULATES across the ring and keeps a
|
|
12
|
+
* bounded recent-timestamp ring for a trend sparkline, so "how often is account X
|
|
13
|
+
* being overloaded, and is it worsening" stays answerable.
|
|
14
|
+
*
|
|
15
|
+
* Overload is account-INDEPENDENT server capacity (retrying on another account is
|
|
16
|
+
* pointless), so — unlike {@link SubscriptionAccountHealth} — this store only
|
|
17
|
+
* OBSERVES; it never gates scheduling. It carries no secrets, only counts + epoch
|
|
18
|
+
* timestamps. In-memory (cleared on restart), same as the other pipeline stores.
|
|
19
|
+
*
|
|
20
|
+
* Shaped like `SubscriptionAccountHealth`: an in-memory `Map`, an injectable
|
|
21
|
+
* `now` clock, no external deps, opaque `providerId\0accountId\0endpoint` keys.
|
|
22
|
+
*
|
|
23
|
+
* @module pipeline/ServerOverloadCounter
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Bounded recent-event ring per entry — the sparkline's data source. */
|
|
27
|
+
declare const OVERLOAD_RECENT_LIMIT = 64;
|
|
28
|
+
/**
|
|
29
|
+
* Entries with no event in this window are pruned on read, so the map cannot
|
|
30
|
+
* grow unbounded across a long-lived process with many transient accounts.
|
|
31
|
+
*/
|
|
32
|
+
declare const OVERLOAD_ENTRY_TTL_MS: number;
|
|
33
|
+
interface OverloadRecordInput {
|
|
34
|
+
providerId: string;
|
|
35
|
+
accountId: string;
|
|
36
|
+
endpoint: AccountRouteEndpoint;
|
|
37
|
+
/** Epoch-ms of the event. Omit to use the clock default. */
|
|
38
|
+
now?: number;
|
|
39
|
+
}
|
|
40
|
+
interface OverloadCounterEntry {
|
|
41
|
+
providerId: string;
|
|
42
|
+
accountId: string;
|
|
43
|
+
endpoint: AccountRouteEndpoint;
|
|
44
|
+
/** Lifetime count of overload events for this key (since first observed). */
|
|
45
|
+
count: number;
|
|
46
|
+
firstTs: number;
|
|
47
|
+
lastTs: number;
|
|
48
|
+
/** Most-recent-first epoch-ms events, capped at {@link OVERLOAD_RECENT_LIMIT}. */
|
|
49
|
+
recent: number[];
|
|
50
|
+
}
|
|
51
|
+
interface OverloadCounterQuery {
|
|
52
|
+
providerId?: string;
|
|
53
|
+
accountId?: string;
|
|
54
|
+
}
|
|
55
|
+
declare class ServerOverloadCounterStore {
|
|
56
|
+
private readonly entries;
|
|
57
|
+
/**
|
|
58
|
+
* Record one overload event. Creates the entry on first sight, then bumps
|
|
59
|
+
* `count`, `lastTs`, and prepends the event to the bounded `recent` ring.
|
|
60
|
+
*/
|
|
61
|
+
recordOverload(input: OverloadRecordInput, now?: number): OverloadCounterEntry;
|
|
62
|
+
/**
|
|
63
|
+
* Snapshot all (optionally filtered) entries, pruning stale ones first. Returns
|
|
64
|
+
* copies — callers (admin API → JSON) never see the live mutable entries.
|
|
65
|
+
*/
|
|
66
|
+
list(query?: OverloadCounterQuery, now?: number): OverloadCounterEntry[];
|
|
67
|
+
clear(): void;
|
|
68
|
+
}
|
|
69
|
+
declare function getSharedOverloadCounter(): ServerOverloadCounterStore;
|
|
70
|
+
/**
|
|
71
|
+
* TEST SEAM — swap the singleton (e.g. with a fresh instance). Mirrors the
|
|
72
|
+
* `setShared…`/`__reset…ForTests` discipline of the sibling pipeline stores.
|
|
73
|
+
*/
|
|
74
|
+
declare function setSharedOverloadCounter(instance: ServerOverloadCounterStore): void;
|
|
75
|
+
declare function __resetSharedOverloadCounterForTests(): void;
|
|
76
|
+
|
|
77
|
+
export { OVERLOAD_ENTRY_TTL_MS, OVERLOAD_RECENT_LIMIT, type OverloadCounterEntry, type OverloadCounterQuery, type OverloadRecordInput, ServerOverloadCounterStore, __resetSharedOverloadCounterForTests, getSharedOverloadCounter, setSharedOverloadCounter };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OVERLOAD_ENTRY_TTL_MS,
|
|
3
|
+
OVERLOAD_RECENT_LIMIT,
|
|
4
|
+
ServerOverloadCounterStore,
|
|
5
|
+
__resetSharedOverloadCounterForTests,
|
|
6
|
+
getSharedOverloadCounter,
|
|
7
|
+
setSharedOverloadCounter
|
|
8
|
+
} from "../chunk-PO3XB56Z.js";
|
|
9
|
+
export {
|
|
10
|
+
OVERLOAD_ENTRY_TTL_MS,
|
|
11
|
+
OVERLOAD_RECENT_LIMIT,
|
|
12
|
+
ServerOverloadCounterStore,
|
|
13
|
+
__resetSharedOverloadCounterForTests,
|
|
14
|
+
getSharedOverloadCounter,
|
|
15
|
+
setSharedOverloadCounter
|
|
16
|
+
};
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var _chunkYK57NMIFcjs = require('../chunk-YK57NMIF.cjs');
|
|
13
12
|
|
|
13
|
+
var _chunkYWL7YZWScjs = require('../chunk-YWL7YZWS.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -21,4 +21,6 @@ var _chunkYK57NMIFcjs = require('../chunk-YK57NMIF.cjs');
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
exports.ACCOUNT_HEALTH_DIAGNOSTIC_LIMIT = _chunkYWL7YZWScjs.ACCOUNT_HEALTH_DIAGNOSTIC_LIMIT; exports.AUTH_ERROR_TTL_MS = _chunkYWL7YZWScjs.AUTH_ERROR_TTL_MS; exports.MAX_QUOTA_COOLDOWN_MS = _chunkYWL7YZWScjs.MAX_QUOTA_COOLDOWN_MS; exports.OVERLOAD_ENABLED_DEFAULT = _chunkYWL7YZWScjs.OVERLOAD_ENABLED_DEFAULT; exports.OVERLOAD_TTL_MS = _chunkYWL7YZWScjs.OVERLOAD_TTL_MS; exports.SERVER_ERROR_TTL_MS = _chunkYWL7YZWScjs.SERVER_ERROR_TTL_MS; exports.SubscriptionAccountHealth = _chunkYWL7YZWScjs.SubscriptionAccountHealth; exports.__resetSharedAccountHealthForTests = _chunkYWL7YZWScjs.__resetSharedAccountHealthForTests; exports.getSharedAccountHealth = _chunkYWL7YZWScjs.getSharedAccountHealth; exports.resolveResetSeconds = _chunkYWL7YZWScjs.resolveResetSeconds; exports.setSharedAccountHealth = _chunkYWL7YZWScjs.setSharedAccountHealth;
|
|
@@ -31,6 +31,12 @@ declare const OVERLOAD_ENABLED_DEFAULT = true;
|
|
|
31
31
|
declare const AUTH_ERROR_TTL_MS: number;
|
|
32
32
|
/** Transient cooldown for a 5xx response or network failure. */
|
|
33
33
|
declare const SERVER_ERROR_TTL_MS: number;
|
|
34
|
+
/**
|
|
35
|
+
* Hard cap on a quota-exhaustion cooldown (the weekly usage window is ~1 week).
|
|
36
|
+
* A parsed/supplied deadline farther than this into the future is clamped, so a
|
|
37
|
+
* bogus parse can never strand an account indefinitely.
|
|
38
|
+
*/
|
|
39
|
+
declare const MAX_QUOTA_COOLDOWN_MS: number;
|
|
34
40
|
/** Per-account health record (all timers are epoch ms). Absent fields ⇒ healthy. */
|
|
35
41
|
interface HealthRecord {
|
|
36
42
|
/** From a 429 authoritative reset header — rate-limited until this instant. */
|
|
@@ -39,11 +45,20 @@ interface HealthRecord {
|
|
|
39
45
|
overloadUntil?: number;
|
|
40
46
|
/** From a final-401 / plain-403 / 5xx / thrown — transient cooldown until this. */
|
|
41
47
|
tempUnavailableUntil?: number;
|
|
48
|
+
/**
|
|
49
|
+
* From a detected quota/usage-limit error (e.g. Codex weekly window exhausted).
|
|
50
|
+
* Intentionally NOT cleared by a 2xx: while the account's credits/window are
|
|
51
|
+
* exhausted, in-flight sessions on the SAME account keep returning 2xx (Codex
|
|
52
|
+
* does not kill them mid-session), which would otherwise immediately heal a
|
|
53
|
+
* transient/rate-limit mark and re-strand every NEW session onto this account.
|
|
54
|
+
* Self-heals only when the deadline elapses.
|
|
55
|
+
*/
|
|
56
|
+
quotaExhaustedUntil?: number;
|
|
42
57
|
/** From a 403-ban — permanent, self-heal never clears it. */
|
|
43
58
|
blocked?: boolean;
|
|
44
59
|
}
|
|
45
60
|
/** The coarse health state surfaced to the admin accounts view (secret-free). */
|
|
46
|
-
type AccountHealthState = 'healthy' | 'rate_limited' | 'overloaded' | 'transient' | 'blocked';
|
|
61
|
+
type AccountHealthState = 'healthy' | 'rate_limited' | 'overloaded' | 'transient' | 'quota_exhausted' | 'blocked';
|
|
47
62
|
/** Admin-facing status projection for one account. */
|
|
48
63
|
interface AccountHealthStatus {
|
|
49
64
|
state: AccountHealthState;
|
|
@@ -68,7 +83,7 @@ interface AccountRecoveryEvent {
|
|
|
68
83
|
/** A recovery listener (fire-and-forget; the emitter never awaits it). */
|
|
69
84
|
type AccountRecoveryListener = (event: AccountRecoveryEvent) => void;
|
|
70
85
|
/** The coarse anomaly state an account transitioned into (secret-free). */
|
|
71
|
-
type AccountAnomalyState = 'blocked' | 'unauthorized' | 'rate_limited' | 'overloaded';
|
|
86
|
+
type AccountAnomalyState = 'blocked' | 'unauthorized' | 'rate_limited' | 'overloaded' | 'quota_exhausted';
|
|
72
87
|
/**
|
|
73
88
|
* The anomaly signal emitted when a HEALTHY account transitions to unhealthy —
|
|
74
89
|
* the additive union #5 (webhooks) consumes, which this tracker's frozen `kind`
|
|
@@ -192,6 +207,20 @@ declare class SubscriptionAccountHealth {
|
|
|
192
207
|
* - 2xx → clear rate-limit + transient state (keep `blocked`).
|
|
193
208
|
*/
|
|
194
209
|
recordUpstreamOutcome(providerId: string, accountId: string, input: RecordUpstreamOutcomeInput): void;
|
|
210
|
+
/**
|
|
211
|
+
* Mark an account quota/usage-exhausted until `untilEpochMs` (the Codex weekly
|
|
212
|
+
* usage-limit wall). Unlike the status-driven timers set by
|
|
213
|
+
* {@link recordUpstreamOutcome}, this mark is NOT cleared by a 2xx: in-flight
|
|
214
|
+
* sessions on the same account keep succeeding after the window is exhausted,
|
|
215
|
+
* so a traffic-driven clear would re-strand every NEW session onto this
|
|
216
|
+
* account. It excludes the account from NEW-session selection until the
|
|
217
|
+
* deadline elapses (existing sessions are unaffected — they already hold their
|
|
218
|
+
* token). Self-heals lazily on read and via {@link sweepRecoveries}.
|
|
219
|
+
* `untilEpochMs` is clamped to {@link MAX_QUOTA_COOLDOWN_MS}; an already-elapsed
|
|
220
|
+
* deadline is a no-op. Emits a `quota_exhausted` anomaly on the healthy→
|
|
221
|
+
* unhealthy edge.
|
|
222
|
+
*/
|
|
223
|
+
markQuotaExhausted(providerId: string, accountId: string, untilEpochMs: number, now?: number): void;
|
|
195
224
|
/** Whether a record is unhealthy at `now`: blocked, or any timer still future. */
|
|
196
225
|
private isUnhealthyAt;
|
|
197
226
|
/**
|
|
@@ -260,4 +289,4 @@ declare function setSharedAccountHealth(instance: SubscriptionAccountHealth): vo
|
|
|
260
289
|
/** Reset the shared singleton (tests / teardown only). */
|
|
261
290
|
declare function __resetSharedAccountHealthForTests(): void;
|
|
262
291
|
|
|
263
|
-
export { ACCOUNT_HEALTH_DIAGNOSTIC_LIMIT, AUTH_ERROR_TTL_MS, type AccountAnomalyEvent, type AccountAnomalyListener, type AccountAnomalyState, type AccountHealthDiagnostic, type AccountHealthDiagnosticFilter, type AccountHealthState, type AccountHealthStatus, type AccountRecoveryEvent, type AccountRecoveryListener, type HeadersLike, type HealthRecord, OVERLOAD_ENABLED_DEFAULT, OVERLOAD_TTL_MS, type RecordUpstreamOutcomeInput, SERVER_ERROR_TTL_MS, SubscriptionAccountHealth, type SubscriptionAccountHealthOptions, __resetSharedAccountHealthForTests, getSharedAccountHealth, resolveResetSeconds, setSharedAccountHealth };
|
|
292
|
+
export { ACCOUNT_HEALTH_DIAGNOSTIC_LIMIT, AUTH_ERROR_TTL_MS, type AccountAnomalyEvent, type AccountAnomalyListener, type AccountAnomalyState, type AccountHealthDiagnostic, type AccountHealthDiagnosticFilter, type AccountHealthState, type AccountHealthStatus, type AccountRecoveryEvent, type AccountRecoveryListener, type HeadersLike, type HealthRecord, MAX_QUOTA_COOLDOWN_MS, OVERLOAD_ENABLED_DEFAULT, OVERLOAD_TTL_MS, type RecordUpstreamOutcomeInput, SERVER_ERROR_TTL_MS, SubscriptionAccountHealth, type SubscriptionAccountHealthOptions, __resetSharedAccountHealthForTests, getSharedAccountHealth, resolveResetSeconds, setSharedAccountHealth };
|