pi-subagents 0.57.0 → 0.59.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/docs/agents.md +18 -9
  3. package/docs/configuration.md +4 -4
  4. package/docs/extension-api.md +40 -1
  5. package/docs/models.md +27 -4
  6. package/docs/observability.md +1 -1
  7. package/docs/tool-reference.md +92 -6
  8. package/docs/workflows.md +115 -0
  9. package/package.json +3 -1
  10. package/prompts/review-loop.md +2 -2
  11. package/skills/council-mode/SKILL.md +1 -1
  12. package/skills/pi-subagents/SKILL.md +3 -1
  13. package/skills/pi-subagents/references/execution-controls.md +6 -2
  14. package/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
  15. package/skills/pi-subagents/references/prompting-and-roles.md +26 -5
  16. package/src/agents/agent-management.ts +28 -17
  17. package/src/agents/agent-serializer.ts +9 -2
  18. package/src/agents/agents.ts +103 -27
  19. package/src/agents/runtime-agent-events.ts +70 -0
  20. package/src/agents/runtime-agent-registry.ts +19 -18
  21. package/src/api/agents.ts +10 -5
  22. package/src/api/background-work.ts +5 -1
  23. package/src/api/delegation.ts +0 -7
  24. package/src/api/preflight.ts +32 -10
  25. package/src/extension/fanout-child.ts +5 -3
  26. package/src/extension/index.ts +66 -27
  27. package/src/extension/public-execution.ts +15 -2
  28. package/src/extension/rpc.ts +35 -14
  29. package/src/extension/schemas.ts +37 -12
  30. package/src/extension/tool-description.ts +25 -6
  31. package/src/integrations/herdr-status.ts +5 -0
  32. package/src/intercom/result-intercom.ts +2 -0
  33. package/src/profiles/profiles.ts +5 -6
  34. package/src/runs/background/active-async-capacity.ts +2 -2
  35. package/src/runs/background/async-execution.ts +78 -46
  36. package/src/runs/background/async-job-tracker.ts +14 -12
  37. package/src/runs/background/async-resume.ts +29 -27
  38. package/src/runs/background/async-status-snapshot.ts +23 -261
  39. package/src/runs/background/async-status.ts +68 -7
  40. package/src/runs/background/chain-append.ts +8 -3
  41. package/src/runs/background/chain-root-attachment.ts +60 -8
  42. package/src/runs/background/fleet-view.ts +21 -11
  43. package/src/runs/background/notify.ts +184 -9
  44. package/src/runs/background/result-delivery-ownership.ts +45 -0
  45. package/src/runs/background/result-files.ts +2 -1
  46. package/src/runs/background/result-watcher.ts +29 -10
  47. package/src/runs/background/resume-guidance.ts +1 -1
  48. package/src/runs/background/retained-children.ts +1 -1
  49. package/src/runs/background/run-status.ts +18 -8
  50. package/src/runs/background/scheduled-runs.ts +86 -7
  51. package/src/runs/background/stale-run-reconciler.ts +10 -4
  52. package/src/runs/background/steering.ts +4 -14
  53. package/src/runs/background/subagent-runner.ts +389 -350
  54. package/src/runs/background/subagent-wait.ts +58 -10
  55. package/src/runs/background/terminal-run-index.ts +1 -1
  56. package/src/runs/background/wait-completions.ts +22 -1
  57. package/src/runs/background/wait-config.ts +23 -9
  58. package/src/runs/background/wait-tool.ts +9 -2
  59. package/src/runs/foreground/async-steering-action.ts +2 -2
  60. package/src/runs/foreground/execution.ts +134 -121
  61. package/src/runs/foreground/foreground-control.ts +3 -0
  62. package/src/runs/foreground/foreground-history.ts +1 -0
  63. package/src/runs/foreground/subagent-executor.ts +527 -257
  64. package/src/runs/foreground/workflow-detach-reconcile.ts +130 -120
  65. package/src/runs/shared/abort-recovery.ts +119 -0
  66. package/src/runs/shared/async-status-projection.ts +463 -0
  67. package/src/runs/shared/child-identity.ts +19 -4
  68. package/src/runs/shared/child-launch-plan.ts +151 -0
  69. package/src/runs/shared/completion-evidence.ts +89 -0
  70. package/src/runs/shared/completion-guard.ts +5 -4
  71. package/src/runs/shared/dynamic-fanout.ts +3 -3
  72. package/src/runs/shared/fast-mode-extension.ts +5 -5
  73. package/src/runs/shared/host-step-status.ts +230 -0
  74. package/src/runs/shared/lane-metadata.ts +105 -0
  75. package/src/runs/shared/launch-cwd.ts +16 -0
  76. package/src/runs/shared/long-running-guard.ts +2 -1
  77. package/src/runs/shared/mcp-config-sources.ts +422 -0
  78. package/src/runs/shared/mcp-direct-tool-allowlist.ts +221 -158
  79. package/src/runs/shared/mcp-direct-tool-grant.ts +197 -0
  80. package/src/runs/shared/model-exclusions.ts +12 -0
  81. package/src/runs/shared/model-fallback.ts +25 -6
  82. package/src/runs/shared/nested-events.ts +6 -2
  83. package/src/runs/shared/nested-render.ts +7 -3
  84. package/src/runs/shared/parallel-handoff.ts +419 -7
  85. package/src/runs/shared/parallel-utils.ts +15 -1
  86. package/src/runs/shared/pi-args.ts +81 -8
  87. package/src/runs/shared/single-output.ts +44 -4
  88. package/src/runs/shared/subagent-prompt-runtime.ts +98 -13
  89. package/src/runs/shared/worktree-cleanup-plan.ts +847 -0
  90. package/src/runs/shared/worktree.ts +18 -0
  91. package/src/shared/child-session-name.ts +46 -0
  92. package/src/shared/extension-context.ts +24 -0
  93. package/src/shared/formatters.ts +11 -2
  94. package/src/shared/launch-contract.ts +5 -1
  95. package/src/shared/settings.ts +9 -103
  96. package/src/shared/types.ts +240 -30
  97. package/src/shared/utils.ts +41 -84
  98. package/src/slash/delegation-adapters.ts +1 -8
  99. package/src/slash/delegation-request.ts +0 -4
  100. package/src/slash/slash-bridge.ts +1 -2
  101. package/src/slash/slash-commands.ts +369 -90
  102. package/src/slash/slash-live-state.ts +22 -11
  103. package/src/slash/subagents-admin.ts +3 -0
  104. package/src/tui/fleet-status.ts +125 -74
  105. package/src/tui/fleet.ts +11 -5
  106. package/src/tui/render.ts +330 -33
  107. package/src/watchdog/turn-delta.ts +1 -1
  108. package/src/workflows/chat-progress.ts +6 -3
  109. package/src/workflows/host-command.ts +230 -0
  110. package/src/workflows/scripted-workflow.ts +496 -35
  111. package/src/workflows/workflow-child-summary.ts +9 -5
  112. package/src/workflows/workflow-preflight.ts +270 -0
  113. package/src/workflows/workflow-receipt.ts +79 -5
  114. package/src/workflows/workflow-settlement.ts +246 -0
  115. package/src/runs/shared/turn-budget.ts +0 -98
@@ -40,11 +40,43 @@ export interface ChainOutputMapEntry {
40
40
 
41
41
  export type ChainOutputMap = Record<string, ChainOutputMapEntry>;
42
42
 
43
- export type WorkflowNodeStatus = "pending" | "running" | "completed" | "failed" | "paused" | "stopped" | "detached" | "rejected";
43
+ export type WorkflowNodeStatus = "pending" | "running" | "completed" | "failed" | "partial" | "paused" | "stopped" | "detached" | "rejected";
44
+
45
+ export type HostStepMonitorKind = "command" | "ci" | "gate";
46
+ export type HostStepState = "pending" | "running" | "done" | "cancelled" | "error";
47
+ export type HostStepVerdict = "pass" | "fail" | "inconclusive";
48
+
49
+ export interface HostStepFreshnessV1 {
50
+ expectedRef: string;
51
+ observedRef?: string;
52
+ stale?: boolean;
53
+ }
54
+
55
+ /** Bounded, provider-agnostic status for a host-owned workflow monitor. */
56
+ export interface HostStepNodeV1 {
57
+ version: 1;
58
+ kind: "host-step";
59
+ /** Explicit monitor category; never inferred from labels or commands. */
60
+ monitorKind: HostStepMonitorKind;
61
+ id: string;
62
+ label: string;
63
+ role?: string;
64
+ provider?: string;
65
+ state: HostStepState;
66
+ verdict?: HostStepVerdict;
67
+ reasonCode?: string;
68
+ detail?: string;
69
+ target?: string;
70
+ freshness?: HostStepFreshnessV1;
71
+ reportPath?: string;
72
+ exitCode?: number | null;
73
+ updatedAt: number;
74
+ deadlineAt?: number;
75
+ }
44
76
 
45
77
  export interface WorkflowGraphNode {
46
78
  id: string;
47
- kind: "step" | "parallel-group" | "dynamic-parallel-group" | "agent";
79
+ kind: "step" | "parallel-group" | "dynamic-parallel-group" | "agent" | "host-step";
48
80
  agent?: string;
49
81
  phase?: string;
50
82
  label: string;
@@ -64,6 +96,7 @@ export interface WorkflowGraphNode {
64
96
  structured?: boolean;
65
97
  acceptanceStatus?: AcceptanceLedgerStatus;
66
98
  error?: string;
99
+ hostStep?: HostStepNodeV1;
67
100
  }
68
101
 
69
102
  export interface WorkflowGraphSnapshot {
@@ -74,8 +107,58 @@ export interface WorkflowGraphSnapshot {
74
107
  currentNodeId?: string;
75
108
  }
76
109
 
110
+ export type WorkflowPreflightCoverage = "complete" | "partial";
111
+ export type WorkflowPreflightMode = "mutation" | "review" | "scout" | "gate";
112
+
113
+ /** Bounded, display-only lane hints supplied alongside a workflowScript launch. */
114
+ export interface WorkflowPreflightLaneV1 {
115
+ key: string;
116
+ mode?: WorkflowPreflightMode;
117
+ decision?: string;
118
+ claims?: string[];
119
+ expectedOutput?: string;
120
+ independence?: string;
121
+ }
122
+
123
+ /** Versioned, display-only workflow launch plan; it never grants launch authority. */
124
+ export interface WorkflowPreflightV1 {
125
+ version: 1;
126
+ coverage: WorkflowPreflightCoverage;
127
+ lanes: WorkflowPreflightLaneV1[];
128
+ }
129
+
77
130
  export type WorkflowReceiptState = "complete" | "failed" | "paused" | "stopped";
78
131
 
132
+ export type WorkflowTerminalResolution = "settled-awaiting-resume" | "failed-child" | "interrupted-child";
133
+
134
+ export interface WorkflowTerminalOutcome {
135
+ state: "partial";
136
+ reason: "budget_exhausted" | "timeout";
137
+ }
138
+
139
+ export interface WorkflowRecoveryAction {
140
+ key: string;
141
+ call: "runs.run";
142
+ resume: { workflowRunId: string; key: string; latest: true };
143
+ taskRequired: true;
144
+ }
145
+
146
+ /**
147
+ * Bounded, launch-declared workflow lane metadata. This is display and
148
+ * triage information only; capability ceilings, authorization, and cleanup
149
+ * safety remain owned by their existing enforcement and handoff paths.
150
+ */
151
+ export type WorkflowLaneMode = "mutation" | "review" | "scout" | "gate";
152
+
153
+ export interface WorkflowLaneMetadata {
154
+ version: 1;
155
+ key: string;
156
+ mode?: WorkflowLaneMode;
157
+ sourceRef?: string;
158
+ claims?: string[];
159
+ outputPaths?: string[];
160
+ }
161
+
79
162
  export interface WorkflowChildSummaryV1 {
80
163
  version: 1;
81
164
  parentToolCallId: string;
@@ -86,6 +169,8 @@ export interface WorkflowChildSummaryV1 {
86
169
  childId: string;
87
170
  runId?: string;
88
171
  agent?: string;
172
+ /** Human-readable display name for the child session, when derived at launch. */
173
+ sessionName?: string;
89
174
  model?: string;
90
175
  thinking?: string;
91
176
  state: "pending" | "running" | "completed" | "failed" | "paused" | "stopped" | "rejected" | "detached";
@@ -98,6 +183,8 @@ type WorkflowReceiptEntryResumability =
98
183
 
99
184
  export type WorkflowReceiptEntry = WorkflowReceiptEntryResumability & {
100
185
  key: string;
186
+ lane?: WorkflowLaneMetadata;
187
+ terminalOutcome?: WorkflowTerminalOutcome;
101
188
  agent?: string;
102
189
  requestedContext?: "fresh" | "fork";
103
190
  resolvedContext?: "fresh" | "fork" | "mixed";
@@ -112,7 +199,11 @@ export interface WorkflowReceipt {
112
199
  state: WorkflowReceiptState;
113
200
  createdAt: number;
114
201
  entries: Record<string, WorkflowReceiptEntry>;
202
+ hostSteps?: HostStepNodeV1[];
115
203
  workflowChildren?: WorkflowChildSummaryV1;
204
+ workflowResolution?: WorkflowTerminalResolution;
205
+ terminalOutcome?: WorkflowTerminalOutcome;
206
+ recovery?: WorkflowRecoveryAction[];
116
207
  }
117
208
 
118
209
  export interface SavedOutputReference {
@@ -139,16 +230,6 @@ export interface Usage {
139
230
  turns: number;
140
231
  }
141
232
 
142
- export interface TurnBudgetConfig {
143
- maxTurns: number;
144
- graceTurns?: number;
145
- }
146
-
147
- export interface ResolvedTurnBudget {
148
- maxTurns: number;
149
- graceTurns: number;
150
- }
151
-
152
233
  export interface ToolBudgetConfig {
153
234
  soft?: number;
154
235
  hard: number;
@@ -171,9 +252,19 @@ export interface ToolBudgetState extends ResolvedToolBudget {
171
252
  blockedTool?: string;
172
253
  }
173
254
 
255
+ /**
256
+ * @deprecated Turn budgets are no longer accepted as launch configuration or
257
+ * enforced. Retained only to decode historical persisted status and result data.
258
+ */
174
259
  export type TurnBudgetOutcome = "within-budget" | "wrap-up-requested" | "termination-deferred" | "exceeded";
175
260
 
176
- export interface TurnBudgetState extends ResolvedTurnBudget {
261
+ /**
262
+ * @deprecated Historical persisted turn-budget state. New runs do not produce
263
+ * this field, but status readers retain it for backwards compatibility.
264
+ */
265
+ export interface TurnBudgetState {
266
+ maxTurns: number;
267
+ graceTurns: number;
177
268
  outcome: TurnBudgetOutcome;
178
269
  turnCount: number;
179
270
  wrapUpRequestedAtTurn?: number;
@@ -239,6 +330,8 @@ export interface CompletionBatchConfig {
239
330
 
240
331
  export interface WaitToolConfigObject {
241
332
  enabled?: boolean;
333
+ /** Default blocking window for subagent_wait calls that omit timeoutMs. */
334
+ defaultTimeoutMs?: number;
242
335
  }
243
336
 
244
337
  export type WaitToolConfig = boolean | WaitToolConfigObject;
@@ -289,6 +382,11 @@ export interface ParallelHandoffChild {
289
382
  index: number;
290
383
  taskIndex: number;
291
384
  agent: string;
385
+ /** Stable workflow identity used to join status/receipt metadata. */
386
+ workflowKey?: string;
387
+ /** Child run id when the worktree belongs to a workflow child. */
388
+ runId?: string;
389
+ lane?: WorkflowLaneMetadata;
292
390
  status: SubagentResultStatus;
293
391
  summary: string;
294
392
  outputPath?: string;
@@ -298,6 +396,15 @@ export interface ParallelHandoffChild {
298
396
  patch: ParallelHandoffPatch;
299
397
  }
300
398
 
399
+ /** Launch-time identity retained while a handoff group has no terminal child rows yet. */
400
+ export interface ParallelHandoffLaneBinding {
401
+ index: number;
402
+ taskIndex: number;
403
+ workflowKey?: string;
404
+ runId?: string;
405
+ lane?: WorkflowLaneMetadata;
406
+ }
407
+
301
408
  export interface ParallelHandoffCleanupTask {
302
409
  index: number;
303
410
  path: string;
@@ -309,11 +416,38 @@ export interface ParallelHandoffCleanupTask {
309
416
  errors?: string[];
310
417
  }
311
418
 
419
+ export type CleanupEligibility =
420
+ | { state: "active" }
421
+ | { state: "terminal-eligible" }
422
+ | { state: "terminal-blocked"; reason: string }
423
+ | { state: "superseded-eligible" }
424
+ | { state: "unknown" };
425
+
426
+ export interface ParallelHandoffMergeEvidence {
427
+ prNumber: number;
428
+ reviewedHead: string;
429
+ mergeCommit: string;
430
+ treeEquivalent: boolean | "unknown";
431
+ postMergeChecks: "recorded" | "unknown";
432
+ attestedBy: string;
433
+ attestedAt: string;
434
+ manifestDigest?: string;
435
+ }
436
+
437
+ export interface ParallelHandoffSupersessionEvidence {
438
+ supersededBy: string;
439
+ attestedBy: string;
440
+ attestedAt: string;
441
+ manifestDigest?: string;
442
+ }
443
+
312
444
  export interface ParallelHandoffGroup {
313
445
  stepIndex: number;
314
446
  baseCommit: string;
315
447
  repoRoot: string;
316
448
  children: ParallelHandoffChild[];
449
+ /** Optional launch identities for pending groups before child results settle. */
450
+ laneBindings?: ParallelHandoffLaneBinding[];
317
451
  cleanup: {
318
452
  state: "complete" | "partial";
319
453
  tasks: ParallelHandoffCleanupTask[];
@@ -331,6 +465,9 @@ export interface ParallelHandoffManifest {
331
465
  createdAt: number;
332
466
  updatedAt: number;
333
467
  groups: ParallelHandoffGroup[];
468
+ merge?: ParallelHandoffMergeEvidence;
469
+ supersession?: ParallelHandoffSupersessionEvidence;
470
+ cleanupEligibility?: CleanupEligibility;
334
471
  }
335
472
 
336
473
  export interface ParallelHandoffReference {
@@ -340,6 +477,7 @@ export interface ParallelHandoffReference {
340
477
  childCount: number;
341
478
  changedPatches: number;
342
479
  cleanupState: "complete" | "partial";
480
+ cleanupEligibility?: CleanupEligibility;
343
481
  }
344
482
 
345
483
  export interface AgentContract {
@@ -348,7 +486,7 @@ export interface AgentContract {
348
486
 
349
487
  export type ChainGateLayer = "execution" | "acceptance";
350
488
 
351
- export type ExecutionProjectionStatus = "completed" | "failed" | "paused" | "stopped" | "detached";
489
+ export type ExecutionProjectionStatus = "completed" | "failed" | "partial" | "paused" | "stopped" | "detached";
352
490
 
353
491
  export interface ExecutionProjection {
354
492
  status: ExecutionProjectionStatus;
@@ -375,8 +513,24 @@ export interface FileMutationEffect {
375
513
  evidence?: TrackedMutationEvidence;
376
514
  }
377
515
 
516
+ export interface SettlementDiagnostic {
517
+ finalTextPresent: boolean;
518
+ mutation: {
519
+ expected: boolean;
520
+ attempted: boolean;
521
+ observed: boolean;
522
+ };
523
+ requiredOutput?: {
524
+ kind: "file-only" | "structured";
525
+ path: string;
526
+ missing: boolean;
527
+ };
528
+ afterCompactionSettlement?: boolean;
529
+ }
530
+
378
531
  export interface EffectsProjection {
379
532
  fileMutation?: FileMutationEffect;
533
+ settlementDiagnostic?: SettlementDiagnostic;
380
534
  }
381
535
 
382
536
  export interface TrackedMutationSnapshot {
@@ -602,12 +756,15 @@ export interface SteeringRecoveryDescriptor {
602
756
  thinking?: string;
603
757
  thinkingCeiling?: ThinkingLevel;
604
758
  tools?: string[];
759
+ allowNestedSubagents?: boolean;
605
760
  extensions?: string[];
606
761
  subagentOnlyExtensions?: string[];
607
762
  mcpDirectTools?: string[];
763
+ mutationTools?: string[];
608
764
  systemPrompt?: string;
609
765
  systemPromptMode: "append" | "replace";
610
766
  inheritProjectContext: boolean;
767
+ inheritGlobalContext: boolean;
611
768
  inheritSkills: boolean;
612
769
  skills?: string[];
613
770
  skillPath?: string[];
@@ -623,8 +780,8 @@ export interface SteeringRecoveryDescriptor {
623
780
  context?: "fresh" | "fork";
624
781
  /** Raw per-run bridge override. Omitted descriptors continue to use global config. */
625
782
  intercomBridge?: IntercomBridgeConfig;
783
+ lane?: WorkflowLaneMetadata;
626
784
  absoluteDeadlineAt?: number;
627
- initialTurnBudget?: ResolvedTurnBudget;
628
785
  initialToolBudget?: ResolvedToolBudget;
629
786
  maxSubagentDepth: number;
630
787
  maxOutput?: MaxOutputConfig;
@@ -638,7 +795,7 @@ export interface SteeringRecoveryDescriptor {
638
795
 
639
796
  export type PublicNestedStepSummary = Pick<
640
797
  NestedStepSummary,
641
- "agent" | "status" | "model" | "thinking" | "sessionFile" | "transcriptPath" | "transcriptError" | "activityState" | "lastActivityAt" | "currentTool" | "currentToolStartedAt" | "currentPath" | "turnCount" | "toolCount" | "toolBudget" | "toolBudgetBlocked" | "startedAt" | "endedAt" | "error" | "timedOut" | "stopped"
798
+ "agent" | "sessionName" | "status" | "model" | "thinking" | "sessionFile" | "transcriptPath" | "transcriptError" | "activityState" | "lastActivityAt" | "currentTool" | "currentToolStartedAt" | "currentPath" | "turnCount" | "toolCount" | "toolBudget" | "toolBudgetBlocked" | "startedAt" | "endedAt" | "error" | "timedOut" | "stopped"
642
799
  > & {
643
800
  children?: PublicNestedRunSummary[];
644
801
  };
@@ -651,7 +808,7 @@ export type CostSummary = {
651
808
 
652
809
  export type PublicNestedRunSummary = Pick<
653
810
  NestedRunSummary,
654
- "id" | "parentRunId" | "parentStepIndex" | "parentAgent" | "depth" | "path" | "asyncDir" | "sessionId" | "sessionFile" | "intercomTarget" | "ownerIntercomTarget" | "leafIntercomTarget" | "ownerState" | "mode" | "state" | "agent" | "agents" | "model" | "thinking" | "currentStep" | "chainStepCount" | "parallelGroups" | "activityState" | "lastActivityAt" | "currentTool" | "currentToolStartedAt" | "currentPath" | "turnCount" | "toolCount" | "toolBudget" | "toolBudgetBlocked" | "totalTokens" | "totalCost" | "startedAt" | "endedAt" | "lastUpdate" | "error" | "timeoutMs" | "deadlineAt" | "timedOut" | "stopped" | "turnBudget" | "turnBudgetExceeded" | "wrapUpRequested"
811
+ "id" | "parentRunId" | "parentStepIndex" | "parentAgent" | "depth" | "path" | "asyncDir" | "sessionId" | "sessionFile" | "intercomTarget" | "ownerIntercomTarget" | "leafIntercomTarget" | "ownerState" | "mode" | "state" | "agent" | "sessionName" | "agents" | "model" | "thinking" | "currentStep" | "chainStepCount" | "parallelGroups" | "activityState" | "lastActivityAt" | "currentTool" | "currentToolStartedAt" | "currentPath" | "turnCount" | "toolCount" | "toolBudget" | "toolBudgetBlocked" | "totalTokens" | "totalCost" | "startedAt" | "endedAt" | "lastUpdate" | "error" | "timeoutMs" | "deadlineAt" | "timedOut" | "stopped" | "turnBudget" | "turnBudgetExceeded" | "wrapUpRequested"
655
812
  > & {
656
813
  steps?: PublicNestedStepSummary[];
657
814
  children?: PublicNestedRunSummary[];
@@ -659,6 +816,8 @@ export type PublicNestedRunSummary = Pick<
659
816
 
660
817
  export interface SubagentResultIntercomChild {
661
818
  agent: string;
819
+ /** Human-readable display name for the child session, when derived at launch. */
820
+ sessionName?: string;
662
821
  /** Process/lifecycle status. It does not establish semantic task completion. */
663
822
  status: SubagentResultStatus;
664
823
  /** Whether the child produced substantive output before its process ended. */
@@ -707,6 +866,8 @@ export interface ChildWatchdogProgress {
707
866
  export interface AgentProgress {
708
867
  index: number;
709
868
  agent: string;
869
+ /** Human-readable display name for the child's session, when derived at launch. */
870
+ sessionName?: string;
710
871
  status: "pending" | "running" | "completed" | "failed" | "detached";
711
872
  activityState?: ActivityState;
712
873
  task: string;
@@ -742,6 +903,8 @@ export interface ToolCallSummary {
742
903
  interface ProgressSummary {
743
904
  index?: number;
744
905
  agent?: string;
906
+ /** Human-readable display name for the child's session, when derived at launch. */
907
+ sessionName?: string;
745
908
  status?: AgentProgress["status"];
746
909
  activityState?: ActivityState;
747
910
  skills?: string[];
@@ -1002,6 +1165,9 @@ export interface SingleResult {
1002
1165
  index: number;
1003
1166
  agent: string;
1004
1167
  task: string;
1168
+ /** Human-readable display name for the child's own session (agent + task
1169
+ * excerpt), when the launcher derived one. Display metadata only. */
1170
+ sessionName?: string;
1005
1171
  /** Resolved launch context for this child. */
1006
1172
  context?: "fresh" | "fork";
1007
1173
  exitCode: number;
@@ -1096,6 +1262,10 @@ export interface WaitCompletionChild {
1096
1262
  agent?: string;
1097
1263
  /** Child run identity where the producer records one (workflow children); artifact files are keyed by it. */
1098
1264
  runId?: string;
1265
+ /** Bounded accounting projection used by /subagent-cost after async completion. */
1266
+ usage?: Usage;
1267
+ /** Persisted Pi child session when available. */
1268
+ sessionFile?: string;
1099
1269
  success?: boolean;
1100
1270
  outputState?: SubagentOutputState;
1101
1271
  error?: string;
@@ -1136,6 +1306,12 @@ export interface Details {
1136
1306
  * identity never reaches tool_result details.
1137
1307
  */
1138
1308
  completions?: WaitCompletion[];
1309
+ wait?: {
1310
+ reason: "window_elapsed";
1311
+ timedOut: true;
1312
+ activeRunIds: string[];
1313
+ activeProviderItems: Array<{ provider: string; id: string }>;
1314
+ };
1139
1315
  controlEvents?: ControlEvent[];
1140
1316
  steering?: SteerActionResult;
1141
1317
  asyncId?: string;
@@ -1145,7 +1321,6 @@ export interface Details {
1145
1321
  deadlineAt?: number;
1146
1322
  timedOut?: boolean;
1147
1323
  stopped?: boolean;
1148
- turnBudget?: ResolvedTurnBudget;
1149
1324
  toolBudget?: ResolvedToolBudget;
1150
1325
  usageBudget?: UsageBudgetState;
1151
1326
  progress?: AgentProgress[];
@@ -1165,6 +1340,9 @@ export interface Details {
1165
1340
  totalSteps?: number; // Total steps in chain
1166
1341
  currentStepIndex?: number; // 0-indexed current step (for running chains)
1167
1342
  workflowGraph?: WorkflowGraphSnapshot;
1343
+ /** Validated, display-only fanout plan supplied with a workflow launch. */
1344
+ preflight?: WorkflowPreflightV1;
1345
+ preflightWarnings?: string[];
1168
1346
  outputs?: ChainOutputMap;
1169
1347
  // Aggregated child usage across all agents in the run
1170
1348
  totalChildUsage?: Usage;
@@ -1193,8 +1371,9 @@ export interface Details {
1193
1371
  mission?: MissionRecord;
1194
1372
  workflow?: {
1195
1373
  value?: unknown;
1374
+ preflightWarnings?: string[];
1196
1375
  trace: Array<{
1197
- operation: "run" | "status" | "steer";
1376
+ operation: "run" | "status" | "steer" | "host";
1198
1377
  key: string;
1199
1378
  state: "started" | "completed" | "failed" | "detached" | "stopped" | "reused" | "queued" | "delivered" | "missed";
1200
1379
  agent?: string;
@@ -1202,6 +1381,9 @@ export interface Details {
1202
1381
  phase?: string;
1203
1382
  label?: string;
1204
1383
  durationMs?: number;
1384
+ /** Internal provenance for a generated runs.lanes child key. */
1385
+ generatedLaneKey?: string;
1386
+ warning?: string;
1205
1387
  error?: string;
1206
1388
  }>;
1207
1389
  emits: unknown[];
@@ -1261,7 +1443,7 @@ export interface AsyncParallelGroupStatus {
1261
1443
  stepIndex: number;
1262
1444
  }
1263
1445
 
1264
- export type NestedRunState = "queued" | "running" | "complete" | "failed" | "paused" | "stopped" | "rejected";
1446
+ export type NestedRunState = "queued" | "running" | "complete" | "failed" | "partial" | "paused" | "stopped" | "rejected";
1265
1447
  export type NestedOwnerState = "live" | "gone" | "unknown";
1266
1448
 
1267
1449
  export interface NestedRunAddress {
@@ -1275,7 +1457,9 @@ export interface NestedRunAddress {
1275
1457
 
1276
1458
  export interface NestedStepSummary {
1277
1459
  agent: string;
1278
- status: "pending" | "running" | "complete" | "completed" | "failed" | "paused" | "stopped" | "rejected";
1460
+ /** Human-readable display name for the child session, when derived at launch. */
1461
+ sessionName?: string;
1462
+ status: "pending" | "running" | "complete" | "completed" | "failed" | "partial" | "paused" | "stopped" | "rejected";
1279
1463
  model?: string;
1280
1464
  thinking?: string;
1281
1465
  sessionFile?: string;
@@ -1326,6 +1510,8 @@ export interface NestedRunSummary extends NestedRunAddress {
1326
1510
  capabilityAudit?: SubagentCapabilityAudit;
1327
1511
  state: NestedRunState;
1328
1512
  agent?: string;
1513
+ /** Human-readable display name for the child session, when derived at launch. */
1514
+ sessionName?: string;
1329
1515
  agents?: string[];
1330
1516
  model?: string;
1331
1517
  thinking?: string;
@@ -1387,6 +1573,7 @@ export interface AsyncStartedEvent {
1387
1573
  chainStepCount?: number;
1388
1574
  parallelGroups?: AsyncParallelGroupStatus[];
1389
1575
  workflowGraph?: WorkflowGraphSnapshot;
1576
+ preflight?: WorkflowPreflightV1;
1390
1577
  launchContractDigest?: string;
1391
1578
  launchResolvedExtensions?: LaunchResolvedChildExtensionsV1;
1392
1579
  runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensionsV1;
@@ -1520,7 +1707,7 @@ export interface AsyncStatus {
1520
1707
  mode: SubagentRunMode;
1521
1708
  context?: "fresh" | "fork" | "mixed";
1522
1709
  isNested?: boolean;
1523
- state: "queued" | "running" | "complete" | "failed" | "paused" | "stopped" | "rejected";
1710
+ state: "queued" | "running" | "complete" | "failed" | "partial" | "paused" | "stopped" | "rejected";
1524
1711
  /** Display-only dismissal marker for a reload-orphaned workflow. */
1525
1712
  displayDismissedAt?: number;
1526
1713
  error?: string;
@@ -1554,6 +1741,7 @@ export interface AsyncStatus {
1554
1741
  pendingAppends?: number;
1555
1742
  parallelGroups?: AsyncParallelGroupStatus[];
1556
1743
  workflowGraph?: WorkflowGraphSnapshot;
1744
+ preflight?: WorkflowPreflightV1;
1557
1745
  processTerminal?: ProcessTerminalV1;
1558
1746
  runFanoutBudget?: RunFanoutBudgetSnapshot;
1559
1747
  runFanoutBudgetDescriptor?: RunFanoutBudgetDescriptor;
@@ -1566,12 +1754,15 @@ export interface AsyncStatus {
1566
1754
  workflowChildren?: WorkflowChildSummaryV1;
1567
1755
  parentWorkflowRunId?: string;
1568
1756
  workflowKey?: string;
1757
+ lane?: WorkflowLaneMetadata;
1569
1758
  /** Set when a durable schedule launched this run, so completions can name their origin. */
1570
1759
  scheduleOrigin?: ScheduleOrigin;
1571
1760
  steps?: Array<{
1572
1761
  /** Stable caller-facing child identity for inspect/status/stop. */
1573
1762
  childId?: string;
1574
1763
  agent: string;
1764
+ /** Human-readable display name for the child session, when derived at launch. */
1765
+ sessionName?: string;
1575
1766
  runner?: ExternalCliRunnerStatus | ExternalJobRunnerStatus;
1576
1767
  externalProcess?: ExternalProcessStatus;
1577
1768
  externalJob?: ExternalJobStatus;
@@ -1582,6 +1773,11 @@ export interface AsyncStatus {
1582
1773
  phase?: string;
1583
1774
  label?: string;
1584
1775
  workflowKey?: string;
1776
+ lane?: WorkflowLaneMetadata;
1777
+ /** Display-only worktree path copied at launch; handoff remains authoritative. */
1778
+ worktreePath?: string;
1779
+ /** Display-only branch copied at launch; handoff remains authoritative. */
1780
+ branch?: string;
1585
1781
  /** Child run identity for workflow capacity reconciliation. */
1586
1782
  runId?: string;
1587
1783
  /** True only when this workflow child owns a detached async runner. */
@@ -1589,7 +1785,7 @@ export interface AsyncStatus {
1589
1785
  parentWorkflowRunId?: string;
1590
1786
  outputName?: string;
1591
1787
  structured?: boolean;
1592
- status: "pending" | "running" | "complete" | "completed" | "failed" | "paused" | "stopped" | "rejected";
1788
+ status: "pending" | "running" | "complete" | "completed" | "failed" | "partial" | "paused" | "stopped" | "rejected";
1593
1789
  stopRequested?: boolean;
1594
1790
  stopRequestedAt?: number;
1595
1791
  children?: NestedRunSummary[];
@@ -1622,6 +1818,7 @@ export interface AsyncStatus {
1622
1818
  skills?: string[];
1623
1819
  model?: string;
1624
1820
  thinking?: string;
1821
+ contextLimit?: number;
1625
1822
  thinkingCeiling?: ThinkingLevel;
1626
1823
  attemptedModels?: string[];
1627
1824
  modelAttempts?: ModelAttempt[];
@@ -1669,7 +1866,7 @@ export interface AsyncJobState {
1669
1866
  cwd?: string;
1670
1867
  /** Parent-resolved child session root retained for trusted live transcript lookup. */
1671
1868
  sessionRoot?: string;
1672
- status: "queued" | "running" | "complete" | "failed" | "paused" | "stopped" | "rejected";
1869
+ status: "queued" | "running" | "complete" | "failed" | "partial" | "paused" | "stopped" | "rejected";
1673
1870
  /** Short caller-facing task/goal shown in fleet surfaces when available. */
1674
1871
  description?: string;
1675
1872
  pid?: number;
@@ -1690,7 +1887,10 @@ export interface AsyncJobState {
1690
1887
  currentStep?: number;
1691
1888
  chainStepCount?: number;
1692
1889
  parallelGroups?: AsyncParallelGroupStatus[];
1890
+ /** Bounded host-owned CI/gate nodes loaded from the workflow status graph. */
1891
+ hostSteps?: HostStepNodeV1[];
1693
1892
  steps?: AsyncJobStep[];
1893
+ preflight?: WorkflowPreflightV1;
1694
1894
  stepsTotal?: number;
1695
1895
  runningSteps?: number;
1696
1896
  completedSteps?: number;
@@ -1720,10 +1920,13 @@ export interface AsyncJobState {
1720
1920
  workflowKey?: string;
1721
1921
  workflow?: Details["workflow"];
1722
1922
  workflowChildren?: WorkflowChildSummaryV1;
1923
+ lane?: WorkflowLaneMetadata;
1723
1924
  }
1724
1925
 
1725
1926
  export interface ForegroundResumeChild {
1726
1927
  agent: string;
1928
+ /** Human-readable display name for the child session, when derived at launch. */
1929
+ sessionName?: string;
1727
1930
  index: number;
1728
1931
  context?: "fresh" | "fork";
1729
1932
  sessionFile?: string;
@@ -1787,6 +1990,8 @@ export interface ForegroundResumeRun {
1787
1990
  export interface ForegroundChildControl {
1788
1991
  index: number;
1789
1992
  agent: string;
1993
+ /** Human-readable display name for the child's session, when derived at launch. */
1994
+ sessionName?: string;
1790
1995
  description?: string;
1791
1996
  startedAt: number;
1792
1997
  updatedAt: number;
@@ -1824,6 +2029,8 @@ export interface ForegroundRunControl {
1824
2029
  /** Effective working directory used to resolve live transcript artifacts. */
1825
2030
  cwd?: string;
1826
2031
  currentAgent?: string;
2032
+ /** Human-readable display name for the current child session, when derived at launch. */
2033
+ sessionName?: string;
1827
2034
  currentIndex?: number;
1828
2035
  /** Short caller-facing task/goal shown in fleet surfaces when available. */
1829
2036
  description?: string;
@@ -2027,6 +2234,8 @@ export interface RunSyncOptions {
2027
2234
  /** Resolved launch context for this child. */
2028
2235
  context?: "fresh" | "fork";
2029
2236
  cwd?: string;
2237
+ /** Original cwd input retained for launch diagnostics. */
2238
+ requestedCwd?: string;
2030
2239
  signal?: AbortSignal;
2031
2240
  interruptSignal?: AbortSignal;
2032
2241
  timeoutMs?: number;
@@ -2035,10 +2244,7 @@ export interface RunSyncOptions {
2035
2244
  toolTimeoutMs?: number;
2036
2245
  /** Raw global config.toolTimeoutMs, used by the per-child resolver. */
2037
2246
  configToolTimeoutMs?: number;
2038
- turnBudget?: ResolvedTurnBudget;
2039
2247
  usageBudget?: UsageBudgetConfig;
2040
- /** Enforce maxTurns + graceTurns as a hard model-turn boundary. */
2041
- enforceHardTurnLimit?: boolean;
2042
2248
  toolBudget?: ResolvedToolBudget;
2043
2249
  allowZeroToolBudget?: boolean;
2044
2250
  allowIntercomDetach?: boolean;
@@ -2063,10 +2269,13 @@ export interface RunSyncOptions {
2063
2269
  sessionFile?: string;
2064
2270
  share?: boolean;
2065
2271
  outputPath?: string;
2272
+ outputClaimPath?: string;
2066
2273
  outputMode?: OutputMode;
2067
2274
  maxSubagentDepth?: number;
2068
2275
  /** Effective parent wait-tool setting propagated to the child runtime. */
2069
2276
  waitToolEnabled?: boolean;
2277
+ /** Effective parent default wait window propagated to the child runtime. */
2278
+ waitToolDefaultTimeoutMs?: number;
2070
2279
  capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
2071
2280
  runFanoutBudget?: RunFanoutBudgetDescriptor;
2072
2281
  nestedRoute?: NestedRouteInfo;
@@ -2085,9 +2294,11 @@ export interface RunSyncOptions {
2085
2294
  /** Package-internal one-use authorization for one foreground workflow child. */
2086
2295
  workflowChildPermitLaunch?: WorkflowChildPermitContext;
2087
2296
  /** Registry models available for heuristic bare-model resolution */
2088
- availableModels?: Array<{ provider: string; id: string; fullId: string }>;
2297
+ availableModels?: Array<{ provider: string; id: string; fullId: string; contextWindow?: number }>;
2089
2298
  /** Current parent-session provider to prefer for ambiguous bare model ids */
2090
2299
  preferredModelProvider?: string;
2300
+ /** Parent Pi event host used to snapshot runtime-registered MCP servers before child launch. */
2301
+ runtimeSnapshotHost?: import("../runs/shared/mcp-direct-tool-allowlist.ts").McpRuntimeSnapshotHost;
2091
2302
  /** Optional subagent model-scope enforcement for fallback candidates */
2092
2303
  modelScope?: ModelScopeRule | ModelScopeRule[];
2093
2304
  /** Skills to make available (overrides agent default if provided) */
@@ -2262,7 +2473,6 @@ export interface ExtensionConfig {
2262
2473
  toolTimeoutMs?: number;
2263
2474
  control?: ControlConfig;
2264
2475
  completionBatch?: CompletionBatchConfig;
2265
- turnBudget?: TurnBudgetConfig;
2266
2476
  toolBudget?: ToolBudgetConfig;
2267
2477
  /** Opt-in native tool permissions. Bash remains outside this policy. */
2268
2478
  permissions?: import("../runs/shared/permissions.ts").PermissionConfig;
@@ -2394,7 +2604,7 @@ export const POLL_INTERVAL_MS = 250;
2394
2604
  export const WIDGET_ANIMATION_INTERVAL_MS = 1000;
2395
2605
  export const MAX_WIDGET_JOBS = 4;
2396
2606
  export const DEFAULT_SUBAGENT_MAX_DEPTH = 2;
2397
- 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", "refine", "refine.show", "refine.rollback", "inspector.open", "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;
2607
+ 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.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;
2398
2608
 
2399
2609
  export const DEFAULT_FORK_PREAMBLE =
2400
2610
  "You are a delegated subagent running from a fork of the parent session. " +