@oai404iao/pi-subagent 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSES/DeepSeek-Harness-MIT.txt +21 -0
- package/README.md +357 -0
- package/THIRD_PARTY_NOTICES.md +27 -0
- package/agents/planner.md +8 -0
- package/agents/reviewer.md +8 -0
- package/agents/scout.md +8 -0
- package/agents/worker.md +8 -0
- package/config.example.json +11 -0
- package/config.schema.json +61 -0
- package/package.json +88 -0
- package/provenance/deepseek-harness-4d03472.json +20 -0
- package/src/agent-sync.ts +583 -0
- package/src/agents.ts +174 -0
- package/src/catalog.ts +89 -0
- package/src/config.ts +182 -0
- package/src/coordinator.ts +1393 -0
- package/src/descriptor.ts +189 -0
- package/src/index.ts +386 -0
- package/src/providers.ts +139 -0
- package/src/render.ts +109 -0
- package/src/result.ts +131 -0
- package/src/schemas.ts +130 -0
- package/src/tool-policy.ts +131 -0
- package/src/types.ts +154 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 oai404iao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
# @oai404iao/pi-subagent
|
|
2
|
+
|
|
3
|
+
Durable, continuable subagents for [Pi](https://github.com/earendil-works/pi-mono).
|
|
4
|
+
The design independently adapts the
|
|
5
|
+
[DeepSeek Harness subagent seam](https://github.com/deepseek-ai/deepseek-harness/tree/4d03472cd098dc48a630e526ca620f4f37f18a0e/docs/subsystems)
|
|
6
|
+
to Pi's extension and SDK APIs.
|
|
7
|
+
|
|
8
|
+
Compatibility: Pi 0.84.2 or newer; tested against 0.84.2.
|
|
9
|
+
|
|
10
|
+
> npm identity: `@oai404iao/pi-subagent`. Once the selected version is
|
|
11
|
+
> available on npm, install it from npm; use a local checkout before its
|
|
12
|
+
> bootstrap or when testing unreleased source.
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- **Named providers**
|
|
17
|
+
- `spawn`: fresh child with no parent conversation
|
|
18
|
+
- `fork`: one-shot child seeded through the parent's latest completed turn
|
|
19
|
+
- **Two lifecycles**
|
|
20
|
+
- foreground one-shot runs return the child's final answer
|
|
21
|
+
- background continuable runs return a child session id immediately
|
|
22
|
+
- **Foreground-only policy** that removes background scheduling and lifecycle controls
|
|
23
|
+
- **Independent context and session** for every child
|
|
24
|
+
- **Bundled presets without filesystem writes by default**, with opt-in
|
|
25
|
+
materialization, backup, and replacement
|
|
26
|
+
- **Durable descriptors and lineage** stored in child JSONL sessions
|
|
27
|
+
- **Cold resume** through `send_message`
|
|
28
|
+
- **Control plane** with listing and interruption
|
|
29
|
+
- **Child-to-parent `report` channel** for continuable children
|
|
30
|
+
- **Nested delegation** with an absolute persisted depth limit
|
|
31
|
+
- **Dynamic agent-name enums** generated from the effective user/project catalog
|
|
32
|
+
- **Parallel-safe delegation**: multiple `subagent` calls in one assistant message may overlap
|
|
33
|
+
- **Composable tool ceilings** that preserve model/extension tool decisions
|
|
34
|
+
- **Usage accounting, streaming progress, output caps, and custom TUI rendering**
|
|
35
|
+
|
|
36
|
+
Children run through Pi's SDK in the same Node.js process, but each owns a separate `AgentSession`, context window, session file, tool selection, and extension runtime.
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
When the selected version is available on npm:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pi install npm:@oai404iao/pi-subagent
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Before its npm bootstrap, or for an unreleased local checkout:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pi install /absolute/path/to/pi-extensions/pi-subagent
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Restart Pi or run `/reload`.
|
|
53
|
+
|
|
54
|
+
For a temporary test:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pi -e /absolute/path/to/pi-extensions/pi-subagent
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This implementation targets Pi `0.84.2`.
|
|
61
|
+
|
|
62
|
+
## Model-facing tools
|
|
63
|
+
|
|
64
|
+
| Tool | Behavior |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `subagent` | Starts a fresh child. Background continuable mode is the default unless configured otherwise; foreground-only mode always waits for the answer. |
|
|
67
|
+
| `subagent_fork` | Starts a foreground one-shot child with the parent's completed-turn history. The in-flight tool turn is excluded. |
|
|
68
|
+
| `send_message` | Sends the next FIFO turn to a direct continuable child; cold-resumes a persisted child when background execution is enabled. |
|
|
69
|
+
| `interrupt_agent` | Requests cancellation of a live descendant's current turn without deleting its session. Active only when background execution is enabled. |
|
|
70
|
+
| `list_agents` | Lists direct children or all descendants as `running`, `idle`, or `ready`. Active only when background execution is enabled. |
|
|
71
|
+
| `report` | Child-only return channel. Installed automatically in continuable children. |
|
|
72
|
+
|
|
73
|
+
The `/subagents` command shows the effective scheduling mode, available agent definitions,
|
|
74
|
+
and the current descendant catalog.
|
|
75
|
+
|
|
76
|
+
At session startup, the `agent` parameter on `subagent` and `subagent_fork` is registered
|
|
77
|
+
as an enum of the effective catalog. Nested delegation tools receive an activation-scoped
|
|
78
|
+
enum. If the effective catalog is empty, both delegation tools are inactive. Run `/reload`
|
|
79
|
+
after adding, removing, or renaming an agent definition so the session schema is refreshed.
|
|
80
|
+
|
|
81
|
+
### Typical prompts
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
Start scout and reviewer as independent background subagents, then continue inspecting the failing tests.
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
Use subagent_fork with planner to plan the change using our completed discussion.
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
List my subagents, then send the scout a follow-up asking for exact call sites.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Pi executes sibling tool calls in parallel, so this package deliberately accepts one delegation per `subagent` call instead of embedding a separate `tasks` array.
|
|
96
|
+
|
|
97
|
+
## Agent definitions
|
|
98
|
+
|
|
99
|
+
The package includes `scout`, `planner`, `reviewer`, and `worker`. By default,
|
|
100
|
+
these bundled definitions are read directly from the package. Startup does
|
|
101
|
+
**not** create, replace, remove, or back up files in the Pi agent directory.
|
|
102
|
+
`/subagents` reports those defaults as `(bundled)`.
|
|
103
|
+
|
|
104
|
+
User and project definitions can override the same names without modifying
|
|
105
|
+
package files. Runtime locations and precedence are:
|
|
106
|
+
|
|
107
|
+
1. bundled package definitions
|
|
108
|
+
2. `<Pi agent dir>/agents/*.md`
|
|
109
|
+
3. nearest trusted `.pi/agents/*.md`
|
|
110
|
+
|
|
111
|
+
Project definitions replace user and bundled definitions with the same name
|
|
112
|
+
when project scope is enabled. Project agents are disabled by the default
|
|
113
|
+
`agentScope: "user"`. Setting the scope to `project` explicitly selects only
|
|
114
|
+
project definitions; `both` loads bundled definitions, user overrides, then
|
|
115
|
+
project overrides.
|
|
116
|
+
|
|
117
|
+
When upgrading from a version that synchronized presets by default, unchanged
|
|
118
|
+
previously managed files are recognized read-only and do not shadow newer
|
|
119
|
+
package defaults. Edited managed files remain user overrides. The default
|
|
120
|
+
never deletes or rewrites those existing files.
|
|
121
|
+
|
|
122
|
+
### Opt-in managed preset synchronization
|
|
123
|
+
|
|
124
|
+
Set `syncBundledAgents: true` only if you explicitly want the package to
|
|
125
|
+
materialize its bundled definitions into:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
<Pi agent dir>/agents/*.md
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
With that opt-in, runtime discovery uses the managed user files rather than
|
|
132
|
+
reading package copies directly, and `/subagents` reports built-ins as
|
|
133
|
+
`(user)`. Synchronization behavior is then:
|
|
134
|
+
|
|
135
|
+
1. **First startup:** missing presets are installed. A different pre-existing same-name file
|
|
136
|
+
is backed up before the bundled version replaces it.
|
|
137
|
+
2. **Ordinary restart of the same release:** user edits are preserved.
|
|
138
|
+
3. **Plugin update:** differing user presets are backed up, then replaced with the new
|
|
139
|
+
bundled versions. A bundled prompt hash change also triggers this refresh even if the
|
|
140
|
+
package version was not bumped.
|
|
141
|
+
4. **Retired preset:** a formerly bundled name is backed up and removed so an obsolete
|
|
142
|
+
prompt does not remain silently active.
|
|
143
|
+
5. Files whose names were never managed bundled presets are left untouched.
|
|
144
|
+
|
|
145
|
+
Synchronization holds a cross-process lock, then preflights and stages the whole update
|
|
146
|
+
before changing agent files. If a commit fails, it rolls back already-applied changes and
|
|
147
|
+
fails extension startup rather than falling back to package prompts. Same-name symbolic
|
|
148
|
+
links are preserved as symbolic links inside the backup directory before the user path is
|
|
149
|
+
replaced. An invalid synchronization manifest is copied to a timestamped `.corrupt-*` file
|
|
150
|
+
and startup fails closed until the manifest is repaired or deliberately removed.
|
|
151
|
+
|
|
152
|
+
Synchronization state and backups live at:
|
|
153
|
+
|
|
154
|
+
```text
|
|
155
|
+
<Pi agent dir>/.pi-subagent/agents-manifest.json
|
|
156
|
+
<Pi agent dir>/.pi-subagent/backups/<timestamp>-to-<version>/*.md
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The startup notification reports installed/updated files and exact backup
|
|
160
|
+
paths. To restore a customization after an update, copy its backup over the
|
|
161
|
+
corresponding user agent file; later startups of that same plugin release
|
|
162
|
+
preserve the restored edit.
|
|
163
|
+
|
|
164
|
+
Add or edit user agents as Markdown files with YAML frontmatter:
|
|
165
|
+
|
|
166
|
+
```markdown
|
|
167
|
+
---
|
|
168
|
+
name: security-reviewer
|
|
169
|
+
description: Review authentication and authorization changes
|
|
170
|
+
tools: read, grep, find, ls, bash
|
|
171
|
+
model: openai/gpt-5.4
|
|
172
|
+
thinking: high
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
Review the delegated change. Report concrete security defects with exact paths.
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Frontmatter:
|
|
179
|
+
|
|
180
|
+
| Key | Required | Meaning |
|
|
181
|
+
| --- | --- | --- |
|
|
182
|
+
| `name` | yes | Stable tool-visible name. |
|
|
183
|
+
| `description` | yes | Short catalog description. |
|
|
184
|
+
| `tools` | no | Comma-separated hard ceiling; use `none` for no ordinary tools, `$mutation` for the active mutation implementation, or omit to preserve the child runtime's active tools. |
|
|
185
|
+
| `model` | no | `provider/model` or an unambiguous model id; omitted means inherit the parent model. |
|
|
186
|
+
| `thinking` | no | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`. |
|
|
187
|
+
|
|
188
|
+
For continuable children, `report` is retained even when the agent has a tool allowlist.
|
|
189
|
+
|
|
190
|
+
### Tool policy and inherited extensions
|
|
191
|
+
|
|
192
|
+
An explicit `tools` list is a **maximum permission ceiling**, not an instruction to
|
|
193
|
+
blindly activate every registered tool:
|
|
194
|
+
|
|
195
|
+
1. Pi builds the child registry from only the listed tools and runtime-mandatory controls.
|
|
196
|
+
2. Inherited extensions run their `session_start` handlers and select tools for the child model.
|
|
197
|
+
3. The agent allowlist narrows that active set. A registered but extension-disabled explicit
|
|
198
|
+
tool fails loud instead of being re-enabled.
|
|
199
|
+
|
|
200
|
+
The foreground-only runtime policy is applied after this composition and removes background
|
|
201
|
+
lifecycle controls even when an agent definition names them.
|
|
202
|
+
|
|
203
|
+
The reserved logical tool `$mutation` lets one definition work with both standard Pi and
|
|
204
|
+
model-specific tool extensions:
|
|
205
|
+
|
|
206
|
+
- if an inherited extension leaves `apply_patch` active, `$mutation` resolves to `apply_patch`;
|
|
207
|
+
- otherwise it resolves to the active built-in `edit` and/or `write` tools;
|
|
208
|
+
- if no mutation implementation is active, child creation fails before the first model request.
|
|
209
|
+
|
|
210
|
+
The bundled `worker` uses `$mutation`. For example, to use
|
|
211
|
+
`@oai404iao/pi-codex-minimal-tools` inside workers:
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"inheritExtensions": true
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
The Codex extension may then select `apply_patch` and suppress `edit`/`write`; the
|
|
220
|
+
subagent ceiling preserves that decision. Tools injected by other extensions but not named
|
|
221
|
+
by the agent remain unavailable. Unknown logical names beginning with `$` are rejected.
|
|
222
|
+
|
|
223
|
+
Omitting `tools` intentionally opts out of a hard ceiling and preserves the effective tool
|
|
224
|
+
set chosen by Pi and inherited extensions. This is more permissive than an explicit list.
|
|
225
|
+
|
|
226
|
+
## Configuration
|
|
227
|
+
|
|
228
|
+
Configuration is loaded from:
|
|
229
|
+
|
|
230
|
+
1. `<Pi agent dir>/subagent.json`
|
|
231
|
+
2. nearest trusted `.pi/subagent.json` (project overrides)
|
|
232
|
+
|
|
233
|
+
See [`config.example.json`](config.example.json) and [`config.schema.json`](config.schema.json).
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"$schema": "/path/to/pi-subagent/config.schema.json",
|
|
238
|
+
"agentScope": "user",
|
|
239
|
+
"syncBundledAgents": false,
|
|
240
|
+
"maxDepth": 3,
|
|
241
|
+
"enableRunInBackground": true,
|
|
242
|
+
"defaultBackground": true,
|
|
243
|
+
"reportDelivery": "wakeup",
|
|
244
|
+
"inheritExtensions": false,
|
|
245
|
+
"maxOutputBytes": 51200
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
| Setting | Default | Meaning |
|
|
250
|
+
| --- | --- | --- |
|
|
251
|
+
| `agentScope` | `user` | Select user definitions, project definitions, or user definitions followed by project overrides. |
|
|
252
|
+
| `syncBundledAgents` | `false` | **User-level config only.** Opt in to writing managed bundled presets into `<Pi agent dir>/agents`. `true` may install, replace, retire, and back up those files. |
|
|
253
|
+
| `maxDepth` | `3` | Absolute delegation depth; a top-level Pi session is depth 0. |
|
|
254
|
+
| `enableRunInBackground` | `true` | Enable continuable background children and their model-facing lifecycle controls. Set `false` for strict foreground-only mode. |
|
|
255
|
+
| `defaultBackground` | `true` | Default scheduling for fresh `subagent` calls when background execution is enabled. |
|
|
256
|
+
| `reportDelivery` | `wakeup` | `wakeup` starts/queues a parent turn; `quiet` waits for the parent's next turn. |
|
|
257
|
+
| `inheritExtensions` | `false` | Load other Pi extensions in child runtimes. This package filters itself out; explicit agent tool ceilings still apply. |
|
|
258
|
+
| `maxOutputBytes` | `51200` | Cap for parent-visible foreground output, reports, and settlement notices. Full output remains in the child session. |
|
|
259
|
+
|
|
260
|
+
Invalid configuration and unknown child tool names fail loud before the child's first model request.
|
|
261
|
+
|
|
262
|
+
### Foreground-only mode
|
|
263
|
+
|
|
264
|
+
```json
|
|
265
|
+
{
|
|
266
|
+
"enableRunInBackground": false
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
In this mode:
|
|
271
|
+
|
|
272
|
+
- `subagent` always waits for the child's final answer, even when `defaultBackground` is `true`;
|
|
273
|
+
- `run_in_background` is removed from the model-facing schema at session startup;
|
|
274
|
+
- a forced `run_in_background: true` call is rejected before a child is created;
|
|
275
|
+
- nested subagents inherit the foreground-only policy through the durable runtime snapshot;
|
|
276
|
+
- `send_message`, `interrupt_agent`, and `list_agents` are removed from the active
|
|
277
|
+
model tool set, including inside nested children;
|
|
278
|
+
- sibling foreground calls may still execute in parallel in one assistant message.
|
|
279
|
+
|
|
280
|
+
`subagent_fork` is already foreground-only and is unchanged. The `/subagents` command
|
|
281
|
+
remains available for human inspection of historical children, but persisted continuable
|
|
282
|
+
children cannot be resumed until background execution is re-enabled. Run `/reload` or
|
|
283
|
+
restart Pi after changing this setting so the active tool set and displayed schema are
|
|
284
|
+
refreshed.
|
|
285
|
+
|
|
286
|
+
## Lifecycle
|
|
287
|
+
|
|
288
|
+
```text
|
|
289
|
+
parent AgentSession
|
|
290
|
+
└─ subagent tool
|
|
291
|
+
└─ provider (spawn | fork)
|
|
292
|
+
└─ child Session + pi-subagent/descriptor
|
|
293
|
+
└─ optional live Activation (AgentSessionRuntime)
|
|
294
|
+
├─ one or more FIFO turns
|
|
295
|
+
└─ owned continuable descendants
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### One-shot
|
|
299
|
+
|
|
300
|
+
The caller waits for one isolated child run. Only the child's last non-empty assistant output enters the parent tool result. The runtime is disposed on every path; the child session remains available as a trace when persistence is enabled.
|
|
301
|
+
|
|
302
|
+
### Continuable
|
|
303
|
+
|
|
304
|
+
The start tool resolves at prompt preflight acceptance and returns the stable child session id. When an activation settles:
|
|
305
|
+
|
|
306
|
+
1. the runtime sends the parent a settlement notice with the stop reason and closing message;
|
|
307
|
+
2. the child runtime is disposed once its owned descendants are done;
|
|
308
|
+
3. its persistent session becomes `ready`;
|
|
309
|
+
4. `send_message` can cold-resume that same session for another FIFO turn.
|
|
310
|
+
|
|
311
|
+
A child can explicitly call `report` before settlement. Reports and settlement notices are separate by design.
|
|
312
|
+
|
|
313
|
+
### Fork boundary
|
|
314
|
+
|
|
315
|
+
The parent is executing a tool when `subagent_fork` starts, so its current assistant/tool-result sequence is incomplete. The provider copies only through the latest assistant message whose stop reason is not `toolUse`. This avoids seeding an invalid unbalanced tool turn.
|
|
316
|
+
|
|
317
|
+
## Security
|
|
318
|
+
|
|
319
|
+
- Extensions and subagents run with the user's OS permissions.
|
|
320
|
+
- Opt-in `syncBundledAgents: true` synchronizes bundled presets into the user
|
|
321
|
+
agent directory and may create backups under
|
|
322
|
+
`<Pi agent dir>/.pi-subagent/backups`. The default does not write these
|
|
323
|
+
paths.
|
|
324
|
+
- Project-local agents are repository-controlled prompts. They are loaded only when the project is trusted and configuration enables project scope.
|
|
325
|
+
- `inheritExtensions` is disabled by default because loading an extension in a child executes its code and may duplicate external side effects.
|
|
326
|
+
- Explicit agent tool lists are enforced as registry ceilings, but this controls model visibility and execution composition rather than providing an OS sandbox.
|
|
327
|
+
- A child may send content only to its recorded direct parent through `report`; `send_message` likewise requires direct-parent identity.
|
|
328
|
+
|
|
329
|
+
## Current limitations
|
|
330
|
+
|
|
331
|
+
- Activations and ownership are process-local; there is no cross-process lease or durable mailbox.
|
|
332
|
+
- Pi does not expose stable inbox message ids, so control acknowledgements return the child id rather than a delivery id.
|
|
333
|
+
- A process crash can lose a prompt accepted just before Pi writes it to the child JSONL; there is no durable mailbox for accepted-but-unlogged work.
|
|
334
|
+
- `interrupt_agent` is fire-and-return and relies on Pi's current `AgentSession.abort()` queue behavior.
|
|
335
|
+
- The fork provider is intentionally one-shot.
|
|
336
|
+
- Structured-output delegation is not implemented yet.
|
|
337
|
+
- Continuable starts require a persisted parent session; ephemeral (`--no-session`) parents can use foreground one-shot delegation only.
|
|
338
|
+
- `subagent_fork` needs a persisted parent to copy completed history; before the first completed turn its safe prefix is empty and it behaves like a fresh child.
|
|
339
|
+
- The extension currently uses Pi's `ModelRegistry` compatibility facade to recover the active `ModelRuntime`; this is why the package pins its tested Pi generation.
|
|
340
|
+
|
|
341
|
+
## Development
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
npm install
|
|
345
|
+
npm run check
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
The test suite includes provider-boundary, descriptor, configuration, discovery, extension-load, foreground-run, background-settlement, and cold-resume coverage with a scripted local model.
|
|
349
|
+
|
|
350
|
+
## License and publication status
|
|
351
|
+
|
|
352
|
+
MIT © 2026 oai404iao. See [LICENSE](LICENSE) and
|
|
353
|
+
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
354
|
+
|
|
355
|
+
Managed global-preset synchronization is opt-in through
|
|
356
|
+
`syncBundledAgents: true`; the default reads bundled definitions without
|
|
357
|
+
writing user files.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
## DeepSeek Harness design reference
|
|
4
|
+
|
|
5
|
+
`@oai404iao/pi-subagent` independently implements Pi extension and SDK
|
|
6
|
+
integration. It adapts high-level subagent design concepts—named spawn/fork
|
|
7
|
+
providers, isolated child sessions, continuable children, and model-facing
|
|
8
|
+
control tools—from the public
|
|
9
|
+
[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) subagent
|
|
10
|
+
documentation at revision
|
|
11
|
+
[`4d03472cd098dc48a630e526ca620f4f37f18a0e`](https://github.com/deepseek-ai/deepseek-harness/commit/4d03472cd098dc48a630e526ca620f4f37f18a0e).
|
|
12
|
+
|
|
13
|
+
No DeepSeek Harness source file is included in this package. The local
|
|
14
|
+
implementation has different runtime APIs, persistence format, provider
|
|
15
|
+
boundary, and test fixtures.
|
|
16
|
+
|
|
17
|
+
DeepSeek Harness is MIT-licensed:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
Copyright (c) 2026 DeepSeek
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The verified upstream license snapshot is preserved in
|
|
24
|
+
[`LICENSES/DeepSeek-Harness-MIT.txt`](LICENSES/DeepSeek-Harness-MIT.txt).
|
|
25
|
+
The immutable revision, blob identifiers, raw URLs, and SHA-256 checksums for
|
|
26
|
+
the source document and license are recorded in
|
|
27
|
+
[`provenance/deepseek-harness-4d03472.json`](provenance/deepseek-harness-4d03472.json).
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: planner
|
|
3
|
+
description: Turn repository evidence into an implementation plan
|
|
4
|
+
tools: read, grep, find, ls
|
|
5
|
+
thinking: high
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Produce a concrete implementation plan grounded in the repository. Identify files to change, interfaces, lifecycle and error paths, and focused verification. Do not edit files. Prefer the smallest coherent design.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reviewer
|
|
3
|
+
description: Review changes for correctness, regressions, and missing tests
|
|
4
|
+
tools: read, grep, find, ls, bash
|
|
5
|
+
thinking: high
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Review the requested change as a critical code reviewer. Inspect relevant source and tests, prioritize concrete defects over style preferences, and report findings by severity with exact paths and actionable fixes. Do not edit files.
|
package/agents/scout.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scout
|
|
3
|
+
description: Fast read-only codebase reconnaissance with compressed findings
|
|
4
|
+
tools: read, grep, find, ls, bash
|
|
5
|
+
thinking: low
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Explore the repository narrowly and quickly. Find the files, symbols, dependencies, and constraints needed by the delegated task. Do not edit files. Return concise findings with exact paths and call out uncertainty.
|
package/agents/worker.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: worker
|
|
3
|
+
description: General-purpose implementation agent with coding tools
|
|
4
|
+
tools: read, grep, find, ls, bash, $mutation, subagent, subagent_fork, send_message, interrupt_agent, list_agents
|
|
5
|
+
thinking: high
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Implement the delegated task end to end. Inspect before editing, keep changes scoped, follow repository instructions, and run focused verification. Report changed files, checks run, and any remaining limitation.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./config.schema.json",
|
|
3
|
+
"agentScope": "user",
|
|
4
|
+
"syncBundledAgents": false,
|
|
5
|
+
"maxDepth": 3,
|
|
6
|
+
"enableRunInBackground": true,
|
|
7
|
+
"defaultBackground": true,
|
|
8
|
+
"reportDelivery": "wakeup",
|
|
9
|
+
"inheritExtensions": false,
|
|
10
|
+
"maxOutputBytes": 51200
|
|
11
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "urn:pi:pi-subagent:config",
|
|
4
|
+
"title": "pi-subagent configuration",
|
|
5
|
+
"description": "Global or project-local configuration for the pi-subagent extension.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Path or URL to this schema.",
|
|
12
|
+
"default": "./config.schema.json"
|
|
13
|
+
},
|
|
14
|
+
"agentScope": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"enum": ["user", "project", "both"],
|
|
17
|
+
"description": "Select user definitions, project definitions, or user definitions followed by project overrides.",
|
|
18
|
+
"default": "user"
|
|
19
|
+
},
|
|
20
|
+
"syncBundledAgents": {
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
"description": "User-level configuration only. Opt in to materializing bundled presets under the Pi agent directory. When true, startup may install, replace, retire, and back up managed agent files; when false, bundled definitions are read directly without writing user files.",
|
|
23
|
+
"default": false
|
|
24
|
+
},
|
|
25
|
+
"maxDepth": {
|
|
26
|
+
"type": "integer",
|
|
27
|
+
"minimum": 0,
|
|
28
|
+
"maximum": 9007199254740991,
|
|
29
|
+
"description": "Absolute delegation depth. A top-level Pi session has depth 0.",
|
|
30
|
+
"default": 3
|
|
31
|
+
},
|
|
32
|
+
"enableRunInBackground": {
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"description": "Enable continuable background children and their model-facing lifecycle controls. Set false for strict foreground-only mode.",
|
|
35
|
+
"default": true
|
|
36
|
+
},
|
|
37
|
+
"defaultBackground": {
|
|
38
|
+
"type": "boolean",
|
|
39
|
+
"description": "Default run mode for the fresh spawn provider when background execution is enabled. Ignored in foreground-only mode.",
|
|
40
|
+
"default": true
|
|
41
|
+
},
|
|
42
|
+
"reportDelivery": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"enum": ["wakeup", "quiet"],
|
|
45
|
+
"description": "Whether child reports trigger a parent turn or wait for the parent's next turn.",
|
|
46
|
+
"default": "wakeup"
|
|
47
|
+
},
|
|
48
|
+
"inheritExtensions": {
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"description": "Load the parent's other Pi extensions in child runtimes. pi-subagent itself is filtered out and explicit agent tool ceilings still apply.",
|
|
51
|
+
"default": false
|
|
52
|
+
},
|
|
53
|
+
"maxOutputBytes": {
|
|
54
|
+
"type": "integer",
|
|
55
|
+
"minimum": 1024,
|
|
56
|
+
"maximum": 1048576,
|
|
57
|
+
"description": "Maximum child output inserted into a parent tool result, report, or settlement notice.",
|
|
58
|
+
"default": 51200
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oai404iao/pi-subagent",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Durable, continuable subagents for Pi with spawn/fork providers and lifecycle controls.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/oai404iao/omp.git",
|
|
8
|
+
"directory": "pi-extensions/pi-subagent"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/oai404iao/omp/tree/main/pi-extensions/pi-subagent#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/oai404iao/omp/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pi-package",
|
|
17
|
+
"pi",
|
|
18
|
+
"pi-coding-agent",
|
|
19
|
+
"extension",
|
|
20
|
+
"subagent",
|
|
21
|
+
"multi-agent"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
28
|
+
"pi": {
|
|
29
|
+
"extensions": [
|
|
30
|
+
"./src/index.ts"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@earendil-works/pi-agent-core": ">=0.84.2",
|
|
35
|
+
"@earendil-works/pi-ai": ">=0.84.2",
|
|
36
|
+
"@earendil-works/pi-coding-agent": ">=0.84.2",
|
|
37
|
+
"@earendil-works/pi-tui": ">=0.84.2",
|
|
38
|
+
"typebox": "*"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@earendil-works/pi-agent-core": "^0.84.2",
|
|
42
|
+
"@earendil-works/pi-ai": "^0.84.2",
|
|
43
|
+
"@earendil-works/pi-coding-agent": "^0.84.2",
|
|
44
|
+
"@earendil-works/pi-tui": "^0.84.2",
|
|
45
|
+
"@types/node": "^26.2.0",
|
|
46
|
+
"tsx": "^4.20.6",
|
|
47
|
+
"typebox": "^1.1.24",
|
|
48
|
+
"typescript": "^7.0.2"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
52
|
+
"test": "tsx --test tests/**/*.test.ts",
|
|
53
|
+
"check": "npm run typecheck && npm test"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"agents/",
|
|
57
|
+
"LICENSES/",
|
|
58
|
+
"provenance/",
|
|
59
|
+
"src/",
|
|
60
|
+
"README.md",
|
|
61
|
+
"LICENSE",
|
|
62
|
+
"THIRD_PARTY_NOTICES.md",
|
|
63
|
+
"config.example.json",
|
|
64
|
+
"config.schema.json",
|
|
65
|
+
"package.json"
|
|
66
|
+
],
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=22.19.0"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"@earendil-works/pi-agent-core": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"@earendil-works/pi-ai": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"@earendil-works/pi-coding-agent": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"@earendil-works/pi-tui": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"typebox": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"gitHead": "ef42984c0e40ef1f26ead4b4c7d149b21280e66b"
|
|
88
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"upstream": {
|
|
4
|
+
"repository": "https://github.com/deepseek-ai/deepseek-harness",
|
|
5
|
+
"revision": "4d03472cd098dc48a630e526ca620f4f37f18a0e",
|
|
6
|
+
"commitUrl": "https://github.com/deepseek-ai/deepseek-harness/commit/4d03472cd098dc48a630e526ca620f4f37f18a0e"
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"LICENSE": {
|
|
10
|
+
"gitBlobSha": "c1f7a78e89e4e4dc7b86664c3b3c76eb5eee1785",
|
|
11
|
+
"sha256": "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
|
|
12
|
+
"rawUrl": "https://raw.githubusercontent.com/deepseek-ai/deepseek-harness/4d03472cd098dc48a630e526ca620f4f37f18a0e/LICENSE"
|
|
13
|
+
},
|
|
14
|
+
"docs/subsystems/subagent.md": {
|
|
15
|
+
"gitBlobSha": "9a21cecce9144c3aa4c268d753c0aeff5f3ac178",
|
|
16
|
+
"sha256": "f8210c06d7e21e3981946d84e1914a057728f07f9b291a5e2a4c2a62b645d685",
|
|
17
|
+
"rawUrl": "https://raw.githubusercontent.com/deepseek-ai/deepseek-harness/4d03472cd098dc48a630e526ca620f4f37f18a0e/docs/subsystems/subagent.md"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|