@herbertgao/pi-extensions 2026.11.1 → 2026.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +4 -4
  3. package/THIRD_PARTY_NOTICES.md +2 -2
  4. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  5. package/node_modules/@herbertgao/pi-subagents/README.md +43 -33
  6. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +1 -1
  7. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +2 -0
  8. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  9. package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +9 -8
  10. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +70 -9
  11. package/node_modules/@herbertgao/pi-subagents/src/agent-record-entry.ts +167 -0
  12. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +156 -13
  13. package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +52 -8
  14. package/node_modules/@herbertgao/pi-subagents/src/default-agents.ts +3 -4
  15. package/node_modules/@herbertgao/pi-subagents/src/index.ts +153 -56
  16. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +3 -2
  17. package/node_modules/@herbertgao/pi-subagents/src/status-note.ts +3 -1
  18. package/node_modules/@herbertgao/pi-subagents/src/types.ts +5 -0
  19. package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +88 -6
  20. package/node_modules/@herbertgao/pi-subagents/src/workflow/progress.ts +3 -2
  21. package/node_modules/pi-provider-qoder/README.md +40 -0
  22. package/node_modules/pi-provider-qoder/dist/index.js +64 -0
  23. package/node_modules/pi-provider-qoder/package.json +4 -3
  24. package/node_modules/pi-typesafe/README.md +3 -3
  25. package/node_modules/pi-typesafe/dist/auth.d.ts +21 -4
  26. package/node_modules/pi-typesafe/dist/auth.js +32 -7
  27. package/node_modules/pi-typesafe/dist/backends.d.ts +2 -2
  28. package/node_modules/pi-typesafe/dist/backends.js +9 -0
  29. package/node_modules/pi-typesafe/dist/client.js +7 -12
  30. package/node_modules/pi-typesafe/dist/errors.d.ts +3 -2
  31. package/node_modules/pi-typesafe/dist/errors.js +12 -10
  32. package/node_modules/pi-typesafe/dist/extension.js +14 -10
  33. package/node_modules/pi-typesafe/package.json +1 -1
  34. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @herbertgao/pi-extensions
2
2
 
3
+ ## 2026.11.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#350](https://github.com/HerbertGao/pi-extensions/pull/350) [`7cda824`](https://github.com/HerbertGao/pi-extensions/commit/7cda82499d91253636153397d00d63ad7d40ace6) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Pin pi-provider-qoder 0.6.10 and pi-typesafe 0.14.0. Qoder logs one line when a newer npm release exists, and that lookup can be skipped. TypeSafe treats only a recent HTTP 401 as a rejected key, and adds Nace.AI as a judgment backend.
8
+
9
+ - Updated dependencies [[`7cda824`](https://github.com/HerbertGao/pi-extensions/commit/7cda82499d91253636153397d00d63ad7d40ace6)]:
10
+ - @herbertgao/pi-subagents@0.23.0
11
+
3
12
  ## 2026.11.1
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -22,7 +22,7 @@ The package bundles 6 active `@herbertgao/*` child packages—`pi-agency`, `pi-b
22
22
 
23
23
  - `pi-antigravity@0.11.0`
24
24
  - `pi-commandcode-provider@0.7.11`
25
- - `pi-provider-qoder@0.6.9`
25
+ - `pi-provider-qoder@0.6.10`
26
26
  - `@dietrichgebert/ponytail@5.3.3`
27
27
  - `@juicesharp/rpiv-ask-user-question@2.15.0`
28
28
  - `@narumitw/pi-btw@0.63.3`
@@ -34,7 +34,7 @@ The package bundles 6 active `@herbertgao/*` child packages—`pi-agency`, `pi-b
34
34
  - `@tifan/pi-recap@0.4.8`
35
35
  - `@tifan/pi-rename@0.6.0`
36
36
  - `@tintinweb/pi-tasks@0.9.1`
37
- - `pi-typesafe@0.13.1`
37
+ - `pi-typesafe@0.14.0`
38
38
  - `pi-next-cue@1.0.8`
39
39
  - `pi-lens@4.4.8`
40
40
  - `pi-web-access@0.46.0`
@@ -61,9 +61,9 @@ Impeccable `4.8.0` is vendored as `@herbertgao/pi-impeccable` and loaded with `/
61
61
 
62
62
  `@narumitw/pi-btw@0.63.3` opens its side workspace through the `@narumitw/pi-tui-kit@^0.68.0` fullscreen handoff. It does not start that UI when the flow is already disposed or the parent terminal cannot be restored. Only one BTW flow can be open per session; a second `/btw` warns and stays closed. In split layout, mounting the first split releases Pi's idle wait so the main input stays usable. Importing new main-thread context stays manual. Settings rows keep a clipped label or value in full under the list, and a searchable model choice shows how many results match.
63
63
 
64
- `clef` asks Cloudflare Clef-flash an on-demand yes/no, choice, or score and prints the questions and answers in the transcript, plus a one-line notice. It is not a permission gate. `pi-typesafe@0.13.1` provides `/typesafe` and `typesafe_evaluate` for explicit structured decisions; `/typesafe enable` or `PI_TYPESAFE_ENABLED=1` is still required for agent tool calls. The default backend remains `https://api.typesafe.ai`. `PI_TYPESAFE_BACKEND` and `PI_TYPESAFE_MODEL` select the session backend and model, and `/typesafe login` stores a key for the named backend. Daily request, token, and USD caps are opt-in. OpenRouter, Command Code, Liquid, SubQ, and a named endpoint stay explicit and use that backend's own key. The promoted SDK is `@typesafe-ai/sdk@0.7.0`. Under Bun, the judge transport reads each response body once and replays it, so the SDK can still read the result after Bun marks the original body used.
64
+ `clef` asks Cloudflare Clef-flash an on-demand yes/no, choice, or score and prints the questions and answers in the transcript, plus a one-line notice. It is not a permission gate. `pi-typesafe@0.14.0` provides `/typesafe` and `typesafe_evaluate` for explicit structured decisions; `/typesafe enable` or `PI_TYPESAFE_ENABLED=1` is still required for agent tool calls. The default backend remains `https://api.typesafe.ai`. `PI_TYPESAFE_BACKEND` and `PI_TYPESAFE_MODEL` select the session backend and model, and `/typesafe login` stores a key for the named backend. Only HTTP 401 refuses that key, and only for 15 minutes; a 403 refuses one request and leaves the key usable. Nace.AI (`https://console.nace.ai`, `NACE_API_KEY`, default model `drex-v2.0`) is a judgment backend. Daily request, token, and USD caps are opt-in. OpenRouter, Command Code, Liquid, SubQ, Nace.AI, and a named endpoint stay explicit and use that backend's own key. The promoted SDK is `@typesafe-ai/sdk@0.7.0`. Under Bun, the judge transport reads each response body once and replays it, so the SDK can still read the result after Bun marks the original body used.
65
65
 
66
- `@herbertgao/sol-pi` adds opt-in Action Fusion, ObservationPack, Evidence-Preserving Reducer, and Online Context Compact; see its [configuration guide](../sol-pi/docs/configuration.md). `pi-lens@4.4.8` publishes a public LSP config schema, reads user-level custom rule directories (project before user before built-in), normalizes argv-style server entries, downgrades `throw-new-error` to a warning, and counts Docker, JSON, and Jedi servers in idle eviction; language routing and the retained multi-root diagnostic facts are unchanged. It promotes `@ast-grep/cli` to `0.51.0` and `@ast-grep/napi` to `^0.51.0`. Concatenated SQL passed to `.execute()` is an advisory full-analysis finding; a parameterized `execute(sql, values)` call stays quiet. Keeping injected findings in later requests is opt-in. A workspace edit through a dangling symlink is refused, and a symlink that resolves outside the workspace is refused; the fallback Biome config no longer names a nursery rule. An identity `filter(x => x).map(...)` stays a warning, and a non-identity `filter(fn).map(...)` is no longer flagged. A reduce that copies its accumulator with `Object.assign` is a warning. A directory whose name starts with `..` stays inside its project. `minimatch` is `^11.0.1`. `pi-web-access@0.46.0` provides configurable web search and fetch tools; its `toolActivation` defaults to `auto`, choosing eager or dynamic tool activation per model. `toolActivation: "none"` stays opt-in and still requires deferred exposure. Field extraction, 9router, empty or off-topic search fallback, and plain HTTP gateway URLs stay off unless configured. An unknown tool-call provider name fails instead of selecting a provider automatically, and DuckDuckGo searches stay spaced apart after a bot check. It adds structured search/fetch data for codemode and an optional, manually started `pi-web-access-mcp` stdio CLI; installing the aggregate does not start that server. Degoog, Keenable, Ceramic, Linkup, DeepSeek fetch, Cloudflare search, SearchApi, and Tabstack are explicit-only, excluded from automatic and `all` selection. Optional `fetchContent.curl` and Exa/Tabstack fetch routing stay off unless configured. Provider gateway base URLs are opt-in and are not configured by the aggregate. OpenAI search now defaults to `gpt-6-luna`, results and clone cleanup are scoped per extension instance, and the promoted `@modelcontextprotocol/sdk@^1.32.1` moves the bundle off GHSA-6qxp-vccf-f47h. Perplexity search now uses the Search API's ranked pages and snippets rather than a Sonar-generated answer; requests requiring prose still use Sonar. `pi-antigravity@0.11.0` reads Pi 0.86+ transcript system messages, so Antigravity requests carry Pi's system prompt and tools; it also registers `google_search` and `generate_image` tools that use the signed-in Antigravity account. `pi-provider-qoder@0.6.9` registers the `qoder` and `qoder-cn` model providers. A queued model-busy response reports its wait instead of being ignored; a ready busy response stays retryable. A queued wait that does not fit in a safe millisecond count uses `retryAfterSeconds` instead. Agent chat prefers the account's remote-agent node and, on daily chat limit code 110, tries the next node. The chosen node is cached for one hour. Sign in with `/login qoder` (browser or a personal access token from [qoder.com/account/integrations](https://qoder.com/account/integrations)) or `/login qoder-cn` (token from [qoder.com.cn/account/integrations](https://qoder.com.cn/account/integrations)). `QODER_PERSONAL_ACCESS_TOKEN` and `QODERCN_PERSONAL_ACCESS_TOKEN` log those providers in at startup. `/qoder-usage footer on` replaces the status-bar footer for that session, so leave it off while the pi-cc footer is in use. `pi-commandcode-provider@0.7.11` registers `commandcode` beside `qoder`, `qoder-cn`, and `antigravity`. `/login` lists those subscription providers and runs only the one you select. `@tifan/pi-preferred-thinking` is no longer bundled. Per-model thinking levels come from Pi. Deprecated `@tifan/pi-titlebar-spinner` is no longer bundled; Rename remains the single owner of Herdr tab naming. `@tifan/pi-handoff` imports `@tifan/pi-rename/naming` when it generates a session name, so Rename stays installed and its `/rename` command stays registered.
66
+ `@herbertgao/sol-pi` adds opt-in Action Fusion, ObservationPack, Evidence-Preserving Reducer, and Online Context Compact; see its [configuration guide](../sol-pi/docs/configuration.md). `pi-lens@4.4.8` publishes a public LSP config schema, reads user-level custom rule directories (project before user before built-in), normalizes argv-style server entries, downgrades `throw-new-error` to a warning, and counts Docker, JSON, and Jedi servers in idle eviction; language routing and the retained multi-root diagnostic facts are unchanged. It promotes `@ast-grep/cli` to `0.51.0` and `@ast-grep/napi` to `^0.51.0`. Concatenated SQL passed to `.execute()` is an advisory full-analysis finding; a parameterized `execute(sql, values)` call stays quiet. Keeping injected findings in later requests is opt-in. A workspace edit through a dangling symlink is refused, and a symlink that resolves outside the workspace is refused; the fallback Biome config no longer names a nursery rule. An identity `filter(x => x).map(...)` stays a warning, and a non-identity `filter(fn).map(...)` is no longer flagged. A reduce that copies its accumulator with `Object.assign` is a warning. A directory whose name starts with `..` stays inside its project. `minimatch` is `^11.0.1`. `pi-web-access@0.46.0` provides configurable web search and fetch tools; its `toolActivation` defaults to `auto`, choosing eager or dynamic tool activation per model. `toolActivation: "none"` stays opt-in and still requires deferred exposure. Field extraction, 9router, empty or off-topic search fallback, and plain HTTP gateway URLs stay off unless configured. An unknown tool-call provider name fails instead of selecting a provider automatically, and DuckDuckGo searches stay spaced apart after a bot check. It adds structured search/fetch data for codemode and an optional, manually started `pi-web-access-mcp` stdio CLI; installing the aggregate does not start that server. Degoog, Keenable, Ceramic, Linkup, DeepSeek fetch, Cloudflare search, SearchApi, and Tabstack are explicit-only, excluded from automatic and `all` selection. Optional `fetchContent.curl` and Exa/Tabstack fetch routing stay off unless configured. Provider gateway base URLs are opt-in and are not configured by the aggregate. OpenAI search now defaults to `gpt-6-luna`, results and clone cleanup are scoped per extension instance, and the promoted `@modelcontextprotocol/sdk@^1.32.1` moves the bundle off GHSA-6qxp-vccf-f47h. Perplexity search now uses the Search API's ranked pages and snippets rather than a Sonar-generated answer; requests requiring prose still use Sonar. `pi-antigravity@0.11.0` reads Pi 0.86+ transcript system messages, so Antigravity requests carry Pi's system prompt and tools; it also registers `google_search` and `generate_image` tools that use the signed-in Antigravity account. `pi-provider-qoder@0.6.10` registers the `qoder` and `qoder-cn` model providers. Startup logs one line when the npm registry has a newer release; `PI_PROVIDER_QODER_SKIP_UPDATE_CHECK=1` skips that lookup. A queued model-busy response reports its wait instead of being ignored; a ready busy response stays retryable. A queued wait that does not fit in a safe millisecond count uses `retryAfterSeconds` instead. Agent chat prefers the account's remote-agent node and, on daily chat limit code 110, tries the next node. The chosen node is cached for one hour. Sign in with `/login qoder` (browser or a personal access token from [qoder.com/account/integrations](https://qoder.com/account/integrations)) or `/login qoder-cn` (token from [qoder.com.cn/account/integrations](https://qoder.com.cn/account/integrations)). `QODER_PERSONAL_ACCESS_TOKEN` and `QODERCN_PERSONAL_ACCESS_TOKEN` log those providers in at startup. `/qoder-usage footer on` replaces the status-bar footer for that session, so leave it off while the pi-cc footer is in use. `pi-commandcode-provider@0.7.11` registers `commandcode` beside `qoder`, `qoder-cn`, and `antigravity`. `/login` lists those subscription providers and runs only the one you select. `@tifan/pi-preferred-thinking` is no longer bundled. Per-model thinking levels come from Pi. Deprecated `@tifan/pi-titlebar-spinner` is no longer bundled; Rename remains the single owner of Herdr tab naming. `@tifan/pi-handoff` imports `@tifan/pi-rename/naming` when it generates a session name, so Rename stays installed and its `/rename` command stays registered.
67
67
 
68
68
  `pi-stash` is no longer bundled: `/btw` already preserves the main editor draft while handling side questions outside the main conversation. Prior `@herbertgao/pi-stash` releases remain available but are no longer maintained here.
69
69
 
@@ -109,7 +109,7 @@ THE SOFTWARE.
109
109
 
110
110
  ## `pi-typesafe`
111
111
 
112
- The aggregate bundles [`pi-typesafe`](https://github.com/DevMortimer/pi-typesafe) version 0.13.1 under its original MIT license:
112
+ The aggregate bundles [`pi-typesafe`](https://github.com/DevMortimer/pi-typesafe) version 0.14.0 under its original MIT license:
113
113
 
114
114
  MIT License
115
115
 
@@ -213,7 +213,7 @@ THE SOFTWARE.
213
213
 
214
214
  ## `pi-provider-qoder`
215
215
 
216
- The aggregate bundles [`pi-provider-qoder`](https://github.com/simonsmh/pi-provider-qoder) version 0.6.9 under its original package name. npm metadata and the repository README declare the MIT license. The published tarball does not include a LICENSE file. The published package corresponds to git commit [`b4dd6a1e42763ccc5ead629d6ec171b07e09105d`](https://github.com/simonsmh/pi-provider-qoder/commit/b4dd6a1e42763ccc5ead629d6ec171b07e09105d).
216
+ The aggregate bundles [`pi-provider-qoder`](https://github.com/simonsmh/pi-provider-qoder) version 0.6.10 under its original package name. npm metadata and the repository README declare the MIT license. The published tarball does not include a LICENSE file. The published package corresponds to git commit [`5275508caeabb311062f84080e0b618d25a301cc`](https://github.com/simonsmh/pi-provider-qoder/commit/5275508caeabb311062f84080e0b618d25a301cc).
217
217
 
218
218
  ## `@herbertgao/pi-impeccable`
219
219
 
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.23.0-local.1
4
+
5
+ ### Minor Changes
6
+
7
+ - [#350](https://github.com/HerbertGao/pi-extensions/pull/350) [`7cda824`](https://github.com/HerbertGao/pi-extensions/commit/7cda82499d91253636153397d00d63ad7d40ace6) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Replay subagents onto upstream 0.23.0. A direct mention of an agent that inherits context now includes the conversation. Resume reopens an evicted agent from its saved session, and a saved result still answers after the live record is gone. Explore uses the session model. Claude Code tool names and bare MCP tool entries select the tools they name. Unconsumed results and a failed worktree cleanup still stay recoverable.
8
+
3
9
  ## 0.22.1-local.1
4
10
 
5
11
  ### Minor Changes
@@ -214,12 +214,12 @@ It is a literal clone — the session's own entries and the same system prompt,
214
214
  | Mode | `@plan sketch the migration`, with no Plan agent running |
215
215
  | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
216
216
  | `model` (default) | a clone of this conversation takes the turn off-screen and calls `Agent`, so the agent starts with a prompt **written from the conversation**. Nothing reaches the chat but a `Prompting @plan…` toast — the wording marks the wait for that turn, where `direct`'s `Started @plan` means it is already running |
217
- | `direct` | the agent starts here, immediately, with your message verbatim as its prompt. No model call at all, so no latency before it begins |
217
+ | `direct` | the agent starts here, immediately, with your message verbatim as its prompt (after this conversation, if its file sets `inherit_context`). No model call at all, so no latency before it begins |
218
218
  | `off` | `@` means only "attach a file" again |
219
219
 
220
- Either way the started agent honours its own frontmatter — `model:`, `thinking:`, `max_turns:` all apply, since neither path passes them and the agent's config wins. Mentioning something as the very first thing in a session works: there is simply no history to carry, and the clone still runs on your model and system prompt. If it cannot deliver at all — a model can always answer in prose instead of calling the tool — the agent is started directly with your text and the toast says so, rather than leaving you with nothing running.
220
+ Either way the started agent honours its own frontmatter — `model:`, `thinking:`, `max_turns:` all apply, since neither path passes them and the agent's config wins, and `inherit_context: true` hands it this conversation even in `direct` mode. Mentioning something as the very first thing in a session works: there is simply no history to carry, and the clone still runs on your model and system prompt. If it cannot deliver at all — a model can always answer in prose instead of calling the tool — the agent is started directly with your text and the toast says so, rather than leaving you with nothing running.
221
221
 
222
- `model` is also the only mode that works outside the TUI: `pi -p '@plan the migration'` clones, spawns, and reports through the normal completion path, where a direct start would have detached the agent and printed nothing. Messaging and resuming stay TUI-only for that reason, in both modes.
222
+ Mentions are TUI-only. In `pi -p '@plan the migration'`, pi itself reads the leading `@plan` as a file to attach and exits with `File not found` before any extension sees the prompt. For a headless run, ask for the agent in plain words so the model calls the `Agent` tool, or use [`--subagents-workflow-file`](#cli-flags).
223
223
 
224
224
  Two things to weigh against `direct`: the clone re-sends the whole conversation, and the agent does not start until that turn finishes.
225
225
 
@@ -269,15 +269,15 @@ Group completions render each agent as a separate block. The LLM receives struct
269
269
 
270
270
  ## Default Agent Types
271
271
 
272
- | Type | Tools | Model | Prompt Mode | Description |
273
- | ----------------- | -------------------------- | ----------------------------- | ---------------------- | ------------------------------------------------------------------------------------- |
274
- | `general-purpose` | all 7 | inherit | `append` (parent twin) | Inherits the parent's full system prompt — same rules, CLAUDE.md, project conventions |
275
- | `Explore` | read, bash, grep, find, ls | haiku (falls back to inherit) | `replace` (standalone) | Fast codebase exploration (read-only) |
276
- | `Plan` | read, bash, grep, find, ls | inherit | `replace` (standalone) | Software architect for implementation planning (read-only) |
272
+ | Type | Tools | Model | Prompt Mode | Description |
273
+ | ----------------- | -------------------------- | ------- | ---------------------- | ------------------------------------------------------------------------------------- |
274
+ | `general-purpose` | all 7 | inherit | `append` (parent twin) | Inherits the parent's full system prompt — same rules, CLAUDE.md, project conventions |
275
+ | `Explore` | read, bash, grep, find, ls | inherit | `replace` (standalone) | Fast codebase exploration (read-only) |
276
+ | `Plan` | read, bash, grep, find, ls | inherit | `replace` (standalone) | Software architect for implementation planning (read-only) |
277
277
 
278
278
  The `general-purpose` agent is a **parent twin** — it receives the parent's system prompt plus a sub-agent context bridge, so it follows the same rules the parent does. The parent's skill list, cwd and extension sections are left out: the subagent's own session adds them for itself, so its skills follow its `skills` setting. Explore and Plan use standalone prompts tailored to their read-only roles.
279
279
 
280
- Default agents can be **ejected** (`/agents` → select agent → Eject) to export them as `.md` files for customization, **overridden** by creating a `.md` file with the same name (e.g. `.pi/agents/general-purpose.md`), or **disabled** per-project with `enabled: false` frontmatter.
280
+ Default agents can be **ejected** (`/agents` → select agent → Eject) to export them as `.md` files for customization, **overridden** by creating a `.md` file with the same name (e.g. `.pi/agents/general-purpose.md`), or **disabled** per-project with `enabled: false` frontmatter. To run Explore on a cheaper model, eject it and add `model:` (e.g. `model: anthropic/claude-haiku-4-5`); a pinned model resolves through any provider with a key, not just the session's.
281
281
 
282
282
  ## Custom Agents
283
283
 
@@ -334,12 +334,12 @@ All fields are optional — sensible defaults for everything.
334
334
  | `name` | filename | **The agent's type** — what `subagent_type` and `@handle` address. Claude Code's rule: the filename doesn't have to match, so `blubb.md` with `name: code-review` dispatches as `code-review`. Omit it and the filename is used. Any value works except one containing `:`, which Claude Code reserves for plugin-scoped identifiers — such a file is skipped with a warning. Two files may declare the same name; the later load wins, as a filename clash always did |
335
335
  | `display_name` | the type | Label shown in the UI (widget, agent list, badges) — cosmetic only, and independent of `name`. Claude Code has no equivalent; a file that sets only `name` badges as its type, unchanged |
336
336
  | `color` | — | Background color for the agent name badge in the Agent tool header, widget, FleetView, and conversation viewer. Supports Claude Code's `red`, `blue`, `green`, `yellow`, `purple`, `orange`, `pink`, `cyan` (the values its own default theme uses); quoted six-digit hex such as `"#8B5CF6"`; and Agency Agents aliases (`amber`, `teal`, `indigo`, `gold`, `neon-green`, `neon-cyan`, `metallic-blue`, `violet`, `rose`, `lime`, `gray`/`grey`, `fuchsia`, `slate`, `navy`). Badge text is black or white, whichever clears 4.5:1 against the rendered background — Claude Code uses one inverse color for every badge. Invalid values render no badge and preserve each surface's existing theme foreground |
337
- | `tools` | all 7 | Which tools the agent can call. Built-in names (`read, grep, …`), `*` / `all` (all built-ins), `none`, and `ext:<extension>` / `ext:<extension>/<tool>` selectors for extension tools. See [Tool & extension scoping](#tool--extension-scoping) below |
337
+ | `tools` | all 7 | Which tools the agent can call. Built-in names (`read, grep, …`, or Claude Code's `Read, Glob, …`), `*` / `all` (all built-ins), `none`, `ext:<extension>` / `ext:<extension>/<tool>` selectors for extension tools, and bare `mcp__<server>__<tool>` entries for MCP tools. See [Tool & extension scoping](#tool--extension-scoping) below |
338
338
  | `extensions` | `true` | Which extensions to load for the agent. `true` (all defaults), `false` (none), or an explicit list: `[mcp, "/abs/path.ts", "*"]`. See [Tool & extension scoping](#tool--extension-scoping) below |
339
339
  | `exclude_extensions` | — | Extension denylist applied after `extensions:` — exclude wins. Plain names only (case-insensitive), no paths or `*`. Useful with `extensions: true` to drop one extension (e.g. `pi-notify`) |
340
340
  | `skills` | `true` | `true` inherits the parent's skills; `false` inherits none. A comma-separated list preloads **only** those skills into the system prompt and does not inherit the rest (see [Skill Preloading](#skill-preloading) for discovery locations) |
341
341
  | `memory` | — | Persistent agent memory scope: `project`, `local`, or `user`. Auto-detects read-only agents |
342
- | `disallowed_tools` | — | Comma-separated tools to deny even if extensions provide them |
342
+ | `disallowed_tools` | — | Comma-separated tools to deny even if extensions provide them. Claude Code's `disallowedTools` key and tool names (`Write`, `Glob`) work too |
343
343
  | `isolation` | — | Set to `worktree` to run in an isolated git worktree, or `off` to refuse one even when the caller passes `isolation: "worktree"` (frontmatter is authoritative). Workflow scripts are the exception: as in Claude Code, only their `agent()` option decides. `none`, `no`, and `false` are accepted spellings of `off` |
344
344
  | `model` | inherit parent | Model — `provider/modelId` or fuzzy name (`"haiku"`, `"sonnet"`). Resolved tolerantly (`.`/`-` and a trailing date stamp are interchangeable) and falls back to the same model under another provider if the named one doesn't have it |
345
345
  | `thinking` | inherit | off, minimal, low, medium, high, xhigh, max — actual availability depends on your pi version and model; pi clamps unsupported levels down |
@@ -358,7 +358,7 @@ Frontmatter is authoritative. If an agent file sets `model`, `thinking`, `max_tu
358
358
 
359
359
  - `isolated` holds on every spawn path, including `@handle` mentions, workflows and [cross-extension RPC](https://github.com/HerbertGao/pi-extensions/blob/master/packages/pi-subagents/docs/rpc.md).
360
360
  - `isolation` holds on every path except workflows: as in Claude Code, only the script's `agent()` option decides there.
361
- - `inherit_context` applies only to `Agent` tool and nested spawns, including default-mode `@handle` mentions, which spawn through the `Agent` tool. As in Claude Code, where only a fork inherits the conversation, every other spawn starts fresh unless its caller asks: workflow children and scheduled runs never inherit, and an RPC caller opts in with `inheritContext`.
361
+ - `inherit_context` holds wherever you start the agent from this session: `Agent` tool and nested spawns, and `@handle` mentions in either mode. Spawns another caller starts are its caller's to decide, as in Claude Code, where only a fork inherits the conversation: workflow children and scheduled runs never inherit, and an RPC caller opts in with `inheritContext`.
362
362
 
363
363
  **Forgiving `model:` resolution.** A `model:` pin is matched against pi's model registry tolerantly, so cosmetic id variations don't silently drop the agent back to the parent's model: `.` and `-` are treated as equivalent in version numbers (`claude-haiku-4.5` ≡ `claude-haiku-4-5`), a trailing `-YYYYMMDD` date stamp is optional (`anthropic/claude-haiku-4-5-20251001` matches an undated registry id and vice-versa), and a `provider/modelId` whose named provider doesn't carry that model retries the bare id against every provider. Precedence is **exact → fuzzy under the named provider → same model under any provider → unavailable**, so an exact match always wins and dated snapshots aren't conflated. If nothing resolves, the pin can't run and the agent inherits the parent model — `/agents → Agent types` flags this case as `(unavailable, fallback: inherit)` and shows the resolved target `(→ provider/id)` when resolution lands on a different provider or version than configured. (This is distinct from [Model Scope](#model-scope) enforcement, which matches the `enabledModels` allowlist by _exact_ entry.)
364
364
 
@@ -395,6 +395,8 @@ tools: read, grep, find # narrow to listed built-ins; extensions still load
395
395
  tools: "*" # all 7 built-ins (alias: `all`)
396
396
  tools: none # zero built-ins (alias: `""`)
397
397
  tools: "*, ext:mcp/search" # built-ins plus one extension tool
398
+ tools: Read, Grep, Glob # Claude Code names: read, grep, find
399
+ tools: "read, mcp__radius__*" # read plus the radius MCP server's tools
398
400
 
399
401
  extensions: false # no extensions load
400
402
  extensions: [mcp] # only mcp loads
@@ -416,24 +418,27 @@ A few rules the examples don't make obvious:
416
418
  - `extensions:` is the sole loading authority. `ext:foo` in `tools:` narrows what surfaces; it can't load `foo` on its own. Mismatches fire `extension-error:…` warnings.
417
419
  - Any `ext:` entry flips extension tools to an explicit allowlist — unnamed extensions still load (handlers fire) but expose no tools. So `tools: "*, ext:mcp/search"` exposes only `search` from `mcp`, nothing from any other extension.
418
420
  - Extension names match case-insensitively (`[Mcp]` = `[mcp]`); tool names in `ext:foo/bar` stay case-sensitive.
421
+ - Claude Code agent files work as written. Built-in names match case-insensitively (`Read` = `read`), `Glob` means `find` and `MultiEdit` means `edit`; Claude Code tools pi lacks (`WebFetch`, `Task`) fire a `tools-error:…` warning. `disallowedTools` is read as `disallowed_tools`.
422
+ - Bare `mcp__<server>__<tool>` entries (exact, or `*` patterns like `mcp__radius__*`; a server-level `mcp__radius` means the whole server, as in Claude Code) narrow MCP tools as pi's `--tools` does: only matching MCP tools stay, from whichever extension serves them, and every other extension tool follows the rules above. The `codemode` and `tool_search` bridges that reach MCP tools stay in scope automatically, even under an `ext:` allowlist. With `extensions: false` or `isolated: true` nothing can serve them, and a `tools-error:…` warning says so.
419
423
  - pi's built-in extensions (`builtin:mcp`, `builtin:codemode`, `builtin:tool-search`) load in subagents as they do in the main session, so with `extensions: true` **every subagent starts its own set of `mcp.json` servers**, which stay up until the subagent's session is disposed (on quit, or ~10 minutes after it finishes). Address them by the full `builtin:` name — bare `[mcp]` matches a third-party extension named `mcp`, not the built-in — and narrow their tools with `ext:builtin:mcp/<tool>`. MCP tools are reached through codemode (or `tool_search` for `deferred` servers), so an `ext:` allowlist must name that bridge too, as pi's `--tools read,codemode,'mcp__*'` does: `tools: "read, ext:builtin:codemode, ext:builtin:mcp/mcp__radius__search"`. Opt out per agent with `exclude_extensions: builtin:mcp`, or everywhere with `-builtin:mcp` in pi's `extensions` setting; starting pi with `--no-mcp` keeps MCP out of subagents too, and `--no-extensions` keeps all three built-ins out. MCP tools stay undeclared until codemode or `tool_search` reaches them, as in the main session, and a codemode script can only call tools inside the agent's scope. Out-of-scope tools are blocked but can still appear in codemode's `searchTools()` and `tool_search` results.
420
424
  - Subagents inherit the parent session's **project trust**: in a project you did not trust, a subagent loads none of its `.pi` extensions or settings and never starts the servers in its `.pi/mcp.json`. A subagent spawned into another directory (RPC `cwd`) treats that directory as untrusted.
421
425
  - Extensions that register tools **lazily** work too. MCP-backed extensions typically can't enumerate their tools until their servers connect, so they register from `session_start` or `before_agent_start` rather than at load. Subagent scoping is re-derived as tools appear, so these surface normally — including under `ext:` selectors, which keep narrowing correctly no matter when a tool shows up.
422
426
  - Extensions bound into a subagent see **both ends** of that session's lifecycle: `session_start` when the agent starts, `session_shutdown` (reason `quit`) when its session is disposed — on quit, and when its record is evicted ~10 minutes after it finishes. Release per-session resources there; anything left armed outlives the session it belongs to. Handlers are given three seconds on quit, after which teardown proceeds regardless.
423
427
  - An installed **package** extension matches by its package short name (`@scope/pi-subagents` → `[pi-subagents]`), in addition to its path-derived name (a package whose entry is `src/index.ts` also answers to `[src]`). Prefer the package name — the path-derived one is incidental.
424
428
  - Plain `tools:` typos fail loudly: `tools: reed, grep` fires `tools-error:…` instead of silently producing an under-tooled agent.
429
+ - An agent whose `tools:` resolve to nothing is refused, as in Claude Code: an entry is unknown (or an `ext:` names an extension that did not load), no built-in survives `disallowed_tools`, and no extension could add a tool. That is mostly `extensions: false` or `isolated: true` with only unknown names (`tools: WebFetch`). With extensions loading the agent still starts, since their tools register after spawn.
425
430
  - `exclude_extensions:` wins over `extensions:` and over `ext:` selectors — an excluded extension never loads and a `tools: ext:` entry can't pull it back. Plain names only (no paths, no `*`); a name matching nothing fires an `extension-error:…` warning.
426
431
  - `exclude_extensions:` is **not a sandbox**: excluded extensions' factory code still executes once during loading. Exclusion suppresses their tools and their bound lifecycle hooks (`pi.on` handlers like `session_start` only fire for extensions bound to the session), but not other load-time side effects — a factory that subscribes directly to the shared `pi.events` bus stays live. Don't rely on it to contain an untrusted extension.
427
432
  - Array and string forms are equivalent: `[a, b]` == `"a, b"`.
428
433
 
429
434
  **How an agent's scope is advertised.** The Agent tool description lists every available agent with a `(Tools: …)` suffix, and that suffix is what the orchestrator reads when deciding where to route work. It describes **built-in scope only** — extension tools are resolved when the agent runs (extensions may register lazily, see above), so they can't be enumerated when the description is built:
430
435
 
431
- | `tools:` | suffix |
432
- | ------------------------------------------------------- | ------------------------------------ |
433
- | omitted, `*`, or `all` | `*` |
434
- | a list of built-ins | that list, e.g. `read, grep` |
435
- | `none` with `isolated: true` or `extensions: false` | `none` |
436
- | `none`, or only `ext:` entries, with extensions loading | `no built-ins, extension tools only` |
436
+ | `tools:` | suffix |
437
+ | ----------------------------------------------------------------- | ------------------------------------ |
438
+ | omitted, `*`, or `all` | `*` |
439
+ | a list of built-ins | that list, e.g. `read, grep` |
440
+ | `none` with `isolated: true` or `extensions: false` | `none` |
441
+ | `none`, or only `ext:` / `mcp__` entries, with extensions loading | `no built-ins, extension tools only` |
437
442
 
438
443
  The last two rows are separate because zero built-ins is not zero tools: `tools: none` alongside `extensions:` still surfaces every extension tool, so calling it `none` would understate what the agent can do. Note `*` doesn't enumerate extension tools either — an agent with `tools: "*, ext:mcp/search"` advertises `*`.
439
444
 
@@ -477,20 +482,20 @@ Four rules define the feature:
477
482
 
478
483
  Launch a sub-agent.
479
484
 
480
- | Parameter | Type | Required | Description |
481
- | ------------------- | ----------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
482
- | `prompt` | string | yes | The task for the agent |
483
- | `description` | string | yes | Short 3-5 word summary (shown in UI) |
484
- | `name` | string | no | Memorable name for this agent (`auth-audit`), addressable as `@name` and accepted by `steer_subagent`/`get_subagent_result`. Additive — the type-derived handle is still assigned |
485
- | `subagent_type` | string | yes | Agent type (built-in or custom) |
486
- | `model` | string | no | Model — `provider/modelId` or fuzzy name (`"haiku"`, `"sonnet"`). Resolved tolerantly (`.`/`-` and a trailing date stamp interchangeable) with provider fallback |
487
- | `thinking` | string | no | Thinking level: off, minimal, low, medium, high, xhigh, max (availability depends on pi version and model) |
488
- | `max_turns` | number | no | Max agentic turns. Omit for unlimited (default) |
489
- | `run_in_background` | boolean | no | Defaults to `true`; `false` blocks and returns the result inline, until [`ctrl+b`](#sending-a-foreground-agent-to-the-background) hands it to the background |
490
- | `resume` | string | no | Agent ID to resume a previous session. The resumed run gets a fresh `max_turns` budget |
491
- | `isolated` | boolean | no | No extension/MCP tools |
492
- | `isolation` | `"off"` \| `"worktree"` | no | `worktree` runs in an isolated git worktree; `off` (the default) does not. Absent from the schema entirely when `worktreeIsolation: false` |
493
- | `inherit_context` | boolean | no | Fork parent conversation into agent |
485
+ | Parameter | Type | Required | Description |
486
+ | ------------------- | ----------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
487
+ | `prompt` | string | yes | The task for the agent |
488
+ | `description` | string | yes | Short 3-5 word summary (shown in UI) |
489
+ | `name` | string | no | Memorable name for this agent (`auth-audit`), addressable as `@name` and accepted by `steer_subagent`/`get_subagent_result`. Additive — the type-derived handle is still assigned |
490
+ | `subagent_type` | string | yes | Agent type (built-in or custom) |
491
+ | `model` | string | no | Model — `provider/modelId` or fuzzy name (`"haiku"`, `"sonnet"`). Resolved tolerantly (`.`/`-` and a trailing date stamp interchangeable) with provider fallback |
492
+ | `thinking` | string | no | Thinking level: off, minimal, low, medium, high, xhigh, max (availability depends on pi version and model) |
493
+ | `max_turns` | number | no | Max agentic turns. Omit for unlimited (default) |
494
+ | `run_in_background` | boolean | no | Defaults to `true`; `false` blocks and returns the result inline, until [`ctrl+b`](#sending-a-foreground-agent-to-the-background) hands it to the background |
495
+ | `resume` | string | no | Agent ID to resume a previous session. The resumed run gets a fresh `max_turns` budget. Works after the agent's record is evicted (about ten minutes after it finishes) or lost to a reload: the agent is reopened from its saved session under the same id, running under its type's current definition and never in a new worktree. Refused, with the reason, when the session was never saved, its file is gone, or it ran in a worktree that held changes (the worktree was removed when the agent finished, and its changes are on the branch named in the result) |
496
+ | `isolated` | boolean | no | No extension/MCP tools |
497
+ | `isolation` | `"off"` \| `"worktree"` | no | `worktree` runs in an isolated git worktree; `off` (the default) does not. Absent from the schema entirely when `worktreeIsolation: false` |
498
+ | `inherit_context` | boolean | no | Fork parent conversation into agent |
494
499
 
495
500
  ### `SubagentWorkflow`
496
501
 
@@ -552,6 +557,8 @@ Check status and retrieve results from a background agent.
552
557
 
553
558
  Cancelling a `wait: true` call (for example, with `Esc`) stops only the wait. The background agent keeps running, and its completion notification still arrives normally.
554
559
 
560
+ A finished agent's result stays retrievable after its in-memory record is cleaned up (about ten minutes after it finishes) or lost to a reload: the final record is saved in the session as a `subagents:record` entry, and `get_subagent_result` answers from it, without the stats or the conversation (`verbose`).
561
+
555
562
  ### `steer_subagent`
556
563
 
557
564
  Send a steering message to a running agent. The message interrupts after the current tool execution.
@@ -718,7 +725,7 @@ Runtime tuning values set via `/agents` → Settings (max concurrency, max foreg
718
725
 
719
726
  **Background by default** (`backgroundByDefault`, default `true`): what an `Agent` call that doesn't say means. On — following Claude Code — the agent runs detached, the call returns its ID immediately, and a completion notification carries a preview of the result (`get_subagent_result` for the full text). Set `false` to restore the previous behaviour, where an unqualified spawn blocked the turn and returned its output inline. An explicit `run_in_background` on the call, or in an agent file's frontmatter, overrides this in both directions; the setting only decides what "unspecified" means. **Top-level only** — a nested spawn (an agent spawning its own) always defaults to foreground, because a detached child is stopped when its parent settles and has no notification path of its own. Toggle via `/agents → Settings → Background by default`; applied live.
720
727
 
721
- **Remember agents** (`rememberAgents`, default `true`): whether subagents persist their pi session, which is what lets [`@handle`](#agent-mentions) reopen an agent's conversation after its in-memory record has been evicted. Two visible consequences of the default: top-level subagents write a session file, and they nest under the session that spawned them in pi's `/resume`. Agents spawned by another agent are excluded — they get no handle, so nothing could reopen their transcript. A custom agent's `persist_session` frontmatter overrides this per agent, in both directions. Toggle via `/agents → Settings → Remember agents`; with it off, handles expire with their record (roughly ten minutes past completion) and `@explore` then starts a fresh agent rather than resuming — the behaviour before this setting existed.
728
+ **Remember agents** (`rememberAgents`, default `true`): whether subagents persist their pi session, which is what lets [`@handle`](#agent-mentions), `Agent({ resume })` and a workflow's `resume` reopen an agent's conversation after its in-memory record has been evicted. Two visible consequences of the default: top-level subagents write a session file, and they nest under the session that spawned them in pi's `/resume`. Agents spawned by another agent are excluded — they get no handle, so nothing could reopen their transcript. A custom agent's `persist_session` frontmatter overrides this per agent, in both directions. Toggle via `/agents → Settings → Remember agents`; with it off, handles expire with their record (roughly ten minutes past completion) and `@explore` then starts a fresh agent rather than resuming — the behaviour before this setting existed — and a later `resume` is refused because nothing was saved. When pi's `/fork` or `/clone` copies a session, resuming one of its agents from the copy forks that agent's session too, so the two parents never write into one file. That agent's `.output` transcript in the copy starts at the resume.
722
729
 
723
730
  **Output transcript** (`outputTranscript`, default `true`): the project/global default for writing each subagent's `.output` transcript. Toggle via `/agents → Settings → Output transcript`, or set `false` in `subagents.json` to make transcripts opt-in project-wide — useful when run transcripts shouldn't sit on disk for backup or DLP tooling to pick up. A custom agent's `output_transcript` frontmatter overrides this per agent. Applied live at spawn time. Governs only the transcript, not `persist_session`, worktree commits, or memory files.
724
731
 
@@ -978,6 +985,8 @@ The agent gets a full, isolated copy of the repository. The worktree is normally
978
985
  - **Agent committed its own work:** the branch is created at the agent's HEAD, preserving its commits (uncommitted leftovers are committed on top first)
979
986
  - **Preservation failed:** the run reports an error and keeps the worktree. Its path is included in the result so the changes can be recovered manually
980
987
 
988
+ A resumed agent never gets a worktree, as in Claude Code: a fresh copy of HEAD would not hold its earlier edits. This covers `Agent({ resume })` and `@handle` once the record is evicted, and a workflow's `resume`. If its worktree held changes, the resume is refused with "its worktree no longer exists"; the work is on its branch. If the worktree held none, the agent continues in the main checkout without isolation.
989
+
981
990
  The agent's system prompt names the worktree as an isolated copy and tells it to work only there, even if other instructions name the main checkout — otherwise an inherited parent prompt or a task prompt mentioning the project path walks it straight back out of the copy. This is a directive, not a sandbox: an agent with shell access can still `cd` out, so don't rely on `isolation` alone to protect the main checkout.
982
991
 
983
992
  The automatic preservation commit uses `--no-verify` and `--no-gpg-sign`, so local pre-commit hooks and interactive signing configuration can't block it. The commit is local-only and never pushed; pre-push and server-side hooks still apply. Other Git failures keep the worktree intact and report its recovery path instead of deleting the only copy.
@@ -1070,6 +1079,7 @@ src/
1070
1079
  completion-outbox.ts # Deliver completion notifications at the parent's next boundary, coalesced
1071
1080
  group-join.ts # `group` join mode: one notification per turn's batch, with timeout
1072
1081
  status-note.ts # Honest status note + salvaged partial output for non-normal outcomes
1082
+ agent-record-entry.ts # The `subagents:record` session entry a finished agent leaves; get_subagent_result's fallback, and what resume reopens an evicted agent from
1073
1083
  usage.ts # Token usage shapes, accumulators, session-stats readers
1074
1084
 
1075
1085
  # Invocation surface
@@ -130,7 +130,7 @@ Fire-and-forget is the intended use: the reply carries nothing to act on, and th
130
130
 
131
131
  Consumption is not terminal. An `@handle` steer un-consumes the record (the mention handler, `src/index.ts`) because the agent's reply to that message still needs relaying. A background resume (`AgentManager.resume`) does too, because the record is starting a new run, and so does handing a foreground agent to the background (`AgentManager.sendToBackground`), because its result now has to reach the parent as a notification.
132
132
 
133
- One related thing that lives nowhere else: on every top-level settle, pi-subagents writes a session entry — not an event — via `pi.appendEntry("subagents:record", …)` (the manager's completion callback, `src/index.ts`), carrying `id`, `type`, `description`, `status`, `result`, `error`, `startedAt` and `completedAt`. It exists for cross-extension history reconstruction. It is append-only history, not something to react to.
133
+ One related thing that lives nowhere else: on every top-level settle, pi-subagents writes a session entry — not an event — via `pi.appendEntry("subagents:record", …)` (the manager's completion callback, `src/index.ts`, and the Agent tool's foreground `resume` branch, which settles inline without that callback; the shape is `AgentRecordEntryData` in `src/agent-record-entry.ts`), carrying `id`, `type`, `description`, `status`, `result`, `error`, `startedAt` and `completedAt`, plus `sessionFile`, `handle` and `alias` when the agent has them, and `worktreeLost: true` when its work lived in a worktree that has since been removed. `get_subagent_result` answers from it once the live record is gone, `Agent({ resume })` reopens the agent's session from it, and it serves cross-extension history reconstruction. It is append-only history, not something to react to.
134
134
 
135
135
  ## Steering a running agent
136
136
 
@@ -279,6 +279,8 @@ Any other key is rejected **by name** at the call. Note that this checks option
279
279
 
280
280
  Combination rules: `resume` cannot be combined with `agentType`, `model`, `effort`, `isolation`, `gate` or `schema` — a resumed child keeps the agent type, model and tree it was started with, and its session predates the `StructuredOutput` tool.
281
281
 
282
+ A child stays resumable for the whole run. The manager evicts a finished child's record about ten minutes after it settles, and a review or a merge queue easily takes longer; `resume` then reopens the child's saved session under the same id, still owned by the run. That reopen runs under the agent type's current definition, so the model and tree the script chose for the first run are not carried over. It fails, resolving to `null` with the reason on that agent's row in the card and the inspector, when the child's session was never saved (`rememberAgents` off, or `persist_session: false`), its file is gone, or it ran with `isolation: "worktree"` and left changes: that worktree was removed when the child finished, with its changes on a branch, and continuing the work anywhere else would split it. A child whose worktree held no changes reopens in the run's directory, as in Claude Code.
283
+
282
284
  ### `pipeline()` and `parallel()`
283
285
 
284
286
  ```js
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-subagents",
3
- "version": "0.22.1-local.1",
3
+ "version": "0.23.0-local.1",
4
4
  "description": "Claude Code-style autonomous subagents and workflow orchestration for Pi, with HerbertGao-maintained UI extensions.",
5
5
  "keywords": [
6
6
  "agent",
@@ -69,10 +69,10 @@
69
69
  },
70
70
  "x-upstream": {
71
71
  "package": "@tintinweb/pi-subagents",
72
- "version": "0.22.1",
73
- "reviewedVersion": "0.22.1",
72
+ "version": "0.23.0",
73
+ "reviewedVersion": "0.23.0",
74
74
  "repository": "https://github.com/tintinweb/pi-subagents",
75
- "commit": "fc089c4b7ab0f1185453b2e53027997c1f637e38",
75
+ "commit": "a60247c47f8b0a17bfe7208f9e248e464eda05f0",
76
76
  "trackVersion": true
77
77
  }
78
78
  }
@@ -263,13 +263,13 @@ ${input.systemPrompt}
263
263
  }
264
264
 
265
265
  /**
266
- * Rebuild the `tools:` CSV from the two halves the loader split it into.
266
+ * Rebuild the `tools:` CSV from the parts the loader split it into.
267
267
  *
268
- * `extSelectors` has to come back with the built-ins: `parseToolsField` splits
269
- * `tools: read, ext:mcp/github` into `["read"]` and `["ext:mcp/github"]`, so
270
- * writing only the first half hands the ejected copy a *narrower* toolset than
271
- * the file it came from. That was invisible while Eject only ever ran on
272
- * built-in defaults, which carry no selectors; a package agent can.
268
+ * `extSelectors` and `mcpToolPatterns` have to come back with the built-ins:
269
+ * `parseToolsField` splits `tools: read, ext:mcp/github` into `["read"]` and
270
+ * `["ext:mcp/github"]`, so writing only the first half hands the ejected copy a
271
+ * *narrower* toolset than the file it came from. That was invisible while Eject
272
+ * only ever ran on built-in defaults, which carry no selectors; a package agent can.
273
273
  *
274
274
  * Zero built-ins with selectors present is not `none` — `none` means no tools at
275
275
  * all, while `ext:` entries alone mean "extension tools only", which the loader
@@ -278,8 +278,9 @@ ${input.systemPrompt}
278
278
  function formatToolsField(
279
279
  tools: string[] | undefined,
280
280
  extSelectors?: string[],
281
+ mcpToolPatterns?: string[],
281
282
  ): string {
282
- const selectors = extSelectors ?? []
283
+ const selectors = [...(extSelectors ?? []), ...(mcpToolPatterns ?? [])]
283
284
  if (tools === undefined)
284
285
  return selectors.length > 0 ? ["*", ...selectors].join(", ") : "all"
285
286
  if (tools.length === 0)
@@ -297,7 +298,7 @@ export function serializeAgentFile(cfg: AgentConfig): string {
297
298
  // `all` for both would hand a deliberately tool-less agent the whole toolbox
298
299
  // the first time it is ejected.
299
300
  fmFields.push(
300
- `tools: ${formatToolsField(cfg.builtinToolNames, cfg.extSelectors)}`,
301
+ `tools: ${formatToolsField(cfg.builtinToolNames, cfg.extSelectors, cfg.mcpToolPatterns)}`,
301
302
  )
302
303
  if (cfg.model) fmFields.push(`model: ${cfg.model}`)
303
304
  if (cfg.thinking) fmFields.push(`thinking: ${cfg.thinking}`)
@@ -23,6 +23,7 @@ import type {
23
23
  ExtensionAPI,
24
24
  ExtensionContext,
25
25
  } from "@earendil-works/pi-coding-agent"
26
+ import { worktreeLost } from "./agent-record-entry.js"
26
27
  import { resumeAgent, runAgent, type ToolActivity } from "./agent-runner.js"
27
28
  import { getAgentConfig } from "./agent-types.js"
28
29
  import { assignHandle, handleBase } from "./mention.js"
@@ -232,8 +233,13 @@ interface SpawnOptions {
232
233
  * Internal capability, like `resumeSessionFile`: a forged handle would
233
234
  * duplicate a live agent's name and make `resolveMention` ambiguous, so
234
235
  * `spawnTopLevel` strips it from anything a caller sends.
236
+ *
237
+ * `id` keeps the evicted agent's id too, so the id the model already holds
238
+ * names the reopened conversation (`Agent({ resume })`, a workflow's
239
+ * `resume`). A name is taken back only while nothing else holds it — see
240
+ * `reclaimable`.
235
241
  */
236
- reclaim?: { handle: string; alias?: string }
242
+ reclaim?: { id?: string; handle?: string; alias?: string }
237
243
  model?: Model<any>
238
244
  maxTurns?: number
239
245
  isolated?: boolean
@@ -575,7 +581,18 @@ export class AgentManager {
575
581
  // can fix and retry; the RPC layer converts throws into error envelopes.
576
582
  assertValidSpawnCwd(options.cwd)
577
583
 
578
- const id = randomUUID().slice(0, 17)
584
+ // A reclaimed id must not be live: the record would replace the one in the
585
+ // map, orphaning its run beyond the reach of stop and `abortAll()`.
586
+ // Callers reopen only what they found evicted; this keeps that true.
587
+ if (
588
+ options.reclaim?.id !== undefined &&
589
+ this.agents.has(options.reclaim.id)
590
+ ) {
591
+ throw new Error(
592
+ `Agent ${options.reclaim.id} is still in memory, so it cannot be reopened from its saved session.`,
593
+ )
594
+ }
595
+ const id = options.reclaim?.id ?? randomUUID().slice(0, 17)
579
596
  const abortController = new AbortController()
580
597
  const record: AgentRecord = {
581
598
  id,
@@ -585,15 +602,18 @@ export class AgentManager {
585
602
  // not consume a name a top-level sibling could otherwise take.
586
603
  handle: !isTopLevelAgent(options)
587
604
  ? undefined
588
- : // A reclaimed handle is used as-is: it belongs to the conversation this
589
- // spawn is reopening, and re-deriving it would lose the numbering.
590
- (options.reclaim?.handle ??
605
+ : // A reclaimed handle is taken back as-is while it is free: it belongs to
606
+ // the conversation this spawn is reopening, and re-deriving it would
607
+ // lose the numbering.
608
+ (this.reclaimable(options.reclaim?.handle, options.reclaim?.id) ??
591
609
  assignHandle(handleBase(type), this.takenHandles())),
592
610
  description: options.description,
593
611
  // Reclaimed here, or filled in below from `name` — in which case it must
594
612
  // see the handle this record just took, since both come out of the same
595
613
  // namespace.
596
- alias: isTopLevelAgent(options) ? options.reclaim?.alias : undefined,
614
+ alias: isTopLevelAgent(options)
615
+ ? this.reclaimable(options.reclaim?.alias, options.reclaim?.id)
616
+ : undefined,
597
617
  // Overwritten below when the spawn is actually queued; a foreground spawn
598
618
  // that queues flips to "queued" there rather than being guessed at here,
599
619
  // since the pool decision needs the finished record.
@@ -619,6 +639,12 @@ export class AgentManager {
619
639
  workflowId: options.workflowId,
620
640
  maxSubagentDepth: options.maxSubagentDepth,
621
641
  rootSessionId: options.rootSessionId,
642
+ // A reopen continues this file until its session says otherwise (a fork
643
+ // gets its own, set at session creation). Seeded so a run that fails
644
+ // before it has a session still names the conversation in its saved
645
+ // record and tombstone: without it, the next resume would be refused as
646
+ // never saved.
647
+ sessionFile: options.resumeSessionFile,
622
648
  }
623
649
  this.agents.set(id, record)
624
650
  // After the insert, so `takenHandles()` already counts this record's own
@@ -830,10 +856,15 @@ export class AgentManager {
830
856
  // mentions pass none, and RPC forwards only its caller's value. Workflow
831
857
  // children are the exception, as in Claude Code, whose workflow agent()
832
858
  // reads only the script's option and ignores the definition's.
859
+ // A reopen never gets a worktree, as in Claude Code: a fresh copy of HEAD
860
+ // would not hold the earlier run's edits, and a reopen whose old worktree
861
+ // held any is refused before it gets here (`reopenTarget`).
833
862
  const isolation =
834
- options.workflowId !== undefined
835
- ? options.isolation
836
- : (getAgentConfig(type)?.isolation ?? options.isolation)
863
+ options.resumeSessionFile !== undefined
864
+ ? undefined
865
+ : options.workflowId !== undefined
866
+ ? options.isolation
867
+ : (getAgentConfig(type)?.isolation ?? options.isolation)
837
868
  let worktreeCwd: string | undefined
838
869
  if (isolation === "worktree" && isWorktreeIsolationEnabled()) {
839
870
  const wt = await createWorktree(pi, baseCwd, id)
@@ -1626,6 +1657,35 @@ export class AgentManager {
1626
1657
  return taken
1627
1658
  }
1628
1659
 
1660
+ /**
1661
+ * `name`, if a reopened agent can take it back. Within one activation that is
1662
+ * always so — tombstoned names are never allocated (`takenHandles`) — but a
1663
+ * resume after a reload reopens from the session's saved record, with no
1664
+ * tombstone holding the name, so a fresh agent may have taken it since. A
1665
+ * name held by a live record, or by another agent's tombstone, stays with
1666
+ * its holder and the reopened agent gets a fresh one.
1667
+ *
1668
+ * `id` is the agent being reopened, when it keeps its own: its tombstone is
1669
+ * the one holding the name, legitimately. The `@handle` path keeps no id and
1670
+ * reopens exactly the tombstone that holds the name, so it skips that check.
1671
+ */
1672
+ private reclaimable(
1673
+ name: string | undefined,
1674
+ id: string | undefined,
1675
+ ): string | undefined {
1676
+ if (name === undefined) return undefined
1677
+ for (const record of this.agents.values()) {
1678
+ if (record.handle === name || record.alias === name) return undefined
1679
+ }
1680
+ if (id !== undefined) {
1681
+ for (const entry of this.tombstones.values()) {
1682
+ if (entry.id !== id && (entry.handle === name || entry.alias === name))
1683
+ return undefined
1684
+ }
1685
+ }
1686
+ return name
1687
+ }
1688
+
1629
1689
  /**
1630
1690
  * Resolve an `@name` from the prompt. Matches a top-level agent's handle
1631
1691
  * case-insensitively, preferring one that can still be steered and otherwise
@@ -1744,6 +1804,7 @@ export class AgentManager {
1744
1804
  description: record.description,
1745
1805
  sessionFile: record.sessionFile,
1746
1806
  completedAt: record.completedAt ?? Date.now(),
1807
+ worktreeLost: worktreeLost(record) || undefined,
1747
1808
  })
1748
1809
  // Bound the memory a long session can accumulate. Oldest first, since the
1749
1810
  // agent someone still wants to reach is the one they used most recently.