@fungi.computer/shiitake-extensions 0.0.2 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -13
- package/dist/almanac/contract.d.ts +94 -0
- package/dist/almanac/contract.js +71 -5
- package/dist/goal/client.d.ts +5 -2
- package/dist/goal/client.js +66 -72
- package/dist/goal/contract.d.ts +181 -64
- package/dist/goal/contract.js +102 -12
- package/dist/goal/host.js +206 -124
- package/dist/home/contract.d.ts +18 -0
- package/dist/home/contract.js +24 -3
- package/dist/home/host.d.ts +3 -0
- package/dist/home/host.js +1 -2
- package/dist/home/routing.js +13 -24
- package/dist/internal/history.d.ts +16 -0
- package/dist/internal/history.js +8 -0
- package/dist/loop/client.d.ts +1 -1
- package/dist/loop/client.js +28 -34
- package/dist/loop/contract.d.ts +129 -84
- package/dist/loop/contract.js +79 -9
- package/dist/loop/host.d.ts +1 -0
- package/dist/loop/host.js +89 -48
- package/dist/plan/client.d.ts +1 -1
- package/dist/plan/contract.d.ts +33 -0
- package/dist/plan/contract.js +28 -3
- package/dist/plan/host.js +12 -7
- package/dist/question/client.d.ts +1 -1
- package/dist/question/contract.d.ts +158 -0
- package/dist/question/contract.js +92 -7
- package/dist/question/host.js +34 -20
- package/dist/roster/conversation-agents.d.ts +31 -0
- package/dist/roster/conversation-agents.js +114 -0
- package/dist/roster.js +1 -0
- package/dist/skills/host.d.ts +1 -0
- package/dist/skills/host.js +22 -17
- package/dist/skills/source.d.ts +34 -0
- package/dist/subagents/client.d.ts +1 -1
- package/dist/subagents/client.js +43 -12
- package/dist/subagents/contract.d.ts +46 -8
- package/dist/subagents/contract.js +38 -8
- package/dist/subagents/host.d.ts +20 -8
- package/dist/subagents/host.js +58 -12
- package/docs/api/README.md +35 -0
- package/docs/api/almanac/contract.md +90 -0
- package/docs/api/almanac/host.md +19 -0
- package/docs/api/goal/client.md +26 -0
- package/docs/api/goal/contract.md +247 -0
- package/docs/api/goal/host.md +29 -0
- package/docs/api/home/contract.md +58 -0
- package/docs/api/home/host.md +55 -0
- package/docs/api/loop/client.md +25 -0
- package/docs/api/loop/contract.md +161 -0
- package/docs/api/loop/host.md +30 -0
- package/docs/api/plan/client.md +26 -0
- package/docs/api/plan/contract.md +163 -0
- package/docs/api/plan/host.md +19 -0
- package/docs/api/question/client.md +25 -0
- package/docs/api/question/contract.md +377 -0
- package/docs/api/question/host.md +19 -0
- package/docs/api/roster/conversation-agents.md +80 -0
- package/docs/api/roster.md +40 -0
- package/docs/api/skills/host.md +39 -0
- package/docs/api/skills/source.md +104 -0
- package/docs/api/subagents/client.md +26 -0
- package/docs/api/subagents/contract.md +131 -0
- package/docs/api/subagents/host.md +115 -0
- package/package.json +14 -8
|
@@ -1,249 +1,407 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
2
|
/** A decision question: first option is recommended, free text belongs to the host. */
|
|
3
3
|
export declare const Question: Schema.Struct<{
|
|
4
|
+
/** Identity used to associate this question with its answer. */
|
|
4
5
|
readonly id: Schema.String;
|
|
6
|
+
/** Short label shown above the question. */
|
|
5
7
|
readonly header: Schema.String;
|
|
8
|
+
/** Decision presented to the person. */
|
|
6
9
|
readonly question: Schema.String;
|
|
10
|
+
/** Offered choices, with the recommended choice first. */
|
|
7
11
|
readonly options: Schema.$Array<Schema.Struct<{
|
|
12
|
+
/** Choice label returned in an answer's selection. */
|
|
8
13
|
readonly label: Schema.String;
|
|
14
|
+
/** Explanation of the choice's trade-off. */
|
|
9
15
|
readonly description: Schema.String;
|
|
10
16
|
}>>;
|
|
17
|
+
/** Whether the person may select more than one offered choice. */
|
|
11
18
|
readonly multiple: Schema.optionalKey<Schema.Boolean>;
|
|
12
19
|
}>;
|
|
20
|
+
/** Bounded question set with distinct question identities. */
|
|
13
21
|
export declare const Questions: Schema.$Array<Schema.Struct<{
|
|
22
|
+
/** Identity used to associate this question with its answer. */
|
|
14
23
|
readonly id: Schema.String;
|
|
24
|
+
/** Short label shown above the question. */
|
|
15
25
|
readonly header: Schema.String;
|
|
26
|
+
/** Decision presented to the person. */
|
|
16
27
|
readonly question: Schema.String;
|
|
28
|
+
/** Offered choices, with the recommended choice first. */
|
|
17
29
|
readonly options: Schema.$Array<Schema.Struct<{
|
|
30
|
+
/** Choice label returned in an answer's selection. */
|
|
18
31
|
readonly label: Schema.String;
|
|
32
|
+
/** Explanation of the choice's trade-off. */
|
|
19
33
|
readonly description: Schema.String;
|
|
20
34
|
}>>;
|
|
35
|
+
/** Whether the person may select more than one offered choice. */
|
|
21
36
|
readonly multiple: Schema.optionalKey<Schema.Boolean>;
|
|
22
37
|
}>>;
|
|
38
|
+
/** One decoded decision question. */
|
|
23
39
|
export type Question = Schema.Schema.Type<typeof Question>;
|
|
24
40
|
/** The complete question data shared by ordinary Session clients. */
|
|
25
41
|
export declare const OpenAsk: Schema.Struct<{
|
|
42
|
+
/** Durable identity of the open ask. */
|
|
26
43
|
readonly askId: Schema.String;
|
|
44
|
+
/** Decisions awaiting the person's answers. */
|
|
27
45
|
readonly questions: Schema.$Array<Schema.Struct<{
|
|
46
|
+
/** Identity used to associate this question with its answer. */
|
|
28
47
|
readonly id: Schema.String;
|
|
48
|
+
/** Short label shown above the question. */
|
|
29
49
|
readonly header: Schema.String;
|
|
50
|
+
/** Decision presented to the person. */
|
|
30
51
|
readonly question: Schema.String;
|
|
52
|
+
/** Offered choices, with the recommended choice first. */
|
|
31
53
|
readonly options: Schema.$Array<Schema.Struct<{
|
|
54
|
+
/** Choice label returned in an answer's selection. */
|
|
32
55
|
readonly label: Schema.String;
|
|
56
|
+
/** Explanation of the choice's trade-off. */
|
|
33
57
|
readonly description: Schema.String;
|
|
34
58
|
}>>;
|
|
59
|
+
/** Whether the person may select more than one offered choice. */
|
|
35
60
|
readonly multiple: Schema.optionalKey<Schema.Boolean>;
|
|
36
61
|
}>>;
|
|
62
|
+
/** Whether the ask is live in a turn or parked for later. */
|
|
37
63
|
readonly status: Schema.Literals<readonly ["live", "parked"]>;
|
|
64
|
+
/** Creation timestamp. */
|
|
38
65
|
readonly createdAt: Schema.Number;
|
|
66
|
+
/** Expiry timestamp, or null when none is set. */
|
|
39
67
|
readonly expiresAt: Schema.NullOr<Schema.Number>;
|
|
40
68
|
}>;
|
|
69
|
+
/** One live or parked ask visible to Session clients. */
|
|
41
70
|
export type OpenAsk = Schema.Schema.Type<typeof OpenAsk>;
|
|
71
|
+
/** Bounded set of open asks projected into the Session. */
|
|
42
72
|
export declare const AskProjection: Schema.Struct<{
|
|
73
|
+
/** Currently visible live and parked asks. */
|
|
43
74
|
readonly asks: Schema.$Array<Schema.Struct<{
|
|
75
|
+
/** Durable identity of the open ask. */
|
|
44
76
|
readonly askId: Schema.String;
|
|
77
|
+
/** Decisions awaiting the person's answers. */
|
|
45
78
|
readonly questions: Schema.$Array<Schema.Struct<{
|
|
79
|
+
/** Identity used to associate this question with its answer. */
|
|
46
80
|
readonly id: Schema.String;
|
|
81
|
+
/** Short label shown above the question. */
|
|
47
82
|
readonly header: Schema.String;
|
|
83
|
+
/** Decision presented to the person. */
|
|
48
84
|
readonly question: Schema.String;
|
|
85
|
+
/** Offered choices, with the recommended choice first. */
|
|
49
86
|
readonly options: Schema.$Array<Schema.Struct<{
|
|
87
|
+
/** Choice label returned in an answer's selection. */
|
|
50
88
|
readonly label: Schema.String;
|
|
89
|
+
/** Explanation of the choice's trade-off. */
|
|
51
90
|
readonly description: Schema.String;
|
|
52
91
|
}>>;
|
|
92
|
+
/** Whether the person may select more than one offered choice. */
|
|
53
93
|
readonly multiple: Schema.optionalKey<Schema.Boolean>;
|
|
54
94
|
}>>;
|
|
95
|
+
/** Whether the ask is live in a turn or parked for later. */
|
|
55
96
|
readonly status: Schema.Literals<readonly ["live", "parked"]>;
|
|
97
|
+
/** Creation timestamp. */
|
|
56
98
|
readonly createdAt: Schema.Number;
|
|
99
|
+
/** Expiry timestamp, or null when none is set. */
|
|
57
100
|
readonly expiresAt: Schema.NullOr<Schema.Number>;
|
|
58
101
|
}>>;
|
|
59
102
|
}>;
|
|
60
103
|
/** Stable identity for a human command and its retry. */
|
|
61
104
|
export declare const RequestId: Schema.String;
|
|
105
|
+
/** Answers keyed by question id, with selected choices and optional free text. */
|
|
62
106
|
export declare const Answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
107
|
+
/** Labels of the offered choices selected by the person. */
|
|
63
108
|
readonly selected: Schema.$Array<Schema.String>;
|
|
109
|
+
/** Optional free-text answer supplied by the person. */
|
|
64
110
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
65
111
|
}>>;
|
|
112
|
+
/** Decoded answers indexed by question identity. */
|
|
66
113
|
export type Answers = Schema.Schema.Type<typeof Answers>;
|
|
114
|
+
/** Idempotent human submission of a complete answer set. */
|
|
67
115
|
export declare const AnswerInput: Schema.Struct<{
|
|
116
|
+
/** Ask being answered. */
|
|
68
117
|
readonly askId: Schema.String;
|
|
118
|
+
/** Stable identity shared by this command and its retries. */
|
|
69
119
|
readonly requestId: Schema.String;
|
|
120
|
+
/** Answers to the ask's question set. */
|
|
70
121
|
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
122
|
+
/** Labels of the offered choices selected by the person. */
|
|
71
123
|
readonly selected: Schema.$Array<Schema.String>;
|
|
124
|
+
/** Optional free-text answer supplied by the person. */
|
|
72
125
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
73
126
|
}>>;
|
|
74
127
|
}>;
|
|
128
|
+
/** Decoded human answer submission. */
|
|
75
129
|
export type AnswerInput = Schema.Schema.Type<typeof AnswerInput>;
|
|
130
|
+
/** Idempotent human refusal to answer an ask. */
|
|
76
131
|
export declare const DeclineInput: Schema.Struct<{
|
|
132
|
+
/** Ask being declined. */
|
|
77
133
|
readonly askId: Schema.String;
|
|
134
|
+
/** Stable identity shared by this command and its retries. */
|
|
78
135
|
readonly requestId: Schema.String;
|
|
136
|
+
/** Optional explanation for declining. */
|
|
79
137
|
readonly note: Schema.optionalKey<Schema.String>;
|
|
80
138
|
}>;
|
|
139
|
+
/** Decoded human decline submission. */
|
|
81
140
|
export type DeclineInput = Schema.Schema.Type<typeof DeclineInput>;
|
|
82
141
|
/** Terminal question outcomes, shared by human replies and model withdrawal. */
|
|
83
142
|
export declare const ClosedStatus: Schema.Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>;
|
|
143
|
+
/** Admission, already-closed state, or absence returned to a human reply. */
|
|
84
144
|
export declare const HumanResult: Schema.Union<readonly [Schema.Struct<{
|
|
145
|
+
/** Reply was accepted. */
|
|
85
146
|
readonly result: Schema.Literal<"accepted">;
|
|
147
|
+
/** Whether the reply resumed its turn or became a follow-up. */
|
|
86
148
|
readonly via: Schema.Literals<readonly ["in_turn", "follow_up"]>;
|
|
87
149
|
}>, Schema.Struct<{
|
|
150
|
+
/** Ask had already reached a terminal state. */
|
|
88
151
|
readonly result: Schema.Literal<"closed">;
|
|
152
|
+
/** Terminal state that prevented another answer. */
|
|
89
153
|
readonly status: Schema.Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>;
|
|
90
154
|
}>, Schema.Struct<{
|
|
155
|
+
/** No ask with this identity exists. */
|
|
91
156
|
readonly result: Schema.Literal<"not_found">;
|
|
92
157
|
}>]>;
|
|
158
|
+
/** Decoded outcome of a human answer or decline. */
|
|
93
159
|
export type HumanResult = Schema.Schema.Type<typeof HumanResult>;
|
|
94
160
|
/** The ordinary /answer conversation carries its draft between typed steps. */
|
|
95
161
|
export declare const AnswerFlowInput: Schema.Union<readonly [Schema.Struct<{
|
|
162
|
+
/** Encoded selection supplied by the human control. */
|
|
96
163
|
readonly selection: Schema.String;
|
|
97
164
|
readonly askId: Schema.String;
|
|
98
165
|
readonly requestId: Schema.String;
|
|
99
166
|
readonly index: Schema.Number;
|
|
100
167
|
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
168
|
+
/** Labels of the offered choices selected by the person. */
|
|
101
169
|
readonly selected: Schema.$Array<Schema.String>;
|
|
170
|
+
/** Optional free-text answer supplied by the person. */
|
|
102
171
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
103
172
|
}>>;
|
|
173
|
+
/** Multiple-choice selection step. */
|
|
104
174
|
readonly stage: Schema.Literal<"multiple">;
|
|
105
175
|
}>, Schema.Struct<{
|
|
176
|
+
/** Encoded selection supplied by the human control. */
|
|
106
177
|
readonly selection: Schema.String;
|
|
107
178
|
readonly askId: Schema.String;
|
|
108
179
|
readonly requestId: Schema.String;
|
|
109
180
|
readonly index: Schema.Number;
|
|
110
181
|
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
182
|
+
/** Labels of the offered choices selected by the person. */
|
|
111
183
|
readonly selected: Schema.$Array<Schema.String>;
|
|
184
|
+
/** Optional free-text answer supplied by the person. */
|
|
112
185
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
113
186
|
}>>;
|
|
187
|
+
/** Single-choice selection step. */
|
|
114
188
|
readonly stage: Schema.Literal<"selection">;
|
|
115
189
|
}>, Schema.Struct<{
|
|
190
|
+
/** Offered choices retained while entering free text. */
|
|
116
191
|
readonly selected: Schema.$Array<Schema.String>;
|
|
192
|
+
/** Free-text answer supplied by the person. */
|
|
117
193
|
readonly text: Schema.String;
|
|
118
194
|
readonly askId: Schema.String;
|
|
119
195
|
readonly requestId: Schema.String;
|
|
120
196
|
readonly index: Schema.Number;
|
|
121
197
|
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
198
|
+
/** Labels of the offered choices selected by the person. */
|
|
122
199
|
readonly selected: Schema.$Array<Schema.String>;
|
|
200
|
+
/** Optional free-text answer supplied by the person. */
|
|
123
201
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
124
202
|
}>>;
|
|
203
|
+
/** Free-text answer step. */
|
|
125
204
|
readonly stage: Schema.Literal<"text">;
|
|
126
205
|
}>, Schema.Struct<{
|
|
206
|
+
/** Ask whose answer conversation should be opened. */
|
|
127
207
|
readonly askId: Schema.String;
|
|
128
208
|
}>, Schema.Struct<{}>]>;
|
|
129
209
|
/** Human reads and the ordinary projection slot; model operations belong to the host. */
|
|
130
210
|
export declare const questionContract: {
|
|
211
|
+
/** Stable extension identity. */
|
|
131
212
|
readonly id: string & import("effect/Brand").Brand<"ExtensionId">;
|
|
213
|
+
/** Human question controls admitted by the Session owner. */
|
|
132
214
|
readonly commands: {
|
|
215
|
+
/** Advance the server-owned answer conversation. */
|
|
133
216
|
readonly answerFlow: {
|
|
217
|
+
/** The Session owns its asks and replies. */
|
|
134
218
|
readonly scope: "session";
|
|
219
|
+
/** Decode the current answer-draft step. */
|
|
135
220
|
readonly input: Schema.Union<readonly [Schema.Struct<{
|
|
221
|
+
/** Encoded selection supplied by the human control. */
|
|
136
222
|
readonly selection: Schema.String;
|
|
137
223
|
readonly askId: Schema.String;
|
|
138
224
|
readonly requestId: Schema.String;
|
|
139
225
|
readonly index: Schema.Number;
|
|
140
226
|
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
227
|
+
/** Labels of the offered choices selected by the person. */
|
|
141
228
|
readonly selected: Schema.$Array<Schema.String>;
|
|
229
|
+
/** Optional free-text answer supplied by the person. */
|
|
142
230
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
143
231
|
}>>;
|
|
232
|
+
/** Multiple-choice selection step. */
|
|
144
233
|
readonly stage: Schema.Literal<"multiple">;
|
|
145
234
|
}>, Schema.Struct<{
|
|
235
|
+
/** Encoded selection supplied by the human control. */
|
|
146
236
|
readonly selection: Schema.String;
|
|
147
237
|
readonly askId: Schema.String;
|
|
148
238
|
readonly requestId: Schema.String;
|
|
149
239
|
readonly index: Schema.Number;
|
|
150
240
|
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
241
|
+
/** Labels of the offered choices selected by the person. */
|
|
151
242
|
readonly selected: Schema.$Array<Schema.String>;
|
|
243
|
+
/** Optional free-text answer supplied by the person. */
|
|
152
244
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
153
245
|
}>>;
|
|
246
|
+
/** Single-choice selection step. */
|
|
154
247
|
readonly stage: Schema.Literal<"selection">;
|
|
155
248
|
}>, Schema.Struct<{
|
|
249
|
+
/** Offered choices retained while entering free text. */
|
|
156
250
|
readonly selected: Schema.$Array<Schema.String>;
|
|
251
|
+
/** Free-text answer supplied by the person. */
|
|
157
252
|
readonly text: Schema.String;
|
|
158
253
|
readonly askId: Schema.String;
|
|
159
254
|
readonly requestId: Schema.String;
|
|
160
255
|
readonly index: Schema.Number;
|
|
161
256
|
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
257
|
+
/** Labels of the offered choices selected by the person. */
|
|
162
258
|
readonly selected: Schema.$Array<Schema.String>;
|
|
259
|
+
/** Optional free-text answer supplied by the person. */
|
|
163
260
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
164
261
|
}>>;
|
|
262
|
+
/** Free-text answer step. */
|
|
165
263
|
readonly stage: Schema.Literal<"text">;
|
|
166
264
|
}>, Schema.Struct<{
|
|
265
|
+
/** Ask whose answer conversation should be opened. */
|
|
167
266
|
readonly askId: Schema.String;
|
|
168
267
|
}>, Schema.Struct<{}>]>;
|
|
268
|
+
/** Return the next human conversation step. */
|
|
169
269
|
readonly output: Schema.declare<import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1, import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1>;
|
|
170
270
|
};
|
|
271
|
+
/** Submit a person's completed answers. */
|
|
171
272
|
readonly answer: {
|
|
273
|
+
/** The Session owns this ask. */
|
|
172
274
|
readonly scope: "session";
|
|
275
|
+
/** Decode the answer submission. */
|
|
173
276
|
readonly input: Schema.Struct<{
|
|
277
|
+
/** Ask being answered. */
|
|
174
278
|
readonly askId: Schema.String;
|
|
279
|
+
/** Stable identity shared by this command and its retries. */
|
|
175
280
|
readonly requestId: Schema.String;
|
|
281
|
+
/** Answers to the ask's question set. */
|
|
176
282
|
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
283
|
+
/** Labels of the offered choices selected by the person. */
|
|
177
284
|
readonly selected: Schema.$Array<Schema.String>;
|
|
285
|
+
/** Optional free-text answer supplied by the person. */
|
|
178
286
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
179
287
|
}>>;
|
|
180
288
|
}>;
|
|
289
|
+
/** Return admission or the ask's terminal state. */
|
|
181
290
|
readonly output: Schema.Union<readonly [Schema.Struct<{
|
|
291
|
+
/** Reply was accepted. */
|
|
182
292
|
readonly result: Schema.Literal<"accepted">;
|
|
293
|
+
/** Whether the reply resumed its turn or became a follow-up. */
|
|
183
294
|
readonly via: Schema.Literals<readonly ["in_turn", "follow_up"]>;
|
|
184
295
|
}>, Schema.Struct<{
|
|
296
|
+
/** Ask had already reached a terminal state. */
|
|
185
297
|
readonly result: Schema.Literal<"closed">;
|
|
298
|
+
/** Terminal state that prevented another answer. */
|
|
186
299
|
readonly status: Schema.Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>;
|
|
187
300
|
}>, Schema.Struct<{
|
|
301
|
+
/** No ask with this identity exists. */
|
|
188
302
|
readonly result: Schema.Literal<"not_found">;
|
|
189
303
|
}>]>;
|
|
190
304
|
};
|
|
305
|
+
/** Decline an ask with an optional note. */
|
|
191
306
|
readonly decline: {
|
|
307
|
+
/** The Session owns this ask. */
|
|
192
308
|
readonly scope: "session";
|
|
309
|
+
/** Decode the decline submission. */
|
|
193
310
|
readonly input: Schema.Struct<{
|
|
311
|
+
/** Ask being declined. */
|
|
194
312
|
readonly askId: Schema.String;
|
|
313
|
+
/** Stable identity shared by this command and its retries. */
|
|
195
314
|
readonly requestId: Schema.String;
|
|
315
|
+
/** Optional explanation for declining. */
|
|
196
316
|
readonly note: Schema.optionalKey<Schema.String>;
|
|
197
317
|
}>;
|
|
318
|
+
/** Return admission or the ask's terminal state. */
|
|
198
319
|
readonly output: Schema.Union<readonly [Schema.Struct<{
|
|
320
|
+
/** Reply was accepted. */
|
|
199
321
|
readonly result: Schema.Literal<"accepted">;
|
|
322
|
+
/** Whether the reply resumed its turn or became a follow-up. */
|
|
200
323
|
readonly via: Schema.Literals<readonly ["in_turn", "follow_up"]>;
|
|
201
324
|
}>, Schema.Struct<{
|
|
325
|
+
/** Ask had already reached a terminal state. */
|
|
202
326
|
readonly result: Schema.Literal<"closed">;
|
|
327
|
+
/** Terminal state that prevented another answer. */
|
|
203
328
|
readonly status: Schema.Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>;
|
|
204
329
|
}>, Schema.Struct<{
|
|
330
|
+
/** No ask with this identity exists. */
|
|
205
331
|
readonly result: Schema.Literal<"not_found">;
|
|
206
332
|
}>]>;
|
|
207
333
|
};
|
|
334
|
+
/** Read the Session's open asks. */
|
|
208
335
|
readonly list: {
|
|
336
|
+
/** The Session owns the ask collection. */
|
|
209
337
|
readonly scope: "session";
|
|
338
|
+
/** No additional arguments are required. */
|
|
210
339
|
readonly input: Schema.Struct<{}>;
|
|
340
|
+
/** Decode the currently visible asks. */
|
|
211
341
|
readonly output: Schema.Struct<{
|
|
342
|
+
/** Currently visible live and parked asks. */
|
|
212
343
|
readonly asks: Schema.$Array<Schema.Struct<{
|
|
344
|
+
/** Durable identity of the open ask. */
|
|
213
345
|
readonly askId: Schema.String;
|
|
346
|
+
/** Decisions awaiting the person's answers. */
|
|
214
347
|
readonly questions: Schema.$Array<Schema.Struct<{
|
|
348
|
+
/** Identity used to associate this question with its answer. */
|
|
215
349
|
readonly id: Schema.String;
|
|
350
|
+
/** Short label shown above the question. */
|
|
216
351
|
readonly header: Schema.String;
|
|
352
|
+
/** Decision presented to the person. */
|
|
217
353
|
readonly question: Schema.String;
|
|
354
|
+
/** Offered choices, with the recommended choice first. */
|
|
218
355
|
readonly options: Schema.$Array<Schema.Struct<{
|
|
356
|
+
/** Choice label returned in an answer's selection. */
|
|
219
357
|
readonly label: Schema.String;
|
|
358
|
+
/** Explanation of the choice's trade-off. */
|
|
220
359
|
readonly description: Schema.String;
|
|
221
360
|
}>>;
|
|
361
|
+
/** Whether the person may select more than one offered choice. */
|
|
222
362
|
readonly multiple: Schema.optionalKey<Schema.Boolean>;
|
|
223
363
|
}>>;
|
|
364
|
+
/** Whether the ask is live in a turn or parked for later. */
|
|
224
365
|
readonly status: Schema.Literals<readonly ["live", "parked"]>;
|
|
366
|
+
/** Creation timestamp. */
|
|
225
367
|
readonly createdAt: Schema.Number;
|
|
368
|
+
/** Expiry timestamp, or null when none is set. */
|
|
226
369
|
readonly expiresAt: Schema.NullOr<Schema.Number>;
|
|
227
370
|
}>>;
|
|
228
371
|
}>;
|
|
229
372
|
};
|
|
230
373
|
};
|
|
374
|
+
/** Open asks visible to Session clients. */
|
|
231
375
|
readonly projection: {
|
|
376
|
+
/** Decoder for projected asks. */
|
|
232
377
|
readonly schema: Schema.Struct<{
|
|
378
|
+
/** Currently visible live and parked asks. */
|
|
233
379
|
readonly asks: Schema.$Array<Schema.Struct<{
|
|
380
|
+
/** Durable identity of the open ask. */
|
|
234
381
|
readonly askId: Schema.String;
|
|
382
|
+
/** Decisions awaiting the person's answers. */
|
|
235
383
|
readonly questions: Schema.$Array<Schema.Struct<{
|
|
384
|
+
/** Identity used to associate this question with its answer. */
|
|
236
385
|
readonly id: Schema.String;
|
|
386
|
+
/** Short label shown above the question. */
|
|
237
387
|
readonly header: Schema.String;
|
|
388
|
+
/** Decision presented to the person. */
|
|
238
389
|
readonly question: Schema.String;
|
|
390
|
+
/** Offered choices, with the recommended choice first. */
|
|
239
391
|
readonly options: Schema.$Array<Schema.Struct<{
|
|
392
|
+
/** Choice label returned in an answer's selection. */
|
|
240
393
|
readonly label: Schema.String;
|
|
394
|
+
/** Explanation of the choice's trade-off. */
|
|
241
395
|
readonly description: Schema.String;
|
|
242
396
|
}>>;
|
|
397
|
+
/** Whether the person may select more than one offered choice. */
|
|
243
398
|
readonly multiple: Schema.optionalKey<Schema.Boolean>;
|
|
244
399
|
}>>;
|
|
400
|
+
/** Whether the ask is live in a turn or parked for later. */
|
|
245
401
|
readonly status: Schema.Literals<readonly ["live", "parked"]>;
|
|
402
|
+
/** Creation timestamp. */
|
|
246
403
|
readonly createdAt: Schema.Number;
|
|
404
|
+
/** Expiry timestamp, or null when none is set. */
|
|
247
405
|
readonly expiresAt: Schema.NullOr<Schema.Number>;
|
|
248
406
|
}>>;
|
|
249
407
|
}>;
|
|
@@ -4,18 +4,29 @@ import { CatalogStep } from "../internal/catalog.js";
|
|
|
4
4
|
const text = (maximum) => Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(maximum), Schema.isPattern(/\S/u));
|
|
5
5
|
/** A decision question: first option is recommended, free text belongs to the host. */
|
|
6
6
|
export const Question = Schema.Struct({
|
|
7
|
+
/** Identity used to associate this question with its answer. */
|
|
7
8
|
id: text(32).check(Schema.isPattern(/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/u)),
|
|
9
|
+
/** Short label shown above the question. */
|
|
8
10
|
header: text(12),
|
|
11
|
+
/** Decision presented to the person. */
|
|
9
12
|
question: text(1_000),
|
|
10
|
-
|
|
13
|
+
/** Offered choices, with the recommended choice first. */
|
|
14
|
+
options: Schema.Array(Schema.Struct({
|
|
15
|
+
/** Choice label returned in an answer's selection. */
|
|
16
|
+
label: text(60),
|
|
17
|
+
/** Explanation of the choice's trade-off. */
|
|
18
|
+
description: text(300),
|
|
19
|
+
})).check(Schema.isMinLength(2), Schema.isMaxLength(4), Schema.makeFilter((options) => new Set(options.map((option) => option.label)).size ===
|
|
11
20
|
options.length || "Option labels must be unique", {
|
|
12
21
|
representation: {
|
|
13
22
|
id: "botanical/ask/unique-option-labels",
|
|
14
23
|
payload: null,
|
|
15
24
|
},
|
|
16
25
|
})),
|
|
26
|
+
/** Whether the person may select more than one offered choice. */
|
|
17
27
|
multiple: Schema.optionalKey(Schema.Boolean),
|
|
18
28
|
});
|
|
29
|
+
/** Bounded question set with distinct question identities. */
|
|
19
30
|
export const Questions = Schema.Array(Question).check(Schema.isMinLength(1), Schema.isMaxLength(4), Schema.makeFilter((questions) => new Set(questions.map((question) => question.id)).size ===
|
|
20
31
|
questions.length || "Question ids must be unique", {
|
|
21
32
|
representation: {
|
|
@@ -25,29 +36,47 @@ export const Questions = Schema.Array(Question).check(Schema.isMinLength(1), Sch
|
|
|
25
36
|
}));
|
|
26
37
|
/** The complete question data shared by ordinary Session clients. */
|
|
27
38
|
export const OpenAsk = Schema.Struct({
|
|
39
|
+
/** Durable identity of the open ask. */
|
|
28
40
|
askId: Schema.String,
|
|
41
|
+
/** Decisions awaiting the person's answers. */
|
|
29
42
|
questions: Questions,
|
|
43
|
+
/** Whether the ask is live in a turn or parked for later. */
|
|
30
44
|
status: Schema.Literals(["live", "parked"]),
|
|
45
|
+
/** Creation timestamp. */
|
|
31
46
|
createdAt: Schema.Number,
|
|
47
|
+
/** Expiry timestamp, or null when none is set. */
|
|
32
48
|
expiresAt: Schema.NullOr(Schema.Number),
|
|
33
49
|
});
|
|
50
|
+
/** Bounded set of open asks projected into the Session. */
|
|
34
51
|
export const AskProjection = Schema.Struct({
|
|
52
|
+
/** Currently visible live and parked asks. */
|
|
35
53
|
asks: Schema.Array(OpenAsk).check(Schema.isMaxLength(4)),
|
|
36
54
|
});
|
|
37
55
|
/** Stable identity for a human command and its retry. */
|
|
38
56
|
export const RequestId = text(256);
|
|
57
|
+
/** Answers keyed by question id, with selected choices and optional free text. */
|
|
39
58
|
export const Answers = Schema.Record(Question.fields.id, Schema.Struct({
|
|
59
|
+
/** Labels of the offered choices selected by the person. */
|
|
40
60
|
selected: Schema.Array(text(60)).check(Schema.isMaxLength(4)),
|
|
61
|
+
/** Optional free-text answer supplied by the person. */
|
|
41
62
|
text: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(4_000))),
|
|
42
63
|
}));
|
|
64
|
+
/** Idempotent human submission of a complete answer set. */
|
|
43
65
|
export const AnswerInput = Schema.Struct({
|
|
66
|
+
/** Ask being answered. */
|
|
44
67
|
askId: text(256),
|
|
68
|
+
/** Stable identity shared by this command and its retries. */
|
|
45
69
|
requestId: RequestId,
|
|
70
|
+
/** Answers to the ask's question set. */
|
|
46
71
|
answers: Answers,
|
|
47
72
|
});
|
|
73
|
+
/** Idempotent human refusal to answer an ask. */
|
|
48
74
|
export const DeclineInput = Schema.Struct({
|
|
75
|
+
/** Ask being declined. */
|
|
49
76
|
askId: text(256),
|
|
77
|
+
/** Stable identity shared by this command and its retries. */
|
|
50
78
|
requestId: RequestId,
|
|
79
|
+
/** Optional explanation for declining. */
|
|
51
80
|
note: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(4_000))),
|
|
52
81
|
});
|
|
53
82
|
/** Terminal question outcomes, shared by human replies and model withdrawal. */
|
|
@@ -59,56 +88,112 @@ export const ClosedStatus = Schema.Literals([
|
|
|
59
88
|
"cancelled",
|
|
60
89
|
"undeliverable",
|
|
61
90
|
]);
|
|
91
|
+
/** Admission, already-closed state, or absence returned to a human reply. */
|
|
62
92
|
export const HumanResult = Schema.Union([
|
|
63
93
|
Schema.Struct({
|
|
94
|
+
/** Reply was accepted. */
|
|
64
95
|
result: Schema.Literal("accepted"),
|
|
96
|
+
/** Whether the reply resumed its turn or became a follow-up. */
|
|
65
97
|
via: Schema.Literals(["in_turn", "follow_up"]),
|
|
66
98
|
}),
|
|
67
99
|
Schema.Struct({
|
|
100
|
+
/** Ask had already reached a terminal state. */
|
|
68
101
|
result: Schema.Literal("closed"),
|
|
102
|
+
/** Terminal state that prevented another answer. */
|
|
69
103
|
status: ClosedStatus,
|
|
70
104
|
}),
|
|
71
|
-
Schema.Struct({
|
|
105
|
+
Schema.Struct({
|
|
106
|
+
/** No ask with this identity exists. */
|
|
107
|
+
result: Schema.Literal("not_found"),
|
|
108
|
+
}),
|
|
72
109
|
]);
|
|
73
110
|
const answerStep = {
|
|
111
|
+
/** Ask whose answer draft is being edited. */
|
|
74
112
|
askId: AnswerInput.fields.askId,
|
|
113
|
+
/** Identity of the eventual answer command. */
|
|
75
114
|
requestId: RequestId,
|
|
115
|
+
/** Zero-based question being edited. */
|
|
76
116
|
index: Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 0, maximum: 3 })),
|
|
117
|
+
/** Answers accumulated by preceding conversation steps. */
|
|
77
118
|
answers: Answers,
|
|
78
119
|
};
|
|
79
120
|
/** The ordinary /answer conversation carries its draft between typed steps. */
|
|
80
121
|
export const AnswerFlowInput = Schema.Union([
|
|
81
122
|
Schema.Struct({
|
|
123
|
+
/** Multiple-choice selection step. */
|
|
82
124
|
stage: Schema.Literal("multiple"),
|
|
83
125
|
...answerStep,
|
|
126
|
+
/** Encoded selection supplied by the human control. */
|
|
84
127
|
selection: Schema.String.check(Schema.isMaxLength(1_000)),
|
|
85
128
|
}),
|
|
86
129
|
Schema.Struct({
|
|
130
|
+
/** Single-choice selection step. */
|
|
87
131
|
stage: Schema.Literal("selection"),
|
|
88
132
|
...answerStep,
|
|
133
|
+
/** Encoded selection supplied by the human control. */
|
|
89
134
|
selection: Schema.String.check(Schema.isMaxLength(1_000)),
|
|
90
135
|
}),
|
|
91
136
|
Schema.Struct({
|
|
137
|
+
/** Free-text answer step. */
|
|
92
138
|
stage: Schema.Literal("text"),
|
|
93
139
|
...answerStep,
|
|
140
|
+
/** Offered choices retained while entering free text. */
|
|
94
141
|
selected: Answers.value.fields.selected,
|
|
142
|
+
/** Free-text answer supplied by the person. */
|
|
95
143
|
text: Schema.String.check(Schema.isMaxLength(4_000)),
|
|
96
144
|
}),
|
|
97
|
-
Schema.Struct({
|
|
145
|
+
Schema.Struct({
|
|
146
|
+
/** Ask whose answer conversation should be opened. */
|
|
147
|
+
askId: AnswerInput.fields.askId,
|
|
148
|
+
}),
|
|
98
149
|
Schema.Struct({}),
|
|
99
150
|
]);
|
|
100
151
|
/** Human reads and the ordinary projection slot; model operations belong to the host. */
|
|
101
152
|
export const questionContract = {
|
|
153
|
+
/** Stable extension identity. */
|
|
102
154
|
id: ExtensionId.make("botanical-session-question"),
|
|
155
|
+
/** Human question controls admitted by the Session owner. */
|
|
103
156
|
commands: {
|
|
157
|
+
/** Advance the server-owned answer conversation. */
|
|
104
158
|
answerFlow: {
|
|
159
|
+
/** The Session owns its asks and replies. */
|
|
105
160
|
scope: "session",
|
|
161
|
+
/** Decode the current answer-draft step. */
|
|
106
162
|
input: AnswerFlowInput,
|
|
163
|
+
/** Return the next human conversation step. */
|
|
107
164
|
output: CatalogStep,
|
|
108
165
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
166
|
+
/** Submit a person's completed answers. */
|
|
167
|
+
answer: {
|
|
168
|
+
/** The Session owns this ask. */
|
|
169
|
+
scope: "session",
|
|
170
|
+
/** Decode the answer submission. */
|
|
171
|
+
input: AnswerInput,
|
|
172
|
+
/** Return admission or the ask's terminal state. */
|
|
173
|
+
output: HumanResult,
|
|
174
|
+
},
|
|
175
|
+
/** Decline an ask with an optional note. */
|
|
176
|
+
decline: {
|
|
177
|
+
/** The Session owns this ask. */
|
|
178
|
+
scope: "session",
|
|
179
|
+
/** Decode the decline submission. */
|
|
180
|
+
input: DeclineInput,
|
|
181
|
+
/** Return admission or the ask's terminal state. */
|
|
182
|
+
output: HumanResult,
|
|
183
|
+
},
|
|
184
|
+
/** Read the Session's open asks. */
|
|
185
|
+
list: {
|
|
186
|
+
/** The Session owns the ask collection. */
|
|
187
|
+
scope: "session",
|
|
188
|
+
/** No additional arguments are required. */
|
|
189
|
+
input: Schema.Struct({}),
|
|
190
|
+
/** Decode the currently visible asks. */
|
|
191
|
+
output: AskProjection,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
/** Open asks visible to Session clients. */
|
|
195
|
+
projection: {
|
|
196
|
+
/** Decoder for projected asks. */
|
|
197
|
+
schema: AskProjection,
|
|
112
198
|
},
|
|
113
|
-
projection: { schema: AskProjection },
|
|
114
199
|
};
|