pi-subagents 0.65.1 → 0.67.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 +123 -0
- package/README.md +5 -4
- package/agents/evidence-auditor.md +34 -0
- package/agents/researcher.md +23 -13
- package/agents/reviewer.md +3 -2
- package/docs/agents.md +20 -3
- package/docs/configuration.md +25 -5
- package/docs/extension-api.md +124 -18
- package/docs/missions.md +8 -0
- package/docs/models.md +59 -2
- package/docs/observability.md +46 -6
- package/docs/standalone-background.md +49 -0
- package/docs/tool-reference.md +20 -10
- package/docs/watchdog.md +35 -4
- package/docs/workflows.md +40 -19
- package/inspector-runner.mjs +2 -2
- package/package.json +2 -1
- package/prompts/parallel-review.md +1 -1
- package/{runner-server-preload.mjs → runner-peer-preload.mjs} +8 -3
- package/skills/pi-subagents/SKILL.md +14 -0
- package/skills/pi-subagents/references/execution-controls.md +20 -5
- package/skills/pi-subagents/references/management-authoring-rpc.md +2 -1
- package/skills/pi-subagents/references/prompting-and-roles.md +2 -2
- package/src/agents/advertised-agent-prompt.ts +94 -0
- package/src/agents/agent-management.ts +14 -1
- package/src/agents/agent-serializer.ts +2 -0
- package/src/agents/agents.ts +14 -0
- package/src/agents/builtin-names.ts +1 -0
- package/src/api/delegation.ts +4 -0
- package/src/api/preflight.ts +76 -45
- package/src/api/shared-types.ts +3 -1
- package/src/api/workflow-resources.ts +6 -0
- package/src/extension/fanout-child.ts +63 -4
- package/src/extension/index.ts +58 -8
- package/src/extension/public-execution.ts +4 -3
- package/src/extension/rpc.ts +8 -21
- package/src/extension/schemas.ts +71 -80
- package/src/extension/tool-description.ts +29 -81
- 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 +104 -67
- package/src/runs/background/active-async-capacity.ts +22 -18
- package/src/runs/background/async-execution.ts +45 -56
- package/src/runs/background/async-job-tracker.ts +35 -3
- package/src/runs/background/async-resume.ts +5 -9
- package/src/runs/background/async-status-snapshot.ts +10 -12
- package/src/runs/background/async-status.ts +17 -9
- package/src/runs/background/auto-drain.ts +44 -30
- package/src/runs/background/binary-bootstrap.ts +33 -0
- package/src/runs/background/chain-root-attachment.ts +8 -0
- package/src/runs/background/control-channel.ts +78 -44
- package/src/runs/background/fleet-view.ts +30 -2
- package/src/runs/background/notify.ts +117 -13
- package/src/runs/background/owned-process-tree.ts +35 -8
- package/src/runs/background/process-terminal.ts +23 -23
- package/src/runs/background/run-child-session.ts +121 -36
- package/src/runs/background/run-status.ts +78 -5
- package/src/runs/background/runner-aliases.ts +28 -9
- package/src/runs/background/runner-child-launch.ts +88 -0
- package/src/runs/background/runner-child-sessions.ts +5 -4
- package/src/runs/background/scheduled-runs.ts +40 -13
- package/src/runs/background/stale-run-reconciler.ts +3 -1
- package/src/runs/background/steering.ts +20 -2
- package/src/runs/background/subagent-runner.ts +458 -239
- package/src/runs/background/subagent-wait.ts +54 -8
- package/src/runs/background/wait-completions.ts +4 -0
- package/src/runs/background/wait-tool.ts +1 -1
- package/src/runs/foreground/async-steering-action.ts +37 -7
- package/src/runs/foreground/execution.ts +145 -56
- package/src/runs/foreground/prompt-audit.ts +3 -1
- package/src/runs/foreground/subagent-executor.ts +584 -297
- package/src/runs/foreground/workflow-detach-reconcile.ts +10 -5
- package/src/runs/foreground/workflow-foreground-steering.ts +57 -2
- package/src/runs/shared/acceptance.ts +7 -4
- package/src/runs/shared/agent-contract.ts +1 -1
- package/src/runs/shared/async-status-projection.ts +51 -47
- package/src/runs/shared/capability-ceiling.ts +2 -0
- package/src/runs/shared/child-hooks.ts +167 -3
- package/src/runs/shared/child-launch.ts +28 -13
- package/src/runs/shared/child-lifecycle.ts +6 -3
- package/src/runs/shared/child-runtime-config.ts +3 -1
- package/src/runs/shared/child-session.ts +75 -8
- package/src/runs/shared/child-tool-plan.ts +124 -5
- package/src/runs/shared/completion-evidence.ts +2 -2
- package/src/runs/shared/completion-guard.ts +6 -3
- package/src/runs/shared/effective-system-prompt.ts +33 -0
- package/src/runs/shared/external-cli-runner.ts +9 -7
- package/src/runs/shared/host-step-status.ts +11 -11
- package/src/runs/shared/llm-intent-arbiter.ts +21 -11
- package/src/runs/shared/model-fallback.ts +12 -6
- package/src/runs/shared/nested-events.ts +5 -5
- package/src/runs/shared/orca-progress-tabs.ts +7 -1
- package/src/runs/shared/parallel-handoff.ts +57 -12
- package/src/runs/shared/parallel-utils.ts +2 -2
- package/src/runs/shared/pi-spawn.ts +10 -0
- package/src/runs/shared/readonly-drain-observation.ts +42 -0
- package/src/runs/shared/readonly-model-continuation.ts +69 -0
- package/src/runs/shared/readonly-session-evidence.ts +307 -0
- package/src/runs/shared/run-fanout-budget.ts +8 -8
- package/src/runs/shared/runtime-acknowledged-extensions.ts +3 -3
- package/src/runs/shared/subagent-prompt-runtime.ts +20 -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 +190 -0
- package/src/runs/shared/worktree.ts +366 -208
- package/src/shared/fork-context.ts +15 -72
- package/src/shared/launch-contract.ts +65 -2
- package/src/shared/opencode-session-headers.ts +30 -0
- package/src/shared/types.ts +85 -61
- package/src/shared/utils.ts +7 -2
- package/src/shared/workflow-child-permit.ts +18 -13
- package/src/slash/delegation-adapters.ts +3 -1
- package/src/slash/delegation-request.ts +14 -0
- package/src/slash/slash-commands.ts +2 -1
- package/src/slash/subagents-admin.ts +11 -4
- package/src/tui/fleet-status.ts +164 -19
- package/src/tui/fleet.ts +27 -19
- package/src/tui/render.ts +172 -33
- package/src/watchdog/child-status.ts +8 -0
- package/src/watchdog/model-selection.ts +20 -0
- package/src/watchdog/permission-arbiter.ts +3 -1
- package/src/watchdog/register-child.ts +1 -0
- package/src/watchdog/register-main.ts +31 -27
- package/src/watchdog/review.ts +132 -67
- package/src/watchdog/runtime.ts +82 -20
- package/src/watchdog/scope.ts +1 -1
- package/src/watchdog/settings.ts +9 -3
- package/src/watchdog/tool-actions.ts +13 -12
- package/src/watchdog/turn-delta.ts +23 -0
- package/src/watchdog/types.ts +4 -0
- package/src/workflows/chat-progress.ts +3 -3
- package/src/workflows/scripted-workflow.ts +275 -17
- package/src/workflows/workflow-checklist.ts +13 -17
- package/src/workflows/workflow-child-summary.ts +57 -8
- package/src/workflows/workflow-preflight.ts +19 -19
- package/src/workflows/workflow-receipt.ts +3 -3
- package/src/workflows/workflow-resources.ts +96 -21
- package/src/workflows/workflow-settlement.ts +3 -0
- /package/src/inspectors/{herdr/shell-command.ts → shell-command.ts} +0 -0
package/src/extension/rpc.ts
CHANGED
|
@@ -499,9 +499,13 @@ function manageParams(params: unknown): SubagentParamsLike {
|
|
|
499
499
|
if (requiresId && typeof input.id !== "string") {
|
|
500
500
|
throw new SubagentRpcError("invalid_params", `RPC manage ${action} requires id.`);
|
|
501
501
|
}
|
|
502
|
+
if (action === "schedule.run" && input.quiet !== undefined && typeof input.quiet !== "boolean") {
|
|
503
|
+
throw new SubagentRpcError("invalid_params", "RPC manage quiet must be a boolean.");
|
|
504
|
+
}
|
|
502
505
|
const output: SubagentParamsLike = {
|
|
503
506
|
action,
|
|
504
507
|
...(typeof input.id === "string" ? { id: input.id.trim() } : {}),
|
|
508
|
+
...(action === "schedule.run" && input.quiet === true ? { quiet: true } : {}),
|
|
505
509
|
};
|
|
506
510
|
assertSubagentParams(output, "RPC manage params");
|
|
507
511
|
return output;
|
|
@@ -643,27 +647,10 @@ function stopAsyncRun(
|
|
|
643
647
|
message: `Stop requested for async run ${initialRunId}.`,
|
|
644
648
|
};
|
|
645
649
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
kill: options.kill,
|
|
651
|
-
now: options.now,
|
|
652
|
-
source: "rpc-stop",
|
|
653
|
-
...(child ? { targetIndex: child.index, childId: child.id } : {}),
|
|
654
|
-
});
|
|
655
|
-
} catch (error) {
|
|
656
|
-
throw new SubagentRpcError("execution_failed", error instanceof Error ? error.message : String(error));
|
|
657
|
-
}
|
|
658
|
-
if (child) emitChildStopping(initialRunId, location.asyncDir, child);
|
|
659
|
-
return {
|
|
660
|
-
runId: initialRunId,
|
|
661
|
-
asyncDir: location.asyncDir,
|
|
662
|
-
previousState: initialStatus.state,
|
|
663
|
-
state: "stopping",
|
|
664
|
-
...(child ? { childId: child.id } : {}),
|
|
665
|
-
message: child ? `Stop requested for child ${child.id} in async run ${initialRunId}.` : `Stop requested for async run ${initialRunId}.`,
|
|
666
|
-
};
|
|
650
|
+
// Workflow controls live in-process; a persisted run directory cannot restore them.
|
|
651
|
+
throw new SubagentRpcError("invalid_state", child
|
|
652
|
+
? `Child '${child.id}' in workflow ${initialRunId} has no live stop callback available.`
|
|
653
|
+
: `Workflow ${initialRunId} has no live run controller available to stop.`);
|
|
667
654
|
}
|
|
668
655
|
|
|
669
656
|
let status;
|
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,21 +62,11 @@ 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
|
-
|
|
69
|
-
|
|
70
|
-
"tests-added",
|
|
71
|
-
"commands-run",
|
|
72
|
-
"validation-output",
|
|
73
|
-
"residual-risks",
|
|
74
|
-
"no-staged-files",
|
|
75
|
-
"diff-summary",
|
|
76
|
-
"review-findings",
|
|
77
|
-
"manual-notes",
|
|
78
|
-
];
|
|
79
|
-
|
|
68
|
+
// Provider boolean branches intentionally overapproximate false-only runtime inputs.
|
|
69
|
+
// Restricted function-declaration converters only support string enum members.
|
|
80
70
|
const AcceptanceOverride = Type.Unsafe({
|
|
81
71
|
anyOf: [
|
|
82
72
|
{ type: "string", enum: ["auto", "attested", "checked"] },
|
|
@@ -89,10 +79,10 @@ const AcceptanceOverride = Type.Unsafe({
|
|
|
89
79
|
{
|
|
90
80
|
type: "string",
|
|
91
81
|
},
|
|
92
|
-
{ type: "boolean"
|
|
82
|
+
{ type: "boolean" },
|
|
93
83
|
{ type: "object", additionalProperties: true },
|
|
94
84
|
],
|
|
95
|
-
description:
|
|
85
|
+
description: "Evidence policy; omit for read-only/review. false disables; true invalid. Prefer object; see guide tool-reference for levels, evidence and review.required.",
|
|
96
86
|
});
|
|
97
87
|
|
|
98
88
|
const AgentContractOverride = Type.Object({
|
|
@@ -111,7 +101,7 @@ const WorkflowLaneMetadata = Type.Object({
|
|
|
111
101
|
sourceRef: Type.Optional(Type.String({ minLength: 1, maxLength: 128 })),
|
|
112
102
|
claims: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 160 }), { maxItems: 20 })),
|
|
113
103
|
outputPaths: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: 256 }), { maxItems: 10 })),
|
|
114
|
-
}, { additionalProperties: false, description: "
|
|
104
|
+
}, { additionalProperties: false, description: "Display/triage only; sourceRef is opaque, never resolved by status." });
|
|
115
105
|
|
|
116
106
|
const ToolBudgetBlock = Type.Unsafe({
|
|
117
107
|
anyOf: [
|
|
@@ -124,7 +114,7 @@ const ToolBudgetOverride = Type.Object({
|
|
|
124
114
|
soft: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
125
115
|
hard: Type.Integer({ minimum: 1 }),
|
|
126
116
|
block: Type.Optional(ToolBudgetBlock),
|
|
127
|
-
}, { additionalProperties: false, description: "
|
|
117
|
+
}, { additionalProperties: false, description: "soft nudges; after hard, block tools (default read/grep/find/ls, '*' for all) so child can finalize." });
|
|
128
118
|
|
|
129
119
|
const UsageBudgetLimitOverride = Type.Object({
|
|
130
120
|
soft: Type.Optional(Type.Number({ exclusiveMinimum: 0 })),
|
|
@@ -134,7 +124,7 @@ const UsageBudgetLimitOverride = Type.Object({
|
|
|
134
124
|
const UsageBudgetOverride = Type.Object({
|
|
135
125
|
tokens: Type.Optional(UsageBudgetLimitOverride),
|
|
136
126
|
costUsd: Type.Optional(UsageBudgetLimitOverride),
|
|
137
|
-
}, { additionalProperties: false, description: "
|
|
127
|
+
}, { additionalProperties: false, description: "Root-only reported usage; hard prevents later launches. Running children are not stopped." });
|
|
138
128
|
|
|
139
129
|
const WorkflowPreflightLane = Type.Object({
|
|
140
130
|
key: Type.String({ minLength: 1, maxLength: 128 }),
|
|
@@ -149,7 +139,7 @@ const WorkflowPreflightOverride = Type.Object({
|
|
|
149
139
|
version: Type.Integer({ minimum: 1, maximum: 1 }),
|
|
150
140
|
coverage: Type.Optional(Type.String({ enum: ["complete", "partial"] })),
|
|
151
141
|
lanes: Type.Array(WorkflowPreflightLane, { maxItems: 64 }),
|
|
152
|
-
}, { additionalProperties: false, description: "
|
|
142
|
+
}, { additionalProperties: false, description: "Display-only lane hints; coverage mismatches warn, never change authority/execution." });
|
|
153
143
|
|
|
154
144
|
// Parallel task item (within a parallel step)
|
|
155
145
|
export const ParallelTaskSchema = Type.Object({
|
|
@@ -257,7 +247,7 @@ export const ChainItem = Type.Object({
|
|
|
257
247
|
const MissionLaunchOverride = Type.Unsafe({
|
|
258
248
|
anyOf: [
|
|
259
249
|
{ type: "object", additionalProperties: true },
|
|
260
|
-
{ type: "boolean"
|
|
250
|
+
{ type: "boolean" },
|
|
261
251
|
],
|
|
262
252
|
});
|
|
263
253
|
const MissionUpdateOverride = Type.Unsafe({ type: "object", additionalProperties: true });
|
|
@@ -278,58 +268,59 @@ const ControlOverrides = Type.Object({
|
|
|
278
268
|
});
|
|
279
269
|
|
|
280
270
|
const SubagentParamProperties = {
|
|
281
|
-
agent: Type.Optional(Type.String({ description: "
|
|
282
|
-
task: Type.Optional(Type.String({ description: "
|
|
283
|
-
extensionBindings: Type.Optional(Type.Unsafe({ type: "object", maxProperties: 16, additionalProperties: true, description: "
|
|
271
|
+
agent: Type.Optional(Type.String({ description: "One-child agent or management target." })),
|
|
272
|
+
task: Type.Optional(Type.String({ description: "One-child task; requires agent." })),
|
|
273
|
+
extensionBindings: Type.Optional(Type.Unsafe({ type: "object", maxProperties: 16, additionalProperties: true, description: "Child-only bounded JSON; namespaces package.name/1." })),
|
|
284
274
|
// Management action (when present, tool operates in management mode)
|
|
285
275
|
action: Type.Optional(Type.String({ minLength: 1,
|
|
286
|
-
description: "
|
|
276
|
+
description: "Management/control only; omit for execution. validate accepts either script input. Discover actions with guide topic tool-reference."
|
|
287
277
|
})),
|
|
288
|
-
capabilities: Type.Optional(Type.Boolean({ description: "
|
|
289
|
-
name: Type.Optional(Type.String({ description: "
|
|
278
|
+
capabilities: Type.Optional(Type.Boolean({ description: "list: compact capability rows/details without system prompts." })),
|
|
279
|
+
name: Type.Optional(Type.String({ description: "schedule.create name." })),
|
|
290
280
|
id: Type.Optional(Type.String({
|
|
291
|
-
description: "Run id/prefix for status/
|
|
281
|
+
description: "Run id/prefix for status/control."
|
|
292
282
|
})),
|
|
293
283
|
runId: Type.Optional(Type.String({
|
|
294
|
-
description: "Target run ID
|
|
284
|
+
description: "Target run ID; prefer id."
|
|
295
285
|
})),
|
|
296
286
|
dir: Type.Optional(Type.String({
|
|
297
|
-
description: "Async
|
|
287
|
+
description: "Async directory for status/control."
|
|
298
288
|
})),
|
|
299
|
-
handoffPath: Type.Optional(Type.String({ description: "Existing
|
|
300
|
-
repo: Type.Optional(Type.String({ description: "
|
|
301
|
-
planId: Type.Optional(Type.String({ description: "
|
|
302
|
-
laneId: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "Exact manifest run id for lane
|
|
303
|
-
merge: Type.Optional(Type.Unsafe({ type: "object", additionalProperties: true, description: "
|
|
304
|
-
supersession: Type.Optional(Type.Unsafe({ type: "object", additionalProperties: true, description: "
|
|
305
|
-
index: Type.Optional(Type.Integer({ minimum: 0, description: "Zero-based child index
|
|
306
|
-
childId: Type.Optional(Type.String({ minLength: 1, maxLength: 256, description: "
|
|
289
|
+
handoffPath: Type.Optional(Type.String({ description: "Existing manifest for worktree/lane actions." })),
|
|
290
|
+
repo: Type.Optional(Type.String({ description: "worktree.cleanup repo; default cwd." })),
|
|
291
|
+
planId: Type.Optional(Type.String({ description: "Reserved; cleanup is plan-only." })),
|
|
292
|
+
laneId: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "Exact manifest run id for lane actions." })),
|
|
293
|
+
merge: Type.Optional(Type.Unsafe({ type: "object", additionalProperties: true, description: "lane.recordMerge evidence; read guide tool-reference." })),
|
|
294
|
+
supersession: Type.Optional(Type.Unsafe({ type: "object", additionalProperties: true, description: "lane.recordSupersession evidence; read guide tool-reference." })),
|
|
295
|
+
index: Type.Optional(Type.Integer({ minimum: 0, description: "Zero-based child/transcript index." })),
|
|
296
|
+
childId: Type.Optional(Type.String({ minLength: 1, maxLength: 256, description: "Child-scoped stop identity." })),
|
|
307
297
|
view: Type.Optional(Type.String({
|
|
308
298
|
enum: ["fleet", "transcript"],
|
|
309
|
-
description: "
|
|
299
|
+
description: "status view: fleet overview or transcript tail with id/dir and optional index.",
|
|
310
300
|
})),
|
|
311
|
-
lines: Type.Optional(Type.Integer({ minimum: 1, maximum: 500, description: "
|
|
301
|
+
lines: Type.Optional(Type.Integer({ minimum: 1, maximum: 500, description: "Transcript tail lines; default 80." })),
|
|
312
302
|
topic: Type.Optional(Type.String()),
|
|
313
|
-
message: Type.Optional(Type.String({ description: "
|
|
314
|
-
mode: Type.Optional(Type.String({ enum: ["steer", "follow_up", "auto", "plan", "apply"], description: "
|
|
315
|
-
steeringRecovery: Type.Optional(Type.Boolean({ description: "
|
|
316
|
-
additional: Type.Optional(Type.Integer({ minimum: 1, description: "
|
|
317
|
-
scope: Type.Optional(Type.String({ enum: ["session", "user", "project"], description: "
|
|
318
|
-
target: Type.Optional(Type.String({ enum: ["main", "children", "child"], description: "
|
|
319
|
-
focus: Type.Optional(Type.Boolean({ description: "Focus
|
|
320
|
-
thinking: Type.Optional(Type.Unsafe({ anyOf: [{ type: "string" }, { type: "boolean"
|
|
321
|
-
at: Type.Optional(Type.String({ description: "
|
|
322
|
-
every: Type.Optional(Type.String({ description: "
|
|
303
|
+
message: Type.Optional(Type.String({ description: "resume/steer guidance or project.open prompt." })),
|
|
304
|
+
mode: Type.Optional(Type.String({ enum: ["steer", "follow_up", "auto", "plan", "apply"], description: "steer delivery mode; worktree.cleanup supports plan only, no apply/removal." })),
|
|
305
|
+
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." })),
|
|
306
|
+
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." })),
|
|
307
|
+
scope: Type.Optional(Type.String({ enum: ["session", "user", "project"], description: "watchdog.configure scope; default session, persistent only if explicit." })),
|
|
308
|
+
target: Type.Optional(Type.String({ enum: ["main", "children", "child"], description: "Watchdog target." })),
|
|
309
|
+
focus: Type.Optional(Type.Boolean({ description: "Focus inspector.open/project.open pane." })),
|
|
310
|
+
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." })),
|
|
311
|
+
at: Type.Optional(Type.String({ description: "schedule.create: delay (+10m) or zoned ISO timestamp." })),
|
|
312
|
+
every: Type.Optional(Type.String({ description: "schedule.create interval, e.g. 30m/6h/2d/2w." })),
|
|
323
313
|
sessionOnly: Type.Optional(Type.Boolean()),
|
|
324
|
-
|
|
314
|
+
quiet: Type.Optional(Type.Boolean()),
|
|
315
|
+
on: Type.Optional(Type.Unsafe({ anyOf: [{ type: "string" }, { type: "integer" }], description: "Reserved calendar selector." })),
|
|
325
316
|
timezone: Type.Optional(Type.String()),
|
|
326
|
-
overlap: Type.Optional(Type.String({ enum: ["skip"]
|
|
327
|
-
catchUp: Type.Optional(Type.String({ enum: ["none", "latest"], description: "Missed
|
|
328
|
-
missionId: Type.Optional(Type.String(
|
|
329
|
-
mission: Type.Optional(Type.Unsafe({ ...MissionLaunchOverride, description: "
|
|
330
|
-
missionUpdate: Type.Optional(Type.Unsafe({ ...MissionUpdateOverride, description: "Mission
|
|
331
|
-
missionStatus: Type.Optional(Type.String(
|
|
332
|
-
missionScope: Type.Optional(Type.String({ description: "
|
|
317
|
+
overlap: Type.Optional(Type.String({ enum: ["skip"] })),
|
|
318
|
+
catchUp: Type.Optional(Type.String({ enum: ["none", "latest"], description: "Missed schedule occurrences; default latest." })),
|
|
319
|
+
missionId: Type.Optional(Type.String()),
|
|
320
|
+
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." })),
|
|
321
|
+
missionUpdate: Type.Optional(Type.Unsafe({ ...MissionUpdateOverride, description: "Mission patch; read guide missions." })),
|
|
322
|
+
missionStatus: Type.Optional(Type.String()),
|
|
323
|
+
missionScope: Type.Optional(Type.String({ description: "project (default) or global pointer index." })),
|
|
333
324
|
runMode: Type.Optional(Type.String({ description: "Attached run mode." })),
|
|
334
325
|
runStatus: Type.Optional(Type.String({ description: "Attached run status." })),
|
|
335
326
|
summary: Type.Optional(Type.String({ description: "Mission close summary." })),
|
|
@@ -339,37 +330,37 @@ const SubagentParamProperties = {
|
|
|
339
330
|
{ type: "object", additionalProperties: true },
|
|
340
331
|
{ type: "string" },
|
|
341
332
|
],
|
|
342
|
-
description: "
|
|
333
|
+
description: "create/update agent config; object or JSON string."
|
|
343
334
|
})),
|
|
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
|
|
346
|
-
workflowScript: Type.Optional(Type.String({ minLength: 1, description: "Inline JavaScript statement body
|
|
347
|
-
workflowScriptPath: Type.Optional(Type.String({ minLength: 1, description: "
|
|
335
|
+
workflow: Type.Optional(Type.String({ minLength: 1, description: "Extension-owned workflow resource." })),
|
|
336
|
+
args: Type.Optional(Type.Unsafe({ type: "object", maxProperties: 16, additionalProperties: true, description: "Bounded plain-JSON resource args." })),
|
|
337
|
+
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." })),
|
|
338
|
+
workflowScriptPath: Type.Optional(Type.String({ minLength: 1, description: "Raw script file; host reads from request cwd before sandbox. Mutually exclusive with workflowScript and workflow." })),
|
|
348
339
|
globalConcurrencyLimit: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
349
340
|
maxSubagentSpawnsPerRun: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
350
341
|
preflight: Type.Optional(WorkflowPreflightOverride),
|
|
351
|
-
chatProgress: Type.Optional(Type.String({ enum: ["auto", "off", "live-card"], description: "
|
|
352
|
-
isolation: Type.Optional(Type.String({ enum: ["none", "worktree"], description: "
|
|
353
|
-
worktree: Type.Optional(Type.Boolean({ description: "
|
|
342
|
+
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." })),
|
|
343
|
+
isolation: Type.Optional(Type.String({ enum: ["none", "worktree"], description: "Shared cwd or managed git worktrees." })),
|
|
344
|
+
worktree: Type.Optional(Type.Boolean({ description: "Isolate each workflow child in a managed git worktree; child worktree:false overrides default." })),
|
|
354
345
|
baseRef: Type.Optional(Type.String()),
|
|
355
346
|
lane: Type.Optional(WorkflowLaneMetadata),
|
|
356
347
|
context: Type.Optional(Type.String({
|
|
357
348
|
enum: ["fresh", "fork", "profile"],
|
|
358
|
-
description: "
|
|
349
|
+
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.",
|
|
359
350
|
})),
|
|
360
|
-
async: Type.Optional(Type.Boolean({ description: "
|
|
351
|
+
async: Type.Optional(Type.Boolean({ description: "Background; default asyncByDefault. false only to block parent." })),
|
|
361
352
|
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." })),
|
|
362
|
-
maxRuntimeMs: Type.Optional(Type.Integer({ minimum: 1, description: "Alias timeoutMs
|
|
363
|
-
toolTimeoutMs: Type.Optional(Type.Integer({ minimum: 1, description: "
|
|
353
|
+
maxRuntimeMs: Type.Optional(Type.Integer({ minimum: 1, description: "Alias timeoutMs (same defaults)." })),
|
|
354
|
+
toolTimeoutMs: Type.Optional(Type.Integer({ minimum: 1, description: "Per-tool deadline (ms); fast builtins default 5m." })),
|
|
364
355
|
toolBudget: Type.Optional(ToolBudgetOverride),
|
|
365
356
|
usageBudget: Type.Optional(UsageBudgetOverride),
|
|
366
|
-
agentScope: Type.Optional(Type.String({ description: "
|
|
367
|
-
cwd: Type.Optional(Type.String({ description: "Execution
|
|
368
|
-
artifacts: Type.Optional(Type.Boolean({ description: "
|
|
369
|
-
includeProgress: Type.Optional(Type.Boolean({ description: "
|
|
370
|
-
share: Type.Optional(Type.Boolean({ description: "Upload session to GitHub Gist
|
|
357
|
+
agentScope: Type.Optional(Type.String({ description: "user/project/both (default); project wins collisions." })),
|
|
358
|
+
cwd: Type.Optional(Type.String({ description: "Execution/project-pane directory." })),
|
|
359
|
+
artifacts: Type.Optional(Type.Boolean({ description: "Debug artifacts; default true." })),
|
|
360
|
+
includeProgress: Type.Optional(Type.Boolean({ description: "Full result progress; default false." })),
|
|
361
|
+
share: Type.Optional(Type.Boolean({ description: "Upload session to GitHub Gist; default false." })),
|
|
371
362
|
sessionDir: Type.Optional(
|
|
372
|
-
Type.String({ description: "
|
|
363
|
+
Type.String({ description: "Session log directory; default temp, independent of share." }),
|
|
373
364
|
),
|
|
374
365
|
control: Type.Optional(ControlOverrides),
|
|
375
366
|
// Workflow defaults forwarded to each runs.run/runs.all child unless overridden there.
|
|
@@ -378,12 +369,12 @@ const SubagentParamProperties = {
|
|
|
378
369
|
{ type: "string" },
|
|
379
370
|
{ type: "boolean" },
|
|
380
371
|
],
|
|
381
|
-
description: "
|
|
372
|
+
description: "Child output path or false; relative workflow paths use managed artifact routing. Bind durable output here, not task prose; return outputReference/outputPathMapping/artifactPaths.",
|
|
382
373
|
})),
|
|
383
374
|
outputMode: Type.Optional(OutputModeOverride),
|
|
384
375
|
skill: Type.Optional(SkillOverride),
|
|
385
|
-
model: Type.Optional(Type.String({ description: "
|
|
386
|
-
fast: Type.Optional(Type.Boolean({ description: "
|
|
376
|
+
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." })),
|
|
377
|
+
fast: Type.Optional(Type.Boolean({ description: "Native OpenAI-Codex priority tier; default false, may cost more/quota." })),
|
|
387
378
|
outputSchema: Type.Optional(JsonSchemaObject),
|
|
388
379
|
agentContract: Type.Optional(AgentContractOverride),
|
|
389
380
|
acceptance: Type.Optional(AcceptanceOverride),
|
|
@@ -5,94 +5,42 @@ 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 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.";
|
|
15
|
-
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.";
|
|
16
|
-
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'). v1 supports only command steps; output is bounded and command failure fails the workflow.";
|
|
17
|
-
|
|
18
|
-
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} ${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.`;
|
|
19
|
-
|
|
20
|
-
export const SUBAGENT_TOOL_PROMPT_SNIPPET = "Delegate to subagents; orchestrate in one workflowScript call.";
|
|
21
|
-
|
|
22
|
-
export const SUBAGENT_TOOL_PROMPT_GUIDELINES = [
|
|
23
|
-
`Use subagent only when delegation is needed. ${AGENT_SELECTION_GUIDANCE}`,
|
|
24
|
-
'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.',
|
|
25
|
-
"workflowScript rejects nested async function, arrow, and method helpers; use top-level await, plain helper functions, or explicit Promise chains.",
|
|
26
|
-
"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.",
|
|
27
|
-
'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" }.',
|
|
28
|
-
];
|
|
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.";
|
|
29
10
|
|
|
30
11
|
export const SUBAGENT_SAFETY_GUIDANCE = `SAFETY-CRITICAL SUBAGENT GUIDANCE:
|
|
31
12
|
• ${AGENT_SELECTION_GUIDANCE}
|
|
32
13
|
• ${SUBAGENT_FAILURE_RECOVERY_GUIDANCE}
|
|
33
|
-
•
|
|
34
|
-
• Async
|
|
35
|
-
•
|
|
36
|
-
•
|
|
37
|
-
•
|
|
38
|
-
•
|
|
39
|
-
•
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
• ${WORKFLOW_LANES_GUIDANCE}
|
|
54
|
-
• 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.
|
|
55
|
-
• 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" }
|
|
56
|
-
• 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}" }
|
|
57
|
-
• 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.
|
|
58
|
-
• 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}.
|
|
59
|
-
|
|
60
|
-
MANAGEMENT / CONTROL (use action; omit execution fields):
|
|
61
|
-
• 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.
|
|
62
|
-
• 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.
|
|
63
|
-
• 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 selects the safe Git ref used by managed worktrees (default HEAD); 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.
|
|
64
|
-
|
|
65
|
-
${SUBAGENT_SAFETY_GUIDANCE}`;
|
|
66
|
-
|
|
67
|
-
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.
|
|
14
|
+
• Omit action for execution. Multi-step/parallel work: exactly one top-level subagent workflow call with async:true; children launch only inside it.
|
|
15
|
+
• 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.
|
|
16
|
+
• Ordinary child subagents are not orchestrators; only configured fanout within depth/session limits. One writer per cwd/worktree; isolate concurrent writers. Fresh-context read-only reviewers, then parent synthesis/fixes. Oracle/advisor unknowns use supervisor dialogue; one-shot only when requested.
|
|
17
|
+
• Bind durable output on runs.run/runs.all, not task filename prose; return actual outputReference/outputPathMapping/artifactPaths, evidence and residual risks.
|
|
18
|
+
• 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.
|
|
19
|
+
• Named resources own authority; raw workflowScript/workflowScriptPath cannot use runs.host. Granted commands/relative outputs use workflow cwd, never per-step cwd.
|
|
20
|
+
• 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.`;
|
|
21
|
+
|
|
22
|
+
const EXECUTION_GUIDANCE = `Delegate one child with {agent,task?}; otherwise choose exactly one of workflowScript, workflowScriptPath 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.
|
|
23
|
+
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.
|
|
24
|
+
Before advanced orchestration (runs.lanes, rolling fanout, mission state, handoffs), read {action:"guide",topic:"workflows"} or the pi-subagents skill. Sandbox: runs, emit, console, JavaScript and enabled mission state; 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.
|
|
25
|
+
Model override: first call {action:"models"}; copy exact provider/id, not agent names. Thinking uses model suffix, not watchdog-only thinking.
|
|
26
|
+
Named resources: {workflow:'review',args:{task:'...'}} or {workflow:'run-ci',args:{command:'npm test'}}; args are bounded plain data. 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.`;
|
|
27
|
+
|
|
28
|
+
export const DEFAULT_SUBAGENT_TOOL_DESCRIPTION = `${EXECUTION_GUIDANCE}\n\n${SUBAGENT_SAFETY_GUIDANCE}`;
|
|
29
|
+
|
|
30
|
+
export const SUBAGENT_TOOL_PROMPT_SNIPPET = "Delegate to subagents; orchestrate in one workflow call.";
|
|
31
|
+
export const SUBAGENT_TOOL_PROMPT_GUIDELINES = [
|
|
32
|
+
"Use subagent only when delegation is needed.",
|
|
33
|
+
];
|
|
68
34
|
|
|
69
|
-
|
|
35
|
+
export const COMPACT_SUBAGENT_TOOL_DESCRIPTION = DEFAULT_SUBAGENT_TOOL_DESCRIPTION;
|
|
70
36
|
|
|
71
|
-
|
|
72
|
-
• ${EXTERNAL_CLI_RUNNER_GUIDANCE}
|
|
73
|
-
• ${AGENT_SELECTION_GUIDANCE}
|
|
74
|
-
• 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.
|
|
75
|
-
• SINGLE {agent:"worker",task:"..."} starts exactly one direct child. Fields apply to that child. Do not combine agent/task with action, workflowScript, or workflowScriptPath.
|
|
76
|
-
• 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; set baseRef to a safe Git ref (default HEAD) to choose the managed worktree starting commit. The source checkout must still be clean. 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.
|
|
77
|
-
• ${WORKFLOW_LANES_GUIDANCE}
|
|
78
|
-
• 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.
|
|
79
|
-
• 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]"}
|
|
80
|
-
• 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.
|
|
81
|
-
|
|
82
|
-
MANAGE / CONTROL:
|
|
83
|
-
• 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.
|
|
84
|
-
• 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}.
|
|
85
|
-
|
|
86
|
-
ASYNC / SAFETY:
|
|
87
|
-
• ${SUBAGENT_FAILURE_RECOVERY_GUIDANCE}
|
|
88
|
-
• 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.
|
|
89
|
-
• ${WORKFLOW_RESUME_KEY_GUIDANCE}
|
|
90
|
-
• ${WORKFLOW_OUTPUT_BINDING_GUIDANCE}
|
|
91
|
-
• ${WORKFLOW_HOST_GUIDANCE}
|
|
92
|
-
• Ordinary children are not orchestrators. Keep one writer per cwd/worktree and use fresh read-only reviewers for independent checks.
|
|
93
|
-
• Oracle/advisor consultations use available supervisor dialogue for material unknowns; request one-shot when desired.
|
|
94
|
-
• Status and artifacts live under asyncId/asyncDir with status.json, events.jsonl, output logs, and {action:"status",id:"..."}.`;
|
|
37
|
+
export const FULL_SUBAGENT_TOOL_DESCRIPTION = `${DEFAULT_SUBAGENT_TOOL_DESCRIPTION}
|
|
95
38
|
|
|
39
|
+
WORKFLOW DETAILS:
|
|
40
|
+
• 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.
|
|
41
|
+
• 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.
|
|
42
|
+
• 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.
|
|
43
|
+
• 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.`;
|
|
96
44
|
|
|
97
45
|
function isToolDescriptionMode(value: unknown): value is ToolDescriptionMode {
|
|
98
46
|
return value === "full" || value === "compact" || value === "custom";
|