@oxy.so/contracts 4.11.0-oxy-one.0 → 4.11.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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/accountGraph.js +5 -3
- package/dist/cjs/agency.js +178 -96
- package/dist/cjs/agentKeys.js +80 -26
- package/dist/cjs/capabilityBindings.js +2 -2
- package/dist/cjs/capabilityInvocation.js +3 -1
- package/dist/cjs/commonsSignIn.js +2 -2
- package/dist/cjs/deviceSession.js +5 -1
- package/dist/cjs/email/messages.js +70 -4
- package/dist/cjs/emailAgentContext.js +16 -8
- package/dist/cjs/externalIdentity.js +30 -12
- package/dist/cjs/identity.js +14 -6
- package/dist/cjs/identityLink.js +7 -2
- package/dist/cjs/identityProof.js +2 -1
- package/dist/cjs/index.js +5 -3
- package/dist/cjs/inference/catalogue.js +2 -12
- package/dist/cjs/inference/decisions.js +102 -83
- package/dist/cjs/inference/economics.js +15 -5
- package/dist/cjs/inference/embeddings.js +44 -6
- package/dist/cjs/inference/inbox.js +33 -2
- package/dist/cjs/inference/providerConnection.js +21 -6
- package/dist/cjs/inference/realtime.js +114 -107
- package/dist/cjs/inference/scopedExecution.js +12 -12
- package/dist/cjs/inference/usage.js +2 -9
- package/dist/cjs/notifications.js +25 -5
- package/dist/cjs/oauth.js +30 -14
- package/dist/cjs/oxyRecordTypes.js +2 -2
- package/dist/cjs/products/access.js +146 -57
- package/dist/cjs/products/billing.js +71 -17
- package/dist/cjs/products/checkout.js +24 -6
- package/dist/cjs/products/plans.js +22 -7
- package/dist/cjs/recommendations.js +4 -6
- package/dist/cjs/reputation.js +3 -6
- package/dist/cjs/sessionStatus.js +1 -6
- package/dist/cjs/signIn.js +17 -4
- package/dist/cjs/transparency.js +3 -1
- package/dist/cjs/updates.js +2 -4
- package/dist/cjs/userResponse.js +27 -7
- package/dist/cjs/username.js +3 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/accountGraph.js +5 -3
- package/dist/esm/agency.js +178 -96
- package/dist/esm/agentKeys.js +80 -26
- package/dist/esm/capabilityBindings.js +2 -2
- package/dist/esm/capabilityInvocation.js +3 -1
- package/dist/esm/commonsSignIn.js +2 -2
- package/dist/esm/deviceSession.js +5 -1
- package/dist/esm/email/messages.js +69 -3
- package/dist/esm/emailAgentContext.js +16 -8
- package/dist/esm/externalIdentity.js +30 -12
- package/dist/esm/identity.js +14 -6
- package/dist/esm/identityLink.js +7 -2
- package/dist/esm/identityProof.js +2 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/inference/aliaModelRelease.js +1 -1
- package/dist/esm/inference/catalogue.js +3 -13
- package/dist/esm/inference/decisions.js +108 -89
- package/dist/esm/inference/economics.js +16 -6
- package/dist/esm/inference/embeddings.js +44 -6
- package/dist/esm/inference/inbox.js +32 -1
- package/dist/esm/inference/providerConnection.js +21 -6
- package/dist/esm/inference/realtime.js +123 -116
- package/dist/esm/inference/scopedExecution.js +15 -15
- package/dist/esm/inference/usage.js +2 -9
- package/dist/esm/notifications.js +25 -5
- package/dist/esm/oauth.js +30 -14
- package/dist/esm/oxyRecordTypes.js +2 -2
- package/dist/esm/products/access.js +146 -57
- package/dist/esm/products/billing.js +71 -17
- package/dist/esm/products/checkout.js +24 -6
- package/dist/esm/products/plans.js +22 -7
- package/dist/esm/recommendations.js +4 -6
- package/dist/esm/reputation.js +3 -6
- package/dist/esm/sessionStatus.js +1 -6
- package/dist/esm/signIn.js +17 -4
- package/dist/esm/transparency.js +3 -1
- package/dist/esm/updates.js +2 -4
- package/dist/esm/userResponse.js +27 -7
- package/dist/esm/username.js +3 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/accountGraph.d.ts +1 -1
- package/dist/types/commonsSignIn.d.ts +2 -2
- package/dist/types/email/messages.d.ts +208 -2
- package/dist/types/identity.d.ts +1 -1
- package/dist/types/index.d.ts +8 -8
- package/dist/types/inference/decisions.d.ts +1 -1
- package/dist/types/inference/inbox.d.ts +129 -5
- package/dist/types/inference/realtime.d.ts +1 -1
- package/dist/types/inference/scopedExecution.d.ts +1 -1
- package/dist/types/moderationReputation.d.ts +1 -1
- package/dist/types/oxyRecordTypes.d.ts +2 -2
- package/dist/types/products/access.d.ts +102 -102
- package/dist/types/products/checkout.d.ts +3 -3
- package/dist/types/products/plans.d.ts +40 -40
- package/dist/types/reputation.d.ts +4 -4
- package/dist/types/updates.d.ts +1 -1
- package/dist/types/userResponse.d.ts +22 -23
- package/package.json +1 -2
|
@@ -129,13 +129,9 @@ exports.realtimeResponseIdSchema = zod_1.z.string().min(1).max(128);
|
|
|
129
129
|
* The audio encodings a session carries, in both directions. Named by what they
|
|
130
130
|
* ARE (sample format, rate) because a realtime stream has no container to say so.
|
|
131
131
|
*/
|
|
132
|
-
exports.realtimeAudioFormatSchema = zod_1.z.enum([
|
|
133
|
-
"pcm16_24khz",
|
|
134
|
-
"g711_ulaw",
|
|
135
|
-
"g711_alaw",
|
|
136
|
-
]);
|
|
132
|
+
exports.realtimeAudioFormatSchema = zod_1.z.enum(['pcm16_24khz', 'g711_ulaw', 'g711_alaw']);
|
|
137
133
|
/** What a session's responses produce. */
|
|
138
|
-
exports.realtimeOutputModalitySchema = zod_1.z.enum([
|
|
134
|
+
exports.realtimeOutputModalitySchema = zod_1.z.enum(['text', 'audio']);
|
|
139
135
|
const audioFrameSchema = zod_1.z
|
|
140
136
|
.string()
|
|
141
137
|
.min(4)
|
|
@@ -155,11 +151,11 @@ const milliseconds = zod_1.z.number().int().nonnegative().safe();
|
|
|
155
151
|
* off, are the two behaviours a caller most needs to have chosen, and a default
|
|
156
152
|
* would choose them silently — and differently per provider.
|
|
157
153
|
*/
|
|
158
|
-
exports.realtimeTurnDetectionSchema = zod_1.z.discriminatedUnion(
|
|
159
|
-
zod_1.z.object({ type: zod_1.z.literal(
|
|
154
|
+
exports.realtimeTurnDetectionSchema = zod_1.z.discriminatedUnion('type', [
|
|
155
|
+
zod_1.z.object({ type: zod_1.z.literal('none') }).strict(),
|
|
160
156
|
zod_1.z
|
|
161
157
|
.object({
|
|
162
|
-
type: zod_1.z.literal(
|
|
158
|
+
type: zod_1.z.literal('server_vad'),
|
|
163
159
|
threshold: zod_1.z.number().min(0).max(1).optional(),
|
|
164
160
|
prefixPaddingMs: zod_1.z.number().int().min(0).max(5000).optional(),
|
|
165
161
|
silenceDurationMs: zod_1.z.number().int().min(0).max(10000).optional(),
|
|
@@ -169,8 +165,8 @@ exports.realtimeTurnDetectionSchema = zod_1.z.discriminatedUnion("type", [
|
|
|
169
165
|
.strict(),
|
|
170
166
|
zod_1.z
|
|
171
167
|
.object({
|
|
172
|
-
type: zod_1.z.literal(
|
|
173
|
-
eagerness: zod_1.z.enum([
|
|
168
|
+
type: zod_1.z.literal('semantic_vad'),
|
|
169
|
+
eagerness: zod_1.z.enum(['low', 'medium', 'high', 'auto']),
|
|
174
170
|
createResponse: zod_1.z.boolean(),
|
|
175
171
|
interruptResponse: zod_1.z.boolean(),
|
|
176
172
|
})
|
|
@@ -245,7 +241,7 @@ exports.realtimeSessionConfigUpdateSchema = zod_1.z
|
|
|
245
241
|
if (Object.keys(update).length === 0) {
|
|
246
242
|
ctx.addIssue({
|
|
247
243
|
code: zod_1.z.ZodIssueCode.custom,
|
|
248
|
-
message:
|
|
244
|
+
message: 'a session update changes at least one field',
|
|
249
245
|
});
|
|
250
246
|
}
|
|
251
247
|
});
|
|
@@ -281,7 +277,7 @@ exports.realtimeClientMetadataSchema = zod_1.z
|
|
|
281
277
|
/* The session request */
|
|
282
278
|
/* -------------------------------------------------------------------------- */
|
|
283
279
|
const modelLineOf = (reference) => {
|
|
284
|
-
const at = reference.indexOf(
|
|
280
|
+
const at = reference.indexOf('@');
|
|
285
281
|
return at === -1 ? reference : reference.slice(0, at);
|
|
286
282
|
};
|
|
287
283
|
/**
|
|
@@ -306,72 +302,83 @@ exports.realtimeSessionRequestSchema = zod_1.z
|
|
|
306
302
|
const { config } = request;
|
|
307
303
|
const issue = (path, message) => ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, path, message });
|
|
308
304
|
if (request.limits.idleTimeoutMs > request.limits.maxDurationMs) {
|
|
309
|
-
issue([
|
|
305
|
+
issue(['limits', 'idleTimeoutMs'], 'an idle timeout cannot outlast the session');
|
|
310
306
|
}
|
|
311
|
-
const producesAudio = config.outputModalities?.includes(
|
|
307
|
+
const producesAudio = config.outputModalities?.includes('audio') === true;
|
|
312
308
|
const hasTools = config.tools !== undefined && config.tools.length > 0;
|
|
313
309
|
switch (request.kind) {
|
|
314
|
-
case
|
|
310
|
+
case 'conversation':
|
|
315
311
|
if (config.outputModalities === undefined) {
|
|
316
|
-
issue([
|
|
312
|
+
issue(['config', 'outputModalities'], 'a conversation names what its responses produce');
|
|
317
313
|
}
|
|
318
|
-
if (producesAudio &&
|
|
319
|
-
|
|
314
|
+
if (producesAudio &&
|
|
315
|
+
(config.voice === undefined || config.outputAudioFormat === undefined)) {
|
|
316
|
+
issue(['config'], 'spoken responses need a voice and an output audio format');
|
|
320
317
|
}
|
|
321
318
|
if (config.translation !== undefined) {
|
|
322
|
-
issue([
|
|
319
|
+
issue(['config', 'translation'], 'only a translation session translates');
|
|
323
320
|
}
|
|
324
321
|
break;
|
|
325
|
-
case
|
|
322
|
+
case 'transcription':
|
|
326
323
|
if (config.inputAudioTranscription === undefined) {
|
|
327
|
-
issue([
|
|
324
|
+
issue(['config', 'inputAudioTranscription'], 'a transcription session transcribes its input');
|
|
328
325
|
}
|
|
329
|
-
for (const field of [
|
|
326
|
+
for (const field of [
|
|
327
|
+
'outputModalities',
|
|
328
|
+
'voice',
|
|
329
|
+
'outputAudioFormat',
|
|
330
|
+
'translation',
|
|
331
|
+
'tools',
|
|
332
|
+
'toolChoice',
|
|
333
|
+
'maxOutputTokens',
|
|
334
|
+
]) {
|
|
330
335
|
if (config[field] !== undefined) {
|
|
331
|
-
issue([
|
|
336
|
+
issue(['config', field], 'a transcription session never responds');
|
|
332
337
|
}
|
|
333
338
|
}
|
|
334
|
-
if (config.turnDetection.type !==
|
|
335
|
-
|
|
339
|
+
if (config.turnDetection.type !== 'none' &&
|
|
340
|
+
(config.turnDetection.createResponse || config.turnDetection.interruptResponse)) {
|
|
341
|
+
issue(['config', 'turnDetection'], 'a transcription session has no response to create or interrupt');
|
|
336
342
|
}
|
|
337
343
|
break;
|
|
338
|
-
case
|
|
344
|
+
case 'translation':
|
|
339
345
|
if (config.translation === undefined || config.outputAudioFormat === undefined) {
|
|
340
|
-
issue([
|
|
346
|
+
issue(['config'], 'a translation session names its target language and output audio format');
|
|
341
347
|
}
|
|
342
348
|
if (config.tools !== undefined || config.toolChoice !== undefined) {
|
|
343
|
-
issue([
|
|
349
|
+
issue(['config', 'tools'], 'a translation session calls no tools');
|
|
344
350
|
}
|
|
345
351
|
break;
|
|
346
352
|
}
|
|
347
353
|
if (config.toolChoice !== undefined && !hasTools) {
|
|
348
|
-
issue([
|
|
354
|
+
issue(['config', 'toolChoice'], 'a tool choice requires at least one tool definition');
|
|
349
355
|
}
|
|
350
356
|
if (config.tools !== undefined) {
|
|
351
357
|
const names = config.tools.map((tool) => tool.name);
|
|
352
358
|
if (new Set(names).size !== names.length) {
|
|
353
|
-
issue([
|
|
359
|
+
issue(['config', 'tools'], 'tool names must be unique within one session');
|
|
354
360
|
}
|
|
355
361
|
}
|
|
356
|
-
if (config.outputModalities !== undefined &&
|
|
357
|
-
|
|
362
|
+
if (config.outputModalities !== undefined &&
|
|
363
|
+
new Set(config.outputModalities).size !== config.outputModalities.length) {
|
|
364
|
+
issue(['config', 'outputModalities'], 'each output modality is named at most once');
|
|
358
365
|
}
|
|
359
366
|
// A session is never substituted: the conversation it holds belongs to one
|
|
360
367
|
// model, so every route serves the line the caller named, and a pinned
|
|
361
368
|
// request is served on exactly the revision it pinned.
|
|
362
369
|
const line = modelLineOf(request.modelReference);
|
|
363
|
-
const pinned = request.modelReference.includes(
|
|
370
|
+
const pinned = request.modelReference.includes('@');
|
|
364
371
|
for (const [index, route] of request.authorizedRoutes.entries()) {
|
|
365
|
-
if (route.substitution !==
|
|
366
|
-
issue([
|
|
372
|
+
if (route.substitution !== 'same_model' || modelLineOf(route.modelReference) !== line) {
|
|
373
|
+
issue(['authorizedRoutes', index], 'every route of a session serves the model it named');
|
|
367
374
|
}
|
|
368
375
|
if (pinned && route.modelReference !== request.modelReference) {
|
|
369
|
-
issue([
|
|
376
|
+
issue(['authorizedRoutes', index, 'modelReference'], 'a pinned session is served on exactly the revision it pinned');
|
|
370
377
|
}
|
|
371
378
|
}
|
|
372
379
|
const deployments = request.authorizedRoutes.map((route) => route.deploymentId);
|
|
373
380
|
if (new Set(deployments).size !== deployments.length) {
|
|
374
|
-
issue([
|
|
381
|
+
issue(['authorizedRoutes'], 'each deployment appears at most once in the authorized route list');
|
|
375
382
|
}
|
|
376
383
|
});
|
|
377
384
|
/* -------------------------------------------------------------------------- */
|
|
@@ -384,26 +391,26 @@ exports.realtimeSessionRequestSchema = zod_1.z
|
|
|
384
391
|
* never does — spoken output arrives as `output_audio.delta` events, and an
|
|
385
392
|
* item echoing it carries only the format and, once known, the transcript.
|
|
386
393
|
*/
|
|
387
|
-
exports.realtimeContentPartSchema = zod_1.z.discriminatedUnion(
|
|
388
|
-
zod_1.z.object({ type: zod_1.z.literal(
|
|
394
|
+
exports.realtimeContentPartSchema = zod_1.z.discriminatedUnion('type', [
|
|
395
|
+
zod_1.z.object({ type: zod_1.z.literal('input_text'), text: zod_1.z.string().max(1048576) }).strict(),
|
|
389
396
|
zod_1.z
|
|
390
397
|
.object({
|
|
391
|
-
type: zod_1.z.literal(
|
|
398
|
+
type: zod_1.z.literal('input_audio'),
|
|
392
399
|
format: exports.realtimeAudioFormatSchema,
|
|
393
400
|
data: audioFrameSchema.optional(),
|
|
394
401
|
transcript: zod_1.z.string().optional(),
|
|
395
402
|
})
|
|
396
403
|
.strict(),
|
|
397
|
-
zod_1.z.object({ type: zod_1.z.literal(
|
|
404
|
+
zod_1.z.object({ type: zod_1.z.literal('output_text'), text: zod_1.z.string() }).strict(),
|
|
398
405
|
zod_1.z
|
|
399
406
|
.object({
|
|
400
|
-
type: zod_1.z.literal(
|
|
407
|
+
type: zod_1.z.literal('output_audio'),
|
|
401
408
|
format: exports.realtimeAudioFormatSchema,
|
|
402
409
|
transcript: zod_1.z.string().optional(),
|
|
403
410
|
})
|
|
404
411
|
.strict(),
|
|
405
412
|
]);
|
|
406
|
-
const INPUT_PARTS = new Set([
|
|
413
|
+
const INPUT_PARTS = new Set(['input_text', 'input_audio']);
|
|
407
414
|
/**
|
|
408
415
|
* One item of the conversation a session holds.
|
|
409
416
|
*
|
|
@@ -411,18 +418,18 @@ const INPUT_PARTS = new Set(["input_text", "input_audio"]);
|
|
|
411
418
|
* is always stated by the server on the events that carry an item.
|
|
412
419
|
*/
|
|
413
420
|
exports.realtimeConversationItemSchema = zod_1.z
|
|
414
|
-
.discriminatedUnion(
|
|
421
|
+
.discriminatedUnion('type', [
|
|
415
422
|
zod_1.z
|
|
416
423
|
.object({
|
|
417
|
-
type: zod_1.z.literal(
|
|
424
|
+
type: zod_1.z.literal('message'),
|
|
418
425
|
itemId: exports.realtimeItemIdSchema.optional(),
|
|
419
|
-
role: zod_1.z.enum([
|
|
426
|
+
role: zod_1.z.enum(['system', 'user', 'assistant']),
|
|
420
427
|
content: zod_1.z.array(exports.realtimeContentPartSchema).min(1).max(64),
|
|
421
428
|
})
|
|
422
429
|
.strict(),
|
|
423
430
|
zod_1.z
|
|
424
431
|
.object({
|
|
425
|
-
type: zod_1.z.literal(
|
|
432
|
+
type: zod_1.z.literal('function_call'),
|
|
426
433
|
itemId: exports.realtimeItemIdSchema.optional(),
|
|
427
434
|
callId: zod_1.z.string().min(1).max(128),
|
|
428
435
|
name: zod_1.z.string().min(1).max(128),
|
|
@@ -431,7 +438,7 @@ exports.realtimeConversationItemSchema = zod_1.z
|
|
|
431
438
|
.strict(),
|
|
432
439
|
zod_1.z
|
|
433
440
|
.object({
|
|
434
|
-
type: zod_1.z.literal(
|
|
441
|
+
type: zod_1.z.literal('function_call_output'),
|
|
435
442
|
itemId: exports.realtimeItemIdSchema.optional(),
|
|
436
443
|
callId: zod_1.z.string().min(1).max(128),
|
|
437
444
|
output: zod_1.z.string().max(1048576),
|
|
@@ -439,24 +446,24 @@ exports.realtimeConversationItemSchema = zod_1.z
|
|
|
439
446
|
.strict(),
|
|
440
447
|
])
|
|
441
448
|
.superRefine((item, ctx) => {
|
|
442
|
-
if (item.type !==
|
|
449
|
+
if (item.type !== 'message')
|
|
443
450
|
return;
|
|
444
451
|
for (const [index, part] of item.content.entries()) {
|
|
445
452
|
const isInput = INPUT_PARTS.has(part.type);
|
|
446
453
|
// A user or system turn is input; an assistant turn is output. A part on
|
|
447
454
|
// the wrong side is one every provider would silently ignore.
|
|
448
|
-
if (item.role ===
|
|
455
|
+
if (item.role === 'assistant' ? isInput : !isInput) {
|
|
449
456
|
ctx.addIssue({
|
|
450
457
|
code: zod_1.z.ZodIssueCode.custom,
|
|
451
|
-
path: [
|
|
458
|
+
path: ['content', index, 'type'],
|
|
452
459
|
message: `a ${item.role} message cannot carry ${part.type}`,
|
|
453
460
|
});
|
|
454
461
|
}
|
|
455
|
-
if (item.role ===
|
|
462
|
+
if (item.role === 'system' && part.type !== 'input_text') {
|
|
456
463
|
ctx.addIssue({
|
|
457
464
|
code: zod_1.z.ZodIssueCode.custom,
|
|
458
|
-
path: [
|
|
459
|
-
message:
|
|
465
|
+
path: ['content', index, 'type'],
|
|
466
|
+
message: 'a system message is text',
|
|
460
467
|
});
|
|
461
468
|
}
|
|
462
469
|
}
|
|
@@ -481,19 +488,19 @@ const commandBase = {
|
|
|
481
488
|
};
|
|
482
489
|
exports.realtimeSessionUpdateCommandSchema = zod_1.z.object({
|
|
483
490
|
...commandBase,
|
|
484
|
-
type: zod_1.z.literal(
|
|
491
|
+
type: zod_1.z.literal('session.update'),
|
|
485
492
|
config: exports.realtimeSessionConfigUpdateSchema,
|
|
486
493
|
});
|
|
487
494
|
exports.realtimeItemCreateCommandSchema = zod_1.z.object({
|
|
488
495
|
...commandBase,
|
|
489
|
-
type: zod_1.z.literal(
|
|
496
|
+
type: zod_1.z.literal('conversation.item.create'),
|
|
490
497
|
/** Insert after this item; absent appends. */
|
|
491
498
|
previousItemId: exports.realtimeItemIdSchema.optional(),
|
|
492
499
|
item: exports.realtimeConversationItemSchema,
|
|
493
500
|
});
|
|
494
501
|
exports.realtimeItemDeleteCommandSchema = zod_1.z.object({
|
|
495
502
|
...commandBase,
|
|
496
|
-
type: zod_1.z.literal(
|
|
503
|
+
type: zod_1.z.literal('conversation.item.delete'),
|
|
497
504
|
itemId: exports.realtimeItemIdSchema,
|
|
498
505
|
});
|
|
499
506
|
/**
|
|
@@ -503,33 +510,33 @@ exports.realtimeItemDeleteCommandSchema = zod_1.z.object({
|
|
|
503
510
|
*/
|
|
504
511
|
exports.realtimeItemTruncateCommandSchema = zod_1.z.object({
|
|
505
512
|
...commandBase,
|
|
506
|
-
type: zod_1.z.literal(
|
|
513
|
+
type: zod_1.z.literal('conversation.item.truncate'),
|
|
507
514
|
itemId: exports.realtimeItemIdSchema,
|
|
508
515
|
contentIndex: zod_1.z.number().int().nonnegative().safe(),
|
|
509
516
|
audioEndMs: milliseconds,
|
|
510
517
|
});
|
|
511
518
|
exports.realtimeInputAudioAppendCommandSchema = zod_1.z.object({
|
|
512
519
|
...commandBase,
|
|
513
|
-
type: zod_1.z.literal(
|
|
520
|
+
type: zod_1.z.literal('input_audio.append'),
|
|
514
521
|
/** One bounded frame in the session's `inputAudioFormat`. */
|
|
515
522
|
data: audioFrameSchema,
|
|
516
523
|
});
|
|
517
524
|
exports.realtimeInputAudioCommitCommandSchema = zod_1.z.object({
|
|
518
525
|
...commandBase,
|
|
519
|
-
type: zod_1.z.literal(
|
|
526
|
+
type: zod_1.z.literal('input_audio.commit'),
|
|
520
527
|
});
|
|
521
528
|
exports.realtimeInputAudioClearCommandSchema = zod_1.z.object({
|
|
522
529
|
...commandBase,
|
|
523
|
-
type: zod_1.z.literal(
|
|
530
|
+
type: zod_1.z.literal('input_audio.clear'),
|
|
524
531
|
});
|
|
525
532
|
exports.realtimeResponseCreateCommandSchema = zod_1.z.object({
|
|
526
533
|
...commandBase,
|
|
527
|
-
type: zod_1.z.literal(
|
|
534
|
+
type: zod_1.z.literal('response.create'),
|
|
528
535
|
response: exports.realtimeResponseParametersSchema.optional(),
|
|
529
536
|
});
|
|
530
537
|
exports.realtimeResponseCancelCommandSchema = zod_1.z.object({
|
|
531
538
|
...commandBase,
|
|
532
|
-
type: zod_1.z.literal(
|
|
539
|
+
type: zod_1.z.literal('response.cancel'),
|
|
533
540
|
/** Absent cancels the response in progress, if any. */
|
|
534
541
|
responseId: exports.realtimeResponseIdSchema.optional(),
|
|
535
542
|
});
|
|
@@ -539,15 +546,15 @@ exports.realtimeResponseCancelCommandSchema = zod_1.z.object({
|
|
|
539
546
|
*/
|
|
540
547
|
exports.realtimeSessionResumeCommandSchema = zod_1.z.object({
|
|
541
548
|
...commandBase,
|
|
542
|
-
type: zod_1.z.literal(
|
|
549
|
+
type: zod_1.z.literal('session.resume'),
|
|
543
550
|
afterSequence: zod_1.z.number().int().min(-1).safe(),
|
|
544
551
|
});
|
|
545
552
|
exports.realtimeSessionCloseCommandSchema = zod_1.z.object({
|
|
546
553
|
...commandBase,
|
|
547
|
-
type: zod_1.z.literal(
|
|
554
|
+
type: zod_1.z.literal('session.close'),
|
|
548
555
|
});
|
|
549
556
|
/** Every command a client can send. */
|
|
550
|
-
exports.realtimeClientCommandSchema = zod_1.z.discriminatedUnion(
|
|
557
|
+
exports.realtimeClientCommandSchema = zod_1.z.discriminatedUnion('type', [
|
|
551
558
|
exports.realtimeSessionUpdateCommandSchema,
|
|
552
559
|
exports.realtimeItemCreateCommandSchema,
|
|
553
560
|
exports.realtimeItemDeleteCommandSchema,
|
|
@@ -580,7 +587,7 @@ const eventBase = {
|
|
|
580
587
|
*/
|
|
581
588
|
exports.realtimeSessionCreatedEventSchema = zod_1.z.object({
|
|
582
589
|
...eventBase,
|
|
583
|
-
type: zod_1.z.literal(
|
|
590
|
+
type: zod_1.z.literal('session.created'),
|
|
584
591
|
resolvedModelReference: identifiers_1.modelReferenceSchema,
|
|
585
592
|
servingProvider: identifiers_1.inferenceProviderSlugSchema,
|
|
586
593
|
deploymentId: identifiers_1.deploymentIdSchema,
|
|
@@ -593,42 +600,42 @@ exports.realtimeSessionCreatedEventSchema = zod_1.z.object({
|
|
|
593
600
|
});
|
|
594
601
|
exports.realtimeSessionUpdatedEventSchema = zod_1.z.object({
|
|
595
602
|
...eventBase,
|
|
596
|
-
type: zod_1.z.literal(
|
|
603
|
+
type: zod_1.z.literal('session.updated'),
|
|
597
604
|
config: exports.realtimeSessionConfigSchema,
|
|
598
605
|
});
|
|
599
606
|
exports.realtimeSessionResumedEventSchema = zod_1.z.object({
|
|
600
607
|
...eventBase,
|
|
601
|
-
type: zod_1.z.literal(
|
|
608
|
+
type: zod_1.z.literal('session.resumed'),
|
|
602
609
|
afterSequence: zod_1.z.number().int().min(-1).safe(),
|
|
603
610
|
});
|
|
604
611
|
/** Sent before a command is applied. `duplicate` means it was not applied again. */
|
|
605
612
|
exports.realtimeCommandAcceptedEventSchema = zod_1.z.object({
|
|
606
613
|
...eventBase,
|
|
607
|
-
type: zod_1.z.literal(
|
|
614
|
+
type: zod_1.z.literal('command.accepted'),
|
|
608
615
|
commandId: exports.realtimeCommandIdSchema,
|
|
609
616
|
duplicate: zod_1.z.boolean(),
|
|
610
617
|
});
|
|
611
618
|
exports.realtimeItemAddedEventSchema = zod_1.z.object({
|
|
612
619
|
...eventBase,
|
|
613
|
-
type: zod_1.z.literal(
|
|
620
|
+
type: zod_1.z.literal('conversation.item.added'),
|
|
614
621
|
itemId: exports.realtimeItemIdSchema,
|
|
615
622
|
previousItemId: exports.realtimeItemIdSchema.optional(),
|
|
616
623
|
item: exports.realtimeConversationItemSchema,
|
|
617
624
|
});
|
|
618
625
|
exports.realtimeItemDoneEventSchema = zod_1.z.object({
|
|
619
626
|
...eventBase,
|
|
620
|
-
type: zod_1.z.literal(
|
|
627
|
+
type: zod_1.z.literal('conversation.item.done'),
|
|
621
628
|
itemId: exports.realtimeItemIdSchema,
|
|
622
629
|
item: exports.realtimeConversationItemSchema,
|
|
623
630
|
});
|
|
624
631
|
exports.realtimeItemDeletedEventSchema = zod_1.z.object({
|
|
625
632
|
...eventBase,
|
|
626
|
-
type: zod_1.z.literal(
|
|
633
|
+
type: zod_1.z.literal('conversation.item.deleted'),
|
|
627
634
|
itemId: exports.realtimeItemIdSchema,
|
|
628
635
|
});
|
|
629
636
|
exports.realtimeItemTruncatedEventSchema = zod_1.z.object({
|
|
630
637
|
...eventBase,
|
|
631
|
-
type: zod_1.z.literal(
|
|
638
|
+
type: zod_1.z.literal('conversation.item.truncated'),
|
|
632
639
|
itemId: exports.realtimeItemIdSchema,
|
|
633
640
|
contentIndex: zod_1.z.number().int().nonnegative().safe(),
|
|
634
641
|
audioEndMs: milliseconds,
|
|
@@ -640,35 +647,35 @@ exports.realtimeItemTruncatedEventSchema = zod_1.z.object({
|
|
|
640
647
|
*/
|
|
641
648
|
exports.realtimeSpeechStartedEventSchema = zod_1.z.object({
|
|
642
649
|
...eventBase,
|
|
643
|
-
type: zod_1.z.literal(
|
|
650
|
+
type: zod_1.z.literal('input_audio.speech_started'),
|
|
644
651
|
itemId: exports.realtimeItemIdSchema,
|
|
645
652
|
audioStartMs: milliseconds,
|
|
646
653
|
});
|
|
647
654
|
exports.realtimeSpeechStoppedEventSchema = zod_1.z.object({
|
|
648
655
|
...eventBase,
|
|
649
|
-
type: zod_1.z.literal(
|
|
656
|
+
type: zod_1.z.literal('input_audio.speech_stopped'),
|
|
650
657
|
itemId: exports.realtimeItemIdSchema,
|
|
651
658
|
audioEndMs: milliseconds,
|
|
652
659
|
});
|
|
653
660
|
exports.realtimeInputAudioCommittedEventSchema = zod_1.z.object({
|
|
654
661
|
...eventBase,
|
|
655
|
-
type: zod_1.z.literal(
|
|
662
|
+
type: zod_1.z.literal('input_audio.committed'),
|
|
656
663
|
itemId: exports.realtimeItemIdSchema,
|
|
657
664
|
previousItemId: exports.realtimeItemIdSchema.optional(),
|
|
658
665
|
});
|
|
659
666
|
exports.realtimeInputAudioClearedEventSchema = zod_1.z.object({
|
|
660
667
|
...eventBase,
|
|
661
|
-
type: zod_1.z.literal(
|
|
668
|
+
type: zod_1.z.literal('input_audio.cleared'),
|
|
662
669
|
});
|
|
663
670
|
exports.realtimeResponseCreatedEventSchema = zod_1.z.object({
|
|
664
671
|
...eventBase,
|
|
665
|
-
type: zod_1.z.literal(
|
|
672
|
+
type: zod_1.z.literal('response.created'),
|
|
666
673
|
responseId: exports.realtimeResponseIdSchema,
|
|
667
674
|
});
|
|
668
675
|
/** One bounded frame of spoken output, in the session's `outputAudioFormat`. */
|
|
669
676
|
exports.realtimeOutputAudioDeltaEventSchema = zod_1.z.object({
|
|
670
677
|
...eventBase,
|
|
671
|
-
type: zod_1.z.literal(
|
|
678
|
+
type: zod_1.z.literal('output_audio.delta'),
|
|
672
679
|
responseId: exports.realtimeResponseIdSchema,
|
|
673
680
|
itemId: exports.realtimeItemIdSchema,
|
|
674
681
|
contentIndex: zod_1.z.number().int().nonnegative().safe(),
|
|
@@ -677,7 +684,7 @@ exports.realtimeOutputAudioDeltaEventSchema = zod_1.z.object({
|
|
|
677
684
|
});
|
|
678
685
|
exports.realtimeOutputAudioDoneEventSchema = zod_1.z.object({
|
|
679
686
|
...eventBase,
|
|
680
|
-
type: zod_1.z.literal(
|
|
687
|
+
type: zod_1.z.literal('output_audio.done'),
|
|
681
688
|
responseId: exports.realtimeResponseIdSchema,
|
|
682
689
|
itemId: exports.realtimeItemIdSchema,
|
|
683
690
|
contentIndex: zod_1.z.number().int().nonnegative().safe(),
|
|
@@ -686,10 +693,10 @@ exports.realtimeOutputAudioDoneEventSchema = zod_1.z.object({
|
|
|
686
693
|
* Which audio a transcript describes: the caller's (`input_audio`) or the
|
|
687
694
|
* model's own speech (`output_audio`). Neither is answer text.
|
|
688
695
|
*/
|
|
689
|
-
exports.realtimeTranscriptSourceSchema = zod_1.z.enum([
|
|
696
|
+
exports.realtimeTranscriptSourceSchema = zod_1.z.enum(['input_audio', 'output_audio']);
|
|
690
697
|
exports.realtimeTranscriptDeltaEventSchema = zod_1.z.object({
|
|
691
698
|
...eventBase,
|
|
692
|
-
type: zod_1.z.literal(
|
|
699
|
+
type: zod_1.z.literal('transcript.delta'),
|
|
693
700
|
source: exports.realtimeTranscriptSourceSchema,
|
|
694
701
|
itemId: exports.realtimeItemIdSchema,
|
|
695
702
|
contentIndex: zod_1.z.number().int().nonnegative().safe(),
|
|
@@ -699,7 +706,7 @@ exports.realtimeTranscriptDeltaEventSchema = zod_1.z.object({
|
|
|
699
706
|
});
|
|
700
707
|
exports.realtimeTranscriptDoneEventSchema = zod_1.z.object({
|
|
701
708
|
...eventBase,
|
|
702
|
-
type: zod_1.z.literal(
|
|
709
|
+
type: zod_1.z.literal('transcript.done'),
|
|
703
710
|
source: exports.realtimeTranscriptSourceSchema,
|
|
704
711
|
itemId: exports.realtimeItemIdSchema,
|
|
705
712
|
contentIndex: zod_1.z.number().int().nonnegative().safe(),
|
|
@@ -709,7 +716,7 @@ exports.realtimeTranscriptDoneEventSchema = zod_1.z.object({
|
|
|
709
716
|
/** Written output of a response (`outputModalities` including `text`). */
|
|
710
717
|
exports.realtimeTextDeltaEventSchema = zod_1.z.object({
|
|
711
718
|
...eventBase,
|
|
712
|
-
type: zod_1.z.literal(
|
|
719
|
+
type: zod_1.z.literal('text.delta'),
|
|
713
720
|
responseId: exports.realtimeResponseIdSchema,
|
|
714
721
|
itemId: exports.realtimeItemIdSchema,
|
|
715
722
|
contentIndex: zod_1.z.number().int().nonnegative().safe(),
|
|
@@ -718,7 +725,7 @@ exports.realtimeTextDeltaEventSchema = zod_1.z.object({
|
|
|
718
725
|
/** A tool call being streamed; same accumulation rules as the one-shot event. */
|
|
719
726
|
exports.realtimeToolCallEventSchema = zod_1.z.object({
|
|
720
727
|
...eventBase,
|
|
721
|
-
type: zod_1.z.literal(
|
|
728
|
+
type: zod_1.z.literal('tool_call'),
|
|
722
729
|
responseId: exports.realtimeResponseIdSchema,
|
|
723
730
|
itemId: exports.realtimeItemIdSchema,
|
|
724
731
|
toolCallId: zod_1.z.string().min(1).max(128),
|
|
@@ -728,10 +735,10 @@ exports.realtimeToolCallEventSchema = zod_1.z.object({
|
|
|
728
735
|
});
|
|
729
736
|
/** How a response ended. */
|
|
730
737
|
exports.realtimeResponseStatusSchema = zod_1.z.enum([
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
738
|
+
'completed',
|
|
739
|
+
'cancelled',
|
|
740
|
+
'incomplete',
|
|
741
|
+
'failed',
|
|
735
742
|
]);
|
|
736
743
|
/**
|
|
737
744
|
* A response ended, with the units it consumed — measurement evidence, as on
|
|
@@ -740,7 +747,7 @@ exports.realtimeResponseStatusSchema = zod_1.z.enum([
|
|
|
740
747
|
*/
|
|
741
748
|
exports.realtimeResponseDoneEventSchema = zod_1.z.object({
|
|
742
749
|
...eventBase,
|
|
743
|
-
type: zod_1.z.literal(
|
|
750
|
+
type: zod_1.z.literal('response.done'),
|
|
744
751
|
responseId: exports.realtimeResponseIdSchema,
|
|
745
752
|
status: exports.realtimeResponseStatusSchema,
|
|
746
753
|
finishReason: streamEvents_1.inferenceFinishReasonSchema.optional(),
|
|
@@ -754,21 +761,21 @@ exports.realtimeResponseDoneEventSchema = zod_1.z.object({
|
|
|
754
761
|
*/
|
|
755
762
|
exports.realtimeErrorEventSchema = zod_1.z.object({
|
|
756
763
|
...eventBase,
|
|
757
|
-
type: zod_1.z.literal(
|
|
764
|
+
type: zod_1.z.literal('error'),
|
|
758
765
|
fatal: zod_1.z.boolean(),
|
|
759
766
|
error: errors_1.inferenceErrorSchema,
|
|
760
767
|
});
|
|
761
768
|
/** Why a session ended. */
|
|
762
769
|
exports.realtimeSessionCloseReasonSchema = zod_1.z.enum([
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
770
|
+
'client_closed',
|
|
771
|
+
'max_duration',
|
|
772
|
+
'idle_timeout',
|
|
773
|
+
'limit_exceeded',
|
|
774
|
+
'resume_expired',
|
|
775
|
+
'upstream_closed',
|
|
776
|
+
'upstream_error',
|
|
777
|
+
'no_route_available',
|
|
778
|
+
'server_shutdown',
|
|
772
779
|
]);
|
|
773
780
|
/**
|
|
774
781
|
* The terminal event. Carries the session's total units; `deploymentId` is
|
|
@@ -776,7 +783,7 @@ exports.realtimeSessionCloseReasonSchema = zod_1.z.enum([
|
|
|
776
783
|
*/
|
|
777
784
|
exports.realtimeSessionClosedEventSchema = zod_1.z.object({
|
|
778
785
|
...eventBase,
|
|
779
|
-
type: zod_1.z.literal(
|
|
786
|
+
type: zod_1.z.literal('session.closed'),
|
|
780
787
|
reason: exports.realtimeSessionCloseReasonSchema,
|
|
781
788
|
deploymentId: identifiers_1.deploymentIdSchema.optional(),
|
|
782
789
|
units: zod_1.z.array(money_1.usageQuantitySchema),
|
|
@@ -785,7 +792,7 @@ exports.realtimeSessionClosedEventSchema = zod_1.z.object({
|
|
|
785
792
|
});
|
|
786
793
|
/** Every event a session can emit. */
|
|
787
794
|
exports.realtimeServerEventSchema = zod_1.z
|
|
788
|
-
.discriminatedUnion(
|
|
795
|
+
.discriminatedUnion('type', [
|
|
789
796
|
exports.realtimeSessionCreatedEventSchema,
|
|
790
797
|
exports.realtimeSessionUpdatedEventSchema,
|
|
791
798
|
exports.realtimeSessionResumedEventSchema,
|
|
@@ -813,14 +820,14 @@ exports.realtimeServerEventSchema = zod_1.z
|
|
|
813
820
|
// Each unit is reported once, as a total — the rule every usage record in
|
|
814
821
|
// this contract holds. Checked on the union because a discriminated union's
|
|
815
822
|
// options must stay plain objects.
|
|
816
|
-
if (event.type !==
|
|
823
|
+
if (event.type !== 'response.done' && event.type !== 'session.closed')
|
|
817
824
|
return;
|
|
818
825
|
const units = event.units.map((quantity) => quantity.unit);
|
|
819
826
|
if (new Set(units).size !== units.length) {
|
|
820
827
|
ctx.addIssue({
|
|
821
828
|
code: zod_1.z.ZodIssueCode.custom,
|
|
822
|
-
path: [
|
|
823
|
-
message:
|
|
829
|
+
path: ['units'],
|
|
830
|
+
message: 'each unit is reported at most once',
|
|
824
831
|
});
|
|
825
832
|
}
|
|
826
833
|
});
|
|
@@ -6,7 +6,7 @@ const zod_1 = require("zod");
|
|
|
6
6
|
const identifiers_1 = require("./identifiers");
|
|
7
7
|
const money_1 = require("./money");
|
|
8
8
|
/** Explicit extension negotiation; never replaces the legacy 3.5 handshake. */
|
|
9
|
-
exports.SCOPED_EXECUTION_CONTRACT_VERSION =
|
|
9
|
+
exports.SCOPED_EXECUTION_CONTRACT_VERSION = '3.6.0';
|
|
10
10
|
/** Scoped only; normal envelope v2 and metadata 3.5 remain unchanged. */
|
|
11
11
|
exports.SCOPED_REQUEST_ENVELOPE_VERSION = 3;
|
|
12
12
|
const identity = zod_1.z.string().min(1).max(256);
|
|
@@ -14,10 +14,10 @@ const sha256 = zod_1.z.string().regex(/^[0-9a-f]{64}$/);
|
|
|
14
14
|
const maxCost = money_1.exactDecimalSchema.refine((value) => {
|
|
15
15
|
if (!money_1.exactDecimalSchema.safeParse(value).success)
|
|
16
16
|
return false;
|
|
17
|
-
const [whole, fraction =
|
|
18
|
-
const units = BigInt(whole) * 1000000000000n + BigInt(fraction.padEnd(12,
|
|
17
|
+
const [whole, fraction = ''] = value.split('.');
|
|
18
|
+
const units = BigInt(whole) * 1000000000000n + BigInt(fraction.padEnd(12, '0'));
|
|
19
19
|
return units > 0n && units <= 10000000000n;
|
|
20
|
-
},
|
|
20
|
+
}, 'scoped cost must be positive and at most 0.01 USD');
|
|
21
21
|
/** Restriction only: none of these identities grants catalogue eligibility. */
|
|
22
22
|
exports.scopedExecutionAudienceSchema = zod_1.z
|
|
23
23
|
.object({
|
|
@@ -42,7 +42,7 @@ exports.scopedExecutionAudienceSchema = zod_1.z
|
|
|
42
42
|
deploymentId: identifiers_1.deploymentIdSchema,
|
|
43
43
|
provider: identifiers_1.inferenceProviderSlugSchema,
|
|
44
44
|
keyId: identity,
|
|
45
|
-
modelReference: identifiers_1.modelReferenceSchema.refine((value) => value.includes(
|
|
45
|
+
modelReference: identifiers_1.modelReferenceSchema.refine((value) => value.includes('@'), 'must pin a revision'),
|
|
46
46
|
upstreamModelId: identity,
|
|
47
47
|
priceVersionId: identity,
|
|
48
48
|
providerRateCardVersionId: identity,
|
|
@@ -63,25 +63,25 @@ exports.scopedExecutionSchema = exports.scopedExecutionAudienceSchema
|
|
|
63
63
|
* reparsed/defaulted decision. Reject non-JSON values rather than dropping them.
|
|
64
64
|
*/
|
|
65
65
|
function canonicalScopedExecutionJson(value) {
|
|
66
|
-
if (value === null || typeof value ===
|
|
66
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
67
67
|
return JSON.stringify(value);
|
|
68
|
-
if (typeof value ===
|
|
68
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
69
69
|
return JSON.stringify(value);
|
|
70
70
|
if (Array.isArray(value)) {
|
|
71
71
|
const entries = Array.from(value, (entry, index) => {
|
|
72
72
|
if (!(index in value))
|
|
73
|
-
throw new Error(
|
|
73
|
+
throw new Error('Scoped execution requires dense JSON arrays.');
|
|
74
74
|
return canonicalScopedExecutionJson(entry);
|
|
75
75
|
});
|
|
76
|
-
return `[${entries.join(
|
|
76
|
+
return `[${entries.join(',')}]`;
|
|
77
77
|
}
|
|
78
|
-
if (typeof value ===
|
|
78
|
+
if (typeof value === 'object' &&
|
|
79
79
|
value !== null &&
|
|
80
80
|
Object.getPrototypeOf(value) === Object.prototype) {
|
|
81
81
|
const entries = Object.keys(value)
|
|
82
82
|
.sort()
|
|
83
83
|
.map((key) => `${JSON.stringify(key)}:${canonicalScopedExecutionJson(value[key])}`);
|
|
84
|
-
return `{${entries.join(
|
|
84
|
+
return `{${entries.join(',')}}`;
|
|
85
85
|
}
|
|
86
|
-
throw new Error(
|
|
86
|
+
throw new Error('Scoped execution requires JSON wire values.');
|
|
87
87
|
}
|