toolroll 0.9.34 → 0.9.37
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/CHANGELOG.md +102 -0
- package/README.md +7 -0
- package/dist/assignment-adapters.d.ts +12 -48
- package/dist/assignment-adapters.js +33 -43
- package/dist/assignment.d.ts +1 -0
- package/dist/assignment.js +2 -2
- package/dist/browser-workspace.d.ts +3 -3
- package/dist/build-review.d.ts +1 -1
- package/dist/build-review.js +2 -1
- package/dist/builder.js +4 -7
- package/dist/chat-acceptance.d.ts +2 -2
- package/dist/chat-actions.d.ts +18 -12
- package/dist/chat-actions.js +15 -65
- package/dist/chat-ask.js +5 -5
- package/dist/chat-decide.d.ts +14 -1
- package/dist/chat-decide.js +12 -6
- package/dist/chat-delivery-state.d.ts +12 -70
- package/dist/chat-delivery-state.js +17 -135
- package/dist/chat-delivery.js +58 -30
- package/dist/chat-flow.js +8 -6
- package/dist/chat-inbox.js +1 -1
- package/dist/coding-context.d.ts +2 -39
- package/dist/coding-context.js +2 -1
- package/dist/coding-handoff.d.ts +6 -25
- package/dist/coding-handoff.js +11 -5
- package/dist/coding-types.d.ts +2 -26
- package/dist/coding-workspace.d.ts +2 -0
- package/dist/coding-workspace.js +50 -14
- package/dist/contracts/acceptance-terms.d.ts +14 -0
- package/dist/contracts/acceptance-terms.js +16 -0
- package/dist/contracts/chat-actions.d.ts +328 -0
- package/dist/contracts/chat-actions.js +133 -0
- package/dist/contracts/chat-callback-rows.d.ts +59 -0
- package/dist/contracts/chat-callback-rows.js +46 -0
- package/dist/contracts/chat-content.d.ts +276 -0
- package/dist/contracts/chat-content.js +127 -0
- package/dist/contracts/chat-tables.d.ts +6 -0
- package/dist/contracts/chat-tables.js +136 -0
- package/dist/contracts/coding-context.d.ts +97 -0
- package/dist/contracts/coding-context.js +60 -0
- package/dist/contracts/coding-handoff.d.ts +44 -0
- package/dist/contracts/coding-handoff.js +47 -0
- package/dist/contracts/coding-workspace.d.ts +165 -0
- package/dist/contracts/coding-workspace.js +71 -0
- package/dist/contracts/contract.d.ts +40 -7
- package/dist/contracts/contract.js +155 -19
- package/dist/contracts/decision.d.ts +45 -0
- package/dist/contracts/decision.js +45 -0
- package/dist/contracts/discord-callback.d.ts +45 -0
- package/dist/contracts/discord-callback.js +34 -0
- package/dist/contracts/flow-card.d.ts +50 -0
- package/dist/contracts/flow-card.js +46 -0
- package/dist/contracts/flow-propose.d.ts +325 -0
- package/dist/contracts/flow-propose.js +41 -0
- package/dist/contracts/flow-send.d.ts +119 -0
- package/dist/contracts/flow-send.js +112 -0
- package/dist/contracts/flow.d.ts +19405 -0
- package/dist/contracts/flow.js +364 -0
- package/dist/contracts/gateway-tools.d.ts +374 -0
- package/dist/contracts/gateway-tools.js +94 -0
- package/dist/contracts/handoff.d.ts +91 -0
- package/dist/contracts/handoff.js +82 -0
- package/dist/contracts/lead-context.d.ts +165 -0
- package/dist/contracts/lead-context.js +73 -0
- package/dist/contracts/lead-tools.d.ts +1905 -0
- package/dist/contracts/lead-tools.js +265 -0
- package/dist/contracts/memory-pass.d.ts +158 -0
- package/dist/contracts/memory-pass.js +102 -0
- package/dist/contracts/project-knowledge.d.ts +126 -0
- package/dist/contracts/project-knowledge.js +93 -0
- package/dist/contracts/project-memory.d.ts +117 -0
- package/dist/contracts/project-memory.js +51 -0
- package/dist/contracts/project-skills.d.ts +121 -0
- package/dist/contracts/project-skills.js +76 -0
- package/dist/contracts/proof.d.ts +136 -0
- package/dist/contracts/proof.js +110 -0
- package/dist/contracts/review-findings.d.ts +46 -0
- package/dist/contracts/review-findings.js +48 -0
- package/dist/contracts/route.d.ts +484 -0
- package/dist/contracts/route.js +128 -0
- package/dist/contracts/scope.d.ts +105 -0
- package/dist/contracts/scope.js +114 -0
- package/dist/contracts/scout-report.d.ts +234 -0
- package/dist/contracts/scout-report.js +141 -0
- package/dist/contracts/slack-callback.d.ts +43 -0
- package/dist/contracts/slack-callback.js +35 -0
- package/dist/contracts/sort-answer.d.ts +83 -0
- package/dist/contracts/sort-answer.js +77 -0
- package/dist/contracts/stage-output.d.ts +127 -0
- package/dist/contracts/stage-output.js +166 -0
- package/dist/contracts/task-sizing.d.ts +24 -0
- package/dist/contracts/task-sizing.js +28 -0
- package/dist/contracts/teammate-turn.d.ts +43 -0
- package/dist/contracts/teammate-turn.js +51 -0
- package/dist/contracts/teams-callback.d.ts +14 -0
- package/dist/contracts/teams-callback.js +14 -0
- package/dist/contracts/telegram-callback.d.ts +120 -0
- package/dist/contracts/telegram-callback.js +97 -0
- package/dist/contracts/verification-receipt.d.ts +148 -0
- package/dist/contracts/verification-receipt.js +87 -0
- package/dist/decision.d.ts +11 -20
- package/dist/decision.js +86 -167
- package/dist/demo.js +28 -11
- package/dist/discord-chat.js +31 -20
- package/dist/evidence.d.ts +3 -40
- package/dist/evidence.js +5 -1
- package/dist/flow-engine.js +14 -17
- package/dist/flow-gallery.d.ts +3 -2
- package/dist/flow-items.d.ts +4 -13
- package/dist/flow-items.js +1 -15
- package/dist/flow-send.d.ts +6 -37
- package/dist/flow-send.js +18 -14
- package/dist/flow-share.d.ts +10 -32
- package/dist/flow-share.js +72 -84
- package/dist/flow-sort.d.ts +7 -26
- package/dist/flow-sort.js +25 -20
- package/dist/flow-starters.d.ts +2 -1
- package/dist/flow-steps.js +3 -2
- package/dist/flow-triggers.d.ts +15 -72
- package/dist/flow-triggers.js +94 -83
- package/dist/flows.d.ts +37 -220
- package/dist/flows.js +356 -387
- package/dist/invoke.js +4 -4
- package/dist/lead-context.d.ts +4 -2
- package/dist/lead-context.js +24 -17
- package/dist/mate-tools.d.ts +4 -0
- package/dist/mate-tools.js +111 -308
- package/dist/mcp-connect.d.ts +27 -4
- package/dist/mcp-connect.js +92 -17
- package/dist/mcp.js +84 -216
- package/dist/memory-pass.d.ts +17 -42
- package/dist/memory-pass.js +54 -26
- package/dist/operate.js +31 -2
- package/dist/phase-routing.d.ts +19 -72
- package/dist/phase-routing.js +34 -164
- package/dist/plan.d.ts +5 -5
- package/dist/plan.js +5 -25
- package/dist/process-recovery-eligibility.d.ts +2 -2
- package/dist/process-recovery-eligibility.js +13 -8
- package/dist/project-knowledge.d.ts +16 -35
- package/dist/project-knowledge.js +42 -21
- package/dist/project-memory.d.ts +2 -28
- package/dist/project-memory.js +28 -13
- package/dist/project-skills.d.ts +16 -38
- package/dist/project-skills.js +41 -32
- package/dist/project-tools.d.ts +1 -0
- package/dist/project-tools.js +4 -4
- package/dist/proof.d.ts +15 -91
- package/dist/proof.js +90 -249
- package/dist/provider.d.ts +2 -0
- package/dist/provider.js +4 -16
- package/dist/result-evidence-readers.d.ts +42 -0
- package/dist/result-evidence-readers.js +91 -0
- package/dist/result-shots.d.ts +1 -1
- package/dist/result-shots.js +2 -1
- package/dist/review-switch.d.ts +3 -8
- package/dist/reviewer.d.ts +8 -12
- package/dist/reviewer.js +11 -35
- package/dist/scope.d.ts +21 -43
- package/dist/scope.js +42 -128
- package/dist/scout-report.d.ts +9 -194
- package/dist/scout-report.js +113 -264
- package/dist/scout.js +15 -11
- package/dist/serve.js +17 -101
- package/dist/slack-chat.js +26 -20
- package/dist/slack-state.js +2 -1
- package/dist/store.d.ts +9 -32
- package/dist/store.js +18 -15
- package/dist/structured-output.js +2 -1
- package/dist/subscription-chat.d.ts +4 -0
- package/dist/subscription-chat.js +4 -1
- package/dist/surface.js +8 -1
- package/dist/task-review-brief.d.ts +69 -0
- package/dist/task-review-brief.js +179 -0
- package/dist/task-sizing.d.ts +3 -27
- package/dist/task-sizing.js +11 -26
- package/dist/task-text.d.ts +0 -5
- package/dist/task-text.js +1 -3
- package/dist/teammate-question.js +7 -5
- package/dist/teammate-work.js +9 -5
- package/dist/teammates.d.ts +13 -64
- package/dist/teammates.js +32 -33
- package/dist/teams-chat.js +20 -11
- package/dist/telegram-flow.js +4 -3
- package/dist/telegram-mate.d.ts +4 -14
- package/dist/telegram-mate.js +8 -7
- package/dist/telegram-team.d.ts +2 -19
- package/dist/telegram.d.ts +1 -1
- package/dist/telegram.js +52 -42
- package/dist/text-limits.d.ts +212 -1
- package/dist/text-limits.js +214 -1
- package/dist/tools-ui.d.ts +2 -1
- package/dist/tools-ui.js +7 -4
- package/dist/verification-evidence.js +24 -12
- package/package.json +1 -1
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP gateway's tools (docs/plans/zod-revamp.md, item 5; docs/mcp-gateway-spec.md): one input schema per tool and
|
|
3
|
+
* one output schema for what each returns. The input schema is the `inputSchema` tools/list advertises and the check
|
|
4
|
+
* a call is read with before its handler runs (mcp.ts): a call it refuses is a JSON-RPC InvalidParams error naming each
|
|
5
|
+
* path, never a tool refusal. The assignment tools' schemas are also what `toolroll assignment` reads its flags with
|
|
6
|
+
* (assignment-adapters.ts), so the CLI and the gateway take exactly the same arguments.
|
|
7
|
+
*
|
|
8
|
+
* A coordinator names a project by its path and a task by `ref`; the lead's tools (lead-tools.ts) say r1 and `task`.
|
|
9
|
+
* Output schemas describe a result's top level: checked in tests, logged when a result disagrees, never a refusal.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
/** The assignment tools, by the operation `toolroll assignment` names them. */
|
|
13
|
+
export declare const ASSIGNMENT_INPUTS: {
|
|
14
|
+
readonly show: z.ZodObject<{
|
|
15
|
+
ref: z.ZodString;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
readonly updates: z.ZodObject<{
|
|
18
|
+
after: z.ZodOptional<z.ZodInt>;
|
|
19
|
+
limit: z.ZodOptional<z.ZodInt>;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
readonly claim: z.ZodObject<{
|
|
22
|
+
ref: z.ZodString;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
readonly check: z.ZodObject<{
|
|
25
|
+
ref: z.ZodString;
|
|
26
|
+
digest: z.ZodString;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
readonly brief: z.ZodObject<{
|
|
29
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
30
|
+
limit: z.ZodOptional<z.ZodInt>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
readonly inbox: z.ZodObject<{
|
|
33
|
+
consumer: z.ZodString;
|
|
34
|
+
limit: z.ZodOptional<z.ZodInt>;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
readonly ack: z.ZodObject<{
|
|
37
|
+
consumer: z.ZodString;
|
|
38
|
+
batchId: z.ZodString;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
};
|
|
41
|
+
export type AssignmentOperation = keyof typeof ASSIGNMENT_INPUTS;
|
|
42
|
+
export type AssignmentInput<O extends AssignmentOperation> = z.infer<(typeof ASSIGNMENT_INPUTS)[O]>;
|
|
43
|
+
export declare const GATEWAY_TOOL_INPUTS: {
|
|
44
|
+
readonly get_project_context: z.ZodObject<{
|
|
45
|
+
repo: z.ZodString;
|
|
46
|
+
query: z.ZodString;
|
|
47
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
impact: "impact";
|
|
49
|
+
search: "search";
|
|
50
|
+
}>>;
|
|
51
|
+
}, z.core.$strict>;
|
|
52
|
+
readonly get_assignment: z.ZodObject<{
|
|
53
|
+
ref: z.ZodString;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
readonly list_assignment_updates: z.ZodObject<{
|
|
56
|
+
after: z.ZodOptional<z.ZodInt>;
|
|
57
|
+
limit: z.ZodOptional<z.ZodInt>;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
readonly claim_assignment: z.ZodObject<{
|
|
60
|
+
ref: z.ZodString;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
readonly acknowledge_assignment: z.ZodObject<{
|
|
63
|
+
ref: z.ZodString;
|
|
64
|
+
digest: z.ZodString;
|
|
65
|
+
}, z.core.$strict>;
|
|
66
|
+
readonly get_assignment_brief: z.ZodObject<{
|
|
67
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
68
|
+
limit: z.ZodOptional<z.ZodInt>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
readonly get_assignment_inbox: z.ZodObject<{
|
|
71
|
+
consumer: z.ZodString;
|
|
72
|
+
limit: z.ZodOptional<z.ZodInt>;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
readonly acknowledge_assignment_delivery: z.ZodObject<{
|
|
75
|
+
consumer: z.ZodString;
|
|
76
|
+
batchId: z.ZodString;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
readonly status: z.ZodObject<{}, z.core.$strict>;
|
|
79
|
+
readonly list_tasks: z.ZodObject<{
|
|
80
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
81
|
+
cancelled: "cancelled";
|
|
82
|
+
done: "done";
|
|
83
|
+
failed: "failed";
|
|
84
|
+
queued: "queued";
|
|
85
|
+
running: "running";
|
|
86
|
+
}>>;
|
|
87
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
88
|
+
cursor: z.ZodOptional<z.ZodInt>;
|
|
89
|
+
limit: z.ZodOptional<z.ZodInt>;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
readonly get_task: z.ZodObject<{
|
|
92
|
+
ref: z.ZodString;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
readonly list_repos: z.ZodObject<{}, z.core.$strict>;
|
|
95
|
+
readonly recap: z.ZodObject<{
|
|
96
|
+
since: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, z.core.$strict>;
|
|
98
|
+
readonly list_decisions: z.ZodObject<{}, z.core.$strict>;
|
|
99
|
+
readonly queue: z.ZodObject<{
|
|
100
|
+
repo: z.ZodString;
|
|
101
|
+
}, z.core.$strict>;
|
|
102
|
+
readonly get_decision: z.ZodObject<{
|
|
103
|
+
decision: z.ZodInt;
|
|
104
|
+
}, z.core.$strict>;
|
|
105
|
+
readonly propose_next: z.ZodObject<{
|
|
106
|
+
ref: z.ZodString;
|
|
107
|
+
}, z.core.$strict>;
|
|
108
|
+
readonly propose_reserve: z.ZodObject<{
|
|
109
|
+
ref: z.ZodString;
|
|
110
|
+
worker: z.ZodNullable<z.ZodString>;
|
|
111
|
+
}, z.core.$strict>;
|
|
112
|
+
readonly propose_hold: z.ZodObject<{
|
|
113
|
+
ref: z.ZodString;
|
|
114
|
+
reason: z.ZodString;
|
|
115
|
+
}, z.core.$strict>;
|
|
116
|
+
readonly propose_unhold: z.ZodObject<{
|
|
117
|
+
ref: z.ZodString;
|
|
118
|
+
}, z.core.$strict>;
|
|
119
|
+
readonly propose_scope: z.ZodObject<{
|
|
120
|
+
ref: z.ZodString;
|
|
121
|
+
goal: z.ZodString;
|
|
122
|
+
not: z.ZodOptional<z.ZodString>;
|
|
123
|
+
touches: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
124
|
+
}, z.core.$strict>;
|
|
125
|
+
readonly propose_cancel: z.ZodObject<{
|
|
126
|
+
ref: z.ZodString;
|
|
127
|
+
reason: z.ZodString;
|
|
128
|
+
}, z.core.$strict>;
|
|
129
|
+
readonly propose_answer: z.ZodObject<{
|
|
130
|
+
decision: z.ZodInt;
|
|
131
|
+
option: z.ZodString;
|
|
132
|
+
rationale: z.ZodString;
|
|
133
|
+
}, z.core.$strict>;
|
|
134
|
+
readonly get_contract: z.ZodObject<{}, z.core.$strict>;
|
|
135
|
+
readonly file_proposal: z.ZodObject<{
|
|
136
|
+
repo: z.ZodString;
|
|
137
|
+
title: z.ZodString;
|
|
138
|
+
intent: z.ZodOptional<z.ZodString>;
|
|
139
|
+
idempotency_key: z.ZodString;
|
|
140
|
+
deliverable: z.ZodOptional<z.ZodEnum<{
|
|
141
|
+
branch: "branch";
|
|
142
|
+
report: "report";
|
|
143
|
+
}>>;
|
|
144
|
+
}, z.core.$strict>;
|
|
145
|
+
};
|
|
146
|
+
export type GatewayToolName = keyof typeof GATEWAY_TOOL_INPUTS;
|
|
147
|
+
export type GatewayToolInput<N extends GatewayToolName> = z.infer<(typeof GATEWAY_TOOL_INPUTS)[N]>;
|
|
148
|
+
export declare const GATEWAY_TOOL_OUTPUTS: {
|
|
149
|
+
readonly get_project_context: z.ZodObject<{
|
|
150
|
+
version: z.ZodLiteral<1>;
|
|
151
|
+
readOnly: z.ZodBoolean;
|
|
152
|
+
query: z.ZodString;
|
|
153
|
+
mode: z.ZodEnum<{
|
|
154
|
+
impact: "impact";
|
|
155
|
+
search: "search";
|
|
156
|
+
}>;
|
|
157
|
+
asOf: z.ZodString;
|
|
158
|
+
excerpts: z.ZodArray<z.ZodUnknown>;
|
|
159
|
+
}, z.core.$loose>;
|
|
160
|
+
readonly get_assignment: z.ZodObject<{
|
|
161
|
+
version: z.ZodLiteral<1>;
|
|
162
|
+
rootId: z.ZodString;
|
|
163
|
+
activeTaskId: z.ZodString;
|
|
164
|
+
title: z.ZodString;
|
|
165
|
+
state: z.ZodString;
|
|
166
|
+
detail: z.ZodString;
|
|
167
|
+
attention: z.ZodArray<z.ZodString>;
|
|
168
|
+
}, z.core.$loose>;
|
|
169
|
+
readonly list_assignment_updates: z.ZodObject<{
|
|
170
|
+
events: z.ZodArray<z.ZodUnknown>;
|
|
171
|
+
nextCursor: z.ZodNumber;
|
|
172
|
+
hasMore: z.ZodBoolean;
|
|
173
|
+
}, z.core.$loose>;
|
|
174
|
+
readonly claim_assignment: z.ZodObject<{
|
|
175
|
+
version: z.ZodLiteral<1>;
|
|
176
|
+
rootId: z.ZodString;
|
|
177
|
+
activeTaskId: z.ZodString;
|
|
178
|
+
title: z.ZodString;
|
|
179
|
+
state: z.ZodString;
|
|
180
|
+
detail: z.ZodString;
|
|
181
|
+
attention: z.ZodArray<z.ZodString>;
|
|
182
|
+
}, z.core.$loose>;
|
|
183
|
+
readonly acknowledge_assignment: z.ZodObject<{
|
|
184
|
+
version: z.ZodLiteral<1>;
|
|
185
|
+
rootId: z.ZodString;
|
|
186
|
+
activeTaskId: z.ZodString;
|
|
187
|
+
title: z.ZodString;
|
|
188
|
+
state: z.ZodString;
|
|
189
|
+
detail: z.ZodString;
|
|
190
|
+
attention: z.ZodArray<z.ZodString>;
|
|
191
|
+
}, z.core.$loose>;
|
|
192
|
+
readonly get_assignment_brief: z.ZodObject<{
|
|
193
|
+
version: z.ZodLiteral<1>;
|
|
194
|
+
asOf: z.ZodString;
|
|
195
|
+
readOnly: z.ZodLiteral<true>;
|
|
196
|
+
assignments: z.ZodArray<z.ZodUnknown>;
|
|
197
|
+
projects: z.ZodArray<z.ZodUnknown>;
|
|
198
|
+
omissions: z.ZodObject<{}, z.core.$loose>;
|
|
199
|
+
}, z.core.$loose>;
|
|
200
|
+
readonly get_assignment_inbox: z.ZodObject<{
|
|
201
|
+
batch: z.ZodObject<{
|
|
202
|
+
id: z.ZodNullable<z.ZodString>;
|
|
203
|
+
consumer: z.ZodString;
|
|
204
|
+
events: z.ZodArray<z.ZodUnknown>;
|
|
205
|
+
hasMore: z.ZodBoolean;
|
|
206
|
+
}, z.core.$loose>;
|
|
207
|
+
}, z.core.$loose>;
|
|
208
|
+
readonly acknowledge_assignment_delivery: z.ZodObject<{
|
|
209
|
+
alreadyAcknowledged: z.ZodBoolean;
|
|
210
|
+
}, z.core.$loose>;
|
|
211
|
+
readonly status: z.ZodObject<{
|
|
212
|
+
waitsOnYou: z.ZodNumber;
|
|
213
|
+
waits: z.ZodObject<{
|
|
214
|
+
approvals: z.ZodNumber;
|
|
215
|
+
questions: z.ZodNumber;
|
|
216
|
+
incidents: z.ZodNumber;
|
|
217
|
+
picks: z.ZodNumber;
|
|
218
|
+
}, z.core.$loose>;
|
|
219
|
+
}, z.core.$loose>;
|
|
220
|
+
readonly list_tasks: z.ZodObject<{
|
|
221
|
+
tasks: z.ZodArray<z.ZodUnknown>;
|
|
222
|
+
}, z.core.$loose>;
|
|
223
|
+
readonly get_task: z.ZodObject<{
|
|
224
|
+
ref: z.ZodString;
|
|
225
|
+
}, z.core.$loose>;
|
|
226
|
+
readonly list_repos: z.ZodObject<{
|
|
227
|
+
repos: z.ZodArray<z.ZodObject<{
|
|
228
|
+
repo: z.ZodString;
|
|
229
|
+
mode: z.ZodString;
|
|
230
|
+
}, z.core.$loose>>;
|
|
231
|
+
}, z.core.$loose>;
|
|
232
|
+
readonly recap: z.ZodObject<{
|
|
233
|
+
since: z.ZodNullable<z.ZodString>;
|
|
234
|
+
repos: z.ZodArray<z.ZodUnknown>;
|
|
235
|
+
waitsOnYou: z.ZodObject<{
|
|
236
|
+
decisions: z.ZodArray<z.ZodUnknown>;
|
|
237
|
+
incidents: z.ZodNumber;
|
|
238
|
+
scopesAwaitingApproval: z.ZodArray<z.ZodUnknown>;
|
|
239
|
+
}, z.core.$loose>;
|
|
240
|
+
running: z.ZodArray<z.ZodUnknown>;
|
|
241
|
+
truncated: z.ZodBoolean;
|
|
242
|
+
}, z.core.$loose>;
|
|
243
|
+
readonly list_decisions: z.ZodObject<{
|
|
244
|
+
decisions: z.ZodArray<z.ZodObject<{
|
|
245
|
+
decision: z.ZodNumber;
|
|
246
|
+
task: z.ZodString;
|
|
247
|
+
question: z.ZodString;
|
|
248
|
+
options: z.ZodArray<z.ZodUnknown>;
|
|
249
|
+
ageHours: z.ZodNumber;
|
|
250
|
+
}, z.core.$loose>>;
|
|
251
|
+
truncated: z.ZodBoolean;
|
|
252
|
+
}, z.core.$loose>;
|
|
253
|
+
readonly queue: z.ZodObject<{
|
|
254
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
255
|
+
column: z.ZodString;
|
|
256
|
+
tasks: z.ZodArray<z.ZodUnknown>;
|
|
257
|
+
}, z.core.$loose>>;
|
|
258
|
+
repo: z.ZodString;
|
|
259
|
+
}, z.core.$loose>;
|
|
260
|
+
readonly get_decision: z.ZodObject<{
|
|
261
|
+
repo: z.ZodString;
|
|
262
|
+
decision: z.ZodNumber;
|
|
263
|
+
task: z.ZodString;
|
|
264
|
+
state: z.ZodString;
|
|
265
|
+
question: z.ZodString;
|
|
266
|
+
options: z.ZodArray<z.ZodObject<{
|
|
267
|
+
id: z.ZodString;
|
|
268
|
+
label: z.ZodString;
|
|
269
|
+
reversible: z.ZodBoolean;
|
|
270
|
+
consequence: z.ZodString;
|
|
271
|
+
}, z.core.$loose>>;
|
|
272
|
+
ageHours: z.ZodNumber;
|
|
273
|
+
}, z.core.$loose>;
|
|
274
|
+
readonly propose_next: z.ZodObject<{
|
|
275
|
+
proposal: z.ZodNumber;
|
|
276
|
+
kind: z.ZodEnum<{
|
|
277
|
+
answer: "answer";
|
|
278
|
+
cancel: "cancel";
|
|
279
|
+
hold: "hold";
|
|
280
|
+
next: "next";
|
|
281
|
+
reserve: "reserve";
|
|
282
|
+
scope: "scope";
|
|
283
|
+
unhold: "unhold";
|
|
284
|
+
}>;
|
|
285
|
+
awaiting: z.ZodString;
|
|
286
|
+
}, z.core.$loose>;
|
|
287
|
+
readonly propose_reserve: z.ZodObject<{
|
|
288
|
+
proposal: z.ZodNumber;
|
|
289
|
+
kind: z.ZodEnum<{
|
|
290
|
+
answer: "answer";
|
|
291
|
+
cancel: "cancel";
|
|
292
|
+
hold: "hold";
|
|
293
|
+
next: "next";
|
|
294
|
+
reserve: "reserve";
|
|
295
|
+
scope: "scope";
|
|
296
|
+
unhold: "unhold";
|
|
297
|
+
}>;
|
|
298
|
+
awaiting: z.ZodString;
|
|
299
|
+
}, z.core.$loose>;
|
|
300
|
+
readonly propose_hold: z.ZodObject<{
|
|
301
|
+
proposal: z.ZodNumber;
|
|
302
|
+
kind: z.ZodEnum<{
|
|
303
|
+
answer: "answer";
|
|
304
|
+
cancel: "cancel";
|
|
305
|
+
hold: "hold";
|
|
306
|
+
next: "next";
|
|
307
|
+
reserve: "reserve";
|
|
308
|
+
scope: "scope";
|
|
309
|
+
unhold: "unhold";
|
|
310
|
+
}>;
|
|
311
|
+
awaiting: z.ZodString;
|
|
312
|
+
}, z.core.$loose>;
|
|
313
|
+
readonly propose_unhold: z.ZodObject<{
|
|
314
|
+
proposal: z.ZodNumber;
|
|
315
|
+
kind: z.ZodEnum<{
|
|
316
|
+
answer: "answer";
|
|
317
|
+
cancel: "cancel";
|
|
318
|
+
hold: "hold";
|
|
319
|
+
next: "next";
|
|
320
|
+
reserve: "reserve";
|
|
321
|
+
scope: "scope";
|
|
322
|
+
unhold: "unhold";
|
|
323
|
+
}>;
|
|
324
|
+
awaiting: z.ZodString;
|
|
325
|
+
}, z.core.$loose>;
|
|
326
|
+
readonly propose_scope: z.ZodObject<{
|
|
327
|
+
proposal: z.ZodNumber;
|
|
328
|
+
kind: z.ZodEnum<{
|
|
329
|
+
answer: "answer";
|
|
330
|
+
cancel: "cancel";
|
|
331
|
+
hold: "hold";
|
|
332
|
+
next: "next";
|
|
333
|
+
reserve: "reserve";
|
|
334
|
+
scope: "scope";
|
|
335
|
+
unhold: "unhold";
|
|
336
|
+
}>;
|
|
337
|
+
awaiting: z.ZodString;
|
|
338
|
+
}, z.core.$loose>;
|
|
339
|
+
readonly propose_cancel: z.ZodObject<{
|
|
340
|
+
proposal: z.ZodNumber;
|
|
341
|
+
kind: z.ZodEnum<{
|
|
342
|
+
answer: "answer";
|
|
343
|
+
cancel: "cancel";
|
|
344
|
+
hold: "hold";
|
|
345
|
+
next: "next";
|
|
346
|
+
reserve: "reserve";
|
|
347
|
+
scope: "scope";
|
|
348
|
+
unhold: "unhold";
|
|
349
|
+
}>;
|
|
350
|
+
awaiting: z.ZodString;
|
|
351
|
+
}, z.core.$loose>;
|
|
352
|
+
readonly propose_answer: z.ZodObject<{
|
|
353
|
+
proposal: z.ZodNumber;
|
|
354
|
+
kind: z.ZodEnum<{
|
|
355
|
+
answer: "answer";
|
|
356
|
+
cancel: "cancel";
|
|
357
|
+
hold: "hold";
|
|
358
|
+
next: "next";
|
|
359
|
+
reserve: "reserve";
|
|
360
|
+
scope: "scope";
|
|
361
|
+
unhold: "unhold";
|
|
362
|
+
}>;
|
|
363
|
+
awaiting: z.ZodString;
|
|
364
|
+
}, z.core.$loose>;
|
|
365
|
+
readonly get_contract: z.ZodObject<{
|
|
366
|
+
contract: z.ZodString;
|
|
367
|
+
}, z.core.$loose>;
|
|
368
|
+
readonly file_proposal: z.ZodObject<{
|
|
369
|
+
ref: z.ZodString;
|
|
370
|
+
replayed: z.ZodBoolean;
|
|
371
|
+
admission: z.ZodString;
|
|
372
|
+
}, z.core.$loose>;
|
|
373
|
+
};
|
|
374
|
+
export type GatewayToolOutput<N extends GatewayToolName> = z.infer<(typeof GATEWAY_TOOL_OUTPUTS)[N]>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP gateway's tools (docs/plans/zod-revamp.md, item 5; docs/mcp-gateway-spec.md): one input schema per tool and
|
|
3
|
+
* one output schema for what each returns. The input schema is the `inputSchema` tools/list advertises and the check
|
|
4
|
+
* a call is read with before its handler runs (mcp.ts): a call it refuses is a JSON-RPC InvalidParams error naming each
|
|
5
|
+
* path, never a tool refusal. The assignment tools' schemas are also what `toolroll assignment` reads its flags with
|
|
6
|
+
* (assignment-adapters.ts), so the CLI and the gateway take exactly the same arguments.
|
|
7
|
+
*
|
|
8
|
+
* A coordinator names a project by its path and a task by `ref`; the lead's tools (lead-tools.ts) say r1 and `task`.
|
|
9
|
+
* Output schemas describe a result's top level: checked in tests, logged when a result disagrees, never a refusal.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { TEXT_LIMITS } from "../text-limits.js";
|
|
13
|
+
import { catchUpOutput, decisionOutput, decisionsOutput, LISTED_TASK_STATES, queueColumnsOutput, recapOutput, repositoryContextOutput, scopeText, touches } from "./lead-tools.js";
|
|
14
|
+
const text = (key) => z.string().max(TEXT_LIMITS[key]);
|
|
15
|
+
const ref = z.string().min(1).max(TEXT_LIMITS.taskRef);
|
|
16
|
+
const projectPath = text("projectPath").min(1);
|
|
17
|
+
const gatewayRepo = text("gatewayRepo").min(1);
|
|
18
|
+
const consumer = z.string().min(1).max(64).regex(/^[a-z0-9][a-z0-9-]{0,63}$/, { error: "must be a stable consumer name: lowercase letters, digits and hyphens" });
|
|
19
|
+
const limit = (most) => z.int().min(1).max(most);
|
|
20
|
+
/** The assignment tools, by the operation `toolroll assignment` names them. */
|
|
21
|
+
export const ASSIGNMENT_INPUTS = {
|
|
22
|
+
show: z.strictObject({ ref }),
|
|
23
|
+
updates: z.strictObject({ after: z.int().min(0).optional(), limit: limit(100).optional() }),
|
|
24
|
+
claim: z.strictObject({ ref }),
|
|
25
|
+
check: z.strictObject({ ref, digest: z.string().min(64).max(64).regex(/^[a-f0-9]{64}$/, { error: "must be the exact 64-character receipt digest from assignment show" }) }),
|
|
26
|
+
brief: z.strictObject({ repo: projectPath.optional(), limit: limit(25).optional() }),
|
|
27
|
+
inbox: z.strictObject({ consumer, limit: limit(100).optional() }),
|
|
28
|
+
ack: z.strictObject({ consumer, batchId: z.string().min(32).max(32).regex(/^[a-f0-9]{32}$/, { error: "must be the exact batchId from assignment inbox" }) }),
|
|
29
|
+
};
|
|
30
|
+
export const GATEWAY_TOOL_INPUTS = {
|
|
31
|
+
get_project_context: z.strictObject({ repo: projectPath, query: text("contextQuery").min(1), mode: z.enum(["search", "impact"]).optional() }),
|
|
32
|
+
get_assignment: ASSIGNMENT_INPUTS.show,
|
|
33
|
+
list_assignment_updates: ASSIGNMENT_INPUTS.updates,
|
|
34
|
+
claim_assignment: ASSIGNMENT_INPUTS.claim,
|
|
35
|
+
acknowledge_assignment: ASSIGNMENT_INPUTS.check,
|
|
36
|
+
get_assignment_brief: ASSIGNMENT_INPUTS.brief,
|
|
37
|
+
get_assignment_inbox: ASSIGNMENT_INPUTS.inbox,
|
|
38
|
+
acknowledge_assignment_delivery: ASSIGNMENT_INPUTS.ack,
|
|
39
|
+
status: z.strictObject({}),
|
|
40
|
+
list_tasks: z.strictObject({ state: z.enum(LISTED_TASK_STATES).optional(), repo: text("gatewayRepo").optional(), cursor: z.int().min(0).optional(), limit: limit(50).optional() }),
|
|
41
|
+
get_task: z.strictObject({ ref }),
|
|
42
|
+
list_repos: z.strictObject({}),
|
|
43
|
+
recap: z.strictObject({ since: text("recapSince").optional() }),
|
|
44
|
+
list_decisions: z.strictObject({}),
|
|
45
|
+
queue: z.strictObject({ repo: gatewayRepo }),
|
|
46
|
+
get_decision: z.strictObject({ decision: z.int().min(1) }),
|
|
47
|
+
propose_next: z.strictObject({ ref }),
|
|
48
|
+
propose_reserve: z.strictObject({ ref, worker: text("workerName").nullable() }),
|
|
49
|
+
propose_hold: z.strictObject({ ref, reason: text("proposalReason") }),
|
|
50
|
+
propose_unhold: z.strictObject({ ref }),
|
|
51
|
+
propose_scope: z.strictObject({ ref, goal: scopeText, not: scopeText.optional(), touches: touches.optional() }),
|
|
52
|
+
propose_cancel: z.strictObject({ ref, reason: text("proposalReason") }),
|
|
53
|
+
propose_answer: z.strictObject({ decision: z.int().min(1), option: text("answerOption").min(1), rationale: text("answerRationale") }),
|
|
54
|
+
get_contract: z.strictObject({}),
|
|
55
|
+
file_proposal: z.strictObject({
|
|
56
|
+
repo: gatewayRepo, title: text("taskTitle").min(1), intent: scopeText.optional(), idempotency_key: text("idempotencyKey").min(8),
|
|
57
|
+
deliverable: z.enum(["branch", "report"]).optional(),
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
// ------------------------------------------------------------- outputs
|
|
61
|
+
const str = z.string();
|
|
62
|
+
const int = z.number().int();
|
|
63
|
+
const list = z.array(z.unknown());
|
|
64
|
+
const rows = (shape) => z.array(z.looseObject(shape));
|
|
65
|
+
const proposed = z.looseObject({ proposal: int, kind: z.enum(["next", "reserve", "hold", "unhold", "scope", "cancel", "answer"]), awaiting: str });
|
|
66
|
+
/** One assignment (assignment.ts `AssignmentSnapshot`). */
|
|
67
|
+
const assignmentOutput = z.looseObject({ version: z.literal(1), rootId: str, activeTaskId: str, title: str, state: str, detail: str, attention: z.array(str) });
|
|
68
|
+
export const GATEWAY_TOOL_OUTPUTS = {
|
|
69
|
+
get_project_context: repositoryContextOutput,
|
|
70
|
+
get_assignment: assignmentOutput,
|
|
71
|
+
list_assignment_updates: z.looseObject({ events: list, nextCursor: int, hasMore: z.boolean() }),
|
|
72
|
+
claim_assignment: assignmentOutput,
|
|
73
|
+
acknowledge_assignment: assignmentOutput,
|
|
74
|
+
get_assignment_brief: catchUpOutput,
|
|
75
|
+
get_assignment_inbox: z.looseObject({ batch: z.looseObject({ id: str.nullable(), consumer: str, events: list, hasMore: z.boolean() }) }),
|
|
76
|
+
acknowledge_assignment_delivery: z.looseObject({ alreadyAcknowledged: z.boolean() }),
|
|
77
|
+
status: z.looseObject({ waitsOnYou: int, waits: z.looseObject({ approvals: int, questions: int, incidents: int, picks: int }) }),
|
|
78
|
+
list_tasks: z.looseObject({ tasks: list }),
|
|
79
|
+
get_task: z.looseObject({ ref: str }),
|
|
80
|
+
list_repos: z.looseObject({ repos: rows({ repo: str, mode: str }) }),
|
|
81
|
+
recap: recapOutput,
|
|
82
|
+
list_decisions: decisionsOutput,
|
|
83
|
+
queue: z.looseObject({ repo: str, ...queueColumnsOutput }),
|
|
84
|
+
get_decision: decisionOutput,
|
|
85
|
+
propose_next: proposed,
|
|
86
|
+
propose_reserve: proposed,
|
|
87
|
+
propose_hold: proposed,
|
|
88
|
+
propose_unhold: proposed,
|
|
89
|
+
propose_scope: proposed,
|
|
90
|
+
propose_cancel: proposed,
|
|
91
|
+
propose_answer: proposed,
|
|
92
|
+
get_contract: z.looseObject({ contract: str }),
|
|
93
|
+
file_proposal: z.looseObject({ ref: str, replayed: z.boolean(), admission: str }),
|
|
94
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The handoff artifact (`handoff.json`, M6.10): one schema for the machine's own statement of where a finished run
|
|
3
|
+
* left the world — workspace identity, exact base and head, which answered decisions the brief carried, the agent's
|
|
4
|
+
* conclusion and lists, and a freshness stamp a successor proves against the branch. `storeHandoffArtifact` writes it
|
|
5
|
+
* and every reader reads it through `readHandoffArtifact`.
|
|
6
|
+
*
|
|
7
|
+
* The agent's own terminal handoff (`STANDING-ORDERS-DONE-*`, `parseHandoff` in decision.ts) is a different contract;
|
|
8
|
+
* this file records what the machine made of it.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { type ContractResult } from "./contract.js";
|
|
12
|
+
export declare const ROUTE_PHASES: readonly ["plan", "build", "repair", "review"];
|
|
13
|
+
export declare const ROUTE_CHOICES: readonly ["recommended", "override", "pinned", "legacy", "fallback"];
|
|
14
|
+
/** The sealed route leg the run ran as (v47); absent on handoffs written before routes existed. */
|
|
15
|
+
export declare const handoffRouteSchema: z.ZodObject<{
|
|
16
|
+
digest: z.ZodString;
|
|
17
|
+
phase: z.ZodEnum<{
|
|
18
|
+
build: "build";
|
|
19
|
+
plan: "plan";
|
|
20
|
+
repair: "repair";
|
|
21
|
+
review: "review";
|
|
22
|
+
}>;
|
|
23
|
+
provider: z.ZodString;
|
|
24
|
+
model: z.ZodNullable<z.ZodString>;
|
|
25
|
+
chosen: z.ZodEnum<{
|
|
26
|
+
fallback: "fallback";
|
|
27
|
+
legacy: "legacy";
|
|
28
|
+
override: "override";
|
|
29
|
+
pinned: "pinned";
|
|
30
|
+
recommended: "recommended";
|
|
31
|
+
}>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
export declare const HANDOFF_VERSION = 1;
|
|
34
|
+
export declare const handoffSchema: z.ZodObject<{
|
|
35
|
+
version: z.ZodLiteral<1>;
|
|
36
|
+
taskId: z.ZodString;
|
|
37
|
+
runId: z.ZodInt;
|
|
38
|
+
provider: z.ZodString;
|
|
39
|
+
model: z.ZodOptional<z.ZodString>;
|
|
40
|
+
route: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
digest: z.ZodString;
|
|
42
|
+
phase: z.ZodEnum<{
|
|
43
|
+
build: "build";
|
|
44
|
+
plan: "plan";
|
|
45
|
+
repair: "repair";
|
|
46
|
+
review: "review";
|
|
47
|
+
}>;
|
|
48
|
+
provider: z.ZodString;
|
|
49
|
+
model: z.ZodNullable<z.ZodString>;
|
|
50
|
+
chosen: z.ZodEnum<{
|
|
51
|
+
fallback: "fallback";
|
|
52
|
+
legacy: "legacy";
|
|
53
|
+
override: "override";
|
|
54
|
+
pinned: "pinned";
|
|
55
|
+
recommended: "recommended";
|
|
56
|
+
}>;
|
|
57
|
+
}, z.core.$strict>>;
|
|
58
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
59
|
+
branch: z.ZodString;
|
|
60
|
+
worktree: z.ZodString;
|
|
61
|
+
base: z.ZodString;
|
|
62
|
+
head: z.ZodString;
|
|
63
|
+
outcome: z.ZodEnum<{
|
|
64
|
+
built: "built";
|
|
65
|
+
"no-change": "no-change";
|
|
66
|
+
}>;
|
|
67
|
+
committed: z.ZodBoolean;
|
|
68
|
+
decisionsIncorporated: z.ZodArray<z.ZodInt>;
|
|
69
|
+
conclusion: z.ZodString;
|
|
70
|
+
changes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
|
+
verification: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
72
|
+
followUps: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
|
+
freshness: z.ZodObject<{
|
|
74
|
+
stampedAt: z.ZodString;
|
|
75
|
+
currentAsOf: z.ZodString;
|
|
76
|
+
}, z.core.$strict>;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
export type HandoffArtifact = z.infer<typeof handoffSchema>;
|
|
79
|
+
/**
|
|
80
|
+
* A handoff written before handoffs carried `version` (every handoff through 0.9.34, stamped `schema: 1`), as
|
|
81
|
+
* version 1. The shape is the same; readers then read only the fields they knew and ignored any others, so this keeps
|
|
82
|
+
* exactly the known fields. Anything not stamped `schema: 1` is left as it is, for the schema to refuse by path.
|
|
83
|
+
*/
|
|
84
|
+
export declare function upgradeSchemaOneHandoff(body: Record<string, unknown>): Record<string, unknown>;
|
|
85
|
+
export declare const HANDOFF_UPGRADES: {
|
|
86
|
+
readonly 0: typeof upgradeSchemaOneHandoff;
|
|
87
|
+
};
|
|
88
|
+
/** Read a handoff artifact: version 1 as itself, a `schema: 1` one upgraded, a newer one refused plainly. */
|
|
89
|
+
export declare function readHandoffArtifact(input: unknown): ContractResult<HandoffArtifact>;
|
|
90
|
+
/** Read a stored handoff's bytes: JSON first, then the schema. */
|
|
91
|
+
export declare function parseHandoffArtifact(raw: string): ContractResult<HandoffArtifact>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The handoff artifact (`handoff.json`, M6.10): one schema for the machine's own statement of where a finished run
|
|
3
|
+
* left the world — workspace identity, exact base and head, which answered decisions the brief carried, the agent's
|
|
4
|
+
* conclusion and lists, and a freshness stamp a successor proves against the branch. `storeHandoffArtifact` writes it
|
|
5
|
+
* and every reader reads it through `readHandoffArtifact`.
|
|
6
|
+
*
|
|
7
|
+
* The agent's own terminal handoff (`STANDING-ORDERS-DONE-*`, `parseHandoff` in decision.ts) is a different contract;
|
|
8
|
+
* this file records what the machine made of it.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { readVersioned, versioned } from "./contract.js";
|
|
12
|
+
export const ROUTE_PHASES = ["plan", "build", "repair", "review"];
|
|
13
|
+
export const ROUTE_CHOICES = ["recommended", "override", "pinned", "legacy", "fallback"];
|
|
14
|
+
/** The sealed route leg the run ran as (v47); absent on handoffs written before routes existed. */
|
|
15
|
+
export const handoffRouteSchema = z.strictObject({
|
|
16
|
+
digest: z.string(),
|
|
17
|
+
phase: z.enum(ROUTE_PHASES),
|
|
18
|
+
provider: z.string(),
|
|
19
|
+
model: z.string().nullable(),
|
|
20
|
+
chosen: z.enum(ROUTE_CHOICES),
|
|
21
|
+
});
|
|
22
|
+
export const HANDOFF_VERSION = 1;
|
|
23
|
+
export const handoffSchema = versioned(HANDOFF_VERSION, {
|
|
24
|
+
taskId: z.string(),
|
|
25
|
+
runId: z.int(),
|
|
26
|
+
provider: z.string(),
|
|
27
|
+
/** v47: the exact model that ran. Absent on handoffs written before routes existed. */
|
|
28
|
+
model: z.string().optional(),
|
|
29
|
+
route: handoffRouteSchema.optional(),
|
|
30
|
+
sessionId: z.string().nullable(),
|
|
31
|
+
branch: z.string(),
|
|
32
|
+
worktree: z.string(),
|
|
33
|
+
base: z.string(),
|
|
34
|
+
head: z.string(),
|
|
35
|
+
outcome: z.enum(["built", "no-change"]),
|
|
36
|
+
committed: z.boolean(),
|
|
37
|
+
/** Decision ids whose answers were in this run's brief — causality, not time. */
|
|
38
|
+
decisionsIncorporated: z.array(z.int()),
|
|
39
|
+
/** The agent's conclusion — agent-reported, and labeled so by its position here. */
|
|
40
|
+
conclusion: z.string(),
|
|
41
|
+
/** The agent's structured lists; absent on handoffs written before they existed, read as none. */
|
|
42
|
+
changes: z.array(z.string()).optional(),
|
|
43
|
+
verification: z.array(z.string()).optional(),
|
|
44
|
+
followUps: z.array(z.string()).optional(),
|
|
45
|
+
freshness: z.strictObject({
|
|
46
|
+
stampedAt: z.string(),
|
|
47
|
+
/** A successor proves this against the branch before trusting anything above. */
|
|
48
|
+
currentAsOf: z.string(),
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
const HANDOFF_FIELDS = Object.keys(handoffSchema.shape).filter(field => field !== "version");
|
|
52
|
+
/**
|
|
53
|
+
* A handoff written before handoffs carried `version` (every handoff through 0.9.34, stamped `schema: 1`), as
|
|
54
|
+
* version 1. The shape is the same; readers then read only the fields they knew and ignored any others, so this keeps
|
|
55
|
+
* exactly the known fields. Anything not stamped `schema: 1` is left as it is, for the schema to refuse by path.
|
|
56
|
+
*/
|
|
57
|
+
export function upgradeSchemaOneHandoff(body) {
|
|
58
|
+
if (body["schema"] !== 1)
|
|
59
|
+
return body;
|
|
60
|
+
const out = { version: HANDOFF_VERSION };
|
|
61
|
+
for (const field of HANDOFF_FIELDS) {
|
|
62
|
+
if (Object.prototype.hasOwnProperty.call(body, field) && body[field] !== undefined)
|
|
63
|
+
out[field] = body[field];
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
export const HANDOFF_UPGRADES = { 0: upgradeSchemaOneHandoff };
|
|
68
|
+
/** Read a handoff artifact: version 1 as itself, a `schema: 1` one upgraded, a newer one refused plainly. */
|
|
69
|
+
export function readHandoffArtifact(input) {
|
|
70
|
+
return readVersioned(handoffSchema, input, HANDOFF_UPGRADES);
|
|
71
|
+
}
|
|
72
|
+
/** Read a stored handoff's bytes: JSON first, then the schema. */
|
|
73
|
+
export function parseHandoffArtifact(raw) {
|
|
74
|
+
let body;
|
|
75
|
+
try {
|
|
76
|
+
body = JSON.parse(raw);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return { ok: false, issues: [{ path: "payload", kind: "invalid", line: "payload: not JSON" }] };
|
|
80
|
+
}
|
|
81
|
+
return readHandoffArtifact(body);
|
|
82
|
+
}
|