@kaana.ai/contracts 8.12.0 → 8.13.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.
@@ -0,0 +1,141 @@
1
+ /** Identity facts only. Kaana owns admission, routing and economic policy. */
2
+ import { z } from 'zod';
3
+ export declare const IDENTITY_SIGNATURE_DOMAIN = "oxy-kaana-identity:v1";
4
+ export declare const IDENTITY_VALIDITY_WINDOW_MS = 60000;
5
+ export declare const OXY_KAANA_IDENTITIES_ENDPOINT = "/internal/kaana/v1/identities";
6
+ /** The exact bytes of this request, not inference content, are signed by hash. */
7
+ export declare const kaanaIdentityRequestSchema: z.ZodObject<{
8
+ schemaVersion: z.ZodLiteral<1>;
9
+ kind: z.ZodLiteral<"identity">;
10
+ requestId: z.ZodString;
11
+ audience: z.ZodLiteral<"kaana.ai">;
12
+ credential: z.ZodString;
13
+ onBehalfOfUserId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
14
+ }, z.core.$strict>;
15
+ export declare const kaanaIdentityLaneSchema: z.ZodEnum<{
16
+ machine_credential: "machine_credential";
17
+ service_token: "service_token";
18
+ }>;
19
+ export declare const kaanaIdentityApplicationClassSchema: z.ZodEnum<{
20
+ system: "system";
21
+ first_party: "first_party";
22
+ third_party: "third_party";
23
+ internal: "internal";
24
+ }>;
25
+ export declare const kaanaIdentityPrincipalSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
+ authority: z.ZodLiteral<"first_party">;
27
+ ownerAccountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
28
+ applicationId: z.ZodString;
29
+ credentialId: z.ZodString;
30
+ environment: z.ZodEnum<{
31
+ development: "development";
32
+ staging: "staging";
33
+ production: "production";
34
+ }>;
35
+ lane: z.ZodEnum<{
36
+ machine_credential: "machine_credential";
37
+ service_token: "service_token";
38
+ }>;
39
+ applicationClass: z.ZodEnum<{
40
+ system: "system";
41
+ first_party: "first_party";
42
+ third_party: "third_party";
43
+ internal: "internal";
44
+ }>;
45
+ applicationIsInternal: z.ZodBoolean;
46
+ }, z.core.$strict>, z.ZodObject<{
47
+ authority: z.ZodLiteral<"external">;
48
+ scopes: z.ZodArray<z.ZodEnum<{
49
+ "inference:invoke": "inference:invoke";
50
+ "inference:models:read": "inference:models:read";
51
+ "inference:usage:read": "inference:usage:read";
52
+ "inference:routing:read": "inference:routing:read";
53
+ "inference:routing:write": "inference:routing:write";
54
+ "inference:providers:read": "inference:providers:read";
55
+ "inference:providers:write": "inference:providers:write";
56
+ }>>;
57
+ ownerAccountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
58
+ applicationId: z.ZodString;
59
+ credentialId: z.ZodString;
60
+ environment: z.ZodEnum<{
61
+ development: "development";
62
+ staging: "staging";
63
+ production: "production";
64
+ }>;
65
+ lane: z.ZodEnum<{
66
+ machine_credential: "machine_credential";
67
+ service_token: "service_token";
68
+ }>;
69
+ applicationClass: z.ZodEnum<{
70
+ system: "system";
71
+ first_party: "first_party";
72
+ third_party: "third_party";
73
+ internal: "internal";
74
+ }>;
75
+ applicationIsInternal: z.ZodBoolean;
76
+ }, z.core.$strict>], "authority">;
77
+ export declare const kaanaIdentityAssertionSchema: z.ZodObject<{
78
+ schemaVersion: z.ZodLiteral<1>;
79
+ kind: z.ZodLiteral<"identity">;
80
+ requestId: z.ZodString;
81
+ audience: z.ZodLiteral<"kaana.ai">;
82
+ requestSha256: z.ZodString;
83
+ issuedAt: z.ZodString;
84
+ expiresAt: z.ZodString;
85
+ principal: z.ZodDiscriminatedUnion<[z.ZodObject<{
86
+ authority: z.ZodLiteral<"first_party">;
87
+ ownerAccountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
88
+ applicationId: z.ZodString;
89
+ credentialId: z.ZodString;
90
+ environment: z.ZodEnum<{
91
+ development: "development";
92
+ staging: "staging";
93
+ production: "production";
94
+ }>;
95
+ lane: z.ZodEnum<{
96
+ machine_credential: "machine_credential";
97
+ service_token: "service_token";
98
+ }>;
99
+ applicationClass: z.ZodEnum<{
100
+ system: "system";
101
+ first_party: "first_party";
102
+ third_party: "third_party";
103
+ internal: "internal";
104
+ }>;
105
+ applicationIsInternal: z.ZodBoolean;
106
+ }, z.core.$strict>, z.ZodObject<{
107
+ authority: z.ZodLiteral<"external">;
108
+ scopes: z.ZodArray<z.ZodEnum<{
109
+ "inference:invoke": "inference:invoke";
110
+ "inference:models:read": "inference:models:read";
111
+ "inference:usage:read": "inference:usage:read";
112
+ "inference:routing:read": "inference:routing:read";
113
+ "inference:routing:write": "inference:routing:write";
114
+ "inference:providers:read": "inference:providers:read";
115
+ "inference:providers:write": "inference:providers:write";
116
+ }>>;
117
+ ownerAccountId: z.core.$ZodBranded<z.ZodString, "OxyAccountId", "out">;
118
+ applicationId: z.ZodString;
119
+ credentialId: z.ZodString;
120
+ environment: z.ZodEnum<{
121
+ development: "development";
122
+ staging: "staging";
123
+ production: "production";
124
+ }>;
125
+ lane: z.ZodEnum<{
126
+ machine_credential: "machine_credential";
127
+ service_token: "service_token";
128
+ }>;
129
+ applicationClass: z.ZodEnum<{
130
+ system: "system";
131
+ first_party: "first_party";
132
+ third_party: "third_party";
133
+ internal: "internal";
134
+ }>;
135
+ applicationIsInternal: z.ZodBoolean;
136
+ }, z.core.$strict>], "authority">;
137
+ userId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DelegatedUserId", "out">>;
138
+ }, z.core.$strict>;
139
+ export type KaanaIdentityRequest = z.infer<typeof kaanaIdentityRequestSchema>;
140
+ export type KaanaIdentityPrincipal = z.infer<typeof kaanaIdentityPrincipalSchema>;
141
+ export type KaanaIdentityAssertion = z.infer<typeof kaanaIdentityAssertionSchema>;
@@ -0,0 +1,82 @@
1
+ /** Identity facts only. Kaana owns admission, routing and economic policy. */
2
+ import { z } from 'zod';
3
+ import { maxUtf16Length, minUtf16Length } from '../stringBounds.js';
4
+ import { delegatedUserIdSchema, inferenceEnvironmentSchema, inferenceTimestampSchema, oxyApplicationIdSchema, oxyCredentialIdSchema, requestIdSchema, } from '../public/identifiers.js';
5
+ import { inferenceScopeSchema } from './attribution.js';
6
+ import { oxyAccountIdSchema } from './identifiers.js';
7
+ export const IDENTITY_SIGNATURE_DOMAIN = 'oxy-kaana-identity:v1';
8
+ export const IDENTITY_VALIDITY_WINDOW_MS = 60_000;
9
+ export const OXY_KAANA_IDENTITIES_ENDPOINT = '/internal/kaana/v1/identities';
10
+ /** The exact bytes of this request, not inference content, are signed by hash. */
11
+ export const kaanaIdentityRequestSchema = z
12
+ .object({
13
+ schemaVersion: z.literal(1),
14
+ kind: z.literal('identity'),
15
+ requestId: requestIdSchema,
16
+ audience: z.literal('kaana.ai'),
17
+ credential: z.string().check(minUtf16Length(1)).check(maxUtf16Length(8192)),
18
+ /** Attribution only. Never proof of the person's identity or data authority. */
19
+ onBehalfOfUserId: delegatedUserIdSchema.optional(),
20
+ })
21
+ .strict();
22
+ export const kaanaIdentityLaneSchema = z.enum(['machine_credential', 'service_token']);
23
+ export const kaanaIdentityApplicationClassSchema = z.enum([
24
+ 'first_party',
25
+ 'third_party',
26
+ 'internal',
27
+ 'system',
28
+ ]);
29
+ const principalFields = {
30
+ ownerAccountId: oxyAccountIdSchema,
31
+ applicationId: oxyApplicationIdSchema,
32
+ credentialId: oxyCredentialIdSchema,
33
+ environment: inferenceEnvironmentSchema,
34
+ // Product sessions require their own identity-only verifier before enrollment.
35
+ lane: kaanaIdentityLaneSchema,
36
+ applicationClass: kaanaIdentityApplicationClassSchema,
37
+ applicationIsInternal: z.boolean(),
38
+ };
39
+ export const kaanaIdentityPrincipalSchema = z
40
+ .discriminatedUnion('authority', [
41
+ z.object({ ...principalFields, authority: z.literal('first_party') }).strict(),
42
+ z
43
+ .object({
44
+ ...principalFields,
45
+ authority: z.literal('external'),
46
+ scopes: z.array(inferenceScopeSchema),
47
+ })
48
+ .strict(),
49
+ ])
50
+ .superRefine((principal, ctx) => {
51
+ if (principal.authority === 'first_party' && principal.lane !== 'service_token') {
52
+ ctx.addIssue({
53
+ code: 'custom',
54
+ path: ['lane'],
55
+ message: 'First-party authority requires a workload service token',
56
+ });
57
+ }
58
+ });
59
+ export const kaanaIdentityAssertionSchema = z
60
+ .object({
61
+ schemaVersion: z.literal(1),
62
+ kind: z.literal('identity'),
63
+ requestId: requestIdSchema,
64
+ audience: z.literal('kaana.ai'),
65
+ requestSha256: z.string().regex(/^[0-9a-f]{64}$/),
66
+ issuedAt: inferenceTimestampSchema,
67
+ expiresAt: inferenceTimestampSchema,
68
+ principal: kaanaIdentityPrincipalSchema,
69
+ /** Attribution only, with the same meaning as onBehalfOfUserId. */
70
+ userId: delegatedUserIdSchema.optional(),
71
+ })
72
+ .strict()
73
+ .superRefine((assertion, ctx) => {
74
+ const duration = Date.parse(assertion.expiresAt) - Date.parse(assertion.issuedAt);
75
+ if (!(duration > 0 && duration <= IDENTITY_VALIDITY_WINDOW_MS)) {
76
+ ctx.addIssue({
77
+ code: 'custom',
78
+ path: ['expiresAt'],
79
+ message: 'Identity assertions are valid for at most 60 seconds',
80
+ });
81
+ }
82
+ });
@@ -19,6 +19,7 @@ export * from './internal/embeddings.js';
19
19
  export * from './internal/errors.js';
20
20
  export * from './internal/grant.js';
21
21
  export * from './internal/identifiers.js';
22
+ export * from './internal/identity.js';
22
23
  export * from './internal/realtime.js';
23
24
  export * from './internal/request.js';
24
25
  export * from './internal/routing.js';
package/dist/internal.js CHANGED
@@ -19,6 +19,7 @@ export * from './internal/embeddings.js';
19
19
  export * from './internal/errors.js';
20
20
  export * from './internal/grant.js';
21
21
  export * from './internal/identifiers.js';
22
+ export * from './internal/identity.js';
22
23
  export * from './internal/realtime.js';
23
24
  export * from './internal/request.js';
24
25
  export * from './internal/routing.js';
@@ -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 = "8.12.0";
103
+ export declare const INFERENCE_CONTRACT_VERSION = "8.13.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:
@@ -249,6 +249,12 @@ export declare const INFERENCE_CONTRACT_VERSION = "8.12.0";
249
249
  * `images_generations` API format, image modality and text input. Nothing in
250
250
  * 8.11.0 changes and the public request and response shapes are unchanged.
251
251
  */
252
+ /**
253
+ * Contract set 8.13.0 adds identity-only Oxy assertions under /internal, with a
254
+ * distinct signature domain and bounded request binding. Existing grants and
255
+ * public inference shapes are unchanged; publishing does not activate native
256
+ * economic authorization or enroll any customer.
257
+ */
252
258
  /** The public API's one origin and version. */
253
259
  export declare const KAANA_API_BASE_URL = "https://kaana.ai/v1";
254
260
  /** The response header that carries the request id. */
@@ -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 = '8.12.0';
103
+ export const INFERENCE_CONTRACT_VERSION = '8.13.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:
@@ -249,6 +249,12 @@ export const INFERENCE_CONTRACT_VERSION = '8.12.0';
249
249
  * `images_generations` API format, image modality and text input. Nothing in
250
250
  * 8.11.0 changes and the public request and response shapes are unchanged.
251
251
  */
252
+ /**
253
+ * Contract set 8.13.0 adds identity-only Oxy assertions under /internal, with a
254
+ * distinct signature domain and bounded request binding. Existing grants and
255
+ * public inference shapes are unchanged; publishing does not activate native
256
+ * economic authorization or enroll any customer.
257
+ */
252
258
  /** The public API's one origin and version. */
253
259
  export const KAANA_API_BASE_URL = 'https://kaana.ai/v1';
254
260
  /** The response header that carries the request id. */
package/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "Kaana API",
5
- "version": "8.12.0",
5
+ "version": "8.13.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": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaana.ai/contracts",
3
- "version": "8.12.0",
3
+ "version": "8.13.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,