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,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lead's `propose_flow` input (docs/plans/zod-revamp.md, item 3): one schema, built from the flow contract's own
|
|
3
|
+
* step and trigger schemas, that is both the JSON Schema the lead is given and the check its call is read with
|
|
4
|
+
* (mate-tools.ts). The lead-tools contract (item 5) imports it from here rather than restating it.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
export declare const PROPOSE_FLOW_OPERATIONS: readonly ["create", "edit", "add_card", "move_card", "approve", "send_back", "choose", "cancel_card", "comment", "assign", "follow", "unfollow", "save_script", "add_trigger", "pause_trigger", "resume_trigger", "remove_trigger", "kit", "starter"];
|
|
8
|
+
export declare const proposeFlowInputSchema: z.ZodObject<{
|
|
9
|
+
operation: z.ZodEnum<{
|
|
10
|
+
add_card: "add_card";
|
|
11
|
+
add_trigger: "add_trigger";
|
|
12
|
+
approve: "approve";
|
|
13
|
+
assign: "assign";
|
|
14
|
+
cancel_card: "cancel_card";
|
|
15
|
+
choose: "choose";
|
|
16
|
+
comment: "comment";
|
|
17
|
+
create: "create";
|
|
18
|
+
edit: "edit";
|
|
19
|
+
follow: "follow";
|
|
20
|
+
kit: "kit";
|
|
21
|
+
move_card: "move_card";
|
|
22
|
+
pause_trigger: "pause_trigger";
|
|
23
|
+
remove_trigger: "remove_trigger";
|
|
24
|
+
resume_trigger: "resume_trigger";
|
|
25
|
+
save_script: "save_script";
|
|
26
|
+
send_back: "send_back";
|
|
27
|
+
starter: "starter";
|
|
28
|
+
unfollow: "unfollow";
|
|
29
|
+
}>;
|
|
30
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
31
|
+
flow: z.ZodOptional<z.ZodInt>;
|
|
32
|
+
card: z.ZodOptional<z.ZodInt>;
|
|
33
|
+
kit: z.ZodOptional<z.ZodEnum<{
|
|
34
|
+
[x: string]: string;
|
|
35
|
+
}>>;
|
|
36
|
+
starter: z.ZodOptional<z.ZodEnum<{
|
|
37
|
+
"ci-fix": "ci-fix";
|
|
38
|
+
"issue-task": "issue-task";
|
|
39
|
+
overnight: "overnight";
|
|
40
|
+
"plane-review": "plane-review";
|
|
41
|
+
}>>;
|
|
42
|
+
name: z.ZodOptional<z.ZodString>;
|
|
43
|
+
template: z.ZodOptional<z.ZodEnum<{
|
|
44
|
+
[x: string]: string;
|
|
45
|
+
}>>;
|
|
46
|
+
steps: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<readonly [z.ZodObject<{
|
|
47
|
+
id: z.ZodOptional<z.ZodString>;
|
|
48
|
+
title: z.ZodString;
|
|
49
|
+
kind: z.ZodLiteral<"inbox">;
|
|
50
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
51
|
+
next: z.ZodOptional<z.ZodString>;
|
|
52
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
53
|
+
thenMoveTo: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
55
|
+
id: z.ZodOptional<z.ZodString>;
|
|
56
|
+
title: z.ZodString;
|
|
57
|
+
kind: z.ZodLiteral<"task">;
|
|
58
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
59
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
60
|
+
next: z.ZodOptional<z.ZodString>;
|
|
61
|
+
planning: z.ZodOptional<z.ZodEnum<{
|
|
62
|
+
auto: "auto";
|
|
63
|
+
required: "required";
|
|
64
|
+
skip: "skip";
|
|
65
|
+
}>>;
|
|
66
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
67
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
69
|
+
id: z.ZodOptional<z.ZodString>;
|
|
70
|
+
title: z.ZodString;
|
|
71
|
+
kind: z.ZodLiteral<"report">;
|
|
72
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
73
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
74
|
+
next: z.ZodOptional<z.ZodString>;
|
|
75
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
76
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
77
|
+
id: z.ZodOptional<z.ZodString>;
|
|
78
|
+
title: z.ZodString;
|
|
79
|
+
kind: z.ZodLiteral<"approval">;
|
|
80
|
+
decider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
81
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
82
|
+
next: z.ZodOptional<z.ZodString>;
|
|
83
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
84
|
+
teammate: z.ZodOptional<z.ZodString>;
|
|
85
|
+
thenMoveTo: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
87
|
+
id: z.ZodOptional<z.ZodString>;
|
|
88
|
+
title: z.ZodString;
|
|
89
|
+
kind: z.ZodLiteral<"check">;
|
|
90
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
91
|
+
next: z.ZodOptional<z.ZodString>;
|
|
92
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
93
|
+
routes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
94
|
+
answer: z.ZodString;
|
|
95
|
+
goesTo: z.ZodString;
|
|
96
|
+
}, z.core.$strict>>>;
|
|
97
|
+
runIn: z.ZodOptional<z.ZodEnum<{
|
|
98
|
+
copy: "copy";
|
|
99
|
+
folder: "folder";
|
|
100
|
+
}>>;
|
|
101
|
+
script: z.ZodOptional<z.ZodString>;
|
|
102
|
+
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
103
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
104
|
+
id: z.ZodOptional<z.ZodString>;
|
|
105
|
+
title: z.ZodString;
|
|
106
|
+
kind: z.ZodLiteral<"pull-request">;
|
|
107
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
108
|
+
merge: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
|
|
109
|
+
merge: "merge";
|
|
110
|
+
rebase: "rebase";
|
|
111
|
+
squash: "squash";
|
|
112
|
+
}>]>>;
|
|
113
|
+
next: z.ZodOptional<z.ZodString>;
|
|
114
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
115
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
116
|
+
id: z.ZodOptional<z.ZodString>;
|
|
117
|
+
title: z.ZodString;
|
|
118
|
+
kind: z.ZodLiteral<"update">;
|
|
119
|
+
close: z.ZodOptional<z.ZodBoolean>;
|
|
120
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
121
|
+
message: z.ZodOptional<z.ZodString>;
|
|
122
|
+
next: z.ZodOptional<z.ZodString>;
|
|
123
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
124
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
125
|
+
id: z.ZodOptional<z.ZodString>;
|
|
126
|
+
title: z.ZodString;
|
|
127
|
+
kind: z.ZodLiteral<"notify">;
|
|
128
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
129
|
+
message: z.ZodOptional<z.ZodString>;
|
|
130
|
+
next: z.ZodOptional<z.ZodString>;
|
|
131
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
132
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
133
|
+
id: z.ZodOptional<z.ZodString>;
|
|
134
|
+
title: z.ZodString;
|
|
135
|
+
kind: z.ZodLiteral<"sort">;
|
|
136
|
+
alsoNote: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
137
|
+
id: z.ZodOptional<z.ZodString>;
|
|
138
|
+
question: z.ZodString;
|
|
139
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
140
|
+
score: "score";
|
|
141
|
+
"yes-no": "yes-no";
|
|
142
|
+
}>>;
|
|
143
|
+
levels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
144
|
+
}, z.core.$strict>>>;
|
|
145
|
+
answers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
146
|
+
answer: z.ZodString;
|
|
147
|
+
means: z.ZodOptional<z.ZodString>;
|
|
148
|
+
goesTo: z.ZodString;
|
|
149
|
+
}, z.core.$strict>>>;
|
|
150
|
+
ifNotSure: z.ZodOptional<z.ZodString>;
|
|
151
|
+
question: z.ZodOptional<z.ZodString>;
|
|
152
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
153
|
+
sureAt: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
155
|
+
id: z.ZodOptional<z.ZodString>;
|
|
156
|
+
title: z.ZodString;
|
|
157
|
+
kind: z.ZodLiteral<"draft">;
|
|
158
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
159
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
160
|
+
next: z.ZodOptional<z.ZodString>;
|
|
161
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
162
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
163
|
+
id: z.ZodOptional<z.ZodString>;
|
|
164
|
+
title: z.ZodString;
|
|
165
|
+
kind: z.ZodLiteral<"request">;
|
|
166
|
+
body: z.ZodOptional<z.ZodString>;
|
|
167
|
+
headers: z.ZodOptional<z.ZodObject<{}, z.core.$catchall<z.ZodString>>>;
|
|
168
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
169
|
+
method: z.ZodOptional<z.ZodEnum<{
|
|
170
|
+
DELETE: "DELETE";
|
|
171
|
+
GET: "GET";
|
|
172
|
+
PATCH: "PATCH";
|
|
173
|
+
POST: "POST";
|
|
174
|
+
PUT: "PUT";
|
|
175
|
+
}>>;
|
|
176
|
+
next: z.ZodOptional<z.ZodString>;
|
|
177
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
178
|
+
url: z.ZodOptional<z.ZodString>;
|
|
179
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
180
|
+
id: z.ZodOptional<z.ZodString>;
|
|
181
|
+
title: z.ZodString;
|
|
182
|
+
kind: z.ZodLiteral<"email">;
|
|
183
|
+
body: z.ZodOptional<z.ZodString>;
|
|
184
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
185
|
+
next: z.ZodOptional<z.ZodString>;
|
|
186
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
187
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
188
|
+
to: z.ZodOptional<z.ZodString>;
|
|
189
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
190
|
+
id: z.ZodOptional<z.ZodString>;
|
|
191
|
+
title: z.ZodString;
|
|
192
|
+
kind: z.ZodLiteral<"tool">;
|
|
193
|
+
args: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{}, z.core.$catchall<z.ZodUnknown>>, z.ZodString]>>;
|
|
194
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
195
|
+
next: z.ZodOptional<z.ZodString>;
|
|
196
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
197
|
+
server: z.ZodOptional<z.ZodString>;
|
|
198
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
199
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
200
|
+
id: z.ZodOptional<z.ZodString>;
|
|
201
|
+
title: z.ZodString;
|
|
202
|
+
kind: z.ZodLiteral<"wait">;
|
|
203
|
+
from: z.ZodOptional<z.ZodString>;
|
|
204
|
+
ifNoReply: z.ZodOptional<z.ZodString>;
|
|
205
|
+
next: z.ZodOptional<z.ZodString>;
|
|
206
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
207
|
+
until: z.ZodOptional<z.ZodString>;
|
|
208
|
+
wait: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
209
|
+
waitFor: z.ZodOptional<z.ZodEnum<{
|
|
210
|
+
hours: "hours";
|
|
211
|
+
reply: "reply";
|
|
212
|
+
time: "time";
|
|
213
|
+
}>>;
|
|
214
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
215
|
+
id: z.ZodOptional<z.ZodString>;
|
|
216
|
+
title: z.ZodString;
|
|
217
|
+
kind: z.ZodLiteral<"teammate">;
|
|
218
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
219
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
220
|
+
next: z.ZodOptional<z.ZodString>;
|
|
221
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
222
|
+
reply: z.ZodOptional<z.ZodBoolean>;
|
|
223
|
+
routes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
224
|
+
answer: z.ZodString;
|
|
225
|
+
goesTo: z.ZodString;
|
|
226
|
+
}, z.core.$strict>>>;
|
|
227
|
+
teammate: z.ZodOptional<z.ZodString>;
|
|
228
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
229
|
+
id: z.ZodOptional<z.ZodString>;
|
|
230
|
+
title: z.ZodString;
|
|
231
|
+
kind: z.ZodLiteral<"send">;
|
|
232
|
+
ifFails: z.ZodOptional<z.ZodString>;
|
|
233
|
+
next: z.ZodOptional<z.ZodString>;
|
|
234
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
235
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
236
|
+
id: z.ZodOptional<z.ZodString>;
|
|
237
|
+
title: z.ZodString;
|
|
238
|
+
kind: z.ZodLiteral<"choose">;
|
|
239
|
+
ifNoReply: z.ZodOptional<z.ZodString>;
|
|
240
|
+
ifReplied: z.ZodOptional<z.ZodString>;
|
|
241
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
242
|
+
label: z.ZodString;
|
|
243
|
+
goesTo: z.ZodOptional<z.ZodString>;
|
|
244
|
+
}, z.core.$strict>>>;
|
|
245
|
+
remindAfter: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
246
|
+
thenMoveTo: z.ZodOptional<z.ZodString>;
|
|
247
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
248
|
+
id: z.ZodOptional<z.ZodString>;
|
|
249
|
+
title: z.ZodString;
|
|
250
|
+
kind: z.ZodLiteral<"done">;
|
|
251
|
+
}, z.core.$strict>], "kind">>>;
|
|
252
|
+
title: z.ZodOptional<z.ZodString>;
|
|
253
|
+
description: z.ZodOptional<z.ZodString>;
|
|
254
|
+
zone: z.ZodOptional<z.ZodString>;
|
|
255
|
+
note: z.ZodOptional<z.ZodString>;
|
|
256
|
+
choice: z.ZodOptional<z.ZodInt>;
|
|
257
|
+
trigger: z.ZodOptional<z.ZodInt>;
|
|
258
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
259
|
+
script: z.ZodOptional<z.ZodObject<{
|
|
260
|
+
name: z.ZodOptional<z.ZodString>;
|
|
261
|
+
about: z.ZodOptional<z.ZodString>;
|
|
262
|
+
body: z.ZodOptional<z.ZodString>;
|
|
263
|
+
timeoutMinutes: z.ZodOptional<z.ZodInt>;
|
|
264
|
+
language: z.ZodOptional<z.ZodEnum<{
|
|
265
|
+
node: "node";
|
|
266
|
+
python: "python";
|
|
267
|
+
shell: "shell";
|
|
268
|
+
}>>;
|
|
269
|
+
file: z.ZodOptional<z.ZodString>;
|
|
270
|
+
}, z.core.$strict>>;
|
|
271
|
+
settings: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
272
|
+
zone: z.ZodOptional<z.ZodString>;
|
|
273
|
+
kind: z.ZodLiteral<"button">;
|
|
274
|
+
label: z.ZodString;
|
|
275
|
+
questions: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>>;
|
|
276
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
277
|
+
zone: z.ZodOptional<z.ZodString>;
|
|
278
|
+
kind: z.ZodLiteral<"schedule">;
|
|
279
|
+
schedule: z.ZodString;
|
|
280
|
+
title: z.ZodOptional<z.ZodString>;
|
|
281
|
+
description: z.ZodOptional<z.ZodString>;
|
|
282
|
+
script: z.ZodOptional<z.ZodString>;
|
|
283
|
+
secrets: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>>;
|
|
284
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
285
|
+
zone: z.ZodOptional<z.ZodString>;
|
|
286
|
+
kind: z.ZodLiteral<"github">;
|
|
287
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
288
|
+
watch: z.ZodOptional<z.ZodEnum<{
|
|
289
|
+
checks: "checks";
|
|
290
|
+
issues: "issues";
|
|
291
|
+
pulls: "pulls";
|
|
292
|
+
}>>;
|
|
293
|
+
label: z.ZodOptional<z.ZodString>;
|
|
294
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
295
|
+
from: z.ZodOptional<z.ZodEnum<{
|
|
296
|
+
anyone: "anyone";
|
|
297
|
+
team: "team";
|
|
298
|
+
}>>;
|
|
299
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
300
|
+
zone: z.ZodOptional<z.ZodString>;
|
|
301
|
+
kind: z.ZodLiteral<"linear">;
|
|
302
|
+
team: z.ZodOptional<z.ZodString>;
|
|
303
|
+
state: z.ZodOptional<z.ZodString>;
|
|
304
|
+
label: z.ZodOptional<z.ZodString>;
|
|
305
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
306
|
+
zone: z.ZodOptional<z.ZodString>;
|
|
307
|
+
kind: z.ZodLiteral<"flow">;
|
|
308
|
+
when: z.ZodOptional<z.ZodString>;
|
|
309
|
+
follow: z.ZodInt;
|
|
310
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
311
|
+
zone: z.ZodOptional<z.ZodString>;
|
|
312
|
+
kind: z.ZodLiteral<"email">;
|
|
313
|
+
folder: z.ZodOptional<z.ZodString>;
|
|
314
|
+
sender: z.ZodOptional<z.ZodString>;
|
|
315
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
316
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
317
|
+
zone: z.ZodOptional<z.ZodString>;
|
|
318
|
+
kind: z.ZodLiteral<"plane-review">;
|
|
319
|
+
at: z.ZodOptional<z.ZodString>;
|
|
320
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
321
|
+
}, z.core.$strict>], "kind">>;
|
|
322
|
+
}, z.core.$strict>;
|
|
323
|
+
export type ProposeFlowInput = z.infer<typeof proposeFlowInputSchema>;
|
|
324
|
+
/** What the lead is told propose_flow takes: exactly the schema its call is read with. */
|
|
325
|
+
export declare const PROPOSE_FLOW_MODEL_SCHEMA: Readonly<Record<string, unknown>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lead's `propose_flow` input (docs/plans/zod-revamp.md, item 3): one schema, built from the flow contract's own
|
|
3
|
+
* step and trigger schemas, that is both the JSON Schema the lead is given and the check its call is read with
|
|
4
|
+
* (mate-tools.ts). The lead-tools contract (item 5) imports it from here rather than restating it.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { LIMITS } from "../decision.js";
|
|
8
|
+
import { STARTER_IDS } from "../flow-starters.js";
|
|
9
|
+
import { FLOW_TEMPLATES } from "../flows.js";
|
|
10
|
+
import { KITS } from "../kits.js";
|
|
11
|
+
import { TEXT_LIMITS } from "../text-limits.js";
|
|
12
|
+
import { toModelSchema } from "./contract.js";
|
|
13
|
+
import { flowStepsSchema, leadTriggerSchema, SCRIPT_LANGUAGES, SCRIPT_NAME } from "./flow.js";
|
|
14
|
+
export const PROPOSE_FLOW_OPERATIONS = ["create", "edit", "add_card", "move_card", "approve", "send_back", "choose", "cancel_card", "comment", "assign", "follow", "unfollow", "save_script", "add_trigger", "pause_trigger", "resume_trigger", "remove_trigger", "kit", "starter"];
|
|
15
|
+
const id = z.int().min(1);
|
|
16
|
+
const enumOf = (values) => z.enum(values);
|
|
17
|
+
export const proposeFlowInputSchema = z.strictObject({
|
|
18
|
+
operation: z.enum(PROPOSE_FLOW_OPERATIONS),
|
|
19
|
+
/** A project as list_repos names it (r1, r2). */
|
|
20
|
+
repo: z.string().regex(/^r[0-9]{1,3}$/, { error: "must be a project from list_repos, like r1" }).optional(),
|
|
21
|
+
flow: id.optional(), card: id.optional(),
|
|
22
|
+
kit: enumOf(KITS.map(one => one.id)).optional(),
|
|
23
|
+
starter: z.enum(STARTER_IDS).optional(),
|
|
24
|
+
name: z.string().max(TEXT_LIMITS.flowName).optional(),
|
|
25
|
+
template: enumOf(FLOW_TEMPLATES.map(one => one.id)).optional(),
|
|
26
|
+
steps: flowStepsSchema.shape.steps.optional(),
|
|
27
|
+
title: z.string().max(TEXT_LIMITS.flowCardTitle).optional(),
|
|
28
|
+
description: z.string().max(TEXT_LIMITS.flowCardDescription).optional(),
|
|
29
|
+
zone: z.string().max(TEXT_LIMITS.flowRef).optional(),
|
|
30
|
+
note: z.string().max(LIMITS.note).describe(`At most ${LIMITS.note} characters; longer is refused with its length, not cut.`).optional(),
|
|
31
|
+
choice: z.int().min(1).max(4).optional(),
|
|
32
|
+
trigger: id.optional(),
|
|
33
|
+
owner: z.string().max(TEXT_LIMITS.flowDecider).optional(),
|
|
34
|
+
script: z.strictObject({
|
|
35
|
+
name: z.string().regex(SCRIPT_NAME, { error: "must be a script's name: lowercase letters, numbers and dashes" }).optional(), about: z.string().max(TEXT_LIMITS.flowScriptAbout).optional(), body: z.string().max(TEXT_LIMITS.flowScriptInline).optional(),
|
|
36
|
+
timeoutMinutes: z.int().min(1).max(60).optional(), language: z.enum(SCRIPT_LANGUAGES).optional(), file: z.string().max(TEXT_LIMITS.flowScriptFile).optional(),
|
|
37
|
+
}).optional(),
|
|
38
|
+
settings: leadTriggerSchema.optional(),
|
|
39
|
+
});
|
|
40
|
+
/** What the lead is told propose_flow takes: exactly the schema its call is read with. */
|
|
41
|
+
export const PROPOSE_FLOW_MODEL_SCHEMA = toModelSchema(proposeFlowInputSchema);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a "Send to me" or "Person chooses" visit sends its person (docs/plans/zod-revamp.md, item 8): worked out once
|
|
3
|
+
* per visit and kept (`flow_send.content_json`), so every chat app and the card show the same (src/flow-send.ts).
|
|
4
|
+
*
|
|
5
|
+
* - `flowSendPayloadSchema`: a send's — the title, summary, links, screenshots and a research report's items.
|
|
6
|
+
* - `flowChoosePayloadSchema`: a choice's — the same, with the options as they were offered and whether a reply is taken.
|
|
7
|
+
* - `flowChoiceAnswerSchema`: the person's answer to a choice, by whichever door it comes (chooseFlowCard).
|
|
8
|
+
*
|
|
9
|
+
* Kept before this contract (version 0), a visit's content had no `version`; it reads as the 0.9.36 reader read it:
|
|
10
|
+
* a title, a summary and a list of links make it readable, items that can't be shown are left out, and a link or
|
|
11
|
+
* option that isn't one is skipped.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { type ContractResult } from "./contract.js";
|
|
15
|
+
/** A link the message carries: a page of Toolroll's (a button) or the one outside page, a pull request. */
|
|
16
|
+
export declare const flowSendLinkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
17
|
+
label: z.ZodString;
|
|
18
|
+
path: z.ZodString;
|
|
19
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
20
|
+
label: z.ZodString;
|
|
21
|
+
url: z.ZodString;
|
|
22
|
+
}, z.core.$strict>]>;
|
|
23
|
+
/** One item of a research report, as the message lists it (flow-items.ts). */
|
|
24
|
+
export declare const flowSendItemSchema: z.ZodObject<{
|
|
25
|
+
title: z.ZodString;
|
|
26
|
+
why: z.ZodString;
|
|
27
|
+
url: z.ZodString;
|
|
28
|
+
source: z.ZodString;
|
|
29
|
+
plug: z.ZodString;
|
|
30
|
+
shot: z.ZodNullable<z.ZodInt>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
export type FlowSendLink = z.infer<typeof flowSendLinkSchema>;
|
|
33
|
+
export type FlowSendItem = z.infer<typeof flowSendItemSchema>;
|
|
34
|
+
export declare const FLOW_SEND_VERSION = 1;
|
|
35
|
+
export declare const flowChoiceOptionSchema: z.ZodObject<{
|
|
36
|
+
choice: z.ZodInt;
|
|
37
|
+
label: z.ZodString;
|
|
38
|
+
}, z.core.$strict>;
|
|
39
|
+
export declare const flowSendPayloadSchema: z.ZodObject<{
|
|
40
|
+
version: z.ZodLiteral<1>;
|
|
41
|
+
title: z.ZodString;
|
|
42
|
+
from: z.ZodOptional<z.ZodString>;
|
|
43
|
+
summary: z.ZodString;
|
|
44
|
+
links: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
45
|
+
label: z.ZodString;
|
|
46
|
+
path: z.ZodString;
|
|
47
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
48
|
+
label: z.ZodString;
|
|
49
|
+
url: z.ZodString;
|
|
50
|
+
}, z.core.$strict>]>>;
|
|
51
|
+
shots: z.ZodNullable<z.ZodObject<{
|
|
52
|
+
taskId: z.ZodString;
|
|
53
|
+
run: z.ZodInt;
|
|
54
|
+
}, z.core.$strict>>;
|
|
55
|
+
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
56
|
+
title: z.ZodString;
|
|
57
|
+
why: z.ZodString;
|
|
58
|
+
url: z.ZodString;
|
|
59
|
+
source: z.ZodString;
|
|
60
|
+
plug: z.ZodString;
|
|
61
|
+
shot: z.ZodNullable<z.ZodInt>;
|
|
62
|
+
}, z.core.$strict>>>;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
export declare const flowChoosePayloadSchema: z.ZodObject<{
|
|
65
|
+
version: z.ZodLiteral<1>;
|
|
66
|
+
title: z.ZodString;
|
|
67
|
+
from: z.ZodOptional<z.ZodString>;
|
|
68
|
+
summary: z.ZodString;
|
|
69
|
+
links: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
70
|
+
label: z.ZodString;
|
|
71
|
+
path: z.ZodString;
|
|
72
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
73
|
+
label: z.ZodString;
|
|
74
|
+
url: z.ZodString;
|
|
75
|
+
}, z.core.$strict>]>>;
|
|
76
|
+
shots: z.ZodNullable<z.ZodObject<{
|
|
77
|
+
taskId: z.ZodString;
|
|
78
|
+
run: z.ZodInt;
|
|
79
|
+
}, z.core.$strict>>;
|
|
80
|
+
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
81
|
+
title: z.ZodString;
|
|
82
|
+
why: z.ZodString;
|
|
83
|
+
url: z.ZodString;
|
|
84
|
+
source: z.ZodString;
|
|
85
|
+
plug: z.ZodString;
|
|
86
|
+
shot: z.ZodNullable<z.ZodInt>;
|
|
87
|
+
}, z.core.$strict>>>;
|
|
88
|
+
options: z.ZodArray<z.ZodObject<{
|
|
89
|
+
choice: z.ZodInt;
|
|
90
|
+
label: z.ZodString;
|
|
91
|
+
}, z.core.$strict>>;
|
|
92
|
+
reply: z.ZodBoolean;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
export type FlowSendPayload = z.infer<typeof flowSendPayloadSchema>;
|
|
95
|
+
export type FlowChoosePayload = z.infer<typeof flowChoosePayloadSchema>;
|
|
96
|
+
/** A visit's content as the console and chat apps read it: a send's, or a choice's with its options. */
|
|
97
|
+
export type FlowSendContent = Omit<FlowSendPayload, "version"> & {
|
|
98
|
+
options?: FlowChoosePayload["options"];
|
|
99
|
+
reply?: boolean;
|
|
100
|
+
};
|
|
101
|
+
export declare function readFlowItems(raw: unknown): FlowSendItem[];
|
|
102
|
+
/** Version 0: content kept before it carried `version`, in this contract's shape (what can't be read is left for the schema to refuse by path). */
|
|
103
|
+
export declare function upgradeSavedSend(body: Record<string, unknown>): Record<string, unknown>;
|
|
104
|
+
/** Read a visit's kept content: a choice's when it carries options, else a send's; version 0 upgraded, newer refused. */
|
|
105
|
+
export declare function readFlowSendPayload(input: unknown): ContractResult<FlowSendContent>;
|
|
106
|
+
/** A visit's content as it is kept: the payload of its kind, with the current version. */
|
|
107
|
+
export declare function flowSendForStore(content: FlowSendContent): string;
|
|
108
|
+
/** A person's answer to a choice: an option by its place (and the words and zone they saw), or a reply (`choice` null)
|
|
109
|
+
* that becomes the note for where replies go. `entry` is the visit they saw; without it, the card's current one. */
|
|
110
|
+
export declare const flowChoiceAnswerSchema: z.ZodObject<{
|
|
111
|
+
card: z.ZodInt;
|
|
112
|
+
entry: z.ZodOptional<z.ZodInt>;
|
|
113
|
+
choice: z.ZodNullable<z.ZodInt>;
|
|
114
|
+
label: z.ZodOptional<z.ZodString>;
|
|
115
|
+
to: z.ZodOptional<z.ZodString>;
|
|
116
|
+
note: z.ZodNullable<z.ZodString>;
|
|
117
|
+
}, z.core.$strict>;
|
|
118
|
+
export type FlowChoiceAnswer = z.infer<typeof flowChoiceAnswerSchema>;
|
|
119
|
+
export declare function readFlowChoiceAnswer(input: unknown): ContractResult<FlowChoiceAnswer>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a "Send to me" or "Person chooses" visit sends its person (docs/plans/zod-revamp.md, item 8): worked out once
|
|
3
|
+
* per visit and kept (`flow_send.content_json`), so every chat app and the card show the same (src/flow-send.ts).
|
|
4
|
+
*
|
|
5
|
+
* - `flowSendPayloadSchema`: a send's — the title, summary, links, screenshots and a research report's items.
|
|
6
|
+
* - `flowChoosePayloadSchema`: a choice's — the same, with the options as they were offered and whether a reply is taken.
|
|
7
|
+
* - `flowChoiceAnswerSchema`: the person's answer to a choice, by whichever door it comes (chooseFlowCard).
|
|
8
|
+
*
|
|
9
|
+
* Kept before this contract (version 0), a visit's content had no `version`; it reads as the 0.9.36 reader read it:
|
|
10
|
+
* a title, a summary and a list of links make it readable, items that can't be shown are left out, and a link or
|
|
11
|
+
* option that isn't one is skipped.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { parseContract, readVersioned, versioned } from "./contract.js";
|
|
15
|
+
/** A link the message carries: a page of Toolroll's (a button) or the one outside page, a pull request. */
|
|
16
|
+
export const flowSendLinkSchema = z.union([
|
|
17
|
+
z.strictObject({ label: z.string(), path: z.string().regex(/^\//, { error: "must be a path in Toolroll, starting with /" }) }),
|
|
18
|
+
z.strictObject({ label: z.string(), url: z.string().regex(/^https:\/\/[^\s<>"]+$/, { error: "must be an https:// address" }) }),
|
|
19
|
+
]);
|
|
20
|
+
/** One item of a research report, as the message lists it (flow-items.ts). */
|
|
21
|
+
export const flowSendItemSchema = z.strictObject({
|
|
22
|
+
title: z.string(),
|
|
23
|
+
why: z.string(),
|
|
24
|
+
url: z.string().regex(/^https?:\/\//, { error: "must be a web address" }),
|
|
25
|
+
/** Where the link goes, by name: "Mobbin", "Linear", "Apple". */
|
|
26
|
+
source: z.string(),
|
|
27
|
+
/** One line: how it plugs in (from the why, else the image's own caption). */
|
|
28
|
+
plug: z.string(),
|
|
29
|
+
/** The item's screenshot (its evidence id in the report's run), when it has one. */
|
|
30
|
+
shot: z.int().nullable(),
|
|
31
|
+
});
|
|
32
|
+
export const FLOW_SEND_VERSION = 1;
|
|
33
|
+
const sendShape = {
|
|
34
|
+
/** The card's title and the step it comes from. */
|
|
35
|
+
title: z.string(),
|
|
36
|
+
/** The step it comes from, when known. */
|
|
37
|
+
from: z.string().optional(),
|
|
38
|
+
summary: z.string(),
|
|
39
|
+
links: z.array(flowSendLinkSchema),
|
|
40
|
+
/** The build's result whose screenshots go with it, when it saved any. */
|
|
41
|
+
shots: z.strictObject({ taskId: z.string(), run: z.int() }).nullable(),
|
|
42
|
+
/** After research: the report's items, numbered in this order in every message and screenshot caption. */
|
|
43
|
+
items: z.array(flowSendItemSchema).min(1).optional(),
|
|
44
|
+
};
|
|
45
|
+
export const flowChoiceOptionSchema = z.strictObject({ choice: z.int().min(0), label: z.string() });
|
|
46
|
+
export const flowSendPayloadSchema = versioned(FLOW_SEND_VERSION, sendShape);
|
|
47
|
+
export const flowChoosePayloadSchema = versioned(FLOW_SEND_VERSION, {
|
|
48
|
+
...sendShape,
|
|
49
|
+
/** The options as they were offered, by place. */
|
|
50
|
+
options: z.array(flowChoiceOptionSchema),
|
|
51
|
+
/** Whether a reply is taken instead (the zone has somewhere replies go). */
|
|
52
|
+
reply: z.boolean(),
|
|
53
|
+
});
|
|
54
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
55
|
+
/** A kept item as 0.9.36 read it: its five words (a web link), and a screenshot id only when it is a whole number. */
|
|
56
|
+
const savedItemSchema = z.object({ ...flowSendItemSchema.shape, shot: z.unknown() });
|
|
57
|
+
export function readFlowItems(raw) {
|
|
58
|
+
if (!Array.isArray(raw))
|
|
59
|
+
return [];
|
|
60
|
+
return raw.flatMap(one => {
|
|
61
|
+
const read = savedItemSchema.safeParse(one);
|
|
62
|
+
if (!read.success)
|
|
63
|
+
return [];
|
|
64
|
+
const shot = read.data.shot;
|
|
65
|
+
return [{ ...read.data, shot: typeof shot === "number" && Number.isSafeInteger(shot) ? shot : null }];
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Version 0: content kept before it carried `version`, in this contract's shape (what can't be read is left for the schema to refuse by path). */
|
|
69
|
+
export function upgradeSavedSend(body) {
|
|
70
|
+
if (typeof body["title"] !== "string" || typeof body["summary"] !== "string" || !Array.isArray(body["links"]))
|
|
71
|
+
return body;
|
|
72
|
+
const items = readFlowItems(body["items"]);
|
|
73
|
+
const shots = sendShape.shots.safeParse(body["shots"]);
|
|
74
|
+
const out = {
|
|
75
|
+
version: FLOW_SEND_VERSION, title: body["title"], ...(typeof body["from"] === "string" ? { from: body["from"] } : {}), summary: body["summary"],
|
|
76
|
+
links: body["links"].filter(one => flowSendLinkSchema.safeParse(one).success), shots: shots.success ? shots.data : null,
|
|
77
|
+
...(body["items"] === undefined || items.length === 0 ? {} : { items }),
|
|
78
|
+
};
|
|
79
|
+
if (Array.isArray(body["options"])) {
|
|
80
|
+
out["options"] = body["options"].filter(one => flowChoiceOptionSchema.safeParse(one).success);
|
|
81
|
+
out["reply"] = body["reply"] === true;
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
/** Read a visit's kept content: a choice's when it carries options, else a send's; version 0 upgraded, newer refused. */
|
|
86
|
+
export function readFlowSendPayload(input) {
|
|
87
|
+
const choose = isRecord(input) && Object.prototype.hasOwnProperty.call(input, "options");
|
|
88
|
+
const read = choose ? readVersioned(flowChoosePayloadSchema, input, { 0: upgradeSavedSend }) : readVersioned(flowSendPayloadSchema, input, { 0: upgradeSavedSend });
|
|
89
|
+
if (!read.ok)
|
|
90
|
+
return read;
|
|
91
|
+
const { version: _version, ...content } = read.value;
|
|
92
|
+
return { ok: true, value: content };
|
|
93
|
+
}
|
|
94
|
+
/** A visit's content as it is kept: the payload of its kind, with the current version. */
|
|
95
|
+
export function flowSendForStore(content) {
|
|
96
|
+
const payload = { version: FLOW_SEND_VERSION, ...content };
|
|
97
|
+
return JSON.stringify(content.options === undefined ? flowSendPayloadSchema.parse(payload) : flowChoosePayloadSchema.parse(payload));
|
|
98
|
+
}
|
|
99
|
+
// ------------------------------------------------------------------ the person's choice
|
|
100
|
+
/** A person's answer to a choice: an option by its place (and the words and zone they saw), or a reply (`choice` null)
|
|
101
|
+
* that becomes the note for where replies go. `entry` is the visit they saw; without it, the card's current one. */
|
|
102
|
+
export const flowChoiceAnswerSchema = z.strictObject({
|
|
103
|
+
card: z.int().min(1),
|
|
104
|
+
entry: z.int().min(1).optional(),
|
|
105
|
+
choice: z.int().min(0).nullable(),
|
|
106
|
+
label: z.string().optional(),
|
|
107
|
+
to: z.string().optional(),
|
|
108
|
+
note: z.string().nullable(),
|
|
109
|
+
});
|
|
110
|
+
export function readFlowChoiceAnswer(input) {
|
|
111
|
+
return parseContract(flowChoiceAnswerSchema, input);
|
|
112
|
+
}
|