pi-subagents 0.64.0 → 0.65.1

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 (106) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +2 -2
  3. package/agents/reviewer.md +1 -1
  4. package/agents/scout.md +1 -1
  5. package/docs/agents.md +19 -17
  6. package/docs/configuration.md +23 -15
  7. package/docs/extension-api.md +18 -6
  8. package/docs/missions.md +2 -0
  9. package/docs/observability.md +10 -12
  10. package/docs/tool-reference.md +15 -8
  11. package/docs/watchdog.md +1 -1
  12. package/docs/workflows.md +13 -3
  13. package/package.json +5 -4
  14. package/runner-server-preload.mjs +13 -0
  15. package/skills/pi-subagents/SKILL.md +2 -1
  16. package/skills/pi-subagents/references/constraints-and-recipes.md +1 -1
  17. package/skills/pi-subagents/references/execution-controls.md +7 -3
  18. package/skills/pi-subagents/references/multi-lane-orchestration.md +2 -0
  19. package/src/agents/agent-management.ts +47 -15
  20. package/src/api/capability-ceiling.ts +0 -1
  21. package/src/api/{pi-args.ts → child-tool-plan.ts} +1 -1
  22. package/src/api/preflight.ts +7 -4
  23. package/src/extension/config.ts +4 -2
  24. package/src/extension/doctor.ts +2 -10
  25. package/src/extension/fanout-child.ts +9 -11
  26. package/src/extension/index.ts +58 -7
  27. package/src/extension/public-execution.ts +14 -0
  28. package/src/extension/rpc.ts +3 -2
  29. package/src/extension/schemas.ts +3 -2
  30. package/src/extension/tool-description.ts +13 -8
  31. package/src/integrations/pi-web-session-liveness.ts +73 -0
  32. package/src/intercom/native-supervisor-channel.ts +159 -95
  33. package/src/intercom/supervisor-ui.ts +244 -0
  34. package/src/missions/workflow-state.ts +37 -16
  35. package/src/runs/background/async-execution.ts +51 -25
  36. package/src/runs/background/async-job-tracker.ts +11 -0
  37. package/src/runs/background/async-resume.ts +14 -3
  38. package/src/runs/background/async-retention.ts +9 -0
  39. package/src/runs/background/control-channel.ts +2 -204
  40. package/src/runs/background/notify.ts +2 -0
  41. package/src/runs/background/process-terminal.ts +1 -1
  42. package/src/runs/background/retained-nested-route-tracker.ts +96 -0
  43. package/src/runs/background/run-child-session.ts +614 -0
  44. package/src/runs/background/run-status.ts +0 -1
  45. package/src/runs/background/runner-aliases.ts +152 -0
  46. package/src/runs/background/runner-child-sessions.ts +31 -0
  47. package/src/runs/background/scheduled-runs.ts +18 -4
  48. package/src/runs/background/subagent-runner.ts +203 -901
  49. package/src/runs/foreground/async-steering-action.ts +1 -17
  50. package/src/runs/foreground/execution.ts +204 -378
  51. package/src/runs/foreground/foreground-control.ts +4 -0
  52. package/src/runs/foreground/foreground-history.ts +3 -1
  53. package/src/runs/foreground/prompt-audit.ts +9 -5
  54. package/src/runs/foreground/subagent-executor.ts +161 -91
  55. package/src/runs/foreground/workflow-foreground-steering.ts +24 -98
  56. package/src/runs/shared/abort-recovery.ts +3 -3
  57. package/src/runs/shared/acceptance.ts +14 -1
  58. package/src/runs/shared/capability-ceiling.ts +1 -2
  59. package/src/runs/shared/child-hooks.ts +25 -0
  60. package/src/runs/shared/child-identity.ts +13 -2
  61. package/src/runs/shared/child-launch.ts +314 -0
  62. package/src/runs/shared/child-lifecycle.ts +25 -0
  63. package/src/runs/shared/child-runtime-config.ts +126 -0
  64. package/src/runs/shared/child-session.ts +337 -0
  65. package/src/runs/shared/child-tool-plan.ts +530 -0
  66. package/src/runs/shared/claude-code-adapter.ts +5 -1
  67. package/src/runs/shared/completion-guard.ts +1 -1
  68. package/src/runs/shared/external-cli-preflight.ts +16 -0
  69. package/src/runs/shared/llm-intent-arbiter.ts +20 -11
  70. package/src/runs/shared/mcp-direct-tool-allowlist.ts +5 -4
  71. package/src/runs/shared/model-exclusions.ts +84 -15
  72. package/src/runs/shared/model-fallback.ts +78 -6
  73. package/src/runs/shared/nested-events.ts +32 -48
  74. package/src/runs/shared/nested-path.ts +0 -14
  75. package/src/runs/shared/orca-progress-tabs.ts +12 -7
  76. package/src/runs/shared/parallel-utils.ts +1 -2
  77. package/src/runs/shared/permissions.ts +0 -13
  78. package/src/runs/shared/process-signal.ts +4 -1
  79. package/src/runs/shared/run-fanout-budget.ts +0 -13
  80. package/src/runs/shared/runtime-acknowledged-extensions.ts +0 -27
  81. package/src/runs/shared/structured-output.ts +17 -4
  82. package/src/runs/shared/subagent-control.ts +2 -0
  83. package/src/runs/shared/subagent-prompt-runtime.ts +87 -384
  84. package/src/runs/shared/tool-availability.ts +18 -62
  85. package/src/runs/shared/tool-budget.ts +0 -14
  86. package/src/runs/shared/worktree-cleanup-plan.ts +31 -9
  87. package/src/runs/shared/worktree.ts +192 -40
  88. package/src/shared/child-session-name.ts +1 -1
  89. package/src/shared/jsonl-writer.ts +11 -0
  90. package/src/shared/model-response-aliases.ts +13 -0
  91. package/src/shared/thinking-ceiling.ts +0 -6
  92. package/src/shared/types.ts +63 -28
  93. package/src/shared/utils.ts +6 -4
  94. package/src/shared/watch-strategy.ts +2 -0
  95. package/src/slash/slash-commands.ts +0 -6
  96. package/src/tui/fleet-status.ts +1 -1
  97. package/src/tui/fleet.ts +0 -1
  98. package/src/tui/render.ts +254 -41
  99. package/src/watchdog/child-status.ts +0 -1
  100. package/src/watchdog/register-child.ts +12 -12
  101. package/src/workflows/scripted-workflow.ts +80 -7
  102. package/src/workflows/workflow-checklist.ts +4 -3
  103. package/src/runs/shared/child-protocol.ts +0 -415
  104. package/src/runs/shared/pi-args.ts +0 -1059
  105. package/src/runs/shared/subagent-startup-retry.ts +0 -116
  106. package/src/shared/post-exit-stdio-guard.ts +0 -85
@@ -14,6 +14,7 @@ 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 {
@@ -56,6 +57,7 @@ function syncCurrentChild(control: ForegroundRunControl, child: ForegroundChildC
56
57
  control.toolCount = child.toolCount;
57
58
  control.interrupt = child.interrupt;
58
59
  control.detach = child.detach;
60
+ control.steer = child.steer;
59
61
  control.updatedAt = child.updatedAt;
60
62
  }
61
63
 
@@ -79,6 +81,7 @@ function clearCurrentChild(control: ForegroundRunControl): void {
79
81
  control.toolCount = undefined;
80
82
  control.interrupt = undefined;
81
83
  control.detach = undefined;
84
+ control.steer = undefined;
82
85
  }
83
86
 
84
87
  export function retainForegroundSchedulingOwner(control: ForegroundRunControl): void {
@@ -122,6 +125,7 @@ export function beginForegroundChild(control: ForegroundRunControl, input: Begin
122
125
  return true;
123
126
  };
124
127
  }
128
+ if (input.steer) child.steer = input.steer;
125
129
  control.activeChildren ??= new Map();
126
130
  control.activeChildren.set(input.index, child);
127
131
  registerLivePromptAudit(control, input.index, input.authoredTask, input.effectivePrompt, {
@@ -5,6 +5,7 @@ import { DIRS } from "../../shared/types.ts";
5
5
  import { writePrivateAtomicJson } from "../../shared/atomic-json.ts";
6
6
  import { utf8Tail } from "../../shared/utf8.ts";
7
7
  import { validateAcceptanceInput } from "../shared/acceptance.ts";
8
+ import { validateModelResponseAliases } from "../../shared/model-response-aliases.ts";
8
9
 
9
10
  export const MAX_REMEMBERED_FOREGROUND_RUNS = 50;
10
11
  const HISTORY_VERSION = 1;
@@ -71,11 +72,12 @@ function isRestorableResumeContract(value: unknown): boolean {
71
72
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
72
73
  try {
73
74
  if (Buffer.byteLength(JSON.stringify(value), "utf8") > MAX_RESUME_CONTRACT_BYTES) return false;
75
+ validateModelResponseAliases((value as ForegroundResumeChild["resumeContract"])?.modelResponseAliases);
74
76
  } catch {
75
77
  return false;
76
78
  }
77
79
  const contract = value as NonNullable<ForegroundResumeChild["resumeContract"]>;
78
- if (Object.keys(contract).some((key) => !["outputSchema", "agentContract", "acceptance", "output", "outputMode"].includes(key))) return false;
80
+ if (Object.keys(contract).some((key) => !["modelResponseAliases", "outputSchema", "agentContract", "acceptance", "output", "outputMode"].includes(key))) return false;
79
81
  if (contract.outputSchema !== undefined && (!contract.outputSchema || typeof contract.outputSchema !== "object" || Array.isArray(contract.outputSchema))) return false;
80
82
  if (contract.agentContract !== undefined && (!contract.agentContract || typeof contract.agentContract !== "object" || Array.isArray(contract.agentContract) || contract.agentContract.version !== 1)) return false;
81
83
  if (validateAcceptanceInput(contract.acceptance).length > 0) return false;
@@ -1,7 +1,6 @@
1
- import { Agent, type StreamFn, type ThinkingLevel } from "@earendil-works/pi-agent-core";
2
- import { convertToLlm, type ExtensionContext } from "@earendil-works/pi-coding-agent";
3
- import { streamSimple } from "@earendil-works/pi-ai/compat";
4
- import type { Model, ProviderHeaders } from "@earendil-works/pi-ai";
1
+ import type { Agent, StreamFn, ThinkingLevel } from "@earendil-works/pi-agent-core";
2
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
3
+ import type { ProviderHeaders } from "@earendil-works/pi-ai";
5
4
  import { agentStreamOptions } from "../../shared/agent-stream-options.ts";
6
5
  import type { ForegroundRunControl } from "../../shared/types.ts";
7
6
  export type PromptAuditView = "authored" | "runtime" | "effective";
@@ -21,7 +20,7 @@ export interface LivePromptAudit {
21
20
 
22
21
  const livePrompts = new WeakMap<ForegroundRunControl, Map<number, LivePromptAudit>>();
23
22
 
24
- type RegistryModel = Model<any>;
23
+ type RegistryModel = NonNullable<ExtensionContext["model"]>;
25
24
 
26
25
  function fullModelId(model: Pick<RegistryModel, "provider" | "id">): string {
27
26
  return `${model.provider}/${model.id}`;
@@ -64,6 +63,11 @@ export async function rewritePromptWithGuidance(input: {
64
63
  }): Promise<string> {
65
64
  const model = input.ctx.model;
66
65
  if (!model) throw new Error("Prompt redo needs the current session model to rewrite the authored task.");
66
+ const [{ Agent }, { convertToLlm }, { streamSimple }] = await Promise.all([
67
+ import("@earendil-works/pi-agent-core"),
68
+ import("@earendil-works/pi-coding-agent"),
69
+ import("@earendil-works/pi-ai/compat"),
70
+ ]);
67
71
  const auth = await resolveRewriteAuth(input.ctx, model);
68
72
  const registeredProvider = (input.ctx.modelRegistry as {
69
73
  getRegisteredProviderConfig?: (provider: string) => { api?: string; streamSimple?: StreamFn } | undefined;