pi-subagents 0.84.0 → 0.86.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 +83 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-JG4QKI5M.js → chunk-2IYBCYFU.js} +214 -97
- package/bundle/{chunk-V2BZYLEP.js → chunk-374MZFF4.js} +7 -2
- package/bundle/{chunk-4E7BKDTX.js → chunk-3RKFH2UZ.js} +11 -156
- package/bundle/{chunk-F4ASL6OV.js → chunk-5H4BICQZ.js} +1 -1
- package/bundle/{chunk-PALJGGYC.js → chunk-6VD7BGIC.js} +6 -3
- package/bundle/{chunk-C5P5CHYK.js → chunk-77ASNIEM.js} +1 -1
- package/bundle/{chunk-XDQORLZ5.js → chunk-7ADDXUGF.js} +15 -6
- package/bundle/{chunk-PV63UFUR.js → chunk-7QA7ZA46.js} +183 -28
- package/bundle/{chunk-NKQ6JNAS.js → chunk-7ZUFN6ME.js} +2 -1
- package/bundle/{chunk-SSG7IEP5.js → chunk-A637IMAO.js} +2 -2
- package/bundle/{chunk-L3WFKBEI.js → chunk-BGXEAYUM.js} +247 -153
- package/bundle/{chunk-J5YL7LYR.js → chunk-BU6PFPVX.js} +59 -27
- package/bundle/{chunk-DZDETGRJ.js → chunk-BWC2LVII.js} +259 -216
- package/bundle/{chunk-CGN2TVE7.js → chunk-GJGTMLPE.js} +322 -18
- package/bundle/{chunk-D3JAFGMO.js → chunk-GRJHIXYF.js} +1 -1
- package/bundle/chunk-HXRB42AF.js +108 -0
- package/bundle/{chunk-LFDBD4PW.js → chunk-LGINOOY5.js} +2 -2
- package/bundle/{chunk-G2Z6ZH26.js → chunk-NAFLUJ26.js} +1 -1
- package/bundle/{chunk-235AWJUQ.js → chunk-O3YH7XIY.js} +324 -111
- package/bundle/{chunk-2DHZTCOL.js → chunk-PYOAIN3V.js} +2 -2
- package/bundle/{chunk-LNRJCP2Y.js → chunk-QGO6HXHG.js} +417 -242
- package/bundle/{chunk-VQVVHSY6.js → chunk-QM3JGE4W.js} +22 -11
- package/bundle/{chunk-2S4K53MV.js → chunk-S2Q75LP3.js} +1 -1
- package/bundle/{chunk-NENDSQUY.js → chunk-UR7OW5S7.js} +9 -6
- package/bundle/{chunk-AKOIVLA5.js → chunk-WN2E5XHN.js} +135 -77
- package/bundle/{chunk-2D52JFLF.js → chunk-YK3QYNLE.js} +41 -117
- package/bundle/{chunk-7BWGNDNK.js → chunk-ZJJCPV3L.js} +190 -1177
- package/bundle/chunk-ZPY5QZCS.js +1067 -0
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +8 -8
- package/bundle/project-panes.js +3 -3
- package/docs/agents.md +23 -2
- package/docs/configuration.md +4 -4
- package/docs/extension-api.md +16 -1
- package/docs/tool-reference.md +2 -0
- package/docs/workflows.md +30 -2
- package/package.json +1 -1
- package/src/agents/agent-management.js +27 -11
- package/src/agents/agent-memory.d.ts +1 -4
- package/src/agents/agent-memory.js +1 -4
- package/src/agents/agents.d.ts +1 -3
- package/src/agents/agents.js +7 -6
- package/src/agents/frontmatter.js +1 -8
- package/src/agents/global-npm-root.d.ts +1 -0
- package/src/agents/global-npm-root.js +11 -3
- package/src/agents/skills.d.ts +0 -3
- package/src/agents/skills.js +0 -3
- package/src/extension/config.js +7 -1
- package/src/extension/herdr-pi-bridge.js +10 -2
- package/src/extension/index.d.ts +0 -13
- package/src/extension/index.js +43 -32
- package/src/extension/public-execution.d.ts +1 -0
- package/src/extension/public-execution.js +4 -0
- package/src/extension/reply-workflow-script.js +24 -4
- package/src/extension/schemas.d.ts +8 -3
- package/src/extension/schemas.js +5 -3
- package/src/extension/session-switch.d.ts +25 -0
- package/src/extension/session-switch.js +138 -0
- package/src/extension/subagent-guide.d.ts +1 -1
- package/src/extension/subagent-guide.js +1 -1
- package/src/extension/subagent-launch-tool.d.ts +25 -0
- package/src/extension/subagent-launch-tool.js +48 -0
- package/src/extension/tool-activation.js +35 -12
- package/src/extension/tool-description.d.ts +1 -1
- package/src/extension/tool-description.js +14 -8
- package/src/inspectors/herdr/actions.d.ts +0 -1
- package/src/inspectors/herdr/actions.js +0 -1
- package/src/inspectors/session-roots-codec.d.ts +0 -1
- package/src/inspectors/session-roots-codec.js +0 -1
- package/src/inspectors/tmux/actions.d.ts +0 -1
- package/src/inspectors/tmux/actions.js +0 -1
- package/src/integrations/herdr-status.js +3 -8
- package/src/intercom/native-supervisor-channel.js +65 -9
- package/src/runs/background/async-execution.d.ts +5 -9
- package/src/runs/background/async-execution.js +62 -27
- package/src/runs/background/async-job-tracker.js +12 -0
- package/src/runs/background/async-resume.d.ts +2 -1
- package/src/runs/background/async-resume.js +112 -39
- package/src/runs/background/async-retention.js +6 -1
- package/src/runs/background/auto-drain.js +2 -1
- package/src/runs/background/boot-id.d.ts +1 -3
- package/src/runs/background/boot-id.js +1 -3
- package/src/runs/background/completion-batcher.d.ts +3 -4
- package/src/runs/background/completion-batcher.js +2 -3
- package/src/runs/background/control-channel.d.ts +0 -6
- package/src/runs/background/control-channel.js +0 -6
- package/src/runs/background/fleet-view.js +2 -3
- package/src/runs/background/notify.d.ts +0 -2
- package/src/runs/background/notify.js +0 -2
- package/src/runs/background/result-watcher.d.ts +1 -0
- package/src/runs/background/result-watcher.js +59 -29
- package/src/runs/background/resume-guidance.js +4 -2
- package/src/runs/background/retained-children.js +2 -1
- package/src/runs/background/run-child-session.d.ts +0 -1
- package/src/runs/background/run-child-session.js +1 -1
- package/src/runs/background/run-status.js +9 -7
- package/src/runs/background/scheduled-runs.d.ts +3 -1
- package/src/runs/background/scheduled-runs.js +13 -16
- package/src/runs/background/subagent-runner.d.ts +2 -4
- package/src/runs/background/subagent-runner.js +15 -12
- package/src/runs/background/subagent-wait.js +12 -15
- package/src/runs/background/wait-config.d.ts +2 -0
- package/src/runs/background/wait-config.js +17 -3
- package/src/runs/background/wait-tool.js +4 -2
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +0 -1
- package/src/runs/foreground/execution.d.ts +0 -3
- package/src/runs/foreground/execution.js +17 -9
- package/src/runs/foreground/subagent-executor.d.ts +3 -2
- package/src/runs/foreground/subagent-executor.js +107 -26
- package/src/runs/shared/acceptance.js +69 -26
- package/src/runs/shared/child-commands.js +15 -2
- package/src/runs/shared/child-hooks.d.ts +1 -7
- package/src/runs/shared/child-hooks.js +13 -5
- package/src/runs/shared/child-launch.js +6 -2
- package/src/runs/shared/child-runtime-config.d.ts +0 -1
- package/src/runs/shared/child-session.d.ts +1 -1
- package/src/runs/shared/child-session.js +21 -2
- package/src/runs/shared/child-tool-plan.d.ts +0 -1
- package/src/runs/shared/child-tool-plan.js +0 -1
- package/src/runs/shared/claude-code-adapter.js +11 -0
- package/src/runs/shared/external-cli-contract.d.ts +49 -0
- package/src/runs/shared/external-cli-contract.js +18 -13
- package/src/runs/shared/external-cli-runner.js +26 -6
- package/src/runs/shared/herdr-connection.js +2 -1
- package/src/runs/shared/herdr-pane-host.d.ts +2 -2
- package/src/runs/shared/herdr-pane-host.js +17 -1
- package/src/runs/shared/herdr-placed-run.js +48 -22
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
- package/src/runs/shared/model-resolution.d.ts +2 -2
- package/src/runs/shared/model-resolution.js +7 -1
- package/src/runs/shared/model-scope.d.ts +1 -5
- package/src/runs/shared/model-scope.js +1 -5
- package/src/runs/shared/mutation-evidence.d.ts +1 -1
- package/src/runs/shared/mutation-evidence.js +52 -7
- package/src/runs/shared/nested-events.d.ts +1 -0
- package/src/runs/shared/nested-events.js +1 -1
- package/src/runs/shared/parallel-utils.d.ts +0 -1
- package/src/runs/shared/permissions.js +5 -3
- package/src/runs/shared/placement-host.d.ts +5 -1
- package/src/runs/shared/rex-pane-host.d.ts +0 -1
- package/src/runs/shared/rex-pane-host.js +0 -2
- package/src/runs/shared/run-launch-folder.d.ts +12 -0
- package/src/runs/shared/run-launch-folder.js +21 -0
- package/src/runs/shared/runner-launcher.d.ts +12 -1
- package/src/runs/shared/runner-launcher.js +16 -0
- package/src/runs/shared/single-output.d.ts +3 -3
- package/src/runs/shared/single-output.js +5 -3
- package/src/runs/shared/structured-output.d.ts +8 -0
- package/src/runs/shared/structured-output.js +40 -5
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +4 -2
- package/src/runs/shared/tool-timeout.js +2 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js +0 -1
- package/src/runs/shared/worktree.d.ts +3 -0
- package/src/runs/shared/worktree.js +20 -0
- package/src/shared/capacity-resilient-json.d.ts +1 -1
- package/src/shared/child-cache-retention.d.ts +1 -2
- package/src/shared/child-cache-retention.js +1 -2
- package/src/shared/fleet-transcript-reader.d.ts +51 -0
- package/src/shared/fleet-transcript-reader.js +333 -0
- package/src/shared/formatters.d.ts +0 -18
- package/src/shared/formatters.js +0 -18
- package/src/shared/session-succession.d.ts +16 -1
- package/src/shared/session-succession.js +41 -2
- package/src/shared/session-warnings.d.ts +7 -0
- package/src/shared/session-warnings.js +26 -0
- package/src/shared/settings.d.ts +0 -23
- package/src/shared/settings.js +3 -35
- package/src/shared/types.d.ts +85 -59
- package/src/shared/types.js +0 -12
- package/src/shared/utils.d.ts +0 -14
- package/src/shared/utils.js +0 -22
- package/src/shared/wait-tool-name.d.ts +8 -0
- package/src/shared/wait-tool-name.js +13 -0
- package/src/slash/slash-commands.js +2 -1
- package/src/slash/subagent-cost.d.ts +3 -2
- package/src/slash/subagent-cost.js +22 -3
- package/src/slash/subagents-admin.js +0 -1
- package/src/tui/fleet-status.d.ts +0 -5
- package/src/tui/fleet-status.js +4 -24
- package/src/tui/fleet-transcript.d.ts +1 -44
- package/src/tui/fleet-transcript.js +1 -327
- package/src/tui/fleet.js +6 -4
- package/src/tui/render.d.ts +0 -9
- package/src/tui/render.js +161 -66
- package/src/tui/subagent-messages.js +3 -2
- package/src/watchdog/register-child.d.ts +2 -3
- package/src/watchdog/register-child.js +2 -3
- package/src/watchdog/turn-delta.js +2 -1
- package/src/workflows/scripted-workflow.js +241 -20
- package/src/workflows/workflow-launch-record.d.ts +15 -6
- package/src/workflows/workflow-launch-record.js +30 -12
- package/src/workflows/workflow-receipt.js +36 -53
- package/src/workflows/workflow-resume-claim.js +2 -2
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +11 -8
- package/src/workflows/workflow-script-worker.d.ts +13 -0
- package/src/workflows/workflow-script-worker.js +79 -0
- package/workflow-script-process.cjs +36 -0
- package/workflow-script-worker.cjs +4 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
requestAsyncStop
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5H4BICQZ.js";
|
|
4
4
|
import "./chunk-NIXWDZZV.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-QGO6HXHG.js";
|
|
6
6
|
import "./chunk-JEZOSEWG.js";
|
|
7
7
|
import "./chunk-YFCK7H2S.js";
|
|
8
8
|
import "./chunk-QXASAHIA.js";
|
package/bundle/index.js
CHANGED
|
@@ -17,7 +17,7 @@ function readInstalledPackageVersion() {
|
|
|
17
17
|
var loadedPackageVersion = readInstalledPackageVersion();
|
|
18
18
|
|
|
19
19
|
// index.ts
|
|
20
|
-
var registerExtension = process.env[HERDR_PI_MODE_ENV] === "1" ? (await import("./chunk-
|
|
20
|
+
var registerExtension = process.env[HERDR_PI_MODE_ENV] === "1" ? (await import("./chunk-QM3JGE4W.js")).default : process.env.PI_SUBAGENT_CHILD === "1" ? void 0 : (await import("./chunk-O3YH7XIY.js")).default;
|
|
21
21
|
function registerSubagentExtension(pi) {
|
|
22
22
|
const installedVersion = readInstalledPackageVersion();
|
|
23
23
|
if (installedVersion !== loadedPackageVersion) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveIntercomSessionTarget
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-77ASNIEM.js";
|
|
4
4
|
import "./chunk-7F6RKT6W.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-QGO6HXHG.js";
|
|
6
6
|
import "./chunk-JEZOSEWG.js";
|
|
7
7
|
import "./chunk-YFCK7H2S.js";
|
|
8
8
|
import "./chunk-QXASAHIA.js";
|
package/bundle/preflight.js
CHANGED
|
@@ -2,22 +2,22 @@ import {
|
|
|
2
2
|
buildEffectiveSystemPrompt,
|
|
3
3
|
canPreferForkFromSnapshot,
|
|
4
4
|
resolveSubagentLaunchContext
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-A637IMAO.js";
|
|
6
|
+
import "./chunk-LGINOOY5.js";
|
|
7
7
|
import {
|
|
8
8
|
loadConfig
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6VD7BGIC.js";
|
|
10
10
|
import {
|
|
11
11
|
nestedResultsPath,
|
|
12
12
|
processTerminalCandidatePath,
|
|
13
13
|
processTerminalPath,
|
|
14
14
|
resultFilePath
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GJGTMLPE.js";
|
|
16
16
|
import {
|
|
17
17
|
applyIntercomBridgeToAgent,
|
|
18
18
|
resolveIntercomBridge,
|
|
19
19
|
validateIntercomBridgeConfig
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-77ASNIEM.js";
|
|
21
21
|
import {
|
|
22
22
|
AGENT_DEFINITION_PROJECTION_VERSION,
|
|
23
23
|
resolveLaunchBinding,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
applyThinkingSuffix,
|
|
28
28
|
resolvePiLaunchToolPlan
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-374MZFF4.js";
|
|
30
30
|
import {
|
|
31
31
|
assertRequiredChildExtensionsAdmitted,
|
|
32
32
|
resolveRequiredChildExtensions
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
import {
|
|
35
35
|
getArtifactPaths,
|
|
36
36
|
getArtifactsDir
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-GRJHIXYF.js";
|
|
38
38
|
import {
|
|
39
39
|
assertClaudeCodeModelScope,
|
|
40
40
|
assertThinkingWithinCeiling,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
resolveSkillsWithFallback,
|
|
62
62
|
resolveStepBehavior,
|
|
63
63
|
unknownAgentDiagnosticContext
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-QGO6HXHG.js";
|
|
65
65
|
import {
|
|
66
66
|
DIRS,
|
|
67
67
|
SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
package/bundle/project-panes.js
CHANGED
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
openProjectPane,
|
|
9
9
|
projectPaneBindingPath,
|
|
10
10
|
readProjectPaneBinding
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-PYOAIN3V.js";
|
|
12
12
|
import "./chunk-7J4ZXMY7.js";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-GRJHIXYF.js";
|
|
14
|
+
import "./chunk-QGO6HXHG.js";
|
|
15
15
|
import "./chunk-JEZOSEWG.js";
|
|
16
16
|
import "./chunk-YFCK7H2S.js";
|
|
17
17
|
import "./chunk-QXASAHIA.js";
|
package/docs/agents.md
CHANGED
|
@@ -194,6 +194,12 @@ node --experimental-strip-types --import ./test/support/register-loader.mjs \
|
|
|
194
194
|
|
|
195
195
|
The read-only smoke must report `writeCanaryExists: false`. The writer smoke must report `writeCanaryMatches: true`. Both reports record `workspaceTrust: "operator-managed-saved"`, confirm that the external prompt root was added, and include startup duration and terminal proof without raw protocol output, prompts, or credentials. A trust-required error remains terminal; the harness does not retry with a trust, force, or yolo flag.
|
|
196
196
|
|
|
197
|
+
#### Safety record and wrapper commands
|
|
198
|
+
|
|
199
|
+
Each code-owned adapter run records a `safety` block in its runner status, in `subagent({ action: "status" })`, and in its workflow receipt entry. The block is the adapter's profile: the access its own argv asks the CLI for. Nothing in it is measured from the launched process, and status labels it `Safety (adapter profile, not measured)`.
|
|
200
|
+
|
|
201
|
+
The record carries `safetySource: { "measured": false, "command": "..." }` beside it. `command` is the launch command as configured; a run on a Herdr saved machine records none, because the remote pane runs the adapter's own binary. When `runner.command` is a wrapper script that changes argv before it starts the CLI, the wrapper can grant more or less than the profile shows, so read the wrapper to know the real grant. Receipts written before `safetySource` existed are read as profile values.
|
|
202
|
+
|
|
197
203
|
#### Native oracle compared with external advisors
|
|
198
204
|
|
|
199
205
|
Native `oracle` runs inside Pi and can use its configured read tools. The Claude profiles send the assembled prompt to the local Claude Code CLI through stdin. An external-job agent sends the assembled prompt to its registered provider. Provider options and a prompt digest are persisted in Pi run state. The prompt text is delivered through the local host bridge to the provider and is not stored in the public result payload. Do not place secrets in advisory prompts unless the target provider is approved to receive them.
|
|
@@ -244,7 +250,7 @@ Supported override fields: `description`, `advertise`, `machine`, `output`, `out
|
|
|
244
250
|
- `description` replaces the discovered description for builtin and custom agents, which lets list output show deployment-specific routing or model metadata.
|
|
245
251
|
- Use `output: false`, `defaultReads: false`, `defaultContext: false`, `acceptanceRole: false`, or `machine: false` to clear an inherited value.
|
|
246
252
|
- Use `tools: "inherit"` when that one role should omit its bundled or frontmatter tool allowlist and receive Pi's normal builtins (plus ambient extensions when it runs as a background child).
|
|
247
|
-
- Project overrides beat user overrides.
|
|
253
|
+
- Project overrides beat user overrides field by field: a project override replaces only the fields it sets, and fields set only in the user override still apply.
|
|
248
254
|
- Matching package, user, and project agents also receive override fields, which replace the same fields declared in their frontmatter. This lets a shared agent keep its persona while local settings choose the effective model, context, tools, or other supported options.
|
|
249
255
|
|
|
250
256
|
Disable and restore:
|
|
@@ -333,9 +339,10 @@ How it behaves:
|
|
|
333
339
|
- **Not combined with other placement.** `launcher` cannot be combined with `machine` (from frontmatter, a settings override, or the call) or with an `external-cli` or `external-job` runner.
|
|
334
340
|
- **Unknown names fail.** If the name is not in `runnerLaunchers`, the launch fails before anything starts, without using a fan-out slot or creating a session directory. It never falls back to running without the launcher.
|
|
335
341
|
- **Status.** The run's `status.json` records `launcher: { name, argv }`. Environment values are never recorded.
|
|
336
|
-
- **Resume and revival.** A resumed run uses the launcher recorded when the run was first launched, not the agent file's current value, and looks up that name's argv in the config the session loaded, like a new launch does; edits to `runnerLaunchers` apply after `/reload`. A run launched without a launcher stays unwrapped even if its agent file gains `launcher` later. If the recorded name is no longer in `runnerLaunchers`, the resume fails before anything starts, and the run can be resumed once the name is defined again.
|
|
342
|
+
- **Resume and revival.** A resumed run uses the launcher recorded when the run was first launched, not the agent file's current value, and looks up that name's argv in the config the session loaded, like a new launch does; edits to `runnerLaunchers` apply after `/reload`. A run recorded as launched without a launcher stays unwrapped even if its agent file gains `launcher` later. When no launcher choice is recorded (a run started before this was recorded, a foreground run, or a workflow child resumed through its workflow run), the resume uses the agent file's current `launcher`, so it never runs unwrapped just because the record is missing. If the recorded name is no longer in `runnerLaunchers`, the resume fails before anything starts, and the run can be resumed once the name is defined again.
|
|
337
343
|
- **Several agents in one runner.** A new chain attached to a running subagent, or steps appended to a running chain, run in one background runner. All agents in it must name the same launcher, or none; a mix is refused before anything starts, and the error names each agent and its launcher. Appended steps must also match the launcher of the runner they join. Steps in one wrapped chain share its sandbox; to give branches different sandboxes, run them as workflow-script children, which each get their own runner.
|
|
338
344
|
- **Agent management.** `subagent({ action: "create" })` and `update` cannot set `launcher`; edit the agent file instead. Other updates keep an existing `launcher` line.
|
|
345
|
+
- **Requiring a launcher from the call.** `options.requireLauncher: { name, definitionDigest }` refuses a launch unless it runs under that launcher with that agent definition. See [Requiring a launcher](extension-api.md#requiring-a-launcher).
|
|
339
346
|
|
|
340
347
|
### Wrapper requirements
|
|
341
348
|
|
|
@@ -348,11 +355,25 @@ A launcher command must:
|
|
|
348
355
|
|
|
349
356
|
Steering, stop, and supervisor requests and replies travel through files in those directories, not through signals, so they work as long as the paths are shared.
|
|
350
357
|
|
|
358
|
+
With `~/.pi/agent` read-only, a child cannot refresh an OAuth login, because Pi locks and rewrites `auth.json` there, so it fails once its token needs a refresh; API keys are unaffected. Child sessions sit under `~/.pi/agent/sessions/` by default, so the child session directory still needs its own read-write binding.
|
|
359
|
+
|
|
360
|
+
### Isolating a run from the parent
|
|
361
|
+
|
|
362
|
+
A launcher can also keep a run from reaching the parent session and other runs. Resume and auto-resume take what to relaunch and under which identity only from records the parent keeps in `async-subagent-launches/<id>/` under the temp root: a workflow's saved launch (its script, owning session and capability ceiling), and a single run's recovery descriptor (its agent, session file, cwd, model, tools, ceilings and launcher). A run that rewrites files in its own run directory, such as `status.json`, cannot make a later resume start something else or continue another run's transcript. For the isolation to hold, the launcher must not give the run write access to:
|
|
363
|
+
|
|
364
|
+
- `async-subagent-launches/`, or other runs' directories under `async-subagent-runs/`;
|
|
365
|
+
- `~/.pi/agent`: extensions, settings and agent files there load into the parent session, so write access to them is a way into the parent. Bind it read-only.
|
|
366
|
+
|
|
367
|
+
The run's working directory stays writable, so a run can still reach the parent through it: the project's `.pi/` extensions and agents, or `.git/config` settings such as `core.fsmonitor` that the parent's git commands run. Give an isolated run a checkout the parent session does not use.
|
|
368
|
+
|
|
369
|
+
Runs that a child starts itself (nested runs) keep these records in their root run's folder under `nested-subagent-runs/`. The child's runner writes them, so they add no isolation.
|
|
370
|
+
|
|
351
371
|
### Broker wrappers
|
|
352
372
|
|
|
353
373
|
Some sandboxes, such as nono's broker mode, start the runner in a separate process instead of as a child of the launcher command. pi-subagents does not rely on the launcher's process being the runner:
|
|
354
374
|
|
|
355
375
|
- Before it starts any work, the runner reports its own process id. The launch waits up to 10 seconds for it and fails if it does not arrive. `status.json` and run events use the runner's process id, not the launcher's.
|
|
376
|
+
- If the launch fails before the runner is told to proceed, pi-subagents stops the reported process only when it is the launcher's process or one of its descendants, so a runner cannot make the parent signal an unrelated process. A broker-started runner is not signalled; it exits by itself within 30 seconds when it is never told to proceed.
|
|
356
377
|
- When the launcher process exits, its exit code and signal are kept in `launcher-close.json` in the run directory. That exit is treated as the runner's exit only when the runner's process is confirmed dead. A runner killed by a signal may be reported by the launcher as exit code `128 + n` (for example `143` for `SIGTERM`).
|
|
357
378
|
- If only the launcher process is killed while the runner keeps working, the run keeps running and still accepts steer and stop. No process-exit proof is recorded when the runner later exits, so if `maxActiveAsyncRunsPerSession` is set, the run's capacity slot stays held; the abandoned-slot policy releases it only if the run ends failed.
|
|
358
379
|
- If the sandbox does not let the parent check the runner's process id, a runner that dies without its launcher noticing stays `running` until the stale-run check marks it failed after 24 hours without a status update.
|
package/docs/configuration.md
CHANGED
|
@@ -108,7 +108,7 @@ The choice is made at session start or tree navigation, and only for a session w
|
|
|
108
108
|
|
|
109
109
|
Controls the parent-facing `subagent` tool description registered at startup. The default registers the short execution/safety description, which states the delegation authorization rule, plus a one-line `promptSnippet`. Explicit `"compact"` uses the same description without the snippet; `"full"` adds workflow and management detail, also without the snippet. All modes retain the same flat parameter schema. Extended examples and recipes are available on demand through `action:"guide"` and the bundled pi-subagents skill; full mode is not an exhaustive manual. Count the default snippet as well as the tool definition when comparing prompt footprints.
|
|
110
110
|
|
|
111
|
-
`custom` reads `subagent-tool-description.md` from the project config directory, then from `~/.pi/agent/subagent-tool-description.md`. Missing, empty, unreadable, or oversized custom files fall back to the full description. Custom templates may use `{{fullDescription}}`, `{{compactDescription}}`, `{{safetyGuidance}}`, `{{agentDir}}`, and `{{projectConfigDir}}`; the safety guidance is always present so custom prose cannot remove the runtime guardrails. Restart Pi after changing the mode or custom file. The change applies to new sessions; a resumed session keeps the tool definition and prompt text it already declared, so its prompt cache stays valid. To apply it to resumed sessions too, set [`pinToolDeclarations`](#pintooldeclarations) to `false`.
|
|
111
|
+
`custom` reads `subagent-tool-description.md` from the project config directory, then from `~/.pi/agent/subagent-tool-description.md`. Missing, empty, unreadable, or oversized custom files fall back to the full description. Custom templates may use `{{fullDescription}}`, `{{compactDescription}}`, `{{safetyGuidance}}`, `{{agentDir}}`, and `{{projectConfigDir}}`; the two description placeholders leave out features turned off with [`disabledFeatures`](#disabledfeatures), and the safety guidance is always present so custom prose cannot remove the runtime guardrails. Restart Pi after changing the mode or custom file. The change applies to new sessions; a resumed session keeps the tool definition and prompt text it already declared, so its prompt cache stays valid. To apply it to resumed sessions too, set [`pinToolDeclarations`](#pintooldeclarations) to `false`.
|
|
112
112
|
|
|
113
113
|
## `pinToolDeclarations`
|
|
114
114
|
|
|
@@ -124,7 +124,7 @@ Pi records each tool definition and prompt section a session declares, and decla
|
|
|
124
124
|
{ "disabledFeatures": ["watchdog", "panes", "preflight", "lane-metadata", "gates"] }
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
Removes feature groups you do not use from the `subagent` tool. Each listed feature loses its top-level parameters from the model-facing schema and its `options` keys are rejected, and any request that still uses one of its parameters or actions fails with an error naming this setting. The check covers the parent tool, fanout-child tools, RPC, slash commands, prompt templates, scheduled launches, delegated launches, and workflow `runs.run`/`runs.all`/`runs.lanes` children, which are rejected before they launch. The built-in tool descriptions, the unknown-action list, the fanout-child tool description, and RPC `ping` no longer mention disabled features. Every `{ action: "guide" }` response starts with a notice: a topic lists what is disabled, and a section points to the `tool-reference` topic for that list. With `workflow-scripts` disabled, the notice also says to use the top-level `tasks` or `chain` fields instead. Custom tool descriptions
|
|
127
|
+
Removes feature groups you do not use from the `subagent` tool. Each listed feature loses its top-level parameters from the model-facing schema and its `options` keys are rejected, and any request that still uses one of its parameters or actions fails with an error naming this setting. The check covers the parent tool, fanout-child tools, RPC, slash commands, prompt templates, scheduled launches, delegated launches, and workflow `runs.run`/`runs.all`/`runs.lanes` children, which are rejected before they launch. The built-in tool descriptions, the unknown-action list, the fanout-child tool description, and RPC `ping` no longer mention disabled features. Every `{ action: "guide" }` response starts with a notice: a topic lists what is disabled, and a section points to the `tool-reference` topic for that list. With `workflow-scripts` disabled, the notice also says to use the top-level `tasks` or `chain` fields instead. Custom tool descriptions keep their own text; only their `{{compactDescription}}` and `{{fullDescription}}` placeholders leave out disabled features. Nothing is disabled by default, and the default schema and description are unchanged. An unknown or duplicate feature name fails config loading rather than silently re-enabling every feature.
|
|
128
128
|
|
|
129
129
|
| Feature | Parameters removed | Actions rejected |
|
|
130
130
|
|---|---|---|
|
|
@@ -404,7 +404,7 @@ Adds a short `active_subagents` section to the parent's system prompt while this
|
|
|
404
404
|
{ "waitTool": { "enabled": true, "defaultTimeoutMs": 120000 } }
|
|
405
405
|
```
|
|
406
406
|
|
|
407
|
-
`defaultTimeoutMs` sets the blocking window used when a `bg_wait` call omits `timeoutMs`; explicit call values win, followed by this setting, then the 30-minute fallback. `bg_wait`
|
|
407
|
+
`defaultTimeoutMs` sets the blocking window used when a `bg_wait` call omits `timeoutMs`; explicit call values win, followed by this setting, then the 30-minute fallback. pi-subagents registers one wait tool, named `bg_wait` unless `name` sets another (a letter, then letters, digits or underscores, at most 64 characters). Rename it when another extension also registers `bg_wait`, because Pi refuses to start when two extensions register the same tool name; for example `{ "waitTool": { "name": "subagent_wait" } }`. Everything pi-subagents says about waiting then uses that name, children get the same name, and a child agent that should wait lists that name in its `tools`. When the window elapses, the tool returns a non-error `window_elapsed` result with the still-active work identities, and that work keeps running. Set `enabled` to `false` to make direct calls return immediately instead of blocking. The default is enabled. You can also set `"waitTool": false`; set `PI_SUBAGENT_WAIT_TOOL_ENABLED=false` (or `0`, `off`, `disabled`) to override config for one process. The effective enabled, default-timeout and name values are passed explicitly to child runtimes. Headless `agent_end` auto-drain retains its own strict deadline and fails if required work remains unresolved. Invalid config or environment values fail instead of being coerced.
|
|
408
408
|
|
|
409
409
|
|
|
410
410
|
Blocking `bg_wait({ id: "..." })` keeps the current tool call open until that run changes. By default it returns when a run needs attention, even when the run is still working normally, for example a `bash` command open longer than `activeNoticeAfterMs`; the result then says the run is still running. Use `bg_wait({ stopOnAttention: false })` for run-to-completion flows: it waits through idle time, a tool held open, or repeated tool failures, and still ends for a supervisor/contact request, a finished run, the timeout, user input, or abort. A steer or follow-up the operator sends while a blocking wait is open also ends it, with a non-error `user_input` result listing the still-active work, so the message reaches the model without waiting out the window. In a long-lived interactive parent session, `bg_wait({ id: "...", nonBlocking: true })` instead resolves the prefix once, persists the exact run identity, returns a subscription token immediately, and wakes that session on completion, failure, attention, reconciliation failure, or timeout. Use it for provider, detached, or other background work without a native completion notification; ordinary async subagent runs notify the parent natively and do not need a wait subscription. Armed subscriptions appear in ordinary `subagent({ action: "status" })` output and are not counted as active child work. A native completion notification goes to the Pi process that launched the run while that process is running; once it has exited, the session gets the result the next time it is open in any Pi. `nonBlocking` subscriptions need a host with a UI context, such as interactive or RPC mode; plain SDK embedding without a UI context rejects them.
|
|
@@ -470,7 +470,7 @@ An explicit `subagent` call value wins over this default. Choose a value at leas
|
|
|
470
470
|
{ "globalConcurrencyLimit": 20 }
|
|
471
471
|
```
|
|
472
472
|
|
|
473
|
-
Caps simultaneously running children inside one run, including durable legacy multi-child runs and workflow script launches through `runs.run`/`runs.all`. Queued workflow children retain their stable keys and begin when a running sibling releases capacity. The default is `20`.
|
|
473
|
+
Caps simultaneously running children inside one run, including durable legacy multi-child runs and workflow script launches through `runs.run`/`runs.all`. Queued workflow children retain their stable keys and begin when a running sibling releases capacity. The default is `20`. The value must be a positive integer; an invalid value fails config loading.
|
|
474
474
|
|
|
475
475
|
Inline or file-backed top-level workflow calls may set a positive safe-integer `globalConcurrencyLimit` to override this value for that workflow. The override is workflow-only and is not forwarded to child calls.
|
|
476
476
|
|
package/docs/extension-api.md
CHANGED
|
@@ -312,6 +312,21 @@ Boundaries:
|
|
|
312
312
|
- Some host-owned facts, such as exact fork snapshots, nested async roots, and live model registries, can only be proven by the Pi host; those appear as `host_required` diagnostics instead of silently pretending to be exact.
|
|
313
313
|
- Preflight reads the extension config, so `defaultSubagentContext: "fresh"` or `"fork"` affects omitted context in the same way as execution. Explicit `context` still wins.
|
|
314
314
|
|
|
315
|
+
### Requiring a launcher
|
|
316
|
+
|
|
317
|
+
An extension that approved one agent definition for one [launcher](agents.md#sandboxing-background-children-with-a-launcher) can make the launch depend on that approval. Read `contract.agent.definitionDigest` from preflight, then pass it with the launcher name in the call, for example by adding it to the `subagent` tool call's input in your `tool_call` handler:
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
event.input.options = { ...event.input.options, requireLauncher: { name: "net", definitionDigest } };
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
pi-subagents checks the requirement after every `tool_call` handler has run, against the agent and launcher it is about to start, and again when it spawns the runner. The launch is refused if the agent has no launcher, uses another launcher, or has a different definition digest (for example because the agent file changed, or a project agent now shadows it). It never falls back to running without the launcher, and a refusal starts nothing. The runner records the checked digest.
|
|
324
|
+
|
|
325
|
+
- Only a top-level single-agent call (`agent` + `task`) accepts it, and it runs in the background because launcher agents always do. `tasks`, `chain`, workflows, workflow children (`runs.run`), actions and `resume` are refused.
|
|
326
|
+
- The requirement travels in the call. Another extension's `tool_call` handler that runs after yours can remove it, and pi-subagents cannot tell. Register your handler so it runs last, or check the run's `status.json` (`launcher.name`) afterwards.
|
|
327
|
+
- Releases without this option reject `options.requireLauncher` as an unknown option, so an older install fails the call instead of ignoring it.
|
|
328
|
+
- The run's recovery record keeps the requirement, and `resume` checks it again: it is refused if the agent is gone, names another launcher, or has a different definition digest, and attaching a chain to the run is refused.
|
|
329
|
+
|
|
315
330
|
## Structured delegation API
|
|
316
331
|
|
|
317
332
|
Other Pi extensions can ask `pi-subagents` to run one configured foreground leaf agent through the structured delegation API. It uses the established `prompt-template:subagent:*` event family and the same executor as the `subagent` tool; it does not add another launcher.
|
|
@@ -593,7 +608,7 @@ When Pi runs inside [Herdr](https://herdr.dev), pi-subagents automatically repor
|
|
|
593
608
|
- The bridge is enabled only when Herdr supplies `HERDR_ENV=1` and `HERDR_PANE_ID`; outside Herdr it registers no listeners or timers.
|
|
594
609
|
- It restores current-session active runs after `/reload` or `/resume`, refreshes metadata while work is active, and clears it on completion or shutdown.
|
|
595
610
|
- The bridge emits `herdr:busy` while async work remains and never raises `herdr:blocked`, because a child's attention request goes to the parent agent, not the user. Herdr's Pi integration does not consume `herdr:busy` yet, so the pane's dot follows the parent's own turn and the metadata label shows the active work.
|
|
596
|
-
- The owning Pi session is the only publisher for its own pane metadata. When an active workflow has an explicit bounded `label`, the newest active label appears in the summary
|
|
611
|
+
- The owning Pi session is the only publisher for its own pane metadata. When an active workflow has an explicit bounded `label`, the newest active label appears in the summary; overlapping completion restores the previous active label. Raw task and goal prompts never enter Herdr metadata. The compact `title-suffix` is always `⏳N`, where N is the number of active subagents, so it stays short in narrow sidebar rows. Attention adds `⚠`, and the suffix is cleared when active work reaches zero.
|
|
597
612
|
|
|
598
613
|
To show the reported label in the expanded Agent sidebar, include `state_text` or `$summary` in its row layout:
|
|
599
614
|
|
package/docs/tool-reference.md
CHANGED
|
@@ -539,6 +539,8 @@ async: true
|
|
|
539
539
|
|
|
540
540
|
Supported: status artifacts, stdout/stderr logs, timeout, and stop. Full stdout and stderr are written to log files, while the in-memory final stdout response and stderr error are limited to their last 64 KiB.
|
|
541
541
|
|
|
542
|
+
A code-owned adapter (`adapter: claude-code-writer` and the others in [agents.md](agents.md#claude-code-profiles)) records a `safety` block and a `safetySource: { measured: false, command }` beside it. The block is the adapter's profile, not a measurement, so a wrapper `command` that changes the CLI's argv can grant something else; see [Safety record and wrapper commands](agents.md#safety-record-and-wrapper-commands).
|
|
543
|
+
|
|
542
544
|
Intentionally unsupported: native Pi child options such as model override, structured output, acceptance/agent contract, tool budgets, fast mode, fork context, skills, or native Pi tools unless the runner explicitly implements them. Foreground/clarify, steer/resume/interrupt-as-pause, and nested subagents are also unsupported.
|
|
543
545
|
|
|
544
546
|
## Session sharing
|
package/docs/workflows.md
CHANGED
|
@@ -37,7 +37,7 @@ When the Pi process that ran an async workflow exits before the workflow finishe
|
|
|
37
37
|
|
|
38
38
|
A stopped run is continued by one relaunch only. While that relaunch exists, another relaunch of the same stopped run, by the same script or by `options.reuseFrom`, is refused with `workflow run '<id>' was resumed as <new id>; wait on it or stop it.` If that relaunch stops the same way, relaunch it instead: it carries the children of every run before it. If the Pi process that started the relaunch exits before the relaunch begins, the stopped run can be relaunched again.
|
|
39
39
|
|
|
40
|
-
To continue a stopped run without sending its script again, resume it by id from the session that owns it: `subagent({ action: "resume", id: "<stopped run id>" })` with no `message`. Every async top-level workflow saves its launch (the script or named resource, its `args` and options) when it starts, and the resume relaunches that launch with `options.reuseFrom` set to the stopped run, in the stopped run's cwd, with no more authority than it had. A named resource is resolved again and must still have the same script. The new run records `workflow.resumeOrigin: { sourceRunId, attempt }`, where `attempt` counts the resumes that followed a Pi exit. Another session cannot resume the run by id; reopen the session that started it, or relaunch the same script with `options.reuseFrom`. When the run cannot be resumed this way (it started before launches were saved, was launched from `tasks` or `chain`, or its resource changed), the refusal says so; relaunch the same script by hand with `options: { reuseFrom: "<stopped run id>" }`.
|
|
40
|
+
To continue a stopped run without sending its script again, resume it by id from the session that owns it: `subagent({ action: "resume", id: "<stopped run id>" })` with no `message`. Every async top-level workflow saves its launch (the script or named resource, its `args` and options) when it starts, outside its run directory, and the resume relaunches that launch with `options.reuseFrom` set to the stopped run, in the stopped run's cwd, with no more authority than it had. A named resource is resolved again and must still have the same script. The new run records `workflow.resumeOrigin: { sourceRunId, attempt }`, where `attempt` counts the resumes that followed a Pi exit. Another session cannot resume the run by id; reopen the session that started it, or relaunch the same script with `options.reuseFrom`. When the run cannot be resumed this way (it started before launches were saved outside run directories, was launched from `tasks` or `chain`, or its resource changed), the refusal says so; relaunch the same script by hand with `options: { reuseFrom: "<stopped run id>" }`.
|
|
41
41
|
|
|
42
42
|
When the session that owns such a run is reopened or reloaded, the run is resumed this way automatically, once, if it was interrupted in the last 24 hours: for a Pi exit, measured from the last time the dead Pi process updated the run. Session start does not wait for the relaunch. A run that cannot be relaunched is named in its notice (`Not auto-resumed: …`, with how to continue by hand); a launch that fails after session start also posts one `Workflow <id> was not auto-resumed: <reason>.` message. Either way the run is not tried again. `/new` and forks do not resume the runs of the session they replaced. The `autoResume` setting turns this off; see [Configuration](configuration.md#autoresume).
|
|
43
43
|
|
|
@@ -45,12 +45,22 @@ Starting Pi in a folder where another session's subagent runs were cut off by it
|
|
|
45
45
|
|
|
46
46
|
The completion notice of a workflow stopped by a Pi exit or a runtime replacement has one line right after `Workflow run: <id>` that says what happens next: `Auto-resumed as <new id>.`, `Resumed as <new id>.` (resumed by id), `Relaunched as <new id>.` (relaunched with the same script or `options.reuseFrom`), `Not auto-resumed: <reason>.` followed by the way to continue by hand, or, when nothing continues it, `Resume by hand: subagent({ action: "resume", id: "<id>" })` (or the `options.reuseFrom` form when its launch cannot be resumed by id).
|
|
47
47
|
|
|
48
|
-
After `/new`, `/resume`, or a fork in the same Pi process, the new session owns the async runs of the session it replaced, and of the sessions that one replaced. It can list, `bg_wait` on, steer, stop, and resume them, receives their completion notices, and answers their children's pending supervisor requests. Over RPC, a host can steer, interrupt, stop, resume, and inspect them, and sees them in the fleet and `subagent-async` snapshots. Startup and other Pi processes inherit nothing; `/reload` adds nothing new but keeps what the session already inherited. To relaunch a stopped workflow instead of controlling its children one by one, use `options.reuseFrom`.
|
|
48
|
+
After `/new`, `/resume`, or a fork in the same Pi process, the new session owns the async runs of the session it replaced, and of the sessions that one replaced. It can list, `bg_wait` on, steer, stop, and resume them, receives their completion notices, and answers their children's pending supervisor requests. Over RPC, a host can steer, interrupt, stop, resume, and inspect them, and sees them in the fleet and `subagent-async` snapshots. Startup and other Pi processes inherit nothing; `/reload` adds nothing new but keeps what the session already inherited. A replaced session that starts again (pi-web reopening it) takes its runs back. To relaunch a stopped workflow instead of controlling its children one by one, use `options.reuseFrom`.
|
|
49
49
|
|
|
50
50
|
Once the Pi process that started a background single, parallel, or chain run has exited, the run is reported once to a Pi window that has its session open, whether it finished while Pi was closed or finishes later. A workflow's children are reported through their workflow.
|
|
51
51
|
|
|
52
52
|
Pi core may print a generic `pi -ne` extension-load hint; that out-of-repo hint is not protocol-approved fallback. A verified compaction abort may continue the retained child once on its already resolved model; it does not authorize an execution-mode or model switch.
|
|
53
53
|
|
|
54
|
+
### Switching sessions with background work
|
|
55
|
+
|
|
56
|
+
When a session with a UI has queued or running async work, live nested children, undelivered results, or supervisor questions, `/new`, `/resume`, `/fork`, and `/clone` first ask **pi-subagents: switch sessions?**:
|
|
57
|
+
|
|
58
|
+
- **Stay here** (default, also Escape): cancel the switch. The work keeps running.
|
|
59
|
+
- **Switch and take the work**: the new session takes the work over, as after any switch without the prompt.
|
|
60
|
+
- **Switch and leave the work here**: the new session inherits nothing from this one. Async single, parallel, and chain runs keep running under this session; reopen it to get their results. Async workflows and detached foreground runs stop on any switch; a stopped workflow resumes automatically only if you reopen this session within 24 hours. A child's question can be answered only until it times out (10 minutes by default).
|
|
61
|
+
|
|
62
|
+
Without outstanding work, or without a UI (`pi -p`, SDK sessions), there is no prompt and the new session takes the work over. Over RPC the prompt is a select dialog that counts as **Stay here** if the host does not answer within one minute. The prompt never enters model history.
|
|
63
|
+
|
|
54
64
|
## Prompt shortcuts
|
|
55
65
|
|
|
56
66
|
The package includes reusable prompt templates for common workflows. You do not need them, but they are handy when you want the same shape every time:
|
|
@@ -85,6 +95,10 @@ Workflow-level child controls default onto each `runs.run`/`runs.all` launch; ex
|
|
|
85
95
|
|
|
86
96
|
Child results cross into the script as plain JSON data. Non-JSON host metadata is omitted, so use returned fields such as `runId`, `ok`, `output`, and `structuredOutput` for workflow control.
|
|
87
97
|
|
|
98
|
+
On Node, each script runs in a new permission-restricted process that can read only its supervisor, worker and Acorn parser; Node denies file writes, other reads, child processes and nested workers. The process inherits no host startup flags, preloads or environment variables (except `SystemRoot` on Windows) and starts in Acorn's directory, because Node lets worker threads read their working directory. A small supervisor keeps IPC responsive, so a busy script is still killed when the parent disconnects. The process ends when the workflow settles.
|
|
99
|
+
|
|
100
|
+
This is a permission layer around the VM, not an OS sandbox: network access stays open on Node 22 and 24, and child launches and `runs.host` commands still run in Pi under their own contracts. Bun has no permission model, so it keeps the in-process worker. If the Node process fails to start, the workflow fails; it never retries in an unrestricted worker.
|
|
101
|
+
|
|
88
102
|
Omitting a child's `async` preserves awaited final-result semantics, even if the child runs in the background. Explicit child `async: true` intentionally returns after launch: its receipt has `state: "running"`, `ok: false`, an empty `output`, and no completion error or final `outputReference`. `ok` confirms successful child completion, not successful dispatch. It does not confirm that the task's intent was carried out: a child that declines or cannot do the work can still end normally. When later steps depend on the work having happened, give the child an `outputSchema` with an explicit status field (and check `structuredOutput` in the script) or a host-run `gate`, and treat only that verdict as success. Use `runId` and `asyncDir` to inspect the running child; `artifactPaths` may include runtime directories and is not a list of final reports. Reusing the same workflow key returns the same receipt, not a refreshed result.
|
|
89
103
|
|
|
90
104
|
A workflow can finish dispatch while these children remain running. Its summary and child rows identify that distinction, and launch receipts do not generate child-completion notices. Consume the later child result before treating its work or report as complete.
|
|
@@ -133,6 +147,20 @@ The host resolves the name and validates bounded plain-JSON `args` before starti
|
|
|
133
147
|
|
|
134
148
|
`parallel` runs independent children together without writing a script: `args.tasks` is a list of `{ agent, task, cwd?, model? }` items, the children run in one `runs.all` batch, and the result lists each child's output in order. `cwd` and `model` are optional per child and apply to that child only, as they do on a `runs.all` item, so one call can fan out across several repositories or mix models. A failed child fails the workflow. Use a workflow script when steps depend on each other.
|
|
135
149
|
|
|
150
|
+
### Approving workflow children in permission extensions
|
|
151
|
+
|
|
152
|
+
Before a workflow starts a child, pi-subagents makes a nested `subagent_launch` tool call, so permission extensions see it in their `tool_call` handler like any other tool call. This covers reply-block, file and named workflows, and `chain` and `tasks`. The call's input is `{ workflowRunId, key, agent?, task?, cwd?, model?, async?, worktree?, resume?, commands?, output? }`. `cwd` is the absolute directory the child starts in. It is left out for a resumed child, which keeps its earlier directory, and for a child placed on another machine. `commands` lists, in run order, the shell commands the child's `gate`, `acceptance.verify` or agent `acceptance` will run on this machine after the child finishes, each `{ command, cwd?, env? }`. A command's `cwd` is absolute and is left out when the child's is; for a `worktree: true` child it names the source directory, because the worktree does not exist yet. `env` lists only the variables the command sets on top of the parent's environment. `output` is the absolute path of the file the child's `output` writes. The other optional fields appear when the child request sets them. A blocked or failed call stops that child, so its commands never run and its output file is never written; it fails with `Workflow child '<key>' was not started: …` and the block reason. Allowed calls do nothing else. The tool is not declared to the model.
|
|
153
|
+
|
|
154
|
+
Extensions that ask about tools they have no rule for ask once per workflow child until you allow `subagent_launch`. Ones that deny unknown tools without a UI, as in `pi -p`, refuse every workflow child until you allow it.
|
|
155
|
+
|
|
156
|
+
Limits:
|
|
157
|
+
- Children reused from an interrupted run's journal are not offered again; nothing new starts.
|
|
158
|
+
- Starts with no tool call behind them are not offered: schedule ticks, auto-resume on session reopen, `/prompt-workflow` and prompt-template delegation, and RPC or SDK launches. Block `schedule.create`, set `authorityPolicy.scheduleCreate` to `"forbid"`, or set [`autoResume`](configuration.md#autoresume) to `false` to control those.
|
|
159
|
+
- Workflows started inside child agents are not offered: children do not register `subagent_launch`. Neither are workflows in a session whose tool allowlist (`pi --tools …`) leaves it out.
|
|
160
|
+
- Commands are offered at launch, not when they run. An extension's `bash` rules don't apply to them on their own; it has to check `commands`.
|
|
161
|
+
- A resumed child's retained `acceptance.verify` commands are not listed again; only commands the resume request adds are.
|
|
162
|
+
- `runs.host` is only available to built-in workflows (`run-ci` runs only `npm test` or `npm run typecheck`) and is not offered.
|
|
163
|
+
|
|
136
164
|
### Opt-in bounded workflows
|
|
137
165
|
|
|
138
166
|
Composite workflows have no default parent deadline. Add bounds only when the workflow contract calls for them:
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import { discoverAvailableSkills, resolveSkills } from "./skills.js";
|
|
|
7
7
|
import { buildProactiveSkillSubagentRecommendationLines, } from "./proactive-skills.js";
|
|
8
8
|
import { parseFrontmatter, parseUnquotedList } from "./frontmatter.js";
|
|
9
9
|
import { resolveEffectiveThinking, THINKING_LEVELS, toModelInfo } from "../shared/model-info.js";
|
|
10
|
-
import { resolveSubagentModelOverride } from "../runs/shared/model-resolution.js";
|
|
10
|
+
import { isUnavailableSubagentModel, resolveSubagentModelOverride } from "../runs/shared/model-resolution.js";
|
|
11
11
|
import { validateToolBudgetConfig } from "../runs/shared/tool-budget.js";
|
|
12
12
|
import { formatReviewGateLabel, validateAcceptanceInput } from "../runs/shared/acceptance.js";
|
|
13
13
|
import { CODE_OWNED_EXTERNAL_CLI_ADAPTER_LABEL, isCodeOwnedExternalCliAdapterId, resolveExternalCliRunnerStatus, validateCodeOwnedProfileRunner } from "../runs/shared/external-cli-contract.js";
|
|
@@ -765,7 +765,8 @@ function agentListMetadata(agent, providerNames, externalCliAvailability) {
|
|
|
765
765
|
function formatAgentListLine(agent, providerNames) {
|
|
766
766
|
return `- ${agent.name} (${agentListMetadata(agent, providerNames)}): ${agent.description}`;
|
|
767
767
|
}
|
|
768
|
-
|
|
768
|
+
const UNAVAILABLE_MODEL_MARKER = "(unavailable in the active model registry)";
|
|
769
|
+
function formatAgentCapabilitiesLine(agent, providerNames, externalCliAvailability, unavailableModels) {
|
|
769
770
|
const declaredTools = [
|
|
770
771
|
...(agent.tools ?? []),
|
|
771
772
|
...(agent.mcpDirectTools ?? []).map((tool) => `mcp:${tool}`),
|
|
@@ -784,6 +785,8 @@ function formatAgentCapabilitiesLine(agent, providerNames, externalCliAvailabili
|
|
|
784
785
|
model = agent.model;
|
|
785
786
|
if (agent.modelProvider && !agent.model.includes("/"))
|
|
786
787
|
model = `${agent.modelProvider}/${agent.model}`;
|
|
788
|
+
if (unavailableModels.has(agent))
|
|
789
|
+
model = `${model} ${UNAVAILABLE_MODEL_MARKER}`;
|
|
787
790
|
}
|
|
788
791
|
const thinking = agent.thinking === false ? "off" : agent.thinking ?? "default";
|
|
789
792
|
const machine = agent.machine ? `; Machine: ${agent.machine} (saved Herdr placement)` : "";
|
|
@@ -864,7 +867,7 @@ function agentCapabilityRow(agent, options) {
|
|
|
864
867
|
aliases: agent.aliases ? [...agent.aliases] : undefined,
|
|
865
868
|
runner: agentCapabilityRunner(agent, options.providerNames, options.externalCliAvailability),
|
|
866
869
|
tools: agentCapabilityTools(agent),
|
|
867
|
-
model: presentDetails({ value: agent.model, thinking: agent.thinking }),
|
|
870
|
+
model: presentDetails({ value: agent.model, thinking: agent.thinking, unavailable: options.unavailableModels.has(agent) || undefined }),
|
|
868
871
|
execution: presentDetails({ defaultAsync: agent.defaultAsync, timeoutMs: agent.defaultTimeoutMs }),
|
|
869
872
|
acceptance: presentDetails({ policy: agent.defaultAcceptance, role: agent.acceptanceRole }),
|
|
870
873
|
output: presentDetails({ path: agent.output, mode: agent.outputMode }),
|
|
@@ -874,8 +877,8 @@ function agentCapabilityRow(agent, options) {
|
|
|
874
877
|
function agentCapabilitiesSnapshot(input) {
|
|
875
878
|
return {
|
|
876
879
|
agents: [
|
|
877
|
-
...input.agents.map((agent) => agentCapabilityRow(agent, { executable: true, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability })),
|
|
878
|
-
...input.restrictedAgents.map((agent) => agentCapabilityRow(agent, { executable: false, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability, restrictionSources: input.restrictedSources })),
|
|
880
|
+
...input.agents.map((agent) => agentCapabilityRow(agent, { executable: true, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability, unavailableModels: input.unavailableModels })),
|
|
881
|
+
...input.restrictedAgents.map((agent) => agentCapabilityRow(agent, { executable: false, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability, unavailableModels: input.unavailableModels, restrictionSources: input.restrictedSources })),
|
|
879
882
|
],
|
|
880
883
|
restrictedCount: input.restrictedAgents.length,
|
|
881
884
|
...(input.restrictedSources?.length ? { capabilityCeilingSources: [...input.restrictedSources] } : {}),
|
|
@@ -908,6 +911,7 @@ function agentCapabilityDetails(input) {
|
|
|
908
911
|
restrictedAgents: input.restrictedAgents,
|
|
909
912
|
providerNames: input.providerNames,
|
|
910
913
|
externalCliAvailability: input.externalCliAvailability,
|
|
914
|
+
unavailableModels: input.unavailableModels,
|
|
911
915
|
restrictedSources: input.restrictedSources,
|
|
912
916
|
})),
|
|
913
917
|
};
|
|
@@ -1037,8 +1041,11 @@ export function handleList(params, ctx) {
|
|
|
1037
1041
|
const providerNameSet = providerNames(providerStatus);
|
|
1038
1042
|
const capabilityMode = params.capabilities === true;
|
|
1039
1043
|
const externalCliAvailability = capabilityMode ? externalCliAvailabilityForAgents([...agents, ...restrictedAgents]) : undefined;
|
|
1044
|
+
const availableModels = capabilityMode ? ctx.modelRegistry.getAvailable().map(toModelInfo) : [];
|
|
1045
|
+
const unavailableModels = new Set([...agents, ...restrictedAgents].filter((agent) => (agent.runner?.type ?? "pi") === "pi"
|
|
1046
|
+
&& isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? ctx.model?.provider)));
|
|
1040
1047
|
const formatLine = capabilityMode
|
|
1041
|
-
? (agent, names) => formatAgentCapabilitiesLine(agent, names, externalCliAvailability)
|
|
1048
|
+
? (agent, names) => formatAgentCapabilitiesLine(agent, names, externalCliAvailability, unavailableModels)
|
|
1042
1049
|
: formatAgentListLine;
|
|
1043
1050
|
const lines = [
|
|
1044
1051
|
capabilityMode ? "Executable agents (capabilities):" : "Executable agents:",
|
|
@@ -1055,12 +1062,19 @@ export function handleList(params, ctx) {
|
|
|
1055
1062
|
restrictedAgents,
|
|
1056
1063
|
providerNames: providerNameSet,
|
|
1057
1064
|
externalCliAvailability: externalCliAvailability ?? new Map(),
|
|
1065
|
+
unavailableModels,
|
|
1058
1066
|
restrictedSources,
|
|
1059
1067
|
}));
|
|
1060
1068
|
}
|
|
1069
|
+
// User then project overrides are layered, so the override's top-level scope can name a file that did not set `model`.
|
|
1070
|
+
function modelOverrideFile(override) {
|
|
1071
|
+
const scopes = override.fieldScopes?.model;
|
|
1072
|
+
const scope = scopes?.includes("project") ? "project" : scopes?.includes("user") ? "user" : override.scope;
|
|
1073
|
+
return { scope, path: override.paths?.[scope] ?? override.path };
|
|
1074
|
+
}
|
|
1061
1075
|
function formatModelSource(agent, currentModel) {
|
|
1062
1076
|
if (agent.override && agent.model !== agent.override.base.model) {
|
|
1063
|
-
return `${agent.override.scope} override`;
|
|
1077
|
+
return `${modelOverrideFile(agent.override).scope} override`;
|
|
1064
1078
|
}
|
|
1065
1079
|
if (agent.modelSource?.type === "subagents.defaultModel" && agent.model === agent.modelSource.model) {
|
|
1066
1080
|
return `${agent.modelSource.scope} defaultModel`;
|
|
@@ -1114,18 +1128,20 @@ function handleModels(params, ctx) {
|
|
|
1114
1128
|
: [{ agent, name: agent.name }, ...(agent.aliases ?? []).map((name) => ({ agent, name }))]);
|
|
1115
1129
|
for (const { agent, name } of modelEntries) {
|
|
1116
1130
|
const resolvedModel = resolveSubagentModelOverride(agent.model, currentModel, availableModels, agent.modelProvider ?? preferredProvider);
|
|
1131
|
+
const shownModel = resolvedModel === undefined ? "(unresolved)"
|
|
1132
|
+
: (agent.runner?.type ?? "pi") === "pi" && isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? preferredProvider) ? `${resolvedModel} ${UNAVAILABLE_MODEL_MARKER}` : resolvedModel;
|
|
1117
1133
|
const effectiveThinking = resolveEffectiveThinking(resolvedModel, agent.thinking)
|
|
1118
1134
|
?? (agent.thinking === false ? "off" : undefined);
|
|
1119
1135
|
const source = `${formatModelSource(agent, currentModel)}${agent.disabled ? "; disabled" : ""}${isAgentAllowedByCapabilityCeiling(agent.name, capabilityCeiling) ? "" : "; restricted"}`;
|
|
1120
1136
|
if (requestedAgent) {
|
|
1121
1137
|
lines.push(`Agent: ${requestedAgent}`);
|
|
1122
1138
|
lines.push("Effective model:");
|
|
1123
|
-
lines.push(` ${
|
|
1139
|
+
lines.push(` ${shownModel}`);
|
|
1124
1140
|
lines.push(`Source: ${source}`);
|
|
1125
1141
|
lines.push(`Thinking: ${effectiveThinking ?? "default"}`);
|
|
1126
1142
|
if (agent.override) {
|
|
1127
1143
|
lines.push("Override file:");
|
|
1128
|
-
lines.push(` ${agent.override.path}`);
|
|
1144
|
+
lines.push(` ${modelOverrideFile(agent.override).path}`);
|
|
1129
1145
|
}
|
|
1130
1146
|
if (agent.model && resolvedModel && agent.model !== resolvedModel) {
|
|
1131
1147
|
lines.push("Requested model setting:");
|
|
@@ -1141,12 +1157,12 @@ function handleModels(params, ctx) {
|
|
|
1141
1157
|
}
|
|
1142
1158
|
lines.push(name);
|
|
1143
1159
|
lines.push(" model:");
|
|
1144
|
-
lines.push(` ${
|
|
1160
|
+
lines.push(` ${shownModel}`);
|
|
1145
1161
|
lines.push(` source: ${source}`);
|
|
1146
1162
|
lines.push(` thinking: ${effectiveThinking ?? "default"}`);
|
|
1147
1163
|
if (agent.override) {
|
|
1148
1164
|
lines.push(" override file:");
|
|
1149
|
-
lines.push(` ${agent.override.path}`);
|
|
1165
|
+
lines.push(` ${modelOverrideFile(agent.override).path}`);
|
|
1150
1166
|
}
|
|
1151
1167
|
if (agent.model && resolvedModel && agent.model !== resolvedModel) {
|
|
1152
1168
|
lines.push(" requested model setting:");
|
|
@@ -15,13 +15,10 @@ import { type AgentConfig, type AgentMemoryConfig } from "./agents.ts";
|
|
|
15
15
|
export declare const AGENT_MEMORY_DIR_NAME = "agent-memory";
|
|
16
16
|
export declare const AGENT_MEMORY_FILE = "MEMORY.md";
|
|
17
17
|
export declare const MAX_MEMORY_LINES = 200;
|
|
18
|
-
/** Parse a `memory` frontmatter block string into a typed config, or undefined if invalid. */
|
|
19
18
|
export declare function parseMemoryFrontmatter(raw: string | undefined): AgentMemoryConfig | undefined;
|
|
20
|
-
/**
|
|
19
|
+
/** Inherits default builtins when `tools` is unset. */
|
|
21
20
|
export declare function agentHasWriteTools(agent: Pick<AgentConfig, "tools">): boolean;
|
|
22
21
|
/**
|
|
23
|
-
* Resolve a memory directory under `rootDir` for the given scoped path.
|
|
24
|
-
*
|
|
25
22
|
* Rejects empty paths, `.`/`..` segments, paths that escape the root, and
|
|
26
23
|
* existing directories whose real path (via symlink) lands outside the root.
|
|
27
24
|
*/
|
|
@@ -29,7 +29,6 @@ function unquoteFrontmatterValue(value) {
|
|
|
29
29
|
}
|
|
30
30
|
return trimmed;
|
|
31
31
|
}
|
|
32
|
-
/** Parse a `memory` frontmatter block string into a typed config, or undefined if invalid. */
|
|
33
32
|
export function parseMemoryFrontmatter(raw) {
|
|
34
33
|
if (!raw)
|
|
35
34
|
return undefined;
|
|
@@ -60,7 +59,7 @@ export function parseMemoryFrontmatter(raw) {
|
|
|
60
59
|
return undefined;
|
|
61
60
|
return { scope, path: scopedPath };
|
|
62
61
|
}
|
|
63
|
-
/**
|
|
62
|
+
/** Inherits default builtins when `tools` is unset. */
|
|
64
63
|
export function agentHasWriteTools(agent) {
|
|
65
64
|
const tools = agent.tools;
|
|
66
65
|
if (!tools)
|
|
@@ -168,8 +167,6 @@ function resolveProjectMemoryRoot(projectRoot) {
|
|
|
168
167
|
}
|
|
169
168
|
}
|
|
170
169
|
/**
|
|
171
|
-
* Resolve a memory directory under `rootDir` for the given scoped path.
|
|
172
|
-
*
|
|
173
170
|
* Rejects empty paths, `.`/`..` segments, paths that escape the root, and
|
|
174
171
|
* existing directories whose real path (via symlink) lands outside the root.
|
|
175
172
|
*/
|
package/src/agents/agents.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent discovery and configuration
|
|
3
|
-
*/
|
|
4
1
|
import * as fs from "node:fs";
|
|
5
2
|
import { type AcceptanceInput, type AcceptanceRole, type AgentRunnerConfig, type JsonSchemaObject, type OutputMode, type ToolBudgetConfig } from "../shared/types.ts";
|
|
6
3
|
import { type ModelScopeConfig } from "../runs/shared/model-scope.ts";
|
|
@@ -85,6 +82,7 @@ interface BuiltinAgentOverrideInfo {
|
|
|
85
82
|
base: BuiltinAgentOverrideBase;
|
|
86
83
|
fields?: string[];
|
|
87
84
|
fieldScopes?: Record<string, Array<"user" | "project">>;
|
|
85
|
+
paths?: Partial<Record<"user" | "project", string>>;
|
|
88
86
|
}
|
|
89
87
|
export interface AgentModelSourceInfo {
|
|
90
88
|
type: "subagents.defaultModel";
|
package/src/agents/agents.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent discovery and configuration
|
|
3
|
-
*/
|
|
4
1
|
import { execSync } from "node:child_process";
|
|
5
2
|
import * as fs from "node:fs";
|
|
6
3
|
import { parse as parseYaml } from "yaml";
|
|
@@ -1217,6 +1214,7 @@ function applyBuiltinOverride(agent, override, meta) {
|
|
|
1217
1214
|
base: agent.override?.base ?? cloneOverrideBase(agent),
|
|
1218
1215
|
fields: [...new Set([...(agent.override?.fields ?? []), ...Object.keys(override)])].sort(),
|
|
1219
1216
|
fieldScopes: Object.fromEntries(Object.entries({ ...(agent.override?.fieldScopes ?? {}) }).map(([field, scopes]) => [field, [...scopes]])),
|
|
1217
|
+
paths: { ...agent.override?.paths, [meta.scope]: meta.path },
|
|
1220
1218
|
};
|
|
1221
1219
|
for (const field of Object.keys(override)) {
|
|
1222
1220
|
const scopes = overrideInfo.fieldScopes[field] ?? [];
|
|
@@ -1364,13 +1362,16 @@ function applyBuiltinOverrides(builtinAgents, userSettings, projectSettings, use
|
|
|
1364
1362
|
};
|
|
1365
1363
|
return builtinAgents.map((agent) => {
|
|
1366
1364
|
const projectOverride = projectSettings.overrides[agent.name];
|
|
1365
|
+
const userOverride = userSettings.overrides[agent.name];
|
|
1367
1366
|
if (projectOverride && projectSettingsPath) {
|
|
1368
|
-
|
|
1367
|
+
const withUserOverride = userOverride
|
|
1368
|
+
? applyBuiltinOverride(agent, userOverride, { scope: "user", path: userSettingsPath })
|
|
1369
|
+
: agent;
|
|
1370
|
+
return applyGlobalThinking(applyBuiltinOverride(withUserOverride, projectOverride, { scope: "project", path: projectSettingsPath }), projectOverride.thinking !== undefined || (!projectThinkingConfigured && userOverride?.thinking !== undefined));
|
|
1369
1371
|
}
|
|
1370
1372
|
if (projectBulkDisabled && projectSettingsPath) {
|
|
1371
1373
|
return applyGlobalThinking(applyBuiltinOverride(agent, { disabled: true }, { scope: "project", path: projectSettingsPath }), false);
|
|
1372
1374
|
}
|
|
1373
|
-
const userOverride = userSettings.overrides[agent.name];
|
|
1374
1375
|
if (userOverride) {
|
|
1375
1376
|
return applyGlobalThinking(applyBuiltinOverride(agent, userOverride, { scope: "user", path: userSettingsPath }), !projectThinkingConfigured && userOverride.thinking !== undefined);
|
|
1376
1377
|
}
|
|
@@ -2500,7 +2501,7 @@ function getAgentDiscoverySources(cwd, preferredModelProvider, includeChains = f
|
|
|
2500
2501
|
const key = discoveryCacheKey(cwd, preferredModelProvider, globalNpmRoot, projectTrusted);
|
|
2501
2502
|
const cached = agentDiscoveryCache.get(key);
|
|
2502
2503
|
if (cached && cached.fingerprint === discoveryFingerprint(cached.sources)) {
|
|
2503
|
-
if (includeChains) {
|
|
2504
|
+
if (includeChains && !cached.sources.userChains) {
|
|
2504
2505
|
ensureDiscoveryChains(cached.sources);
|
|
2505
2506
|
cached.fingerprint = discoveryFingerprint(cached.sources);
|
|
2506
2507
|
}
|