@fungi.computer/shiitake-extensions 0.2.0 → 0.4.0
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 +33 -21
- package/dist/goal/contract.d.ts +27 -8
- package/dist/goal/contract.js +20 -3
- package/dist/goal/host.d.ts +4 -1
- package/dist/goal/host.js +375 -128
- package/dist/goal/prompts.d.ts +73 -0
- package/dist/goal/prompts.js +98 -0
- package/dist/home/host.js +9 -3
- package/dist/internal/headline.d.ts +7 -0
- package/dist/internal/headline.js +18 -0
- package/dist/loop/client.js +1 -1
- package/dist/loop/contract.d.ts +6 -2
- package/dist/loop/contract.js +10 -1
- package/dist/loop/host.js +10 -12
- package/dist/loop/prompts.d.ts +56 -0
- package/dist/loop/prompts.js +54 -0
- package/dist/question/answer-flow.d.ts +27 -0
- package/dist/question/answer-flow.js +115 -0
- package/dist/question/client.d.ts +1 -1
- package/dist/question/client.js +22 -3
- package/dist/question/contract.d.ts +202 -60
- package/dist/question/contract.js +78 -22
- package/dist/question/host.d.ts +4 -0
- package/dist/question/host.js +348 -304
- package/dist/roster/conversation-agents.d.ts +22 -15
- package/dist/roster/conversation-agents.js +161 -37
- package/dist/roster.d.ts +8 -2
- package/dist/roster.js +33 -6
- package/dist/skills/host.js +20 -2
- package/dist/subagents/client.js +64 -20
- package/dist/subagents/contract.d.ts +123 -10
- package/dist/subagents/contract.js +38 -5
- package/dist/subagents/host.d.ts +5 -5
- package/dist/subagents/host.js +152 -22
- package/docs/api/goal/contract.md +5 -2
- package/docs/api/goal/host.md +22 -1
- package/docs/api/home/host.md +6 -5
- package/docs/api/loop/contract.md +5 -2
- package/docs/api/question/client.md +2 -1
- package/docs/api/question/contract.md +183 -51
- package/docs/api/question/host.md +30 -0
- package/docs/api/roster/conversation-agents.md +15 -7
- package/docs/api/roster.md +39 -2
- package/docs/api/subagents/contract.md +101 -28
- package/docs/api/subagents/host.md +5 -2
- package/package.json +5 -6
|
@@ -41,6 +41,16 @@ export type Question = Schema.Schema.Type<typeof Question>;
|
|
|
41
41
|
export declare const OpenAsk: Schema.Struct<{
|
|
42
42
|
/** Durable identity of the open ask. */
|
|
43
43
|
readonly askId: Schema.String;
|
|
44
|
+
/**
|
|
45
|
+
* The Agent this ask waits on first, derived by the host from whom the
|
|
46
|
+
* asking run's work came from. Absent means a person. An ask waiting on an
|
|
47
|
+
* Agent is calm: the Agent answers it or escalates it to a person.
|
|
48
|
+
*/
|
|
49
|
+
readonly waitingOn: Schema.optionalKey<Schema.Struct<{
|
|
50
|
+
readonly agentId: Schema.NonEmptyString;
|
|
51
|
+
readonly sessionId: Schema.NonEmptyString;
|
|
52
|
+
readonly name: Schema.NonEmptyString;
|
|
53
|
+
}>>;
|
|
44
54
|
/** Decisions awaiting the person's answers. */
|
|
45
55
|
readonly questions: Schema.$Array<Schema.Struct<{
|
|
46
56
|
/** Identity used to associate this question with its answer. */
|
|
@@ -74,6 +84,16 @@ export declare const AskProjection: Schema.Struct<{
|
|
|
74
84
|
readonly asks: Schema.$Array<Schema.Struct<{
|
|
75
85
|
/** Durable identity of the open ask. */
|
|
76
86
|
readonly askId: Schema.String;
|
|
87
|
+
/**
|
|
88
|
+
* The Agent this ask waits on first, derived by the host from whom the
|
|
89
|
+
* asking run's work came from. Absent means a person. An ask waiting on an
|
|
90
|
+
* Agent is calm: the Agent answers it or escalates it to a person.
|
|
91
|
+
*/
|
|
92
|
+
readonly waitingOn: Schema.optionalKey<Schema.Struct<{
|
|
93
|
+
readonly agentId: Schema.NonEmptyString;
|
|
94
|
+
readonly sessionId: Schema.NonEmptyString;
|
|
95
|
+
readonly name: Schema.NonEmptyString;
|
|
96
|
+
}>>;
|
|
77
97
|
/** Decisions awaiting the person's answers. */
|
|
78
98
|
readonly questions: Schema.$Array<Schema.Struct<{
|
|
79
99
|
/** Identity used to associate this question with its answer. */
|
|
@@ -146,6 +166,8 @@ export declare const HumanResult: Schema.Union<readonly [Schema.Struct<{
|
|
|
146
166
|
readonly result: Schema.Literal<"accepted">;
|
|
147
167
|
/** Whether the reply resumed its turn or became a follow-up. */
|
|
148
168
|
readonly via: Schema.Literals<readonly ["in_turn", "follow_up"]>;
|
|
169
|
+
/** The follow-up command carrying the reply, when it became one. */
|
|
170
|
+
readonly commandId: Schema.optionalKey<Schema.String>;
|
|
149
171
|
}>, Schema.Struct<{
|
|
150
172
|
/** Ask had already reached a terminal state. */
|
|
151
173
|
readonly result: Schema.Literal<"closed">;
|
|
@@ -157,40 +179,80 @@ export declare const HumanResult: Schema.Union<readonly [Schema.Struct<{
|
|
|
157
179
|
}>]>;
|
|
158
180
|
/** Decoded outcome of a human answer or decline. */
|
|
159
181
|
export type HumanResult = Schema.Schema.Type<typeof HumanResult>;
|
|
160
|
-
/**
|
|
161
|
-
export declare const
|
|
162
|
-
/**
|
|
163
|
-
readonly
|
|
164
|
-
|
|
165
|
-
readonly
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
readonly
|
|
182
|
+
/** Only the Agent an Ask waits on may answer or escalate it. */
|
|
183
|
+
export declare const SenderRefusal: Schema.Struct<{
|
|
184
|
+
/** The caller is not the Agent this Ask waits on. */
|
|
185
|
+
readonly result: Schema.Literal<"refused">;
|
|
186
|
+
/** Explains why the Agent's response cannot be applied. */
|
|
187
|
+
readonly reason: Schema.Literal<"not_sender">;
|
|
188
|
+
}>;
|
|
189
|
+
/** Outcome of the Agent an Ask waits on answering it. */
|
|
190
|
+
export declare const AgentAnswerResult: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
191
|
+
/** Reply was accepted. */
|
|
192
|
+
readonly result: Schema.Literal<"accepted">;
|
|
193
|
+
/** Whether the reply resumed its turn or became a follow-up. */
|
|
194
|
+
readonly via: Schema.Literals<readonly ["in_turn", "follow_up"]>;
|
|
195
|
+
/** The follow-up command carrying the reply, when it became one. */
|
|
196
|
+
readonly commandId: Schema.optionalKey<Schema.String>;
|
|
197
|
+
}>, Schema.Struct<{
|
|
198
|
+
/** Ask had already reached a terminal state. */
|
|
199
|
+
readonly result: Schema.Literal<"closed">;
|
|
200
|
+
/** Terminal state that prevented another answer. */
|
|
201
|
+
readonly status: Schema.Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>;
|
|
175
202
|
}>, Schema.Struct<{
|
|
176
|
-
/**
|
|
177
|
-
readonly
|
|
203
|
+
/** No ask with this identity exists. */
|
|
204
|
+
readonly result: Schema.Literal<"not_found">;
|
|
205
|
+
}>]>, Schema.Struct<{
|
|
206
|
+
/** The caller is not the Agent this Ask waits on. */
|
|
207
|
+
readonly result: Schema.Literal<"refused">;
|
|
208
|
+
/** Explains why the Agent's response cannot be applied. */
|
|
209
|
+
readonly reason: Schema.Literal<"not_sender">;
|
|
210
|
+
}>]>;
|
|
211
|
+
/** Decoded result of an authenticated Agent answer. */
|
|
212
|
+
export type AgentAnswerResult = Schema.Schema.Type<typeof AgentAnswerResult>;
|
|
213
|
+
/** The Agent that answered, as the host authenticated it. */
|
|
214
|
+
export declare const AnsweredBy: Schema.Struct<{
|
|
215
|
+
/** Identifies an Agent, never a person. */
|
|
216
|
+
readonly kind: Schema.Literal<"agent">;
|
|
217
|
+
/** Stable identity of the authenticated Agent. */
|
|
218
|
+
readonly agentId: Schema.String;
|
|
219
|
+
}>;
|
|
220
|
+
/** Outcome of the Agent an Ask waits on passing it on. */
|
|
221
|
+
export declare const EscalateResult: Schema.Union<readonly [Schema.Struct<{
|
|
222
|
+
/** The Ask now waits on someone else. */
|
|
223
|
+
readonly result: Schema.Literal<"escalated">;
|
|
224
|
+
/** Whom it waits on now: a person. */
|
|
225
|
+
readonly to: Schema.Literal<"person">;
|
|
226
|
+
}>, Schema.Struct<{
|
|
227
|
+
/** Ask had already reached a terminal state. */
|
|
228
|
+
readonly result: Schema.Literal<"closed">;
|
|
229
|
+
/** Terminal state that prevented the escalation. */
|
|
230
|
+
readonly status: Schema.Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>;
|
|
231
|
+
}>, Schema.Struct<{
|
|
232
|
+
/** No ask with this identity exists. */
|
|
233
|
+
readonly result: Schema.Literal<"not_found">;
|
|
234
|
+
}>, Schema.Struct<{
|
|
235
|
+
/** The caller is not the Agent this Ask waits on. */
|
|
236
|
+
readonly result: Schema.Literal<"refused">;
|
|
237
|
+
/** Explains why the Agent's response cannot be applied. */
|
|
238
|
+
readonly reason: Schema.Literal<"not_sender">;
|
|
239
|
+
}>]>;
|
|
240
|
+
/** Decoded result of passing an Ask on. */
|
|
241
|
+
export type EscalateResult = Schema.Schema.Type<typeof EscalateResult>;
|
|
242
|
+
/** The Agent's request to pass an Ask on; the caller is host context. */
|
|
243
|
+
export declare const EscalateInput: Schema.Struct<{
|
|
244
|
+
/** Ask being passed on. */
|
|
178
245
|
readonly askId: Schema.String;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
246
|
+
}>;
|
|
247
|
+
/** The answer conversation carries its draft between decision steps. */
|
|
248
|
+
export declare const AnswerFlowInput: Schema.Union<readonly [Schema.Struct<{
|
|
249
|
+
/** The person's picks and optional written answer for question `index`. */
|
|
250
|
+
readonly answer: Schema.Struct<{
|
|
182
251
|
/** Labels of the offered choices selected by the person. */
|
|
183
252
|
readonly selected: Schema.$Array<Schema.String>;
|
|
184
253
|
/** Optional free-text answer supplied by the person. */
|
|
185
254
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
186
|
-
}
|
|
187
|
-
/** Single-choice selection step. */
|
|
188
|
-
readonly stage: Schema.Literal<"selection">;
|
|
189
|
-
}>, Schema.Struct<{
|
|
190
|
-
/** Offered choices retained while entering free text. */
|
|
191
|
-
readonly selected: Schema.$Array<Schema.String>;
|
|
192
|
-
/** Free-text answer supplied by the person. */
|
|
193
|
-
readonly text: Schema.String;
|
|
255
|
+
}>;
|
|
194
256
|
readonly askId: Schema.String;
|
|
195
257
|
readonly requestId: Schema.String;
|
|
196
258
|
readonly index: Schema.Number;
|
|
@@ -200,8 +262,8 @@ export declare const AnswerFlowInput: Schema.Union<readonly [Schema.Struct<{
|
|
|
200
262
|
/** Optional free-text answer supplied by the person. */
|
|
201
263
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
202
264
|
}>>;
|
|
203
|
-
/**
|
|
204
|
-
readonly stage: Schema.Literal<"
|
|
265
|
+
/** One decision answered in the composer. */
|
|
266
|
+
readonly stage: Schema.Literal<"decision">;
|
|
205
267
|
}>, Schema.Struct<{
|
|
206
268
|
/** Ask whose answer conversation should be opened. */
|
|
207
269
|
readonly askId: Schema.String;
|
|
@@ -218,38 +280,13 @@ export declare const questionContract: {
|
|
|
218
280
|
readonly scope: "session";
|
|
219
281
|
/** Decode the current answer-draft step. */
|
|
220
282
|
readonly input: Schema.Union<readonly [Schema.Struct<{
|
|
221
|
-
/**
|
|
222
|
-
readonly
|
|
223
|
-
readonly askId: Schema.String;
|
|
224
|
-
readonly requestId: Schema.String;
|
|
225
|
-
readonly index: Schema.Number;
|
|
226
|
-
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
283
|
+
/** The person's picks and optional written answer for question `index`. */
|
|
284
|
+
readonly answer: Schema.Struct<{
|
|
227
285
|
/** Labels of the offered choices selected by the person. */
|
|
228
286
|
readonly selected: Schema.$Array<Schema.String>;
|
|
229
287
|
/** Optional free-text answer supplied by the person. */
|
|
230
288
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
231
|
-
}
|
|
232
|
-
/** Multiple-choice selection step. */
|
|
233
|
-
readonly stage: Schema.Literal<"multiple">;
|
|
234
|
-
}>, Schema.Struct<{
|
|
235
|
-
/** Encoded selection supplied by the human control. */
|
|
236
|
-
readonly selection: Schema.String;
|
|
237
|
-
readonly askId: Schema.String;
|
|
238
|
-
readonly requestId: Schema.String;
|
|
239
|
-
readonly index: Schema.Number;
|
|
240
|
-
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
241
|
-
/** Labels of the offered choices selected by the person. */
|
|
242
|
-
readonly selected: Schema.$Array<Schema.String>;
|
|
243
|
-
/** Optional free-text answer supplied by the person. */
|
|
244
|
-
readonly text: Schema.optionalKey<Schema.String>;
|
|
245
|
-
}>>;
|
|
246
|
-
/** Single-choice selection step. */
|
|
247
|
-
readonly stage: Schema.Literal<"selection">;
|
|
248
|
-
}>, Schema.Struct<{
|
|
249
|
-
/** Offered choices retained while entering free text. */
|
|
250
|
-
readonly selected: Schema.$Array<Schema.String>;
|
|
251
|
-
/** Free-text answer supplied by the person. */
|
|
252
|
-
readonly text: Schema.String;
|
|
289
|
+
}>;
|
|
253
290
|
readonly askId: Schema.String;
|
|
254
291
|
readonly requestId: Schema.String;
|
|
255
292
|
readonly index: Schema.Number;
|
|
@@ -259,8 +296,8 @@ export declare const questionContract: {
|
|
|
259
296
|
/** Optional free-text answer supplied by the person. */
|
|
260
297
|
readonly text: Schema.optionalKey<Schema.String>;
|
|
261
298
|
}>>;
|
|
262
|
-
/**
|
|
263
|
-
readonly stage: Schema.Literal<"
|
|
299
|
+
/** One decision answered in the composer. */
|
|
300
|
+
readonly stage: Schema.Literal<"decision">;
|
|
264
301
|
}>, Schema.Struct<{
|
|
265
302
|
/** Ask whose answer conversation should be opened. */
|
|
266
303
|
readonly askId: Schema.String;
|
|
@@ -292,6 +329,8 @@ export declare const questionContract: {
|
|
|
292
329
|
readonly result: Schema.Literal<"accepted">;
|
|
293
330
|
/** Whether the reply resumed its turn or became a follow-up. */
|
|
294
331
|
readonly via: Schema.Literals<readonly ["in_turn", "follow_up"]>;
|
|
332
|
+
/** The follow-up command carrying the reply, when it became one. */
|
|
333
|
+
readonly commandId: Schema.optionalKey<Schema.String>;
|
|
295
334
|
}>, Schema.Struct<{
|
|
296
335
|
/** Ask had already reached a terminal state. */
|
|
297
336
|
readonly result: Schema.Literal<"closed">;
|
|
@@ -302,6 +341,87 @@ export declare const questionContract: {
|
|
|
302
341
|
readonly result: Schema.Literal<"not_found">;
|
|
303
342
|
}>]>;
|
|
304
343
|
};
|
|
344
|
+
/** Submit the answer of the Agent this Ask waits on; never a human answer. */
|
|
345
|
+
readonly answerAgent: {
|
|
346
|
+
/** The child Session owns the Ask; caller authority is host context. */
|
|
347
|
+
readonly scope: "session";
|
|
348
|
+
/** Decode the answer submission without any caller-supplied actor. */
|
|
349
|
+
readonly input: Schema.Struct<{
|
|
350
|
+
/** Ask being answered. */
|
|
351
|
+
readonly askId: Schema.String;
|
|
352
|
+
/** Stable identity shared by this command and its retries. */
|
|
353
|
+
readonly requestId: Schema.String;
|
|
354
|
+
/** Answers to the ask's question set. */
|
|
355
|
+
readonly answers: Schema.$Record<Schema.String, Schema.Struct<{
|
|
356
|
+
/** Labels of the offered choices selected by the person. */
|
|
357
|
+
readonly selected: Schema.$Array<Schema.String>;
|
|
358
|
+
/** Optional free-text answer supplied by the person. */
|
|
359
|
+
readonly text: Schema.optionalKey<Schema.String>;
|
|
360
|
+
}>>;
|
|
361
|
+
}>;
|
|
362
|
+
/** Attribute the accepted answer to its authenticated Agent. */
|
|
363
|
+
readonly output: Schema.Struct<{
|
|
364
|
+
/** Whether the answer was accepted, or why not. */
|
|
365
|
+
readonly result: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
366
|
+
/** Reply was accepted. */
|
|
367
|
+
readonly result: Schema.Literal<"accepted">;
|
|
368
|
+
/** Whether the reply resumed its turn or became a follow-up. */
|
|
369
|
+
readonly via: Schema.Literals<readonly ["in_turn", "follow_up"]>;
|
|
370
|
+
/** The follow-up command carrying the reply, when it became one. */
|
|
371
|
+
readonly commandId: Schema.optionalKey<Schema.String>;
|
|
372
|
+
}>, Schema.Struct<{
|
|
373
|
+
/** Ask had already reached a terminal state. */
|
|
374
|
+
readonly result: Schema.Literal<"closed">;
|
|
375
|
+
/** Terminal state that prevented another answer. */
|
|
376
|
+
readonly status: Schema.Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>;
|
|
377
|
+
}>, Schema.Struct<{
|
|
378
|
+
/** No ask with this identity exists. */
|
|
379
|
+
readonly result: Schema.Literal<"not_found">;
|
|
380
|
+
}>]>, Schema.Struct<{
|
|
381
|
+
/** The caller is not the Agent this Ask waits on. */
|
|
382
|
+
readonly result: Schema.Literal<"refused">;
|
|
383
|
+
/** Explains why the Agent's response cannot be applied. */
|
|
384
|
+
readonly reason: Schema.Literal<"not_sender">;
|
|
385
|
+
}>]>;
|
|
386
|
+
/** The authenticated Agent that answered. */
|
|
387
|
+
readonly answeredBy: Schema.Struct<{
|
|
388
|
+
/** Identifies an Agent, never a person. */
|
|
389
|
+
readonly kind: Schema.Literal<"agent">;
|
|
390
|
+
/** Stable identity of the authenticated Agent. */
|
|
391
|
+
readonly agentId: Schema.String;
|
|
392
|
+
}>;
|
|
393
|
+
}>;
|
|
394
|
+
};
|
|
395
|
+
/** Pass the Ask on from the Agent it waits on; never a human action. */
|
|
396
|
+
readonly escalateAgent: {
|
|
397
|
+
/** The child Session owns the Ask; caller authority is host context. */
|
|
398
|
+
readonly scope: "session";
|
|
399
|
+
/** Decode the escalation without any caller-supplied recipient. */
|
|
400
|
+
readonly input: Schema.Struct<{
|
|
401
|
+
/** Ask being passed on. */
|
|
402
|
+
readonly askId: Schema.String;
|
|
403
|
+
}>;
|
|
404
|
+
/** Where the Ask waits now, or why it did not move. */
|
|
405
|
+
readonly output: Schema.Union<readonly [Schema.Struct<{
|
|
406
|
+
/** The Ask now waits on someone else. */
|
|
407
|
+
readonly result: Schema.Literal<"escalated">;
|
|
408
|
+
/** Whom it waits on now: a person. */
|
|
409
|
+
readonly to: Schema.Literal<"person">;
|
|
410
|
+
}>, Schema.Struct<{
|
|
411
|
+
/** Ask had already reached a terminal state. */
|
|
412
|
+
readonly result: Schema.Literal<"closed">;
|
|
413
|
+
/** Terminal state that prevented the escalation. */
|
|
414
|
+
readonly status: Schema.Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>;
|
|
415
|
+
}>, Schema.Struct<{
|
|
416
|
+
/** No ask with this identity exists. */
|
|
417
|
+
readonly result: Schema.Literal<"not_found">;
|
|
418
|
+
}>, Schema.Struct<{
|
|
419
|
+
/** The caller is not the Agent this Ask waits on. */
|
|
420
|
+
readonly result: Schema.Literal<"refused">;
|
|
421
|
+
/** Explains why the Agent's response cannot be applied. */
|
|
422
|
+
readonly reason: Schema.Literal<"not_sender">;
|
|
423
|
+
}>]>;
|
|
424
|
+
};
|
|
305
425
|
/** Decline an ask with an optional note. */
|
|
306
426
|
readonly decline: {
|
|
307
427
|
/** The Session owns this ask. */
|
|
@@ -321,6 +441,8 @@ export declare const questionContract: {
|
|
|
321
441
|
readonly result: Schema.Literal<"accepted">;
|
|
322
442
|
/** Whether the reply resumed its turn or became a follow-up. */
|
|
323
443
|
readonly via: Schema.Literals<readonly ["in_turn", "follow_up"]>;
|
|
444
|
+
/** The follow-up command carrying the reply, when it became one. */
|
|
445
|
+
readonly commandId: Schema.optionalKey<Schema.String>;
|
|
324
446
|
}>, Schema.Struct<{
|
|
325
447
|
/** Ask had already reached a terminal state. */
|
|
326
448
|
readonly result: Schema.Literal<"closed">;
|
|
@@ -343,6 +465,16 @@ export declare const questionContract: {
|
|
|
343
465
|
readonly asks: Schema.$Array<Schema.Struct<{
|
|
344
466
|
/** Durable identity of the open ask. */
|
|
345
467
|
readonly askId: Schema.String;
|
|
468
|
+
/**
|
|
469
|
+
* The Agent this ask waits on first, derived by the host from whom the
|
|
470
|
+
* asking run's work came from. Absent means a person. An ask waiting on an
|
|
471
|
+
* Agent is calm: the Agent answers it or escalates it to a person.
|
|
472
|
+
*/
|
|
473
|
+
readonly waitingOn: Schema.optionalKey<Schema.Struct<{
|
|
474
|
+
readonly agentId: Schema.NonEmptyString;
|
|
475
|
+
readonly sessionId: Schema.NonEmptyString;
|
|
476
|
+
readonly name: Schema.NonEmptyString;
|
|
477
|
+
}>>;
|
|
346
478
|
/** Decisions awaiting the person's answers. */
|
|
347
479
|
readonly questions: Schema.$Array<Schema.Struct<{
|
|
348
480
|
/** Identity used to associate this question with its answer. */
|
|
@@ -379,6 +511,16 @@ export declare const questionContract: {
|
|
|
379
511
|
readonly asks: Schema.$Array<Schema.Struct<{
|
|
380
512
|
/** Durable identity of the open ask. */
|
|
381
513
|
readonly askId: Schema.String;
|
|
514
|
+
/**
|
|
515
|
+
* The Agent this ask waits on first, derived by the host from whom the
|
|
516
|
+
* asking run's work came from. Absent means a person. An ask waiting on an
|
|
517
|
+
* Agent is calm: the Agent answers it or escalates it to a person.
|
|
518
|
+
*/
|
|
519
|
+
readonly waitingOn: Schema.optionalKey<Schema.Struct<{
|
|
520
|
+
readonly agentId: Schema.NonEmptyString;
|
|
521
|
+
readonly sessionId: Schema.NonEmptyString;
|
|
522
|
+
readonly name: Schema.NonEmptyString;
|
|
523
|
+
}>>;
|
|
382
524
|
/** Decisions awaiting the person's answers. */
|
|
383
525
|
readonly questions: Schema.$Array<Schema.Struct<{
|
|
384
526
|
/** Identity used to associate this question with its answer. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtensionId } from "@fungi.computer/shiitake/extensions";
|
|
1
|
+
import { AttentionRecipientSchema, ExtensionId, } from "@fungi.computer/shiitake/extensions";
|
|
2
2
|
import * as Schema from "effect/Schema";
|
|
3
3
|
import { CatalogStep } from "../internal/catalog.js";
|
|
4
4
|
const text = (maximum) => Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(maximum), Schema.isPattern(/\S/u));
|
|
@@ -38,6 +38,12 @@ export const Questions = Schema.Array(Question).check(Schema.isMinLength(1), Sch
|
|
|
38
38
|
export const OpenAsk = Schema.Struct({
|
|
39
39
|
/** Durable identity of the open ask. */
|
|
40
40
|
askId: Schema.String,
|
|
41
|
+
/**
|
|
42
|
+
* The Agent this ask waits on first, derived by the host from whom the
|
|
43
|
+
* asking run's work came from. Absent means a person. An ask waiting on an
|
|
44
|
+
* Agent is calm: the Agent answers it or escalates it to a person.
|
|
45
|
+
*/
|
|
46
|
+
waitingOn: Schema.optionalKey(AttentionRecipientSchema),
|
|
41
47
|
/** Decisions awaiting the person's answers. */
|
|
42
48
|
questions: Questions,
|
|
43
49
|
/** Whether the ask is live in a turn or parked for later. */
|
|
@@ -95,6 +101,8 @@ export const HumanResult = Schema.Union([
|
|
|
95
101
|
result: Schema.Literal("accepted"),
|
|
96
102
|
/** Whether the reply resumed its turn or became a follow-up. */
|
|
97
103
|
via: Schema.Literals(["in_turn", "follow_up"]),
|
|
104
|
+
/** The follow-up command carrying the reply, when it became one. */
|
|
105
|
+
commandId: Schema.optionalKey(text(256)),
|
|
98
106
|
}),
|
|
99
107
|
Schema.Struct({
|
|
100
108
|
/** Ask had already reached a terminal state. */
|
|
@@ -107,6 +115,47 @@ export const HumanResult = Schema.Union([
|
|
|
107
115
|
result: Schema.Literal("not_found"),
|
|
108
116
|
}),
|
|
109
117
|
]);
|
|
118
|
+
/** Only the Agent an Ask waits on may answer or escalate it. */
|
|
119
|
+
export const SenderRefusal = Schema.Struct({
|
|
120
|
+
/** The caller is not the Agent this Ask waits on. */
|
|
121
|
+
result: Schema.Literal("refused"),
|
|
122
|
+
/** Explains why the Agent's response cannot be applied. */
|
|
123
|
+
reason: Schema.Literal("not_sender"),
|
|
124
|
+
});
|
|
125
|
+
/** Outcome of the Agent an Ask waits on answering it. */
|
|
126
|
+
export const AgentAnswerResult = Schema.Union([HumanResult, SenderRefusal]);
|
|
127
|
+
/** The Agent that answered, as the host authenticated it. */
|
|
128
|
+
export const AnsweredBy = Schema.Struct({
|
|
129
|
+
/** Identifies an Agent, never a person. */
|
|
130
|
+
kind: Schema.Literal("agent"),
|
|
131
|
+
/** Stable identity of the authenticated Agent. */
|
|
132
|
+
agentId: text(256),
|
|
133
|
+
});
|
|
134
|
+
/** Outcome of the Agent an Ask waits on passing it on. */
|
|
135
|
+
export const EscalateResult = Schema.Union([
|
|
136
|
+
Schema.Struct({
|
|
137
|
+
/** The Ask now waits on someone else. */
|
|
138
|
+
result: Schema.Literal("escalated"),
|
|
139
|
+
/** Whom it waits on now: a person. */
|
|
140
|
+
to: Schema.Literal("person"),
|
|
141
|
+
}),
|
|
142
|
+
Schema.Struct({
|
|
143
|
+
/** Ask had already reached a terminal state. */
|
|
144
|
+
result: Schema.Literal("closed"),
|
|
145
|
+
/** Terminal state that prevented the escalation. */
|
|
146
|
+
status: ClosedStatus,
|
|
147
|
+
}),
|
|
148
|
+
Schema.Struct({
|
|
149
|
+
/** No ask with this identity exists. */
|
|
150
|
+
result: Schema.Literal("not_found"),
|
|
151
|
+
}),
|
|
152
|
+
SenderRefusal,
|
|
153
|
+
]);
|
|
154
|
+
/** The Agent's request to pass an Ask on; the caller is host context. */
|
|
155
|
+
export const EscalateInput = Schema.Struct({
|
|
156
|
+
/** Ask being passed on. */
|
|
157
|
+
askId: text(256),
|
|
158
|
+
});
|
|
110
159
|
const answerStep = {
|
|
111
160
|
/** Ask whose answer draft is being edited. */
|
|
112
161
|
askId: AnswerInput.fields.askId,
|
|
@@ -117,30 +166,14 @@ const answerStep = {
|
|
|
117
166
|
/** Answers accumulated by preceding conversation steps. */
|
|
118
167
|
answers: Answers,
|
|
119
168
|
};
|
|
120
|
-
/** The
|
|
169
|
+
/** The answer conversation carries its draft between decision steps. */
|
|
121
170
|
export const AnswerFlowInput = Schema.Union([
|
|
122
171
|
Schema.Struct({
|
|
123
|
-
/**
|
|
124
|
-
stage: Schema.Literal("
|
|
172
|
+
/** One decision answered in the composer. */
|
|
173
|
+
stage: Schema.Literal("decision"),
|
|
125
174
|
...answerStep,
|
|
126
|
-
/**
|
|
127
|
-
|
|
128
|
-
}),
|
|
129
|
-
Schema.Struct({
|
|
130
|
-
/** Single-choice selection step. */
|
|
131
|
-
stage: Schema.Literal("selection"),
|
|
132
|
-
...answerStep,
|
|
133
|
-
/** Encoded selection supplied by the human control. */
|
|
134
|
-
selection: Schema.String.check(Schema.isMaxLength(1_000)),
|
|
135
|
-
}),
|
|
136
|
-
Schema.Struct({
|
|
137
|
-
/** Free-text answer step. */
|
|
138
|
-
stage: Schema.Literal("text"),
|
|
139
|
-
...answerStep,
|
|
140
|
-
/** Offered choices retained while entering free text. */
|
|
141
|
-
selected: Answers.value.fields.selected,
|
|
142
|
-
/** Free-text answer supplied by the person. */
|
|
143
|
-
text: Schema.String.check(Schema.isMaxLength(4_000)),
|
|
175
|
+
/** The person's picks and optional written answer for question `index`. */
|
|
176
|
+
answer: Answers.value,
|
|
144
177
|
}),
|
|
145
178
|
Schema.Struct({
|
|
146
179
|
/** Ask whose answer conversation should be opened. */
|
|
@@ -172,6 +205,29 @@ export const questionContract = {
|
|
|
172
205
|
/** Return admission or the ask's terminal state. */
|
|
173
206
|
output: HumanResult,
|
|
174
207
|
},
|
|
208
|
+
/** Submit the answer of the Agent this Ask waits on; never a human answer. */
|
|
209
|
+
answerAgent: {
|
|
210
|
+
/** The child Session owns the Ask; caller authority is host context. */
|
|
211
|
+
scope: "session",
|
|
212
|
+
/** Decode the answer submission without any caller-supplied actor. */
|
|
213
|
+
input: AnswerInput,
|
|
214
|
+
/** Attribute the accepted answer to its authenticated Agent. */
|
|
215
|
+
output: Schema.Struct({
|
|
216
|
+
/** Whether the answer was accepted, or why not. */
|
|
217
|
+
result: AgentAnswerResult,
|
|
218
|
+
/** The authenticated Agent that answered. */
|
|
219
|
+
answeredBy: AnsweredBy,
|
|
220
|
+
}),
|
|
221
|
+
},
|
|
222
|
+
/** Pass the Ask on from the Agent it waits on; never a human action. */
|
|
223
|
+
escalateAgent: {
|
|
224
|
+
/** The child Session owns the Ask; caller authority is host context. */
|
|
225
|
+
scope: "session",
|
|
226
|
+
/** Decode the escalation without any caller-supplied recipient. */
|
|
227
|
+
input: EscalateInput,
|
|
228
|
+
/** Where the Ask waits now, or why it did not move. */
|
|
229
|
+
output: EscalateResult,
|
|
230
|
+
},
|
|
175
231
|
/** Decline an ask with an optional note. */
|
|
176
232
|
decline: {
|
|
177
233
|
/** The Session owns this ask. */
|
package/dist/question/host.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { type RosteredExtensionV0 } from "@fungi.computer/shiitake/extensions";
|
|
2
2
|
/** One durable question owner over the ordinary extension doors. */
|
|
3
|
+
export declare function questionExtensionFor(routesToSender: boolean): RosteredExtensionV0;
|
|
4
|
+
/** Hub's shared roster sends every Ask to a person. */
|
|
3
5
|
export declare const questionExtension: RosteredExtensionV0;
|
|
6
|
+
/** Local's roster sends an Ask to the Agent that sent the asking work first. */
|
|
7
|
+
export declare const localQuestionExtension: RosteredExtensionV0;
|