@ashx-j/lunr 0.2.18 → 0.2.20

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 (190) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.md +2 -2
  3. package/dist/builtin-extensions/ashxj-tui.d.ts +2 -2
  4. package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
  5. package/dist/builtin-extensions/ashxj-tui.js +11 -8
  6. package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
  7. package/dist/builtin-extensions/index.d.ts.map +1 -1
  8. package/dist/builtin-extensions/index.js +0 -2
  9. package/dist/builtin-extensions/index.js.map +1 -1
  10. package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts +6 -4
  11. package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts.map +1 -1
  12. package/dist/builtin-extensions/pi-intercom/broker/spawn.js +93 -49
  13. package/dist/builtin-extensions/pi-intercom/broker/spawn.js.map +1 -1
  14. package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
  15. package/dist/builtin-extensions/pi-intercom/index.js +351 -351
  16. package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
  17. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +2 -1
  18. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  19. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +80 -43
  20. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  21. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts +18 -8
  22. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
  23. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +36 -11
  24. package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
  25. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +4 -3
  26. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
  27. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +21 -12
  28. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
  29. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +7 -1
  30. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
  31. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +225 -15
  32. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
  33. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts +29 -0
  34. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts.map +1 -0
  35. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js +179 -0
  36. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js.map +1 -0
  37. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts +89 -0
  38. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts.map +1 -0
  39. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js +541 -0
  40. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js.map +1 -0
  41. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +9 -1
  42. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
  43. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +34 -9
  44. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
  45. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts.map +1 -1
  46. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js +1 -2
  47. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js.map +1 -1
  48. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts +2 -1
  49. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts.map +1 -1
  50. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js +35 -8
  51. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js.map +1 -1
  52. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +1 -1
  53. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
  54. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +3 -3
  55. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
  56. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts +1 -0
  57. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -1
  58. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +54 -38
  59. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js.map +1 -1
  60. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +3 -6
  61. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
  62. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +64 -5
  63. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
  64. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
  65. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +1 -0
  66. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
  67. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
  68. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +21 -8
  69. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
  70. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  71. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +62 -16
  72. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  73. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts +2 -0
  74. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts.map +1 -1
  75. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js +75 -18
  76. package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js.map +1 -1
  77. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +13 -1
  78. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
  79. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +67 -11
  80. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
  81. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
  82. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +5 -2
  83. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
  84. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
  85. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +13 -3
  86. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
  87. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts +3 -0
  88. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -1
  89. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +68 -11
  90. package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -1
  91. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts +12 -1
  92. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts.map +1 -1
  93. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js +21 -2
  94. package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js.map +1 -1
  95. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +16 -4
  96. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
  97. package/dist/builtin-extensions/pi-subagents/src/shared/types.js +1 -1
  98. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
  99. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +2 -0
  100. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
  101. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +24 -6
  102. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
  103. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +44 -4
  104. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
  105. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +227 -133
  106. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
  107. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts.map +1 -1
  108. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js +1 -1
  109. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js.map +1 -1
  110. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts +2 -13
  111. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts.map +1 -1
  112. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js +5 -91
  113. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js.map +1 -1
  114. package/dist/core/permissions.d.ts +1 -0
  115. package/dist/core/permissions.d.ts.map +1 -1
  116. package/dist/core/permissions.js +8 -4
  117. package/dist/core/permissions.js.map +1 -1
  118. package/dist/core/plan-mode.d.ts.map +1 -1
  119. package/dist/core/plan-mode.js +0 -5
  120. package/dist/core/plan-mode.js.map +1 -1
  121. package/dist/core/runtime-bridges.d.ts.map +1 -1
  122. package/dist/core/runtime-bridges.js +0 -2
  123. package/dist/core/runtime-bridges.js.map +1 -1
  124. package/dist/core/subagent-cancellation.d.ts +21 -0
  125. package/dist/core/subagent-cancellation.d.ts.map +1 -0
  126. package/dist/core/subagent-cancellation.js +53 -0
  127. package/dist/core/subagent-cancellation.js.map +1 -0
  128. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  129. package/dist/modes/interactive/components/assistant-message.js +12 -18
  130. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  131. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  132. package/dist/modes/interactive/components/tool-execution.js +12 -0
  133. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  134. package/dist/modes/interactive/interactive-mode.d.ts +1 -2
  135. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  136. package/dist/modes/interactive/interactive-mode.js +29 -22
  137. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  138. package/dist/node-runtime/{agent-session-services-35WNVGMR.js → agent-session-services-75JKASCW.js} +3 -3
  139. package/dist/node-runtime/{builtin-extensions-QATGXENO.js → builtin-extensions-X4JMM4ZS.js} +3 -3
  140. package/dist/node-runtime/{chunk-XATUM2HK.js → chunk-25I2BHAA.js} +1 -1
  141. package/dist/node-runtime/{chunk-MCUNIRD5.js → chunk-46ECNOLF.js} +477 -246
  142. package/dist/node-runtime/{chunk-J26TSGDL.js → chunk-6N22HULO.js} +8 -5
  143. package/dist/node-runtime/{chunk-NI6OTSBH.js → chunk-AL2FMKKM.js} +7 -7
  144. package/dist/node-runtime/chunk-AOFXZQKA.js +24 -0
  145. package/dist/node-runtime/chunk-BBUVIEZB.js +51 -0
  146. package/dist/node-runtime/{chunk-EBF6COVM.js → chunk-ELWEXVO5.js} +7 -7
  147. package/dist/node-runtime/{chunk-R5EDISSV.js → chunk-JHYKXIMM.js} +5 -2
  148. package/dist/node-runtime/{chunk-ATGA2WLC.js → chunk-JYNNB7DU.js} +397 -34
  149. package/dist/node-runtime/{chunk-ZBV7FAHG.js → chunk-K3646JTM.js} +17 -118
  150. package/dist/node-runtime/{chunk-PNJSG3IZ.js → chunk-LTYWTR3V.js} +1 -369
  151. package/dist/node-runtime/{chunk-G4P75AIS.js → chunk-QKFMBRAL.js} +47 -54
  152. package/dist/node-runtime/cli-runtime.js +1 -1
  153. package/dist/node-runtime/{command-AAV3YRR5.js → command-RBTRL55A.js} +1 -1
  154. package/dist/node-runtime/{gateway-OAC4OBBL.js → gateway-L4ANRTVE.js} +2 -2
  155. package/dist/node-runtime/index.js +10 -9
  156. package/dist/node-runtime/{interactive-mode-2SZUO53H.js → interactive-mode-HPUNH7SV.js} +5 -4
  157. package/dist/node-runtime/{interactive-view-S6J3QHEF.js → interactive-view-ILS6TAN5.js} +1 -1
  158. package/dist/node-runtime/{lunr-cron-AUUYP4N4.js → lunr-cron-NNYTWTGF.js} +2 -2
  159. package/dist/node-runtime/main.js +8 -8
  160. package/dist/node-runtime/{pi-intercom-EEMBGQID.js → pi-intercom-DDQMRNPJ.js} +96 -76
  161. package/dist/node-runtime/{pi-subagents-7YJ3I4VE.js → pi-subagents-T5WMMLBB.js} +1040 -318
  162. package/dist/node-runtime/rpc-entry.js +8 -8
  163. package/dist/node-runtime/{runtime-bridges-3RKBDLNA.js → runtime-bridges-NJQERQ72.js} +2 -4
  164. package/dist/node-runtime/{subagent-executor-5Q5A4HJ2.js → subagent-executor-SRFC26SJ.js} +168 -249
  165. package/docs/features.md +17 -3
  166. package/docs/keybindings.md +3 -1
  167. package/docs/settings.md +1 -1
  168. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  169. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  170. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  171. package/examples/extensions/gondolin/package-lock.json +2 -2
  172. package/examples/extensions/gondolin/package.json +1 -1
  173. package/examples/extensions/sandbox/package-lock.json +2 -2
  174. package/examples/extensions/sandbox/package.json +1 -1
  175. package/examples/extensions/with-deps/package-lock.json +2 -2
  176. package/examples/extensions/with-deps/package.json +1 -1
  177. package/package.json +4 -4
  178. package/dist/builtin-extensions/lunr-settings-tools.d.ts +0 -4
  179. package/dist/builtin-extensions/lunr-settings-tools.d.ts.map +0 -1
  180. package/dist/builtin-extensions/lunr-settings-tools.js +0 -120
  181. package/dist/builtin-extensions/lunr-settings-tools.js.map +0 -1
  182. package/dist/core/settings-tools-bridge.d.ts +0 -35
  183. package/dist/core/settings-tools-bridge.d.ts.map +0 -1
  184. package/dist/core/settings-tools-bridge.js +0 -56
  185. package/dist/core/settings-tools-bridge.js.map +0 -1
  186. package/dist/modes/interactive/injected-context.d.ts +0 -2
  187. package/dist/modes/interactive/injected-context.d.ts.map +0 -1
  188. package/dist/modes/interactive/injected-context.js +0 -7
  189. package/dist/modes/interactive/injected-context.js.map +0 -1
  190. package/dist/node-runtime/chunk-3NMWLTPV.js +0 -64
@@ -2,7 +2,7 @@ import { createRequire as __lunrRequire } from "node:module"; const require = __
2
2
  import {
3
3
  PLAN_MODE_WRITE_SPAWN_ERROR,
4
4
  resolveChildPermissions
5
- } from "./chunk-XATUM2HK.js";
5
+ } from "./chunk-25I2BHAA.js";
6
6
  import {
7
7
  createReadOnlyTools
8
8
  } from "./chunk-WKDK4C5P.js";
@@ -63,7 +63,7 @@ function resolveTempScopeId(options) {
63
63
  }
64
64
  return "shared";
65
65
  }
66
- var MAX_PARALLEL = Number.MAX_SAFE_INTEGER, MAX_CONCURRENCY = Number.MAX_SAFE_INTEGER, TEMP_ROOT_DIR = path.join(os.tmpdir(), `pi-subagents-${resolveTempScopeId()}`), RESULTS_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-results"), ASYNC_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-runs"), CHAIN_RUNS_DIR = path.join(TEMP_ROOT_DIR, "chain-runs"), TEMP_ARTIFACTS_DIR = path.join(TEMP_ROOT_DIR, "artifacts"), WIDGET_KEY = "subagent-async", SLASH_RESULT_TYPE = "subagent-slash-result", SLASH_TEXT_RESULT_TYPE = "subagent-slash-text-result", SLASH_SUBAGENT_REQUEST_EVENT = "subagent:slash:request", SLASH_SUBAGENT_STARTED_EVENT = "subagent:slash:started", SLASH_SUBAGENT_RESPONSE_EVENT = "subagent:slash:response", SLASH_SUBAGENT_UPDATE_EVENT = "subagent:slash:update", SLASH_SUBAGENT_CANCEL_EVENT = "subagent:slash:cancel", POLL_INTERVAL_MS = 250, MAX_WIDGET_JOBS = 4, DEFAULT_SUBAGENT_MAX_DEPTH = 2, SUBAGENT_ACTIONS = ["status", "interrupt", "resume", "steer", "stop", "append-step", "doctor", "watchdog.status", "watchdog.check", "watchdog.configure", "watchdog.recommend-model", "schedule", "schedule-list", "schedule-status", "schedule-cancel"];
66
+ var MAX_PARALLEL = Number.MAX_SAFE_INTEGER, MAX_CONCURRENCY = Number.MAX_SAFE_INTEGER, TEMP_ROOT_DIR = path.join(os.tmpdir(), `pi-subagents-${resolveTempScopeId()}`), RESULTS_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-results"), ASYNC_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-runs"), CHAIN_RUNS_DIR = path.join(TEMP_ROOT_DIR, "chain-runs"), TEMP_ARTIFACTS_DIR = path.join(TEMP_ROOT_DIR, "artifacts"), WIDGET_KEY = "subagent-async", SLASH_RESULT_TYPE = "subagent-slash-result", SLASH_TEXT_RESULT_TYPE = "subagent-slash-text-result", SLASH_SUBAGENT_REQUEST_EVENT = "subagent:slash:request", SLASH_SUBAGENT_STARTED_EVENT = "subagent:slash:started", SLASH_SUBAGENT_RESPONSE_EVENT = "subagent:slash:response", SLASH_SUBAGENT_UPDATE_EVENT = "subagent:slash:update", SLASH_SUBAGENT_CANCEL_EVENT = "subagent:slash:cancel", POLL_INTERVAL_MS = 250, MAX_WIDGET_JOBS = 4, DEFAULT_SUBAGENT_MAX_DEPTH = 2, SUBAGENT_ACTIONS = ["status", "interrupt", "resume", "steer", "stop", "append-step", "doctor", "watchdog.status", "watchdog.check", "watchdog.recommend-model", "schedule", "schedule-list", "schedule-status", "schedule-cancel"];
67
67
  var DEFAULT_FORK_PREAMBLE = "You are a delegated subagent running from a fork of the parent session. Treat the inherited conversation as reference-only context, not a live thread to continue. Do not continue or answer prior messages as if they are waiting for a reply. Your sole job is to execute the task below and return a focused result for that task using your tools.";
68
68
  function normalizeTopLevelParallelValue(value) {
69
69
  let parsed = typeof value == "number" ? value : typeof value == "string" ? Number(value) : NaN;
@@ -420,7 +420,22 @@ function formatModelThinking(model, thinking) {
420
420
  return [displayModel, formatThinkingLabel(model, thinking)].filter(Boolean).join(" \xB7 ");
421
421
  }
422
422
  function formatModelSelection(selection, resolvedModel, thinking) {
423
- return selection?.kind === "tier" && selection.tier ? [selection.tier, formatThinkingLabel(resolvedModel, thinking)].filter(Boolean).join(" \xB7 ") : formatModelThinking(resolvedModel, thinking);
423
+ if (selection?.kind === "tier" && selection.tier)
424
+ return [selection.tier, formatThinkingLabel(resolvedModel, thinking)].filter(Boolean).join(" \xB7 ");
425
+ let selectedModel = selection?.kind === "model" ? selection.model : void 0;
426
+ return formatModelThinking(selectedModel || resolvedModel, thinking);
427
+ }
428
+ function formatModelId(model) {
429
+ if (!model)
430
+ return "";
431
+ let displayModel = splitKnownThinkingSuffix(model).baseModel, slashIdx = displayModel.lastIndexOf("/");
432
+ return slashIdx !== -1 && (displayModel = displayModel.slice(slashIdx + 1)), displayModel;
433
+ }
434
+ function formatCompactModelBadge(selection, resolvedModel) {
435
+ if (selection?.kind === "tier" && selection.tier)
436
+ return selection.tier;
437
+ let explicit = selection?.kind === "model" && typeof selection.model == "string" && selection.model.trim() ? selection.model : void 0;
438
+ return formatModelId(explicit ?? resolvedModel);
424
439
  }
425
440
  function formatUsage(u, model) {
426
441
  let parts = [];
@@ -1968,9 +1983,9 @@ function buildPiArgs(input) {
1968
1983
  ...input.childAgentName ? { agent: input.childAgentName } : {}
1969
1984
  }] : []
1970
1985
  ];
1971
- if (env[SUBAGENT_PARENT_EVENT_SINK_ENV] = fanoutAuthorized ? input.parentEventSink ?? process.env[SUBAGENT_PARENT_EVENT_SINK_ENV] ?? "" : "", env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] = fanoutAuthorized ? input.parentControlInbox ?? process.env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] ?? "" : "", env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] = fanoutAuthorized ? input.parentRootRunId ?? process.env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] ?? input.runId ?? "" : "", env[SUBAGENT_PARENT_RUN_ID_ENV] = fanoutAuthorized ? parentRunId : "", env[SUBAGENT_PARENT_CHILD_INDEX_ENV] = fanoutAuthorized ? parentChildIndex : "", env[SUBAGENT_PARENT_DEPTH_ENV] = fanoutAuthorized ? String(parentDepth) : "", env[SUBAGENT_PARENT_PATH_ENV] = fanoutAuthorized ? encodeNestedPathEnv(parentPath) : "", env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] = fanoutAuthorized ? input.parentCapabilityToken ?? process.env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] ?? "" : "", env.PI_SUBAGENT_INHERIT_PROJECT_CONTEXT = input.inheritProjectContext ? "1" : "0", env.PI_SUBAGENT_INHERIT_SKILLS = input.inheritSkills ? "1" : "0", input.intercomSessionName && (env.PI_SUBAGENT_INTERCOM_SESSION_NAME = input.intercomSessionName), input.orchestratorIntercomTarget && (env[SUBAGENT_ORCHESTRATOR_TARGET_ENV] = input.orchestratorIntercomTarget), input.parentSessionId && (env[SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV] = input.parentSessionId), input.orchestratorIntercomTarget && input.parentSessionId && input.runId && input.childAgentName) {
1972
- let childIndex = input.childIndex ?? 0, channelDir = supervisorChannelDir(input.runId, input.childAgentName, childIndex);
1973
- fs9.mkdirSync(path10.join(channelDir, "requests"), { recursive: !0 }), fs9.mkdirSync(path10.join(channelDir, "replies"), { recursive: !0 }), env[SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV] = channelDir;
1986
+ if (env[SUBAGENT_PARENT_EVENT_SINK_ENV] = fanoutAuthorized ? input.parentEventSink ?? process.env[SUBAGENT_PARENT_EVENT_SINK_ENV] ?? "" : "", env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] = fanoutAuthorized ? input.parentControlInbox ?? process.env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] ?? "" : "", env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] = fanoutAuthorized ? input.parentRootRunId ?? process.env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] ?? input.runId ?? "" : "", env[SUBAGENT_PARENT_RUN_ID_ENV] = fanoutAuthorized ? parentRunId : "", env[SUBAGENT_PARENT_CHILD_INDEX_ENV] = fanoutAuthorized ? parentChildIndex : "", env[SUBAGENT_PARENT_DEPTH_ENV] = fanoutAuthorized ? String(parentDepth) : "", env[SUBAGENT_PARENT_PATH_ENV] = fanoutAuthorized ? encodeNestedPathEnv(parentPath) : "", env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] = fanoutAuthorized ? input.parentCapabilityToken ?? process.env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] ?? "" : "", env.PI_SUBAGENT_INHERIT_PROJECT_CONTEXT = input.inheritProjectContext ? "1" : "0", env.PI_SUBAGENT_INHERIT_SKILLS = input.inheritSkills ? "1" : "0", input.intercomSessionName && (env.PI_SUBAGENT_INTERCOM_SESSION_NAME = input.intercomSessionName), input.orchestratorIntercomTarget && (env[SUBAGENT_ORCHESTRATOR_TARGET_ENV] = input.orchestratorIntercomTarget), input.parentSessionId && (env[SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV] = input.parentSessionId), input.parentSessionId && input.runId && (input.childId || input.childAgentName)) {
1987
+ let childIndex = input.childIndex ?? 0, channelAgent = input.childId ?? input.childAgentName, channelDir = supervisorChannelDir(input.runId, channelAgent, childIndex);
1988
+ fs9.mkdirSync(path10.join(channelDir, "requests"), { recursive: !0 }), fs9.mkdirSync(path10.join(channelDir, "replies"), { recursive: !0 }), fs9.mkdirSync(path10.join(channelDir, "questions"), { recursive: !0 }), env[SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV] = channelDir, env[SUBAGENT_CHILD_INDEX_ENV] = String(childIndex);
1974
1989
  }
1975
1990
  input.runId && (env[SUBAGENT_RUN_ID_ENV] = input.runId), (input.childId || input.childAgentName) && (env[SUBAGENT_CHILD_AGENT_ENV] = input.childId ?? input.childAgentName), input.childIndex !== void 0 && (env[SUBAGENT_CHILD_INDEX_ENV] = String(input.childIndex)), input.mcpDirectTools?.length ? env.MCP_DIRECT_TOOLS = input.mcpDirectTools.join(",") : env.MCP_DIRECT_TOOLS = "__none__", input.structuredOutput && (env[STRUCTURED_OUTPUT_CAPTURE_ENV] = input.structuredOutput.outputPath, env[STRUCTURED_OUTPUT_SCHEMA_ENV] = input.structuredOutput.schemaPath), input.steerInboxDir && (env[SUBAGENT_STEER_INBOX_ENV] = input.steerInboxDir), input.steerCapabilityPath && (env[SUBAGENT_STEER_CAPABILITY_ENV] = input.steerCapabilityPath), input.steerAckDir && (env[SUBAGENT_STEER_ACK_DIR_ENV] = input.steerAckDir);
1976
1991
  let encodedToolBudget = encodeToolBudgetEnv(input.toolBudget);
@@ -1988,11 +2003,7 @@ function cleanupTempDir(tempDir) {
1988
2003
 
1989
2004
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js
1990
2005
  function splitThinkingSuffix(model) {
1991
- let colonIdx = model.lastIndexOf(":");
1992
- return colonIdx === -1 ? { baseModel: model, thinkingSuffix: "" } : {
1993
- baseModel: model.substring(0, colonIdx),
1994
- thinkingSuffix: model.substring(colonIdx)
1995
- };
2006
+ return splitKnownThinkingSuffix(model);
1996
2007
  }
1997
2008
  var INHERIT_MODEL = "inherit";
1998
2009
  function normalizeModelSegment(segment) {
@@ -2120,14 +2131,61 @@ function resolveRequiredTierModel(tier, availableModels, preferredProvider) {
2120
2131
  throw new Error(`Model tier '${String(tier)}' resolves to '${baseModel}', but that model is unavailable or unauthenticated. Configure an available model in /settings.`);
2121
2132
  return `${resolvedBase}${thinkingSuffix}`;
2122
2133
  }
2134
+ function requestedModelString(model) {
2135
+ return typeof model == "string" && model.trim() && model.trim() !== INHERIT_MODEL ? model.trim() : void 0;
2136
+ }
2123
2137
  function requestedTier(tier) {
2124
2138
  return tier === "light" || tier === "standard" || tier === "heavy" ? tier : void 0;
2125
2139
  }
2140
+ function parseExplicitThinking(value, pathLabel = "thinking") {
2141
+ if (value !== void 0) {
2142
+ if (value === !1 || value === "off")
2143
+ return "off";
2144
+ if (typeof value != "string" || !THINKING_LEVELS.includes(value))
2145
+ throw new Error(`${pathLabel} must be one of ${THINKING_LEVELS.join(", ")}.`);
2146
+ return value;
2147
+ }
2148
+ }
2126
2149
  function captureModelSelection(input) {
2127
- let tier = requestedTier(input.tier);
2128
- if (!tier)
2129
- throw new Error('Every subagent execution requires tier: "light", "standard", or "heavy".');
2130
- return { kind: "tier", tier };
2150
+ let model = typeof input.model == "string" ? input.model.trim() : "", hasModel = !!model, tier = requestedTier(input.tier);
2151
+ if (hasModel && model === INHERIT_MODEL)
2152
+ throw new Error('model "inherit" is not supported; choose tier: "light", "standard", or "heavy", or an explicit provider/model.');
2153
+ if (hasModel && tier)
2154
+ throw new Error("Choose exactly one of tier or model; do not pass both.");
2155
+ if (hasModel)
2156
+ return { kind: "model", model };
2157
+ if (tier)
2158
+ return { kind: "tier", tier };
2159
+ throw new Error('Every executable child requires tier: "light", "standard", or "heavy", or an explicit model when the user names one.');
2160
+ }
2161
+ function resolveRequiredExplicitModel(model, availableModels, preferredProvider, thinking) {
2162
+ let requested = requestedModelString(model);
2163
+ if (!requested)
2164
+ throw new Error('Explicit model selection requires model as "provider/id".');
2165
+ if (!availableModels?.length)
2166
+ throw new Error(`Model '${requested}' cannot launch because no authenticated models are available.`);
2167
+ let { baseModel, thinkingSuffix } = splitThinkingSuffix(requested), resolvedBase = resolveBaseModelCandidate(baseModel, availableModels, preferredProvider);
2168
+ if (!resolvedBase)
2169
+ throw new Error(`Model '${baseModel}' is unavailable or unauthenticated. Choose an available provider/model or a configured tier.`);
2170
+ let fromSuffix = thinkingSuffix ? thinkingSuffix.slice(1) : void 0, fromParam = parseExplicitThinking(thinking);
2171
+ if (fromSuffix && fromParam && fromSuffix !== fromParam)
2172
+ throw new Error(`Conflicting thinking levels '${fromSuffix}' and '${fromParam}' for model '${requested}'.`);
2173
+ let level = fromParam ?? fromSuffix;
2174
+ if (!level)
2175
+ return resolvedBase;
2176
+ let info = availableModels.find((entry) => entry.fullId === resolvedBase), supported = getSupportedThinkingLevels(info);
2177
+ if (!supported.includes(level))
2178
+ throw new Error(`Thinking level '${level}' is not supported by '${resolvedBase}'. Supported: ${supported.join(", ") || "none"}.`);
2179
+ return applyThinkingSuffix(resolvedBase, level, !0) ?? resolvedBase;
2180
+ }
2181
+ function resolveExecutableChildModel(input) {
2182
+ let selection = input.modelSelection ?? captureModelSelection({ model: input.model, tier: input.tier });
2183
+ if (selection.kind === "tier") {
2184
+ if (input.thinking !== void 0)
2185
+ throw new Error("thinking is only valid with an explicit model; tier children use the configured tier thinking level.");
2186
+ return resolveRequiredTierModel(selection.tier, input.availableModels, input.preferredProvider);
2187
+ }
2188
+ return resolveRequiredExplicitModel(input.model, input.availableModels, input.preferredProvider, input.thinking);
2131
2189
  }
2132
2190
  function buildModelCandidates(primaryModel, fallbackModels, availableModels, preferredProvider, options) {
2133
2191
  let seen = /* @__PURE__ */ new Set(), candidates = [], rawCandidates = [primaryModel, ...fallbackModels ?? []];
@@ -2272,12 +2330,24 @@ function optionalCount(value) {
2272
2330
  function isModelSelection(value) {
2273
2331
  if (!value || typeof value != "object")
2274
2332
  return !1;
2275
- if (value.kind === "tier") {
2333
+ let kind = value.kind;
2334
+ if (kind === "model")
2335
+ return !0;
2336
+ if (kind === "tier") {
2276
2337
  let tier = value.tier;
2277
2338
  return tier === "light" || tier === "standard" || tier === "heavy";
2278
2339
  }
2279
2340
  return !1;
2280
2341
  }
2342
+ function parseThinking(value, pathLabel) {
2343
+ if (value !== void 0) {
2344
+ if (value === !1)
2345
+ return "off";
2346
+ if (typeof value == "string" && THINKING_LEVELS.includes(value))
2347
+ return value;
2348
+ throw new Error(`${pathLabel}.thinking must be one of ${THINKING_LEVELS.join(", ")}.`);
2349
+ }
2350
+ }
2281
2351
  function normalizeChildSpec(input, options) {
2282
2352
  let pathLabel = options.pathLabel ?? "task", description = validateChildDescription(input.description, `${pathLabel}.description`), task = typeof input.task == "string" && input.task.trim() ? input.task : options.defaultTask;
2283
2353
  if (typeof task != "string" || !task.trim())
@@ -2285,21 +2355,40 @@ function normalizeChildSpec(input, options) {
2285
2355
  let requested = parseChildPermissionsInput(input.permissions, `${pathLabel}.permissions`), resolved = resolveChildPermissions(options.parentMode, requested);
2286
2356
  if (!resolved.ok)
2287
2357
  throw new Error(resolved.error || PLAN_MODE_WRITE_SPAWN_ERROR);
2288
- if (input.model !== void 0 && !isModelSelection(input.modelSelection))
2289
- throw new Error(`${pathLabel}.model is not supported for executable children; choose tier: "light", "standard", or "heavy".`);
2290
- let selectedTier = isModelSelection(input.modelSelection) ? input.modelSelection.tier : input.tier;
2291
- if (selectedTier !== "light" && selectedTier !== "standard" && selectedTier !== "heavy")
2292
- throw new Error(`${pathLabel}.tier is required and must be "light", "standard", or "heavy".`);
2293
- let tier = selectedTier, outputMode = input.outputMode === "inline" || input.outputMode === "file-only" ? input.outputMode : void 0, modelSelection = isModelSelection(input.modelSelection) ? input.modelSelection : captureModelSelection({ tier });
2358
+ let preservedSelection = isModelSelection(input.modelSelection) ? input.modelSelection : void 0, rawModel = optionalString(input.model);
2359
+ if (rawModel === INHERIT_MODEL)
2360
+ throw new Error(`${pathLabel}.model "inherit" is not supported; choose tier or an explicit provider/model.`);
2361
+ let modelSelection, tier, model, thinking;
2362
+ if (preservedSelection)
2363
+ if (modelSelection = preservedSelection, modelSelection.kind === "tier") {
2364
+ if (tier = modelSelection.tier, model = void 0, input.thinking !== void 0)
2365
+ throw new Error(`${pathLabel}.thinking is only valid with an explicit model selection.`);
2366
+ } else {
2367
+ if (model = rawModel ?? optionalString(modelSelection.model), !model)
2368
+ throw new Error(`${pathLabel}.model is required when modelSelection.kind is "model".`);
2369
+ modelSelection.model || (modelSelection = { kind: "model", model }), thinking = parseThinking(input.thinking, pathLabel);
2370
+ }
2371
+ else if (options.resolvedModelIsRuntime) {
2372
+ let selectedTier = input.tier === "light" || input.tier === "standard" || input.tier === "heavy" ? input.tier : void 0;
2373
+ if (!selectedTier)
2374
+ throw new Error(`${pathLabel}.tier is required to resume a child without a stored modelSelection.`);
2375
+ modelSelection = { kind: "tier", tier: selectedTier }, tier = selectedTier, model = void 0;
2376
+ } else if (modelSelection = captureModelSelection({ model: input.model, tier: input.tier }), modelSelection.kind === "tier") {
2377
+ if (tier = modelSelection.tier, model = void 0, input.thinking !== void 0)
2378
+ throw new Error(`${pathLabel}.thinking is only valid with an explicit model selection.`);
2379
+ } else
2380
+ model = rawModel, !modelSelection.model && model && (modelSelection = { kind: "model", model }), thinking = parseThinking(input.thinking, pathLabel);
2381
+ let outputMode = input.outputMode === "inline" || input.outputMode === "file-only" ? input.outputMode : void 0;
2294
2382
  return {
2295
2383
  childId: options.childId ?? allocateChildId(options.runId, options.index),
2296
2384
  task,
2297
2385
  description,
2298
2386
  requestedPermissions: resolved.requested,
2299
2387
  effectivePermissions: resolved.effective,
2300
- model: optionalString(input.model),
2388
+ model,
2301
2389
  tier,
2302
2390
  modelSelection,
2391
+ thinking,
2303
2392
  skill: optionalSkill(input.skill),
2304
2393
  cwd: optionalString(input.cwd),
2305
2394
  output: optionalOutput(input.output),
@@ -3896,7 +3985,7 @@ var LEVEL_RANK = {
3896
3985
  "diff-summary",
3897
3986
  "review-findings",
3898
3987
  "manual-notes"
3899
- ]), ACCEPTANCE_CONFIG_KEYS = /* @__PURE__ */ new Set(["level", "criteria", "evidence", "verify", "review", "stopRules", "reason"]), ACCEPTANCE_GATE_KEYS = /* @__PURE__ */ new Set(["id", "must", "evidence", "severity"]), ACCEPTANCE_VERIFY_KEYS = /* @__PURE__ */ new Set(["id", "command", "timeoutMs", "cwd", "env", "allowFailure"]), ACCEPTANCE_REVIEW_KEYS = /* @__PURE__ */ new Set(["agent", "focus", "required"]), EXPLICIT_REVIEWED_UNAVAILABLE = "cannot be requested explicitly because this run cannot supply an independent reviewer result; use checked/verified and orchestrate the reviewer separately, or omit acceptance for read-only review tasks.";
3988
+ ]), ACCEPTANCE_CONFIG_KEYS = /* @__PURE__ */ new Set(["level", "criteria", "evidence", "verify", "review", "stopRules", "reason"]), PERSISTED_ACCEPTANCE_KEYS = /* @__PURE__ */ new Set([...ACCEPTANCE_CONFIG_KEYS, "explicit", "inferredReason"]), ACCEPTANCE_GATE_KEYS = /* @__PURE__ */ new Set(["id", "must", "evidence", "severity"]), ACCEPTANCE_VERIFY_KEYS = /* @__PURE__ */ new Set(["id", "command", "timeoutMs", "cwd", "env", "allowFailure"]), ACCEPTANCE_REVIEW_KEYS = /* @__PURE__ */ new Set(["agent", "focus", "required"]), EXPLICIT_REVIEWED_UNAVAILABLE = "cannot be requested explicitly because this run cannot supply an independent reviewer result; use checked/verified and orchestrate the reviewer separately, or omit acceptance for read-only review tasks.", RESOLVED_LEVELS = /* @__PURE__ */ new Set(["none", "attested", "checked", "verified", "reviewed"]);
3900
3989
  function normalizeLevel(level) {
3901
3990
  return level ?? "auto";
3902
3991
  }
@@ -3946,18 +4035,25 @@ function normalizeAcceptanceInput(input) {
3946
4035
  function explicitAcceptanceCanDisable(explicit) {
3947
4036
  return explicit.level === "none" && typeof explicit.reason == "string" && explicit.reason.trim().length > 0;
3948
4037
  }
3949
- function validateAcceptanceInput(input, pathLabel = "acceptance") {
4038
+ function validateAcceptanceValue(input, pathLabel, mode) {
3950
4039
  let errors = [];
3951
- if (input === void 0 || input === !1)
4040
+ if (input === void 0)
3952
4041
  return errors;
3953
- if (typeof input == "string")
3954
- return VALID_LEVELS.has(input) ? input === "none" ? errors.push(`${pathLabel} level "none" requires a reason; use { level: "none", reason: "..." }.`) : input === "reviewed" && errors.push(`${pathLabel} ${EXPLICIT_REVIEWED_UNAVAILABLE}`) : errors.push(`${pathLabel} has invalid level '${input}'.`), errors;
3955
- if (!input || typeof input != "object" || Array.isArray(input))
3956
- return errors.push(`${pathLabel} must be a string level, false, or an object.`), errors;
3957
- let value = input;
4042
+ if (mode === "persisted") {
4043
+ if (!input || typeof input != "object" || Array.isArray(input))
4044
+ return errors.push(`${pathLabel} must be a resolved acceptance object.`), errors;
4045
+ } else {
4046
+ if (input === !1)
4047
+ return errors;
4048
+ if (typeof input == "string")
4049
+ return VALID_LEVELS.has(input) ? input === "none" ? errors.push(`${pathLabel} level "none" requires a reason; use { level: "none", reason: "..." }.`) : input === "reviewed" && errors.push(`${pathLabel} ${EXPLICIT_REVIEWED_UNAVAILABLE}`) : errors.push(`${pathLabel} has invalid level '${input}'.`), errors;
4050
+ if (!input || typeof input != "object" || Array.isArray(input))
4051
+ return errors.push(`${pathLabel} must be a string level, false, or an object.`), errors;
4052
+ }
4053
+ let value = input, allowedKeys = mode === "persisted" ? PERSISTED_ACCEPTANCE_KEYS : ACCEPTANCE_CONFIG_KEYS;
3958
4054
  for (let key of Object.keys(value))
3959
- ACCEPTANCE_CONFIG_KEYS.has(key) || errors.push(`${pathLabel}.${key} is not supported.`);
3960
- if (value.level !== void 0 && (typeof value.level != "string" || !VALID_LEVELS.has(value.level)) && errors.push(`${pathLabel}.level must be one of auto, none, attested, checked, verified, reviewed.`), value.level === "none" && (typeof value.reason != "string" || !value.reason.trim()) && errors.push(`${pathLabel}.reason is required when level is none.`), value.level === "reviewed" && errors.push(`${pathLabel}.level ${EXPLICIT_REVIEWED_UNAVAILABLE}`), value.reason !== void 0 && typeof value.reason != "string" && errors.push(`${pathLabel}.reason must be a string.`), value.criteria !== void 0 && !Array.isArray(value.criteria) && errors.push(`${pathLabel}.criteria must be an array.`), Array.isArray(value.criteria)) {
4055
+ allowedKeys.has(key) || errors.push(`${pathLabel}.${key} is not supported.`);
4056
+ if (mode === "persisted" ? (typeof value.level != "string" || !RESOLVED_LEVELS.has(value.level)) && errors.push(`${pathLabel}.level must be one of none, attested, checked, verified, reviewed.`) : value.level !== void 0 && (typeof value.level != "string" || !VALID_LEVELS.has(value.level)) && errors.push(`${pathLabel}.level must be one of auto, none, attested, checked, verified, reviewed.`), value.level === "none" && (typeof value.reason != "string" || !value.reason.trim()) && errors.push(`${pathLabel}.reason is required when level is none.`), mode === "launch" && value.level === "reviewed" && errors.push(`${pathLabel}.level ${EXPLICIT_REVIEWED_UNAVAILABLE}`), mode === "persisted" && (value.explicit !== void 0 && typeof value.explicit != "boolean" && errors.push(`${pathLabel}.explicit must be a boolean.`), value.inferredReason !== void 0 && (!Array.isArray(value.inferredReason) || value.inferredReason.some((item) => typeof item != "string")) && errors.push(`${pathLabel}.inferredReason must be an array of strings.`)), value.reason !== void 0 && typeof value.reason != "string" && errors.push(`${pathLabel}.reason must be a string.`), value.criteria !== void 0 && !Array.isArray(value.criteria) && errors.push(`${pathLabel}.criteria must be an array.`), Array.isArray(value.criteria)) {
3961
4057
  let criterionIds = /* @__PURE__ */ new Set();
3962
4058
  for (let [index, criterion] of value.criteria.entries()) {
3963
4059
  if (typeof criterion == "string")
@@ -4017,6 +4113,29 @@ function validateAcceptanceInput(input, pathLabel = "acceptance") {
4017
4113
  typeof item != "string" && errors.push(`${pathLabel}.stopRules[${index}] must be a string.`);
4018
4114
  return errors;
4019
4115
  }
4116
+ function validateAcceptanceInput(input, pathLabel = "acceptance") {
4117
+ return validateAcceptanceValue(input, pathLabel, "launch");
4118
+ }
4119
+ function validatePersistedAcceptance(input, pathLabel = "acceptance") {
4120
+ return validateAcceptanceValue(input, pathLabel, "persisted");
4121
+ }
4122
+ function restorePersistedAcceptance(input, pathLabel = "acceptance") {
4123
+ let errors = validatePersistedAcceptance(input, pathLabel);
4124
+ if (errors.length > 0)
4125
+ throw new Error(errors.join(" "));
4126
+ let value = input, evidence = Array.isArray(value.evidence) ? unique(value.evidence.filter((item) => VALID_EVIDENCE.has(item))) : [];
4127
+ return {
4128
+ level: value.level,
4129
+ explicit: value.explicit === !0,
4130
+ inferredReason: Array.isArray(value.inferredReason) ? value.inferredReason.filter((item) => typeof item == "string") : [],
4131
+ criteria: normalizeCriteria(value.criteria, evidence),
4132
+ evidence,
4133
+ verify: Array.isArray(value.verify) ? value.verify : [],
4134
+ review: value.review,
4135
+ stopRules: Array.isArray(value.stopRules) ? value.stopRules.filter((item) => typeof item == "string") : [],
4136
+ ...typeof value.reason == "string" ? { reason: value.reason } : {}
4137
+ };
4138
+ }
4020
4139
  function validateExecutionAcceptance(input) {
4021
4140
  let errors = validateAcceptanceInput(input.acceptance, "acceptance");
4022
4141
  for (let [index, task] of (input.tasks ?? []).entries())
@@ -4038,9 +4157,11 @@ function normalizeCriteria(criteria, evidence) {
4038
4157
  }
4039
4158
  function resolveEffectiveAcceptance(input) {
4040
4159
  let explicit = normalizeAcceptanceInput(input.explicit), inferred = inferLevel(input), explicitLevel = normalizeLevel(explicit.level), level = explicitAcceptanceCanDisable(explicit) ? "none" : explicitLevel === "auto" ? inferred.level : LEVEL_RANK[explicitLevel] >= LEVEL_RANK[inferred.level] ? explicitLevel : inferred.level, evidence = unique([...level === inferred.level ? inferred.evidence : requiredEvidenceForLevel(level), ...explicit.evidence ?? []]), criteria = normalizeCriteria(explicit.criteria?.length ? explicit.criteria : inferred.criteria, evidence), review = explicit.review !== void 0 ? explicit.review : inferred.review;
4041
- return level === "reviewed" && input.explicit !== void 0 && explicitLevel !== "reviewed" && explicit.review === void 0 && review && review !== !1 && (review = { ...review, required: !1 }), {
4160
+ level === "reviewed" && input.explicit !== void 0 && explicitLevel !== "reviewed" && explicit.review === void 0 && review && review !== !1 && (review = { ...review, required: !1 });
4161
+ let parentRequestedLevel = input.explicit === void 0 || explicitLevel === "auto" ? void 0 : explicitLevel;
4162
+ return {
4042
4163
  level,
4043
- explicit: input.explicit !== void 0,
4164
+ explicit: parentRequestedLevel === level,
4044
4165
  inferredReason: inferred.reasons,
4045
4166
  criteria,
4046
4167
  evidence,
@@ -4663,132 +4784,36 @@ function shouldAbortForTurnBudget(budget, turnCount, terminalAssistantStop) {
4663
4784
  return turnCount < hardLimit ? !1 : turnCount > hardLimit ? !0 : !terminalAssistantStop;
4664
4785
  }
4665
4786
 
4666
- // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js
4667
- import * as fs14 from "node:fs";
4668
- import * as os7 from "node:os";
4669
- import * as path15 from "node:path";
4670
- var NATIVE_INTERCOM_EXTENSION_DIR = "native:pi-subagents-supervisor-channel";
4671
- function defaultAgentDir() {
4672
- return getAgentDir();
4673
- }
4674
- function defaultSubagentConfigDir(agentDir = defaultAgentDir()) {
4675
- return path15.join(agentDir, "extensions", "subagent");
4676
- }
4677
- var DEFAULT_INTERCOM_TARGET_PREFIX = "subagent-chat", INTERCOM_BRIDGE_MARKER = "Intercom orchestration channel:", DEFAULT_INTERCOM_BRIDGE_TEMPLATE = `The inherited thread is reference-only. Do not continue that conversation or send questions, status updates, or completion handoffs to the supervisor in normal assistant text.
4678
-
4679
- Use contact_supervisor first. It resolves the supervisor session "{orchestratorTarget}" and run metadata automatically.
4680
- - Need a decision, blocked, approval, or product/API/scope ambiguity: contact_supervisor({ reason: "need_decision", message: "<question>" })
4681
- - Need structured supervisor input rather than a freeform reply: contact_supervisor({ reason: "interview_request", message: "<what input is needed>", interview: { title: "...", questions: [] } })
4682
- - After contact_supervisor with reason "need_decision" or "interview_request", stay alive and continue only after the reply arrives. Do not finish your final response with a choose-one question.
4683
- - Do not ask for clarification when the only conflict is review-only/no-edit versus progress-writing or artifact-writing instructions. If an output path is configured but no write-capable tool is available, return the complete artifact in your final response; the runtime will persist it. Do not contact the supervisor merely because you cannot write that output path directly.
4684
- - Meaningful progress or unexpected discoveries that change the plan: contact_supervisor({ reason: "progress_update", message: "UPDATE: <summary>" })
4685
- - Generic intercom is lower-level plumbing/fallback only: intercom({ action: "ask", to: "{orchestratorTarget}", message: "<question>" })
4686
-
4687
- Do not use contact_supervisor or intercom for routine completion handoffs. If no coordination is needed, return a focused task result.`;
4688
- function resolveIntercomSessionTarget(sessionName, sessionId) {
4689
- let trimmedName = sessionName?.trim();
4690
- if (trimmedName)
4691
- return trimmedName;
4692
- let normalizedSessionId = sessionId.startsWith("session-") ? sessionId.slice(8) : sessionId;
4693
- return `${DEFAULT_INTERCOM_TARGET_PREFIX}-${normalizedSessionId.slice(0, 8)}`;
4694
- }
4695
- function sanitizeIntercomTargetPart(value) {
4696
- return value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || "agent";
4697
- }
4698
- function resolveSubagentIntercomTarget(runId, agent, index) {
4699
- let stepSuffix = index !== void 0 ? `-${index + 1}` : "";
4700
- return `subagent-${sanitizeIntercomTargetPart(agent)}-${sanitizeIntercomTargetPart(runId)}${stepSuffix}`;
4701
- }
4702
- function resolveIntercomBridgeMode(value) {
4703
- return value === "off" || value === "always" || value === "fork-only" ? value : "always";
4704
- }
4705
- function resolveIntercomBridgeConfig(value) {
4706
- return !value || typeof value != "object" || Array.isArray(value) ? { mode: "always", instructionFile: "" } : {
4707
- mode: resolveIntercomBridgeMode(value.mode),
4708
- instructionFile: typeof value.instructionFile == "string" ? value.instructionFile : ""
4709
- };
4710
- }
4711
- function expandTilde(filePath) {
4712
- return filePath.startsWith("~/") ? path15.join(os7.homedir(), filePath.slice(2)) : filePath;
4713
- }
4714
- function resolveInstructionTemplate(instructionFile, settingsDir) {
4715
- if (!instructionFile)
4716
- return DEFAULT_INTERCOM_BRIDGE_TEMPLATE;
4717
- let expandedPath = expandTilde(instructionFile), resolvedPath = path15.isAbsolute(expandedPath) ? expandedPath : path15.resolve(settingsDir, expandedPath);
4718
- try {
4719
- return fs14.readFileSync(resolvedPath, "utf-8");
4720
- } catch (error) {
4721
- return console.warn(`Failed to read intercom bridge instructionFile at '${resolvedPath}'. Using default instructions.`, error), DEFAULT_INTERCOM_BRIDGE_TEMPLATE;
4722
- }
4723
- }
4724
- function buildIntercomBridgeInstruction(orchestratorTarget, template) {
4725
- let instruction = template.replaceAll("{orchestratorTarget}", orchestratorTarget).trim();
4726
- return instruction.startsWith(INTERCOM_BRIDGE_MARKER) ? instruction : `${INTERCOM_BRIDGE_MARKER}
4727
- ${instruction}`;
4728
- }
4729
- function inactiveReason(mode, context, orchestratorTarget) {
4730
- if (mode === "off")
4731
- return "bridge mode is off";
4732
- if (mode === "fork-only" && context !== "fork")
4733
- return "bridge mode is fork-only and context is not fork";
4734
- if (!orchestratorTarget)
4735
- return "orchestrator target is not available";
4736
- }
4737
- function diagnoseIntercomBridge(input) {
4738
- let mode = resolveIntercomBridgeConfig(input.config).mode, orchestratorTarget = input.orchestratorTarget?.trim(), wantsIntercom = mode !== "off" && !(mode === "fork-only" && input.context !== "fork"), reason = inactiveReason(mode, input.context, orchestratorTarget);
4739
- return {
4740
- active: reason === void 0,
4741
- mode,
4742
- wantsIntercom,
4743
- supervisorChannelAvailable: !0,
4744
- extensionDir: NATIVE_INTERCOM_EXTENSION_DIR,
4745
- ...orchestratorTarget ? { orchestratorTarget } : {},
4746
- ...reason ? { reason } : {}
4747
- };
4748
- }
4749
- function resolveIntercomBridge(input) {
4750
- let config = resolveIntercomBridgeConfig(input.config), mode = config.mode, orchestratorTarget = input.orchestratorTarget?.trim(), agentDir = path15.resolve(input.agentDir ?? defaultAgentDir()), settingsDir = path15.resolve(input.settingsDir ?? defaultSubagentConfigDir(agentDir)), defaultInstruction = buildIntercomBridgeInstruction(orchestratorTarget || "{orchestratorTarget}", DEFAULT_INTERCOM_BRIDGE_TEMPLATE);
4751
- return inactiveReason(mode, input.context, orchestratorTarget) || !orchestratorTarget ? { active: !1, mode, extensionDir: NATIVE_INTERCOM_EXTENSION_DIR, instruction: defaultInstruction } : {
4752
- active: !0,
4753
- mode,
4754
- orchestratorTarget,
4755
- extensionDir: NATIVE_INTERCOM_EXTENSION_DIR,
4756
- instruction: buildIntercomBridgeInstruction(orchestratorTarget, resolveInstructionTemplate(config.instructionFile, settingsDir))
4757
- };
4758
- }
4759
- function applyIntercomBridgeToAgent(agent, bridge) {
4760
- if (!bridge.active || !bridge.orchestratorTarget)
4761
- return agent;
4762
- let bridgeTools = ["intercom", "contact_supervisor"], tools = agent.tools ? [...agent.tools, ...bridgeTools.filter((tool) => !agent.tools?.includes(tool))] : agent.tools, instruction = bridge.instruction, trimmedPrompt = agent.systemPrompt?.trim() || "", systemPrompt = trimmedPrompt.includes(INTERCOM_BRIDGE_MARKER) ? trimmedPrompt : trimmedPrompt ? `${trimmedPrompt}
4763
-
4764
- ${instruction}` : instruction;
4765
- return tools === agent.tools && systemPrompt === agent.systemPrompt ? agent : {
4766
- ...agent,
4767
- tools,
4768
- systemPrompt
4769
- };
4770
- }
4771
-
4772
4787
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/control-channel.js
4773
4788
  import { randomUUID as randomUUID3 } from "node:crypto";
4774
- import * as fs15 from "node:fs";
4775
- import * as path16 from "node:path";
4789
+ import * as fs14 from "node:fs";
4790
+ import * as path15 from "node:path";
4776
4791
  var INTERRUPT_SIGNAL = process.platform === "win32" ? "SIGBREAK" : "SIGUSR2", STEER_REQUESTS_DIR = "steer-requests";
4777
- var STEER_ACKS_DIR = "steer-acks", STEER_INBOX_CLOSED_FILE = "steer-inbox-closed.json", MAX_STEER_MESSAGE_BYTES = 128 * 1024, MAX_STEER_REQUEST_ID_LENGTH = 256;
4792
+ var STEER_CAPABILITIES_DIR = "steer-capabilities", STEER_ACKS_DIR = "steer-acks", STEER_INBOX_CLOSED_FILE = "steer-inbox-closed.json", MAX_STEER_MESSAGE_BYTES = 128 * 1024, MAX_STEER_REQUEST_ID_LENGTH = 256;
4778
4793
  function controlInboxDir(asyncDir) {
4779
- return path16.join(asyncDir, "control");
4794
+ return path15.join(asyncDir, "control");
4780
4795
  }
4781
4796
  function interruptRequestPath(asyncDir) {
4782
- return path16.join(controlInboxDir(asyncDir), "interrupt.json");
4797
+ return path15.join(controlInboxDir(asyncDir), "interrupt.json");
4783
4798
  }
4784
4799
  function stopRequestPath(asyncDir) {
4785
- return path16.join(controlInboxDir(asyncDir), "stop.json");
4800
+ return path15.join(controlInboxDir(asyncDir), "stop.json");
4786
4801
  }
4787
4802
  function steerRequestsDir(asyncDir) {
4788
- return path16.join(controlInboxDir(asyncDir), STEER_REQUESTS_DIR);
4803
+ return path15.join(controlInboxDir(asyncDir), STEER_REQUESTS_DIR);
4789
4804
  }
4790
4805
  function steerInboxClosedPath(asyncDir) {
4791
- return path16.join(controlInboxDir(asyncDir), STEER_INBOX_CLOSED_FILE);
4806
+ return path15.join(controlInboxDir(asyncDir), STEER_INBOX_CLOSED_FILE);
4807
+ }
4808
+ function steerCapabilitiesDir(asyncDir) {
4809
+ return path15.join(controlInboxDir(asyncDir), STEER_CAPABILITIES_DIR);
4810
+ }
4811
+ function steerCapabilityPath(asyncDir, index) {
4812
+ return assertChildIndex(index), path15.join(steerCapabilitiesDir(asyncDir), `${index}.json`);
4813
+ }
4814
+ function assertChildIndex(index) {
4815
+ if (!Number.isInteger(index) || index < 0 || index > 1e6)
4816
+ throw new Error("steer child index must be a non-negative integer.");
4792
4817
  }
4793
4818
  function steerRequestFileName(request) {
4794
4819
  return `${String(request.ts).padStart(13, "0")}-${Buffer.from(request.id).toString("base64url")}.json`;
@@ -4799,7 +4824,7 @@ function validSteerRequest(request) {
4799
4824
  function writeSteerRequestToDir(dir, request) {
4800
4825
  if (!validSteerRequest(request))
4801
4826
  throw new Error("steer request is malformed or exceeds transport limits.");
4802
- let requestPath = path16.join(dir, steerRequestFileName(request));
4827
+ let requestPath = path15.join(dir, steerRequestFileName(request));
4803
4828
  return writeAtomicJson(requestPath, request), requestPath;
4804
4829
  }
4805
4830
  function requestAsyncInterrupt(asyncDir, payload = {}, deps = {}) {
@@ -4821,7 +4846,7 @@ function requestAsyncSteer(asyncDir, payload, deps = {}) {
4821
4846
  if (payload.targetIndexes !== void 0 && (!Array.isArray(payload.targetIndexes) || payload.targetIndex !== void 0 || payload.targetIndexes.length === 0 || payload.targetIndexes.length > 1e3 || payload.targetIndexes.some((index) => !Number.isInteger(index) || index < 0 || index > 1e6) || new Set(payload.targetIndexes).size !== payload.targetIndexes.length))
4822
4847
  throw new Error("steer targetIndexes must contain 1-1000 unique non-negative integers and cannot be combined with targetIndex.");
4823
4848
  let closedPath = steerInboxClosedPath(asyncDir);
4824
- if (fs15.existsSync(closedPath))
4849
+ if (fs14.existsSync(closedPath))
4825
4850
  throw new Error("Async run no longer accepts steering requests.");
4826
4851
  let request = {
4827
4852
  type: "steer",
@@ -4832,10 +4857,17 @@ function requestAsyncSteer(asyncDir, payload, deps = {}) {
4832
4857
  ...payload.targetIndexes !== void 0 ? { targetIndexes: [...payload.targetIndexes] } : {},
4833
4858
  ...payload.source ? { source: payload.source } : {}
4834
4859
  }, requestPath = writeSteerRequestToDir(steerRequestsDir(asyncDir), request);
4835
- if (fs15.existsSync(closedPath))
4836
- throw fs15.rmSync(requestPath, { force: !0 }), new Error("Async run stopped accepting steering before the request was committed.");
4860
+ if (fs14.existsSync(closedPath))
4861
+ throw fs14.rmSync(requestPath, { force: !0 }), new Error("Async run stopped accepting steering before the request was committed.");
4837
4862
  return requestPath;
4838
4863
  }
4864
+ function parseSteerCapability(raw) {
4865
+ if (!raw || typeof raw != "object" || Array.isArray(raw))
4866
+ return;
4867
+ let input = raw;
4868
+ if (!(input.type !== "steer-capability" || input.protocolVersion !== 1) && !(!Number.isInteger(input.index) || input.index < 0 || input.index > 1e6) && !(!Number.isInteger(input.pid) || input.pid <= 0 || !Number.isFinite(input.readyAt) || input.readyAt <= 0 || typeof input.supported != "boolean"))
4869
+ return { type: "steer-capability", protocolVersion: 1, index: input.index, pid: input.pid, readyAt: input.readyAt, supported: input.supported };
4870
+ }
4839
4871
  function parseSteerAck(raw) {
4840
4872
  if (!raw || typeof raw != "object" || Array.isArray(raw))
4841
4873
  return;
@@ -4843,8 +4875,15 @@ function parseSteerAck(raw) {
4843
4875
  if (!(input.type !== "steer-ack" || input.protocolVersion !== 1 || typeof input.requestId != "string" || !/^[^\s]+$/.test(input.requestId) || input.requestId.length > 256) && !(!Number.isInteger(input.index) || input.index < 0 || input.index > 1e6 || !Number.isFinite(input.ts) || input.ts <= 0) && !(input.state !== "delivered" && input.state !== "failed") && !(typeof input.message != "string" || !input.message.trim() || input.message.length > 1e3))
4844
4876
  return { type: "steer-ack", protocolVersion: 1, requestId: input.requestId, index: input.index, ts: input.ts, state: input.state, message: input.message.trim() };
4845
4877
  }
4846
- function consumeSteerAcks(asyncDir, fsImpl = fs15) {
4847
- let root = path16.join(controlInboxDir(asyncDir), STEER_ACKS_DIR);
4878
+ function readSteerCapability(asyncDir, index) {
4879
+ try {
4880
+ return parseSteerCapability(JSON.parse(fs14.readFileSync(steerCapabilityPath(asyncDir, index), "utf-8")));
4881
+ } catch {
4882
+ return;
4883
+ }
4884
+ }
4885
+ function consumeSteerAcks(asyncDir, fsImpl = fs14) {
4886
+ let root = path15.join(controlInboxDir(asyncDir), STEER_ACKS_DIR);
4848
4887
  if (!fsImpl.existsSync(root))
4849
4888
  return [];
4850
4889
  let acks = [], indexNames;
@@ -4854,14 +4893,14 @@ function consumeSteerAcks(asyncDir, fsImpl = fs15) {
4854
4893
  return [];
4855
4894
  }
4856
4895
  for (let indexName of indexNames) {
4857
- let dir = path16.join(root, indexName), entries;
4896
+ let dir = path15.join(root, indexName), entries;
4858
4897
  try {
4859
4898
  entries = fsImpl.readdirSync(dir).filter((name) => name.endsWith(".json")).sort();
4860
4899
  } catch {
4861
4900
  continue;
4862
4901
  }
4863
4902
  for (let entry of entries) {
4864
- let target = path16.join(dir, entry), ack;
4903
+ let target = path15.join(dir, entry), ack;
4865
4904
  try {
4866
4905
  ack = parseSteerAck(JSON.parse(fsImpl.readFileSync(target, "utf-8")));
4867
4906
  } catch {
@@ -4886,7 +4925,7 @@ function deliverInterruptRequest(input) {
4886
4925
  if (error?.code === "ENOSYS")
4887
4926
  return;
4888
4927
  try {
4889
- fs15.rmSync(requestPath, { force: !0 });
4928
+ fs14.rmSync(requestPath, { force: !0 });
4890
4929
  } catch {
4891
4930
  }
4892
4931
  throw error;
@@ -4896,6 +4935,112 @@ function deliverStopRequest(input) {
4896
4935
  requestAsyncStop(input.asyncDir, input.source ? { source: input.source } : {}, { now: input.now });
4897
4936
  }
4898
4937
 
4938
+ // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js
4939
+ import * as fs15 from "node:fs";
4940
+ import * as os7 from "node:os";
4941
+ import * as path16 from "node:path";
4942
+ var NATIVE_INTERCOM_EXTENSION_DIR = "native:pi-subagents-supervisor-channel";
4943
+ function defaultAgentDir() {
4944
+ return getAgentDir();
4945
+ }
4946
+ function defaultSubagentConfigDir(agentDir = defaultAgentDir()) {
4947
+ return path16.join(agentDir, "extensions", "subagent");
4948
+ }
4949
+ var DEFAULT_INTERCOM_TARGET_PREFIX = "subagent-chat", INTERCOM_BRIDGE_MARKER = "Intercom orchestration channel:", DEFAULT_INTERCOM_BRIDGE_TEMPLATE = `The inherited thread is reference-only. Do not continue that conversation or send questions, status updates, or completion handoffs to the supervisor in normal assistant text.
4950
+
4951
+ Use contact_supervisor first. It resolves the supervisor session "{orchestratorTarget}" and run metadata automatically.
4952
+ - Need a decision, blocked, approval, or product/API/scope ambiguity: contact_supervisor({ reason: "need_decision", message: "<question>" })
4953
+ - Need structured supervisor input rather than a freeform reply: contact_supervisor({ reason: "interview_request", message: "<what input is needed>", interview: { title: "...", questions: [] } })
4954
+ - After contact_supervisor with reason "need_decision" or "interview_request", stay alive and continue only after the reply arrives. Do not finish your final response with a choose-one question.
4955
+ - Do not ask for clarification when the only conflict is review-only/no-edit versus progress-writing or artifact-writing instructions. If an output path is configured but no write-capable tool is available, return the complete artifact in your final response; the runtime will persist it. Do not contact the supervisor merely because you cannot write that output path directly.
4956
+ - Meaningful progress or unexpected discoveries that change the plan: contact_supervisor({ reason: "progress_update", message: "UPDATE: <summary>" })
4957
+ - Generic intercom is lower-level plumbing/fallback only: intercom({ action: "ask", to: "{orchestratorTarget}", message: "<question>" })
4958
+
4959
+ Do not use contact_supervisor or intercom for routine completion handoffs. If no coordination is needed, return a focused task result.`;
4960
+ function resolveIntercomSessionTarget(sessionName, sessionId) {
4961
+ let trimmedName = sessionName?.trim();
4962
+ if (trimmedName)
4963
+ return trimmedName;
4964
+ let normalizedSessionId = sessionId.startsWith("session-") ? sessionId.slice(8) : sessionId;
4965
+ return `${DEFAULT_INTERCOM_TARGET_PREFIX}-${normalizedSessionId.slice(0, 8)}`;
4966
+ }
4967
+ function sanitizeIntercomTargetPart(value) {
4968
+ return value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || "agent";
4969
+ }
4970
+ function resolveSubagentIntercomTarget(runId, agent, index) {
4971
+ let stepSuffix = index !== void 0 ? `-${index + 1}` : "";
4972
+ return `subagent-${sanitizeIntercomTargetPart(agent)}-${sanitizeIntercomTargetPart(runId)}${stepSuffix}`;
4973
+ }
4974
+ function resolveIntercomBridgeMode(value) {
4975
+ return value === "off" || value === "always" || value === "fork-only" ? value : "always";
4976
+ }
4977
+ function resolveIntercomBridgeConfig(value) {
4978
+ return !value || typeof value != "object" || Array.isArray(value) ? { mode: "always", instructionFile: "" } : {
4979
+ mode: resolveIntercomBridgeMode(value.mode),
4980
+ instructionFile: typeof value.instructionFile == "string" ? value.instructionFile : ""
4981
+ };
4982
+ }
4983
+ function expandTilde(filePath) {
4984
+ return filePath.startsWith("~/") ? path16.join(os7.homedir(), filePath.slice(2)) : filePath;
4985
+ }
4986
+ function resolveInstructionTemplate(instructionFile, settingsDir) {
4987
+ if (!instructionFile)
4988
+ return DEFAULT_INTERCOM_BRIDGE_TEMPLATE;
4989
+ let expandedPath = expandTilde(instructionFile), resolvedPath = path16.isAbsolute(expandedPath) ? expandedPath : path16.resolve(settingsDir, expandedPath);
4990
+ try {
4991
+ return fs15.readFileSync(resolvedPath, "utf-8");
4992
+ } catch (error) {
4993
+ return console.warn(`Failed to read intercom bridge instructionFile at '${resolvedPath}'. Using default instructions.`, error), DEFAULT_INTERCOM_BRIDGE_TEMPLATE;
4994
+ }
4995
+ }
4996
+ function buildIntercomBridgeInstruction(orchestratorTarget, template) {
4997
+ let instruction = template.replaceAll("{orchestratorTarget}", orchestratorTarget).trim();
4998
+ return instruction.startsWith(INTERCOM_BRIDGE_MARKER) ? instruction : `${INTERCOM_BRIDGE_MARKER}
4999
+ ${instruction}`;
5000
+ }
5001
+ function inactiveReason(mode, context, orchestratorTarget) {
5002
+ if (mode === "off")
5003
+ return "bridge mode is off";
5004
+ if (mode === "fork-only" && context !== "fork")
5005
+ return "bridge mode is fork-only and context is not fork";
5006
+ if (!orchestratorTarget)
5007
+ return "orchestrator target is not available";
5008
+ }
5009
+ function diagnoseIntercomBridge(input) {
5010
+ let mode = resolveIntercomBridgeConfig(input.config).mode, orchestratorTarget = input.orchestratorTarget?.trim(), wantsIntercom = mode !== "off" && !(mode === "fork-only" && input.context !== "fork"), reason = inactiveReason(mode, input.context, orchestratorTarget);
5011
+ return {
5012
+ active: reason === void 0,
5013
+ mode,
5014
+ wantsIntercom,
5015
+ supervisorChannelAvailable: !0,
5016
+ extensionDir: NATIVE_INTERCOM_EXTENSION_DIR,
5017
+ ...orchestratorTarget ? { orchestratorTarget } : {},
5018
+ ...reason ? { reason } : {}
5019
+ };
5020
+ }
5021
+ function resolveIntercomBridge(input) {
5022
+ let config = resolveIntercomBridgeConfig(input.config), mode = config.mode, orchestratorTarget = input.orchestratorTarget?.trim(), agentDir = path16.resolve(input.agentDir ?? defaultAgentDir()), settingsDir = path16.resolve(input.settingsDir ?? defaultSubagentConfigDir(agentDir)), defaultInstruction = buildIntercomBridgeInstruction(orchestratorTarget || "{orchestratorTarget}", DEFAULT_INTERCOM_BRIDGE_TEMPLATE);
5023
+ return inactiveReason(mode, input.context, orchestratorTarget) || !orchestratorTarget ? { active: !1, mode, extensionDir: NATIVE_INTERCOM_EXTENSION_DIR, instruction: defaultInstruction } : {
5024
+ active: !0,
5025
+ mode,
5026
+ orchestratorTarget,
5027
+ extensionDir: NATIVE_INTERCOM_EXTENSION_DIR,
5028
+ instruction: buildIntercomBridgeInstruction(orchestratorTarget, resolveInstructionTemplate(config.instructionFile, settingsDir))
5029
+ };
5030
+ }
5031
+ function applyIntercomBridgeToAgent(agent, bridge) {
5032
+ if (!bridge.active || !bridge.orchestratorTarget)
5033
+ return agent;
5034
+ let bridgeTools = ["intercom", "contact_supervisor"], tools = agent.tools ? [...agent.tools, ...bridgeTools.filter((tool) => !agent.tools?.includes(tool))] : agent.tools, instruction = bridge.instruction, trimmedPrompt = agent.systemPrompt?.trim() || "", systemPrompt = trimmedPrompt.includes(INTERCOM_BRIDGE_MARKER) ? trimmedPrompt : trimmedPrompt ? `${trimmedPrompt}
5035
+
5036
+ ${instruction}` : instruction;
5037
+ return tools === agent.tools && systemPrompt === agent.systemPrompt ? agent : {
5038
+ ...agent,
5039
+ tools,
5040
+ systemPrompt
5041
+ };
5042
+ }
5043
+
4899
5044
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js
4900
5045
  import * as fs16 from "node:fs";
4901
5046
  import * as path17 from "node:path";
@@ -4926,6 +5071,15 @@ function interruptLiveAsyncResumeTarget(input) {
4926
5071
  function getErrorMessage3(error) {
4927
5072
  return error instanceof Error ? error.message : String(error);
4928
5073
  }
5074
+ var TURN_BUDGET_RUNTIME_KEYS = /* @__PURE__ */ new Set(["outcome", "turnCount", "wrapUpRequestedAtTurn", "exceededAtTurn"]);
5075
+ function persistedTurnBudgetConfig(raw) {
5076
+ if (!raw || typeof raw != "object" || Array.isArray(raw))
5077
+ return raw;
5078
+ let config = {};
5079
+ for (let [key, value] of Object.entries(raw))
5080
+ TURN_BUDGET_RUNTIME_KEYS.has(key) || (config[key] = value);
5081
+ return config;
5082
+ }
4929
5083
  function ensureObject(value, source) {
4930
5084
  if (!value || typeof value != "object" || Array.isArray(value))
4931
5085
  throw new Error(`Async result file '${source}' must contain a JSON object.`);
@@ -5149,7 +5303,7 @@ function readAsyncRecoveryDescriptor(asyncDir) {
5149
5303
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': ${field} must be a non-empty string.`);
5150
5304
  if (parsed.permissions !== "full" && parsed.permissions !== "read-only")
5151
5305
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': permissions must be full or read-only.`);
5152
- if (parsed.tier !== "light" && parsed.tier !== "standard" && parsed.tier !== "heavy")
5306
+ if (parsed.tier !== void 0 && parsed.tier !== "light" && parsed.tier !== "standard" && parsed.tier !== "heavy")
5153
5307
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': tier must be light, standard, or heavy.`);
5154
5308
  if (validateChildDescription(parsed.description, `Async recovery descriptor '${descriptorPath}' description`), parsed.outputMode !== "inline" && parsed.outputMode !== "file-only")
5155
5309
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': outputMode is invalid.`);
@@ -5170,17 +5324,23 @@ function readAsyncRecoveryDescriptor(asyncDir) {
5170
5324
  let selection = parsed.modelSelection;
5171
5325
  if (!selection || typeof selection != "object")
5172
5326
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': modelSelection must be an object.`);
5173
- if (selection.kind !== "tier")
5327
+ if (selection.kind === "tier") {
5328
+ if (selection.tier !== "light" && selection.tier !== "standard" && selection.tier !== "heavy")
5329
+ throw new Error(`Invalid async recovery descriptor '${descriptorPath}': modelSelection.tier is invalid.`);
5330
+ } else if (selection.kind === "model") {
5331
+ if (selection.model !== void 0 && (typeof selection.model != "string" || !selection.model.trim()))
5332
+ throw new Error(`Invalid async recovery descriptor '${descriptorPath}': modelSelection.model must be a non-empty string.`);
5333
+ } else
5174
5334
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': modelSelection.kind is invalid.`);
5175
- if (selection.kind === "tier" && selection.tier !== "light" && selection.tier !== "standard" && selection.tier !== "heavy")
5176
- throw new Error(`Invalid async recovery descriptor '${descriptorPath}': modelSelection.tier is invalid.`);
5177
- }
5335
+ } else if (parsed.tier === void 0)
5336
+ throw new Error(`Invalid async recovery descriptor '${descriptorPath}': tier or modelSelection is required.`);
5178
5337
  if (parsed.absoluteDeadlineAt !== void 0 && (!Number.isFinite(parsed.absoluteDeadlineAt) || parsed.absoluteDeadlineAt <= 0))
5179
5338
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': absoluteDeadlineAt must be a positive timestamp.`);
5180
5339
  if (parsed.initialTurnBudget !== void 0) {
5181
- let result = resolveTurnBudgetConfig(parsed.initialTurnBudget, "recoveryDescriptor.initialTurnBudget");
5340
+ let result = resolveTurnBudgetConfig(persistedTurnBudgetConfig(parsed.initialTurnBudget), "recoveryDescriptor.initialTurnBudget");
5182
5341
  if (result.error)
5183
5342
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': ${result.error}`);
5343
+ result.turnBudget && (parsed.initialTurnBudget = result.turnBudget);
5184
5344
  }
5185
5345
  if (parsed.initialToolBudget !== void 0) {
5186
5346
  let result = validateToolBudgetConfig(parsed.initialToolBudget, "recoveryDescriptor.initialToolBudget");
@@ -5226,7 +5386,7 @@ function readAsyncRecoveryDescriptor(asyncDir) {
5226
5386
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': controlConfig.notifyChannels is invalid.`);
5227
5387
  }
5228
5388
  if (parsed.acceptance !== void 0) {
5229
- let errors = validateAcceptanceInput(parsed.acceptance, "recoveryDescriptor.acceptance");
5389
+ let errors = validatePersistedAcceptance(parsed.acceptance, "recoveryDescriptor.acceptance");
5230
5390
  if (errors.length)
5231
5391
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': ${errors.join(" ")}`);
5232
5392
  }
@@ -5279,6 +5439,7 @@ function resolveAsyncResumeTarget(params, deps = {}, options = {}) {
5279
5439
  sessionFile: selectedStep.sessionFile ?? status?.sessionFile ?? result?.sessionFile,
5280
5440
  model: selectedStep.model,
5281
5441
  thinking: selectedStep.thinking,
5442
+ modelSelection: selectedStep.modelSelection,
5282
5443
  ...recoveryDescriptor ? { recoveryDescriptor } : {}
5283
5444
  };
5284
5445
  if (selectedStep?.status === "pending")
@@ -5304,6 +5465,7 @@ function resolveAsyncResumeTarget(params, deps = {}, options = {}) {
5304
5465
  sessionFile: selected.step.sessionFile ?? status?.sessionFile ?? result?.sessionFile,
5305
5466
  model: selected.step.model,
5306
5467
  thinking: selected.step.thinking,
5468
+ modelSelection: selected.step.modelSelection,
5307
5469
  ...recoveryDescriptor ? { recoveryDescriptor } : {}
5308
5470
  };
5309
5471
  }
@@ -5336,6 +5498,7 @@ function resolveAsyncResumeTarget(params, deps = {}, options = {}) {
5336
5498
  intercomTarget: resolveSubagentIntercomTarget(runId, childId ?? agent, index),
5337
5499
  cwd: status?.cwd ?? result?.cwd,
5338
5500
  ...resolvedSessionFile ? { sessionFile: resolvedSessionFile } : {},
5501
+ modelSelection: statusSteps[index]?.modelSelection,
5339
5502
  ...stepModel ? { model: stepModel } : {},
5340
5503
  ...stepThinking ? { thinking: stepThinking } : {},
5341
5504
  ...recoveryDescriptor ? { recoveryDescriptor } : {}
@@ -5357,6 +5520,76 @@ function buildRevivedAsyncTask(target, message) {
5357
5520
  `);
5358
5521
  }
5359
5522
 
5523
+ // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.js
5524
+ import * as fs17 from "node:fs";
5525
+ import * as path18 from "node:path";
5526
+ function exactAsyncLocation(id, asyncDirRoot, resultsDir) {
5527
+ let asyncDir = path18.join(asyncDirRoot, id), resultPath = path18.join(resultsDir, `${id}.json`);
5528
+ if (!(!fs17.existsSync(asyncDir) && !fs17.existsSync(resultPath)))
5529
+ return {
5530
+ asyncDir: fs17.existsSync(asyncDir) ? asyncDir : null,
5531
+ resultPath: fs17.existsSync(resultPath) ? resultPath : null,
5532
+ resolvedId: id
5533
+ };
5534
+ }
5535
+ function foregroundIds(state) {
5536
+ if (!state)
5537
+ return [];
5538
+ let remembered = state.currentSessionId ? [...state.foregroundRuns?.values() ?? []].filter((run) => run.sessionId === state.currentSessionId).map((run) => run.runId) : [];
5539
+ return [.../* @__PURE__ */ new Set([...state.foregroundControls.keys(), ...remembered])];
5540
+ }
5541
+ function hasExactForegroundId(state, id) {
5542
+ if (!state)
5543
+ return !1;
5544
+ if (state.foregroundControls.has(id))
5545
+ return !0;
5546
+ let remembered = state.foregroundRuns?.get(id);
5547
+ return !!(remembered && state.currentSessionId && remembered.sessionId === state.currentSessionId);
5548
+ }
5549
+ function nestedScopeFromState(state) {
5550
+ if (!state)
5551
+ return;
5552
+ let routes = [], seen = /* @__PURE__ */ new Set(), add = (route) => {
5553
+ if (!route)
5554
+ return;
5555
+ let key = `${route.rootRunId}:${route.eventSink}:${route.controlInbox}`;
5556
+ seen.has(key) || (seen.add(key), routes.push(route));
5557
+ };
5558
+ for (let control of state.foregroundControls.values())
5559
+ add(control.nestedRoute);
5560
+ for (let job of state.asyncJobs.values())
5561
+ add(job.nestedRoute);
5562
+ return { routes };
5563
+ }
5564
+ function asyncPrefixMatches(prefix, asyncDirRoot, resultsDir) {
5565
+ return findAsyncRunPrefixMatches(prefix, asyncDirRoot, resultsDir);
5566
+ }
5567
+ function resolveSubagentRunId(id, deps = {}) {
5568
+ assertSafeNestedId("id", id);
5569
+ let asyncDirRoot = deps.asyncDirRoot ?? ASYNC_DIR, resultsDir = deps.resultsDir ?? RESULTS_DIR, nestedScope = deps.nested ?? nestedScopeFromState(deps.state);
5570
+ if (hasExactForegroundId(deps.state, id))
5571
+ return { kind: "foreground", id };
5572
+ let exactAsync = exactAsyncLocation(id, asyncDirRoot, resultsDir);
5573
+ if (exactAsync)
5574
+ return { kind: "async", id, location: exactAsync };
5575
+ let exactNested = findNestedRunMatchesById(id, nestedScope ? { scope: nestedScope } : {});
5576
+ if (exactNested.length > 1)
5577
+ throw new Error(`Nested run id '${id}' is ambiguous across authorized registries. Provide the full id after stale registries are cleaned up.`);
5578
+ if (exactNested[0])
5579
+ return { kind: "nested", id, match: exactNested[0] };
5580
+ let matches = [];
5581
+ for (let foregroundId of foregroundIds(deps.state).filter((candidate) => candidate.startsWith(id)))
5582
+ matches.push({ kind: "foreground", id: foregroundId });
5583
+ for (let match of asyncPrefixMatches(id, asyncDirRoot, resultsDir))
5584
+ matches.push({ kind: "async", id: match.id, location: match.location });
5585
+ for (let match of findNestedRunMatchesById(id, nestedScope ? { prefix: !0, scope: nestedScope } : { prefix: !0 }))
5586
+ matches.push({ kind: "nested", id: match.run.id, match });
5587
+ let values = [...new Map(matches.map((match) => [`${match.kind}:${match.id}`, match])).values()];
5588
+ if (values.length > 1)
5589
+ throw new Error(`Ambiguous subagent run id prefix '${id}' matched: ${values.map((match) => `${match.kind}:${match.id}`).join(", ")}. Provide a longer id.`);
5590
+ return values[0];
5591
+ }
5592
+
5360
5593
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js
5361
5594
  var SUBAGENT_CONTROL_MESSAGE_TYPE = "subagent_control_notice";
5362
5595
  function controlNoticeTarget(details) {
@@ -5407,8 +5640,8 @@ function handleSubagentControlNotice(input) {
5407
5640
  }
5408
5641
 
5409
5642
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/async-status.js
5410
- import * as fs17 from "node:fs";
5411
- import * as path18 from "node:path";
5643
+ import * as fs18 from "node:fs";
5644
+ import * as path19 from "node:path";
5412
5645
  function getErrorMessage4(error) {
5413
5646
  return error instanceof Error ? error.message : String(error);
5414
5647
  }
@@ -5416,9 +5649,9 @@ function isNotFoundError3(error) {
5416
5649
  return typeof error == "object" && error !== null && "code" in error && error.code === "ENOENT";
5417
5650
  }
5418
5651
  function isAsyncRunDir(root, entry) {
5419
- let entryPath = path18.join(root, entry);
5652
+ let entryPath = path19.join(root, entry);
5420
5653
  try {
5421
- return fs17.statSync(entryPath).isDirectory();
5654
+ return fs18.statSync(entryPath).isDirectory();
5422
5655
  } catch (error) {
5423
5656
  if (isNotFoundError3(error))
5424
5657
  return !1;
@@ -5430,7 +5663,7 @@ function isAsyncRunDir(root, entry) {
5430
5663
  function outputFileMtime(outputFile) {
5431
5664
  if (outputFile)
5432
5665
  try {
5433
- return fs17.statSync(outputFile).mtimeMs;
5666
+ return fs18.statSync(outputFile).mtimeMs;
5434
5667
  } catch (error) {
5435
5668
  if (isNotFoundError3(error))
5436
5669
  return;
@@ -5442,7 +5675,7 @@ function outputFileMtime(outputFile) {
5442
5675
  function deriveAsyncActivityState(asyncDir, status) {
5443
5676
  if (status.state !== "running")
5444
5677
  return { activityState: status.activityState, lastActivityAt: status.lastActivityAt };
5445
- let outputPath = status.outputFile ? path18.isAbsolute(status.outputFile) ? status.outputFile : path18.join(asyncDir, status.outputFile) : void 0, currentStep = typeof status.currentStep == "number" ? status.steps?.[status.currentStep] : void 0;
5678
+ let outputPath = status.outputFile ? path19.isAbsolute(status.outputFile) ? status.outputFile : path19.join(asyncDir, status.outputFile) : void 0, currentStep = typeof status.currentStep == "number" ? status.steps?.[status.currentStep] : void 0;
5446
5679
  return {
5447
5680
  activityState: status.activityState,
5448
5681
  lastActivityAt: status.lastActivityAt ?? outputFileMtime(outputPath) ?? currentStep?.lastActivityAt ?? currentStep?.startedAt ?? status.startedAt
@@ -5450,7 +5683,7 @@ function deriveAsyncActivityState(asyncDir, status) {
5450
5683
  }
5451
5684
  function statusToSummary(asyncDir, status, nestedWarnings = [], nestedRoute) {
5452
5685
  if (status.sessionId !== void 0 && typeof status.sessionId != "string")
5453
- throw new Error(`Invalid async status '${path18.join(asyncDir, "status.json")}': sessionId must be a string.`);
5686
+ throw new Error(`Invalid async status '${path19.join(asyncDir, "status.json")}': sessionId must be a string.`);
5454
5687
  let { activityState, lastActivityAt } = deriveAsyncActivityState(asyncDir, status), steps = status.steps ?? [], chainStepCount = status.chainStepCount ?? steps.length, parallelGroups = normalizeParallelGroups(status.parallelGroups, steps.length, chainStepCount), nestedChildren = [];
5455
5688
  if (nestedWarnings.length === 0 && nestedRoute)
5456
5689
  try {
@@ -5496,8 +5729,8 @@ function statusToSummary(asyncDir, status, nestedWarnings = [], nestedRoute) {
5496
5729
  ...step.children?.length ? { children: step.children } : {}
5497
5730
  };
5498
5731
  });
5499
- return attachRootChildrenToSteps(status.runId || path18.basename(asyncDir), summarizedSteps, nestedChildren), {
5500
- id: status.runId || path18.basename(asyncDir),
5732
+ return attachRootChildrenToSteps(status.runId || path19.basename(asyncDir), summarizedSteps, nestedChildren), {
5733
+ id: status.runId || path19.basename(asyncDir),
5501
5734
  asyncDir,
5502
5735
  ...status.sessionId ? { sessionId: status.sessionId } : {},
5503
5736
  state: status.state,
@@ -5567,7 +5800,7 @@ function sortRuns(runs) {
5567
5800
  function listAsyncRuns(asyncDirRoot, options = {}) {
5568
5801
  let entries;
5569
5802
  try {
5570
- entries = fs17.readdirSync(asyncDirRoot).filter((entry) => isAsyncRunDir(asyncDirRoot, entry));
5803
+ entries = fs18.readdirSync(asyncDirRoot).filter((entry) => isAsyncRunDir(asyncDirRoot, entry));
5571
5804
  } catch (error) {
5572
5805
  if (isNotFoundError3(error))
5573
5806
  return [];
@@ -5577,13 +5810,13 @@ function listAsyncRuns(asyncDirRoot, options = {}) {
5577
5810
  }
5578
5811
  let allowedStates = options.states ? new Set(options.states) : void 0, runs = [], nestedRouteIndex, resolveNestedRoute = (rootRunId) => (nestedRouteIndex || (nestedRouteIndex = buildNestedRouteIndex()), nestedRouteIndex.get(rootRunId));
5579
5812
  for (let entry of entries) {
5580
- let asyncDir = path18.join(asyncDirRoot, entry), status = (options.reconcile === !1 ? void 0 : reconcileAsyncRun(asyncDir, { resultsDir: options.resultsDir, kill: options.kill, now: options.now }))?.status ?? readStatus(asyncDir);
5813
+ let asyncDir = path19.join(asyncDirRoot, entry), status = (options.reconcile === !1 ? void 0 : reconcileAsyncRun(asyncDir, { resultsDir: options.resultsDir, kill: options.kill, now: options.now }))?.status ?? readStatus(asyncDir);
5581
5814
  if (!status || allowedStates && !allowedStates.has(status.state) || options.sessionId && status.sessionId !== options.sessionId)
5582
5815
  continue;
5583
5816
  let nestedWarnings = [], nestedRoute;
5584
5817
  if (options.reconcile !== !1)
5585
5818
  try {
5586
- nestedRoute = resolveNestedRoute(status.runId || path18.basename(asyncDir)), nestedRoute && reconcileNestedAsyncDescendants(nestedRoute, { resultsDir: options.resultsDir, kill: options.kill, now: options.now });
5819
+ nestedRoute = resolveNestedRoute(status.runId || path19.basename(asyncDir)), nestedRoute && reconcileNestedAsyncDescendants(nestedRoute, { resultsDir: options.resultsDir, kill: options.kill, now: options.now });
5587
5820
  } catch (error) {
5588
5821
  nestedWarnings.push(`Nested status unavailable: ${getErrorMessage4(error)}`);
5589
5822
  }
@@ -5611,7 +5844,7 @@ function formatStepLine(step) {
5611
5844
  }
5612
5845
  function formatAsyncRunOutputPath(run) {
5613
5846
  if (run.outputFile)
5614
- return path18.isAbsolute(run.outputFile) ? run.outputFile : path18.join(run.asyncDir, run.outputFile);
5847
+ return path19.isAbsolute(run.outputFile) ? run.outputFile : path19.join(run.asyncDir, run.outputFile);
5615
5848
  }
5616
5849
  function formatAsyncRunProgressLabel(run) {
5617
5850
  let stepCount = run.steps.length || 1, chainStepCount = run.chainStepCount ?? stepCount, groups = normalizeParallelGroups(run.parallelGroups, run.steps.length, chainStepCount), activeGroup = run.currentStep !== void 0 ? groups.find((group) => run.currentStep >= group.start && run.currentStep < group.start + group.count) : void 0;
@@ -5645,8 +5878,8 @@ function formatAsyncRunList(runs, heading = "Active async runs") {
5645
5878
  }
5646
5879
 
5647
5880
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.js
5648
- import * as fs18 from "node:fs";
5649
- import * as path19 from "node:path";
5881
+ import * as fs19 from "node:fs";
5882
+ import * as path20 from "node:path";
5650
5883
  var DEFAULT_TRANSCRIPT_LINES = 80, MAX_TRANSCRIPT_LINES = 500, TRANSCRIPT_TAIL_BYTES = 256 * 1024;
5651
5884
  function transcriptLineLimit(value) {
5652
5885
  return value === void 0 || !Number.isFinite(value) ? DEFAULT_TRANSCRIPT_LINES : Math.max(1, Math.min(MAX_TRANSCRIPT_LINES, Math.trunc(value)));
@@ -5659,11 +5892,11 @@ function uniqueStrings2(values) {
5659
5892
  }
5660
5893
  function resolveMaybeRelative(asyncDir, filePath) {
5661
5894
  if (filePath)
5662
- return path19.resolve(asyncDir, filePath);
5895
+ return path20.resolve(asyncDir, filePath);
5663
5896
  }
5664
5897
  function pathWithin(base, candidate) {
5665
- let resolvedBase = path19.resolve(base), resolvedCandidate = path19.resolve(candidate);
5666
- return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path19.sep}`);
5898
+ let resolvedBase = path20.resolve(base), resolvedCandidate = path20.resolve(candidate);
5899
+ return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path20.sep}`);
5667
5900
  }
5668
5901
  function getErrorMessage5(error) {
5669
5902
  return error instanceof Error ? error.message : String(error);
@@ -5674,7 +5907,7 @@ function isNotFoundError4(error) {
5674
5907
  function readTextTail(filePath, maxLines) {
5675
5908
  let stat;
5676
5909
  try {
5677
- stat = fs18.statSync(filePath);
5910
+ stat = fs19.statSync(filePath);
5678
5911
  } catch (error) {
5679
5912
  return isNotFoundError4(error) ? { path: filePath, lines: [], truncated: !1 } : { path: filePath, lines: [], truncated: !1, error: getErrorMessage5(error) };
5680
5913
  }
@@ -5683,24 +5916,24 @@ function readTextTail(filePath, maxLines) {
5683
5916
  let fd;
5684
5917
  try {
5685
5918
  let bytesToRead = Math.min(stat.size, TRANSCRIPT_TAIL_BYTES), start = stat.size - bytesToRead, buffer = Buffer.alloc(bytesToRead);
5686
- fd = fs18.openSync(filePath, "r");
5687
- let bytesRead = fs18.readSync(fd, buffer, 0, bytesToRead, start), lines = buffer.subarray(0, bytesRead).toString("utf-8").split(/\r?\n/);
5919
+ fd = fs19.openSync(filePath, "r");
5920
+ let bytesRead = fs19.readSync(fd, buffer, 0, bytesToRead, start), lines = buffer.subarray(0, bytesRead).toString("utf-8").split(/\r?\n/);
5688
5921
  return start > 0 && lines.length > 0 && (lines = lines.slice(1)), lines.at(-1) === "" && (lines = lines.slice(0, -1)), { path: filePath, lines: lines.slice(-maxLines), truncated: start > 0 || lines.length > maxLines };
5689
5922
  } catch (error) {
5690
5923
  return { path: filePath, lines: [], truncated: !1, error: getErrorMessage5(error) };
5691
5924
  } finally {
5692
- fd !== void 0 && fs18.closeSync(fd);
5925
+ fd !== void 0 && fs19.closeSync(fd);
5693
5926
  }
5694
5927
  }
5695
5928
  function readContainedTextTail(filePath, maxLines, trustedRoots, label) {
5696
5929
  if (trustedRoots.length === 0)
5697
5930
  return { path: filePath, lines: [], truncated: !1, error: `Refusing to read ${label} transcript path without a trusted root: ${filePath}` };
5698
- let resolvedPath = path19.resolve(filePath);
5931
+ let resolvedPath = path20.resolve(filePath);
5699
5932
  if (!trustedRoots.some((root) => pathWithin(root, resolvedPath)))
5700
5933
  return { path: filePath, lines: [], truncated: !1, error: `Refusing to read ${label} transcript path outside trusted roots: ${filePath}` };
5701
5934
  let lstat;
5702
5935
  try {
5703
- lstat = fs18.lstatSync(resolvedPath);
5936
+ lstat = fs19.lstatSync(resolvedPath);
5704
5937
  } catch (error) {
5705
5938
  return isNotFoundError4(error) ? { path: filePath, lines: [], truncated: !1 } : { path: filePath, lines: [], truncated: !1, error: getErrorMessage5(error) };
5706
5939
  }
@@ -5710,7 +5943,7 @@ function readContainedTextTail(filePath, maxLines, trustedRoots, label) {
5710
5943
  return { path: filePath, lines: [], truncated: !1, error: `Refusing to read non-file ${label} transcript path: ${filePath}` };
5711
5944
  let realPath, realRoots;
5712
5945
  try {
5713
- realPath = fs18.realpathSync(resolvedPath), realRoots = trustedRoots.filter((root) => fs18.existsSync(root)).map((root) => fs18.realpathSync(root));
5946
+ realPath = fs19.realpathSync(resolvedPath), realRoots = trustedRoots.filter((root) => fs19.existsSync(root)).map((root) => fs19.realpathSync(root));
5714
5947
  } catch (error) {
5715
5948
  return { path: filePath, lines: [], truncated: !1, error: getErrorMessage5(error) };
5716
5949
  }
@@ -5801,8 +6034,8 @@ function formatAsyncFleetLines(runs) {
5801
6034
  for (let step of run.steps) {
5802
6035
  let display = step.label ? `${step.label} (${step.agent})` : step.agent, phase = step.phase ? `[${step.phase}] ` : "", stepActivity = formatActivityFacts2(step), modelThinking = formatModelSelection(step.modelSelection, step.model, step.thinking), parts = [`${step.index}. ${phase}${display}`, step.status, stepActivity, modelThinking].filter(Boolean);
5803
6036
  lines.push(` ${parts.join(" | ")}`);
5804
- let output = path19.join(run.asyncDir, `output-${step.index}.log`);
5805
- fs18.existsSync(output) && lines.push(` output: ${shortenPath(output)}`), step.sessionFile && lines.push(` session: ${shortenPath(step.sessionFile)}`), (step.status === "running" || step.recentOutput?.length || fs18.existsSync(output)) && lines.push(` transcript: subagent({ action: "status", id: "${run.id}", index: ${step.index}, view: "transcript" })`), lines.push(...formatNestedRunStatusLines(step.children, { indent: " ", commandHints: !0, maxLines: 12 }));
6037
+ let output = path20.join(run.asyncDir, `output-${step.index}.log`);
6038
+ fs19.existsSync(output) && lines.push(` output: ${shortenPath(output)}`), step.sessionFile && lines.push(` session: ${shortenPath(step.sessionFile)}`), (step.status === "running" || step.recentOutput?.length || fs19.existsSync(output)) && lines.push(` transcript: subagent({ action: "status", id: "${run.id}", index: ${step.index}, view: "transcript" })`), lines.push(...formatNestedRunStatusLines(step.children, { indent: " ", commandHints: !0, maxLines: 12 }));
5806
6039
  }
5807
6040
  let attached = new Set(run.steps.flatMap((step) => step.children?.map((child) => child.id) ?? [])), unattached = run.nestedChildren?.filter((child) => !attached.has(child.id)) ?? [];
5808
6041
  lines.push(...formatNestedRunStatusLines(unattached, { indent: " ", commandHints: !0, maxLines: 12 })), run.error && lines.push(` error: ${run.error}`);
@@ -5892,14 +6125,14 @@ function appendTranscriptBody(lines, sourceLabel, sourceLines, truncated) {
5892
6125
  lines.push(` ${line}`);
5893
6126
  }
5894
6127
  function formatAsyncRunTranscript(status, asyncDir, options = {}) {
5895
- let lineLimit = transcriptLineLimit(options.lines), selected = selectTranscriptStep(status, options), stepOutputPath = selected.index !== void 0 ? path19.join(asyncDir, `output-${selected.index}.log`) : void 0, runOutputPath = resolveMaybeRelative(asyncDir, status.outputFile), logPath = path19.join(asyncDir, `subagent-log-${status.runId}.md`), outputPaths = selected.index !== void 0 ? uniqueStrings2([stepOutputPath, runOutputPath && stepOutputPath && path19.resolve(runOutputPath) === path19.resolve(stepOutputPath) ? runOutputPath : void 0]) : uniqueStrings2([runOutputPath]), sessionFile = selected.index !== void 0 ? selected.step?.sessionFile : status.sessionFile, eventsPath = path19.join(asyncDir, "events.jsonl"), lines = [
6128
+ let lineLimit = transcriptLineLimit(options.lines), selected = selectTranscriptStep(status, options), stepOutputPath = selected.index !== void 0 ? path20.join(asyncDir, `output-${selected.index}.log`) : void 0, runOutputPath = resolveMaybeRelative(asyncDir, status.outputFile), logPath = path20.join(asyncDir, `subagent-log-${status.runId}.md`), outputPaths = selected.index !== void 0 ? uniqueStrings2([stepOutputPath, runOutputPath && stepOutputPath && path20.resolve(runOutputPath) === path20.resolve(stepOutputPath) ? runOutputPath : void 0]) : uniqueStrings2([runOutputPath]), sessionFile = selected.index !== void 0 ? selected.step?.sessionFile : status.sessionFile, eventsPath = path20.join(asyncDir, "events.jsonl"), lines = [
5896
6129
  `Run: ${status.runId}`,
5897
6130
  `State: ${status.state}`,
5898
6131
  `Mode: ${status.mode}`,
5899
6132
  stepStateLine(status.mode, selected.index, selected.step),
5900
6133
  selected.hint
5901
6134
  ].filter((line) => !!line);
5902
- appendKnownArtifacts(lines, { outputPaths, sessionFile, eventsPath: fs18.existsSync(eventsPath) ? eventsPath : void 0, logPath: fs18.existsSync(logPath) ? logPath : void 0 });
6135
+ appendKnownArtifacts(lines, { outputPaths, sessionFile, eventsPath: fs19.existsSync(eventsPath) ? eventsPath : void 0, logPath: fs19.existsSync(logPath) ? logPath : void 0 });
5903
6136
  let warnings = [], transcriptLines = [], transcriptSource = "Transcript tail", truncated = !1;
5904
6137
  for (let outputPath of outputPaths) {
5905
6138
  let tail = readContainedTextTail(outputPath, lineLimit, [asyncDir], "output");
@@ -5945,7 +6178,7 @@ function formatNestedRunTranscript(run, options = {}) {
5945
6178
  `);
5946
6179
  }
5947
6180
  function formatAsyncResultTranscript(data, resultPath, options = {}) {
5948
- let lineLimit = transcriptLineLimit(options.lines), runId = data.runId ?? data.id ?? path19.basename(resultPath, ".json"), children = Array.isArray(data.results) ? data.results : data.agent ? [{ agent: data.agent, output: data.output, summary: data.summary, sessionFile: data.sessionFile, state: data.state, success: data.success, exitCode: data.exitCode }] : [], index = options.index;
6181
+ let lineLimit = transcriptLineLimit(options.lines), runId = data.runId ?? data.id ?? path20.basename(resultPath, ".json"), children = Array.isArray(data.results) ? data.results : data.agent ? [{ agent: data.agent, output: data.output, summary: data.summary, sessionFile: data.sessionFile, state: data.state, success: data.success, exitCode: data.exitCode }] : [], index = options.index;
5949
6182
  if (index !== void 0 && !Number.isInteger(index))
5950
6183
  throw new Error("Transcript index must be an integer.");
5951
6184
  if (index === void 0 && children.length === 1 && (index = 0), index !== void 0 && (index < 0 || index >= children.length))
@@ -6083,8 +6316,8 @@ function recommendStrongWatchdogModel(ctx) {
6083
6316
  }
6084
6317
 
6085
6318
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/watchdog/settings.js
6086
- import * as fs19 from "node:fs";
6087
- import * as path20 from "node:path";
6319
+ import * as fs20 from "node:fs";
6320
+ import * as path21 from "node:path";
6088
6321
 
6089
6322
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/watchdog/types.js
6090
6323
  var SUBAGENT_WATCHDOG_WARNING_TYPE = "subagent_watchdog_warning", WATCHDOG_WARNING_SEVERITIES = ["concern", "blocker"], WATCHDOG_WARNING_CATEGORIES = [
@@ -6210,7 +6443,7 @@ function parseNonEmptyString(value, field, meta) {
6210
6443
  return value.trim();
6211
6444
  throw invalid(meta, field, "a non-empty string");
6212
6445
  }
6213
- function parseThinking(value, field, meta) {
6446
+ function parseThinking2(value, field, meta) {
6214
6447
  if (value === !1)
6215
6448
  return !1;
6216
6449
  if (typeof value == "string" && THINKING_LEVELS.includes(value))
@@ -6249,19 +6482,19 @@ function parseEndpointPatch(value, field, meta) {
6249
6482
  let input = parseObject(value, field, meta);
6250
6483
  assertKnownFields(input, ENDPOINT_FIELDS, field, meta);
6251
6484
  let patch = {};
6252
- return "enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking = parseThinking(input.thinking, `${field}.thinking`, meta)), patch;
6485
+ return "enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking = parseThinking2(input.thinking, `${field}.thinking`, meta)), patch;
6253
6486
  }
6254
6487
  function parseChildOverridePatch(value, field, meta) {
6255
6488
  let input = parseObject(value, field, meta);
6256
6489
  assertKnownFields(input, CHILD_OVERRIDE_FIELDS, field, meta);
6257
6490
  let patch = {};
6258
- return "enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking = parseThinking(input.thinking, `${field}.thinking`, meta)), patch;
6491
+ return "enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking = parseThinking2(input.thinking, `${field}.thinking`, meta)), patch;
6259
6492
  }
6260
6493
  function parseChildrenPatch(value, field, meta) {
6261
6494
  let input = parseObject(value, field, meta);
6262
6495
  assertKnownFields(input, CHILDREN_FIELDS, field, meta);
6263
6496
  let patch = {};
6264
- if ("enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking = parseThinking(input.thinking, `${field}.thinking`, meta)), "watchdogTailTimeoutMs" in input && (patch.watchdogTailTimeoutMs = parseInteger(input.watchdogTailTimeoutMs, `${field}.watchdogTailTimeoutMs`, meta, "a positive integer", (candidate) => candidate >= 1)), "autoFollow" in input && (patch.autoFollow = parseAutoFollowPatch(input.autoFollow, `${field}.autoFollow`, meta)), "overrides" in input) {
6497
+ if ("enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking = parseThinking2(input.thinking, `${field}.thinking`, meta)), "watchdogTailTimeoutMs" in input && (patch.watchdogTailTimeoutMs = parseInteger(input.watchdogTailTimeoutMs, `${field}.watchdogTailTimeoutMs`, meta, "a positive integer", (candidate) => candidate >= 1)), "autoFollow" in input && (patch.autoFollow = parseAutoFollowPatch(input.autoFollow, `${field}.autoFollow`, meta)), "overrides" in input) {
6265
6498
  let overrides = parseObject(input.overrides, `${field}.overrides`, meta);
6266
6499
  patch.overrides = {};
6267
6500
  for (let [agent, override] of Object.entries(overrides)) {
@@ -6297,11 +6530,11 @@ function parseSettingsObject(settings, meta) {
6297
6530
  return "watchdog" in subagents ? parseWatchdogPatch(subagents.watchdog, "subagents.watchdog", meta) : {};
6298
6531
  }
6299
6532
  function readSettingsFileStrict(filePath) {
6300
- if (!fs19.existsSync(filePath))
6533
+ if (!fs20.existsSync(filePath))
6301
6534
  return {};
6302
6535
  let raw;
6303
6536
  try {
6304
- raw = fs19.readFileSync(filePath, "utf-8");
6537
+ raw = fs20.readFileSync(filePath, "utf-8");
6305
6538
  } catch (error) {
6306
6539
  let message = error instanceof Error ? error.message : String(error);
6307
6540
  throw new Error(`Failed to read settings file '${filePath}': ${message}`, { cause: error });
@@ -6319,13 +6552,13 @@ function readSettingsFileStrict(filePath) {
6319
6552
  }
6320
6553
  function isDirectory(dir) {
6321
6554
  try {
6322
- return fs19.statSync(dir).isDirectory();
6555
+ return fs20.statSync(dir).isDirectory();
6323
6556
  } catch {
6324
6557
  return !1;
6325
6558
  }
6326
6559
  }
6327
6560
  function getUserSettingsPath() {
6328
- return path20.join(getAgentDir(), "settings.json");
6561
+ return path21.join(getAgentDir(), "settings.json");
6329
6562
  }
6330
6563
  function getWatchdogUserSettingsPath() {
6331
6564
  return getUserSettingsPath();
@@ -6333,16 +6566,16 @@ function getWatchdogUserSettingsPath() {
6333
6566
  function getProjectSettingsPath(cwd) {
6334
6567
  let currentDir = cwd;
6335
6568
  for (; ; ) {
6336
- if (isDirectory(getProjectConfigDir(currentDir)) || isDirectory(path20.join(currentDir, ".agents")))
6337
- return path20.join(getProjectConfigDir(currentDir), "settings.json");
6338
- let parentDir = path20.dirname(currentDir);
6569
+ if (isDirectory(getProjectConfigDir(currentDir)) || isDirectory(path21.join(currentDir, ".agents")))
6570
+ return path21.join(getProjectConfigDir(currentDir), "settings.json");
6571
+ let parentDir = path21.dirname(currentDir);
6339
6572
  if (parentDir === currentDir)
6340
6573
  return;
6341
6574
  currentDir = parentDir;
6342
6575
  }
6343
6576
  }
6344
6577
  function getWatchdogProjectSettingsPath(cwd) {
6345
- return path20.join(getProjectConfigDir(cwd), "settings.json");
6578
+ return path21.join(getProjectConfigDir(cwd), "settings.json");
6346
6579
  }
6347
6580
  function deepMerge(base, patch) {
6348
6581
  let next = { ...base };
@@ -6386,7 +6619,7 @@ function targetSettingsObject(watchdog, target, meta) {
6386
6619
  return ensureObjectField(overrides, target.agent.trim(), `subagents.watchdog.children.overrides.${target.agent.trim()}`, meta);
6387
6620
  }
6388
6621
  function writeSettingsFile(settingsPath, settings) {
6389
- return fs19.mkdirSync(path20.dirname(settingsPath), { recursive: !0 }), fs19.writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}
6622
+ return fs20.mkdirSync(path21.dirname(settingsPath), { recursive: !0 }), fs20.writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}
6390
6623
  `, "utf-8"), settingsPath;
6391
6624
  }
6392
6625
  function writeUserWatchdogEnabled(enabled) {
@@ -6404,7 +6637,7 @@ function resolveWatchdogConfig(cwd, options = {}) {
6404
6637
  ];
6405
6638
  for (let source of sourceSpecs)
6406
6639
  if (source.path) {
6407
- sources.push({ scope: source.scope, path: source.path, exists: fs19.existsSync(source.path) });
6640
+ sources.push({ scope: source.scope, path: source.path, exists: fs20.existsSync(source.path) });
6408
6641
  try {
6409
6642
  patch = deepMerge(patch, parseSourceFile(source.path, source.scope));
6410
6643
  } catch (error) {
@@ -6678,8 +6911,8 @@ import { createHash as createHash4 } from "node:crypto";
6678
6911
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/watchdog/change-signature.js
6679
6912
  import { spawnSync as spawnSync2 } from "node:child_process";
6680
6913
  import { createHash as createHash2 } from "node:crypto";
6681
- import * as fs20 from "node:fs";
6682
- import * as path21 from "node:path";
6914
+ import * as fs21 from "node:fs";
6915
+ import * as path22 from "node:path";
6683
6916
  var IGNORED_CHANGE_PREFIXES = [".pi-subagents/", "tmp/", "node_modules/"], IGNORED_CHANGE_PATHS = /* @__PURE__ */ new Set([".pi-subagents", "tmp", "node_modules"]);
6684
6917
  function git(cwd, args) {
6685
6918
  let result = spawnSync2("git", ["-C", cwd, ...args], { encoding: "utf-8", maxBuffer: 10485760 });
@@ -6687,28 +6920,28 @@ function git(cwd, args) {
6687
6920
  return result.stdout;
6688
6921
  }
6689
6922
  function normalizeRelPath(value) {
6690
- return value.replaceAll(path21.sep, "/").replace(/^\.\//, "");
6923
+ return value.replaceAll(path22.sep, "/").replace(/^\.\//, "");
6691
6924
  }
6692
6925
  function ignoredRelPath(relPath) {
6693
6926
  let normalized = normalizeRelPath(relPath);
6694
6927
  return IGNORED_CHANGE_PATHS.has(normalized) || IGNORED_CHANGE_PREFIXES.some((prefix) => normalized.startsWith(prefix));
6695
6928
  }
6696
6929
  function hashFile(filePath) {
6697
- return createHash2("sha256").update(fs20.readFileSync(filePath)).digest("hex");
6930
+ return createHash2("sha256").update(fs21.readFileSync(filePath)).digest("hex");
6698
6931
  }
6699
6932
  function hashPath(root, relPath) {
6700
- let normalized = normalizeRelPath(relPath), fullPath = path21.join(root, normalized), stat;
6933
+ let normalized = normalizeRelPath(relPath), fullPath = path22.join(root, normalized), stat;
6701
6934
  try {
6702
- stat = fs20.lstatSync(fullPath);
6935
+ stat = fs21.lstatSync(fullPath);
6703
6936
  } catch (error) {
6704
6937
  if (error.code === "ENOENT")
6705
6938
  return { path: normalized, state: "deleted" };
6706
6939
  throw error;
6707
6940
  }
6708
6941
  if (stat.isSymbolicLink())
6709
- return { path: normalized, state: "symlink", target: fs20.readlinkSync(fullPath) };
6942
+ return { path: normalized, state: "symlink", target: fs21.readlinkSync(fullPath) };
6710
6943
  if (stat.isDirectory()) {
6711
- let entries = fs20.readdirSync(fullPath).map((entry) => normalizeRelPath(path21.posix.join(normalized, entry))).filter((entry) => !ignoredRelPath(entry)).sort();
6944
+ let entries = fs21.readdirSync(fullPath).map((entry) => normalizeRelPath(path22.posix.join(normalized, entry))).filter((entry) => !ignoredRelPath(entry)).sort();
6712
6945
  return { path: normalized, state: "dir", entries: entries.map((entry) => hashPath(root, entry)) };
6713
6946
  }
6714
6947
  return stat.isFile() ? { path: normalized, state: "file", mode: stat.mode & 511, size: stat.size, hash: hashFile(fullPath) } : { path: normalized, state: "other", mode: stat.mode };
@@ -6841,8 +7074,8 @@ var WatchdogEmissionGuard = class {
6841
7074
  // packages/coding-agent/dist/builtin-extensions/pi-subagents/src/watchdog/lsp-diagnostics.js
6842
7075
  import { spawn as spawn2 } from "node:child_process";
6843
7076
  import { createHash as createHash3 } from "node:crypto";
6844
- import * as fs21 from "node:fs";
6845
- import * as path22 from "node:path";
7077
+ import * as fs22 from "node:fs";
7078
+ import * as path23 from "node:path";
6846
7079
  import { pathToFileURL } from "node:url";
6847
7080
  var TS_JS_EXTENSIONS = /* @__PURE__ */ new Map([
6848
7081
  [".ts", "typescript"],
@@ -6855,14 +7088,14 @@ var TS_JS_EXTENSIONS = /* @__PURE__ */ new Map([
6855
7088
  [".cjs", "javascript"]
6856
7089
  ]), PROVIDER_NAME = "typescript-language-server", MAX_MESSAGE_LENGTH = 500, MAX_STDERR_LENGTH = 2e3, SHUTDOWN_TIMEOUT_MS = 250;
6857
7090
  function normalizeRelPath2(value) {
6858
- return value.replaceAll(path22.sep, "/").replace(/^\.\//, "");
7091
+ return value.replaceAll(path23.sep, "/").replace(/^\.\//, "");
6859
7092
  }
6860
7093
  function isPathInsideRoot(absPath, root) {
6861
- let rel = path22.relative(root, absPath);
6862
- return rel === "" || !rel.startsWith("..") && !path22.isAbsolute(rel);
7094
+ let rel = path23.relative(root, absPath);
7095
+ return rel === "" || !rel.startsWith("..") && !path23.isAbsolute(rel);
6863
7096
  }
6864
7097
  function languageIdForPath(filePath) {
6865
- return TS_JS_EXTENSIONS.get(path22.extname(filePath).toLowerCase());
7098
+ return TS_JS_EXTENSIONS.get(path23.extname(filePath).toLowerCase());
6866
7099
  }
6867
7100
  function trimDiagnosticMessage(message) {
6868
7101
  let normalized = message.replace(/\s+/g, " ").trim();
@@ -6873,7 +7106,7 @@ function severityFromLsp(value) {
6873
7106
  }
6874
7107
  function pathExecutable(filePath) {
6875
7108
  try {
6876
- return fs21.statSync(filePath).isFile() ? (process.platform === "win32" || fs21.accessSync(filePath, fs21.constants.X_OK), !0) : !1;
7109
+ return fs22.statSync(filePath).isFile() ? (process.platform === "win32" || fs22.accessSync(filePath, fs22.constants.X_OK), !0) : !1;
6877
7110
  } catch {
6878
7111
  return !1;
6879
7112
  }
@@ -6886,13 +7119,13 @@ function pathExecutableNames(name) {
6886
7119
  }
6887
7120
  function resolveTypeScriptLanguageServer(root) {
6888
7121
  for (let name of pathExecutableNames(PROVIDER_NAME)) {
6889
- let local = path22.join(root, "node_modules", ".bin", name);
7122
+ let local = path23.join(root, "node_modules", ".bin", name);
6890
7123
  if (pathExecutable(local))
6891
7124
  return { command: local, args: ["--stdio"], label: `${PROVIDER_NAME} (project)` };
6892
7125
  }
6893
- for (let dir of (process.env.PATH ?? "").split(path22.delimiter).filter(Boolean))
7126
+ for (let dir of (process.env.PATH ?? "").split(path23.delimiter).filter(Boolean))
6894
7127
  for (let name of pathExecutableNames(PROVIDER_NAME)) {
6895
- let candidate = path22.join(dir, name);
7128
+ let candidate = path23.join(dir, name);
6896
7129
  if (pathExecutable(candidate))
6897
7130
  return { command: candidate, args: ["--stdio"], label: PROVIDER_NAME };
6898
7131
  }
@@ -6900,14 +7133,14 @@ function resolveTypeScriptLanguageServer(root) {
6900
7133
  function collectTargetFiles(root, changedPaths, maxFiles) {
6901
7134
  let targets = [], skippedPaths = [];
6902
7135
  for (let changedPath of changedPaths) {
6903
- let relPath = normalizeRelPath2(changedPath), absPath = path22.resolve(root, relPath), languageId = languageIdForPath(absPath);
7136
+ let relPath = normalizeRelPath2(changedPath), absPath = path23.resolve(root, relPath), languageId = languageIdForPath(absPath);
6904
7137
  if (!languageId || !isPathInsideRoot(absPath, root)) {
6905
7138
  skippedPaths.push(relPath);
6906
7139
  continue;
6907
7140
  }
6908
7141
  let stat;
6909
7142
  try {
6910
- stat = fs21.statSync(absPath);
7143
+ stat = fs22.statSync(absPath);
6911
7144
  } catch (error) {
6912
7145
  if (error.code === "ENOENT") {
6913
7146
  skippedPaths.push(relPath);
@@ -7134,7 +7367,7 @@ function initializeParams(root) {
7134
7367
  },
7135
7368
  workspace: { configuration: !1, workspaceFolders: !0 }
7136
7369
  },
7137
- workspaceFolders: [{ uri: rootUri, name: path22.basename(root) || "workspace" }]
7370
+ workspaceFolders: [{ uri: rootUri, name: path23.basename(root) || "workspace" }]
7138
7371
  };
7139
7372
  }
7140
7373
  async function waitForDiagnostics(client, targets, timeoutMs, signal) {
@@ -7157,7 +7390,7 @@ async function collectWithTypeScriptLanguageServer(input) {
7157
7390
  try {
7158
7391
  await client.request("initialize", initializeParams(input.root), remaining(), input.signal), client.notify("initialized", {});
7159
7392
  for (let target of input.targets) {
7160
- let text = fs21.readFileSync(target.absPath, "utf-8");
7393
+ let text = fs22.readFileSync(target.absPath, "utf-8");
7161
7394
  client.notify("textDocument/didOpen", {
7162
7395
  textDocument: { uri: target.uri, languageId: target.languageId, version: 1, text }
7163
7396
  }), client.notify("textDocument/didSave", {
@@ -7191,7 +7424,7 @@ async function collectWithTypeScriptLanguageServer(input) {
7191
7424
  async function collectWatchdogLspDiagnostics(request) {
7192
7425
  if (!request.config.enabled)
7193
7426
  return { status: "disabled", checkedPaths: [], skippedPaths: [], diagnostics: [] };
7194
- let root = path22.resolve(request.root || request.cwd), { targets, skippedPaths } = collectTargetFiles(root, request.changedPaths, request.config.maxFiles);
7427
+ let root = path23.resolve(request.root || request.cwd), { targets, skippedPaths } = collectTargetFiles(root, request.changedPaths, request.config.maxFiles);
7195
7428
  if (!targets.length)
7196
7429
  return {
7197
7430
  status: "skipped",
@@ -7900,7 +8133,7 @@ function buildWatchdogStatus(snapshot, ctx) {
7900
8133
  `Auto-follow: not implemented${snapshot.autoFollowQueued ? " (queued)" : ""}`,
7901
8134
  `Review model call: ${snapshot.reviewDescription}`
7902
8135
  ];
7903
- return snapshot.failedReviews > 0 && lines.push(`Failed reviews: ${snapshot.failedReviews}`), snapshot.staleReviews > 0 && lines.push(`Stale reviews: ${snapshot.staleReviews}`), snapshot.changedPaths?.length && lines.push(`Changed paths: ${snapshot.changedPaths.slice(0, 8).join(", ")}${snapshot.changedPaths.length > 8 ? `, +${snapshot.changedPaths.length - 8} more` : ""}`), snapshot.lastWarning && lines.push(`Last warning: ${snapshot.lastWarning.severity} \xB7 ${snapshot.lastWarning.state ?? "candidate"} \xB7 ${snapshot.lastWarning.summary}`), snapshot.lastError && lines.push(`Last error: ${snapshot.lastError}`), snapshot.configOk ? lines.push("", "Config: ok") : lines.push("", "Config errors:", ...snapshot.errors.map((error) => `- ${error.message}`), "Watchdog is disabled until the config is fixed."), lines.push("Sources:", ...snapshot.sources.map(sourceLine), "", "Model commands:", "- /subagents-watchdog recommend-model", "- /subagents-watchdog model recommended", "- /subagents-watchdog model <provider/model[:thinking]>", "- /subagents-watchdog model inherit", "- /subagents-watchdog session model recommended", 'Agent action: subagent({ action: "watchdog.configure", model: "recommended", scope: "session" })'), lines.join(`
8136
+ return snapshot.failedReviews > 0 && lines.push(`Failed reviews: ${snapshot.failedReviews}`), snapshot.staleReviews > 0 && lines.push(`Stale reviews: ${snapshot.staleReviews}`), snapshot.changedPaths?.length && lines.push(`Changed paths: ${snapshot.changedPaths.slice(0, 8).join(", ")}${snapshot.changedPaths.length > 8 ? `, +${snapshot.changedPaths.length - 8} more` : ""}`), snapshot.lastWarning && lines.push(`Last warning: ${snapshot.lastWarning.severity} \xB7 ${snapshot.lastWarning.state ?? "candidate"} \xB7 ${snapshot.lastWarning.summary}`), snapshot.lastError && lines.push(`Last error: ${snapshot.lastError}`), snapshot.configOk ? lines.push("", "Config: ok") : lines.push("", "Config errors:", ...snapshot.errors.map((error) => `- ${error.message}`), "Watchdog is disabled until the config is fixed."), lines.push("Sources:", ...snapshot.sources.map(sourceLine), "", "Model commands:", "- /subagents-watchdog recommend-model", "- /subagents-watchdog model recommended", "- /subagents-watchdog model <provider/model[:thinking]>", "- /subagents-watchdog model inherit", "- /subagents-watchdog session model recommended", "Configure via /subagents-watchdog or /settings; agent watchdog.configure is not available."), lines.join(`
7904
8137
  `);
7905
8138
  }
7906
8139
  function parseTestCommand(input) {
@@ -8218,7 +8451,6 @@ export {
8218
8451
  buildChainInstructions,
8219
8452
  resolveParallelBehaviors,
8220
8453
  createParallelDirs,
8221
- THINKING_LEVELS,
8222
8454
  toModelInfo,
8223
8455
  resolveEffectiveThinking,
8224
8456
  splitKnownThinkingSuffix,
@@ -8226,6 +8458,7 @@ export {
8226
8458
  getSupportedThinkingLevels,
8227
8459
  formatTokens,
8228
8460
  formatModelSelection,
8461
+ formatCompactModelBadge,
8229
8462
  formatUsage,
8230
8463
  formatDuration,
8231
8464
  buildChainSummary,
@@ -8280,8 +8513,8 @@ export {
8280
8513
  splitThinkingSuffix,
8281
8514
  resolveModelCandidate,
8282
8515
  resolveEffectiveSubagentModel,
8283
- resolveRequiredTierModel,
8284
8516
  captureModelSelection,
8517
+ resolveExecutableChildModel,
8285
8518
  buildModelCandidates,
8286
8519
  isRetryableModelFailure,
8287
8520
  formatModelAttemptNote,
@@ -8306,7 +8539,6 @@ export {
8306
8539
  formatControlIntercomMessage,
8307
8540
  writeAtomicJson,
8308
8541
  writePrivateAtomicJson,
8309
- assertSafeNestedId,
8310
8542
  createNestedRoute,
8311
8543
  resolveInheritedNestedRouteFromEnv,
8312
8544
  resolveNestedParentAddressFromEnv,
@@ -8314,7 +8546,6 @@ export {
8314
8546
  sanitizeSummary,
8315
8547
  findNestedRouteForRootId,
8316
8548
  projectNestedRegistryForRoot,
8317
- findNestedRunMatchesById,
8318
8549
  writeNestedEvent,
8319
8550
  writeNestedControlRequest,
8320
8551
  readNestedControlResults,
@@ -8340,6 +8571,7 @@ export {
8340
8571
  formatSubagentResultReceipt,
8341
8572
  expectsImplementationMutation,
8342
8573
  validateAcceptanceInput,
8574
+ restorePersistedAcceptance,
8343
8575
  validateExecutionAcceptance,
8344
8576
  resolveEffectiveAcceptance,
8345
8577
  formatAcceptancePrompt,
@@ -8360,28 +8592,27 @@ export {
8360
8592
  initialTurnBudgetState,
8361
8593
  turnBudgetState,
8362
8594
  shouldAbortForTurnBudget,
8363
- parseWatchdogThinkingInput,
8364
8595
  resolveWatchdogModelInput,
8365
8596
  recommendStrongWatchdogModel,
8366
- writeWatchdogModelSettings,
8367
8597
  resolveWatchdogConfig,
8368
8598
  buildWatchdogStatus,
8369
8599
  registerMainWatchdog,
8600
+ requestAsyncSteer,
8601
+ readSteerCapability,
8602
+ consumeSteerAcks,
8603
+ deliverInterruptRequest,
8604
+ deliverStopRequest,
8370
8605
  INTERCOM_BRIDGE_MARKER,
8371
8606
  resolveIntercomSessionTarget,
8372
8607
  resolveSubagentIntercomTarget,
8373
8608
  diagnoseIntercomBridge,
8374
8609
  resolveIntercomBridge,
8375
8610
  applyIntercomBridgeToAgent,
8376
- requestAsyncSteer,
8377
- consumeSteerAcks,
8378
- deliverInterruptRequest,
8379
- deliverStopRequest,
8380
8611
  interruptLiveAsyncResumeTarget,
8381
- findAsyncRunPrefixMatches,
8382
8612
  resolveAsyncRunLocation,
8383
8613
  resolveAsyncResumeTarget,
8384
8614
  buildRevivedAsyncTask,
8615
+ resolveSubagentRunId,
8385
8616
  SUBAGENT_CONTROL_MESSAGE_TYPE,
8386
8617
  clearPendingForegroundControlNotices,
8387
8618
  handleSubagentControlNotice