@omnicross/contracts 0.1.2 → 0.1.3

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.
Files changed (41) hide show
  1. package/dist/account-tokens-types.d.cts +157 -1
  2. package/dist/account-tokens-types.d.ts +157 -1
  3. package/dist/audit-types.cjs +36 -0
  4. package/dist/audit-types.d.cts +98 -0
  5. package/dist/audit-types.d.ts +98 -0
  6. package/dist/audit-types.js +11 -0
  7. package/dist/billing-types.cjs +33 -0
  8. package/dist/billing-types.d.cts +98 -0
  9. package/dist/billing-types.d.ts +98 -0
  10. package/dist/billing-types.js +8 -0
  11. package/dist/canonical-models.d.cts +1 -1
  12. package/dist/canonical-models.d.ts +1 -1
  13. package/dist/endpoint-resolver.d.cts +1 -1
  14. package/dist/endpoint-resolver.d.ts +1 -1
  15. package/dist/health-logging-types.cjs +32 -0
  16. package/dist/health-logging-types.d.cts +68 -0
  17. package/dist/health-logging-types.d.ts +68 -0
  18. package/dist/health-logging-types.js +7 -0
  19. package/dist/index.cjs +48 -0
  20. package/dist/index.d.cts +8 -3
  21. package/dist/index.d.ts +8 -3
  22. package/dist/index.js +42 -0
  23. package/dist/{llm-config-D1jKQLVp.d.ts → llm-config-CKOaFFdy.d.ts} +8 -1
  24. package/dist/{llm-config-CQjOimv2.d.cts → llm-config-DeWNx1ig.d.cts} +8 -1
  25. package/dist/llm-config.d.cts +1 -1
  26. package/dist/llm-config.d.ts +1 -1
  27. package/dist/provider-presets/index.d.cts +2 -2
  28. package/dist/provider-presets/index.d.ts +2 -2
  29. package/dist/thinking-config.d.cts +1 -1
  30. package/dist/thinking-config.d.ts +1 -1
  31. package/dist/usage-stats-types.d.cts +22 -1
  32. package/dist/usage-stats-types.d.ts +22 -1
  33. package/dist/voucher-types.cjs +32 -0
  34. package/dist/voucher-types.d.cts +153 -0
  35. package/dist/voucher-types.d.ts +153 -0
  36. package/dist/voucher-types.js +7 -0
  37. package/dist/webhook-types.cjs +40 -0
  38. package/dist/webhook-types.d.cts +122 -0
  39. package/dist/webhook-types.d.ts +122 -0
  40. package/dist/webhook-types.js +14 -0
  41. package/package.json +26 -1
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Billing-event-stream contracts (billing-event-stream, design D1/D6).
3
+ *
4
+ * Two dependency-light shapes shared across the `@omnicross/*` packages:
5
+ * - `BillingEvent` — the FROZEN per-request metered fact an EXTERNAL consumer
6
+ * ingests (a metering service, a data warehouse, a billing platform). It is
7
+ * SECRET-FREE BY CONSTRUCTION: it carries the outbound key ID (an id, NEVER
8
+ * the key material/hash) and NEVER a token, Authorization header, or the
9
+ * signing secret. Its `id` (the request id) doubles as the consumer's
10
+ * IDEMPOTENCY KEY — delivery is at-least-once, so a consumer dedupes by `id`.
11
+ * A secret-scan test asserts no key/token/secret pattern survives in a
12
+ * written/POSTed event.
13
+ * - `BillingConfig` — the `billing` config segment. Default OFF (zero
14
+ * regression). Carries the OPTIONAL POST `endpoint` (absent ⇒ ledger-only
15
+ * mode) and the OPTIONAL HMAC `secret` (the ONLY secret — encrypted at rest +
16
+ * masked in admin, never in a payload/log).
17
+ *
18
+ * Distinct from `usage-events.jsonl` (internal dashboard telemetry): billing is
19
+ * the external-facing metered fact with its OWN schema + delivery + HMAC.
20
+ *
21
+ * @module billing-types
22
+ */
23
+ /**
24
+ * One per-request billing event (design D1) — the metered fact for external
25
+ * consumption. Produced at the post-response point from the SAME computed cost
26
+ * the usage telemetry records (no double pricing). NO field ever holds key
27
+ * material, an upstream token, or the HMAC signing secret.
28
+ */
29
+ interface BillingEvent {
30
+ /**
31
+ * Request id — the consumer's IDEMPOTENCY KEY. Stable for one event across
32
+ * delivery RETRIES (the retry sweep re-POSTs the SAME id) so an at-least-once
33
+ * consumer applies it exactly once. NOT any secret.
34
+ */
35
+ id: string;
36
+ /** Epoch ms the request was billed (the request timestamp). */
37
+ ts: number;
38
+ /** Outbound key id (attribution) — NEVER the key secret/hash. Null when unattributed. */
39
+ keyId?: string | null;
40
+ /** Resolved upstream model the request billed against. */
41
+ model: string;
42
+ /** Upstream provider id (or `'byo'`). */
43
+ provider?: string;
44
+ /** Re-auth mode the request billed under (BYO key vs subscription OAuth). */
45
+ authMode: 'byo' | 'subscription';
46
+ /** Prompt-side token count. */
47
+ inputTokens: number;
48
+ /** Completion-side token count. */
49
+ outputTokens: number;
50
+ /** Cost in USD (the SAME value the usage telemetry recorded). */
51
+ costUsd: number;
52
+ /** HTTP status of the billed request. */
53
+ status: number;
54
+ }
55
+ /**
56
+ * The `billing` config segment (design D6), normalized like `audit`.
57
+ * Absent/`enabled:false` ⇒ no sink wired ⇒ `publishBillingEvent` is a no-op ⇒
58
+ * no append, no POST, byte-identical zero regression. `enabled` WITHOUT an
59
+ * `endpoint` is a first-class LEDGER-ONLY mode (the durable jsonl IS the product;
60
+ * an external tailer consumes it). The `secret` is the ONLY secret field
61
+ * (encrypted at rest + masked in admin).
62
+ */
63
+ interface BillingConfig {
64
+ /** Master switch; default FALSE (zero regression). */
65
+ enabled: boolean;
66
+ /**
67
+ * POST target for the built-in delivery. ABSENT ⇒ ledger-only mode: events are
68
+ * durably appended and an external consumer tails the jsonl directly (no push).
69
+ */
70
+ endpoint?: string;
71
+ /**
72
+ * HMAC-SHA256 signing key — a SECRET. When set, each POST carries
73
+ * `X-Omnicross-Billing-Signature: sha256=<hmac hex of body>`. Encrypted at rest
74
+ * + masked in admin views; the secret ONLY signs, it NEVER travels in the event
75
+ * payload or a log line.
76
+ */
77
+ secret?: string;
78
+ /**
79
+ * Stop RE-POSTing an undelivered event after this age (ms); default 24h,
80
+ * clamped. This governs RETRY only — an over-age undelivered event is RETAINED
81
+ * in the ledger for reconciliation, NEVER deleted (a billing ledger is a
82
+ * financial record).
83
+ */
84
+ maxRetryAgeMs: number;
85
+ }
86
+ /** Frozen defaults for the `billing` segment (SSOT). 24h retry bound. */
87
+ declare const DEFAULT_BILLING_CONFIG: BillingConfig;
88
+ /** Aggregate delivery status the authed admin surfaces (secret-free counts). */
89
+ interface BillingDeliveryStatus {
90
+ /** Total events in the durable ledger. */
91
+ total: number;
92
+ /** Events an external endpoint has acknowledged (delivered). */
93
+ delivered: number;
94
+ /** Events not yet delivered (still retried within `maxRetryAgeMs`, then retained). */
95
+ pending: number;
96
+ }
97
+
98
+ export { type BillingConfig, type BillingDeliveryStatus, type BillingEvent, DEFAULT_BILLING_CONFIG };
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Billing-event-stream contracts (billing-event-stream, design D1/D6).
3
+ *
4
+ * Two dependency-light shapes shared across the `@omnicross/*` packages:
5
+ * - `BillingEvent` — the FROZEN per-request metered fact an EXTERNAL consumer
6
+ * ingests (a metering service, a data warehouse, a billing platform). It is
7
+ * SECRET-FREE BY CONSTRUCTION: it carries the outbound key ID (an id, NEVER
8
+ * the key material/hash) and NEVER a token, Authorization header, or the
9
+ * signing secret. Its `id` (the request id) doubles as the consumer's
10
+ * IDEMPOTENCY KEY — delivery is at-least-once, so a consumer dedupes by `id`.
11
+ * A secret-scan test asserts no key/token/secret pattern survives in a
12
+ * written/POSTed event.
13
+ * - `BillingConfig` — the `billing` config segment. Default OFF (zero
14
+ * regression). Carries the OPTIONAL POST `endpoint` (absent ⇒ ledger-only
15
+ * mode) and the OPTIONAL HMAC `secret` (the ONLY secret — encrypted at rest +
16
+ * masked in admin, never in a payload/log).
17
+ *
18
+ * Distinct from `usage-events.jsonl` (internal dashboard telemetry): billing is
19
+ * the external-facing metered fact with its OWN schema + delivery + HMAC.
20
+ *
21
+ * @module billing-types
22
+ */
23
+ /**
24
+ * One per-request billing event (design D1) — the metered fact for external
25
+ * consumption. Produced at the post-response point from the SAME computed cost
26
+ * the usage telemetry records (no double pricing). NO field ever holds key
27
+ * material, an upstream token, or the HMAC signing secret.
28
+ */
29
+ interface BillingEvent {
30
+ /**
31
+ * Request id — the consumer's IDEMPOTENCY KEY. Stable for one event across
32
+ * delivery RETRIES (the retry sweep re-POSTs the SAME id) so an at-least-once
33
+ * consumer applies it exactly once. NOT any secret.
34
+ */
35
+ id: string;
36
+ /** Epoch ms the request was billed (the request timestamp). */
37
+ ts: number;
38
+ /** Outbound key id (attribution) — NEVER the key secret/hash. Null when unattributed. */
39
+ keyId?: string | null;
40
+ /** Resolved upstream model the request billed against. */
41
+ model: string;
42
+ /** Upstream provider id (or `'byo'`). */
43
+ provider?: string;
44
+ /** Re-auth mode the request billed under (BYO key vs subscription OAuth). */
45
+ authMode: 'byo' | 'subscription';
46
+ /** Prompt-side token count. */
47
+ inputTokens: number;
48
+ /** Completion-side token count. */
49
+ outputTokens: number;
50
+ /** Cost in USD (the SAME value the usage telemetry recorded). */
51
+ costUsd: number;
52
+ /** HTTP status of the billed request. */
53
+ status: number;
54
+ }
55
+ /**
56
+ * The `billing` config segment (design D6), normalized like `audit`.
57
+ * Absent/`enabled:false` ⇒ no sink wired ⇒ `publishBillingEvent` is a no-op ⇒
58
+ * no append, no POST, byte-identical zero regression. `enabled` WITHOUT an
59
+ * `endpoint` is a first-class LEDGER-ONLY mode (the durable jsonl IS the product;
60
+ * an external tailer consumes it). The `secret` is the ONLY secret field
61
+ * (encrypted at rest + masked in admin).
62
+ */
63
+ interface BillingConfig {
64
+ /** Master switch; default FALSE (zero regression). */
65
+ enabled: boolean;
66
+ /**
67
+ * POST target for the built-in delivery. ABSENT ⇒ ledger-only mode: events are
68
+ * durably appended and an external consumer tails the jsonl directly (no push).
69
+ */
70
+ endpoint?: string;
71
+ /**
72
+ * HMAC-SHA256 signing key — a SECRET. When set, each POST carries
73
+ * `X-Omnicross-Billing-Signature: sha256=<hmac hex of body>`. Encrypted at rest
74
+ * + masked in admin views; the secret ONLY signs, it NEVER travels in the event
75
+ * payload or a log line.
76
+ */
77
+ secret?: string;
78
+ /**
79
+ * Stop RE-POSTing an undelivered event after this age (ms); default 24h,
80
+ * clamped. This governs RETRY only — an over-age undelivered event is RETAINED
81
+ * in the ledger for reconciliation, NEVER deleted (a billing ledger is a
82
+ * financial record).
83
+ */
84
+ maxRetryAgeMs: number;
85
+ }
86
+ /** Frozen defaults for the `billing` segment (SSOT). 24h retry bound. */
87
+ declare const DEFAULT_BILLING_CONFIG: BillingConfig;
88
+ /** Aggregate delivery status the authed admin surfaces (secret-free counts). */
89
+ interface BillingDeliveryStatus {
90
+ /** Total events in the durable ledger. */
91
+ total: number;
92
+ /** Events an external endpoint has acknowledged (delivered). */
93
+ delivered: number;
94
+ /** Events not yet delivered (still retried within `maxRetryAgeMs`, then retained). */
95
+ pending: number;
96
+ }
97
+
98
+ export { type BillingConfig, type BillingDeliveryStatus, type BillingEvent, DEFAULT_BILLING_CONFIG };
@@ -0,0 +1,8 @@
1
+ // src/billing-types.ts
2
+ var DEFAULT_BILLING_CONFIG = {
3
+ enabled: false,
4
+ maxRetryAgeMs: 24 * 60 * 6e4
5
+ };
6
+ export {
7
+ DEFAULT_BILLING_CONFIG
8
+ };
@@ -1,5 +1,5 @@
1
1
  import { T as ThinkLevel } from './thinking-CBWSLel8.cjs';
2
- import { M as ModelConfig } from './llm-config-CQjOimv2.cjs';
2
+ import { M as ModelConfig } from './llm-config-DeWNx1ig.cjs';
3
3
 
4
4
  /**
5
5
  * Canonical Model Registry
@@ -1,5 +1,5 @@
1
1
  import { T as ThinkLevel } from './thinking-CBWSLel8.js';
2
- import { M as ModelConfig } from './llm-config-D1jKQLVp.js';
2
+ import { M as ModelConfig } from './llm-config-CKOaFFdy.js';
3
3
 
4
4
  /**
5
5
  * Canonical Model Registry
@@ -1,4 +1,4 @@
1
- import { L as LLMProvider } from './llm-config-CQjOimv2.cjs';
1
+ import { L as LLMProvider } from './llm-config-DeWNx1ig.cjs';
2
2
  import './thinking-CBWSLel8.cjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { L as LLMProvider } from './llm-config-D1jKQLVp.js';
1
+ import { L as LLMProvider } from './llm-config-CKOaFFdy.js';
2
2
  import './thinking-CBWSLel8.js';
3
3
 
4
4
  /**
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/health-logging-types.ts
21
+ var health_logging_types_exports = {};
22
+ __export(health_logging_types_exports, {
23
+ healthHttpStatus: () => healthHttpStatus
24
+ });
25
+ module.exports = __toCommonJS(health_logging_types_exports);
26
+ function healthHttpStatus(status) {
27
+ return status === "ok" ? 200 : 503;
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ healthHttpStatus
32
+ });
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Health-probe + logging contracts (daemon-health-endpoint / configurable-logging).
3
+ *
4
+ * Two small, dependency-light shapes shared across the `@omnicross/*` packages:
5
+ * - `HealthReport` — the coarse, SECRET-FREE body served by the unauthenticated
6
+ * `/health` probe (mounted on the admin server before its auth gate, and
7
+ * optionally on the outbound `/v1/*` server before key-auth). Frozen so a
8
+ * liveness/readiness probe + sibling changes (#8 health-cron surfacing into
9
+ * `checks`) agree on one shape.
10
+ * - `LogLevel` / `LoggingConfig` — the configurable-logger's level enum + config
11
+ * segment. Frozen so sibling changes (#5 webhooks / #13 audit-log) reuse the
12
+ * SAME level vocabulary + config shape rather than reinventing it.
13
+ *
14
+ * NON-SECRET by construction: nothing here carries a token, email, config value,
15
+ * or record-of-count. `HealthReport.checks` are COARSE booleans only.
16
+ *
17
+ * @module health-logging-types
18
+ */
19
+ /** The coarse health status. Anything other than `ok` maps to HTTP 503. */
20
+ type HealthStatus = 'ok' | 'degraded' | 'error';
21
+ /**
22
+ * The `/health` probe body (design D2). COARSE + SECRET-FREE:
23
+ * - `status` — `ok` (200) | `degraded` | `error` (both 503).
24
+ * - `version` — the daemon package version (already exposed pre-auth via
25
+ * the `x-omnicross-daemon` response header; non-sensitive).
26
+ * - `uptimeSeconds` — `Math.floor(process.uptime())`.
27
+ * - `timestamp` — ISO time the report was built.
28
+ * - `memory` — coarse process stats (rss / heapUsed, MB).
29
+ * - `checks` — COARSE dependency booleans ONLY (never tokens/emails/
30
+ * config-values/record-counts).
31
+ */
32
+ interface HealthReport {
33
+ status: HealthStatus;
34
+ version: string;
35
+ uptimeSeconds: number;
36
+ timestamp: string;
37
+ memory: {
38
+ rssMb: number;
39
+ heapUsedMb: number;
40
+ };
41
+ checks: Record<string, boolean>;
42
+ }
43
+ /** Map a {@link HealthStatus} to its probe HTTP code: `ok` → 200, else → 503. */
44
+ declare function healthHttpStatus(status: HealthStatus): number;
45
+ /**
46
+ * The logger's level threshold (configurable-logging, design D3). Numeric
47
+ * severity order `error(0) < warn(1) < info(2) < debug(3)`; a message at a level
48
+ * BELOW the configured threshold's severity (i.e. a higher ordinal) is dropped.
49
+ */
50
+ type LogLevel = 'error' | 'warn' | 'info' | 'debug';
51
+ /** Output shape of the logger sinks. */
52
+ type LogFormat = 'text' | 'json';
53
+ /**
54
+ * The daemon's `logging` config segment (design D3/D4). ALL fields optional; an
55
+ * absent/empty segment reads as the zero-regression default (console + all
56
+ * levels + text — byte-identical to the legacy `ConsoleLogger`).
57
+ * - `level` — threshold (default `debug` = print everything).
58
+ * - `format` — `text` (human-readable, legacy shape) | `json` (structured lines).
59
+ * - `file` — OPTIONAL append-only file sink path. A PLAIN config value (NOT a
60
+ * secret — never walked by the at-rest secret encryption).
61
+ */
62
+ interface LoggingConfig {
63
+ level?: LogLevel;
64
+ format?: LogFormat;
65
+ file?: string;
66
+ }
67
+
68
+ export { type HealthReport, type HealthStatus, type LogFormat, type LogLevel, type LoggingConfig, healthHttpStatus };
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Health-probe + logging contracts (daemon-health-endpoint / configurable-logging).
3
+ *
4
+ * Two small, dependency-light shapes shared across the `@omnicross/*` packages:
5
+ * - `HealthReport` — the coarse, SECRET-FREE body served by the unauthenticated
6
+ * `/health` probe (mounted on the admin server before its auth gate, and
7
+ * optionally on the outbound `/v1/*` server before key-auth). Frozen so a
8
+ * liveness/readiness probe + sibling changes (#8 health-cron surfacing into
9
+ * `checks`) agree on one shape.
10
+ * - `LogLevel` / `LoggingConfig` — the configurable-logger's level enum + config
11
+ * segment. Frozen so sibling changes (#5 webhooks / #13 audit-log) reuse the
12
+ * SAME level vocabulary + config shape rather than reinventing it.
13
+ *
14
+ * NON-SECRET by construction: nothing here carries a token, email, config value,
15
+ * or record-of-count. `HealthReport.checks` are COARSE booleans only.
16
+ *
17
+ * @module health-logging-types
18
+ */
19
+ /** The coarse health status. Anything other than `ok` maps to HTTP 503. */
20
+ type HealthStatus = 'ok' | 'degraded' | 'error';
21
+ /**
22
+ * The `/health` probe body (design D2). COARSE + SECRET-FREE:
23
+ * - `status` — `ok` (200) | `degraded` | `error` (both 503).
24
+ * - `version` — the daemon package version (already exposed pre-auth via
25
+ * the `x-omnicross-daemon` response header; non-sensitive).
26
+ * - `uptimeSeconds` — `Math.floor(process.uptime())`.
27
+ * - `timestamp` — ISO time the report was built.
28
+ * - `memory` — coarse process stats (rss / heapUsed, MB).
29
+ * - `checks` — COARSE dependency booleans ONLY (never tokens/emails/
30
+ * config-values/record-counts).
31
+ */
32
+ interface HealthReport {
33
+ status: HealthStatus;
34
+ version: string;
35
+ uptimeSeconds: number;
36
+ timestamp: string;
37
+ memory: {
38
+ rssMb: number;
39
+ heapUsedMb: number;
40
+ };
41
+ checks: Record<string, boolean>;
42
+ }
43
+ /** Map a {@link HealthStatus} to its probe HTTP code: `ok` → 200, else → 503. */
44
+ declare function healthHttpStatus(status: HealthStatus): number;
45
+ /**
46
+ * The logger's level threshold (configurable-logging, design D3). Numeric
47
+ * severity order `error(0) < warn(1) < info(2) < debug(3)`; a message at a level
48
+ * BELOW the configured threshold's severity (i.e. a higher ordinal) is dropped.
49
+ */
50
+ type LogLevel = 'error' | 'warn' | 'info' | 'debug';
51
+ /** Output shape of the logger sinks. */
52
+ type LogFormat = 'text' | 'json';
53
+ /**
54
+ * The daemon's `logging` config segment (design D3/D4). ALL fields optional; an
55
+ * absent/empty segment reads as the zero-regression default (console + all
56
+ * levels + text — byte-identical to the legacy `ConsoleLogger`).
57
+ * - `level` — threshold (default `debug` = print everything).
58
+ * - `format` — `text` (human-readable, legacy shape) | `json` (structured lines).
59
+ * - `file` — OPTIONAL append-only file sink path. A PLAIN config value (NOT a
60
+ * secret — never walked by the at-rest secret encryption).
61
+ */
62
+ interface LoggingConfig {
63
+ level?: LogLevel;
64
+ format?: LogFormat;
65
+ file?: string;
66
+ }
67
+
68
+ export { type HealthReport, type HealthStatus, type LogFormat, type LogLevel, type LoggingConfig, healthHttpStatus };
@@ -0,0 +1,7 @@
1
+ // src/health-logging-types.ts
2
+ function healthHttpStatus(status) {
3
+ return status === "ok" ? 200 : 503;
4
+ }
5
+ export {
6
+ healthHttpStatus
7
+ };
package/dist/index.cjs CHANGED
@@ -24,10 +24,13 @@ __export(index_exports, {
24
24
  CANNOT_DISABLE_THINKING_PATTERNS: () => CANNOT_DISABLE_THINKING_PATTERNS,
25
25
  CATALOG_VERSION: () => CATALOG_VERSION,
26
26
  CODING_PLAN_URL_PRESETS: () => CODING_PLAN_URL_PRESETS,
27
+ DEFAULT_AUDIT_CONFIG: () => DEFAULT_AUDIT_CONFIG,
28
+ DEFAULT_BILLING_CONFIG: () => DEFAULT_BILLING_CONFIG,
27
29
  DEFAULT_LITELLM_PRICING_URL: () => DEFAULT_LITELLM_PRICING_URL,
28
30
  DEFAULT_MAX_TOKENS: () => DEFAULT_MAX_TOKENS,
29
31
  DEFAULT_MCP_SESSION_CONFIG: () => DEFAULT_MCP_SESSION_CONFIG,
30
32
  DEFAULT_SEED_PRESET_IDS: () => DEFAULT_SEED_PRESET_IDS,
33
+ DEFAULT_VOUCHER_CONFIG: () => DEFAULT_VOUCHER_CONFIG,
31
34
  EFFORT_RATIO: () => EFFORT_RATIO,
32
35
  EXTENDED_CONTEXT_CAPABLE_MODELS: () => EXTENDED_CONTEXT_CAPABLE_MODELS,
33
36
  KNOWN_MODELS: () => KNOWN_MODELS,
@@ -38,6 +41,8 @@ __export(index_exports, {
38
41
  PROVIDER_SEARCH_CONFIGS: () => PROVIDER_SEARCH_CONFIGS,
39
42
  REASONING_MODEL_PATTERNS: () => REASONING_MODEL_PATTERNS,
40
43
  THINKING_TOKEN_MAP: () => THINKING_TOKEN_MAP,
44
+ WEBHOOK_DESTINATION_TYPES: () => WEBHOOK_DESTINATION_TYPES,
45
+ WEBHOOK_EVENT_KINDS: () => WEBHOOK_EVENT_KINDS,
41
46
  applyAlias: () => applyAlias,
42
47
  buildAnthropicThinking: () => buildAnthropicThinking,
43
48
  buildGeminiThinkingConfig: () => buildGeminiThinkingConfig,
@@ -52,6 +57,7 @@ __export(index_exports, {
52
57
  getPresetById: () => getPresetById,
53
58
  getPresetRevision: () => getPresetRevision,
54
59
  getProviderSearchConfig: () => getProviderSearchConfig,
60
+ healthHttpStatus: () => healthHttpStatus,
55
61
  isApiProvider: () => isApiProvider,
56
62
  isExtendedContextCapable: () => isExtendedContextCapable,
57
63
  isLocalProvider: () => isLocalProvider,
@@ -66,6 +72,21 @@ __export(index_exports, {
66
72
  });
67
73
  module.exports = __toCommonJS(index_exports);
68
74
 
75
+ // src/audit-types.ts
76
+ var DEFAULT_AUDIT_CONFIG = {
77
+ enabled: false,
78
+ captureBodies: false,
79
+ maxBodyBytes: 8192,
80
+ retentionDays: 7,
81
+ trustForwardedFor: false
82
+ };
83
+
84
+ // src/billing-types.ts
85
+ var DEFAULT_BILLING_CONFIG = {
86
+ enabled: false,
87
+ maxRetryAgeMs: 24 * 60 * 6e4
88
+ };
89
+
69
90
  // src/canonical-models.ts
70
91
  var OPENAI_MODELS = {
71
92
  "gpt-5.5": { category: "reasoning", contextLength: 105e4, maxTokens: 128e3, reasoning: true, vision: true, functionCall: true, thinkingLevels: ["none", "low", "medium", "high", "xhigh"], thinkingTokenLimit: { min: 0, max: 128e3 } },
@@ -328,6 +349,11 @@ function isExtendedContextCapable(model) {
328
349
  return EXTENDED_CONTEXT_CAPABLE_MODELS.has(model);
329
350
  }
330
351
 
352
+ // src/health-logging-types.ts
353
+ function healthHttpStatus(status) {
354
+ return status === "ok" ? 200 : 503;
355
+ }
356
+
331
357
  // src/mcp-types.ts
332
358
  var DEFAULT_MCP_SESSION_CONFIG = {
333
359
  mode: "auto",
@@ -2674,6 +2700,22 @@ function buildQwenThinkingConfig(level, userMaxTokens) {
2674
2700
  };
2675
2701
  }
2676
2702
 
2703
+ // src/voucher-types.ts
2704
+ var DEFAULT_VOUCHER_CONFIG = {
2705
+ enabled: false
2706
+ };
2707
+
2708
+ // src/webhook-types.ts
2709
+ var WEBHOOK_EVENT_KINDS = [
2710
+ "account.recovery",
2711
+ "account.anomaly",
2712
+ "key.quotaWarning",
2713
+ "key.quotaExceeded",
2714
+ "server.error",
2715
+ "test"
2716
+ ];
2717
+ var WEBHOOK_DESTINATION_TYPES = ["custom", "feishu"];
2718
+
2677
2719
  // src/websearch-types.ts
2678
2720
  function isApiProvider(id) {
2679
2721
  return !id.startsWith("local-");
@@ -2687,10 +2729,13 @@ function isLocalProvider(id) {
2687
2729
  CANNOT_DISABLE_THINKING_PATTERNS,
2688
2730
  CATALOG_VERSION,
2689
2731
  CODING_PLAN_URL_PRESETS,
2732
+ DEFAULT_AUDIT_CONFIG,
2733
+ DEFAULT_BILLING_CONFIG,
2690
2734
  DEFAULT_LITELLM_PRICING_URL,
2691
2735
  DEFAULT_MAX_TOKENS,
2692
2736
  DEFAULT_MCP_SESSION_CONFIG,
2693
2737
  DEFAULT_SEED_PRESET_IDS,
2738
+ DEFAULT_VOUCHER_CONFIG,
2694
2739
  EFFORT_RATIO,
2695
2740
  EXTENDED_CONTEXT_CAPABLE_MODELS,
2696
2741
  KNOWN_MODELS,
@@ -2701,6 +2746,8 @@ function isLocalProvider(id) {
2701
2746
  PROVIDER_SEARCH_CONFIGS,
2702
2747
  REASONING_MODEL_PATTERNS,
2703
2748
  THINKING_TOKEN_MAP,
2749
+ WEBHOOK_DESTINATION_TYPES,
2750
+ WEBHOOK_EVENT_KINDS,
2704
2751
  applyAlias,
2705
2752
  buildAnthropicThinking,
2706
2753
  buildGeminiThinkingConfig,
@@ -2715,6 +2762,7 @@ function isLocalProvider(id) {
2715
2762
  getPresetById,
2716
2763
  getPresetRevision,
2717
2764
  getProviderSearchConfig,
2765
+ healthHttpStatus,
2718
2766
  isApiProvider,
2719
2767
  isExtendedContextCapable,
2720
2768
  isLocalProvider,
package/dist/index.d.cts CHANGED
@@ -1,16 +1,21 @@
1
- export { AccountTokensConfig, AuthMethod, ClaudeAuthMethod, ClaudeTokenConfig, CodexTokenConfig, GeminiTokenConfig, OAuthParams, SubscriptionAccountEntry, SubscriptionAccountSanitized, SubscriptionLevel, SyncWarningCode, TokenExchangeRequest, TokenStatus } from './account-tokens-types.cjs';
1
+ export { AccountClientIdentity, AccountTokensConfig, AuthMethod, ClaudeAuthMethod, ClaudeTokenConfig, CodexTokenConfig, GeminiTokenConfig, OAuthParams, ProxyConfig, SanitizedProxyConfig, SubscriptionAccountEntry, SubscriptionAccountSanitized, SubscriptionLevel, SyncWarningCode, TokenExchangeRequest, TokenStatus } from './account-tokens-types.cjs';
2
+ export { AuditConfig, AuditQueryResult, AuditRecord, DEFAULT_AUDIT_CONFIG } from './audit-types.cjs';
3
+ export { BillingConfig, BillingDeliveryStatus, BillingEvent, DEFAULT_BILLING_CONFIG } from './billing-types.cjs';
2
4
  export { KNOWN_MODELS, KnownModelCapabilities, MODEL_ALIASES, ResolvedModelCapabilities, applyAlias, lookupCanonicalCapabilities, normalizeModelId, resolveModelCapabilities } from './canonical-models.cjs';
3
5
  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';
4
6
  export { R as ReasoningConfig, T as ThinkLevel, a as ThinkingContent } from './thinking-CBWSLel8.cjs';
5
7
  export { ResolvedEndpoint, resolveProviderEndpoint } from './endpoint-resolver.cjs';
6
8
  export { EXTENDED_CONTEXT_CAPABLE_MODELS, isExtendedContextCapable } from './extended-context.cjs';
7
- export { A as API_MODE_IDS, a as AgentDefaultModels, b as ApiFormat, c as ApiKeyEntry, d as ApiMode, e as ApiModeId, C as ChatApiFormat, f as CodingPlanConfig, g as CompletionSettings, G as GlobalModelParameters, L as LLMProvider, M as ModelConfig, h as ModelGroup, i as ModelParameter, j as ModelRef, O as OpenRouterDataCollection, k as OpenRouterMaxPrice, l as OpenRouterProviderRouting, m as OpenRouterProviderSort, n as OpenRouterQuantization, P as PresetProviderTemplate, o as ProviderApiType, p as ProviderModelMapping, q as ProviderSearchConfig, r as ProviderTemplate, S as SearchCapability, T as TransformerConfig, s as TransformerEntry } from './llm-config-CQjOimv2.cjs';
9
+ export { HealthReport, HealthStatus, LogFormat, LogLevel, LoggingConfig, healthHttpStatus } from './health-logging-types.cjs';
10
+ export { A as API_MODE_IDS, a as AgentDefaultModels, b as ApiFormat, c as ApiKeyEntry, d as ApiMode, e as ApiModeId, C as ChatApiFormat, f as CodingPlanConfig, g as CompletionSettings, G as GlobalModelParameters, L as LLMProvider, M as ModelConfig, h as ModelGroup, i as ModelParameter, j as ModelRef, O as OpenRouterDataCollection, k as OpenRouterMaxPrice, l as OpenRouterProviderRouting, m as OpenRouterProviderSort, n as OpenRouterQuantization, P as PresetProviderTemplate, o as ProviderApiType, p as ProviderModelMapping, q as ProviderSearchConfig, r as ProviderTemplate, S as SearchCapability, T as TransformerConfig, s as TransformerEntry } from './llm-config-DeWNx1ig.cjs';
8
11
  export { DEFAULT_MCP_SESSION_CONFIG, MCPCallToolResponse, MCPTool, MCPToolResponseContent, McpActionResult, McpDiscoverResult, McpMode, McpServerConfig, McpServerInput, McpServerJsonInput, McpServerList, McpServerRecord, McpServerRemoveInput, McpServerScope, McpServerTransport, McpSessionConfig, McpTestResult, McpToolInfo } from './mcp-types.cjs';
9
12
  export { MessageBlock, MessageBlockBase, MessageBlockType, TextBlock, ThinkingBlock, ToolResultBlock, ToolUseBlock } from './message-blocks.cjs';
10
13
  export { DEFAULT_LITELLM_PRICING_URL, PricingConflict, PricingConflictDecision, PricingEntry, PricingEntryInput, PricingFetchResult, PricingResolution, PricingSource } from './pricing-types.cjs';
11
14
  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';
12
15
  export { OpenCodeGoModelEntry, OpenCodeGoScenario, OpenCodeGoTokenConfig, OpenCodeGoTokenSanitized, ProviderChannel, SubscriptionListEntry, SubscriptionProviderId, SubscriptionStatusEntry, legacyCliBackendToSubscriptionProvider, subscriptionTargetForSession } from './subscription-types.cjs';
13
16
  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';
14
- export { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTotals } from './usage-stats-types.cjs';
17
+ export { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals } from './usage-stats-types.cjs';
15
18
  export { UsageEngineOrigin, UsageTokens } from './usage-types.cjs';
19
+ export { DEFAULT_VOUCHER_CONFIG, VoucherConfig, VoucherCreated, VoucherGrant, VoucherInfo, VoucherRecord, VoucherRedeemResult, VoucherStatus, VoucherType } from './voucher-types.cjs';
20
+ export { SanitizedWebhookConfig, SanitizedWebhookDestination, WEBHOOK_DESTINATION_TYPES, WEBHOOK_EVENT_KINDS, WebhookAnomalyState, WebhookConfig, WebhookDestination, WebhookDestinationType, WebhookEvent, WebhookEventKind, WebhookQuotaScope } from './webhook-types.cjs';
16
21
  export { JinaReaderResponse, WebSearchOptions, WebSearchProviderConfig, WebSearchProviderId, WebSearchProviderType, WebSearchResponse, WebSearchResult, isApiProvider, isLocalProvider } from './websearch-types.cjs';
package/dist/index.d.ts CHANGED
@@ -1,16 +1,21 @@
1
- export { AccountTokensConfig, AuthMethod, ClaudeAuthMethod, ClaudeTokenConfig, CodexTokenConfig, GeminiTokenConfig, OAuthParams, SubscriptionAccountEntry, SubscriptionAccountSanitized, SubscriptionLevel, SyncWarningCode, TokenExchangeRequest, TokenStatus } from './account-tokens-types.js';
1
+ export { AccountClientIdentity, AccountTokensConfig, AuthMethod, ClaudeAuthMethod, ClaudeTokenConfig, CodexTokenConfig, GeminiTokenConfig, OAuthParams, ProxyConfig, SanitizedProxyConfig, SubscriptionAccountEntry, SubscriptionAccountSanitized, SubscriptionLevel, SyncWarningCode, TokenExchangeRequest, TokenStatus } from './account-tokens-types.js';
2
+ export { AuditConfig, AuditQueryResult, AuditRecord, DEFAULT_AUDIT_CONFIG } from './audit-types.js';
3
+ export { BillingConfig, BillingDeliveryStatus, BillingEvent, DEFAULT_BILLING_CONFIG } from './billing-types.js';
2
4
  export { KNOWN_MODELS, KnownModelCapabilities, MODEL_ALIASES, ResolvedModelCapabilities, applyAlias, lookupCanonicalCapabilities, normalizeModelId, resolveModelCapabilities } from './canonical-models.js';
3
5
  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';
4
6
  export { R as ReasoningConfig, T as ThinkLevel, a as ThinkingContent } from './thinking-CBWSLel8.js';
5
7
  export { ResolvedEndpoint, resolveProviderEndpoint } from './endpoint-resolver.js';
6
8
  export { EXTENDED_CONTEXT_CAPABLE_MODELS, isExtendedContextCapable } from './extended-context.js';
7
- export { A as API_MODE_IDS, a as AgentDefaultModels, b as ApiFormat, c as ApiKeyEntry, d as ApiMode, e as ApiModeId, C as ChatApiFormat, f as CodingPlanConfig, g as CompletionSettings, G as GlobalModelParameters, L as LLMProvider, M as ModelConfig, h as ModelGroup, i as ModelParameter, j as ModelRef, O as OpenRouterDataCollection, k as OpenRouterMaxPrice, l as OpenRouterProviderRouting, m as OpenRouterProviderSort, n as OpenRouterQuantization, P as PresetProviderTemplate, o as ProviderApiType, p as ProviderModelMapping, q as ProviderSearchConfig, r as ProviderTemplate, S as SearchCapability, T as TransformerConfig, s as TransformerEntry } from './llm-config-D1jKQLVp.js';
9
+ export { HealthReport, HealthStatus, LogFormat, LogLevel, LoggingConfig, healthHttpStatus } from './health-logging-types.js';
10
+ export { A as API_MODE_IDS, a as AgentDefaultModels, b as ApiFormat, c as ApiKeyEntry, d as ApiMode, e as ApiModeId, C as ChatApiFormat, f as CodingPlanConfig, g as CompletionSettings, G as GlobalModelParameters, L as LLMProvider, M as ModelConfig, h as ModelGroup, i as ModelParameter, j as ModelRef, O as OpenRouterDataCollection, k as OpenRouterMaxPrice, l as OpenRouterProviderRouting, m as OpenRouterProviderSort, n as OpenRouterQuantization, P as PresetProviderTemplate, o as ProviderApiType, p as ProviderModelMapping, q as ProviderSearchConfig, r as ProviderTemplate, S as SearchCapability, T as TransformerConfig, s as TransformerEntry } from './llm-config-CKOaFFdy.js';
8
11
  export { DEFAULT_MCP_SESSION_CONFIG, MCPCallToolResponse, MCPTool, MCPToolResponseContent, McpActionResult, McpDiscoverResult, McpMode, McpServerConfig, McpServerInput, McpServerJsonInput, McpServerList, McpServerRecord, McpServerRemoveInput, McpServerScope, McpServerTransport, McpSessionConfig, McpTestResult, McpToolInfo } from './mcp-types.js';
9
12
  export { MessageBlock, MessageBlockBase, MessageBlockType, TextBlock, ThinkingBlock, ToolResultBlock, ToolUseBlock } from './message-blocks.js';
10
13
  export { DEFAULT_LITELLM_PRICING_URL, PricingConflict, PricingConflictDecision, PricingEntry, PricingEntryInput, PricingFetchResult, PricingResolution, PricingSource } from './pricing-types.js';
11
14
  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';
12
15
  export { OpenCodeGoModelEntry, OpenCodeGoScenario, OpenCodeGoTokenConfig, OpenCodeGoTokenSanitized, ProviderChannel, SubscriptionListEntry, SubscriptionProviderId, SubscriptionStatusEntry, legacyCliBackendToSubscriptionProvider, subscriptionTargetForSession } from './subscription-types.js';
13
16
  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';
14
- export { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTotals } from './usage-stats-types.js';
17
+ export { ApiKeyUsageRow, MessageUsageRow, ModelUsageRow, SessionCacheStats, UsageDateRange, UsageEventInput, UsageEventRecord, UsageQueryParams, UsageTimeBucket, UsageTimeSeriesBucket, UsageTotals } from './usage-stats-types.js';
15
18
  export { UsageEngineOrigin, UsageTokens } from './usage-types.js';
19
+ export { DEFAULT_VOUCHER_CONFIG, VoucherConfig, VoucherCreated, VoucherGrant, VoucherInfo, VoucherRecord, VoucherRedeemResult, VoucherStatus, VoucherType } from './voucher-types.js';
20
+ export { SanitizedWebhookConfig, SanitizedWebhookDestination, WEBHOOK_DESTINATION_TYPES, WEBHOOK_EVENT_KINDS, WebhookAnomalyState, WebhookConfig, WebhookDestination, WebhookDestinationType, WebhookEvent, WebhookEventKind, WebhookQuotaScope } from './webhook-types.js';
16
21
  export { JinaReaderResponse, WebSearchOptions, WebSearchProviderConfig, WebSearchProviderId, WebSearchProviderType, WebSearchResponse, WebSearchResult, isApiProvider, isLocalProvider } from './websearch-types.js';