@xzzpig/pi-subagents 0.24.2 → 0.25.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 (258) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/bundle/agent-management.js +4 -4
  3. package/bundle/agents.js +3 -3
  4. package/bundle/child-tool-plan.js +2 -2
  5. package/bundle/chunk-34TUUBRN.js +1107 -0
  6. package/bundle/{chunk-SW2VMNIU.js → chunk-5OD3OWTE.js} +2 -2
  7. package/bundle/{chunk-XWWUDWUW.js → chunk-5YEOWNSD.js} +371 -135
  8. package/bundle/{chunk-EUPJB4S7.js → chunk-5Z7JAORM.js} +196 -1219
  9. package/bundle/{chunk-LCDJWBVM.js → chunk-66JNFRFS.js} +1 -1
  10. package/bundle/{chunk-4UH4WS4G.js → chunk-6MNRKUHY.js} +23 -12
  11. package/bundle/{chunk-ED55MIC2.js → chunk-CGFF4WA3.js} +42 -19
  12. package/bundle/{chunk-TMHVDPYW.js → chunk-DLVPMML3.js} +263 -154
  13. package/bundle/chunk-HXRB42AF.js +108 -0
  14. package/bundle/{chunk-355ECEP2.js → chunk-IH7LQVEE.js} +29 -14
  15. package/bundle/{chunk-CYY5UMJU.js → chunk-IJWITCC6.js} +411 -249
  16. package/bundle/{chunk-RU522D5W.js → chunk-IKFKH5EL.js} +369 -50
  17. package/bundle/{chunk-Z6TFJ6BR.js → chunk-INWSUNI6.js} +1 -1
  18. package/bundle/{chunk-JEA2ZKUA.js → chunk-IUDEI6FJ.js} +35 -200
  19. package/bundle/{chunk-WW76JRIX.js → chunk-JAXVBXGF.js} +1 -1
  20. package/bundle/{chunk-ICNYIALB.js → chunk-JH5H4CYJ.js} +784 -474
  21. package/bundle/{chunk-35GII5EF.js → chunk-JWFLPSTP.js} +41 -117
  22. package/bundle/{chunk-224WMDIV.js → chunk-KCJFGKVK.js} +350 -123
  23. package/bundle/{chunk-RB4GELQA.js → chunk-LPJEKHOY.js} +1 -1
  24. package/bundle/chunk-LYKG4FKH.js +523 -0
  25. package/bundle/{chunk-X6LOM3Z4.js → chunk-LZ3HBDTR.js} +161 -78
  26. package/bundle/{chunk-FG6SQJAR.js → chunk-OGPOCGWX.js} +24 -6
  27. package/bundle/{chunk-BQ2OAB4Q.js → chunk-OSVXFWPG.js} +67 -30
  28. package/bundle/{chunk-FJWI64H7.js → chunk-RMSABUN3.js} +27 -13
  29. package/bundle/{chunk-H36HBZB2.js → chunk-SJPABBZG.js} +2 -2
  30. package/bundle/{chunk-3U633XDZ.js → chunk-U3ZDUUTM.js} +11 -3
  31. package/bundle/{chunk-LVWU2HOO.js → chunk-ULGMXABL.js} +16 -7
  32. package/bundle/{chunk-WPW4V6HM.js → chunk-W7ZA6TYD.js} +2 -2
  33. package/bundle/{chunk-V2KFIGFH.js → chunk-XAC2XNAP.js} +503 -304
  34. package/bundle/{chunk-O4D5PBVI.js → chunk-YWXILP5N.js} +3 -2
  35. package/bundle/control-channel.js +2 -2
  36. package/bundle/index.js +1 -1
  37. package/bundle/intercom-bridge.js +2 -2
  38. package/bundle/preflight.js +12 -10
  39. package/bundle/project-panes.js +3 -3
  40. package/bundle/workflow-resources.js +1 -1
  41. package/docs/agents.md +27 -6
  42. package/docs/configuration.md +20 -8
  43. package/docs/extension-api.md +18 -1
  44. package/docs/models.md +6 -2
  45. package/docs/observability.md +2 -0
  46. package/docs/tool-reference.md +7 -1
  47. package/docs/workflows.md +30 -2
  48. package/package.json +2 -2
  49. package/skills/pi-subagents/SKILL.md +15 -6
  50. package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
  51. package/src/agents/agent-management.d.ts +1 -0
  52. package/src/agents/agent-management.js +46 -18
  53. package/src/agents/agent-memory.d.ts +1 -4
  54. package/src/agents/agent-memory.js +1 -4
  55. package/src/agents/agent-serializer.d.ts +2 -0
  56. package/src/agents/agent-serializer.js +1 -1
  57. package/src/agents/agents.d.ts +2 -3
  58. package/src/agents/agents.js +46 -20
  59. package/src/agents/frontmatter.js +1 -8
  60. package/src/agents/global-npm-root.d.ts +1 -0
  61. package/src/agents/global-npm-root.js +11 -3
  62. package/src/agents/skills.d.ts +0 -3
  63. package/src/agents/skills.js +0 -3
  64. package/src/api/preflight.d.ts +3 -1
  65. package/src/api/preflight.js +2 -0
  66. package/src/extension/config.d.ts +1 -0
  67. package/src/extension/config.js +13 -1
  68. package/src/extension/herdr-pi-bridge.js +10 -2
  69. package/src/extension/index.d.ts +0 -13
  70. package/src/extension/index.js +51 -37
  71. package/src/extension/public-execution.d.ts +1 -0
  72. package/src/extension/public-execution.js +4 -0
  73. package/src/extension/reply-workflow-script.js +24 -4
  74. package/src/extension/schemas.d.ts +12 -3
  75. package/src/extension/schemas.js +7 -3
  76. package/src/extension/session-switch.d.ts +25 -0
  77. package/src/extension/session-switch.js +138 -0
  78. package/src/extension/subagent-guide.d.ts +1 -1
  79. package/src/extension/subagent-guide.js +1 -1
  80. package/src/extension/subagent-launch-tool.d.ts +25 -0
  81. package/src/extension/subagent-launch-tool.js +48 -0
  82. package/src/extension/tool-activation.js +55 -15
  83. package/src/extension/tool-description.d.ts +1 -1
  84. package/src/extension/tool-description.js +14 -8
  85. package/src/inspectors/herdr/actions.d.ts +0 -1
  86. package/src/inspectors/herdr/actions.js +0 -1
  87. package/src/inspectors/session-roots-codec.d.ts +0 -1
  88. package/src/inspectors/session-roots-codec.js +0 -1
  89. package/src/inspectors/tmux/actions.d.ts +0 -1
  90. package/src/inspectors/tmux/actions.js +0 -1
  91. package/src/integrations/herdr-status.js +3 -8
  92. package/src/intercom/native-supervisor-channel.js +65 -9
  93. package/src/runs/background/async-execution.d.ts +7 -10
  94. package/src/runs/background/async-execution.js +66 -29
  95. package/src/runs/background/async-job-tracker.js +12 -0
  96. package/src/runs/background/async-resume.d.ts +2 -1
  97. package/src/runs/background/async-resume.js +114 -40
  98. package/src/runs/background/async-retention.d.ts +0 -2
  99. package/src/runs/background/async-retention.js +17 -6
  100. package/src/runs/background/async-status.d.ts +2 -0
  101. package/src/runs/background/async-status.js +4 -0
  102. package/src/runs/background/auto-drain.js +2 -1
  103. package/src/runs/background/boot-id.d.ts +1 -3
  104. package/src/runs/background/boot-id.js +1 -3
  105. package/src/runs/background/completion-batcher.d.ts +3 -4
  106. package/src/runs/background/completion-batcher.js +2 -3
  107. package/src/runs/background/control-channel.d.ts +0 -6
  108. package/src/runs/background/control-channel.js +0 -6
  109. package/src/runs/background/fleet-view.js +2 -3
  110. package/src/runs/background/notify.d.ts +0 -2
  111. package/src/runs/background/notify.js +0 -2
  112. package/src/runs/background/result-watcher.d.ts +1 -0
  113. package/src/runs/background/result-watcher.js +59 -29
  114. package/src/runs/background/resume-guidance.js +4 -2
  115. package/src/runs/background/retained-children.js +2 -1
  116. package/src/runs/background/run-child-session.d.ts +2 -3
  117. package/src/runs/background/run-child-session.js +5 -8
  118. package/src/runs/background/run-status.js +9 -7
  119. package/src/runs/background/runner-aliases.js +15 -0
  120. package/src/runs/background/scheduled-runs.d.ts +3 -1
  121. package/src/runs/background/scheduled-runs.js +13 -16
  122. package/src/runs/background/steering.d.ts +2 -11
  123. package/src/runs/background/steering.js +11 -6
  124. package/src/runs/background/subagent-runner.d.ts +2 -6
  125. package/src/runs/background/subagent-runner.js +88 -70
  126. package/src/runs/background/subagent-wait.js +12 -15
  127. package/src/runs/background/wait-config.d.ts +2 -0
  128. package/src/runs/background/wait-config.js +17 -3
  129. package/src/runs/background/wait-subscriptions.js +124 -12
  130. package/src/runs/background/wait-tool.js +4 -2
  131. package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
  132. package/src/runs/background/workflow-terminal-proof.js +0 -1
  133. package/src/runs/foreground/async-steering-action.js +24 -9
  134. package/src/runs/foreground/async-stop-action.d.ts +1 -1
  135. package/src/runs/foreground/async-stop-action.js +9 -1
  136. package/src/runs/foreground/execution.d.ts +0 -3
  137. package/src/runs/foreground/execution.js +56 -24
  138. package/src/runs/foreground/prompt-audit.js +1 -0
  139. package/src/runs/foreground/subagent-executor.d.ts +5 -10
  140. package/src/runs/foreground/subagent-executor.js +164 -49
  141. package/src/runs/shared/acceptance.js +69 -26
  142. package/src/runs/shared/async-status-projection.d.ts +2 -0
  143. package/src/runs/shared/async-status-projection.js +10 -0
  144. package/src/runs/shared/child-commands.js +15 -2
  145. package/src/runs/shared/child-hooks.d.ts +1 -7
  146. package/src/runs/shared/child-hooks.js +13 -5
  147. package/src/runs/shared/child-launch.js +6 -2
  148. package/src/runs/shared/child-runtime-config.d.ts +0 -1
  149. package/src/runs/shared/child-session.d.ts +6 -5
  150. package/src/runs/shared/child-session.js +85 -38
  151. package/src/runs/shared/child-tool-plan.d.ts +0 -1
  152. package/src/runs/shared/child-tool-plan.js +0 -1
  153. package/src/runs/shared/claude-code-adapter.js +11 -0
  154. package/src/runs/shared/external-cli-contract.d.ts +49 -0
  155. package/src/runs/shared/external-cli-contract.js +18 -13
  156. package/src/runs/shared/external-cli-runner.js +26 -6
  157. package/src/runs/shared/herdr-connection.js +2 -1
  158. package/src/runs/shared/herdr-pane-host.d.ts +2 -2
  159. package/src/runs/shared/herdr-pane-host.js +17 -1
  160. package/src/runs/shared/herdr-placed-run.js +51 -24
  161. package/src/runs/shared/lane-metadata.d.ts +0 -1
  162. package/src/runs/shared/lane-metadata.js +0 -1
  163. package/src/runs/shared/mcp-config-sources.d.ts +4 -1
  164. package/src/runs/shared/mcp-config-sources.js +1 -1
  165. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
  166. package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
  167. package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
  168. package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
  169. package/src/runs/shared/model-resolution.d.ts +20 -5
  170. package/src/runs/shared/model-resolution.js +55 -50
  171. package/src/runs/shared/model-scope.d.ts +1 -5
  172. package/src/runs/shared/model-scope.js +1 -5
  173. package/src/runs/shared/mutation-evidence.d.ts +1 -1
  174. package/src/runs/shared/mutation-evidence.js +52 -7
  175. package/src/runs/shared/nested-events.d.ts +1 -0
  176. package/src/runs/shared/nested-events.js +1 -1
  177. package/src/runs/shared/parallel-utils.d.ts +0 -1
  178. package/src/runs/shared/permissions.js +5 -3
  179. package/src/runs/shared/placement-host.d.ts +5 -1
  180. package/src/runs/shared/rex-pane-host.d.ts +0 -1
  181. package/src/runs/shared/rex-pane-host.js +0 -2
  182. package/src/runs/shared/run-launch-folder.d.ts +12 -0
  183. package/src/runs/shared/run-launch-folder.js +21 -0
  184. package/src/runs/shared/runner-launcher.d.ts +12 -1
  185. package/src/runs/shared/runner-launcher.js +16 -0
  186. package/src/runs/shared/single-output.d.ts +3 -3
  187. package/src/runs/shared/single-output.js +5 -3
  188. package/src/runs/shared/structured-output.d.ts +8 -0
  189. package/src/runs/shared/structured-output.js +40 -5
  190. package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
  191. package/src/runs/shared/subagent-prompt-runtime.js +18 -4
  192. package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
  193. package/src/runs/shared/supervisor-wait-timer.js +61 -0
  194. package/src/runs/shared/tool-timeout.js +2 -1
  195. package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
  196. package/src/runs/shared/worktree-cleanup-plan.js +0 -1
  197. package/src/runs/shared/worktree.d.ts +3 -0
  198. package/src/runs/shared/worktree.js +20 -0
  199. package/src/shared/artifacts.d.ts +1 -0
  200. package/src/shared/artifacts.js +132 -22
  201. package/src/shared/capacity-resilient-json.d.ts +1 -1
  202. package/src/shared/child-cache-retention.d.ts +1 -2
  203. package/src/shared/child-cache-retention.js +1 -2
  204. package/src/shared/fleet-transcript-reader.d.ts +51 -0
  205. package/src/shared/fleet-transcript-reader.js +333 -0
  206. package/src/shared/formatters.d.ts +0 -18
  207. package/src/shared/formatters.js +0 -18
  208. package/src/shared/pruned-fork.js +2 -2
  209. package/src/shared/reported-progress.d.ts +1 -0
  210. package/src/shared/reported-progress.js +12 -0
  211. package/src/shared/session-succession.d.ts +16 -1
  212. package/src/shared/session-succession.js +41 -2
  213. package/src/shared/session-warnings.d.ts +7 -0
  214. package/src/shared/session-warnings.js +26 -0
  215. package/src/shared/settings.d.ts +0 -23
  216. package/src/shared/settings.js +3 -35
  217. package/src/shared/status-format.d.ts +1 -0
  218. package/src/shared/status-format.js +1 -1
  219. package/src/shared/types.d.ts +108 -59
  220. package/src/shared/types.js +0 -12
  221. package/src/shared/utils.d.ts +3 -15
  222. package/src/shared/utils.js +4 -22
  223. package/src/shared/wait-tool-name.d.ts +8 -0
  224. package/src/shared/wait-tool-name.js +13 -0
  225. package/src/slash/slash-commands.js +2 -1
  226. package/src/slash/subagent-cost.d.ts +3 -2
  227. package/src/slash/subagent-cost.js +22 -3
  228. package/src/slash/subagents-admin.js +0 -1
  229. package/src/tui/fleet-status.d.ts +0 -5
  230. package/src/tui/fleet-status.js +4 -24
  231. package/src/tui/fleet.js +6 -4
  232. package/src/tui/render.d.ts +0 -9
  233. package/src/tui/render.js +194 -68
  234. package/src/tui/subagent-messages.js +3 -2
  235. package/src/watchdog/model-selection.js +2 -2
  236. package/src/watchdog/permission-arbiter.js +1 -0
  237. package/src/watchdog/register-child.d.ts +2 -3
  238. package/src/watchdog/register-child.js +2 -3
  239. package/src/watchdog/review.d.ts +0 -5
  240. package/src/watchdog/review.js +4 -3
  241. package/src/watchdog/turn-delta.js +2 -1
  242. package/src/workflows/scripted-workflow.d.ts +2 -0
  243. package/src/workflows/scripted-workflow.js +344 -59
  244. package/src/workflows/structured-workflow-scripts.d.ts +4 -3
  245. package/src/workflows/structured-workflow-scripts.js +32 -11
  246. package/src/workflows/workflow-launch-record.d.ts +15 -6
  247. package/src/workflows/workflow-launch-record.js +30 -12
  248. package/src/workflows/workflow-receipt.js +36 -53
  249. package/src/workflows/workflow-resources.js +4 -4
  250. package/src/workflows/workflow-resume-claim.d.ts +2 -0
  251. package/src/workflows/workflow-resume-claim.js +3 -3
  252. package/src/workflows/workflow-resume.d.ts +1 -1
  253. package/src/workflows/workflow-resume.js +13 -8
  254. package/src/workflows/workflow-script-worker.d.ts +13 -0
  255. package/src/workflows/workflow-script-worker.js +81 -0
  256. package/workflow-script-process.cjs +36 -0
  257. package/workflow-script-worker.cjs +4 -1
  258. package/bundle/chunk-U4ODUYAG.js +0 -235
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  registerRuntimeAgent
3
- } from "./chunk-Z6TFJ6BR.js";
3
+ } from "./chunk-INWSUNI6.js";
4
4
 
5
5
  // src/agents/runtime-agent-events.ts
6
6
  var RUNTIME_AGENT_REGISTER_EVENT = "pi-subagents:runtime-agent-register:v1";
@@ -1,25 +1,31 @@
1
1
  import {
2
2
  rewriteSubagentPrompt
3
- } from "./chunk-FG6SQJAR.js";
3
+ } from "./chunk-OGPOCGWX.js";
4
4
  import {
5
5
  package_default
6
- } from "./chunk-O4D5PBVI.js";
7
- import "./chunk-EUPJB4S7.js";
6
+ } from "./chunk-YWXILP5N.js";
7
+ import {
8
+ WATCHDOG_DIFF_TOOL_NAME,
9
+ captureWatchdogDiffBaseline,
10
+ createWatchdogDiffTool
11
+ } from "./chunk-5Z7JAORM.js";
12
+ import "./chunk-DLVPMML3.js";
13
+ import "./chunk-34TUUBRN.js";
8
14
  import {
9
15
  MODEL_ONLY_TOOL
10
- } from "./chunk-TMHVDPYW.js";
11
- import "./chunk-FJWI64H7.js";
16
+ } from "./chunk-HXRB42AF.js";
17
+ import "./chunk-RMSABUN3.js";
12
18
  import {
13
19
  appendAgentRefinementOverlay
14
- } from "./chunk-SW2VMNIU.js";
15
- import "./chunk-ICNYIALB.js";
16
- import "./chunk-U4ODUYAG.js";
20
+ } from "./chunk-5OD3OWTE.js";
21
+ import "./chunk-JH5H4CYJ.js";
22
+ import "./chunk-LYKG4FKH.js";
17
23
  import "./chunk-NIXWDZZV.js";
18
- import "./chunk-WW76JRIX.js";
24
+ import "./chunk-JAXVBXGF.js";
19
25
  import "./chunk-BGIYHF2W.js";
20
26
  import {
21
27
  assertNoToolModifierEntries
22
- } from "./chunk-355ECEP2.js";
28
+ } from "./chunk-IH7LQVEE.js";
23
29
  import "./chunk-CTPAE36Y.js";
24
30
  import {
25
31
  HERDR_PI_MAX_FRAME_BYTES,
@@ -37,7 +43,7 @@ import {
37
43
  discoverAgents,
38
44
  resolveExistingReadPaths,
39
45
  resolveSkills
40
- } from "./chunk-V2KFIGFH.js";
46
+ } from "./chunk-XAC2XNAP.js";
41
47
  import "./chunk-UQDHXMUG.js";
42
48
  import "./chunk-QXASAHIA.js";
43
49
  import "./chunk-YFCK7H2S.js";
@@ -240,9 +246,11 @@ ${resolvedSystemPrompt}` } : void 0;
240
246
  const resolved = resolveRemoteHerdrResources(process.cwd(), { agent: resources.agent, ...resources.skills ? { skills: resources.skills } : {}, ...resources.toolCeiling ? { toolCeiling: resources.toolCeiling } : {}, ...resources.reads !== void 0 ? { reads: resources.reads } : {} }, context ? pi.getActiveTools() : []);
241
247
  resolvedSystemPrompt = resolved.systemPrompt;
242
248
  resolvedContextPolicy = resolved;
249
+ if (resolved.tools.includes(WATCHDOG_DIFF_TOOL_NAME) && !pi.getAllTools().some((tool) => tool.name === WATCHDOG_DIFF_TOOL_NAME)) pi.registerTool(createWatchdogDiffTool(captureWatchdogDiffBaseline(process.cwd()), { workingTreeAtLaunch: true }));
243
250
  pi.setActiveTools(resolved.tools);
244
251
  const acknowledged = context ? pi.getActiveTools() : [];
245
- if (acknowledged.some((tool) => !resolved.tools.includes(tool)) || resolved.tools.some((tool) => !acknowledged.includes(tool))) throw new Error("Remote Pi did not apply the resolved active-tool set exactly.");
252
+ const missing = resolved.tools.filter((tool) => !acknowledged.includes(tool)), extra = acknowledged.filter((tool) => !resolved.tools.includes(tool));
253
+ if (missing.length || extra.length) throw new Error(`Remote Pi did not apply the resolved active-tool set exactly (${[...missing.length ? [`not available: ${missing.join(", ")}`] : [], ...extra.length ? [`unexpected: ${extra.join(", ")}`] : []].join("; ")}).`);
246
254
  configured = true;
247
255
  send({ type: "configured", requestId: frame.requestId, nativeSessionId, agent: resolved.agent, skills: resolved.skills, model: context?.model?.provider && context.model.id ? `${context.model.provider}/${context.model.id}` : void 0, tools: acknowledged });
248
256
  continue;
@@ -258,9 +266,12 @@ ${resolvedSystemPrompt}` } : void 0;
258
266
  send({ type: "prepared", requestId: frame.requestId, nativeSessionId });
259
267
  }
260
268
  } catch (error) {
269
+ context?.ui?.notify(`pi-subagents bridge: ${error.message}`, "error");
261
270
  socket.destroy(error);
262
271
  }
263
272
  });
273
+ socket.on("error", () => {
274
+ });
264
275
  socket.on("close", () => {
265
276
  if (client === socket) client = void 0;
266
277
  });
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  resolvePiLaunchToolPlan
3
- } from "./chunk-355ECEP2.js";
3
+ } from "./chunk-IH7LQVEE.js";
4
4
  import {
5
5
  listExternalJobProviders
6
6
  } from "./chunk-YYREO77V.js";
7
7
  import {
8
8
  mergeRuntimeAgents
9
- } from "./chunk-Z6TFJ6BR.js";
9
+ } from "./chunk-INWSUNI6.js";
10
10
  import {
11
11
  CODE_OWNED_EXTERNAL_CLI_ADAPTER_LABEL,
12
+ MAX_LISTED_AGENTS,
12
13
  THINKING_LEVELS,
13
14
  buildRuntimeName,
14
15
  defaultInheritProjectContext,
@@ -22,6 +23,8 @@ import {
22
23
  frontmatterNameForConfig,
23
24
  getProjectConfigDir,
24
25
  isCodeOwnedExternalCliAdapterId,
26
+ isUnavailableSubagentModel,
27
+ knownModelProviders,
25
28
  mergeAgentsForScope,
26
29
  mergeBuiltinAgentOverride,
27
30
  parseFrontmatter,
@@ -43,7 +46,7 @@ import {
43
46
  validatePermissionProfileName,
44
47
  validateSandboxProfileName,
45
48
  validateToolBudgetConfig
46
- } from "./chunk-V2KFIGFH.js";
49
+ } from "./chunk-XAC2XNAP.js";
47
50
  import {
48
51
  capabilityCeilingAgentRestrictionSources,
49
52
  isAgentAllowedByCapabilityCeiling,
@@ -360,6 +363,7 @@ function editableAgentConfig(agent) {
360
363
  const next = { ...config };
361
364
  if (!hasDeclaredField("model")) delete next.model;
362
365
  if (!hasDeclaredField("thinking")) delete next.thinking;
366
+ if (!hasDeclaredField("inheritGlobalContext")) next.inheritGlobalContext = false;
363
367
  return next;
364
368
  };
365
369
  const {
@@ -408,7 +412,7 @@ function editableAgentConfig(agent) {
408
412
  ...base.thinking !== void 0 && hasDeclaredField("thinking") ? { thinking: base.thinking } : {},
409
413
  systemPromptMode: base.systemPromptMode,
410
414
  inheritProjectContext: base.inheritProjectContext,
411
- inheritGlobalContext: base.inheritGlobalContext,
415
+ inheritGlobalContext: hasDeclaredField("inheritGlobalContext") && base.inheritGlobalContext,
412
416
  inheritSkills: base.inheritSkills,
413
417
  ...base.defaultContext !== void 0 ? { defaultContext: base.defaultContext } : {},
414
418
  ...base.acceptanceRole !== void 0 ? { acceptanceRole: base.acceptanceRole } : {},
@@ -816,7 +820,8 @@ function agentListMetadata(agent, providerNames2, externalCliAvailability) {
816
820
  function formatAgentListLine(agent, providerNames2) {
817
821
  return `- ${agent.name} (${agentListMetadata(agent, providerNames2)}): ${agent.description}`;
818
822
  }
819
- function formatAgentCapabilitiesLine(agent, providerNames2, externalCliAvailability) {
823
+ var UNAVAILABLE_MODEL_MARKER = "(unavailable in the active model registry)";
824
+ function formatAgentCapabilitiesLine(agent, providerNames2, externalCliAvailability, unavailableModels) {
820
825
  const declaredTools = [
821
826
  ...agent.tools ?? [],
822
827
  ...(agent.mcpDirectTools ?? []).map((tool) => `mcp:${tool}`)
@@ -832,6 +837,7 @@ function formatAgentCapabilitiesLine(agent, providerNames2, externalCliAvailabil
832
837
  if (agent.model !== void 0) {
833
838
  model = agent.model;
834
839
  if (agent.modelProvider && !agent.model.includes("/")) model = `${agent.modelProvider}/${agent.model}`;
840
+ if (unavailableModels.has(agent)) model = `${model} ${UNAVAILABLE_MODEL_MARKER}`;
835
841
  }
836
842
  const thinking = agent.thinking === false ? "off" : agent.thinking ?? "default";
837
843
  const machine = agent.machine ? `; Machine: ${agent.machine} (saved Herdr placement)` : "";
@@ -904,7 +910,7 @@ function agentCapabilityRow(agent, options) {
904
910
  aliases: agent.aliases ? [...agent.aliases] : void 0,
905
911
  runner: agentCapabilityRunner(agent, options.providerNames, options.externalCliAvailability),
906
912
  tools: agentCapabilityTools(agent),
907
- model: presentDetails({ value: agent.model, thinking: agent.thinking }),
913
+ model: presentDetails({ value: agent.model, thinking: agent.thinking, unavailable: options.unavailableModels.has(agent) || void 0 }),
908
914
  execution: presentDetails({ defaultAsync: agent.defaultAsync, timeoutMs: agent.defaultTimeoutMs }),
909
915
  acceptance: presentDetails({ policy: agent.defaultAcceptance, role: agent.acceptanceRole }),
910
916
  output: presentDetails({ path: agent.output, mode: agent.outputMode }),
@@ -914,8 +920,8 @@ function agentCapabilityRow(agent, options) {
914
920
  function agentCapabilitiesSnapshot(input) {
915
921
  return {
916
922
  agents: [
917
- ...input.agents.map((agent) => agentCapabilityRow(agent, { executable: true, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability })),
918
- ...input.restrictedAgents.map((agent) => agentCapabilityRow(agent, { executable: false, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability, restrictionSources: input.restrictedSources }))
923
+ ...input.agents.map((agent) => agentCapabilityRow(agent, { executable: true, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability, unavailableModels: input.unavailableModels })),
924
+ ...input.restrictedAgents.map((agent) => agentCapabilityRow(agent, { executable: false, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability, unavailableModels: input.unavailableModels, restrictionSources: input.restrictedSources }))
919
925
  ],
920
926
  restrictedCount: input.restrictedAgents.length,
921
927
  ...input.restrictedSources?.length ? { capabilityCeilingSources: [...input.restrictedSources] } : {}
@@ -952,6 +958,7 @@ function agentCapabilityDetails(input) {
952
958
  restrictedAgents: input.restrictedAgents,
953
959
  providerNames: input.providerNames,
954
960
  externalCliAvailability: input.externalCliAvailability,
961
+ unavailableModels: input.unavailableModels,
955
962
  restrictedSources: input.restrictedSources
956
963
  }))
957
964
  };
@@ -1036,7 +1043,8 @@ function handleList(params, ctx) {
1036
1043
  let scopedAgents = effectiveAgentsForScope(scope, d, ctx.runtimeAgentOwner, ctx.model?.provider);
1037
1044
  scopedAgents = scopedAgents.sort((a, b) => a.name.localeCompare(b.name));
1038
1045
  const capabilityCeiling = resolveCurrentSubagentCapabilityCeiling(ctx.piSessionId);
1039
- const visibleAgents = scopedAgents.filter((a) => !a.disabled);
1046
+ const search = typeof params.search === "string" ? params.search.trim().toLowerCase() : "";
1047
+ const visibleAgents = scopedAgents.filter((a) => !a.disabled && (!search || [a.name, a.description, ...a.aliases ?? []].some((text) => text.toLowerCase().includes(search))));
1040
1048
  const agents = visibleAgents.filter((a) => isAgentAllowedByCapabilityCeiling(a.name, capabilityCeiling));
1041
1049
  const restrictedAgents = visibleAgents.filter((a) => !isAgentAllowedByCapabilityCeiling(a.name, capabilityCeiling));
1042
1050
  const restrictedSources = capabilityCeilingAgentRestrictionSources(capabilityCeiling);
@@ -1049,12 +1057,19 @@ function handleList(params, ctx) {
1049
1057
  const providerNameSet = providerNames(providerStatus);
1050
1058
  const capabilityMode = params.capabilities === true;
1051
1059
  const externalCliAvailability = capabilityMode ? externalCliAvailabilityForAgents([...agents, ...restrictedAgents]) : void 0;
1052
- const formatLine = capabilityMode ? (agent, names) => formatAgentCapabilitiesLine(agent, names, externalCliAvailability) : formatAgentListLine;
1060
+ const availableModels = capabilityMode ? ctx.modelRegistry.getAvailable().map(toModelInfo) : [];
1061
+ const knownProviders = knownModelProviders(ctx.modelRegistry);
1062
+ const unavailableModels = new Set([...agents, ...restrictedAgents].filter((agent) => (agent.runner?.type ?? "pi") === "pi" && isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? ctx.model?.provider, knownProviders)));
1063
+ const formatLine = capabilityMode ? (agent, names) => formatAgentCapabilitiesLine(agent, names, externalCliAvailability, unavailableModels) : formatAgentListLine;
1064
+ const shownAgents = agents.slice(0, MAX_LISTED_AGENTS);
1065
+ const shownRestrictedAgents = restrictedAgents.slice(0, MAX_LISTED_AGENTS - shownAgents.length);
1066
+ const omittedCount = Math.max(0, agents.length + restrictedAgents.length - MAX_LISTED_AGENTS);
1053
1067
  const lines = [
1054
1068
  capabilityMode ? "Executable agents (capabilities):" : "Executable agents:",
1055
- ...formatAgentListSections(agents, providerNameSet, formatLine)
1069
+ ...formatAgentListSections(shownAgents, providerNameSet, formatLine)
1056
1070
  ];
1057
- appendRestrictedAgentLines({ lines, agents: restrictedAgents, sources: restrictedSources, providerNames: providerNameSet, formatLine });
1071
+ appendRestrictedAgentLines({ lines, agents: shownRestrictedAgents, sources: restrictedSources, providerNames: providerNameSet, formatLine });
1072
+ if (omittedCount > 0) lines.push("", `+${omittedCount} more; narrow with {action:"list", options:{search:"<term>"}}`);
1058
1073
  appendExternalJobRegistryLine(lines, [...agents, ...restrictedAgents], providerStatus);
1059
1074
  appendAgentDiagnosticLines(lines, d.agentDiagnostics);
1060
1075
  if (proactiveSuggestions.length) lines.push("", ...proactiveSuggestions);
@@ -1064,12 +1079,18 @@ function handleList(params, ctx) {
1064
1079
  restrictedAgents,
1065
1080
  providerNames: providerNameSet,
1066
1081
  externalCliAvailability: externalCliAvailability ?? /* @__PURE__ */ new Map(),
1082
+ unavailableModels,
1067
1083
  restrictedSources
1068
1084
  }));
1069
1085
  }
1086
+ function modelOverrideFile(override) {
1087
+ const scopes = override.fieldScopes?.model;
1088
+ const scope = scopes?.includes("project") ? "project" : scopes?.includes("user") ? "user" : override.scope;
1089
+ return { scope, path: override.paths?.[scope] ?? override.path };
1090
+ }
1070
1091
  function formatModelSource(agent, currentModel) {
1071
1092
  if (agent.override && agent.model !== agent.override.base.model) {
1072
- return `${agent.override.scope} override`;
1093
+ return `${modelOverrideFile(agent.override).scope} override`;
1073
1094
  }
1074
1095
  if (agent.modelSource?.type === "subagents.defaultModel" && agent.model === agent.modelSource.model) {
1075
1096
  return `${agent.modelSource.scope} defaultModel`;
@@ -1085,6 +1106,7 @@ function handleModels(params, ctx) {
1085
1106
  const discovered = discoverCatalog(ctx, ctx.cwd, ctx.model?.provider);
1086
1107
  const effectiveAgents = effectiveAgentsForScope(scope, discovered, ctx.runtimeAgentOwner, ctx.model?.provider).sort((a, b) => a.name.localeCompare(b.name));
1087
1108
  const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
1109
+ const knownProviders = knownModelProviders(ctx.modelRegistry);
1088
1110
  const currentModel = ctx.model ? { provider: ctx.model.provider, id: ctx.model.id } : void 0;
1089
1111
  const preferredProvider = ctx.model?.provider;
1090
1112
  const capabilityCeiling = resolveCurrentSubagentCapabilityCeiling(ctx.piSessionId);
@@ -1113,18 +1135,19 @@ function handleModels(params, ctx) {
1113
1135
  ];
1114
1136
  const modelEntries = selectedAgents.flatMap((agent) => requestedAgent ? [{ agent, name: requestedAgent }] : [{ agent, name: agent.name }, ...(agent.aliases ?? []).map((name) => ({ agent, name }))]);
1115
1137
  for (const { agent, name } of modelEntries) {
1116
- const resolvedModel = resolveSubagentModelOverride(agent.model, currentModel, availableModels, agent.modelProvider ?? preferredProvider);
1138
+ const resolvedModel = resolveSubagentModelOverride(agent.model, currentModel, availableModels, agent.modelProvider ?? preferredProvider, { knownProviders });
1139
+ const shownModel = resolvedModel === void 0 ? "(unresolved)" : (agent.runner?.type ?? "pi") === "pi" && isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? preferredProvider, knownProviders) ? `${resolvedModel} ${UNAVAILABLE_MODEL_MARKER}` : resolvedModel;
1117
1140
  const effectiveThinking = resolveEffectiveThinking(resolvedModel, agent.thinking) ?? (agent.thinking === false ? "off" : void 0);
1118
1141
  const source = `${formatModelSource(agent, currentModel)}${agent.disabled ? "; disabled" : ""}${isAgentAllowedByCapabilityCeiling(agent.name, capabilityCeiling) ? "" : "; restricted"}`;
1119
1142
  if (requestedAgent) {
1120
1143
  lines.push(`Agent: ${requestedAgent}`);
1121
1144
  lines.push("Effective model:");
1122
- lines.push(` ${resolvedModel ?? "(unresolved)"}`);
1145
+ lines.push(` ${shownModel}`);
1123
1146
  lines.push(`Source: ${source}`);
1124
1147
  lines.push(`Thinking: ${effectiveThinking ?? "default"}`);
1125
1148
  if (agent.override) {
1126
1149
  lines.push("Override file:");
1127
- lines.push(` ${agent.override.path}`);
1150
+ lines.push(` ${modelOverrideFile(agent.override).path}`);
1128
1151
  }
1129
1152
  if (agent.model && resolvedModel && agent.model !== resolvedModel) {
1130
1153
  lines.push("Requested model setting:");
@@ -1138,12 +1161,12 @@ function handleModels(params, ctx) {
1138
1161
  }
1139
1162
  lines.push(name);
1140
1163
  lines.push(" model:");
1141
- lines.push(` ${resolvedModel ?? "(unresolved)"}`);
1164
+ lines.push(` ${shownModel}`);
1142
1165
  lines.push(` source: ${source}`);
1143
1166
  lines.push(` thinking: ${effectiveThinking ?? "default"}`);
1144
1167
  if (agent.override) {
1145
1168
  lines.push(" override file:");
1146
- lines.push(` ${agent.override.path}`);
1169
+ lines.push(` ${modelOverrideFile(agent.override).path}`);
1147
1170
  }
1148
1171
  if (agent.model && resolvedModel && agent.model !== resolvedModel) {
1149
1172
  lines.push(" requested model setting:");
@@ -1228,7 +1251,7 @@ function handleCreate(params, ctx) {
1228
1251
  if (mw) warnings.push(mw);
1229
1252
  const sw = skillsWarning(ctx.cwd, agent);
1230
1253
  if (sw) warnings.push(sw);
1231
- fs.writeFileSync(targetPath, serializeAgent(agent), "utf-8");
1254
+ fs.writeFileSync(targetPath, serializeAgent(agent, { explicitInheritGlobalContext: hasKey(cfg, "inheritGlobalContext") }), "utf-8");
1232
1255
  ctx.onAgentsChanged?.();
1233
1256
  return result([`Created agent '${runtimeName}' at ${targetPath}.`, ...warnings].join("\n"));
1234
1257
  }