@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
|
@@ -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
|
*
|
|
@@ -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>;
|
|
@@ -291,10 +262,9 @@ export declare const modelDeploymentSchema: z.ZodObject<{
|
|
|
291
262
|
}, z.core.$strip>;
|
|
292
263
|
/**
|
|
293
264
|
* The commercial facts Kaana publishes about ONE deployment on the descriptors
|
|
294
|
-
* it serves to Oxy (`POST /internal/v1/deployments/query`
|
|
295
|
-
*
|
|
296
|
-
* `
|
|
297
|
-
* 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
|
|
298
268
|
* descriptor. New in contract set 4.4.0.
|
|
299
269
|
*
|
|
300
270
|
* `customer_byok` is the commercial basis of a `byok_only` route and of no
|
|
@@ -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,
|
|
@@ -213,10 +210,9 @@ export const modelDeploymentSchema = z
|
|
|
213
210
|
});
|
|
214
211
|
/**
|
|
215
212
|
* The commercial facts Kaana publishes about ONE deployment on the descriptors
|
|
216
|
-
* it serves to Oxy (`POST /internal/v1/deployments/query`
|
|
217
|
-
*
|
|
218
|
-
* `
|
|
219
|
-
* no `commercial` at all, which is why the member is optional on the
|
|
213
|
+
* it serves to Oxy (`POST /internal/v1/deployments/query`), from the reviewed
|
|
214
|
+
* file `configs/deployment-commercial.json`. A deployment that is not sold
|
|
215
|
+
* carries no `commercial` at all, which is why the member is optional on the
|
|
220
216
|
* descriptor. New in contract set 4.4.0.
|
|
221
217
|
*
|
|
222
218
|
* `customer_byok` is the commercial basis of a `byok_only` route and of no
|
|
@@ -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>;
|
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>;
|
|
@@ -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;
|
|
@@ -353,24 +364,6 @@ export declare const grantStepSchema: z.ZodObject<{
|
|
|
353
364
|
sameModelFailover: z.ZodDefault<z.ZodBoolean>;
|
|
354
365
|
}, z.core.$strict>;
|
|
355
366
|
}, 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
367
|
/**
|
|
375
368
|
* The signed grant: the body of a successful authorization for an inference
|
|
376
369
|
* operation. Kaana verifies it and executes inside it; Oxy settles against it.
|
|
@@ -392,7 +385,8 @@ export declare const grantSchema: z.ZodObject<{
|
|
|
392
385
|
issuedAt: z.ZodString;
|
|
393
386
|
executeBy: z.ZodString;
|
|
394
387
|
bodySha256: z.ZodString;
|
|
395
|
-
principal: z.ZodObject<{
|
|
388
|
+
principal: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
389
|
+
authority: z.ZodLiteral<"first_party">;
|
|
396
390
|
billingAccountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
|
|
397
391
|
applicationId: z.ZodString;
|
|
398
392
|
credentialId: z.ZodString;
|
|
@@ -401,6 +395,13 @@ export declare const grantSchema: z.ZodObject<{
|
|
|
401
395
|
staging: "staging";
|
|
402
396
|
production: "production";
|
|
403
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">>;
|
|
404
405
|
scopes: z.ZodArray<z.ZodEnum<{
|
|
405
406
|
"inference:invoke": "inference:invoke";
|
|
406
407
|
"inference:models:read": "inference:models:read";
|
|
@@ -410,12 +411,20 @@ export declare const grantSchema: z.ZodObject<{
|
|
|
410
411
|
"inference:providers:read": "inference:providers:read";
|
|
411
412
|
"inference:providers:write": "inference:providers:write";
|
|
412
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
|
+
}>;
|
|
413
422
|
lane: z.ZodEnum<{
|
|
414
423
|
machine_credential: "machine_credential";
|
|
415
424
|
service_token: "service_token";
|
|
416
425
|
product_session: "product_session";
|
|
417
426
|
}>;
|
|
418
|
-
}, z.core.$strict>;
|
|
427
|
+
}, z.core.$strict>], "authority">;
|
|
419
428
|
userId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
|
|
420
429
|
economics: z.ZodObject<{
|
|
421
430
|
treatment: z.ZodEnum<{
|
|
@@ -479,19 +488,6 @@ export declare const grantSchema: z.ZodObject<{
|
|
|
479
488
|
sameModelFailover: z.ZodDefault<z.ZodBoolean>;
|
|
480
489
|
}, z.core.$strict>;
|
|
481
490
|
}, 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
491
|
customerProviderCredential: z.ZodOptional<z.ZodObject<{
|
|
496
492
|
credentialHandle: z.ZodString;
|
|
497
493
|
credentialRevision: z.ZodNumber;
|
|
@@ -693,7 +689,6 @@ export type GrantPrincipal = z.infer<typeof grantPrincipalSchema>;
|
|
|
693
689
|
export type AdmittedModelLine = z.infer<typeof admittedModelLineSchema>;
|
|
694
690
|
export type GrantStepLimits = z.infer<typeof grantStepLimitsSchema>;
|
|
695
691
|
export type GrantStep = z.infer<typeof grantStepSchema>;
|
|
696
|
-
export type GrantExactRoute = z.infer<typeof grantExactRouteSchema>;
|
|
697
692
|
export type Grant = z.infer<typeof grantSchema>;
|
|
698
693
|
export type CatalogueAccess = z.infer<typeof catalogueAccessSchema>;
|
|
699
694
|
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`. */
|
|
@@ -201,16 +197,32 @@ export const grantLaneSchema = z.enum(['machine_credential', 'service_token', 'p
|
|
|
201
197
|
* authenticated application, UNRESOLVED: the ledger resolves the billable
|
|
202
198
|
* ancestor. The end user never pays.
|
|
203
199
|
*/
|
|
204
|
-
|
|
205
|
-
.object({
|
|
200
|
+
const grantPrincipalIdentity = {
|
|
206
201
|
billingAccountId: oxyAccountIdSchema,
|
|
207
202
|
applicationId: oxyApplicationIdSchema,
|
|
208
203
|
credentialId: oxyCredentialIdSchema,
|
|
209
204
|
environment: inferenceEnvironmentSchema,
|
|
210
|
-
scopes: z.array(inferenceScopeSchema),
|
|
211
205
|
lane: grantLaneSchema,
|
|
212
|
-
}
|
|
213
|
-
|
|
206
|
+
};
|
|
207
|
+
export const grantPrincipalSchema = z
|
|
208
|
+
.discriminatedUnion('authority', [
|
|
209
|
+
z.object({ ...grantPrincipalIdentity, authority: z.literal('first_party') }).strict(),
|
|
210
|
+
z
|
|
211
|
+
.object({
|
|
212
|
+
...grantPrincipalIdentity,
|
|
213
|
+
authority: z.literal('external').optional(),
|
|
214
|
+
scopes: z.array(inferenceScopeSchema),
|
|
215
|
+
})
|
|
216
|
+
.strict(),
|
|
217
|
+
])
|
|
218
|
+
.superRefine((principal, ctx) => {
|
|
219
|
+
if (principal.authority === 'first_party' && principal.lane === 'machine_credential')
|
|
220
|
+
ctx.addIssue({
|
|
221
|
+
code: 'custom',
|
|
222
|
+
path: ['lane'],
|
|
223
|
+
message: 'A customer API key never has first-party authority',
|
|
224
|
+
});
|
|
225
|
+
});
|
|
214
226
|
/** A model line Oxy admits for a step, with the price it settles at. */
|
|
215
227
|
export const admittedModelLineSchema = z
|
|
216
228
|
.object({
|
|
@@ -299,34 +311,6 @@ export const grantStepSchema = z
|
|
|
299
311
|
});
|
|
300
312
|
}
|
|
301
313
|
});
|
|
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
314
|
/** The BYOK binding, exactly as an authorized route carries it today. */
|
|
331
315
|
const customerProviderCredentialBinding = authorizedRouteSchema.options[0].shape.customerProviderCredential;
|
|
332
316
|
/**
|
|
@@ -360,7 +344,7 @@ export const grantSchema = z
|
|
|
360
344
|
reservationId: z.string().min(1).max(128),
|
|
361
345
|
/** The most the hold covers. Shown, never spent by Kaana. */
|
|
362
346
|
ceiling: moneySchema,
|
|
363
|
-
/** `promotional-only
|
|
347
|
+
/** `promotional-only`: the hold draws on promotional credit alone. */
|
|
364
348
|
fundingRestriction: z.literal('promotional-only').optional(),
|
|
365
349
|
})
|
|
366
350
|
.strict()
|
|
@@ -371,7 +355,6 @@ export const grantSchema = z
|
|
|
371
355
|
.strict()
|
|
372
356
|
.optional(),
|
|
373
357
|
steps: z.array(grantStepSchema).min(1).max(8),
|
|
374
|
-
exactRoute: grantExactRouteSchema.optional(),
|
|
375
358
|
/** BYOK: the customer's own provider key. Excludes `maxFundingTier`. */
|
|
376
359
|
customerProviderCredential: customerProviderCredentialBinding,
|
|
377
360
|
idempotencyKey: idempotencyKeySchema.optional(),
|
|
@@ -403,22 +386,6 @@ export const grantSchema = z
|
|
|
403
386
|
issue(['steps', index, 'limits', 'maxFundingTier'], 'a funding ceiling bounds platform keys; a customer credential is billed to the customer');
|
|
404
387
|
}
|
|
405
388
|
}
|
|
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
389
|
});
|
|
423
390
|
/**
|
|
424
391
|
* The answer to a catalogue authorization: what the credential may see.
|