@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.
Files changed (46) hide show
  1. package/README.md +33 -21
  2. package/dist/goal/contract.d.ts +27 -8
  3. package/dist/goal/contract.js +20 -3
  4. package/dist/goal/host.d.ts +4 -1
  5. package/dist/goal/host.js +375 -128
  6. package/dist/goal/prompts.d.ts +73 -0
  7. package/dist/goal/prompts.js +98 -0
  8. package/dist/home/host.js +9 -3
  9. package/dist/internal/headline.d.ts +7 -0
  10. package/dist/internal/headline.js +18 -0
  11. package/dist/loop/client.js +1 -1
  12. package/dist/loop/contract.d.ts +6 -2
  13. package/dist/loop/contract.js +10 -1
  14. package/dist/loop/host.js +10 -12
  15. package/dist/loop/prompts.d.ts +56 -0
  16. package/dist/loop/prompts.js +54 -0
  17. package/dist/question/answer-flow.d.ts +27 -0
  18. package/dist/question/answer-flow.js +115 -0
  19. package/dist/question/client.d.ts +1 -1
  20. package/dist/question/client.js +22 -3
  21. package/dist/question/contract.d.ts +202 -60
  22. package/dist/question/contract.js +78 -22
  23. package/dist/question/host.d.ts +4 -0
  24. package/dist/question/host.js +348 -304
  25. package/dist/roster/conversation-agents.d.ts +22 -15
  26. package/dist/roster/conversation-agents.js +161 -37
  27. package/dist/roster.d.ts +8 -2
  28. package/dist/roster.js +33 -6
  29. package/dist/skills/host.js +20 -2
  30. package/dist/subagents/client.js +64 -20
  31. package/dist/subagents/contract.d.ts +123 -10
  32. package/dist/subagents/contract.js +38 -5
  33. package/dist/subagents/host.d.ts +5 -5
  34. package/dist/subagents/host.js +152 -22
  35. package/docs/api/goal/contract.md +5 -2
  36. package/docs/api/goal/host.md +22 -1
  37. package/docs/api/home/host.md +6 -5
  38. package/docs/api/loop/contract.md +5 -2
  39. package/docs/api/question/client.md +2 -1
  40. package/docs/api/question/contract.md +183 -51
  41. package/docs/api/question/host.md +30 -0
  42. package/docs/api/roster/conversation-agents.md +15 -7
  43. package/docs/api/roster.md +39 -2
  44. package/docs/api/subagents/contract.md +101 -28
  45. package/docs/api/subagents/host.md +5 -2
  46. package/package.json +5 -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, while a parked question resumes through one follow-up. |
71
- | Goal | One live or paused objective per Session. The model creates, reads and completes it through `goal.*` tools; humans set, pause, resume or clear it. Esc, failed work, a block or three tool-less continuations pause it. 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 read-only footer view: one row per Agent this Session sent work to or created, with its live status (working, waiting on you, idle, failed, unavailable). A row opens that Agent's conversation, 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, while a parked question resumes through one follow-up. On Local, an Ask raised during work another Agent sent waits on that sender first: it always parks, reads `waiting on <name>` instead of needing a person, and rides the child's reply to the sender as `waiting_on_you`. Only that sender's Session can answer it with `agents.answer`, or pass it to a person with `agents.escalate`; a person may always answer. An Ask the sender neither answers nor escalates goes to a person when the sender's turn ends, or after fifteen minutes. 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
@@ -90,14 +90,21 @@ metadata used for compact notes and appear as ordinary message bubbles.
90
90
 
91
91
  Goal pause stops continuation, not already accepted work. Model-requested
92
92
  completion or blocking is provisional until successful settlement; a blocked
93
- goal pauses and resumes like any paused goal. Only a live or paused goal asks
94
- before a replacement, which uses the observed revision to avoid replacing a
95
- newer goal; the replaced goal is recorded as cleared. When a runtime restart (a
96
- Hub deploy or eviction, a Local service restart) interrupts a goal turn, the
97
- turn resumes and the goal stays live. A live goal pauses when any turn of its
98
- Session fails, cannot resume or is stopped by a person (Esc), including the
99
- person's own messages ("The last turn failed"). A missing extension origin does
100
- not establish a human sender; mail and host admissions can also lack one.
93
+ goal pauses and resumes like any paused goal. Each run's goal tools are fenced
94
+ by the goal revision that run saw, so a later follow-up command (for example a
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 paused or stopped accepts only
97
+ completion from the model, and only a person clears a live goal. When a
98
+ tool-less goal turn ends while a recorded sub-agent command is live, the goal
99
+ raises `goal-waiting` attention and rechecks on a timer instead of counting a
100
+ stall; it continues once the child settles or replies. Only a live or paused
101
+ goal asks before a replacement, which uses the observed revision to avoid
102
+ replacing a newer goal; the replaced goal is recorded as cleared. When a runtime
103
+ restart (a Hub deploy or eviction, a Local service restart) interrupts a goal
104
+ turn, the turn resumes and the goal stays live. A live goal pauses when any turn
105
+ of its Session fails, cannot resume or is stopped by a person (Esc), including
106
+ the person's own messages ("The last turn failed"). A missing extension origin
107
+ does not establish a human sender; mail and host admissions can also lack one.
101
108
 
102
109
  Goal's shared wire and durable row use `pauseCause: { kind, detail }` while
103
110
  paused and `null` while active. The closed kinds are `person`, `blocked`,
@@ -262,9 +269,14 @@ expands the footer rows, per Session and in memory).
262
269
  `source.read(sessionId, limit)` returns the Agents that Session sent work to or
263
270
  created, newest first, with a count of the rest; `source.open` is the host's
264
271
  existing Agent access. Each child's status is its owner's own Session state:
265
- `running` is working, any open attention (a question or a tool approval) is
266
- waiting on you, `done` is idle and `errored` is failed. A child whose state
267
- cannot be read is unavailable, never idle.
272
+ `running` is working, `done` is idle and `errored` is failed. Attention that
273
+ waits on a person (a question, or an approval an extension raises) is
274
+ `needs you`; a question that waits on the Agent that sent the work is
275
+ `waiting on <name>`, calm until it is escalated, and counted apart in the
276
+ collapsed summary, which is amber only when a child needs a person. A
277
+ `needs you` question carries its text and one Answer action that runs the
278
+ question's own answer conversation. A child whose state cannot be read is
279
+ unavailable, never idle.
268
280
 
269
281
  Rows refresh when a watcher reads the parent Session and they are at least a
270
282
  second old. While a row is working or waiting, they poll every five seconds
@@ -44,9 +44,12 @@ export declare const EndedGoal: Schema.Struct<{
44
44
  readonly sequence: Schema.Int;
45
45
  /** Objective that finished or was cleared. */
46
46
  readonly objective: Schema.String;
47
- /** Whether the model achieved the goal or a person cleared it. */
47
+ /** Whether the model achieved the goal or it was cleared. */
48
48
  readonly outcome: Schema.Literals<readonly ["achieved", "cleared"]>;
49
- /** The model's evidence for an achieved goal; null when cleared. */
49
+ /**
50
+ * The model's evidence for an achieved goal, or its explanation for
51
+ * clearing its own paused goal; null when a person cleared it.
52
+ */
50
53
  readonly reason: Schema.NullOr<Schema.String>;
51
54
  /** Completion time in epoch milliseconds. */
52
55
  readonly endedAt: Schema.Int;
@@ -74,7 +77,9 @@ export declare const GoalCommandInput: Schema.Union<readonly [Schema.Struct<{
74
77
  readonly confirmed: Schema.optional<Schema.Boolean>;
75
78
  }>, Schema.Struct<{
76
79
  /** Select an existing-goal control. */
77
- readonly action: Schema.Literals<readonly ["pause", "resume", "replace", "clear"]>;
80
+ readonly action: Schema.Literals<readonly ["pause", "resume", "replace", "clear", "clear-ask"]>;
81
+ /** The human's answer to "clear this goal?"; absent for a typed clear. */
82
+ readonly confirmed: Schema.optional<Schema.Boolean>;
78
83
  }>, Schema.Struct<{}>]>;
79
84
  /** Goal's contract: Session-scope human controls and one projection slot. */
80
85
  export declare const GoalProjection: Schema.Struct<{
@@ -102,9 +107,12 @@ export declare const GoalProjection: Schema.Struct<{
102
107
  readonly sequence: Schema.Int;
103
108
  /** Objective that finished or was cleared. */
104
109
  readonly objective: Schema.String;
105
- /** Whether the model achieved the goal or a person cleared it. */
110
+ /** Whether the model achieved the goal or it was cleared. */
106
111
  readonly outcome: Schema.Literals<readonly ["achieved", "cleared"]>;
107
- /** The model's evidence for an achieved goal; null when cleared. */
112
+ /**
113
+ * The model's evidence for an achieved goal, or its explanation for
114
+ * clearing its own paused goal; null when a person cleared it.
115
+ */
108
116
  readonly reason: Schema.NullOr<Schema.String>;
109
117
  /** Completion time in epoch milliseconds. */
110
118
  readonly endedAt: Schema.Int;
@@ -138,7 +146,9 @@ export declare const goalContract: {
138
146
  readonly confirmed: Schema.optional<Schema.Boolean>;
139
147
  }>, Schema.Struct<{
140
148
  /** Select an existing-goal control. */
141
- readonly action: Schema.Literals<readonly ["pause", "resume", "replace", "clear"]>;
149
+ readonly action: Schema.Literals<readonly ["pause", "resume", "replace", "clear", "clear-ask"]>;
150
+ /** The human's answer to "clear this goal?"; absent for a typed clear. */
151
+ readonly confirmed: Schema.optional<Schema.Boolean>;
142
152
  }>, Schema.Struct<{}>]>;
143
153
  /** Return the server-owned conversation step. */
144
154
  readonly output: Schema.declare<import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1, import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1>;
@@ -214,6 +224,12 @@ export declare const goalContract: {
214
224
  readonly expectedRevision: Schema.NullOr<Schema.String>;
215
225
  /** Idempotency key for this setting command. */
216
226
  readonly requestId: Schema.String;
227
+ /**
228
+ * Work already admitted in this Session that carries the objective,
229
+ * such as a delegated send. The goal adopts it instead of admitting
230
+ * the objective again; its settlement starts the goal turns.
231
+ */
232
+ readonly adoptCommandId: Schema.optionalKey<Schema.String>;
217
233
  }>;
218
234
  /** Return the goal and its admission receipt. */
219
235
  readonly output: Schema.Struct<{
@@ -273,9 +289,12 @@ export declare const goalContract: {
273
289
  readonly sequence: Schema.Int;
274
290
  /** Objective that finished or was cleared. */
275
291
  readonly objective: Schema.String;
276
- /** Whether the model achieved the goal or a person cleared it. */
292
+ /** Whether the model achieved the goal or it was cleared. */
277
293
  readonly outcome: Schema.Literals<readonly ["achieved", "cleared"]>;
278
- /** The model's evidence for an achieved goal; null when cleared. */
294
+ /**
295
+ * The model's evidence for an achieved goal, or its explanation for
296
+ * clearing its own paused goal; null when a person cleared it.
297
+ */
279
298
  readonly reason: Schema.NullOr<Schema.String>;
280
299
  /** Completion time in epoch milliseconds. */
281
300
  readonly endedAt: Schema.Int;
@@ -46,9 +46,12 @@ export const EndedGoal = Schema.Struct({
46
46
  sequence: Schema.Int.check(Schema.isGreaterThan(0)),
47
47
  /** Objective that finished or was cleared. */
48
48
  objective: Objective,
49
- /** Whether the model achieved the goal or a person cleared it. */
49
+ /** Whether the model achieved the goal or it was cleared. */
50
50
  outcome: Schema.Literals(["achieved", "cleared"]),
51
- /** The model's evidence for an achieved goal; null when cleared. */
51
+ /**
52
+ * The model's evidence for an achieved goal, or its explanation for
53
+ * clearing its own paused goal; null when a person cleared it.
54
+ */
52
55
  reason: Schema.NullOr(GoalReason),
53
56
  /** Completion time in epoch milliseconds. */
54
57
  endedAt: EpochMillis,
@@ -76,7 +79,15 @@ export const GoalCommandInput = Schema.Union([
76
79
  }),
77
80
  Schema.Struct({
78
81
  /** Select an existing-goal control. */
79
- action: Schema.Literals(["pause", "resume", "replace", "clear"]),
82
+ action: Schema.Literals([
83
+ "pause",
84
+ "resume",
85
+ "replace",
86
+ "clear",
87
+ "clear-ask",
88
+ ]),
89
+ /** The human's answer to "clear this goal?"; absent for a typed clear. */
90
+ confirmed: Schema.optional(Schema.Boolean),
80
91
  }),
81
92
  Schema.Struct({}),
82
93
  ]);
@@ -143,6 +154,12 @@ export const goalContract = {
143
154
  expectedRevision: Schema.NullOr(Schema.String),
144
155
  /** Idempotency key for this setting command. */
145
156
  requestId: RequestId,
157
+ /**
158
+ * Work already admitted in this Session that carries the objective,
159
+ * such as a delegated send. The goal adopts it instead of admitting
160
+ * the objective again; its settlement starts the goal turns.
161
+ */
162
+ adoptCommandId: Schema.optionalKey(RequestId),
146
163
  }),
147
164
  /** Return the goal and its admission receipt. */
148
165
  output: Schema.Struct({
@@ -1,5 +1,8 @@
1
1
  import { type RosteredExtensionV0 } from "@fungi.computer/shiitake/extensions";
2
+ import type { SubagentSource } from "../subagents/host.js";
2
3
  /** The commands this extension advertises to every client. */
3
4
  export declare const goalCatalog: import("@fungi.computer/shiitake/extensions").Json;
4
- /** Botanical's Session goal, driven only by settled runs. */
5
+ /** Botanical's Session goal; hosts with created-Agent facts include them in progress. */
6
+ export declare function goalExtensionFor(subagents?: SubagentSource): RosteredExtensionV0;
7
+ /** Ordinary roster when no created-Agent directory is available. */
5
8
  export declare const goalExtension: RosteredExtensionV0;