@xzzpig/pi-subagents 0.14.0 → 0.15.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 (198) hide show
  1. package/CHANGELOG.md +233 -0
  2. package/README.md +6 -5
  3. package/agents/evidence-auditor.md +34 -0
  4. package/agents/researcher.md +23 -13
  5. package/agents/reviewer.md +3 -2
  6. package/docs/agents.md +56 -15
  7. package/docs/configuration.md +92 -14
  8. package/docs/extension-api.md +132 -19
  9. package/docs/missions.md +10 -2
  10. package/docs/models.md +11 -22
  11. package/docs/observability.md +63 -11
  12. package/docs/standalone-background.md +59 -0
  13. package/docs/tool-reference.md +42 -23
  14. package/docs/watchdog.md +39 -10
  15. package/docs/workflows.md +58 -19
  16. package/index.ts +5 -2
  17. package/inspector-runner.mjs +2 -2
  18. package/node_modules/@xzzpig/pi-components/dist/src/transcript.d.ts +13 -3
  19. package/node_modules/@xzzpig/pi-components/dist/src/transcript.js +18 -6
  20. package/node_modules/@xzzpig/pi-components/src/transcript.ts +26 -6
  21. package/package.json +9 -4
  22. package/prompts/parallel-review.md +1 -1
  23. package/runner-peer-loader.mjs +24 -0
  24. package/runner-peer-preload.mjs +36 -0
  25. package/skills/pi-subagents/SKILL.md +34 -22
  26. package/skills/pi-subagents/references/constraints-and-recipes.md +3 -2
  27. package/skills/pi-subagents/references/execution-controls.md +27 -8
  28. package/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
  29. package/skills/pi-subagents/references/multi-lane-orchestration.md +3 -1
  30. package/skills/pi-subagents/references/prompting-and-roles.md +17 -13
  31. package/skills/pi-subagents/references/review-and-validation.md +3 -3
  32. package/src/agents/advertised-agent-prompt.ts +94 -0
  33. package/src/agents/agent-management.ts +71 -59
  34. package/src/agents/agent-serializer.ts +6 -3
  35. package/src/agents/agents.ts +198 -72
  36. package/src/agents/builtin-names.ts +1 -0
  37. package/src/agents/chain-serializer.ts +5 -0
  38. package/src/agents/runtime-agent-registry.ts +7 -6
  39. package/src/api/delegation.ts +4 -0
  40. package/src/api/preflight.ts +110 -71
  41. package/src/api/required-child-extensions.ts +6 -0
  42. package/src/api/shared-types.ts +3 -1
  43. package/src/api/workflow-resources.ts +6 -0
  44. package/src/extension/config.ts +14 -37
  45. package/src/extension/fanout-child.ts +68 -5
  46. package/src/extension/herdr-pi-bridge.ts +164 -0
  47. package/src/extension/index.ts +141 -51
  48. package/src/extension/public-execution.ts +7 -6
  49. package/src/extension/rpc.ts +8 -21
  50. package/src/extension/schemas.ts +86 -84
  51. package/src/extension/tool-description.ts +32 -79
  52. package/src/inspectors/actions.ts +148 -0
  53. package/src/inspectors/ghostty/actions.ts +74 -0
  54. package/src/inspectors/ghostty/plugin.ts +17 -0
  55. package/src/inspectors/herdr/actions.ts +99 -179
  56. package/src/inspectors/herdr/plugin.ts +20 -0
  57. package/src/inspectors/herdr/project-panes.ts +4 -1
  58. package/src/inspectors/{herdr/inspector-runner.ts → inspector-runner.ts} +12 -12
  59. package/src/inspectors/plugins.ts +8 -0
  60. package/src/inspectors/{herdr/session-roots-codec.ts → session-roots-codec.ts} +3 -14
  61. package/src/inspectors/types.ts +51 -0
  62. package/src/integrations/pi-web-session-liveness.ts +73 -0
  63. package/src/intercom/intercom-bridge.ts +50 -8
  64. package/src/intercom/native-supervisor-channel.ts +142 -115
  65. package/src/intercom/supervisor-ui.ts +3 -2
  66. package/src/missions/workflow-state.ts +37 -16
  67. package/src/policy/authority.ts +4 -0
  68. package/src/profiles/profiles.ts +12 -6
  69. package/src/runs/background/active-async-capacity.ts +22 -18
  70. package/src/runs/background/active-run-index.ts +17 -1
  71. package/src/runs/background/async-execution.ts +359 -176
  72. package/src/runs/background/async-job-tracker.ts +41 -7
  73. package/src/runs/background/async-resume.ts +19 -12
  74. package/src/runs/background/async-retention.ts +20 -0
  75. package/src/runs/background/async-status-snapshot.ts +10 -12
  76. package/src/runs/background/async-status.ts +32 -13
  77. package/src/runs/background/auto-drain.ts +59 -35
  78. package/src/runs/background/binary-bootstrap.ts +38 -0
  79. package/src/runs/background/chain-append.ts +1 -1
  80. package/src/runs/background/chain-root-attachment.ts +22 -33
  81. package/src/runs/background/control-channel.ts +78 -44
  82. package/src/runs/background/fleet-view.ts +30 -2
  83. package/src/runs/background/notify.ts +193 -19
  84. package/src/runs/background/owned-process-tree.ts +35 -8
  85. package/src/runs/background/process-terminal.ts +23 -23
  86. package/src/runs/background/result-files.ts +8 -4
  87. package/src/runs/background/result-watcher.ts +19 -2
  88. package/src/runs/background/retained-nested-route-tracker.ts +96 -0
  89. package/src/runs/background/run-child-session.ts +118 -41
  90. package/src/runs/background/run-status.ts +78 -5
  91. package/src/runs/background/runner-aliases.ts +22 -5
  92. package/src/runs/background/runner-child-launch.ts +93 -0
  93. package/src/runs/background/runner-child-sessions.ts +5 -4
  94. package/src/runs/background/runner-http-dispatcher.ts +119 -0
  95. package/src/runs/background/scheduled-runs.ts +51 -18
  96. package/src/runs/background/stale-run-reconciler.ts +38 -12
  97. package/src/runs/background/steering.ts +20 -2
  98. package/src/runs/background/subagent-runner.ts +766 -432
  99. package/src/runs/background/subagent-wait.ts +179 -28
  100. package/src/runs/background/wait-completions.ts +79 -27
  101. package/src/runs/background/wait-subscriptions.ts +9 -3
  102. package/src/runs/background/wait-tool.ts +5 -3
  103. package/src/runs/foreground/async-steering-action.ts +37 -7
  104. package/src/runs/foreground/async-stop-action.ts +93 -3
  105. package/src/runs/foreground/execution.ts +174 -194
  106. package/src/runs/foreground/foreground-history.ts +5 -2
  107. package/src/runs/foreground/prompt-audit.ts +12 -6
  108. package/src/runs/foreground/subagent-executor.ts +896 -397
  109. package/src/runs/foreground/workflow-detach-reconcile.ts +10 -5
  110. package/src/runs/foreground/workflow-foreground-steering.ts +57 -2
  111. package/src/runs/shared/acceptance.ts +54 -14
  112. package/src/runs/shared/agent-contract.ts +1 -1
  113. package/src/runs/shared/async-status-projection.ts +172 -78
  114. package/src/runs/shared/capability-ceiling.ts +2 -0
  115. package/src/runs/shared/child-hooks.ts +167 -3
  116. package/src/runs/shared/child-launch-plan.ts +15 -3
  117. package/src/runs/shared/child-launch.ts +44 -16
  118. package/src/runs/shared/child-lifecycle.ts +6 -3
  119. package/src/runs/shared/child-runtime-config.ts +8 -1
  120. package/src/runs/shared/child-session.ts +130 -24
  121. package/src/runs/shared/child-tool-plan.ts +145 -14
  122. package/src/runs/shared/completion-evidence.ts +2 -2
  123. package/src/runs/shared/completion-guard.ts +6 -3
  124. package/src/runs/shared/dynamic-fanout.ts +2 -2
  125. package/src/runs/shared/effective-system-prompt.ts +33 -0
  126. package/src/runs/shared/external-cli-contract.ts +11 -1
  127. package/src/runs/shared/external-cli-preflight.ts +6 -2
  128. package/src/runs/shared/external-cli-runner.ts +9 -7
  129. package/src/runs/shared/herdr-connection.ts +134 -0
  130. package/src/runs/shared/herdr-external-adapters.ts +169 -0
  131. package/src/runs/shared/herdr-machine.ts +279 -0
  132. package/src/runs/shared/herdr-pi-protocol.ts +59 -0
  133. package/src/runs/shared/herdr-placed-run.ts +263 -0
  134. package/src/runs/shared/host-step-status.ts +11 -11
  135. package/src/runs/shared/llm-intent-arbiter.ts +40 -21
  136. package/src/runs/shared/model-resolution-diagnostic.ts +76 -0
  137. package/src/runs/shared/{model-fallback.ts → model-resolution.ts} +34 -218
  138. package/src/runs/shared/model-scope.ts +1 -1
  139. package/src/runs/shared/nested-events.ts +19 -10
  140. package/src/runs/shared/orca-progress-tabs.ts +7 -1
  141. package/src/runs/shared/parallel-handoff.ts +57 -12
  142. package/src/runs/shared/parallel-utils.ts +10 -4
  143. package/src/runs/shared/pi-spawn.ts +10 -0
  144. package/src/runs/shared/readonly-drain-observation.ts +42 -0
  145. package/src/runs/shared/run-fanout-budget.ts +8 -8
  146. package/src/runs/shared/runtime-acknowledged-extensions.ts +3 -3
  147. package/src/runs/shared/subagent-prompt-runtime.ts +23 -5
  148. package/src/runs/shared/task-intent.ts +46 -13
  149. package/src/runs/shared/workflow-async-child-guidance.ts +18 -0
  150. package/src/runs/shared/worktree-cleanup-plan.ts +6 -3
  151. package/src/runs/shared/worktree-setup-command.ts +213 -0
  152. package/src/runs/shared/worktree.ts +437 -214
  153. package/src/shared/child-cache-retention.ts +43 -0
  154. package/src/shared/fork-context.ts +15 -72
  155. package/src/shared/launch-contract.ts +70 -8
  156. package/src/shared/model-response-aliases.ts +13 -0
  157. package/src/shared/opencode-session-headers.ts +30 -0
  158. package/src/shared/pruned-fork.ts +1 -1
  159. package/src/shared/required-child-extensions.ts +81 -0
  160. package/src/shared/settings.ts +5 -2
  161. package/src/shared/shortcuts.ts +0 -4
  162. package/src/shared/types.ts +163 -90
  163. package/src/shared/utils.ts +10 -2
  164. package/src/shared/watch-strategy.ts +2 -0
  165. package/src/shared/workflow-child-permit.ts +18 -13
  166. package/src/slash/delegation-adapters.ts +3 -1
  167. package/src/slash/delegation-request.ts +14 -0
  168. package/src/slash/slash-commands.ts +2 -7
  169. package/src/slash/subagents-admin.ts +31 -14
  170. package/src/tui/fleet-status.ts +165 -20
  171. package/src/tui/fleet.ts +30 -19
  172. package/src/tui/render.ts +210 -50
  173. package/src/watchdog/child-status.ts +28 -28
  174. package/src/watchdog/lsp-diagnostics.ts +1 -1
  175. package/src/watchdog/model-selection.ts +21 -1
  176. package/src/watchdog/permission-arbiter.ts +5 -2
  177. package/src/watchdog/register-child.ts +10 -2
  178. package/src/watchdog/register-main.ts +39 -35
  179. package/src/watchdog/render.ts +1 -1
  180. package/src/watchdog/review.ts +122 -74
  181. package/src/watchdog/rules.ts +1 -1
  182. package/src/watchdog/runtime.ts +100 -27
  183. package/src/watchdog/scope.ts +1 -1
  184. package/src/watchdog/settings.ts +3 -0
  185. package/src/watchdog/tool-actions.ts +13 -12
  186. package/src/watchdog/turn-delta.ts +23 -0
  187. package/src/watchdog/types.ts +5 -3
  188. package/src/watchdog/warning-format.ts +1 -1
  189. package/src/workflows/chat-progress.ts +3 -3
  190. package/src/workflows/scripted-workflow.ts +349 -26
  191. package/src/workflows/workflow-checklist.ts +17 -20
  192. package/src/workflows/workflow-child-summary.ts +57 -8
  193. package/src/workflows/workflow-preflight.ts +19 -19
  194. package/src/workflows/workflow-receipt.ts +24 -6
  195. package/src/workflows/workflow-resources.ts +108 -22
  196. package/src/workflows/workflow-settlement.ts +3 -0
  197. package/src/runs/shared/model-exclusions.ts +0 -373
  198. /package/src/inspectors/{herdr/shell-command.ts → shell-command.ts} +0 -0
@@ -135,6 +135,9 @@ function isNotFoundError(error: unknown): boolean {
135
135
  * Read async job status from disk (with mtime-based caching)
136
136
  */
137
137
  export function readStatus(asyncDir: string): AsyncStatus | null {
138
+ if (Buffer.byteLength(path.basename(asyncDir), "utf-8") > 255) {
139
+ return null;
140
+ }
138
141
  const statusPath = path.join(asyncDir, "status.json");
139
142
 
140
143
  let stat: fs.Stats;
@@ -454,8 +457,13 @@ export function hasEmptyTerminalAssistantResponse(messages: Message[]): boolean
454
457
  const lastAssistant = messages.findLast((message) => message.role === "assistant");
455
458
  return lastAssistant?.role === "assistant"
456
459
  && Array.isArray(lastAssistant.content)
457
- && lastAssistant.content.length === 0
458
- && lastAssistant.usage.output === 0;
460
+ && ((lastAssistant.content.length === 0 && lastAssistant.usage.output === 0)
461
+ || (messages.at(-1) === lastAssistant
462
+ && lastAssistant.stopReason === "stop"
463
+ && !lastAssistant.errorMessage
464
+ && lastAssistant.content.length > 0
465
+ // Token accounting can be nonzero even when no response text was emitted.
466
+ && lastAssistant.content.every((part) => part.type === "text" && part.text === "")));
459
467
  }
460
468
 
461
469
  export function formatEmptyTerminalAssistantResponseError(messages: Message[]): string {
@@ -2,9 +2,11 @@ export type FileWatchPurpose =
2
2
  | "result-delivery"
3
3
  | "supervisor-channel"
4
4
  | "async-job-tracker"
5
+ | "retained-nested-route-tracker"
5
6
  | "runner-control-inbox"
6
7
  | "child-steering-inbox";
7
8
 
8
9
  export function shouldUseNativeFsWatch(_purpose: FileWatchPurpose, platform: NodeJS.Platform = process.platform): boolean {
10
+ if (_purpose === "retained-nested-route-tracker" && platform === "win32") return false;
9
11
  return platform !== "darwin";
10
12
  }
@@ -1,5 +1,5 @@
1
1
  import { stableJsonDigest } from "./launch-contract.ts";
2
- import type { WorkflowResourceProvenanceV1 } from "./types.ts";
2
+ import type { WorkflowResourceProvenance } from "./types.ts";
3
3
 
4
4
  export interface WorkflowChildPermitInput {
5
5
  issuerPackage: string;
@@ -117,12 +117,12 @@ export function workflowChildPermitConsumed(permit: WorkflowChildPermit): boolea
117
117
  }
118
118
 
119
119
  export interface WorkflowResourceHostAuthority {
120
- keys: readonly string[];
121
- commands: readonly string[];
120
+ key: string;
121
+ command: string;
122
122
  }
123
123
 
124
124
  export interface WorkflowResourceAuthority {
125
- host?: WorkflowResourceHostAuthority;
125
+ host?: readonly WorkflowResourceHostAuthority[];
126
126
  }
127
127
 
128
128
  export interface WorkflowResourcePermitInput {
@@ -143,7 +143,7 @@ interface WorkflowResourcePermitRecord {
143
143
  resourceId: string;
144
144
  scriptDigest: string;
145
145
  authority: WorkflowResourceAuthority;
146
- provenance: WorkflowResourceProvenanceV1;
146
+ provenance: WorkflowResourceProvenance;
147
147
  state: "available" | "consumed";
148
148
  }
149
149
 
@@ -152,11 +152,17 @@ const resourceRecords = new WeakMap<object, WorkflowResourcePermitRecord>();
152
152
  function cloneWorkflowResourceAuthority(authority: WorkflowResourceAuthority): WorkflowResourceAuthority {
153
153
  if (!authority || typeof authority !== "object" || Array.isArray(authority)) throw new Error("Workflow resource authority must be an object.");
154
154
  if (authority.host === undefined) return Object.freeze({});
155
- if (!authority.host || typeof authority.host !== "object" || Array.isArray(authority.host)) throw new Error("Workflow resource host authority must be an object.");
156
- const { keys, commands } = authority.host;
157
- if (!Array.isArray(keys) || keys.some((key) => typeof key !== "string" || !key.trim())) throw new Error("Workflow resource host authority keys must be non-empty strings.");
158
- if (!Array.isArray(commands) || commands.some((command) => typeof command !== "string" || !command.trim())) throw new Error("Workflow resource host authority commands must be non-empty strings.");
159
- return Object.freeze({ host: Object.freeze({ keys: Object.freeze([...keys]), commands: Object.freeze([...commands]) }) });
155
+ if (!Array.isArray(authority.host) || authority.host.length > 32) throw new Error("Workflow resource host authority must be an array of at most 32 grants.");
156
+ const keys = new Set<string>();
157
+ const host = Array.from(authority.host, (grant) => {
158
+ if (!grant || typeof grant !== "object" || Object.keys(grant).some((field) => field !== "key" && field !== "command")) throw new Error("Workflow resource host grant must contain only key and command.");
159
+ const { key, command } = grant;
160
+ if (typeof key !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(key) || keys.has(key)) throw new Error("Workflow resource host grant requires a unique safe key.");
161
+ if (typeof command !== "string" || !command.trim() || Buffer.byteLength(command.trim(), "utf8") > 16 * 1024 || command.includes("\0")) throw new Error("Workflow resource host grant requires a non-empty command of at most 16384 bytes without NUL.");
162
+ keys.add(key);
163
+ return Object.freeze({ key, command: command.trim() });
164
+ });
165
+ return Object.freeze({ host: Object.freeze(host) });
160
166
  }
161
167
 
162
168
  /** Package-internal permit for a workflow resource resolved by the extension. */
@@ -186,7 +192,7 @@ export function createWorkflowResourcePermit(input: WorkflowResourcePermitInput)
186
192
  return permit;
187
193
  }
188
194
 
189
- export function consumeWorkflowResourcePermit(permit: WorkflowResourcePermit, script: string): { provenance: WorkflowResourceProvenanceV1; authority: WorkflowResourceAuthority } | string {
195
+ export function consumeWorkflowResourcePermit(permit: WorkflowResourcePermit, script: string): { provenance: WorkflowResourceProvenance; authority: WorkflowResourceAuthority } | string {
190
196
  const record = resourceRecords.get(permit as object);
191
197
  if (!record) return "Workflow resource permit is invalid.";
192
198
  if (record.state !== "available") return "Workflow resource permit is already consumed.";
@@ -201,7 +207,6 @@ export function authorizeWorkflowResourceHost(permit: WorkflowResourcePermit, ke
201
207
  if (!record || record.state !== "consumed") return "Workflow resource authority is unavailable.";
202
208
  const host = record.authority.host;
203
209
  if (!host) return "runs.host is not allowed for this workflow resource.";
204
- if (!host.keys.includes(key)) return `runs.host('${key}') is not allowed for workflow resource '${record.resourceName}'.`;
205
- if (!host.commands.includes(command.trim())) return `The command for runs.host('${key}') is not allowed for workflow resource '${record.resourceName}'.`;
210
+ if (!host.some((grant) => grant.key === key && grant.command === command.trim())) return `The command for runs.host('${key}') is not allowed for workflow resource '${record.resourceName}'.`;
206
211
  return undefined;
207
212
  }
@@ -6,7 +6,7 @@ import {
6
6
  type SubagentDelegationUpdate,
7
7
  type SubagentDelegationValue,
8
8
  } from "../api/delegation.ts";
9
- import type { AcceptanceInput, AgentContract, EffectsProjection, ExecutionProjection, JsonSchemaObject, ReviewProjection, ToolBudgetConfig, Usage } from "../shared/types.ts";
9
+ import type { AcceptanceInput, AgentContract, EffectsProjection, ExecutionProjection, IntercomBridgeConfig, JsonSchemaObject, ReviewProjection, ToolBudgetConfig, Usage } from "../shared/types.ts";
10
10
  import { cloneJsonWithinByteLimit } from "./delegation-json.ts";
11
11
 
12
12
  export interface PromptTemplateDelegationRequest {
@@ -127,6 +127,7 @@ export interface DelegatedSubagentExecutionParams {
127
127
  agentContract?: AgentContract;
128
128
  acceptance?: AcceptanceInput;
129
129
  artifacts?: boolean;
130
+ intercomBridge?: IntercomBridgeConfig;
130
131
  /** Internal-only thinking override accepted by executeDelegated. */
131
132
  delegatedThinkingOverride?: SubagentDelegationThinking;
132
133
  /** Internal-only capability accepted and stripped by executeDelegated. */
@@ -295,6 +296,7 @@ export function toSubagentDelegationExecutionParams(request: SubagentDelegationR
295
296
  ...(request.result.kind === "structured" ? { outputSchema: request.result.schema } : {}),
296
297
  acceptance: false,
297
298
  artifacts: request.artifacts,
299
+ ...(request.intercomBridge !== undefined ? { intercomBridge: request.intercomBridge } : {}),
298
300
  delegatedThinkingOverride: request.thinking,
299
301
  delegatedAllowZeroToolBudget: true,
300
302
  async: false,
@@ -1,7 +1,9 @@
1
1
  import {
2
2
  type SubagentDelegationRequest,
3
3
  } from "../api/delegation.ts";
4
+ import { validateIntercomBridgeConfig } from "../intercom/intercom-bridge.ts";
4
5
  import { validateToolBudgetConfig } from "../runs/shared/tool-budget.ts";
6
+ import type { IntercomBridgeConfig } from "../shared/types.ts";
5
7
  import { cloneJsonWithinByteLimit } from "./delegation-json.ts";
6
8
 
7
9
  export type SubagentDelegationParseResult =
@@ -22,6 +24,7 @@ const supportedFields = new Set([
22
24
  "toolBudget",
23
25
  "skill",
24
26
  "artifacts",
27
+ "intercomBridge",
25
28
  "result",
26
29
  ]);
27
30
 
@@ -97,6 +100,15 @@ export function parseSubagentDelegationRequest(data: unknown): SubagentDelegatio
97
100
  if (value.artifacts !== undefined && typeof value.artifacts !== "boolean") {
98
101
  return { ok: false, ...identity, error: "artifacts must be a boolean." };
99
102
  }
103
+ let intercomBridge: IntercomBridgeConfig | undefined;
104
+ if (value.intercomBridge !== undefined) {
105
+ const bridge = validateIntercomBridgeConfig({ value: value.intercomBridge, label: "intercomBridge" });
106
+ if (!bridge.ok) return { ok: false, ...identity, error: bridge.error };
107
+ if (typeof bridge.value.instructionFile === "string" && Buffer.byteLength(bridge.value.instructionFile, "utf8") > MAX_SHORT_TEXT_BYTES) {
108
+ return { ok: false, ...identity, error: "intercomBridge.instructionFile exceeds 1 KiB when UTF-8 encoded." };
109
+ }
110
+ intercomBridge = bridge.value;
111
+ }
100
112
  if (Buffer.byteLength(value.task as string, "utf8") > MAX_TASK_BYTES) {
101
113
  return { ok: false, ...identity, error: "Delegation task exceeds 1 MiB when UTF-8 encoded." };
102
114
  }
@@ -154,6 +166,8 @@ export function parseSubagentDelegationRequest(data: unknown): SubagentDelegatio
154
166
  ok: true,
155
167
  request: {
156
168
  ...value,
169
+ // The validated copy replaces the caller's object so the request never aliases untrusted input.
170
+ ...(intercomBridge ? { intercomBridge } : {}),
157
171
  result: structuredSchema
158
172
  ? { kind: "structured", schema: structuredSchema }
159
173
  : { kind: "text" },
@@ -25,12 +25,12 @@ import { resolveAsyncStatusChild } from "../runs/shared/child-identity.ts";
25
25
  import { readStatus } from "../shared/utils.ts";
26
26
  import { getArtifactPaths, getArtifactsDir } from "../shared/artifacts.ts";
27
27
  import { readWorkflowReceipt } from "../workflows/workflow-receipt.ts";
28
- import { FLEET_OPEN_SHORTCUT } from "../shared/shortcuts.ts";
29
28
  import type { SlashSubagentResponse, SlashSubagentUpdate } from "./slash-bridge.ts";
30
29
  import { registerPromptWorkflowCommands } from "./prompt-workflows.ts";
31
30
  import { openSubagentsAdmin } from "./subagents-admin.ts";
32
31
  import { SUBAGENT_GUIDE_TOPICS } from "../extension/subagent-guide.ts";
33
32
  import { openSubagentFleet } from "../tui/fleet.ts";
33
+ import { createBuiltinInspectorPlugins } from "../inspectors/plugins.ts";
34
34
  import {
35
35
  applySlashUpdate,
36
36
  buildSlashInitialResult,
@@ -860,7 +860,7 @@ export function registerSlashCommands(
860
860
  }
861
861
  fleetOpen = true;
862
862
  try {
863
- await openSubagentFleet(ctx, state, { asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: options.fleetKeybindings, events: pi.events });
863
+ await openSubagentFleet(ctx, state, { asyncDirRoot: DIRS.async, inspectorPlugins: createBuiltinInspectorPlugins(), resultsDir: DIRS.results, fleetKeybindings: options.fleetKeybindings, events: pi.events });
864
864
  } finally {
865
865
  fleetOpen = false;
866
866
  }
@@ -975,11 +975,6 @@ export function registerSlashCommands(
975
975
  handler: async (_args, ctx) => showFleet(ctx),
976
976
  });
977
977
 
978
- pi.registerShortcut(FLEET_OPEN_SHORTCUT, {
979
- description: "Open subagent fleet inspector",
980
- handler: async (ctx) => showFleet(ctx),
981
- });
982
-
983
978
  const detachForegroundRun = (args: string, ctx: ExtensionContext): void => {
984
979
  const id = args.trim();
985
980
  let control: ReturnType<typeof selectForegroundDetachControl>;
@@ -12,6 +12,7 @@ import {
12
12
  } from "../agents/agents.ts";
13
13
  import { serializeAgent } from "../agents/agent-serializer.ts";
14
14
  import { emitUiSpanSilent, type UiSpanSilentEvents } from "../ui-silent-marker.ts";
15
+ import { mergeRuntimeAgents, type RuntimeAgentOwner } from "../agents/runtime-agent-registry.ts";
15
16
 
16
17
  /** Event bus captured for the duration of one admin flow. */
17
18
  let adminDialogEvents: UiSpanSilentEvents | undefined;
@@ -20,7 +21,6 @@ let adminDialogEvents: UiSpanSilentEvents | undefined;
20
21
  function markAdminDialogSilent(): void {
21
22
  emitUiSpanSilent(adminDialogEvents, "admin");
22
23
  }
23
-
24
24
  import { editableAgentConfig, preservedAgentFrontmatterFields } from "../agents/agent-management.ts";
25
25
  import { findModelInfo, getSupportedThinkingLevels, toModelInfo } from "../shared/model-info.ts";
26
26
  import { SelectorComponent, type SelectorItem, type SelectorResult } from "./selector.ts";
@@ -38,11 +38,13 @@ function sourceRank(source: AgentConfig["source"]): number {
38
38
  return 3;
39
39
  }
40
40
 
41
- function allVisibleAgents(cwd: string): AgentConfig[] {
41
+ function allVisibleAgents(pi: RuntimeAgentOwner, cwd: string): AgentConfig[] {
42
42
  const d = discoverAgentsAll(cwd);
43
- return [...d.project, ...d.user, ...d.package, ...d.builtin]
44
- .filter((agent) => !agent.disabled)
45
- .sort((a, b) => a.name.localeCompare(b.name) || sourceRank(a.source) - sourceRank(b.source));
43
+ const allConfigured = [...d.project, ...d.user, ...d.package, ...d.builtin];
44
+ const visibleConfigured = allConfigured.filter((agent) => !agent.disabled);
45
+ // Disabled definitions remain in collision checks even though the panel hides them.
46
+ const agents = mergeRuntimeAgents(pi, { agents: visibleConfigured }, allConfigured).agents;
47
+ return agents.sort((a, b) => a.name.localeCompare(b.name) || sourceRank(a.source) - sourceRank(b.source));
46
48
  }
47
49
 
48
50
  function agentLabel(agent: AgentConfig): string {
@@ -81,9 +83,23 @@ function modelFullId(model: ModelInfo): string {
81
83
  return `${model.provider}/${model.id}`;
82
84
  }
83
85
 
84
- function liveAvailableModels(ctx: ExtensionContext) {
86
+ async function liveAvailableModels(ctx: ExtensionContext) {
85
87
  try {
86
- ctx.modelRegistry.refresh?.();
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
+ 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
+ }
102
+ }
87
103
  } catch (error) {
88
104
  const message = error instanceof Error ? error.message : String(error);
89
105
  ctx.ui.notify(`Could not refresh the model registry; using the last loaded choices. ${message}`, "warning");
@@ -94,7 +110,6 @@ function liveAvailableModels(ctx: ExtensionContext) {
94
110
  function buildBuiltinBase(agent: AgentConfig): BuiltinAgentOverrideBase {
95
111
  return {
96
112
  ...(agent.model !== undefined ? { model: agent.model } : {}),
97
- ...(agent.fallbackModels !== undefined ? { fallbackModels: [...agent.fallbackModels] } : {}),
98
113
  ...(agent.thinking !== undefined ? { thinking: agent.thinking } : {}),
99
114
  systemPromptMode: agent.systemPromptMode,
100
115
  inheritProjectContext: agent.inheritProjectContext,
@@ -149,6 +164,9 @@ function isReadOnlyExtraAgent(agent: AgentConfig): boolean {
149
164
  }
150
165
 
151
166
  function readOnlyAgentMessage(agent: AgentConfig, field: EditableOverrideField): string | undefined {
167
+ if (agent.source === "runtime") {
168
+ return `Cannot update '${agent.name}' ${field} because that agent is runtime-registered by an extension; edit its source definition instead.`;
169
+ }
152
170
  if (agent.source === "package") {
153
171
  return `Cannot update '${agent.name}' ${field} because that field is owned by its read-only package definition.`;
154
172
  }
@@ -157,8 +175,8 @@ function readOnlyAgentMessage(agent: AgentConfig, field: EditableOverrideField):
157
175
  : undefined;
158
176
  }
159
177
 
160
- async function selectAgent(ctx: ExtensionContext, args: string): Promise<AgentSelection> {
161
- const agents = allVisibleAgents(ctx.cwd);
178
+ async function selectAgent(pi: RuntimeAgentOwner, ctx: ExtensionContext, args: string): Promise<AgentSelection> {
179
+ const agents = allVisibleAgents(pi, ctx.cwd);
162
180
  const requestedName = args.trim().split(/\s+/)[0] ?? "";
163
181
  if (agents.length === 0) return { kind: "not-found", agents, requestedName: requestedName || undefined };
164
182
 
@@ -192,7 +210,6 @@ function metadataFor(agent: AgentConfig): string {
192
210
  lines.push(`Package: ${agent.packageName}`);
193
211
  }
194
212
  lines.push(`Model: ${agent.model ?? "default / inherit"}`);
195
- if (agent.fallbackModels?.length) lines.push(`Fallback models: ${agent.fallbackModels.join(", ")}`);
196
213
  if (agent.thinking !== undefined) lines.push(`Thinking: ${agent.thinking === false ? "off" : agent.thinking}`);
197
214
  if (tools.length) lines.push(`Tools: ${tools.join(", ")}`);
198
215
  if (agent.excludeTools?.length) lines.push(`Excluded tools: ${agent.excludeTools.join(", ")}`);
@@ -228,7 +245,7 @@ async function selectFromList(ctx: ExtensionContext, title: string, subtitle: st
228
245
  }
229
246
 
230
247
  async function chooseModel(ctx: ExtensionContext, agent: AgentConfig): Promise<string | undefined | null> {
231
- const models = liveAvailableModels(ctx);
248
+ const models = await liveAvailableModels(ctx);
232
249
  const current = agent.model ?? INHERIT_MODEL_CHOICE;
233
250
  const items: SelectorItem[] = [{ value: INHERIT_MODEL_CHOICE, label: INHERIT_MODEL_CHOICE, current: !agent.model }];
234
251
  if (agent.model && !models.some((model) => modelFullId(model) === agent.model)) {
@@ -244,7 +261,7 @@ async function chooseModel(ctx: ExtensionContext, agent: AgentConfig): Promise<s
244
261
  }
245
262
 
246
263
  async function chooseThinking(ctx: ExtensionContext, agent: AgentConfig): Promise<string | undefined | null> {
247
- const availableModels = liveAvailableModels(ctx).map(toModelInfo);
264
+ const availableModels = (await liveAvailableModels(ctx)).map(toModelInfo);
248
265
  const effectiveModel = agent.model ?? (ctx.model ? modelFullId(ctx.model) : undefined);
249
266
  const modelInfo = findModelInfo(effectiveModel, availableModels, ctx.model?.provider);
250
267
  const levels = getSupportedThinkingLevels(modelInfo);
@@ -405,7 +422,7 @@ export async function openSubagentsAdmin(pi: ExtensionAPI, ctx: ExtensionContext
405
422
  }
406
423
 
407
424
  async function runAdminFlow(pi: ExtensionAPI, ctx: ExtensionContext, args = ""): Promise<void> {
408
- const selection = await selectAgent(ctx, args);
425
+ const selection = await selectAgent(pi, ctx, args);
409
426
  if (selection.kind === "cancelled") return;
410
427
  if (selection.kind === "ambiguous") {
411
428
  sendAdminMessage(pi, `Subagent '${selection.requestedName}' is ambiguous. Choose a scope in interactive mode:\n${selection.matches.map((agent) => `- ${agent.source}: ${agent.filePath}`).join("\n")}`);