@dcdr/contracts 1.9.6

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 (69) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +411 -0
  3. package/dist/capabilities.contract.d.ts +69 -0
  4. package/dist/capabilities.contract.d.ts.map +1 -0
  5. package/dist/capabilities.contract.js +126 -0
  6. package/dist/control.contract.d.ts +39 -0
  7. package/dist/control.contract.d.ts.map +1 -0
  8. package/dist/control.contract.js +2 -0
  9. package/dist/credentials.contract.d.ts +37 -0
  10. package/dist/credentials.contract.d.ts.map +1 -0
  11. package/dist/credentials.contract.js +15 -0
  12. package/dist/entitlements.contract.d.ts +107 -0
  13. package/dist/entitlements.contract.d.ts.map +1 -0
  14. package/dist/entitlements.contract.js +11 -0
  15. package/dist/errors.contract.d.ts +47 -0
  16. package/dist/errors.contract.d.ts.map +1 -0
  17. package/dist/errors.contract.js +48 -0
  18. package/dist/execution.contract.d.ts +240 -0
  19. package/dist/execution.contract.d.ts.map +1 -0
  20. package/dist/execution.contract.js +22 -0
  21. package/dist/http.contract.d.ts +20 -0
  22. package/dist/http.contract.d.ts.map +1 -0
  23. package/dist/http.contract.js +8 -0
  24. package/dist/implementations.contract.d.ts +120 -0
  25. package/dist/implementations.contract.d.ts.map +1 -0
  26. package/dist/implementations.contract.js +2 -0
  27. package/dist/index.d.ts +22 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +37 -0
  30. package/dist/intent.contract.d.ts +137 -0
  31. package/dist/intent.contract.d.ts.map +1 -0
  32. package/dist/intent.contract.js +76 -0
  33. package/dist/logs.contract.d.ts +10 -0
  34. package/dist/logs.contract.d.ts.map +1 -0
  35. package/dist/logs.contract.js +2 -0
  36. package/dist/messages.contract.d.ts +16 -0
  37. package/dist/messages.contract.d.ts.map +1 -0
  38. package/dist/messages.contract.js +2 -0
  39. package/dist/policies.contract.d.ts +253 -0
  40. package/dist/policies.contract.d.ts.map +1 -0
  41. package/dist/policies.contract.js +283 -0
  42. package/dist/prompt-variable-schema.contract.d.ts +75 -0
  43. package/dist/prompt-variable-schema.contract.d.ts.map +1 -0
  44. package/dist/prompt-variable-schema.contract.js +572 -0
  45. package/dist/prompts.contract.d.ts +97 -0
  46. package/dist/prompts.contract.d.ts.map +1 -0
  47. package/dist/prompts.contract.js +87 -0
  48. package/dist/provider.contract.d.ts +477 -0
  49. package/dist/provider.contract.d.ts.map +1 -0
  50. package/dist/provider.contract.js +3310 -0
  51. package/dist/registry.stats.contract.d.ts +39 -0
  52. package/dist/registry.stats.contract.d.ts.map +1 -0
  53. package/dist/registry.stats.contract.js +9 -0
  54. package/dist/runtime.client.d.ts +362 -0
  55. package/dist/runtime.client.d.ts.map +1 -0
  56. package/dist/runtime.client.js +545 -0
  57. package/dist/service-tokens.contract.d.ts +29 -0
  58. package/dist/service-tokens.contract.d.ts.map +1 -0
  59. package/dist/service-tokens.contract.js +10 -0
  60. package/dist/session.contract.d.ts +51 -0
  61. package/dist/session.contract.d.ts.map +1 -0
  62. package/dist/session.contract.js +187 -0
  63. package/dist/subscription.contract.d.ts +37 -0
  64. package/dist/subscription.contract.d.ts.map +1 -0
  65. package/dist/subscription.contract.js +45 -0
  66. package/dist/utils.contract.d.ts +21 -0
  67. package/dist/utils.contract.d.ts.map +1 -0
  68. package/dist/utils.contract.js +79 -0
  69. package/package.json +57 -0
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CapabilityKey = void 0;
4
+ exports.getRequiredCapabilitiesForIntent = getRequiredCapabilitiesForIntent;
5
+ exports.getRequiredCapabilitiesFromRegistry = getRequiredCapabilitiesFromRegistry;
6
+ exports.getMissingCapabilities = getMissingCapabilities;
7
+ exports.assertCapabilitiesAllowed = assertCapabilitiesAllowed;
8
+ const policies_contract_1 = require("./policies.contract");
9
+ /**
10
+ * Stable, public capability identifiers derived from configuration/registry usage.
11
+ *
12
+ * Purpose
13
+ * - Provide a single, exportable vocabulary to describe what a given registry/config *requires*.
14
+ * - Enable:
15
+ * - Freeware runtime (`runtime` mode) to reject advanced features (allowlist).
16
+ * - Backend tier enforcement to map subscriptions/features to required runtime capabilities.
17
+ *
18
+ * Notes
19
+ * - These are *technical* capabilities, not billing/subscription concepts.
20
+ * - Keep values stable; they can become part of wire-level compatibility checks.
21
+ */
22
+ var CapabilityKey;
23
+ (function (CapabilityKey) {
24
+ /** Prompt canary rollouts (canary prompt + weight). */
25
+ CapabilityKey["AI_PROMPTS_CANARY"] = "AI_PROMPTS_CANARY";
26
+ /** Any non-default/advanced execution policy (non-WEIGHTED). */
27
+ CapabilityKey["AI_INTENTS_ADVANCED_EXECUTION_POLICY"] = "AI_INTENTS_ADVANCED_EXECUTION_POLICY";
28
+ /** ExecutionPolicy exploration enabled (epsilon-greedy / top-K sampling). */
29
+ CapabilityKey["AI_INTENTS_EXPLORATION_POLICY"] = "AI_INTENTS_EXPLORATION_POLICY";
30
+ /** Response caching enabled with per-implementation TTL configuration. */
31
+ CapabilityKey["AI_RUNTIME_CACHE_TTL_CONFIGURABLE"] = "AI_RUNTIME_CACHE_TTL_CONFIGURABLE";
32
+ /** Execution window override at the implementation level. */
33
+ CapabilityKey["AI_BASE_MODEL_EXECUTION_WINDOWS_OVERRIDE_PER_IMPLEMENTATION"] = "AI_BASE_MODEL_EXECUTION_WINDOWS_OVERRIDE_PER_IMPLEMENTATION";
34
+ // ---------------------------------------------------------------------------
35
+ // Runtime / platform capabilities (may be enforced by mode, not by registry)
36
+ // ---------------------------------------------------------------------------
37
+ /** Backend registry sync (cloud/cloud-pro control plane). */
38
+ CapabilityKey["AI_RUNTIME_BACKEND_REGISTRY_SYNC"] = "AI_RUNTIME_BACKEND_REGISTRY_SYNC";
39
+ /** Backend log ingestion (cloud/cloud-pro; runtime/freeware should not send logs to backend). */
40
+ CapabilityKey["AI_OBSERVABILITY_BACKEND_LOG_INGESTION"] = "AI_OBSERVABILITY_BACKEND_LOG_INGESTION";
41
+ /** Internal backend bypass auth mode (backend-to-runtime trusted traffic). */
42
+ CapabilityKey["AI_SECURITY_INTERNAL_BYPASS"] = "AI_SECURITY_INTERNAL_BYPASS";
43
+ })(CapabilityKey || (exports.CapabilityKey = CapabilityKey = {}));
44
+ /**
45
+ * Extracts required capabilities for a single intent.
46
+ * @param intent The intent contract to inspect.
47
+ * @returns Required capabilities for this intent.
48
+ */
49
+ function getRequiredCapabilitiesForIntent(intent) {
50
+ const out = [];
51
+ if (!intent)
52
+ return out;
53
+ if (intent.canaryPrompt || (typeof intent.canaryPromptWeight === "number" && intent.canaryPromptWeight > 0)) {
54
+ out.push(CapabilityKey.AI_PROMPTS_CANARY);
55
+ }
56
+ if (intent.executionPolicy && intent.executionPolicy.type !== policies_contract_1.ExecutionPolicyType.WEIGHTED) {
57
+ out.push(CapabilityKey.AI_INTENTS_ADVANCED_EXECUTION_POLICY);
58
+ }
59
+ if (intent.executionPolicy && intent.executionPolicy.exploration) {
60
+ out.push(CapabilityKey.AI_INTENTS_EXPLORATION_POLICY);
61
+ }
62
+ const implementations = Array.isArray(intent.implementations) ? intent.implementations : [];
63
+ for (const impl of implementations) {
64
+ if (!impl)
65
+ continue;
66
+ if (typeof impl.cacheTTLSeconds === "number" && impl.cacheTTLSeconds > 0) {
67
+ out.push(CapabilityKey.AI_RUNTIME_CACHE_TTL_CONFIGURABLE);
68
+ }
69
+ if (impl.executionWindow) {
70
+ out.push(CapabilityKey.AI_BASE_MODEL_EXECUTION_WINDOWS_OVERRIDE_PER_IMPLEMENTATION);
71
+ }
72
+ }
73
+ return out;
74
+ }
75
+ /**
76
+ * Derives the set of required capabilities implied by a registry.
77
+ *
78
+ * Intended usage
79
+ * - Runtime freeware mode: compare with an allowlist and fail loudly when unsupported.
80
+ * - Backend: map subscription/module-features to capabilities and enforce before emitting a registry.
81
+ *
82
+ * @param registry The registry to inspect.
83
+ * @returns Unique capability keys required by the registry.
84
+ */
85
+ function getRequiredCapabilitiesFromRegistry(registry) {
86
+ const unique = new Set();
87
+ const intents = registry && Array.isArray(registry.intents) ? registry.intents : [];
88
+ for (const intent of intents) {
89
+ for (const cap of getRequiredCapabilitiesForIntent(intent)) {
90
+ unique.add(cap);
91
+ }
92
+ }
93
+ return Array.from(unique.values());
94
+ }
95
+ /**
96
+ * Returns the capabilities that are required but not present in the allowlist.
97
+ * @param required Required capabilities.
98
+ * @param allowed Allowed capabilities.
99
+ * @returns Missing capabilities.
100
+ */
101
+ function getMissingCapabilities(required, allowed) {
102
+ const allowedSet = new Set(Array.isArray(allowed) ? allowed : []);
103
+ const out = [];
104
+ for (const cap of Array.isArray(required) ? required : []) {
105
+ if (!allowedSet.has(cap))
106
+ out.push(cap);
107
+ }
108
+ return out;
109
+ }
110
+ /**
111
+ * Asserts that all required capabilities are in the allowlist.
112
+ *
113
+ * Intended usage
114
+ * - Freeware runtime mode: reject registries/configurations that require pro/cloud capabilities.
115
+ *
116
+ * @param required Required capabilities.
117
+ * @param allowed Allowed capabilities.
118
+ * @param context Optional context string included in error messages.
119
+ */
120
+ function assertCapabilitiesAllowed(required, allowed, context) {
121
+ const missing = getMissingCapabilities(required, allowed);
122
+ if (missing.length === 0)
123
+ return;
124
+ const ctx = context ? ` (${context})` : "";
125
+ throw new Error(`Unsupported capabilities${ctx}: ${missing.join(", ")}`);
126
+ }
@@ -0,0 +1,39 @@
1
+ import { CredentialsContract } from "./credentials.contract";
2
+ import { IntentContract } from "./intent.contract";
3
+ /**
4
+ * DCDR Registry designed in the backend and consumed by DCDR server.
5
+ */
6
+ export interface DcdrRegistry {
7
+ /**
8
+ * SHA256 hash of the registry bundle (stable JSON serialization).
9
+ * Useful as an immutable fingerprint / audit trail.
10
+ */
11
+ sha256: string;
12
+ /** When the bundle was generated by the backend (ISO string). */
13
+ generatedAt?: string;
14
+ /**
15
+ * Optional cryptographic signature for this registry bundle.
16
+ *
17
+ * Intended usage
18
+ * - When present and valid, the runtime can treat the registry as "trusted backend-issued".
19
+ * - This allows enabling cloud/cloud-pro capabilities while preventing a fake backend from injecting pro-only configuration.
20
+ *
21
+ * Signing payload
22
+ * - Registry `sha256` string (UTF-8 bytes).
23
+ *
24
+ * Recommended algorithm
25
+ * - Ed25519 signature by backend (private key) verified by runtime (embedded public key).
26
+ * - This raises the bar against a "fake backend" serving a pro-enabled registry.
27
+ *
28
+ * Encoding
29
+ * - Base64-encoded signature.
30
+ */
31
+ signature?: string;
32
+ /** Optional key id / version for signature rotation (backend-defined). */
33
+ signatureKeyId?: string;
34
+ /** Full list of intent contracts */
35
+ intents: IntentContract[];
36
+ /** Full list of credential contracts */
37
+ credentials?: CredentialsContract[];
38
+ }
39
+ //# sourceMappingURL=control.contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.contract.d.ts","sourceRoot":"","sources":["../src/control.contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;GAEG;AACH,MAAM,WAAW,YAAY;IAG3B;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,oCAAoC;IACpC,OAAO,EAAE,cAAc,EAAE,CAAC;IAE1B,wCAAwC;IACxC,WAAW,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACrC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,37 @@
1
+ import { IntentProvider } from "./provider.contract";
2
+ import { HttpRequestParams } from "./http.contract";
3
+ /**
4
+ * How a credential is resolved into concrete HTTP request parameters.
5
+ *
6
+ * Security model
7
+ * - `INLINE`: Secrets (headers/query/cookies) are carried inside the registry.
8
+ * - `BACKEND`: Registry carries only a reference; runtime resolves secrets from backend at execution time.
9
+ */
10
+ export declare enum CredentialsResolutionMode {
11
+ INLINE = "INLINE",
12
+ BACKEND = "BACKEND"
13
+ }
14
+ /**
15
+ * Represents credentials used to authenticate provider requests.
16
+ * Implementations reference credentials via credentialRef.
17
+ */
18
+ export interface CredentialsContract {
19
+ id: string;
20
+ name: string;
21
+ description?: string;
22
+ /**
23
+ * Resolution strategy.
24
+ * - Omitted defaults to `INLINE` for backward compatibility.
25
+ */
26
+ resolution?: CredentialsResolutionMode;
27
+ /**
28
+ * Optional provider hint for UI, filtering or validation.
29
+ * Credentials remain provider-agnostic at runtime.
30
+ */
31
+ provider?: IntentProvider;
32
+ /** HTTP headers/query injected into provider requests */
33
+ readonly headers?: HttpRequestParams["headers"];
34
+ readonly query?: HttpRequestParams["query"];
35
+ readonly cookies?: HttpRequestParams["cookies"];
36
+ }
37
+ //# sourceMappingURL=credentials.contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.contract.d.ts","sourceRoot":"","sources":["../src/credentials.contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;GAMG;AACH,oBAAY,yBAAyB;IACnC,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,yBAAyB,CAAC;IAEvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B,yDAAyD;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAChD,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;CACjD"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CredentialsResolutionMode = void 0;
4
+ /**
5
+ * How a credential is resolved into concrete HTTP request parameters.
6
+ *
7
+ * Security model
8
+ * - `INLINE`: Secrets (headers/query/cookies) are carried inside the registry.
9
+ * - `BACKEND`: Registry carries only a reference; runtime resolves secrets from backend at execution time.
10
+ */
11
+ var CredentialsResolutionMode;
12
+ (function (CredentialsResolutionMode) {
13
+ CredentialsResolutionMode["INLINE"] = "INLINE";
14
+ CredentialsResolutionMode["BACKEND"] = "BACKEND";
15
+ })(CredentialsResolutionMode || (exports.CredentialsResolutionMode = CredentialsResolutionMode = {}));
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Generic entitlement snapshot for a gateway/runtime.
3
+ *
4
+ * Keep this contract business-agnostic:
5
+ * - "limits" are pure technical quotas
6
+ * - "usageBaseline" is a snapshot for the current billing window
7
+ *
8
+ * Backend remains source-of-truth; runtime uses snapshot + local delta.
9
+ */
10
+ import { SubscriptionStatus } from "./subscription.contract";
11
+ /**
12
+ * Hard/soft technical limits enforced by the runtime.
13
+ */
14
+ export interface DcdrEntitlementLimits {
15
+ /** Hard limit (monthly). Null = unlimited. */
16
+ maxCallsPerMonth: number | null;
17
+ /** Optional hard limits for shorter windows. Null = unlimited / not enforced. */
18
+ maxCallsPerHour?: number | null;
19
+ maxCallsPerDay?: number | null;
20
+ /** Soft limit: after this, runtime should disable I/O tracking/log enrichment. */
21
+ maxTrackedCallsPerMonth?: number | null;
22
+ }
23
+ /**
24
+ * Backend-provided usage baseline for the current billing window.
25
+ * Runtime uses this + local counters to enforce quotas.
26
+ */
27
+ export interface DcdrEntitlementUsageBaseline {
28
+ /** Billing window key in UTC, e.g. "2026-03" */
29
+ periodKey: string;
30
+ /** Baseline calls already accounted for in backend for this period. */
31
+ callsThisMonth: number;
32
+ /** Baseline tracked calls already accounted for (optional). */
33
+ trackedCallsThisMonth?: number;
34
+ }
35
+ /**
36
+ * Optional business-level limits (primarily used by UI/control plane).
37
+ *
38
+ * Notes
39
+ * - Runtime should not rely on these for critical enforcement.
40
+ * - These fields are included so clients can display subscription/plan info.
41
+ */
42
+ export interface DcdrBusinessLimitsContract {
43
+ maxUsers?: number;
44
+ maxServiceTokens?: number;
45
+ logRetentionDays?: number;
46
+ maxIntents?: number;
47
+ maxImplementations?: number;
48
+ maxPromptTemplates?: number;
49
+ maxCredentials?: number;
50
+ maxExecutionWindows?: number;
51
+ maxWebhooks?: number;
52
+ }
53
+ /**
54
+ * Optional business-level usage counters (primarily used by UI/control plane).
55
+ */
56
+ export interface DcdrBusinessUsageContract {
57
+ users?: number;
58
+ serviceTokens?: number;
59
+ implementations?: number;
60
+ intents?: number;
61
+ promptTemplates?: number;
62
+ credentials?: number;
63
+ executionWindows?: number;
64
+ webhooks?: number;
65
+ }
66
+ /**
67
+ * Entitlements snapshot returned by the backend and cached in the runtime.
68
+ *
69
+ * Notes
70
+ * - Runtime enforces `limits` and uses `usageBaseline`.
71
+ * - Other fields are optional and mainly for diagnostics / UI parity.
72
+ */
73
+ export interface DcdrEntitlementsContract {
74
+ cid: string;
75
+ limits: DcdrEntitlementLimits;
76
+ usageBaseline: DcdrEntitlementUsageBaseline;
77
+ /**
78
+ * Optional gate controlling whether the tenant can use the paid DCDR virtual provider.
79
+ *
80
+ * Notes
81
+ * - Additive and fail-open: when omitted, the runtime must assume the virtual provider is enabled.
82
+ * - Intended for wallet/balance enforcement in managed (cloud) mode without affecting BYOK providers.
83
+ */
84
+ dcdrVirtual?: {
85
+ /** When false, runtime must block executions that target `IntentProvider.DCDR`. */
86
+ enabled: boolean;
87
+ /** Optional business-friendly reason code (no sensitive details). */
88
+ reason?: string;
89
+ /** Optional hint for clients on when to retry (ms). */
90
+ retryAfterMs?: number;
91
+ };
92
+ /** Optional reset time for quotas (unix ms). */
93
+ resetAt?: number;
94
+ /** Issued at (unix ms). Optional. */
95
+ iat?: number;
96
+ /** Optional subscription/contract status (backend-defined), e.g. `TRIAL`. */
97
+ subscriptionStatus?: SubscriptionStatus;
98
+ /** Optional subscription end date (unix ms). */
99
+ subscriptionEndDateMs?: number;
100
+ /** Optional log retention in days (may mirror businessLimits.logRetentionDays). */
101
+ logRetentionDays?: number;
102
+ /** Optional business/UI limits snapshot. */
103
+ businessLimits?: DcdrBusinessLimitsContract;
104
+ /** Optional business/UI usage snapshot. */
105
+ businessUsage?: DcdrBusinessUsageContract;
106
+ }
107
+ //# sourceMappingURL=entitlements.contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entitlements.contract.d.ts","sourceRoot":"","sources":["../src/entitlements.contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,iFAAiF;IACjF,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B,kFAAkF;IAClF,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAElB,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;IAEvB,+DAA+D;IAC/D,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,qBAAqB,CAAC;IAC9B,aAAa,EAAE,4BAA4B,CAAC;IAE5C;;;;;;OAMG;IACH,WAAW,CAAC,EAAE;QACZ,mFAAmF;QACnF,OAAO,EAAE,OAAO,CAAC;QAEjB,qEAAqE;QACrE,MAAM,CAAC,EAAE,MAAM,CAAC;QAEhB,uDAAuD;QACvD,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IAEF,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,qCAAqC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,6EAA6E;IAC7E,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC,gDAAgD;IAChD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,4CAA4C;IAC5C,cAAc,CAAC,EAAE,0BAA0B,CAAC;IAE5C,2CAA2C;IAC3C,aAAa,CAAC,EAAE,yBAAyB,CAAC;CAC3C"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * Generic entitlement snapshot for a gateway/runtime.
4
+ *
5
+ * Keep this contract business-agnostic:
6
+ * - "limits" are pure technical quotas
7
+ * - "usageBaseline" is a snapshot for the current billing window
8
+ *
9
+ * Backend remains source-of-truth; runtime uses snapshot + local delta.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Error info for a single attempt or final result.
3
+ * Keep codes stable because your backend may do analytics on them.
4
+ */
5
+ export declare enum ExecutionErrorCode {
6
+ BAD_REQUEST = "BAD_REQUEST",
7
+ TOKEN_BUDGET_TOO_LOW = "TOKEN_BUDGET_TOO_LOW",
8
+ INVALID_INPUT = "INVALID_INPUT",
9
+ VALIDATION_ERROR = "VALIDATION_ERROR",
10
+ UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION",
11
+ MISSING_VARIABLE = "MISSING_VARIABLE",
12
+ CONFIG_ERROR = "CONFIG_ERROR",
13
+ RULES_ERROR = "RULES_ERROR",
14
+ INVALID_OPERATION = "INVALID_OPERATION",
15
+ MODEL_NOT_FOUND = "MODEL_NOT_FOUND",
16
+ MODEL_UNSUPPORTED = "MODEL_UNSUPPORTED",
17
+ PAYMENT_REQUIRED = "PAYMENT_REQUIRED",
18
+ INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
19
+ NO_CONFIG = "NO_CONFIG",
20
+ NO_ACTIVE_MODEL = "NO_ACTIVE_MODEL",
21
+ NO_ELIGIBLE_IMPLEMENTATION = "NO_ELIGIBLE_IMPLEMENTATION",
22
+ PROVIDER_ERROR = "PROVIDER_ERROR",
23
+ PROVIDER_EMPTY_RESPONSE = "PROVIDER_EMPTY_RESPONSE",
24
+ TIMEOUT = "TIMEOUT",
25
+ RATE_LIMIT = "RATE_LIMIT",
26
+ UPSTREAM_5XX = "UPSTREAM_5XX",
27
+ NETWORK = "NETWORK",
28
+ PARSE_FAIL = "PARSE_FAIL",
29
+ SCHEMA_FAIL = "SCHEMA_FAIL",
30
+ INTERNAL_ERROR = "INTERNAL_ERROR",
31
+ CIRCUIT_OPEN = "CIRCUIT_OPEN"
32
+ }
33
+ export interface ExecutionError {
34
+ /**
35
+ * Stable, analytics-friendly code.
36
+ */
37
+ code: ExecutionErrorCode;
38
+ message: string;
39
+ providerStatus?: number;
40
+ details?: any;
41
+ }
42
+ /**
43
+ * Runtime guard for checking whether a string is a known execution error code.
44
+ */
45
+ export declare function isExecutionErrorCode(code: string): code is ExecutionErrorCode;
46
+ export declare function createExecutionError(code: ExecutionErrorCode, message: string, details?: any, providerStatus?: number): ExecutionError;
47
+ //# sourceMappingURL=errors.contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.contract.d.ts","sourceRoot":"","sources":["../src/errors.contract.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B,WAAW,gBAAgB;IAC3B,oBAAoB,yBAAyB;IAC7C,aAAa,kBAAkB;IAC/B,gBAAgB,qBAAqB;IACrC,qBAAqB,0BAA0B;IAC/C,gBAAgB,qBAAqB;IACrC,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,iBAAiB,sBAAsB;IACvC,eAAe,oBAAoB;IACnC,iBAAiB,sBAAsB;IACvC,gBAAgB,qBAAqB;IACrC,mBAAmB,wBAAwB;IAC3C,SAAS,cAAc;IACvB,eAAe,oBAAoB;IACnC,0BAA0B,+BAA+B;IACzD,cAAc,mBAAmB;IACjC,uBAAuB,4BAA4B;IACnD,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAG7E;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,GAAG,EACb,cAAc,CAAC,EAAE,MAAM,GACtB,cAAc,CAEhB"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecutionErrorCode = void 0;
4
+ exports.isExecutionErrorCode = isExecutionErrorCode;
5
+ exports.createExecutionError = createExecutionError;
6
+ /**
7
+ * Error info for a single attempt or final result.
8
+ * Keep codes stable because your backend may do analytics on them.
9
+ */
10
+ var ExecutionErrorCode;
11
+ (function (ExecutionErrorCode) {
12
+ ExecutionErrorCode["BAD_REQUEST"] = "BAD_REQUEST";
13
+ ExecutionErrorCode["TOKEN_BUDGET_TOO_LOW"] = "TOKEN_BUDGET_TOO_LOW";
14
+ ExecutionErrorCode["INVALID_INPUT"] = "INVALID_INPUT";
15
+ ExecutionErrorCode["VALIDATION_ERROR"] = "VALIDATION_ERROR";
16
+ ExecutionErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
17
+ ExecutionErrorCode["MISSING_VARIABLE"] = "MISSING_VARIABLE";
18
+ ExecutionErrorCode["CONFIG_ERROR"] = "CONFIG_ERROR";
19
+ ExecutionErrorCode["RULES_ERROR"] = "RULES_ERROR";
20
+ ExecutionErrorCode["INVALID_OPERATION"] = "INVALID_OPERATION";
21
+ ExecutionErrorCode["MODEL_NOT_FOUND"] = "MODEL_NOT_FOUND";
22
+ ExecutionErrorCode["MODEL_UNSUPPORTED"] = "MODEL_UNSUPPORTED";
23
+ ExecutionErrorCode["PAYMENT_REQUIRED"] = "PAYMENT_REQUIRED";
24
+ ExecutionErrorCode["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
25
+ ExecutionErrorCode["NO_CONFIG"] = "NO_CONFIG";
26
+ ExecutionErrorCode["NO_ACTIVE_MODEL"] = "NO_ACTIVE_MODEL";
27
+ ExecutionErrorCode["NO_ELIGIBLE_IMPLEMENTATION"] = "NO_ELIGIBLE_IMPLEMENTATION";
28
+ ExecutionErrorCode["PROVIDER_ERROR"] = "PROVIDER_ERROR";
29
+ ExecutionErrorCode["PROVIDER_EMPTY_RESPONSE"] = "PROVIDER_EMPTY_RESPONSE";
30
+ ExecutionErrorCode["TIMEOUT"] = "TIMEOUT";
31
+ ExecutionErrorCode["RATE_LIMIT"] = "RATE_LIMIT";
32
+ ExecutionErrorCode["UPSTREAM_5XX"] = "UPSTREAM_5XX";
33
+ ExecutionErrorCode["NETWORK"] = "NETWORK";
34
+ ExecutionErrorCode["PARSE_FAIL"] = "PARSE_FAIL";
35
+ ExecutionErrorCode["SCHEMA_FAIL"] = "SCHEMA_FAIL";
36
+ ExecutionErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
37
+ ExecutionErrorCode["CIRCUIT_OPEN"] = "CIRCUIT_OPEN";
38
+ })(ExecutionErrorCode || (exports.ExecutionErrorCode = ExecutionErrorCode = {}));
39
+ /**
40
+ * Runtime guard for checking whether a string is a known execution error code.
41
+ */
42
+ function isExecutionErrorCode(code) {
43
+ // Object.values on string enums returns the string values.
44
+ return Object.values(ExecutionErrorCode).includes(code);
45
+ }
46
+ function createExecutionError(code, message, details, providerStatus) {
47
+ return { code, message, details, providerStatus };
48
+ }