@kaana.ai/contracts 8.7.0 → 8.9.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.
@@ -56,6 +56,7 @@ export declare const inferenceInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
56
56
  content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
57
57
  type: z.ZodLiteral<"text">;
58
58
  text: z.ZodString;
59
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
59
60
  }, z.core.$strict>, z.ZodObject<{
60
61
  type: z.ZodLiteral<"image">;
61
62
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -71,6 +72,7 @@ export declare const inferenceInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
71
72
  high: "high";
72
73
  auto: "auto";
73
74
  }>>;
75
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
74
76
  }, z.core.$strict>, z.ZodObject<{
75
77
  type: z.ZodLiteral<"audio">;
76
78
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -92,6 +94,7 @@ export declare const inferenceInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
92
94
  data: z.ZodString;
93
95
  }, z.core.$strict>], "kind">;
94
96
  filename: z.ZodOptional<z.ZodString>;
97
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
95
98
  }, z.core.$strict>, z.ZodObject<{
96
99
  type: z.ZodLiteral<"refusal">;
97
100
  text: z.ZodString;
@@ -244,6 +247,7 @@ export declare const inferenceRequestSchema: z.ZodObject<{
244
247
  content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
245
248
  type: z.ZodLiteral<"text">;
246
249
  text: z.ZodString;
250
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
247
251
  }, z.core.$strict>, z.ZodObject<{
248
252
  type: z.ZodLiteral<"image">;
249
253
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -259,6 +263,7 @@ export declare const inferenceRequestSchema: z.ZodObject<{
259
263
  high: "high";
260
264
  auto: "auto";
261
265
  }>>;
266
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
262
267
  }, z.core.$strict>, z.ZodObject<{
263
268
  type: z.ZodLiteral<"audio">;
264
269
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -280,6 +285,7 @@ export declare const inferenceRequestSchema: z.ZodObject<{
280
285
  data: z.ZodString;
281
286
  }, z.core.$strict>], "kind">;
282
287
  filename: z.ZodOptional<z.ZodString>;
288
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
283
289
  }, z.core.$strict>, z.ZodObject<{
284
290
  type: z.ZodLiteral<"refusal">;
285
291
  text: z.ZodString;
@@ -355,6 +361,7 @@ export declare const inferenceRequestSchema: z.ZodObject<{
355
361
  description: z.ZodOptional<z.ZodString>;
356
362
  parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
357
363
  strict: z.ZodOptional<z.ZodBoolean>;
364
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
358
365
  }, z.core.$strict>>>;
359
366
  toolChoice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
360
367
  auto: "auto";
@@ -31,6 +31,7 @@ export declare const chatCompletionMessageSchema: z.ZodObject<{
31
31
  content: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
32
32
  type: z.ZodLiteral<"text">;
33
33
  text: z.ZodString;
34
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
34
35
  }, z.core.$strict>, z.ZodObject<{
35
36
  type: z.ZodLiteral<"image">;
36
37
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -46,6 +47,7 @@ export declare const chatCompletionMessageSchema: z.ZodObject<{
46
47
  high: "high";
47
48
  auto: "auto";
48
49
  }>>;
50
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
49
51
  }, z.core.$strict>, z.ZodObject<{
50
52
  type: z.ZodLiteral<"audio">;
51
53
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -67,6 +69,7 @@ export declare const chatCompletionMessageSchema: z.ZodObject<{
67
69
  data: z.ZodString;
68
70
  }, z.core.$strict>], "kind">;
69
71
  filename: z.ZodOptional<z.ZodString>;
72
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
70
73
  }, z.core.$strict>, z.ZodObject<{
71
74
  type: z.ZodLiteral<"refusal">;
72
75
  text: z.ZodString;
@@ -107,6 +110,7 @@ export declare const chatCompletionsRequestSchema: z.ZodObject<{
107
110
  content: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
108
111
  type: z.ZodLiteral<"text">;
109
112
  text: z.ZodString;
113
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
110
114
  }, z.core.$strict>, z.ZodObject<{
111
115
  type: z.ZodLiteral<"image">;
112
116
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -122,6 +126,7 @@ export declare const chatCompletionsRequestSchema: z.ZodObject<{
122
126
  high: "high";
123
127
  auto: "auto";
124
128
  }>>;
129
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
125
130
  }, z.core.$strict>, z.ZodObject<{
126
131
  type: z.ZodLiteral<"audio">;
127
132
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -143,6 +148,7 @@ export declare const chatCompletionsRequestSchema: z.ZodObject<{
143
148
  data: z.ZodString;
144
149
  }, z.core.$strict>], "kind">;
145
150
  filename: z.ZodOptional<z.ZodString>;
151
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
146
152
  }, z.core.$strict>, z.ZodObject<{
147
153
  type: z.ZodLiteral<"refusal">;
148
154
  text: z.ZodString;
@@ -65,6 +65,7 @@ export declare const inferenceContentSourceSchema: z.ZodDiscriminatedUnion<[z.Zo
65
65
  export declare const inferenceContentPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
66
66
  type: z.ZodLiteral<"text">;
67
67
  text: z.ZodString;
68
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
68
69
  }, z.core.$strict>, z.ZodObject<{
69
70
  type: z.ZodLiteral<"image">;
70
71
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -80,6 +81,7 @@ export declare const inferenceContentPartSchema: z.ZodDiscriminatedUnion<[z.ZodO
80
81
  high: "high";
81
82
  auto: "auto";
82
83
  }>>;
84
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
83
85
  }, z.core.$strict>, z.ZodObject<{
84
86
  type: z.ZodLiteral<"audio">;
85
87
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -101,6 +103,7 @@ export declare const inferenceContentPartSchema: z.ZodDiscriminatedUnion<[z.ZodO
101
103
  data: z.ZodString;
102
104
  }, z.core.$strict>], "kind">;
103
105
  filename: z.ZodOptional<z.ZodString>;
106
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
104
107
  }, z.core.$strict>, z.ZodObject<{
105
108
  type: z.ZodLiteral<"refusal">;
106
109
  text: z.ZodString;
@@ -202,6 +205,7 @@ export declare const inferenceMessageSchema: z.ZodObject<{
202
205
  content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
203
206
  type: z.ZodLiteral<"text">;
204
207
  text: z.ZodString;
208
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
205
209
  }, z.core.$strict>, z.ZodObject<{
206
210
  type: z.ZodLiteral<"image">;
207
211
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -217,6 +221,7 @@ export declare const inferenceMessageSchema: z.ZodObject<{
217
221
  high: "high";
218
222
  auto: "auto";
219
223
  }>>;
224
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
220
225
  }, z.core.$strict>, z.ZodObject<{
221
226
  type: z.ZodLiteral<"audio">;
222
227
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -238,6 +243,7 @@ export declare const inferenceMessageSchema: z.ZodObject<{
238
243
  data: z.ZodString;
239
244
  }, z.core.$strict>], "kind">;
240
245
  filename: z.ZodOptional<z.ZodString>;
246
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
241
247
  }, z.core.$strict>, z.ZodObject<{
242
248
  type: z.ZodLiteral<"refusal">;
243
249
  text: z.ZodString;
@@ -275,6 +281,7 @@ export declare const toolDefinitionSchema: z.ZodObject<{
275
281
  description: z.ZodOptional<z.ZodString>;
276
282
  parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
277
283
  strict: z.ZodOptional<z.ZodBoolean>;
284
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
278
285
  }, z.core.$strict>;
279
286
  /** Whether, and which, tool the model must call. */
280
287
  export declare const toolChoiceSchema: z.ZodUnion<readonly [z.ZodEnum<{
@@ -30,6 +30,22 @@ export const inferenceContentSourceSchema = z.discriminatedUnion('kind', [
30
30
  })
31
31
  .strict(),
32
32
  ]);
33
+ /**
34
+ * A prompt-cache breakpoint (contract set 8.8.0): the prompt up to and including
35
+ * the part, system message or tool that carries it is to be cached by a provider
36
+ * that can express it. `true` is Anthropic's `cache_control: {type: "ephemeral"}`
37
+ * with the default 5-minute lifetime and nothing else: there is no lifetime
38
+ * field, because the one cache-write unit cannot price a longer one.
39
+ *
40
+ * It is a hint with no effect on the answer. A route that cannot express it
41
+ * ignores it and still succeeds; Kaana's executor sends it only to a route whose
42
+ * granted price version prices `cache_write_input_tokens`, so a cache write is
43
+ * never provoked that the customer is not charged for at its own rate. A provider
44
+ * that allows fewer breakpoints than are marked receives the earliest ones in
45
+ * prompt order (tools, then system, then messages). `false` is the same as absent.
46
+ * Only a part whose type a provider caches (`text`, `image`, `file`) carries it.
47
+ */
48
+ const cacheBreakpointSchema = z.boolean().optional();
33
49
  /**
34
50
  * One part of a message's content. A message is always a list of parts.
35
51
  *
@@ -73,13 +89,20 @@ export const inferenceContentSourceSchema = z.discriminatedUnion('kind', [
73
89
  * the continuation is lost, the conversation is not.
74
90
  */
75
91
  export const inferenceContentPartSchema = z.discriminatedUnion('type', [
76
- z.object({ type: z.literal('text'), text: z.string() }).strict(),
92
+ z
93
+ .object({
94
+ type: z.literal('text'),
95
+ text: z.string(),
96
+ cacheBreakpoint: cacheBreakpointSchema,
97
+ })
98
+ .strict(),
77
99
  z
78
100
  .object({
79
101
  type: z.literal('image'),
80
102
  source: inferenceContentSourceSchema,
81
103
  /** Provider-independent hint; providers that ignore it are unaffected. */
82
104
  detail: z.enum(['auto', 'low', 'high']).optional(),
105
+ cacheBreakpoint: cacheBreakpointSchema,
83
106
  })
84
107
  .strict(),
85
108
  z.object({ type: z.literal('audio'), source: inferenceContentSourceSchema }).strict(),
@@ -88,6 +111,7 @@ export const inferenceContentPartSchema = z.discriminatedUnion('type', [
88
111
  type: z.literal('file'),
89
112
  source: inferenceContentSourceSchema,
90
113
  filename: z.string().check(maxUtf16Length(255)).optional(),
114
+ cacheBreakpoint: cacheBreakpointSchema,
91
115
  })
92
116
  .strict(),
93
117
  /**
@@ -324,6 +348,8 @@ export const toolDefinitionSchema = z
324
348
  parameters: z.record(z.string(), z.unknown()),
325
349
  /** Ask the provider to enforce the schema, where it supports enforcement. */
326
350
  strict: z.boolean().optional(),
351
+ /** A prompt-cache breakpoint after this tool ({@link cacheBreakpointSchema}). */
352
+ cacheBreakpoint: cacheBreakpointSchema,
327
353
  })
328
354
  .strict();
329
355
  /** Whether, and which, tool the model must call. */
@@ -135,7 +135,10 @@ export const realtimeTranslationSchema = z
135
135
  * A function tool a session may call: the chat tool without `strict`, which no
136
136
  * realtime provider's session schema has (contract set 5.0.0).
137
137
  */
138
- export const realtimeToolDefinitionSchema = toolDefinitionSchema.omit({ strict: true });
138
+ export const realtimeToolDefinitionSchema = toolDefinitionSchema.omit({
139
+ strict: true,
140
+ cacheBreakpoint: true,
141
+ });
139
142
  /**
140
143
  * A session's full configuration, as signed at open and as echoed back by
141
144
  * `session.created` and `session.updated`.
@@ -23,6 +23,33 @@ export declare const modelTargetSchema: z.ZodUnion<readonly [z.ZodString, z.ZodE
23
23
  pro: "pro";
24
24
  ultra: "ultra";
25
25
  }>]>;
26
+ /**
27
+ * The response format of `POST /v1/responses`: the signed request's format
28
+ * (`responseFormatSchema`) and, on the two JSON formats, `repair` (contract set
29
+ * 8.9.0, Kaana ADR 0009 decision 5).
30
+ *
31
+ * `repair: true` asks Kaana to repair nearly valid JSON in the final text of a
32
+ * non-streaming answer that ended with `stop`: a surrounding code fence, prose
33
+ * around the value, trailing commas, closers a normal stop forgot. It never
34
+ * changes text that already parses, never repairs an answer cut by the token
35
+ * limit (`length`) or ended by a filter, a refusal or a tool call, and checks
36
+ * nothing against `schema` (Kaana carries no validator). A repaired answer is
37
+ * marked by the response header `Kaana-Repaired: true`, never by a body
38
+ * member. It is refused on `text` and with `stream: true`, and it is not part of
39
+ * the signed request: no provider and no Oxy sees it. Default off.
40
+ */
41
+ export declare const responsesResponseFormatSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
42
+ type: z.ZodLiteral<"text">;
43
+ }, z.core.$strict>, z.ZodObject<{
44
+ type: z.ZodLiteral<"json_object">;
45
+ repair: z.ZodOptional<z.ZodBoolean>;
46
+ }, z.core.$strict>, z.ZodObject<{
47
+ type: z.ZodLiteral<"json_schema">;
48
+ name: z.ZodString;
49
+ schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
50
+ strict: z.ZodBoolean;
51
+ repair: z.ZodOptional<z.ZodBoolean>;
52
+ }, z.core.$strict>], "type">;
26
53
  /**
27
54
  * The request. `model` may be absent: the application's routing policy in Oxy
28
55
  * Console may name a default target, and the request is refused only when it
@@ -53,6 +80,7 @@ export declare const responsesRequestSchema: z.ZodObject<{
53
80
  content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
54
81
  type: z.ZodLiteral<"text">;
55
82
  text: z.ZodString;
83
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
56
84
  }, z.core.$strict>, z.ZodObject<{
57
85
  type: z.ZodLiteral<"image">;
58
86
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -68,6 +96,7 @@ export declare const responsesRequestSchema: z.ZodObject<{
68
96
  high: "high";
69
97
  auto: "auto";
70
98
  }>>;
99
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
71
100
  }, z.core.$strict>, z.ZodObject<{
72
101
  type: z.ZodLiteral<"audio">;
73
102
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -89,6 +118,7 @@ export declare const responsesRequestSchema: z.ZodObject<{
89
118
  data: z.ZodString;
90
119
  }, z.core.$strict>], "kind">;
91
120
  filename: z.ZodOptional<z.ZodString>;
121
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
92
122
  }, z.core.$strict>, z.ZodObject<{
93
123
  type: z.ZodLiteral<"refusal">;
94
124
  text: z.ZodString;
@@ -120,6 +150,7 @@ export declare const responsesRequestSchema: z.ZodObject<{
120
150
  description: z.ZodOptional<z.ZodString>;
121
151
  parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
122
152
  strict: z.ZodOptional<z.ZodBoolean>;
153
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
123
154
  }, z.core.$strict>>>;
124
155
  toolChoice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
125
156
  auto: "auto";
@@ -133,11 +164,13 @@ export declare const responsesRequestSchema: z.ZodObject<{
133
164
  type: z.ZodLiteral<"text">;
134
165
  }, z.core.$strict>, z.ZodObject<{
135
166
  type: z.ZodLiteral<"json_object">;
167
+ repair: z.ZodOptional<z.ZodBoolean>;
136
168
  }, z.core.$strict>, z.ZodObject<{
137
169
  type: z.ZodLiteral<"json_schema">;
138
170
  name: z.ZodString;
139
171
  schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
140
172
  strict: z.ZodBoolean;
173
+ repair: z.ZodOptional<z.ZodBoolean>;
141
174
  }, z.core.$strict>], "type">>;
142
175
  reasoning: z.ZodOptional<z.ZodObject<{
143
176
  effort: z.ZodOptional<z.ZodEnum<{
@@ -207,6 +240,7 @@ export declare const responseSchema: z.ZodObject<{
207
240
  content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
208
241
  type: z.ZodLiteral<"text">;
209
242
  text: z.ZodString;
243
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
210
244
  }, z.core.$strict>, z.ZodObject<{
211
245
  type: z.ZodLiteral<"image">;
212
246
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -222,6 +256,7 @@ export declare const responseSchema: z.ZodObject<{
222
256
  high: "high";
223
257
  auto: "auto";
224
258
  }>>;
259
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
225
260
  }, z.core.$strict>, z.ZodObject<{
226
261
  type: z.ZodLiteral<"audio">;
227
262
  source: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -243,6 +278,7 @@ export declare const responseSchema: z.ZodObject<{
243
278
  data: z.ZodString;
244
279
  }, z.core.$strict>], "kind">;
245
280
  filename: z.ZodOptional<z.ZodString>;
281
+ cacheBreakpoint: z.ZodOptional<z.ZodBoolean>;
246
282
  }, z.core.$strict>, z.ZodObject<{
247
283
  type: z.ZodLiteral<"refusal">;
248
284
  text: z.ZodString;
@@ -287,6 +323,7 @@ export declare const responseSchema: z.ZodObject<{
287
323
  }, z.core.$strict>;
288
324
  latencyMs: z.ZodNumber;
289
325
  }, z.core.$strict>;
326
+ export type ResponsesResponseFormat = z.infer<typeof responsesResponseFormatSchema>;
290
327
  export type ModelTarget = z.infer<typeof modelTargetSchema>;
291
328
  export type ResponsesRequest = z.infer<typeof responsesRequestSchema>;
292
329
  export type Response = z.infer<typeof responseSchema>;
@@ -11,7 +11,7 @@ import { z } from 'zod';
11
11
  import { maxUtf16Length, minUtf16Length } from '../stringBounds.js';
12
12
  import { powerLevelSchema } from './catalogue.js';
13
13
  import { generationIdSchema, modelReferenceSchema, requestIdSchema } from './identifiers.js';
14
- import { inferenceMessageSchema, inferenceReasoningSchema, requestLabelsSchema, responseFormatSchema, toolChoiceSchema, toolDefinitionSchema, } from './messages.js';
14
+ import { inferenceMessageSchema, inferenceReasoningSchema, requestLabelsSchema, toolChoiceSchema, toolDefinitionSchema, } from './messages.js';
15
15
  import { usageQuantitySchema } from './money.js';
16
16
  import { routingPolicyReferenceSchema } from './policy.js';
17
17
  import { promptCacheKeySchema, providerPreferencesSchema } from './providerPreferences.js';
@@ -23,6 +23,34 @@ import { inferenceFinishReasonSchema } from './streamEvents.js';
23
23
  * the string alone).
24
24
  */
25
25
  export const modelTargetSchema = z.union([modelReferenceSchema, powerLevelSchema]);
26
+ /**
27
+ * The response format of `POST /v1/responses`: the signed request's format
28
+ * (`responseFormatSchema`) and, on the two JSON formats, `repair` (contract set
29
+ * 8.9.0, Kaana ADR 0009 decision 5).
30
+ *
31
+ * `repair: true` asks Kaana to repair nearly valid JSON in the final text of a
32
+ * non-streaming answer that ended with `stop`: a surrounding code fence, prose
33
+ * around the value, trailing commas, closers a normal stop forgot. It never
34
+ * changes text that already parses, never repairs an answer cut by the token
35
+ * limit (`length`) or ended by a filter, a refusal or a tool call, and checks
36
+ * nothing against `schema` (Kaana carries no validator). A repaired answer is
37
+ * marked by the response header `Kaana-Repaired: true`, never by a body
38
+ * member. It is refused on `text` and with `stream: true`, and it is not part of
39
+ * the signed request: no provider and no Oxy sees it. Default off.
40
+ */
41
+ export const responsesResponseFormatSchema = z.discriminatedUnion('type', [
42
+ z.object({ type: z.literal('text') }).strict(),
43
+ z.object({ type: z.literal('json_object'), repair: z.boolean().optional() }).strict(),
44
+ z
45
+ .object({
46
+ type: z.literal('json_schema'),
47
+ name: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)),
48
+ schema: z.record(z.string(), z.unknown()),
49
+ strict: z.boolean(),
50
+ repair: z.boolean().optional(),
51
+ })
52
+ .strict(),
53
+ ]);
26
54
  /** The message-or-text input `/v1/responses` accepts. */
27
55
  const responsesInputSchema = z.union([
28
56
  z.string().check(minUtf16Length(1)),
@@ -55,7 +83,7 @@ export const responsesRequestSchema = z
55
83
  .optional(),
56
84
  tools: z.array(toolDefinitionSchema).max(128).optional(),
57
85
  toolChoice: toolChoiceSchema.optional(),
58
- responseFormat: responseFormatSchema.optional(),
86
+ responseFormat: responsesResponseFormatSchema.optional(),
59
87
  /** Refused when the resolved model does not advertise the effort. */
60
88
  reasoning: inferenceReasoningSchema.optional(),
61
89
  labels: requestLabelsSchema.optional(),
@@ -68,6 +96,16 @@ export const responsesRequestSchema = z
68
96
  })
69
97
  .strict()
70
98
  .superRefine((request, ctx) => {
99
+ if (request.responseFormat !== undefined &&
100
+ 'repair' in request.responseFormat &&
101
+ request.responseFormat.repair === true &&
102
+ request.stream === true) {
103
+ ctx.addIssue({
104
+ code: 'custom',
105
+ path: ['responseFormat', 'repair'],
106
+ message: 'repair works on a whole answer and cannot be used with stream: true',
107
+ });
108
+ }
71
109
  if (request.toolChoice !== undefined && (request.tools ?? []).length === 0) {
72
110
  ctx.addIssue({
73
111
  code: 'custom',
@@ -100,7 +100,7 @@
100
100
  * change to, say, the catalogue reject every in-flight inference request; the
101
101
  * per-shape `schemaVersion` is what a message is validated against.
102
102
  */
103
- export declare const INFERENCE_CONTRACT_VERSION = "8.7.0";
103
+ export declare const INFERENCE_CONTRACT_VERSION = "8.9.0";
104
104
  /**
105
105
  * Contract set 4.0.0 (Kaana ADR 0002) is the first published as
106
106
  * `@kaana.ai/contracts`. MAJOR because the set changed hands and split in two:
@@ -223,6 +223,13 @@ export declare const INFERENCE_CONTRACT_VERSION = "8.7.0";
223
223
  * is emitted only to a request that carried `reasoning`. A consumer on 8.5.0 or
224
224
  * earlier (Oxy's legacy signed lane) refuses a message or request that carries
225
225
  * what is new, so Oxy reads it before a customer sends it.
226
+ *
227
+ * Contract set 8.9.0 is additive: the optional `repair` member of
228
+ * `POST /v1/responses`'s `responseFormat` (`responsesResponseFormatSchema`, Kaana
229
+ * ADR 0009 decision 5) and the response header `Kaana-Repaired`. It is a public
230
+ * request member only: the signed grant and envelope are unchanged, and a
231
+ * response carries no new body member, so every older reader parses what 8.9.0
232
+ * serves.
226
233
  */
227
234
  /** The public API's one origin and version. */
228
235
  export declare const KAANA_API_BASE_URL = "https://kaana.ai/v1";
@@ -254,6 +261,12 @@ export declare const KAANA_USAGE_HEADER = "Kaana-Usage";
254
261
  */
255
262
  export declare const KAANA_ROUTING_POLICY_ID_HEADER = "Kaana-Routing-Policy-Id";
256
263
  export declare const KAANA_ROUTING_POLICY_VERSION_HEADER = "Kaana-Routing-Policy-Version";
264
+ /**
265
+ * The response header Kaana sets to `true` when it changed the model's JSON
266
+ * text because the request asked for `responseFormat.repair` (contract set
267
+ * 8.9.0). Absent otherwise.
268
+ */
269
+ export declare const KAANA_REPAIRED_HEADER = "Kaana-Repaired";
257
270
  /** The request header that names the end user a service token acts for. */
258
271
  export declare const KAANA_ON_BEHALF_OF_HEADER = "X-Oxy-User-Id";
259
272
  /** The request header that makes a request idempotent. */
@@ -100,7 +100,7 @@
100
100
  * change to, say, the catalogue reject every in-flight inference request; the
101
101
  * per-shape `schemaVersion` is what a message is validated against.
102
102
  */
103
- export const INFERENCE_CONTRACT_VERSION = '8.7.0';
103
+ export const INFERENCE_CONTRACT_VERSION = '8.9.0';
104
104
  /**
105
105
  * Contract set 4.0.0 (Kaana ADR 0002) is the first published as
106
106
  * `@kaana.ai/contracts`. MAJOR because the set changed hands and split in two:
@@ -223,6 +223,13 @@ export const INFERENCE_CONTRACT_VERSION = '8.7.0';
223
223
  * is emitted only to a request that carried `reasoning`. A consumer on 8.5.0 or
224
224
  * earlier (Oxy's legacy signed lane) refuses a message or request that carries
225
225
  * what is new, so Oxy reads it before a customer sends it.
226
+ *
227
+ * Contract set 8.9.0 is additive: the optional `repair` member of
228
+ * `POST /v1/responses`'s `responseFormat` (`responsesResponseFormatSchema`, Kaana
229
+ * ADR 0009 decision 5) and the response header `Kaana-Repaired`. It is a public
230
+ * request member only: the signed grant and envelope are unchanged, and a
231
+ * response carries no new body member, so every older reader parses what 8.9.0
232
+ * serves.
226
233
  */
227
234
  /** The public API's one origin and version. */
228
235
  export const KAANA_API_BASE_URL = 'https://kaana.ai/v1';
@@ -254,6 +261,12 @@ export const KAANA_USAGE_HEADER = 'Kaana-Usage';
254
261
  */
255
262
  export const KAANA_ROUTING_POLICY_ID_HEADER = 'Kaana-Routing-Policy-Id';
256
263
  export const KAANA_ROUTING_POLICY_VERSION_HEADER = 'Kaana-Routing-Policy-Version';
264
+ /**
265
+ * The response header Kaana sets to `true` when it changed the model's JSON
266
+ * text because the request asked for `responseFormat.repair` (contract set
267
+ * 8.9.0). Absent otherwise.
268
+ */
269
+ export const KAANA_REPAIRED_HEADER = 'Kaana-Repaired';
257
270
  /** The request header that names the end user a service token acts for. */
258
271
  export const KAANA_ON_BEHALF_OF_HEADER = 'X-Oxy-User-Id';
259
272
  /** The request header that makes a request idempotent. */
package/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "Kaana API",
5
- "version": "8.7.0",
5
+ "version": "8.9.0",
6
6
  "description": "Kaana inference API. Generated from @kaana.ai/contracts; the Zod source is the authority. Accounts, applications, oxy_sk_ keys, limits and billing are managed in Oxy Console: https://console.oxy.so"
7
7
  },
8
8
  "servers": [
@@ -4079,6 +4079,9 @@
4079
4079
  },
4080
4080
  "text": {
4081
4081
  "type": "string"
4082
+ },
4083
+ "cacheBreakpoint": {
4084
+ "type": "boolean"
4082
4085
  }
4083
4086
  },
4084
4087
  "required": [
@@ -4104,6 +4107,9 @@
4104
4107
  "low",
4105
4108
  "high"
4106
4109
  ]
4110
+ },
4111
+ "cacheBreakpoint": {
4112
+ "type": "boolean"
4107
4113
  }
4108
4114
  },
4109
4115
  "required": [
@@ -4142,6 +4148,9 @@
4142
4148
  "filename": {
4143
4149
  "type": "string",
4144
4150
  "maxLength": 255
4151
+ },
4152
+ "cacheBreakpoint": {
4153
+ "type": "boolean"
4145
4154
  }
4146
4155
  },
4147
4156
  "required": [
@@ -8017,7 +8026,7 @@
8017
8026
  "$ref": "#/components/schemas/ToolChoice"
8018
8027
  },
8019
8028
  "responseFormat": {
8020
- "$ref": "#/components/schemas/ResponseFormat"
8029
+ "$ref": "#/components/schemas/ResponsesResponseFormat"
8021
8030
  },
8022
8031
  "reasoning": {
8023
8032
  "$ref": "#/components/schemas/InferenceReasoning"
@@ -8042,6 +8051,73 @@
8042
8051
  ],
8043
8052
  "additionalProperties": false
8044
8053
  },
8054
+ "ResponsesResponseFormat": {
8055
+ "oneOf": [
8056
+ {
8057
+ "type": "object",
8058
+ "properties": {
8059
+ "type": {
8060
+ "type": "string",
8061
+ "const": "text"
8062
+ }
8063
+ },
8064
+ "required": [
8065
+ "type"
8066
+ ],
8067
+ "additionalProperties": false
8068
+ },
8069
+ {
8070
+ "type": "object",
8071
+ "properties": {
8072
+ "type": {
8073
+ "type": "string",
8074
+ "const": "json_object"
8075
+ },
8076
+ "repair": {
8077
+ "type": "boolean"
8078
+ }
8079
+ },
8080
+ "required": [
8081
+ "type"
8082
+ ],
8083
+ "additionalProperties": false
8084
+ },
8085
+ {
8086
+ "type": "object",
8087
+ "properties": {
8088
+ "type": {
8089
+ "type": "string",
8090
+ "const": "json_schema"
8091
+ },
8092
+ "name": {
8093
+ "type": "string",
8094
+ "minLength": 1,
8095
+ "maxLength": 128
8096
+ },
8097
+ "schema": {
8098
+ "type": "object",
8099
+ "propertyNames": {
8100
+ "type": "string"
8101
+ },
8102
+ "additionalProperties": {}
8103
+ },
8104
+ "strict": {
8105
+ "type": "boolean"
8106
+ },
8107
+ "repair": {
8108
+ "type": "boolean"
8109
+ }
8110
+ },
8111
+ "required": [
8112
+ "type",
8113
+ "name",
8114
+ "schema",
8115
+ "strict"
8116
+ ],
8117
+ "additionalProperties": false
8118
+ }
8119
+ ]
8120
+ },
8045
8121
  "RoutingPolicyReference": {
8046
8122
  "type": "object",
8047
8123
  "properties": {
@@ -8308,6 +8384,9 @@
8308
8384
  },
8309
8385
  "strict": {
8310
8386
  "type": "boolean"
8387
+ },
8388
+ "cacheBreakpoint": {
8389
+ "type": "boolean"
8311
8390
  }
8312
8391
  },
8313
8392
  "required": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaana.ai/contracts",
3
- "version": "8.7.0",
3
+ "version": "8.9.0",
4
4
  "description": "Kaana inference contract: the Zod schemas of the public API at https://kaana.ai/v1 and, under /internal, of the Oxy-Kaana grant, settlement and signed lane.",
5
5
  "type": "module",
6
6
  "sideEffects": false,