@xzzpig/pi-subagents 0.18.0 → 0.20.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 +129 -0
- package/README.md +1 -1
- package/docs/agents.md +32 -16
- package/docs/configuration.md +76 -9
- package/docs/extension-api.md +6 -5
- package/docs/missions.md +28 -14
- package/docs/models.md +8 -4
- package/docs/observability.md +10 -5
- package/docs/standalone-background.md +1 -1
- package/docs/tool-reference.md +90 -88
- package/docs/workflows.md +171 -173
- package/node_modules/@xzzpig/pi-components/package.json +4 -4
- package/package.json +6 -6
- package/prompts/review-loop.md +1 -1
- package/skills/council-mode/SKILL.md +1 -1
- package/skills/pi-subagents/SKILL.md +12 -5
- package/skills/pi-subagents/references/constraints-and-recipes.md +3 -3
- package/skills/pi-subagents/references/execution-controls.md +68 -67
- package/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
- package/skills/pi-subagents/references/multi-lane-orchestration.md +1 -1
- package/skills/pi-subagents/references/prompting-and-roles.md +45 -48
- package/src/agents/advertised-agent-prompt.ts +21 -41
- package/src/agents/agent-management.ts +2 -2
- package/src/agents/agents.ts +66 -3
- package/src/api/preflight.ts +109 -63
- package/src/extension/config.ts +15 -4
- package/src/extension/control-notices.ts +3 -0
- package/src/extension/doctor.ts +1 -0
- package/src/extension/fanout-child.ts +12 -3
- package/src/extension/herdr-pi-bridge.ts +2 -0
- package/src/extension/index.ts +90 -174
- package/src/extension/public-execution.ts +72 -35
- package/src/extension/reply-workflow-script.ts +58 -0
- package/src/extension/rpc.ts +29 -10
- package/src/extension/schemas.ts +40 -135
- package/src/extension/tool-activation.ts +57 -108
- package/src/extension/tool-description.ts +62 -27
- package/src/extension/upgrade-notice.ts +40 -0
- package/src/integrations/herdr-status.ts +19 -3
- package/src/intercom/native-supervisor-channel.ts +4 -1
- package/src/missions/goal-driver.ts +44 -31
- package/src/missions/store.ts +10 -1
- package/src/profiles/profiles.ts +5 -2
- package/src/runs/background/async-execution.ts +146 -59
- package/src/runs/background/async-job-tracker.ts +66 -24
- package/src/runs/background/async-retention.ts +46 -16
- package/src/runs/background/await-async-run.ts +78 -0
- package/src/runs/background/chain-root-attachment.ts +4 -4
- package/src/runs/background/control-channel.ts +61 -2
- package/src/runs/background/notify.ts +5 -0
- package/src/runs/background/run-child-session.ts +17 -7
- package/src/runs/background/run-status.ts +6 -0
- package/src/runs/background/runner-aliases.ts +37 -6
- package/src/runs/background/runner-child-launch.ts +3 -0
- package/src/runs/background/scheduled-runs.ts +33 -18
- package/src/runs/background/stale-run-reconciler.ts +13 -2
- package/src/runs/background/subagent-runner.ts +58 -5
- package/src/runs/foreground/async-stop-action.ts +17 -3
- package/src/runs/foreground/command-action.ts +41 -0
- package/src/runs/foreground/execution.ts +145 -131
- package/src/runs/foreground/subagent-executor.ts +546 -296
- package/src/runs/shared/async-status-projection.ts +5 -0
- package/src/runs/shared/child-commands.ts +228 -0
- package/src/runs/shared/child-launch.ts +15 -2
- package/src/runs/shared/child-session.ts +184 -24
- package/src/runs/shared/child-tool-plan.ts +16 -4
- package/src/runs/shared/claude-code-adapter.ts +157 -2
- package/src/runs/shared/dynamic-fanout.ts +2 -2
- package/src/runs/shared/external-cli-preflight.ts +54 -6
- package/src/runs/shared/external-cli-runner.ts +5 -1
- package/src/runs/shared/mcp-config-sources.ts +2 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.ts +104 -11
- package/src/runs/shared/model-resolution.ts +38 -10
- package/src/runs/shared/model-scope.ts +28 -9
- package/src/runs/shared/nested-events.ts +55 -55
- package/src/runs/shared/parallel-utils.ts +4 -0
- package/src/runs/shared/pi-spawn.ts +7 -95
- package/src/runs/shared/run-history.ts +87 -0
- package/src/runs/shared/subagent-control.ts +32 -17
- package/src/runs/shared/subagent-prompt-runtime.ts +14 -6
- package/src/runs/shared/worktree.ts +1 -1
- package/src/shared/disabled-features.ts +123 -0
- package/src/shared/extension-context.ts +13 -0
- package/src/shared/model-info.ts +9 -0
- package/src/shared/required-child-extensions.ts +39 -5
- package/src/shared/settings.ts +1 -1
- package/src/shared/types.ts +27 -1
- package/src/slash/prompt-template-bridge.ts +2 -2
- package/src/slash/slash-commands.ts +10 -5
- package/src/slash/subagent-cost.ts +9 -5
- package/src/slash/subagents-admin.ts +24 -24
- package/src/tui/fleet-status.ts +14 -6
- package/src/tui/fleet.ts +14 -2
- package/src/tui/render.ts +117 -56
- package/src/tui/running-tone.ts +28 -0
- package/src/watchdog/diff-tool.ts +23 -9
- package/src/watchdog/register-child.ts +3 -3
- package/src/watchdog/register-main.ts +3 -3
- package/src/watchdog/review.ts +2 -2
- package/src/watchdog/turn-delta.ts +1 -1
- package/src/workflows/chat-progress.ts +2 -2
- package/src/workflows/scripted-workflow.ts +117 -37
- package/src/workflows/structured-workflow-scripts.ts +177 -0
- package/src/workflows/workflow-checklist.ts +6 -0
- package/src/workflows/workflow-receipt.ts +10 -4
- package/src/workflows/workflow-resources.ts +44 -16
- package/src/workflows/workflow-reuse.ts +120 -0
- package/src/workflows/workflow-revival.ts +123 -0
|
@@ -16,10 +16,13 @@ export interface RequiredChildExtension {
|
|
|
16
16
|
export interface RegisterRequiredChildExtensionsInput {
|
|
17
17
|
sessionId: string;
|
|
18
18
|
extensions: readonly RequiredChildExtension[];
|
|
19
|
+
/** Reject launches whose runner or machine placement cannot load these extensions, instead of dropping them. */
|
|
20
|
+
requireForAllRunners?: boolean;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export interface RequiredChildExtensionRegistration { dispose(): void }
|
|
22
|
-
|
|
24
|
+
/** Registration stamps `requireForAllRunners` on each entry so every carrier of the snapshot retains it. */
|
|
25
|
+
export type RequiredChildExtensionSnapshot = ReadonlyArray<Readonly<RequiredChildExtension & { requireForAllRunners?: true }>>;
|
|
23
26
|
|
|
24
27
|
/** Validate and freeze a snapshot; registration canonicalizes once, while retained launches preserve that identity. */
|
|
25
28
|
export function snapshotRequiredChildExtensions(value: unknown, label = "Required child extensions", canonicalizeFiles = false): RequiredChildExtensionSnapshot {
|
|
@@ -27,11 +30,14 @@ export function snapshotRequiredChildExtensions(value: unknown, label = "Require
|
|
|
27
30
|
const ids = new Set<string>();
|
|
28
31
|
const paths = new Set<string>();
|
|
29
32
|
return Object.freeze(value.map((entry, index) => {
|
|
30
|
-
|
|
33
|
+
// The flag comes from registration, so only serialized snapshots (not registration input) may carry it.
|
|
34
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry) || Object.keys(entry).some((key) => key !== "id" && key !== "path" && (canonicalizeFiles || key !== "requireForAllRunners"))) throw new Error(`${label} entry ${index} requires only id and path.`);
|
|
31
35
|
const id = "id" in entry ? entry.id : undefined;
|
|
32
36
|
const rawPath = "path" in entry ? entry.path : undefined;
|
|
37
|
+
const requireForAllRunners = "requireForAllRunners" in entry ? entry.requireForAllRunners : undefined;
|
|
33
38
|
if (typeof id !== "string" || !ID_PATTERN.test(id)) throw new Error(`${label} entry ${index} requires a safe id of at most 128 characters.`);
|
|
34
39
|
if (ids.has(id)) throw new Error(`${label} id '${id}' is duplicated.`);
|
|
40
|
+
if (requireForAllRunners !== undefined && requireForAllRunners !== true) throw new Error(`${label} '${id}' requireForAllRunners must be true when present.`);
|
|
35
41
|
if (typeof rawPath !== "string" || !rawPath.trim() || rawPath.includes("\0") || Buffer.byteLength(rawPath, "utf8") > MAX_PATH_BYTES || (!canonicalizeFiles && !path.isAbsolute(rawPath))) throw new Error(`${label} '${id}' requires ${canonicalizeFiles ? "a" : "an absolute"} non-empty path of at most ${MAX_PATH_BYTES} bytes without NUL.`);
|
|
36
42
|
let extensionPath = rawPath;
|
|
37
43
|
if (canonicalizeFiles) {
|
|
@@ -45,7 +51,7 @@ export function snapshotRequiredChildExtensions(value: unknown, label = "Require
|
|
|
45
51
|
if (paths.has(extensionPath)) throw new Error(`${label} path '${extensionPath}' is duplicated.`);
|
|
46
52
|
ids.add(id);
|
|
47
53
|
paths.add(extensionPath);
|
|
48
|
-
return Object.freeze({ id, path: extensionPath });
|
|
54
|
+
return Object.freeze(requireForAllRunners ? { id, path: extensionPath, requireForAllRunners } : { id, path: extensionPath });
|
|
49
55
|
}));
|
|
50
56
|
}
|
|
51
57
|
|
|
@@ -66,9 +72,11 @@ function registry(): Registry {
|
|
|
66
72
|
|
|
67
73
|
/** Register one immutable host-required extension snapshot for a parent session. */
|
|
68
74
|
export function registerRequiredChildExtensions(input: RegisterRequiredChildExtensionsInput): RequiredChildExtensionRegistration {
|
|
69
|
-
if (!input || typeof input !== "object" || Array.isArray(input) || Object.keys(input).some((key) => key !== "sessionId" && key !== "extensions")) throw new Error("Required child extension registration
|
|
75
|
+
if (!input || typeof input !== "object" || Array.isArray(input) || Object.keys(input).some((key) => key !== "sessionId" && key !== "extensions" && key !== "requireForAllRunners")) throw new Error("Required child extension registration accepts only sessionId, extensions, and requireForAllRunners.");
|
|
70
76
|
if (typeof input.sessionId !== "string" || !input.sessionId || input.sessionId.trim() !== input.sessionId || input.sessionId.length > 256 || input.sessionId.includes("\0")) throw new Error("Required child extension registration requires a non-empty trimmed sessionId of at most 256 characters without NUL.");
|
|
71
|
-
|
|
77
|
+
if (input.requireForAllRunners !== undefined && typeof input.requireForAllRunners !== "boolean") throw new Error("Required child extension registration requireForAllRunners must be a boolean.");
|
|
78
|
+
const canonical = snapshotRequiredChildExtensions(input.extensions, "Required child extensions", true);
|
|
79
|
+
const frozen = input.requireForAllRunners ? Object.freeze(canonical.map((entry) => Object.freeze({ ...entry, requireForAllRunners: true as const }))) : canonical;
|
|
72
80
|
const store = registry();
|
|
73
81
|
if (store.bySession.has(input.sessionId)) throw new Error(`Required child extensions are already registered for session '${input.sessionId}'; dispose them first.`);
|
|
74
82
|
store.bySession.set(input.sessionId, frozen);
|
|
@@ -79,3 +87,29 @@ export function resolveRequiredChildExtensions(sessionId: string | undefined): R
|
|
|
79
87
|
if (!sessionId) return EMPTY_SNAPSHOT;
|
|
80
88
|
return registry().bySession.get(sessionId) ?? EMPTY_SNAPSHOT;
|
|
81
89
|
}
|
|
90
|
+
|
|
91
|
+
/** Reject a non-native runner or machine placement when any given snapshot has a `requireForAllRunners` entry. */
|
|
92
|
+
export function assertRequiredChildExtensionsAdmitted(snapshots: ReadonlyArray<RequiredChildExtensionSnapshot | undefined>, launch: { agent: string; runnerType?: string; machine?: string }): void {
|
|
93
|
+
const ids = [...new Set(snapshots.flatMap((snapshot) => snapshot ?? []).filter((entry) => entry.requireForAllRunners).map((entry) => entry.id))];
|
|
94
|
+
if (ids.length === 0) return;
|
|
95
|
+
const route = launch.machine ? `machine '${launch.machine}'` : launch.runnerType !== undefined && launch.runnerType !== "pi" ? `runner.type='${launch.runnerType}'` : undefined;
|
|
96
|
+
if (route) throw new Error(`Agent '${launch.agent}' cannot run on ${route}: the host requires child extensions (${ids.join(", ")}) for every runner, and only local native Pi children load them.`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function hasMandatoryRequiredChildExtensions(snapshot: RequiredChildExtensionSnapshot | undefined): snapshot is RequiredChildExtensionSnapshot {
|
|
100
|
+
return snapshot?.some((entry) => entry.requireForAllRunners) === true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const RETAINED_FILE = "required-child-extensions.json";
|
|
104
|
+
|
|
105
|
+
/** Persist a run's mandatory snapshot so append-step admits against it; writes nothing without a mandatory entry. */
|
|
106
|
+
export function writeRetainedRequiredChildExtensions(asyncDir: string, snapshot: RequiredChildExtensionSnapshot): void {
|
|
107
|
+
if (!hasMandatoryRequiredChildExtensions(snapshot)) return;
|
|
108
|
+
fs.writeFileSync(path.join(asyncDir, RETAINED_FILE), `${JSON.stringify(snapshot)}\n`, { mode: 0o600 });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function readRetainedRequiredChildExtensions(asyncDir: string): RequiredChildExtensionSnapshot | undefined {
|
|
112
|
+
const filePath = path.join(asyncDir, RETAINED_FILE);
|
|
113
|
+
if (!fs.existsSync(filePath)) return undefined;
|
|
114
|
+
return snapshotRequiredChildExtensions(JSON.parse(fs.readFileSync(filePath, "utf-8")), "Retained required child extensions");
|
|
115
|
+
}
|
package/src/shared/settings.ts
CHANGED
|
@@ -46,7 +46,7 @@ export interface SequentialStep {
|
|
|
46
46
|
acceptance?: AcceptanceInput;
|
|
47
47
|
agentContract?: AgentContract;
|
|
48
48
|
gateOn?: ChainGateLayer;
|
|
49
|
-
/** Internal workflow child isolation; public
|
|
49
|
+
/** Internal workflow child isolation; public workflow scripts supply this on runs.run. */
|
|
50
50
|
worktree?: boolean;
|
|
51
51
|
}
|
|
52
52
|
|
package/src/shared/types.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { ModelScopeRule } from "../runs/shared/model-scope.ts";
|
|
|
12
12
|
import type { ResolvedSubagentCapabilityCeiling, SubagentCapabilityAudit } from "../runs/shared/capability-ceiling.ts";
|
|
13
13
|
import type { AuthorityPolicyConfig } from "../policy/authority.ts";
|
|
14
14
|
import type { ThinkingLevel } from "./model-info.ts";
|
|
15
|
+
import type { SubagentFeature } from "./disabled-features.ts";
|
|
15
16
|
import type { GlobalMissionIndexRecord, MissionRecord, MissionStoreConfig } from "../missions/types.ts";
|
|
16
17
|
import type { ExtensionBindings } from "../runs/shared/extension-bindings.ts";
|
|
17
18
|
import type { WorkflowChildPermitContext } from "./workflow-child-permit.ts";
|
|
@@ -131,6 +132,8 @@ export interface WorkflowPreflight {
|
|
|
131
132
|
|
|
132
133
|
export type WorkflowReceiptState = "complete" | "failed" | "paused" | "stopped";
|
|
133
134
|
|
|
135
|
+
export type WorkflowScriptFailureKind = "validation" | "script" | "child" | "return-serialization" | "timeout" | "detached-child" | "runtime";
|
|
136
|
+
|
|
134
137
|
export type WorkflowTerminalResolution = "settled-awaiting-resume" | "failed-child" | "interrupted-child";
|
|
135
138
|
|
|
136
139
|
export interface WorkflowTerminalOutcome {
|
|
@@ -1274,6 +1277,8 @@ export interface SingleResult {
|
|
|
1274
1277
|
index: number;
|
|
1275
1278
|
/** Workflow child key that owns this result when returned from workflow details. */
|
|
1276
1279
|
workflowKey?: string;
|
|
1280
|
+
/** Workflow child run id that produced this result; resumed rounds share a session file but not a run id. */
|
|
1281
|
+
runId?: string;
|
|
1277
1282
|
agent: string;
|
|
1278
1283
|
task: string;
|
|
1279
1284
|
/** Human-readable display name for the child's own session (agent + task
|
|
@@ -1436,6 +1441,7 @@ export interface AgentCapabilityRow {
|
|
|
1436
1441
|
}
|
|
1437
1442
|
|
|
1438
1443
|
export interface Details {
|
|
1444
|
+
commands?: import("../runs/shared/child-commands.ts").ChildCommandSnapshot[];
|
|
1439
1445
|
mode: SubagentResultMode | "management";
|
|
1440
1446
|
workflowReceiptPath?: string;
|
|
1441
1447
|
runId?: string;
|
|
@@ -1525,8 +1531,15 @@ export interface Details {
|
|
|
1525
1531
|
mission?: MissionRecord;
|
|
1526
1532
|
workflow?: {
|
|
1527
1533
|
value?: unknown;
|
|
1534
|
+
failureKind?: WorkflowScriptFailureKind;
|
|
1528
1535
|
args?: Record<string, unknown>;
|
|
1529
1536
|
argsDigest?: string;
|
|
1537
|
+
/** SHA-256 of the workflow script source (async workflows). */
|
|
1538
|
+
scriptDigest?: string;
|
|
1539
|
+
/** Structured stop cause; set only when the owning extension runtime was replaced. */
|
|
1540
|
+
stopCause?: "runtime-replaced";
|
|
1541
|
+
/** Runtime-replaced workflow run whose finished children this run reused. */
|
|
1542
|
+
reusedFrom?: string;
|
|
1530
1543
|
resource?: WorkflowResourceProvenance;
|
|
1531
1544
|
preflightWarnings?: string[];
|
|
1532
1545
|
trace: Array<{
|
|
@@ -1542,6 +1555,8 @@ export interface Details {
|
|
|
1542
1555
|
generatedLaneKey?: string;
|
|
1543
1556
|
warning?: string;
|
|
1544
1557
|
error?: string;
|
|
1558
|
+
/** Came from a previous runtime-replaced run of the same script and args; this run launched nothing. */
|
|
1559
|
+
reused?: boolean;
|
|
1545
1560
|
}>;
|
|
1546
1561
|
emits: unknown[];
|
|
1547
1562
|
console: Array<{ level: "log" | "info" | "warn" | "error"; text: string }>;
|
|
@@ -1984,6 +1999,8 @@ export interface AsyncStatus {
|
|
|
1984
1999
|
outputName?: string;
|
|
1985
2000
|
structured?: boolean;
|
|
1986
2001
|
status: "pending" | "running" | "complete" | "completed" | "failed" | "partial" | "paused" | "stopped" | "rejected";
|
|
2002
|
+
/** Workflow child result reused from a previous runtime-replaced run; the child was not re-run. */
|
|
2003
|
+
reused?: boolean;
|
|
1987
2004
|
stopRequested?: boolean;
|
|
1988
2005
|
stopRequestedAt?: number;
|
|
1989
2006
|
children?: NestedRunSummary[];
|
|
@@ -2482,6 +2499,8 @@ export interface RunSyncOptions {
|
|
|
2482
2499
|
/** Original cwd input retained for launch diagnostics. */
|
|
2483
2500
|
requestedCwd?: string;
|
|
2484
2501
|
signal?: AbortSignal;
|
|
2502
|
+
/** Report a child ended by `signal` as stopped; set for workflow children, whose signal is the workflow's. */
|
|
2503
|
+
abortedAsStopped?: boolean;
|
|
2485
2504
|
interruptSignal?: AbortSignal;
|
|
2486
2505
|
timeoutMs?: number;
|
|
2487
2506
|
deadlineAt?: number;
|
|
@@ -2609,6 +2628,7 @@ export interface ProactiveSkillSubagentsConfig {
|
|
|
2609
2628
|
}
|
|
2610
2629
|
|
|
2611
2630
|
export type ToolDescriptionMode = "full" | "compact" | "custom";
|
|
2631
|
+
export type ToolActivationMode = "auto" | "dynamic" | "eager";
|
|
2612
2632
|
export type InlineToolDisplay = "rich" | "summary";
|
|
2613
2633
|
|
|
2614
2634
|
export interface ScheduledRunsConfig {
|
|
@@ -2682,10 +2702,16 @@ export interface ExtensionConfig {
|
|
|
2682
2702
|
fleetKeybindings?: FleetKeybindingsConfig;
|
|
2683
2703
|
/** Show the under-editor async runs widget. Defaults to true, including when FleetView is enabled. */
|
|
2684
2704
|
asyncWidget?: boolean;
|
|
2705
|
+
/** Start the under-editor async runs widget folded. Defaults to false. */
|
|
2706
|
+
asyncWidgetCollapsed?: boolean;
|
|
2685
2707
|
/** Exact provider/model candidates mapped to operator-declared equivalent response IDs. Empty arrays add no accepted IDs. */
|
|
2686
2708
|
modelResponseAliases?: Record<string, string[]>;
|
|
2687
2709
|
/** Tool description variant registered for the parent-facing subagent tool. Defaults to split metadata. */
|
|
2688
2710
|
toolDescriptionMode?: ToolDescriptionMode;
|
|
2711
|
+
/** How a new parent session offers the subagent tool. Defaults to auto. */
|
|
2712
|
+
toolActivation?: ToolActivationMode;
|
|
2713
|
+
/** Opt-in feature groups removed from the subagent tool schema and rejected at every execution boundary. */
|
|
2714
|
+
disabledFeatures?: SubagentFeature[];
|
|
2689
2715
|
/** Inline chat rendering for the subagent tool. Defaults to rich. */
|
|
2690
2716
|
inlineToolDisplay?: InlineToolDisplay;
|
|
2691
2717
|
/** Density controls for the main chat subagent call/result renderer. */
|
|
@@ -2871,7 +2897,7 @@ export const POLL_INTERVAL_MS = 250;
|
|
|
2871
2897
|
export const WIDGET_ANIMATION_INTERVAL_MS = 1000;
|
|
2872
2898
|
export const MAX_WIDGET_JOBS = 4;
|
|
2873
2899
|
export const DEFAULT_SUBAGENT_MAX_DEPTH = 2;
|
|
2874
|
-
export const SUBAGENT_ACTIONS = ["list", "get", "models", "children.list", "guide", "validate", "create", "update", "delete", "eject", "disable", "enable", "reset", "mission.create", "mission.list", "mission.show", "mission.update", "mission.resolve-decision", "mission.attach-run", "mission.close", "worktree.discard", "worktree.cleanup", "lane.status", "lane.recordMerge", "lane.recordSupersession", "refine", "refine.show", "refine.rollback", "inspector.open", "inspector.command", "inspector.status", "inspector.close", "project.open", "project.status", "project.close", "status", "debug.run", "grant-spawn-budget", "interrupt", "resume", "steer", "stop", "dismiss", "doctor", "watchdog.status", "watchdog.check", "watchdog.configure", "watchdog.recommend-model", "schedule.create", "schedule.list", "schedule.show", "schedule.history", "schedule.pause", "schedule.resume", "schedule.run", "schedule.run-due", "schedule.delete"] as const;
|
|
2900
|
+
export const SUBAGENT_ACTIONS = ["list", "get", "models", "children.list", "guide", "validate", "create", "update", "delete", "eject", "disable", "enable", "reset", "mission.create", "mission.list", "mission.show", "mission.update", "mission.resolve-decision", "mission.attach-run", "mission.close", "worktree.discard", "worktree.cleanup", "lane.status", "lane.recordMerge", "lane.recordSupersession", "refine", "refine.show", "refine.rollback", "inspector.open", "inspector.command", "inspector.status", "inspector.close", "project.open", "project.status", "project.close", "status", "debug.run", "grant-spawn-budget", "interrupt", "resume", "steer", "stop", "command.status", "command.yield", "command.cancel", "dismiss", "doctor", "watchdog.status", "watchdog.check", "watchdog.configure", "watchdog.recommend-model", "schedule.create", "schedule.list", "schedule.show", "schedule.history", "schedule.pause", "schedule.resume", "schedule.run", "schedule.run-due", "schedule.delete"] as const;
|
|
2875
2901
|
|
|
2876
2902
|
export const DEFAULT_FORK_PREAMBLE =
|
|
2877
2903
|
"You are a delegated subagent running from a fork of the parent session. " +
|
|
@@ -234,7 +234,7 @@ export function registerPromptTemplateDelegationBridge<Ctx extends { cwd?: strin
|
|
|
234
234
|
requestId: legacy.requestId,
|
|
235
235
|
messages: [],
|
|
236
236
|
isError: true,
|
|
237
|
-
errorText: "Legacy prompt-template tasks/worktree orchestration was removed; use
|
|
237
|
+
errorText: "Legacy prompt-template tasks/worktree orchestration was removed; use a workflow script.",
|
|
238
238
|
});
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
@@ -245,7 +245,7 @@ export function registerPromptTemplateDelegationBridge<Ctx extends { cwd?: strin
|
|
|
245
245
|
...legacyRequest,
|
|
246
246
|
messages: [],
|
|
247
247
|
isError: true,
|
|
248
|
-
errorText: "Legacy prompt-template direct delegation was removed; use
|
|
248
|
+
errorText: "Legacy prompt-template direct delegation was removed; use a workflow script through the subagent tool or structured delegation.",
|
|
249
249
|
} satisfies PromptTemplateDelegationResponse);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
@@ -592,14 +592,19 @@ async function runSlashSubagent(
|
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
594
|
|
|
595
|
-
function slashRunWorkflowScript(key: string, child:
|
|
595
|
+
function slashRunWorkflowScript(key: string, child: SubagentParamsLike): string {
|
|
596
596
|
return `return runs.run(${JSON.stringify(key)}, ${JSON.stringify(child)})`;
|
|
597
597
|
}
|
|
598
598
|
|
|
599
599
|
export function registerSlashCommands(
|
|
600
600
|
pi: ExtensionAPI,
|
|
601
601
|
state: SubagentState,
|
|
602
|
-
options: {
|
|
602
|
+
options: {
|
|
603
|
+
fleetKeybindings?: FleetKeybindingsConfig;
|
|
604
|
+
foregroundDetachShortcut?: string;
|
|
605
|
+
/** disabledFeatures "workflow-scripts": /run launches its one child directly instead of through a script. */
|
|
606
|
+
workflowScriptsDisabled?: boolean;
|
|
607
|
+
} = {},
|
|
603
608
|
): { dispose: () => void } {
|
|
604
609
|
let fleetOpen = false;
|
|
605
610
|
let disposed = false;
|
|
@@ -640,7 +645,7 @@ export function registerSlashCommands(
|
|
|
640
645
|
});
|
|
641
646
|
|
|
642
647
|
pi.registerCommand("run", {
|
|
643
|
-
description: "Run one subagent through
|
|
648
|
+
description: "Run one subagent through a workflow script: /run agent[output=file] [task] [--bg] [--fork]",
|
|
644
649
|
getArgumentCompletions: makeAgentCompletions(pi, state),
|
|
645
650
|
handler: async (args, ctx) => {
|
|
646
651
|
const { args: cleanedArgs, bg, fork } = extractExecutionFlags(args);
|
|
@@ -667,13 +672,13 @@ export function registerSlashCommands(
|
|
|
667
672
|
const existingReads = inline.reads.filter((read) => resolveExistingReadPaths([read], state.baseCwd).length > 0);
|
|
668
673
|
if (existingReads.length > 0) finalTask = `[Read from: ${existingReads.join(", ")}]\n\n${finalTask}`;
|
|
669
674
|
}
|
|
670
|
-
const child:
|
|
675
|
+
const child: SubagentParamsLike = { agent: agentName, task: finalTask, agentScope: "both" };
|
|
671
676
|
if (inline.output !== undefined) child.output = inline.output;
|
|
672
677
|
if (inline.outputMode !== undefined) child.outputMode = inline.outputMode;
|
|
673
678
|
if (inline.skill !== undefined) child.skill = inline.skill;
|
|
674
679
|
if (inline.model) child.model = inline.model;
|
|
675
680
|
if (fork) child.context = "fork";
|
|
676
|
-
launchCommand(ctx, { workflowScript: slashRunWorkflowScript("run", child), async: bg
|
|
681
|
+
launchCommand(ctx, options.workflowScriptsDisabled ? { ...child, async: bg } : { workflowScript: slashRunWorkflowScript("run", child), async: bg });
|
|
677
682
|
},
|
|
678
683
|
});
|
|
679
684
|
|
|
@@ -3,7 +3,7 @@ import * as path from "node:path";
|
|
|
3
3
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { getArtifactPaths, getArtifactsDir } from "../shared/artifacts.ts";
|
|
5
5
|
import { formatTokens } from "../shared/formatters.ts";
|
|
6
|
-
import { DIRS, SLASH_RESULT_TYPE, type Details, type
|
|
6
|
+
import { DIRS, SLASH_RESULT_TYPE, type Details, type SubagentState, type Usage } from "../shared/types.ts";
|
|
7
7
|
import { readStatus } from "../shared/utils.ts";
|
|
8
8
|
import { readWorkflowReceipt } from "../workflows/workflow-receipt.ts";
|
|
9
9
|
import { resolveSlashMessageDetails } from "./slash-live-state.ts";
|
|
@@ -187,12 +187,12 @@ export function collectSubagentCost(
|
|
|
187
187
|
if (parentUsage) addUsage(parent, parentUsage);
|
|
188
188
|
const details = detailsFromSessionEntry(entry);
|
|
189
189
|
if (!details) continue;
|
|
190
|
-
|
|
190
|
+
// Only async workflows persist a receipt file; foreground workflow child usage is already in results.
|
|
191
|
+
if (details.mode === "workflow" && details.runId && details.asyncId) workflowRunIds.add(details.runId);
|
|
191
192
|
// An async launch result has no child results; its usage lands in run artifacts.
|
|
192
193
|
else if (details.asyncId && details.results.length === 0) asyncRunIds.add(details.asyncId);
|
|
193
194
|
for (const result of details.results) {
|
|
194
|
-
|
|
195
|
-
addChild({ agent: result.agent, runId: typeof resultRunId === "string" ? resultRunId : undefined, usage: usageFromValue(result.usage), sessionFile: result.sessionFile });
|
|
195
|
+
addChild({ agent: result.agent, runId: typeof result.runId === "string" ? result.runId : undefined, usage: usageFromValue(result.usage), sessionFile: result.sessionFile });
|
|
196
196
|
}
|
|
197
197
|
for (const completion of details.completions ?? []) {
|
|
198
198
|
if (completion.mode === "workflow") workflowRunIds.add(completion.runId);
|
|
@@ -248,7 +248,11 @@ export function collectSubagentCost(
|
|
|
248
248
|
if (!usage || !addChild({ ...ref, usage })) unresolvedAsyncChildren += 1;
|
|
249
249
|
}
|
|
250
250
|
} catch (error) {
|
|
251
|
-
|
|
251
|
+
// Without a receipt, a bg_wait completion cannot prove it reported every child (a stopped workflow may omit one).
|
|
252
|
+
unresolvedAsyncChildren += 1;
|
|
253
|
+
// A running workflow has no receipt yet; readWorkflowReceipt keeps the ENOENT as its cause.
|
|
254
|
+
const missing = (error as NodeJS.ErrnoException).code === "ENOENT" || ((error as Error).cause as NodeJS.ErrnoException | undefined)?.code === "ENOENT";
|
|
255
|
+
if (!missing) console.error(`Failed to resolve async subagent usage for '${workflowRunId}':`, error);
|
|
252
256
|
}
|
|
253
257
|
}
|
|
254
258
|
|
|
@@ -19,7 +19,7 @@ let adminDialogEvents: UiSpanSilentEvents | undefined;
|
|
|
19
19
|
|
|
20
20
|
/** Claims the next dialog span as silent (pi-notify protocol). */
|
|
21
21
|
function markAdminDialogSilent(): void {
|
|
22
|
-
emitUiSpanSilent(adminDialogEvents, "admin");
|
|
22
|
+
emitUiSpanSilent(adminDialogEvents, "admin");
|
|
23
23
|
}
|
|
24
24
|
import { editableAgentConfig, preservedAgentFrontmatterFields } from "../agents/agent-management.ts";
|
|
25
25
|
import { findModelInfo, getSupportedThinkingLevels, toModelInfo } from "../shared/model-info.ts";
|
|
@@ -86,20 +86,20 @@ function modelFullId(model: ModelInfo): string {
|
|
|
86
86
|
async function liveAvailableModels(ctx: ExtensionContext) {
|
|
87
87
|
try {
|
|
88
88
|
// Reload local configuration and cached catalogs without network discovery on picker open.
|
|
89
|
-
// Host SDK versions differ on the refresh result shape: newer hosts return a result
|
|
90
|
-
// object with per-provider errors and an abort flag, older hosts resolve void.
|
|
91
|
-
const refresh = ctx.modelRegistry.refresh as ((options?: unknown) => Promise<unknown>) | undefined;
|
|
92
|
-
const result = await refresh?.({ allowNetwork: false, signal: AbortSignal.timeout(5_000) });
|
|
93
|
-
if (result && typeof result === "object") {
|
|
94
|
-
const errors = (result as { errors?: Map<string, Error> }).errors;
|
|
95
|
-
const aborted = (result as { aborted?: boolean }).aborted;
|
|
96
|
-
const firstError = errors?.entries().next().value;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
} else if (aborted) {
|
|
100
|
-
|
|
89
|
+
// Host SDK versions differ on the refresh result shape: newer hosts return a result
|
|
90
|
+
// object with per-provider errors and an abort flag, older hosts resolve void.
|
|
91
|
+
const refresh = ctx.modelRegistry.refresh as ((options?: unknown) => Promise<unknown>) | undefined;
|
|
92
|
+
const result = await refresh?.({ allowNetwork: false, signal: AbortSignal.timeout(5_000) });
|
|
93
|
+
if (result && typeof result === "object") {
|
|
94
|
+
const errors = (result as { errors?: Map<string, Error> }).errors;
|
|
95
|
+
const aborted = (result as { aborted?: boolean }).aborted;
|
|
96
|
+
const firstError = errors?.entries().next().value;
|
|
97
|
+
if (firstError) {
|
|
98
|
+
ctx.ui.notify(`Could not refresh ${firstError[0]}; using the currently loaded choices. ${firstError[1].message}`, "warning");
|
|
99
|
+
} else if (aborted) {
|
|
100
|
+
ctx.ui.notify("Model registry refresh timed out; using the currently loaded choices.", "warning");
|
|
101
|
+
}
|
|
101
102
|
}
|
|
102
|
-
}
|
|
103
103
|
} catch (error) {
|
|
104
104
|
const message = error instanceof Error ? error.message : String(error);
|
|
105
105
|
ctx.ui.notify(`Could not refresh the model registry; using the last loaded choices. ${message}`, "warning");
|
|
@@ -229,7 +229,7 @@ function metadataFor(agent: AgentConfig): string {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
async function selectFromList(ctx: ExtensionContext, title: string, subtitle: string | undefined, items: SelectorItem[]): Promise<string | undefined> {
|
|
232
|
-
markAdminDialogSilent();
|
|
232
|
+
markAdminDialogSilent();
|
|
233
233
|
if (typeof ctx.ui.custom === "function") {
|
|
234
234
|
const result = await ctx.ui.custom<SelectorResult>(
|
|
235
235
|
(tui, theme, kb, done) => new SelectorComponent(tui, theme, kb, { title, subtitle, items, done }),
|
|
@@ -284,7 +284,7 @@ async function chooseOverrideScope(ctx: ExtensionContext, agent: AgentConfig): P
|
|
|
284
284
|
return agent.source === "project" && agent.override.scope === "user" && d.projectSettingsPath ? "project" : agent.override.scope;
|
|
285
285
|
}
|
|
286
286
|
if (!d.projectSettingsPath || !ctx.hasUI) return "user";
|
|
287
|
-
markAdminDialogSilent();
|
|
287
|
+
markAdminDialogSilent();
|
|
288
288
|
const choice = await ctx.ui.select(`Save subagent override for ${agent.name}`, ["user", "project"]);
|
|
289
289
|
return choice === "user" || choice === "project" ? choice : undefined;
|
|
290
290
|
}
|
|
@@ -401,7 +401,7 @@ async function editSystemPrompt(ctx: ExtensionContext, agent: AgentConfig): Prom
|
|
|
401
401
|
const readOnlyMessage = readOnlyAgentMessage(agent, "systemPrompt");
|
|
402
402
|
if (readOnlyMessage) return readOnlyMessage;
|
|
403
403
|
}
|
|
404
|
-
markAdminDialogSilent();
|
|
404
|
+
markAdminDialogSilent();
|
|
405
405
|
const edited = await ctx.ui.editor(`Edit '${agent.name}' system prompt`, agent.systemPrompt ?? "");
|
|
406
406
|
if (edited === undefined) return null;
|
|
407
407
|
const projectOwnsLowerScopeOverride = agent.source === "project" && agent.override?.scope === "user" && discoverAgentsAll(ctx.cwd).projectSettingsPath;
|
|
@@ -412,12 +412,12 @@ markAdminDialogSilent();
|
|
|
412
412
|
}
|
|
413
413
|
|
|
414
414
|
export async function openSubagentsAdmin(pi: ExtensionAPI, ctx: ExtensionContext, args = ""): Promise<void> {
|
|
415
|
-
adminDialogEvents = pi.events;
|
|
416
|
-
try {
|
|
417
|
-
return await runAdminFlow(pi, ctx, args);
|
|
418
|
-
} finally {
|
|
419
|
-
adminDialogEvents = undefined;
|
|
420
|
-
}
|
|
415
|
+
adminDialogEvents = pi.events;
|
|
416
|
+
try {
|
|
417
|
+
return await runAdminFlow(pi, ctx, args);
|
|
418
|
+
} finally {
|
|
419
|
+
adminDialogEvents = undefined;
|
|
420
|
+
}
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
async function runAdminFlow(pi: ExtensionAPI, ctx: ExtensionContext, args = ""): Promise<void> {
|
|
@@ -449,7 +449,7 @@ async function runAdminFlow(pi: ExtensionAPI, ctx: ExtensionContext, args = ""):
|
|
|
449
449
|
else if (requestedAction === "prompt" || requestedAction === "system-prompt" || requestedAction === "edit") action = "Edit system prompt";
|
|
450
450
|
else if (requestedAction === "details" || requestedAction === "info") action = "Show details";
|
|
451
451
|
if (!action) {
|
|
452
|
-
markAdminDialogSilent();
|
|
452
|
+
markAdminDialogSilent();
|
|
453
453
|
action = await ctx.ui.select(
|
|
454
454
|
`Administer ${agent.name}\n${metadataSummary(agent)}`,
|
|
455
455
|
["Change model", "Change thinking level", "Edit system prompt", "Show details", "Done"],
|
package/src/tui/fleet-status.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { formatWorkflowJsonPreview } from "../workflows/scripted-workflow.ts";
|
|
|
9
9
|
import { hostStepReportName, hostStepVerdictLabel } from "../runs/shared/host-step-status.ts";
|
|
10
10
|
import { isStaleExtensionContextError } from "../shared/extension-context.ts";
|
|
11
11
|
import { inlineWorkflowRenderKey } from "./render.ts";
|
|
12
|
+
import { runningTone } from "./running-tone.ts";
|
|
13
|
+
import { childThinkingLevel, type ThinkingLevel } from "../shared/model-info.ts";
|
|
12
14
|
import { formatWorkflowChecklistBottleneck, formatWorkflowChecklistPhase, formatWorkflowChecklistSummary, projectWorkflowChecklist, type WorkflowChecklistPhase, type WorkflowChecklistProjection } from "../workflows/workflow-checklist.ts";
|
|
13
15
|
|
|
14
16
|
export const FLEET_STATUS_WIDGET_KEY = "subagent-fleet-status";
|
|
@@ -75,6 +77,8 @@ type FleetNestedRow = {
|
|
|
75
77
|
agentIdentity?: string;
|
|
76
78
|
state: NestedRunSummary["state"] | NestedStepSummary["status"];
|
|
77
79
|
modelThinking?: string;
|
|
80
|
+
/** Thinking level of the child this row stands for; it colors the running glyph. */
|
|
81
|
+
thinking?: ThinkingLevel;
|
|
78
82
|
activity?: string;
|
|
79
83
|
startedAt?: number;
|
|
80
84
|
endedAt?: number;
|
|
@@ -178,8 +182,8 @@ function isWorkflowRowTerminal(row: AsyncStatusWorkflowRow): boolean {
|
|
|
178
182
|
return row.state === "complete" || row.state === "completed";
|
|
179
183
|
}
|
|
180
184
|
|
|
181
|
-
function nestedStatusGlyph(state: FleetNestedRow["state"] | "planned", theme: Theme): string {
|
|
182
|
-
if (state === "running") return theme
|
|
185
|
+
function nestedStatusGlyph(state: FleetNestedRow["state"] | "planned", theme: Theme, thinking?: ThinkingLevel): string {
|
|
186
|
+
if (state === "running") return runningTone(theme, thinking)("●");
|
|
183
187
|
if (state === "queued" || state === "pending" || state === "planned") return theme.fg("muted", "◦");
|
|
184
188
|
if (state === "complete" || state === "completed") return theme.fg("success", "✓");
|
|
185
189
|
if (state === "failed" || state === "rejected") return theme.fg("error", "✗");
|
|
@@ -222,6 +226,7 @@ function nestedFleetRows(children: NestedRunSummary[] | undefined, visibleLimit:
|
|
|
222
226
|
}
|
|
223
227
|
const step = steps[stepIndex]!;
|
|
224
228
|
const modelThinking = formatModelThinking(step.model, step.thinking) || undefined;
|
|
229
|
+
const thinking = childThinkingLevel(step);
|
|
225
230
|
const activity = nestedActivity(step);
|
|
226
231
|
rows.push({
|
|
227
232
|
name: step.agent,
|
|
@@ -229,6 +234,7 @@ function nestedFleetRows(children: NestedRunSummary[] | undefined, visibleLimit:
|
|
|
229
234
|
state: step.status,
|
|
230
235
|
depth,
|
|
231
236
|
...(modelThinking ? { modelThinking } : {}),
|
|
237
|
+
...(thinking ? { thinking } : {}),
|
|
232
238
|
...(activity ? { activity } : {}),
|
|
233
239
|
...(step.startedAt !== undefined ? { startedAt: step.startedAt } : {}),
|
|
234
240
|
...(step.endedAt !== undefined ? { endedAt: step.endedAt } : {}),
|
|
@@ -246,6 +252,7 @@ function nestedFleetRows(children: NestedRunSummary[] | undefined, visibleLimit:
|
|
|
246
252
|
return false;
|
|
247
253
|
}
|
|
248
254
|
const modelThinking = formatModelThinking(child.model, child.thinking) || undefined;
|
|
255
|
+
const thinking = childThinkingLevel(child);
|
|
249
256
|
const activity = nestedActivity(child);
|
|
250
257
|
rows.push({
|
|
251
258
|
name: nestedRunLabel(child),
|
|
@@ -253,6 +260,7 @@ function nestedFleetRows(children: NestedRunSummary[] | undefined, visibleLimit:
|
|
|
253
260
|
state: child.state,
|
|
254
261
|
depth,
|
|
255
262
|
...(modelThinking ? { modelThinking } : {}),
|
|
263
|
+
...(thinking ? { thinking } : {}),
|
|
256
264
|
...(activity ? { activity } : {}),
|
|
257
265
|
...(child.startedAt !== undefined ? { startedAt: child.startedAt } : {}),
|
|
258
266
|
...(child.endedAt !== undefined ? { endedAt: child.endedAt } : {}),
|
|
@@ -896,13 +904,13 @@ export class SubagentFleetStatus {
|
|
|
896
904
|
if (row.overflow !== undefined) return truncateToWidth(`${indent}${marker} ${theme.fg("dim", `+${row.overflow} nested leaves`)}`, width);
|
|
897
905
|
const modelThinking = row.modelThinking ? ` (${row.modelThinking})` : "";
|
|
898
906
|
const activity = row.activity ? ` · ${row.activity}` : "";
|
|
899
|
-
const left = `${indent}${marker} ${nestedStatusGlyph(row.state, theme)} ${theme.fg(fleetAgentIdentityColor(row.agentIdentity ?? row.name), `${row.name}${modelThinking}`)} · ${row.state}${activity}`;
|
|
907
|
+
const left = `${indent}${marker} ${nestedStatusGlyph(row.state, theme, row.thinking)} ${theme.fg(fleetAgentIdentityColor(row.agentIdentity ?? row.name), `${row.name}${modelThinking}`)} · ${row.state}${activity}`;
|
|
900
908
|
const elapsed = detailElapsed(row);
|
|
901
909
|
return truncateToWidth(`${left}${elapsed !== undefined ? theme.fg("dim", ` · ${elapsed}`) : ""}`, width);
|
|
902
910
|
}
|
|
903
911
|
|
|
904
912
|
private workflowRowGlyph(row: AsyncStatusWorkflowRow, theme: Theme): string {
|
|
905
|
-
if (!row.kind) return nestedStatusGlyph(row.state as FleetNestedRow["state"], theme);
|
|
913
|
+
if (!row.kind) return nestedStatusGlyph(row.state as FleetNestedRow["state"], theme, row.thinking);
|
|
906
914
|
const state = row.state as HostStepState;
|
|
907
915
|
if (state === "pending") return theme.fg("muted", "◦");
|
|
908
916
|
if (state === "running") return theme.fg("accent", "●");
|
|
@@ -913,7 +921,7 @@ export class SubagentFleetStatus {
|
|
|
913
921
|
|
|
914
922
|
private workflowRowStateLabel(row: AsyncStatusWorkflowRow, theme: Theme): string {
|
|
915
923
|
const state = row.kind ? hostStepVerdictLabel(row.state as HostStepState, row.verdict as HostStepVerdict | undefined) : row.state;
|
|
916
|
-
if (state === "running") return theme.fg("accent", state);
|
|
924
|
+
if (state === "running") return row.kind ? theme.fg("accent", state) : runningTone(theme, row.thinking)(state);
|
|
917
925
|
if (state === "pending" || state === "queued") return theme.fg("muted", state);
|
|
918
926
|
if (state === "pass" || state === "complete" || state === "completed") return theme.fg("success", state === "pass" ? "pass" : "complete");
|
|
919
927
|
if (state === "fail" || state === "failed" || state === "error") return theme.fg("error", state === "fail" ? "fail" : state);
|
|
@@ -925,7 +933,7 @@ export class SubagentFleetStatus {
|
|
|
925
933
|
const glyph = phase.state === "complete"
|
|
926
934
|
? theme.fg("success", "✓")
|
|
927
935
|
: phase.state === "running"
|
|
928
|
-
? theme
|
|
936
|
+
? runningTone(theme)("●")
|
|
929
937
|
: phase.state === "blocked" || phase.state === "failed"
|
|
930
938
|
? theme.fg("error", phase.state === "blocked" ? "!" : "✗")
|
|
931
939
|
: phase.state === "queued"
|
package/src/tui/fleet.ts
CHANGED
|
@@ -23,8 +23,10 @@ import { stopAsyncRun } from "../runs/foreground/async-stop-action.ts";
|
|
|
23
23
|
import { resolveWorkflowForegroundSteeringTarget, steerWorkflowForegroundTarget } from "../runs/foreground/workflow-foreground-steering.ts";
|
|
24
24
|
import { contextModeBadge, contextModeLabel } from "../runs/shared/context-mode.ts";
|
|
25
25
|
import { FLEET_STATUS_WIDGET_KEY } from "./fleet-status.ts";
|
|
26
|
-
import { readFleetTranscript, renderFleetTranscript } from "./fleet-transcript.ts";
|
|
26
|
+
import { readFleetTranscript, renderFleetTranscript, type FleetTranscript } from "./fleet-transcript.ts";
|
|
27
27
|
import { buildNativeFleetTranscript, loadNativeTranscriptSupport, type NativeTranscriptModule } from "./fleet-native-transcript.ts";
|
|
28
|
+
import { runningTone } from "./running-tone.ts";
|
|
29
|
+
import { childThinkingLevel, type ThinkingLevel } from "../shared/model-info.ts";
|
|
28
30
|
import { handleInspectorAction } from "../inspectors/actions.ts";
|
|
29
31
|
import type { InspectorPlugin } from "../inspectors/types.ts";
|
|
30
32
|
import { getLivePromptAudit, type LivePromptAudit, type PromptAuditView } from "../runs/foreground/prompt-audit.ts";
|
|
@@ -360,8 +362,18 @@ function visibleWorkflowParentKeyForForegroundKey(state: SubagentState, key: str
|
|
|
360
362
|
return undefined;
|
|
361
363
|
}
|
|
362
364
|
|
|
365
|
+
/** The recorded level of the one child a running Fleet row stands for; a whole run or an external run has none. */
|
|
366
|
+
function fleetItemThinkingLevel(item: FleetItem): ThinkingLevel | undefined {
|
|
367
|
+
switch (item.kind) {
|
|
368
|
+
case "foreground-active": return childThinkingLevel(item.activeChild ?? item.control);
|
|
369
|
+
case "foreground-recent": return childThinkingLevel(item.child);
|
|
370
|
+
case "async": return childThinkingLevel(item.step);
|
|
371
|
+
case "external": return undefined;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
363
375
|
function statusGlyph(item: FleetItem, theme: Theme): string {
|
|
364
|
-
if (item.state === "running") return theme
|
|
376
|
+
if (item.state === "running") return runningTone(theme, fleetItemThinkingLevel(item))("●");
|
|
365
377
|
if (item.state === "queued" || item.state === "pending") return theme.fg("muted", "◦");
|
|
366
378
|
if (item.state === "complete" || item.state === "completed") return theme.fg("success", "✓");
|
|
367
379
|
if (item.state === "paused" || item.state === "stopped" || item.state === "detached") return theme.fg("warning", "■");
|