@fungi.computer/shiitake-extensions 0.6.5 → 0.6.7
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 +30 -17
- package/dist/goal/client.js +6 -2
- package/dist/goal/contract.d.ts +98 -10
- package/dist/goal/contract.js +50 -1
- package/dist/goal/host.js +68 -13
- package/dist/goal/prompts.js +1 -0
- package/dist/question/client.js +13 -2
- package/dist/question/contract.d.ts +70 -4
- package/dist/question/contract.js +14 -2
- package/dist/question/host.js +224 -122
- package/dist/subagents/client.js +28 -10
- package/dist/subagents/contract.d.ts +93 -0
- package/dist/subagents/contract.js +49 -0
- package/dist/subagents/host.d.ts +3 -3
- package/dist/subagents/host.js +77 -14
- package/dist/subagents/presentation.d.ts +4 -0
- package/dist/subagents/presentation.js +9 -0
- package/docs/api/goal/contract.md +35 -26
- package/docs/api/question/contract.md +62 -30
- package/docs/api/subagents/contract.md +51 -14
- package/docs/api/subagents/host.md +4 -4
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -65,16 +65,16 @@ helper borrows the Agent. Its owner closes it when the host's lifetime ends.
|
|
|
65
65
|
|
|
66
66
|
## Core concepts
|
|
67
67
|
|
|
68
|
-
| Extension | Ownership and behavior
|
|
69
|
-
| --------- |
|
|
70
|
-
| Ask | Up to four open decisions per Session. The model asks or withdraws; humans answer or decline. A live waiter receives the answer
|
|
71
|
-
| Goal | One live or paused objective per Session. The model creates, reads and completes it through `goal.*` tools, from any later turn of its Session; humans set, pause, resume or clear it. Esc, failed work, a block or three tool-less continuations pause it; a tool-less goal turn while a sub-agent command is live waits instead. Closing the app pauses it only if work stops without resuming; background work and runtime-auto-resumed turns keep it live. An achieved or cleared goal becomes one chat line in its history.
|
|
72
|
-
| Loop | One repeated prompt per Session. It runs on a fixed cron cadence or lets its own active run request the next occurrence. Commands start, pause, resume and stop it.
|
|
73
|
-
| Plan | One checklist per Session. `plan.update_plan` replaces it whole, with at most one step in progress and at most 50 steps; `steps: []` clears it. The human clears it with `/plan clear` or the footer row's Clear plan action, through the same owner. `/plan` opens the full checklist in the footer; updates keep only the current step and progress visible, and a finished or cleared plan leaves the footer while its history stays in state.
|
|
74
|
-
| Almanac | Agent-scope one-shot or recurring schedules. Each schedule targets a Session and tracks admission, retry and its next due time.
|
|
75
|
-
| Skills | Host-supplied, read-only skill discovery. Metadata enters the prompt; `skill.load` reads a skill body or supporting file; `/skills` lists them.
|
|
76
|
-
| Home | Agent-scope choice of an attached Computer. Each run captures its scoped file tools and current attachment choice.
|
|
77
|
-
| Subagents | A footer view: one row per Agent this Session sent work to or created, with its live status (working, waiting on an Agent, needs you, idle, failed, unavailable). A row opens that Agent's conversation, a question that needs a person can be answered from its row, and `/agents` collapses the rows to one summary row and expands them again. It owns no relationship and no durable state.
|
|
68
|
+
| Extension | Ownership and behavior |
|
|
69
|
+
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
70
|
+
| Ask | Up to four open decisions per Session. The model asks or withdraws; humans answer or decline. A live waiter receives the answer; a parked question resumes through one follow-up. On Local, delegated work and extension turns in a delegated Session wait on the parent first, read `waiting on <name>` and report `waiting_on_you`. The exact receiving Session answers with `agents.answer` or bubbles to its own parent with `agents.escalate`; only a root or gone parent reaches a person. Silence never escalates: at most two Local reminders, then quiet waiting. Durable fifteen-minute checks promote only an archived or absent sender, never an unknown one. Asker expiry follows its chosen action. Hub sends every Ask to a person. |
|
|
71
|
+
| Goal | One live or paused objective per Session. The model creates, reads and completes it through `goal.*` tools, from any later turn of its Session; humans set, pause, resume or clear it. Esc, failed work, a block or three tool-less continuations pause it; a tool-less goal turn while a sub-agent command is live waits instead. Closing the app pauses it only if work stops without resuming; background work and runtime-auto-resumed turns keep it live. An achieved or cleared goal becomes one chat line in its history. |
|
|
72
|
+
| Loop | One repeated prompt per Session. It runs on a fixed cron cadence or lets its own active run request the next occurrence. Commands start, pause, resume and stop it. |
|
|
73
|
+
| Plan | One checklist per Session. `plan.update_plan` replaces it whole, with at most one step in progress and at most 50 steps; `steps: []` clears it. The human clears it with `/plan clear` or the footer row's Clear plan action, through the same owner. `/plan` opens the full checklist in the footer; updates keep only the current step and progress visible, and a finished or cleared plan leaves the footer while its history stays in state. |
|
|
74
|
+
| Almanac | Agent-scope one-shot or recurring schedules. Each schedule targets a Session and tracks admission, retry and its next due time. |
|
|
75
|
+
| Skills | Host-supplied, read-only skill discovery. Metadata enters the prompt; `skill.load` reads a skill body or supporting file; `/skills` lists them. |
|
|
76
|
+
| Home | Agent-scope choice of an attached Computer. Each run captures its scoped file tools and current attachment choice. |
|
|
77
|
+
| Subagents | A footer view: one row per Agent this Session sent work to or created, with its live status (working, waiting on an Agent, needs you, idle, failed, unavailable). A row opens that Agent's conversation, a question that needs a person can be answered from its row, and `/agents` collapses the rows to one summary row and expands them again. It owns no relationship and no durable state. |
|
|
78
78
|
|
|
79
79
|
An active Goal is quiet system context on every run. Continuation instructions
|
|
80
80
|
apply only to runs admitted by Goal with its continuation correlation; human
|
|
@@ -93,8 +93,13 @@ completion or blocking is provisional until successful settlement; a blocked
|
|
|
93
93
|
goal pauses and resumes like any paused goal. Each run's goal tools are fenced
|
|
94
94
|
by the goal revision that run saw, so a later follow-up command (for example a
|
|
95
95
|
parent's message to a sub-agent) can complete, block, clear or resume a goal
|
|
96
|
-
that paused on its own; a goal a person
|
|
97
|
-
completion from the model
|
|
96
|
+
that paused on its own; a goal a person or delegator paused accepts only
|
|
97
|
+
completion from the child model. The exact Session recorded as first delegator
|
|
98
|
+
may pause or clear the child's goal with `agents.goal`, retaining the clear's
|
|
99
|
+
reason and `clearedBy`; it may resume only a pause it imposed. Siblings and
|
|
100
|
+
other Sessions, including those that later sent work, are refused. Person
|
|
101
|
+
controls remain available to the owner and reject authenticated Agent callers.
|
|
102
|
+
An open decision waiting on an Agent also stops goal continuation. When a
|
|
98
103
|
tool-less goal turn ends while a recorded sub-agent command is live, the goal
|
|
99
104
|
raises `goal-waiting` attention and rechecks on a timer instead of counting a
|
|
100
105
|
stall; it continues once the child settles or replies. Only a live or paused
|
|
@@ -285,11 +290,19 @@ existing Agent access. Each child's status is its owner's own Session state:
|
|
|
285
290
|
`running` is working, `done` is idle and `errored` is failed. Attention that
|
|
286
291
|
waits on a person (a question, or an approval an extension raises) is
|
|
287
292
|
`needs you`; a question that waits on the Agent that sent the work is
|
|
288
|
-
`waiting on <name>`, calm until it is escalated
|
|
289
|
-
collapsed summary, which is amber only when a child needs a
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
+
`waiting on <name>`, calm until it is escalated past the Agent chain, and
|
|
294
|
+
counted apart in the collapsed summary, which is amber only when a child needs a
|
|
295
|
+
person. Counts cover up to 256 children, with at most eight owner reads in
|
|
296
|
+
flight, before the fifteen listed rows are selected. Needs-you, waiting-on-Agent
|
|
297
|
+
and working rows precede failed, unavailable and idle ones; ties retain the
|
|
298
|
+
source's newest order. Additional children are explicitly `not read`, never
|
|
299
|
+
silently counted as idle. An open decision takes precedence over a running or
|
|
300
|
+
errored Session: neither work nor failure hides an answerable item. Escalated
|
|
301
|
+
rows name who escalated, or whose archive/disappearance caused the promotion.
|
|
302
|
+
Collapsed summaries retain those names even beyond listed rows. A `needs you`
|
|
303
|
+
question carries its text and one Answer action that runs the question's own
|
|
304
|
+
answer conversation. A child whose state cannot be read is unavailable, never
|
|
305
|
+
idle.
|
|
293
306
|
|
|
294
307
|
Rows refresh when a watcher reads the parent Session and they are at least a
|
|
295
308
|
second old. While a row is working or waiting, they poll every five seconds
|
package/dist/goal/client.js
CHANGED
|
@@ -19,8 +19,12 @@ function currentRow(goal) {
|
|
|
19
19
|
const active = goal.state === "active";
|
|
20
20
|
const status = active
|
|
21
21
|
? `Pursuing goal since ${clockTime(goal.startedAt)}`
|
|
22
|
-
:
|
|
23
|
-
|
|
22
|
+
: goal.pauseCause?.kind === "delegator"
|
|
23
|
+
? `Goal paused by ${summary(goal.pauseCause.detail ?? "delegator")} (/goal resume)`
|
|
24
|
+
: "Goal paused (/goal resume)";
|
|
25
|
+
const reason = !active &&
|
|
26
|
+
goal.pauseCause?.kind !== "delegator" &&
|
|
27
|
+
goal.pauseCause?.detail != null
|
|
24
28
|
? [summary(goal.pauseCause.detail)]
|
|
25
29
|
: [];
|
|
26
30
|
const row = {
|
package/dist/goal/contract.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const GoalReason: Schema.String;
|
|
|
12
12
|
/** Why work paused, independent of the words shown to a person. */
|
|
13
13
|
export declare const GoalPauseCause: Schema.Struct<{
|
|
14
14
|
/** Typed origin of the pause. */
|
|
15
|
-
readonly kind: Schema.Literals<readonly ["person", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
15
|
+
readonly kind: Schema.Literals<readonly ["person", "delegator", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
16
16
|
/** Additional explanation, or null when no detail was supplied. */
|
|
17
17
|
readonly detail: Schema.NullOr<Schema.String>;
|
|
18
18
|
}>;
|
|
@@ -31,7 +31,7 @@ export declare const Goal: Schema.Struct<{
|
|
|
31
31
|
/** A typed cause while paused; null while active. */
|
|
32
32
|
readonly pauseCause: Schema.NullOr<Schema.Struct<{
|
|
33
33
|
/** Typed origin of the pause. */
|
|
34
|
-
readonly kind: Schema.Literals<readonly ["person", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
34
|
+
readonly kind: Schema.Literals<readonly ["person", "delegator", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
35
35
|
/** Additional explanation, or null when no detail was supplied. */
|
|
36
36
|
readonly detail: Schema.NullOr<Schema.String>;
|
|
37
37
|
}>>;
|
|
@@ -48,9 +48,16 @@ export declare const EndedGoal: Schema.Struct<{
|
|
|
48
48
|
readonly outcome: Schema.Literals<readonly ["achieved", "cleared"]>;
|
|
49
49
|
/**
|
|
50
50
|
* The model's evidence for an achieved goal, or its explanation for
|
|
51
|
-
* clearing its own paused goal
|
|
51
|
+
* clearing its own paused goal, or the delegator's clear reason;
|
|
52
|
+
* null when a person cleared it.
|
|
52
53
|
*/
|
|
53
54
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
55
|
+
/**
|
|
56
|
+
* Authenticated delegating Agent id, absent for person/model endings.
|
|
57
|
+
* This ending is Session-scoped; its immutable first-delegator record
|
|
58
|
+
* retains the exact authorized Session, rather than duplicating that pair.
|
|
59
|
+
*/
|
|
60
|
+
readonly clearedBy: Schema.optionalKey<Schema.NonEmptyString>;
|
|
54
61
|
/** Completion time in epoch milliseconds. */
|
|
55
62
|
readonly endedAt: Schema.Int;
|
|
56
63
|
/** Committed Session position when this goal ended; zero before any entry. */
|
|
@@ -96,7 +103,7 @@ export declare const GoalProjection: Schema.Struct<{
|
|
|
96
103
|
/** A typed cause while paused; null while active. */
|
|
97
104
|
readonly pauseCause: Schema.NullOr<Schema.Struct<{
|
|
98
105
|
/** Typed origin of the pause. */
|
|
99
|
-
readonly kind: Schema.Literals<readonly ["person", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
106
|
+
readonly kind: Schema.Literals<readonly ["person", "delegator", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
100
107
|
/** Additional explanation, or null when no detail was supplied. */
|
|
101
108
|
readonly detail: Schema.NullOr<Schema.String>;
|
|
102
109
|
}>>;
|
|
@@ -111,9 +118,16 @@ export declare const GoalProjection: Schema.Struct<{
|
|
|
111
118
|
readonly outcome: Schema.Literals<readonly ["achieved", "cleared"]>;
|
|
112
119
|
/**
|
|
113
120
|
* The model's evidence for an achieved goal, or its explanation for
|
|
114
|
-
* clearing its own paused goal
|
|
121
|
+
* clearing its own paused goal, or the delegator's clear reason;
|
|
122
|
+
* null when a person cleared it.
|
|
115
123
|
*/
|
|
116
124
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
125
|
+
/**
|
|
126
|
+
* Authenticated delegating Agent id, absent for person/model endings.
|
|
127
|
+
* This ending is Session-scoped; its immutable first-delegator record
|
|
128
|
+
* retains the exact authorized Session, rather than duplicating that pair.
|
|
129
|
+
*/
|
|
130
|
+
readonly clearedBy: Schema.optionalKey<Schema.NonEmptyString>;
|
|
117
131
|
/** Completion time in epoch milliseconds. */
|
|
118
132
|
readonly endedAt: Schema.Int;
|
|
119
133
|
/** Committed Session position when this goal ended; zero before any entry. */
|
|
@@ -128,6 +142,73 @@ export declare const goalContract: {
|
|
|
128
142
|
readonly id: string & import("effect/Brand").Brand<"ExtensionId">;
|
|
129
143
|
/** Goal commands admitted by the Session owner. */
|
|
130
144
|
readonly commands: {
|
|
145
|
+
/** Exact first delegator's controls; never an ordinary person command. */
|
|
146
|
+
readonly controlAgent: {
|
|
147
|
+
/** The child's Session owns this goal. */
|
|
148
|
+
readonly scope: "session";
|
|
149
|
+
/** Requested control; caller identity comes only from the host. */
|
|
150
|
+
readonly input: Schema.Struct<{
|
|
151
|
+
/** Pause, resume this delegator's own pause, or clear the goal. */
|
|
152
|
+
readonly action: Schema.Literals<readonly ["pause", "resume", "clear"]>;
|
|
153
|
+
/** Explanation retained with the control change. */
|
|
154
|
+
readonly reason: Schema.String;
|
|
155
|
+
}>;
|
|
156
|
+
/** Applied control or an explicit refusal without mutation. */
|
|
157
|
+
readonly output: Schema.Union<readonly [Schema.Struct<{
|
|
158
|
+
/** The exact delegator paused this goal. */
|
|
159
|
+
readonly result: Schema.Literal<"paused">;
|
|
160
|
+
/** Current paused goal and its controller attribution. */
|
|
161
|
+
readonly goal: Schema.Struct<{
|
|
162
|
+
/** Owner-issued revision that guards an explicit replacement. */
|
|
163
|
+
readonly revision: Schema.String;
|
|
164
|
+
/** Objective being pursued by this Session. */
|
|
165
|
+
readonly objective: Schema.String;
|
|
166
|
+
/** Live, or paused until a person resumes it (a blocked goal is paused). */
|
|
167
|
+
readonly state: Schema.Literals<readonly ["active", "paused"]>;
|
|
168
|
+
/** When this goal was set, in epoch milliseconds. */
|
|
169
|
+
readonly startedAt: Schema.Int;
|
|
170
|
+
/** A typed cause while paused; null while active. */
|
|
171
|
+
readonly pauseCause: Schema.NullOr<Schema.Struct<{
|
|
172
|
+
/** Typed origin of the pause. */
|
|
173
|
+
readonly kind: Schema.Literals<readonly ["person", "delegator", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
174
|
+
/** Additional explanation, or null when no detail was supplied. */
|
|
175
|
+
readonly detail: Schema.NullOr<Schema.String>;
|
|
176
|
+
}>>;
|
|
177
|
+
}>;
|
|
178
|
+
}>, Schema.Struct<{
|
|
179
|
+
/** This delegator resumed its own pause. */
|
|
180
|
+
readonly result: Schema.Literal<"resumed">;
|
|
181
|
+
/** Current active goal. */
|
|
182
|
+
readonly goal: Schema.Struct<{
|
|
183
|
+
/** Owner-issued revision that guards an explicit replacement. */
|
|
184
|
+
readonly revision: Schema.String;
|
|
185
|
+
/** Objective being pursued by this Session. */
|
|
186
|
+
readonly objective: Schema.String;
|
|
187
|
+
/** Live, or paused until a person resumes it (a blocked goal is paused). */
|
|
188
|
+
readonly state: Schema.Literals<readonly ["active", "paused"]>;
|
|
189
|
+
/** When this goal was set, in epoch milliseconds. */
|
|
190
|
+
readonly startedAt: Schema.Int;
|
|
191
|
+
/** A typed cause while paused; null while active. */
|
|
192
|
+
readonly pauseCause: Schema.NullOr<Schema.Struct<{
|
|
193
|
+
/** Typed origin of the pause. */
|
|
194
|
+
readonly kind: Schema.Literals<readonly ["person", "delegator", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
195
|
+
/** Additional explanation, or null when no detail was supplied. */
|
|
196
|
+
readonly detail: Schema.NullOr<Schema.String>;
|
|
197
|
+
}>>;
|
|
198
|
+
}>;
|
|
199
|
+
}>, Schema.Struct<{
|
|
200
|
+
/** The exact delegator cleared the goal. */
|
|
201
|
+
readonly result: Schema.Literal<"cleared">;
|
|
202
|
+
}>, Schema.Struct<{
|
|
203
|
+
/** No live goal exists to control. */
|
|
204
|
+
readonly result: Schema.Literal<"no_goal">;
|
|
205
|
+
}>, Schema.Struct<{
|
|
206
|
+
/** No goal state changed. */
|
|
207
|
+
readonly result: Schema.Literal<"refused">;
|
|
208
|
+
/** Caller lacks exact authority, or does not own this pause. */
|
|
209
|
+
readonly reason: Schema.Literals<readonly ["not_delegator", "not_paused_by_delegator"]>;
|
|
210
|
+
}>]>;
|
|
211
|
+
};
|
|
131
212
|
/** Open or answer the human goal controls. */
|
|
132
213
|
readonly goal: {
|
|
133
214
|
/** The Session owns this goal. */
|
|
@@ -172,7 +253,7 @@ export declare const goalContract: {
|
|
|
172
253
|
/** A typed cause while paused; null while active. */
|
|
173
254
|
readonly pauseCause: Schema.NullOr<Schema.Struct<{
|
|
174
255
|
/** Typed origin of the pause. */
|
|
175
|
-
readonly kind: Schema.Literals<readonly ["person", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
256
|
+
readonly kind: Schema.Literals<readonly ["person", "delegator", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
176
257
|
/** Additional explanation, or null when no detail was supplied. */
|
|
177
258
|
readonly detail: Schema.NullOr<Schema.String>;
|
|
178
259
|
}>>;
|
|
@@ -197,7 +278,7 @@ export declare const goalContract: {
|
|
|
197
278
|
/** A typed cause while paused; null while active. */
|
|
198
279
|
readonly pauseCause: Schema.NullOr<Schema.Struct<{
|
|
199
280
|
/** Typed origin of the pause. */
|
|
200
|
-
readonly kind: Schema.Literals<readonly ["person", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
281
|
+
readonly kind: Schema.Literals<readonly ["person", "delegator", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
201
282
|
/** Additional explanation, or null when no detail was supplied. */
|
|
202
283
|
readonly detail: Schema.NullOr<Schema.String>;
|
|
203
284
|
}>>;
|
|
@@ -246,7 +327,7 @@ export declare const goalContract: {
|
|
|
246
327
|
/** A typed cause while paused; null while active. */
|
|
247
328
|
readonly pauseCause: Schema.NullOr<Schema.Struct<{
|
|
248
329
|
/** Typed origin of the pause. */
|
|
249
|
-
readonly kind: Schema.Literals<readonly ["person", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
330
|
+
readonly kind: Schema.Literals<readonly ["person", "delegator", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
250
331
|
/** Additional explanation, or null when no detail was supplied. */
|
|
251
332
|
readonly detail: Schema.NullOr<Schema.String>;
|
|
252
333
|
}>>;
|
|
@@ -278,7 +359,7 @@ export declare const goalContract: {
|
|
|
278
359
|
/** A typed cause while paused; null while active. */
|
|
279
360
|
readonly pauseCause: Schema.NullOr<Schema.Struct<{
|
|
280
361
|
/** Typed origin of the pause. */
|
|
281
|
-
readonly kind: Schema.Literals<readonly ["person", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
362
|
+
readonly kind: Schema.Literals<readonly ["person", "delegator", "blocked", "stalled", "cancelled", "failed", "no-terminal"]>;
|
|
282
363
|
/** Additional explanation, or null when no detail was supplied. */
|
|
283
364
|
readonly detail: Schema.NullOr<Schema.String>;
|
|
284
365
|
}>>;
|
|
@@ -293,9 +374,16 @@ export declare const goalContract: {
|
|
|
293
374
|
readonly outcome: Schema.Literals<readonly ["achieved", "cleared"]>;
|
|
294
375
|
/**
|
|
295
376
|
* The model's evidence for an achieved goal, or its explanation for
|
|
296
|
-
* clearing its own paused goal
|
|
377
|
+
* clearing its own paused goal, or the delegator's clear reason;
|
|
378
|
+
* null when a person cleared it.
|
|
297
379
|
*/
|
|
298
380
|
readonly reason: Schema.NullOr<Schema.String>;
|
|
381
|
+
/**
|
|
382
|
+
* Authenticated delegating Agent id, absent for person/model endings.
|
|
383
|
+
* This ending is Session-scoped; its immutable first-delegator record
|
|
384
|
+
* retains the exact authorized Session, rather than duplicating that pair.
|
|
385
|
+
*/
|
|
386
|
+
readonly clearedBy: Schema.optionalKey<Schema.NonEmptyString>;
|
|
299
387
|
/** Completion time in epoch milliseconds. */
|
|
300
388
|
readonly endedAt: Schema.Int;
|
|
301
389
|
/** Committed Session position when this goal ended; zero before any entry. */
|
package/dist/goal/contract.js
CHANGED
|
@@ -18,6 +18,7 @@ export const GoalPauseCause = Schema.Struct({
|
|
|
18
18
|
/** Typed origin of the pause. */
|
|
19
19
|
kind: Schema.Literals([
|
|
20
20
|
"person",
|
|
21
|
+
"delegator",
|
|
21
22
|
"blocked",
|
|
22
23
|
"stalled",
|
|
23
24
|
"cancelled",
|
|
@@ -50,9 +51,16 @@ export const EndedGoal = Schema.Struct({
|
|
|
50
51
|
outcome: Schema.Literals(["achieved", "cleared"]),
|
|
51
52
|
/**
|
|
52
53
|
* The model's evidence for an achieved goal, or its explanation for
|
|
53
|
-
* clearing its own paused goal
|
|
54
|
+
* clearing its own paused goal, or the delegator's clear reason;
|
|
55
|
+
* null when a person cleared it.
|
|
54
56
|
*/
|
|
55
57
|
reason: Schema.NullOr(GoalReason),
|
|
58
|
+
/**
|
|
59
|
+
* Authenticated delegating Agent id, absent for person/model endings.
|
|
60
|
+
* This ending is Session-scoped; its immutable first-delegator record
|
|
61
|
+
* retains the exact authorized Session, rather than duplicating that pair.
|
|
62
|
+
*/
|
|
63
|
+
clearedBy: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(256))),
|
|
56
64
|
/** Completion time in epoch milliseconds. */
|
|
57
65
|
endedAt: EpochMillis,
|
|
58
66
|
/** Committed Session position when this goal ended; zero before any entry. */
|
|
@@ -106,6 +114,47 @@ export const goalContract = {
|
|
|
106
114
|
id: ExtensionId.make("botanical-session-goal"),
|
|
107
115
|
/** Goal commands admitted by the Session owner. */
|
|
108
116
|
commands: {
|
|
117
|
+
/** Exact first delegator's controls; never an ordinary person command. */
|
|
118
|
+
controlAgent: {
|
|
119
|
+
/** The child's Session owns this goal. */
|
|
120
|
+
scope: "session",
|
|
121
|
+
/** Requested control; caller identity comes only from the host. */
|
|
122
|
+
input: Schema.Struct({
|
|
123
|
+
/** Pause, resume this delegator's own pause, or clear the goal. */
|
|
124
|
+
action: Schema.Literals(["pause", "resume", "clear"]),
|
|
125
|
+
/** Explanation retained with the control change. */
|
|
126
|
+
reason: GoalReason,
|
|
127
|
+
}),
|
|
128
|
+
/** Applied control or an explicit refusal without mutation. */
|
|
129
|
+
output: Schema.Union([
|
|
130
|
+
Schema.Struct({
|
|
131
|
+
/** The exact delegator paused this goal. */
|
|
132
|
+
result: Schema.Literal("paused"),
|
|
133
|
+
/** Current paused goal and its controller attribution. */
|
|
134
|
+
goal: Goal,
|
|
135
|
+
}),
|
|
136
|
+
Schema.Struct({
|
|
137
|
+
/** This delegator resumed its own pause. */
|
|
138
|
+
result: Schema.Literal("resumed"),
|
|
139
|
+
/** Current active goal. */
|
|
140
|
+
goal: Goal,
|
|
141
|
+
}),
|
|
142
|
+
Schema.Struct({
|
|
143
|
+
/** The exact delegator cleared the goal. */
|
|
144
|
+
result: Schema.Literal("cleared"),
|
|
145
|
+
}),
|
|
146
|
+
Schema.Struct({
|
|
147
|
+
/** No live goal exists to control. */
|
|
148
|
+
result: Schema.Literal("no_goal"),
|
|
149
|
+
}),
|
|
150
|
+
Schema.Struct({
|
|
151
|
+
/** No goal state changed. */
|
|
152
|
+
result: Schema.Literal("refused"),
|
|
153
|
+
/** Caller lacks exact authority, or does not own this pause. */
|
|
154
|
+
reason: Schema.Literals(["not_delegator", "not_paused_by_delegator"]),
|
|
155
|
+
}),
|
|
156
|
+
]),
|
|
157
|
+
},
|
|
109
158
|
/** Open or answer the human goal controls. */
|
|
110
159
|
goal: {
|
|
111
160
|
/** The Session owns this goal. */
|
package/dist/goal/host.js
CHANGED
|
@@ -11,7 +11,7 @@ import { ask, catalog, declined, done, freshRequestId, } from "../internal/catal
|
|
|
11
11
|
import { EndedGoal, endedGoalLimit, Goal, GoalCommandInput, goalContract, GoalReason, Objective, } from "./contract.js";
|
|
12
12
|
import { clearConfirmation, goalMenuPrompt, replaceConfirmation, } from "./prompts.js";
|
|
13
13
|
/** The rules the model follows; the describe page and an active goal's prompt share them. */
|
|
14
|
-
const rules = "You may start a goal yourself when none is current. Before marking complete audit every requirement against evidence; complete only after actual achievement. Block only after the same external impasse for three consecutive goal turns; a blocked goal stays paused until it is resumed. You may complete, block, clear or resume a goal that paused on its own (stalled, blocked or failed work)
|
|
14
|
+
const rules = "You may start a goal yourself when none is current. Before marking complete audit every requirement against evidence; complete only after actual achievement. Block only after the same external impasse for three consecutive goal turns; a blocked goal stays paused until it is resumed. You may complete, block, clear or resume a goal that paused on its own (stalled, blocked or failed work). A goal a person or your delegator paused you may only complete. Only a person or the exact Agent Session that delegated this Session pauses or clears a live goal; that delegator may resume its own pause with agents.goal. Person controls stay with the person. Use plan.update_plan for multi-step work when available.";
|
|
15
15
|
/** Hashed prose and policy: every constant goal reads comes from here. */
|
|
16
16
|
const config = {
|
|
17
17
|
continuation: "Continue working toward the current goal described in the goal section. Find goal.get_goal and goal.update_goal with forage.search({query:'goal'}) and forage.describe. Audit every requirement against evidence before goal.update_goal({status:'complete', reason}). If the same external blocker persists for three goal turns, report blocked with a reason. Check for progress rather than repeating yourself. If there is nothing to do until something outside this turn happens (a child's reply, a person, the train, main), call goal.wait({reason, fallbackMinutes}) and end the turn instead of polling.",
|
|
@@ -150,7 +150,7 @@ function paused(goal, kind, detail) {
|
|
|
150
150
|
* Finish the current goal: it leaves the current slot and joins the
|
|
151
151
|
* Session's bounded history, which the chat shows as one line.
|
|
152
152
|
*/
|
|
153
|
-
function finishGoal(ctx, goal, outcome, reason) {
|
|
153
|
+
function finishGoal(ctx, goal, outcome, reason, clearedBy) {
|
|
154
154
|
return Effect.gen(function* () {
|
|
155
155
|
const endedAt = yield* Clock.currentTimeMillis;
|
|
156
156
|
const afterSequence = yield* ctx.sessionPosition(goal.sessionId);
|
|
@@ -164,6 +164,8 @@ function finishGoal(ctx, goal, outcome, reason) {
|
|
|
164
164
|
endedAt,
|
|
165
165
|
afterSequence,
|
|
166
166
|
};
|
|
167
|
+
if (clearedBy !== undefined)
|
|
168
|
+
Object.assign(ending, { clearedBy });
|
|
167
169
|
yield* ctx.state.endings.put({
|
|
168
170
|
sessionId: goal.sessionId,
|
|
169
171
|
ended: [...(previous?.ended ?? []), ending].slice(-endedGoalLimit),
|
|
@@ -250,7 +252,7 @@ function settle(ctx, run, subagents) {
|
|
|
250
252
|
// answer is a legitimate wait, whether or not this turn polled.
|
|
251
253
|
const waitingForChild = goalTurn &&
|
|
252
254
|
(subagents?.hasLiveChildCommand(run.sessionId) === true ||
|
|
253
|
-
(yield* ctx.attention.
|
|
255
|
+
(yield* ctx.attention.awaitsDecision(run.sessionId)));
|
|
254
256
|
const waiting = goal.waiting ?? null;
|
|
255
257
|
// The run that called goal.wait fixes the fallback instant as it settles.
|
|
256
258
|
const requested = waiting !== null &&
|
|
@@ -367,7 +369,7 @@ function recheckWaiting(ctx, timer, subagents) {
|
|
|
367
369
|
return yield* commitGoal(ctx, yield* continueIfIdle(ctx, { ...found.value, waiting: null, stalledTurns: 0 }, `goal-wait:${found.value.trackedWorkId}`)).pipe(Effect.andThen(ctx.observe(sessionId)));
|
|
368
370
|
}
|
|
369
371
|
if (subagents?.hasLiveChildCommand(sessionId) === true ||
|
|
370
|
-
(yield* ctx.attention.
|
|
372
|
+
(yield* ctx.attention.awaitsDecision(sessionId)))
|
|
371
373
|
return yield* ctx.timers.set(timer.key, timer.firedAt + ctx.config.waitCheckMs);
|
|
372
374
|
yield* commitGoal(ctx, yield* continueIfIdle(ctx, found.value, `goal-wait:${found.value.trackedWorkId}`));
|
|
373
375
|
yield* ctx.observe(sessionId);
|
|
@@ -543,8 +545,10 @@ function goalModule(ctx, sessionId, workId, initialRevision) {
|
|
|
543
545
|
const decoded = yield* Schema.decodeUnknownEffect(GoalReason)(reason).pipe(Effect.mapError(() => conflict("Goal reason is invalid")));
|
|
544
546
|
const goal = yield* currentGoal;
|
|
545
547
|
// A person's pause or stop is theirs: the model may only finish it.
|
|
546
|
-
if (status !== "complete" &&
|
|
547
|
-
return yield* Effect.fail(conflict(
|
|
548
|
+
if (status !== "complete" && heldByController(goal))
|
|
549
|
+
return yield* Effect.fail(conflict(goal.pauseCause?.kind === "delegator"
|
|
550
|
+
? "Your delegator paused this goal; only complete is available to you"
|
|
551
|
+
: "A person paused or stopped this goal; only complete is available to you"));
|
|
548
552
|
if (status === "resume") {
|
|
549
553
|
const resumed = yield* modelResume(goal, workId);
|
|
550
554
|
yield* commitGoal(ctx, resumed);
|
|
@@ -571,10 +575,11 @@ function goalModule(ctx, sessionId, workId, initialRevision) {
|
|
|
571
575
|
},
|
|
572
576
|
});
|
|
573
577
|
}
|
|
574
|
-
/** A
|
|
575
|
-
function
|
|
578
|
+
/** A controller's pause: the child model may complete, never undo it. */
|
|
579
|
+
function heldByController(goal) {
|
|
576
580
|
return (goal.state === "paused" &&
|
|
577
581
|
(goal.pauseCause?.kind === "person" ||
|
|
582
|
+
goal.pauseCause?.kind === "delegator" ||
|
|
578
583
|
goal.pauseCause?.kind === "cancelled"));
|
|
579
584
|
}
|
|
580
585
|
/**
|
|
@@ -693,6 +698,55 @@ function clearGoal(ctx, sessionId) {
|
|
|
693
698
|
return true;
|
|
694
699
|
});
|
|
695
700
|
}
|
|
701
|
+
/** Authentication is host context; authority is only this Session's immutable first delegator. */
|
|
702
|
+
function controlAgent(ctx, sessionId, input, caller) {
|
|
703
|
+
return Effect.gen(function* () {
|
|
704
|
+
if (caller === undefined)
|
|
705
|
+
return yield* Effect.fail(new ExtensionCommandError({
|
|
706
|
+
reason: "rejected",
|
|
707
|
+
message: "Only an authenticated Agent can control a delegated goal",
|
|
708
|
+
}));
|
|
709
|
+
const parent = yield* ctx.sessionParent(sessionId);
|
|
710
|
+
if (parent?.agentId !== caller.agentId ||
|
|
711
|
+
parent.sessionId !== caller.sessionId)
|
|
712
|
+
return { result: "refused", reason: "not_delegator" };
|
|
713
|
+
const current = yield* ctx.state.goals.get(sessionId);
|
|
714
|
+
if (Option.isNone(current))
|
|
715
|
+
return { result: "no_goal" };
|
|
716
|
+
const goal = current.value;
|
|
717
|
+
if (input.action === "clear") {
|
|
718
|
+
yield* finishGoal(ctx, goal, "cleared", input.reason, caller.agentId);
|
|
719
|
+
yield* ctx.observe(sessionId);
|
|
720
|
+
return { result: "cleared" };
|
|
721
|
+
}
|
|
722
|
+
if (input.action === "resume") {
|
|
723
|
+
if (goal.state !== "paused" || goal.pauseCause?.kind !== "delegator")
|
|
724
|
+
return {
|
|
725
|
+
result: "refused",
|
|
726
|
+
reason: "not_paused_by_delegator",
|
|
727
|
+
};
|
|
728
|
+
return {
|
|
729
|
+
result: "resumed",
|
|
730
|
+
goal: yield* resumeGoal(ctx, sessionId),
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
// A parent cannot relabel a person's pause and then resume it.
|
|
734
|
+
const next = heldByController(goal) && goal.pauseCause?.kind !== "delegator"
|
|
735
|
+
? goal
|
|
736
|
+
: paused(goal, "delegator", `${parent.name}: ${input.reason}`);
|
|
737
|
+
yield* commitGoal(ctx, next);
|
|
738
|
+
yield* ctx.observe(sessionId);
|
|
739
|
+
return { result: "paused", goal: committed(next) };
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
function personOnly(caller, command) {
|
|
743
|
+
return caller === undefined
|
|
744
|
+
? command
|
|
745
|
+
: Effect.fail(new ExtensionCommandError({
|
|
746
|
+
reason: "rejected",
|
|
747
|
+
message: "Only a person may use person goal controls",
|
|
748
|
+
}));
|
|
749
|
+
}
|
|
696
750
|
/**
|
|
697
751
|
* The human `/goal` conversation. Every step is decided here from the
|
|
698
752
|
* committed goal, so every client shows the same choices.
|
|
@@ -860,11 +914,12 @@ export function goalExtensionFor(subagents) {
|
|
|
860
914
|
commands: {
|
|
861
915
|
specs: goalContract.commands,
|
|
862
916
|
handlers: (ctx) => ({
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
917
|
+
controlAgent: ({ sessionId, input, caller }) => controlAgent(ctx, sessionId, input, caller),
|
|
918
|
+
goal: ({ sessionId, input, caller }) => personOnly(caller, humanGoal(ctx, sessionId, input)),
|
|
919
|
+
pause: ({ sessionId, caller }) => personOnly(caller, pauseGoal(ctx, sessionId)),
|
|
920
|
+
resume: ({ sessionId, caller }) => personOnly(caller, resumeGoal(ctx, sessionId)),
|
|
921
|
+
clear: ({ sessionId, caller, }) => personOnly(caller, clearGoal(ctx, sessionId).pipe(Effect.as({}))),
|
|
922
|
+
set: ({ sessionId, input, caller }) => personOnly(caller, setGoal(ctx, sessionId, input)),
|
|
868
923
|
}),
|
|
869
924
|
},
|
|
870
925
|
}));
|
package/dist/goal/prompts.js
CHANGED
|
@@ -15,6 +15,7 @@ function startedAt(epochMillis, now) {
|
|
|
15
15
|
/** What happened, by the typed cause and never by the goal's own words. */
|
|
16
16
|
const pausedSummary = {
|
|
17
17
|
person: "You paused this goal.",
|
|
18
|
+
delegator: "The exact Session that delegated this work paused the goal. It may resume its own pause; you may resume or clear it too.",
|
|
18
19
|
blocked: "The Agent is stuck and needs you.",
|
|
19
20
|
stalled: "No progress for 3 turns, so Fungi paused it.",
|
|
20
21
|
cancelled: "You stopped the goal's turn.",
|
package/dist/question/client.js
CHANGED
|
@@ -8,8 +8,19 @@ export default defineClientEntry(questionContract, {
|
|
|
8
8
|
? []
|
|
9
9
|
: view.value.asks.map((ask) => {
|
|
10
10
|
const first = ask.questions[0];
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
let title = `${first?.question ?? "Question"}${ask.questions.length > 1 ? ` (+${String(ask.questions.length - 1)} more)` : ""}`;
|
|
12
|
+
let detail = first?.options.map((option) => option.label).join(" · ") ?? "";
|
|
13
|
+
if (ask.escalated !== undefined) {
|
|
14
|
+
const { by, reason, note } = ask.escalated;
|
|
15
|
+
const label = reason === "escalated"
|
|
16
|
+
? `escalated by ${by.name}`
|
|
17
|
+
: reason === "sender_archived"
|
|
18
|
+
? `${by.name} archived`
|
|
19
|
+
: `${by.name} is gone`;
|
|
20
|
+
title = `${label} · ${title}`;
|
|
21
|
+
if (note !== undefined)
|
|
22
|
+
detail = `${detail}\n${note}`;
|
|
23
|
+
}
|
|
13
24
|
// An ask waiting on an Agent is calm: it never takes over the
|
|
14
25
|
// composer, but a person may still answer it first.
|
|
15
26
|
if (ask.waitingOn !== undefined)
|