pi-subagents 0.89.1 → 0.90.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 +48 -0
- package/bundle/agents.js +4 -4
- package/bundle/child-tool-plan.js +3 -3
- package/bundle/{chunk-SG3NCWZW.js → chunk-2LEBXCLU.js} +29 -19
- package/bundle/{chunk-UUW7P6KJ.js → chunk-37EJGDYO.js} +2 -2
- package/bundle/{chunk-IGZTXGPG.js → chunk-4DA22WRU.js} +59 -30
- package/bundle/{chunk-77VQEATI.js → chunk-5J2RTMKW.js} +2 -2
- package/bundle/{chunk-7J4ZXMY7.js → chunk-72334PEI.js} +6 -4
- package/bundle/{chunk-F6PTAPQ3.js → chunk-7HPZIT4W.js} +13 -13
- package/bundle/{chunk-SWGB2P5J.js → chunk-7Y4IJMCW.js} +1 -1
- package/bundle/{chunk-TRN65L4F.js → chunk-ACTHBJUI.js} +1 -1
- package/bundle/{chunk-6D54VW3E.js → chunk-AJWRYQPH.js} +145 -76
- package/bundle/{chunk-TXC7WIPL.js → chunk-C45WQQZX.js} +1 -1
- package/bundle/{chunk-YJIU5WF4.js → chunk-CPWZN5KM.js} +1 -1
- package/bundle/{chunk-BERAWSQQ.js → chunk-DNJ2GHSI.js} +7 -7
- package/bundle/{chunk-CASL47ST.js → chunk-EBGTTJKP.js} +6 -6
- package/bundle/{chunk-LWH7IGI3.js → chunk-F4NSLXB2.js} +8 -6
- package/bundle/{chunk-URKQZHVH.js → chunk-G43SW4BT.js} +29 -19
- package/bundle/{chunk-Q4VH72JI.js → chunk-KNVQTRSY.js} +2 -2
- package/bundle/{chunk-5TXWZB73.js → chunk-P2M6RIVX.js} +1 -1
- package/bundle/{chunk-ROJH7KPK.js → chunk-PSB3VLMH.js} +2 -2
- package/bundle/{chunk-VEEUXJDO.js → chunk-PTN7XAXI.js} +2 -2
- package/bundle/{chunk-TDXVQPZW.js → chunk-RIBMW6V3.js} +69 -15
- package/bundle/{chunk-KCDPTXHT.js → chunk-SIB2GQHL.js} +238 -200
- package/bundle/{chunk-JEZOSEWG.js → chunk-SRWJIAIP.js} +2 -0
- package/bundle/{chunk-OUM6SEVD.js → chunk-UC22RDXP.js} +8 -4
- package/bundle/{chunk-W2BZS6UC.js → chunk-VMJGZHUL.js} +9 -5
- package/bundle/{chunk-MIX3MCIF.js → chunk-WANQBKAZ.js} +12 -7
- package/bundle/{chunk-LUNVS6KP.js → chunk-WHHRG32M.js} +27 -20
- package/bundle/{chunk-C22YEYFZ.js → chunk-XIQKWTFY.js} +5 -5
- package/bundle/{chunk-YLU5JFW2.js → chunk-XYIVVS3A.js} +7 -3
- package/bundle/{chunk-R3NH5XAL.js → chunk-YVDKGAEO.js} +5 -4
- package/bundle/{chunk-4FFKVLBG.js → chunk-ZWGOHOGI.js} +5 -5
- package/bundle/control-channel.js +3 -3
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +3 -3
- package/bundle/preflight.js +13 -11
- package/bundle/project-panes.js +5 -5
- package/bundle/shared-types.js +1 -1
- package/bundle/workflow-resources.js +1 -1
- package/docs/configuration.md +12 -3
- package/docs/models.md +1 -1
- package/docs/observability.md +10 -2
- package/docs/tool-reference.md +5 -2
- package/docs/watchdog.md +3 -2
- package/docs/workflows.md +1 -1
- package/package.json +1 -1
- package/skills/pi-subagents/SKILL.md +1 -1
- package/src/agents/agents.d.ts +2 -0
- package/src/agents/agents.js +4 -0
- package/src/api/preflight.d.ts +1 -0
- package/src/api/preflight.js +2 -1
- package/src/extension/config.js +3 -0
- package/src/extension/public-execution.js +4 -2
- package/src/extension/reply-workflow-script.js +10 -1
- package/src/extension/schemas.d.ts +1 -0
- package/src/extension/schemas.js +2 -0
- package/src/extension/subagent-options.d.ts +2 -0
- package/src/extension/subagent-options.js +10 -4
- package/src/inspectors/herdr/project-panes.d.ts +2 -0
- package/src/inspectors/herdr/project-panes.js +7 -1
- package/src/inspectors/shell-command.d.ts +2 -1
- package/src/inspectors/shell-command.js +7 -5
- package/src/runs/background/active-async-capacity.js +2 -1
- package/src/runs/background/active-run-index.d.ts +1 -0
- package/src/runs/background/active-run-index.js +3 -0
- package/src/runs/background/async-execution.d.ts +2 -0
- package/src/runs/background/async-execution.js +6 -3
- package/src/runs/background/async-retention.js +48 -12
- package/src/runs/background/async-status.js +32 -17
- package/src/runs/background/process-terminal.d.ts +6 -0
- package/src/runs/background/process-terminal.js +34 -2
- package/src/runs/background/retained-children.js +1 -1
- package/src/runs/background/run-status.js +2 -1
- package/src/runs/background/stale-run-reconciler.d.ts +8 -0
- package/src/runs/background/stale-run-reconciler.js +38 -8
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +4 -4
- package/src/runs/foreground/execution.js +7 -9
- package/src/runs/foreground/subagent-executor.d.ts +2 -0
- package/src/runs/foreground/subagent-executor.js +129 -45
- package/src/runs/shared/fast-mode-extension.d.ts +2 -1
- package/src/runs/shared/fast-mode-extension.js +5 -3
- package/src/runs/shared/herdr-pane-host.js +10 -2
- package/src/runs/shared/mcp-config-sources.d.ts +1 -0
- package/src/runs/shared/mcp-config-sources.js +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.js +1 -0
- package/src/shared/capacity-resilient-json.d.ts +7 -3
- package/src/shared/capacity-resilient-json.js +8 -6
- package/src/shared/disabled-features.d.ts +4 -0
- package/src/shared/disabled-features.js +1 -0
- package/src/shared/types.d.ts +19 -0
- package/src/shared/types.js +2 -0
- package/src/tui/fleet-transcript.js +21 -9
- package/src/tui/fleet.js +1 -0
- package/src/watchdog/runtime.d.ts +4 -0
- package/src/watchdog/runtime.js +50 -12
- package/src/watchdog/turn-delta.d.ts +2 -0
- package/src/watchdog/turn-delta.js +21 -0
- package/src/workflows/structured-workflow-scripts.js +6 -4
- package/src/workflows/workflow-resources.js +4 -2
- package/src/workflows/workflow-revival.d.ts +6 -0
- package/src/workflows/workflow-revival.js +1 -1
package/docs/configuration.md
CHANGED
|
@@ -132,7 +132,7 @@ Pi records each tool definition and prompt section a session declares, and decla
|
|
|
132
132
|
{ "disabledFeatures": ["watchdog", "panes", "preflight", "lane-metadata", "gates"] }
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
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.
|
|
135
|
+
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, resumed runs whose saved launch enabled `share`, 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.
|
|
136
136
|
|
|
137
137
|
| Feature | Parameters removed | Actions rejected |
|
|
138
138
|
|---|---|---|
|
|
@@ -150,9 +150,10 @@ Removes feature groups you do not use from the `subagent` tool. Each listed feat
|
|
|
150
150
|
| `control-overrides` | `control` | |
|
|
151
151
|
| `extension-bindings` | `extensionBindings` | |
|
|
152
152
|
| `external-machines` | `machine` | |
|
|
153
|
+
| `session-sharing` | `share` | |
|
|
153
154
|
| `workflow-scripts` | `workflow`, `args`, `preflight`, `globalConcurrencyLimit`, `maxSubagentSpawnsPerRun` | `validate` |
|
|
154
155
|
|
|
155
|
-
Disabling a per-call option removes only the per-call override. Configured defaults such as `toolBudget`, `usageBudget`, and `control` in this file still apply, the watchdog still follows its own settings, missions still attach automatically when [`missions`](#missions) enables them, and agents with a `machine` in their definition still run there. Operator screens that do not go through the `subagent` executor, such as `/subagents-admin`, are unchanged. With every feature and [`scheduledRuns.enabled`](#scheduledruns) disabled, the default `subagent` tool declaration (name, description, and parameter schema as JSON) shrinks from 18,239 to 10,263 characters (80 to 41 parameters). Restart Pi after changing this setting. The smaller declaration applies to new sessions; a resumed session keeps the tool declaration it already sent, so its prompt cache stays valid. Disabled options and actions are still rejected in every session.
|
|
156
|
+
Disabling a per-call option removes only the per-call override. Configured defaults such as `toolBudget`, `usageBudget`, and `control` in this file still apply, the watchdog still follows its own settings, missions still attach automatically when [`missions`](#missions) enables them, and agents with a `machine` in their definition still run there. `share` is the exception: it has no configured default, so `session-sharing` removes the only path that uploads a session to a GitHub Gist. Operator screens that do not go through the `subagent` executor, such as `/subagents-admin`, are unchanged. With every feature and [`scheduledRuns.enabled`](#scheduledruns) disabled, the default `subagent` tool declaration (name, description, and parameter schema as JSON) shrinks from 18,239 to 10,263 characters (80 to 41 parameters). Restart Pi after changing this setting. The smaller declaration applies to new sessions; a resumed session keeps the tool declaration it already sent, so its prompt cache stays valid. Disabled options and actions are still rejected in every session.
|
|
156
157
|
|
|
157
158
|
### Chain and tasks without workflow scripts
|
|
158
159
|
|
|
@@ -300,6 +301,14 @@ Sets `fresh` or `fork` for every subagent launch that omits `context`. This glob
|
|
|
300
301
|
|
|
301
302
|
With `"fork"`, the setting uses the existing implicit-fork behavior. A launch starts fresh when the parent session file or current leaf is not available. `"fresh"` starts fresh even when the selected agent defaults to fork. Scheduled runs continue to set fresh context explicitly. A runner or provider that does not support fork context keeps its existing rejection behavior.
|
|
302
303
|
|
|
304
|
+
## `fastServiceTier`
|
|
305
|
+
|
|
306
|
+
```json
|
|
307
|
+
{ "fastServiceTier": "ultrafast" }
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Sets the OpenAI `service_tier` that `fast: true` requests for native OpenAI-Codex children: `"priority"` (default) or `"ultrafast"`. Whether a tier is available depends on the model and account.
|
|
311
|
+
|
|
303
312
|
## `forkContext`
|
|
304
313
|
|
|
305
314
|
```json
|
|
@@ -484,7 +493,7 @@ An explicit `subagent` call value wins over this default. Choose a value at leas
|
|
|
484
493
|
|
|
485
494
|
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.
|
|
486
495
|
|
|
487
|
-
|
|
496
|
+
Top-level workflow calls (inline, file-backed, or named) 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.
|
|
488
497
|
|
|
489
498
|
## `maxSubagentSpawnsPerSession`
|
|
490
499
|
|
package/docs/models.md
CHANGED
|
@@ -88,7 +88,7 @@ For a persistent role override:
|
|
|
88
88
|
|
|
89
89
|
## Fast mode
|
|
90
90
|
|
|
91
|
-
Set `fast: true` on a run, in agent frontmatter, or in `subagents.agentOverrides.<name>.fast` to request
|
|
91
|
+
Set `fast: true` on a run, in agent frontmatter, or in `subagents.agentOverrides.<name>.fast` to request a faster OpenAI service tier (Priority by default; see `fastServiceTier`) for supported native OpenAI-Codex children. This can use a higher quota tier or cost more. It is off by default.
|
|
92
92
|
|
|
93
93
|
Fast mode fails before launch unless the resolved model is a native `openai-codex/*` model. External runners, Anthropic models, and other providers do not use fast mode.
|
|
94
94
|
|
package/docs/observability.md
CHANGED
|
@@ -120,7 +120,7 @@ Default keys:
|
|
|
120
120
|
- `↑`/`↓` or `j`/`k` — select a child
|
|
121
121
|
- `K`/`J` (Shift+k / Shift+j) — scroll output one line
|
|
122
122
|
- `PgUp`/`PgDn` — scroll output one body viewport page (structured headers stay pinned)
|
|
123
|
-
- `x`/`Ctrl+O` — toggle tool details
|
|
123
|
+
- `x`/`Ctrl+O` — toggle tool details, including the full `bash` command (multiline commands show every line)
|
|
124
124
|
- `r` — refresh
|
|
125
125
|
- `Esc` — close
|
|
126
126
|
- `Enter` — open the selected inspectable async child through the available Inspect plugin
|
|
@@ -271,6 +271,8 @@ Lifecycle artifacts include `process-terminal-candidate.json` (private runner ev
|
|
|
271
271
|
|
|
272
272
|
A proof is `observed` only after the live parent observes the exact detached runner's `close` event and any tracked canonical-session lease is free. Children run inside the runner process, so the candidate records no separate writer processes. If the observer is unavailable, the proof is `unknown`; do not infer process exit from `endedAt`, result-file existence, PID disappearance, or lease-directory absence.
|
|
273
273
|
|
|
274
|
+
When a finished run's runner PID is confirmed dead and `process-terminal.json` is still `pending`, for example because the Pi that launched it has exited, a status read writes `process-terminal-unobserved.json` with an `unknown` proof (reason `observer-unavailable`). It never touches `process-terminal.json`; status readers report it only while `process-terminal.json` is still `pending` for the same runner, so a close that is observed later still wins.
|
|
275
|
+
|
|
274
276
|
The `subagent:process-terminal` event and RPC `ping.capabilities.processTerminalProof` expose this status. Process proof is point-in-time evidence and remains separate from execution success or stopped/non-resumable state.
|
|
275
277
|
|
|
276
278
|
### Child session events
|
|
@@ -338,7 +340,13 @@ Async events:
|
|
|
338
340
|
- `subagent:async-complete`
|
|
339
341
|
- `subagent:jobs-changed` (see [extension-api.md](extension-api.md#refresh-a-host-view-without-polling))
|
|
340
342
|
|
|
341
|
-
For regular async starts, the `subagent:async-started` payload includes redacted `task` and `goal` prompt fields. Async workflow script roots emit the same event with `mode: "workflow"` after their initial `status.json` is durable; workflow roots can omit `task`, and any included prompt fields are redacted. Their keyed children are then announced dynamically through `subagent:child-status`. Companion UI extensions can combine those hints with the authoritative live lifecycle artifacts under `asyncDir` without scraping terminal output.
|
|
343
|
+
For regular async starts, the `subagent:async-started` payload includes redacted `task` and `goal` prompt fields. Single, chain and parallel starts also include `description`: the first agent's description, or its name when it has none, never the task prompt. Async workflow script roots emit the same event with `mode: "workflow"` after their initial `status.json` is durable; workflow roots can omit `task`, and any included prompt fields are redacted. Their keyed children are then announced dynamically through `subagent:child-status`. Companion UI extensions can combine those hints with the authoritative live lifecycle artifacts under `asyncDir` without scraping terminal output.
|
|
344
|
+
|
|
345
|
+
Foreground lifecycle event:
|
|
346
|
+
|
|
347
|
+
- `task:subagent:lifecycle`
|
|
348
|
+
|
|
349
|
+
A foreground single run emits it with `status: "started"` when the child launches and `"completed"`, `"failed"` or `"aborted"` (stopped or paused) when it ends. Payload: `id` (the run id), `agent`, `description` (the agent's description, never the task prompt), `success` (terminal events only), `mode: "foreground"`, and `parentWorkflowRunId` / `workflowKey` when the run belongs to a workflow. A child detached to the background reports its terminal status when it exits. Hosts that only listen for `subagent:async-*` can use this event to show foreground runs. `subagent:foreground-complete` is unchanged.
|
|
342
350
|
|
|
343
351
|
Intercom delivery events:
|
|
344
352
|
|
package/docs/tool-reference.md
CHANGED
|
@@ -67,7 +67,7 @@ The complete plain-JSON inventory is validated before the first launch (maximum
|
|
|
67
67
|
|
|
68
68
|
## Parameter reference
|
|
69
69
|
|
|
70
|
-
The `subagent` tool schema lists `agent`, `task`, `workflow`, `args`, `async`, `model`, `cwd`, `worktree`, `output`, `action`, `id` and `
|
|
70
|
+
The `subagent` tool schema lists `agent`, `task`, `workflow`, `args`, `async`, `model`, `cwd`, `worktree`, `output`, `action`, `id`, `message` and `label` at the top level and every other field inside `options`, for example `subagent({ action: "status", id: "<run-id>", options: { view: "transcript" } })`. Management fields and the `runId`, `maxRuntimeMs` and `isolation` aliases also keep working at the top level, as in RPC payloads, slash commands, schedules and workflow `runs.run`/`runs.all` items; a field given in both places with different values is rejected.
|
|
71
71
|
|
|
72
72
|
### Target and management parameters
|
|
73
73
|
|
|
@@ -76,6 +76,7 @@ The `subagent` tool schema lists `agent`, `task`, `workflow`, `args`, `async`, `
|
|
|
76
76
|
| `options` | object | - | Management and control fields; the rows named `options.<name>` below go here. Unknown keys are rejected with the closest valid option. The same fields are also accepted at the top level. |
|
|
77
77
|
| `agent` | string | - | One direct child or agent-management target. Workflow child agents are set inside `runs.run` or `runs.all`. |
|
|
78
78
|
| `task` | string | agent default | Direct child's task; requires `agent`, excludes `action` and workflow inputs. `agent` may also select a management target. |
|
|
79
|
+
| `label` | string | task excerpt | 2-4 words naming a direct child, at most 80 characters. Names the child's session and status row and is sent as `description` in `subagent:async-started`. Each `args.tasks` item of `workflow: "parallel"` also takes a `label`. |
|
|
79
80
|
| `action` | string | - | Offline workflow `validate`, agent management (including `guide`, `children.list`, and `refine`/`refine.show`/`refine.rollback`), lane evidence (`lane.status`, `lane.recordMerge`, `lane.recordSupersession`), mission (`mission.create/list/show/update/resolve-decision/attach-run/close`), Inspect actions (`inspector.command/open/status/close`), Herdr project pane (`project.open/status/close`), status/control, reviewed `worktree.cleanup`, schedule, watchdog, or doctor action. |
|
|
80
81
|
| `options.topic` | `overview \| workflows \| agents \| missions \| observability \| tool-reference \| configuration \| models \| watchdog \| extension-api \| council`, or `<topic>/<section>` | `overview` | Packaged guide topic for `action: "guide"`. A docs topic returns its table of contents; `<topic>/<section>` returns one section. |
|
|
81
82
|
| `options.config` | object/string | - | Agent config for management create/update. |
|
|
@@ -118,7 +119,7 @@ The `subagent` tool schema lists `agent`, `task`, `workflow`, `args`, `async`, `
|
|
|
118
119
|
| `options.maxOutput` | object | none | Final output truncation limits `{ bytes?, lines? }`. For child runs it is only applied when set; there is no default cap on the inline path, so use `outputMode: "file-only"` for large outputs. For workflow script results, the Return, Emitted, and Console sections are always capped, at 200 KB / 5000 lines unless `maxOutput` sets other limits. |
|
|
119
120
|
| `options.artifacts` | boolean | true | Write debug artifacts. |
|
|
120
121
|
| `options.includeProgress` | boolean | false | Include full progress in result. |
|
|
121
|
-
| `options.share` | boolean | false | Upload session export to GitHub Gist. |
|
|
122
|
+
| `options.share` | boolean | false | Upload session export to GitHub Gist. Disable with `disabledFeatures: ["session-sharing"]`. |
|
|
122
123
|
| `options.sessionDir` | string | derived | Override session log directory. |
|
|
123
124
|
| `options.acceptance` | string/object/false | inferred | Configure evidence gates. See [Acceptance gates](#acceptance-gates). |
|
|
124
125
|
| `options.gate` | string \| object | - | One host-run verification command, shorthand for `acceptance: { level: "verified", verify: [{ id: "gate", command }] }`. The object form `{ command, output?: "json", schema?, timeoutMs? }` adds a [typed gate](#typed-gates): with `output: "json"`, a passing command's stdout becomes the child's `structuredOutput`. Also valid on individual `runs.run`/`runs.all` items. Rejects `acceptance` except `false` (treated as omitted), rejects retained `resume`, and `output: "json"` rejects `outputSchema`. |
|
|
@@ -551,6 +552,8 @@ Intentionally unsupported: native Pi child options such as model override, struc
|
|
|
551
552
|
|
|
552
553
|
Pass `share: true` to export a full session to HTML, upload it to a secret GitHub Gist through your `gh` credentials, and return a `https://shittycodingagent.ai/session/?<gistId>` URL.
|
|
553
554
|
|
|
555
|
+
A secret Gist is unlisted, not private: anyone with the link can read it, and nothing asks before the upload, so treat `share: true` as publishing. With `context: "fork"`, the parent conversation is included. Setting `disabledFeatures: ["session-sharing"]` turns sharing off for an install.
|
|
556
|
+
|
|
554
557
|
```js workflow
|
|
555
558
|
return runs.run("main", { agent: "scout", task: "..." });
|
|
556
559
|
```
|
package/docs/watchdog.md
CHANGED
|
@@ -69,8 +69,9 @@ Child watchdog findings are lifted into the parent in three ways:
|
|
|
69
69
|
|
|
70
70
|
## What the reviewer is given
|
|
71
71
|
|
|
72
|
-
- **Turn delta** with changed repo paths. Over-long input keeps the first 6,000 characters and the tail.
|
|
72
|
+
- **Turn delta** with changed repo paths. Over-long input keeps up to the first 6,000 characters and the tail. Whenever any of the run's turn text was left out to fit (whole turns dropped, or one long turn or the delta cut), the delta starts with a note saying how much, and the reviewer is told not to report an instruction as missing when it may be in an omitted part.
|
|
73
73
|
- **Current scope** (`scope.enabled`, default on): bounded real user prompts. Side questions are additive; only explicit changes supersede older requirements. Scope survives compaction within the current session.
|
|
74
|
+
- **Supervisor replies** (with scope, child watchdogs): paired `contact_supervisor` decision and interview requests with their non-error replies, kept outside the turn delta so a long run cannot drop them. Each entry is bounded to 3,000 characters, with a 6,000-character recent tail kept for the session like scope.
|
|
74
75
|
- **`watchdog_diff`** when inside git: diff since the session-start commit, including later commits, plus untracked paths to inspect with `read`; accepts `path` and `stat:true`.
|
|
75
76
|
- **`WATCHDOG.md`** standing instructions, read fresh on every review: `<project>/.pi/WATCHDOG.md` first, then `~/.pi/agent/WATCHDOG.md`, capped at 8,000 characters. Set `guidance.watchdogMd: false` to ignore them.
|
|
76
77
|
- **LSP diagnostics** from `typescript-language-server`, auto-detected in `node_modules/.bin` or `PATH`; it is never installed and never run over the whole workspace. Errors become blockers, warnings concerns, and info/hints stay in status.
|
|
@@ -122,7 +123,7 @@ With this opt-in, completed `turn_end` events retain a recent actual-activity ta
|
|
|
122
123
|
|
|
123
124
|
New unreviewed activity permits at most one additional boundary review per user prompt even with no local edit. Side questions keep earlier authorized task evidence available; they do not themselves trigger a model call. Activity gathered after that prompt's extra review remains available for the next prompt. Warning continuations cannot supply fresh triggering activity. No polling, task scheduling, cross-worktree scans or idle calls are added.
|
|
124
125
|
|
|
125
|
-
**Visibility limit:** external task/gate completions are visible when returned through those parent tool results. Standalone native completion notifications, arbitrary custom messages, direct shell/CI output, and events not delivered to the parent through these contracts are not ingested by this activity tail. Existing scope retains at most eight prompts (2,000 characters each); new streaming user input cancels an active review
|
|
126
|
+
**Visibility limit:** external task/gate completions are visible when returned through those parent tool results. Standalone native completion notifications, arbitrary custom messages, direct shell/CI output, and events not delivered to the parent through these contracts are not ingested by this activity tail. Existing scope retains at most eight prompts (2,000 characters each); new streaming user input cancels an active review and is added to scope. Reminders depend on retained evidence and model judgment, not an exhaustive view of running work.
|
|
126
127
|
|
|
127
128
|
Set `subagents.watchdog.clarification: true` in Pi settings alongside `enabled: true`. It defaults to `false` and applies **only to the main watchdog**, not child watchdogs or child permission arbitration.
|
|
128
129
|
|
package/docs/workflows.md
CHANGED
|
@@ -145,7 +145,7 @@ subagent({ workflow: "parallel", args: { tasks: [{ agent: "reviewer", task: "Rev
|
|
|
145
145
|
|
|
146
146
|
The host resolves the name and validates bounded plain-JSON `args` before starting the workflow. Resource provenance is recorded in workflow details and receipts for downstream permission/policy checks. Resource authority is not caller-supplied: `runs.host` is available only when the resolved resource explicitly grants the requested host key and command. Reply-block (`workflow: true`) and file-path scripts remain raw, unknown-provenance inputs, so their `runs.host` calls are unavailable through the public execution boundary. Named resources cannot be combined with `agent` or `task`; the package ships the `review`, `run-ci` and `parallel` resources, not a user/project resource registry.
|
|
147
147
|
|
|
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.
|
|
148
|
+
`parallel` runs independent children together without writing a script: `args.tasks` is a list of `{ agent, task, cwd?, model?, label? }` 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.
|
|
149
149
|
|
|
150
150
|
### Approving workflow children in permission extensions
|
|
151
151
|
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ does the work itself where that is cheaper.
|
|
|
23
23
|
|
|
24
24
|
```typescript
|
|
25
25
|
subagent({ agent: "worker", task: "<brief>" }) // one child; async by default
|
|
26
|
-
subagent({ workflow: "parallel", args: { tasks: [{ agent, task, cwd?, model? }] } }) // independent children
|
|
26
|
+
subagent({ workflow: "parallel", args: { tasks: [{ agent, task, cwd?, model?, label? }] } }) // independent children
|
|
27
27
|
subagent({ workflow: true }) // runs the one ```js workflow block in this same reply
|
|
28
28
|
subagent({ workflow: "./lane.js", args }) // script file, path relative to the request cwd
|
|
29
29
|
subagent({ action: "validate", workflow: "./lane.js" }) // check a script without launching
|
package/src/agents/agents.d.ts
CHANGED
|
@@ -238,6 +238,8 @@ export declare function unknownAgentDiagnosticContext(discovered: Pick<AgentDisc
|
|
|
238
238
|
export declare const MAX_LISTED_AGENTS = 30;
|
|
239
239
|
/** One line per agent the caller can launch instead, so a wrong name needs no separate list call. */
|
|
240
240
|
export declare function formatAvailableAgentLines(agents: readonly AgentConfig[]): string[];
|
|
241
|
+
/** What a run is called in lifecycle events: its launch label, else the agent's description, else the agent name. */
|
|
242
|
+
export declare function agentRunDescription<Name extends string | undefined>(agentName: Name, agent: AgentConfig | undefined, label?: string): string | Name;
|
|
241
243
|
/** The closest agent name or alias when `name` looks like a typo of one. */
|
|
242
244
|
export declare function suggestAgentName(name: string, agents: readonly AgentConfig[]): string | undefined;
|
|
243
245
|
/** Render local discovery evidence without exposing filesystem error details. */
|
package/src/agents/agents.js
CHANGED
|
@@ -98,6 +98,10 @@ export function formatAvailableAgentLines(agents) {
|
|
|
98
98
|
lines.push(`+${sorted.length - MAX_LISTED_AGENTS} more; {action:"list", options:{search:"<term>"}}`);
|
|
99
99
|
return lines.length ? lines : ["- (none)"];
|
|
100
100
|
}
|
|
101
|
+
/** What a run is called in lifecycle events: its launch label, else the agent's description, else the agent name. */
|
|
102
|
+
export function agentRunDescription(agentName, agent, label) {
|
|
103
|
+
return label ?? (agent?.description?.trim() || agentName);
|
|
104
|
+
}
|
|
101
105
|
/** The closest agent name or alias when `name` looks like a typo of one. */
|
|
102
106
|
export function suggestAgentName(name, agents) {
|
|
103
107
|
return closestMatch(name.trim(), new Set(agents.flatMap((agent) => [agent.name, ...(agent.localName ? [agent.localName] : []), ...(agent.aliases ?? [])])));
|
package/src/api/preflight.d.ts
CHANGED
package/src/api/preflight.js
CHANGED
|
@@ -22,7 +22,7 @@ import { loadConfig } from "../extension/config.js";
|
|
|
22
22
|
import { applyIntercomBridgeToAgent, resolveIntercomBridge, validateIntercomBridgeConfig } from "../intercom/intercom-bridge.js";
|
|
23
23
|
import { AGENT_DEFINITION_PROJECTION_VERSION, resolveLaunchBinding, stableJsonDigest } from "../shared/launch-contract.js";
|
|
24
24
|
import { DIRS, TEMP_ROOT_DIR } from "../shared/types.js";
|
|
25
|
-
import { processTerminalCandidatePath, processTerminalPath } from "../runs/background/process-terminal.js";
|
|
25
|
+
import { processTerminalCandidatePath, processTerminalPath, unobservedRunnerExitPath } from "../runs/background/process-terminal.js";
|
|
26
26
|
import { resultFilePath } from "../runs/background/result-files.js";
|
|
27
27
|
import { nestedResultsPath } from "../runs/shared/nested-events.js";
|
|
28
28
|
import { normalizeExtensionBindings } from "../runs/shared/extension-bindings.js";
|
|
@@ -398,6 +398,7 @@ export async function resolveSubagentLaunchContract(input) {
|
|
|
398
398
|
eventsPath: path.join(lifecycleAsyncDir, "events.jsonl"),
|
|
399
399
|
processTerminalPath: processTerminalPath(lifecycleAsyncDir),
|
|
400
400
|
processTerminalCandidatePath: processTerminalCandidatePath(lifecycleAsyncDir),
|
|
401
|
+
unobservedRunnerExitPath: unobservedRunnerExitPath(lifecycleAsyncDir),
|
|
401
402
|
},
|
|
402
403
|
},
|
|
403
404
|
protocol: {
|
package/src/extension/config.js
CHANGED
|
@@ -211,6 +211,9 @@ function validateConfig(config) {
|
|
|
211
211
|
if (config.asyncWidgetLayout !== undefined && config.asyncWidgetLayout !== "adaptive" && config.asyncWidgetLayout !== "rows") {
|
|
212
212
|
throw new Error('config.asyncWidgetLayout must be "adaptive" or "rows"');
|
|
213
213
|
}
|
|
214
|
+
if (config.fastServiceTier !== undefined && config.fastServiceTier !== "priority" && config.fastServiceTier !== "ultrafast") {
|
|
215
|
+
throw new Error('config.fastServiceTier must be "priority" or "ultrafast"');
|
|
216
|
+
}
|
|
214
217
|
if (config.programStatus !== undefined && typeof config.programStatus !== "boolean") {
|
|
215
218
|
throw new Error("config.programStatus must be a boolean");
|
|
216
219
|
}
|
|
@@ -76,8 +76,10 @@ export function normalizePublicSubagentExecution(params, options = {}) {
|
|
|
76
76
|
return { ok: false, error: capacityOverrideError, mode: params.action === undefined ? "workflow" : "management" };
|
|
77
77
|
const validatesSpawnBudget = typeof params.action === "string" && params.action.trim() === "validate"
|
|
78
78
|
&& params.globalConcurrencyLimit === undefined && params.maxSubagentSpawnsPerRun !== undefined;
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
// A named workflow runs as a generated script, so it takes the same concurrency cap (#3320).
|
|
80
|
+
const namedConcurrencyLimit = hasNamedWorkflow && params.maxSubagentSpawnsPerRun === undefined;
|
|
81
|
+
if ((params.action !== undefined && !validatesSpawnBudget) || (!hasRawScript && !namedConcurrencyLimit)) {
|
|
82
|
+
return { ok: false, error: `Workflow capacity overrides are only supported on top-level ${RAW_SCRIPT_FORMS} calls; named workflow calls accept globalConcurrencyLimit only; validate accepts maxSubagentSpawnsPerRun for static budget checks.`, mode: params.action === undefined ? "workflow" : "management" };
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
if (params.preflight !== undefined && !hasWorkflowInput) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isUnsetPlaceholder } from "./subagent-options.js";
|
|
1
2
|
const WORKFLOW_FENCE = /^```(?:js|javascript) workflow[ \t]*$/;
|
|
2
3
|
const PLAIN_JS_FENCE = /^```(?:js|javascript)[ \t]*$/;
|
|
3
4
|
const OPEN_FENCE = /^(`{3,}|~{3,})/;
|
|
@@ -41,9 +42,17 @@ function earlierTurnHasJsBlock(branch, callIndex) {
|
|
|
41
42
|
}
|
|
42
43
|
return false;
|
|
43
44
|
}
|
|
45
|
+
/** Whether flattenSubagentToolOptions will read this call's options.script, which it does after dropping "null" placeholders. */
|
|
46
|
+
function hasOptionsScript(options) {
|
|
47
|
+
if (typeof options !== "object" || options === null || Array.isArray(options))
|
|
48
|
+
return false;
|
|
49
|
+
const script = options.script;
|
|
50
|
+
return script !== undefined && !isUnsetPlaceholder(script);
|
|
51
|
+
}
|
|
44
52
|
function scriptFromReply(content, earlierBlock) {
|
|
53
|
+
// A call that also passes options.script runs that script, not the reply's block (#3320).
|
|
45
54
|
const replyCalls = content.filter((block) => block.type === "toolCall" && block.name === "subagent"
|
|
46
|
-
&& (block.arguments?.workflow === true || block.arguments?.workflow === "true")).length;
|
|
55
|
+
&& (block.arguments?.workflow === true || block.arguments?.workflow === "true") && !hasOptionsScript(block.arguments?.options)).length;
|
|
47
56
|
if (replyCalls > 1)
|
|
48
57
|
return { error: `This reply has ${replyCalls} subagent calls with workflow: true; a reply can carry only one. Pass other scripts as workflow file paths.` };
|
|
49
58
|
if (!content.some((block) => block.type === "text")) {
|
|
@@ -274,6 +274,7 @@ export declare const SubagentParams: Type.TObject<{
|
|
|
274
274
|
id: Type.TOptional<Type.TString>;
|
|
275
275
|
message: Type.TOptional<Type.TString>;
|
|
276
276
|
options: Type.TOptional<Type.TUnsafe<Record<string, unknown>>>;
|
|
277
|
+
label: Type.TOptional<Type.TString>;
|
|
277
278
|
}>;
|
|
278
279
|
export declare function createSubagentParamsSchema(disabled?: DisabledFeatureSurface): typeof SubagentParams;
|
|
279
280
|
export declare const SubagentWaitParams: Type.TObject<{
|
package/src/extension/schemas.js
CHANGED
|
@@ -272,6 +272,8 @@ export const SubagentOptionParams = Type.Object(SubagentOptionProperties, { addi
|
|
|
272
272
|
const ModelTopLevelProperties = {
|
|
273
273
|
agent, task, workflow, args, async, model, cwd, worktree, output, action, id, message,
|
|
274
274
|
options: Type.Optional(Type.Unsafe({ type: "object", additionalProperties: true, description: "Every field not listed here, such as acceptance, timeoutMs, context, view and index; guide tool-reference/parameter-reference." })),
|
|
275
|
+
// Appended after options so the earlier fields keep their order.
|
|
276
|
+
label: Type.Optional(Type.String({ minLength: 1, maxLength: 80, description: "2-4 words on what it does; appears wherever the run is listed." })),
|
|
275
277
|
};
|
|
276
278
|
export const SubagentParams = keepTopLevelParameterDescriptions(Type.Object(ModelTopLevelProperties));
|
|
277
279
|
// Replaces workflow scripts when disabledFeatures lists "workflow-scripts". Kept small because every
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { SubagentParamsLike } from "../runs/foreground/subagent-executor.ts";
|
|
2
2
|
import type { DisabledFeatureSurface } from "../shared/disabled-features.ts";
|
|
3
|
+
/** Some models fill every unset optional parameter with the string "null" (#3285); it means the field was left out. */
|
|
4
|
+
export declare function isUnsetPlaceholder(value: unknown): boolean;
|
|
3
5
|
/**
|
|
4
6
|
* Lowers a model tool call's `options` into the flat params the executor reads.
|
|
5
7
|
* Management fields given at the top level keep working, as in the flat shape older sessions declared.
|
|
@@ -7,15 +7,19 @@ import { SUBAGENT_OPTION_KEYS, SubagentOptionParams, createSubagentParamsSchema
|
|
|
7
7
|
const optionKeys = new Set(SUBAGENT_OPTION_KEYS);
|
|
8
8
|
const ALIAS_HINTS = { runId: "id (top-level)", maxRuntimeMs: "options.timeoutMs", isolation: "worktree (top-level)" };
|
|
9
9
|
const optionsValidator = Compile(SubagentOptionParams);
|
|
10
|
+
/** Some models fill every unset optional parameter with the string "null" (#3285); it means the field was left out. */
|
|
11
|
+
export function isUnsetPlaceholder(value) {
|
|
12
|
+
return value === "null";
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* Lowers a model tool call's `options` into the flat params the executor reads.
|
|
12
16
|
* Management fields given at the top level keep working, as in the flat shape older sessions declared.
|
|
13
17
|
*/
|
|
14
18
|
export function flattenSubagentToolOptions(params, disabled) {
|
|
15
19
|
// Some models fill every unset optional parameter with the string "null", and the workflow union with "false" (#3285).
|
|
16
|
-
params = Object.fromEntries(Object.entries(params).filter(([key, value]) => value
|
|
20
|
+
params = Object.fromEntries(Object.entries(params).filter(([key, value]) => !isUnsetPlaceholder(value) && !(key === "workflow" && value === "false")));
|
|
17
21
|
if (params.options && typeof params.options === "object" && !Array.isArray(params.options)) {
|
|
18
|
-
params.options = Object.fromEntries(Object.entries(params.options).filter(([, value]) => value
|
|
22
|
+
params.options = Object.fromEntries(Object.entries(params.options).filter(([, value]) => !isUnsetPlaceholder(value)));
|
|
19
23
|
}
|
|
20
24
|
const removedTopLevel = removedModelWorkflowFieldError(params);
|
|
21
25
|
if (removedTopLevel)
|
|
@@ -33,9 +37,11 @@ export function flattenSubagentToolOptions(params, disabled) {
|
|
|
33
37
|
if (script !== undefined) {
|
|
34
38
|
if (typeof script !== "string" || !script.trim())
|
|
35
39
|
throw new Error("subagent: options.script must be the workflow script's source text.");
|
|
36
|
-
|
|
40
|
+
// workflow: true also means "the script is inline", so it adds nothing next to options.script (#3320).
|
|
41
|
+
const { workflow, ...withoutWorkflow } = topLevel;
|
|
42
|
+
if (workflow !== undefined && workflow !== true && workflow !== "true")
|
|
37
43
|
throw new Error("subagent: options.script replaces workflow; pass only one of them.");
|
|
38
|
-
return { ...flattenSubagentToolOptions({ ...
|
|
44
|
+
return { ...flattenSubagentToolOptions({ ...withoutWorkflow, options: rest }, disabled), workflowScript: script };
|
|
39
45
|
}
|
|
40
46
|
const entries = Object.entries(options);
|
|
41
47
|
const enabledKeys = SUBAGENT_OPTION_KEYS.filter((key) => !disabled?.params.has(key));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import type { Details, SubagentState } from "../../shared/types.ts";
|
|
3
3
|
import { type HerdrClient, type HerdrErrorCode } from "./client.ts";
|
|
4
|
+
import { type ShellFlavor } from "../shell-command.ts";
|
|
4
5
|
export declare const HERDR_PROJECT_PANE_ACTIONS: readonly ["project.open", "project.status", "project.close"];
|
|
5
6
|
export type HerdrProjectPaneAction = typeof HERDR_PROJECT_PANE_ACTIONS[number];
|
|
6
7
|
/** Versioned public contract exported through `pi-subagents/project-panes`. */
|
|
@@ -127,6 +128,7 @@ export declare function readHerdrProjectPaneBinding(projectRoot: string): HerdrP
|
|
|
127
128
|
/** Strict public reader for extension integrations. */
|
|
128
129
|
export declare function readProjectPaneBinding(projectRoot: string): ProjectPaneResult<HerdrProjectPaneBinding | undefined>;
|
|
129
130
|
export declare function restoreHerdrProjectPaneSnapshots(state: SubagentState, projectRoots: Iterable<string>, now?: number): void;
|
|
131
|
+
export declare function projectPaneShellFlavor(platform: NodeJS.Platform, shell: string | undefined): ShellFlavor;
|
|
130
132
|
export declare function createProjectPaneManager(options?: ProjectPaneManagerOptions): ProjectPaneManager;
|
|
131
133
|
export declare function openProjectPane(options: OpenProjectPaneOptions): Promise<ProjectPaneResult<OpenProjectPaneData>>;
|
|
132
134
|
export declare function getProjectPaneStatus(options: GetProjectPaneStatusOptions): Promise<ProjectPaneResult<ProjectPaneStatusData>>;
|
|
@@ -254,10 +254,16 @@ async function inspectPane(client, paneId, signal) {
|
|
|
254
254
|
return projectPaneError("INVALID_PANE_RESPONSE", `Herdr pane get returned no pane runtime for '${paneId}'.`, { details: live.data });
|
|
255
255
|
return { ok: true, data: runtime };
|
|
256
256
|
}
|
|
257
|
+
export function projectPaneShellFlavor(platform, shell) {
|
|
258
|
+
// Herdr types the command into the pane's own shell: Git Bash on Windows cannot parse PowerShell's `&` call operator.
|
|
259
|
+
if (platform !== "win32")
|
|
260
|
+
return "auto";
|
|
261
|
+
return /(^|[\\/])(bash|zsh|sh|dash|ksh)(\.exe)?$/i.test(shell ?? "") ? "posix" : "auto";
|
|
262
|
+
}
|
|
257
263
|
function projectPaneCommand(message) {
|
|
258
264
|
const args = message?.trim() ? [message.trim()] : [];
|
|
259
265
|
const command = getPiSpawnCommand(args);
|
|
260
|
-
return formatShellCommand(command.command, command.args);
|
|
266
|
+
return formatShellCommand(command.command, command.args, process.platform, projectPaneShellFlavor(process.platform, process.env.SHELL));
|
|
261
267
|
}
|
|
262
268
|
function canonicalRuntimePath(value) {
|
|
263
269
|
if (!value)
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ShellFlavor = "auto" | "posix";
|
|
2
|
+
export declare function formatShellCommand(exe: string, args: readonly string[], platform?: NodeJS.Platform, flavor?: ShellFlavor): string;
|
|
@@ -6,11 +6,13 @@ function shellQuote(value, platform) {
|
|
|
6
6
|
function isBareExecutable(value) {
|
|
7
7
|
return /^[\w./@:-]+$/.test(value);
|
|
8
8
|
}
|
|
9
|
-
export function formatShellCommand(exe, args, platform = process.platform) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export function formatShellCommand(exe, args, platform = process.platform, flavor = "auto") {
|
|
10
|
+
const posix = flavor === "posix" || (flavor === "auto" && platform !== "win32");
|
|
11
|
+
const quotePlatform = posix ? "linux" : platform;
|
|
12
|
+
const quotedArgs = args.map((arg) => shellQuote(arg, quotePlatform));
|
|
13
|
+
if (!posix)
|
|
14
|
+
return `& ${[shellQuote(exe, quotePlatform), ...quotedArgs].join(" ")}`;
|
|
13
15
|
// Nushell treats a leading quoted token as a string, so use a bare invoker for paths that need quoting.
|
|
14
|
-
const invocation = isBareExecutable(exe) ? exe : `sh -c 'exec "$0" "$@"' ${shellQuote(exe,
|
|
16
|
+
const invocation = isBareExecutable(exe) ? exe : `sh -c 'exec "$0" "$@"' ${shellQuote(exe, quotePlatform)}`;
|
|
15
17
|
return [invocation, ...quotedArgs].join(" ");
|
|
16
18
|
}
|
|
@@ -8,7 +8,8 @@ import { checkPidLiveness, checkRecordedPidLiveness } from "./stale-run-reconcil
|
|
|
8
8
|
import { currentBootId } from "./boot-id.js";
|
|
9
9
|
import { currentPidNamespaceScope } from "./pid-namespace.js";
|
|
10
10
|
import { readProcessTerminal } from "./process-terminal.js";
|
|
11
|
-
import {
|
|
11
|
+
import { readWorkflowChildEvidence, readWorkflowChildProcessEvidence } from "./workflow-terminal-proof.js";
|
|
12
|
+
import { isTerminalAsyncState as terminalState } from "./active-run-index.js";
|
|
12
13
|
export const ACTIVE_ASYNC_CAPACITY_DIR = path.join(TEMP_ROOT_DIR, "session-active-async-capacity");
|
|
13
14
|
export const DEFAULT_ABANDONED_SLOT_RELEASE_AFTER_MS = 20 * 60 * 1000;
|
|
14
15
|
export const MIN_ABANDONED_SLOT_RELEASE_AFTER_MS = 5 * 60 * 1000;
|
|
@@ -2,6 +2,7 @@ import type { AsyncStatus } from "../../shared/types.ts";
|
|
|
2
2
|
export declare const ACTIVE_RUN_INDEX_DIR = ".active-runs";
|
|
3
3
|
export declare const DEFAULT_STALE_TERMINAL_ACTIVE_MARKER_MS: number;
|
|
4
4
|
export declare function isActiveAsyncState(state: AsyncStatus["state"]): boolean;
|
|
5
|
+
export declare function isTerminalAsyncState(state: AsyncStatus["state"]): state is Exclude<AsyncStatus["state"], "queued" | "running" | "paused">;
|
|
5
6
|
export declare function releaseActiveRunIndex(asyncDir: string): void;
|
|
6
7
|
export declare function updateActiveRunIndex(asyncDir: string, state: AsyncStatus["state"], toolCallId?: string, options?: {
|
|
7
8
|
retryCapacityErrors?: boolean;
|
|
@@ -34,6 +34,9 @@ function removeEmptyAncestors(start, stop) {
|
|
|
34
34
|
export function isActiveAsyncState(state) {
|
|
35
35
|
return state === "queued" || state === "running";
|
|
36
36
|
}
|
|
37
|
+
export function isTerminalAsyncState(state) {
|
|
38
|
+
return state !== "queued" && state !== "running" && state !== "paused";
|
|
39
|
+
}
|
|
37
40
|
function releaseToolCallAliases(asyncDir) {
|
|
38
41
|
const root = path.join(indexDir(path.dirname(asyncDir)), TOOL_CALL_INDEX_DIR);
|
|
39
42
|
let entries;
|
|
@@ -195,6 +195,8 @@ interface AsyncSingleParams {
|
|
|
195
195
|
runFanoutBudget?: RunFanoutBudgetDescriptor;
|
|
196
196
|
parentWorkflowRunId?: string;
|
|
197
197
|
workflowKey?: string;
|
|
198
|
+
/** Launch or workflow child label; names the child session and its status step. */
|
|
199
|
+
label?: string;
|
|
198
200
|
lane?: WorkflowLaneMetadata;
|
|
199
201
|
workflowAwaitAsync?: boolean;
|
|
200
202
|
activeAsyncCapacity?: ActiveAsyncCapacityHandle;
|
|
@@ -4,7 +4,7 @@ import * as fs from "node:fs";
|
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import * as nodeModule from "node:module";
|
|
7
|
-
import { discoverAgents, formatUnknownAgentError, unknownAgentDiagnosticContext } from "../../agents/agents.js";
|
|
7
|
+
import { agentRunDescription, discoverAgents, formatUnknownAgentError, unknownAgentDiagnosticContext } from "../../agents/agents.js";
|
|
8
8
|
import { createAtomicJsonWriter, writePrivateAtomicJson } from "../../shared/atomic-json.js";
|
|
9
9
|
import { childCacheRetentionEnv } from "../../shared/child-cache-retention.js";
|
|
10
10
|
import { buildEffectiveSystemPrompt } from "../shared/effective-system-prompt.js";
|
|
@@ -588,7 +588,7 @@ function spawnRunner(cfg, suffix, cwd, initialStatus, initialStatusPath, launchP
|
|
|
588
588
|
// Diagnostic only; process-terminal proof stays authoritative.
|
|
589
589
|
}
|
|
590
590
|
// The runner may outlive its wrapper; only a confirmed-dead runner in this pid namespace finalizes here,
|
|
591
|
-
// otherwise status
|
|
591
|
+
// otherwise a later status read in the runner's pid namespace records the proof as unknown once its pid is dead.
|
|
592
592
|
if (!runnerIdentity || runnerIdentity.pidNamespaceScope !== currentPidNamespaceScope()
|
|
593
593
|
|| checkRecordedPidLiveness(runnerIdentity) !== "dead")
|
|
594
594
|
return;
|
|
@@ -1551,6 +1551,7 @@ export function executeAsyncChain(id, params) {
|
|
|
1551
1551
|
completionOwnerId: ctx.completionOwnerId ?? currentCompletionOwnerId(),
|
|
1552
1552
|
mode: resultMode,
|
|
1553
1553
|
agent: firstAgents[0],
|
|
1554
|
+
description: agentRunDescription(firstAgents[0], agents.find((candidate) => candidate.name === firstAgents[0])),
|
|
1554
1555
|
agents: flatAgents,
|
|
1555
1556
|
task: firstTask?.trim() ? PROMPT_REDACTED : undefined,
|
|
1556
1557
|
goal: workflowGoal?.trim() ? PROMPT_REDACTED : undefined,
|
|
@@ -1970,6 +1971,7 @@ export function executeAsyncSingle(id, params) {
|
|
|
1970
1971
|
...(capabilityCeiling ? { capabilityCeiling } : {}),
|
|
1971
1972
|
agent,
|
|
1972
1973
|
task: taskText,
|
|
1974
|
+
...(params.label ? { label: params.label } : {}),
|
|
1973
1975
|
...(agentConfig.runner ? { runner: agentConfig.runner } : {}),
|
|
1974
1976
|
...(singleClaudeCodeOverride ? { claudeCodeOverrideArgs: singleClaudeCodeOverride.args } : {}),
|
|
1975
1977
|
...(machine ? { machine } : {}),
|
|
@@ -2092,7 +2094,7 @@ export function executeAsyncSingle(id, params) {
|
|
|
2092
2094
|
chainStepCount: 1,
|
|
2093
2095
|
...(lane ? { lane } : {}),
|
|
2094
2096
|
...(launcher ? { launcher } : {}),
|
|
2095
|
-
steps: [{ agent, status: "pending", ...(lane ? { lane } : {}), ...(model ? { model } : {}), ...(contextLimit !== undefined ? { contextLimit } : {}) }],
|
|
2097
|
+
steps: [{ agent, status: "pending", ...(params.label ? { label: params.label } : {}), ...(lane ? { lane } : {}), ...(model ? { model } : {}), ...(contextLimit !== undefined ? { contextLimit } : {}) }],
|
|
2096
2098
|
}, path.join(asyncDir, "status.json"), launchParentSessionId, (proof) => emitProcessTerminalEvent(ctx, proof), (runnerProcessInstanceId) => params.activeAsyncCapacity?.markStarted(runnerProcessInstanceId), params.requestedCwd ?? runnerCwd);
|
|
2097
2099
|
}
|
|
2098
2100
|
catch (error) {
|
|
@@ -2162,6 +2164,7 @@ export function executeAsyncSingle(id, params) {
|
|
|
2162
2164
|
mode: "single",
|
|
2163
2165
|
...(params.toolCallId ? { toolCallId: params.toolCallId } : {}),
|
|
2164
2166
|
agent,
|
|
2167
|
+
description: agentRunDescription(agent, agentConfig, params.label),
|
|
2165
2168
|
task: task?.trim() ? PROMPT_REDACTED : undefined,
|
|
2166
2169
|
goal: (params.goal ?? task).trim() ? PROMPT_REDACTED : undefined,
|
|
2167
2170
|
cwd: runnerCwd,
|