@tshu-w/pi-agents 0.1.1 → 0.2.1
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 +27 -20
- package/bin/daemon.mjs +32 -14
- package/bin/host.mjs +9 -1
- package/bin/pd.mjs +87 -42
- package/docs/HOSTS.md +111 -0
- package/docs/PROGRAM.md +39 -114
- package/docs/SPEC.md +109 -161
- package/package.json +7 -5
- package/src/agents/agents.ts +129 -55
- package/src/agents/registry.ts +62 -10
- package/src/agents/search.ts +21 -4
- package/src/agents/tool.ts +41 -13
- package/src/daemon/client.mjs +4 -1
- package/src/host/client.mjs +30 -5
- package/src/host/extension.ts +38 -14
- package/src/host/rpc-client.mjs +380 -0
- package/src/index.ts +44 -16
- package/src/output.ts +5 -1
- package/src/programs/codemode.ts +2 -2
- package/src/programs/execute.ts +150 -34
- package/src/programs/host-patches.ts +56 -27
- package/src/programs/loadout.ts +18 -3
- package/src/programs/programs.ts +128 -20
- package/src/programs/run-output.mjs +11 -0
- package/src/programs/sandbox.ts +17 -4
- package/src/programs/scope.ts +15 -7
- package/src/programs/tool.ts +172 -16
- package/src/render-call.ts +113 -15
- package/src/roots/guard.mjs +8 -2
- package/src/roots/paths.mjs +4 -4
- package/src/roots/queue.ts +52 -0
- package/src/roots/report.ts +12 -6
- package/src/roots/rpc.ts +618 -0
- package/src/roots/runtime.ts +17 -2
- package/src/roots/transport.mjs +41 -23
- package/src/ui/message.ts +24 -0
- package/src/ui/panel.ts +39 -7
- package/src/ui/queue.ts +47 -0
- package/src/ui/viewer.ts +182 -38
- package/src/workbench.mjs +91 -51
- package/docs/WORKBENCH.md +0 -167
package/docs/SPEC.md
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
# Pi Agents Specification
|
|
2
2
|
|
|
3
|
-
Pi Agents lets Agents in Pi discover, message, and wait for each other.
|
|
4
|
-
Programs built on these operations are specified in PROGRAM.md.
|
|
3
|
+
Pi Agents lets Agents in Pi discover, message, and wait for each other. Programs built on these operations are specified in PROGRAM.md.
|
|
5
4
|
|
|
6
|
-
Terms follow Pi's
|
|
7
|
-
[Pico5 specification](https://github.com/earendil-works/pi/blob/main/packages/durable/docs/pico-v5.md).
|
|
5
|
+
Terms follow Pi's [Pi Durable specification](https://github.com/earendil-works/pi/blob/main/packages/durable/docs/spec.md).
|
|
8
6
|
|
|
9
7
|
## 1. Semantic model
|
|
10
8
|
|
|
11
|
-
An **Agent** is an addressable conversation with a stable identity. The Agent
|
|
12
|
-
that spawns another Agent is its **owner**. A root Agent has no owner and is
|
|
13
|
-
usually opened by a user. Ownership forms trees.
|
|
9
|
+
An **Agent** is an addressable conversation with a stable identity. The Agent that spawns another Agent is its **owner**. A root Agent has no owner and is usually opened by a user. Ownership forms trees.
|
|
14
10
|
|
|
15
|
-
An Agent is shown by its name and **short ID**: the shortest prefix of its
|
|
16
|
-
ID, at least 8 characters, that no other Agent visible to the reader has.
|
|
17
|
-
An address is an ID, a name, or a unique ID prefix, tried in that order.
|
|
11
|
+
An Agent is shown by its name and **short ID**: the shortest prefix of its ID, at least 8 characters, that no other Agent visible to the reader has. An address is an ID, a name, or a unique ID prefix, tried in that order.
|
|
18
12
|
|
|
19
|
-
A **message** carries text from one Agent to another. An **input** asks the
|
|
20
|
-
recipient to act. A **write** only adds to the recipient's conversation.
|
|
13
|
+
A **message** carries text from one Agent to another. An **input** asks the recipient to act. A **write** only adds to the recipient's conversation.
|
|
21
14
|
|
|
22
|
-
A **turn** is one continuous run of an Agent's model and tools. Its final
|
|
23
|
-
assistant message is the **answer** to the inputs it handled.
|
|
15
|
+
A **turn** is one continuous run of an Agent's model and tools. Its final assistant message is the **answer** to the inputs it handled.
|
|
24
16
|
|
|
25
17
|
An owner can **wait** for answers to the inputs it sends to its owned Agents.
|
|
26
18
|
|
|
@@ -30,94 +22,61 @@ An owner can **wait** for answers to the inputs it sends to its owned Agents.
|
|
|
30
22
|
|
|
31
23
|
### 2.1 spawn
|
|
32
24
|
|
|
33
|
-
`spawn` creates a named, owned Agent and sends it a first input. It
|
|
34
|
-
accepts an optional working directory, model, thinking level, and forked
|
|
35
|
-
context, and returns the Agent's ID. Names are unique among siblings.
|
|
25
|
+
`spawn` creates a named, owned Agent and sends it a first input. It accepts an optional working directory, model, thinking level, and forked context, and returns the Agent's ID. Names are unique among siblings.
|
|
36
26
|
|
|
37
27
|
### 2.2 send
|
|
38
28
|
|
|
39
|
-
`send` sends a message to a visible Agent by address. An ambiguous or
|
|
40
|
-
unknown address is rejected.
|
|
29
|
+
`send` sends a message to a visible Agent by address. An ambiguous or unknown address is rejected.
|
|
41
30
|
|
|
42
|
-
An input to an Agent with a turn in progress is either answered by the current turn
|
|
43
|
-
(`steer`) or by a new turn after it (`followUp`, the default).
|
|
31
|
+
An input to an Agent with a turn in progress is either answered by the current turn (`steer`) or by a new turn after it (`followUp`, the default).
|
|
44
32
|
|
|
45
|
-
A write is added at the recipient's next tool boundary, or at once if it is
|
|
46
|
-
|
|
33
|
+
A write is added at the recipient's next tool boundary, or at once if it is idle. A write can go to several Agents at once.
|
|
34
|
+
|
|
35
|
+
When the user of a root Agent clears its queued messages, messages from other Agents stay queued. After an Agent's turn is stopped, messages from other Agents, notifications included, become writes until its next input from its user or owner.
|
|
47
36
|
|
|
48
37
|
### 2.3 wait
|
|
49
38
|
|
|
50
|
-
`wait` returns results of inputs sent to owned Agents. It can target
|
|
51
|
-
specific Agents and take a timeout.
|
|
39
|
+
`wait` returns results of inputs sent to owned Agents. It can target specific Agents and take a timeout.
|
|
52
40
|
|
|
53
41
|
### 2.4 list
|
|
54
42
|
|
|
55
|
-
`list` returns visible Agents with their ID, name, working directory, and
|
|
56
|
-
state.
|
|
43
|
+
`list` returns visible Agents with their ID, name, working directory, state, and latest request: the last user message or input it received.
|
|
57
44
|
|
|
58
45
|
### 2.5 abort
|
|
59
46
|
|
|
60
|
-
`abort` stops an owned Agent's current turn and withdraws its queued
|
|
61
|
-
inputs. The Agent stays available.
|
|
47
|
+
`abort` stops an owned Agent's current turn and withdraws its queued inputs. The Agent stays available.
|
|
62
48
|
|
|
63
49
|
## 3. Lifecycle
|
|
64
50
|
|
|
65
|
-
An Agent is `running` while a turn is in progress, `waiting` while its turn
|
|
66
|
-
waits in `wait` (§4), `queued` while its next turn waits for a slot (§4),
|
|
67
|
-
and `idle` otherwise. An Agent goes offline when its runtime unloads it; it
|
|
68
|
-
stays `idle`.
|
|
51
|
+
An Agent is `running` while a turn is in progress, `waiting` while its turn waits in `wait` (§4), `queued` while its next turn waits for a slot (§4), and `idle` otherwise. An Agent goes offline when its runtime unloads it; it stays `idle`.
|
|
69
52
|
|
|
70
|
-
`send` returns once the recipient's runtime accepts the message, waking it
|
|
71
|
-
if needed. Acceptance does not mean the recipient has handled it; a message
|
|
72
|
-
not yet handled is lost if the recipient exits.
|
|
53
|
+
`send` returns once the recipient's runtime accepts the message, waking it if needed. Acceptance does not mean the recipient has handled it; a message not yet handled is lost if the recipient exits.
|
|
73
54
|
|
|
74
|
-
An input to an offline Agent wakes it
|
|
55
|
+
An input to an offline Agent wakes it; a write to one is rejected.
|
|
75
56
|
|
|
76
|
-
Owned Agents run independently of their owner's turns. When their owner
|
|
77
|
-
goes offline, they go offline too, from the bottom of the tree up, and their
|
|
78
|
-
unfinished inputs end as `aborted`. They return as `idle` when their owner
|
|
79
|
-
is loaded again.
|
|
57
|
+
Owned Agents run independently of their owner's turns. When their owner goes offline, they go offline too, from the bottom of the tree up, and their unfinished inputs end as `aborted`. They return as `idle` when their owner is loaded again.
|
|
80
58
|
|
|
81
|
-
On abort or when going offline, work that has not stopped within a timeout
|
|
82
|
-
is abandoned: it no longer counts as live work and may keep running until
|
|
83
|
-
the process exits; the timeout is reported.
|
|
59
|
+
On abort or when going offline, work that has not stopped within a timeout is abandoned: it no longer counts as live work and may keep running until the process exits; the timeout is reported.
|
|
84
60
|
|
|
85
|
-
A root Agent is `running` while it has a turn in progress or pending messages,
|
|
86
|
-
or while its tree has live work (§7 Task panel); otherwise it is `idle`.
|
|
61
|
+
A root Agent is `running` while it has a turn in progress or pending messages, or while its tree has live work (§7 Task panel); otherwise it is `idle`.
|
|
87
62
|
|
|
88
63
|
## 4. Visibility and limits
|
|
89
64
|
|
|
90
|
-
An Agent sees every Agent in its own tree. A root Agent also sees other root
|
|
91
|
-
Agents.
|
|
65
|
+
An Agent sees every Agent in its own tree. A root Agent also sees other root Agents.
|
|
92
66
|
|
|
93
67
|
Limits apply to owned Agents in each tree.
|
|
94
68
|
|
|
95
|
-
An owned Agent needs a slot to run a turn. `maxConcurrent` (default 3) is
|
|
96
|
-
the number of slots. An input that would start a turn waits for a free
|
|
97
|
-
slot, and `spawn` or `send` reports that it is queued. A `steer` input to
|
|
98
|
-
an Agent with a turn in progress joins it and needs no new slot. An Agent gives
|
|
99
|
-
up its slot while it waits in `wait`, and takes one again before
|
|
100
|
-
continuing, ahead of inputs that have not started.
|
|
69
|
+
An owned Agent needs a slot to run a turn. `maxConcurrent` (default 3) is the number of slots. An input that would start a turn waits for a free slot, and `spawn` or `send` reports that it is queued. A `steer` input to an Agent with a turn in progress joins it and needs no new slot. An Agent gives up its slot while it waits in `wait`, and takes one again before continuing, ahead of inputs that have not started.
|
|
101
70
|
|
|
102
|
-
An input is outstanding from acceptance until its turn ends or it is
|
|
103
|
-
withdrawn. `maxOutstanding` (default 8) limits outstanding inputs; an input
|
|
104
|
-
beyond it is rejected. `maxConcurrent` cannot exceed `maxOutstanding`.
|
|
71
|
+
An input is outstanding from acceptance until its turn ends or it is withdrawn. `maxOutstanding` (default 8) limits outstanding inputs; an input beyond it is rejected. Notifications (§5) do not count.
|
|
105
72
|
|
|
106
73
|
## 5. Results and notifications
|
|
107
74
|
|
|
108
|
-
An input sent to an owned Agent ends as `completed` when its turn answers
|
|
109
|
-
it, `failed` when its turn fails, or `aborted` when it is aborted or
|
|
110
|
-
withdrawn. Its result is the answer or the error. Only inputs from the
|
|
111
|
-
owner have results; the recipient replies to other senders with `send`.
|
|
75
|
+
An input sent to an owned Agent ends as `completed` when its turn answers it, `failed` when its turn fails, or `aborted` when it is aborted or withdrawn. Its result is the answer or the error. Only inputs from the owner have results; the recipient replies to other senders with `send`.
|
|
112
76
|
|
|
113
|
-
`wait` returns unread results in order and marks them read. On timeout, it
|
|
114
|
-
returns the results so far and names the Agents still pending. It can also
|
|
115
|
-
return read results again.
|
|
77
|
+
`wait` returns unread results in order and marks them read. On timeout, it returns the results so far and names the Agents still pending. A steer input to the waiting Agent, from any sender, ends `wait` the same way; a write does not. It can also return read results again.
|
|
116
78
|
|
|
117
|
-
When an input ends and its owner is not waiting for that Agent, the owner
|
|
118
|
-
receives a notification, unless the owner aborted it. The notification is an input delivered as `steer`,
|
|
119
|
-
and it names the Agent and how the input ended. It does not include the
|
|
120
|
-
result; the owner reads the result with `wait`.
|
|
79
|
+
When an input ends and its owner is not waiting for that Agent, the owner receives a notification, unless the owner aborted it. The notification is an input delivered as `steer` (a write after the owner's turn is stopped, §2.2), and it names the Agent and how the input ended. It does not include the result; the owner reads the result with `wait`.
|
|
121
80
|
|
|
122
81
|
A recipient sees each message with its sender's name and ID.
|
|
123
82
|
|
|
@@ -127,17 +86,7 @@ A recipient sees each message with its sender's name and ID.
|
|
|
127
86
|
|
|
128
87
|
description:
|
|
129
88
|
|
|
130
|
-
Create, message, and coordinate Agents. `spawn` creates an owned Agent and
|
|
131
|
-
sends its first input; `send` sends an input or a write to a visible Agent;
|
|
132
|
-
`wait` waits for owned Agents and returns unread results; `list` finds
|
|
133
|
-
visible Agents; `abort` stops an owned Agent's current turn and queued
|
|
134
|
-
inputs while keeping it available. When an owned Agent finishes an input
|
|
135
|
-
while its owner is not waiting for it, the owner receives a notification
|
|
136
|
-
naming the Agent and outcome; `wait` returns the result. Owned Agents under
|
|
137
|
-
the same root share `${maxConcurrent}` execution slots and a limit of
|
|
138
|
-
`${maxOutstanding}` inputs that have not ended. Inputs that start a new
|
|
139
|
-
turn queue when all slots are busy; new inputs are rejected at the input
|
|
140
|
-
limit.
|
|
89
|
+
Create, message, and coordinate Agents. `spawn` creates an owned Agent and sends its first input; `send` sends an input or a write to a visible Agent; `wait` waits for owned Agents and returns unread results; `list` finds visible Agents; `abort` stops an owned Agent's current turn and queued inputs while keeping it available. When an owned Agent finishes an input while its owner is not waiting for it, the owner receives a notification naming the Agent and outcome; `wait` returns the result. Owned Agents under the same root share `${maxConcurrent}` execution slots and a limit of `${maxOutstanding}` inputs that have not ended. Inputs that start a new turn queue when all slots are busy; new inputs are rejected at the input limit.
|
|
141
90
|
|
|
142
91
|
promptSnippet:
|
|
143
92
|
|
|
@@ -145,13 +94,9 @@ Create, message, and coordinate Agents
|
|
|
145
94
|
|
|
146
95
|
promptGuidelines:
|
|
147
96
|
|
|
148
|
-
- Use `agent(action='spawn', name=..., message=...)` for concrete, bounded
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
- For independent work, start the Agents before waiting and partition tasks
|
|
152
|
-
into non-overlapping responsibilities.
|
|
153
|
-
- Use `agent(action='wait', ...)` when the next step depends on Agent
|
|
154
|
-
results. Prefer one longer wait over repeated short polling.
|
|
97
|
+
- Use `agent(action='spawn', name=..., message=...)` for concrete, bounded work with a clear expected result. Keep the first message self-contained; use `context='fork'` only when the Agent needs the caller's conversation.
|
|
98
|
+
- For independent work, start the Agents before waiting and partition tasks into non-overlapping responsibilities.
|
|
99
|
+
- Use `agent(action='wait', ...)` when the next step depends on Agent results. Prefer one longer wait over repeated short polling.
|
|
155
100
|
|
|
156
101
|
parameters:
|
|
157
102
|
|
|
@@ -161,7 +106,7 @@ parameters:
|
|
|
161
106
|
- `cwd`: Working directory for `spawn` (default: the caller's current working directory).
|
|
162
107
|
- `context`: Context for `spawn` (default: fresh). fresh starts without the caller's conversation; fork snapshots it.
|
|
163
108
|
- `model`: Model for `spawn` as provider/modelId (default: the caller's model).
|
|
164
|
-
- `thinkingLevel`: Thinking level for `spawn`: off, minimal, low, medium, high, or
|
|
109
|
+
- `thinkingLevel`: Thinking level for `spawn`: off, minimal, low, medium, high, xhigh, or max (default: the caller's level).
|
|
165
110
|
- `target`: Agent ID, name, or unique ID prefix for `send`, `wait`, or `abort`. `wait` and `send` with `deliverAs='write'` also accept an array. When omitted for `wait`, selects all owned Agents with pending or unread results.
|
|
166
111
|
- `deliverAs`: Delivery for `send` (default: followUp). followUp waits until the recipient's current turn ends; steer delivers after its current tool calls, before the next model call; write delivers like steer but never starts a turn and has no result.
|
|
167
112
|
- `history`: Number of most recent read results to return again per selected Agent for `wait` (default: 0).
|
|
@@ -173,8 +118,7 @@ parameters:
|
|
|
173
118
|
|
|
174
119
|
results:
|
|
175
120
|
|
|
176
|
-
In these formats, `<id>` is the Agent's short ID. Details use full IDs;
|
|
177
|
-
arrays remain present when empty.
|
|
121
|
+
In these formats, `<id>` is the Agent's short ID. Details use full IDs; arrays remain present when empty.
|
|
178
122
|
|
|
179
123
|
`spawn`:
|
|
180
124
|
|
|
@@ -214,9 +158,14 @@ write: { ids }
|
|
|
214
158
|
Still pending: <name> (<id>), ...
|
|
215
159
|
```
|
|
216
160
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
161
|
+
When a steer input ended the wait, a line follows:
|
|
162
|
+
|
|
163
|
+
```text
|
|
164
|
+
Still pending: <name> (<id>), ...
|
|
165
|
+
Stopped waiting for a new message. Wait again to keep waiting.
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
A result returned again through `history` adds `history="true"`. A single unread completed result, with nothing pending, is returned as the answer alone. When there are no results or pending inputs:
|
|
220
169
|
|
|
221
170
|
```text
|
|
222
171
|
No results.
|
|
@@ -225,18 +174,16 @@ No results.
|
|
|
225
174
|
Details:
|
|
226
175
|
|
|
227
176
|
```text
|
|
228
|
-
{ results: [{ id, name, state, history, result? }], pending: [id] }
|
|
177
|
+
{ results: [{ id, name, state, history, result? }], pending: [{ id, name }], interrupted? }
|
|
229
178
|
```
|
|
230
179
|
|
|
231
|
-
`state` is the input outcome (§5); `history` marks a previously read result.
|
|
180
|
+
`state` is the input outcome (§5); `history` marks a previously read result; `interrupted` is `true` when a steer input ended the wait.
|
|
232
181
|
|
|
233
|
-
`list` returns one entry per Agent. With a query, entries are ordered by
|
|
234
|
-
their most recent match. When a summary or user message matches, the entry
|
|
235
|
-
shows the latest matching excerpt and its time:
|
|
182
|
+
`list` returns one entry per Agent, followed by its latest request, if any, and its time. With a query, entries are ordered by their most recent match, and a matching summary or user message shows its latest excerpt instead:
|
|
236
183
|
|
|
237
184
|
```text
|
|
238
185
|
<name> (<id>) <state> <cwd>
|
|
239
|
-
YYYY-MM-DD HH:MM
|
|
186
|
+
YYYY-MM-DD HH:MM <latest request or matching excerpt>
|
|
240
187
|
```
|
|
241
188
|
|
|
242
189
|
When more entries remain:
|
|
@@ -257,8 +204,7 @@ Details:
|
|
|
257
204
|
{ total, agents: [{ id, name?, ownerId?, state }] }
|
|
258
205
|
```
|
|
259
206
|
|
|
260
|
-
`agents` is the current page; `total` counts all matches. `state` is the
|
|
261
|
-
Agent's current state (§3).
|
|
207
|
+
`agents` is the current page; `total` counts all matches. `state` is the Agent's current state (§3).
|
|
262
208
|
|
|
263
209
|
`abort`:
|
|
264
210
|
|
|
@@ -277,8 +223,7 @@ For unnamed root Agents, show the ID without a name or parentheses.
|
|
|
277
223
|
|
|
278
224
|
errors:
|
|
279
225
|
|
|
280
|
-
Invalid calls fail with an error. Errors that need a follow-up say what to
|
|
281
|
-
do:
|
|
226
|
+
Invalid calls fail with an error. Errors that need a follow-up say what to do:
|
|
282
227
|
|
|
283
228
|
```text
|
|
284
229
|
No visible Agent matches "<target>". Use list to find Agents.
|
|
@@ -304,21 +249,21 @@ Input rejected: <N> inputs have not ended. Wait for results or abort an Agent.
|
|
|
304
249
|
<name> (<id>) is not owned by the caller.
|
|
305
250
|
```
|
|
306
251
|
|
|
252
|
+
When an aborted turn does not stop within the timeout (§3), `abort` fails with the following; only restarting Pi stops it.
|
|
253
|
+
|
|
254
|
+
```text
|
|
255
|
+
Agent <name> (<id>) did not stop within the timeout and may still be running.
|
|
256
|
+
```
|
|
257
|
+
|
|
307
258
|
truncation:
|
|
308
259
|
|
|
309
|
-
Text beyond Pi's output limits is truncated with Pi's native notice, and
|
|
310
|
-
the full text is saved to a file whose path appears in the notice. `wait`
|
|
311
|
-
adds results in order; the result that crosses the limit is truncated but
|
|
312
|
-
keeps its closing tag, and later results are omitted. A truncated result
|
|
313
|
-
counts as read. Omitted results stay unread, and the text ends with:
|
|
260
|
+
Text beyond Pi's output limits is truncated with Pi's native notice, and the full text is saved to a file whose path appears in the notice. `wait` adds results in order; the result that crosses the limit is truncated but keeps its closing tag, and later results are omitted. A truncated result counts as read. Omitted results stay unread, and the text ends with:
|
|
314
261
|
|
|
315
262
|
```text
|
|
316
263
|
[Results omitted: <name> (<id>), ... Use wait with fewer targets.]
|
|
317
264
|
```
|
|
318
265
|
|
|
319
|
-
Details retain metadata, `truncation`, and `fullOutputPath`.
|
|
320
|
-
`wait.results[].result` contains only retained text and is absent for
|
|
321
|
-
omitted results.
|
|
266
|
+
Details retain metadata, `truncation`, and `fullOutputPath`. `wait.results[].result` contains only retained text and is absent for omitted results.
|
|
322
267
|
|
|
323
268
|
messages:
|
|
324
269
|
|
|
@@ -328,18 +273,16 @@ A notification to the owner:
|
|
|
328
273
|
Agent <name> (<id>) <outcome>.
|
|
329
274
|
```
|
|
330
275
|
|
|
331
|
-
A recipient sees each message in an `agent-message` element naming the
|
|
332
|
-
sender. An input from a sender other than the owner also carries a note
|
|
333
|
-
asking for a reply:
|
|
276
|
+
A recipient sees each message in an `agent-message` element naming the sender. An input from a sender other than the owner also carries a note asking for a reply:
|
|
334
277
|
|
|
335
278
|
```text
|
|
336
|
-
<agent-message
|
|
279
|
+
<agent-message name="<name>" id="<id>">
|
|
337
280
|
<body>
|
|
338
281
|
</agent-message>
|
|
339
282
|
```
|
|
340
283
|
|
|
341
284
|
```text
|
|
342
|
-
<agent-message
|
|
285
|
+
<agent-message name="<name>" id="<id>" note="Reply with send">
|
|
343
286
|
<body>
|
|
344
287
|
</agent-message>
|
|
345
288
|
```
|
|
@@ -350,43 +293,61 @@ asking for a reply:
|
|
|
350
293
|
|
|
351
294
|
A panel above the editor shows the current Agent's live work:
|
|
352
295
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
296
|
+
```text
|
|
297
|
+
Tasks (<N> live, /tasks to view)
|
|
298
|
+
Agent <name> (<id>) <state> <time> <cost> <N> pending
|
|
299
|
+
Agent <name> (<id>) <state> <time> <cost>
|
|
300
|
+
Program <id> running <time> <cost>
|
|
301
|
+
Agent <name> (<id>) <state> <time> <cost>
|
|
302
|
+
+<N> more
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
The live work is the owned Agents that are not `idle`, and the running background Programs with their Agents that are not `idle`. The rows list them as a tree in the order they started, each under its owner and each Program under its caller, with the owners needed to keep the tree. Rows that do not fit are counted in the last row. The time is how long the Agent's current turn or the Program has run, and the cost what the replies in that turn have cost, or for a Program, those of all the Agents under it. When a reply has no price, the cost is the input and output tokens instead, like `7.3M tok`.
|
|
306
|
+
|
|
307
|
+
The panel updates as states change, and its times each second. It is shown while it has a row. `/tasks panel` hides or shows it.
|
|
308
|
+
|
|
309
|
+
### Queued messages
|
|
359
310
|
|
|
360
|
-
|
|
361
|
-
background Programs with their Agents that are not `idle`. The rows list
|
|
362
|
-
them as a tree in the order they started, each
|
|
363
|
-
under its owner and each Program under its caller, with the owners needed to
|
|
364
|
-
keep the tree. Rows that do not fit are counted in the last row.
|
|
311
|
+
Messages from other Agents that wait in the Session's queue, as during a turn, are listed above the editor, below the user's queued messages, until the Session takes them in:
|
|
365
312
|
|
|
366
|
-
|
|
367
|
-
|
|
313
|
+
```text
|
|
314
|
+
Steering: [<sender>] <body>
|
|
315
|
+
Write: [<sender>] <body>
|
|
316
|
+
Follow-up: [<sender>] <body>
|
|
317
|
+
```
|
|
368
318
|
|
|
369
|
-
###
|
|
319
|
+
### Messages and results
|
|
370
320
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
`<name> ‹ <owner> ‹ …`, where a Program is `Program <id>`. The viewer shows the
|
|
376
|
-
Agent's conversation and updates while it works; the current Session keeps
|
|
377
|
-
running behind it.
|
|
321
|
+
A message from another Agent shows its sender after the label:
|
|
322
|
+
|
|
323
|
+
```text
|
|
324
|
+
[pi-agents] from <name> (<id>)
|
|
378
325
|
|
|
379
|
-
|
|
380
|
-
|
|
326
|
+
<body>
|
|
327
|
+
```
|
|
381
328
|
|
|
382
|
-
|
|
383
|
-
|
|
329
|
+
The user's input from the task viewer shows as a user message. `wait` shows each result with the first lines of its body; a Program's body starts at its output:
|
|
330
|
+
|
|
331
|
+
```text
|
|
332
|
+
<name> (<id>) <state>
|
|
333
|
+
<body>
|
|
334
|
+
Program <id> <state> <time>
|
|
335
|
+
<body>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Expanding (`app.tools.expand`) shows them as Pi shows them by default.
|
|
339
|
+
|
|
340
|
+
### Task viewer
|
|
341
|
+
|
|
342
|
+
`/tasks` lists the Agents in the current Agent's tree, including its Programs' Agents, and its background Programs, live ones first and newest first, with their state and latest activity, and opens the selected one in a viewer. An Agent not owned by the current Agent is named with its owners, as `<name> ‹ <owner> ‹ …`, where a Program is `Program <id>`. The viewer follows an Agent's conversation as Pi's chat shows it, or a Program as it shows in the foreground, while the current Session keeps running.
|
|
343
|
+
|
|
344
|
+
Text entered in an Agent's viewer is the user's input to it, sent as in Pi's editor; a Program takes no input.
|
|
345
|
+
|
|
346
|
+
Keys act as in Pi's editor, on the viewed Agent or Program; on an empty input, `Ctrl+C` (`app.clear`) closes the viewer. The viewer scrolls as fullscreen mode does.
|
|
384
347
|
|
|
385
348
|
### Workbench
|
|
386
349
|
|
|
387
|
-
`pd agents` opens the workbench, which lists every root Session on this
|
|
388
|
-
machine and lets the user open and message them. Interactive Sessions keep
|
|
389
|
-
running after their terminal closes. See [WORKBENCH.md](WORKBENCH.md).
|
|
350
|
+
`pd agents` opens the workbench, which lists every root Session on this machine and lets the user open and message them. Sessions started with `pd` keep running after their terminal closes. See [HOSTS.md](HOSTS.md).
|
|
390
351
|
|
|
391
352
|
## 8. Configuration
|
|
392
353
|
|
|
@@ -402,26 +363,13 @@ Settings live under `"pi-agents"` in the global `settings.json`:
|
|
|
402
363
|
}
|
|
403
364
|
```
|
|
404
365
|
|
|
405
|
-
- `maxConcurrent`, `maxOutstanding`: limits from §4. Both are positive
|
|
406
|
-
|
|
407
|
-
- `extensions`: extension paths loaded by owned Agents, relative to Pi's
|
|
408
|
-
agent directory. An owned Agent can use only tools its owner can use.
|
|
366
|
+
- `maxConcurrent`, `maxOutstanding`: limits from §4. Both are positive integers with `maxConcurrent <= maxOutstanding`.
|
|
367
|
+
- `extensions`: extension paths loaded by owned Agents, relative to Pi's agent directory. An owned Agent can use only tools its owner can use.
|
|
409
368
|
|
|
410
369
|
Invalid settings produce a startup warning, and the defaults are used.
|
|
411
370
|
|
|
412
371
|
## 9. Runtime
|
|
413
372
|
|
|
414
|
-
Each Agent is a persistent Pi Session. A root Agent is an ordinary Session.
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
A delivered message enters the recipient's current branch. An offline root
|
|
419
|
-
Agent is started in a host, detached, with its saved working directory and
|
|
420
|
-
model and the current configuration (WORKBENCH §4).
|
|
421
|
-
If a root process cannot finish cleanup within a grace period on exit, it is
|
|
422
|
-
forcibly terminated.
|
|
423
|
-
Before shutting down an idle Session, another extension can emit
|
|
424
|
-
`busy:query` on `pi.events` with `{ busy: false }`; it is set to `true`
|
|
425
|
-
while the tree has live work.
|
|
426
|
-
One runtime uses a Session at a time. If a Session is occupied at interactive
|
|
427
|
-
startup, its lock error stays visible until the user dismisses it, then Pi exits.
|
|
373
|
+
Each Agent is a persistent Pi Session. A root Agent is an ordinary Session. An owned Agent is a child Session that records its owner and root, and runs in its owner's process.
|
|
374
|
+
|
|
375
|
+
A delivered message enters the recipient's current branch. An offline root Agent is started in a host, detached, with its saved working directory and model and the current configuration (HOSTS §4). If a root process cannot finish cleanup within a grace period on exit, it is forcibly terminated. Before shutting down an idle Session, another extension can emit `busy:query` on `pi.events` with `{ busy: false }`; it is set to `true` while the tree has live work. One runtime uses a Session at a time. If a Session is occupied at startup, Pi reports it and exits.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tshu-w/pi-agents",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Multi-agent runtime for Pi: async agents,
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Multi-agent runtime for Pi: persistent async agents, dynamic workflows, and inter-agent messaging",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,11 +19,13 @@
|
|
|
19
19
|
"docs"
|
|
20
20
|
],
|
|
21
21
|
"keywords": [
|
|
22
|
-
"pi-package",
|
|
23
|
-
"pi-extension",
|
|
24
|
-
"pi-coding-agent",
|
|
25
22
|
"pi",
|
|
23
|
+
"pi-coding-agent",
|
|
24
|
+
"pi-extension",
|
|
25
|
+
"pi-package",
|
|
26
26
|
"multi-agent",
|
|
27
|
+
"async-agents",
|
|
28
|
+
"dynamic-workflows",
|
|
27
29
|
"rlm"
|
|
28
30
|
],
|
|
29
31
|
"pi": {
|