@sealkeeper/schema 0.4.6 → 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.
Files changed (90) hide show
  1. package/README.md +2 -2
  2. package/dist/api.d.ts +787 -35
  3. package/dist/api.js +357 -44
  4. package/dist/conformance.d.ts +4 -0
  5. package/dist/conformance.js +7 -0
  6. package/dist/credential.d.ts +196 -27
  7. package/dist/credential.js +128 -80
  8. package/dist/dimensions.d.ts +16 -3
  9. package/dist/dimensions.js +48 -2
  10. package/dist/events.d.ts +1 -0
  11. package/dist/events.js +13 -1
  12. package/dist/fingerprint-conformance.d.ts +17 -0
  13. package/dist/fingerprint-conformance.js +83 -0
  14. package/dist/fingerprint.d.ts +132 -0
  15. package/dist/fingerprint.js +166 -0
  16. package/dist/goal.d.ts +16 -1
  17. package/dist/goal.js +29 -6
  18. package/dist/handshake-conformance.d.ts +18 -0
  19. package/dist/handshake-conformance.js +276 -0
  20. package/dist/handshake.d.ts +66 -0
  21. package/dist/handshake.js +187 -0
  22. package/dist/hidden.d.ts +1 -0
  23. package/dist/hidden.js +5 -0
  24. package/dist/index.d.ts +4 -1
  25. package/dist/index.js +4 -1
  26. package/dist/moderation.js +1 -4
  27. package/dist/policy.d.ts +1 -1
  28. package/dist/policy.js +1 -1
  29. package/dist/seal-conformance.js +148 -4
  30. package/dist/seal-verify.d.ts +21 -0
  31. package/dist/seal-verify.js +63 -0
  32. package/dist/standing.d.ts +61 -0
  33. package/dist/standing.js +132 -4
  34. package/dist/task-templates.d.ts +46 -0
  35. package/dist/task-templates.js +501 -0
  36. package/dist/tasks.d.ts +43 -0
  37. package/dist/tasks.js +103 -0
  38. package/dist/template-conformance.d.ts +10 -0
  39. package/dist/template-conformance.js +298 -0
  40. package/dist/top-dimensions.d.ts +3 -3
  41. package/dist/top-dimensions.js +12 -6
  42. package/package.json +4 -8
  43. package/dist/db/agent-milestones.d.ts +0 -75
  44. package/dist/db/agent-milestones.js +0 -16
  45. package/dist/db/agent-renames.d.ts +0 -126
  46. package/dist/db/agent-renames.js +0 -20
  47. package/dist/db/agents.d.ts +0 -351
  48. package/dist/db/agents.js +0 -99
  49. package/dist/db/client.d.ts +0 -2561
  50. package/dist/db/client.js +0 -61
  51. package/dist/db/credentials.d.ts +0 -143
  52. package/dist/db/credentials.js +0 -16
  53. package/dist/db/deleted-operators.d.ts +0 -75
  54. package/dist/db/deleted-operators.js +0 -13
  55. package/dist/db/events.d.ts +0 -160
  56. package/dist/db/events.js +0 -41
  57. package/dist/db/feed-items.d.ts +0 -109
  58. package/dist/db/feed-items.js +0 -21
  59. package/dist/db/index.d.ts +0 -76
  60. package/dist/db/index.js +0 -28
  61. package/dist/db/migrate.d.ts +0 -1
  62. package/dist/db/migrate.js +0 -34
  63. package/dist/db/migrator.d.ts +0 -6
  64. package/dist/db/migrator.js +0 -36
  65. package/dist/db/operator-identities.d.ts +0 -211
  66. package/dist/db/operator-identities.js +0 -49
  67. package/dist/db/operator-level-grants.d.ts +0 -109
  68. package/dist/db/operator-level-grants.js +0 -30
  69. package/dist/db/operator-slugs.d.ts +0 -92
  70. package/dist/db/operator-slugs.js +0 -25
  71. package/dist/db/operators.d.ts +0 -228
  72. package/dist/db/operators.js +0 -39
  73. package/dist/db/quota-counters.d.ts +0 -109
  74. package/dist/db/quota-counters.js +0 -17
  75. package/dist/db/ratings.d.ts +0 -160
  76. package/dist/db/ratings.js +0 -27
  77. package/dist/db/scores.d.ts +0 -160
  78. package/dist/db/scores.js +0 -15
  79. package/dist/db/standing.d.ts +0 -264
  80. package/dist/db/standing.js +0 -34
  81. package/dist/db/task-claim-failures.d.ts +0 -143
  82. package/dist/db/task-claim-failures.js +0 -37
  83. package/dist/db/task-outcomes.d.ts +0 -145
  84. package/dist/db/task-outcomes.js +0 -25
  85. package/dist/db/tasks.d.ts +0 -381
  86. package/dist/db/tasks.js +0 -106
  87. package/dist/db/timestamps.d.ts +0 -4
  88. package/dist/db/timestamps.js +0 -24
  89. package/dist/db/url.d.ts +0 -12
  90. package/dist/db/url.js +0 -25
@@ -0,0 +1,132 @@
1
+ import { z } from 'zod';
2
+ export declare const FINGERPRINT_PARTS: readonly ['model_set', 'prompt', 'tools', 'framework'];
3
+ export type FingerprintPartName = (typeof FINGERPRINT_PARTS)[number];
4
+ export declare const FINGERPRINT_NOT_DECLARED = "not_declared";
5
+ export declare const FINGERPRINT_UNSTABLE = "unstable";
6
+ export declare const FINGERPRINT_UNSTABLE_CAPTURES = 5;
7
+ export declare const Sha256Base64url: z.ZodString;
8
+ export declare const FingerprintPart: z.ZodUnion<readonly [z.ZodObject<{
9
+ hash: z.ZodString;
10
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
11
+ export type FingerprintPart = z.infer<typeof FingerprintPart>;
12
+ export declare const FingerprintParts: z.ZodObject<{
13
+ model_set: z.ZodUnion<readonly [z.ZodObject<{
14
+ hash: z.ZodString;
15
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
16
+ prompt: z.ZodUnion<readonly [z.ZodObject<{
17
+ hash: z.ZodString;
18
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
19
+ tools: z.ZodUnion<readonly [z.ZodObject<{
20
+ hash: z.ZodString;
21
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
22
+ framework: z.ZodUnion<readonly [z.ZodObject<{
23
+ hash: z.ZodString;
24
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
25
+ }, z.core.$strict>;
26
+ export type FingerprintParts = z.infer<typeof FingerprintParts>;
27
+ export declare const FINGERPRINT_MAX_CAPTURED_AT = 253402300799;
28
+ export declare const Fingerprint: z.ZodObject<{
29
+ parts: z.ZodObject<{
30
+ model_set: z.ZodUnion<readonly [z.ZodObject<{
31
+ hash: z.ZodString;
32
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
33
+ prompt: z.ZodUnion<readonly [z.ZodObject<{
34
+ hash: z.ZodString;
35
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
36
+ tools: z.ZodUnion<readonly [z.ZodObject<{
37
+ hash: z.ZodString;
38
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
39
+ framework: z.ZodUnion<readonly [z.ZodObject<{
40
+ hash: z.ZodString;
41
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
42
+ }, z.core.$strict>;
43
+ hash: z.ZodString;
44
+ captured_at: z.ZodNumber;
45
+ }, z.core.$strict>;
46
+ export type Fingerprint = z.infer<typeof Fingerprint>;
47
+ export declare function fingerprintPartText(part: FingerprintPart): string;
48
+ export declare function fingerprintCanonical(parts: FingerprintParts): Uint8Array;
49
+ export declare function fingerprintHash(parts: FingerprintParts): Promise<string>;
50
+ export declare function partHash(agentId: string, content: Uint8Array | string): Promise<string>;
51
+ export declare function makeFingerprint(parts: FingerprintParts, capturedAt: number): Promise<Fingerprint>;
52
+ export declare function fingerprintProblem(value: unknown): Promise<'malformed' | 'hash_mismatch' | null>;
53
+ export declare const FINGERPRINT_DECLARED = "declared";
54
+ export declare const FingerprintPartState: z.ZodEnum<{
55
+ declared: "declared";
56
+ not_declared: "not_declared";
57
+ unstable: "unstable";
58
+ }>;
59
+ export type FingerprintPartState = z.infer<typeof FingerprintPartState>;
60
+ export declare const FingerprintStates: z.ZodObject<{
61
+ model_set: z.ZodEnum<{
62
+ declared: "declared";
63
+ not_declared: "not_declared";
64
+ unstable: "unstable";
65
+ }>;
66
+ prompt: z.ZodEnum<{
67
+ declared: "declared";
68
+ not_declared: "not_declared";
69
+ unstable: "unstable";
70
+ }>;
71
+ tools: z.ZodEnum<{
72
+ declared: "declared";
73
+ not_declared: "not_declared";
74
+ unstable: "unstable";
75
+ }>;
76
+ framework: z.ZodEnum<{
77
+ declared: "declared";
78
+ not_declared: "not_declared";
79
+ unstable: "unstable";
80
+ }>;
81
+ }, z.core.$strict>;
82
+ export type FingerprintStates = z.infer<typeof FingerprintStates>;
83
+ export declare const AgentFingerprint: z.ZodObject<{
84
+ hash: z.ZodString;
85
+ at: z.ZodISODateTime;
86
+ parts: z.ZodObject<{
87
+ model_set: z.ZodEnum<{
88
+ declared: "declared";
89
+ not_declared: "not_declared";
90
+ unstable: "unstable";
91
+ }>;
92
+ prompt: z.ZodEnum<{
93
+ declared: "declared";
94
+ not_declared: "not_declared";
95
+ unstable: "unstable";
96
+ }>;
97
+ tools: z.ZodEnum<{
98
+ declared: "declared";
99
+ not_declared: "not_declared";
100
+ unstable: "unstable";
101
+ }>;
102
+ framework: z.ZodEnum<{
103
+ declared: "declared";
104
+ not_declared: "not_declared";
105
+ unstable: "unstable";
106
+ }>;
107
+ }, z.core.$strict>;
108
+ }, z.core.$strict>;
109
+ export type AgentFingerprint = z.infer<typeof AgentFingerprint>;
110
+ export declare function fingerprintPartState(part: FingerprintPart): FingerprintPartState;
111
+ export declare function agentFingerprintOf(fingerprint: Fingerprint): AgentFingerprint;
112
+ export declare const FingerprintDeclaration: z.ZodObject<{
113
+ fingerprint: z.ZodObject<{
114
+ parts: z.ZodObject<{
115
+ model_set: z.ZodUnion<readonly [z.ZodObject<{
116
+ hash: z.ZodString;
117
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
118
+ prompt: z.ZodUnion<readonly [z.ZodObject<{
119
+ hash: z.ZodString;
120
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
121
+ tools: z.ZodUnion<readonly [z.ZodObject<{
122
+ hash: z.ZodString;
123
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
124
+ framework: z.ZodUnion<readonly [z.ZodObject<{
125
+ hash: z.ZodString;
126
+ }, z.core.$strict>, z.ZodLiteral<"not_declared">, z.ZodLiteral<"unstable">]>;
127
+ }, z.core.$strict>;
128
+ hash: z.ZodString;
129
+ captured_at: z.ZodNumber;
130
+ }, z.core.$strict>;
131
+ }, z.core.$strict>;
132
+ export type FingerprintDeclaration = z.infer<typeof FingerprintDeclaration>;
@@ -0,0 +1,166 @@
1
+ import { z } from 'zod';
2
+ import { AgentId } from './agent-id.js';
3
+ import { base64urlEncode, utf8Encode } from './base64url.js';
4
+ /*
5
+ * The fingerprint of what an agent runs now, beside its version and never in
6
+ * place of it (D-VB-1). The version stays the operator's label and the
7
+ * scoring key. The fingerprint records the model, prompt, tools and
8
+ * framework the agent ran under, each as a SHA-256 hash the CLI computed on
9
+ * the machine. What a part is hashed from never leaves the machine.
10
+ *
11
+ * A part is its hash, not_declared when the adapter cannot see it, or
12
+ * unstable when its hash changed on every one of the last captures, so a
13
+ * part that churns does not make every fingerprint look new.
14
+ *
15
+ * The hash rule. A part's hash is SHA-256 over the agent id, one newline,
16
+ * then the content, in base64url (partHash). The agent id keeps a part from
17
+ * being a dictionary lookup, since a model id or a framework version is
18
+ * easy to guess, and a fingerprint is only ever compared with the same
19
+ * agent's. The fingerprint hash is SHA-256 over the four parts in the fixed
20
+ * order model_set, prompt, tools, framework, each as its hash or its state
21
+ * string, joined by one newline with no newline at the end, UTF-8
22
+ * (fingerprintHash). No JSON canonicalisation anywhere.
23
+ */
24
+ // The parts in the fixed order the canonical bytes use. Adding a part is a
25
+ // new fingerprint format, since it changes every hash.
26
+ export const FINGERPRINT_PARTS = [
27
+ 'model_set',
28
+ 'prompt',
29
+ 'tools',
30
+ 'framework',
31
+ ];
32
+ export const FINGERPRINT_NOT_DECLARED = 'not_declared';
33
+ export const FINGERPRINT_UNSTABLE = 'unstable';
34
+ // A part whose hash differed from the capture before it on each of the last
35
+ // this many captures reads unstable (D-VB-4). The CLI keeps this many, and
36
+ // the profile's help names the number.
37
+ export const FINGERPRINT_UNSTABLE_CAPTURES = 5;
38
+ // A SHA-256 digest in base64url without padding, 43 characters. 256 bits
39
+ // leave 4 bits in the last character, so only the 16 characters whose low
40
+ // two bits are zero can end it, which keeps one spelling per digest.
41
+ export const Sha256Base64url = z
42
+ .string()
43
+ .regex(/^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/, 'SHA-256, base64url');
44
+ export const FingerprintPart = z.union([
45
+ z.strictObject({ hash: Sha256Base64url }),
46
+ z.literal(FINGERPRINT_NOT_DECLARED),
47
+ z.literal(FINGERPRINT_UNSTABLE),
48
+ ]);
49
+ export const FingerprintParts = z.strictObject({
50
+ model_set: FingerprintPart,
51
+ prompt: FingerprintPart,
52
+ tools: FingerprintPart,
53
+ framework: FingerprintPart,
54
+ });
55
+ // The last second of 9999-12-31 UTC, the latest captured_at a fingerprint
56
+ // may carry. A capture past it is refused at the edge with the rest of the
57
+ // shape, rather than failing in the database.
58
+ export const FINGERPRINT_MAX_CAPTURED_AT = 253402300799;
59
+ // hash is fingerprintHash(parts). The schema checks the shape only. A reader
60
+ // that relies on hash recomputes it, see fingerprintProblem.
61
+ export const Fingerprint = z.strictObject({
62
+ parts: FingerprintParts,
63
+ hash: Sha256Base64url,
64
+ // When the CLI captured it, Unix seconds, at most the last second of
65
+ // year 9999, so every value is a timestamp Postgres and Date can hold.
66
+ captured_at: z.number().int().min(0).max(FINGERPRINT_MAX_CAPTURED_AT),
67
+ });
68
+ // A part as it appears in the canonical bytes, its hash or its state.
69
+ export function fingerprintPartText(part) {
70
+ return typeof part === 'string' ? part : part.hash;
71
+ }
72
+ // The canonical bytes of the parts. Each part as its hash or its state
73
+ // string, in the order of FINGERPRINT_PARTS, joined by one newline with no
74
+ // newline at the end, UTF-8. No JSON and no canonicalisation library, the
75
+ // same stance as the JWS.
76
+ export function fingerprintCanonical(parts) {
77
+ return utf8Encode(FINGERPRINT_PARTS.map((name) => fingerprintPartText(parts[name])).join('\n'));
78
+ }
79
+ // WebCrypto, so the same code runs in Node, the browser and edge runtimes.
80
+ async function sha256(bytes) {
81
+ const digest = await globalThis.crypto.subtle.digest('SHA-256', new Uint8Array(bytes));
82
+ return base64urlEncode(new Uint8Array(digest));
83
+ }
84
+ // The fingerprint hash, SHA-256 of the canonical bytes, base64url.
85
+ export function fingerprintHash(parts) {
86
+ return sha256(fingerprintCanonical(parts));
87
+ }
88
+ // A part's hash under the hash rule above, for the agent agentId. A string
89
+ // is hashed as its UTF-8 bytes. Every adapter hashes through this, so one
90
+ // input gives one hash wherever it is computed. Throws on an agent id that
91
+ // is not one, as a rejected promise.
92
+ export async function partHash(agentId, content) {
93
+ const id = AgentId.parse(agentId);
94
+ const body = typeof content === 'string' ? utf8Encode(content) : content;
95
+ const prefix = utf8Encode(`${id}\n`);
96
+ const bytes = new Uint8Array(prefix.length + body.length);
97
+ bytes.set(prefix);
98
+ bytes.set(body, prefix.length);
99
+ return sha256(bytes);
100
+ }
101
+ // A whole fingerprint from its parts, with its hash.
102
+ export async function makeFingerprint(parts, capturedAt) {
103
+ return Fingerprint.parse({
104
+ parts,
105
+ hash: await fingerprintHash(parts),
106
+ captured_at: capturedAt,
107
+ });
108
+ }
109
+ // Why a value is not a fingerprint to rely on, or null when it is one. The
110
+ // shape comes first, then the hash, which must be the hash of its parts.
111
+ export async function fingerprintProblem(value) {
112
+ const parsed = Fingerprint.safeParse(value);
113
+ if (!parsed.success)
114
+ return 'malformed';
115
+ const hash = await fingerprintHash(parsed.data.parts);
116
+ return hash === parsed.data.hash ? null : 'hash_mismatch';
117
+ }
118
+ /*
119
+ * The agent's current fingerprint as the agent answer shows it (VB-4). Its
120
+ * hash, when it was captured, and each part as its state alone, declared,
121
+ * not_declared or unstable. The part hashes stay out, since they are
122
+ * salted with the agent id and serve no reader. The handshake (VB-6)
123
+ * compares the fingerprint hash.
124
+ */
125
+ export const FINGERPRINT_DECLARED = 'declared';
126
+ export const FingerprintPartState = z.enum([
127
+ FINGERPRINT_DECLARED,
128
+ FINGERPRINT_NOT_DECLARED,
129
+ FINGERPRINT_UNSTABLE,
130
+ ]);
131
+ export const FingerprintStates = z.strictObject({
132
+ model_set: FingerprintPartState,
133
+ prompt: FingerprintPartState,
134
+ tools: FingerprintPartState,
135
+ framework: FingerprintPartState,
136
+ });
137
+ // at is captured_at as an ISO 8601 timestamp.
138
+ export const AgentFingerprint = z.strictObject({
139
+ hash: Sha256Base64url,
140
+ at: z.iso.datetime(),
141
+ parts: FingerprintStates,
142
+ });
143
+ // A part's state, declared when it is a hash.
144
+ export function fingerprintPartState(part) {
145
+ return typeof part === 'string' ? part : FINGERPRINT_DECLARED;
146
+ }
147
+ // The answer's view of a stored fingerprint, never a part hash.
148
+ export function agentFingerprintOf(fingerprint) {
149
+ const { parts } = fingerprint;
150
+ return {
151
+ hash: fingerprint.hash,
152
+ at: new Date(fingerprint.captured_at * 1000).toISOString(),
153
+ parts: {
154
+ model_set: fingerprintPartState(parts.model_set),
155
+ prompt: fingerprintPartState(parts.prompt),
156
+ tools: fingerprintPartState(parts.tools),
157
+ framework: fingerprintPartState(parts.framework),
158
+ },
159
+ };
160
+ }
161
+ // The signed payload of the fingerprint a sync declares (VB-4). A batch's
162
+ // envelopes are events, so the fingerprint travels as its own JWS, signed
163
+ // by the same agent, under fingerprint on EventsBatchRequest.
164
+ export const FingerprintDeclaration = z.strictObject({
165
+ fingerprint: Fingerprint,
166
+ });
package/dist/goal.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- export declare const GOAL_ACTION_CODES: readonly ['dormant', 'operator_verification_lapsing', 'confirm_outcomes', 'addressed_waiting', 'claim_seed_tasks', 'claim_tasks', 'counterparty_tasks', 'need_operators', 'history_days', 'reliability_below', 'safety_below', 'safety_incident_window', 'clean_days', 'provenance_below', 'declare_model', 'operator_unverified', 'need_ratings', 'version_cap', 'operator_silver_cap', 'report_as_poster'];
2
+ export declare const GOAL_ACTION_CODES: readonly ['dormant', 'operator_verification_lapsing', 'confirm_outcomes', 'report_as_poster', 'addressed_waiting', 'claim_seed_tasks', 'post_task', 'post_confirmed_task', 'claim_tasks', 'counterparty_tasks', 'need_operators', 'history_days', 'reliability_below', 'safety_below', 'safety_incident_window', 'clean_days', 'provenance_below', 'declare_model', 'operator_unverified', 'need_ratings', 'version_cap', 'operator_silver_cap'];
3
3
  export declare const GoalActionCode: z.ZodEnum<{
4
4
  addressed_waiting: "addressed_waiting";
5
5
  claim_seed_tasks: "claim_seed_tasks";
@@ -15,6 +15,8 @@ export declare const GoalActionCode: z.ZodEnum<{
15
15
  operator_silver_cap: "operator_silver_cap";
16
16
  operator_unverified: "operator_unverified";
17
17
  operator_verification_lapsing: "operator_verification_lapsing";
18
+ post_confirmed_task: "post_confirmed_task";
19
+ post_task: "post_task";
18
20
  provenance_below: "provenance_below";
19
21
  reliability_below: "reliability_below";
20
22
  report_as_poster: "report_as_poster";
@@ -83,6 +85,11 @@ export declare const GoalPending: z.ZodObject<{
83
85
  posterOutcomes: z.ZodInt;
84
86
  }, z.core.$strict>;
85
87
  export type GoalPending = z.infer<typeof GoalPending>;
88
+ export declare const GoalSide: z.ZodObject<{
89
+ current: z.ZodNumber;
90
+ required: z.ZodNumber;
91
+ }, z.core.$strict>;
92
+ export type GoalSide = z.infer<typeof GoalSide>;
86
93
  export declare const GoalResponse: z.ZodObject<{
87
94
  agentId: z.ZodString;
88
95
  version: z.ZodString;
@@ -128,6 +135,14 @@ export declare const GoalResponse: z.ZodObject<{
128
135
  required: z.ZodNumber;
129
136
  }, z.core.$strict>>;
130
137
  }, z.core.$strict>>;
138
+ taken: z.ZodNullable<z.ZodObject<{
139
+ current: z.ZodNumber;
140
+ required: z.ZodNumber;
141
+ }, z.core.$strict>>;
142
+ posted: z.ZodNullable<z.ZodObject<{
143
+ current: z.ZodNumber;
144
+ required: z.ZodNumber;
145
+ }, z.core.$strict>>;
131
146
  actions: z.ZodArray<z.ZodObject<{
132
147
  code: z.ZodString;
133
148
  count: z.ZodNullable<z.ZodInt>;
package/dist/goal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { AgentId } from './agent-id.js';
3
- import { Version } from './events.js';
3
+ import { StoredVersion } from './events.js';
4
4
  import { LADDER, Level } from './standing.js';
5
5
  // GET /v1/agents/:id/goal. What the agent's current version needs for its
6
6
  // next level, threshold by threshold, and what to do next. The API sends
@@ -24,12 +24,28 @@ export const GOAL_ACTION_CODES = [
24
24
  // confirmed task counts for its claimant, so this counts toward the
25
25
  // agent's own level. count is how many.
26
26
  'confirm_outcomes',
27
+ // Counterparty tasks this agent posted wait for its outcome report. It
28
+ // confirms the task for the claimant, and since POST-3 the confirmed task
29
+ // counts in this agent's posted tasks too, so it comes beside
30
+ // confirm_outcomes. count is how many.
31
+ 'report_as_poster',
27
32
  // Tasks addressed to this agent are waiting to be claimed. count is how
28
33
  // many.
29
34
  'addressed_waiting',
30
35
  // Verified tasks still needed. Seed tasks count toward it at every level
31
36
  // (VOU-172). count is how many.
32
37
  'claim_seed_tasks',
38
+ // Posted tasks that other operators' agents complete still needed, for
39
+ // the posted tasks or posted operators of the next level (POST-3). count
40
+ // is the posts at least still needed. It comes before claim_seed_tasks
41
+ // when posting is further behind than taking (POST-6), else where the
42
+ // posted rows come in the table.
43
+ 'post_task',
44
+ // Posted confirmed tasks still needed (POST-6). Only a counterparty task
45
+ // the agent posted by hand, completed by another operator's agent and
46
+ // confirmed by both outcome reports, counts, so a template or adopted
47
+ // post never closes it. count is how many.
48
+ 'post_confirmed_task',
33
49
  // Verified tasks from other operators' agents still needed. No threshold
34
50
  // sends it since VOU-172, where seed tasks count at every level. Kept so
35
51
  // a client that knows it keeps working.
@@ -65,10 +81,6 @@ export const GOAL_ACTION_CODES = [
65
81
  // taken (OPERATOR_SILVER_CAP), so the agent is held at bronze. count is
66
82
  // the whole days until the next slot frees and until the moment it does.
67
83
  'operator_silver_cap',
68
- // Counterparty tasks this agent posted wait for its outcome report. It
69
- // helps the claimant, the other agent, and adds nothing to this agent's
70
- // level, so it comes after every step that does. count is how many.
71
- 'report_as_poster',
72
84
  ];
73
85
  export const GoalActionCode = z.enum(GOAL_ACTION_CODES);
74
86
  // One rule of the next level. current is what the version has (0 for a
@@ -156,14 +168,25 @@ export const GoalPending = z.strictObject({
156
168
  outcomes: Count,
157
169
  posterOutcomes: Count,
158
170
  });
171
+ // One side of the agent's work toward the next level (POST-6), current
172
+ // against required, in counted units. taken is the verified_tasks
173
+ // threshold, the tasks the agent took. posted is the posted_tasks
174
+ // threshold, the tasks it posted that other operators' agents completed.
175
+ export const GoalSide = z.strictObject({
176
+ current: z.number(),
177
+ required: z.number(),
178
+ });
159
179
  export const GoalResponse = z.strictObject({
160
180
  agentId: AgentId,
161
- version: Version,
181
+ version: StoredVersion,
162
182
  level: Level,
163
183
  nextLevel: Level.nullable(),
164
184
  ladder: z.array(GoalLadderStep),
165
185
  thresholds: z.array(GoalThreshold),
166
186
  steps: z.array(GoalStep),
187
+ // Taken and posted toward nextLevel, null when nextLevel is null.
188
+ taken: GoalSide.nullable(),
189
+ posted: GoalSide.nullable(),
167
190
  actions: z.array(GoalAction),
168
191
  pending: GoalPending,
169
192
  today: GoalToday,
@@ -0,0 +1,18 @@
1
+ import { type WellKnown } from './credential.js';
2
+ import { type HandshakeRefusal, type HandshakeResult } from './handshake.js';
3
+ export type HandshakeConformanceCase = {
4
+ name: string;
5
+ jws: string;
6
+ expected: Exclude<HandshakeResult, 'no_fingerprint'> | HandshakeRefusal;
7
+ nonce?: string;
8
+ nowSeconds?: number;
9
+ };
10
+ export type HandshakeConformance = {
11
+ nowSeconds: number;
12
+ sub: string;
13
+ fingerprint: string;
14
+ seal: string;
15
+ wellKnown: WellKnown;
16
+ cases: HandshakeConformanceCase[];
17
+ };
18
+ export declare function handshakeConformanceCases(): Promise<HandshakeConformance>;