@oxy.so/contracts 4.3.0 → 4.4.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.
@@ -25,7 +25,7 @@
25
25
  * docs/adr/0017-authorized-routes-in-the-envelope.md.
26
26
  */
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.inferenceRequestSchema = exports.inferenceSpeechParametersSchema = exports.clientRequestMetadataSchema = exports.inferenceReasoningSchema = exports.responseFormatSchema = exports.toolChoiceSchema = exports.toolDefinitionSchema = exports.samplingParametersSchema = exports.inferenceInputSchema = exports.inferenceMessageSchema = exports.inferenceMessageRoleSchema = exports.inferenceToolCallSchema = exports.inferenceContentPartSchema = exports.inferenceContentSourceSchema = void 0;
28
+ exports.inferenceRequestSchema = exports.inferenceAudioOutputParametersSchema = exports.inferenceSpeechParametersSchema = exports.clientRequestMetadataSchema = exports.inferenceReasoningSchema = exports.responseFormatSchema = exports.toolChoiceSchema = exports.toolDefinitionSchema = exports.samplingParametersSchema = exports.inferenceInputSchema = exports.inferenceMessageSchema = exports.inferenceMessageRoleSchema = exports.inferenceToolCallSchema = exports.inferenceContentPartSchema = exports.inferenceContentSourceSchema = void 0;
29
29
  const zod_1 = require("zod");
30
30
  const attribution_1 = require("./attribution");
31
31
  const catalogue_1 = require("./catalogue");
@@ -292,16 +292,7 @@ exports.inferenceReasoningSchema = zod_1.z
292
292
  exports.clientRequestMetadataSchema = zod_1.z
293
293
  .object({
294
294
  /** The public dialect the customer called. The response is rendered in it. */
295
- apiFormat: zod_1.z.enum([
296
- "responses",
297
- "chat_completions",
298
- "embeddings",
299
- "images_generations",
300
- "audio_transcriptions",
301
- "audio_speech",
302
- "rerank",
303
- "batches",
304
- ]),
295
+ apiFormat: catalogue_1.inferenceApiFormatSchema,
305
296
  /** The public path, e.g. `/v1/responses`. */
306
297
  endpoint: zod_1.z.string().min(1).max(256),
307
298
  /** The customer's own correlation id, when they sent one. */
@@ -330,6 +321,25 @@ exports.inferenceSpeechParametersSchema = zod_1.z.object({
330
321
  responseFormat: zod_1.z.enum(["mp3", "opus", "aac", "flac", "wav", "pcm"]),
331
322
  speed: zod_1.z.number().min(0.25).max(4).optional(),
332
323
  }).strict();
324
+ /**
325
+ * Spoken output from a CONVERSATIONAL model (contract set 3.2.0) — an audio chat
326
+ * model answering in its own voice, as opposed to `speech`, which reads given
327
+ * text aloud. Presence is the request: a chat request carrying this asks for
328
+ * the answer as audio AND its transcript, which is the only combination the
329
+ * audio chat models produce (OpenAI's `modalities: ["text", "audio"]`).
330
+ *
331
+ * The audio streams as `audio` events and the words as `delta` events on the
332
+ * `output_audio_transcript` channel — never as `output_text`, because a
333
+ * transcript of speech the customer is already hearing is not a second answer.
334
+ * `pcm` is the only format an audio chat model can STREAM; the refinement on the
335
+ * envelope holds that rather than leaving a provider to refuse it mid-flight.
336
+ */
337
+ exports.inferenceAudioOutputParametersSchema = zod_1.z
338
+ .object({
339
+ voice: zod_1.z.string().min(1).max(64),
340
+ format: zod_1.z.enum(["wav", "mp3", "flac", "opus", "pcm"]),
341
+ })
342
+ .strict();
333
343
  /**
334
344
  * The canonical internal request Oxy forwards to the data plane.
335
345
  *
@@ -352,6 +362,8 @@ exports.inferenceRequestSchema = zod_1.z
352
362
  /** Absent means the route's own default reasoning behaviour. */
353
363
  reasoning: exports.inferenceReasoningSchema.optional(),
354
364
  speech: exports.inferenceSpeechParametersSchema.optional(),
365
+ /** Spoken output from a conversational model. Contract set 3.2.0. */
366
+ audioOutput: exports.inferenceAudioOutputParametersSchema.optional(),
355
367
  tools: zod_1.z.array(exports.toolDefinitionSchema).default([]),
356
368
  toolChoice: exports.toolChoiceSchema.optional(),
357
369
  responseFormat: exports.responseFormatSchema.optional(),
@@ -401,6 +413,17 @@ exports.inferenceRequestSchema = zod_1.z
401
413
  if (!isSpeech && request.speech !== undefined) {
402
414
  ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, path: ["speech"], message: "speech parameters require the audio_speech API format" });
403
415
  }
416
+ if (request.audioOutput !== undefined) {
417
+ if (request.client.apiFormat !== "chat_completions") {
418
+ ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, path: ["audioOutput"], message: "spoken output from a conversational model requires the chat_completions API format" });
419
+ }
420
+ if (request.modality !== "audio" || request.input.format !== "messages") {
421
+ ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, path: ["audioOutput"], message: "spoken output requires audio modality and a messages input" });
422
+ }
423
+ if (request.stream && request.audioOutput.format !== "pcm") {
424
+ ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, path: ["audioOutput", "format"], message: "streamed spoken output is pcm; the other formats exist only whole" });
425
+ }
426
+ }
404
427
  if (request.toolChoice !== undefined && request.tools.length === 0) {
405
428
  ctx.addIssue({
406
429
  code: zod_1.z.ZodIssueCode.custom,
@@ -62,7 +62,13 @@ exports.inferenceStreamDeltaEventSchema = zod_1.z.object({
62
62
  sequence: zod_1.z.number().int().nonnegative().safe(),
63
63
  /** Which output of a multi-output response this chunk belongs to. */
64
64
  outputIndex: zod_1.z.number().int().nonnegative().safe(),
65
- channel: zod_1.z.enum(['output_text', 'reasoning', 'refusal']),
65
+ /**
66
+ * `output_audio_transcript` (contract set 3.2.0) carries the words of spoken
67
+ * output requested with `audioOutput`. It is its own channel for the same
68
+ * reason `reasoning` is: a renderer that shows it as `output_text` presents
69
+ * the transcript of what the customer is hearing as a second, written answer.
70
+ */
71
+ channel: zod_1.z.enum(['output_text', 'reasoning', 'refusal', 'output_audio_transcript']),
66
72
  text: zod_1.z.string(),
67
73
  });
68
74
  /** The encodings an audio output may carry. */
@@ -102,4 +102,4 @@ exports.INFERENCE_CONTRACT_VERSION = void 0;
102
102
  * change to, say, the catalogue reject every in-flight inference request; the
103
103
  * per-shape `schemaVersion` is what a message is validated against.
104
104
  */
105
- exports.INFERENCE_CONTRACT_VERSION = '3.1.0';
105
+ exports.INFERENCE_CONTRACT_VERSION = '3.2.0';