@oxyhq/contracts 0.29.0 → 0.31.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.
Files changed (51) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountGraph.js +41 -0
  3. package/dist/cjs/identity.js +33 -1
  4. package/dist/cjs/index.js +35 -7
  5. package/dist/cjs/inference/aliaModelRelease.js +262 -0
  6. package/dist/cjs/inference/catalogue.js +1 -4
  7. package/dist/cjs/inference/identifiers.js +23 -3
  8. package/dist/cjs/inference/modelDocumentation.js +433 -0
  9. package/dist/cjs/inference/providerConnection.js +77 -7
  10. package/dist/cjs/inference/request.js +188 -5
  11. package/dist/cjs/inference/routingPolicy.js +81 -2
  12. package/dist/cjs/inference/streamEvents.js +27 -0
  13. package/dist/cjs/inference/usage.js +32 -1
  14. package/dist/cjs/inference/version.js +15 -2
  15. package/dist/cjs/updates.js +2 -0
  16. package/dist/esm/.tsbuildinfo +1 -1
  17. package/dist/esm/accountGraph.js +41 -0
  18. package/dist/esm/identity.js +32 -0
  19. package/dist/esm/index.js +14 -4
  20. package/dist/esm/inference/aliaModelRelease.js +259 -0
  21. package/dist/esm/inference/catalogue.js +2 -5
  22. package/dist/esm/inference/identifiers.js +22 -2
  23. package/dist/esm/inference/modelDocumentation.js +430 -0
  24. package/dist/esm/inference/providerConnection.js +76 -6
  25. package/dist/esm/inference/request.js +189 -6
  26. package/dist/esm/inference/routingPolicy.js +81 -2
  27. package/dist/esm/inference/streamEvents.js +27 -0
  28. package/dist/esm/inference/usage.js +32 -1
  29. package/dist/esm/inference/version.js +15 -2
  30. package/dist/esm/updates.js +2 -0
  31. package/dist/types/.tsbuildinfo +1 -1
  32. package/dist/types/accountGraph.d.ts +43 -0
  33. package/dist/types/identity.d.ts +59 -1
  34. package/dist/types/index.d.ts +10 -6
  35. package/dist/types/inference/accountBilling.d.ts +26 -26
  36. package/dist/types/inference/aliaModelRelease.d.ts +609 -0
  37. package/dist/types/inference/catalogue.d.ts +6 -6
  38. package/dist/types/inference/entitlement.d.ts +4 -4
  39. package/dist/types/inference/identifiers.d.ts +20 -2
  40. package/dist/types/inference/modelDocumentation.d.ts +1603 -0
  41. package/dist/types/inference/money.d.ts +4 -4
  42. package/dist/types/inference/priceVersion.d.ts +14 -14
  43. package/dist/types/inference/providerConnection.d.ts +37 -8
  44. package/dist/types/inference/request.d.ts +291 -5
  45. package/dist/types/inference/routingPolicy.d.ts +109 -13
  46. package/dist/types/inference/streamEvents.d.ts +53 -26
  47. package/dist/types/inference/usage.d.ts +103 -79
  48. package/dist/types/inference/version.d.ts +15 -2
  49. package/dist/types/keyRecovery.d.ts +4 -4
  50. package/dist/types/updates.d.ts +10 -0
  51. package/package.json +1 -1
@@ -69,11 +69,11 @@ export declare const moneySchema: z.ZodObject<{
69
69
  amount: z.ZodBranded<z.ZodString, "ExactDecimal">;
70
70
  currency: z.ZodString;
71
71
  }, "strict", z.ZodTypeAny, {
72
- amount: string & z.BRAND<"ExactDecimal">;
73
72
  currency: string;
73
+ amount: string & z.BRAND<"ExactDecimal">;
74
74
  }, {
75
- amount: string;
76
75
  currency: string;
76
+ amount: string;
77
77
  }>;
78
78
  /**
79
79
  * The closed set of units inference is metered in.
@@ -166,13 +166,13 @@ export declare const unitPriceSchema: z.ZodObject<{
166
166
  per: z.ZodNumber;
167
167
  currency: z.ZodString;
168
168
  }, "strict", z.ZodTypeAny, {
169
- amount: string & z.BRAND<"ExactDecimal">;
170
169
  currency: string;
170
+ amount: string & z.BRAND<"ExactDecimal">;
171
171
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
172
172
  per: number;
173
173
  }, {
174
- amount: string;
175
174
  currency: string;
175
+ amount: string;
176
176
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
177
177
  per: number;
178
178
  }>;
@@ -46,13 +46,13 @@ export declare const priceVersionSchema: z.ZodEffects<z.ZodObject<{
46
46
  per: z.ZodNumber;
47
47
  currency: z.ZodString;
48
48
  }, "strict", z.ZodTypeAny, {
49
- amount: string & z.BRAND<"ExactDecimal">;
50
49
  currency: string;
50
+ amount: string & z.BRAND<"ExactDecimal">;
51
51
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
52
52
  per: number;
53
53
  }, {
54
- amount: string;
55
54
  currency: string;
55
+ amount: string;
56
56
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
57
57
  per: number;
58
58
  }>, "many">;
@@ -64,15 +64,15 @@ export declare const priceVersionSchema: z.ZodEffects<z.ZodObject<{
64
64
  createdAt: z.ZodString;
65
65
  }, "strip", z.ZodTypeAny, {
66
66
  status: "active" | "superseded" | "draft";
67
- createdAt: string;
68
67
  currency: string;
68
+ createdAt: string;
69
69
  provider: string;
70
70
  schemaVersion: 1;
71
71
  priceVersionId: string;
72
72
  modelReference: string;
73
73
  unitPrices: {
74
- amount: string & z.BRAND<"ExactDecimal">;
75
74
  currency: string;
75
+ amount: string & z.BRAND<"ExactDecimal">;
76
76
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
77
77
  per: number;
78
78
  }[];
@@ -81,15 +81,15 @@ export declare const priceVersionSchema: z.ZodEffects<z.ZodObject<{
81
81
  supersedesPriceVersionId?: string | undefined;
82
82
  }, {
83
83
  status: "active" | "superseded" | "draft";
84
- createdAt: string;
85
84
  currency: string;
85
+ createdAt: string;
86
86
  provider: string;
87
87
  schemaVersion: 1;
88
88
  priceVersionId: string;
89
89
  modelReference: string;
90
90
  unitPrices: {
91
- amount: string;
92
91
  currency: string;
92
+ amount: string;
93
93
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
94
94
  per: number;
95
95
  }[];
@@ -98,15 +98,15 @@ export declare const priceVersionSchema: z.ZodEffects<z.ZodObject<{
98
98
  supersedesPriceVersionId?: string | undefined;
99
99
  }>, {
100
100
  status: "active" | "superseded" | "draft";
101
- createdAt: string;
102
101
  currency: string;
102
+ createdAt: string;
103
103
  provider: string;
104
104
  schemaVersion: 1;
105
105
  priceVersionId: string;
106
106
  modelReference: string;
107
107
  unitPrices: {
108
- amount: string & z.BRAND<"ExactDecimal">;
109
108
  currency: string;
109
+ amount: string & z.BRAND<"ExactDecimal">;
110
110
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
111
111
  per: number;
112
112
  }[];
@@ -115,15 +115,15 @@ export declare const priceVersionSchema: z.ZodEffects<z.ZodObject<{
115
115
  supersedesPriceVersionId?: string | undefined;
116
116
  }, {
117
117
  status: "active" | "superseded" | "draft";
118
- createdAt: string;
119
118
  currency: string;
119
+ createdAt: string;
120
120
  provider: string;
121
121
  schemaVersion: 1;
122
122
  priceVersionId: string;
123
123
  modelReference: string;
124
124
  unitPrices: {
125
- amount: string;
126
125
  currency: string;
126
+ amount: string;
127
127
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
128
128
  per: number;
129
129
  }[];
@@ -148,13 +148,13 @@ export declare const priceSnapshotSchema: z.ZodObject<{
148
148
  per: z.ZodNumber;
149
149
  currency: z.ZodString;
150
150
  }, "strict", z.ZodTypeAny, {
151
- amount: string & z.BRAND<"ExactDecimal">;
152
151
  currency: string;
152
+ amount: string & z.BRAND<"ExactDecimal">;
153
153
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
154
154
  per: number;
155
155
  }, {
156
- amount: string;
157
156
  currency: string;
157
+ amount: string;
158
158
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
159
159
  per: number;
160
160
  }>, "many">;
@@ -162,8 +162,8 @@ export declare const priceSnapshotSchema: z.ZodObject<{
162
162
  currency: string;
163
163
  priceVersionId: string;
164
164
  unitPrices: {
165
- amount: string & z.BRAND<"ExactDecimal">;
166
165
  currency: string;
166
+ amount: string & z.BRAND<"ExactDecimal">;
167
167
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
168
168
  per: number;
169
169
  }[];
@@ -171,8 +171,8 @@ export declare const priceSnapshotSchema: z.ZodObject<{
171
171
  currency: string;
172
172
  priceVersionId: string;
173
173
  unitPrices: {
174
- amount: string;
175
174
  currency: string;
175
+ amount: string;
176
176
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
177
177
  per: number;
178
178
  }[];
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * The credential itself is NOT here and cannot be put here. This shape carries
6
6
  * a locator (`secretRef`) into Vault/KMS/managed secret storage, a prefix short
7
- * enough to be useless, a fingerprint, and validation state. Two mechanisms
7
+ * enough to be useless, a fingerprint, and validation state. Three mechanisms
8
8
  * make that structural rather than a convention somebody must remember:
9
9
  *
10
10
  * - The object is `.strict()`. A producer that attaches `apiKey`, `secret`,
@@ -14,6 +14,10 @@
14
14
  * - `keyPrefix` is capped at 12 characters — shorter than any provider's
15
15
  * usable credential — so the one field designed to show part of a key cannot
16
16
  * be widened into showing all of it without changing the contract.
17
+ * - `secretRef` is DERIVED, not free text: the grammar is closed and the
18
+ * refinement below requires it to be this connection's own environment,
19
+ * owner account and id under one namespace. A field with no free span is a
20
+ * field a credential cannot be smuggled through.
17
21
  *
18
22
  * BYOK does not move the billing relationship: the upstream provider bills the
19
23
  * customer's own account directly, and Oxy charges only its platform fee. The
@@ -64,12 +68,37 @@ export declare const providerConnectionScopeSchema: z.ZodDiscriminatedUnion<"kin
64
68
  accountId: string;
65
69
  applicationId: string;
66
70
  }>]>;
71
+ /**
72
+ * The namespace every Oxy BYOK locator lives under, whichever store holds it.
73
+ *
74
+ * Part of the grammar rather than an implementation detail of the writer: it is
75
+ * the prefix a store-side IAM or Vault policy is scoped to, so a locator outside
76
+ * it is one Oxy's own credentials could not resolve anyway.
77
+ */
78
+ export declare const PROVIDER_SECRET_REFERENCE_NAMESPACE = "oxy/inference/byok";
67
79
  /**
68
80
  * A locator for the credential in managed secret storage — never the credential.
69
81
  *
70
- * The scheme prefix is constrained to the stores Oxy actually uses, so a
71
- * producer cannot pass a raw key through this field and have it look like a
72
- * reference; whitespace is excluded for the same reason.
82
+ * The grammar is CLOSED, and that is the whole of its value: a store from a
83
+ * four-name set, one fixed namespace, an environment from a three-name set, and
84
+ * two bounded id segments. Nothing may precede, follow or be interpolated
85
+ * between them, so there is no free-form span for credential material to occupy:
86
+ * the only places anything a producer chooses can sit are the two ids, and
87
+ * `providerConnectionSchema` below pins those to THIS connection's own owner
88
+ * account and id.
89
+ *
90
+ * ## It was not always closed, and the difference was measured
91
+ *
92
+ * The previous grammar was `<store>:<anything from a wide charset>`, under a
93
+ * comment claiming that meant "a producer cannot pass a raw key through this
94
+ * field and have it look like a reference". It did not. Splicing a credential in
95
+ * after the store name —
96
+ * `vault:sk-ant-api03-…/oxy/inference/byok/production/<account>/<id>` — satisfied
97
+ * that regex, satisfied the storage partition CHECK (which pins the END of the
98
+ * string and said nothing about its start), and parsed cleanly. Both mechanisms
99
+ * constrained the SHAPE of the locator; neither constrained what could be put in
100
+ * front of it. `packages/api`'s `providerSecretLeak.test.ts` plants exactly that
101
+ * value, and it is now refused here, by the CHECK, and by the refinement below.
73
102
  */
74
103
  export declare const providerSecretReferenceSchema: z.ZodString;
75
104
  /** Why a credential check failed, as a closed set the Console can render. */
@@ -178,6 +207,7 @@ export declare const providerConnectionSchema: z.ZodEffects<z.ZodObject<{
178
207
  failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
179
208
  };
180
209
  status: "active" | "revoked" | "disabled" | "pending_validation";
210
+ createdAt: string;
181
211
  scope: {
182
212
  kind: "account";
183
213
  accountId: string & z.BRAND<"OxyAccountId">;
@@ -189,7 +219,6 @@ export declare const providerConnectionSchema: z.ZodEffects<z.ZodObject<{
189
219
  accountId: string & z.BRAND<"OxyAccountId">;
190
220
  applicationId: string;
191
221
  };
192
- createdAt: string;
193
222
  provider: string;
194
223
  schemaVersion: 1;
195
224
  connectionId: string;
@@ -208,6 +237,7 @@ export declare const providerConnectionSchema: z.ZodEffects<z.ZodObject<{
208
237
  failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
209
238
  };
210
239
  status: "active" | "revoked" | "disabled" | "pending_validation";
240
+ createdAt: string;
211
241
  scope: {
212
242
  kind: "account";
213
243
  accountId: string;
@@ -219,7 +249,6 @@ export declare const providerConnectionSchema: z.ZodEffects<z.ZodObject<{
219
249
  accountId: string;
220
250
  applicationId: string;
221
251
  };
222
- createdAt: string;
223
252
  provider: string;
224
253
  schemaVersion: 1;
225
254
  connectionId: string;
@@ -238,6 +267,7 @@ export declare const providerConnectionSchema: z.ZodEffects<z.ZodObject<{
238
267
  failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
239
268
  };
240
269
  status: "active" | "revoked" | "disabled" | "pending_validation";
270
+ createdAt: string;
241
271
  scope: {
242
272
  kind: "account";
243
273
  accountId: string & z.BRAND<"OxyAccountId">;
@@ -249,7 +279,6 @@ export declare const providerConnectionSchema: z.ZodEffects<z.ZodObject<{
249
279
  accountId: string & z.BRAND<"OxyAccountId">;
250
280
  applicationId: string;
251
281
  };
252
- createdAt: string;
253
282
  provider: string;
254
283
  schemaVersion: 1;
255
284
  connectionId: string;
@@ -268,6 +297,7 @@ export declare const providerConnectionSchema: z.ZodEffects<z.ZodObject<{
268
297
  failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
269
298
  };
270
299
  status: "active" | "revoked" | "disabled" | "pending_validation";
300
+ createdAt: string;
271
301
  scope: {
272
302
  kind: "account";
273
303
  accountId: string;
@@ -279,7 +309,6 @@ export declare const providerConnectionSchema: z.ZodEffects<z.ZodObject<{
279
309
  accountId: string;
280
310
  applicationId: string;
281
311
  };
282
- createdAt: string;
283
312
  provider: string;
284
313
  schemaVersion: 1;
285
314
  connectionId: string;