pi-subagents 0.38.0 → 0.40.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 (59) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +85 -13
  3. package/agents/worker.md +1 -0
  4. package/package.json +1 -1
  5. package/prompts/review-loop.md +1 -1
  6. package/skills/pi-subagents/SKILL.md +4 -3
  7. package/skills/pi-subagents/references/execution-controls.md +22 -3
  8. package/skills/pi-subagents/references/management-authoring-rpc.md +5 -1
  9. package/skills/pi-subagents/references/prompting-and-roles.md +17 -3
  10. package/src/agents/agent-management.ts +71 -30
  11. package/src/agents/agent-serializer.ts +4 -0
  12. package/src/agents/agents.ts +60 -1
  13. package/src/api/preflight.ts +16 -12
  14. package/src/extension/chain-validation.ts +17 -1
  15. package/src/extension/rpc.ts +2 -0
  16. package/src/extension/schemas.ts +16 -3
  17. package/src/extension/tool-description.ts +6 -5
  18. package/src/intercom/result-intercom.ts +33 -4
  19. package/src/runs/background/async-execution.ts +63 -16
  20. package/src/runs/background/async-job-tracker.ts +5 -1
  21. package/src/runs/background/async-resume.ts +1 -0
  22. package/src/runs/background/async-status.ts +18 -2
  23. package/src/runs/background/chain-append.ts +48 -5
  24. package/src/runs/background/control-channel.ts +60 -0
  25. package/src/runs/background/notify.ts +26 -4
  26. package/src/runs/background/result-watcher.ts +20 -3
  27. package/src/runs/background/run-status.ts +29 -3
  28. package/src/runs/background/subagent-runner.ts +302 -18
  29. package/src/runs/foreground/async-stop-action.ts +65 -0
  30. package/src/runs/foreground/chain-execution.ts +143 -43
  31. package/src/runs/foreground/execution.ts +384 -202
  32. package/src/runs/foreground/foreground-control.ts +30 -0
  33. package/src/runs/foreground/subagent-executor.ts +314 -77
  34. package/src/runs/shared/capability-ceiling.ts +51 -19
  35. package/src/runs/shared/chain-outputs.ts +3 -1
  36. package/src/runs/shared/dynamic-fanout.ts +1 -1
  37. package/src/runs/shared/nested-events.ts +97 -20
  38. package/src/runs/shared/parallel-utils.ts +43 -12
  39. package/src/runs/shared/pi-args.ts +45 -3
  40. package/src/runs/shared/process-signal.ts +19 -0
  41. package/src/runs/shared/run-history.ts +45 -9
  42. package/src/runs/shared/runtime-acknowledged-extensions.ts +71 -0
  43. package/src/runs/shared/subagent-prompt-runtime.ts +30 -0
  44. package/src/runs/shared/usage-budget.ts +65 -0
  45. package/src/runs/shared/workflow-graph.ts +26 -1
  46. package/src/shared/settings.ts +17 -1
  47. package/src/shared/types.ts +124 -8
  48. package/src/shared/utils.ts +12 -1
  49. package/src/slash/slash-commands.ts +43 -1
  50. package/src/slash/slash-live-state.ts +5 -3
  51. package/src/tui/fleet-status.ts +12 -2
  52. package/src/tui/fleet.ts +181 -8
  53. package/src/tui/render.ts +4 -2
  54. package/src/watchdog/register-main.ts +14 -7
  55. package/src/watchdog/review.ts +4 -3
  56. package/src/watchdog/runtime.ts +170 -17
  57. package/src/watchdog/scope.ts +62 -0
  58. package/src/watchdog/settings.ts +41 -1
  59. package/src/watchdog/types.ts +10 -0
@@ -4,7 +4,10 @@ interface BeginForegroundChildInput {
4
4
  index: number;
5
5
  agent: string;
6
6
  description?: string;
7
+ model?: string;
8
+ thinking?: string;
7
9
  interrupt: () => boolean;
10
+ detach?: () => boolean;
8
11
  }
9
12
 
10
13
  function copyProgress(target: ForegroundChildControl, progress: AgentProgress | undefined): void {
@@ -40,6 +43,7 @@ function syncCurrentChild(control: ForegroundRunControl, child: ForegroundChildC
40
43
  control.thinking = child.thinking;
41
44
  control.toolCount = child.toolCount;
42
45
  control.interrupt = child.interrupt;
46
+ control.detach = child.detach;
43
47
  control.updatedAt = child.updatedAt;
44
48
  }
45
49
 
@@ -59,6 +63,21 @@ function clearCurrentChild(control: ForegroundRunControl): void {
59
63
  control.thinking = undefined;
60
64
  control.toolCount = undefined;
61
65
  control.interrupt = undefined;
66
+ control.detach = undefined;
67
+ }
68
+
69
+ export function retainForegroundSchedulingOwner(control: ForegroundRunControl): void {
70
+ control.schedulingOwners = (control.schedulingOwners ?? 0) + 1;
71
+ control.updatedAt = Date.now();
72
+ }
73
+
74
+ export function settleForegroundSchedulingOwner(control: ForegroundRunControl): void {
75
+ control.schedulingOwners = Math.max(0, (control.schedulingOwners ?? 0) - 1);
76
+ control.updatedAt = Date.now();
77
+ }
78
+
79
+ export function foregroundSchedulingSettled(control: ForegroundRunControl): boolean {
80
+ return (control.schedulingOwners ?? 0) === 0;
62
81
  }
63
82
 
64
83
  export function beginForegroundChild(control: ForegroundRunControl, input: BeginForegroundChildInput): void {
@@ -69,6 +88,8 @@ export function beginForegroundChild(control: ForegroundRunControl, input: Begin
69
88
  ...(input.description ? { description: input.description } : {}),
70
89
  startedAt: now,
71
90
  updatedAt: now,
91
+ ...(input.model ? { model: input.model } : {}),
92
+ ...(input.thinking ? { thinking: input.thinking } : {}),
72
93
  };
73
94
  child.interrupt = () => {
74
95
  if (!input.interrupt()) return false;
@@ -77,6 +98,15 @@ export function beginForegroundChild(control: ForegroundRunControl, input: Begin
77
98
  syncCurrentChild(control, child);
78
99
  return true;
79
100
  };
101
+ if (input.detach) {
102
+ child.detach = () => {
103
+ if (!input.detach?.()) return false;
104
+ child.currentActivityState = undefined;
105
+ child.updatedAt = Date.now();
106
+ syncCurrentChild(control, child);
107
+ return true;
108
+ };
109
+ }
80
110
  control.activeChildren ??= new Map();
81
111
  control.activeChildren.set(input.index, child);
82
112
  syncCurrentChild(control, child);