pi-subagents 0.66.0 → 0.68.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 +138 -0
- package/README.md +5 -4
- package/agents/evidence-auditor.md +34 -0
- package/agents/reviewer.md +3 -2
- package/docs/agents.md +43 -15
- package/docs/configuration.md +67 -23
- package/docs/extension-api.md +38 -19
- package/docs/missions.md +10 -2
- package/docs/models.md +11 -79
- package/docs/observability.md +22 -12
- package/docs/standalone-background.md +59 -0
- package/docs/tool-reference.md +33 -20
- package/docs/watchdog.md +39 -10
- package/docs/workflows.md +37 -13
- package/index.ts +5 -2
- package/inspector-runner.mjs +2 -2
- package/package.json +4 -2
- package/prompts/parallel-review.md +1 -1
- package/runner-peer-loader.mjs +24 -0
- package/runner-peer-preload.mjs +32 -0
- package/skills/pi-subagents/SKILL.md +32 -21
- package/skills/pi-subagents/references/constraints-and-recipes.md +3 -2
- package/skills/pi-subagents/references/execution-controls.md +11 -9
- package/skills/pi-subagents/references/management-authoring-rpc.md +0 -1
- package/skills/pi-subagents/references/multi-lane-orchestration.md +1 -1
- package/skills/pi-subagents/references/prompting-and-roles.md +17 -13
- package/skills/pi-subagents/references/review-and-validation.md +3 -3
- package/src/agents/advertised-agent-prompt.ts +34 -3
- package/src/agents/agent-management.ts +57 -58
- package/src/agents/agent-serializer.ts +4 -3
- package/src/agents/agents.ts +190 -71
- package/src/agents/builtin-names.ts +1 -0
- package/src/agents/chain-serializer.ts +5 -0
- package/src/agents/runtime-agent-registry.ts +7 -6
- package/src/api/delegation.ts +4 -0
- package/src/api/preflight.ts +94 -59
- package/src/api/required-child-extensions.ts +6 -0
- package/src/api/shared-types.ts +2 -0
- package/src/extension/config.ts +10 -37
- package/src/extension/fanout-child.ts +66 -4
- package/src/extension/herdr-pi-bridge.ts +160 -0
- package/src/extension/index.ts +62 -39
- package/src/extension/public-execution.ts +7 -5
- package/src/extension/rpc.ts +4 -0
- package/src/extension/schemas.ts +81 -81
- package/src/extension/tool-description.ts +30 -82
- package/src/inspectors/actions.ts +148 -0
- package/src/inspectors/ghostty/actions.ts +74 -0
- package/src/inspectors/ghostty/plugin.ts +17 -0
- package/src/inspectors/herdr/actions.ts +99 -179
- package/src/inspectors/herdr/plugin.ts +20 -0
- package/src/inspectors/herdr/project-panes.ts +1 -1
- package/src/inspectors/{herdr/inspector-runner.ts → inspector-runner.ts} +12 -12
- package/src/inspectors/plugins.ts +8 -0
- package/src/inspectors/{herdr/session-roots-codec.ts → session-roots-codec.ts} +3 -14
- package/src/inspectors/types.ts +51 -0
- package/src/intercom/intercom-bridge.ts +50 -8
- package/src/intercom/native-supervisor-channel.ts +44 -31
- package/src/policy/authority.ts +4 -0
- package/src/profiles/profiles.ts +12 -6
- package/src/runs/background/active-async-capacity.ts +4 -0
- package/src/runs/background/active-run-index.ts +17 -1
- package/src/runs/background/async-execution.ts +348 -176
- package/src/runs/background/async-job-tracker.ts +8 -6
- package/src/runs/background/async-resume.ts +17 -12
- package/src/runs/background/async-status.ts +15 -4
- package/src/runs/background/auto-drain.ts +23 -10
- package/src/runs/background/binary-bootstrap.ts +38 -0
- package/src/runs/background/chain-append.ts +1 -1
- package/src/runs/background/chain-root-attachment.ts +14 -33
- package/src/runs/background/fleet-view.ts +30 -2
- package/src/runs/background/notify.ts +105 -7
- package/src/runs/background/owned-process-tree.ts +29 -2
- package/src/runs/background/result-files.ts +8 -4
- package/src/runs/background/result-watcher.ts +19 -2
- package/src/runs/background/run-child-session.ts +81 -33
- package/src/runs/background/run-status.ts +3 -0
- package/src/runs/background/runner-aliases.ts +12 -33
- package/src/runs/background/runner-child-launch.ts +6 -1
- package/src/runs/background/runner-child-sessions.ts +5 -4
- package/src/runs/background/runner-http-dispatcher.ts +119 -0
- package/src/runs/background/scheduled-runs.ts +51 -18
- package/src/runs/background/stale-run-reconciler.ts +35 -11
- package/src/runs/background/steering.ts +20 -2
- package/src/runs/background/subagent-runner.ts +441 -304
- package/src/runs/background/subagent-wait.ts +176 -28
- package/src/runs/background/wait-completions.ts +75 -27
- package/src/runs/background/wait-subscriptions.ts +9 -3
- package/src/runs/background/wait-tool.ts +5 -3
- package/src/runs/foreground/async-steering-action.ts +18 -7
- package/src/runs/foreground/async-stop-action.ts +93 -3
- package/src/runs/foreground/execution.ts +134 -248
- package/src/runs/foreground/foreground-history.ts +2 -1
- package/src/runs/foreground/prompt-audit.ts +3 -1
- package/src/runs/foreground/subagent-executor.ts +374 -178
- package/src/runs/foreground/workflow-detach-reconcile.ts +2 -0
- package/src/runs/foreground/workflow-foreground-steering.ts +2 -1
- package/src/runs/shared/acceptance.ts +38 -11
- package/src/runs/shared/async-status-projection.ts +127 -33
- package/src/runs/shared/capability-ceiling.ts +2 -0
- package/src/runs/shared/child-hooks.ts +25 -10
- package/src/runs/shared/child-launch-plan.ts +15 -3
- package/src/runs/shared/child-launch.ts +28 -5
- package/src/runs/shared/child-lifecycle.ts +6 -3
- package/src/runs/shared/child-runtime-config.ts +8 -1
- package/src/runs/shared/child-session.ts +127 -52
- package/src/runs/shared/child-tool-plan.ts +142 -11
- package/src/runs/shared/completion-guard.ts +5 -3
- package/src/runs/shared/dynamic-fanout.ts +2 -2
- package/src/runs/shared/effective-system-prompt.ts +33 -0
- package/src/runs/shared/external-cli-contract.ts +11 -1
- package/src/runs/shared/external-cli-preflight.ts +6 -2
- package/src/runs/shared/external-cli-runner.ts +9 -7
- package/src/runs/shared/herdr-connection.ts +134 -0
- package/src/runs/shared/herdr-external-adapters.ts +169 -0
- package/src/runs/shared/herdr-machine.ts +279 -0
- package/src/runs/shared/herdr-pi-protocol.ts +59 -0
- package/src/runs/shared/herdr-placed-run.ts +263 -0
- package/src/runs/shared/llm-intent-arbiter.ts +12 -3
- package/src/runs/shared/model-resolution-diagnostic.ts +76 -0
- package/src/runs/shared/{model-fallback.ts → model-resolution.ts} +22 -235
- package/src/runs/shared/model-scope.ts +1 -1
- package/src/runs/shared/nested-events.ts +11 -2
- package/src/runs/shared/orca-progress-tabs.ts +1 -1
- package/src/runs/shared/parallel-utils.ts +7 -2
- package/src/runs/shared/pi-spawn.ts +10 -0
- package/src/runs/shared/subagent-prompt-runtime.ts +12 -4
- package/src/runs/shared/task-intent.ts +46 -13
- package/src/runs/shared/workflow-async-child-guidance.ts +18 -0
- package/src/runs/shared/worktree-setup-command.ts +27 -4
- package/src/runs/shared/worktree.ts +45 -15
- package/src/shared/child-cache-retention.ts +43 -0
- package/src/shared/fork-context.ts +15 -72
- package/src/shared/launch-contract.ts +68 -8
- package/src/shared/opencode-session-headers.ts +30 -0
- package/src/shared/pruned-fork.ts +1 -1
- package/src/shared/required-child-extensions.ts +81 -0
- package/src/shared/settings.ts +5 -2
- package/src/shared/shortcuts.ts +0 -4
- package/src/shared/types.ts +74 -30
- package/src/slash/delegation-adapters.ts +3 -1
- package/src/slash/delegation-request.ts +14 -0
- package/src/slash/slash-commands.ts +2 -7
- package/src/slash/subagents-admin.ts +24 -13
- package/src/tui/fleet-status.ts +164 -19
- package/src/tui/fleet.ts +16 -14
- package/src/tui/render.ts +168 -37
- package/src/watchdog/child-status.ts +28 -28
- package/src/watchdog/lsp-diagnostics.ts +1 -1
- package/src/watchdog/model-selection.ts +21 -1
- package/src/watchdog/permission-arbiter.ts +3 -1
- package/src/watchdog/register-child.ts +10 -2
- package/src/watchdog/register-main.ts +39 -35
- package/src/watchdog/render.ts +1 -1
- package/src/watchdog/review.ts +123 -74
- package/src/watchdog/rules.ts +1 -1
- package/src/watchdog/runtime.ts +100 -27
- package/src/watchdog/scope.ts +1 -1
- package/src/watchdog/settings.ts +3 -0
- package/src/watchdog/tool-actions.ts +13 -12
- package/src/watchdog/turn-delta.ts +23 -0
- package/src/watchdog/types.ts +5 -3
- package/src/watchdog/warning-format.ts +1 -1
- package/src/workflows/scripted-workflow.ts +279 -10
- package/src/workflows/workflow-checklist.ts +2 -2
- package/src/workflows/workflow-receipt.ts +21 -3
- package/src/workflows/workflow-resources.ts +13 -2
- package/runner-server-preload.mjs +0 -13
- package/src/runs/shared/model-exclusions.ts +0 -374
- package/src/runs/shared/readonly-model-continuation.ts +0 -69
- package/src/runs/shared/readonly-session-evidence.ts +0 -307
- /package/src/inspectors/{herdr/shell-command.ts → shell-command.ts} +0 -0
package/src/extension/schemas.ts
CHANGED
|
@@ -35,7 +35,7 @@ const SkillOverride = Type.Unsafe({
|
|
|
35
35
|
{ type: "boolean" },
|
|
36
36
|
{ type: "string" },
|
|
37
37
|
],
|
|
38
|
-
description: "
|
|
38
|
+
description: "Skills: names/CSV/array; false disables, true uses default.",
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
const OutputOverride = Type.Unsafe({
|
|
@@ -48,7 +48,7 @@ const OutputOverride = Type.Unsafe({
|
|
|
48
48
|
|
|
49
49
|
const OutputModeOverride = Type.String({
|
|
50
50
|
enum: ["inline", "file-only"],
|
|
51
|
-
description: "
|
|
51
|
+
description: "Default inline; file-only requires output path.",
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
const ReadsOverride = Type.Unsafe({
|
|
@@ -62,20 +62,13 @@ const ReadsOverride = Type.Unsafe({
|
|
|
62
62
|
const JsonSchemaObject = Type.Unsafe({
|
|
63
63
|
type: "object",
|
|
64
64
|
additionalProperties: true,
|
|
65
|
-
description: "
|
|
65
|
+
description: "Strict structured output; object-root JSON Schema only.",
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
const
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
"validation-output",
|
|
73
|
-
"residual-risks",
|
|
74
|
-
"no-staged-files",
|
|
75
|
-
"diff-summary",
|
|
76
|
-
"review-findings",
|
|
77
|
-
"manual-notes",
|
|
78
|
-
];
|
|
68
|
+
const OutputSchemaOverride = Type.Unsafe({
|
|
69
|
+
anyOf: [JsonSchemaObject, { type: "boolean" }],
|
|
70
|
+
description: "Structured output schema override; false disables an agent default.",
|
|
71
|
+
});
|
|
79
72
|
|
|
80
73
|
// Provider boolean branches intentionally overapproximate false-only runtime inputs.
|
|
81
74
|
// Restricted function-declaration converters only support string enum members.
|
|
@@ -90,11 +83,12 @@ const AcceptanceOverride = Type.Unsafe({
|
|
|
90
83
|
},
|
|
91
84
|
{
|
|
92
85
|
type: "string",
|
|
86
|
+
pattern: "^\\s*\\{",
|
|
93
87
|
},
|
|
94
88
|
{ type: "boolean" },
|
|
95
89
|
{ type: "object", additionalProperties: true },
|
|
96
90
|
],
|
|
97
|
-
description:
|
|
91
|
+
description: "Evidence policy; omit for read-only/review. false disables; true invalid. Prefer object; see guide tool-reference for levels, evidence and review.required.",
|
|
98
92
|
});
|
|
99
93
|
|
|
100
94
|
const AgentContractOverride = Type.Object({
|
|
@@ -113,7 +107,7 @@ const WorkflowLaneMetadata = Type.Object({
|
|
|
113
107
|
sourceRef: Type.Optional(Type.String({ minLength: 1, maxLength: 128 })),
|
|
114
108
|
claims: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 160 }), { maxItems: 20 })),
|
|
115
109
|
outputPaths: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 256 }), { maxItems: 10 })),
|
|
116
|
-
}, { additionalProperties: false, description: "
|
|
110
|
+
}, { additionalProperties: false, description: "Display/triage only; sourceRef is opaque, never resolved by status." });
|
|
117
111
|
|
|
118
112
|
const ToolBudgetBlock = Type.Unsafe({
|
|
119
113
|
anyOf: [
|
|
@@ -126,7 +120,7 @@ const ToolBudgetOverride = Type.Object({
|
|
|
126
120
|
soft: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
127
121
|
hard: Type.Integer({ minimum: 1 }),
|
|
128
122
|
block: Type.Optional(ToolBudgetBlock),
|
|
129
|
-
}, { additionalProperties: false, description: "
|
|
123
|
+
}, { additionalProperties: false, description: "soft nudges; after hard, block tools (default read/grep/find/ls, '*' for all) so child can finalize." });
|
|
130
124
|
|
|
131
125
|
const UsageBudgetLimitOverride = Type.Object({
|
|
132
126
|
soft: Type.Optional(Type.Number({ exclusiveMinimum: 0 })),
|
|
@@ -136,7 +130,7 @@ const UsageBudgetLimitOverride = Type.Object({
|
|
|
136
130
|
const UsageBudgetOverride = Type.Object({
|
|
137
131
|
tokens: Type.Optional(UsageBudgetLimitOverride),
|
|
138
132
|
costUsd: Type.Optional(UsageBudgetLimitOverride),
|
|
139
|
-
}, { additionalProperties: false, description: "
|
|
133
|
+
}, { additionalProperties: false, description: "Root-only reported usage; hard prevents later launches. Running children are not stopped." });
|
|
140
134
|
|
|
141
135
|
const WorkflowPreflightLane = Type.Object({
|
|
142
136
|
key: Type.String({ minLength: 1, maxLength: 128 }),
|
|
@@ -151,7 +145,7 @@ const WorkflowPreflightOverride = Type.Object({
|
|
|
151
145
|
version: Type.Integer({ minimum: 1, maximum: 1 }),
|
|
152
146
|
coverage: Type.Optional(Type.String({ enum: ["complete", "partial"] })),
|
|
153
147
|
lanes: Type.Array(WorkflowPreflightLane, { maxItems: 64 }),
|
|
154
|
-
}, { additionalProperties: false, description: "
|
|
148
|
+
}, { additionalProperties: false, description: "Display-only lane hints; coverage mismatches warn, never change authority/execution." });
|
|
155
149
|
|
|
156
150
|
// Parallel task item (within a parallel step)
|
|
157
151
|
export const ParallelTaskSchema = Type.Object({
|
|
@@ -160,8 +154,9 @@ export const ParallelTaskSchema = Type.Object({
|
|
|
160
154
|
phase: Type.Optional(Type.String({ description: "Optional phase/group label for status and graph rendering." })),
|
|
161
155
|
label: Type.Optional(Type.String({ description: "Optional user-facing label for this parallel task." })),
|
|
162
156
|
as: Type.Optional(Type.String({ description: "Optional safe identifier used as {outputs.name} in later chain steps." })),
|
|
163
|
-
outputSchema: Type.Optional(
|
|
157
|
+
outputSchema: Type.Optional(OutputSchemaOverride),
|
|
164
158
|
cwd: Type.Optional(Type.String()),
|
|
159
|
+
machine: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "Herdr saved machine id or label." })),
|
|
165
160
|
count: Type.Optional(Type.Integer({ minimum: 1, description: "Repeat this parallel task N times with the same settings." })),
|
|
166
161
|
output: Type.Optional(OutputOverride),
|
|
167
162
|
outputMode: Type.Optional(OutputModeOverride),
|
|
@@ -192,8 +187,9 @@ export const DynamicParallelTemplateSchema = Type.Object({
|
|
|
192
187
|
task: Type.Optional(Type.String({ description: "Task template with {item}, {item.path}, {task}, {previous}, {chain_dir}, and {outputs.name} variables." })),
|
|
193
188
|
phase: Type.Optional(Type.String({ description: "Optional phase/group label for status and graph rendering." })),
|
|
194
189
|
label: Type.Optional(Type.String({ description: "Optional user-facing label; item templates are supported." })),
|
|
195
|
-
outputSchema: Type.Optional(
|
|
190
|
+
outputSchema: Type.Optional(OutputSchemaOverride),
|
|
196
191
|
cwd: Type.Optional(Type.String()),
|
|
192
|
+
machine: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "Herdr saved machine id or label." })),
|
|
197
193
|
output: Type.Optional(OutputOverride),
|
|
198
194
|
outputMode: Type.Optional(OutputModeOverride),
|
|
199
195
|
reads: Type.Optional(ReadsOverride),
|
|
@@ -221,8 +217,9 @@ export const ChainItem = Type.Object({
|
|
|
221
217
|
phase: Type.Optional(Type.String({ description: "Optional phase/group label for status and graph rendering." })),
|
|
222
218
|
label: Type.Optional(Type.String({ description: "Optional user-facing label for this chain step." })),
|
|
223
219
|
as: Type.Optional(Type.String({ description: "Optional safe identifier used as {outputs.name} in later chain steps." })),
|
|
224
|
-
outputSchema: Type.Optional(
|
|
220
|
+
outputSchema: Type.Optional(OutputSchemaOverride),
|
|
225
221
|
cwd: Type.Optional(Type.String()),
|
|
222
|
+
machine: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "Herdr saved machine id or label." })),
|
|
226
223
|
output: Type.Optional(OutputOverride),
|
|
227
224
|
outputMode: Type.Optional(OutputModeOverride),
|
|
228
225
|
reads: Type.Optional(ReadsOverride),
|
|
@@ -280,58 +277,59 @@ const ControlOverrides = Type.Object({
|
|
|
280
277
|
});
|
|
281
278
|
|
|
282
279
|
const SubagentParamProperties = {
|
|
283
|
-
agent: Type.Optional(Type.String({ description: "
|
|
284
|
-
task: Type.Optional(Type.String({ description: "
|
|
285
|
-
extensionBindings: Type.Optional(Type.Unsafe({ type: "object", maxProperties: 16, additionalProperties: true, description: "
|
|
280
|
+
agent: Type.Optional(Type.String({ description: "One-child agent or management target." })),
|
|
281
|
+
task: Type.Optional(Type.String({ description: "One-child task; requires agent." })),
|
|
282
|
+
extensionBindings: Type.Optional(Type.Unsafe({ type: "object", maxProperties: 16, additionalProperties: true, description: "Child-only bounded JSON; namespaces package.name/1." })),
|
|
286
283
|
// Management action (when present, tool operates in management mode)
|
|
287
284
|
action: Type.Optional(Type.String({ minLength: 1,
|
|
288
|
-
description: "
|
|
285
|
+
description: "Management/control only; omit for execution. validate accepts either script input. Discover actions with guide topic tool-reference."
|
|
289
286
|
})),
|
|
290
|
-
capabilities: Type.Optional(Type.Boolean({ description: "
|
|
291
|
-
name: Type.Optional(Type.String({ description: "
|
|
287
|
+
capabilities: Type.Optional(Type.Boolean({ description: "list: compact capability rows/details without system prompts." })),
|
|
288
|
+
name: Type.Optional(Type.String({ description: "schedule.create name." })),
|
|
292
289
|
id: Type.Optional(Type.String({
|
|
293
|
-
description: "Run id/prefix for status/
|
|
290
|
+
description: "Run id/prefix for status/control."
|
|
294
291
|
})),
|
|
295
292
|
runId: Type.Optional(Type.String({
|
|
296
|
-
description: "Target run ID
|
|
293
|
+
description: "Target run ID; prefer id."
|
|
297
294
|
})),
|
|
298
295
|
dir: Type.Optional(Type.String({
|
|
299
|
-
description: "Async
|
|
296
|
+
description: "Async directory for status/control."
|
|
300
297
|
})),
|
|
301
|
-
handoffPath: Type.Optional(Type.String({ description: "Existing
|
|
302
|
-
repo: Type.Optional(Type.String({ description: "
|
|
303
|
-
planId: Type.Optional(Type.String({ description: "
|
|
304
|
-
laneId: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "Exact manifest run id for lane
|
|
305
|
-
merge: Type.Optional(Type.Unsafe({ type: "object", additionalProperties: true, description: "
|
|
306
|
-
supersession: Type.Optional(Type.Unsafe({ type: "object", additionalProperties: true, description: "
|
|
307
|
-
index: Type.Optional(Type.Integer({ minimum: 0, description: "Zero-based child index
|
|
308
|
-
childId: Type.Optional(Type.String({ minLength: 1, maxLength: 256, description: "
|
|
298
|
+
handoffPath: Type.Optional(Type.String({ description: "Existing manifest for worktree/lane actions." })),
|
|
299
|
+
repo: Type.Optional(Type.String({ description: "worktree.cleanup repo; default cwd." })),
|
|
300
|
+
planId: Type.Optional(Type.String({ description: "Reserved; cleanup is plan-only." })),
|
|
301
|
+
laneId: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "Exact manifest run id for lane actions." })),
|
|
302
|
+
merge: Type.Optional(Type.Unsafe({ type: "object", additionalProperties: true, description: "lane.recordMerge evidence; read guide tool-reference." })),
|
|
303
|
+
supersession: Type.Optional(Type.Unsafe({ type: "object", additionalProperties: true, description: "lane.recordSupersession evidence; read guide tool-reference." })),
|
|
304
|
+
index: Type.Optional(Type.Integer({ minimum: 0, description: "Zero-based child/transcript index." })),
|
|
305
|
+
childId: Type.Optional(Type.String({ minLength: 1, maxLength: 256, description: "Child-scoped stop identity." })),
|
|
309
306
|
view: Type.Optional(Type.String({
|
|
310
307
|
enum: ["fleet", "transcript"],
|
|
311
|
-
description: "
|
|
308
|
+
description: "status view: fleet overview or transcript tail with id/dir and optional index.",
|
|
312
309
|
})),
|
|
313
|
-
lines: Type.Optional(Type.Integer({ minimum: 1, maximum: 500, description: "
|
|
310
|
+
lines: Type.Optional(Type.Integer({ minimum: 1, maximum: 500, description: "Transcript tail lines; default 80." })),
|
|
314
311
|
topic: Type.Optional(Type.String()),
|
|
315
|
-
message: Type.Optional(Type.String({ description: "
|
|
316
|
-
mode: Type.Optional(Type.String({ enum: ["steer", "follow_up", "auto", "plan", "apply"], description: "
|
|
317
|
-
steeringRecovery: Type.Optional(Type.Boolean({ description: "
|
|
318
|
-
additional: Type.Optional(Type.Integer({ minimum: 1, description: "
|
|
319
|
-
scope: Type.Optional(Type.String({ enum: ["session", "user", "project"], description: "
|
|
320
|
-
target: Type.Optional(Type.String({ enum: ["main", "children", "child"], description: "
|
|
321
|
-
focus: Type.Optional(Type.Boolean({ description: "Focus
|
|
322
|
-
thinking: Type.Optional(Type.Unsafe({ anyOf: [{ type: "string" }, { type: "boolean" }], description: "
|
|
323
|
-
at: Type.Optional(Type.String({ description: "
|
|
324
|
-
every: Type.Optional(Type.String({ description: "
|
|
312
|
+
message: Type.Optional(Type.String({ description: "resume/steer guidance or project.open prompt." })),
|
|
313
|
+
mode: Type.Optional(Type.String({ enum: ["steer", "follow_up", "auto", "plan", "apply"], description: "steer delivery mode; worktree.cleanup supports plan only, no apply/removal." })),
|
|
314
|
+
steeringRecovery: Type.Optional(Type.Boolean({ description: "steer: pause/revive after missed acknowledgment; default true in direct steer mode, forced false by extension RPC for exact ownership." })),
|
|
315
|
+
additional: Type.Optional(Type.Integer({ minimum: 1, description: "grant-spawn-budget: root interactive parent + native user confirmation only; total grants capped at original configured cap." })),
|
|
316
|
+
scope: Type.Optional(Type.String({ enum: ["session", "user", "project"], description: "watchdog.configure scope; default session, persistent only if explicit." })),
|
|
317
|
+
target: Type.Optional(Type.String({ enum: ["main", "children", "child"], description: "Watchdog target." })),
|
|
318
|
+
focus: Type.Optional(Type.Boolean({ description: "Focus inspector.open/project.open pane." })),
|
|
319
|
+
thinking: Type.Optional(Type.Unsafe({ anyOf: [{ type: "string" }, { type: "boolean" }], description: "watchdog.configure only: off/minimal/low/medium/high/xhigh/max, inherit, false=off; true invalid. Dispatch ignores this; use model suffix." })),
|
|
320
|
+
at: Type.Optional(Type.String({ description: "schedule.create: delay (+10m) or zoned ISO timestamp." })),
|
|
321
|
+
every: Type.Optional(Type.String({ description: "schedule.create interval, e.g. 30m/6h/2d/2w." })),
|
|
325
322
|
sessionOnly: Type.Optional(Type.Boolean()),
|
|
326
|
-
|
|
323
|
+
quiet: Type.Optional(Type.Boolean()),
|
|
324
|
+
on: Type.Optional(Type.Unsafe({ anyOf: [{ type: "string" }, { type: "integer" }], description: "Reserved calendar selector." })),
|
|
327
325
|
timezone: Type.Optional(Type.String()),
|
|
328
|
-
overlap: Type.Optional(Type.String({ enum: ["skip"]
|
|
329
|
-
catchUp: Type.Optional(Type.String({ enum: ["none", "latest"], description: "Missed
|
|
330
|
-
missionId: Type.Optional(Type.String(
|
|
331
|
-
mission: Type.Optional(Type.Unsafe({ ...MissionLaunchOverride, description: "
|
|
332
|
-
missionUpdate: Type.Optional(Type.Unsafe({ ...MissionUpdateOverride, description: "Mission
|
|
333
|
-
missionStatus: Type.Optional(Type.String(
|
|
334
|
-
missionScope: Type.Optional(Type.String({ description: "
|
|
326
|
+
overlap: Type.Optional(Type.String({ enum: ["skip"] })),
|
|
327
|
+
catchUp: Type.Optional(Type.String({ enum: ["none", "latest"], description: "Missed schedule occurrences; default latest." })),
|
|
328
|
+
missionId: Type.Optional(Type.String()),
|
|
329
|
+
mission: Type.Optional(Type.Unsafe({ ...MissionLaunchOverride, description: "false disables; true invalid. Object: exactly one non-empty title or summary; objective/labels optional; goal only true, requires budget.tokens." })),
|
|
330
|
+
missionUpdate: Type.Optional(Type.Unsafe({ ...MissionUpdateOverride, description: "Mission patch; read guide missions." })),
|
|
331
|
+
missionStatus: Type.Optional(Type.String()),
|
|
332
|
+
missionScope: Type.Optional(Type.String({ description: "project (default) or global pointer index." })),
|
|
335
333
|
runMode: Type.Optional(Type.String({ description: "Attached run mode." })),
|
|
336
334
|
runStatus: Type.Optional(Type.String({ description: "Attached run status." })),
|
|
337
335
|
summary: Type.Optional(Type.String({ description: "Mission close summary." })),
|
|
@@ -341,37 +339,39 @@ const SubagentParamProperties = {
|
|
|
341
339
|
{ type: "object", additionalProperties: true },
|
|
342
340
|
{ type: "string" },
|
|
343
341
|
],
|
|
344
|
-
description: "
|
|
342
|
+
description: "create/update agent config; object or JSON string."
|
|
345
343
|
})),
|
|
346
|
-
workflow: Type.Optional(Type.String({ minLength: 1, description: "Extension-owned workflow resource
|
|
347
|
-
args: Type.Optional(Type.Unsafe({ type: "object", maxProperties: 16, additionalProperties: true, description: "Bounded plain-JSON args for
|
|
348
|
-
workflowScript: Type.Optional(Type.String({ minLength: 1, description: "Inline JavaScript statement body
|
|
349
|
-
workflowScriptPath: Type.Optional(Type.String({ minLength: 1, description: "
|
|
344
|
+
workflow: Type.Optional(Type.String({ minLength: 1, description: "Extension-owned workflow resource." })),
|
|
345
|
+
args: Type.Optional(Type.Unsafe({ type: "object", maxProperties: 16, additionalProperties: true, description: "Bounded plain-JSON args for named, inline, or file-backed workflows; raw-script args are exposed deeply frozen and persisted, so do not include secrets." })),
|
|
346
|
+
workflowScript: Type.Optional(Type.String({ minLength: 1, description: "Inline JavaScript statement body; raw/unknown provenance, no runs.host. Use explicit return and top-level await; see tool guidance/guide workflows." })),
|
|
347
|
+
workflowScriptPath: Type.Optional(Type.String({ minLength: 1, description: "Raw script file; host reads from request cwd before sandbox. Mutually exclusive with workflowScript and workflow." })),
|
|
350
348
|
globalConcurrencyLimit: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
351
349
|
maxSubagentSpawnsPerRun: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
352
350
|
preflight: Type.Optional(WorkflowPreflightOverride),
|
|
353
|
-
chatProgress: Type.Optional(Type.String({ enum: ["auto", "off", "live-card"], description: "
|
|
354
|
-
isolation: Type.Optional(Type.String({ enum: ["none", "worktree"], description: "
|
|
355
|
-
worktree: Type.Optional(Type.Boolean({ description: "
|
|
351
|
+
chatProgress: Type.Optional(Type.String({ enum: ["auto", "off", "live-card"], description: "auto: live card only for watched foreground in same Git repository. live-card requires same-repo async:false; async: omit or auto/off." })),
|
|
352
|
+
isolation: Type.Optional(Type.String({ enum: ["none", "worktree"], description: "Shared cwd or managed git worktrees." })),
|
|
353
|
+
worktree: Type.Optional(Type.Boolean({ description: "Isolate each workflow child in a managed git worktree; child worktree:false overrides default." })),
|
|
356
354
|
baseRef: Type.Optional(Type.String()),
|
|
357
355
|
lane: Type.Optional(WorkflowLaneMetadata),
|
|
358
356
|
context: Type.Optional(Type.String({
|
|
359
357
|
enum: ["fresh", "fork", "profile"],
|
|
360
|
-
description: "
|
|
358
|
+
description: "fresh/fork overrides every child; profile requires agent's declared defaultContext, ignoring config. Omitted: defaultSubagentContext wins over each agent defaultContext; implicit fork needs persisted parent + leaf, else fresh. forkContext may prune forks before spawn.",
|
|
361
359
|
})),
|
|
362
|
-
async: Type.Optional(Type.Boolean({ description: "
|
|
360
|
+
async: Type.Optional(Type.Boolean({ description: "Background; default asyncByDefault. false only to block parent." })),
|
|
363
361
|
timeoutMs: Type.Optional(Type.Integer({ minimum: 1, description: "Timeout. Foreground and single async runs use config timeoutMs, else 30m; async composites have no default parent deadline. Alias maxRuntimeMs." })),
|
|
364
|
-
maxRuntimeMs: Type.Optional(Type.Integer({ minimum: 1, description: "Alias timeoutMs
|
|
365
|
-
|
|
362
|
+
maxRuntimeMs: Type.Optional(Type.Integer({ minimum: 1, description: "Alias timeoutMs (same defaults)." })),
|
|
363
|
+
checkpointBeforeDeadlineMs: Type.Optional(Type.Integer({ minimum: 1, maximum: 2_147_483_647, description: "Async single-agent runs only: the runner requests that the child checkpoint and stop this many ms before the run deadline (best-effort; the deadline kill still applies)." })),
|
|
364
|
+
toolTimeoutMs: Type.Optional(Type.Integer({ minimum: 1, description: "Per-tool deadline (ms); fast builtins default 5m." })),
|
|
366
365
|
toolBudget: Type.Optional(ToolBudgetOverride),
|
|
367
366
|
usageBudget: Type.Optional(UsageBudgetOverride),
|
|
368
|
-
agentScope: Type.Optional(Type.String({ description: "
|
|
369
|
-
cwd: Type.Optional(Type.String({ description: "Execution
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
367
|
+
agentScope: Type.Optional(Type.String({ description: "user/project/both (default); project wins collisions." })),
|
|
368
|
+
cwd: Type.Optional(Type.String({ description: "Execution/project-pane directory." })),
|
|
369
|
+
machine: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "Herdr saved machine id or label; runs an external CLI agent there. cwd then means the directory on that machine." })),
|
|
370
|
+
artifacts: Type.Optional(Type.Boolean({ description: "Debug artifacts; default true." })),
|
|
371
|
+
includeProgress: Type.Optional(Type.Boolean({ description: "Full result progress; default false." })),
|
|
372
|
+
share: Type.Optional(Type.Boolean({ description: "Upload session to GitHub Gist; default false." })),
|
|
373
373
|
sessionDir: Type.Optional(
|
|
374
|
-
Type.String({ description: "
|
|
374
|
+
Type.String({ description: "Session log directory; default temp, independent of share." }),
|
|
375
375
|
),
|
|
376
376
|
control: Type.Optional(ControlOverrides),
|
|
377
377
|
// Workflow defaults forwarded to each runs.run/runs.all child unless overridden there.
|
|
@@ -380,13 +380,13 @@ const SubagentParamProperties = {
|
|
|
380
380
|
{ type: "string" },
|
|
381
381
|
{ type: "boolean" },
|
|
382
382
|
],
|
|
383
|
-
description: "
|
|
383
|
+
description: "Child output path or false; relative workflow paths use managed artifact routing. Bind durable output here, not task prose; return outputReference/outputPathMapping/artifactPaths.",
|
|
384
384
|
})),
|
|
385
385
|
outputMode: Type.Optional(OutputModeOverride),
|
|
386
386
|
skill: Type.Optional(SkillOverride),
|
|
387
|
-
model: Type.Optional(Type.String({ description: "
|
|
388
|
-
fast: Type.Optional(Type.Boolean({ description: "
|
|
389
|
-
outputSchema: Type.Optional(
|
|
387
|
+
model: Type.Optional(Type.String({ description: "Child model provider/id; bare id only if unique. Suffix :off/minimal/low/medium/high/xhigh/max overrides agent thinking default." })),
|
|
388
|
+
fast: Type.Optional(Type.Boolean({ description: "Native OpenAI-Codex priority tier; default false, may cost more/quota." })),
|
|
389
|
+
outputSchema: Type.Optional(OutputSchemaOverride),
|
|
390
390
|
agentContract: Type.Optional(AgentContractOverride),
|
|
391
391
|
acceptance: Type.Optional(AcceptanceOverride),
|
|
392
392
|
gate: Type.Optional(Type.String({ minLength: 1, description: "Host gate command. Cannot be combined with acceptance; an explicit acceptance of false is treated as omitted." })),
|
|
@@ -5,95 +5,43 @@ import { getAgentDir, getProjectConfigDir } from "../shared/utils.ts";
|
|
|
5
5
|
|
|
6
6
|
const CUSTOM_TOOL_DESCRIPTION_FILE = "subagent-tool-description.md";
|
|
7
7
|
const CUSTOM_TOOL_DESCRIPTION_MAX_BYTES = 50 * 1024;
|
|
8
|
-
const
|
|
9
|
-
const SUBAGENT_FAILURE_RECOVERY_GUIDANCE = "
|
|
10
|
-
const AGENT_SELECTION_GUIDANCE = "Before execution, call { action: \"list\", capabilities: true } and run only executable, non-disabled agents; for external-cli rows, also require runner.available === true. This is a passive PATH/PATHEXT/X_OK lookup, not authentication, version, or launch proof; launch preflight remains authoritative.";
|
|
11
|
-
const WORKFLOW_RESUME_KEY_GUIDANCE = "Each workflow key identifies one result lane: use a new stable workflow key for every distinct retained resume pass; same-key calls are reused only when launch parameters are identical, and incompatible parameters are rejected.";
|
|
12
|
-
const WORKFLOW_OUTPUT_BINDING_GUIDANCE = "For durable workflow child files, set output on runs.run/runs.all; task filename prose is not an output declaration, and return the child's outputReference, outputPathMapping, or artifactPaths instead of inventing a literal path.";
|
|
13
|
-
const WORKFLOW_LANES_GUIDANCE = "For bounded parallel sequential chains, use runs.lanes([{key,stages:[{key,agent,task},{key,resume:'previous',task},...]}]); first stages run together, later stages sequence per lane, and the bounded board reports lane-local failures. Only an explicit structuredOutput.verdict === 'blocked' blocks a successful stage; reviewer prose is not parsed.";
|
|
14
|
-
const WORKTREE_BASE_REF_GUIDANCE = "baseRef must be HEAD or a supported named ref such as refs/heads/main; full 40/64-character commit IDs and revision expressions such as HEAD~1 are unsupported. Omitted baseRef defaults to HEAD resolved at worktree allocation. The source checkout must still be clean.";
|
|
15
|
-
const WORKFLOW_SCRIPT_PORTABILITY_GUIDANCE = "workflowScript rejects nested async function, arrow, and method helpers; use top-level await, plain helper functions that return runs.run(...), or explicit Promise chains instead.";
|
|
16
|
-
const WORKFLOW_RESOURCE_GUIDANCE = "For permission/policy-extension interoperability, use an extension-owned named resource such as {workflow:'review',args:{task:'...'}} or {workflow:'run-ci',args:{command:'npm test'}}. The host resolves the script and authority internally so policy can distinguish it from raw workflowScript/workflowScriptPath; args are bounded plain data, and do not combine workflow with agent, task, workflowScript, or workflowScriptPath.";
|
|
17
|
-
const WORKFLOW_HOST_GUIDANCE = "For permission-sensitive host calls, use an extension-owned resource such as {workflow:'run-ci',args:{command:'npm test'}}; raw workflowScript/workflowScriptPath have unknown resource provenance and cannot use runs.host. In a resource that grants it, await runs.host(key,{kind:'command',command,timeoutMs,output?,role?,provider?}). runs.host has no per-step cwd: commands and relative output paths use the workflow cwd; set cwd on the outer subagent request instead (for example, {cwd:'/path/to/worktree',workflowScript:'...'}), or put a trusted directory change in the command (for example, 'cd /path/to/worktree && npm test'). runs.host supports only command steps; output is bounded and command failure fails the workflow.";
|
|
18
|
-
|
|
19
|
-
export const DEFAULT_SUBAGENT_TOOL_DESCRIPTION = `Delegate to configured subagents. For execution, omit action and use {agent, task?} for one child, workflowScript for inline orchestration, workflowScriptPath to load a script from the request cwd, or a named workflow resource for permission/policy-aware execution. ${WORKFLOW_RESOURCE_GUIDANCE} ${AGENT_SELECTION_GUIDANCE} The script inputs are mutually exclusive. Use action:'validate' with either script input to check it without launching children. For multi-step or parallel work, make exactly one top-level subagent call with async:true; launch children only inside that workflow and do not make another top-level call for them. Use runs.run('key',{agent,task}) for one child, await runs.all([{key:'a',agent:'reviewer',task:'...'},{key:'b',agent:'reviewer',task:'...'}]) for ordinary parallel children, and read its ordered array result with indexes, destructuring, or .map(...), not by key property. ${WORKFLOW_SCRIPT_PORTABILITY_GUIDANCE} ${WORKFLOW_LANES_GUIDANCE} ${WORKFLOW_HOST_GUIDANCE} ${WORKTREE_BASE_REF_GUIDANCE} ${EXTERNAL_CLI_RUNNER_GUIDANCE} ${SUBAGENT_FAILURE_RECOVERY_GUIDANCE} Use action only for management/control. Use guide or the pi-subagents skill for advanced workflow details.`;
|
|
20
|
-
|
|
21
|
-
export const SUBAGENT_TOOL_PROMPT_SNIPPET = "Delegate to subagents; orchestrate in one workflowScript call.";
|
|
22
|
-
|
|
23
|
-
export const SUBAGENT_TOOL_PROMPT_GUIDELINES = [
|
|
24
|
-
`Use subagent only when delegation is needed. ${AGENT_SELECTION_GUIDANCE}`,
|
|
25
|
-
'Omit action for execution; use { agent, task? } for one child. For multi-step or parallel work, make exactly one top-level { workflowScript, async: true } call and launch children only inside it. Use action only for management/control.',
|
|
26
|
-
"workflowScript rejects nested async function, arrow, and method helpers; use top-level await, plain helper functions, or explicit Promise chains.",
|
|
27
|
-
"Inside workflowScript, use runs.run/runs.all and await their results. runs.all returns an ordered array, not a key map; stored runs.run promises must later be observed with direct await, Promise.race, or Promise.all.",
|
|
28
|
-
'Keep one writer per cwd/worktree; isolate concurrent writers. For durable files, set output on runs.run/runs.all and return the child\'s outputReference, outputPathMapping, or artifactPaths. For advanced workflows, read the bundled pi-subagents skill or call { action: "guide", topic: "workflows" }.',
|
|
29
|
-
];
|
|
8
|
+
const AGENT_SELECTION_GUIDANCE = 'First call {action:"list",capabilities:true}: executable, non-disabled agents only; external-cli requires runner.available === true. Passive PATH/PATHEXT/X_OK is not authentication/version/launch proof; preflight is authoritative.';
|
|
9
|
+
const SUBAGENT_FAILURE_RECOVERY_GUIDANCE = "Workflow, child launch, prompt runtime, extension load or child tooling failure is a lane infrastructure blocker. Stop; report exact failure, run/status and repo/cwd/worktree/branch/ref; verify clean worktree or capture partial diff before same-protocol retry or asking the owner. Never silently switch to interactive_shell, pi -ne, Codex/Claude/Cursor CLI or foreground/external mode: governed-workflow fallback requires explicit owner approval, not Pi core's generic pi -ne hint. Explicit foreground/CLI requests and work outside that protocol remain valid.";
|
|
30
10
|
|
|
31
11
|
export const SUBAGENT_SAFETY_GUIDANCE = `SAFETY-CRITICAL SUBAGENT GUIDANCE:
|
|
12
|
+
• Direct parent execution is the default. Invoke subagents only when delegation is authorized by the operator's current request or applicable user/project instructions; task size, complexity, risk, tool-call count, or recipe fit do not independently authorize delegation.
|
|
32
13
|
• ${AGENT_SELECTION_GUIDANCE}
|
|
33
14
|
• ${SUBAGENT_FAILURE_RECOVERY_GUIDANCE}
|
|
34
|
-
•
|
|
35
|
-
• Async
|
|
36
|
-
•
|
|
37
|
-
•
|
|
38
|
-
•
|
|
39
|
-
•
|
|
40
|
-
•
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
• ${WORKFLOW_LANES_GUIDANCE}
|
|
55
|
-
• FILE SCRIPT: { workflowScriptPath:"workflows/review.js" }. Relative paths resolve against the request cwd. The host reads the file before the filesystem-free workflow sandbox starts. Do not combine this field with workflowScript.
|
|
56
|
-
• Sequential example: { workflowScript: "const a = await runs.run('analyze', {agent:'agent-a', task:'Analyze the request'}); return (await runs.run('plan', {agent:'agent-b', task:'Plan from: '+a.output})).output" }
|
|
57
|
-
• Parallel example: { workflowScript: "const [a,b] = await runs.all([{key:'correctness',agent:'agent-a',task:'Review correctness'},{key:'tests',agent:'agent-b',task:'Review tests'}]); return {correctness:a.output,tests:b.output}" }
|
|
58
|
-
• Optional context is "fresh", "fork", or "profile". profile requires the selected agent's declared defaultContext and ignores config defaultSubagentContext. Explicit fresh/fork wins. When omitted, config defaultSubagentContext wins over agent defaultContext. Config forkContext can summarize transcript overflow with stable recovery refs before spawn without adding another public context value. timeoutMs/maxRuntimeMs apply to foreground and async workflows; foreground workflows default to 30 minutes and async workflows have no default timeout. Omit acceptance for reviewer/read-only calls; evidence levels end at verified, and acceptance.review.required requests independent writer review.
|
|
59
|
-
• Durable mission attachment is automatic by default. Use missionId to attach an existing mission, mission:{...} to override auto-create, or mission:false for ephemeral work. A mission object needs exactly one non-empty title or summary; objective and labels are optional. goal may only be true and requires budget:{tokens}.
|
|
60
|
-
|
|
61
|
-
MANAGEMENT / CONTROL (use action; omit execution fields):
|
|
62
|
-
• validate checks workflowScript or workflowScriptPath syntax and statically decidable structure without launching children. list, get, models, guide, children.list, create, update, delete, eject, disable, enable, reset, status, debug.run, doctor, grant-spawn-budget, worktree.discard, worktree.cleanup (plan-only), lane.status, lane.recordMerge, lane.recordSupersession, refine/refine.show/refine.rollback, mission.create/list/show/update/resolve-decision/attach-run/close, inspector.open/status/close, project.open/status/close, and watchdog actions remain available. Use {action:"guide", topic:"overview"} for packaged current-version help; topics are overview, workflows, agents, missions, observability, tool-reference, configuration, models, watchdog, and extension-api.
|
|
63
|
-
• status, interrupt, stop, resume, and steer manage live or persisted runs. Use status view:"fleet" for an overview or view:"transcript" with id and optional index to tail output.
|
|
64
|
-
• Create durable project schedules with { action:"schedule.create", id?, name?, sessionOnly?:true, at:"+10m" | ISO, baseRef?, workflowScript:"return runs.run('main', {agent:'worker', task:'...'})" }, or use workflowScriptPath instead. An optional baseRef uses the same managed-worktree ref policy and resolves at allocation; the source checkout must still be clean. With sessionOnly:true, the schedule records the creating session file and only that session can restore or execute it; omitted/false preserves project-wide behavior. Manage them with schedule.list/show/history/pause/resume/run/run-due/delete. This first slice supports fixed intervals; calendar schedules and schedule mission attachment are deferred.
|
|
65
|
-
|
|
66
|
-
${SUBAGENT_SAFETY_GUIDANCE}`;
|
|
67
|
-
|
|
68
|
-
export const COMPACT_SUBAGENT_TOOL_DESCRIPTION = `Run one child with { agent, task? }; use { workflowScript } for inline orchestration or { workflowScriptPath } to load it from the request cwd. The script inputs are mutually exclusive. Omit action for execution. Use action only for management/control actions.
|
|
15
|
+
• Omit action for execution. For an authorized delegated multi-step/parallel workflow: exactly one top-level subagent workflow call with async:true; children launch only inside it.
|
|
16
|
+
• Async follows asyncByDefault (normally true); async:false only to block the parent, not for final reviews/gates. Consume results at dependency barriers. Native async completion wakes this session: return control, no sleep/poll or bg_wait merely for a wake. bg_wait is for provider/detached work without native notification needing a same-turn result.
|
|
17
|
+
• Ordinary child subagents are not orchestrators; only configured fanout within depth/session limits. For an authorized delegated workflow, keep one writer per cwd/worktree and isolate concurrent writers. Use fresh-context read-only reviewers when independent review was requested, then parent synthesis/fixes. Oracle/advisor unknowns use supervisor dialogue; one-shot only when requested.
|
|
18
|
+
• Bind durable output on runs.run/runs.all, not task filename prose; return actual outputReference/outputPathMapping/artifactPaths, evidence and residual risks.
|
|
19
|
+
• children.list: resume only resumable rows. {action:"resume",id,message} detaches a follow-up/challenge with stored agent/model/tool contract. If none is resumable, label a same-role fallback challenge. Scripts await runs.run(newKey,{resume:runId,task}); continue from latest returned runId. Each distinct resume pass needs a new stable key; same-key reuse requires identical launch parameters.
|
|
20
|
+
• Named resources own authority; raw workflowScript/workflowScriptPath cannot use runs.host. Granted commands/relative outputs use workflow cwd, never per-step cwd.
|
|
21
|
+
• Inspect asyncId/asyncDir (status.json, events.jsonl, logs) with status/debug.run; control with interrupt/stop/resume/steer. Read {action:"guide",topic:"tool-reference"} for controls/evidence gates.`;
|
|
22
|
+
|
|
23
|
+
const EXECUTION_GUIDANCE = `Delegate one child with {agent,task?}; otherwise choose exactly one of {workflowScript,args?}, {workflowScriptPath,args?} or {workflow,args}. agent/task exclude workflow inputs; task excludes action. agent may target management actions. action is management/control; validate accepts either script without launching. workflowScriptPath loads from request cwd before sandbox execution.
|
|
24
|
+
Scripts: JavaScript statement bodies with explicit return, top-level await, plain helpers/Promise chains; nested async function/arrow/method helpers are rejected. Await runs.run('key',{agent,task}) before .output; await runs.all([{key,agent,task},...]) for an ordered array, not a key map. Observe every stored run promise with direct await, Promise.race or Promise.all. Await/return runs.steer(key,message,options?) for a prior key, never raw run ids; queued/delivered/missed/failed receipts are not compliance proof.
|
|
25
|
+
Before advanced orchestration (runs.lanes, rolling fanout, mission state, handoffs), read {action:"guide",topic:"workflows"} or the pi-subagents skill. Raw-script sandboxes add deeply frozen args; all sandboxes provide runs, emit, console, JavaScript and enabled mission state, with no filesystem/shell/Pi tools/host globals. External CLI agents support native options only when their runner declares them; read guide tool-reference before passing model, structured output, acceptance/agentContract, tool budget, fast, fork context or skills/tools.
|
|
26
|
+
Model override: first call {action:"models"}; copy exact provider/id, not agent names. Thinking uses model suffix, not watchdog-only thinking.
|
|
27
|
+
Named resources: {workflow:'review',args:{task:'...'}} or {workflow:'run-ci',args:{command:'npm test'}}. Raw scripts also accept bounded plain-data args; raw-script args persist as evidence, so never include secrets. worktree:true requires clean source; baseRef defaults to HEAD at allocation or a supported named ref, never full 40/64-character commit IDs or revision expressions.`;
|
|
28
|
+
|
|
29
|
+
export const DEFAULT_SUBAGENT_TOOL_DESCRIPTION = `${EXECUTION_GUIDANCE}\n\n${SUBAGENT_SAFETY_GUIDANCE}`;
|
|
30
|
+
|
|
31
|
+
export const SUBAGENT_TOOL_PROMPT_SNIPPET = "For operator-requested delegation, use subagents; compose multi-child work in one workflow call.";
|
|
32
|
+
export const SUBAGENT_TOOL_PROMPT_GUIDELINES = [
|
|
33
|
+
"Do not invoke subagents unless the operator requested delegation directly or through applicable instructions.",
|
|
34
|
+
];
|
|
69
35
|
|
|
70
|
-
|
|
36
|
+
export const COMPACT_SUBAGENT_TOOL_DESCRIPTION = DEFAULT_SUBAGENT_TOOL_DESCRIPTION;
|
|
71
37
|
|
|
72
|
-
|
|
73
|
-
• ${EXTERNAL_CLI_RUNNER_GUIDANCE}
|
|
74
|
-
• ${AGENT_SELECTION_GUIDANCE}
|
|
75
|
-
• Passing an explicit model? Call {action:"models"} first and copy an exact provider/id; bare ids resolve only when unique in the registry; agent names (e.g. gpt-pro, advisor) are not model ids. Per-run thinking is a suffix on the model string (provider/id:high; off/minimal/low/medium/high/xhigh/max), and the suffix wins over the agent's thinking default; the thinking field only applies to action='watchdog.configure' and is ignored on dispatch.
|
|
76
|
-
• SINGLE {agent:"worker",task:"..."} starts exactly one direct child. Fields apply to that child. Do not combine agent/task with action, workflowScript, or workflowScriptPath.
|
|
77
|
-
• SCRIPT {workflowScript:"return runs.run('main', {agent:'worker', task:'...'})"}. Use stable-key runs.run for one child and await runs.all([{key,agent,task}, ...]) for ordinary parallel work. runs.all resolves to an ordered array, not a key map; use results[0], destructuring, or results.map(...), not results.<key>. Do not read .output from unawaited runs.run launches. Stored runs.run promises are only for advanced rolling fanout and each must later be observed with direct await, Promise.race, or Promise.all. Await runs.steer(key,message,options?) to guide a prior keyed child; it returns queued, delivered, missed, or failed and never accepts a raw run id. Always await or return steering calls. Use {action:"children.list"} for recent retained workflow children and resume only rows reported resumable. Use {action:"resume",id:"run-id",message:"..."} for a simple follow-up or challenge; resume keeps the stored agent/model/tool contract. If none is resumable, launch a same-role fallback challenge and label it as fallback. Inside workflowScript use runs.run(key,{resume:"run-id",task:"follow-up"}) when the script must wait for completion and continue from the latest returned runId. Workflows get async state.get/state.set through their automatic or explicit mission; mission:false does not. Scripts are ordinary JavaScript statement bodies; use explicit return for a useful result. Use top-level await, plain helper functions, or explicit Promise chains; nested async function, arrow, and method helpers are rejected. For task text with Markdown fences or shell blocks, build quoted lines instead of nesting raw template literals: \`const task=["Run:","\`\`\`bash","npm test","\`\`\`"].join("\\n")\`. Use JavaScript for sequence, branching, retries, and aggregation. For repository mutation lanes, use worktree:true on the workflow or runs.run/runs.all item for managed isolation. ${WORKTREE_BASE_REF_GUIDANCE} Scripts normally start async unless config sets asyncByDefault:false; set async:true explicitly when async behavior matters. async:false blocks the parent until completion and auto-enables a same-repo live chat card unless chatProgress is off; explicit live-card requires same-repository async:false, so async workflows should omit chatProgress or use auto/off.
|
|
78
|
-
• ${WORKFLOW_LANES_GUIDANCE}
|
|
79
|
-
• FILE SCRIPT {workflowScriptPath:"workflows/review.js"} loads the script on the host relative to the request cwd before sandbox execution. Do not combine it with workflowScript.
|
|
80
|
-
• Example: {workflowScript:"const [a,b]=await runs.all([{key:'a',agent:'agent-a',task:'Implement A',worktree:true},{key:'b',agent:'agent-b',task:'Implement B',worktree:true}]); return [a.output,b.output]"}
|
|
81
|
-
• context can be fresh, fork, or profile. profile requires the selected agent's declared defaultContext and ignores defaultSubagentContext. Explicit fresh/fork wins; omitted context follows defaultSubagentContext before agent defaultContext. Config forkContext can summarize transcript overflow with stable recovery refs before spawn without adding another public context value. timeoutMs/maxRuntimeMs apply to foreground and async workflows; foreground workflows default to 30 minutes and async workflows have no default timeout. Omit acceptance for reviewer/read-only calls.
|
|
82
|
-
|
|
83
|
-
MANAGE / CONTROL:
|
|
84
|
-
• Use action without execution fields for list/get/models/guide/authoring, refine/refine.show/refine.rollback, mission, watchdog, status, interrupt, stop, resume, steer, worktree.cleanup (mode:'plan' only), script-only scheduling, diagnostics, and other management actions. guide reads shipped current-version docs by topic.
|
|
85
|
-
• A mission object needs exactly one non-empty title or summary; objective and labels are optional. goal may only be true and requires budget:{tokens}.
|
|
86
|
-
|
|
87
|
-
ASYNC / SAFETY:
|
|
88
|
-
• ${SUBAGENT_FAILURE_RECOVERY_GUIDANCE}
|
|
89
|
-
• Omitted async follows asyncByDefault config; set async:true explicitly when async behavior matters. Continue independent work only until its next dependency barrier; consume the result before work that depends on it. Ordinary async subagents notify this session natively, so return control and do not call bg_wait merely to get a completion wake. Do not sleep or poll merely to wait; use bg_wait only for provider, detached, or other background work without a native notification when this turn must receive its result.
|
|
90
|
-
• ${WORKFLOW_RESUME_KEY_GUIDANCE}
|
|
91
|
-
• ${WORKFLOW_OUTPUT_BINDING_GUIDANCE}
|
|
92
|
-
• ${WORKFLOW_HOST_GUIDANCE}
|
|
93
|
-
• Ordinary children are not orchestrators. Keep one writer per cwd/worktree and use fresh read-only reviewers for independent checks.
|
|
94
|
-
• Oracle/advisor consultations use available supervisor dialogue for material unknowns; request one-shot when desired.
|
|
95
|
-
• Status and artifacts live under asyncId/asyncDir with status.json, events.jsonl, output logs, and {action:"status",id:"..."}.`;
|
|
38
|
+
export const FULL_SUBAGENT_TOOL_DESCRIPTION = `${DEFAULT_SUBAGENT_TOOL_DESCRIPTION}
|
|
96
39
|
|
|
40
|
+
WORKFLOW DETAILS:
|
|
41
|
+
• runs.lanes([{key,stages:[{key,agent,task},{key,resume:'previous',task}]}]) runs first stages together, later stages sequentially per lane. Failures stay lane-local; only explicit structuredOutput.verdict === 'blocked' blocks a successful stage, never reviewer prose.
|
|
42
|
+
• Workflow child controls default onto runs.run/runs.all items; child fields override them. worktree:true isolates each child and returns handoff artifacts. usageBudget is shared across the workflow; already-running children are not stopped.
|
|
43
|
+
• Missions auto-attach unless mission:false; await state.get(key)/state.set(key,JSONValue) requires a mission. See guide topic missions. Omit acceptance for reviewer/read-only calls; acceptance.review.required requests independent writer review.
|
|
44
|
+
• Management discovery: list/get/models/guide; create/update/delete/eject/disable/enable/reset/refine; mission.*, schedule.*, watchdog.*, inspector.*, project.*, lane.status/recordMerge/recordSupersession; worktree.discard and plan-only worktree.cleanup; doctor and grant-spawn-budget. Use guide topics agents, missions, observability, tool-reference, configuration, models, watchdog or extension-api for exact action fields. Schedules take script inputs, not direct children; recipes live in the missions guide.`;
|
|
97
45
|
|
|
98
46
|
function isToolDescriptionMode(value: unknown): value is ToolDescriptionMode {
|
|
99
47
|
return value === "full" || value === "compact" || value === "custom";
|