@kaana.ai/contracts 6.1.1 → 8.0.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/internal/attribution.d.ts +32 -23
- package/dist/internal/attribution.js +14 -12
- package/dist/internal/catalogue.d.ts +3 -33
- package/dist/internal/catalogue.js +3 -7
- package/dist/internal/decisions.d.ts +30 -4
- package/dist/internal/grant.d.ts +40 -45
- package/dist/internal/grant.js +28 -61
- package/dist/internal/realtime.d.ts +15 -2
- package/dist/internal/request.d.ts +16 -669
- package/dist/internal/request.js +17 -104
- package/dist/internal/settlement.d.ts +30 -4
- package/dist/internal/usage.d.ts +15 -2
- package/dist/internal.d.ts +4 -7
- package/dist/internal.js +4 -7
- package/dist/public/decisions.d.ts +7 -1
- package/dist/public/decisions.js +9 -1
- package/dist/public/version.d.ts +12 -1
- package/dist/public/version.js +12 -1
- package/openapi.json +1 -2
- package/package.json +1 -1
- package/dist/internal/canonical.d.ts +0 -31
- package/dist/internal/canonical.js +0 -57
- package/dist/internal/privateAutoExecution.d.ts +0 -158
- package/dist/internal/privateAutoExecution.js +0 -188
- package/dist/internal/scopedExecution.d.ts +0 -74
- package/dist/internal/scopedExecution.js +0 -61
package/dist/internal/request.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The signed Oxy→Kaana request envelope (versions 1–
|
|
2
|
+
* The signed Oxy→Kaana request envelope (versions 1–2).
|
|
3
3
|
*
|
|
4
4
|
* Moved from `@oxy.so/contracts` 4.12.0 (`src/inference/request.ts`) by Kaana ADR 0002.
|
|
5
5
|
*/
|
|
@@ -10,9 +10,7 @@ import { idempotencyKeySchema, inferenceTimestampSchema } from '../public/identi
|
|
|
10
10
|
import { inferenceAudioOutputParametersSchema, inferenceMessageSchema, inferenceReasoningSchema, inferenceSpeechParametersSchema, inferenceTranscriptionParametersSchema, responseFormatSchema, samplingParametersSchema, toolChoiceSchema, toolDefinitionSchema, } from '../public/messages.js';
|
|
11
11
|
import { routingPolicyReferenceSchema } from '../public/policy.js';
|
|
12
12
|
import { inferenceAttributionSchema } from './attribution.js';
|
|
13
|
-
import { PRIVATE_AUTO_REQUEST_ENVELOPE_VERSION, privateAutoExecutionSchema, privateAutoInputSchema, } from './privateAutoExecution.js';
|
|
14
13
|
import { authorizedRouteSchema, routingTargetSchema } from './routing.js';
|
|
15
|
-
import { SCOPED_REQUEST_ENVELOPE_VERSION, scopedExecutionSchema } from './scopedExecution.js';
|
|
16
14
|
/**
|
|
17
15
|
* The request's input.
|
|
18
16
|
*
|
|
@@ -84,8 +82,6 @@ const modelLineOf = (reference) => {
|
|
|
84
82
|
const inferenceRequestObjectSchema = z.object({
|
|
85
83
|
/** See `version.ts`: this is the Oxy→data-plane request envelope. */
|
|
86
84
|
schemaVersion: z.literal(2),
|
|
87
|
-
/** Recognized so v2 refuses rather than silently stripping a restriction. */
|
|
88
|
-
scopedExecution: scopedExecutionSchema.optional(),
|
|
89
85
|
attribution: inferenceAttributionSchema,
|
|
90
86
|
target: routingTargetSchema,
|
|
91
87
|
modality: inferenceModalitySchema,
|
|
@@ -142,17 +138,22 @@ const inferenceRequestObjectSchema = z.object({
|
|
|
142
138
|
authorizedRoutes: z.array(authorizedRouteSchema).min(1).optional(),
|
|
143
139
|
});
|
|
144
140
|
export const inferenceRequestSchema = inferenceRequestObjectSchema.superRefine((request, ctx) => {
|
|
145
|
-
if (request.scopedExecution !== undefined)
|
|
146
|
-
ctx.addIssue({
|
|
147
|
-
code: 'custom',
|
|
148
|
-
path: ['scopedExecution'],
|
|
149
|
-
message: 'Scoped execution requires envelope v3.',
|
|
150
|
-
});
|
|
151
141
|
if (request.input.format === 'decisions' || request.client.apiFormat === 'decisions') {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
142
|
+
// A pinned model is served on exactly that revision, and an unpinned one
|
|
143
|
+
// on one revision of its line. A request that named no model carries its
|
|
144
|
+
// policy's target and is served on whichever pinned line the first
|
|
145
|
+
// admissible route names. Either way no route substitutes a revision, and
|
|
146
|
+
// an attempt never moves after dispatch.
|
|
147
|
+
const target = request.target;
|
|
148
|
+
const routes = request.authorizedRoutes ?? [];
|
|
149
|
+
const revision = target.kind === 'model' && target.modelReference.includes('@')
|
|
150
|
+
? target.modelReference
|
|
151
|
+
: routes[0]?.modelReference;
|
|
152
|
+
const exactModel = target.kind === 'routing_profile_id' ||
|
|
153
|
+
(revision !== undefined && revision.split('@')[0] === target.modelReference.split('@')[0]);
|
|
154
|
+
const foreignRoute = routes.some((route) => target.kind === 'model'
|
|
155
|
+
? route.modelReference !== revision || route.substitution !== 'same_model'
|
|
156
|
+
: !route.modelReference.includes('@'));
|
|
156
157
|
if (request.input.format !== 'decisions' ||
|
|
157
158
|
request.client.apiFormat !== 'decisions' ||
|
|
158
159
|
request.modality !== 'text' ||
|
|
@@ -171,7 +172,7 @@ export const inferenceRequestSchema = inferenceRequestObjectSchema.superRefine((
|
|
|
171
172
|
ctx.addIssue({
|
|
172
173
|
code: 'custom',
|
|
173
174
|
path: ['input'],
|
|
174
|
-
message: 'Decisions require
|
|
175
|
+
message: 'Decisions require typed nonstreaming input on pinned routes without generation controls or revision substitution.',
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
}
|
|
@@ -327,91 +328,3 @@ export const inferenceRequestSchema = inferenceRequestObjectSchema.superRefine((
|
|
|
327
328
|
});
|
|
328
329
|
}
|
|
329
330
|
});
|
|
330
|
-
/** Explicit restrictive generation: old v2 receivers reject this version whole. */
|
|
331
|
-
export const scopedInferenceRequestSchema = inferenceRequestObjectSchema
|
|
332
|
-
.extend({
|
|
333
|
-
schemaVersion: z.literal(SCOPED_REQUEST_ENVELOPE_VERSION),
|
|
334
|
-
scopedExecution: scopedExecutionSchema,
|
|
335
|
-
})
|
|
336
|
-
.superRefine((request, ctx) => {
|
|
337
|
-
const { scopedExecution: scope, ...base } = request;
|
|
338
|
-
const legacy = inferenceRequestSchema.safeParse({ ...base, schemaVersion: 2 });
|
|
339
|
-
if (!legacy.success)
|
|
340
|
-
for (const issue of legacy.error.issues)
|
|
341
|
-
ctx.addIssue({ code: 'custom', path: issue.path, message: issue.message });
|
|
342
|
-
const principal = request.attribution.principal;
|
|
343
|
-
const route = request.authorizedRoutes?.[0];
|
|
344
|
-
if (request.input.format !== 'decisions' ||
|
|
345
|
-
request.client.apiFormat !== 'decisions' ||
|
|
346
|
-
scope.requestId !== request.attribution.requestId ||
|
|
347
|
-
scope.idempotencyKey !== request.idempotencyKey ||
|
|
348
|
-
scope.principal.accountId !== principal.billing.accountId ||
|
|
349
|
-
scope.principal.applicationId !== principal.applicationId ||
|
|
350
|
-
scope.principal.credentialId !== principal.credentialId ||
|
|
351
|
-
scope.principal.environment !== principal.environment ||
|
|
352
|
-
scope.policy.routingPolicyId !== request.routingPolicy.routingPolicyId ||
|
|
353
|
-
scope.policy.policyVersion !== request.routingPolicy.policyVersion ||
|
|
354
|
-
request.authorizedRoutes?.length !== 1 ||
|
|
355
|
-
route?.customerProviderCredential !== undefined ||
|
|
356
|
-
route?.deploymentId !== scope.deploymentId ||
|
|
357
|
-
route?.provider !== scope.provider ||
|
|
358
|
-
route?.modelReference !== scope.modelReference ||
|
|
359
|
-
request.target.kind !== 'model' ||
|
|
360
|
-
request.target.modelReference !== scope.modelReference) {
|
|
361
|
-
ctx.addIssue({
|
|
362
|
-
code: 'custom',
|
|
363
|
-
path: ['scopedExecution'],
|
|
364
|
-
message: 'Scoped execution must restrict the exact attributed decisions request and one platform route.',
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
/** Private repeated Auto is independently negotiated, never a v3 fixture renewal. */
|
|
369
|
-
export const privateAutoInferenceRequestSchema = inferenceRequestObjectSchema
|
|
370
|
-
.omit({ scopedExecution: true })
|
|
371
|
-
.extend({
|
|
372
|
-
schemaVersion: z.literal(PRIVATE_AUTO_REQUEST_ENVELOPE_VERSION),
|
|
373
|
-
privateAutoExecution: privateAutoExecutionSchema,
|
|
374
|
-
})
|
|
375
|
-
.strict()
|
|
376
|
-
.superRefine((request, ctx) => {
|
|
377
|
-
const { privateAutoExecution: permit, ...base } = request;
|
|
378
|
-
const legacy = inferenceRequestSchema.safeParse({ ...base, schemaVersion: 2 });
|
|
379
|
-
if (!legacy.success)
|
|
380
|
-
for (const issue of legacy.error.issues)
|
|
381
|
-
ctx.addIssue({ code: 'custom', path: issue.path, message: issue.message });
|
|
382
|
-
const input = privateAutoInputSchema.safeParse(request.input);
|
|
383
|
-
if (!input.success)
|
|
384
|
-
for (const issue of input.error.issues)
|
|
385
|
-
ctx.addIssue({ code: 'custom', path: ['input', ...issue.path], message: issue.message });
|
|
386
|
-
const principal = request.attribution.principal;
|
|
387
|
-
const route = request.authorizedRoutes?.[0];
|
|
388
|
-
if (request.attribution.userId !== undefined ||
|
|
389
|
-
request.client.apiFormat !== 'decisions' ||
|
|
390
|
-
permit.requestId !== request.attribution.requestId ||
|
|
391
|
-
permit.operationId !== request.idempotencyKey ||
|
|
392
|
-
permit.principal.accountId !== principal.billing.accountId ||
|
|
393
|
-
permit.principal.applicationId !== principal.applicationId ||
|
|
394
|
-
permit.principal.credentialId !== principal.credentialId ||
|
|
395
|
-
permit.principal.environment !== principal.environment ||
|
|
396
|
-
!principal.inferenceScopes.includes('inference:invoke') ||
|
|
397
|
-
request.client.endpoint !== '/internal/auto-classification' ||
|
|
398
|
-
permit.policy.routingPolicyId !== request.routingPolicy.routingPolicyId ||
|
|
399
|
-
permit.policy.policyVersion !== request.routingPolicy.policyVersion ||
|
|
400
|
-
request.authorizedRoutes?.length !== 1 ||
|
|
401
|
-
route?.customerProviderCredential !== undefined ||
|
|
402
|
-
route?.deploymentId !== permit.deploymentId ||
|
|
403
|
-
route?.provider !== permit.provider ||
|
|
404
|
-
route?.modelReference !== permit.modelReference ||
|
|
405
|
-
request.target.kind !== 'model' ||
|
|
406
|
-
request.target.modelReference !== permit.modelReference ||
|
|
407
|
-
route.regions.length !== permit.regions.length ||
|
|
408
|
-
route.regions.some((region) => !permit.regions.includes(region)) ||
|
|
409
|
-
Date.parse(permit.runtimeExpiresAt) <= Date.parse(request.client.receivedAt) ||
|
|
410
|
-
Date.parse(permit.runtimeExpiresAt) > Date.parse(request.client.receivedAt) + 1000) {
|
|
411
|
-
ctx.addIssue({
|
|
412
|
-
code: 'custom',
|
|
413
|
-
path: ['privateAutoExecution'],
|
|
414
|
-
message: 'Private Auto must bind one exact attributed decisions child and platform route.',
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
});
|
|
@@ -30,7 +30,8 @@ export declare const settlementSchema: z.ZodObject<{
|
|
|
30
30
|
requestId: z.ZodString;
|
|
31
31
|
generationId: z.ZodOptional<z.ZodString>;
|
|
32
32
|
attribution: z.ZodObject<{
|
|
33
|
-
principal: z.ZodObject<{
|
|
33
|
+
principal: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
34
|
+
authority: z.ZodLiteral<"first_party">;
|
|
34
35
|
billing: z.ZodObject<{
|
|
35
36
|
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
36
37
|
}, z.core.$strict>;
|
|
@@ -41,6 +42,8 @@ export declare const settlementSchema: z.ZodObject<{
|
|
|
41
42
|
staging: "staging";
|
|
42
43
|
production: "production";
|
|
43
44
|
}>;
|
|
45
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
46
|
+
authority: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
44
47
|
inferenceScopes: z.ZodArray<z.ZodEnum<{
|
|
45
48
|
"inference:invoke": "inference:invoke";
|
|
46
49
|
"inference:models:read": "inference:models:read";
|
|
@@ -50,7 +53,17 @@ export declare const settlementSchema: z.ZodObject<{
|
|
|
50
53
|
"inference:providers:read": "inference:providers:read";
|
|
51
54
|
"inference:providers:write": "inference:providers:write";
|
|
52
55
|
}>>;
|
|
53
|
-
|
|
56
|
+
billing: z.ZodObject<{
|
|
57
|
+
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
applicationId: z.ZodString;
|
|
60
|
+
credentialId: z.ZodString;
|
|
61
|
+
environment: z.ZodEnum<{
|
|
62
|
+
development: "development";
|
|
63
|
+
staging: "staging";
|
|
64
|
+
production: "production";
|
|
65
|
+
}>;
|
|
66
|
+
}, z.core.$strict>], "authority">;
|
|
54
67
|
userId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
|
|
55
68
|
requestId: z.ZodString;
|
|
56
69
|
generationId: z.ZodOptional<z.ZodString>;
|
|
@@ -141,7 +154,8 @@ export declare const settlementPageSchema: z.ZodObject<{
|
|
|
141
154
|
requestId: z.ZodString;
|
|
142
155
|
generationId: z.ZodOptional<z.ZodString>;
|
|
143
156
|
attribution: z.ZodObject<{
|
|
144
|
-
principal: z.ZodObject<{
|
|
157
|
+
principal: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
158
|
+
authority: z.ZodLiteral<"first_party">;
|
|
145
159
|
billing: z.ZodObject<{
|
|
146
160
|
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
147
161
|
}, z.core.$strict>;
|
|
@@ -152,6 +166,8 @@ export declare const settlementPageSchema: z.ZodObject<{
|
|
|
152
166
|
staging: "staging";
|
|
153
167
|
production: "production";
|
|
154
168
|
}>;
|
|
169
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
170
|
+
authority: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
155
171
|
inferenceScopes: z.ZodArray<z.ZodEnum<{
|
|
156
172
|
"inference:invoke": "inference:invoke";
|
|
157
173
|
"inference:models:read": "inference:models:read";
|
|
@@ -161,7 +177,17 @@ export declare const settlementPageSchema: z.ZodObject<{
|
|
|
161
177
|
"inference:providers:read": "inference:providers:read";
|
|
162
178
|
"inference:providers:write": "inference:providers:write";
|
|
163
179
|
}>>;
|
|
164
|
-
|
|
180
|
+
billing: z.ZodObject<{
|
|
181
|
+
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
182
|
+
}, z.core.$strict>;
|
|
183
|
+
applicationId: z.ZodString;
|
|
184
|
+
credentialId: z.ZodString;
|
|
185
|
+
environment: z.ZodEnum<{
|
|
186
|
+
development: "development";
|
|
187
|
+
staging: "staging";
|
|
188
|
+
production: "production";
|
|
189
|
+
}>;
|
|
190
|
+
}, z.core.$strict>], "authority">;
|
|
165
191
|
userId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
|
|
166
192
|
requestId: z.ZodString;
|
|
167
193
|
generationId: z.ZodOptional<z.ZodString>;
|
package/dist/internal/usage.d.ts
CHANGED
|
@@ -54,7 +54,8 @@ export declare const normalizedUsageReportSchema: z.ZodObject<{
|
|
|
54
54
|
requestId: z.ZodString;
|
|
55
55
|
generationId: z.ZodOptional<z.ZodString>;
|
|
56
56
|
attribution: z.ZodObject<{
|
|
57
|
-
principal: z.ZodObject<{
|
|
57
|
+
principal: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
58
|
+
authority: z.ZodLiteral<"first_party">;
|
|
58
59
|
billing: z.ZodObject<{
|
|
59
60
|
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
60
61
|
}, z.core.$strict>;
|
|
@@ -65,6 +66,8 @@ export declare const normalizedUsageReportSchema: z.ZodObject<{
|
|
|
65
66
|
staging: "staging";
|
|
66
67
|
production: "production";
|
|
67
68
|
}>;
|
|
69
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
70
|
+
authority: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
68
71
|
inferenceScopes: z.ZodArray<z.ZodEnum<{
|
|
69
72
|
"inference:invoke": "inference:invoke";
|
|
70
73
|
"inference:models:read": "inference:models:read";
|
|
@@ -74,7 +77,17 @@ export declare const normalizedUsageReportSchema: z.ZodObject<{
|
|
|
74
77
|
"inference:providers:read": "inference:providers:read";
|
|
75
78
|
"inference:providers:write": "inference:providers:write";
|
|
76
79
|
}>>;
|
|
77
|
-
|
|
80
|
+
billing: z.ZodObject<{
|
|
81
|
+
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
applicationId: z.ZodString;
|
|
84
|
+
credentialId: z.ZodString;
|
|
85
|
+
environment: z.ZodEnum<{
|
|
86
|
+
development: "development";
|
|
87
|
+
staging: "staging";
|
|
88
|
+
production: "production";
|
|
89
|
+
}>;
|
|
90
|
+
}, z.core.$strict>], "authority">;
|
|
78
91
|
userId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
|
|
79
92
|
requestId: z.ZodString;
|
|
80
93
|
generationId: z.ZodOptional<z.ZodString>;
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@kaana.ai/contracts/internal` — what Oxy and Kaana exchange privately.
|
|
3
3
|
*
|
|
4
|
-
* The grant and its authorization request, the settlement, the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The grant and its authorization request, the settlement, the operational
|
|
5
|
+
* catalogue, customer-credential control and the signed v1–v2 envelope with
|
|
6
|
+
* its stream and usage report (retired at the end of the cut, Kaana ADR 0002
|
|
7
|
+
* phase 5). Nothing here is a public API: it names
|
|
8
8
|
* providers, deployments, keys and billing accounts.
|
|
9
9
|
*
|
|
10
10
|
* Shared vocabulary (identifiers, messages, money) is imported from the
|
|
11
11
|
* package root; this entry point exports only what is internal.
|
|
12
12
|
*/
|
|
13
13
|
export * from './internal/attribution.js';
|
|
14
|
-
export * from './internal/canonical.js';
|
|
15
14
|
export * from './internal/catalogue.js';
|
|
16
15
|
export * from './internal/credentialControl.js';
|
|
17
16
|
export * from './internal/decisions.js';
|
|
@@ -20,11 +19,9 @@ export * from './internal/embeddings.js';
|
|
|
20
19
|
export * from './internal/errors.js';
|
|
21
20
|
export * from './internal/grant.js';
|
|
22
21
|
export * from './internal/identifiers.js';
|
|
23
|
-
export * from './internal/privateAutoExecution.js';
|
|
24
22
|
export * from './internal/realtime.js';
|
|
25
23
|
export * from './internal/request.js';
|
|
26
24
|
export * from './internal/routing.js';
|
|
27
|
-
export * from './internal/scopedExecution.js';
|
|
28
25
|
export * from './internal/settlement.js';
|
|
29
26
|
export * from './internal/streamEvents.js';
|
|
30
27
|
export * from './internal/usage.js';
|
package/dist/internal.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@kaana.ai/contracts/internal` — what Oxy and Kaana exchange privately.
|
|
3
3
|
*
|
|
4
|
-
* The grant and its authorization request, the settlement, the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The grant and its authorization request, the settlement, the operational
|
|
5
|
+
* catalogue, customer-credential control and the signed v1–v2 envelope with
|
|
6
|
+
* its stream and usage report (retired at the end of the cut, Kaana ADR 0002
|
|
7
|
+
* phase 5). Nothing here is a public API: it names
|
|
8
8
|
* providers, deployments, keys and billing accounts.
|
|
9
9
|
*
|
|
10
10
|
* Shared vocabulary (identifiers, messages, money) is imported from the
|
|
11
11
|
* package root; this entry point exports only what is internal.
|
|
12
12
|
*/
|
|
13
13
|
export * from './internal/attribution.js';
|
|
14
|
-
export * from './internal/canonical.js';
|
|
15
14
|
export * from './internal/catalogue.js';
|
|
16
15
|
export * from './internal/credentialControl.js';
|
|
17
16
|
export * from './internal/decisions.js';
|
|
@@ -20,11 +19,9 @@ export * from './internal/embeddings.js';
|
|
|
20
19
|
export * from './internal/errors.js';
|
|
21
20
|
export * from './internal/grant.js';
|
|
22
21
|
export * from './internal/identifiers.js';
|
|
23
|
-
export * from './internal/privateAutoExecution.js';
|
|
24
22
|
export * from './internal/realtime.js';
|
|
25
23
|
export * from './internal/request.js';
|
|
26
24
|
export * from './internal/routing.js';
|
|
27
|
-
export * from './internal/scopedExecution.js';
|
|
28
25
|
export * from './internal/settlement.js';
|
|
29
26
|
export * from './internal/streamEvents.js';
|
|
30
27
|
export * from './internal/usage.js';
|
|
@@ -72,6 +72,12 @@ export declare const decisionInputSchema: z.ZodObject<{
|
|
|
72
72
|
xhigh: "xhigh";
|
|
73
73
|
}>>;
|
|
74
74
|
}, z.core.$strict>;
|
|
75
|
+
/**
|
|
76
|
+
* `model`, when present, pins the exact revision that must answer, and is
|
|
77
|
+
* never substituted. Absent, the application's decisions profile chooses: Oxy
|
|
78
|
+
* grants its lines in order and the first one Kaana can serve answers; the
|
|
79
|
+
* success names the revision that did (contract set 7.0.0).
|
|
80
|
+
*/
|
|
75
81
|
export declare const decisionRequestSchema: z.ZodObject<{
|
|
76
82
|
state: z.ZodString;
|
|
77
83
|
instructions: z.ZodOptional<z.ZodString>;
|
|
@@ -100,7 +106,7 @@ export declare const decisionRequestSchema: z.ZodObject<{
|
|
|
100
106
|
instant: "instant";
|
|
101
107
|
xhigh: "xhigh";
|
|
102
108
|
}>>;
|
|
103
|
-
model: z.ZodString
|
|
109
|
+
model: z.ZodOptional<z.ZodString>;
|
|
104
110
|
}, z.core.$strict>;
|
|
105
111
|
export declare const decisionAnswerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
106
112
|
id: z.ZodString;
|
package/dist/public/decisions.js
CHANGED
|
@@ -155,9 +155,17 @@ function validateInput(payload, ctx) {
|
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
export const decisionInputSchema = z.object(payloadFields).strict().superRefine(validateInput);
|
|
158
|
+
/**
|
|
159
|
+
* `model`, when present, pins the exact revision that must answer, and is
|
|
160
|
+
* never substituted. Absent, the application's decisions profile chooses: Oxy
|
|
161
|
+
* grants its lines in order and the first one Kaana can serve answers; the
|
|
162
|
+
* success names the revision that did (contract set 7.0.0).
|
|
163
|
+
*/
|
|
158
164
|
export const decisionRequestSchema = z
|
|
159
165
|
.object({
|
|
160
|
-
model: modelReferenceSchema
|
|
166
|
+
model: modelReferenceSchema
|
|
167
|
+
.refine((model) => model.includes('@'), 'Decisions require a revision-pinned model.')
|
|
168
|
+
.optional(),
|
|
161
169
|
...payloadFields,
|
|
162
170
|
})
|
|
163
171
|
.strict()
|
package/dist/public/version.d.ts
CHANGED
|
@@ -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 = "
|
|
103
|
+
export declare const INFERENCE_CONTRACT_VERSION = "8.0.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:
|
|
@@ -170,6 +170,17 @@ export declare const INFERENCE_CONTRACT_VERSION = "6.0.0";
|
|
|
170
170
|
* per item, and `REALTIME_DEFAULT_SILENCE_DURATION_MS`, the silence a
|
|
171
171
|
* `server_vad` that names none waits on every provider. A client on 5.0.0
|
|
172
172
|
* parses every 6.0.0 response.
|
|
173
|
+
*
|
|
174
|
+
* Contract set 7.0.0 serves decisions as an ordinary grant: a decisions
|
|
175
|
+
* request's `model` is optional (pinned when present; absent, the
|
|
176
|
+
* application's decisions profile chooses), and the signed envelope admits a
|
|
177
|
+
* decisions request carried as its policy's target on pinned routes. MAJOR
|
|
178
|
+
* because it REMOVES the one-off source approvals: the grant's `exactRoute`
|
|
179
|
+
* (`grantExactRouteSchema`) and the authorization's `canonicalInputSha256`,
|
|
180
|
+
* `canonicalJson` and `canonicalInputSha256()`, the scoped and Private Auto
|
|
181
|
+
* envelopes v3 and v4 (`scopedExecutionSchema`, `privateAutoExecutionSchema`
|
|
182
|
+
* and every shape under them) and a deployment's `scopedExecution`. A grant
|
|
183
|
+
* or a request that parsed under 6.0.0 without them still parses the same.
|
|
173
184
|
*/
|
|
174
185
|
/** The public API's one origin and version. */
|
|
175
186
|
export declare const KAANA_API_BASE_URL = "https://kaana.ai/v1";
|
package/dist/public/version.js
CHANGED
|
@@ -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 = '
|
|
103
|
+
export const INFERENCE_CONTRACT_VERSION = '8.0.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:
|
|
@@ -170,6 +170,17 @@ export const INFERENCE_CONTRACT_VERSION = '6.0.0';
|
|
|
170
170
|
* per item, and `REALTIME_DEFAULT_SILENCE_DURATION_MS`, the silence a
|
|
171
171
|
* `server_vad` that names none waits on every provider. A client on 5.0.0
|
|
172
172
|
* parses every 6.0.0 response.
|
|
173
|
+
*
|
|
174
|
+
* Contract set 7.0.0 serves decisions as an ordinary grant: a decisions
|
|
175
|
+
* request's `model` is optional (pinned when present; absent, the
|
|
176
|
+
* application's decisions profile chooses), and the signed envelope admits a
|
|
177
|
+
* decisions request carried as its policy's target on pinned routes. MAJOR
|
|
178
|
+
* because it REMOVES the one-off source approvals: the grant's `exactRoute`
|
|
179
|
+
* (`grantExactRouteSchema`) and the authorization's `canonicalInputSha256`,
|
|
180
|
+
* `canonicalJson` and `canonicalInputSha256()`, the scoped and Private Auto
|
|
181
|
+
* envelopes v3 and v4 (`scopedExecutionSchema`, `privateAutoExecutionSchema`
|
|
182
|
+
* and every shape under them) and a deployment's `scopedExecution`. A grant
|
|
183
|
+
* or a request that parsed under 6.0.0 without them still parses the same.
|
|
173
184
|
*/
|
|
174
185
|
/** The public API's one origin and version. */
|
|
175
186
|
export const KAANA_API_BASE_URL = 'https://kaana.ai/v1';
|
package/openapi.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"openapi": "3.1.0",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "Kaana API",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "8.0.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": [
|
|
@@ -2307,7 +2307,6 @@
|
|
|
2307
2307
|
}
|
|
2308
2308
|
},
|
|
2309
2309
|
"required": [
|
|
2310
|
-
"model",
|
|
2311
2310
|
"state",
|
|
2312
2311
|
"questions"
|
|
2313
2312
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaana.ai/contracts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.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,
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonical JSON and the canonical input hash.
|
|
3
|
-
*
|
|
4
|
-
* Operations with a source approval (scoped execution, Private Auto, the Jev
|
|
5
|
-
* classifier) bind the exact input they were approved for. Kaana computes the
|
|
6
|
-
* hash of the input it is about to execute and Oxy compares it with the one
|
|
7
|
-
* the approval fixed (Kaana ADR 0002, decision 4), so both sides must hash the
|
|
8
|
-
* same bytes. This is that one definition.
|
|
9
|
-
*
|
|
10
|
-
* `canonicalJson` is moved from `@oxy.so/contracts` 4.12.0
|
|
11
|
-
* (`canonicalScopedExecutionJson`, `src/inference/scopedExecution.ts`), and Go
|
|
12
|
-
* restates it in `internal/contract/scoped_execution.go`.
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Canonical JSON wire bytes: recursive UTF-16 key order, JSON string/number
|
|
16
|
-
* encoding, arrays in order, no whitespace. Hash the whole signed input, not a
|
|
17
|
-
* reparsed/defaulted decision. Reject non-JSON values rather than dropping them.
|
|
18
|
-
*/
|
|
19
|
-
export declare function canonicalJson(value: unknown): string;
|
|
20
|
-
/** The name scoped execution has always used for {@link canonicalJson}. */
|
|
21
|
-
export declare const canonicalScopedExecutionJson: typeof canonicalJson;
|
|
22
|
-
/**
|
|
23
|
-
* The canonical input hash: lowercase hex SHA-256 of {@link canonicalJson} of
|
|
24
|
-
* the request input, UTF-8 encoded.
|
|
25
|
-
*
|
|
26
|
-
* Asynchronous because it uses Web Crypto, which every runtime this package
|
|
27
|
-
* supports (Node 20+, Bun, browsers, Hermes with a crypto polyfill) provides
|
|
28
|
-
* without importing a platform module. Never logged or persisted: it binds
|
|
29
|
-
* transient signed bytes.
|
|
30
|
-
*/
|
|
31
|
-
export declare function canonicalInputSha256(input: unknown): Promise<string>;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonical JSON and the canonical input hash.
|
|
3
|
-
*
|
|
4
|
-
* Operations with a source approval (scoped execution, Private Auto, the Jev
|
|
5
|
-
* classifier) bind the exact input they were approved for. Kaana computes the
|
|
6
|
-
* hash of the input it is about to execute and Oxy compares it with the one
|
|
7
|
-
* the approval fixed (Kaana ADR 0002, decision 4), so both sides must hash the
|
|
8
|
-
* same bytes. This is that one definition.
|
|
9
|
-
*
|
|
10
|
-
* `canonicalJson` is moved from `@oxy.so/contracts` 4.12.0
|
|
11
|
-
* (`canonicalScopedExecutionJson`, `src/inference/scopedExecution.ts`), and Go
|
|
12
|
-
* restates it in `internal/contract/scoped_execution.go`.
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Canonical JSON wire bytes: recursive UTF-16 key order, JSON string/number
|
|
16
|
-
* encoding, arrays in order, no whitespace. Hash the whole signed input, not a
|
|
17
|
-
* reparsed/defaulted decision. Reject non-JSON values rather than dropping them.
|
|
18
|
-
*/
|
|
19
|
-
export function canonicalJson(value) {
|
|
20
|
-
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
21
|
-
return JSON.stringify(value);
|
|
22
|
-
if (typeof value === 'number' && Number.isFinite(value))
|
|
23
|
-
return JSON.stringify(value);
|
|
24
|
-
if (Array.isArray(value)) {
|
|
25
|
-
const entries = Array.from(value, (entry, index) => {
|
|
26
|
-
if (!(index in value))
|
|
27
|
-
throw new Error('Canonical JSON requires dense JSON arrays.');
|
|
28
|
-
return canonicalJson(entry);
|
|
29
|
-
});
|
|
30
|
-
return `[${entries.join(',')}]`;
|
|
31
|
-
}
|
|
32
|
-
if (typeof value === 'object' &&
|
|
33
|
-
value !== null &&
|
|
34
|
-
Object.getPrototypeOf(value) === Object.prototype) {
|
|
35
|
-
const entries = Object.keys(value)
|
|
36
|
-
.sort()
|
|
37
|
-
.map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`);
|
|
38
|
-
return `{${entries.join(',')}}`;
|
|
39
|
-
}
|
|
40
|
-
throw new Error('Canonical JSON requires JSON wire values.');
|
|
41
|
-
}
|
|
42
|
-
/** The name scoped execution has always used for {@link canonicalJson}. */
|
|
43
|
-
export const canonicalScopedExecutionJson = canonicalJson;
|
|
44
|
-
/**
|
|
45
|
-
* The canonical input hash: lowercase hex SHA-256 of {@link canonicalJson} of
|
|
46
|
-
* the request input, UTF-8 encoded.
|
|
47
|
-
*
|
|
48
|
-
* Asynchronous because it uses Web Crypto, which every runtime this package
|
|
49
|
-
* supports (Node 20+, Bun, browsers, Hermes with a crypto polyfill) provides
|
|
50
|
-
* without importing a platform module. Never logged or persisted: it binds
|
|
51
|
-
* transient signed bytes.
|
|
52
|
-
*/
|
|
53
|
-
export async function canonicalInputSha256(input) {
|
|
54
|
-
const bytes = new TextEncoder().encode(canonicalJson(input));
|
|
55
|
-
const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes);
|
|
56
|
-
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
57
|
-
}
|