@sealkeeper/schema 0.4.7 → 0.4.8

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.
@@ -13,7 +13,7 @@ export declare const CREDENTIAL_EXTENSION_URI = "https://vouched.run/ext/credent
13
13
  export declare const LEGACY_SEAL_EXTENSION_URIS: readonly string[];
14
14
  export declare const SEAL_EXTENSION_URIS: readonly string[];
15
15
  export declare const SEAL_VERSION = 1;
16
- export declare const SEAL_VERSIONS: readonly [1, 2];
16
+ export declare const SEAL_VERSIONS: readonly [1, 2, 3];
17
17
  export declare const IdentityKind: z.ZodUnion<readonly [z.ZodEnum<{
18
18
  kya: "kya";
19
19
  oidc: "oidc";
@@ -41,6 +41,17 @@ export type IdentityReference = z.infer<typeof IdentityReference>;
41
41
  export declare const operatorVerified: (identity: readonly IdentityReference[]) => boolean;
42
42
  export declare const SEAL_MAX_TTL_SECONDS: number;
43
43
  export declare const SEAL_CLOCK_SKEW_SECONDS = 300;
44
+ export declare const SealState: z.ZodEnum<{
45
+ changed: "changed";
46
+ matches: "matches";
47
+ provisional: "provisional";
48
+ }>;
49
+ export type SealState = z.infer<typeof SealState>;
50
+ export declare const SealFingerprint: z.ZodNullable<z.ZodObject<{
51
+ hash: z.ZodString;
52
+ at: z.ZodInt;
53
+ }, z.core.$strict>>;
54
+ export type SealFingerprint = z.infer<typeof SealFingerprint>;
44
55
  export declare const CredentialPayload: z.ZodObject<{
45
56
  iss: z.ZodLiteral<"sealkeeper.run">;
46
57
  sub: z.ZodString;
@@ -60,7 +71,7 @@ export declare const CredentialPayload: z.ZodObject<{
60
71
  provenance: "provenance";
61
72
  reliability: "reliability";
62
73
  safety: "safety";
63
- }>, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
74
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
64
75
  counts: z.ZodObject<{
65
76
  events: z.ZodInt;
66
77
  history_days: z.ZodInt;
@@ -113,7 +124,7 @@ export declare const CredentialPayloadV2: z.ZodObject<{
113
124
  provenance: "provenance";
114
125
  reliability: "reliability";
115
126
  safety: "safety";
116
- }>, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
127
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
117
128
  counts: z.ZodObject<{
118
129
  events: z.ZodInt;
119
130
  history_days: z.ZodInt;
@@ -153,6 +164,78 @@ export declare const CredentialPayloadV2: z.ZodObject<{
153
164
  dormant_days: z.ZodNullable<z.ZodInt>;
154
165
  }, z.core.$strict>;
155
166
  export type CredentialPayloadV2 = z.infer<typeof CredentialPayloadV2>;
167
+ export declare const CredentialPayloadV3: z.ZodObject<{
168
+ iss: z.ZodLiteral<"sealkeeper.run">;
169
+ sub: z.ZodString;
170
+ ver: z.ZodLiteral<3>;
171
+ iat: z.ZodInt;
172
+ exp: z.ZodInt;
173
+ agent_version: z.ZodString;
174
+ level: z.ZodEnum<{
175
+ bronze: "bronze";
176
+ gold: "gold";
177
+ none: "none";
178
+ silver: "silver";
179
+ }>;
180
+ scores: z.ZodRecord<z.ZodUnion<readonly [z.ZodEnum<{
181
+ cost_latency: "cost_latency";
182
+ provenance: "provenance";
183
+ reliability: "reliability";
184
+ safety: "safety";
185
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
186
+ counts: z.ZodObject<{
187
+ events: z.ZodInt;
188
+ history_days: z.ZodInt;
189
+ verified_tasks: z.ZodInt;
190
+ seed_tasks: z.ZodInt;
191
+ server_checked_tasks: z.ZodInt;
192
+ confirmed_tasks: z.ZodInt;
193
+ distinct_operators: z.ZodInt;
194
+ safety_incidents_90d: z.ZodInt;
195
+ posted_tasks: z.ZodInt;
196
+ posted_distinct_operators: z.ZodInt;
197
+ posted_confirmed_tasks: z.ZodInt;
198
+ }, z.core.$strict>;
199
+ counted: z.ZodObject<{
200
+ verified_tasks: z.ZodInt;
201
+ seed_tasks: z.ZodInt;
202
+ server_checked_tasks: z.ZodInt;
203
+ confirmed_tasks: z.ZodInt;
204
+ posted_tasks: z.ZodInt;
205
+ posted_confirmed_tasks: z.ZodInt;
206
+ }, z.core.$strict>;
207
+ fingerprint: z.ZodNullable<z.ZodObject<{
208
+ hash: z.ZodString;
209
+ at: z.ZodInt;
210
+ }, z.core.$strict>>;
211
+ state: z.ZodEnum<{
212
+ changed: "changed";
213
+ matches: "matches";
214
+ provisional: "provisional";
215
+ }>;
216
+ operator: z.ZodObject<{
217
+ verified: z.ZodBoolean;
218
+ }, z.core.$strict>;
219
+ identity: z.ZodArray<z.ZodObject<{
220
+ provider: z.ZodURL;
221
+ kind: z.ZodUnion<readonly [z.ZodEnum<{
222
+ kya: "kya";
223
+ oidc: "oidc";
224
+ saml: "saml";
225
+ verifiable_credential: "verifiable_credential";
226
+ }>, z.ZodURL]>;
227
+ ref: z.ZodString;
228
+ subject_hash: z.ZodString;
229
+ attested_at: z.ZodInt;
230
+ scope: z.ZodEnum<{
231
+ agent: "agent";
232
+ operator: "operator";
233
+ }>;
234
+ }, z.core.$strict>>;
235
+ last_active: z.ZodNullable<z.ZodInt>;
236
+ dormant_days: z.ZodNullable<z.ZodInt>;
237
+ }, z.core.$strict>;
238
+ export type CredentialPayloadV3 = z.infer<typeof CredentialPayloadV3>;
156
239
  export declare const VerifiedCredentialPayload: z.ZodObject<{
157
240
  iss: z.ZodEnum<{
158
241
  "sealkeeper.run": "sealkeeper.run";
@@ -175,7 +258,7 @@ export declare const VerifiedCredentialPayload: z.ZodObject<{
175
258
  provenance: "provenance";
176
259
  reliability: "reliability";
177
260
  safety: "safety";
178
- }>, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
261
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
179
262
  counts: z.ZodObject<{
180
263
  events: z.ZodInt;
181
264
  history_days: z.ZodInt;
@@ -231,7 +314,7 @@ export declare const VerifiedCredentialPayloadV2: z.ZodObject<{
231
314
  provenance: "provenance";
232
315
  reliability: "reliability";
233
316
  safety: "safety";
234
- }>, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
317
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
235
318
  counts: z.ZodObject<{
236
319
  events: z.ZodInt;
237
320
  history_days: z.ZodInt;
@@ -271,6 +354,81 @@ export declare const VerifiedCredentialPayloadV2: z.ZodObject<{
271
354
  dormant_days: z.ZodNullable<z.ZodInt>;
272
355
  }, z.core.$strict>;
273
356
  export type VerifiedCredentialPayloadV2 = z.infer<typeof VerifiedCredentialPayloadV2>;
357
+ export declare const VerifiedCredentialPayloadV3: z.ZodObject<{
358
+ iss: z.ZodEnum<{
359
+ "sealkeeper.run": "sealkeeper.run";
360
+ "vouched.run": "vouched.run";
361
+ }>;
362
+ sub: z.ZodString;
363
+ ver: z.ZodLiteral<3>;
364
+ iat: z.ZodInt;
365
+ exp: z.ZodInt;
366
+ agent_version: z.ZodString;
367
+ level: z.ZodEnum<{
368
+ bronze: "bronze";
369
+ gold: "gold";
370
+ none: "none";
371
+ silver: "silver";
372
+ }>;
373
+ scores: z.ZodRecord<z.ZodUnion<readonly [z.ZodEnum<{
374
+ cost_latency: "cost_latency";
375
+ provenance: "provenance";
376
+ reliability: "reliability";
377
+ safety: "safety";
378
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
379
+ counts: z.ZodObject<{
380
+ events: z.ZodInt;
381
+ history_days: z.ZodInt;
382
+ verified_tasks: z.ZodInt;
383
+ seed_tasks: z.ZodInt;
384
+ server_checked_tasks: z.ZodInt;
385
+ confirmed_tasks: z.ZodInt;
386
+ distinct_operators: z.ZodInt;
387
+ safety_incidents_90d: z.ZodInt;
388
+ posted_tasks: z.ZodInt;
389
+ posted_distinct_operators: z.ZodInt;
390
+ posted_confirmed_tasks: z.ZodInt;
391
+ }, z.core.$strict>;
392
+ counted: z.ZodObject<{
393
+ verified_tasks: z.ZodInt;
394
+ seed_tasks: z.ZodInt;
395
+ server_checked_tasks: z.ZodInt;
396
+ confirmed_tasks: z.ZodInt;
397
+ posted_tasks: z.ZodInt;
398
+ posted_confirmed_tasks: z.ZodInt;
399
+ }, z.core.$strict>;
400
+ fingerprint: z.ZodNullable<z.ZodObject<{
401
+ hash: z.ZodString;
402
+ at: z.ZodInt;
403
+ }, z.core.$strict>>;
404
+ state: z.ZodEnum<{
405
+ changed: "changed";
406
+ matches: "matches";
407
+ provisional: "provisional";
408
+ }>;
409
+ operator: z.ZodObject<{
410
+ verified: z.ZodBoolean;
411
+ }, z.core.$strict>;
412
+ identity: z.ZodArray<z.ZodObject<{
413
+ provider: z.ZodURL;
414
+ kind: z.ZodUnion<readonly [z.ZodEnum<{
415
+ kya: "kya";
416
+ oidc: "oidc";
417
+ saml: "saml";
418
+ verifiable_credential: "verifiable_credential";
419
+ }>, z.ZodURL]>;
420
+ ref: z.ZodString;
421
+ subject_hash: z.ZodString;
422
+ attested_at: z.ZodInt;
423
+ scope: z.ZodEnum<{
424
+ agent: "agent";
425
+ operator: "operator";
426
+ }>;
427
+ }, z.core.$strict>>;
428
+ last_active: z.ZodNullable<z.ZodInt>;
429
+ dormant_days: z.ZodNullable<z.ZodInt>;
430
+ }, z.core.$strict>;
431
+ export type VerifiedCredentialPayloadV3 = z.infer<typeof VerifiedCredentialPayloadV3>;
274
432
  export declare const SealPayload: z.ZodUnion<readonly [z.ZodObject<{
275
433
  iss: z.ZodEnum<{
276
434
  "sealkeeper.run": "sealkeeper.run";
@@ -293,7 +451,7 @@ export declare const SealPayload: z.ZodUnion<readonly [z.ZodObject<{
293
451
  provenance: "provenance";
294
452
  reliability: "reliability";
295
453
  safety: "safety";
296
- }>, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
454
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
297
455
  counts: z.ZodObject<{
298
456
  events: z.ZodInt;
299
457
  history_days: z.ZodInt;
@@ -347,7 +505,7 @@ export declare const SealPayload: z.ZodUnion<readonly [z.ZodObject<{
347
505
  provenance: "provenance";
348
506
  reliability: "reliability";
349
507
  safety: "safety";
350
- }>, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
508
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
351
509
  counts: z.ZodObject<{
352
510
  events: z.ZodInt;
353
511
  history_days: z.ZodInt;
@@ -385,6 +543,79 @@ export declare const SealPayload: z.ZodUnion<readonly [z.ZodObject<{
385
543
  }, z.core.$strict>>;
386
544
  last_active: z.ZodNullable<z.ZodInt>;
387
545
  dormant_days: z.ZodNullable<z.ZodInt>;
546
+ }, z.core.$strict>, z.ZodObject<{
547
+ iss: z.ZodEnum<{
548
+ "sealkeeper.run": "sealkeeper.run";
549
+ "vouched.run": "vouched.run";
550
+ }>;
551
+ sub: z.ZodString;
552
+ ver: z.ZodLiteral<3>;
553
+ iat: z.ZodInt;
554
+ exp: z.ZodInt;
555
+ agent_version: z.ZodString;
556
+ level: z.ZodEnum<{
557
+ bronze: "bronze";
558
+ gold: "gold";
559
+ none: "none";
560
+ silver: "silver";
561
+ }>;
562
+ scores: z.ZodRecord<z.ZodUnion<readonly [z.ZodEnum<{
563
+ cost_latency: "cost_latency";
564
+ provenance: "provenance";
565
+ reliability: "reliability";
566
+ safety: "safety";
567
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">, z.ZodTemplateLiteral<`competence:${string}`>]> & z.core.$partial, z.ZodNullable<z.ZodNumber>>;
568
+ counts: z.ZodObject<{
569
+ events: z.ZodInt;
570
+ history_days: z.ZodInt;
571
+ verified_tasks: z.ZodInt;
572
+ seed_tasks: z.ZodInt;
573
+ server_checked_tasks: z.ZodInt;
574
+ confirmed_tasks: z.ZodInt;
575
+ distinct_operators: z.ZodInt;
576
+ safety_incidents_90d: z.ZodInt;
577
+ posted_tasks: z.ZodInt;
578
+ posted_distinct_operators: z.ZodInt;
579
+ posted_confirmed_tasks: z.ZodInt;
580
+ }, z.core.$strict>;
581
+ counted: z.ZodObject<{
582
+ verified_tasks: z.ZodInt;
583
+ seed_tasks: z.ZodInt;
584
+ server_checked_tasks: z.ZodInt;
585
+ confirmed_tasks: z.ZodInt;
586
+ posted_tasks: z.ZodInt;
587
+ posted_confirmed_tasks: z.ZodInt;
588
+ }, z.core.$strict>;
589
+ fingerprint: z.ZodNullable<z.ZodObject<{
590
+ hash: z.ZodString;
591
+ at: z.ZodInt;
592
+ }, z.core.$strict>>;
593
+ state: z.ZodEnum<{
594
+ changed: "changed";
595
+ matches: "matches";
596
+ provisional: "provisional";
597
+ }>;
598
+ operator: z.ZodObject<{
599
+ verified: z.ZodBoolean;
600
+ }, z.core.$strict>;
601
+ identity: z.ZodArray<z.ZodObject<{
602
+ provider: z.ZodURL;
603
+ kind: z.ZodUnion<readonly [z.ZodEnum<{
604
+ kya: "kya";
605
+ oidc: "oidc";
606
+ saml: "saml";
607
+ verifiable_credential: "verifiable_credential";
608
+ }>, z.ZodURL]>;
609
+ ref: z.ZodString;
610
+ subject_hash: z.ZodString;
611
+ attested_at: z.ZodInt;
612
+ scope: z.ZodEnum<{
613
+ agent: "agent";
614
+ operator: "operator";
615
+ }>;
616
+ }, z.core.$strict>>;
617
+ last_active: z.ZodNullable<z.ZodInt>;
618
+ dormant_days: z.ZodNullable<z.ZodInt>;
388
619
  }, z.core.$strict>]>;
389
620
  export type SealPayload = z.infer<typeof SealPayload>;
390
621
  export declare const sealCounted: (p: SealPayload) => CountedCounts | null;
@@ -437,13 +668,14 @@ export declare const SealExtension: z.ZodObject<{
437
668
  description: z.ZodString;
438
669
  params: z.ZodObject<{
439
670
  credential: z.ZodString;
671
+ handshake: z.ZodOptional<z.ZodString>;
440
672
  }, z.core.$strict>;
441
673
  }, z.core.$strict>;
442
674
  export type SealExtension = z.infer<typeof SealExtension>;
443
675
  export declare const credentialExtension: (jws: string) => CredentialExtension;
444
676
  export declare const legacySealExtension: (jws: string) => LegacySealExtension;
445
- export declare const sealExtension: (jws: string) => SealExtension;
446
- export declare const sealExtensions: (jws: string) => ({
677
+ export declare const sealExtension: (jws: string, handshake?: string) => SealExtension;
678
+ export declare const sealExtensions: (jws: string, handshake?: string) => ({
447
679
  uri: "https://vouched.run/ext/credential/v1";
448
680
  description: string;
449
681
  params: {
@@ -460,6 +692,7 @@ export declare const sealExtensions: (jws: string) => ({
460
692
  description: string;
461
693
  params: {
462
694
  credential: string;
695
+ handshake?: string | undefined;
463
696
  };
464
697
  })[];
465
698
  export declare const A2A_PROTOCOL_VERSION = "0.3.0";
@@ -483,6 +716,7 @@ export declare const AgentCard: z.ZodObject<{
483
716
  description: z.ZodString;
484
717
  params: z.ZodObject<{
485
718
  credential: z.ZodString;
719
+ handshake: z.ZodOptional<z.ZodString>;
486
720
  }, z.core.$strict>;
487
721
  }, z.core.$strict>, z.ZodObject<{
488
722
  uri: z.ZodLiteral<"https://vouched.run/ext/seal/v1">;
@@ -1,9 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  import { AgentId, Ed25519PublicKey } from './agent-id.js';
3
- import { Dimension } from './dimensions.js';
3
+ import { AcceptedDimension, Dimension } from './dimensions.js';
4
4
  import { Jws } from './envelope.js';
5
5
  import { StoredVersion } from './events.js';
6
- import { CountedCounts, Level, StandingCounts } from './standing.js';
6
+ import { HANDSHAKE_MAX_CHARS } from './handshake.js';
7
+ import { CountedCounts, CountedCountsV3, Level, StandingCounts, StandingCountsV3, } from './standing.js';
7
8
  // The issuer every SEAL carries as iss from the SealKeeper cutover on.
8
9
  export const CREDENTIAL_ISSUER = 'sealkeeper.run';
9
10
  // Issuers a verifier still accepts for a while after the cutover. A SEAL
@@ -50,11 +51,14 @@ const Count = z.int().min(0);
50
51
  // The version of the SEAL standard this issuer writes, carried as ver.
51
52
  export const SEAL_VERSION = 1;
52
53
  // Every version a verifier understands. Version 2 is version 1 plus
53
- // `counted`, the counted evidence the level read (VOU-139). CLIs 0.4.x
54
- // understand version 1 only and refuse any other ver, so the issuer keeps
55
- // writing version 1 until they are gone, and verifiers from this release
56
- // on accept both. SEAL standard section 9.
57
- export const SEAL_VERSIONS = [1, 2];
54
+ // `counted`, the counted evidence the level read (VOU-139). Version 3 is
55
+ // version 2 plus the posted counts, `fingerprint` and `state`, with the
56
+ // deprecated `version` dropped (VOU-77). CLIs before 0.4.5 understand
57
+ // version 1 only, and CLIs before 0.4.11 do not understand version 3, and
58
+ // each refuses a ver it does not know. So the issuer keeps writing version
59
+ // 1 until every CLI before 0.4.11 is gone. Verifiers accept all three from
60
+ // CLI 0.4.11 on. SEAL standard section 9.
61
+ export const SEAL_VERSIONS = [1, 2, 3];
58
62
  // One identity attestation reference, SEAL standard section 4a. A pointer
59
63
  // to an attestation an external provider made, never the attestation, a
60
64
  // name or a tenant id. kind is one of the four names or a URL for anything
@@ -76,8 +80,16 @@ export const IdentityReference = z.strictObject({
76
80
  // revoked, so every reference it still holds is current.
77
81
  export const operatorVerified = (identity) => identity.some((r) => r.scope === 'operator');
78
82
  // Each score is 0 to 1, or null when unearned (standard section 2). A
79
- // payload with a score outside that is malformed.
80
- const Scores = z.partialRecord(Dimension, z.number().min(0).max(1).nullable());
83
+ // payload with a score outside that is malformed. The issuer writes the
84
+ // base dimensions and competence by category only (Dimension). A verifier
85
+ // also accepts competence by task type (AcceptedDimension), the key SEALs
86
+ // carried before RT-3, so a SEAL issued before the change stays valid until
87
+ // it expires and a verifier never has to know which keys an issuer writes
88
+ // today. The API reads its stored SEALs back with the issued shape, so a
89
+ // stored SEAL with a task type key fails that parse and is reissued.
90
+ const Score = z.number().min(0).max(1).nullable();
91
+ const IssuedScores = z.partialRecord(Dimension, Score);
92
+ const VerifiedScores = z.partialRecord(AcceptedDimension, Score);
81
93
  // A SEAL lives at most 24 hours from issue, standard section 2. The issuer's
82
94
  // CREDENTIAL_TTL_HOURS may not go above it, and a payload whose exp is
83
95
  // further from its iat is malformed.
@@ -92,6 +104,26 @@ export const SEAL_CLOCK_SKEW_SECONDS = 300;
92
104
  // and parseSealPayload checks the clock with acceptedIssuer first.
93
105
  const IssuedIssuer = z.literal(CREDENTIAL_ISSUER);
94
106
  const VerifiedIssuer = z.enum([CREDENTIAL_ISSUER, ...LEGACY_ISSUERS]);
107
+ // The state of a version 3 SEAL, how the agent's current fingerprint stands
108
+ // against the one its level was last confirmed under. The set is closed.
109
+ // matches is the only value the issuer writes until the re-check flow
110
+ // exists. changed and provisional are reserved for it, so a verifier of
111
+ // version 3 already reads them.
112
+ export const SealState = z.enum(['matches', 'changed', 'provisional']);
113
+ // The fingerprint of a version 3 SEAL. hash is SHA-256 over bytes a later
114
+ // change to the standard defines, base64url, and a verifier treats it as
115
+ // opaque until then. at is Unix seconds of when the level was last
116
+ // confirmed under it, never after iat. null when the agent has sent no
117
+ // fingerprint. A 32 byte value in base64url has 43 characters and only
118
+ // some last characters, the rule agent-id.ts uses for a key.
119
+ export const SealFingerprint = z
120
+ .strictObject({
121
+ hash: z
122
+ .string()
123
+ .regex(/^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/, 'SHA-256, base64url'),
124
+ at: Seconds,
125
+ })
126
+ .nullable();
95
127
  const withinMaxTtl = (c) => c.exp - c.iat <= SEAL_MAX_TTL_SECONDS;
96
128
  const MAX_TTL_MESSAGE = 'exp must be at most 24 hours after iat';
97
129
  /*
@@ -104,7 +136,7 @@ const MAX_TTL_MESSAGE = 'exp must be at most 24 hours after iat';
104
136
  * Unix seconds of the agent's newest accepted event, null when it has sent
105
137
  * none, and dormant_days whole days since then at issue, null with it.
106
138
  */
107
- const v1Payload = (iss) => z
139
+ const v1Payload = (iss, scores) => z
108
140
  .strictObject({
109
141
  iss,
110
142
  sub: AgentId,
@@ -114,7 +146,7 @@ const v1Payload = (iss) => z
114
146
  agent_version: StoredVersion,
115
147
  version: StoredVersion,
116
148
  level: Level,
117
- scores: Scores,
149
+ scores,
118
150
  counts: StandingCounts,
119
151
  operator: z.strictObject({ verified: z.boolean() }),
120
152
  identity: z.array(IdentityReference).max(16),
@@ -129,7 +161,7 @@ const v1Payload = (iss) => z
129
161
  * counted evidence the level read (CountedCounts). counts stay the raw
130
162
  * facts. Each counted value is at most its raw count.
131
163
  */
132
- const v2Payload = (iss) => z
164
+ const v2Payload = (iss, scores) => z
133
165
  .strictObject({
134
166
  iss,
135
167
  sub: AgentId,
@@ -139,7 +171,7 @@ const v2Payload = (iss) => z
139
171
  agent_version: StoredVersion,
140
172
  version: StoredVersion,
141
173
  level: Level,
142
- scores: Scores,
174
+ scores,
143
175
  counts: StandingCounts,
144
176
  counted: CountedCounts,
145
177
  operator: z.strictObject({ verified: z.boolean() }),
@@ -153,27 +185,69 @@ const v2Payload = (iss) => z
153
185
  .refine((c) => c.counted.seed_tasks <= c.counts.seed_tasks &&
154
186
  c.counted.server_checked_tasks <= c.counts.server_checked_tasks &&
155
187
  c.counted.confirmed_tasks <= c.counts.confirmed_tasks, 'counted must not exceed counts');
156
- // The issuer side. iss is CREDENTIAL_ISSUER only.
157
- export const CredentialPayload = v1Payload(IssuedIssuer);
158
- export const CredentialPayloadV2 = v2Payload(IssuedIssuer);
159
- // The verifier side. iss may also be a LEGACY_ISSUERS entry. The shape has
188
+ /*
189
+ * Version 3. Every version 2 field with the same meaning except version,
190
+ * which is dropped (VOU-77), so agent_version alone names the agent
191
+ * version. counts gains the three posted counts (StandingCountsV3), counted
192
+ * gains the counted twins of posted_tasks and posted_confirmed_tasks
193
+ * (CountedCountsV3), and fingerprint and state are new. Each counted value
194
+ * is at most its raw count, and fingerprint.at is not after iat. Nothing
195
+ * issues it yet.
196
+ */
197
+ const v3Payload = (iss, scores) => z
198
+ .strictObject({
199
+ iss,
200
+ sub: AgentId,
201
+ ver: z.literal(3),
202
+ iat: Seconds,
203
+ exp: Seconds,
204
+ agent_version: StoredVersion,
205
+ level: Level,
206
+ scores,
207
+ counts: StandingCountsV3,
208
+ counted: CountedCountsV3,
209
+ fingerprint: SealFingerprint,
210
+ state: SealState,
211
+ operator: z.strictObject({ verified: z.boolean() }),
212
+ identity: z.array(IdentityReference).max(16),
213
+ last_active: Seconds.nullable(),
214
+ dormant_days: Count.nullable(),
215
+ })
216
+ .refine((c) => c.exp > c.iat, 'exp must be after iat')
217
+ .refine(withinMaxTtl, MAX_TTL_MESSAGE)
218
+ .refine((c) => c.counted.seed_tasks <= c.counts.seed_tasks &&
219
+ c.counted.server_checked_tasks <= c.counts.server_checked_tasks &&
220
+ c.counted.confirmed_tasks <= c.counts.confirmed_tasks &&
221
+ c.counted.posted_tasks <= c.counts.posted_tasks &&
222
+ c.counted.posted_confirmed_tasks <= c.counts.posted_confirmed_tasks, 'counted must not exceed counts')
223
+ .refine((c) => c.fingerprint === null || c.fingerprint.at <= c.iat, 'fingerprint.at must not be after iat');
224
+ // The issuer side. iss is CREDENTIAL_ISSUER only, and scores carry
225
+ // competence by category only.
226
+ export const CredentialPayload = v1Payload(IssuedIssuer, IssuedScores);
227
+ export const CredentialPayloadV2 = v2Payload(IssuedIssuer, IssuedScores);
228
+ export const CredentialPayloadV3 = v3Payload(IssuedIssuer, IssuedScores);
229
+ // The verifier side. iss may also be a LEGACY_ISSUERS entry, and scores may
230
+ // also carry competence by task type. The shape has
160
231
  // no clock, so read these through parseSealPayload, never on their own.
161
- export const VerifiedCredentialPayload = v1Payload(VerifiedIssuer);
162
- export const VerifiedCredentialPayloadV2 = v2Payload(VerifiedIssuer);
163
- // Any payload a verifier accepts today, version 1 or version 2, from the
164
- // current issuer or a legacy one. Version 2 has every version 1 field with
165
- // the same meaning, so a reader of version 1 fields takes both.
232
+ export const VerifiedCredentialPayload = v1Payload(VerifiedIssuer, VerifiedScores);
233
+ export const VerifiedCredentialPayloadV2 = v2Payload(VerifiedIssuer, VerifiedScores);
234
+ export const VerifiedCredentialPayloadV3 = v3Payload(VerifiedIssuer, VerifiedScores);
235
+ // Any payload a verifier accepts today, version 1, 2 or 3, from the current
236
+ // issuer or a legacy one. Each version has every field of the one before
237
+ // with the same meaning, except version, which version 3 drops. A reader
238
+ // takes the agent version from agent_version, which all three carry.
166
239
  export const SealPayload = z.union([
167
240
  VerifiedCredentialPayload,
168
241
  VerifiedCredentialPayloadV2,
242
+ VerifiedCredentialPayloadV3,
169
243
  ]);
170
244
  // The counted evidence a SEAL carries, version 2 on, null before.
171
245
  export const sealCounted = (p) => 'counted' in p ? p.counted : null;
172
246
  const hasVer = (raw) => typeof raw === 'object' && raw !== null && 'ver' in raw;
173
247
  /*
174
248
  * Whether a verifier understands the version of a signed payload. Read
175
- * after the signature and the issuer check out and before the shape. ver 1
176
- * and 2 (SEAL_VERSIONS) are understood. Any other ver is
249
+ * after the signature and the issuer check out and before the shape. ver 1,
250
+ * 2 and 3 (SEAL_VERSIONS) are understood. Any other ver is
177
251
  * unsupported_version, as section 9 of the standard says, never valid with
178
252
  * an unknown meaning. So is no ver at all, a SEAL issued before version 1,
179
253
  * whose last one expired on 26 September 2026. Anything that is not an
@@ -210,9 +284,12 @@ export function parseSealPayload(raw, nowSeconds) {
210
284
  const problem = sealVersionProblem(raw);
211
285
  if (problem)
212
286
  return { ok: false, reason: problem };
213
- const parsed = (hasVer(raw) && raw.ver === 2
214
- ? VerifiedCredentialPayloadV2
215
- : VerifiedCredentialPayload).safeParse(raw);
287
+ const ver = hasVer(raw) ? raw.ver : undefined;
288
+ const parsed = (ver === 3
289
+ ? VerifiedCredentialPayloadV3
290
+ : ver === 2
291
+ ? VerifiedCredentialPayloadV2
292
+ : VerifiedCredentialPayload).safeParse(raw);
216
293
  return parsed.success
217
294
  ? { ok: true, payload: parsed.data }
218
295
  : { ok: false, reason: 'malformed' };
@@ -241,10 +318,17 @@ export const LegacySealExtension = z.strictObject({
241
318
  description: z.string().min(1).max(512),
242
319
  params: z.strictObject({ credential: Jws }),
243
320
  });
321
+ // The current extension may also carry handshake, the agent's signed
322
+ // handshake (VB-6, ./handshake.ts) beside the SEAL, refreshed each time the
323
+ // card is written. A reader takes params loosely, so one that does not know
324
+ // handshake ignores it. The two old URIs carry the SEAL alone.
244
325
  export const SealExtension = z.strictObject({
245
326
  uri: z.literal(SEAL_EXTENSION_URI),
246
327
  description: z.string().min(1).max(512),
247
- params: z.strictObject({ credential: Jws }),
328
+ params: z.strictObject({
329
+ credential: Jws,
330
+ handshake: Jws.max(HANDSHAKE_MAX_CHARS).optional(),
331
+ }),
248
332
  });
249
333
  export const credentialExtension = (jws) => ({
250
334
  uri: CREDENTIAL_EXTENSION_URI,
@@ -256,15 +340,17 @@ export const legacySealExtension = (jws) => ({
256
340
  description: EXTENSION_DESCRIPTION,
257
341
  params: { credential: jws },
258
342
  });
259
- export const sealExtension = (jws) => ({
343
+ export const sealExtension = (jws, handshake) => ({
260
344
  uri: SEAL_EXTENSION_URI,
261
345
  description: EXTENSION_DESCRIPTION,
262
- params: { credential: jws },
346
+ params: handshake === undefined
347
+ ? { credential: jws }
348
+ : { credential: jws, handshake },
263
349
  });
264
350
  // The extensions a card carries for one SEAL, in SEAL_EXTENSION_URIS order,
265
- // the current URI first.
266
- export const sealExtensions = (jws) => [
267
- sealExtension(jws),
351
+ // the current URI first. A handshake goes on the current one only.
352
+ export const sealExtensions = (jws, handshake) => [
353
+ sealExtension(jws, handshake),
268
354
  legacySealExtension(jws),
269
355
  credentialExtension(jws),
270
356
  ];
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { TaskCategory } from './tasks.js';
2
3
  export declare const TaskType: z.ZodString;
3
4
  export type TaskType = z.infer<typeof TaskType>;
4
5
  export declare const BaseDimension: z.ZodEnum<{
@@ -8,14 +9,26 @@ export declare const BaseDimension: z.ZodEnum<{
8
9
  safety: "safety";
9
10
  }>;
10
11
  export type BaseDimension = z.infer<typeof BaseDimension>;
11
- export declare const CompetenceDimension: z.ZodTemplateLiteral<`competence:${string}`>;
12
+ export declare const CompetenceDimension: z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">;
12
13
  export type CompetenceDimension = z.infer<typeof CompetenceDimension>;
14
+ export declare const COMPETENCE_TYPES_MAX = 32;
15
+ export declare const COMPETENCE_DIMENSIONS: readonly CompetenceDimension[];
13
16
  export declare const Dimension: z.ZodUnion<readonly [z.ZodEnum<{
14
17
  cost_latency: "cost_latency";
15
18
  provenance: "provenance";
16
19
  reliability: "reliability";
17
20
  safety: "safety";
18
- }>, z.ZodTemplateLiteral<`competence:${string}`>]>;
21
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">]>;
19
22
  export type Dimension = z.infer<typeof Dimension>;
20
- export declare const competence: (taskType: TaskType) => CompetenceDimension;
23
+ export declare const TypeCompetenceDimension: z.ZodTemplateLiteral<`competence:${string}`>;
24
+ export type TypeCompetenceDimension = z.infer<typeof TypeCompetenceDimension>;
25
+ export declare const AcceptedDimension: z.ZodUnion<readonly [z.ZodEnum<{
26
+ cost_latency: "cost_latency";
27
+ provenance: "provenance";
28
+ reliability: "reliability";
29
+ safety: "safety";
30
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">, z.ZodTemplateLiteral<`competence:${string}`>]>;
31
+ export type AcceptedDimension = z.infer<typeof AcceptedDimension>;
32
+ export declare const competence: (category: TaskCategory) => CompetenceDimension;
33
+ export declare const categoryOf: (dimension: string) => TaskCategory | null;
21
34
  export declare const isTrustDimension: (dimension: string) => boolean;