@omnicross/contracts 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.
@@ -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 .
@@ -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 };
@@ -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 };
@@ -2,7 +2,7 @@
2
2
  var DEFAULT_AUDIT_CONFIG = {
3
3
  enabled: false,
4
4
  captureBodies: false,
5
- maxBodyBytes: 8192,
5
+ maxBodyBytes: -1,
6
6
  retentionDays: 7,
7
7
  trustForwardedFor: false
8
8
  };
package/dist/index.cjs CHANGED
@@ -79,7 +79,7 @@ module.exports = __toCommonJS(index_exports);
79
79
  var DEFAULT_AUDIT_CONFIG = {
80
80
  enabled: false,
81
81
  captureBodies: false,
82
- maxBodyBytes: 8192,
82
+ maxBodyBytes: -1,
83
83
  retentionDays: 7,
84
84
  trustForwardedFor: false
85
85
  };
@@ -573,6 +573,7 @@ var DEFAULT_SEED_PRESET_IDS = [
573
573
  // MiniMax + Xiaomi MiMo bumped up next to Kimi per UX preference —
574
574
  // popular Anthropic-format Chinese providers cluster together.
575
575
  "openrouter",
576
+ "openrouter-response",
576
577
  "zhipu",
577
578
  "zhipu-bigmodel",
578
579
  "kimi",
@@ -1615,6 +1616,63 @@ var openrouter_default = {
1615
1616
  ]
1616
1617
  };
1617
1618
 
1619
+ // src/provider-presets/presets/openrouter-response.json
1620
+ var openrouter_response_default = {
1621
+ id: "openrouter-response",
1622
+ presetId: "openrouter-response",
1623
+ name: "OpenRouter (Responses API)",
1624
+ apiFormat: "openai-response",
1625
+ api_base_url: "https://openrouter.ai/api/v1",
1626
+ modelsEndpoint: "https://openrouter.ai/api/v1/models",
1627
+ models: [
1628
+ "anthropic/claude-sonnet-4-6",
1629
+ "openai/gpt-5",
1630
+ "google/gemini-3.1-pro",
1631
+ "meta-llama/llama-3.3-70b-instruct",
1632
+ "deepseek/deepseek-v3.2"
1633
+ ],
1634
+ modelConfigs: [
1635
+ {
1636
+ id: "anthropic/claude-sonnet-4-6",
1637
+ name: "Claude Sonnet 4.6 (OpenRouter Responses)",
1638
+ enabled: true
1639
+ },
1640
+ {
1641
+ id: "openai/gpt-5",
1642
+ name: "GPT-5 (OpenRouter Responses)",
1643
+ enabled: true
1644
+ },
1645
+ {
1646
+ id: "google/gemini-3.1-pro",
1647
+ name: "Gemini 3.1 Pro (OpenRouter Responses)",
1648
+ enabled: true
1649
+ },
1650
+ {
1651
+ id: "meta-llama/llama-3.3-70b-instruct",
1652
+ name: "Llama 3.3 70B (OpenRouter Responses)",
1653
+ enabled: true
1654
+ },
1655
+ {
1656
+ id: "deepseek/deepseek-v3.2",
1657
+ name: "DeepSeek V3.2 (OpenRouter Responses)",
1658
+ enabled: true
1659
+ }
1660
+ ],
1661
+ description: "OpenRouter Responses API \u2014 \u539F\u6837\u900F\u4F20 Responses \u53C2\u6570\uFF0C\u652F\u6301 Claude \u663E\u5F0F\u7F13\u5B58\u63A7\u5236",
1662
+ icon: "openrouter",
1663
+ website: "https://openrouter.ai",
1664
+ docsUrl: "https://openrouter.ai/docs/api-reference/responses/overview",
1665
+ defaultSettings: {
1666
+ temperature: 0.7,
1667
+ maxTokens: 4096
1668
+ },
1669
+ isSystem: true,
1670
+ features: [
1671
+ "vision",
1672
+ "reasoning"
1673
+ ]
1674
+ };
1675
+
1618
1676
  // src/provider-presets/presets/perplexity.json
1619
1677
  var perplexity_default = {
1620
1678
  id: "perplexity",
@@ -2335,6 +2393,7 @@ var RAW_PRESETS_IN_ORDER = [
2335
2393
  openai_response_default,
2336
2394
  siliconflow_default,
2337
2395
  openrouter_default,
2396
+ openrouter_response_default,
2338
2397
  mistral_default,
2339
2398
  together_default,
2340
2399
  perplexity_default,
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
@@ -2,7 +2,7 @@
2
2
  var DEFAULT_AUDIT_CONFIG = {
3
3
  enabled: false,
4
4
  captureBodies: false,
5
- maxBodyBytes: 8192,
5
+ maxBodyBytes: -1,
6
6
  retentionDays: 7,
7
7
  trustForwardedFor: false
8
8
  };
@@ -496,6 +496,7 @@ var DEFAULT_SEED_PRESET_IDS = [
496
496
  // MiniMax + Xiaomi MiMo bumped up next to Kimi per UX preference —
497
497
  // popular Anthropic-format Chinese providers cluster together.
498
498
  "openrouter",
499
+ "openrouter-response",
499
500
  "zhipu",
500
501
  "zhipu-bigmodel",
501
502
  "kimi",
@@ -1538,6 +1539,63 @@ var openrouter_default = {
1538
1539
  ]
1539
1540
  };
1540
1541
 
1542
+ // src/provider-presets/presets/openrouter-response.json
1543
+ var openrouter_response_default = {
1544
+ id: "openrouter-response",
1545
+ presetId: "openrouter-response",
1546
+ name: "OpenRouter (Responses API)",
1547
+ apiFormat: "openai-response",
1548
+ api_base_url: "https://openrouter.ai/api/v1",
1549
+ modelsEndpoint: "https://openrouter.ai/api/v1/models",
1550
+ models: [
1551
+ "anthropic/claude-sonnet-4-6",
1552
+ "openai/gpt-5",
1553
+ "google/gemini-3.1-pro",
1554
+ "meta-llama/llama-3.3-70b-instruct",
1555
+ "deepseek/deepseek-v3.2"
1556
+ ],
1557
+ modelConfigs: [
1558
+ {
1559
+ id: "anthropic/claude-sonnet-4-6",
1560
+ name: "Claude Sonnet 4.6 (OpenRouter Responses)",
1561
+ enabled: true
1562
+ },
1563
+ {
1564
+ id: "openai/gpt-5",
1565
+ name: "GPT-5 (OpenRouter Responses)",
1566
+ enabled: true
1567
+ },
1568
+ {
1569
+ id: "google/gemini-3.1-pro",
1570
+ name: "Gemini 3.1 Pro (OpenRouter Responses)",
1571
+ enabled: true
1572
+ },
1573
+ {
1574
+ id: "meta-llama/llama-3.3-70b-instruct",
1575
+ name: "Llama 3.3 70B (OpenRouter Responses)",
1576
+ enabled: true
1577
+ },
1578
+ {
1579
+ id: "deepseek/deepseek-v3.2",
1580
+ name: "DeepSeek V3.2 (OpenRouter Responses)",
1581
+ enabled: true
1582
+ }
1583
+ ],
1584
+ description: "OpenRouter Responses API \u2014 \u539F\u6837\u900F\u4F20 Responses \u53C2\u6570\uFF0C\u652F\u6301 Claude \u663E\u5F0F\u7F13\u5B58\u63A7\u5236",
1585
+ icon: "openrouter",
1586
+ website: "https://openrouter.ai",
1587
+ docsUrl: "https://openrouter.ai/docs/api-reference/responses/overview",
1588
+ defaultSettings: {
1589
+ temperature: 0.7,
1590
+ maxTokens: 4096
1591
+ },
1592
+ isSystem: true,
1593
+ features: [
1594
+ "vision",
1595
+ "reasoning"
1596
+ ]
1597
+ };
1598
+
1541
1599
  // src/provider-presets/presets/perplexity.json
1542
1600
  var perplexity_default = {
1543
1601
  id: "perplexity",
@@ -2258,6 +2316,7 @@ var RAW_PRESETS_IN_ORDER = [
2258
2316
  openai_response_default,
2259
2317
  siliconflow_default,
2260
2318
  openrouter_default,
2319
+ openrouter_response_default,
2261
2320
  mistral_default,
2262
2321
  together_default,
2263
2322
  perplexity_default,
@@ -232,6 +232,7 @@ var DEFAULT_SEED_PRESET_IDS = [
232
232
  // MiniMax + Xiaomi MiMo bumped up next to Kimi per UX preference —
233
233
  // popular Anthropic-format Chinese providers cluster together.
234
234
  "openrouter",
235
+ "openrouter-response",
235
236
  "zhipu",
236
237
  "zhipu-bigmodel",
237
238
  "kimi",
@@ -1274,6 +1275,63 @@ var openrouter_default = {
1274
1275
  ]
1275
1276
  };
1276
1277
 
1278
+ // src/provider-presets/presets/openrouter-response.json
1279
+ var openrouter_response_default = {
1280
+ id: "openrouter-response",
1281
+ presetId: "openrouter-response",
1282
+ name: "OpenRouter (Responses API)",
1283
+ apiFormat: "openai-response",
1284
+ api_base_url: "https://openrouter.ai/api/v1",
1285
+ modelsEndpoint: "https://openrouter.ai/api/v1/models",
1286
+ models: [
1287
+ "anthropic/claude-sonnet-4-6",
1288
+ "openai/gpt-5",
1289
+ "google/gemini-3.1-pro",
1290
+ "meta-llama/llama-3.3-70b-instruct",
1291
+ "deepseek/deepseek-v3.2"
1292
+ ],
1293
+ modelConfigs: [
1294
+ {
1295
+ id: "anthropic/claude-sonnet-4-6",
1296
+ name: "Claude Sonnet 4.6 (OpenRouter Responses)",
1297
+ enabled: true
1298
+ },
1299
+ {
1300
+ id: "openai/gpt-5",
1301
+ name: "GPT-5 (OpenRouter Responses)",
1302
+ enabled: true
1303
+ },
1304
+ {
1305
+ id: "google/gemini-3.1-pro",
1306
+ name: "Gemini 3.1 Pro (OpenRouter Responses)",
1307
+ enabled: true
1308
+ },
1309
+ {
1310
+ id: "meta-llama/llama-3.3-70b-instruct",
1311
+ name: "Llama 3.3 70B (OpenRouter Responses)",
1312
+ enabled: true
1313
+ },
1314
+ {
1315
+ id: "deepseek/deepseek-v3.2",
1316
+ name: "DeepSeek V3.2 (OpenRouter Responses)",
1317
+ enabled: true
1318
+ }
1319
+ ],
1320
+ description: "OpenRouter Responses API \u2014 \u539F\u6837\u900F\u4F20 Responses \u53C2\u6570\uFF0C\u652F\u6301 Claude \u663E\u5F0F\u7F13\u5B58\u63A7\u5236",
1321
+ icon: "openrouter",
1322
+ website: "https://openrouter.ai",
1323
+ docsUrl: "https://openrouter.ai/docs/api-reference/responses/overview",
1324
+ defaultSettings: {
1325
+ temperature: 0.7,
1326
+ maxTokens: 4096
1327
+ },
1328
+ isSystem: true,
1329
+ features: [
1330
+ "vision",
1331
+ "reasoning"
1332
+ ]
1333
+ };
1334
+
1277
1335
  // src/provider-presets/presets/perplexity.json
1278
1336
  var perplexity_default = {
1279
1337
  id: "perplexity",
@@ -1994,6 +2052,7 @@ var RAW_PRESETS_IN_ORDER = [
1994
2052
  openai_response_default,
1995
2053
  siliconflow_default,
1996
2054
  openrouter_default,
2055
+ openrouter_response_default,
1997
2056
  mistral_default,
1998
2057
  together_default,
1999
2058
  perplexity_default,
@@ -193,6 +193,7 @@ var DEFAULT_SEED_PRESET_IDS = [
193
193
  // MiniMax + Xiaomi MiMo bumped up next to Kimi per UX preference —
194
194
  // popular Anthropic-format Chinese providers cluster together.
195
195
  "openrouter",
196
+ "openrouter-response",
196
197
  "zhipu",
197
198
  "zhipu-bigmodel",
198
199
  "kimi",
@@ -1235,6 +1236,63 @@ var openrouter_default = {
1235
1236
  ]
1236
1237
  };
1237
1238
 
1239
+ // src/provider-presets/presets/openrouter-response.json
1240
+ var openrouter_response_default = {
1241
+ id: "openrouter-response",
1242
+ presetId: "openrouter-response",
1243
+ name: "OpenRouter (Responses API)",
1244
+ apiFormat: "openai-response",
1245
+ api_base_url: "https://openrouter.ai/api/v1",
1246
+ modelsEndpoint: "https://openrouter.ai/api/v1/models",
1247
+ models: [
1248
+ "anthropic/claude-sonnet-4-6",
1249
+ "openai/gpt-5",
1250
+ "google/gemini-3.1-pro",
1251
+ "meta-llama/llama-3.3-70b-instruct",
1252
+ "deepseek/deepseek-v3.2"
1253
+ ],
1254
+ modelConfigs: [
1255
+ {
1256
+ id: "anthropic/claude-sonnet-4-6",
1257
+ name: "Claude Sonnet 4.6 (OpenRouter Responses)",
1258
+ enabled: true
1259
+ },
1260
+ {
1261
+ id: "openai/gpt-5",
1262
+ name: "GPT-5 (OpenRouter Responses)",
1263
+ enabled: true
1264
+ },
1265
+ {
1266
+ id: "google/gemini-3.1-pro",
1267
+ name: "Gemini 3.1 Pro (OpenRouter Responses)",
1268
+ enabled: true
1269
+ },
1270
+ {
1271
+ id: "meta-llama/llama-3.3-70b-instruct",
1272
+ name: "Llama 3.3 70B (OpenRouter Responses)",
1273
+ enabled: true
1274
+ },
1275
+ {
1276
+ id: "deepseek/deepseek-v3.2",
1277
+ name: "DeepSeek V3.2 (OpenRouter Responses)",
1278
+ enabled: true
1279
+ }
1280
+ ],
1281
+ description: "OpenRouter Responses API \u2014 \u539F\u6837\u900F\u4F20 Responses \u53C2\u6570\uFF0C\u652F\u6301 Claude \u663E\u5F0F\u7F13\u5B58\u63A7\u5236",
1282
+ icon: "openrouter",
1283
+ website: "https://openrouter.ai",
1284
+ docsUrl: "https://openrouter.ai/docs/api-reference/responses/overview",
1285
+ defaultSettings: {
1286
+ temperature: 0.7,
1287
+ maxTokens: 4096
1288
+ },
1289
+ isSystem: true,
1290
+ features: [
1291
+ "vision",
1292
+ "reasoning"
1293
+ ]
1294
+ };
1295
+
1238
1296
  // src/provider-presets/presets/perplexity.json
1239
1297
  var perplexity_default = {
1240
1298
  id: "perplexity",
@@ -1955,6 +2013,7 @@ var RAW_PRESETS_IN_ORDER = [
1955
2013
  openai_response_default,
1956
2014
  siliconflow_default,
1957
2015
  openrouter_default,
2016
+ openrouter_response_default,
1958
2017
  mistral_default,
1959
2018
  together_default,
1960
2019
  perplexity_default,
@@ -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
  *
@@ -41,8 +46,18 @@ interface UsageEventRecord {
41
46
  rawUsage: string | null;
42
47
  /** Host run-correlation id (owning agent-run, when the host has one). Additive / nullable. */
43
48
  runId?: string | null;
49
+ /** Token-free process-local Route Lease id; never the route bearer token. */
50
+ routeLeaseId?: string | null;
51
+ /** Bounded logical Route Lease consumer. */
52
+ routeLeaseConsumer?: string | null;
53
+ /** Bounded Route Lease stage attribution. */
54
+ routeLeaseStageId?: string | null;
44
55
  /** Host event-correlation id for this LLM call. NULL when unknown. Additive / nullable. */
45
56
  eventId?: string | null;
57
+ /** Safe prompt-cache-key provenance; absent on historical/non-attributed rows. */
58
+ cacheKeySource?: UsageCacheKeySource;
59
+ /** True only when the gateway generated and attached the prompt-cache key. */
60
+ cacheKeyInjected?: boolean;
46
61
  }
47
62
  /** Input shape for inserting a new event. `id` and `ts` are filled by the recorder/store. */
48
63
  type UsageEventInput = Omit<UsageEventRecord, 'id' | 'ts'> & {
@@ -69,6 +84,12 @@ interface UsageTotals {
69
84
  costSavedByCacheUsd: number;
70
85
  /** Number of events contributing to these totals. */
71
86
  eventCount: number;
87
+ /** Events with at least one prompt-side token, eligible for cache-rate metrics. */
88
+ cacheEligibleEventCount: number;
89
+ /** Eligible events that read zero tokens from cache. */
90
+ coldCacheEventCount: number;
91
+ /** Median of per-event cache-read ratios; null when no event is eligible. */
92
+ medianCacheHitRate: number | null;
72
93
  }
73
94
  /** 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
95
  type UsageTimeBucket = 'hour' | 'day' | 'month';
@@ -161,4 +182,4 @@ interface MessageUsageRow {
161
182
  costSavedByCacheUsd: number;
162
183
  }
163
184
 
164
- export type { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals };
185
+ 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
  *
@@ -41,8 +46,18 @@ interface UsageEventRecord {
41
46
  rawUsage: string | null;
42
47
  /** Host run-correlation id (owning agent-run, when the host has one). Additive / nullable. */
43
48
  runId?: string | null;
49
+ /** Token-free process-local Route Lease id; never the route bearer token. */
50
+ routeLeaseId?: string | null;
51
+ /** Bounded logical Route Lease consumer. */
52
+ routeLeaseConsumer?: string | null;
53
+ /** Bounded Route Lease stage attribution. */
54
+ routeLeaseStageId?: string | null;
44
55
  /** Host event-correlation id for this LLM call. NULL when unknown. Additive / nullable. */
45
56
  eventId?: string | null;
57
+ /** Safe prompt-cache-key provenance; absent on historical/non-attributed rows. */
58
+ cacheKeySource?: UsageCacheKeySource;
59
+ /** True only when the gateway generated and attached the prompt-cache key. */
60
+ cacheKeyInjected?: boolean;
46
61
  }
47
62
  /** Input shape for inserting a new event. `id` and `ts` are filled by the recorder/store. */
48
63
  type UsageEventInput = Omit<UsageEventRecord, 'id' | 'ts'> & {
@@ -69,6 +84,12 @@ interface UsageTotals {
69
84
  costSavedByCacheUsd: number;
70
85
  /** Number of events contributing to these totals. */
71
86
  eventCount: number;
87
+ /** Events with at least one prompt-side token, eligible for cache-rate metrics. */
88
+ cacheEligibleEventCount: number;
89
+ /** Eligible events that read zero tokens from cache. */
90
+ coldCacheEventCount: number;
91
+ /** Median of per-event cache-read ratios; null when no event is eligible. */
92
+ medianCacheHitRate: number | null;
72
93
  }
73
94
  /** 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
95
  type UsageTimeBucket = 'hour' | 'day' | 'month';
@@ -161,4 +182,4 @@ interface MessageUsageRow {
161
182
  costSavedByCacheUsd: number;
162
183
  }
163
184
 
164
- export type { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals };
185
+ export type { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageCacheKeySource, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals };
@@ -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
  /**
@@ -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.6",
3
+ "version": "0.1.8",
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)",