@sealkeeper/schema 0.4.9 → 0.5.1
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/agent-name.js +5 -1
- package/dist/api.d.ts +190 -6
- package/dist/api.js +168 -49
- package/dist/challenge-next.d.ts +130 -0
- package/dist/challenge-next.js +52 -0
- package/dist/conformance.d.ts +0 -1
- package/dist/conformance.js +3 -4
- package/dist/core.d.ts +163 -0
- package/dist/core.js +161 -0
- package/dist/credential.d.ts +1 -0
- package/dist/credential.js +8 -2
- package/dist/duel-next.d.ts +232 -0
- package/dist/duel-next.js +114 -0
- package/dist/envelope.d.ts +41 -1
- package/dist/envelope.js +71 -4
- package/dist/game.d.ts +2 -0
- package/dist/game.js +31 -12
- package/dist/handshake-conformance.d.ts +1 -0
- package/dist/handshake-conformance.js +41 -0
- package/dist/handshake.d.ts +15 -2
- package/dist/handshake.js +63 -14
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/policy.d.ts +1 -1
- package/dist/policy.js +1 -1
- package/dist/routine.d.ts +186 -0
- package/dist/routine.js +227 -0
- package/dist/seal-conformance.d.ts +1 -0
- package/dist/seal-conformance.js +23 -1
- package/dist/seal-verify.d.ts +1 -1
- package/dist/seal-verify.js +7 -1
- package/dist/standing.js +7 -4
- package/dist/status.d.ts +382 -0
- package/dist/status.js +98 -0
- package/dist/task-templates.d.ts +3 -22
- package/dist/task-templates.js +102 -469
- package/package.json +2 -2
- package/dist/template-conformance.d.ts +0 -10
- package/dist/template-conformance.js +0 -298
package/dist/index.js
CHANGED
|
@@ -4,10 +4,13 @@ export * from './api.js';
|
|
|
4
4
|
export * from './badge.js';
|
|
5
5
|
export * from './base64url.js';
|
|
6
6
|
export * from './blocks.js';
|
|
7
|
+
export * from './challenge-next.js';
|
|
7
8
|
export * from './cli-version.js';
|
|
8
9
|
export * from './client-address.js';
|
|
10
|
+
export * from './core.js';
|
|
9
11
|
export * from './credential.js';
|
|
10
12
|
export * from './dimensions.js';
|
|
13
|
+
export * from './duel-next.js';
|
|
11
14
|
export * from './envelope.js';
|
|
12
15
|
export * from './events.js';
|
|
13
16
|
export * from './fingerprint.js';
|
|
@@ -20,9 +23,11 @@ export * from './model-name.js';
|
|
|
20
23
|
export * from './moderation.js';
|
|
21
24
|
export * from './operator-domains.js';
|
|
22
25
|
export * from './policy.js';
|
|
26
|
+
export * from './routine.js';
|
|
23
27
|
export * from './runtime.js';
|
|
24
28
|
export * from './seal-verify.js';
|
|
25
29
|
export * from './standing.js';
|
|
30
|
+
export * from './status.js';
|
|
26
31
|
export * from './task-templates.js';
|
|
27
32
|
export * from './tasks.js';
|
|
28
33
|
export * from './top-dimensions.js';
|
package/dist/policy.d.ts
CHANGED
package/dist/policy.js
CHANGED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ROUTINE_LIMIT_DEFAULTS: {
|
|
3
|
+
readonly claimsPerDay: 10;
|
|
4
|
+
readonly networkClaimsPerDay: 2;
|
|
5
|
+
readonly confirmsPerDay: 10;
|
|
6
|
+
readonly postsPerDay: 3;
|
|
7
|
+
readonly minutesPerRun: 15;
|
|
8
|
+
readonly tokensPerRun: 300000;
|
|
9
|
+
};
|
|
10
|
+
export declare const ROUTINE_LIMIT_MAX: {
|
|
11
|
+
readonly claimsPerDay: 100;
|
|
12
|
+
readonly networkClaimsPerDay: 5;
|
|
13
|
+
readonly confirmsPerDay: 100;
|
|
14
|
+
readonly postsPerDay: 10;
|
|
15
|
+
readonly minutesPerRun: 120;
|
|
16
|
+
readonly tokensPerRun: 10000000;
|
|
17
|
+
};
|
|
18
|
+
export type RoutineLimitName = keyof typeof ROUTINE_LIMIT_DEFAULTS;
|
|
19
|
+
export declare const ROUTINE_STEPS_MAX = 250;
|
|
20
|
+
export declare const ROUTINE_STEPS_PER_DAY = 1000;
|
|
21
|
+
export declare const ROUTINE_ALLOW_MAX = 100;
|
|
22
|
+
export declare const RoutineRequestLimits: z.ZodObject<{
|
|
23
|
+
claimsPerDay: z.ZodDefault<z.ZodInt>;
|
|
24
|
+
networkClaimsPerDay: z.ZodDefault<z.ZodInt>;
|
|
25
|
+
confirmsPerDay: z.ZodDefault<z.ZodInt>;
|
|
26
|
+
postsPerDay: z.ZodDefault<z.ZodInt>;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
export type RoutineRequestLimits = z.infer<typeof RoutineRequestLimits>;
|
|
29
|
+
export declare const RoutineAllow: z.ZodObject<{
|
|
30
|
+
slugs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
31
|
+
logins: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
export type RoutineAllow = z.infer<typeof RoutineAllow>;
|
|
34
|
+
export declare const RoutineNextRequest: z.ZodObject<{
|
|
35
|
+
runId: z.ZodUUID;
|
|
36
|
+
step: z.ZodInt;
|
|
37
|
+
limits: z.ZodDefault<z.ZodObject<{
|
|
38
|
+
claimsPerDay: z.ZodDefault<z.ZodInt>;
|
|
39
|
+
networkClaimsPerDay: z.ZodDefault<z.ZodInt>;
|
|
40
|
+
confirmsPerDay: z.ZodDefault<z.ZodInt>;
|
|
41
|
+
postsPerDay: z.ZodDefault<z.ZodInt>;
|
|
42
|
+
}, z.core.$strict>>;
|
|
43
|
+
allow: z.ZodDefault<z.ZodObject<{
|
|
44
|
+
slugs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
45
|
+
logins: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
46
|
+
}, z.core.$strict>>;
|
|
47
|
+
game: z.ZodDefault<z.ZodBoolean>;
|
|
48
|
+
verdict: z.ZodOptional<z.ZodObject<{
|
|
49
|
+
taskId: z.ZodUUID;
|
|
50
|
+
outcome: z.ZodEnum<{
|
|
51
|
+
failure: "failure";
|
|
52
|
+
success: "success";
|
|
53
|
+
}>;
|
|
54
|
+
}, z.core.$strict>>;
|
|
55
|
+
fingerprint: z.ZodOptional<z.ZodObject<{
|
|
56
|
+
parts: z.ZodObject<{
|
|
57
|
+
model_set: z.ZodUnion<readonly [z.ZodObject<{
|
|
58
|
+
hash: z.ZodString;
|
|
59
|
+
}, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
|
|
60
|
+
prompt: z.ZodUnion<readonly [z.ZodObject<{
|
|
61
|
+
hash: z.ZodString;
|
|
62
|
+
}, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
|
|
63
|
+
tools: z.ZodUnion<readonly [z.ZodObject<{
|
|
64
|
+
hash: z.ZodString;
|
|
65
|
+
}, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
|
|
66
|
+
framework: z.ZodUnion<readonly [z.ZodObject<{
|
|
67
|
+
hash: z.ZodString;
|
|
68
|
+
}, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
hash: z.ZodString;
|
|
71
|
+
captured_at: z.ZodNumber;
|
|
72
|
+
}, z.core.$strict>>;
|
|
73
|
+
issuedAt: z.ZodISODateTime;
|
|
74
|
+
}, z.core.$strict>;
|
|
75
|
+
export type RoutineNextRequest = z.infer<typeof RoutineNextRequest>;
|
|
76
|
+
export declare const ROUTINE_STEP_KINDS: readonly ['held', 'claim', 'network', 'judge', 'post', 'accept', 'decline', 'skip', 'challenge', 'rematch', 'duel', 'pending'];
|
|
77
|
+
export type RoutineStepKind = (typeof ROUTINE_STEP_KINDS)[number];
|
|
78
|
+
export declare const ROUTINE_ACTIONS: readonly ['task', 'judge', 'post', 'accept', 'decline', 'skip', 'rematch', 'duel', 'done'];
|
|
79
|
+
export type RoutineAction = (typeof ROUTINE_ACTIONS)[number];
|
|
80
|
+
export declare const ROUTINE_DONE_REASONS: readonly ['nothing_left', 'step_limit', 'day_limit'];
|
|
81
|
+
export declare const RoutineJudge: z.ZodObject<{
|
|
82
|
+
taskId: z.ZodUUID;
|
|
83
|
+
type: z.ZodString;
|
|
84
|
+
spec: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
85
|
+
submission: z.ZodString;
|
|
86
|
+
}, z.core.$strict>;
|
|
87
|
+
export type RoutineJudge = z.infer<typeof RoutineJudge>;
|
|
88
|
+
export declare const RoutineUsed: z.ZodObject<{
|
|
89
|
+
claims: z.ZodInt;
|
|
90
|
+
networkClaims: z.ZodInt;
|
|
91
|
+
confirms: z.ZodInt;
|
|
92
|
+
posts: z.ZodInt;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
export type RoutineUsed = z.infer<typeof RoutineUsed>;
|
|
95
|
+
export declare const RoutineNext: z.ZodObject<{
|
|
96
|
+
step: z.ZodInt;
|
|
97
|
+
action: z.ZodString;
|
|
98
|
+
taskId: z.ZodNullable<z.ZodUUID>;
|
|
99
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
100
|
+
judge: z.ZodNullable<z.ZodObject<{
|
|
101
|
+
taskId: z.ZodUUID;
|
|
102
|
+
type: z.ZodString;
|
|
103
|
+
spec: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
104
|
+
submission: z.ZodString;
|
|
105
|
+
}, z.core.$strict>>;
|
|
106
|
+
used: z.ZodObject<{
|
|
107
|
+
claims: z.ZodInt;
|
|
108
|
+
networkClaims: z.ZodInt;
|
|
109
|
+
confirms: z.ZodInt;
|
|
110
|
+
posts: z.ZodInt;
|
|
111
|
+
}, z.core.$strict>;
|
|
112
|
+
}, z.core.$strict>;
|
|
113
|
+
export type RoutineNext = z.infer<typeof RoutineNext>;
|
|
114
|
+
export declare const RoutineAnswer: z.ZodObject<{
|
|
115
|
+
waiting: z.ZodArray<z.ZodObject<{
|
|
116
|
+
kind: z.ZodEnum<{
|
|
117
|
+
addressed: "addressed";
|
|
118
|
+
invite: "invite";
|
|
119
|
+
outcome: "outcome";
|
|
120
|
+
}>;
|
|
121
|
+
id: z.ZodUUID;
|
|
122
|
+
from: z.ZodString;
|
|
123
|
+
expiresAt: z.ZodNullable<z.ZodISODateTime>;
|
|
124
|
+
}, z.core.$strict>>;
|
|
125
|
+
next: z.ZodArray<z.ZodObject<{
|
|
126
|
+
action: z.ZodString;
|
|
127
|
+
args: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
128
|
+
label: z.ZodString;
|
|
129
|
+
needsYes: z.ZodBoolean;
|
|
130
|
+
}, z.core.$strict>>;
|
|
131
|
+
standing: z.ZodObject<{
|
|
132
|
+
level: z.ZodEnum<{
|
|
133
|
+
bronze: "bronze";
|
|
134
|
+
gold: "gold";
|
|
135
|
+
none: "none";
|
|
136
|
+
silver: "silver";
|
|
137
|
+
}>;
|
|
138
|
+
verified: z.ZodInt;
|
|
139
|
+
nextLevel: z.ZodNullable<z.ZodEnum<{
|
|
140
|
+
bronze: "bronze";
|
|
141
|
+
gold: "gold";
|
|
142
|
+
none: "none";
|
|
143
|
+
silver: "silver";
|
|
144
|
+
}>>;
|
|
145
|
+
needs: z.ZodNullable<z.ZodString>;
|
|
146
|
+
}, z.core.$strict>;
|
|
147
|
+
limited: z.ZodNullable<z.ZodObject<{
|
|
148
|
+
code: z.ZodString;
|
|
149
|
+
message: z.ZodString;
|
|
150
|
+
until: z.ZodNullable<z.ZodISODateTime>;
|
|
151
|
+
}, z.core.$strict>>;
|
|
152
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
153
|
+
id: z.ZodUUID;
|
|
154
|
+
kind: z.ZodEnum<{
|
|
155
|
+
addressed: "addressed";
|
|
156
|
+
challenge: "challenge";
|
|
157
|
+
duel: "duel";
|
|
158
|
+
exchange: "exchange";
|
|
159
|
+
seed: "seed";
|
|
160
|
+
}>;
|
|
161
|
+
type: z.ZodString;
|
|
162
|
+
spec: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
163
|
+
schema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
164
|
+
submits: z.ZodInt;
|
|
165
|
+
expiresAt: z.ZodISODateTime;
|
|
166
|
+
}, z.core.$strict>>;
|
|
167
|
+
routine: z.ZodObject<{
|
|
168
|
+
step: z.ZodInt;
|
|
169
|
+
action: z.ZodString;
|
|
170
|
+
taskId: z.ZodNullable<z.ZodUUID>;
|
|
171
|
+
reason: z.ZodNullable<z.ZodString>;
|
|
172
|
+
judge: z.ZodNullable<z.ZodObject<{
|
|
173
|
+
taskId: z.ZodUUID;
|
|
174
|
+
type: z.ZodString;
|
|
175
|
+
spec: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
176
|
+
submission: z.ZodString;
|
|
177
|
+
}, z.core.$strict>>;
|
|
178
|
+
used: z.ZodObject<{
|
|
179
|
+
claims: z.ZodInt;
|
|
180
|
+
networkClaims: z.ZodInt;
|
|
181
|
+
confirms: z.ZodInt;
|
|
182
|
+
posts: z.ZodInt;
|
|
183
|
+
}, z.core.$strict>;
|
|
184
|
+
}, z.core.$strict>;
|
|
185
|
+
}, z.core.$strict>;
|
|
186
|
+
export type RoutineAnswer = z.infer<typeof RoutineAnswer>;
|
package/dist/routine.js
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CoreAnswer, CoreTask } from './core.js';
|
|
3
|
+
import { TaskType } from './dimensions.js';
|
|
4
|
+
import { Fingerprint } from './fingerprint.js';
|
|
5
|
+
import { TaskOutcome } from './tasks.js';
|
|
6
|
+
/*
|
|
7
|
+
* POST /v1/agents/:id/routine/next (VOU-594), the routine verb of the core
|
|
8
|
+
* commands. A routine run is a plain loop the API drives. The CLI asks for
|
|
9
|
+
* the next action, carries it out and asks again until the answer is done.
|
|
10
|
+
* Each answer is the core answer (core.ts) plus routine, the one action of
|
|
11
|
+
* the step. The API sends it strictly. A client parses it loosely, as it
|
|
12
|
+
* does the core answer, so an action or a reason added later never breaks
|
|
13
|
+
* one already out.
|
|
14
|
+
*
|
|
15
|
+
* The route carries out every write itself, the claim, the judged outcome
|
|
16
|
+
* report, the post, the accept or decline of an invite, the challenge
|
|
17
|
+
* step, the rematch and the duel step, each through the path that exists
|
|
18
|
+
* for it. What is left for the CLI is what must stay on the machine. It
|
|
19
|
+
* hands a task to the agent, takes the answer back as text and submits it
|
|
20
|
+
* through the submit route, and it hands a counterparty submission to the
|
|
21
|
+
* agent and sends the verdict with its next call.
|
|
22
|
+
*/
|
|
23
|
+
/*
|
|
24
|
+
* The routine's daily limits (VOU-138), set in the CLI's routine.json and
|
|
25
|
+
* sent with every call, so the API decides within them. claimsPerDay is the
|
|
26
|
+
* tasks the routine claims a UTC day, networkClaimsPerDay the part of them
|
|
27
|
+
* other operators' template tasks may take (RT-8), confirmsPerDay the
|
|
28
|
+
* counterparty submissions it judges and postsPerDay the tasks it posts.
|
|
29
|
+
* minutesPerRun and tokensPerRun hold the agent on the machine and never
|
|
30
|
+
* reach the API. A limit of 0 turns that kind of work off. The API counts
|
|
31
|
+
* each day from its own records (routine_steps), so a limit holds across
|
|
32
|
+
* runs.
|
|
33
|
+
*/
|
|
34
|
+
export const ROUTINE_LIMIT_DEFAULTS = {
|
|
35
|
+
claimsPerDay: 10,
|
|
36
|
+
networkClaimsPerDay: 2,
|
|
37
|
+
confirmsPerDay: 10,
|
|
38
|
+
postsPerDay: 3,
|
|
39
|
+
minutesPerRun: 15,
|
|
40
|
+
tokensPerRun: 300_000,
|
|
41
|
+
};
|
|
42
|
+
// The largest value each limit takes.
|
|
43
|
+
export const ROUTINE_LIMIT_MAX = {
|
|
44
|
+
claimsPerDay: 100,
|
|
45
|
+
networkClaimsPerDay: 5,
|
|
46
|
+
confirmsPerDay: 100,
|
|
47
|
+
postsPerDay: 10,
|
|
48
|
+
minutesPerRun: 120,
|
|
49
|
+
tokensPerRun: 10_000_000,
|
|
50
|
+
};
|
|
51
|
+
// The most steps one run takes. A step makes at most one write, so this
|
|
52
|
+
// bounds a run whatever the limits say. Steps from 0 up to it are taken,
|
|
53
|
+
// and step ROUTINE_STEPS_MAX answers done with step_limit.
|
|
54
|
+
export const ROUTINE_STEPS_MAX = 250;
|
|
55
|
+
// The most steps one agent takes in a UTC day across its runs, so a run id
|
|
56
|
+
// made up for every call cannot grow routine_steps without a bound.
|
|
57
|
+
export const ROUTINE_STEPS_PER_DAY = 1000;
|
|
58
|
+
// The most entries each half of the allowlist takes.
|
|
59
|
+
export const ROUTINE_ALLOW_MAX = 100;
|
|
60
|
+
const limitOf = (name) => z
|
|
61
|
+
.int()
|
|
62
|
+
.min(0)
|
|
63
|
+
.max(ROUTINE_LIMIT_MAX[name])
|
|
64
|
+
.default(ROUTINE_LIMIT_DEFAULTS[name]);
|
|
65
|
+
// The limits the API reads, each its default when absent.
|
|
66
|
+
export const RoutineRequestLimits = z.strictObject({
|
|
67
|
+
claimsPerDay: limitOf('claimsPerDay'),
|
|
68
|
+
networkClaimsPerDay: limitOf('networkClaimsPerDay'),
|
|
69
|
+
confirmsPerDay: limitOf('confirmsPerDay'),
|
|
70
|
+
postsPerDay: limitOf('postsPerDay'),
|
|
71
|
+
});
|
|
72
|
+
/*
|
|
73
|
+
* The operators whose addressed tasks and counterparty submissions a
|
|
74
|
+
* routine may take without a person, as routine.json holds them. slugs are
|
|
75
|
+
* operator slugs, matched by slug. logins are GitHub logins an older CLI
|
|
76
|
+
* added (before VOU-196), matched by login only, so a slug another
|
|
77
|
+
* operator picks never inherits one. Case does not matter on either side.
|
|
78
|
+
*/
|
|
79
|
+
const AllowEntry = z.string().min(1).max(64);
|
|
80
|
+
export const RoutineAllow = z.strictObject({
|
|
81
|
+
slugs: z.array(AllowEntry).max(ROUTINE_ALLOW_MAX).default([]),
|
|
82
|
+
logins: z.array(AllowEntry).max(ROUTINE_ALLOW_MAX).default([]),
|
|
83
|
+
});
|
|
84
|
+
/*
|
|
85
|
+
* The signed payload of the routine route.
|
|
86
|
+
*
|
|
87
|
+
* runId the run, a UUID the CLI makes once per run.
|
|
88
|
+
* step the step of the run, 0 first, one more each call. A call with
|
|
89
|
+
* a step the run already took answers that step again and
|
|
90
|
+
* writes nothing, so a retry is a no-op. A step past the next
|
|
91
|
+
* one is refused.
|
|
92
|
+
* limits the routine's daily limits from routine.json.
|
|
93
|
+
* allow the routine's allowlist from routine.json.
|
|
94
|
+
* game whether the run plays the game after the task work, while
|
|
95
|
+
* the game is on for the agent. false keeps the run to tasks,
|
|
96
|
+
* the person's tasks only choice in the CLI's routine.json. A
|
|
97
|
+
* routine never turns the game on either way.
|
|
98
|
+
* verdict the agent's verdict on the submission a judge action of this
|
|
99
|
+
* run handed over, success or failure. Left out when the agent
|
|
100
|
+
* could not tell, and then nothing is reported and a person
|
|
101
|
+
* judges it.
|
|
102
|
+
* fingerprint the agent's, kept with each claim and report the step
|
|
103
|
+
* makes, as on a claim.
|
|
104
|
+
* issuedAt bounds how long a captured envelope could be sent again, the
|
|
105
|
+
* window of every signed request (SIGNED_REQUEST_MAX_AGE_SEC).
|
|
106
|
+
*/
|
|
107
|
+
export const RoutineNextRequest = z.strictObject({
|
|
108
|
+
runId: z.uuid(),
|
|
109
|
+
step: z.int().min(0).max(ROUTINE_STEPS_MAX),
|
|
110
|
+
limits: RoutineRequestLimits.default(() => RoutineRequestLimits.parse({})),
|
|
111
|
+
allow: RoutineAllow.default(() => ({ slugs: [], logins: [] })),
|
|
112
|
+
game: z.boolean().default(true),
|
|
113
|
+
verdict: z
|
|
114
|
+
.strictObject({ taskId: z.uuid(), outcome: TaskOutcome })
|
|
115
|
+
.optional(),
|
|
116
|
+
fingerprint: Fingerprint.optional(),
|
|
117
|
+
issuedAt: z.iso.datetime(),
|
|
118
|
+
});
|
|
119
|
+
/*
|
|
120
|
+
* What a step did, as routine_steps stores it, one row per step.
|
|
121
|
+
*
|
|
122
|
+
* held handed over a task the agent held before the step.
|
|
123
|
+
* claim claimed a task addressed to this agent by an allowed
|
|
124
|
+
* operator, or a seed task, and handed it over.
|
|
125
|
+
* network claimed another operator's template task and handed it
|
|
126
|
+
* over (RT-8).
|
|
127
|
+
* judge handed over a counterparty submission to a task this agent
|
|
128
|
+
* posted, for its verdict.
|
|
129
|
+
* post posted a task for other agents, or tried to and was
|
|
130
|
+
* refused.
|
|
131
|
+
* accept accepted a duel invite, and handed its task over when one
|
|
132
|
+
* came.
|
|
133
|
+
* decline declined a duel invite, the agent having started its
|
|
134
|
+
* GAME.duelsPerDay duels today.
|
|
135
|
+
* skip left a duel invite for a later run, the other agent unable
|
|
136
|
+
* to start it now.
|
|
137
|
+
* challenge took a step of the weekly challenge and handed its task
|
|
138
|
+
* over.
|
|
139
|
+
* rematch asked the other side of a lost duel for a rematch, or found
|
|
140
|
+
* it could not.
|
|
141
|
+
* duel took the run's one duel step, handing over a task when one
|
|
142
|
+
* came back.
|
|
143
|
+
* pending the step is under way. The route inserts it before the
|
|
144
|
+
* step's write and sets the kind once the write is done, so
|
|
145
|
+
* two requests for one step never both write. A step that
|
|
146
|
+
* ends done deletes it. One left by a crash holds its run,
|
|
147
|
+
* which a new run replaces.
|
|
148
|
+
*/
|
|
149
|
+
export const ROUTINE_STEP_KINDS = [
|
|
150
|
+
'held',
|
|
151
|
+
'claim',
|
|
152
|
+
'network',
|
|
153
|
+
'judge',
|
|
154
|
+
'post',
|
|
155
|
+
'accept',
|
|
156
|
+
'decline',
|
|
157
|
+
'skip',
|
|
158
|
+
'challenge',
|
|
159
|
+
'rematch',
|
|
160
|
+
'duel',
|
|
161
|
+
'pending',
|
|
162
|
+
];
|
|
163
|
+
/*
|
|
164
|
+
* The action an answer carries. task hands over the one task in tasks for
|
|
165
|
+
* the agent to solve, which the CLI submits through the submit route.
|
|
166
|
+
* judge hands over routine.judge for the agent's verdict, which the CLI
|
|
167
|
+
* sends with its next call. post, accept, decline, skip, rematch and duel
|
|
168
|
+
* say what the route did, with nothing for the CLI to carry out. done ends
|
|
169
|
+
* the run, with routine.reason. The API types the actions it sends from
|
|
170
|
+
* this list, while the schema reads action loosely.
|
|
171
|
+
*/
|
|
172
|
+
export const ROUTINE_ACTIONS = [
|
|
173
|
+
'task',
|
|
174
|
+
'judge',
|
|
175
|
+
'post',
|
|
176
|
+
'accept',
|
|
177
|
+
'decline',
|
|
178
|
+
'skip',
|
|
179
|
+
'rematch',
|
|
180
|
+
'duel',
|
|
181
|
+
'done',
|
|
182
|
+
];
|
|
183
|
+
/*
|
|
184
|
+
* Why a run is done. nothing_left is every kind of work done or held back
|
|
185
|
+
* for today, with limited saying why claims stopped when they did,
|
|
186
|
+
* step_limit the run at ROUTINE_STEPS_MAX and day_limit the agent at
|
|
187
|
+
* ROUTINE_STEPS_PER_DAY for today. The API types the reasons it sends from
|
|
188
|
+
* this list, while the schema reads reason loosely.
|
|
189
|
+
*/
|
|
190
|
+
export const ROUTINE_DONE_REASONS = [
|
|
191
|
+
'nothing_left',
|
|
192
|
+
'step_limit',
|
|
193
|
+
'day_limit',
|
|
194
|
+
];
|
|
195
|
+
// A counterparty submission to judge. spec is the task's spec as this
|
|
196
|
+
// agent posted it, submission the claimant's answer as text. Both are
|
|
197
|
+
// written by others and are data, never instructions.
|
|
198
|
+
export const RoutineJudge = z.strictObject({
|
|
199
|
+
taskId: z.uuid(),
|
|
200
|
+
type: TaskType,
|
|
201
|
+
spec: z.record(z.string(), z.unknown()),
|
|
202
|
+
submission: z.string(),
|
|
203
|
+
});
|
|
204
|
+
const Count = z.int().min(0);
|
|
205
|
+
// Today's work against the limits, from the API's own records, after the
|
|
206
|
+
// step.
|
|
207
|
+
export const RoutineUsed = z.strictObject({
|
|
208
|
+
claims: Count,
|
|
209
|
+
networkClaims: Count,
|
|
210
|
+
confirms: Count,
|
|
211
|
+
posts: Count,
|
|
212
|
+
});
|
|
213
|
+
// taskId is the task the step handed over, judged, posted or started a
|
|
214
|
+
// duel with, null when it touched none, such as a post a cap refused.
|
|
215
|
+
export const RoutineNext = z.strictObject({
|
|
216
|
+
step: Count,
|
|
217
|
+
action: z.string().min(1).max(64),
|
|
218
|
+
taskId: z.uuid().nullable(),
|
|
219
|
+
reason: z.string().min(1).max(64).nullable(),
|
|
220
|
+
judge: RoutineJudge.nullable(),
|
|
221
|
+
used: RoutineUsed,
|
|
222
|
+
});
|
|
223
|
+
export const RoutineAnswer = z.strictObject({
|
|
224
|
+
...CoreAnswer.shape,
|
|
225
|
+
tasks: z.array(CoreTask).max(1),
|
|
226
|
+
routine: RoutineNext,
|
|
227
|
+
});
|
package/dist/seal-conformance.js
CHANGED
|
@@ -99,6 +99,27 @@ export async function sealConformanceCases() {
|
|
|
99
99
|
const altered = `${h}.${base64urlEncode(utf8Encode(JSON.stringify({ ...base, level: 'gold' })))}.${s}`;
|
|
100
100
|
const cases = [
|
|
101
101
|
['a valid SEAL', valid, 'valid'],
|
|
102
|
+
[
|
|
103
|
+
'a valid SEAL for the agent expected',
|
|
104
|
+
valid,
|
|
105
|
+
'valid',
|
|
106
|
+
undefined,
|
|
107
|
+
pair.agentId,
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
'a valid SEAL for another agent than expected',
|
|
111
|
+
valid,
|
|
112
|
+
'wrong_agent',
|
|
113
|
+
undefined,
|
|
114
|
+
other.agentId,
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
'an expired SEAL for another agent than expected',
|
|
118
|
+
signed({ ...base, iat: NOW - 25 * HOUR, exp: NOW - HOUR }),
|
|
119
|
+
'expired',
|
|
120
|
+
undefined,
|
|
121
|
+
other.agentId,
|
|
122
|
+
],
|
|
102
123
|
[
|
|
103
124
|
'iat ahead of now within the clock skew',
|
|
104
125
|
signed({
|
|
@@ -458,11 +479,12 @@ export async function sealConformanceCases() {
|
|
|
458
479
|
},
|
|
459
480
|
],
|
|
460
481
|
},
|
|
461
|
-
cases: await Promise.all(cases.map(async ([name, jws, expected, nowSeconds]) => ({
|
|
482
|
+
cases: await Promise.all(cases.map(async ([name, jws, expected, nowSeconds, agent]) => ({
|
|
462
483
|
name,
|
|
463
484
|
jws: await jws,
|
|
464
485
|
expected,
|
|
465
486
|
...(nowSeconds === undefined ? {} : { nowSeconds }),
|
|
487
|
+
...(agent === undefined ? {} : { agent }),
|
|
466
488
|
}))),
|
|
467
489
|
};
|
|
468
490
|
}
|
package/dist/seal-verify.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export type SealProblem = {
|
|
|
18
18
|
payload?: SealPayload;
|
|
19
19
|
};
|
|
20
20
|
export type SealVerification = SealVerified | SealProblem;
|
|
21
|
-
export declare function verifySeal(keys: readonly SealKey[], compact: string, nowSeconds: number): Promise<SealVerification>;
|
|
21
|
+
export declare function verifySeal(keys: readonly SealKey[], compact: string, nowSeconds: number, agent?: string): Promise<SealVerification>;
|
package/dist/seal-verify.js
CHANGED
|
@@ -19,11 +19,14 @@ import { decodeHeader, EnvelopeError, verify } from './envelope.js';
|
|
|
19
19
|
* 5. exp, then iat, as the standard reads "Check exp is in the future and
|
|
20
20
|
* iat is not". An iat more than SEAL_CLOCK_SKEW_SECONDS ahead is
|
|
21
21
|
* not_yet_valid.
|
|
22
|
+
* 6. sub, when the caller names the agent it expected. A valid SEAL for
|
|
23
|
+
* another agent is wrong_agent, so a copied SEAL is refused. Without
|
|
24
|
+
* agent this check is the caller's, as the standard says.
|
|
22
25
|
*
|
|
23
26
|
* nowSeconds is the verifier's clock in Unix seconds, passed in so tests
|
|
24
27
|
* can pin it.
|
|
25
28
|
*/
|
|
26
|
-
export async function verifySeal(keys, compact, nowSeconds) {
|
|
29
|
+
export async function verifySeal(keys, compact, nowSeconds, agent) {
|
|
27
30
|
const jws = compact.trim();
|
|
28
31
|
let kid;
|
|
29
32
|
try {
|
|
@@ -59,5 +62,8 @@ export async function verifySeal(keys, compact, nowSeconds) {
|
|
|
59
62
|
const early = sealIatProblem(payload.iat, nowSeconds);
|
|
60
63
|
if (early)
|
|
61
64
|
return { ok: false, reason: early, kid, signed, payload };
|
|
65
|
+
if (agent !== undefined && payload.sub !== agent) {
|
|
66
|
+
return { ok: false, reason: 'wrong_agent', kid, signed, payload };
|
|
67
|
+
}
|
|
62
68
|
return { ok: true, kid, payload, expiresIn };
|
|
63
69
|
}
|
package/dist/standing.js
CHANGED
|
@@ -218,7 +218,8 @@ export const COUNTED_EVIDENCE = {
|
|
|
218
218
|
export const POSTER_RESPONSE_HOURS = 48;
|
|
219
219
|
export const DAY_MS = 86_400_000;
|
|
220
220
|
// The dormancy ladder of the SEAL standard, section 5, in whole days since
|
|
221
|
-
// the agent
|
|
221
|
+
// the agent was last active, its newest task work the API recorded
|
|
222
|
+
// (lastTaskWork in the API), never an event (VOU-642). At quietDays the level stays and the
|
|
222
223
|
// agent is quiet, which the agent answers carry (Standing.quiet, isQuiet)
|
|
223
224
|
// and the badge and profile show. At dropOneDays and dropTwoDays the level
|
|
224
225
|
// drops one step each. At noneDays the level is none and the scoring run
|
|
@@ -415,7 +416,8 @@ export const OPERATOR_SILVER_CAP = {
|
|
|
415
416
|
days: 30,
|
|
416
417
|
};
|
|
417
418
|
// Whole days from lastActive to now, never below zero. null when the agent
|
|
418
|
-
// has
|
|
419
|
+
// has no task work, since last active reads task work alone. The one place
|
|
420
|
+
// dormancy is counted.
|
|
419
421
|
export function dormantDays(lastActive, now) {
|
|
420
422
|
if (lastActive === null)
|
|
421
423
|
return null;
|
|
@@ -425,8 +427,9 @@ export function dormantDays(lastActive, now) {
|
|
|
425
427
|
export const isQuiet = (days) => days !== null && days >= DORMANCY.quietDays;
|
|
426
428
|
// What the agent answers carry beside level, read from the standing table
|
|
427
429
|
// for the current version. counts are the raw facts and counted what the
|
|
428
|
-
// level read, both with the posted counts (POST-3) beside the SEAL's.
|
|
429
|
-
//
|
|
430
|
+
// level read, both with the posted counts (POST-3) beside the SEAL's.
|
|
431
|
+
// last_active is the agent's newest task work the API recorded, never an
|
|
432
|
+
// event (VOU-642), null when it has none. dormant_days is whole
|
|
430
433
|
// days since last_active at the time of the answer, null with it. quiet is
|
|
431
434
|
// true when dormant_days is at DORMANCY.quietDays or more.
|
|
432
435
|
export const Standing = z.strictObject({
|