@oxy.so/contracts 4.5.0 → 4.6.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.
package/dist/esm/index.js CHANGED
@@ -134,11 +134,11 @@ export {
134
134
  priceVersionStatusSchema, priceVersionSchema, priceSnapshotSchema, } from './inference/priceVersion.js';
135
135
  export {
136
136
  // The six distinct catalogue objects + the customer-safe projection.
137
- inferenceModalitySchema, reasoningEffortSchema, inferenceApiFormatSchema, realtimeSessionKindSchema, realtimeSessionTransportSchema, modelRealtimeCapabilitiesSchema, modelCapabilitiesSchema, modelLicenseSchema, modelProvenanceSchema, inferenceDataPolicySchema, availabilityScopeSchema, commercialPermissionSchema, modelDeprecationSchema, modelEvaluationResultSchema, modelSafetyMetadataSchema, modelPublisherSchema, catalogueModelSchema, modelRevisionSchema, inferenceProviderSchema, modelDeploymentSchema, routingProfileCandidateSchema, routingProfileSchema, cataloguePublisherSummarySchema, catalogueServingProviderSummarySchema, modelCatalogueEntrySchema, } from './inference/catalogue.js';
137
+ inferenceModalitySchema, reasoningEffortSchema, powerLevelSchema, modelPowerClassSchema, inferenceApiFormatSchema, realtimeSessionKindSchema, realtimeSessionTransportSchema, modelRealtimeCapabilitiesSchema, modelCapabilitiesSchema, modelLicenseSchema, modelProvenanceSchema, inferenceDataPolicySchema, availabilityScopeSchema, commercialPermissionSchema, modelDeprecationSchema, modelEvaluationResultSchema, modelSafetyMetadataSchema, modelPublisherSchema, catalogueModelSchema, modelRevisionSchema, inferenceProviderSchema, modelDeploymentSchema, routingProfileCandidateSchema, routingProfileSchema, cataloguePublisherSummarySchema, catalogueServingProviderSummarySchema, modelCatalogueEntrySchema, } from './inference/catalogue.js';
138
138
  export {
139
139
  // Routing policy: every control, plus the refinement that rejects a policy
140
140
  // no route could ever satisfy.
141
- routingTargetSchema, routingPolicyScopeSchema, routingFallbackPolicySchema, routingPolicySchema, routingPolicyReferenceSchema,
141
+ routingTargetSchema, routingPolicyScopeSchema, routingFallbackPolicySchema, routingPolicySchema, routingPolicyReferenceSchema, effectiveSameModelDeployment,
142
142
  // What the data plane actually receives: the routes the policy authorized.
143
143
  authorizedRouteSchema, } from './inference/routingPolicy.js';
144
144
  export {
@@ -49,6 +49,38 @@ export const inferenceModalitySchema = z.enum([
49
49
  * effort the resolved model does not advertise rather than dropping it.
50
50
  */
51
51
  export const reasoningEffortSchema = z.enum(['low', 'medium', 'high']);
52
+ /**
53
+ * A POWER LEVEL: the public name of a product-preset routing profile that asks
54
+ * Oxy to choose a model by capability tier instead of naming one (contract set
55
+ * 3.4.0). Ordered cheapest first; `auto` asks Oxy to pick the cheapest level
56
+ * that suffices for the request.
57
+ *
58
+ * - `instant` — very cheap, fast small models; no reasoning effort requested
59
+ * - `medium` — mid-size models, low reasoning effort
60
+ * - `high` — strong models, medium reasoning effort
61
+ * - `xhigh` — strong models, high reasoning effort
62
+ * - `pro` — frontier models, high reasoning effort
63
+ * - `ultra` — the heaviest frontier models, maximum reasoning effort
64
+ *
65
+ * A power level is a routing profile, never a model: its slug has no `/`, and
66
+ * the response always reports the concrete model that ran.
67
+ */
68
+ export const powerLevelSchema = z.enum([
69
+ 'auto',
70
+ 'instant',
71
+ 'medium',
72
+ 'high',
73
+ 'xhigh',
74
+ 'pro',
75
+ 'ultra',
76
+ ]);
77
+ /**
78
+ * The reviewed capability tier of one MODEL, which power levels choose from.
79
+ * `xhigh` and `auto` are not classes: `xhigh` runs `high`-class models at a
80
+ * higher effort, and `auto` chooses a level. Reviewed catalogue data with a
81
+ * cited public benchmark source — never inferred from a model's name.
82
+ */
83
+ export const modelPowerClassSchema = z.enum(['instant', 'medium', 'high', 'pro', 'ultra']);
52
84
  /**
53
85
  * The public dialects a request can arrive in — `client.apiFormat` on the
54
86
  * envelope, and the list a deployment declares it can execute.
@@ -539,6 +571,18 @@ export const routingProfileSchema = z.object({
539
571
  candidates: z.array(routingProfileCandidateSchema).min(1),
540
572
  /** A product preset (Alia's "fast" toggle) rather than a customer's own profile. */
541
573
  isProductPreset: z.boolean(),
574
+ /**
575
+ * Present when this profile IS a power level (contract set 3.4.0). Its
576
+ * `candidates` are then the currently servable models of the level's class,
577
+ * and may change between reads; cross-model failover among them is
578
+ * authorized by the profile and reported with a `route_switch` event.
579
+ */
580
+ powerLevel: powerLevelSchema.optional(),
581
+ /**
582
+ * The reasoning effort a power level asks for when the request names none,
583
+ * applied only on a model that advertises it. Absent: none is requested.
584
+ */
585
+ reasoningEffort: reasoningEffortSchema.optional(),
542
586
  });
543
587
  /* -------------------------------------------------------------------------- */
544
588
  /* Customer-safe catalogue projection */
@@ -607,4 +651,10 @@ export const modelCatalogueEntrySchema = z.object({
607
651
  evaluations: z.array(modelEvaluationResultSchema).default([]),
608
652
  safety: modelSafetyMetadataSchema.optional(),
609
653
  modelCardUrl: inferenceHttpsUrlSchema.optional(),
654
+ /**
655
+ * The reviewed power class this model serves in, when one has been reviewed
656
+ * (contract set 3.4.0). Absent means the model is callable by name only and
657
+ * no power level chooses it.
658
+ */
659
+ powerClass: modelPowerClassSchema.optional(),
610
660
  });
@@ -85,10 +85,26 @@ export const routingPolicyScopeSchema = z.discriminatedUnion("kind", [
85
85
  export const routingFallbackPolicySchema = z
86
86
  .object({
87
87
  disabled: z.boolean(),
88
- sameModelDeployment: z.boolean(),
88
+ /**
89
+ * Same-model deployment failover. OPTIONAL since contract set 3.4.0, and
90
+ * absent means ON unless `disabled` is set: serving the same weights from
91
+ * another deployment of the same revision is an availability decision, not
92
+ * a substitution. A policy opts out with an explicit `false` (or
93
+ * `disabled: true`). See `effectiveSameModelDeployment`.
94
+ */
95
+ sameModelDeployment: z.boolean().optional(),
89
96
  authorizedCrossModel: z.array(modelReferenceSchema).default([]),
90
97
  })
91
98
  .strict();
99
+ /**
100
+ * Whether a fallback block authorizes same-model deployment failover: an
101
+ * explicit `sameModelDeployment` wins; absent means on unless `disabled`.
102
+ */
103
+ export function effectiveSameModelDeployment(fallback) {
104
+ if (fallback.disabled)
105
+ return false;
106
+ return fallback.sameModelDeployment ?? true;
107
+ }
92
108
  /**
93
109
  * A versioned routing policy.
94
110
  *
@@ -128,6 +144,14 @@ export const routingPolicySchema = z
128
144
  allowedLicenseIds: z.array(z.string().min(1).max(128)).default([]),
129
145
  requireCommercialUseRights: z.boolean(),
130
146
  fallback: routingFallbackPolicySchema,
147
+ /**
148
+ * The routing profiles (power levels) this scope may target, by exact id
149
+ * (contract set 3.4.0). Empty means no restriction. A request naming a
150
+ * profile outside a non-empty list is refused with `policy_violation`, and
151
+ * `auto` only climbs to levels on the list. Concrete model targets are
152
+ * governed by the other controls, not by this list.
153
+ */
154
+ allowedRoutingProfileIds: z.array(routingProfileIdSchema).default([]),
131
155
  /** Whether the customer's own provider credentials may or must be used. */
132
156
  byokPreference: z.enum(["disabled", "prefer", "require"]),
133
157
  /** Enterprise reserved capacity rather than shared endpoints. */
@@ -207,6 +231,25 @@ export const routingPolicySchema = z
207
231
  }
208
232
  }
209
233
  }
234
+ const allowedProfiles = policy.allowedRoutingProfileIds;
235
+ if (new Set(allowedProfiles).size !== allowedProfiles.length) {
236
+ ctx.addIssue({
237
+ code: z.ZodIssueCode.custom,
238
+ path: ["allowedRoutingProfileIds"],
239
+ message: "each routing profile is allowed at most once",
240
+ });
241
+ }
242
+ // A default the policy itself forbids would refuse every request that
243
+ // names no model — a policy that cannot serve its own default.
244
+ if (allowedProfiles.length > 0 &&
245
+ policy.defaultTarget?.kind === "routing_profile_id" &&
246
+ !allowedProfiles.includes(policy.defaultTarget.routingProfileId)) {
247
+ ctx.addIssue({
248
+ code: z.ZodIssueCode.custom,
249
+ path: ["defaultTarget", "routingProfileId"],
250
+ message: "the default routing profile must be one of allowedRoutingProfileIds",
251
+ });
252
+ }
210
253
  });
211
254
  /**
212
255
  * The reference a request records: which policy, at which of the customer's own
@@ -99,4 +99,4 @@
99
99
  * change to, say, the catalogue reject every in-flight inference request; the
100
100
  * per-shape `schemaVersion` is what a message is validated against.
101
101
  */
102
- export const INFERENCE_CONTRACT_VERSION = '3.3.0';
102
+ export const INFERENCE_CONTRACT_VERSION = '3.4.0';