pi-subagents 0.89.2 → 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 +28 -0
- package/bundle/agents.js +4 -4
- package/bundle/child-tool-plan.js +3 -3
- package/bundle/{chunk-U753SUBC.js → chunk-2LEBXCLU.js} +29 -19
- package/bundle/{chunk-UUW7P6KJ.js → chunk-37EJGDYO.js} +2 -2
- package/bundle/{chunk-ME4IS3Y3.js → chunk-4DA22WRU.js} +58 -29
- package/bundle/{chunk-77VQEATI.js → chunk-5J2RTMKW.js} +2 -2
- package/bundle/{chunk-UBPAMRVL.js → chunk-7HPZIT4W.js} +13 -13
- package/bundle/{chunk-SWGB2P5J.js → chunk-7Y4IJMCW.js} +1 -1
- package/bundle/{chunk-DGLXVN3F.js → chunk-ACTHBJUI.js} +1 -1
- package/bundle/{chunk-76WVWEFE.js → chunk-AJWRYQPH.js} +134 -74
- package/bundle/{chunk-TXC7WIPL.js → chunk-C45WQQZX.js} +1 -1
- package/bundle/{chunk-YJIU5WF4.js → chunk-CPWZN5KM.js} +1 -1
- package/bundle/{chunk-RHKIP45B.js → chunk-DNJ2GHSI.js} +6 -6
- package/bundle/{chunk-DYBRIEIF.js → chunk-EBGTTJKP.js} +6 -6
- package/bundle/{chunk-LWH7IGI3.js → chunk-F4NSLXB2.js} +8 -6
- package/bundle/{chunk-FO2GIU5F.js → chunk-G43SW4BT.js} +11 -10
- 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-2UCFLUE4.js → chunk-RIBMW6V3.js} +9 -7
- package/bundle/{chunk-DHY5TY2Y.js → chunk-SIB2GQHL.js} +3 -3
- package/bundle/{chunk-JEZOSEWG.js → chunk-SRWJIAIP.js} +2 -0
- package/bundle/{chunk-JEYG7CNC.js → chunk-UC22RDXP.js} +2 -2
- package/bundle/{chunk-W2BZS6UC.js → chunk-VMJGZHUL.js} +9 -5
- package/bundle/{chunk-FF5K5HQU.js → chunk-WANQBKAZ.js} +5 -5
- package/bundle/{chunk-KA4MKMYT.js → chunk-WHHRG32M.js} +27 -20
- package/bundle/{chunk-464OJSDP.js → chunk-XIQKWTFY.js} +5 -5
- package/bundle/{chunk-4KQW5R6U.js → chunk-XYIVVS3A.js} +7 -3
- package/bundle/{chunk-AHGJSJYY.js → chunk-YVDKGAEO.js} +2 -2
- package/bundle/{chunk-SRCMJY4F.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 +9 -9
- package/bundle/project-panes.js +4 -4
- 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 +7 -1
- package/docs/tool-reference.md +5 -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/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/runs/background/async-execution.d.ts +1 -1
- package/src/runs/background/async-execution.js +3 -1
- package/src/runs/background/async-retention.js +48 -12
- package/src/runs/background/async-status.js +32 -17
- package/src/runs/background/retained-children.js +1 -1
- package/src/runs/foreground/execution.js +5 -7
- package/src/runs/foreground/subagent-executor.d.ts +1 -1
- package/src/runs/foreground/subagent-executor.js +122 -47
- package/src/runs/shared/fast-mode-extension.d.ts +2 -1
- package/src/runs/shared/fast-mode-extension.js +5 -3
- 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 +18 -1
- package/src/shared/types.js +2 -0
- package/src/tui/fleet.js +1 -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildWorkflowChatProgressRows
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XIQKWTFY.js";
|
|
4
4
|
import {
|
|
5
5
|
aggregateStepStatus,
|
|
6
6
|
contextModeBadge,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
projectAsyncWorkflowRows,
|
|
23
23
|
projectWorkflowChecklist,
|
|
24
24
|
workflowGraphStageNodes
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-2LEBXCLU.js";
|
|
26
26
|
import {
|
|
27
27
|
isStaleExtensionContextError,
|
|
28
28
|
isUnboundExtensionRuntimeError,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
formatWorkflowJsonPreview,
|
|
35
35
|
hostStepReportName,
|
|
36
36
|
hostStepVerdictLabel
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-SIB2GQHL.js";
|
|
38
38
|
import {
|
|
39
39
|
snapshotExternalRuns
|
|
40
40
|
} from "./chunk-UKG4V45O.js";
|
|
@@ -52,12 +52,12 @@ import {
|
|
|
52
52
|
getSingleResultOutput,
|
|
53
53
|
shortenPath,
|
|
54
54
|
unresolvedChildWatchdogBlockers
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-F4NSLXB2.js";
|
|
56
56
|
import {
|
|
57
57
|
MAX_WIDGET_JOBS,
|
|
58
58
|
WIDGET_ANIMATION_INTERVAL_MS,
|
|
59
59
|
WIDGET_KEY
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-SRWJIAIP.js";
|
|
61
61
|
import {
|
|
62
62
|
previewDisplayText,
|
|
63
63
|
sanitizeDisplayText,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
requestAsyncStop
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-37EJGDYO.js";
|
|
4
4
|
import "./chunk-NIXWDZZV.js";
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-F4NSLXB2.js";
|
|
6
|
+
import "./chunk-SRWJIAIP.js";
|
|
7
7
|
import "./chunk-YFCK7H2S.js";
|
|
8
8
|
import "./chunk-QXASAHIA.js";
|
|
9
9
|
export {
|
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-7HPZIT4W.js")).default : process.env.PI_SUBAGENT_CHILD === "1" ? void 0 : (await import("./chunk-4DA22WRU.js")).default;
|
|
21
21
|
function registerSubagentExtension(pi) {
|
|
22
22
|
const installedVersion = readInstalledPackageVersion();
|
|
23
23
|
if (installedVersion !== loadedPackageVersion) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveIntercomSessionTarget
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CPWZN5KM.js";
|
|
4
4
|
import "./chunk-7F6RKT6W.js";
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-F4NSLXB2.js";
|
|
6
|
+
import "./chunk-SRWJIAIP.js";
|
|
7
7
|
import "./chunk-YFCK7H2S.js";
|
|
8
8
|
import "./chunk-QXASAHIA.js";
|
|
9
9
|
export {
|
package/bundle/preflight.js
CHANGED
|
@@ -2,23 +2,23 @@ import {
|
|
|
2
2
|
buildEffectiveSystemPrompt,
|
|
3
3
|
canPreferForkFromSnapshot,
|
|
4
4
|
resolveSubagentLaunchContext
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-PSB3VLMH.js";
|
|
6
|
+
import "./chunk-KNVQTRSY.js";
|
|
7
7
|
import {
|
|
8
8
|
loadConfig
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XYIVVS3A.js";
|
|
10
10
|
import {
|
|
11
11
|
nestedResultsPath,
|
|
12
12
|
processTerminalCandidatePath,
|
|
13
13
|
processTerminalPath,
|
|
14
14
|
resultFilePath,
|
|
15
15
|
unobservedRunnerExitPath
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-SIB2GQHL.js";
|
|
17
17
|
import {
|
|
18
18
|
applyIntercomBridgeToAgent,
|
|
19
19
|
resolveIntercomBridge,
|
|
20
20
|
validateIntercomBridgeConfig
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-CPWZN5KM.js";
|
|
22
22
|
import {
|
|
23
23
|
AGENT_DEFINITION_PROJECTION_VERSION,
|
|
24
24
|
resolveLaunchBinding,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
import {
|
|
28
28
|
applyThinkingSuffix,
|
|
29
29
|
resolvePiLaunchToolPlan
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-YVDKGAEO.js";
|
|
31
31
|
import {
|
|
32
32
|
assertRequiredChildExtensionsAdmitted,
|
|
33
33
|
resolveRequiredChildExtensions
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
import {
|
|
36
36
|
getArtifactPaths,
|
|
37
37
|
getArtifactsDir
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-5J2RTMKW.js";
|
|
39
39
|
import {
|
|
40
40
|
assertClaudeCodeModelScope,
|
|
41
41
|
assertThinkingWithinCeiling,
|
|
@@ -62,12 +62,12 @@ import {
|
|
|
62
62
|
resolveSkillsWithFallback,
|
|
63
63
|
resolveStepBehavior,
|
|
64
64
|
unknownAgentDiagnosticContext
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-F4NSLXB2.js";
|
|
66
66
|
import {
|
|
67
67
|
DIRS,
|
|
68
68
|
SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
69
69
|
TEMP_ROOT_DIR
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-SRWJIAIP.js";
|
|
71
71
|
import "./chunk-YFCK7H2S.js";
|
|
72
72
|
import {
|
|
73
73
|
capabilityCeilingAgentRestrictionMessage,
|
package/bundle/project-panes.js
CHANGED
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
openProjectPane,
|
|
9
9
|
projectPaneBindingPath,
|
|
10
10
|
readProjectPaneBinding
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-UC22RDXP.js";
|
|
12
12
|
import "./chunk-72334PEI.js";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-5J2RTMKW.js";
|
|
14
|
+
import "./chunk-F4NSLXB2.js";
|
|
15
|
+
import "./chunk-SRWJIAIP.js";
|
|
16
16
|
import "./chunk-YFCK7H2S.js";
|
|
17
17
|
import "./chunk-QXASAHIA.js";
|
|
18
18
|
export {
|
package/bundle/shared-types.js
CHANGED
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
|
@@ -340,7 +340,13 @@ Async events:
|
|
|
340
340
|
- `subagent:async-complete`
|
|
341
341
|
- `subagent:jobs-changed` (see [extension-api.md](extension-api.md#refresh-a-host-view-without-polling))
|
|
342
342
|
|
|
343
|
-
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.
|
|
344
350
|
|
|
345
351
|
Intercom delivery events:
|
|
346
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/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/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));
|
|
@@ -195,7 +195,7 @@ interface AsyncSingleParams {
|
|
|
195
195
|
runFanoutBudget?: RunFanoutBudgetDescriptor;
|
|
196
196
|
parentWorkflowRunId?: string;
|
|
197
197
|
workflowKey?: string;
|
|
198
|
-
/**
|
|
198
|
+
/** Launch or workflow child label; names the child session and its status step. */
|
|
199
199
|
label?: string;
|
|
200
200
|
lane?: WorkflowLaneMetadata;
|
|
201
201
|
workflowAwaitAsync?: boolean;
|
|
@@ -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";
|
|
@@ -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,
|
|
@@ -2163,6 +2164,7 @@ export function executeAsyncSingle(id, params) {
|
|
|
2163
2164
|
mode: "single",
|
|
2164
2165
|
...(params.toolCallId ? { toolCallId: params.toolCallId } : {}),
|
|
2165
2166
|
agent,
|
|
2167
|
+
description: agentRunDescription(agent, agentConfig, params.label),
|
|
2166
2168
|
task: task?.trim() ? PROMPT_REDACTED : undefined,
|
|
2167
2169
|
goal: (params.goal ?? task).trim() ? PROMPT_REDACTED : undefined,
|
|
2168
2170
|
cwd: runnerCwd,
|
|
@@ -7,7 +7,7 @@ import { Worker } from "node:worker_threads";
|
|
|
7
7
|
import { writeAtomicJson } from "../../shared/atomic-json.js";
|
|
8
8
|
import { readMissionBinding } from "../../missions/lifecycle.js";
|
|
9
9
|
import { MissionNotFoundError, readMission } from "../../missions/store.js";
|
|
10
|
-
import { REVIVAL_ORIGIN_FILE } from "../../workflows/workflow-revival.js";
|
|
10
|
+
import { projectWorkflowKeyRevival, REVIVAL_LINK_FILE, REVIVAL_ORIGIN_FILE } from "../../workflows/workflow-revival.js";
|
|
11
11
|
import { ACTIVE_RUN_INDEX_DIR } from "./active-run-index.js";
|
|
12
12
|
import { encodeIndexSegment } from "./index-segment.js";
|
|
13
13
|
import { reconcileAsyncRun } from "./stale-run-reconciler.js";
|
|
@@ -149,6 +149,50 @@ function missionReferenceBlocksReclaim(runDir, resultsDir, runId) {
|
|
|
149
149
|
return !(error instanceof MissionNotFoundError);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
+
// A run is kept by its own state: live, waited on, recent, resumable, or unreadable. A missing run keeps nothing.
|
|
153
|
+
function runKept(input, runId) {
|
|
154
|
+
const runDir = path.join(input.asyncDirRoot, runId);
|
|
155
|
+
if (!fs.existsSync(runDir))
|
|
156
|
+
return false;
|
|
157
|
+
const status = readStatus(runDir);
|
|
158
|
+
if (status?.runId !== runId || !TERMINAL_STATES.has(status.state))
|
|
159
|
+
return true;
|
|
160
|
+
if (input.protectedRunIds.has(runId) || input.waitRunIds.has(runId) || activeMarkerExists(input.asyncDirRoot, runId))
|
|
161
|
+
return true;
|
|
162
|
+
const timestamp = statusTimestamp(status, runDir);
|
|
163
|
+
return timestamp === undefined || timestamp > input.cutoff || (timestamp > input.resumableCutoff && hasResumableContract(runDir, status));
|
|
164
|
+
}
|
|
165
|
+
// A workflow, its children and their revivals are reclaimed together: each is kept while any of them is.
|
|
166
|
+
function workflowTreeKept(input, workflow) {
|
|
167
|
+
return (workflow.steps ?? []).some((step) => {
|
|
168
|
+
if (!step.runId || !validRunId(step.runId))
|
|
169
|
+
return false;
|
|
170
|
+
const revived = step.workflowKey ? projectWorkflowKeyRevival(input.asyncDirRoot, workflow.runId, step.workflowKey, step.runId)?.revivedRunIds ?? [] : [];
|
|
171
|
+
const chain = [step.runId, ...revived];
|
|
172
|
+
// The chain ends at a link it could not follow when that link file is still there.
|
|
173
|
+
return fs.existsSync(path.join(input.asyncDirRoot, chain.at(-1), REVIVAL_LINK_FILE)) || chain.some((runId) => runKept(input, runId));
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
// Only the workflow checks its tree; its children wait for its folder to go, then are judged on their own.
|
|
177
|
+
// An invalid workflow id names no folder to wait for, so it keeps them too.
|
|
178
|
+
function workflowKeepsChildren(asyncDirRoot, workflowRunId) {
|
|
179
|
+
return !validRunId(workflowRunId) || fs.existsSync(path.join(asyncDirRoot, workflowRunId));
|
|
180
|
+
}
|
|
181
|
+
function workflowReferenceBlocksReclaim(input, runDir, status) {
|
|
182
|
+
if (status.mode === "workflow" && workflowTreeKept(input, status))
|
|
183
|
+
return true;
|
|
184
|
+
let workflowRunId = status.parentWorkflowRunId;
|
|
185
|
+
// A revived workflow child is a link in its key's revival chain and belongs to that workflow.
|
|
186
|
+
if (fs.existsSync(path.join(runDir, REVIVAL_ORIGIN_FILE))) {
|
|
187
|
+
const origin = readJson(path.join(runDir, REVIVAL_ORIGIN_FILE));
|
|
188
|
+
if (typeof origin?.workflowRunId !== "string")
|
|
189
|
+
return true;
|
|
190
|
+
workflowRunId = origin.workflowRunId;
|
|
191
|
+
}
|
|
192
|
+
if (workflowRunId === undefined)
|
|
193
|
+
return status.workflowKey !== undefined;
|
|
194
|
+
return workflowKeepsChildren(input.asyncDirRoot, workflowRunId);
|
|
195
|
+
}
|
|
152
196
|
function runTombstoneMarkerPath(maintenanceRoot, runId) {
|
|
153
197
|
return path.join(maintenanceRoot, RUN_TOMBSTONE_MARKERS_DIR, `${encodeIndexSegment(runId)}.json`);
|
|
154
198
|
}
|
|
@@ -234,10 +278,7 @@ function runSkipReason(input) {
|
|
|
234
278
|
return "active-index";
|
|
235
279
|
if (!TERMINAL_STATES.has(status.state))
|
|
236
280
|
return "non-terminal";
|
|
237
|
-
if (
|
|
238
|
-
return "workflow-reference";
|
|
239
|
-
// A revived workflow child is a link in its key's revival chain; deleting it would cut off later revivals.
|
|
240
|
-
if (fs.existsSync(path.join(runDir, REVIVAL_ORIGIN_FILE)))
|
|
281
|
+
if (workflowReferenceBlocksReclaim(input, runDir, status))
|
|
241
282
|
return "workflow-reference";
|
|
242
283
|
if (hasNestedReferences(status))
|
|
243
284
|
return "nested-reference";
|
|
@@ -450,11 +491,6 @@ function hasUnresolvedResultHandoff(data) {
|
|
|
450
491
|
const manifestPath = data.parallelHandoff.path;
|
|
451
492
|
return typeof manifestPath !== "string" || !manifestPath || unresolvedHandoff(manifestPath);
|
|
452
493
|
}
|
|
453
|
-
function completionMode(data) {
|
|
454
|
-
return data.completion && typeof data.completion === "object" && !Array.isArray(data.completion)
|
|
455
|
-
? data.completion.mode
|
|
456
|
-
: undefined;
|
|
457
|
-
}
|
|
458
494
|
function resultSkipReason(input) {
|
|
459
495
|
if (!input.data)
|
|
460
496
|
return "invalid-result";
|
|
@@ -473,7 +509,8 @@ function resultSkipReason(input) {
|
|
|
473
509
|
return "run-present";
|
|
474
510
|
if (missionObserverIndexExists(input.resultsDir, runId))
|
|
475
511
|
return "mission-reference";
|
|
476
|
-
|
|
512
|
+
// The run dir is gone here, so a workflow's own result is an orphan; a child's result waits for its workflow's folder.
|
|
513
|
+
if (typeof input.data.parentWorkflowRunId === "string" ? workflowKeepsChildren(input.asyncDirRoot, input.data.parentWorkflowRunId) : typeof input.data.workflowKey === "string")
|
|
477
514
|
return "workflow-reference";
|
|
478
515
|
if (hasUnresolvedResultHandoff(input.data))
|
|
479
516
|
return "handoff-reference";
|
|
@@ -833,7 +870,6 @@ export async function cleanupAsyncRetention(options) {
|
|
|
833
870
|
continue;
|
|
834
871
|
}
|
|
835
872
|
fs.rmSync(tombstone, { recursive: true });
|
|
836
|
-
// Retention never deletes a workflow run, so this removes only a single run's recovery descriptor.
|
|
837
873
|
fs.rmSync(runLaunchDir(options.asyncDirRoot, status.runId), { recursive: true, force: true });
|
|
838
874
|
removeRunTombstoneMarker(maintenanceRoot, status.runId);
|
|
839
875
|
result.deletedRuns += 1;
|