@oxyhq/contracts 0.28.0 → 0.29.0

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.
@@ -37,9 +37,14 @@ import { z } from 'zod';
37
37
  * PLATFORM's own credential fails every identical retry until an operator
38
38
  * rotates a key, so classifying it as `provider_error` would send every client
39
39
  * into a retry loop against a request that cannot succeed.
40
+ *
41
+ * `provider_billing_refused` is in that group for the same reason and was found
42
+ * the same way — an upstream declining to bill OXY (Anthropic answers 402) has
43
+ * to be distinguishable from the customer's own balance running out, or the
44
+ * error tells them to go and top up an account that is not the one at fault.
40
45
  */
41
- export declare const INFERENCE_ERROR_CODES: readonly ["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "service_unavailable", "internal_error"];
42
- export declare const inferenceErrorCodeSchema: z.ZodEnum<["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "service_unavailable", "internal_error"]>;
46
+ export declare const INFERENCE_ERROR_CODES: readonly ["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "provider_billing_refused", "service_unavailable", "internal_error"];
47
+ export declare const inferenceErrorCodeSchema: z.ZodEnum<["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "provider_billing_refused", "service_unavailable", "internal_error"]>;
43
48
  /**
44
49
  * Codes for which an identical retried request cannot succeed.
45
50
  *
@@ -55,12 +60,43 @@ export declare const inferenceErrorCodeSchema: z.ZodEnum<["invalid_request", "au
55
60
  * one because only the first names an action the customer can take. Both are
56
61
  * non-retryable for the same reason: a credential an upstream has refused keeps
57
62
  * being refused until somebody replaces it.
63
+ *
64
+ * `quota_exceeded` and `provider_billing_refused` divide along the same line:
65
+ * both are money, but one is the CUSTOMER's ceiling and the other is Oxy's
66
+ * account with an upstream. Reporting the second as the first is retryability-
67
+ * correct and diagnostically wrong, which is the worst combination — it reads
68
+ * as actionable and the action does nothing.
58
69
  */
59
- export declare const NON_RETRYABLE_INFERENCE_ERROR_CODES: readonly ["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "provider_credential_invalid"];
70
+ export declare const NON_RETRYABLE_INFERENCE_ERROR_CODES: readonly ["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "provider_credential_invalid", "provider_billing_refused"];
60
71
  /**
61
- * Free text that is safe to hand a customer: bounded, and refused outright if a
62
- * credential marker appears in it. Applied to BOTH the Oxy message and the
72
+ * Free text that is safe to hand a customer: bounded, and refused if it still
73
+ * looks like it carries a credential. Applied to BOTH the Oxy message and the
63
74
  * upstream one — a leak is no less a leak for having been written by a provider.
75
+ *
76
+ * ## This is a last-resort REFUSAL, not protection
77
+ *
78
+ * A pattern over the OUTPUT cannot be the control that keeps a credential out of
79
+ * an error, and a producer that treats it as one has the hole #1027 reported.
80
+ * The only reliable control is redacting the KNOWN SECRET VALUE at the point
81
+ * where the producer still holds the bytes it sent — which is an adapter's job
82
+ * and is available to nobody else. This refinement exists to catch what that
83
+ * control missed, and nothing here is a licence to skip it.
84
+ *
85
+ * Two rules follow, and they are the whole reason this text is longer than the
86
+ * pattern it describes:
87
+ *
88
+ * - **Never redact by replacing the span this pattern matched.** The span is
89
+ * the MARKER; the secret is what follows it. OxyHQ/Relay#3 measured the
90
+ * result: `{x-api-key: <key>}` is refused, `{x-[redacted] <key>}` was
91
+ * accepted, and both carry the key. Redaction made the leak worse by
92
+ * converting "this string is dangerous" into "this string is fine".
93
+ * - **This package deliberately ships no redaction helper.** One keyed on these
94
+ * patterns would rebuild the same defect one layer up, and one that took the
95
+ * secret as an argument would only restate what the producer already has.
96
+ *
97
+ * What it still cannot see, stated so nobody relies on it: a credential with no
98
+ * marker, no issued-token prefix and no placeholder beside it is bytes that look
99
+ * like a request id, and refusing those means refusing request ids.
64
100
  */
65
101
  export declare const safeErrorTextSchema: z.ZodEffects<z.ZodString, string, string>;
66
102
  /**
@@ -110,7 +146,7 @@ export declare const providerErrorPassthroughSchema: z.ZodObject<{
110
146
  export declare const inferenceErrorSchema: z.ZodEffects<z.ZodObject<{
111
147
  /** See `version.ts`: this shape appears alone on the wire, so it is versioned. */
112
148
  schemaVersion: z.ZodLiteral<1>;
113
- code: z.ZodEnum<["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "service_unavailable", "internal_error"]>;
149
+ code: z.ZodEnum<["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "provider_billing_refused", "service_unavailable", "internal_error"]>;
114
150
  message: z.ZodEffects<z.ZodString, string, string>;
115
151
  retryable: z.ZodBoolean;
116
152
  requestId: z.ZodString;
@@ -140,7 +176,7 @@ export declare const inferenceErrorSchema: z.ZodEffects<z.ZodObject<{
140
176
  status?: number | undefined;
141
177
  }>>;
142
178
  }, "strip", z.ZodTypeAny, {
143
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
179
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
144
180
  message: string;
145
181
  requestId: string;
146
182
  schemaVersion: 1;
@@ -155,7 +191,7 @@ export declare const inferenceErrorSchema: z.ZodEffects<z.ZodObject<{
155
191
  status?: number | undefined;
156
192
  } | undefined;
157
193
  }, {
158
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
194
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
159
195
  message: string;
160
196
  requestId: string;
161
197
  schemaVersion: 1;
@@ -170,7 +206,7 @@ export declare const inferenceErrorSchema: z.ZodEffects<z.ZodObject<{
170
206
  status?: number | undefined;
171
207
  } | undefined;
172
208
  }>, {
173
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
209
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
174
210
  message: string;
175
211
  requestId: string;
176
212
  schemaVersion: 1;
@@ -185,7 +221,7 @@ export declare const inferenceErrorSchema: z.ZodEffects<z.ZodObject<{
185
221
  status?: number | undefined;
186
222
  } | undefined;
187
223
  }, {
188
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
224
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
189
225
  message: string;
190
226
  requestId: string;
191
227
  schemaVersion: 1;
@@ -345,7 +345,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
345
345
  /** Carries its own `schemaVersion`: the same body is returned non-streaming. */
346
346
  error: z.ZodEffects<z.ZodObject<{
347
347
  schemaVersion: z.ZodLiteral<1>;
348
- code: z.ZodEnum<["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "service_unavailable", "internal_error"]>;
348
+ code: z.ZodEnum<["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "provider_billing_refused", "service_unavailable", "internal_error"]>;
349
349
  message: z.ZodEffects<z.ZodString, string, string>;
350
350
  retryable: z.ZodBoolean;
351
351
  requestId: z.ZodString;
@@ -369,7 +369,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
369
369
  status?: number | undefined;
370
370
  }>>;
371
371
  }, "strip", z.ZodTypeAny, {
372
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
372
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
373
373
  message: string;
374
374
  requestId: string;
375
375
  schemaVersion: 1;
@@ -384,7 +384,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
384
384
  status?: number | undefined;
385
385
  } | undefined;
386
386
  }, {
387
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
387
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
388
388
  message: string;
389
389
  requestId: string;
390
390
  schemaVersion: 1;
@@ -399,7 +399,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
399
399
  status?: number | undefined;
400
400
  } | undefined;
401
401
  }>, {
402
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
402
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
403
403
  message: string;
404
404
  requestId: string;
405
405
  schemaVersion: 1;
@@ -414,7 +414,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
414
414
  status?: number | undefined;
415
415
  } | undefined;
416
416
  }, {
417
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
417
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
418
418
  message: string;
419
419
  requestId: string;
420
420
  schemaVersion: 1;
@@ -435,7 +435,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
435
435
  schemaVersion: 1;
436
436
  sequence: number;
437
437
  error: {
438
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
438
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
439
439
  message: string;
440
440
  requestId: string;
441
441
  schemaVersion: 1;
@@ -456,7 +456,7 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
456
456
  schemaVersion: 1;
457
457
  sequence: number;
458
458
  error: {
459
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
459
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
460
460
  message: string;
461
461
  requestId: string;
462
462
  schemaVersion: 1;
@@ -472,8 +472,17 @@ export declare const inferenceStreamErrorEventSchema: z.ZodObject<{
472
472
  } | undefined;
473
473
  };
474
474
  }>;
475
- /** Why generation stopped. */
476
- export declare const inferenceFinishReasonSchema: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "cancelled"]>;
475
+ /**
476
+ * Why generation stopped.
477
+ *
478
+ * `refusal` and `content_filter` are separate members because they are separate
479
+ * events: the MODEL declining to answer is a property of the answer, while a
480
+ * filter is an upstream system removing one. The delta channels already carry
481
+ * that distinction (`channel: 'refusal'` beside the filter's own error code),
482
+ * so collapsing it here would have made the terminal event less specific than
483
+ * the stream that produced it.
484
+ */
485
+ export declare const inferenceFinishReasonSchema: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "refusal", "cancelled"]>;
477
486
  /**
478
487
  * The successful terminal event.
479
488
  *
@@ -487,7 +496,7 @@ export declare const inferenceStreamDoneEventSchema: z.ZodObject<{
487
496
  requestId: z.ZodString;
488
497
  sequence: z.ZodNumber;
489
498
  generationId: z.ZodOptional<z.ZodString>;
490
- finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "cancelled"]>;
499
+ finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "refusal", "cancelled"]>;
491
500
  receiptId: z.ZodOptional<z.ZodString>;
492
501
  completedAt: z.ZodString;
493
502
  }, "strip", z.ZodTypeAny, {
@@ -495,7 +504,7 @@ export declare const inferenceStreamDoneEventSchema: z.ZodObject<{
495
504
  requestId: string;
496
505
  schemaVersion: 1;
497
506
  sequence: number;
498
- finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
507
+ finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
499
508
  completedAt: string;
500
509
  generationId?: string | undefined;
501
510
  receiptId?: string | undefined;
@@ -504,7 +513,7 @@ export declare const inferenceStreamDoneEventSchema: z.ZodObject<{
504
513
  requestId: string;
505
514
  schemaVersion: 1;
506
515
  sequence: number;
507
- finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
516
+ finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
508
517
  completedAt: string;
509
518
  generationId?: string | undefined;
510
519
  receiptId?: string | undefined;
@@ -738,7 +747,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
738
747
  /** Carries its own `schemaVersion`: the same body is returned non-streaming. */
739
748
  error: z.ZodEffects<z.ZodObject<{
740
749
  schemaVersion: z.ZodLiteral<1>;
741
- code: z.ZodEnum<["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "service_unavailable", "internal_error"]>;
750
+ code: z.ZodEnum<["invalid_request", "authentication_failed", "permission_denied", "insufficient_scope", "model_not_found", "unsupported_modality", "context_length_exceeded", "request_too_large", "output_limit_exceeded", "idempotency_conflict", "insufficient_balance", "spending_limit_exceeded", "quota_exceeded", "byok_credential_invalid", "policy_violation", "commercial_permission_denied", "no_route_available", "upstream_content_filtered", "cancelled", "rate_limited", "deployment_unavailable", "provider_error", "provider_timeout", "provider_overloaded", "provider_credential_invalid", "provider_billing_refused", "service_unavailable", "internal_error"]>;
742
751
  message: z.ZodEffects<z.ZodString, string, string>;
743
752
  retryable: z.ZodBoolean;
744
753
  requestId: z.ZodString;
@@ -762,7 +771,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
762
771
  status?: number | undefined;
763
772
  }>>;
764
773
  }, "strip", z.ZodTypeAny, {
765
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
774
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
766
775
  message: string;
767
776
  requestId: string;
768
777
  schemaVersion: 1;
@@ -777,7 +786,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
777
786
  status?: number | undefined;
778
787
  } | undefined;
779
788
  }, {
780
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
789
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
781
790
  message: string;
782
791
  requestId: string;
783
792
  schemaVersion: 1;
@@ -792,7 +801,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
792
801
  status?: number | undefined;
793
802
  } | undefined;
794
803
  }>, {
795
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
804
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
796
805
  message: string;
797
806
  requestId: string;
798
807
  schemaVersion: 1;
@@ -807,7 +816,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
807
816
  status?: number | undefined;
808
817
  } | undefined;
809
818
  }, {
810
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
819
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
811
820
  message: string;
812
821
  requestId: string;
813
822
  schemaVersion: 1;
@@ -828,7 +837,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
828
837
  schemaVersion: 1;
829
838
  sequence: number;
830
839
  error: {
831
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
840
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
832
841
  message: string;
833
842
  requestId: string;
834
843
  schemaVersion: 1;
@@ -849,7 +858,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
849
858
  schemaVersion: 1;
850
859
  sequence: number;
851
860
  error: {
852
- code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "service_unavailable" | "internal_error";
861
+ code: "invalid_request" | "authentication_failed" | "permission_denied" | "insufficient_scope" | "model_not_found" | "unsupported_modality" | "context_length_exceeded" | "request_too_large" | "output_limit_exceeded" | "idempotency_conflict" | "insufficient_balance" | "spending_limit_exceeded" | "quota_exceeded" | "byok_credential_invalid" | "policy_violation" | "commercial_permission_denied" | "no_route_available" | "upstream_content_filtered" | "cancelled" | "rate_limited" | "deployment_unavailable" | "provider_error" | "provider_timeout" | "provider_overloaded" | "provider_credential_invalid" | "provider_billing_refused" | "service_unavailable" | "internal_error";
853
862
  message: string;
854
863
  requestId: string;
855
864
  schemaVersion: 1;
@@ -871,7 +880,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
871
880
  requestId: z.ZodString;
872
881
  sequence: z.ZodNumber;
873
882
  generationId: z.ZodOptional<z.ZodString>;
874
- finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "cancelled"]>;
883
+ finishReason: z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "refusal", "cancelled"]>;
875
884
  receiptId: z.ZodOptional<z.ZodString>;
876
885
  completedAt: z.ZodString;
877
886
  }, "strip", z.ZodTypeAny, {
@@ -879,7 +888,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
879
888
  requestId: string;
880
889
  schemaVersion: 1;
881
890
  sequence: number;
882
- finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
891
+ finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
883
892
  completedAt: string;
884
893
  generationId?: string | undefined;
885
894
  receiptId?: string | undefined;
@@ -888,7 +897,7 @@ export declare const inferenceStreamEventSchema: z.ZodDiscriminatedUnion<"type",
888
897
  requestId: string;
889
898
  schemaVersion: 1;
890
899
  sequence: number;
891
- finishReason: "length" | "cancelled" | "content_filter" | "stop" | "tool_calls";
900
+ finishReason: "length" | "cancelled" | "content_filter" | "refusal" | "stop" | "tool_calls";
892
901
  completedAt: string;
893
902
  generationId?: string | undefined;
894
903
  receiptId?: string | undefined;
@@ -71,12 +71,19 @@
71
71
  *
72
72
  * MAJOR is bumped when any individual shape's `schemaVersion` increments (at
73
73
  * least one message is now read differently by the two sides); MINOR when a
74
- * shape or an optional field is added; PATCH for documentation-only changes
75
- * that leave every parsed byte identical.
74
+ * shape or an optional field is added, when a CLOSED ENUM gains a member, or
75
+ * when a refinement changes which bytes parse; PATCH for documentation-only
76
+ * changes that leave every parsed byte identical.
77
+ *
78
+ * The last two are MINOR rather than PATCH because both produce the same
79
+ * failure: a producer on the newer set emits something the older set refuses,
80
+ * with no `schemaVersion` difference to explain it. A new enum member and a
81
+ * loosened refinement are exactly what the handshake exists to surface — a
82
+ * skew the per-message version cannot express.
76
83
  *
77
84
  * This constant is deliberately NOT embedded in the request envelope. Pinning a
78
85
  * request to the version of the whole set would make an unrelated additive
79
86
  * change to, say, the catalogue reject every in-flight inference request; the
80
87
  * per-shape `schemaVersion` is what a message is validated against.
81
88
  */
82
- export declare const INFERENCE_CONTRACT_VERSION = "1.0.0";
89
+ export declare const INFERENCE_CONTRACT_VERSION = "1.1.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/contracts",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "OxyHQ API contracts — single source of truth for request/response Zod schemas and inferred types, shared by the backend and the client SDKs",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",