@fungi.computer/shiitake-extensions 0.3.0 → 0.5.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 +20 -16
- package/dist/goal/contract.d.ts +6 -0
- package/dist/goal/contract.js +6 -0
- package/dist/goal/host.js +183 -31
- package/dist/loop/contract.d.ts +136 -2
- package/dist/loop/contract.js +45 -2
- package/dist/loop/host.js +23 -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 -339
- package/dist/roster/conversation-agents.d.ts +21 -1
- package/dist/roster/conversation-agents.js +47 -2
- package/dist/roster.d.ts +5 -2
- package/dist/roster.js +16 -5
- package/dist/schedules.d.ts +178 -0
- package/dist/schedules.js +182 -0
- 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 +2 -4
- package/dist/subagents/host.js +152 -22
- package/docs/api/README.md +1 -0
- package/docs/api/goal/contract.md +1 -1
- package/docs/api/goal/host.md +22 -1
- package/docs/api/loop/contract.md +43 -31
- 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 +34 -8
- package/docs/api/roster.md +39 -2
- package/docs/api/schedules.md +481 -0
- package/docs/api/subagents/contract.md +101 -28
- package/docs/api/subagents/host.md +5 -3
- package/package.json +9 -6
|
@@ -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;
|