@kaana.ai/contracts 6.1.1 → 7.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/catalogue.d.ts +0 -29
- package/dist/internal/catalogue.js +0 -3
- package/dist/internal/grant.d.ts +4 -36
- package/dist/internal/grant.js +7 -56
- package/dist/internal/request.d.ts +1 -667
- package/dist/internal/request.js +17 -104
- 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
|
@@ -226,35 +226,6 @@ export declare const inferenceProviderSchema: z.ZodObject<{
|
|
|
226
226
|
export declare const modelDeploymentSchema: z.ZodObject<{
|
|
227
227
|
schemaVersion: z.ZodLiteral<2>;
|
|
228
228
|
deploymentId: z.ZodString;
|
|
229
|
-
scopedExecution: z.ZodOptional<z.ZodObject<{
|
|
230
|
-
permitId: z.ZodString;
|
|
231
|
-
idempotencyKey: z.ZodString;
|
|
232
|
-
fixtureSha256: z.ZodString;
|
|
233
|
-
expiresAt: z.ZodString;
|
|
234
|
-
principal: z.ZodObject<{
|
|
235
|
-
accountId: z.ZodString;
|
|
236
|
-
applicationId: z.ZodString;
|
|
237
|
-
credentialId: z.ZodString;
|
|
238
|
-
environment: z.ZodEnum<{
|
|
239
|
-
development: "development";
|
|
240
|
-
staging: "staging";
|
|
241
|
-
production: "production";
|
|
242
|
-
}>;
|
|
243
|
-
}, z.core.$strict>;
|
|
244
|
-
policy: z.ZodObject<{
|
|
245
|
-
routingPolicyId: z.ZodString;
|
|
246
|
-
policyVersion: z.ZodNumber;
|
|
247
|
-
}, z.core.$strict>;
|
|
248
|
-
deploymentId: z.ZodString;
|
|
249
|
-
provider: z.ZodString;
|
|
250
|
-
keyId: z.ZodString;
|
|
251
|
-
modelReference: z.ZodString;
|
|
252
|
-
upstreamModelId: z.ZodString;
|
|
253
|
-
priceVersionId: z.ZodString;
|
|
254
|
-
providerRateCardVersionId: z.ZodString;
|
|
255
|
-
providerSourceVersion: z.ZodString;
|
|
256
|
-
maxCostUsd: z.core.$ZodBranded<z.ZodString, "ExactDecimal", "out">;
|
|
257
|
-
}, z.core.$strict>>;
|
|
258
229
|
provider: z.ZodString;
|
|
259
230
|
modelReference: z.ZodString;
|
|
260
231
|
regions: z.ZodArray<z.ZodString>;
|
|
@@ -9,7 +9,6 @@ import { cataloguePublisherSummarySchema, inferenceDataPolicySchema, modelCapabi
|
|
|
9
9
|
import { inferenceDateSchema, inferenceHttpsUrlSchema, inferenceRegionSchema, inferenceTimestampSchema, modelIdSchema, modelReferenceSchema, modelRevisionLabelSchema, modelSlugSchema, publisherSlugSchema, RESERVED_ALIA_PUBLISHER, sha256DigestSchema, } from '../public/identifiers.js';
|
|
10
10
|
import { priceSnapshotSchema } from '../public/money.js';
|
|
11
11
|
import { deploymentIdSchema, inferenceProviderSlugSchema, routingProfileIdSchema, routingProfileSlugSchema, } from './identifiers.js';
|
|
12
|
-
import { scopedExecutionAudienceSchema } from './scopedExecution.js';
|
|
13
12
|
/**
|
|
14
13
|
* Who a route may be served to. Availability to an official Oxy product never
|
|
15
14
|
* implies permission to resell the same provider/model publicly, which is why
|
|
@@ -155,8 +154,6 @@ export const modelDeploymentSchema = z
|
|
|
155
154
|
/** See `version.ts`: exchanged with the data plane on its own. */
|
|
156
155
|
schemaVersion: z.literal(2),
|
|
157
156
|
deploymentId: deploymentIdSchema,
|
|
158
|
-
/** Restrictive audience; never an eligibility approval. */
|
|
159
|
-
scopedExecution: scopedExecutionAudienceSchema.optional(),
|
|
160
157
|
provider: inferenceProviderSlugSchema,
|
|
161
158
|
/** Always revision-pinned: a deployment serves specific weights. */
|
|
162
159
|
modelReference: modelReferenceSchema,
|
package/dist/internal/grant.d.ts
CHANGED
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
* executes inside the grant; without a valid grant no provider is called.
|
|
13
13
|
*
|
|
14
14
|
* The grant carries the funding model as it is today, field for field: it
|
|
15
|
-
* invents no policy. New in contract set 4.0.0; it replaces what the v1–
|
|
16
|
-
* envelopes signed (`authorizedRoutes
|
|
15
|
+
* invents no policy. New in contract set 4.0.0; it replaces what the v1–v2
|
|
16
|
+
* envelopes signed (`authorizedRoutes`). Contract set 7.0.0 removes the exact
|
|
17
|
+
* route and the canonical input hash of the one-off source approvals: every
|
|
18
|
+
* operation, decisions included, is an ordinary grant of ordered steps.
|
|
17
19
|
*/
|
|
18
20
|
import { z } from 'zod';
|
|
19
21
|
/** The signature domain of a grant. Same Ed25519 keys as the envelope (`KAANA_EDGE_PUBLIC_KEYS`). */
|
|
@@ -134,7 +136,6 @@ export declare const inferenceAuthorizationRequestSchema: z.ZodObject<{
|
|
|
134
136
|
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
135
137
|
onBehalfOfUserId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
|
|
136
138
|
bodySha256: z.ZodString;
|
|
137
|
-
canonicalInputSha256: z.ZodOptional<z.ZodString>;
|
|
138
139
|
client: z.ZodObject<{
|
|
139
140
|
endpoint: z.ZodString;
|
|
140
141
|
clientRequestId: z.ZodOptional<z.ZodString>;
|
|
@@ -214,7 +215,6 @@ export declare const authorizationRequestSchema: z.ZodDiscriminatedUnion<[z.ZodO
|
|
|
214
215
|
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
215
216
|
onBehalfOfUserId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
|
|
216
217
|
bodySha256: z.ZodString;
|
|
217
|
-
canonicalInputSha256: z.ZodOptional<z.ZodString>;
|
|
218
218
|
client: z.ZodObject<{
|
|
219
219
|
endpoint: z.ZodString;
|
|
220
220
|
clientRequestId: z.ZodOptional<z.ZodString>;
|
|
@@ -353,24 +353,6 @@ export declare const grantStepSchema: z.ZodObject<{
|
|
|
353
353
|
sameModelFailover: z.ZodDefault<z.ZodBoolean>;
|
|
354
354
|
}, z.core.$strict>;
|
|
355
355
|
}, z.core.$strict>;
|
|
356
|
-
/**
|
|
357
|
-
* The exact route of an operation with a source approval (scoped execution,
|
|
358
|
-
* Private Auto, the Mention classifier): the deployment, provider, key and
|
|
359
|
-
* price the approval fixed, and the input it was approved for.
|
|
360
|
-
*/
|
|
361
|
-
export declare const grantExactRouteSchema: z.ZodObject<{
|
|
362
|
-
approval: z.ZodEnum<{
|
|
363
|
-
scoped_execution: "scoped_execution";
|
|
364
|
-
private_auto: "private_auto";
|
|
365
|
-
mention_classifier: "mention_classifier";
|
|
366
|
-
}>;
|
|
367
|
-
deploymentId: z.ZodString;
|
|
368
|
-
provider: z.ZodString;
|
|
369
|
-
keyId: z.ZodString;
|
|
370
|
-
modelReference: z.ZodString;
|
|
371
|
-
priceVersionId: z.ZodString;
|
|
372
|
-
inputSha256: z.ZodString;
|
|
373
|
-
}, z.core.$strict>;
|
|
374
356
|
/**
|
|
375
357
|
* The signed grant: the body of a successful authorization for an inference
|
|
376
358
|
* operation. Kaana verifies it and executes inside it; Oxy settles against it.
|
|
@@ -479,19 +461,6 @@ export declare const grantSchema: z.ZodObject<{
|
|
|
479
461
|
sameModelFailover: z.ZodDefault<z.ZodBoolean>;
|
|
480
462
|
}, z.core.$strict>;
|
|
481
463
|
}, z.core.$strict>>;
|
|
482
|
-
exactRoute: z.ZodOptional<z.ZodObject<{
|
|
483
|
-
approval: z.ZodEnum<{
|
|
484
|
-
scoped_execution: "scoped_execution";
|
|
485
|
-
private_auto: "private_auto";
|
|
486
|
-
mention_classifier: "mention_classifier";
|
|
487
|
-
}>;
|
|
488
|
-
deploymentId: z.ZodString;
|
|
489
|
-
provider: z.ZodString;
|
|
490
|
-
keyId: z.ZodString;
|
|
491
|
-
modelReference: z.ZodString;
|
|
492
|
-
priceVersionId: z.ZodString;
|
|
493
|
-
inputSha256: z.ZodString;
|
|
494
|
-
}, z.core.$strict>>;
|
|
495
464
|
customerProviderCredential: z.ZodOptional<z.ZodObject<{
|
|
496
465
|
credentialHandle: z.ZodString;
|
|
497
466
|
credentialRevision: z.ZodNumber;
|
|
@@ -693,7 +662,6 @@ export type GrantPrincipal = z.infer<typeof grantPrincipalSchema>;
|
|
|
693
662
|
export type AdmittedModelLine = z.infer<typeof admittedModelLineSchema>;
|
|
694
663
|
export type GrantStepLimits = z.infer<typeof grantStepLimitsSchema>;
|
|
695
664
|
export type GrantStep = z.infer<typeof grantStepSchema>;
|
|
696
|
-
export type GrantExactRoute = z.infer<typeof grantExactRouteSchema>;
|
|
697
665
|
export type Grant = z.infer<typeof grantSchema>;
|
|
698
666
|
export type CatalogueAccess = z.infer<typeof catalogueAccessSchema>;
|
|
699
667
|
export type ReceiptAccess = z.infer<typeof receiptAccessSchema>;
|
package/dist/internal/grant.js
CHANGED
|
@@ -12,19 +12,21 @@
|
|
|
12
12
|
* executes inside the grant; without a valid grant no provider is called.
|
|
13
13
|
*
|
|
14
14
|
* The grant carries the funding model as it is today, field for field: it
|
|
15
|
-
* invents no policy. New in contract set 4.0.0; it replaces what the v1–
|
|
16
|
-
* envelopes signed (`authorizedRoutes
|
|
15
|
+
* invents no policy. New in contract set 4.0.0; it replaces what the v1–v2
|
|
16
|
+
* envelopes signed (`authorizedRoutes`). Contract set 7.0.0 removes the exact
|
|
17
|
+
* route and the canonical input hash of the one-off source approvals: every
|
|
18
|
+
* operation, decisions included, is an ordinary grant of ordered steps.
|
|
17
19
|
*/
|
|
18
20
|
import { z } from 'zod';
|
|
19
21
|
import { powerLevelSchema, realtimeSessionKindSchema } from '../public/catalogue.js';
|
|
20
22
|
import { generationRecordSchema } from '../public/generations.js';
|
|
21
|
-
import { delegatedUserIdSchema, generationIdSchema, idempotencyKeySchema, inferenceEnvironmentSchema, inferenceRegionSchema, inferenceTimestampSchema, modelIdSchema,
|
|
23
|
+
import { delegatedUserIdSchema, generationIdSchema, idempotencyKeySchema, inferenceEnvironmentSchema, inferenceRegionSchema, inferenceTimestampSchema, modelIdSchema, modelRevisionLabelSchema, oxyApplicationIdSchema, oxyCredentialIdSchema, requestIdSchema, } from '../public/identifiers.js';
|
|
22
24
|
import { requestLabelsSchema } from '../public/messages.js';
|
|
23
25
|
import { moneySchema } from '../public/money.js';
|
|
24
26
|
import { routingPolicyReferenceSchema } from '../public/policy.js';
|
|
25
27
|
import { inferenceScopeSchema } from './attribution.js';
|
|
26
28
|
import { inferenceEconomicTreatmentSchema } from './economics.js';
|
|
27
|
-
import {
|
|
29
|
+
import { inferenceFundingTierSchema, inferenceProviderSlugSchema, oxyAccountIdSchema, } from './identifiers.js';
|
|
28
30
|
import { authorizedRouteSchema } from './routing.js';
|
|
29
31
|
/* -------------------------------------------------------------------------- */
|
|
30
32
|
/* Signing */
|
|
@@ -132,12 +134,6 @@ export const inferenceAuthorizationRequestSchema = z
|
|
|
132
134
|
onBehalfOfUserId: delegatedUserIdSchema.optional(),
|
|
133
135
|
/** SHA-256 of the normalized request body; the grant is bound to it. */
|
|
134
136
|
bodySha256: sha256HexSchema,
|
|
135
|
-
/**
|
|
136
|
-
* For an operation under a source approval (scoped execution, Private Auto,
|
|
137
|
-
* the Jev classifier): `canonicalInputSha256(input)`, which Oxy compares
|
|
138
|
-
* with the hash the approval fixed.
|
|
139
|
-
*/
|
|
140
|
-
canonicalInputSha256: sha256HexSchema.optional(),
|
|
141
137
|
client: z
|
|
142
138
|
.object({
|
|
143
139
|
/** The public path, e.g. `/v1/responses`. */
|
|
@@ -299,34 +295,6 @@ export const grantStepSchema = z
|
|
|
299
295
|
});
|
|
300
296
|
}
|
|
301
297
|
});
|
|
302
|
-
/**
|
|
303
|
-
* The exact route of an operation with a source approval (scoped execution,
|
|
304
|
-
* Private Auto, the Mention classifier): the deployment, provider, key and
|
|
305
|
-
* price the approval fixed, and the input it was approved for.
|
|
306
|
-
*/
|
|
307
|
-
export const grantExactRouteSchema = z
|
|
308
|
-
.object({
|
|
309
|
-
approval: z.enum(['scoped_execution', 'private_auto', 'mention_classifier']),
|
|
310
|
-
deploymentId: deploymentIdSchema,
|
|
311
|
-
provider: inferenceProviderSlugSchema,
|
|
312
|
-
/** The provider key the approval fixed (opaque Kaana key identity). */
|
|
313
|
-
keyId: z.string().min(1).max(256),
|
|
314
|
-
/** Always revision-pinned. */
|
|
315
|
-
modelReference: modelReferenceSchema,
|
|
316
|
-
priceVersionId: z.string().min(1).max(128),
|
|
317
|
-
/** `canonicalInputSha256` of the approved input. */
|
|
318
|
-
inputSha256: sha256HexSchema,
|
|
319
|
-
})
|
|
320
|
-
.strict()
|
|
321
|
-
.superRefine((route, ctx) => {
|
|
322
|
-
if (!route.modelReference.includes('@')) {
|
|
323
|
-
ctx.addIssue({
|
|
324
|
-
code: 'custom',
|
|
325
|
-
path: ['modelReference'],
|
|
326
|
-
message: 'an exact route pins an immutable revision',
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
298
|
/** The BYOK binding, exactly as an authorized route carries it today. */
|
|
331
299
|
const customerProviderCredentialBinding = authorizedRouteSchema.options[0].shape.customerProviderCredential;
|
|
332
300
|
/**
|
|
@@ -360,7 +328,7 @@ export const grantSchema = z
|
|
|
360
328
|
reservationId: z.string().min(1).max(128),
|
|
361
329
|
/** The most the hold covers. Shown, never spent by Kaana. */
|
|
362
330
|
ceiling: moneySchema,
|
|
363
|
-
/** `promotional-only
|
|
331
|
+
/** `promotional-only`: the hold draws on promotional credit alone. */
|
|
364
332
|
fundingRestriction: z.literal('promotional-only').optional(),
|
|
365
333
|
})
|
|
366
334
|
.strict()
|
|
@@ -371,7 +339,6 @@ export const grantSchema = z
|
|
|
371
339
|
.strict()
|
|
372
340
|
.optional(),
|
|
373
341
|
steps: z.array(grantStepSchema).min(1).max(8),
|
|
374
|
-
exactRoute: grantExactRouteSchema.optional(),
|
|
375
342
|
/** BYOK: the customer's own provider key. Excludes `maxFundingTier`. */
|
|
376
343
|
customerProviderCredential: customerProviderCredentialBinding,
|
|
377
344
|
idempotencyKey: idempotencyKeySchema.optional(),
|
|
@@ -403,22 +370,6 @@ export const grantSchema = z
|
|
|
403
370
|
issue(['steps', index, 'limits', 'maxFundingTier'], 'a funding ceiling bounds platform keys; a customer credential is billed to the customer');
|
|
404
371
|
}
|
|
405
372
|
}
|
|
406
|
-
if (grant.exactRoute !== undefined) {
|
|
407
|
-
const [step] = grant.steps;
|
|
408
|
-
const route = grant.exactRoute;
|
|
409
|
-
const [line, revision] = route.modelReference.split('@');
|
|
410
|
-
if (grant.steps.length !== 1 ||
|
|
411
|
-
step.target.kind !== 'model' ||
|
|
412
|
-
step.target.modelLine !== line ||
|
|
413
|
-
step.target.revision !== revision ||
|
|
414
|
-
byok) {
|
|
415
|
-
issue(['exactRoute'], 'an exact route is one platform route for the one pinned model the grant serves');
|
|
416
|
-
}
|
|
417
|
-
if (step !== undefined &&
|
|
418
|
-
!step.limits.admittedModelLines.some((admitted) => admitted.modelLine === line && admitted.priceVersionId === route.priceVersionId)) {
|
|
419
|
-
issue(['exactRoute', 'priceVersionId'], 'the exact route settles at its admitted price');
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
373
|
});
|
|
423
374
|
/**
|
|
424
375
|
* The answer to a catalogue authorization: what the credential may see.
|