@oxyhq/contracts 0.26.0 → 0.28.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 (52) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountGraph.js +4 -3
  3. package/dist/cjs/index.js +186 -1
  4. package/dist/cjs/inference/accountBilling.js +334 -0
  5. package/dist/cjs/inference/attribution.js +106 -0
  6. package/dist/cjs/inference/catalogue.js +482 -0
  7. package/dist/cjs/inference/entitlement.js +217 -0
  8. package/dist/cjs/inference/errors.js +210 -0
  9. package/dist/cjs/inference/identifiers.js +197 -0
  10. package/dist/cjs/inference/money.js +188 -0
  11. package/dist/cjs/inference/priceVersion.js +110 -0
  12. package/dist/cjs/inference/providerConnection.js +142 -0
  13. package/dist/cjs/inference/request.js +288 -0
  14. package/dist/cjs/inference/routingPolicy.js +213 -0
  15. package/dist/cjs/inference/streamEvents.js +219 -0
  16. package/dist/cjs/inference/usage.js +297 -0
  17. package/dist/cjs/inference/version.js +85 -0
  18. package/dist/esm/.tsbuildinfo +1 -1
  19. package/dist/esm/accountGraph.js +4 -3
  20. package/dist/esm/index.js +54 -0
  21. package/dist/esm/inference/accountBilling.js +331 -0
  22. package/dist/esm/inference/attribution.js +103 -0
  23. package/dist/esm/inference/catalogue.js +479 -0
  24. package/dist/esm/inference/entitlement.js +214 -0
  25. package/dist/esm/inference/errors.js +207 -0
  26. package/dist/esm/inference/identifiers.js +194 -0
  27. package/dist/esm/inference/money.js +185 -0
  28. package/dist/esm/inference/priceVersion.js +107 -0
  29. package/dist/esm/inference/providerConnection.js +139 -0
  30. package/dist/esm/inference/request.js +285 -0
  31. package/dist/esm/inference/routingPolicy.js +210 -0
  32. package/dist/esm/inference/streamEvents.js +216 -0
  33. package/dist/esm/inference/usage.js +294 -0
  34. package/dist/esm/inference/version.js +82 -0
  35. package/dist/types/.tsbuildinfo +1 -1
  36. package/dist/types/accountGraph.d.ts +6 -5
  37. package/dist/types/index.d.ts +27 -0
  38. package/dist/types/inference/accountBilling.d.ts +738 -0
  39. package/dist/types/inference/attribution.d.ts +176 -0
  40. package/dist/types/inference/catalogue.d.ts +1612 -0
  41. package/dist/types/inference/entitlement.d.ts +519 -0
  42. package/dist/types/inference/errors.d.ts +206 -0
  43. package/dist/types/inference/identifiers.d.ts +157 -0
  44. package/dist/types/inference/money.d.ts +185 -0
  45. package/dist/types/inference/priceVersion.d.ts +182 -0
  46. package/dist/types/inference/providerConnection.d.ts +297 -0
  47. package/dist/types/inference/request.d.ts +2364 -0
  48. package/dist/types/inference/routingPolicy.d.ts +426 -0
  49. package/dist/types/inference/streamEvents.d.ts +906 -0
  50. package/dist/types/inference/usage.d.ts +1139 -0
  51. package/dist/types/inference/version.d.ts +82 -0
  52. package/package.json +1 -1
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Version rule for the Oxy↔data-plane inference contracts.
3
+ *
4
+ * Oxy is the control plane; the inference data plane is a separate service.
5
+ * They are deployed independently, in different repositories, possibly in
6
+ * different languages.
7
+ * Every shape they exchange therefore carries its version IN THE PARSED DATA,
8
+ * never as a comment or an out-of-band assumption, so a producer running ahead
9
+ * of a consumer fails loudly at the parse instead of being silently reinterpreted.
10
+ *
11
+ * The rule, enforced by `src/__tests__/inference.compatibility.test.ts`:
12
+ *
13
+ * - A schema carries `schemaVersion: z.literal(<n>)` **if and only if** it can
14
+ * appear on the wire as a whole message — a request envelope, a stream event,
15
+ * a catalogue descriptor, a ledger record, an error body.
16
+ * - A schema that only ever appears EMBEDDED inside such a message (the
17
+ * attribution block, one message part, one usage quantity, a data-retention
18
+ * policy) carries no version of its own: it inherits the version of the
19
+ * envelope it rides in. Versioning it separately would create two versions
20
+ * that can disagree about one byte stream.
21
+ * - A shape that is BOTH — `inferenceErrorSchema` is returned as an HTTP body
22
+ * and also rides inside the stream's error event — keeps its own version.
23
+ * The envelope's version then governs the envelope and the payload's governs
24
+ * the payload, which is two versions of two things rather than two versions
25
+ * of one.
26
+ * - Every exported object schema in `src/inference/` must fall into exactly one
27
+ * of those groups. The compatibility test holds both lists as exact
28
+ * equalities, so a new shape that is in neither fails the build rather than
29
+ * quietly shipping unversioned.
30
+ *
31
+ * A shape's own version is bumped when its meaning changes in a way a consumer
32
+ * pinned to the previous version would misread — a field removed, a field's
33
+ * units changed, a closed enum's member given a new meaning. Adding an OPTIONAL
34
+ * field is additive and does not bump it, because a consumer on the previous
35
+ * version parses the message correctly and simply does not read the new field.
36
+ *
37
+ * ## Which shapes reject an unknown field
38
+ *
39
+ * That last rule is why the shapes EXCHANGED WITH THE DATA PLANE are not
40
+ * `.strict()` at their top level — the request envelope, the four usage records,
41
+ * the stream events, the error body, the catalogue descriptors, the price
42
+ * version. The split is a decision rather than an omission: `.strict()` and
43
+ * "adding an optional field is additive" cannot both hold on one shape, because
44
+ * a producer one minor version ahead would have its whole message REFUSED
45
+ * rather than its new field ignored. For a usage report that means a request
46
+ * already served upstream can never be settled and Oxy absorbs its cost, which
47
+ * is a worse failure than the one strictness would have caught.
48
+ *
49
+ * Their LEAVES are strict, and that is where the protection lives: a stripped
50
+ * field is the worse outcome exactly where it would be a leak or a second
51
+ * source of truth, because it disappears at this parse and survives in the
52
+ * producer, which is where somebody eventually reads it. So
53
+ * `clientRequestMetadataSchema` (no IP, ever), `moneySchema` (no convenience
54
+ * float beside the exact decimal), `providerErrorPassthroughSchema` (no
55
+ * upstream request or headers beside the message), `usageQuantitySchema` and
56
+ * `unitPriceSchema` all refuse an unknown field, while the envelope carrying
57
+ * them tolerates an additive one.
58
+ *
59
+ * A shape Oxy does NOT exchange with the data plane is strict at its top level
60
+ * too, since nothing there can run ahead of this package:
61
+ * `providerConnectionSchema`, where an unknown field is how a BYOK credential
62
+ * escapes, and the billing and entitlement records, where one is a second
63
+ * number beside an exact amount.
64
+ *
65
+ * Decided in: docs/adr/0006-oxy-relay-boundary.md, docs/adr/0010-public-api-compatibility.md.
66
+ */
67
+ /**
68
+ * Version of the contract SET as a whole — the value the control plane and the
69
+ * data plane exchange in a startup/health handshake to establish that they were built against
70
+ * compatible definitions before a single inference request is served.
71
+ *
72
+ * MAJOR is bumped when any individual shape's `schemaVersion` increments (at
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.
76
+ *
77
+ * This constant is deliberately NOT embedded in the request envelope. Pinning a
78
+ * request to the version of the whole set would make an unrelated additive
79
+ * change to, say, the catalogue reject every in-flight inference request; the
80
+ * per-shape `schemaVersion` is what a message is validated against.
81
+ */
82
+ export declare const INFERENCE_CONTRACT_VERSION = "1.0.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/contracts",
3
- "version": "0.26.0",
3
+ "version": "0.28.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",