@xzzpig/pi-subagents 0.8.0 → 0.9.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 (218) hide show
  1. package/CHANGELOG.md +443 -0
  2. package/README.md +2 -2
  3. package/agents/claude-code-writer.md +15 -0
  4. package/agents/claude-code.md +15 -0
  5. package/agents/codex-exec-writer.md +15 -0
  6. package/agents/codex-exec.md +15 -0
  7. package/agents/cursor-agent-writer.md +14 -0
  8. package/agents/cursor-agent.md +14 -0
  9. package/agents/reviewer.md +1 -1
  10. package/agents/scout.md +1 -1
  11. package/docs/agents.md +151 -39
  12. package/docs/configuration.md +81 -22
  13. package/docs/extension-api.md +69 -14
  14. package/docs/missions.md +2 -0
  15. package/docs/models.md +32 -9
  16. package/docs/observability.md +22 -20
  17. package/docs/tool-reference.md +123 -14
  18. package/docs/watchdog.md +92 -114
  19. package/docs/workflows.md +142 -4
  20. package/install.mjs +1 -1
  21. package/package.json +5 -4
  22. package/prompts/review-loop.md +2 -2
  23. package/skills/council-mode/SKILL.md +48 -243
  24. package/skills/council-mode/references/pass-contracts.md +150 -0
  25. package/skills/pi-subagents/SKILL.md +89 -35
  26. package/skills/pi-subagents/references/constraints-and-recipes.md +30 -234
  27. package/skills/pi-subagents/references/execution-controls.md +91 -15
  28. package/skills/pi-subagents/references/management-authoring-rpc.md +5 -5
  29. package/skills/pi-subagents/references/multi-lane-orchestration.md +13 -1
  30. package/skills/pi-subagents/references/prompting-and-roles.md +59 -31
  31. package/skills/pi-subagents/references/review-and-validation.md +73 -0
  32. package/src/agents/agent-management.ts +370 -114
  33. package/src/agents/agent-refinements.ts +4 -4
  34. package/src/agents/agent-serializer.ts +12 -2
  35. package/src/agents/agents.ts +919 -372
  36. package/src/agents/builtin-names.ts +6 -0
  37. package/src/agents/runtime-agent-events.ts +70 -0
  38. package/src/agents/runtime-agent-registry.ts +31 -20
  39. package/src/api/agents.ts +10 -5
  40. package/src/api/background-work.ts +12 -3
  41. package/src/api/capability-ceiling.ts +0 -1
  42. package/src/api/{pi-args.ts → child-tool-plan.ts} +1 -1
  43. package/src/api/delegation.ts +0 -7
  44. package/src/api/external-runs.ts +67 -4
  45. package/src/api/preflight.ts +48 -18
  46. package/src/api/shared-types.ts +6 -0
  47. package/src/extension/config.ts +90 -0
  48. package/src/extension/doctor.ts +5 -13
  49. package/src/extension/fanout-child.ts +14 -14
  50. package/src/extension/index.ts +115 -37
  51. package/src/extension/public-execution.ts +103 -15
  52. package/src/extension/rpc.ts +120 -25
  53. package/src/extension/schemas.ts +57 -21
  54. package/src/extension/tool-description.ts +48 -26
  55. package/src/inspectors/herdr/actions.ts +2 -1
  56. package/src/inspectors/herdr/inspector-runner.ts +21 -23
  57. package/src/inspectors/herdr/session-roots-codec.ts +42 -0
  58. package/src/integrations/herdr-status.ts +51 -3
  59. package/src/intercom/native-supervisor-channel.ts +138 -60
  60. package/src/intercom/result-intercom.ts +2 -0
  61. package/src/intercom/supervisor-ui.ts +243 -0
  62. package/src/profiles/profiles.ts +5 -6
  63. package/src/runs/background/active-async-capacity.ts +103 -18
  64. package/src/runs/background/async-execution.ts +366 -128
  65. package/src/runs/background/async-job-tracker.ts +95 -15
  66. package/src/runs/background/async-resume.ts +45 -28
  67. package/src/runs/background/async-retention.ts +20 -3
  68. package/src/runs/background/async-status-snapshot.ts +23 -261
  69. package/src/runs/background/async-status.ts +189 -14
  70. package/src/runs/background/auto-drain.ts +1 -1
  71. package/src/runs/background/chain-append.ts +8 -3
  72. package/src/runs/background/chain-root-attachment.ts +74 -8
  73. package/src/runs/background/control-channel.ts +4 -205
  74. package/src/runs/background/fleet-view.ts +38 -22
  75. package/src/runs/background/inspect-rpc.ts +8 -8
  76. package/src/runs/background/notify.ts +238 -12
  77. package/src/runs/background/process-terminal.ts +16 -0
  78. package/src/runs/background/result-delivery-ownership.ts +45 -0
  79. package/src/runs/background/result-files.ts +28 -14
  80. package/src/runs/background/result-watcher.ts +39 -16
  81. package/src/runs/background/resume-guidance.ts +2 -2
  82. package/src/runs/background/retained-children.ts +1 -1
  83. package/src/runs/background/run-child-session.ts +613 -0
  84. package/src/runs/background/run-status.ts +84 -17
  85. package/src/runs/background/runner-aliases.ts +125 -0
  86. package/src/runs/background/runner-child-sessions.ts +31 -0
  87. package/src/runs/background/scheduled-runs.ts +174 -18
  88. package/src/runs/background/stale-run-reconciler.ts +10 -4
  89. package/src/runs/background/steering.ts +8 -15
  90. package/src/runs/background/subagent-runner.ts +676 -1161
  91. package/src/runs/background/subagent-wait.ts +86 -31
  92. package/src/runs/background/terminal-run-index.ts +1 -1
  93. package/src/runs/background/wait-completions.ts +43 -2
  94. package/src/runs/background/wait-config.ts +23 -9
  95. package/src/runs/background/wait-tool.ts +26 -19
  96. package/src/runs/foreground/async-steering-action.ts +3 -19
  97. package/src/runs/foreground/execution.ts +468 -499
  98. package/src/runs/foreground/foreground-control.ts +13 -0
  99. package/src/runs/foreground/foreground-history.ts +23 -1
  100. package/src/runs/foreground/subagent-executor.ts +1172 -400
  101. package/src/runs/foreground/workflow-detach-reconcile.ts +140 -115
  102. package/src/runs/foreground/workflow-foreground-steering.ts +24 -98
  103. package/src/runs/shared/abort-recovery.ts +119 -0
  104. package/src/runs/shared/acceptance.ts +138 -36
  105. package/src/runs/shared/async-status-projection.ts +565 -0
  106. package/src/runs/shared/background-process-options.ts +9 -0
  107. package/src/runs/shared/capability-ceiling.ts +2 -2
  108. package/src/runs/shared/child-hooks.ts +25 -0
  109. package/src/runs/shared/child-identity.ts +32 -6
  110. package/src/runs/shared/child-launch-plan.ts +151 -0
  111. package/src/runs/shared/child-launch.ts +314 -0
  112. package/src/runs/shared/child-lifecycle.ts +25 -0
  113. package/src/runs/shared/child-runtime-config.ts +126 -0
  114. package/src/runs/shared/child-session.ts +342 -0
  115. package/src/runs/shared/child-tool-plan.ts +540 -0
  116. package/src/runs/shared/claude-code-adapter.ts +133 -0
  117. package/src/runs/shared/codex-exec-adapter.ts +129 -0
  118. package/src/runs/shared/completion-evidence.ts +89 -0
  119. package/src/runs/shared/completion-guard.ts +6 -5
  120. package/src/runs/shared/cursor-agent-adapter.ts +114 -0
  121. package/src/runs/shared/dynamic-fanout.ts +3 -3
  122. package/src/runs/shared/external-cli-contract.ts +167 -0
  123. package/src/runs/shared/external-cli-preflight.ts +138 -0
  124. package/src/runs/shared/external-cli-runner.ts +348 -55
  125. package/src/runs/shared/fast-mode-extension.ts +5 -5
  126. package/src/runs/shared/host-step-status.ts +231 -0
  127. package/src/runs/shared/lane-metadata.ts +126 -0
  128. package/src/runs/shared/launch-cwd.ts +16 -0
  129. package/src/runs/shared/long-running-guard.ts +2 -1
  130. package/src/runs/shared/mcp-config-sources.ts +422 -0
  131. package/src/runs/shared/mcp-direct-tool-allowlist.ts +222 -158
  132. package/src/runs/shared/mcp-direct-tool-grant.ts +194 -0
  133. package/src/runs/shared/model-exclusions.ts +139 -9
  134. package/src/runs/shared/model-fallback.ts +142 -14
  135. package/src/runs/shared/mutation-evidence.ts +57 -3
  136. package/src/runs/shared/nested-events.ts +38 -48
  137. package/src/runs/shared/nested-path.ts +0 -14
  138. package/src/runs/shared/nested-render.ts +9 -5
  139. package/src/runs/shared/orca-progress-tabs.ts +12 -7
  140. package/src/runs/shared/parallel-handoff.ts +423 -7
  141. package/src/runs/shared/parallel-utils.ts +15 -7
  142. package/src/runs/shared/permissions.ts +1 -14
  143. package/src/runs/shared/pi-spawn.ts +69 -35
  144. package/src/runs/shared/process-signal.ts +16 -0
  145. package/src/runs/shared/run-fanout-budget.ts +0 -13
  146. package/src/runs/shared/run-history.ts +21 -1
  147. package/src/runs/shared/runtime-acknowledged-extensions.ts +0 -27
  148. package/src/runs/shared/single-output.ts +89 -22
  149. package/src/runs/shared/structured-output.ts +49 -9
  150. package/src/runs/shared/subagent-control.ts +6 -2
  151. package/src/runs/shared/subagent-prompt-runtime.ts +188 -365
  152. package/src/runs/shared/task-intent.ts +21 -7
  153. package/src/runs/shared/tool-availability.ts +18 -62
  154. package/src/runs/shared/tool-budget.ts +0 -14
  155. package/src/runs/shared/tool-timeout.ts +1 -1
  156. package/src/runs/shared/workflow-graph.ts +16 -0
  157. package/src/runs/shared/worktree-cleanup-plan.ts +866 -0
  158. package/src/runs/shared/worktree.ts +571 -62
  159. package/src/shared/atomic-json.ts +3 -1
  160. package/src/shared/child-session-name.ts +46 -0
  161. package/src/shared/extension-context.ts +24 -0
  162. package/src/shared/fork-context.ts +21 -12
  163. package/src/shared/fork-session-cwd.ts +27 -0
  164. package/src/shared/formatters.ts +18 -3
  165. package/src/shared/jsonl-writer.ts +11 -0
  166. package/src/shared/launch-contract.ts +8 -1
  167. package/src/shared/pruned-fork.ts +450 -0
  168. package/src/shared/session-file-trust.ts +19 -0
  169. package/src/shared/session-tokens.ts +14 -3
  170. package/src/shared/settings.ts +19 -105
  171. package/src/shared/shortcuts.ts +17 -0
  172. package/src/shared/thinking-ceiling.ts +0 -6
  173. package/src/shared/types.ts +524 -70
  174. package/src/shared/utils.ts +60 -93
  175. package/src/shared/workflow-child-permit.ts +207 -0
  176. package/src/slash/delegation-adapters.ts +1 -9
  177. package/src/slash/delegation-request.ts +0 -4
  178. package/src/slash/prompt-template-bridge.ts +37 -1
  179. package/src/slash/slash-bridge.ts +1 -2
  180. package/src/slash/slash-commands.ts +383 -116
  181. package/src/slash/slash-live-state.ts +22 -11
  182. package/src/slash/subagents-admin.ts +29 -12
  183. package/src/tui/fleet-native-transcript.ts +4 -0
  184. package/src/tui/fleet-status.ts +217 -82
  185. package/src/tui/fleet-transcript.ts +11 -5
  186. package/src/tui/fleet.ts +54 -28
  187. package/src/tui/render-helpers.ts +31 -0
  188. package/src/tui/render.ts +1429 -163
  189. package/src/watchdog/change-signature.ts +40 -1
  190. package/src/watchdog/child-status.ts +54 -34
  191. package/src/watchdog/diff-tool.ts +77 -0
  192. package/src/watchdog/emission-guard.ts +5 -3
  193. package/src/watchdog/guidance.ts +20 -0
  194. package/src/watchdog/register-child.ts +28 -25
  195. package/src/watchdog/register-main.ts +10 -9
  196. package/src/watchdog/render.ts +4 -5
  197. package/src/watchdog/review.ts +15 -4
  198. package/src/watchdog/rules.ts +70 -0
  199. package/src/watchdog/runtime.ts +75 -92
  200. package/src/watchdog/scope.ts +0 -11
  201. package/src/watchdog/settings.ts +48 -104
  202. package/src/watchdog/turn-delta.ts +1 -1
  203. package/src/watchdog/types.ts +18 -32
  204. package/src/watchdog/warning-format.ts +0 -1
  205. package/src/workflows/chat-progress.ts +7 -3
  206. package/src/workflows/host-command.ts +235 -0
  207. package/src/workflows/scripted-workflow.ts +988 -59
  208. package/src/workflows/workflow-checklist.ts +439 -0
  209. package/src/workflows/workflow-child-summary.ts +121 -0
  210. package/src/workflows/workflow-preflight.ts +297 -0
  211. package/src/workflows/workflow-receipt.ts +232 -6
  212. package/src/workflows/workflow-resources.ts +150 -0
  213. package/src/workflows/workflow-settlement.ts +246 -0
  214. package/src/runs/shared/child-protocol.ts +0 -401
  215. package/src/runs/shared/pi-args.ts +0 -935
  216. package/src/runs/shared/subagent-startup-retry.ts +0 -116
  217. package/src/runs/shared/turn-budget.ts +0 -98
  218. package/src/shared/post-exit-stdio-guard.ts +0 -85
@@ -14,10 +14,12 @@ interface BeginForegroundChildInput {
14
14
  thinking?: string;
15
15
  interrupt: () => boolean;
16
16
  detach?: () => boolean;
17
+ steer?: ForegroundChildControl["steer"];
17
18
  }
18
19
 
19
20
  function copyProgress(target: ForegroundChildControl, progress: AgentProgress | undefined): void {
20
21
  if (!progress) return;
22
+ target.sessionName = progress.sessionName;
21
23
  target.currentActivityState = progress.activityState;
22
24
  target.lastActivityAt = progress.lastActivityAt;
23
25
  target.currentTool = progress.currentTool;
@@ -27,6 +29,8 @@ function copyProgress(target: ForegroundChildControl, progress: AgentProgress |
27
29
  target.tokens = progress.tokens;
28
30
  target.inputTokens = progress.inputTokens;
29
31
  target.outputTokens = progress.outputTokens;
32
+ target.window = progress.window;
33
+ target.windowPeak = progress.windowPeak;
30
34
  target.model = progress.model;
31
35
  target.thinking = progress.thinking;
32
36
  target.toolCount = progress.toolCount;
@@ -34,6 +38,7 @@ function copyProgress(target: ForegroundChildControl, progress: AgentProgress |
34
38
 
35
39
  function syncCurrentChild(control: ForegroundRunControl, child: ForegroundChildControl): void {
36
40
  control.currentAgent = child.agent;
41
+ control.sessionName = child.sessionName;
37
42
  control.currentIndex = child.index;
38
43
  control.description = child.description;
39
44
  control.currentActivityState = child.currentActivityState;
@@ -45,16 +50,20 @@ function syncCurrentChild(control: ForegroundRunControl, child: ForegroundChildC
45
50
  control.tokens = child.tokens;
46
51
  control.inputTokens = child.inputTokens;
47
52
  control.outputTokens = child.outputTokens;
53
+ control.window = child.window;
54
+ control.windowPeak = child.windowPeak;
48
55
  control.model = child.model;
49
56
  control.thinking = child.thinking;
50
57
  control.toolCount = child.toolCount;
51
58
  control.interrupt = child.interrupt;
52
59
  control.detach = child.detach;
60
+ control.steer = child.steer;
53
61
  control.updatedAt = child.updatedAt;
54
62
  }
55
63
 
56
64
  function clearCurrentChild(control: ForegroundRunControl): void {
57
65
  control.currentAgent = undefined;
66
+ control.sessionName = undefined;
58
67
  control.currentIndex = undefined;
59
68
  control.currentActivityState = undefined;
60
69
  control.lastActivityAt = undefined;
@@ -65,11 +74,14 @@ function clearCurrentChild(control: ForegroundRunControl): void {
65
74
  control.tokens = undefined;
66
75
  control.inputTokens = undefined;
67
76
  control.outputTokens = undefined;
77
+ control.window = undefined;
78
+ control.windowPeak = undefined;
68
79
  control.model = undefined;
69
80
  control.thinking = undefined;
70
81
  control.toolCount = undefined;
71
82
  control.interrupt = undefined;
72
83
  control.detach = undefined;
84
+ control.steer = undefined;
73
85
  }
74
86
 
75
87
  export function retainForegroundSchedulingOwner(control: ForegroundRunControl): void {
@@ -113,6 +125,7 @@ export function beginForegroundChild(control: ForegroundRunControl, input: Begin
113
125
  return true;
114
126
  };
115
127
  }
128
+ if (input.steer) child.steer = input.steer;
116
129
  control.activeChildren ??= new Map();
117
130
  control.activeChildren.set(input.index, child);
118
131
  registerLivePromptAudit(control, input.index, input.authoredTask, input.effectivePrompt, {
@@ -4,10 +4,12 @@ import type { ForegroundResumeChild, ForegroundResumeRun, SubagentState } from "
4
4
  import { DIRS } from "../../shared/types.ts";
5
5
  import { writePrivateAtomicJson } from "../../shared/atomic-json.ts";
6
6
  import { utf8Tail } from "../../shared/utf8.ts";
7
+ import { validateAcceptanceInput } from "../shared/acceptance.ts";
7
8
 
8
9
  export const MAX_REMEMBERED_FOREGROUND_RUNS = 50;
9
10
  const HISTORY_VERSION = 1;
10
11
  const MAX_INLINE_OUTPUT_BYTES = 64 * 1024;
12
+ const MAX_RESUME_CONTRACT_BYTES = 64 * 1024;
11
13
 
12
14
  interface ForegroundHistoryIndex {
13
15
  version: 1;
@@ -27,6 +29,7 @@ function compactChild(child: ForegroundResumeChild): ForegroundResumeChild {
27
29
  return {
28
30
  agent: child.agent,
29
31
  index: child.index,
32
+ ...(child.sessionName ? { sessionName: child.sessionName } : {}),
30
33
  ...(child.context ? { context: child.context } : {}),
31
34
  ...(child.sessionFile ? { sessionFile: child.sessionFile } : {}),
32
35
  ...(child.model ? { model: child.model } : {}),
@@ -51,6 +54,7 @@ function compactChild(child: ForegroundResumeChild): ForegroundResumeChild {
51
54
  ...(child.transcriptPath ? { transcriptPath: child.transcriptPath } : {}),
52
55
  ...(child.transcriptError ? { transcriptError: child.transcriptError } : {}),
53
56
  ...(child.acceptance ? { acceptance: child.acceptance } : {}),
57
+ ...(child.resumeContract ? { resumeContract: child.resumeContract } : {}),
54
58
  ...(child.launchContractDigest ? { launchContractDigest: child.launchContractDigest } : {}),
55
59
  ...(child.extensionBindings ? { extensionBindings: child.extensionBindings } : {}),
56
60
  ...(child.capabilityCeiling ? { capabilityCeiling: child.capabilityCeiling } : {}),
@@ -62,9 +66,26 @@ function isRestorableForegroundStatus(status: unknown): status is ForegroundResu
62
66
  return status === "completed" || status === "failed" || status === "paused" || status === "stopped";
63
67
  }
64
68
 
69
+ function isRestorableResumeContract(value: unknown): boolean {
70
+ if (value === undefined) return true;
71
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
72
+ try {
73
+ if (Buffer.byteLength(JSON.stringify(value), "utf8") > MAX_RESUME_CONTRACT_BYTES) return false;
74
+ } catch {
75
+ return false;
76
+ }
77
+ const contract = value as NonNullable<ForegroundResumeChild["resumeContract"]>;
78
+ if (Object.keys(contract).some((key) => !["outputSchema", "agentContract", "acceptance", "output", "outputMode"].includes(key))) return false;
79
+ if (contract.outputSchema !== undefined && (!contract.outputSchema || typeof contract.outputSchema !== "object" || Array.isArray(contract.outputSchema))) return false;
80
+ if (contract.agentContract !== undefined && (!contract.agentContract || typeof contract.agentContract !== "object" || Array.isArray(contract.agentContract) || contract.agentContract.version !== 1)) return false;
81
+ if (validateAcceptanceInput(contract.acceptance).length > 0) return false;
82
+ if (contract.output !== undefined && typeof contract.output !== "string" && typeof contract.output !== "boolean") return false;
83
+ return contract.outputMode === undefined || contract.outputMode === "inline" || contract.outputMode === "file-only";
84
+ }
85
+
65
86
  function compactRun(run: ForegroundResumeRun): ForegroundResumeRun | undefined {
66
87
  if (!run.sessionId) return undefined;
67
- if (run.children.length === 0 || !run.children.every((child) => isRestorableForegroundStatus(child.status))) return undefined;
88
+ if (run.children.length === 0 || !run.children.every((child) => isRestorableForegroundStatus(child.status) && isRestorableResumeContract(child.resumeContract))) return undefined;
68
89
  return {
69
90
  runId: run.runId,
70
91
  mode: run.mode,
@@ -102,6 +123,7 @@ function isRestorableRun(value: unknown): value is ForegroundResumeRun {
102
123
  && run.children.every((child) => Boolean(child && typeof child === "object" && !Array.isArray(child)
103
124
  && typeof (child as Partial<ForegroundResumeChild>).agent === "string"
104
125
  && typeof (child as Partial<ForegroundResumeChild>).index === "number"
126
+ && isRestorableResumeContract((child as Partial<ForegroundResumeChild>).resumeContract)
105
127
  && isRestorableForegroundStatus((child as Partial<ForegroundResumeChild>).status)));
106
128
  }
107
129