pi-ptc-subagents 0.1.2 → 1.0.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/CHANGELOG.md +56 -0
- package/README.md +34 -4
- package/dist/index.d.ts +556 -2
- package/dist/index.js +41 -3128
- package/dist/protocol-CfOgxz3u.js +2 -0
- package/dist/worker.js +3 -758
- package/package.json +3 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/protocol-DUnAP1Ro.js +0 -117
- package/dist/protocol-DUnAP1Ro.js.map +0 -1
- package/dist/worker.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,62 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.0] - 2026-09-24
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Background dispatch: PTC programs can fan out to long-lived children.**
|
|
13
|
+
`pi.dispatch(...)` gains an opt-in `{ background: true }` path: instead of
|
|
14
|
+
awaiting the child, the binding returns a `DispatchHandle`
|
|
15
|
+
(`{ taskId, label, status: "running" }`) immediately, and a detached pump
|
|
16
|
+
drives a session-level `TaskRecord` through
|
|
17
|
+
`running / stopping / succeeded / failed / canceled / lost`, past the end of
|
|
18
|
+
the program and of the turn. The handle is a frozen spawn-time projection;
|
|
19
|
+
live state comes from three model-facing tools that stay on when PTC mode is
|
|
20
|
+
off (`/ptc off` only blocks new spawns):
|
|
21
|
+
- **`ptc_task_list`** — list this session's tasks (`status?`, `limit?`,
|
|
22
|
+
default 100, newest first);
|
|
23
|
+
- **`ptc_task_output`** — read a task's captured output (`taskId`,
|
|
24
|
+
`sinceBytes?`), tail-truncated to pi's 50 KB / 2000-line contract
|
|
25
|
+
(ADR-0015) with the full text written to a temp file;
|
|
26
|
+
- **`ptc_task_stop`** — ask a running task to stop (`taskId`, `reason?`,
|
|
27
|
+
default `"model stop"`), moving it `running -> stopping -> canceled`.
|
|
28
|
+
|
|
29
|
+
Lifecycle changes arrive as user-role `<bg-task-notification>` events under a
|
|
30
|
+
`<bg-task-notifications>` batch, cursor-delivered per subscriber with a
|
|
31
|
+
2048-byte inline-preview ceiling. Background tasks count against the existing
|
|
32
|
+
`dispatchConcurrency` (8) for their whole lifetime and share the
|
|
33
|
+
`maxDispatchDepth` (3) recursion bound. Existing foreground `pi.dispatch`
|
|
34
|
+
keeps its `DispatchResult` shape unchanged. ADR-0022.
|
|
35
|
+
|
|
36
|
+
## [0.1.3] - 2026-09-23
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- **PTC rows show what the program is doing while it runs.** Two partial-state
|
|
41
|
+
visuals on the `ptc_run_code` / `ptc_workflow` row, both absent until now:
|
|
42
|
+
- a **shimmer** on the call row — same text, one character at a time bright,
|
|
43
|
+
the highlight sweeping at 150ms — so a running row is distinguishable from a
|
|
44
|
+
settled one in a column (ADR-0020);
|
|
45
|
+
- a **sub-call tree** under it: one row per binding call the program made,
|
|
46
|
+
live from the moment the call is made, with its own five-state status
|
|
47
|
+
(`running` / `ok` / `error` / `cancelled` / `rejected`) and duration,
|
|
48
|
+
visible without expanding the row and capped at 32 with a `+N more` tail
|
|
49
|
+
(ADR-0021). A failed run shows the failure text but no sub-call tree: the
|
|
50
|
+
tool throws (pi's convention), and pi builds that error result with an empty
|
|
51
|
+
`details`, so the tracked calls are dropped with it.
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
|
|
55
|
+
- **Build pipeline: minify + source-map exclusion.** `pnpm run build`
|
|
56
|
+
(`vp pack`) now produces minified `dist/*.js` (rolldown's built-in oxc
|
|
57
|
+
minifier; no new dependency). The npm tarball excludes `dist/**/*.map`
|
|
58
|
+
via the `package.json#files` whitelist — sourcemaps stay on disk for
|
|
59
|
+
local stack traces, but no longer ship. Tarball shrinks from 168.7 kB
|
|
60
|
+
packed / 548.6 kB unpacked (v0.1.2 baseline) to 40.5 kB / 113.6 kB
|
|
61
|
+
(−76% / −79%); `dist/*.js` total shrinks from 161,303 B to 53,959 B
|
|
62
|
+
(−66.5%). All 39 public exports retain their original names. ADR-0019.
|
|
63
|
+
|
|
8
64
|
## [0.1.2] - 2026-09-23
|
|
9
65
|
|
|
10
66
|
### Fixed
|
package/README.md
CHANGED
|
@@ -32,6 +32,9 @@ required — install it and the extension is on for the next pi startup.
|
|
|
32
32
|
- `ptc_workflow` — structured variant with `meta` + plain-JSON `args`, plus the
|
|
33
33
|
workflow helpers (`log`, `phase`, `parallel`, `pipeline`). There is no
|
|
34
34
|
`agent()` helper on either surface.
|
|
35
|
+
- `ptc_task_list` / `ptc_task_output` / `ptc_task_stop` — manage background
|
|
36
|
+
dispatches (see [Background dispatch](#background-dispatch)). They stay
|
|
37
|
+
available when PTC mode is off.
|
|
35
38
|
|
|
36
39
|
Long output follows pi's own truncation contract ([ADR-0015](./docs/adr/0015-pi-truncation-contract.md)):
|
|
37
40
|
|
|
@@ -43,9 +46,11 @@ the next program can `tools.read`; the collapsed row then shows `truncated` in i
|
|
|
43
46
|
|
|
44
47
|
PTC programs can spawn a fresh `pi` subprocess per call via the **`pi.dispatch(...)`** binding ([ADR-0016](./docs/adr/0016-ptc-dispatch-binding.md)). Use it to fan out to a specialist agent — the child subprocess loads the named agent's markdown from `~/.pi/agent/agents/<name>.md` (or `.pi/agents/<name>.md` for project-scope agents), runs that agent's tool set and system prompt in isolation, and returns a structured result.
|
|
45
48
|
|
|
49
|
+
Bindings are reached through the one `tools` table — there is no `pi` global in the worker — so the binding named `pi.dispatch` is called as `tools["pi.dispatch"]({ … })` with a single object argument.
|
|
50
|
+
|
|
46
51
|
```ts
|
|
47
52
|
// inside a ptc_run_code program
|
|
48
|
-
const result = await pi.dispatch({
|
|
53
|
+
const result = await tools["pi.dispatch"]({
|
|
49
54
|
agent: "scout",
|
|
50
55
|
task: "find all auth code in src/",
|
|
51
56
|
cwd: process.cwd(),
|
|
@@ -62,8 +67,8 @@ const result = await pi.dispatch({
|
|
|
62
67
|
```ts
|
|
63
68
|
const [read, scoutA, scoutB] = await Promise.all([
|
|
64
69
|
tools.read({ path: "package.json" }),
|
|
65
|
-
pi.dispatch({ agent: "scout", task: "review auth" }),
|
|
66
|
-
pi.dispatch({ agent: "scout", task: "review db" }),
|
|
70
|
+
tools["pi.dispatch"]({ agent: "scout", task: "review auth" }),
|
|
71
|
+
tools["pi.dispatch"]({ agent: "scout", task: "review db" }),
|
|
67
72
|
]);
|
|
68
73
|
```
|
|
69
74
|
|
|
@@ -78,11 +83,36 @@ const [read, scoutA, scoutB] = await Promise.all([
|
|
|
78
83
|
```ts
|
|
79
84
|
// in a hypothetical runner that wants to keep reads-only:
|
|
80
85
|
createBuiltinBindings({ cwd: "/abs/path", names: ["read", "grep"] });
|
|
81
|
-
// `pi.dispatch` is NOT in the resulting table.
|
|
86
|
+
// `pi.dispatch` is NOT in the resulting `tools` table.
|
|
82
87
|
```
|
|
83
88
|
|
|
84
89
|
**Not a subagent.** The term _subagent_ is overloaded in this field (DSH's `subagent` is a different thing; pi's `examples/extensions/subagent/` extension is also a different thing). pi-ptc uses _parallel binding_ and _concurrent tool call_ throughout; see `CONTEXT.md` for the canonical terms.
|
|
85
90
|
|
|
91
|
+
### Background dispatch
|
|
92
|
+
|
|
93
|
+
Foreground `pi.dispatch` blocks the program until the child exits. Pass `background: true` to spawn the child and return immediately with a `DispatchHandle` ([ADR-0022](./docs/adr/0022-background-dispatch.md)); the child outlives both the program and the turn:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
// inside a ptc_run_code program — bindings are reached as tools["<name>"]
|
|
97
|
+
const handle = await tools["pi.dispatch"]({
|
|
98
|
+
agent: "scout",
|
|
99
|
+
task: "audit the auth code",
|
|
100
|
+
background: true,
|
|
101
|
+
label: "auth audit", // defaults to task.slice(0, 64)
|
|
102
|
+
});
|
|
103
|
+
// handle: { taskId: "01J…", label: "auth audit", status: "running" }
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
(The binding's name is `pi.dispatch`; a program reaches it as `tools["pi.dispatch"]`.)
|
|
107
|
+
|
|
108
|
+
A detached pump drives the task's lifecycle (`running` -> `succeeded` / `failed` / `canceled` / `lost`), and the model observes it with three always-on tools — they are not part of the PTC-mode loadout, so `/ptc off` (which only blocks new spawns) does not remove them:
|
|
109
|
+
|
|
110
|
+
- `ptc_task_list({ status?, limit? })` — list this session's tasks, newest first (default limit 100).
|
|
111
|
+
- `ptc_task_output({ taskId, sinceBytes? })` — read a task's captured output, tail-truncated to pi's 50 KB / 2000-line contract (ADR-0015).
|
|
112
|
+
- `ptc_task_stop({ taskId, reason? })` — ask a running task to stop.
|
|
113
|
+
|
|
114
|
+
Background tasks count against the same `dispatchConcurrency` (default 8) for their whole lifetime and share the `maxDispatchDepth` (default 3) recursion bound. A pre-spawn refusal (depth or concurrency cap, unknown agent) still comes back as the familiar `DispatchResult` with `status: "rejected"`. Full guide: [`docs/usage/bgdispatch.md`](./docs/usage/bgdispatch.md).
|
|
115
|
+
|
|
86
116
|
## TUI rendering
|
|
87
117
|
|
|
88
118
|
Both tools register custom `renderCall` / `renderResult` hooks, so a PTC run reads as a program
|