@sealkeeper/schema 0.4.8 → 0.4.9

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.
@@ -5,6 +5,7 @@ import { Jws } from './envelope.js';
5
5
  import { StoredVersion } from './events.js';
6
6
  import { HANDSHAKE_MAX_CHARS } from './handshake.js';
7
7
  import { CountedCounts, CountedCountsV3, Level, StandingCounts, StandingCountsV3, } from './standing.js';
8
+ import { STORED_TASK_CATEGORIES, StoredTaskCategory } from './tasks.js';
8
9
  // The issuer every SEAL carries as iss from the SealKeeper cutover on.
9
10
  export const CREDENTIAL_ISSUER = 'sealkeeper.run';
10
11
  // Issuers a verifier still accepts for a while after the cutover. A SEAL
@@ -48,17 +49,33 @@ export const SEAL_EXTENSION_URIS = [
48
49
  ];
49
50
  const Seconds = z.int().min(0);
50
51
  const Count = z.int().min(0);
51
- // The version of the SEAL standard this issuer writes, carried as ver.
52
+ // Version 1 of the SEAL standard, the ver of a version 1 SEAL. The API
53
+ // writes version 1, 3 or 4, whichever its SEAL_ISSUE_VERSION names.
52
54
  export const SEAL_VERSION = 1;
53
55
  // Every version a verifier understands. Version 2 is version 1 plus
54
56
  // `counted`, the counted evidence the level read (VOU-139). Version 3 is
55
57
  // 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
+ // deprecated `version` dropped (VOU-77). Version 4 is version 3 plus
59
+ // `trust` and `top_categories` (VOU-560). CLIs before 0.4.5 understand
60
+ // version 1 only, CLIs before 0.4.11 do not understand version 3 and CLIs
61
+ // before 0.4.14 do not understand version 4, and each refuses a ver it does
62
+ // not know. So the issuer keeps writing version 1 until every CLI before
63
+ // the first that reads the version it moves to is gone, and then moves
64
+ // when the API's SEAL_ISSUE_VERSION is set by hand. Verifiers accept
65
+ // versions 1, 2 and 3 from CLI 0.4.11 on and all four from CLI 0.4.14 on.
66
+ // SEAL standard section 9.
67
+ export const SEAL_VERSIONS = [1, 2, 3, 4];
68
+ // The first CLI that reads SEAL version 3, a CliVersion. Gone means no CLI
69
+ // older than this, and no signed request without a CLI version, for
70
+ // SEAL_V3_QUIET_DAYS whole days. GET /internal/metrics measures it from
71
+ // the CLI version each signed request names (VOU-454), in cliVersions.
72
+ export const SEAL_V3_FIRST_CLI = '0.4.11';
73
+ export const SEAL_V3_QUIET_DAYS = 14;
74
+ // The first CLI that reads SEAL version 4, a CliVersion, under the same
75
+ // rule and the same SEAL_V3_QUIET_DAYS. It is also the first CLI that
76
+ // names its version on a signed request, so every older one is a request
77
+ // without a CLI version, which cliVersions already counts as old.
78
+ export const SEAL_V4_FIRST_CLI = '0.4.14';
62
79
  // One identity attestation reference, SEAL standard section 4a. A pointer
63
80
  // to an attestation an external provider made, never the attestation, a
64
81
  // name or a tenant id. kind is one of the four names or a URL for anything
@@ -98,22 +115,26 @@ export const SEAL_MAX_TTL_SECONDS = 24 * 3600;
98
115
  // valid. Five minutes covers clock drift between issuer and verifier.
99
116
  export const SEAL_CLOCK_SKEW_SECONDS = 300;
100
117
  // iss on the issuer side is CREDENTIAL_ISSUER and nothing else. The API
101
- // writes it and reads its stored SEALs back with CredentialPayload, so a
118
+ // writes it and reads its stored SEALs back with IssuedSealPayload, so a
102
119
  // stored SEAL with a legacy issuer fails that parse and is reissued. Only
103
120
  // a verifier accepts a legacy issuer, through the Verified shapes below,
104
121
  // and parseSealPayload checks the clock with acceptedIssuer first.
105
122
  const IssuedIssuer = z.literal(CREDENTIAL_ISSUER);
106
123
  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.
124
+ // The state of a version 3 or 4 SEAL, how the agent's current fingerprint
125
+ // stands against the one the SEAL carries. The set is closed. matches is
126
+ // the only value the issuer writes until the re-check flow exists, and
127
+ // means only that the fingerprint is the one on the issuer's record at
128
+ // issue. With a null fingerprint it says nothing. changed and provisional
129
+ // are reserved for that flow, so a verifier of version 3 already reads
130
+ // them.
112
131
  export const SealState = z.enum(['matches', 'changed', 'provisional']);
113
- // The fingerprint of a version 3 SEAL. hash is SHA-256 over bytes a later
132
+ // The fingerprint of a version 3 or 4 SEAL. hash is SHA-256 over bytes a later
114
133
  // 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
134
+ // opaque until then. It is the agent's current fingerprint on the issuer's
135
+ // record at issue. at is Unix seconds of when the agent's software says it
136
+ // captured it, never after iat, unchecked, and no level is checked against
137
+ // it (SEAL standard section 4b). null when the agent has sent no
117
138
  // fingerprint. A 32 byte value in base64url has 43 characters and only
118
139
  // some last characters, the rule agent-id.ts uses for a key.
119
140
  export const SealFingerprint = z
@@ -124,6 +145,65 @@ export const SealFingerprint = z
124
145
  at: Seconds,
125
146
  })
126
147
  .nullable();
148
+ // The most entries top_categories of a version 4 SEAL holds.
149
+ export const SEAL_TOP_CATEGORIES_MAX = 3;
150
+ // One entry of top_categories in a version 4 SEAL, a category of the
151
+ // agent version's Trust Score and its score there, a whole number.
152
+ export const SealTopCategory = z.strictObject({
153
+ category: StoredTaskCategory,
154
+ score: Count,
155
+ });
156
+ // A stored score as a SEAL carries it, rounded as the Trust answer rounds.
157
+ // A value that is not a finite number, which no scoring run writes, reads 0.
158
+ const whole = (n) => Number.isFinite(n) ? Math.max(0, Math.round(n)) : 0;
159
+ const categoryOrder = (c) => STORED_TASK_CATEGORIES.indexOf(c);
160
+ // Highest score first, a tie in the order of STORED_TASK_CATEGORIES, the
161
+ // order topDimensions keeps for the competence categories. Negative when a
162
+ // goes first.
163
+ const bySealOrder = (a, b) => b.score - a.score || categoryOrder(a.category) - categoryOrder(b.category);
164
+ // top_categories of a version 4 SEAL. At most SEAL_TOP_CATEGORIES_MAX,
165
+ // each category once, in bySealOrder, so the order a verifier reads is the
166
+ // one sealTrust writes.
167
+ export const SealTopCategories = z
168
+ .array(SealTopCategory)
169
+ .max(SEAL_TOP_CATEGORIES_MAX)
170
+ .refine((list) => list.every((c, i) => i === 0 || bySealOrder(list[i - 1], c) < 0), 'top_categories must be highest first, a tie in category order, each category once');
171
+ /*
172
+ * trust and top_categories of a version 4 SEAL, from the stored rows the
173
+ * scoring run wrote for the agent version the SEAL is for, its Trust Score
174
+ * (standing.trust_score) and its categories (standing.trust_categories).
175
+ * The issuer computes nothing new. trust is the Trust Score rounded to a
176
+ * whole number as GET /v1/agents/:id/trust rounds it, 0 with none stored.
177
+ * top_categories is the SEAL_TOP_CATEGORIES_MAX categories with the
178
+ * highest stored score, a tie in category order, chosen before rounding so
179
+ * they are the three the trust answer ranks first, save an exact tie at the
180
+ * third, which it breaks by name. Each is then rounded the same way and put
181
+ * in bySealOrder, empty with none stored. A key that is not a stored task
182
+ * category and an entry without a finite score are left out, and a
183
+ * trust_score that is not finite reads 0, so a stray stored value never
184
+ * stops a SEAL from being issued. The issuer reads this and nothing else
185
+ * for the two fields, and the verifier's shape holds the same order. A
186
+ * value is never below 0, as no stored score is, so a SEAL is never
187
+ * refused over it.
188
+ */
189
+ export function sealTrust(score, categories) {
190
+ const stored = [];
191
+ for (const [key, c] of Object.entries(categories ?? {})) {
192
+ const category = StoredTaskCategory.safeParse(key);
193
+ const raw = c?.score;
194
+ if (category.success && typeof raw === 'number' && Number.isFinite(raw)) {
195
+ stored.push({ category: category.data, score: raw });
196
+ }
197
+ }
198
+ return {
199
+ trust: whole(score ?? 0),
200
+ top_categories: stored
201
+ .sort(bySealOrder)
202
+ .slice(0, SEAL_TOP_CATEGORIES_MAX)
203
+ .map((c) => ({ category: c.category, score: whole(c.score) }))
204
+ .sort(bySealOrder),
205
+ };
206
+ }
127
207
  const withinMaxTtl = (c) => c.exp - c.iat <= SEAL_MAX_TTL_SECONDS;
128
208
  const MAX_TTL_MESSAGE = 'exp must be at most 24 hours after iat';
129
209
  /*
@@ -191,8 +271,8 @@ const v2Payload = (iss, scores) => z
191
271
  * version. counts gains the three posted counts (StandingCountsV3), counted
192
272
  * gains the counted twins of posted_tasks and posted_confirmed_tasks
193
273
  * (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.
274
+ * is at most its raw count, and fingerprint.at is not after iat. The API
275
+ * issues it when its SEAL_ISSUE_VERSION is 3.
196
276
  */
197
277
  const v3Payload = (iss, scores) => z
198
278
  .strictObject({
@@ -221,25 +301,75 @@ const v3Payload = (iss, scores) => z
221
301
  c.counted.posted_tasks <= c.counts.posted_tasks &&
222
302
  c.counted.posted_confirmed_tasks <= c.counts.posted_confirmed_tasks, 'counted must not exceed counts')
223
303
  .refine((c) => c.fingerprint === null || c.fingerprint.at <= c.iat, 'fingerprint.at must not be after iat');
304
+ /*
305
+ * Version 4. Every version 3 field with the same meaning, plus trust and
306
+ * top_categories (VOU-560, D-UI-4, D-UI-5), both from sealTrust. trust is
307
+ * the Trust Score of the agent version the SEAL is for, a whole number.
308
+ * top_categories is its highest categories, at most three, in the order
309
+ * SealTopCategories holds. Both are what the agent has earned, read from
310
+ * the issuer's own rows at issue, never a permission and never a level.
311
+ * The API issues it when its SEAL_ISSUE_VERSION is 4.
312
+ */
313
+ const v4Payload = (iss, scores) => z
314
+ .strictObject({
315
+ iss,
316
+ sub: AgentId,
317
+ ver: z.literal(4),
318
+ iat: Seconds,
319
+ exp: Seconds,
320
+ agent_version: StoredVersion,
321
+ level: Level,
322
+ scores,
323
+ counts: StandingCountsV3,
324
+ counted: CountedCountsV3,
325
+ fingerprint: SealFingerprint,
326
+ state: SealState,
327
+ trust: Count,
328
+ top_categories: SealTopCategories,
329
+ operator: z.strictObject({ verified: z.boolean() }),
330
+ identity: z.array(IdentityReference).max(16),
331
+ last_active: Seconds.nullable(),
332
+ dormant_days: Count.nullable(),
333
+ })
334
+ .refine((c) => c.exp > c.iat, 'exp must be after iat')
335
+ .refine(withinMaxTtl, MAX_TTL_MESSAGE)
336
+ .refine((c) => c.counted.seed_tasks <= c.counts.seed_tasks &&
337
+ c.counted.server_checked_tasks <= c.counts.server_checked_tasks &&
338
+ c.counted.confirmed_tasks <= c.counts.confirmed_tasks &&
339
+ c.counted.posted_tasks <= c.counts.posted_tasks &&
340
+ c.counted.posted_confirmed_tasks <= c.counts.posted_confirmed_tasks, 'counted must not exceed counts')
341
+ .refine((c) => c.fingerprint === null || c.fingerprint.at <= c.iat, 'fingerprint.at must not be after iat');
224
342
  // The issuer side. iss is CREDENTIAL_ISSUER only, and scores carry
225
343
  // competence by category only.
226
344
  export const CredentialPayload = v1Payload(IssuedIssuer, IssuedScores);
227
345
  export const CredentialPayloadV2 = v2Payload(IssuedIssuer, IssuedScores);
228
346
  export const CredentialPayloadV3 = v3Payload(IssuedIssuer, IssuedScores);
347
+ export const CredentialPayloadV4 = v4Payload(IssuedIssuer, IssuedScores);
348
+ // What the issuer writes, version 1, 3 or 4, whichever the API's
349
+ // SEAL_ISSUE_VERSION names. The API serves it and reads its stored SEALs
350
+ // back with it, so a SEAL stored before the setting changed still parses
351
+ // and is reissued once. Version 2 is never issued.
352
+ export const IssuedSealPayload = z.union([
353
+ CredentialPayload,
354
+ CredentialPayloadV3,
355
+ CredentialPayloadV4,
356
+ ]);
229
357
  // The verifier side. iss may also be a LEGACY_ISSUERS entry, and scores may
230
358
  // also carry competence by task type. The shape has
231
359
  // no clock, so read these through parseSealPayload, never on their own.
232
360
  export const VerifiedCredentialPayload = v1Payload(VerifiedIssuer, VerifiedScores);
233
361
  export const VerifiedCredentialPayloadV2 = v2Payload(VerifiedIssuer, VerifiedScores);
234
362
  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.
363
+ export const VerifiedCredentialPayloadV4 = v4Payload(VerifiedIssuer, VerifiedScores);
364
+ // Any payload a verifier accepts today, version 1, 2, 3 or 4, from the
365
+ // current issuer or a legacy one. Each version has every field of the one
366
+ // before with the same meaning, except version, which version 3 drops. A
367
+ // reader takes the agent version from agent_version, which all four carry.
239
368
  export const SealPayload = z.union([
240
369
  VerifiedCredentialPayload,
241
370
  VerifiedCredentialPayloadV2,
242
371
  VerifiedCredentialPayloadV3,
372
+ VerifiedCredentialPayloadV4,
243
373
  ]);
244
374
  // The counted evidence a SEAL carries, version 2 on, null before.
245
375
  export const sealCounted = (p) => 'counted' in p ? p.counted : null;
@@ -247,7 +377,7 @@ const hasVer = (raw) => typeof raw === 'object' && raw !== null && 'ver' in raw;
247
377
  /*
248
378
  * Whether a verifier understands the version of a signed payload. Read
249
379
  * 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
380
+ * 2, 3 and 4 (SEAL_VERSIONS) are understood. Any other ver is
251
381
  * unsupported_version, as section 9 of the standard says, never valid with
252
382
  * an unknown meaning. So is no ver at all, a SEAL issued before version 1,
253
383
  * whose last one expired on 26 September 2026. Anything that is not an
@@ -285,11 +415,13 @@ export function parseSealPayload(raw, nowSeconds) {
285
415
  if (problem)
286
416
  return { ok: false, reason: problem };
287
417
  const ver = hasVer(raw) ? raw.ver : undefined;
288
- const parsed = (ver === 3
289
- ? VerifiedCredentialPayloadV3
290
- : ver === 2
291
- ? VerifiedCredentialPayloadV2
292
- : VerifiedCredentialPayload).safeParse(raw);
418
+ const parsed = (ver === 4
419
+ ? VerifiedCredentialPayloadV4
420
+ : ver === 3
421
+ ? VerifiedCredentialPayloadV3
422
+ : ver === 2
423
+ ? VerifiedCredentialPayloadV2
424
+ : VerifiedCredentialPayload).safeParse(raw);
293
425
  return parsed.success
294
426
  ? { ok: true, payload: parsed.data }
295
427
  : { ok: false, reason: 'malformed' };
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { TaskCategory } from './tasks.js';
2
+ import { StoredTaskCategory } from './tasks.js';
3
3
  export declare const TaskType: z.ZodString;
4
4
  export type TaskType = z.infer<typeof TaskType>;
5
5
  export declare const BaseDimension: z.ZodEnum<{
@@ -9,7 +9,7 @@ export declare const BaseDimension: z.ZodEnum<{
9
9
  safety: "safety";
10
10
  }>;
11
11
  export type BaseDimension = z.infer<typeof BaseDimension>;
12
- export declare const CompetenceDimension: z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">;
12
+ export declare const CompetenceDimension: z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:math" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">;
13
13
  export type CompetenceDimension = z.infer<typeof CompetenceDimension>;
14
14
  export declare const COMPETENCE_TYPES_MAX = 32;
15
15
  export declare const COMPETENCE_DIMENSIONS: readonly CompetenceDimension[];
@@ -18,7 +18,7 @@ export declare const Dimension: z.ZodUnion<readonly [z.ZodEnum<{
18
18
  provenance: "provenance";
19
19
  reliability: "reliability";
20
20
  safety: "safety";
21
- }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">]>;
21
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:math" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">]>;
22
22
  export type Dimension = z.infer<typeof Dimension>;
23
23
  export declare const TypeCompetenceDimension: z.ZodTemplateLiteral<`competence:${string}`>;
24
24
  export type TypeCompetenceDimension = z.infer<typeof TypeCompetenceDimension>;
@@ -27,8 +27,8 @@ export declare const AcceptedDimension: z.ZodUnion<readonly [z.ZodEnum<{
27
27
  provenance: "provenance";
28
28
  reliability: "reliability";
29
29
  safety: "safety";
30
- }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">, z.ZodTemplateLiteral<`competence:${string}`>]>;
30
+ }>, z.ZodTemplateLiteral<"competence:code" | "competence:conversation" | "competence:data" | "competence:math" | "competence:operations" | "competence:other" | "competence:research" | "competence:writing">, z.ZodTemplateLiteral<`competence:${string}`>]>;
31
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;
32
+ export declare const competence: (category: StoredTaskCategory) => CompetenceDimension;
33
+ export declare const categoryOf: (dimension: string) => StoredTaskCategory | null;
34
34
  export declare const isTrustDimension: (dimension: string) => boolean;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { TASK_CATEGORIES, TaskCategory } from './tasks.js';
2
+ import { STORED_TASK_CATEGORIES, StoredTaskCategory } from './tasks.js';
3
3
  export const TaskType = z.string().regex(/^[a-z0-9_-]{1,32}$/);
4
4
  export const BaseDimension = z.enum([
5
5
  'reliability',
@@ -11,21 +11,25 @@ export const BaseDimension = z.enum([
11
11
  * Competence rolls up to the task's category (RT-3), one dimension per
12
12
  * category, competence:data and so on. The per task type values stay a
13
13
  * breakdown under the category on the score answer and are never a
14
- * dimension of their own.
14
+ * dimension of their own. It reads the stored categories, conversation and
15
+ * other included, since a task keeps the category it was scored under
16
+ * (D-UI-12), so the run still scores them and a stored score or a SEAL
17
+ * that names one still parses until its tasks leave the window.
15
18
  */
16
19
  export const CompetenceDimension = z.templateLiteral([
17
20
  'competence:',
18
- TaskCategory,
21
+ StoredTaskCategory,
19
22
  ]);
20
23
  // The most task types a competence entry's breakdown lists, the most
21
24
  // claimed first, so the answer stays small however many free task types an
22
25
  // agent took.
23
26
  export const COMPETENCE_TYPES_MAX = 32;
24
- // The seven competence dimensions in category order, the order every list
25
- // shows them in.
26
- export const COMPETENCE_DIMENSIONS = TASK_CATEGORIES.map((c) => CompetenceDimension.parse(`competence:${c}`));
27
+ // The eight competence dimensions in stored category order, the order every
28
+ // list shows them in. The scoring run keeps a stored competence row only
29
+ // when it names one of them.
30
+ export const COMPETENCE_DIMENSIONS = STORED_TASK_CATEGORIES.map((c) => CompetenceDimension.parse(`competence:${c}`));
27
31
  // What the issuer writes and what a request may name, the base dimensions
28
- // and the seven competence categories.
32
+ // and the eight competence categories.
29
33
  export const Dimension = z.union([BaseDimension, CompetenceDimension]);
30
34
  /*
31
35
  * competence:<task_type>, the competence key SEALs carried before RT-3,
@@ -128,5 +128,6 @@ export declare const FingerprintDeclaration: z.ZodObject<{
128
128
  hash: z.ZodString;
129
129
  captured_at: z.ZodNumber;
130
130
  }, z.core.$strict>;
131
+ model: z.ZodOptional<z.ZodString>;
131
132
  }, z.core.$strict>;
132
133
  export type FingerprintDeclaration = z.infer<typeof FingerprintDeclaration>;
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { AgentId } from './agent-id.js';
3
3
  import { base64urlEncode, utf8Encode } from './base64url.js';
4
+ import { ModelName } from './model-name.js';
4
5
  /*
5
6
  * The fingerprint of what an agent runs now, beside its version and never in
6
7
  * place of it (D-VB-1). The version stays the operator's label and the
@@ -161,6 +162,17 @@ export function agentFingerprintOf(fingerprint) {
161
162
  // The signed payload of the fingerprint a sync declares (VB-4). A batch's
162
163
  // envelopes are events, so the fingerprint travels as its own JWS, signed
163
164
  // by the same agent, under fingerprint on EventsBatchRequest.
165
+ //
166
+ // model is the name of the model the agent runs, as text (VOU-566), the one
167
+ // place a signed report names it. Optional, so a declaration from a CLI
168
+ // before it parses. It rides here rather than as an event type, since this
169
+ // report is already signed, already sent at every sync and already the
170
+ // record of what the agent runs, and an API from before the field refuses
171
+ // only the declaration, which the CLI sends again without it, where an
172
+ // unknown event type would refuse the whole batch. The name is what the
173
+ // agent says. Nothing reads it as proof, and it is not a part, so the
174
+ // fingerprint and its hash stay as they are.
164
175
  export const FingerprintDeclaration = z.strictObject({
165
176
  fingerprint: Fingerprint,
177
+ model: ModelName.optional(),
166
178
  });
package/dist/game.d.ts ADDED
@@ -0,0 +1,100 @@
1
+ import { z } from 'zod';
2
+ export declare const GAME_CAP_MAX = 5;
3
+ export declare const GameCap: z.ZodInt;
4
+ export type GameCap = z.infer<typeof GameCap>;
5
+ export declare const DUEL_SEEK_STATES: readonly ['open', 'matched', 'expired', 'cancelled'];
6
+ export declare const DuelSeekState: z.ZodEnum<{
7
+ cancelled: "cancelled";
8
+ expired: "expired";
9
+ matched: "matched";
10
+ open: "open";
11
+ }>;
12
+ export type DuelSeekState = z.infer<typeof DuelSeekState>;
13
+ export declare const DUEL_STATES: readonly ['invited', 'active', 'finished', 'aborted', 'declined', 'expired'];
14
+ export declare const DuelState: z.ZodEnum<{
15
+ aborted: "aborted";
16
+ active: "active";
17
+ declined: "declined";
18
+ expired: "expired";
19
+ finished: "finished";
20
+ invited: "invited";
21
+ }>;
22
+ export type DuelState = z.infer<typeof DuelState>;
23
+ export declare const DUEL_ORIGINS: readonly ['seek', 'challenge', 'rematch', 'web'];
24
+ export declare const DuelOrigin: z.ZodEnum<{
25
+ challenge: "challenge";
26
+ rematch: "rematch";
27
+ seek: "seek";
28
+ web: "web";
29
+ }>;
30
+ export type DuelOrigin = z.infer<typeof DuelOrigin>;
31
+ export declare const DUEL_RESULTS: readonly ['challenger_win', 'opponent_win', 'draw'];
32
+ export declare const DuelResult: z.ZodEnum<{
33
+ challenger_win: "challenger_win";
34
+ draw: "draw";
35
+ opponent_win: "opponent_win";
36
+ }>;
37
+ export type DuelResult = z.infer<typeof DuelResult>;
38
+ export declare const DUEL_RATING_START = 1200;
39
+ export declare const DUEL_RATING_K_NEW = 32;
40
+ export declare const DUEL_RATING_K = 16;
41
+ export declare const DUEL_RATING_NEW_DUELS = 30;
42
+ export type DuelRatingSide = {
43
+ rating: number;
44
+ ratedDuels: number;
45
+ };
46
+ export type DuelRatingMove = {
47
+ before: number;
48
+ after: number;
49
+ k: number;
50
+ };
51
+ export declare const duelRatingK: (ratedDuels: number) => number;
52
+ export declare function duelRatingMoves(a: DuelRatingSide, b: DuelRatingSide, scoreA: 0 | 0.5 | 1): [DuelRatingMove, DuelRatingMove];
53
+ export declare const CHALLENGE_STATES: readonly ['open', 'closed'];
54
+ export declare const ChallengeState: z.ZodEnum<{
55
+ closed: "closed";
56
+ open: "open";
57
+ }>;
58
+ export type ChallengeState = z.infer<typeof ChallengeState>;
59
+ export declare const CHALLENGE_TASKS = 10;
60
+ export declare const ISO_WEEK_PATTERN = "^[0-9]{4}-W(0[1-9]|[1-4][0-9]|5[0-3])$";
61
+ export declare const IsoWeek: z.ZodString;
62
+ export type IsoWeek = z.infer<typeof IsoWeek>;
63
+ export declare function isoWeekOf(at: Date): IsoWeek;
64
+ export declare const KEEPER_RANKS: readonly ['apprentice', 'keeper', 'master_keeper'];
65
+ export declare const KeeperRank: z.ZodEnum<{
66
+ apprentice: "apprentice";
67
+ keeper: "keeper";
68
+ master_keeper: "master_keeper";
69
+ }>;
70
+ export type KeeperRank = z.infer<typeof KeeperRank>;
71
+ export declare const GAME_BADGE_KINDS: readonly ['finisher', 'top_10', 'winner'];
72
+ export declare const GameBadgeKind: z.ZodEnum<{
73
+ finisher: "finisher";
74
+ top_10: "top_10";
75
+ winner: "winner";
76
+ }>;
77
+ export type GameBadgeKind = z.infer<typeof GameBadgeKind>;
78
+ export declare const GAME: {
79
+ readonly seekHours: 24;
80
+ readonly inviteHours: 24;
81
+ readonly duelHours: 48;
82
+ readonly openOutgoingMax: 2;
83
+ readonly requestsPerDay: 10;
84
+ readonly pairDays: 7;
85
+ readonly ratingBand: 200;
86
+ readonly ratingBandWide: 400;
87
+ readonly wideAfterHours: 12;
88
+ readonly drawMs: 1000;
89
+ readonly duelSubmits: 1;
90
+ readonly provisionalDuels: 10;
91
+ readonly recentDuels: 5;
92
+ readonly summaryBadges: 52;
93
+ readonly challengeSubmits: 1;
94
+ readonly challengeRankMax: 10000;
95
+ readonly challengeTopPlaces: 10;
96
+ readonly challengeTopEntrants: 20;
97
+ readonly challengeWinnerEntrants: 5;
98
+ readonly challengePlaceCorrect: 1;
99
+ readonly challengePodium: 3;
100
+ };