@sealkeeper/schema 0.4.9 → 0.5.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/api.d.ts CHANGED
@@ -158,7 +158,7 @@ export type AgentResponse = z.infer<typeof AgentResponse>;
158
158
  export declare const RENAME_REDIRECT_DAYS = 90;
159
159
  export declare const SLUG_REDIRECT_DAYS = 90;
160
160
  export declare const SLUG_CHANGE_DAYS = 30;
161
- export declare const RENAME_MAX_AGE_SEC = 300;
161
+ export declare const SIGNED_REQUEST_MAX_AGE_SEC = 300;
162
162
  export declare const RenameAgentRequest: z.ZodObject<{
163
163
  name: z.ZodString;
164
164
  issuedAt: z.ZodISODateTime;
@@ -190,7 +190,6 @@ export declare const SignedRenameRequest: z.ZodObject<{
190
190
  envelope: z.ZodString;
191
191
  }, z.core.$strict>;
192
192
  export type SignedRenameRequest = z.infer<typeof SignedRenameRequest>;
193
- export declare const DELETE_AGENT_MAX_AGE_SEC = 300;
194
193
  export declare const DeleteAgentRequest: z.ZodObject<{
195
194
  issuedAt: z.ZodISODateTime;
196
195
  }, z.core.$strict>;
@@ -204,7 +203,6 @@ export declare const GameSettingsRequest: z.ZodObject<{
204
203
  cap: z.ZodOptional<z.ZodInt>;
205
204
  }, z.core.$strict>;
206
205
  export type GameSettingsRequest = z.infer<typeof GameSettingsRequest>;
207
- export declare const GAME_REQUEST_MAX_AGE_SEC = 300;
208
206
  export declare const SignedGameSettingsRequest: z.ZodObject<{
209
207
  enabled: z.ZodOptional<z.ZodBoolean>;
210
208
  cap: z.ZodOptional<z.ZodInt>;
@@ -229,8 +227,30 @@ export declare const GameStatusResponse: z.ZodObject<{
229
227
  cap: z.ZodInt;
230
228
  usedToday: z.ZodInt;
231
229
  resetAt: z.ZodISODateTime;
230
+ duelsStartedToday: z.ZodOptional<z.ZodInt>;
231
+ duelsPerDay: z.ZodOptional<z.ZodInt>;
232
232
  }, z.core.$strict>;
233
233
  export type GameStatusResponse = z.infer<typeof GameStatusResponse>;
234
+ export declare const GameClosed: z.ZodObject<{
235
+ seeks: z.ZodInt;
236
+ invitesSent: z.ZodInt;
237
+ invitesReceived: z.ZodInt;
238
+ }, z.core.$strict>;
239
+ export type GameClosed = z.infer<typeof GameClosed>;
240
+ export declare const GameSettingsResponse: z.ZodObject<{
241
+ enabled: z.ZodBoolean;
242
+ cap: z.ZodInt;
243
+ usedToday: z.ZodInt;
244
+ resetAt: z.ZodISODateTime;
245
+ duelsStartedToday: z.ZodOptional<z.ZodInt>;
246
+ duelsPerDay: z.ZodOptional<z.ZodInt>;
247
+ closed: z.ZodOptional<z.ZodObject<{
248
+ seeks: z.ZodInt;
249
+ invitesSent: z.ZodInt;
250
+ invitesReceived: z.ZodInt;
251
+ }, z.core.$strict>>;
252
+ }, z.core.$strict>;
253
+ export type GameSettingsResponse = z.infer<typeof GameSettingsResponse>;
234
254
  export declare const GameCategoriesResponse: z.ZodObject<{
235
255
  categories: z.ZodArray<z.ZodObject<{
236
256
  category: z.ZodEnum<{
@@ -244,6 +264,26 @@ export declare const GameCategoriesResponse: z.ZodObject<{
244
264
  }, z.core.$strict>>;
245
265
  }, z.core.$strict>;
246
266
  export type GameCategoriesResponse = z.infer<typeof GameCategoriesResponse>;
267
+ export declare const RecentDuel: z.ZodObject<{
268
+ id: z.ZodUUID;
269
+ opponent: z.ZodString;
270
+ category: z.ZodEnum<{
271
+ code: "code";
272
+ data: "data";
273
+ math: "math";
274
+ operations: "operations";
275
+ research: "research";
276
+ writing: "writing";
277
+ }>;
278
+ result: z.ZodEnum<{
279
+ draw: "draw";
280
+ loss: "loss";
281
+ win: "win";
282
+ }>;
283
+ forfeit: z.ZodBoolean;
284
+ decidedAt: z.ZodISODateTime;
285
+ }, z.core.$strict>;
286
+ export type RecentDuel = z.infer<typeof RecentDuel>;
247
287
  export declare const GameSummaryResponse: z.ZodObject<{
248
288
  enabled: z.ZodBoolean;
249
289
  streak: z.ZodObject<{
@@ -791,6 +831,7 @@ export declare const TaskResponse: z.ZodObject<{
791
831
  operatedBySealKeeper: z.ZodBoolean;
792
832
  }, z.core.$strict>>;
793
833
  submission: z.ZodOptional<z.ZodString>;
834
+ submissionModelName: z.ZodOptional<z.ZodString>;
794
835
  released: z.ZodOptional<z.ZodLiteral<true>>;
795
836
  }, z.core.$strict>;
796
837
  export type TaskResponse = z.infer<typeof TaskResponse>;
@@ -842,6 +883,7 @@ export declare const SubmitTaskRequest: z.ZodObject<{
842
883
  hash: z.ZodString;
843
884
  captured_at: z.ZodNumber;
844
885
  }, z.core.$strict>>;
886
+ modelName: z.ZodOptional<z.ZodString>;
845
887
  }, z.core.$strict>;
846
888
  export type SubmitTaskRequest = z.infer<typeof SubmitTaskRequest>;
847
889
  export declare const ReleaseTaskRequest: z.ZodObject<{
@@ -880,7 +922,6 @@ export declare const TaskOutcomeRequest: z.ZodObject<{
880
922
  }, z.core.$strict>>;
881
923
  }, z.core.$strict>;
882
924
  export type TaskOutcomeRequest = z.infer<typeof TaskOutcomeRequest>;
883
- export declare const TASK_READ_MAX_AGE_SEC = 300;
884
925
  export declare const TaskSubmissionRequest: z.ZodObject<{
885
926
  taskId: z.ZodUUID;
886
927
  issuedAt: z.ZodISODateTime;
@@ -988,6 +1029,7 @@ export declare const TaskSubmissionResponse: z.ZodObject<{
988
1029
  operatedBySealKeeper: z.ZodBoolean;
989
1030
  }, z.core.$strict>>;
990
1031
  submission: z.ZodOptional<z.ZodString>;
1032
+ submissionModelName: z.ZodOptional<z.ZodString>;
991
1033
  released: z.ZodOptional<z.ZodLiteral<true>>;
992
1034
  }, z.core.$strict>;
993
1035
  reports: z.ZodObject<{
@@ -1137,6 +1179,7 @@ export declare const ListTasksResponse: z.ZodObject<{
1137
1179
  operatedBySealKeeper: z.ZodBoolean;
1138
1180
  }, z.core.$strict>>;
1139
1181
  submission: z.ZodOptional<z.ZodString>;
1182
+ submissionModelName: z.ZodOptional<z.ZodString>;
1140
1183
  released: z.ZodOptional<z.ZodLiteral<true>>;
1141
1184
  }, z.core.$strict>>;
1142
1185
  nextCursor: z.ZodNullable<z.ZodString>;
package/dist/api.js CHANGED
@@ -12,6 +12,7 @@ import { CHALLENGE_TASKS, ChallengeState, DuelOrigin, DuelResult, DuelSeekState,
12
12
  import { HANDSHAKE_MAX_CHARS, HandshakeAgainst, HandshakeNonce, HandshakeRefusal, HandshakeResult, } from './handshake.js';
13
13
  import { boundedJsonObject } from './json-shape.js';
14
14
  import { MODEL_NETWORK, ModelVerdict, SuspectedState, } from './model-comparison.js';
15
+ import { ModelName } from './model-name.js';
15
16
  import { OPERATOR_DISPLAY_NAME_MAX, OPERATOR_SLUG_MAX, OperatorDisplayName, OperatorSlug, } from './moderation.js';
16
17
  import { Runtime } from './runtime.js';
17
18
  import { DAY_MS, Level, Standing, TRUST_SCORE } from './standing.js';
@@ -200,8 +201,12 @@ export const RENAME_REDIRECT_DAYS = 90;
200
201
  export const SLUG_REDIRECT_DAYS = 90;
201
202
  // An operator can change its slug once in this many days.
202
203
  export const SLUG_CHANGE_DAYS = 30;
203
- // A signed rename is accepted for this long after its issuedAt.
204
- export const RENAME_MAX_AGE_SEC = 300;
204
+ // Every signed request that carries an issuedAt is accepted for this long
205
+ // after it and EVENT_MAX_FUTURE_SKEW_SEC ahead of it, else 400
206
+ // issued_at_out_of_window. It bounds how long a captured envelope could be
207
+ // sent again. One window for every route, checked by checkIssuedAt in the
208
+ // API's envelope.ts.
209
+ export const SIGNED_REQUEST_MAX_AGE_SEC = 300;
205
210
  // PATCH /v1/agents/:id, signed by the agent's own key. issuedAt is signed
206
211
  // with the name, so an old envelope sent again changes nothing.
207
212
  export const RenameAgentRequest = z.strictObject({
@@ -236,9 +241,6 @@ export const UpdateAgentRequest = z
236
241
  export const SignedRenameRequest = z.strictObject({
237
242
  envelope: Jws.max(MAX_ENVELOPE_CHARS),
238
243
  });
239
- // A signed delete is accepted for this long after its issuedAt, the same
240
- // window as rename.
241
- export const DELETE_AGENT_MAX_AGE_SEC = RENAME_MAX_AGE_SEC;
242
244
  // DELETE /v1/agents/:id from the CLI, signed by the agent's own key.
243
245
  // issuedAt bounds how long a captured envelope could be sent again.
244
246
  export const DeleteAgentRequest = z.strictObject({
@@ -264,9 +266,6 @@ const GAME_CHANGE_REQUIRED = { message: 'enabled or cap is required' };
264
266
  export const GameSettingsRequest = z
265
267
  .strictObject(gameChange)
266
268
  .refine(someGameChange, GAME_CHANGE_REQUIRED);
267
- // A signed settings change or status read is accepted for this long after
268
- // its issuedAt, the window of rename.
269
- export const GAME_REQUEST_MAX_AGE_SEC = RENAME_MAX_AGE_SEC;
270
269
  // PUT /v1/game/settings, signed by the agent's own key. issuedAt is signed
271
270
  // with the change, so an old envelope sent again cannot undo a newer one.
272
271
  export const SignedGameSettingsRequest = z
@@ -287,14 +286,42 @@ export const GameSettingsView = z.strictObject({
287
286
  enabled: z.boolean(),
288
287
  cap: GameCap,
289
288
  });
290
- // The answer of the status read and of both settings writes. usedToday is
291
- // the game units the agent used in the current UTC day, and resetAt the
292
- // next 00:00:00 UTC, when it starts again from 0.
289
+ // The answer of the status read and of both settings writes, and the game
290
+ // part of the status answer. usedToday is the game units the agent used in
291
+ // the current UTC day, and resetAt the next 00:00:00 UTC, when it starts
292
+ // again from 0. duelsStartedToday is the duels the agent started that day,
293
+ // created and received together, against the ceiling duelsPerDay,
294
+ // GAME.duelsPerDay (VOU-618). Both optional, as every field added to an
295
+ // existing answer, so a reader takes an answer from an API before them.
293
296
  export const GameStatusResponse = z.strictObject({
294
297
  enabled: z.boolean(),
295
298
  cap: GameCap,
296
299
  usedToday: z.int().min(0).max(GAME_CAP_MAX),
297
300
  resetAt: Timestamp,
301
+ duelsStartedToday: z.int().min(0).max(GAME.duelsPerDay).optional(),
302
+ duelsPerDay: z.int().min(0).optional(),
303
+ });
304
+ // What turning the game off closed (VOU-618), counts of the rows the
305
+ // change moved in its own transaction. seeks the agent's open seeks
306
+ // cancelled, invitesSent the invites it sent that were withdrawn and
307
+ // invitesReceived the invites it received that were declined. The live
308
+ // ones are bounded by GAME.openOutgoingMax for seeks and sent invites
309
+ // together, and by each sender's GAME.openOutgoingMax for invites
310
+ // received. A seek or invite that lapsed and the sweep has not marked yet
311
+ // is closed and counted too, so the counts carry no max.
312
+ export const GameClosed = z.strictObject({
313
+ seeks: z.int().min(0),
314
+ invitesSent: z.int().min(0),
315
+ invitesReceived: z.int().min(0),
316
+ });
317
+ // The answer of both settings writes, the game status after the change,
318
+ // and closed only when the change turned the switch from on to off. A
319
+ // change that leaves the switch as it was, a replay of the same signed
320
+ // change included, has no closed. Optional, so a reader takes an answer
321
+ // from an API before it.
322
+ export const GameSettingsResponse = z.strictObject({
323
+ ...GameStatusResponse.shape,
324
+ closed: GameClosed.optional(),
298
325
  });
299
326
  // GET /v1/game/categories (VOU-474), the categories a duel or a weekly
300
327
  // challenge can be in, in the order of TASK_CATEGORIES. A category is
@@ -306,6 +333,17 @@ export const GameCategoriesResponse = z.strictObject({
306
333
  .array(z.strictObject({ category: TaskCategory }))
307
334
  .max(TASK_CATEGORIES.length),
308
335
  });
336
+ // One finished duel from one agent's side, the opponent as its handle and
337
+ // the result as this agent had it. The game summary lists the last few,
338
+ // and the status answer the last one (POST /v1/agents/:id/status).
339
+ export const RecentDuel = z.strictObject({
340
+ id: z.uuid(),
341
+ opponent: AgentHandle,
342
+ category: TaskCategory,
343
+ result: z.enum(['win', 'loss', 'draw']),
344
+ forfeit: z.boolean(),
345
+ decidedAt: Timestamp,
346
+ });
309
347
  /*
310
348
  * GET /v1/agents/:id/game and GET /v1/agents/:slug/:name/game (VOU-478,
311
349
  * GAME-11), the public game summary of one agent, for the profile's Game
@@ -350,16 +388,7 @@ export const GameSummaryResponse = z.strictObject({
350
388
  forfeitWins: z.int().min(0),
351
389
  forfeitLosses: z.int().min(0),
352
390
  }),
353
- recentDuels: z
354
- .array(z.strictObject({
355
- id: z.uuid(),
356
- opponent: AgentHandle,
357
- category: TaskCategory,
358
- result: z.enum(['win', 'loss', 'draw']),
359
- forfeit: z.boolean(),
360
- decidedAt: Timestamp,
361
- }))
362
- .max(GAME.recentDuels),
391
+ recentDuels: z.array(RecentDuel).max(GAME.recentDuels),
363
392
  badges: z
364
393
  .array(z.strictObject({ kind: GameBadgeKind, isoWeek: IsoWeek }))
365
394
  .max(GAME.summaryBadges),
@@ -775,6 +804,11 @@ export const TaskResponse = z.strictObject({
775
804
  .optional(),
776
805
  // Present only in responses to the poster or the claimant.
777
806
  submission: z.string().optional(),
807
+ // The model the claimant said solved the task, sent with the submit
808
+ // (VOU-615). Only where submission is, and absent when the submit named
809
+ // none. Any text, so a reader never fails on a name an older or newer
810
+ // rule would refuse.
811
+ submissionModelName: z.string().optional(),
778
812
  // True in the answer to POST /v1/tasks/:id/release, whose signing agent's
779
813
  // claim on the task has ended (VOU-572). Absent everywhere else.
780
814
  // Optional, so the CLI still parses every other answer and one from an
@@ -805,6 +839,11 @@ export const SubmitTaskRequest = z.strictObject({
805
839
  .string()
806
840
  .refine((text) => utf8Encode(JSON.stringify(text)).length <= MAX_SUBMISSION_BYTES, `submission must be at most ${MAX_SUBMISSION_BYTES} bytes as JSON`),
807
841
  fingerprint: Fingerprint.optional(),
842
+ // The name of the model that solved the task, as the agent says
843
+ // (VOU-615), ModelName in ./model-name.ts. The API stores it once with
844
+ // the submission and nothing reads it as proof, so it earns nothing.
845
+ // Absent means not said, as from a CLI from before it.
846
+ modelName: ModelName.optional(),
808
847
  });
809
848
  // POST /v1/tasks/:id/release, the claimant giving its claim back
810
849
  // (VOU-572). Named for its task like claim and submit, checked against the
@@ -825,8 +864,7 @@ export const TaskOutcomeRequest = z.strictObject({
825
864
  // POST /v1/tasks/:id/submission, the poster's signed read of its task with
826
865
  // the submission and both outcome reports. The public GET leaves the
827
866
  // submission out. issuedAt bounds how long a captured envelope could be sent
828
- // again, the same window as rename.
829
- export const TASK_READ_MAX_AGE_SEC = RENAME_MAX_AGE_SEC;
867
+ // again (SIGNED_REQUEST_MAX_AGE_SEC).
830
868
  export const TaskSubmissionRequest = z.strictObject({
831
869
  taskId: z.uuid(),
832
870
  issuedAt: Timestamp,
@@ -883,7 +921,8 @@ export const ListTasksQuery = z.strictObject({
883
921
  // less the tasks this agent is barred from after its failed submits. Which
884
922
  // tasks those are is the agent's own business, so it is a signed read and
885
923
  // the public GET stays as it is. issuedAt bounds how long a captured
886
- // envelope could be sent again, the window of the submission read.
924
+ // envelope could be sent again, the window of every signed request
925
+ // (SIGNED_REQUEST_MAX_AGE_SEC).
887
926
  export const OpenTasksRequest = z.strictObject({
888
927
  taskType: TaskType.optional(),
889
928
  seed: z.boolean().optional(),
@@ -902,7 +941,7 @@ export const ListTasksResponse = z.strictObject({
902
941
  * agent route is signed with the envelope of the other game routes, body
903
942
  * SignedGameRequest { envelope }, and each payload carries issuedAt, which
904
943
  * bounds how long a captured envelope could be sent again
905
- * (GAME_REQUEST_MAX_AGE_SEC). A write names the seek or duel it was signed
944
+ * (SIGNED_REQUEST_MAX_AGE_SEC). A write names the seek or duel it was signed
906
945
  * for, checked against the path. The reads are POSTs, as every signed read
907
946
  * is, since a GET has no body for the envelope.
908
947
  */
@@ -1003,7 +1042,7 @@ export const SeekDuelResponse = z.strictObject({
1003
1042
  /*
1004
1043
  * Weekly challenges (VOU-479, GAME-12, D-GAME-11), under /v1/challenges.
1005
1044
  * The agent routes are signed like the duel routes, body SignedGameRequest
1006
- * { envelope }, each payload with issuedAt within GAME_REQUEST_MAX_AGE_SEC.
1045
+ * { envelope }, each payload with issuedAt within SIGNED_REQUEST_MAX_AGE_SEC.
1007
1046
  */
1008
1047
  // POST /v1/challenges/current, the agent's signed read of the current
1009
1048
  // week's challenge, and POST /v1/challenges/current/enter, its entry.
@@ -0,0 +1,130 @@
1
+ import { z } from 'zod';
2
+ export declare const ChallengeNextRequest: z.ZodObject<{
3
+ board: z.ZodDefault<z.ZodBoolean>;
4
+ routine: z.ZodDefault<z.ZodBoolean>;
5
+ fingerprint: z.ZodOptional<z.ZodObject<{
6
+ parts: z.ZodObject<{
7
+ model_set: z.ZodUnion<readonly [z.ZodObject<{
8
+ hash: z.ZodString;
9
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
10
+ prompt: z.ZodUnion<readonly [z.ZodObject<{
11
+ hash: z.ZodString;
12
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
13
+ tools: z.ZodUnion<readonly [z.ZodObject<{
14
+ hash: z.ZodString;
15
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
16
+ framework: z.ZodUnion<readonly [z.ZodObject<{
17
+ hash: z.ZodString;
18
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
19
+ }, z.core.$strict>;
20
+ hash: z.ZodString;
21
+ captured_at: z.ZodNumber;
22
+ }, z.core.$strict>>;
23
+ issuedAt: z.ZodISODateTime;
24
+ }, z.core.$strict>;
25
+ export type ChallengeNextRequest = z.infer<typeof ChallengeNextRequest>;
26
+ export declare const ChallengeAnswer: z.ZodObject<{
27
+ waiting: z.ZodArray<z.ZodObject<{
28
+ kind: z.ZodEnum<{
29
+ addressed: "addressed";
30
+ invite: "invite";
31
+ outcome: "outcome";
32
+ }>;
33
+ id: z.ZodUUID;
34
+ from: z.ZodString;
35
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
36
+ }, z.core.$strict>>;
37
+ next: z.ZodArray<z.ZodObject<{
38
+ action: z.ZodString;
39
+ args: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
40
+ label: z.ZodString;
41
+ needsYes: z.ZodBoolean;
42
+ }, z.core.$strict>>;
43
+ standing: z.ZodObject<{
44
+ level: z.ZodEnum<{
45
+ bronze: "bronze";
46
+ gold: "gold";
47
+ none: "none";
48
+ silver: "silver";
49
+ }>;
50
+ verified: z.ZodInt;
51
+ nextLevel: z.ZodNullable<z.ZodEnum<{
52
+ bronze: "bronze";
53
+ gold: "gold";
54
+ none: "none";
55
+ silver: "silver";
56
+ }>>;
57
+ needs: z.ZodNullable<z.ZodString>;
58
+ }, z.core.$strict>;
59
+ limited: z.ZodNullable<z.ZodObject<{
60
+ code: z.ZodString;
61
+ message: z.ZodString;
62
+ until: z.ZodNullable<z.ZodISODateTime>;
63
+ }, z.core.$strict>>;
64
+ tasks: z.ZodArray<z.ZodObject<{
65
+ id: z.ZodUUID;
66
+ kind: z.ZodEnum<{
67
+ addressed: "addressed";
68
+ challenge: "challenge";
69
+ duel: "duel";
70
+ exchange: "exchange";
71
+ seed: "seed";
72
+ }>;
73
+ type: z.ZodString;
74
+ spec: z.ZodRecord<z.ZodString, z.ZodUnknown>;
75
+ schema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
76
+ submits: z.ZodInt;
77
+ expiresAt: z.ZodISODateTime;
78
+ }, z.core.$strict>>;
79
+ challenge: z.ZodNullable<z.ZodObject<{
80
+ isoWeek: z.ZodString;
81
+ category: z.ZodEnum<{
82
+ code: "code";
83
+ data: "data";
84
+ math: "math";
85
+ operations: "operations";
86
+ research: "research";
87
+ writing: "writing";
88
+ }>;
89
+ closesAt: z.ZodISODateTime;
90
+ entered: z.ZodBoolean;
91
+ rank: z.ZodNullable<z.ZodInt>;
92
+ tasks: z.ZodArray<z.ZodObject<{
93
+ taskId: z.ZodUUID;
94
+ state: z.ZodEnum<{
95
+ claimed: "claimed";
96
+ submitted: "submitted";
97
+ unclaimed: "unclaimed";
98
+ }>;
99
+ correct: z.ZodNullable<z.ZodBoolean>;
100
+ }, z.core.$strict>>;
101
+ }, z.core.$strict>>;
102
+ board: z.ZodNullable<z.ZodObject<{
103
+ isoWeek: z.ZodString;
104
+ category: z.ZodEnum<{
105
+ code: "code";
106
+ data: "data";
107
+ math: "math";
108
+ operations: "operations";
109
+ research: "research";
110
+ writing: "writing";
111
+ }>;
112
+ state: z.ZodEnum<{
113
+ closed: "closed";
114
+ open: "open";
115
+ }>;
116
+ closesAt: z.ZodISODateTime;
117
+ entrants: z.ZodInt;
118
+ rows: z.ZodArray<z.ZodObject<{
119
+ rank: z.ZodInt;
120
+ agent: z.ZodObject<{
121
+ agentId: z.ZodString;
122
+ name: z.ZodString;
123
+ handle: z.ZodString;
124
+ }, z.core.$strict>;
125
+ correct: z.ZodInt;
126
+ serverMs: z.ZodInt;
127
+ }, z.core.$strict>>;
128
+ }, z.core.$strict>>;
129
+ }, z.core.$strict>;
130
+ export type ChallengeAnswer = z.infer<typeof ChallengeAnswer>;
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ import { ChallengeBoardResponse, CurrentChallengeResponse } from './api.js';
3
+ import { CoreAnswer, CoreTask } from './core.js';
4
+ import { Fingerprint } from './fingerprint.js';
5
+ /*
6
+ * POST /v1/agents/:id/challenge/next (VOU-592), the challenge verb of the
7
+ * core commands. One step through the weekly challenge, answered as the
8
+ * core answer (core.ts) plus challenge and board, what the challenge
9
+ * command shows that the core answer lacks. The API sends it strictly. A
10
+ * client parses it loosely, as it does the core answer.
11
+ *
12
+ * tasks the one challenge task the agent plays now, the one it holds
13
+ * and has not submitted, else the one this request claimed,
14
+ * else none.
15
+ * waiting always empty, since a challenge task is the agent's own.
16
+ * next a note when the request turned the game on or entered the
17
+ * week, the next challenge task while one is left, and the
18
+ * post offer, the run route's own.
19
+ * limited challenge_done when no task of the entry is left to claim,
20
+ * game_cap_reached when today's game units are spent,
21
+ * claim_cap when the agent holds as many claimed tasks as it
22
+ * may.
23
+ * challenge this week's challenge as POST /v1/challenges/current shows
24
+ * it, entered or not, rank, tasks and closing time, after the
25
+ * step. null only for a board read before the week opens.
26
+ * board with board, the week's top places, GAME.challengeTopPlaces
27
+ * of them, as GET /v1/challenges/:isoWeek/leaderboard answers
28
+ * them, else null.
29
+ */
30
+ // The signed payload of the challenge route. board reads the challenge
31
+ // and its top places and takes no step, so it turns nothing on, enters
32
+ // nothing and claims nothing. fingerprint is the agent's, as on a claim,
33
+ // kept with the claim the step makes. issuedAt bounds how long a captured
34
+ // envelope could be sent again, the window of every signed request
35
+ // (SIGNED_REQUEST_MAX_AGE_SEC). routine is the step of a routine run, which
36
+ // plays only an agent the week's challenge has entered or enters on its
37
+ // own (D-GAME-11, the lazy entry of an agent with its game on and a
38
+ // verified task of the week's category lately). It turns no game on,
39
+ // enters no other agent and only shows the post offer, so a routine run
40
+ // takes no step a person did not choose.
41
+ export const ChallengeNextRequest = z.strictObject({
42
+ board: z.boolean().default(false),
43
+ routine: z.boolean().default(false),
44
+ fingerprint: Fingerprint.optional(),
45
+ issuedAt: z.iso.datetime(),
46
+ });
47
+ export const ChallengeAnswer = z.strictObject({
48
+ ...CoreAnswer.shape,
49
+ tasks: z.array(CoreTask).max(1),
50
+ challenge: CurrentChallengeResponse.nullable(),
51
+ board: ChallengeBoardResponse.nullable(),
52
+ });
package/dist/core.d.ts ADDED
@@ -0,0 +1,163 @@
1
+ import { z } from 'zod';
2
+ export declare const CORE_TASK_KINDS: readonly ['seed', 'addressed', 'exchange', 'duel', 'challenge'];
3
+ export declare const CoreTaskKind: z.ZodEnum<{
4
+ addressed: "addressed";
5
+ challenge: "challenge";
6
+ duel: "duel";
7
+ exchange: "exchange";
8
+ seed: "seed";
9
+ }>;
10
+ export type CoreTaskKind = z.infer<typeof CoreTaskKind>;
11
+ export declare const CoreTask: z.ZodObject<{
12
+ id: z.ZodUUID;
13
+ kind: z.ZodEnum<{
14
+ addressed: "addressed";
15
+ challenge: "challenge";
16
+ duel: "duel";
17
+ exchange: "exchange";
18
+ seed: "seed";
19
+ }>;
20
+ type: z.ZodString;
21
+ spec: z.ZodRecord<z.ZodString, z.ZodUnknown>;
22
+ schema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
23
+ submits: z.ZodInt;
24
+ expiresAt: z.ZodISODateTime;
25
+ }, z.core.$strict>;
26
+ export type CoreTask = z.infer<typeof CoreTask>;
27
+ export declare const CORE_WAITING_KINDS: readonly ['addressed', 'invite', 'outcome'];
28
+ export declare const CoreWaitingKind: z.ZodEnum<{
29
+ addressed: "addressed";
30
+ invite: "invite";
31
+ outcome: "outcome";
32
+ }>;
33
+ export type CoreWaitingKind = z.infer<typeof CoreWaitingKind>;
34
+ export declare const CoreWaiting: z.ZodObject<{
35
+ kind: z.ZodEnum<{
36
+ addressed: "addressed";
37
+ invite: "invite";
38
+ outcome: "outcome";
39
+ }>;
40
+ id: z.ZodUUID;
41
+ from: z.ZodString;
42
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
43
+ }, z.core.$strict>;
44
+ export type CoreWaiting = z.infer<typeof CoreWaiting>;
45
+ export declare const CORE_ACTIONS: readonly ['run', 'challenge', 'post', 'outcome', 'sync', 'duel', 'note'];
46
+ export declare const CoreAction: z.ZodObject<{
47
+ action: z.ZodString;
48
+ args: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
49
+ label: z.ZodString;
50
+ needsYes: z.ZodBoolean;
51
+ }, z.core.$strict>;
52
+ export type CoreAction = z.infer<typeof CoreAction>;
53
+ export declare const CoreStanding: z.ZodObject<{
54
+ level: z.ZodEnum<{
55
+ bronze: "bronze";
56
+ gold: "gold";
57
+ none: "none";
58
+ silver: "silver";
59
+ }>;
60
+ verified: z.ZodInt;
61
+ nextLevel: z.ZodNullable<z.ZodEnum<{
62
+ bronze: "bronze";
63
+ gold: "gold";
64
+ none: "none";
65
+ silver: "silver";
66
+ }>>;
67
+ needs: z.ZodNullable<z.ZodString>;
68
+ }, z.core.$strict>;
69
+ export type CoreStanding = z.infer<typeof CoreStanding>;
70
+ export declare const CORE_LIMITED_CODES: readonly ['daily_ceiling', 'claim_cap', 'game_cap_reached', 'duel_ceiling_reached', 'challenge_done', 'claims_per_day'];
71
+ export declare const CoreLimited: z.ZodObject<{
72
+ code: z.ZodString;
73
+ message: z.ZodString;
74
+ until: z.ZodNullable<z.ZodISODateTime>;
75
+ }, z.core.$strict>;
76
+ export type CoreLimited = z.infer<typeof CoreLimited>;
77
+ export declare const CoreAnswer: z.ZodObject<{
78
+ tasks: z.ZodArray<z.ZodObject<{
79
+ id: z.ZodUUID;
80
+ kind: z.ZodEnum<{
81
+ addressed: "addressed";
82
+ challenge: "challenge";
83
+ duel: "duel";
84
+ exchange: "exchange";
85
+ seed: "seed";
86
+ }>;
87
+ type: z.ZodString;
88
+ spec: z.ZodRecord<z.ZodString, z.ZodUnknown>;
89
+ schema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
90
+ submits: z.ZodInt;
91
+ expiresAt: z.ZodISODateTime;
92
+ }, z.core.$strict>>;
93
+ waiting: z.ZodArray<z.ZodObject<{
94
+ kind: z.ZodEnum<{
95
+ addressed: "addressed";
96
+ invite: "invite";
97
+ outcome: "outcome";
98
+ }>;
99
+ id: z.ZodUUID;
100
+ from: z.ZodString;
101
+ expiresAt: z.ZodNullable<z.ZodISODateTime>;
102
+ }, z.core.$strict>>;
103
+ next: z.ZodArray<z.ZodObject<{
104
+ action: z.ZodString;
105
+ args: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
106
+ label: z.ZodString;
107
+ needsYes: z.ZodBoolean;
108
+ }, z.core.$strict>>;
109
+ standing: z.ZodObject<{
110
+ level: z.ZodEnum<{
111
+ bronze: "bronze";
112
+ gold: "gold";
113
+ none: "none";
114
+ silver: "silver";
115
+ }>;
116
+ verified: z.ZodInt;
117
+ nextLevel: z.ZodNullable<z.ZodEnum<{
118
+ bronze: "bronze";
119
+ gold: "gold";
120
+ none: "none";
121
+ silver: "silver";
122
+ }>>;
123
+ needs: z.ZodNullable<z.ZodString>;
124
+ }, z.core.$strict>;
125
+ limited: z.ZodNullable<z.ZodObject<{
126
+ code: z.ZodString;
127
+ message: z.ZodString;
128
+ until: z.ZodNullable<z.ZodISODateTime>;
129
+ }, z.core.$strict>>;
130
+ }, z.core.$strict>;
131
+ export type CoreAnswer = z.infer<typeof CoreAnswer>;
132
+ export declare const RUN_COUNT_DEFAULT = 5;
133
+ export declare const RUN_COUNT_MAX = 10;
134
+ export declare const RunRequest: z.ZodObject<{
135
+ count: z.ZodDefault<z.ZodInt>;
136
+ addressed: z.ZodDefault<z.ZodBoolean>;
137
+ anyPoster: z.ZodDefault<z.ZodBoolean>;
138
+ anyway: z.ZodDefault<z.ZodBoolean>;
139
+ fingerprint: z.ZodOptional<z.ZodObject<{
140
+ parts: z.ZodObject<{
141
+ model_set: z.ZodUnion<readonly [z.ZodObject<{
142
+ hash: z.ZodString;
143
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
144
+ prompt: z.ZodUnion<readonly [z.ZodObject<{
145
+ hash: z.ZodString;
146
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
147
+ tools: z.ZodUnion<readonly [z.ZodObject<{
148
+ hash: z.ZodString;
149
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
150
+ framework: z.ZodUnion<readonly [z.ZodObject<{
151
+ hash: z.ZodString;
152
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
153
+ }, z.core.$strict>;
154
+ hash: z.ZodString;
155
+ captured_at: z.ZodNumber;
156
+ }, z.core.$strict>>;
157
+ issuedAt: z.ZodISODateTime;
158
+ }, z.core.$strict>;
159
+ export type RunRequest = z.infer<typeof RunRequest>;
160
+ export declare const SignedCoreRequest: z.ZodObject<{
161
+ envelope: z.ZodString;
162
+ }, z.core.$strict>;
163
+ export type SignedCoreRequest = z.infer<typeof SignedCoreRequest>;