@fungi.computer/shiitake-extensions 0.11.6 → 0.11.8
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 +80 -38
- package/dist/goal/contract.d.ts +3 -3
- package/dist/goal/contract.js +3 -3
- package/dist/goal/host.js +8 -5
- package/dist/question/host.js +64 -12
- package/dist/roster/conversation-agents.d.ts +13 -10
- package/dist/roster/conversation-agents.js +34 -62
- package/docs/api/goal/contract.md +30 -30
- package/docs/api/roster/conversation-agents.md +16 -15
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# Shiitake extensions (`@fungi.computer/shiitake-extensions`)
|
|
2
2
|
|
|
3
|
+
Shiitake extensions are the built-in abilities of Fungi's agents: asking you
|
|
4
|
+
questions, working toward goals across turns, repeating loops, plans, schedules,
|
|
5
|
+
skills, a home Computer and a list of helper agents.
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
flowchart LR
|
|
9
|
+
Host[Shiitake host] -->|one roster| Extensions[Shiitake extensions]
|
|
10
|
+
Extensions --> Goal[Goals]
|
|
11
|
+
Extensions --> Question[Questions]
|
|
12
|
+
Extensions --> Plans[Plans and schedules]
|
|
13
|
+
Extensions --> Subagents[Sub-agents and home Computer]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
Install it:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install @fungi.computer/shiitake-extensions
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Illustrative: this helper receives an already open Agent with the product roster
|
|
25
|
+
and reads the goal slot for one Session. A fresh Session has no goal value. The
|
|
26
|
+
helper requests neither model work nor a goal mutation.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import {
|
|
30
|
+
bindSessionExtension,
|
|
31
|
+
type ShiitakeAgent,
|
|
32
|
+
} from "@fungi.computer/shiitake/client";
|
|
33
|
+
import { goalContract } from "@fungi.computer/shiitake-extensions/goal";
|
|
34
|
+
import { botanicalAgentExtensions } from "@fungi.computer/shiitake-extensions/roster";
|
|
35
|
+
|
|
36
|
+
export const extensions = botanicalAgentExtensions;
|
|
37
|
+
|
|
38
|
+
export async function readGoal(agent: ShiitakeAgent) {
|
|
39
|
+
const session = agent.session("example-session");
|
|
40
|
+
const goal = bindSessionExtension(session, goalContract);
|
|
41
|
+
return goal.view(await session.read());
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The bound view distinguishes `unavailable`, `stopped` with a reason, and
|
|
46
|
+
`running` with a value or `null`. Existing [goal tests](test/goal.test.ts) bind
|
|
47
|
+
that same contract, read observed state, issue commands and close the owner. The
|
|
48
|
+
helper borrows the Agent. Its owner closes it when the host's lifetime ends.
|
|
49
|
+
|
|
50
|
+
## Common tasks
|
|
51
|
+
|
|
52
|
+
### Read an Agent's goal
|
|
53
|
+
|
|
54
|
+
`bindSessionExtension` with `goalContract` reads the goal slot. See the Quick
|
|
55
|
+
start.
|
|
56
|
+
|
|
57
|
+
### Add the whole roster to a host
|
|
58
|
+
|
|
59
|
+
See [Core concepts](#core-concepts).
|
|
60
|
+
|
|
61
|
+
### Understand state and lifetime
|
|
62
|
+
|
|
63
|
+
See [State and lifetime](#state-and-lifetime).
|
|
64
|
+
|
|
65
|
+
### Add the Home, Subagents or Schedules extensions
|
|
66
|
+
|
|
67
|
+
See [Add the host-composed extensions](#add-the-host-composed-extensions).
|
|
68
|
+
|
|
69
|
+
## Reference
|
|
70
|
+
|
|
71
|
+
### Overview
|
|
72
|
+
|
|
3
73
|
The extensions behind Fungi's Agents: questions an Agent asks you, goals it
|
|
4
74
|
pursues across turns, repeating loops, plans, schedules, skills, a home Computer
|
|
5
75
|
and a footer of its sub-agents. Add them to any
|
|
@@ -35,46 +105,18 @@ and mark shortened listings; the prompt still lists every admitted skill. The
|
|
|
35
105
|
Hub uses the shared roster without Skills and adds its own scoped Home
|
|
36
106
|
extension.
|
|
37
107
|
|
|
38
|
-
## Quick start: read the committed goal
|
|
39
|
-
|
|
40
|
-
Illustrative: this helper receives an already open Agent with the product roster
|
|
41
|
-
and reads the goal slot for one Session. A fresh Session has no goal value. The
|
|
42
|
-
helper requests neither model work nor a goal mutation.
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
import {
|
|
46
|
-
bindSessionExtension,
|
|
47
|
-
type ShiitakeAgent,
|
|
48
|
-
} from "@fungi.computer/shiitake/client";
|
|
49
|
-
import { goalContract } from "@fungi.computer/shiitake-extensions/goal";
|
|
50
|
-
import { botanicalAgentExtensions } from "@fungi.computer/shiitake-extensions/roster";
|
|
51
|
-
|
|
52
|
-
export const extensions = botanicalAgentExtensions;
|
|
53
|
-
|
|
54
|
-
export async function readGoal(agent: ShiitakeAgent) {
|
|
55
|
-
const session = agent.session("example-session");
|
|
56
|
-
const goal = bindSessionExtension(session, goalContract);
|
|
57
|
-
return goal.view(await session.read());
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
The bound view distinguishes `unavailable`, `stopped` with a reason, and
|
|
62
|
-
`running` with a value or `null`. Existing [goal tests](test/goal.test.ts) bind
|
|
63
|
-
that same contract, read observed state, issue commands and close the owner. The
|
|
64
|
-
helper borrows the Agent. Its owner closes it when the host's lifetime ends.
|
|
65
|
-
|
|
66
108
|
## Core concepts
|
|
67
109
|
|
|
68
|
-
| Extension | Ownership and behavior
|
|
69
|
-
| --------- |
|
|
70
|
-
| Ask | Up to four open
|
|
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.
|
|
110
|
+
| Extension | Ownership and behavior |
|
|
111
|
+
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
112
|
+
| Ask | Up to four open questions per Session. The agent asks or withdraws a question, and a person answers or declines it. If the asker is still waiting, it gets the answer; if the question was parked, one follow-up message resumes it. On Local, a helper agent's questions go to its parent first, and the parent answers or passes the question up to its own parent. Only a top-level agent, or one whose parent is gone, reaches a person. Silence never escalates: there are at most two reminders on Local, then quiet waiting. A check every fifteen minutes promotes only a sender that is archived or absent, never an unknown one. A question's expiry follows the action it was waiting on. Hub sends every question to a person. The technical names are `agents.answer`, `agents.escalate` and `waiting_on_you`. |
|
|
113
|
+
| 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. |
|
|
114
|
+
| 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. |
|
|
115
|
+
| 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. |
|
|
116
|
+
| Almanac | Agent-scope one-shot or recurring schedules. Each schedule targets a Session and tracks admission, retry and its next due time. |
|
|
117
|
+
| Skills | Host-supplied, read-only skill discovery. Metadata enters the prompt; `skill.load` reads a skill body or supporting file; `/skills` lists them. |
|
|
118
|
+
| Home | Agent-scope choice of an attached Computer. Each run captures its scoped file tools and current attachment choice. |
|
|
119
|
+
| 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
120
|
|
|
79
121
|
An active Goal is quiet system context on every run. Continuation instructions
|
|
80
122
|
apply only to runs admitted by Goal with its continuation correlation; human
|
package/dist/goal/contract.d.ts
CHANGED
|
@@ -142,7 +142,7 @@ export declare const goalContract: {
|
|
|
142
142
|
readonly id: string & import("effect/Brand").Brand<"ExtensionId">;
|
|
143
143
|
/** Goal commands admitted by the Session owner. */
|
|
144
144
|
readonly commands: {
|
|
145
|
-
/**
|
|
145
|
+
/** The delegating or making Agent's controls, from any of its Sessions; never a person command. */
|
|
146
146
|
readonly controlAgent: {
|
|
147
147
|
/** The child's Session owns this goal. */
|
|
148
148
|
readonly scope: "session";
|
|
@@ -155,7 +155,7 @@ export declare const goalContract: {
|
|
|
155
155
|
}>;
|
|
156
156
|
/** Applied control or an explicit refusal without mutation. */
|
|
157
157
|
readonly output: Schema.Union<readonly [Schema.Struct<{
|
|
158
|
-
/** The
|
|
158
|
+
/** The delegating or making Agent paused this goal. */
|
|
159
159
|
readonly result: Schema.Literal<"paused">;
|
|
160
160
|
/** Current paused goal and its controller attribution. */
|
|
161
161
|
readonly goal: Schema.Struct<{
|
|
@@ -197,7 +197,7 @@ export declare const goalContract: {
|
|
|
197
197
|
}>>;
|
|
198
198
|
}>;
|
|
199
199
|
}>, Schema.Struct<{
|
|
200
|
-
/** The
|
|
200
|
+
/** The delegating or making Agent cleared the goal. */
|
|
201
201
|
readonly result: Schema.Literal<"cleared">;
|
|
202
202
|
}>, Schema.Struct<{
|
|
203
203
|
/** No live goal exists to control. */
|
package/dist/goal/contract.js
CHANGED
|
@@ -114,7 +114,7 @@ export const goalContract = {
|
|
|
114
114
|
id: ExtensionId.make("botanical-session-goal"),
|
|
115
115
|
/** Goal commands admitted by the Session owner. */
|
|
116
116
|
commands: {
|
|
117
|
-
/**
|
|
117
|
+
/** The delegating or making Agent's controls, from any of its Sessions; never a person command. */
|
|
118
118
|
controlAgent: {
|
|
119
119
|
/** The child's Session owns this goal. */
|
|
120
120
|
scope: "session",
|
|
@@ -128,7 +128,7 @@ export const goalContract = {
|
|
|
128
128
|
/** Applied control or an explicit refusal without mutation. */
|
|
129
129
|
output: Schema.Union([
|
|
130
130
|
Schema.Struct({
|
|
131
|
-
/** The
|
|
131
|
+
/** The delegating or making Agent paused this goal. */
|
|
132
132
|
result: Schema.Literal("paused"),
|
|
133
133
|
/** Current paused goal and its controller attribution. */
|
|
134
134
|
goal: Goal,
|
|
@@ -140,7 +140,7 @@ export const goalContract = {
|
|
|
140
140
|
goal: Goal,
|
|
141
141
|
}),
|
|
142
142
|
Schema.Struct({
|
|
143
|
-
/** The
|
|
143
|
+
/** The delegating or making Agent cleared the goal. */
|
|
144
144
|
result: Schema.Literal("cleared"),
|
|
145
145
|
}),
|
|
146
146
|
Schema.Struct({
|
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). A goal a person or your delegator paused you may only complete. Only a person
|
|
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, the Agent that delegated this Session or the Agent that made you pauses or clears a live goal, from any of its Sessions; that Agent 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.",
|
|
@@ -698,7 +698,7 @@ function clearGoal(ctx, sessionId) {
|
|
|
698
698
|
return true;
|
|
699
699
|
});
|
|
700
700
|
}
|
|
701
|
-
/** Authentication is host context; authority is
|
|
701
|
+
/** Authentication is host context; authority is the delegating or making Agent's. */
|
|
702
702
|
function controlAgent(ctx, sessionId, input, caller) {
|
|
703
703
|
return Effect.gen(function* () {
|
|
704
704
|
if (caller === undefined)
|
|
@@ -706,9 +706,12 @@ function controlAgent(ctx, sessionId, input, caller) {
|
|
|
706
706
|
reason: "rejected",
|
|
707
707
|
message: "Only an authenticated Agent can control a delegated goal",
|
|
708
708
|
}));
|
|
709
|
+
// Custody is an Agent's, from any of its Sessions: the Agent whose mail
|
|
710
|
+
// delegated this Session, and the Agent that made this one.
|
|
709
711
|
const parent = yield* ctx.sessionParent(sessionId);
|
|
710
|
-
|
|
711
|
-
|
|
712
|
+
const maker = yield* ctx.sessionMaker(sessionId);
|
|
713
|
+
const controller = [parent, maker].find((candidate) => candidate?.agentId === caller.agentId);
|
|
714
|
+
if (controller === undefined || controller === null)
|
|
712
715
|
return { result: "refused", reason: "not_delegator" };
|
|
713
716
|
const current = yield* ctx.state.goals.get(sessionId);
|
|
714
717
|
if (Option.isNone(current))
|
|
@@ -733,7 +736,7 @@ function controlAgent(ctx, sessionId, input, caller) {
|
|
|
733
736
|
// A parent cannot relabel a person's pause and then resume it.
|
|
734
737
|
const next = heldByController(goal) && goal.pauseCause?.kind !== "delegator"
|
|
735
738
|
? goal
|
|
736
|
-
: paused(goal, "delegator", `${
|
|
739
|
+
: paused(goal, "delegator", `${controller.name}: ${input.reason}`);
|
|
737
740
|
yield* commitGoal(ctx, next);
|
|
738
741
|
yield* ctx.observe(sessionId);
|
|
739
742
|
return { result: "paused", goal: committed(next) };
|
package/dist/question/host.js
CHANGED
|
@@ -501,8 +501,7 @@ function respond(ctx, sessionId, input) {
|
|
|
501
501
|
if (row.pending !== null)
|
|
502
502
|
return yield* record({ result: "closed", status: row.pending.status });
|
|
503
503
|
// A person may always answer; an Agent only when the ask waits on it.
|
|
504
|
-
if (input.kind === "agent_answer" &&
|
|
505
|
-
!waitsOn(row, input.caller.agentId, input.caller.sessionId))
|
|
504
|
+
if (input.kind === "agent_answer" && !waitsOn(row, input.caller.agentId))
|
|
506
505
|
// A refusal changes nothing, so it must not spend the request id.
|
|
507
506
|
return { result: "refused", reason: "not_sender" };
|
|
508
507
|
if (input.kind === "answer" || input.kind === "agent_answer") {
|
|
@@ -516,9 +515,12 @@ function respond(ctx, sessionId, input) {
|
|
|
516
515
|
return yield* record(yield* offerResponse(ctx, row, response));
|
|
517
516
|
});
|
|
518
517
|
}
|
|
519
|
-
/**
|
|
520
|
-
|
|
521
|
-
|
|
518
|
+
/**
|
|
519
|
+
* Whether this ask waits on this Agent. Custody is the Agent's, not one of its
|
|
520
|
+
* Sessions: any Session of the Agent may answer, escalate or be reminded.
|
|
521
|
+
*/
|
|
522
|
+
function waitsOn(row, agentId) {
|
|
523
|
+
return row.waitingOn?.agentId === agentId;
|
|
522
524
|
}
|
|
523
525
|
function respondPerson(ctx, sessionId, input) {
|
|
524
526
|
return respond(ctx, sessionId, input).pipe(Effect.flatMap((result) => result.result === "refused"
|
|
@@ -549,6 +551,41 @@ function askAttention(row) {
|
|
|
549
551
|
function checkTimer(askId) {
|
|
550
552
|
return `check:${askId}`;
|
|
551
553
|
}
|
|
554
|
+
/** Rows one reconciliation page reads; the collection's own page ceiling. */
|
|
555
|
+
const reconcilePage = 64;
|
|
556
|
+
/**
|
|
557
|
+
* In an Agent another Agent made, a parked question that waits on a person
|
|
558
|
+
* only because it was asked before its turns carried their maker goes to
|
|
559
|
+
* that maker, as a new question would. A question a parent escalated stays
|
|
560
|
+
* with the person. Running it again changes nothing.
|
|
561
|
+
*/
|
|
562
|
+
function routeParkedAsksToMaker(ctx) {
|
|
563
|
+
return Effect.gen(function* () {
|
|
564
|
+
let after;
|
|
565
|
+
for (;;) {
|
|
566
|
+
const page = yield* ctx.state.asks.page({ after, limit: reconcilePage });
|
|
567
|
+
for (const row of page) {
|
|
568
|
+
if (row.status !== "parked" ||
|
|
569
|
+
row.pending !== null ||
|
|
570
|
+
row.waitingOn !== undefined ||
|
|
571
|
+
row.escalated !== undefined)
|
|
572
|
+
continue;
|
|
573
|
+
const maker = yield* ctx.sessionMaker(row.sessionId);
|
|
574
|
+
if (maker === null)
|
|
575
|
+
continue;
|
|
576
|
+
const moved = { ...row, waitingOn: maker };
|
|
577
|
+
yield* ctx.state.asks.put(moved);
|
|
578
|
+
yield* ctx.timers.set(checkTimer(row.askId), (yield* Clock.currentTimeMillis) + ctx.config.senderCheckMs);
|
|
579
|
+
yield* ctx.attention.set(row.sessionId, askAttention(moved));
|
|
580
|
+
yield* ctx.observe(row.sessionId);
|
|
581
|
+
}
|
|
582
|
+
const last = page.at(-1);
|
|
583
|
+
if (page.length < reconcilePage || last === undefined)
|
|
584
|
+
return;
|
|
585
|
+
after = last.askId;
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
}
|
|
552
589
|
/** Hand an ask to a person, preserving why it left the Agent chain. */
|
|
553
590
|
function escalateAsk(ctx, row, escalated) {
|
|
554
591
|
return Effect.gen(function* () {
|
|
@@ -578,13 +615,11 @@ function escalateFromAgent(ctx, sessionId, askId, caller, note, next) {
|
|
|
578
615
|
};
|
|
579
616
|
return answered;
|
|
580
617
|
}
|
|
581
|
-
if (row.waitingOn === undefined ||
|
|
582
|
-
!waitsOn(row, caller.agentId, caller.sessionId)) {
|
|
618
|
+
if (row.waitingOn === undefined || !waitsOn(row, caller.agentId)) {
|
|
583
619
|
// Replaying the same handoff lets the host retry its idempotent parent
|
|
584
620
|
// notification after an ambiguous transport failure, without moving it again.
|
|
585
621
|
if (row.escalated?.reason === "escalated" &&
|
|
586
622
|
row.escalated.by.agentId === caller.agentId &&
|
|
587
|
-
row.escalated.by.sessionId === caller.sessionId &&
|
|
588
623
|
row.escalated.note === note)
|
|
589
624
|
return row.waitingOn === undefined
|
|
590
625
|
? { result: "escalated", to: "person" }
|
|
@@ -599,7 +634,12 @@ function escalateFromAgent(ctx, sessionId, askId, caller, note, next) {
|
|
|
599
634
|
};
|
|
600
635
|
return refused;
|
|
601
636
|
}
|
|
602
|
-
|
|
637
|
+
// The escalating Session acts for the Agent the ask waits on.
|
|
638
|
+
const by = {
|
|
639
|
+
agentId: caller.agentId,
|
|
640
|
+
sessionId: caller.sessionId,
|
|
641
|
+
name: row.waitingOn.name,
|
|
642
|
+
};
|
|
603
643
|
// Preparation read the host outside SQLite. Do not use absent/stale evidence
|
|
604
644
|
// as proof of a root; closed/replayed items above need no host lookup.
|
|
605
645
|
if (next === undefined)
|
|
@@ -910,6 +950,13 @@ export function questionExtensionFor(routesToSender) {
|
|
|
910
950
|
attention: true,
|
|
911
951
|
timers: true,
|
|
912
952
|
hooks: {
|
|
953
|
+
// Opening the Agent, as reading it does, re-routes what an older
|
|
954
|
+
// build left with a person, once the Agent is bound.
|
|
955
|
+
start: (ctx) => ctx.config.routesToSender
|
|
956
|
+
? Effect.asVoid(Effect.forkScoped(ctx
|
|
957
|
+
.transact(routeParkedAsksToMaker(ctx))
|
|
958
|
+
.pipe(Effect.catch((cause) => Effect.logWarning("question.route_to_maker", cause)))))
|
|
959
|
+
: Effect.void,
|
|
913
960
|
onSettled: (ctx, page) => Effect.forEach(page, (run) => settle(ctx, run), { discard: true }),
|
|
914
961
|
onTimer: {
|
|
915
962
|
prepare: (ctx, timer) => Effect.gen(function* () {
|
|
@@ -929,7 +976,7 @@ export function questionExtensionFor(routesToSender) {
|
|
|
929
976
|
row.value.waitingOn !== undefined &&
|
|
930
977
|
row.value.pending === null) {
|
|
931
978
|
if (recipient !== undefined &&
|
|
932
|
-
waitsOn(row.value, recipient.agentId
|
|
979
|
+
waitsOn(row.value, recipient.agentId) &&
|
|
933
980
|
(status === "archived" || status === "absent"))
|
|
934
981
|
yield* escalateAsk(ctx, row.value, {
|
|
935
982
|
by: row.value.waitingOn,
|
|
@@ -996,8 +1043,13 @@ export function questionExtensionFor(routesToSender) {
|
|
|
996
1043
|
found.value.sessionId === sessionId &&
|
|
997
1044
|
found.value.pending === null &&
|
|
998
1045
|
found.value.waitingOn !== undefined &&
|
|
999
|
-
waitsOn(found.value, caller.agentId
|
|
1000
|
-
|
|
1046
|
+
waitsOn(found.value, caller.agentId)) {
|
|
1047
|
+
// The escalating Session's own parent is the next Agent up.
|
|
1048
|
+
const parent = yield* ctx.recipientParent({
|
|
1049
|
+
agentId: caller.agentId,
|
|
1050
|
+
sessionId: caller.sessionId,
|
|
1051
|
+
name: found.value.waitingOn.name,
|
|
1052
|
+
});
|
|
1001
1053
|
if (parent === null)
|
|
1002
1054
|
next = null;
|
|
1003
1055
|
else {
|
|
@@ -26,19 +26,22 @@ export declare function adoptDelegatedGoal(session: Pick<ShiitakeSession, "exten
|
|
|
26
26
|
commandId: string;
|
|
27
27
|
}>): Promise<void>;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
29
|
+
* The sub-agent view of one Agent (Wiki: agent-runtime-tools-and-clients,
|
|
30
|
+
* read-only sub-agent view). Its children are the Agents whose own record
|
|
31
|
+
* names it as `createdBy`, the one parent edge, so every Session of the Agent
|
|
32
|
+
* lists the same rows and nothing per Session is recorded. Accepted child
|
|
33
|
+
* command receipts are kept only to reconcile against their owner's
|
|
34
|
+
* settlement records for the sending conversation's goal guard; they grant
|
|
35
|
+
* no authority over a child.
|
|
35
36
|
*/
|
|
36
|
-
export declare function createConversationAgents(storage: WatchdogSqliteOwner
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
export declare function createConversationAgents(storage: WatchdogSqliteOwner,
|
|
38
|
+
/** The Agent this host runs, read when used: the parent of every Agent it created. */
|
|
39
|
+
agentId: () => string): {
|
|
40
|
+
/** Bind the caller and send watching to the Agent's existing directory. */
|
|
41
|
+
recording: <Directory extends SendingDirectory>(directory: Directory) => Directory;
|
|
39
42
|
/** Agent-control tools bound to the conversation that acquires them. */
|
|
40
43
|
control: (directoryFor: (parentSessionId: string | undefined) => AgentControlDirectory) => CapabilitySource;
|
|
41
|
-
/** The footer rows
|
|
44
|
+
/** The footer rows: this Agent's children; archived and unknown Agents leave it. */
|
|
42
45
|
source: (directory: Pick<AgentControlDirectory, "list"> & Pick<SubagentSource, "open">) => SubagentSource;
|
|
43
46
|
};
|
|
44
47
|
/**
|
|
@@ -12,10 +12,6 @@ export function assertOrdinaryAgentCreation(input) {
|
|
|
12
12
|
if (input.extensions?.some((id) => !held.has(id)))
|
|
13
13
|
throw new AgentCreateRefused("exceeds_creator", "this creation door grants only the ordinary base roster");
|
|
14
14
|
}
|
|
15
|
-
const conversationAgentRow = Schema.Struct({
|
|
16
|
-
agent_id: Schema.String,
|
|
17
|
-
session_id: Schema.NullOr(Schema.String),
|
|
18
|
-
});
|
|
19
15
|
const delegatedCommandRow = Schema.Struct({
|
|
20
16
|
parent_session_id: Schema.String,
|
|
21
17
|
agent_id: Schema.String,
|
|
@@ -50,58 +46,35 @@ export async function adoptDelegatedGoal(session, input) {
|
|
|
50
46
|
});
|
|
51
47
|
}
|
|
52
48
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
49
|
+
* The sub-agent view of one Agent (Wiki: agent-runtime-tools-and-clients,
|
|
50
|
+
* read-only sub-agent view). Its children are the Agents whose own record
|
|
51
|
+
* names it as `createdBy`, the one parent edge, so every Session of the Agent
|
|
52
|
+
* lists the same rows and nothing per Session is recorded. Accepted child
|
|
53
|
+
* command receipts are kept only to reconcile against their owner's
|
|
54
|
+
* settlement records for the sending conversation's goal guard; they grant
|
|
55
|
+
* no authority over a child.
|
|
59
56
|
*/
|
|
60
|
-
export function createConversationAgents(storage
|
|
57
|
+
export function createConversationAgents(storage,
|
|
58
|
+
/** The Agent this host runs, read when used: the parent of every Agent it created. */
|
|
59
|
+
agentId) {
|
|
61
60
|
// Composing a host does no storage I/O; the first record or read prepares it.
|
|
62
61
|
let prepared = false;
|
|
63
62
|
function sql() {
|
|
64
63
|
if (!prepared) {
|
|
65
|
-
storage.sql.exec("CREATE TABLE IF NOT EXISTS oyster_conversation_agents (parent_session_id TEXT NOT NULL, agent_id TEXT NOT NULL, session_id TEXT, at INTEGER NOT NULL, PRIMARY KEY (parent_session_id, agent_id)) STRICT");
|
|
66
|
-
storage.sql.exec("CREATE INDEX IF NOT EXISTS idx_oyster_conversation_agents_parent ON oyster_conversation_agents(parent_session_id, at)");
|
|
67
64
|
storage.sql.exec("CREATE TABLE IF NOT EXISTS oyster_delegated_commands (parent_session_id TEXT NOT NULL, agent_id TEXT NOT NULL, session_id TEXT NOT NULL, command_id TEXT NOT NULL PRIMARY KEY, at INTEGER NOT NULL) STRICT");
|
|
68
65
|
prepared = true;
|
|
69
66
|
}
|
|
70
67
|
return storage.sql;
|
|
71
68
|
}
|
|
72
|
-
/**
|
|
73
|
-
function
|
|
74
|
-
sql().exec("INSERT OR
|
|
75
|
-
|
|
76
|
-
/** A send may not know its Session until the recipient accepts it. */
|
|
77
|
-
function sent(parentSessionId, agentId, sessionId, commandId) {
|
|
78
|
-
sql().exec("INSERT INTO oyster_conversation_agents(parent_session_id, agent_id, session_id, at) VALUES (?, ?, ?, ?) ON CONFLICT(parent_session_id, agent_id) DO UPDATE SET session_id = excluded.session_id, at = excluded.at", parentSessionId, agentId, sessionId ?? null, Date.now());
|
|
79
|
-
if (sessionId !== undefined) {
|
|
80
|
-
sql().exec("INSERT OR REPLACE INTO oyster_delegated_commands(parent_session_id, agent_id, session_id, command_id, at) VALUES (?, ?, ?, ?, ?)", parentSessionId, agentId, sessionId, commandId, Date.now());
|
|
81
|
-
sql().exec("DELETE FROM oyster_delegated_commands WHERE command_id NOT IN (SELECT command_id FROM oyster_delegated_commands ORDER BY at DESC LIMIT ?)", maxWatchedCommands);
|
|
82
|
-
}
|
|
69
|
+
/** Watch one accepted child command until its owner records settlement. */
|
|
70
|
+
function watch(sendingSessionId, childAgentId, sessionId, commandId) {
|
|
71
|
+
sql().exec("INSERT OR REPLACE INTO oyster_delegated_commands(parent_session_id, agent_id, session_id, command_id, at) VALUES (?, ?, ?, ?, ?)", sendingSessionId, childAgentId, sessionId, commandId, Date.now());
|
|
72
|
+
sql().exec("DELETE FROM oyster_delegated_commands WHERE command_id NOT IN (SELECT command_id FROM oyster_delegated_commands ORDER BY at DESC LIMIT ?)", maxWatchedCommands);
|
|
83
73
|
}
|
|
84
|
-
/**
|
|
85
|
-
function recording(
|
|
86
|
-
const {
|
|
87
|
-
let recorded = directory;
|
|
88
|
-
if (parentSessionId !== undefined)
|
|
89
|
-
recorded = {
|
|
90
|
-
...recorded,
|
|
91
|
-
sentSessions: (sourceSessionId, agentId) => sql()
|
|
92
|
-
.exec("SELECT session_id FROM oyster_conversation_agents WHERE parent_session_id = ? AND agent_id = ? AND session_id IS NOT NULL", sourceSessionId, agentId)
|
|
93
|
-
.toArray()
|
|
94
|
-
.map((row) => Schema.decodeUnknownSync(Schema.Struct({ session_id: Schema.String }))(row).session_id),
|
|
95
|
-
};
|
|
96
|
-
if (create !== undefined && parentSessionId !== undefined)
|
|
97
|
-
recorded = {
|
|
98
|
-
...recorded,
|
|
99
|
-
create: async (request, signal) => {
|
|
100
|
-
const agent = await create(request, signal);
|
|
101
|
-
created(parentSessionId, agent.agentId);
|
|
102
|
-
return agent;
|
|
103
|
-
},
|
|
104
|
-
};
|
|
74
|
+
/** The Agent's directory: it names its caller and watches accepted sends. */
|
|
75
|
+
function recording(directory) {
|
|
76
|
+
const { send } = directory;
|
|
77
|
+
let recorded = { ...directory, callerAgentId: agentId };
|
|
105
78
|
if (send !== undefined)
|
|
106
79
|
recorded = {
|
|
107
80
|
...recorded,
|
|
@@ -109,7 +82,8 @@ export function createConversationAgents(storage) {
|
|
|
109
82
|
const accepted = await send(task, sourceSessionId, signal, invocation);
|
|
110
83
|
if (accepted.status === "accepted") {
|
|
111
84
|
const sessionId = accepted.sessionId ?? task.sessionId;
|
|
112
|
-
|
|
85
|
+
if (sessionId !== undefined)
|
|
86
|
+
watch(sourceSessionId, task.agentId, sessionId, accepted.commandId);
|
|
113
87
|
// A send that opens a new Session puts it under a goal, so the
|
|
114
88
|
// lane keeps working until it reports complete or blocked. A
|
|
115
89
|
// retry replays the same request id, so the goal is set once.
|
|
@@ -136,17 +110,17 @@ export function createConversationAgents(storage) {
|
|
|
136
110
|
return recorded;
|
|
137
111
|
}
|
|
138
112
|
return {
|
|
139
|
-
/** Bind
|
|
113
|
+
/** Bind the caller and send watching to the Agent's existing directory. */
|
|
140
114
|
recording,
|
|
141
115
|
/** Agent-control tools bound to the conversation that acquires them. */
|
|
142
116
|
control: (directoryFor) => ({
|
|
143
|
-
id: createAgentControlSource(recording(
|
|
117
|
+
id: createAgentControlSource(recording(directoryFor(undefined))).id,
|
|
144
118
|
acquire: (context) => {
|
|
145
119
|
const parentSessionId = context.session?.sessionId;
|
|
146
|
-
return createAgentControlSource(recording(
|
|
120
|
+
return createAgentControlSource(recording(directoryFor(parentSessionId))).acquire(context);
|
|
147
121
|
},
|
|
148
122
|
}),
|
|
149
|
-
/** The footer rows
|
|
123
|
+
/** The footer rows: this Agent's children; archived and unknown Agents leave it. */
|
|
150
124
|
source: (directory) => {
|
|
151
125
|
const polling = new Set();
|
|
152
126
|
const signal = new AbortController().signal;
|
|
@@ -228,18 +202,16 @@ export function createConversationAgents(storage) {
|
|
|
228
202
|
poll(commandId);
|
|
229
203
|
return live.length > 0;
|
|
230
204
|
},
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
: [{ agentId: row.agent_id, name, sessionId: row.session_id }];
|
|
242
|
-
});
|
|
205
|
+
// Every Session of this Agent lists the same children; the subagents
|
|
206
|
+
// view shows each child's lead Session.
|
|
207
|
+
read: async (_sessionId, limit) => {
|
|
208
|
+
const agents = (await directory.list(new AbortController().signal))
|
|
209
|
+
.filter((agent) => agent.createdBy === agentId())
|
|
210
|
+
.map((agent) => ({
|
|
211
|
+
agentId: agent.agentId,
|
|
212
|
+
name: agent.name,
|
|
213
|
+
sessionId: null,
|
|
214
|
+
}));
|
|
243
215
|
return {
|
|
244
216
|
agents: agents.slice(0, limit),
|
|
245
217
|
more: Math.max(0, agents.length - limit),
|
|
@@ -227,33 +227,33 @@ Session-owned goal controls and their visible projection.
|
|
|
227
227
|
|
|
228
228
|
#### Type Declaration
|
|
229
229
|
|
|
230
|
-
| Name | Type | Default value | Description
|
|
231
|
-
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
|
|
232
|
-
| <a id="property-id"></a> `id` | `string` & `Brand`\<`"ExtensionId"`\> | - | Stable extension identity.
|
|
233
|
-
| <a id="property-commands"></a> `commands` | `object` | - | Goal commands admitted by the Session owner.
|
|
234
|
-
| `commands.controlAgent` | `object` | - |
|
|
235
|
-
| `commands.controlAgent.scope` | `"session"` | `"session"` | The child's Session owns this goal.
|
|
236
|
-
| `commands.controlAgent.input` | `Struct`\<\{ `action`: `Literals`\<readonly \[`"pause"`, `"resume"`, `"clear"`\]\>; `reason`: `String`; \}\> | - | Requested control; caller identity comes only from the host.
|
|
237
|
-
| `commands.controlAgent.output` | `Union`\<readonly \[`Struct`\<\{ `result`: `Literal`\<`"paused"`\>; `goal`: `Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[..., ...\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<...\>\>; \}\>; \}\>, `Struct`\<\{ `result`: `Literal`\<`"resumed"`\>; `goal`: `Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[..., ...\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<...\>\>; \}\>; \}\>, `Struct`\<\{ `result`: `Literal`\<`"cleared"`\>; \}\>, `Struct`\<\{ `result`: `Literal`\<`"no_goal"`\>; \}\>, `Struct`\<\{ `result`: `Literal`\<`"refused"`\>; `reason`: `Literals`\<readonly \[`"not_delegator"`, `"not_paused_by_delegator"`\]\>; \}\>\]\> | - | Applied control or an explicit refusal without mutation.
|
|
238
|
-
| `commands.goal` | `object` | - | Open or answer the human goal controls.
|
|
239
|
-
| `commands.goal.scope` | `"session"` | `"session"` | The Session owns this goal.
|
|
240
|
-
| `commands.goal.input` | `Union`\<readonly \[`Struct`\<\{ `action`: `Literal`\<`"set"`\>; `objective`: `String`; `requestId`: `String`; `expectedRevision`: `optional`\<`NullOr`\<`String`\>\>; `confirmed`: `optional`\<`Boolean`\>; \}\>, `Struct`\<\{ `action`: `Literals`\<readonly \[`"pause"`, `"resume"`, `"replace"`, `"clear"`, `"clear-ask"`\]\>; `confirmed`: `optional`\<`Boolean`\>; \}\>, `Struct`\<\{ \}\>\]\> | `GoalCommandInput` | Decode the control action.
|
|
241
|
-
| `commands.goal.output` | `declare`\<`WhistleCatalogStepV1`, `WhistleCatalogStepV1`\> | `CatalogStep` | Return the server-owned conversation step.
|
|
242
|
-
| `commands.pause` | `object` | - | Pause work on the current goal.
|
|
243
|
-
| `commands.pause.scope` | `"session"` | `"session"` | The Session owns this goal.
|
|
244
|
-
| `commands.pause.input` | `Struct`\<\{ \}\> | - | No additional arguments are required.
|
|
245
|
-
| `commands.pause.output` | `Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<\{ `kind`: `Literals`\<readonly \[`"person"`, `"delegator"`, `"blocked"`, `"stalled"`, `"cancelled"`, `"failed"`, `"no-terminal"`\]\>; `detail`: `NullOr`\<`String`\>; \}\>\>; \}\> | `Goal` | Return the paused goal.
|
|
246
|
-
| `commands.resume` | `object` | - | Resume work on a paused goal.
|
|
247
|
-
| `commands.resume.scope` | `"session"` | `"session"` | The Session owns this goal.
|
|
248
|
-
| `commands.resume.input` | `Struct`\<\{ \}\> | - | No additional arguments are required.
|
|
249
|
-
| `commands.resume.output` | `Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<\{ `kind`: `Literals`\<readonly \[`"person"`, `"delegator"`, `"blocked"`, `"stalled"`, `"cancelled"`, `"failed"`, `"no-terminal"`\]\>; `detail`: `NullOr`\<`String`\>; \}\>\>; \}\> | `Goal` | Return the active goal.
|
|
250
|
-
| `commands.clear` | `object` | - | Clear the current objective.
|
|
251
|
-
| `commands.clear.scope` | `"session"` | `"session"` | The Session owns this goal.
|
|
252
|
-
| `commands.clear.input` | `Struct`\<\{ \}\> | - | No additional arguments are required.
|
|
253
|
-
| `commands.clear.output` | `Struct`\<\{ \}\> | - | A successful clear has no result fields.
|
|
254
|
-
| `commands.set` | `object` | - | Set an objective against the revision the person saw.
|
|
255
|
-
| `commands.set.scope` | `"session"` | `"session"` | The Session owns this goal.
|
|
256
|
-
| `commands.set.input` | `Struct`\<\{ `objective`: `String`; `expectedRevision`: `NullOr`\<`String`\>; `requestId`: `String`; `adoptCommandId`: `optionalKey`\<`String`\>; \}\> | - | Decode the new objective and replacement fence.
|
|
257
|
-
| `commands.set.output` | `Struct`\<\{ `goal`: `Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<\{ `kind`: `Literals`\<...\>; `detail`: `NullOr`\<...\>; \}\>\>; \}\>; `accepted`: `Struct`\<\{ `status`: `Literal`\<`"accepted"`\>; `commandId`: `String`; \}\>; \}\> | - | Return the goal and its admission receipt.
|
|
258
|
-
| <a id="property-projection"></a> `projection` | `object` | - | Current and ended goals visible to clients.
|
|
259
|
-
| `projection.schema` | `Struct`\<\{ `goal`: `NullOr`\<`Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<\{ `kind`: `Literals`\<...\>; `detail`: `NullOr`\<...\>; \}\>\>; \}\>\>; `ended`: `$Array`\<`Struct`\<\{ `sequence`: `Int`; `objective`: `String`; `outcome`: `Literals`\<readonly \[`"achieved"`, `"cleared"`\]\>; `reason`: `NullOr`\<`String`\>; `clearedBy`: `optionalKey`\<`NonEmptyString`\>; `endedAt`: `Int`; `afterSequence`: `Int`; \}\>\>; `omitted`: `Int`; \}\> | `GoalProjection` | Decoder for the goal projection.
|
|
230
|
+
| Name | Type | Default value | Description |
|
|
231
|
+
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -------------------------------------------------------------------------------------------- |
|
|
232
|
+
| <a id="property-id"></a> `id` | `string` & `Brand`\<`"ExtensionId"`\> | - | Stable extension identity. |
|
|
233
|
+
| <a id="property-commands"></a> `commands` | `object` | - | Goal commands admitted by the Session owner. |
|
|
234
|
+
| `commands.controlAgent` | `object` | - | The delegating or making Agent's controls, from any of its Sessions; never a person command. |
|
|
235
|
+
| `commands.controlAgent.scope` | `"session"` | `"session"` | The child's Session owns this goal. |
|
|
236
|
+
| `commands.controlAgent.input` | `Struct`\<\{ `action`: `Literals`\<readonly \[`"pause"`, `"resume"`, `"clear"`\]\>; `reason`: `String`; \}\> | - | Requested control; caller identity comes only from the host. |
|
|
237
|
+
| `commands.controlAgent.output` | `Union`\<readonly \[`Struct`\<\{ `result`: `Literal`\<`"paused"`\>; `goal`: `Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[..., ...\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<...\>\>; \}\>; \}\>, `Struct`\<\{ `result`: `Literal`\<`"resumed"`\>; `goal`: `Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[..., ...\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<...\>\>; \}\>; \}\>, `Struct`\<\{ `result`: `Literal`\<`"cleared"`\>; \}\>, `Struct`\<\{ `result`: `Literal`\<`"no_goal"`\>; \}\>, `Struct`\<\{ `result`: `Literal`\<`"refused"`\>; `reason`: `Literals`\<readonly \[`"not_delegator"`, `"not_paused_by_delegator"`\]\>; \}\>\]\> | - | Applied control or an explicit refusal without mutation. |
|
|
238
|
+
| `commands.goal` | `object` | - | Open or answer the human goal controls. |
|
|
239
|
+
| `commands.goal.scope` | `"session"` | `"session"` | The Session owns this goal. |
|
|
240
|
+
| `commands.goal.input` | `Union`\<readonly \[`Struct`\<\{ `action`: `Literal`\<`"set"`\>; `objective`: `String`; `requestId`: `String`; `expectedRevision`: `optional`\<`NullOr`\<`String`\>\>; `confirmed`: `optional`\<`Boolean`\>; \}\>, `Struct`\<\{ `action`: `Literals`\<readonly \[`"pause"`, `"resume"`, `"replace"`, `"clear"`, `"clear-ask"`\]\>; `confirmed`: `optional`\<`Boolean`\>; \}\>, `Struct`\<\{ \}\>\]\> | `GoalCommandInput` | Decode the control action. |
|
|
241
|
+
| `commands.goal.output` | `declare`\<`WhistleCatalogStepV1`, `WhistleCatalogStepV1`\> | `CatalogStep` | Return the server-owned conversation step. |
|
|
242
|
+
| `commands.pause` | `object` | - | Pause work on the current goal. |
|
|
243
|
+
| `commands.pause.scope` | `"session"` | `"session"` | The Session owns this goal. |
|
|
244
|
+
| `commands.pause.input` | `Struct`\<\{ \}\> | - | No additional arguments are required. |
|
|
245
|
+
| `commands.pause.output` | `Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<\{ `kind`: `Literals`\<readonly \[`"person"`, `"delegator"`, `"blocked"`, `"stalled"`, `"cancelled"`, `"failed"`, `"no-terminal"`\]\>; `detail`: `NullOr`\<`String`\>; \}\>\>; \}\> | `Goal` | Return the paused goal. |
|
|
246
|
+
| `commands.resume` | `object` | - | Resume work on a paused goal. |
|
|
247
|
+
| `commands.resume.scope` | `"session"` | `"session"` | The Session owns this goal. |
|
|
248
|
+
| `commands.resume.input` | `Struct`\<\{ \}\> | - | No additional arguments are required. |
|
|
249
|
+
| `commands.resume.output` | `Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<\{ `kind`: `Literals`\<readonly \[`"person"`, `"delegator"`, `"blocked"`, `"stalled"`, `"cancelled"`, `"failed"`, `"no-terminal"`\]\>; `detail`: `NullOr`\<`String`\>; \}\>\>; \}\> | `Goal` | Return the active goal. |
|
|
250
|
+
| `commands.clear` | `object` | - | Clear the current objective. |
|
|
251
|
+
| `commands.clear.scope` | `"session"` | `"session"` | The Session owns this goal. |
|
|
252
|
+
| `commands.clear.input` | `Struct`\<\{ \}\> | - | No additional arguments are required. |
|
|
253
|
+
| `commands.clear.output` | `Struct`\<\{ \}\> | - | A successful clear has no result fields. |
|
|
254
|
+
| `commands.set` | `object` | - | Set an objective against the revision the person saw. |
|
|
255
|
+
| `commands.set.scope` | `"session"` | `"session"` | The Session owns this goal. |
|
|
256
|
+
| `commands.set.input` | `Struct`\<\{ `objective`: `String`; `expectedRevision`: `NullOr`\<`String`\>; `requestId`: `String`; `adoptCommandId`: `optionalKey`\<`String`\>; \}\> | - | Decode the new objective and replacement fence. |
|
|
257
|
+
| `commands.set.output` | `Struct`\<\{ `goal`: `Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<\{ `kind`: `Literals`\<...\>; `detail`: `NullOr`\<...\>; \}\>\>; \}\>; `accepted`: `Struct`\<\{ `status`: `Literal`\<`"accepted"`\>; `commandId`: `String`; \}\>; \}\> | - | Return the goal and its admission receipt. |
|
|
258
|
+
| <a id="property-projection"></a> `projection` | `object` | - | Current and ended goals visible to clients. |
|
|
259
|
+
| `projection.schema` | `Struct`\<\{ `goal`: `NullOr`\<`Struct`\<\{ `revision`: `String`; `objective`: `String`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`\]\>; `startedAt`: `Int`; `pauseCause`: `NullOr`\<`Struct`\<\{ `kind`: `Literals`\<...\>; `detail`: `NullOr`\<...\>; \}\>\>; \}\>\>; `ended`: `$Array`\<`Struct`\<\{ `sequence`: `Int`; `objective`: `String`; `outcome`: `Literals`\<readonly \[`"achieved"`, `"cleared"`\]\>; `reason`: `NullOr`\<`String`\>; `clearedBy`: `optionalKey`\<`NonEmptyString`\>; `endedAt`: `Int`; `afterSequence`: `Int`; \}\>\>; `omitted`: `Int`; \}\> | `GoalProjection` | Decoder for the goal projection. |
|
|
@@ -74,29 +74,30 @@ delivery.
|
|
|
74
74
|
### createConversationAgents()
|
|
75
75
|
|
|
76
76
|
```ts
|
|
77
|
-
function createConversationAgents(storage): object;
|
|
77
|
+
function createConversationAgents(storage, agentId): object;
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
child.
|
|
80
|
+
The sub-agent view of one Agent (Wiki: agent-runtime-tools-and-clients,
|
|
81
|
+
read-only sub-agent view). Its children are the Agents whose own record names it
|
|
82
|
+
as `createdBy`, the one parent edge, so every Session of the Agent lists the
|
|
83
|
+
same rows and nothing per Session is recorded. Accepted child command receipts
|
|
84
|
+
are kept only to reconcile against their owner's settlement records for the
|
|
85
|
+
sending conversation's goal guard; they grant no authority over a child.
|
|
86
86
|
|
|
87
87
|
#### Parameters
|
|
88
88
|
|
|
89
|
-
| Parameter | Type |
|
|
90
|
-
| --------- | --------------------- |
|
|
91
|
-
| `storage` | `WatchdogSqliteOwner` |
|
|
89
|
+
| Parameter | Type | Description |
|
|
90
|
+
| --------- | --------------------- | ------------------------------------------------------------------------------- |
|
|
91
|
+
| `storage` | `WatchdogSqliteOwner` | - |
|
|
92
|
+
| `agentId` | () => `string` | The Agent this host runs, read when used: the parent of every Agent it created. |
|
|
92
93
|
|
|
93
94
|
#### Returns
|
|
94
95
|
|
|
95
|
-
| Name | Type | Description
|
|
96
|
-
| ------------- | ------------------------------------------------------------------------ |
|
|
97
|
-
| `recording()` | \<`Directory`\>(`
|
|
98
|
-
| `control()` | (`directoryFor`) => `CapabilitySource` | Agent-control tools bound to the conversation that acquires them.
|
|
99
|
-
| `source()` | (`directory`) => [`SubagentSource`](../subagents/host.md#subagentsource) | The footer rows
|
|
96
|
+
| Name | Type | Description |
|
|
97
|
+
| ------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
98
|
+
| `recording()` | \<`Directory`\>(`directory`) => `Directory` | Bind the caller and send watching to the Agent's existing directory. The Agent's directory: it names its caller and watches accepted sends. |
|
|
99
|
+
| `control()` | (`directoryFor`) => `CapabilitySource` | Agent-control tools bound to the conversation that acquires them. |
|
|
100
|
+
| `source()` | (`directory`) => [`SubagentSource`](../subagents/host.md#subagentsource) | The footer rows: this Agent's children; archived and unknown Agents leave it. |
|
|
100
101
|
|
|
101
102
|
---
|
|
102
103
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/shiitake-extensions",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.8",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Botanical's product Shiitake extensions: goal, loop and Almanac on the generic extension surface",
|
|
@@ -120,9 +120,9 @@
|
|
|
120
120
|
"dependencies": {
|
|
121
121
|
"@fungi.computer/almanac": "0.2.1",
|
|
122
122
|
"@fungi.computer/cairn": "0.1.0",
|
|
123
|
-
"@fungi.computer/knapsack": "0.4.
|
|
124
|
-
"@fungi.computer/mycelium": "0.4.
|
|
125
|
-
"@fungi.computer/shiitake": "0.20.
|
|
123
|
+
"@fungi.computer/knapsack": "0.4.19",
|
|
124
|
+
"@fungi.computer/mycelium": "0.4.6",
|
|
125
|
+
"@fungi.computer/shiitake": "0.20.3",
|
|
126
126
|
"@fungi.computer/watchdog": "0.1.4",
|
|
127
127
|
"@fungi.computer/whistle": "0.3.0",
|
|
128
128
|
"effect": "4.0.2",
|