@kaana.ai/contracts 7.0.0 → 8.0.1
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 -4
- package/dist/internal/catalogue.js +18 -18
- package/dist/internal/credentialControl.js +4 -3
- package/dist/internal/decisions.d.ts +30 -4
- package/dist/internal/embeddings.js +4 -3
- package/dist/internal/errors.js +3 -2
- package/dist/internal/grant.d.ts +36 -9
- package/dist/internal/grant.js +34 -15
- package/dist/internal/identifiers.js +13 -5
- package/dist/internal/realtime.d.ts +15 -2
- package/dist/internal/realtime.js +4 -3
- package/dist/internal/request.d.ts +15 -2
- package/dist/internal/request.js +4 -3
- package/dist/internal/routing.js +2 -1
- package/dist/internal/settlement.d.ts +30 -4
- package/dist/internal/settlement.js +7 -6
- package/dist/internal/usage.d.ts +15 -2
- package/dist/public/audio.js +12 -7
- package/dist/public/audioFormats.js +2 -1
- package/dist/public/catalogue.js +18 -13
- package/dist/public/chatCompletions.js +26 -23
- package/dist/public/decisions.js +4 -3
- package/dist/public/embeddings.js +7 -3
- package/dist/public/errors.js +4 -3
- package/dist/public/generations.js +5 -4
- package/dist/public/identifiers.js +20 -14
- package/dist/public/images.js +8 -7
- package/dist/public/messages.js +31 -17
- package/dist/public/money.js +2 -1
- package/dist/public/policy.js +2 -1
- package/dist/public/realtime.js +30 -20
- package/dist/public/responses.js +10 -3
- package/dist/public/streamEvents.js +9 -4
- package/dist/public/version.d.ts +1 -1
- package/dist/public/version.js +1 -1
- package/dist/stringBounds.d.ts +11 -0
- package/dist/stringBounds.js +61 -0
- package/dist/timestampCheck.d.ts +3 -0
- package/dist/timestampCheck.js +18 -0
- package/openapi.json +7 -15
- package/package.json +3 -4
|
@@ -4,15 +4,7 @@
|
|
|
4
4
|
* Moved from `@oxy.so/contracts` 4.12.0 (`src/inference/attribution.ts`) by Kaana ADR 0002.
|
|
5
5
|
*/
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
/**
|
|
8
|
-
* The inference capability scopes the data plane needs to know about.
|
|
9
|
-
*
|
|
10
|
-
* A credential may carry many other Oxy scopes; only these cross the boundary,
|
|
11
|
-
* because the data plane's authorization questions are exactly "may this caller
|
|
12
|
-
* invoke", "may it read the catalogue", "may it read usage", "may it read or
|
|
13
|
-
* write routing", "may it read or write provider connections". Everything else
|
|
14
|
-
* is the control plane's business and is not the data plane's to hold.
|
|
15
|
-
*/
|
|
7
|
+
/** External caller limits recorded by Oxy. First-party instructions carry no scopes. */
|
|
16
8
|
export declare const INFERENCE_SCOPES: readonly ["inference:invoke", "inference:models:read", "inference:usage:read", "inference:routing:read", "inference:routing:write", "inference:providers:read", "inference:providers:write"];
|
|
17
9
|
export declare const inferenceScopeSchema: z.ZodEnum<{
|
|
18
10
|
"inference:invoke": "inference:invoke";
|
|
@@ -35,17 +27,9 @@ export declare const inferenceScopeSchema: z.ZodEnum<{
|
|
|
35
27
|
export declare const billingPrincipalSchema: z.ZodObject<{
|
|
36
28
|
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
37
29
|
}, z.core.$strict>;
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* Mirrors what a verified Oxy service token carries (`appId`, `credentialId`,
|
|
42
|
-
* `ownerAccountId`, `environment`, effective scopes) so that the two
|
|
43
|
-
* authentication paths — a machine API key and a first-party service token —
|
|
44
|
-
* produce one shape downstream. The data plane authorizes against this
|
|
45
|
-
* envelope; it does not re-derive access from its own database, because it has
|
|
46
|
-
* no account graph to re-derive it from.
|
|
47
|
-
*/
|
|
48
|
-
export declare const authenticatedPrincipalSchema: z.ZodObject<{
|
|
30
|
+
/** Oxy has authorized this instruction; the discriminator never grants customer access in Kaana. */
|
|
31
|
+
export declare const authenticatedPrincipalSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
32
|
+
authority: z.ZodLiteral<"first_party">;
|
|
49
33
|
billing: z.ZodObject<{
|
|
50
34
|
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
51
35
|
}, z.core.$strict>;
|
|
@@ -56,6 +40,8 @@ export declare const authenticatedPrincipalSchema: z.ZodObject<{
|
|
|
56
40
|
staging: "staging";
|
|
57
41
|
production: "production";
|
|
58
42
|
}>;
|
|
43
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
44
|
+
authority: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
59
45
|
inferenceScopes: z.ZodArray<z.ZodEnum<{
|
|
60
46
|
"inference:invoke": "inference:invoke";
|
|
61
47
|
"inference:models:read": "inference:models:read";
|
|
@@ -65,7 +51,17 @@ export declare const authenticatedPrincipalSchema: z.ZodObject<{
|
|
|
65
51
|
"inference:providers:read": "inference:providers:read";
|
|
66
52
|
"inference:providers:write": "inference:providers:write";
|
|
67
53
|
}>>;
|
|
68
|
-
|
|
54
|
+
billing: z.ZodObject<{
|
|
55
|
+
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
applicationId: z.ZodString;
|
|
58
|
+
credentialId: z.ZodString;
|
|
59
|
+
environment: z.ZodEnum<{
|
|
60
|
+
development: "development";
|
|
61
|
+
staging: "staging";
|
|
62
|
+
production: "production";
|
|
63
|
+
}>;
|
|
64
|
+
}, z.core.$strict>], "authority">;
|
|
69
65
|
/**
|
|
70
66
|
* The attribution block carried by every request, receipt and ledger record.
|
|
71
67
|
*
|
|
@@ -85,7 +81,8 @@ export declare const authenticatedPrincipalSchema: z.ZodObject<{
|
|
|
85
81
|
* because only the data plane knows how many outputs a request produced.
|
|
86
82
|
*/
|
|
87
83
|
export declare const inferenceAttributionSchema: z.ZodObject<{
|
|
88
|
-
principal: z.ZodObject<{
|
|
84
|
+
principal: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
85
|
+
authority: z.ZodLiteral<"first_party">;
|
|
89
86
|
billing: z.ZodObject<{
|
|
90
87
|
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
91
88
|
}, z.core.$strict>;
|
|
@@ -96,6 +93,8 @@ export declare const inferenceAttributionSchema: z.ZodObject<{
|
|
|
96
93
|
staging: "staging";
|
|
97
94
|
production: "production";
|
|
98
95
|
}>;
|
|
96
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
97
|
+
authority: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
99
98
|
inferenceScopes: z.ZodArray<z.ZodEnum<{
|
|
100
99
|
"inference:invoke": "inference:invoke";
|
|
101
100
|
"inference:models:read": "inference:models:read";
|
|
@@ -105,7 +104,17 @@ export declare const inferenceAttributionSchema: z.ZodObject<{
|
|
|
105
104
|
"inference:providers:read": "inference:providers:read";
|
|
106
105
|
"inference:providers:write": "inference:providers:write";
|
|
107
106
|
}>>;
|
|
108
|
-
|
|
107
|
+
billing: z.ZodObject<{
|
|
108
|
+
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
applicationId: z.ZodString;
|
|
111
|
+
credentialId: z.ZodString;
|
|
112
|
+
environment: z.ZodEnum<{
|
|
113
|
+
development: "development";
|
|
114
|
+
staging: "staging";
|
|
115
|
+
production: "production";
|
|
116
|
+
}>;
|
|
117
|
+
}, z.core.$strict>], "authority">;
|
|
109
118
|
userId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
|
|
110
119
|
requestId: z.ZodString;
|
|
111
120
|
generationId: z.ZodOptional<z.ZodString>;
|
|
@@ -6,15 +6,7 @@
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import { delegatedUserIdSchema, generationIdSchema, inferenceEnvironmentSchema, oxyApplicationIdSchema, oxyCredentialIdSchema, requestIdSchema, } from '../public/identifiers.js';
|
|
8
8
|
import { oxyAccountIdSchema } from './identifiers.js';
|
|
9
|
-
/**
|
|
10
|
-
* The inference capability scopes the data plane needs to know about.
|
|
11
|
-
*
|
|
12
|
-
* A credential may carry many other Oxy scopes; only these cross the boundary,
|
|
13
|
-
* because the data plane's authorization questions are exactly "may this caller
|
|
14
|
-
* invoke", "may it read the catalogue", "may it read usage", "may it read or
|
|
15
|
-
* write routing", "may it read or write provider connections". Everything else
|
|
16
|
-
* is the control plane's business and is not the data plane's to hold.
|
|
17
|
-
*/
|
|
9
|
+
/** External caller limits recorded by Oxy. First-party instructions carry no scopes. */
|
|
18
10
|
export const INFERENCE_SCOPES = [
|
|
19
11
|
'inference:invoke',
|
|
20
12
|
'inference:models:read',
|
|
@@ -49,13 +41,23 @@ export const billingPrincipalSchema = z
|
|
|
49
41
|
* envelope; it does not re-derive access from its own database, because it has
|
|
50
42
|
* no account graph to re-derive it from.
|
|
51
43
|
*/
|
|
52
|
-
|
|
44
|
+
const principalIdentity = {
|
|
53
45
|
billing: billingPrincipalSchema,
|
|
54
46
|
applicationId: oxyApplicationIdSchema,
|
|
55
47
|
credentialId: oxyCredentialIdSchema,
|
|
56
48
|
environment: inferenceEnvironmentSchema,
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
};
|
|
50
|
+
/** Oxy has authorized this instruction; the discriminator never grants customer access in Kaana. */
|
|
51
|
+
export const authenticatedPrincipalSchema = z.discriminatedUnion('authority', [
|
|
52
|
+
z.object({ ...principalIdentity, authority: z.literal('first_party') }).strict(),
|
|
53
|
+
z
|
|
54
|
+
.object({
|
|
55
|
+
...principalIdentity,
|
|
56
|
+
authority: z.literal('external').optional(),
|
|
57
|
+
inferenceScopes: z.array(inferenceScopeSchema),
|
|
58
|
+
})
|
|
59
|
+
.strict(),
|
|
60
|
+
]);
|
|
59
61
|
/**
|
|
60
62
|
* The attribution block carried by every request, receipt and ledger record.
|
|
61
63
|
*
|
|
@@ -262,10 +262,9 @@ export declare const modelDeploymentSchema: z.ZodObject<{
|
|
|
262
262
|
}, z.core.$strip>;
|
|
263
263
|
/**
|
|
264
264
|
* The commercial facts Kaana publishes about ONE deployment on the descriptors
|
|
265
|
-
* it serves to Oxy (`POST /internal/v1/deployments/query`
|
|
266
|
-
*
|
|
267
|
-
* `
|
|
268
|
-
* no `commercial` at all, which is why the member is optional on the
|
|
265
|
+
* it serves to Oxy (`POST /internal/v1/deployments/query`), from the reviewed
|
|
266
|
+
* file `configs/deployment-commercial.json`. A deployment that is not sold
|
|
267
|
+
* carries no `commercial` at all, which is why the member is optional on the
|
|
269
268
|
* descriptor. New in contract set 4.4.0.
|
|
270
269
|
*
|
|
271
270
|
* `customer_byok` is the commercial basis of a `byok_only` route and of no
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Moved from `@oxy.so/contracts` 4.12.0 (`src/inference/catalogue.ts`) by Kaana ADR 0002.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
import { maxUtf16Length, minUtf16Length } from '../stringBounds.js';
|
|
8
9
|
import { cataloguePublisherSummarySchema, inferenceDataPolicySchema, modelCapabilitiesSchema, modelDeprecationSchema, modelEvaluationResultSchema, modelLicenseSchema, modelPowerClassSchema, modelProvenanceSchema, modelSafetyMetadataSchema, modelSchema, powerLevelSchema, reasoningEffortSchema, } from '../public/catalogue.js';
|
|
9
10
|
import { inferenceDateSchema, inferenceHttpsUrlSchema, inferenceRegionSchema, inferenceTimestampSchema, modelIdSchema, modelReferenceSchema, modelRevisionLabelSchema, modelSlugSchema, publisherSlugSchema, RESERVED_ALIA_PUBLISHER, sha256DigestSchema, } from '../public/identifiers.js';
|
|
10
11
|
import { priceSnapshotSchema } from '../public/money.js';
|
|
@@ -34,10 +35,10 @@ export const commercialPermissionSchema = z.enum([
|
|
|
34
35
|
export const modelPublisherSchema = z.object({
|
|
35
36
|
/** See `version.ts`: served on its own by the catalogue, so it is versioned. */
|
|
36
37
|
schemaVersion: z.literal(1),
|
|
37
|
-
publisherId: z.string().
|
|
38
|
+
publisherId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)),
|
|
38
39
|
slug: publisherSlugSchema,
|
|
39
|
-
displayName: z.string().
|
|
40
|
-
description: z.string().
|
|
40
|
+
displayName: z.string().check(minUtf16Length(1)).check(maxUtf16Length(200)),
|
|
41
|
+
description: z.string().check(maxUtf16Length(2000)).optional(),
|
|
41
42
|
websiteUrl: inferenceHttpsUrlSchema.optional(),
|
|
42
43
|
});
|
|
43
44
|
/**
|
|
@@ -54,8 +55,8 @@ export const catalogueModelSchema = z
|
|
|
54
55
|
modelId: modelIdSchema,
|
|
55
56
|
publisher: publisherSlugSchema,
|
|
56
57
|
slug: modelSlugSchema,
|
|
57
|
-
displayName: z.string().
|
|
58
|
-
description: z.string().
|
|
58
|
+
displayName: z.string().check(minUtf16Length(1)).check(maxUtf16Length(200)),
|
|
59
|
+
description: z.string().check(maxUtf16Length(4000)).optional(),
|
|
59
60
|
capabilities: modelCapabilitiesSchema,
|
|
60
61
|
license: modelLicenseSchema,
|
|
61
62
|
provenance: modelProvenanceSchema,
|
|
@@ -98,7 +99,7 @@ export const modelRevisionSchema = z
|
|
|
98
99
|
.object({
|
|
99
100
|
/** See `version.ts`: served on its own by the catalogue, so it is versioned. */
|
|
100
101
|
schemaVersion: z.literal(1),
|
|
101
|
-
revisionId: z.string().
|
|
102
|
+
revisionId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)),
|
|
102
103
|
modelId: modelIdSchema,
|
|
103
104
|
revision: modelRevisionLabelSchema,
|
|
104
105
|
reference: modelReferenceSchema,
|
|
@@ -123,9 +124,9 @@ export const modelRevisionSchema = z
|
|
|
123
124
|
export const inferenceProviderSchema = z.object({
|
|
124
125
|
/** See `version.ts`: served on its own by the catalogue, so it is versioned. */
|
|
125
126
|
schemaVersion: z.literal(1),
|
|
126
|
-
providerId: z.string().
|
|
127
|
+
providerId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)),
|
|
127
128
|
slug: inferenceProviderSlugSchema,
|
|
128
|
-
displayName: z.string().
|
|
129
|
+
displayName: z.string().check(minUtf16Length(1)).check(maxUtf16Length(200)),
|
|
129
130
|
/**
|
|
130
131
|
* `customer_byok` means the customer's own upstream account is billed
|
|
131
132
|
* directly by the provider and Oxy charges only its platform fee.
|
|
@@ -165,7 +166,7 @@ export const modelDeploymentSchema = z
|
|
|
165
166
|
/** Reserved capacity for one enterprise account rather than shared. */
|
|
166
167
|
dedicatedCapacity: z.boolean(),
|
|
167
168
|
/** The price version customers are charged under on this route. */
|
|
168
|
-
priceVersionId: z.string().
|
|
169
|
+
priceVersionId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)).optional(),
|
|
169
170
|
})
|
|
170
171
|
.superRefine((deployment, ctx) => {
|
|
171
172
|
if (!deployment.modelReference.includes('@')) {
|
|
@@ -210,10 +211,9 @@ export const modelDeploymentSchema = z
|
|
|
210
211
|
});
|
|
211
212
|
/**
|
|
212
213
|
* The commercial facts Kaana publishes about ONE deployment on the descriptors
|
|
213
|
-
* it serves to Oxy (`POST /internal/v1/deployments/query`
|
|
214
|
-
*
|
|
215
|
-
* `
|
|
216
|
-
* no `commercial` at all, which is why the member is optional on the
|
|
214
|
+
* it serves to Oxy (`POST /internal/v1/deployments/query`), from the reviewed
|
|
215
|
+
* file `configs/deployment-commercial.json`. A deployment that is not sold
|
|
216
|
+
* carries no `commercial` at all, which is why the member is optional on the
|
|
217
217
|
* descriptor. New in contract set 4.4.0.
|
|
218
218
|
*
|
|
219
219
|
* `customer_byok` is the commercial basis of a `byok_only` route and of no
|
|
@@ -269,8 +269,8 @@ export const routingProfileSchema = z.object({
|
|
|
269
269
|
schemaVersion: z.literal(1),
|
|
270
270
|
routingProfileId: routingProfileIdSchema,
|
|
271
271
|
slug: routingProfileSlugSchema,
|
|
272
|
-
displayName: z.string().
|
|
273
|
-
description: z.string().
|
|
272
|
+
displayName: z.string().check(minUtf16Length(1)).check(maxUtf16Length(200)),
|
|
273
|
+
description: z.string().check(maxUtf16Length(2000)).optional(),
|
|
274
274
|
/** What the profile optimises for when several candidates qualify. */
|
|
275
275
|
optimiseFor: z.enum(['price', 'latency', 'throughput', 'quality', 'balanced']),
|
|
276
276
|
candidates: z.array(routingProfileCandidateSchema).min(1),
|
|
@@ -301,7 +301,7 @@ export const routingProfileSchema = z.object({
|
|
|
301
301
|
export const catalogueServingProviderSummarySchema = z
|
|
302
302
|
.object({
|
|
303
303
|
slug: inferenceProviderSlugSchema,
|
|
304
|
-
displayName: z.string().
|
|
304
|
+
displayName: z.string().check(minUtf16Length(1)).check(maxUtf16Length(200)),
|
|
305
305
|
regions: z.array(inferenceRegionSchema).default([]),
|
|
306
306
|
dataPolicy: inferenceDataPolicySchema,
|
|
307
307
|
})
|
|
@@ -318,8 +318,8 @@ export const modelCatalogueEntrySchema = z.object({
|
|
|
318
318
|
schemaVersion: z.literal(3),
|
|
319
319
|
modelId: modelIdSchema,
|
|
320
320
|
publisher: cataloguePublisherSummarySchema,
|
|
321
|
-
displayName: z.string().
|
|
322
|
-
description: z.string().
|
|
321
|
+
displayName: z.string().check(minUtf16Length(1)).check(maxUtf16Length(200)),
|
|
322
|
+
description: z.string().check(maxUtf16Length(4000)).optional(),
|
|
323
323
|
currentRevision: modelRevisionLabelSchema,
|
|
324
324
|
/** Revisions a customer may pin today, newest first. */
|
|
325
325
|
availableRevisions: z.array(modelRevisionLabelSchema).min(1),
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* validation and custody metadata) stay in `@oxy.so/contracts`.
|
|
7
7
|
*/
|
|
8
8
|
import { z } from 'zod';
|
|
9
|
+
import { maxUtf16Length, minUtf16Length } from '../stringBounds.js';
|
|
9
10
|
import { inferenceEnvironmentSchema, oxyApplicationIdSchema, PADDED_BASE64_PATTERN, } from '../public/identifiers.js';
|
|
10
11
|
import { deploymentIdSchema, inferenceProviderSlugSchema } from './identifiers.js';
|
|
11
12
|
/** Opaque reference minted by Kaana. It is not a KMS/Vault/SSM locator. */
|
|
@@ -28,7 +29,7 @@ export const kaanaCredentialIdentitySchema = z
|
|
|
28
29
|
.strict();
|
|
29
30
|
const kaanaCredentialOperationActorSchema = z
|
|
30
31
|
.string()
|
|
31
|
-
.
|
|
32
|
+
.check(minUtf16Length(1))
|
|
32
33
|
.refine((value) => new TextEncoder().encode(value).byteLength <= 256 &&
|
|
33
34
|
value === value.trim() &&
|
|
34
35
|
!/[\r\n]/.test(value), {
|
|
@@ -70,8 +71,8 @@ function isVisibleASCIIProviderCredential(value) {
|
|
|
70
71
|
}
|
|
71
72
|
const kaanaCredentialSecretBase64Schema = z
|
|
72
73
|
.string()
|
|
73
|
-
.
|
|
74
|
-
.
|
|
74
|
+
.check(minUtf16Length(1))
|
|
75
|
+
.check(maxUtf16Length(8192))
|
|
75
76
|
.regex(PADDED_BASE64_PATTERN)
|
|
76
77
|
.refine(isVisibleASCIIProviderCredential, {
|
|
77
78
|
message: 'a decoded provider credential is 1-4096 visible ASCII bytes',
|
|
@@ -10,7 +10,8 @@ export declare const decisionResultSchema: z.ZodObject<{
|
|
|
10
10
|
requestId: z.ZodString;
|
|
11
11
|
generationId: z.ZodOptional<z.ZodString>;
|
|
12
12
|
attribution: z.ZodObject<{
|
|
13
|
-
principal: z.ZodObject<{
|
|
13
|
+
principal: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
14
|
+
authority: z.ZodLiteral<"first_party">;
|
|
14
15
|
billing: z.ZodObject<{
|
|
15
16
|
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
16
17
|
}, z.core.$strict>;
|
|
@@ -21,6 +22,8 @@ export declare const decisionResultSchema: z.ZodObject<{
|
|
|
21
22
|
staging: "staging";
|
|
22
23
|
production: "production";
|
|
23
24
|
}>;
|
|
25
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
26
|
+
authority: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
24
27
|
inferenceScopes: z.ZodArray<z.ZodEnum<{
|
|
25
28
|
"inference:invoke": "inference:invoke";
|
|
26
29
|
"inference:models:read": "inference:models:read";
|
|
@@ -30,7 +33,17 @@ export declare const decisionResultSchema: z.ZodObject<{
|
|
|
30
33
|
"inference:providers:read": "inference:providers:read";
|
|
31
34
|
"inference:providers:write": "inference:providers:write";
|
|
32
35
|
}>>;
|
|
33
|
-
|
|
36
|
+
billing: z.ZodObject<{
|
|
37
|
+
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
38
|
+
}, z.core.$strict>;
|
|
39
|
+
applicationId: z.ZodString;
|
|
40
|
+
credentialId: z.ZodString;
|
|
41
|
+
environment: z.ZodEnum<{
|
|
42
|
+
development: "development";
|
|
43
|
+
staging: "staging";
|
|
44
|
+
production: "production";
|
|
45
|
+
}>;
|
|
46
|
+
}, z.core.$strict>], "authority">;
|
|
34
47
|
userId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
|
|
35
48
|
requestId: z.ZodString;
|
|
36
49
|
generationId: z.ZodOptional<z.ZodString>;
|
|
@@ -170,7 +183,8 @@ export declare const decisionFailureSchema: z.ZodObject<{
|
|
|
170
183
|
requestId: z.ZodString;
|
|
171
184
|
generationId: z.ZodOptional<z.ZodString>;
|
|
172
185
|
attribution: z.ZodObject<{
|
|
173
|
-
principal: z.ZodObject<{
|
|
186
|
+
principal: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
187
|
+
authority: z.ZodLiteral<"first_party">;
|
|
174
188
|
billing: z.ZodObject<{
|
|
175
189
|
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
176
190
|
}, z.core.$strict>;
|
|
@@ -181,6 +195,8 @@ export declare const decisionFailureSchema: z.ZodObject<{
|
|
|
181
195
|
staging: "staging";
|
|
182
196
|
production: "production";
|
|
183
197
|
}>;
|
|
198
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
199
|
+
authority: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
184
200
|
inferenceScopes: z.ZodArray<z.ZodEnum<{
|
|
185
201
|
"inference:invoke": "inference:invoke";
|
|
186
202
|
"inference:models:read": "inference:models:read";
|
|
@@ -190,7 +206,17 @@ export declare const decisionFailureSchema: z.ZodObject<{
|
|
|
190
206
|
"inference:providers:read": "inference:providers:read";
|
|
191
207
|
"inference:providers:write": "inference:providers:write";
|
|
192
208
|
}>>;
|
|
193
|
-
|
|
209
|
+
billing: z.ZodObject<{
|
|
210
|
+
accountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
211
|
+
}, z.core.$strict>;
|
|
212
|
+
applicationId: z.ZodString;
|
|
213
|
+
credentialId: z.ZodString;
|
|
214
|
+
environment: z.ZodEnum<{
|
|
215
|
+
development: "development";
|
|
216
|
+
staging: "staging";
|
|
217
|
+
production: "production";
|
|
218
|
+
}>;
|
|
219
|
+
}, z.core.$strict>], "authority">;
|
|
194
220
|
userId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
|
|
195
221
|
requestId: z.ZodString;
|
|
196
222
|
generationId: z.ZodOptional<z.ZodString>;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Moved from `@oxy.so/contracts` 4.12.0 (`src/inference/embeddings.ts`) by Kaana ADR 0002.
|
|
5
5
|
*/
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
+
import { maxUtf16Length, minUtf16Length } from '../stringBounds.js';
|
|
7
8
|
import { inferenceErrorSchema } from './errors.js';
|
|
8
9
|
export const embeddingVectorSchema = z
|
|
9
10
|
.object({
|
|
@@ -24,8 +25,8 @@ export const embeddingUsageSchema = z
|
|
|
24
25
|
export const embeddingSuccessSchema = z
|
|
25
26
|
.object({
|
|
26
27
|
schemaVersion: z.literal(1),
|
|
27
|
-
requestId: z.string().
|
|
28
|
-
model: z.string().
|
|
28
|
+
requestId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)),
|
|
29
|
+
model: z.string().check(minUtf16Length(1)).check(maxUtf16Length(255)),
|
|
29
30
|
dimension: z.number().int().positive().max(1024),
|
|
30
31
|
data: z.array(embeddingVectorSchema).min(1).max(2048),
|
|
31
32
|
usage: embeddingUsageSchema,
|
|
@@ -52,7 +53,7 @@ export const embeddingSuccessSchema = z
|
|
|
52
53
|
export const embeddingFailureSchema = z
|
|
53
54
|
.object({
|
|
54
55
|
schemaVersion: z.literal(1),
|
|
55
|
-
requestId: z.string().
|
|
56
|
+
requestId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)),
|
|
56
57
|
error: inferenceErrorSchema,
|
|
57
58
|
})
|
|
58
59
|
.strict();
|
package/dist/internal/errors.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Moved from `@oxy.so/contracts` 4.12.0 (`src/inference/errors.ts`) by Kaana ADR 0002.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
import { maxUtf16Length } from '../stringBounds.js';
|
|
8
9
|
import { publicErrorSchema, safeErrorTextSchema, upstreamErrorCategorySchema, } from '../public/errors.js';
|
|
9
10
|
import { requestIdSchema } from '../public/identifiers.js';
|
|
10
11
|
import { inferenceProviderSlugSchema } from './identifiers.js';
|
|
@@ -120,7 +121,7 @@ export const providerErrorPassthroughSchema = z
|
|
|
120
121
|
/** The upstream HTTP status, when the upstream spoke HTTP. */
|
|
121
122
|
status: z.number().int().min(100).max(599).optional(),
|
|
122
123
|
/** The upstream's own error code, verbatim and uninterpreted. */
|
|
123
|
-
code: z.string().
|
|
124
|
+
code: z.string().check(maxUtf16Length(128)).optional(),
|
|
124
125
|
/** The upstream's message, subject to the same credential refusal. */
|
|
125
126
|
message: safeErrorTextSchema.optional(),
|
|
126
127
|
})
|
|
@@ -143,7 +144,7 @@ export const inferenceErrorSchema = z
|
|
|
143
144
|
/** How long to wait before retrying. Only meaningful when `retryable`. */
|
|
144
145
|
retryAfterMs: z.number().int().nonnegative().safe().optional(),
|
|
145
146
|
/** The request field at fault, for `invalid_request`. */
|
|
146
|
-
param: z.string().
|
|
147
|
+
param: z.string().check(maxUtf16Length(128)).optional(),
|
|
147
148
|
/** Present only when an upstream provider was reached and failed. */
|
|
148
149
|
upstreamCategory: upstreamErrorCategorySchema.optional(),
|
|
149
150
|
providerError: providerErrorPassthroughSchema.optional(),
|
package/dist/internal/grant.d.ts
CHANGED
|
@@ -241,12 +241,8 @@ export declare const grantLaneSchema: z.ZodEnum<{
|
|
|
241
241
|
service_token: "service_token";
|
|
242
242
|
product_session: "product_session";
|
|
243
243
|
}>;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
* authenticated application, UNRESOLVED: the ledger resolves the billable
|
|
247
|
-
* ancestor. The end user never pays.
|
|
248
|
-
*/
|
|
249
|
-
export declare const grantPrincipalSchema: z.ZodObject<{
|
|
244
|
+
export declare const grantPrincipalSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
245
|
+
authority: z.ZodLiteral<"first_party">;
|
|
250
246
|
billingAccountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
251
247
|
applicationId: z.ZodString;
|
|
252
248
|
credentialId: z.ZodString;
|
|
@@ -255,6 +251,13 @@ export declare const grantPrincipalSchema: z.ZodObject<{
|
|
|
255
251
|
staging: "staging";
|
|
256
252
|
production: "production";
|
|
257
253
|
}>;
|
|
254
|
+
lane: z.ZodEnum<{
|
|
255
|
+
machine_credential: "machine_credential";
|
|
256
|
+
service_token: "service_token";
|
|
257
|
+
product_session: "product_session";
|
|
258
|
+
}>;
|
|
259
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
260
|
+
authority: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
258
261
|
scopes: z.ZodArray<z.ZodEnum<{
|
|
259
262
|
"inference:invoke": "inference:invoke";
|
|
260
263
|
"inference:models:read": "inference:models:read";
|
|
@@ -264,12 +267,20 @@ export declare const grantPrincipalSchema: z.ZodObject<{
|
|
|
264
267
|
"inference:providers:read": "inference:providers:read";
|
|
265
268
|
"inference:providers:write": "inference:providers:write";
|
|
266
269
|
}>>;
|
|
270
|
+
billingAccountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
271
|
+
applicationId: z.ZodString;
|
|
272
|
+
credentialId: z.ZodString;
|
|
273
|
+
environment: z.ZodEnum<{
|
|
274
|
+
development: "development";
|
|
275
|
+
staging: "staging";
|
|
276
|
+
production: "production";
|
|
277
|
+
}>;
|
|
267
278
|
lane: z.ZodEnum<{
|
|
268
279
|
machine_credential: "machine_credential";
|
|
269
280
|
service_token: "service_token";
|
|
270
281
|
product_session: "product_session";
|
|
271
282
|
}>;
|
|
272
|
-
}, z.core.$strict>;
|
|
283
|
+
}, z.core.$strict>], "authority">;
|
|
273
284
|
/** A model line Oxy admits for a step, with the price it settles at. */
|
|
274
285
|
export declare const admittedModelLineSchema: z.ZodObject<{
|
|
275
286
|
modelLine: z.ZodString;
|
|
@@ -374,7 +385,8 @@ export declare const grantSchema: z.ZodObject<{
|
|
|
374
385
|
issuedAt: z.ZodString;
|
|
375
386
|
executeBy: z.ZodString;
|
|
376
387
|
bodySha256: z.ZodString;
|
|
377
|
-
principal: z.ZodObject<{
|
|
388
|
+
principal: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
389
|
+
authority: z.ZodLiteral<"first_party">;
|
|
378
390
|
billingAccountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
379
391
|
applicationId: z.ZodString;
|
|
380
392
|
credentialId: z.ZodString;
|
|
@@ -383,6 +395,13 @@ export declare const grantSchema: z.ZodObject<{
|
|
|
383
395
|
staging: "staging";
|
|
384
396
|
production: "production";
|
|
385
397
|
}>;
|
|
398
|
+
lane: z.ZodEnum<{
|
|
399
|
+
machine_credential: "machine_credential";
|
|
400
|
+
service_token: "service_token";
|
|
401
|
+
product_session: "product_session";
|
|
402
|
+
}>;
|
|
403
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
404
|
+
authority: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
386
405
|
scopes: z.ZodArray<z.ZodEnum<{
|
|
387
406
|
"inference:invoke": "inference:invoke";
|
|
388
407
|
"inference:models:read": "inference:models:read";
|
|
@@ -392,12 +411,20 @@ export declare const grantSchema: z.ZodObject<{
|
|
|
392
411
|
"inference:providers:read": "inference:providers:read";
|
|
393
412
|
"inference:providers:write": "inference:providers:write";
|
|
394
413
|
}>>;
|
|
414
|
+
billingAccountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
415
|
+
applicationId: z.ZodString;
|
|
416
|
+
credentialId: z.ZodString;
|
|
417
|
+
environment: z.ZodEnum<{
|
|
418
|
+
development: "development";
|
|
419
|
+
staging: "staging";
|
|
420
|
+
production: "production";
|
|
421
|
+
}>;
|
|
395
422
|
lane: z.ZodEnum<{
|
|
396
423
|
machine_credential: "machine_credential";
|
|
397
424
|
service_token: "service_token";
|
|
398
425
|
product_session: "product_session";
|
|
399
426
|
}>;
|
|
400
|
-
}, z.core.$strict>;
|
|
427
|
+
}, z.core.$strict>], "authority">;
|
|
401
428
|
userId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
|
|
402
429
|
economics: z.ZodObject<{
|
|
403
430
|
treatment: z.ZodEnum<{
|
package/dist/internal/grant.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* operation, decisions included, is an ordinary grant of ordered steps.
|
|
19
19
|
*/
|
|
20
20
|
import { z } from 'zod';
|
|
21
|
+
import { maxUtf16Length, minUtf16Length } from '../stringBounds.js';
|
|
21
22
|
import { powerLevelSchema, realtimeSessionKindSchema } from '../public/catalogue.js';
|
|
22
23
|
import { generationRecordSchema } from '../public/generations.js';
|
|
23
24
|
import { delegatedUserIdSchema, generationIdSchema, idempotencyKeySchema, inferenceEnvironmentSchema, inferenceRegionSchema, inferenceTimestampSchema, modelIdSchema, modelRevisionLabelSchema, oxyApplicationIdSchema, oxyCredentialIdSchema, requestIdSchema, } from '../public/identifiers.js';
|
|
@@ -113,7 +114,7 @@ export const grantRequestFactsSchema = z
|
|
|
113
114
|
realtimeSessionKind: realtimeSessionKindSchema.optional(),
|
|
114
115
|
})
|
|
115
116
|
.strict();
|
|
116
|
-
const credentialSchema = z.string().
|
|
117
|
+
const credentialSchema = z.string().check(minUtf16Length(1)).check(maxUtf16Length(8192));
|
|
117
118
|
/**
|
|
118
119
|
* `POST /internal/kaana/v1/authorizations` for an inference request. Kaana
|
|
119
120
|
* authenticates as a workload (Oxy ADR 0026); `credential` is the caller's
|
|
@@ -137,8 +138,8 @@ export const inferenceAuthorizationRequestSchema = z
|
|
|
137
138
|
client: z
|
|
138
139
|
.object({
|
|
139
140
|
/** The public path, e.g. `/v1/responses`. */
|
|
140
|
-
endpoint: z.string().
|
|
141
|
-
clientRequestId: z.string().
|
|
141
|
+
endpoint: z.string().check(minUtf16Length(1)).check(maxUtf16Length(256)),
|
|
142
|
+
clientRequestId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)).optional(),
|
|
142
143
|
receivedAt: inferenceTimestampSchema,
|
|
143
144
|
labels: requestLabelsSchema.optional(),
|
|
144
145
|
})
|
|
@@ -197,21 +198,37 @@ export const grantLaneSchema = z.enum(['machine_credential', 'service_token', 'p
|
|
|
197
198
|
* authenticated application, UNRESOLVED: the ledger resolves the billable
|
|
198
199
|
* ancestor. The end user never pays.
|
|
199
200
|
*/
|
|
200
|
-
|
|
201
|
-
.object({
|
|
201
|
+
const grantPrincipalIdentity = {
|
|
202
202
|
billingAccountId: oxyAccountIdSchema,
|
|
203
203
|
applicationId: oxyApplicationIdSchema,
|
|
204
204
|
credentialId: oxyCredentialIdSchema,
|
|
205
205
|
environment: inferenceEnvironmentSchema,
|
|
206
|
-
scopes: z.array(inferenceScopeSchema),
|
|
207
206
|
lane: grantLaneSchema,
|
|
208
|
-
}
|
|
209
|
-
|
|
207
|
+
};
|
|
208
|
+
export const grantPrincipalSchema = z
|
|
209
|
+
.discriminatedUnion('authority', [
|
|
210
|
+
z.object({ ...grantPrincipalIdentity, authority: z.literal('first_party') }).strict(),
|
|
211
|
+
z
|
|
212
|
+
.object({
|
|
213
|
+
...grantPrincipalIdentity,
|
|
214
|
+
authority: z.literal('external').optional(),
|
|
215
|
+
scopes: z.array(inferenceScopeSchema),
|
|
216
|
+
})
|
|
217
|
+
.strict(),
|
|
218
|
+
])
|
|
219
|
+
.superRefine((principal, ctx) => {
|
|
220
|
+
if (principal.authority === 'first_party' && principal.lane === 'machine_credential')
|
|
221
|
+
ctx.addIssue({
|
|
222
|
+
code: 'custom',
|
|
223
|
+
path: ['lane'],
|
|
224
|
+
message: 'A customer API key never has first-party authority',
|
|
225
|
+
});
|
|
226
|
+
});
|
|
210
227
|
/** A model line Oxy admits for a step, with the price it settles at. */
|
|
211
228
|
export const admittedModelLineSchema = z
|
|
212
229
|
.object({
|
|
213
230
|
modelLine: modelIdSchema,
|
|
214
|
-
priceVersionId: z.string().
|
|
231
|
+
priceVersionId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)),
|
|
215
232
|
})
|
|
216
233
|
.strict();
|
|
217
234
|
/**
|
|
@@ -234,7 +251,9 @@ export const grantStepLimitsSchema = z
|
|
|
234
251
|
deniedRegions: z.array(inferenceRegionSchema).default([]),
|
|
235
252
|
requireZeroDataRetention: z.boolean(),
|
|
236
253
|
prohibitTrainingOnCustomerData: z.boolean(),
|
|
237
|
-
allowedLicenseIds: z
|
|
254
|
+
allowedLicenseIds: z
|
|
255
|
+
.array(z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)))
|
|
256
|
+
.default([]),
|
|
238
257
|
requireCommercialUseRights: z.boolean(),
|
|
239
258
|
/**
|
|
240
259
|
* Whether Kaana may fail over, inside this step, between providers (and
|
|
@@ -304,7 +323,7 @@ const customerProviderCredentialBinding = authorizedRouteSchema.options[0].shape
|
|
|
304
323
|
export const grantSchema = z
|
|
305
324
|
.object({
|
|
306
325
|
schemaVersion: z.literal(1),
|
|
307
|
-
grantId: z.string().
|
|
326
|
+
grantId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)),
|
|
308
327
|
requestId: requestIdSchema,
|
|
309
328
|
operation: grantOperationSchema,
|
|
310
329
|
issuedAt: inferenceTimestampSchema,
|
|
@@ -318,14 +337,14 @@ export const grantSchema = z
|
|
|
318
337
|
economics: z
|
|
319
338
|
.object({
|
|
320
339
|
treatment: inferenceEconomicTreatmentSchema,
|
|
321
|
-
policyVersion: z.string().
|
|
322
|
-
relationshipId: z.string().
|
|
340
|
+
policyVersion: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)),
|
|
341
|
+
relationshipId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)).optional(),
|
|
323
342
|
})
|
|
324
343
|
.strict(),
|
|
325
344
|
/** The hold. Absent for `internal_metered`, which holds nothing. */
|
|
326
345
|
reservation: z
|
|
327
346
|
.object({
|
|
328
|
-
reservationId: z.string().
|
|
347
|
+
reservationId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)),
|
|
329
348
|
/** The most the hold covers. Shown, never spent by Kaana. */
|
|
330
349
|
ceiling: moneySchema,
|
|
331
350
|
/** `promotional-only`: the hold draws on promotional credit alone. */
|
|
@@ -335,7 +354,7 @@ export const grantSchema = z
|
|
|
335
354
|
.optional(),
|
|
336
355
|
/** The capacity slot an internal relationship claimed (e.g. `alia-kaana`). */
|
|
337
356
|
capacity: z
|
|
338
|
-
.object({ meteredUsageId: z.string().
|
|
357
|
+
.object({ meteredUsageId: z.string().check(minUtf16Length(1)).check(maxUtf16Length(128)) })
|
|
339
358
|
.strict()
|
|
340
359
|
.optional(),
|
|
341
360
|
steps: z.array(grantStepSchema).min(1).max(8),
|