@omnicross/contracts 0.1.6 → 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 +1 -1
- package/dist/account-tokens-types.d.ts +1 -1
- 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/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- 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
|
@@ -291,7 +291,7 @@ type SubscriptionAccountSanitized = {
|
|
|
291
291
|
* currently excluded from the pool (multi-account) or would surface the
|
|
292
292
|
* upstream's error (single-account). Secret-free.
|
|
293
293
|
*/
|
|
294
|
-
health?: 'healthy' | 'rate_limited' | 'overloaded' | 'transient' | 'blocked';
|
|
294
|
+
health?: 'healthy' | 'rate_limited' | 'overloaded' | 'transient' | 'quota_exhausted' | 'blocked';
|
|
295
295
|
/**
|
|
296
296
|
* ISO instant the current health cooldown elapses (absent for healthy /
|
|
297
297
|
* permanently-blocked). Lets the admin view render "rate-limited until .
|
|
@@ -291,7 +291,7 @@ type SubscriptionAccountSanitized = {
|
|
|
291
291
|
* currently excluded from the pool (multi-account) or would surface the
|
|
292
292
|
* upstream's error (single-account). Secret-free.
|
|
293
293
|
*/
|
|
294
|
-
health?: 'healthy' | 'rate_limited' | 'overloaded' | 'transient' | 'blocked';
|
|
294
|
+
health?: 'healthy' | 'rate_limited' | 'overloaded' | 'transient' | 'quota_exhausted' | 'blocked';
|
|
295
295
|
/**
|
|
296
296
|
* ISO instant the current health cooldown elapses (absent for healthy /
|
|
297
297
|
* permanently-blocked). Lets the admin view render "rate-limited until .
|
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 };
|
package/dist/audit-types.d.ts
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 };
|
package/dist/audit-types.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AccountClientIdentity, AccountTokensConfig, AuthMethod, ClaudeAuthMethod, ClaudeTokenConfig, CodexTokenConfig, GeminiTokenConfig, OAuthParams, ProxyConfig, SanitizedProxyConfig, SubscriptionAccountEntry, SubscriptionAccountSanitized, SubscriptionLevel, SyncWarningCode, TokenExchangeRequest, TokenStatus } from './account-tokens-types.cjs';
|
|
2
2
|
import { SubscriptionProviderId } from './subscription-types.cjs';
|
|
3
3
|
export { OpenCodeGoModelEntry, OpenCodeGoScenario, OpenCodeGoTokenConfig, OpenCodeGoTokenSanitized, ProviderChannel, SubscriptionListEntry, SubscriptionStatusEntry, legacyCliBackendToSubscriptionProvider, subscriptionTargetForSession } from './subscription-types.cjs';
|
|
4
|
-
export { AuditConfig, AuditQueryResult, AuditRecord, DEFAULT_AUDIT_CONFIG } from './audit-types.cjs';
|
|
4
|
+
export { AuditConfig, AuditQueryResult, AuditRecord, AuditStats, DEFAULT_AUDIT_CONFIG } from './audit-types.cjs';
|
|
5
5
|
export { BillingConfig, BillingDeliveryStatus, BillingEvent, DEFAULT_BILLING_CONFIG } from './billing-types.cjs';
|
|
6
6
|
export { KNOWN_MODELS, KnownModelCapabilities, MODEL_ALIASES, ResolvedModelCapabilities, applyAlias, lookupCanonicalCapabilities, normalizeModelId, resolveModelCapabilities } from './canonical-models.cjs';
|
|
7
7
|
export { AnthropicAudioContent, AnthropicChatRequest, AnthropicChatResponse, AnthropicContentPart, AnthropicImageContent, AnthropicMessage, AnthropicSystemContent, AnthropicTextContent, AnthropicThinkingContent, AnthropicTool, AnthropicToolResultContent, AnthropicToolUseContent, AnthropicVideoContent, ConversionConfig, OpenAIChatRequest, OpenAIChatResponse, OpenAIContentPart, OpenAIMessage, OpenAIStreamChunk, OpenAITool, OpenAIToolCall, SimpleChatAudio, SimpleChatImage, SimpleChatMessage, SimpleChatSession, SimpleChatVideo } from './completion-types.cjs';
|
|
@@ -16,7 +16,7 @@ export { DEFAULT_LITELLM_PRICING_URL, DEFAULT_OPENROUTER_PRICING_URL, PricingCon
|
|
|
16
16
|
export { CATALOG_VERSION, CODING_PLAN_URL_PRESETS, DEFAULT_SEED_PRESET_IDS, LLM_PROVIDER_PRESETS, MAX_CONCURRENCY_DEFAULTS, PROVIDER_MODEL_MAPPINGS, PROVIDER_SEARCH_CONFIGS, getAllProviderPresets, getCodingPlanBaseUrl, getPresetById, getPresetRevision, getProviderSearchConfig, resolveFollowProviderModel } from './provider-presets/index.cjs';
|
|
17
17
|
export { SUBSCRIPTION_MODEL_CATALOG, subscriptionProviderHasCatalog } from './subscription-model-catalog.cjs';
|
|
18
18
|
export { CANNOT_DISABLE_THINKING_PATTERNS, DEFAULT_MAX_TOKENS, EFFORT_RATIO, REASONING_MODEL_PATTERNS, THINKING_TOKEN_MAP, buildAnthropicThinking, buildGeminiThinkingConfig, buildQwenThinkingConfig, calculateThinkingBudget, canDisableThinking, findTokenLimit, getClaudeMaxTokens, getOpenAIReasoningEffort, isReasoningModel } from './thinking-config.cjs';
|
|
19
|
-
export { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals } from './usage-stats-types.cjs';
|
|
19
|
+
export { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageCacheKeySource, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals } from './usage-stats-types.cjs';
|
|
20
20
|
export { UsageEngineOrigin, UsageTokens } from './usage-types.cjs';
|
|
21
21
|
export { DEFAULT_VOUCHER_CONFIG, VoucherConfig, VoucherCreated, VoucherGrant, VoucherInfo, VoucherRecord, VoucherRedeemResult, VoucherStatus, VoucherType } from './voucher-types.cjs';
|
|
22
22
|
export { SanitizedWebhookConfig, SanitizedWebhookDestination, WEBHOOK_DESTINATION_TYPES, WEBHOOK_EVENT_KINDS, WebhookAnomalyState, WebhookConfig, WebhookDestination, WebhookDestinationType, WebhookEvent, WebhookEventKind, WebhookQuotaScope } from './webhook-types.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AccountClientIdentity, AccountTokensConfig, AuthMethod, ClaudeAuthMethod, ClaudeTokenConfig, CodexTokenConfig, GeminiTokenConfig, OAuthParams, ProxyConfig, SanitizedProxyConfig, SubscriptionAccountEntry, SubscriptionAccountSanitized, SubscriptionLevel, SyncWarningCode, TokenExchangeRequest, TokenStatus } from './account-tokens-types.js';
|
|
2
2
|
import { SubscriptionProviderId } from './subscription-types.js';
|
|
3
3
|
export { OpenCodeGoModelEntry, OpenCodeGoScenario, OpenCodeGoTokenConfig, OpenCodeGoTokenSanitized, ProviderChannel, SubscriptionListEntry, SubscriptionStatusEntry, legacyCliBackendToSubscriptionProvider, subscriptionTargetForSession } from './subscription-types.js';
|
|
4
|
-
export { AuditConfig, AuditQueryResult, AuditRecord, DEFAULT_AUDIT_CONFIG } from './audit-types.js';
|
|
4
|
+
export { AuditConfig, AuditQueryResult, AuditRecord, AuditStats, DEFAULT_AUDIT_CONFIG } from './audit-types.js';
|
|
5
5
|
export { BillingConfig, BillingDeliveryStatus, BillingEvent, DEFAULT_BILLING_CONFIG } from './billing-types.js';
|
|
6
6
|
export { KNOWN_MODELS, KnownModelCapabilities, MODEL_ALIASES, ResolvedModelCapabilities, applyAlias, lookupCanonicalCapabilities, normalizeModelId, resolveModelCapabilities } from './canonical-models.js';
|
|
7
7
|
export { AnthropicAudioContent, AnthropicChatRequest, AnthropicChatResponse, AnthropicContentPart, AnthropicImageContent, AnthropicMessage, AnthropicSystemContent, AnthropicTextContent, AnthropicThinkingContent, AnthropicTool, AnthropicToolResultContent, AnthropicToolUseContent, AnthropicVideoContent, ConversionConfig, OpenAIChatRequest, OpenAIChatResponse, OpenAIContentPart, OpenAIMessage, OpenAIStreamChunk, OpenAITool, OpenAIToolCall, SimpleChatAudio, SimpleChatImage, SimpleChatMessage, SimpleChatSession, SimpleChatVideo } from './completion-types.js';
|
|
@@ -16,7 +16,7 @@ export { DEFAULT_LITELLM_PRICING_URL, DEFAULT_OPENROUTER_PRICING_URL, PricingCon
|
|
|
16
16
|
export { CATALOG_VERSION, CODING_PLAN_URL_PRESETS, DEFAULT_SEED_PRESET_IDS, LLM_PROVIDER_PRESETS, MAX_CONCURRENCY_DEFAULTS, PROVIDER_MODEL_MAPPINGS, PROVIDER_SEARCH_CONFIGS, getAllProviderPresets, getCodingPlanBaseUrl, getPresetById, getPresetRevision, getProviderSearchConfig, resolveFollowProviderModel } from './provider-presets/index.js';
|
|
17
17
|
export { SUBSCRIPTION_MODEL_CATALOG, subscriptionProviderHasCatalog } from './subscription-model-catalog.js';
|
|
18
18
|
export { CANNOT_DISABLE_THINKING_PATTERNS, DEFAULT_MAX_TOKENS, EFFORT_RATIO, REASONING_MODEL_PATTERNS, THINKING_TOKEN_MAP, buildAnthropicThinking, buildGeminiThinkingConfig, buildQwenThinkingConfig, calculateThinkingBudget, canDisableThinking, findTokenLimit, getClaudeMaxTokens, getOpenAIReasoningEffort, isReasoningModel } from './thinking-config.js';
|
|
19
|
-
export { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals } from './usage-stats-types.js';
|
|
19
|
+
export { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageCacheKeySource, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals } from './usage-stats-types.js';
|
|
20
20
|
export { UsageEngineOrigin, UsageTokens } from './usage-types.js';
|
|
21
21
|
export { DEFAULT_VOUCHER_CONFIG, VoucherConfig, VoucherCreated, VoucherGrant, VoucherInfo, VoucherRecord, VoucherRedeemResult, VoucherStatus, VoucherType } from './voucher-types.js';
|
|
22
22
|
export { SanitizedWebhookConfig, SanitizedWebhookDestination, WEBHOOK_DESTINATION_TYPES, WEBHOOK_EVENT_KINDS, WebhookAnomalyState, WebhookConfig, WebhookDestination, WebhookDestinationType, WebhookEvent, WebhookEventKind, WebhookQuotaScope } from './webhook-types.js';
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,11 @@ import { UsageEngineOrigin } from './usage-types.cjs';
|
|
|
12
12
|
* @module usage-stats-types
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* How the prompt-cache key attached to a request was obtained. Values describe
|
|
17
|
+
* only the extraction path; raw session ids and cache keys are never persisted.
|
|
18
|
+
*/
|
|
19
|
+
type UsageCacheKeySource = 'client' | 'session-header' | 'thread-header' | 'body-session-id' | 'body-thread-id' | 'content-fingerprint' | 'none';
|
|
15
20
|
/**
|
|
16
21
|
* One captured LLM request, as persisted by the host store.
|
|
17
22
|
*
|
|
@@ -43,6 +48,10 @@ interface UsageEventRecord {
|
|
|
43
48
|
runId?: string | null;
|
|
44
49
|
/** Host event-correlation id for this LLM call. NULL when unknown. Additive / nullable. */
|
|
45
50
|
eventId?: string | null;
|
|
51
|
+
/** Safe prompt-cache-key provenance; absent on historical/non-attributed rows. */
|
|
52
|
+
cacheKeySource?: UsageCacheKeySource;
|
|
53
|
+
/** True only when the gateway generated and attached the prompt-cache key. */
|
|
54
|
+
cacheKeyInjected?: boolean;
|
|
46
55
|
}
|
|
47
56
|
/** Input shape for inserting a new event. `id` and `ts` are filled by the recorder/store. */
|
|
48
57
|
type UsageEventInput = Omit<UsageEventRecord, 'id' | 'ts'> & {
|
|
@@ -69,6 +78,12 @@ interface UsageTotals {
|
|
|
69
78
|
costSavedByCacheUsd: number;
|
|
70
79
|
/** Number of events contributing to these totals. */
|
|
71
80
|
eventCount: number;
|
|
81
|
+
/** Events with at least one prompt-side token, eligible for cache-rate metrics. */
|
|
82
|
+
cacheEligibleEventCount: number;
|
|
83
|
+
/** Eligible events that read zero tokens from cache. */
|
|
84
|
+
coldCacheEventCount: number;
|
|
85
|
+
/** Median of per-event cache-read ratios; null when no event is eligible. */
|
|
86
|
+
medianCacheHitRate: number | null;
|
|
72
87
|
}
|
|
73
88
|
/** Granularity for a usage time-series query. `week` is NOT a bucket — a "week" view is a `day` bucket over a 7-day range. */
|
|
74
89
|
type UsageTimeBucket = 'hour' | 'day' | 'month';
|
|
@@ -161,4 +176,4 @@ interface MessageUsageRow {
|
|
|
161
176
|
costSavedByCacheUsd: number;
|
|
162
177
|
}
|
|
163
178
|
|
|
164
|
-
export type { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals };
|
|
179
|
+
export type { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageCacheKeySource, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals };
|
|
@@ -12,6 +12,11 @@ import { UsageEngineOrigin } from './usage-types.js';
|
|
|
12
12
|
* @module usage-stats-types
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* How the prompt-cache key attached to a request was obtained. Values describe
|
|
17
|
+
* only the extraction path; raw session ids and cache keys are never persisted.
|
|
18
|
+
*/
|
|
19
|
+
type UsageCacheKeySource = 'client' | 'session-header' | 'thread-header' | 'body-session-id' | 'body-thread-id' | 'content-fingerprint' | 'none';
|
|
15
20
|
/**
|
|
16
21
|
* One captured LLM request, as persisted by the host store.
|
|
17
22
|
*
|
|
@@ -43,6 +48,10 @@ interface UsageEventRecord {
|
|
|
43
48
|
runId?: string | null;
|
|
44
49
|
/** Host event-correlation id for this LLM call. NULL when unknown. Additive / nullable. */
|
|
45
50
|
eventId?: string | null;
|
|
51
|
+
/** Safe prompt-cache-key provenance; absent on historical/non-attributed rows. */
|
|
52
|
+
cacheKeySource?: UsageCacheKeySource;
|
|
53
|
+
/** True only when the gateway generated and attached the prompt-cache key. */
|
|
54
|
+
cacheKeyInjected?: boolean;
|
|
46
55
|
}
|
|
47
56
|
/** Input shape for inserting a new event. `id` and `ts` are filled by the recorder/store. */
|
|
48
57
|
type UsageEventInput = Omit<UsageEventRecord, 'id' | 'ts'> & {
|
|
@@ -69,6 +78,12 @@ interface UsageTotals {
|
|
|
69
78
|
costSavedByCacheUsd: number;
|
|
70
79
|
/** Number of events contributing to these totals. */
|
|
71
80
|
eventCount: number;
|
|
81
|
+
/** Events with at least one prompt-side token, eligible for cache-rate metrics. */
|
|
82
|
+
cacheEligibleEventCount: number;
|
|
83
|
+
/** Eligible events that read zero tokens from cache. */
|
|
84
|
+
coldCacheEventCount: number;
|
|
85
|
+
/** Median of per-event cache-read ratios; null when no event is eligible. */
|
|
86
|
+
medianCacheHitRate: number | null;
|
|
72
87
|
}
|
|
73
88
|
/** Granularity for a usage time-series query. `week` is NOT a bucket — a "week" view is a `day` bucket over a 7-day range. */
|
|
74
89
|
type UsageTimeBucket = 'hour' | 'day' | 'month';
|
|
@@ -161,4 +176,4 @@ interface MessageUsageRow {
|
|
|
161
176
|
costSavedByCacheUsd: number;
|
|
162
177
|
}
|
|
163
178
|
|
|
164
|
-
export type { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals };
|
|
179
|
+
export type { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageCacheKeySource, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals };
|
package/dist/webhook-types.d.cts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* @module webhook-types
|
|
21
21
|
*/
|
|
22
22
|
/** The coarse anomaly state an account transitioned into (secret-free). */
|
|
23
|
-
type WebhookAnomalyState = 'blocked' | 'unauthorized' | 'rate_limited' | 'overloaded';
|
|
23
|
+
type WebhookAnomalyState = 'blocked' | 'unauthorized' | 'rate_limited' | 'overloaded' | 'quota_exhausted';
|
|
24
24
|
/** The cost-limit scope a key quota event refers to. */
|
|
25
25
|
type WebhookQuotaScope = 'daily' | 'weekly' | 'total';
|
|
26
26
|
/**
|
package/dist/webhook-types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* @module webhook-types
|
|
21
21
|
*/
|
|
22
22
|
/** The coarse anomaly state an account transitioned into (secret-free). */
|
|
23
|
-
type WebhookAnomalyState = 'blocked' | 'unauthorized' | 'rate_limited' | 'overloaded';
|
|
23
|
+
type WebhookAnomalyState = 'blocked' | 'unauthorized' | 'rate_limited' | 'overloaded' | 'quota_exhausted';
|
|
24
24
|
/** The cost-limit scope a key quota event refers to. */
|
|
25
25
|
type WebhookQuotaScope = 'daily' | 'weekly' | 'total';
|
|
26
26
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnicross/contracts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Dependency-light, host-agnostic contract types + runtime-value helpers shared by the @omnicross/* packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sayo (https://github.com/Dumoedss)",
|